import java.io.PrintWriter; import java.util.*; public class Main { public static void vectorPrint(Vector lis){ PrintWriter out = new PrintWriter(System.out); for (int i=0 ; i dic = new HashMap<>(); for (int i=0; i tup : dic.entrySet()){ ans += tup.getValue(); ans -= 1; } System.out.println(ans); } } class Dsu { int n; int[] p; int[] s; Dsu(int N) { this.n = N; this.p = new int[N]; this.s = new int[N]; for (int i=0; i visit = new Vector(); while (this.p[a] != a){ visit.addElement(a); a = this.p[a]; } for (Integer v: visit){ this.p[v] = a; } return a; } public int merge(int a,int b){ int pa = this.leader(a); int pb = this.leader(b); if (pa == pb){ return pa; }else if (this.s[pa] >= this.s[pb]){ this.s[pa] += this.s[pb]; this.p[pb] = pa; return pa; }else{ this.s[pb] += this.s[pa]; this.p[pa] = pb; return pb; } } public Boolean same(int a, int b){ int pa = this.leader(a); int pb = this.leader(b); return (pa == pb); } public int size(int a){ int pa = this.leader(a); return this.s[pa]; } }