4	public class C{ public static void main( String[] args)throws IOException { read(); int t = RI(); while((t-- > 0)){read(); int n = RI();  List<Integer> cur = new ArrayList<Integer>();  int[] lvl = new int[(n + 10)]; while((n-- > 0)){read(); int x = RI(); if ( (cur.size() == 0)) {cur.add(x); lvl[cur.size()] = x; } else {while(!cur.isEmpty()){if ( (x == (1 + lvl[cur.size()]))) { int size = cur.size(); cur.remove((size - 1)); cur.add((1 + lvl[size])); lvl[size] = x; break;} else {if ( (x == 1)) {cur.add(x); lvl[cur.size()] = x; break;} else {lvl[cur.size()] = 0; cur.remove((cur.size() - 1)); }}}if ( (cur.size() == 0)) {cur.add(x); lvl[cur.size()] = x; } }for ( int i = 0;(i < cur.size());i++) {out.print(cur.get(i)); if ( (i != (cur.size() - 1))) out.print("."); }out.println(); }}out.close(); } static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static StringTokenizer st ; static void read()throws IOException { st = new StringTokenizer(br.readLine()); } static int RI()throws IOException { return Integer.parseInt(st.nextToken());} }
1	public class Main{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt(),d = s.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); }Arrays.sort(arr); int count = 0; for ( int i = 1;(i < n);i++) { int dist = (arr[i] - arr[(i - 1)]); if ( (dist > (2 * d))) {count += 2; } else if ( (dist == (2 * d))) {count++; } }System.out.println((count + 2)); } }
4	public class CF1185G2{ static final int MD = 1000000007; static int[][] solve1( int[] aa, int t, int n){ int[][] da = new int[(t + 1)][(n + 1)]; da[0][0] = 1; for ( int i = 0;(i < n);i++) { int a = aa[i]; for ( int s = (t - 1);(s >= 0);s--) for ( int m = 0;(m < n);m++) { int x = da[s][m]; if ( (x != 0)) { int s_ = (s + a); if ( (s_ <= t)) da[s_][(m + 1)] = ((da[s_][(m + 1)] + x) % MD); } }}return da;} static int[][][] solve2( int[] aa, int[] bb, int t, int na, int nb){ int[][] da = solve1(aa,t,na);  int[][][] dab = new int[(t + 1)][(na + 1)][(nb + 1)]; for ( int s = 0;(s <= t);s++) for ( int ma = 0;(ma <= na);ma++) dab[s][ma][0] = da[s][ma]; for ( int i = 0;(i < nb);i++) { int b = bb[i]; for ( int s = (t - 1);(s >= 0);s--) for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb < nb);mb++) { int x = dab[s][ma][mb]; if ( (x != 0)) { int s_ = (s + b); if ( (s_ <= t)) dab[s_][ma][(mb + 1)] = ((dab[s_][ma][(mb + 1)] + x) % MD); } }}return dab;} static long power( int a, int k){ if ( (k == 0)) return 1; long p = power(a,(k / 2)); p = ((p * p) % MD); if ( ((k % 2) == 1)) p = ((p * a) % MD); return p;} static int[] ff ,gg ; static int ch( int n, int k){ return (int)(((((long)ff[n] * gg[(n - k)]) % MD) * gg[k]) % MD);} static int[][][] init( int n, int na, int nb, int nc){ ff = new int[(n + 1)]; gg = new int[(n + 1)]; for ( int i = 0,f = 1;(i <= n);i++) {ff[i] = f; gg[i] = (int)power(f,(MD - 2)); f = (int)(((long)f * (i + 1)) % MD); } int[][][] dp = new int[(na + 1)][(nb + 1)][(nc + 1)]; for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) for ( int mc = 0;(mc <= nc);mc++) { int x = (int)(((((((long)ff[((ma + mb) + mc)] * gg[ma]) % MD) * gg[mb]) % MD) * gg[mc]) % MD); for ( int ma_ = ((ma == 0)?0:1);(ma_ <= ma);ma_++) { int cha = ((ma == 0)?1:ch((ma - 1),(ma_ - 1))); for ( int mb_ = ((mb == 0)?0:1);(mb_ <= mb);mb_++) { int chb = ((mb == 0)?1:ch((mb - 1),(mb_ - 1))); for ( int mc_ = ((mc == 0)?0:1);(mc_ <= mc);mc_++) { int chc = ((mc == 0)?1:ch((mc - 1),(mc_ - 1)));  int y = dp[ma_][mb_][mc_]; if ( (y == 0)) continue; x = (int)((x - ((((((long)y * cha) % MD) * chb) % MD) * chc)) % MD); }}}if ( (x < 0)) x += MD; dp[ma][mb][mc] = x; }for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) for ( int mc = 0;(mc <= nc);mc++) dp[ma][mb][mc] = (int)(((((((long)dp[ma][mb][mc] * ff[ma]) % MD) * ff[mb]) % MD) * ff[mc]) % MD); return dp;} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int t = Integer.parseInt(st.nextToken());  int[] aa = new int[n];  int[] bb = new int[n];  int[] cc = new int[n];  int na = 0,nb = 0,nc = 0; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken());  int g = Integer.parseInt(st.nextToken()); if ( (g == 1)) aa[na++] = a; else if ( (g == 2)) bb[nb++] = a; else cc[nc++] = a; } int[][][] dp = init(n,na,nb,nc);  int[][][] dab = solve2(aa,bb,t,na,nb);  int[][] dc = solve1(cc,t,nc);  int ans = 0; for ( int tab = 0;(tab <= t);tab++) { int tc = (t - tab); for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) { int xab = dab[tab][ma][mb]; if ( (xab == 0)) continue; for ( int mc = 0;(mc <= nc);mc++) { int xc = dc[tc][mc]; if ( (xc == 0)) continue; ans = (int)((ans + ((((long)xab * xc) % MD) * dp[ma][mb][mc])) % MD); }}}System.out.println(ans); } }
3	public class SameSumBlocksHard{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  long[] a = new long[(n + 1)];  long[] sum = new long[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = in.nextInt(); sum[i] = (sum[(i - 1)] + a[i]); } Map<Long,List<int[]>> map = new HashMap<>(); for ( int i = 1;(i <= n);i++) {for ( int j = i;(j <= n);j++) { long x = (sum[j] - sum[(i - 1)]);  List<int[]> list = map.get(x); if ( (list == null)) {list = new ArrayList<>(); map.put(x,list); } list.add(new int[]{i,j}); }} List<int[]> ans = new ArrayList<>(); for ( Map.Entry<Long,List<int[]>> entry :map.entrySet()) { List<int[]> list = entry.getValue();  List<int[]> tmp = new ArrayList<>(); calc(list,tmp); if ( (tmp.size() > ans.size())) {ans.clear(); ans.addAll(tmp); } }System.out.println(ans.size()); for ( int[] pair :ans) {System.out.println(((pair[0] + " ") + pair[1])); }in.close(); } static void calc( List<int[]> list, List<int[]> tmp){ Collections.sort(list,new Comparator<int[]>(){}); int last = -1; for ( int[] p :list) {if ( (last == -1)) {last = p[1]; tmp.add(p); } else if ( (p[0] > last)) {last = p[1]; tmp.add(p); } }} }
6	public class Solution{ public void doMain()throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),m = sc.nextInt();  boolean[][] adj = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (sc.nextInt() - 1),b = (sc.nextInt() - 1); adj[a][b] = adj[b][a] = true; } long res = 0; for ( int st = 0;((st + 1) < n);st++) { long[][] numWays = new long[(1 << ((n - st) - 1))][((n - st) - 1)]; for ( int i = (st + 1);(i < n);i++) if ( adj[st][i]) numWays[(1 << ((i - st) - 1))][((i - st) - 1)] = 1; for ( int mask = 1;(mask < (1 << ((n - st) - 1)));mask++) { boolean simple = ((mask & (mask - 1)) == 0); for ( int last = 0;(last < ((n - st) - 1));last++) if ( (numWays[mask][last] != 0)) {if ( (adj[((last + st) + 1)][st] && !simple)) res += numWays[mask][last]; for ( int next = 0;(next < ((n - st) - 1));next++) if ( (adj[((last + st) + 1)][((next + st) + 1)] && ((mask & (1 << next)) == 0))) numWays[(mask | (1 << next))][next] += numWays[mask][last]; } }}System.out.println((res / 2)); } public static void main( String[] args)throws Exception { new Solution().doMain(); } }
1	public class B14G{ public static void main( String[] args)throws IOException { init_io(); int t = nint(); while((t-- > 0)){ int N = nint(); if ( ((N % 2) != 0)) {out.println("NO"); continue;} N /= 2; int sqrt = (int)Math.round(Math.sqrt(N));  int sqrt2 = (int)Math.round(Math.sqrt((N / 2))); if ( (((sqrt * sqrt) == N) || (((sqrt2 * sqrt2) * 2) == N))) {out.println("YES"); } else {out.println("NO"); }}out.close(); } static StreamTokenizer in ; static PrintWriter out ; static BufferedReader br ; static int nint()throws IOException { in.nextToken(); return (int)in.nval;} static void init_io()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); in = new StreamTokenizer(br); out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); } }
1	public class Main{ public static void main( String[] args){ Scanner reader = new Scanner(System.in);  int n = reader.nextInt();  long d = reader.nextLong();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = reader.nextInt(); Arrays.sort(a); int ans = 2; for ( int i = 0;(i < (n - 1));i++) {if ( ((a[(i + 1)] - a[i]) > (2 * d))) {ans += 2; } else if ( ((a[(i + 1)] - a[i]) == (2 * d))) ans++; }System.out.println(ans); } }
4	public class GG{ public static void main( String[] args){ FastScanner scanner = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int N = scanner.nextInt();  int M = scanner.nextInt();  int K = scanner.nextInt();  int C = scanner.nextInt();  int D = scanner.nextInt();  MinCostMaxFlowSolver solver = new EdmondsKarp();  int[] people = new int[K]; for ( int i = 0;(i < K);i++) people[i] = (scanner.nextInt() - 1); Node src = solver.addNode();  Node snk = solver.addNode();  int amt = 150;  Node[][] timeNodes = new Node[N][amt]; for ( int i = 0;(i < N);i++) {for ( int j = 1;(j < amt);j++) {timeNodes[i][j] = solver.addNode(); if ( (j > 1)) solver.link(timeNodes[i][(j - 1)],timeNodes[i][j],Integer.MAX_VALUE,0); }}for ( int i = 0;(i < K);i++) {solver.link(src,timeNodes[people[i]][1],1,0); }for ( int i = 1;(i < amt);i++) {for ( int j = 0;(j < K);j++) {solver.link(timeNodes[0][i],snk,1,((C * i) - C)); }}for ( int i = 0;(i < M);i++) { int a = (scanner.nextInt() - 1);  int b = (scanner.nextInt() - 1); for ( int j = 1;(j < (amt - 1));j++) { int prev = 0; for ( int k = 1;(k <= K);k++) {solver.link(timeNodes[a][j],timeNodes[b][(j + 1)],1,(((D * k) * k) - prev)); solver.link(timeNodes[b][j],timeNodes[a][(j + 1)],1,(((D * k) * k) - prev)); prev = ((D * k) * k); }}} long[] ret = solver.getMinCostMaxFlow(src,snk); out.println(ret[1]); out.flush(); } public static class Node{ private Node(){ } List<Edge> edges = new ArrayList<Edge>(); int index ; } public static class Edge{ boolean forward ; Node from ,to ; long flow ; final long capacity ; Edge dual ; long cost ; protected Edge( Node s, Node d, long c, boolean f){ forward = f; from = s; to = d; capacity = c; } void addFlow( long amount){ flow += amount; dual.flow -= amount; } } static class EdmondsKarp extends MinCostMaxFlowSolver{ EdmondsKarp(){ this(0); } EdmondsKarp( int n){ super(n); } long minCost ; @Override public long[] getMinCostMaxFlow( Node src, Node snk){ long maxflow = getMaxFlow(src,snk); return new long[]{maxflow,minCost};} static final long INF = (Long.MAX_VALUE / 4); @Override public long getMaxFlow( Node src, Node snk){ final int n = nodes.size(); final int source = src.index; final int sink = snk.index;  long flow = 0;  long cost = 0;  long[] potential = new long[n]; while(true){ Edge[] parent = new Edge[n];  long[] dist = new long[n]; Arrays.fill(dist,INF); dist[source] = 0; PriorityQueue<Item> que = new PriorityQueue<Item>(); que.add(new Item(0,source)); while(!que.isEmpty()){ Item item = que.poll(); if ( (item.dist != dist[item.v])) continue; for ( Edge e :nodes.get(item.v).edges) { long temp = (((dist[item.v] + e.cost) + potential[item.v]) - potential[e.to.index]); if ( ((e.capacity > e.flow) && (dist[e.to.index] > temp))) {dist[e.to.index] = temp; parent[e.to.index] = e; que.add(new Item(temp,e.to.index)); } }}if ( (parent[sink] == null)) break; for ( int i = 0;(i < n);i++) if ( (parent[i] != null)) potential[i] += dist[i];  long augFlow = Long.MAX_VALUE; for ( int i = sink;(i != source);i = parent[i].from.index) augFlow = Math.min(augFlow,(parent[i].capacity - parent[i].flow)); for ( int i = sink;(i != source);i = parent[i].from.index) { Edge e = parent[i]; e.addFlow(augFlow); cost += (augFlow * e.cost); }flow += augFlow; }minCost = cost; return flow;} static class Item implements Comparable<Item>{ long dist ; int v ; public Item( long dist, int v){ this.dist = dist; this.v = v; } } } public static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( Reader in){ br = new BufferedReader(in); } public FastScanner(){ this(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
5	public class A{ private void solve()throws IOException { int n = nextInt();  int a = nextInt();  int b = nextInt();  int[] h = new int[n]; for ( int i = 0;(i < n);i++) h[i] = nextInt(); Arrays.sort(h); int fstB = h[(h.length - a)];  int lstA = h[((h.length - a) - 1)]; pl((((fstB - lstA) > 0)?(fstB - lstA):0)); } public static void main( String[] args){ new A().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} void p( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.flush(); writer.print(objects[i]); writer.flush(); }} void pl( Object... objects){ p(objects); writer.flush(); writer.println(); writer.flush(); } int cc ; }
6	public class cf16e{ static int n ; static double[][] prob ; static double[] memo ; public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextInt(); prob = new double[n][n]; memo = new double[(1 << n)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) prob[i][j] = in.nextDouble(); memo[((1 << n) - 1)] = 1; for ( int k = ((1 << n) - 1);(k > 0);k--) { int numWays = Integer.bitCount(k); numWays = ((numWays * (numWays - 1)) / 2); for ( int first = 0;(first < n);first++) {if ( !isSet(k,first)) continue; for ( int second = (first + 1);(second < n);second++) {if ( !isSet(k,second)) continue; memo[reset(k,first)] += ((prob[second][first] * memo[k]) / numWays); memo[reset(k,second)] += ((prob[first][second] * memo[k]) / numWays); }}}for ( int i = 0;(i < n);i++) System.out.printf("%.6f ",memo[set(0,i)]); System.out.println(); } static boolean isSet( int x, int p){ return ((x & (1 << p)) != 0);} static int set( int x, int p){ return (x | (1 << p));} static int reset( int x, int p){ return (x & (1 << p));} }
2	public class B{ static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static MyScanner sc ; {try{sc = new MyScanner(); }catch (FileNotFoundException e){ e.printStackTrace(); } }public static void main( String[] args){ doTask(); out.flush(); } public static void doTask(){ long n = sc.nextInt();  long k = sc.nextInt();  long c = (-2 * (n + k));  long d = (9 - (4 * c));  double result = (n - ((-3 + Math.sqrt((1.0 * d))) / 2)); out.println(Math.round(result)); } public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner()throws FileNotFoundException{ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
2	public class MainA{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(new BufferedInputStream(System.in));  PrintStream out = new PrintStream(System.out);  Solution solution = new Solution(in,out); solution.solve(); in.close(); out.close(); } private static class Solution{ final int inf = (int)1e9; int n ,x ,y ,c ; int f( int u, int r, int sec){ if ( ((u == 0) && (r == 0))) return 0; if ( (u == 0)) {return (r - 1);} if ( (r == 0)) {return (u - 1);} return Math.min((sec - 1),(((u - 1) + r) - 1));} boolean isok( int sec){ int up = (x - 1);  int down = (n - x);  int right = (n - y);  int left = (y - 1);  int u = 0,d = 0,r = 0,l = 0;  int total = 1;  int add = 4; for ( int i = 1;(i <= sec);i++) { int cc = 0; if ( ((i > up) && (++cc > 0))) u++; if ( ((i > down) && (++cc > 0))) d++; if ( ((i > right) && (++cc > 0))) r++; if ( ((i > left) && (++cc > 0))) l++; total += (add - cc); total -= Math.max(0,f(u,r,i)); total -= Math.max(0,f(u,l,i)); total -= Math.max(0,f(d,r,i)); total -= Math.max(0,f(d,l,i)); if ( (total >= c)) return true; add += 4; }return false;} public void solve(){ n = in.nextInt(); x = in.nextInt(); y = in.nextInt(); c = in.nextInt(); if ( (c == 1)) {out.println(0); return ;} int lo = 0,hi = 60000; while((lo < hi)){ int mid = ((lo + hi) / 2); if ( isok(mid)) {hi = mid; } else {lo = (mid + 1); }}out.println(lo); } public Solution( Scanner in, PrintStream out){ this.in = in; this.out = out; } Scanner in ; PrintStream out ; } }
3	public class F2{ private static int n ; private static int[] a ; private static Collection<Segment> answer ; public static void main( String[] args){ in(); solution(); out(); } private static void in(){ Scanner in = new Scanner(System.in); n = in.nextInt(); a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }} private static void solution(){ HashMap<Long,LinkedList<Segment>> segments = new HashMap<>(); for ( int i = 0;(i < n);i++) { long sum = 0; for ( int j = i;(j < n);j++) {sum += a[j]; if ( segments.containsKey(sum)) {segments.get(sum).add(new Segment(i,j)); } else { LinkedList<Segment> toPut = new LinkedList<>(); toPut.add(new Segment(i,j)); segments.put(sum,toPut); }}}answer = null; for ( Map.Entry<Long,LinkedList<Segment>> sums :segments.entrySet()) { LinkedList<Segment> currentSegments = sums.getValue(); Collections.sort(currentSegments); LinkedList<Segment> segmentsWithoutCrossing = new LinkedList<>(); for ( Segment segment :currentSegments) {if ( (segmentsWithoutCrossing.isEmpty() || !segmentsWithoutCrossing.getLast().isCrossingToNextSegment(segment))) {segmentsWithoutCrossing.add(segment); } else if ( (segmentsWithoutCrossing.getLast().getR() > segment.getR())) {segmentsWithoutCrossing.removeLast(); segmentsWithoutCrossing.add(segment); } }answer = ((segmentsWithoutCrossing.size() > ((answer != null)?answer.size():0))?segmentsWithoutCrossing:answer); }} private static void out(){ System.out.println(answer.size()); for ( Segment segment :answer) {System.out.println((((segment.getL() + 1) + " ") + (segment.getR() + 1))); }} } class Segment implements Comparable<Segment>{ private int l ,r ; Segment( int l, int r){ this.l = l; this.r = r; } int getL(){ return l;} int getR(){ return r;} boolean isCrossingToNextSegment( Segment segment){ if ( ((l == segment.l) || (r == segment.r))) {return true;} else if ( (l < segment.l)) {return (r >= segment.l);} else if ( (r > segment.r)) {return (l <= segment.r);} else {return true;}} }
0	public class LCMChallenge{ public static void main( String[] args){ Scanner in = new Scanner(new BufferedInputStream(System.in));  long N = in.nextLong(); if ( ((N == 1) || (N == 2))) {System.out.printf("%d\n",N); return ;} if ( ((N & 1) == 1)) { long lcm = ((N * (N - 1)) * (N - 2)); System.out.printf("%d\n",lcm); } else { long lcm ; if ( ((N % 3) == 0)) {lcm = (((N - 1) * (N - 2)) * (N - 3)); } else {lcm = ((N * (N - 1)) * (N - 3)); }System.out.printf("%d\n",lcm); }} }
6	public class CodeJ{ static class Scanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String nextLine(){ try{return br.readLine(); }catch (Exception e){ throw (new RuntimeException());} } public String next(){ while(!st.hasMoreTokens()){ String l = nextLine(); if ( (l == null)) return null; st = new StringTokenizer(l); }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} } static int nFilas ; static int nColumnas ; static byte[][][][][] dp ; static byte dp( int mascaraActual, int enviadosActual, int enviadosSiguiente, int filaActual, int columnaActual){ if ( (dp[mascaraActual][enviadosActual][enviadosSiguiente][filaActual][columnaActual] != Byte.MAX_VALUE)) return dp[mascaraActual][enviadosActual][enviadosSiguiente][filaActual][columnaActual]; if ( (filaActual == nFilas)) return dp[mascaraActual][enviadosActual][enviadosSiguiente][filaActual][columnaActual] = 0; if ( (columnaActual == nColumnas)) { int ambos = (mascaraActual & enviadosSiguiente);  int mascaraSiguiente = ((1 << nColumnas) - 1); mascaraSiguiente ^= ambos; int mascaraEnviados = enviadosSiguiente; mascaraEnviados ^= ambos; return dp[mascaraActual][enviadosActual][enviadosSiguiente][filaActual][columnaActual] = (byte)((nColumnas - Integer.bitCount(mascaraActual)) + dp(mascaraSiguiente,mascaraEnviados,0,(filaActual + 1),0));} if ( ((mascaraActual & (1 << columnaActual)) == 0)) { byte a = dp((mascaraActual | (1 << columnaActual)),enviadosActual,(enviadosSiguiente | (1 << columnaActual)),filaActual,(columnaActual + 1));  byte b = dp(mascaraActual,enviadosActual,enviadosSiguiente,filaActual,(columnaActual + 1)); return dp[mascaraActual][enviadosActual][enviadosSiguiente][filaActual][columnaActual] = (byte)Math.max(a,b);} if ( ((enviadosActual & (1 << columnaActual)) != 0)) { byte a = dp(mascaraActual,enviadosActual,(enviadosSiguiente | (1 << columnaActual)),filaActual,(columnaActual + 1));  byte b = dp(mascaraActual,enviadosActual,enviadosSiguiente,filaActual,(columnaActual + 1)); return dp[mascaraActual][enviadosActual][enviadosSiguiente][filaActual][columnaActual] = (byte)Math.max(a,b);} byte ans = 0; if ( (columnaActual != 0)) ans = (byte)Math.max(ans,dp(((mascaraActual ^ (1 << columnaActual)) | (1 << (columnaActual - 1))),enviadosActual,enviadosSiguiente,filaActual,(columnaActual + 1))); if ( (columnaActual != (nColumnas - 1))) ans = (byte)Math.max(ans,dp(((mascaraActual ^ (1 << columnaActual)) | (1 << (columnaActual + 1))),(enviadosActual | (1 << (columnaActual + 1))),enviadosSiguiente,filaActual,(columnaActual + 1))); if ( (filaActual != (nFilas - 1))) ans = (byte)Math.max(ans,dp((mascaraActual ^ (1 << columnaActual)),enviadosActual,(enviadosSiguiente | (1 << columnaActual)),filaActual,(columnaActual + 1))); ans = (byte)Math.max(ans,dp(mascaraActual,enviadosActual,enviadosSiguiente,filaActual,(columnaActual + 1))); return dp[mascaraActual][enviadosActual][enviadosSiguiente][filaActual][columnaActual] = ans;} public static void main( String[] args){ Scanner sc = new Scanner();  int a = sc.nextInt();  int b = sc.nextInt(); nFilas = Math.max(a,b); nColumnas = Math.min(a,b); dp = new byte[(1 << nColumnas)][(1 << nColumnas)][(1 << nColumnas)][(nFilas + 1)][(nColumnas + 1)]; for ( byte[][][][] i :dp) for ( byte[][][] j :i) for ( byte[][] k :j) for ( byte[] l :k) Arrays.fill(l,Byte.MAX_VALUE); System.out.println(dp(((1 << nColumnas) - 1),0,0,0,0)); } }
2	public class CF817C{ static long count( long x){ return ((x < 10)?x:(count((x / 10)) + (x % 10)));} static boolean check( long x, long s){ return ((x - count(x)) >= s);} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  long n = Long.parseLong(st.nextToken());  long s = Long.parseLong(st.nextToken());  int d = (9 * 18);  long cnt ; if ( (n >= (s + d))) {cnt = ((n - s) - d); for ( long x = s;(x <= (s + d));x++) if ( check(x,s)) cnt++; } else {cnt = 0; for ( long x = s;(x <= n);x++) if ( check(x,s)) cnt++; }System.out.println(cnt); } }
0	public class Main{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  long a = s.nextLong(),b = s.nextLong();  long c = 0; while(true){if ( (a == b)) {System.out.println((c + a)); return ;} else if ( (b == (a + 1))) {c += 1; b = a; } else if ( (b < a)) { long h = ((a / b) - 1); if ( (h <= 0)) {a -= b; c++; continue;} a -= (b * h); c += h; } else {if ( (a == 1)) { long t = (b - a); b = t; c += t; b = a; continue;} long t = (b - a);  long h = ((b / a) - 1); if ( (h <= 0)) {b = t; c += 1; continue;} c += h; b -= (h * a); }}} }
3	public class CodeforcesProblems{ static class Pair{ public Pair( int key, int val){ this.key = key; this.val = val; } int key ; int val ; } public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  String[] strings = br.readLine().split(" ");  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(strings[i]); } HashMap<Integer,ArrayList<Pair>> segments = new HashMap<>(); for ( int r = 0;(r < arr.length);r++) { int sum = 0; for ( int l = r;(l >= 0);l--) {sum += arr[l]; ArrayList<Pair> pairs = segments.get(sum); if ( (pairs == null)) {pairs = new ArrayList<>(); segments.put(sum,pairs); } pairs.add(new Pair(l,r)); }} int res = 0;  ArrayList<Pair> result = new ArrayList<>(); for ( ArrayList<Pair> pairs :segments.values()) { ArrayList<Pair> temp = new ArrayList<>();  int count = 0;  int r = -1; for ( Pair p :pairs) {if ( (p.key > r)) {count++; temp.add(p); r = p.val; } }if ( (count > res)) {res = count; result = temp; } }System.out.println(res); StringBuilder sb = new StringBuilder(); for ( Pair p :result) {sb.append((p.key + 1)).append(' ').append((p.val + 1)).append('\n'); }System.out.print(sb); } }
6	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] line = in.readLine().split(" ");  int Xs = Integer.parseInt(line[0]);  int Ys = Integer.parseInt(line[1]);  int n = Integer.parseInt(in.readLine());  int[][] points = new int[(n + 1)][2]; points[n][0] = Xs; points[n][1] = Ys; for ( int i = 0;(i < n);i++) {line = in.readLine().split(" "); points[i][0] = Integer.parseInt(line[0]); points[i][1] = Integer.parseInt(line[1]); } int[][] distances = new int[(n + 1)][(n + 1)]; ComputeDistances(points,distances,n); int[] dp = new int[(1 << n)];  int[] path = new int[(1 << n)]; ComputeLowestPath(dp,path,distances,n); OutputLowestAndPath(dp,path,n); } private static void ComputeLowestPath( int[] dp, int[] path, int[][] distances, int n){ for ( int i = 1;(i < (1 << n));i++) { int j = 0; while(true){if ( ((i & (1 << j)) != 0)) {break;} j++; } int pastEntry = (i & (1 << j)); path[i] = pastEntry; int distance = (distances[j][n] * 2); dp[i] = (dp[pastEntry] + distance); for ( int m = (j + 1);(m < n);m++) {if ( ((i & (1 << m)) != 0)) { int entry = (i & ((1 << j) | (1 << m))); distance = ((distances[j][n] + distances[j][m]) + distances[m][n]); if ( (dp[i] > (dp[entry] + distance))) {dp[i] = (dp[entry] + distance); path[i] = entry; } } }}} private static void OutputLowestAndPath( int[] dp, int[] path, int n){ StringBuilder out = new StringBuilder(); out.append(dp[((1 << n) - 1)]); out.append("\n"); out.append("0 "); int index = ((1 << n) - 1); while((index != 0)){ int j = path[index];  int k = (index ^ j); for ( int m = 0;(m < n);m++) {if ( ((k & (1 << m)) != 0)) {out.append((m + 1)); out.append(" "); } }out.append("0 "); index = j; }System.out.println(out.toString()); } private static void ComputeDistances( int[][] points, int[][] distances, int n){ for ( int i = 0;(i <= n);i++) {for ( int j = (i + 1);(j <= n);j++) { int x = (points[i][0] - points[j][0]);  int y = (points[i][1] - points[j][1]); distances[i][j] = ((x * x) + (y * y)); }}} }
6	public class Main implements Runnable{ private int n ; private int nn ; private boolean[][] gr ; private long[][] D ; private void solve()throws Throwable { n = nextInt(); nn = (1 << n); gr = new boolean[n][n]; int m = nextInt(); for ( int i = 0;(i < m);i++) { int a = (nextInt() - 1),b = (nextInt() - 1); gr[a][b] = gr[b][a] = true; }D = new long[n][nn]; for ( int i = 0;(i < n);i++) {Arrays.fill(D[i],-1); } long count = 0; for ( int i = 0;(i < n);i++) {count += getD(i,i,1,(1 << i)); }pw.println((count / 2)); } private long getD( int first, int last, int cnt, int mask){ if ( (D[last][mask] != -1)) return D[last][mask]; long ans = 0; if ( ((cnt >= 3) && gr[first][last])) ans++; for ( int i = (first + 1);(i < n);i++) {if ( (gr[last][i] && ((mask & (1 << i)) == 0))) {ans += getD(first,i,(cnt + 1),(mask | (1 << i))); } }D[last][mask] = ans; return ans;} PrintWriter pw ; BufferedReader in ; StringTokenizer st ; void initStreams()throws FileNotFoundException { in = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); } String nextString()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextString());} static Throwable sError ; public static void main( String[] args)throws Throwable { Thread t = new Thread(new Main()); t.start(); t.join(); if ( (sError != null)) {throw (sError);} } }
5	public class Main{ public static void main( String[] args){ new Main().run(); } void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = (sc.nextInt() * 2);  H[] tbl = new H[n]; for ( int i = 0;(i < n);i++) tbl[i] = new H((sc.nextInt() * 2),(sc.nextInt() * 2)); Arrays.sort(tbl); TreeSet<Integer> cand = new TreeSet<Integer>(); for ( int i = 0;(i < n);i++) { int left = ((tbl[i].x - (tbl[i].len / 2)) - (t / 2)); if ( !cand.contains(left)) {if ( ((i > 0) && ((tbl[(i - 1)].x + (tbl[(i - 1)].len / 2)) > (left - (t / 2))))) {} else {cand.add(left); }} int right = ((tbl[i].x + (tbl[i].len / 2)) + (t / 2)); if ( !cand.contains(right)) {if ( ((i < (n - 1)) && ((tbl[(i + 1)].x - (tbl[(i + 1)].len / 2)) < (right + (t / 2))))) {} else {cand.add(right); }} }System.out.println(cand.size()); } class H implements Comparable<H>{ int x ,len ; H( int a, int b){ x = a; len = b; } } }
1	public class B{ public void solve()throws IOException { int n = nextInt();  int k = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } int[] num = new int[n];  Set<Integer> set = new HashSet<Integer>();  int s = -1;  int l = -1; for ( int i = 0;(i < n);i++) {set.add(a[i]); num[i] = set.size(); if ( (num[i] == k)) {l = (i + 1); set = new HashSet<Integer>(); for ( int j = i;(j >= 0);j--) {set.add(a[j]); if ( (set.size() == k)) {s = (j + 1); break;} }break;} }writer.println(((s + " ") + l)); } public static void main( String[] args)throws IOException { new B().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run()throws IOException { try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } public int nextInt()throws IOException { return Integer.parseInt(nextToken());} public String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
1	public class Main{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  int size = Integer.parseInt(r.readLine());  String line = r.readLine();  int counter = 0; for ( int i = 0;(i < line.length());i++) {if ( (line.charAt(i) == 'H')) counter++; } int minimum = Integer.MAX_VALUE; for ( int i = 0;(i < line.length());i++) {if ( (line.charAt(i) == 'H')) { int current = 0; for ( int j = i;(j < (i + counter));j++) {if ( (line.charAt((j % line.length())) == 'T')) current++; }minimum = Math.min(current,minimum); } }System.out.println(minimum); } }
0	public class B{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  StringTokenizer st = new StringTokenizer(bf.readLine());  int n = Integer.parseInt(st.nextToken());  int m = Integer.parseInt(st.nextToken());  StringBuilder ans1 = new StringBuilder();  StringBuilder ans2 = new StringBuilder(); for ( int i = 0;(i < 2229);i++) ans1.append('5'); ans1.append('6'); for ( int i = 0;(i < 2230);i++) ans2.append('4'); out.println(ans1.toString()); out.println(ans2.toString()); out.close(); System.exit(0); } }
2	public class palin{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(System.out);  Scanner scan = new Scanner(System.in);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } } class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ long n = (in.nextLong() - 1);  long k = (in.nextLong() - 1); if ( (n == 0)) {out.print("0"); } else {if ( (k >= n)) {out.print("1"); } else {if ( (((k * (k + 1)) / 2) < n)) {out.print("-1"); } else { long t = binsearch(n,k,1,k);  long ans = ((k - t) + 1); if ( ((((k * (k + 1)) / 2) - ((t * (t - 1)) / 2)) != n)) ans++; System.out.println(ans); }}}} public static long binsearch( long n, long k, long from, long to){ if ( (from == to)) {return from;} long mid = ((from + to) / 2); if ( ((((k * (k + 1)) / 2) - ((mid * (mid - 1)) / 2)) > n)) return binsearch(n,k,(mid + 1),to); else return binsearch(n,k,from,mid);} } class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); st = null; } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
6	public class cf1185g1_3{ public static void main( String[] args)throws IOException { int n = rni(),t = ni(),song[][] = new int[n][2]; for ( int i = 0;(i < n);++i) {song[i][0] = rni(); song[i][1] = (ni() - 1); } int dp[][] = new int[(1 << n)][4],sum[] = new int[(1 << n)],ans = 0; dp[0][3] = 1; for ( int i = 0;(i < (1 << n));++i) {for ( int j = 0;(j < 4);++j) {for ( int k = 0;(k < n);++k) {if ( (((i & (1 << k)) == 0) && (song[k][1] != j))) {dp[(i | (1 << k))][song[k][1]] = madd(dp[(i | (1 << k))][song[k][1]],dp[i][j]); sum[(i | (1 << k))] = (sum[i] + song[k][0]); } }}}for ( int i = 0;(i < (1 << n));++i) {if ( (sum[i] == t)) {ans = madd(ans,dp[i][0],dp[i][1],dp[i][2]); } }prln(ans); close(); } static int mmod = 1000000007; static int madd( int a, int b){ return ((a + b) % mmod);} static int madd( int... a){ int ans = a[0]; for ( int i = 1;(i < a.length);++i) {ans = madd(ans,a[i]); }return ans;} static int mmul( int a, int b){ return (int)(((long)a * b) % mmod);} static int mmul( int... a){ int ans = a[0]; for ( int i = 1;(i < a.length);++i) {ans = mmul(ans,a[i]); }return ans;} static BufferedReader __i = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter __o = new PrintWriter(new OutputStreamWriter(System.out)); static StringTokenizer input ; static Random __r = new Random(); static final int IBIG = 1000000007; static final int IMAX = 2147483647; static final long LMAX = 9223372036854775807L; static int gcf( int a, int b){ return ((b == 0)?a:gcf(b,(a % b)));} static long gcf( long a, long b){ return ((b == 0)?a:gcf(b,(a % b)));} static int[] exgcd( int a, int b){ if ( (b == 0)) return new int[]{1,0}; int[] y = exgcd(b,(a % b)); return new int[]{y[1],(y[0] - (y[1] * (a / b)))};} static long[] exgcd( long a, long b){ if ( (b == 0)) return new long[]{1,0}; long[] y = exgcd(b,(a % b)); return new long[]{y[1],(y[0] - (y[1] * (a / b)))};} static int randInt( int min, int max){ return (__r.nextInt(((max - min) + 1)) + min);} static void shuffle( int[] a){ int n = (a.length - 1); for ( int i = 0;(i < n);++i) { int ind = randInt(i,n);  int swap = a[i]; a[i] = a[ind]; a[ind] = swap; }} static void shuffle( long[] a){ int n = (a.length - 1); for ( int i = 0;(i < n);++i) { int ind = randInt(i,n);  long swap = a[i]; a[i] = a[ind]; a[ind] = swap; }} static void shuffle( double[] a){ int n = (a.length - 1); for ( int i = 0;(i < n);++i) { int ind = randInt(i,n);  double swap = a[i]; a[i] = a[ind]; a[ind] = swap; }} static void r()throws IOException { input = new StringTokenizer(rline()); } static String rline()throws IOException { return __i.readLine();} static String n(){ return input.nextToken();} static int rni()throws IOException { r(); return ni();} static int ni(){ return Integer.parseInt(n());} static long nl(){ return Long.parseLong(n());} static double nd(){ return Double.parseDouble(n());} static void pr( int i){ __o.print(i); } static void prln( int i){ __o.println(i); } static void pr( long l){ __o.print(l); } static void prln( long l){ __o.println(l); } static void pr( double d){ __o.print(d); } static void prln( double d){ __o.println(d); } static void pr( char c){ __o.print(c); } static void prln( char c){ __o.println(c); } static void pr( char[] s){ __o.print(new String(s)); } static void prln( char[] s){ __o.println(new String(s)); } static void pr( String s){ __o.print(s); } static void prln( String s){ __o.println(s); } static void pr( Object o){ __o.print(o); } static void prln( Object o){ __o.println(o); } static void prln(){ __o.println(); } static void prln( int... a){ for ( int i = 0,len = (a.length - 1);(i < len);pr(a[i]),pr(' '),++i) ;if ( (a.length > 0)) prln(a[(a.length - 1)]); else prln(); } static void prln( long... a){ for ( int i = 0,len = (a.length - 1);(i < len);pr(a[i]),pr(' '),++i) ;if ( (a.length > 0)) prln(a[(a.length - 1)]); else prln(); } static void prln( double... a){ for ( int i = 0,len = (a.length - 1);(i < len);pr(a[i]),pr(' '),++i) ;if ( (a.length > 0)) prln(a[(a.length - 1)]); else prln(); } static <T> void prln( Collection<T> c){ int n = (c.size() - 1);  Iterator<T> iter = c.iterator(); for ( int i = 0;(i < n);pr(iter.next()),pr(' '),++i) ;if ( (n >= 0)) prln(iter.next()); else prln(); } static void flush(){ __o.flush(); } static void close(){ __o.close(); } }
2	public class B{ static Scanner in ; static PrintWriter out ; public static long count( long k, long x, long y, long n){ long sum = (((2 * k) * (k + 1)) + 1); if ( (k >= (x - 1))) {sum -= (((k - x) + 1) * ((k - x) + 1)); } if ( (k >= (y - 1))) {sum -= (((k - y) + 1) * ((k - y) + 1)); } if ( ((k + x) >= n)) {sum -= (((k + x) - n) * ((k + x) - n)); } if ( ((k + y) >= n)) {sum -= (((k + y) - n) * ((k + y) - n)); } if ( (k > ((x + y) - 1))) {sum += (((((k + 1) - x) - y) * ((((k + 1) - x) - y) + 1)) / 2); } if ( (k > ((n - x) + y))) {sum += (((((k + x) - n) - y) * ((((k + x) - n) - y) + 1)) / 2); } if ( (k > ((n - y) + x))) {sum += (((((k + y) - n) - x) * ((((k + y) - n) - x) + 1)) / 2); } if ( (k > ((((2 * n) - x) - y) + 1))) {sum += ((((((k - (2 * n)) + x) + y) - 1) * (((k - (2 * n)) + x) + y)) / 2); } return sum;} public static void main( String[] args)throws Exception { in = new Scanner(System.in); out = new PrintWriter(System.out); long n = in.nextLong(),x = in.nextLong(),y = in.nextLong(),c = in.nextLong();  long res = 0; while((count(res,x,y,n) < c))res++; out.println(res); out.println(); out.close(); } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, InputReader in, PrintWriter out){ long a = in.nextLong();  long b = in.nextLong();  long res = 0; while((b > 0)){res += (a / b); long t = (a % b); a = b; b = t; }out.println(res); } } class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
5	public class A2{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = new int[n];  int[] b = new int[n]; for ( int i = 0;(i < n);i++) b[i] = a[i] = ni(); b = radixSort(b); int ct = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) ct++; }if ( (ct <= 2)) {out.println("YES"); } else {out.println("NO"); }} public static int[] radixSort( int[] f){ int[] to = new int[f.length]; { int[] b = new int[65537]; for ( int i = 0;(i < f.length);i++) b[(1 + (f[i] & 0xffff))]++; for ( int i = 1;(i <= 65536);i++) b[i] += b[(i - 1)]; for ( int i = 0;(i < f.length);i++) to[b[(f[i] & 0xffff)]++] = f[i]; int[] d = f; f = to; to = d; }{ int[] b = new int[65537]; for ( int i = 0;(i < f.length);i++) b[(1 + (f[i] >>> 16))]++; for ( int i = 1;(i <= 65536);i++) b[i] += b[(i - 1)]; for ( int i = 0;(i < f.length);i++) to[b[(f[i] >>> 16)]++] = f[i]; int[] d = f; f = to; to = d; }return f;} void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new A2().run(); } public int ni(){ try{ int num = 0;  boolean minus = false; while((((num = is.read()) != -1) && (((num >= '0') && (num <= '9')) || (num == '-'))));if ( (num == '-')) {num = 0; minus = true; } else {num -= '0'; }while(true){ int b = is.read(); if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}} }catch (IOException e){ } return -1;} public String ns(){ try{ int b = 0;  StringBuilder sb = new StringBuilder(); while((((b = is.read()) != -1) && (((b == '\r') || (b == '\n')) || (b == ' '))));if ( (b == -1)) return ""; sb.append((char)b); while(true){b = is.read(); if ( (b == -1)) return sb.toString(); if ( (((b == '\r') || (b == '\n')) || (b == ' '))) return sb.toString(); sb.append((char)b); } }catch (IOException e){ } return "";} public char[] ns( int n){ char[] buf = new char[n]; try{ int b = 0,p = 0; while((((b = is.read()) != -1) && (((b == ' ') || (b == '\r')) || (b == '\n'))));if ( (b == -1)) return null; buf[p++] = (char)b; while((p < n)){b = is.read(); if ( ((((b == -1) || (b == ' ')) || (b == '\r')) || (b == '\n'))) break; buf[p++] = (char)b; }return Arrays.copyOf(buf,p); }catch (IOException e){ } return null;} boolean oj = (System.getProperty("ONLINE_JUDGE") != null); void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
1	public class Main implements Runnable{ StreamTokenizer ST ; PrintWriter out ; BufferedReader br ; Scanner in ; static final int inf = 1000000000; int nextInt()throws IOException { ST.nextToken(); return (int)ST.nval;} public static void main( String[] args)throws IOException { new Thread(new Main()).start(); } public void solve()throws IOException { int n = nextInt();  int K = nextInt();  boolean[] f = new boolean[(n + 1)]; Arrays.fill(f,true); Vector<Integer> P = new Vector<Integer>(); for ( int i = 2;(i <= n);i++) if ( f[i]) {for ( int j = (2 * i);(j <= n);j += i) f[j] = false; P.add(i); } for ( int i = 0;(i < (P.size() - 1));i++) { int x = ((P.elementAt(i) + P.elementAt((i + 1))) + 1); if ( ((x <= n) && f[x])) K--; }if ( (K <= 0)) out.println("YES"); else out.println("NO"); } }
3	public class Main{ static final long MOD = 1_000_000_007,INF = 1_000_000_000_000_000_000L; static final int INf = 1_000_000_000; static FastReader reader ; static PrintWriter writer ; public static void main( String[] args){ Thread t = new Thread(null,new O(),"Integer.MAX_VALUE",100000000); t.start(); } static class O implements Runnable{ } static class FastReader{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public FastReader(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public FastReader( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws IOException { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } static void magic()throws IOException { reader = new FastReader(); writer = new PrintWriter(System.out,true); Map<Integer,ArrayList<Pair>> map = new HashMap<>();  int n = reader.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);++i) {arr[i] = reader.nextInt(); }for ( int i = 0;(i < n);++i) { int sum = 0; for ( int j = i;(j < n);++j) {sum += arr[j]; ArrayList<Pair> list = map.get(sum); if ( (list == null)) {list = new ArrayList<>(); } list.add(new Pair((i + 1),(j + 1))); map.put(sum,list); }} int ans = 0,at = -1; for ( int e :map.keySet()) { ArrayList<Pair> list = map.get(e); Collections.sort(list); int ispe = 0;  int len = list.size(); for ( int i = 0;(i < len);++i) {ispe++; int r = list.get(i).y; while((((i + 1) < len) && (list.get((i + 1)).x <= r))){i++; }}if ( (ans < ispe)) {ans = ispe; at = e; } }writer.println(ans); ArrayList<Pair> list = map.get(at); Collections.sort(list); int len = list.size(); for ( int i = 0;(i < len);++i) {writer.println(((list.get(i).x + " ") + list.get(i).y)); int r = list.get(i).y; while((((i + 1) < len) && (list.get((i + 1)).x <= r))){i++; }}} static class Pair implements Comparable<Pair>{ int x ,y ; Pair( int x, int y){ this.x = x; this.y = y; } } }
2	public class Berland{ public static void main( String[] args)throws NumberFormatException,IOException { new Berland().run(); } public void run()throws NumberFormatException,IOException { BufferedReader file = new BufferedReader(new InputStreamReader(System.in));  long N = Long.parseLong(file.readLine());  long[] cutoff = new long[13]; cutoff[0] = 0; for ( int i = 1;(i <= 12);i++) {cutoff[i] = (cutoff[(i - 1)] + ((long)(9 * Math.pow(10,(i - 1))) * i)); } int dig = -1; for ( int i = 0;(i < 12);i++) {if ( (cutoff[i] >= N)) {dig = i; break;} } long sub = ((N - cutoff[(dig - 1)]) - 1);  long num = (sub / dig);  long number = ((long)Math.pow(10,(dig - 1)) + num);  int pos = (int)(sub % dig); System.out.println((number + "")); } }
3	public class utkarsh{ InputStream is ; PrintWriter out ; double x[] ,y[] ,R ; boolean game( double x1, double y1, double x2, double y2){ double dis = (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2))); return (dis <= ((4.0 * R) * R));} void play( int n){ double l ,r ,m ;  double a[] = new double[n]; for ( int i = 0;(i < n);i++) {l = 0.0; r = 1000000.0; for ( int j = 0;(j < 50);j++) {m = ((l + r) / 2); if ( game(x[i],0,x[n],m)) l = m; else r = m; }a[i] = l; }for ( int i = 0;(i < n);i++) {if ( ((a[i] > 0.0) && ((y[i] + a[i]) > y[n]))) y[n] = (y[i] + a[i]); }} void solve(){ int i ,j ,n ; n = ni(); R = nd(); x = new double[n]; y = new double[n]; for ( i = 0;(i < n);i++) x[i] = nd(); for ( i = 0;(i < n);i++) {play(i); }for ( i = 0;(i < n);i++) out.print(((R + y[i]) + " ")); } public static void main( String[] args){ new utkarsh().run(); } void run(){ is = System.in; out = new PrintWriter(System.out); solve(); out.flush(); } byte input[] = new byte[1024]; int len = 0,ptr = 0; int readByte(){ if ( (ptr >= len)) {ptr = 0; try{len = is.read(input); }catch (IOException e){ throw (new InputMismatchException());} if ( (len <= 0)) {return -1;} } return input[ptr++];} boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} int skip(){ int b = readByte(); while(((b != -1) && isSpaceChar(b))){b = readByte(); }return b;} String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} int ni(){ int n = 0,b = readByte();  boolean minus = false; while(((b != -1) && (((b >= '0') && (b <= '9')) || (b == '-')))){b = readByte(); }if ( (b == '-')) {minus = true; b = readByte(); } if ( (b == -1)) {return -1;} while(((b >= '0') && (b <= '9'))){n = ((n * 10) + (b - '0')); b = readByte(); }return (minus?-n:n);} double nd(){ return Double.parseDouble(ns());} char[] ns( int n){ char c[] = new char[n];  int i ,b = skip(); for ( i = 0;(i < n);i++) {if ( isSpaceChar(b)) {break;} c[i] = (char)b; b = readByte(); }return ((i == n)?c:Arrays.copyOf(c,i));} }
4	public class Abra{ public static void main( String[] args)throws IOException { new Abra().run(); } StreamTokenizer in ; PrintWriter out ; boolean oj ; void init()throws IOException { oj = (System.getProperty("ONLINE_JUDGE") != null); Reader reader = (oj?new InputStreamReader(System.in):new FileReader("input.txt"));  Writer writer = (oj?new OutputStreamWriter(System.out):new FileWriter("output.txt")); in = new StreamTokenizer(new BufferedReader(reader)); out = new PrintWriter(writer); } void run()throws IOException { long beginTime = System.currentTimeMillis(); init(); solve(); out.flush(); } String nextString()throws IOException { in.nextToken(); return in.sval;} long gcd( long a, long b){ if ( (a < b)) { long c = b; b = a; a = c; } while(((a % b) != 0)){a = (a % b); if ( (a < b)) { long c = b; b = a; a = c; } }return b;} int gcd( int a, int b){ if ( (a < b)) { int c = b; b = a; a = c; } while(((a % b) != 0)){a = (a % b); if ( (a < b)) { int c = b; b = a; a = c; } }return b;} int countOccurences( String x, String y){ int a = 0,i = 0; while(true){i = y.indexOf(x); if ( (i == -1)) break; a++; y = y.substring((i + 1)); }return a;} int[] primes ; int partition( int n, int l, int m){ if ( (n < l)) return 0; if ( (n < (l + 2))) return 1; if ( (l == 1)) return 1; int c = 0; for ( int i = Math.min(((n - l) + 1),m);(i >= (((n + l) - 1) / l));i--) {c += partition((n - i),(l - 1),i); }return c;} String s ; int l ; void solve()throws IOException { s = nextString(); l = s.length(); int max = 0; for ( int i = 0;(i < (l - 1));i++) {for ( int j = (i + 1);(j < l);j++) {if ( (countOccurences(s.substring(i,j),s) > 1)) if ( ((j - i) > max)) max = (j - i);  }}out.println(max); } }
2	public class ed817Q3{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int t = 1; for ( int zxz = 0;(zxz < t);zxz++) { long n = in.nextLong();  long s = in.nextLong();  long start = s,end = n;  long ans = (n + 1); while((start <= end)){ long mid = (start + ((end - start) / 2)); if ( ((mid - digitSum(mid)) >= s)) {ans = mid; end = (mid - 1); } else {start = (mid + 1); }}System.out.println(((n - ans) + 1)); }} static int digitSum( long n){ int sum = 0; while((n > 0)){sum += (n % 10); n = (n / 10); }return sum;} static class InputReader{ private InputStream stream ; private byte[] buf = new byte[8192]; private int curChar ,snumChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int snext(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = snext(); while(isSpaceChar(c))c = snext(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = snext(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = snext(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = snext(); while(isSpaceChar(c))c = snext(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = snext(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = snext(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
6	public class f{ static int n ,m ; static int start ; static int[][] memo ; static int[][] arr ; static int[][] costs ; static int[][] wrapCosts ; public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out); n = in.nextInt(); m = in.nextInt(); arr = new int[n][m]; costs = new int[n][n]; wrapCosts = new int[n][n]; for ( int r = 0;(r < n);r++) {for ( int c = 0;(c < m);c++) {arr[r][c] = in.nextInt(); }}for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {costs[i][j] = Integer.MAX_VALUE; for ( int c = 0;(c < m);c++) {costs[i][j] = Math.min(costs[i][j],Math.abs((arr[i][c] - arr[j][c]))); }costs[j][i] = costs[i][j]; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {wrapCosts[i][j] = Integer.MAX_VALUE; for ( int c = 0;(c < (m - 1));c++) {wrapCosts[i][j] = Math.min(wrapCosts[i][j],Math.abs((arr[i][(c + 1)] - arr[j][c]))); }}}memo = new int[n][(1 << n)]; long best = 0; for ( start = 0;(start < n);start++) {for ( int[] a :memo) Arrays.fill(a,-1); best = Math.max(best,go(start,(((1 << n) - 1) - (1 << start)))); }out.println(best); out.close(); } static int go( int cur, int mask){ if ( (mask == 0)) {return wrapCosts[start][cur];} if ( (memo[cur][mask] != -1)) return memo[cur][mask]; int ans = 0; for ( int next = 0;(next < n);next++) { int bit = (1 << next); if ( ((mask & bit) == 0)) continue; ans = Math.max(ans,Math.min(costs[cur][next],go(next,(mask ^ bit)))); }return memo[cur][mask] = ans;} static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream i){ br = new BufferedReader(new InputStreamReader(i)); st = new StringTokenizer(""); } public String next()throws IOException { if ( st.hasMoreTokens()) return st.nextToken(); else st = new StringTokenizer(br.readLine()); return next();} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
0	public class Main{ public static void main( String[] args){ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); try{ String parameterStringList[] = reader.readLine().split(" ");  int x = Integer.parseInt(parameterStringList[0]);  int y = Integer.parseInt(parameterStringList[1]);  int z = Integer.parseInt(parameterStringList[2]);  int t1 = Integer.parseInt(parameterStringList[3]);  int t2 = Integer.parseInt(parameterStringList[4]);  int t3 = Integer.parseInt(parameterStringList[5]);  int T1 = (Math.abs((x - y)) * t1);  int T2 = (((Math.abs((x - z)) * t2) + (3 * t3)) + (Math.abs((x - y)) * t2)); if ( (T2 <= T1)) System.out.println("YES"); else System.out.println("NO"); }catch (IOException e){ e.printStackTrace(); } } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskE solver = new TaskE(); solver.solve(1,in,out); out.close(); } } class TaskE{ private int n ; private double[] dp ; private double[][] p ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); p = new double[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {p[i][j] = in.nextDouble(); }}dp = new double[(1 << n)]; Arrays.fill(dp,-1); for ( int i = 0;(i < n);++i) {out.printf("%.6f ",rec((1 << i))); }out.println(); } private double rec( int mask){ if ( (mask == ((1 << n) - 1))) return 1; if ( (dp[mask] > -0.5)) return dp[mask]; double res = 0;  int nn = Integer.bitCount(mask);  int total = ((nn * (nn + 1)) / 2); for ( int i = 0;(i < n);++i) if ( BitUtils.checkBit(mask,i)) for ( int j = 0;(j < n);++j) if ( !BitUtils.checkBit(mask,j)) {res += (rec(BitUtils.setBit(mask,j)) * p[i][j]); } res /= total; dp[mask] = res; return res;} } class InputReader{ private BufferedReader reader ; private StringTokenizer stt ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); } public String nextLine(){ try{return reader.readLine().trim(); }catch (IOException e){ return null;} } public String nextString(){ while(((stt == null) || !stt.hasMoreTokens())){stt = new StringTokenizer(nextLine()); }return stt.nextToken();} public int nextInt(){ return Integer.parseInt(nextString());} public double nextDouble(){ return Double.parseDouble(nextString());} }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  BSportMafia solver = new BSportMafia(); solver.solve(1,in,out); out.close(); } static class BSportMafia{ public void solve( int testNumber, InputReader in, PrintWriter out){ long n = in.nextInt();  long k = in.nextInt();  long d = (9 + (4 * ((2 * n) + (2 * k))));  double smh = Math.sqrt(d);  double ans = ((-3 + smh) / 2); out.println((n - (int)ans)); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
6	public class CFContest{ public static void main( String[] args)throws Exception { boolean local = (System.getProperty("ONLINE_JUDGE") == null);  boolean async = true;  Charset charset = Charset.forName("ascii");  FastIO io = (local?new FastIO(new FileInputStream("D:\\DATABASE\\TESTCASE\\Code.in"),System.out,charset):new FastIO(System.in,System.out,charset));  Task task = new Task(io,new Debug(local)); if ( async) { Thread t = new Thread(null,task,"dalt",(1 << 27)); t.setPriority(Thread.MAX_PRIORITY); t.start(); t.join(); } else {task.run(); }if ( local) {io.cache.append((("\n\n--memory -- \n" + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20)) + "M")); } io.flush(); } public static class Task implements Runnable{ final FastIO io ; final Debug debug ; int inf = (int)1e8; long lInf = (long)1e18; public Task( FastIO io, Debug debug){ this.io = io; this.debug = debug; } @Override public void run(){ int t = io.readInt(); while((t-- > 0))solve1(); } public void solve1(){ cache.clear(); int n = io.readInt();  int m = io.readInt();  Col[] mat = new Col[m]; for ( int i = 0;(i < m);i++) {mat[i] = new Col(); mat[i].data = new int[n]; }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int v = io.readInt(); mat[j].data[i] = v; mat[j].max = Math.max(mat[j].max,v); }}Arrays.sort(mat,(a,b)->(a.max - b.max)); mat = Arrays.copyOf(mat,Math.min(n,m)); io.cache.append(bf(mat,getCol(n),n,0)).append('\n'); } public void enhance( Col mask, Col c, Col ans, int n){ for ( int i = 0;(i < n);i++) {ans.data[i] = Math.max(mask.get(i),c.get(i)); }} Deque<Col> cache = new ArrayDeque<>(); public Col getCol( int n){ if ( cache.isEmpty()) { Col col = new Col(); col.data = new int[n]; return col;} return cache.removeFirst();} public void destroy( Col c){ c.offset = 0; c.max = 0; cache.addLast(c); } public int bf( Col[] cols, Col mask, int n, int k){ if ( (k >= cols.length)) { int sum = 0; for ( int i = 0;(i < n);i++) {sum += mask.data[i]; }return sum;} int max = 0; cols[k].offset = 0; for ( int i = 0;(i < n);i++) { Col c = getCol(n); enhance(mask,cols[k],c,n); max = Math.max(max,bf(cols,c,n,(k + 1))); destroy(c); cols[k].turn(); }return max;} } public static class Col{ int[] data ; int offset ; public int get( int i){ return data[((i + offset) % data.length)];} public void turn(){ offset++; } int max ; } public static class FastIO{ public final StringBuilder cache = new StringBuilder((20 << 20)); private final InputStream is ; private final OutputStream os ; private final Charset charset ; private StringBuilder defaultStringBuf = new StringBuilder((1 << 8)); private byte[] buf = new byte[(1 << 20)]; private int bufLen ; private int bufOffset ; private int next ; public FastIO( InputStream is, OutputStream os, Charset charset){ this.is = is; this.os = os; this.charset = charset; } public FastIO( InputStream is, OutputStream os){ this(is,os,Charset.forName("ascii")); } private int read(){ while((bufLen == bufOffset)){bufOffset = 0; try{bufLen = is.read(buf); }catch (IOException e){ throw (new RuntimeException(e));} if ( (bufLen == -1)) {return -1;} }return buf[bufOffset++];} public void skipBlank(){ while(((next >= 0) && (next <= 32))){next = read(); }} public int readInt(){ int sign = 1; skipBlank(); if ( ((next == '+') || (next == '-'))) {sign = ((next == '+')?1:-1); next = read(); } int val = 0; if ( (sign == 1)) {while(((next >= '0') && (next <= '9'))){val = (((val * 10) + next) - '0'); next = read(); }} else {while(((next >= '0') && (next <= '9'))){val = (((val * 10) - next) + '0'); next = read(); }}return val;} public String readString( StringBuilder builder){ skipBlank(); while((next > 32)){builder.append((char)next); next = read(); }return builder.toString();} public String readString(){ defaultStringBuf.setLength(0); return readString(defaultStringBuf);} public int readString( char[] data, int offset){ skipBlank(); int originalOffset = offset; while((next > 32)){data[offset++] = (char)next; next = read(); }return (offset - originalOffset);} public int readString( byte[] data, int offset){ skipBlank(); int originalOffset = offset; while((next > 32)){data[offset++] = (byte)next; next = read(); }return (offset - originalOffset);} public void flush(){ try{os.write(cache.toString().getBytes(charset)); os.flush(); cache.setLength(0); }catch (IOException e){ throw (new RuntimeException(e));} } } public static class Debug{ private boolean allowDebug ; public Debug( boolean allowDebug){ this.allowDebug = allowDebug; } public void fail(){ throw (new RuntimeException());} private void outputName( String name){ System.out.print((name + " = ")); } } }
2	public class Main{ static class Task{ int NN = 500005; int MOD = 1000000007; int INF = 2000000000; long INFINITY = 2000000000000000000L; public void solve( InputReader in, PrintWriter out){ int t = in.nextInt(); while((t-- > 0)){ long n = in.nextLong();  long k = in.nextLong(); if ( ((n < 32) && (k > (((1L << (2L * n)) - 1L) / 3L)))) {out.println("NO"); continue;} if ( ((n == 2) && (k == 3))) {out.println("NO"); continue;} if ( (n >= 32)) {out.println(("YES " + (n - 1))); continue;} boolean done = false; for ( long i = 1;(i <= n);++i) {if ( (k < (((1L << (i + 2L)) - i) - 3L))) {done = true; out.println(("YES " + (n - i))); break;} }if ( !done) {out.println("YES 0"); } }} } static void prepareIO( boolean isFileIO){ Task solver = new Task(); if ( !isFileIO) { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream); solver.solve(in,out); out.close(); } else { String IPfilePath = (System.getProperty("user.home") + "/Downloads/ip.in");  String OPfilePath = (System.getProperty("user.home") + "/Downloads/op.out");  InputReader fin = new InputReader(IPfilePath);  PrintWriter fout = null; try{fout = new PrintWriter(new File(OPfilePath)); }catch (FileNotFoundException e){ e.printStackTrace(); } solver.solve(fin,fout); fout.close(); }} public static void main( String[] args){ prepareIO(false); } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public InputReader( String filePath){ File file = new File(filePath); try{reader = new BufferedReader(new FileReader(file)); }catch (FileNotFoundException e){ e.printStackTrace(); } tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} } }
1	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); if ( ((n >= 3) && (n <= 100))) { int num[] = new int[n]; for ( int i = 0;(i < n);i++) {num[i] = in.nextInt(); } int even = 0,odd = 0,ceven = 0,codd = 0; for ( int i = 0;(i < n);i++) {if ( ((num[i] % 2) == 0)) {even++; ceven = (i + 1); } else {odd++; codd = (i + 1); }}if ( (odd == 1)) {System.out.println(("" + codd)); } else {System.out.println(("" + ceven)); }} } }
3	public class DivRound584ProblemA{ static FastReader sc = new FastReader(); public static void main( String[] args)throws IOException { int n = sc.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); int c = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] < 0)) continue; c = (c - 1); for ( int j = (i + 1);(j < n);j++) {if ( (a[j] < 0)) continue; if ( ((a[j] % a[i]) == 0)) {a[j] = c; } }}System.out.println(Math.abs(c)); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
3	public class p4{ static int N ,M ,K ; static String s ; static StringTokenizer st ; static int[] d ; public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int N = Integer.parseInt(br.readLine());  int[] d = new int[N]; st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < N);i++) {d[i] = Integer.parseInt(st.nextToken()); } boolean cur = ((inv(d) % 2) == 1);  int Q = Integer.parseInt(br.readLine()); for ( int i = 0;(i < Q);i++) {st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken());  int b = Integer.parseInt(st.nextToken());  int dif = ((b - a) + 1); if ( (((dif / 2) % 2) == 1)) {cur = !cur; } System.out.println((cur?"odd":"even")); }} static class BIT{ int[] tree ; int N ; public BIT( int N){ this.N = N; tree = new int[(N + 1)]; } public BIT( int N, int[] d){ this.N = N; tree = new int[(N + 1)]; for ( int i = 1;(i < d.length);i++) {update(i,d[i]); }} public int query( int K){ int sum = 0; for ( int i = K;(i > 0);i -= (i & -i)) {sum += tree[i]; }return sum;} public void update( int K, int val){ for ( int i = K;(i <= N);i += (i & -i)) {tree[i] += val; }} } public static int[] toRel( int[] d){ pair[] p = new pair[d.length]; for ( int i = 0;(i < d.length);i++) {p[i] = new pair(d[i],(i + 1)); }Arrays.sort(p); int[] fin = new int[d.length]; for ( int i = 0;(i < d.length);i++) {fin[i] = p[i].b; }return fin;} public static int inv( int[] d){ int ans = 0;  int N = d.length;  int[] x = toRel(d);  BIT b = new BIT((N + 1)); for ( int i = (N - 1);(i >= 0);i--) {ans += b.query(x[i]); b.update(x[i],1); }return ans;} } class pair implements Comparable<pair>{ int a ,b ; public pair( int _a, int _b){ this.a = _a; this.b = _b; } }
0	public class Solution{ public static void main( String[] args){ Scanner stdin = new Scanner(System.in);  long n = stdin.nextLong(); if ( (n < 3)) System.out.println(n); else {if ( ((n % 2) == 0)) { long a = 0,b = 0; if ( ((n % 3) != 0)) a = ((n * (n - 1)) * (n - 3)); n--; b = ((n * (n - 1)) * (n - 2)); System.out.println(Math.max(a,b)); } else System.out.println(((n * (n - 1)) * (n - 2))); }} }
1	public class A{ void exe(){ LinkedList<Integer> list = new LinkedList<Integer>(); for ( int i = 2;(i <= 1000);i++) if ( isPrime(i)) list.add(i);  Object[] primes = list.toArray();  Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  int cnt = 0; for ( int c = 2;(c <= n);c++) {if ( !isPrime(c)) continue; for ( int i = 0;(i < (primes.length - 1));i++) { int p1 = (Integer)primes[i];  int p2 = (Integer)primes[(i + 1)]; if ( (c == ((1 + p1) + p2))) {cnt++; } }}if ( (cnt >= k)) {System.out.println("YES"); } else {System.out.println("NO"); }} boolean isPrime( int n){ if ( (n <= 1)) return false; if ( (n == 2)) return true; if ( ((n % 2) == 0)) return false; int m = ((int)Math.sqrt(n) + 1); for ( int i = 3;(i <= m);i += 2) if ( ((n % i) == 0)) return false; return true;} public static void main( String[] args){ Locale.setDefault(Locale.US); new A().exe(); } }
1	public class Naldbah implements Runnable{ boolean isLocalMode = false; public static void main( String[] args){ new Naldbah().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(getReader()); tokenizer = null; writer = new PrintWriter(System.out); doJob(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } private void doJob()throws IOException { int n = nextInt();  int k = nextInt();  boolean[] primes = sieve((n + 1)); for ( int i = n;(i >= 2);i--) {if ( primes[i]) { int solve = (i - 1);  int sn = getNextD(primes,solve);  int en = getNextD(primes,n); while(((en != -1) && ((sn + en) >= solve))){if ( ((sn + en) == solve)) k--; sn = en; en = getNextD(primes,en); }} }writer.write(((k <= 0)?"YES":"NO")); } private int getNextD( boolean[] primes, int i){ for ( int p = (i - 1);(p >= 2);p--) {if ( primes[p]) return p; }return -1;} public boolean[] sieve( int n){ boolean[] prime = new boolean[(n + 1)]; Arrays.fill(prime,true); prime[0] = false; prime[1] = false; int m = (int)Math.sqrt(n); for ( int i = 2;(i <= m);i++) if ( prime[i]) for ( int k = (i * i);(k <= n);k += i) prime[k] = false; return prime;} int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} public Reader getReader()throws FileNotFoundException { if ( isLocalMode) {return new FileReader("input.txt");} else {return new InputStreamReader(System.in);}} }
4	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ Scanner in ; PrintWriter out ; public void solve( int testNumber, Scanner in, PrintWriter out){ this.in = in; this.out = out; run(); } void run(){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int[][][] dis = new int[n][m][4];  int[][] dir = {{0,1},{0,-1},{1,0},{-1,0}};  int tmp ; final int M = (int)1e8; Algo.fill(dis,M); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {tmp = in.nextInt(); dis[i][j][0] = tmp; dis[i][(j + 1)][1] = tmp; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {tmp = in.nextInt(); dis[i][j][2] = tmp; dis[(i + 1)][j][3] = tmp; }} int[][] ans = new int[n][m]; if ( ((k % 2) == 1)) {Algo.fill(ans,-1); } else { int halfK = (k / 2);  int[][][] dp = new int[(halfK + 1)][n][m]; Algo.fill(dp,M); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[0][i][j] = 0; }}for ( int step = 1;(step <= halfK);step++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {for ( int d = 0;(d < dir.length);d++) { int toX = (i + dir[d][0]);  int toY = (j + dir[d][1]); if ( ((((toX < 0) || (toY < 0)) || (toX >= n)) || (toY >= m))) continue; dp[step][i][j] = Math.min((dp[(step - 1)][toX][toY] + (2 * dis[i][j][d])),dp[step][i][j]); }}}}ans = dp[halfK]; }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print(ans[i][j]); out.print(' '); }out.println(""); }} } static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); eat(""); } private void eat( String s){ st = new StringTokenizer(s); } public String nextLine(){ try{return br.readLine(); }catch (IOException e){ return null;} } public boolean hasNext(){ while(!st.hasMoreTokens()){ String s = nextLine(); if ( (s == null)) return false; eat(s); }return true;} public String next(){ hasNext(); return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
5	public class A{ Scanner in = new Scanner(System.in); public class Houses implements Comparable<Houses>{ double x ; double a ; public Houses( double xVal, double aVal){ x = (xVal - (aVal / 2)); a = aVal; } } public void solve2( ArrayList<Houses> list, int t){ Collections.sort(list); int count = 2; for ( int f = 0;(f < (list.size() - 1));f++) {if ( (((list.get((f + 1)).x - list.get(f).x) - list.get(f).a) > t)) {count += 2; } else if ( (((list.get((f + 1)).x - list.get(f).x) - list.get(f).a) == t)) {count++; } }System.out.println(count); } public void solve(){ ArrayList<Houses> list = new ArrayList<Houses>();  int n = in.nextInt();  int t = in.nextInt(); for ( int i = 0;(i < n);i++) {list.add(new Houses(in.nextDouble(),in.nextDouble())); }solve2(list,t); } public static void main( String[] args){ A p = new A(); p.solve(); } }
2	public class ehsan{ public static BigInteger f( BigInteger m, BigInteger n){ BigInteger s ,l ; s = n.multiply(m.add(BigInteger.valueOf(1))); l = m.multiply(m.add(BigInteger.valueOf(1))); l = l.divide(BigInteger.valueOf(2)); s = s.subtract(l); s = s.subtract(m); return s;} public static BigInteger bs( BigInteger a, BigInteger b, BigInteger n, BigInteger d){ BigInteger c ,e ; c = a.add(b); c = c.divide(BigInteger.valueOf(2)); e = f(c,n); if ( e.equals(d)) return c.add(BigInteger.valueOf(1)); if ( a.equals(b.add(BigInteger.valueOf(-1)))) return b.add(BigInteger.valueOf(1)); if ( (e.compareTo(d) > 0)) return bs(a,c,n,d); return bs(c,b,n,d);} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  BigInteger bi1 = sc.nextBigInteger();  BigInteger bi2 = sc.nextBigInteger();  BigInteger i ,n = bi2;  BigInteger i2 = BigInteger.valueOf(1);  BigInteger sum = BigInteger.valueOf(0); if ( (bi1.compareTo(bi2) < 0)) {System.out.println(0); return ;} else if ( (bi1.compareTo(bi2) == 0)) {System.out.println(1); return ;} bi2 = n.multiply(n.add(BigInteger.valueOf(1))).subtract(n.subtract(BigInteger.valueOf(1))); if ( (bi1.compareTo(bi2) > 0)) System.out.println(-1); else {System.out.println(bs(BigInteger.valueOf(0),n.add(BigInteger.valueOf(-2)),n,bi1)); }} }
4	public class CF387D{ static class A{ ArrayList<Integer> list = new ArrayList<>(); int u ,v ,d ; } static final int INF = Integer.MAX_VALUE; static boolean bfs( A[] aa, int n){ ArrayDeque<Integer> q = new ArrayDeque<>(); for ( int u = 1;(u <= n);u++) if ( (aa[u].v > 0)) aa[u].d = INF; else {aa[u].d = 0; q.addLast(u); }aa[0].d = INF; while(!q.isEmpty()){ int u = q.removeFirst(); for ( int v :aa[u].list) { int w = aa[v].u; if ( (aa[w].d == INF)) {aa[w].d = (aa[u].d + 1); if ( (w == 0)) return true; q.addLast(w); } }}return false;} static boolean dfs( A[] aa, int n, int u){ if ( (u == 0)) return true; for ( int v :aa[u].list) { int w = aa[v].u; if ( ((aa[w].d == (aa[u].d + 1)) && dfs(aa,n,w))) {aa[u].v = v; aa[v].u = u; return true;} }aa[u].d = INF; return false;} static int matchings( A[] aa, int n){ int cnt = 0; while(bfs(aa,n))for ( int u = 1;(u <= n);u++) if ( ((aa[u].v == 0) && dfs(aa,n,u))) cnt++; return cnt;} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int m = Integer.parseInt(st.nextToken());  int[] eu = new int[m];  int[] ev = new int[m]; for ( int j = 0;(j < m);j++) {st = new StringTokenizer(br.readLine()); eu[j] = Integer.parseInt(st.nextToken()); ev[j] = Integer.parseInt(st.nextToken()); } A[] aa = new A[(n + 1)];  int min = (m + (n * 3)); for ( int ctr = 1;(ctr <= n);ctr++) { boolean loop = false;  boolean[] ci = new boolean[(n + 1)];  boolean[] co = new boolean[(n + 1)]; for ( int i = 0;(i <= n);i++) aa[i] = new A(); int m_ = 0; for ( int j = 0;(j < m);j++) { int u = eu[j];  int v = ev[j]; if ( ((u == ctr) && (v == ctr))) loop = true; else if ( ((u == ctr) && (v != ctr))) ci[v] = true; else if ( ((u != ctr) && (v == ctr))) co[u] = true; else {aa[u].list.add(v); m_++; }} int cnt = (loop?0:1); for ( int i = 1;(i <= n);i++) if ( (i != ctr)) {if ( !ci[i]) cnt++; if ( !co[i]) cnt++; } int m2 = matchings(aa,n); cnt += ((m_ - m2) + ((n - 1) - m2)); if ( (min > cnt)) min = cnt; }System.out.println(min); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastReader in = new FastReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ static final long MODULO = (long)(1e9 + 7); public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.nextInt();  long[][] dp = new long[(n + 100)][(n + 100)]; dp[0][0] = 1; for ( int i = 0;(i < n);++i) { char current = in.nextCharacter(); if ( (current == 'f')) {for ( int j = 0;(j < n);++j) {dp[(i + 1)][(j + 1)] += dp[i][j]; dp[(i + 1)][(j + 1)] %= MODULO; }} else { long runningSum = 0; for ( int j = n;(j >= 0);--j) {runningSum += dp[i][j]; runningSum %= MODULO; dp[(i + 1)][j] += runningSum; dp[(i + 1)][j] %= MODULO; }}}out.println(dp[n][0]); } } static class FastReader{ private InputStream stream ; private byte[] buf = new byte[8192]; private int curChar ; private int pnumChars ; public FastReader( InputStream stream){ this.stream = stream; } private int pread(){ if ( (pnumChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= pnumChars)) {curChar = 0; try{pnumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (pnumChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = pread(); while(isSpaceChar(c))c = pread(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = pread(); } int res = 0; do {if ( (c == ',')) {c = pread(); } if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = pread(); }while(!isSpaceChar(c));return (res * sgn);} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public char nextCharacter(){ int c = pread(); while(isSpaceChar(c))c = pread(); return (char)c;} } }
4	public class A implements Runnable{ public static void main( String[] args){ new A().run(); } class FastScanner{ BufferedReader br ; StringTokenizer st ; boolean eof ; String buf ; public FastScanner( String fileName)throws FileNotFoundException{ br = new BufferedReader(new FileReader(fileName)); nextToken(); } public FastScanner( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); nextToken(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; break;} } String ret = buf; buf = (eof?"-1":st.nextToken()); return ret;} int nextInt(){ return Integer.parseInt(nextToken());} long nextLong(){ return Long.parseLong(nextToken());} double nextDouble(){ return Double.parseDouble(nextToken());} void close(){ try{br.close(); }catch (Exception e){ } } } FastScanner sc ; PrintWriter out ; public void run(){ Locale.setDefault(Locale.US); try{sc = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); sc.close(); out.close(); }catch (Throwable e){ e.printStackTrace(); System.exit(1); } } int nextInt(){ return sc.nextInt();} String nextToken(){ return sc.nextToken();} long nextLong(){ return sc.nextLong();} double nextDouble(){ return sc.nextDouble();} void solve(){ String s = nextToken(); for ( int len = s.length();(len >= 1);len--) {for ( int i = 0;((i + len) <= s.length());i++) { int cnt = 0; for ( int j = 0;((j + len) <= s.length());j++) { boolean ok = true; for ( int k = 0;(k < len);k++) {if ( (s.charAt((i + k)) != s.charAt((j + k)))) {ok = false; break;} }if ( ok) {cnt++; } }if ( (cnt > 1)) {out.println(len); return ;} }}out.println(0); } }
6	public class F{ public static void main( String[] args){ FastScanner scanner = new FastScanner();  int N = scanner.nextInt();  int M = scanner.nextInt();  int[][] matrix = new int[N][M]; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {matrix[i][j] = scanner.nextInt(); }} int[][] maxDist = new int[N][N]; for ( int i = 0;(i < N);i++) {Arrays.fill(maxDist[i],Integer.MAX_VALUE); }for ( int i = 0;(i < M);i++) {for ( int j = 0;(j < N);j++) {for ( int k = (j + 1);(k < N);k++) {maxDist[j][k] = Math.min(maxDist[j][k],Math.abs((matrix[k][i] - matrix[j][i]))); maxDist[k][j] = maxDist[j][k]; }}} int[][] distTop = new int[N][N]; for ( int i = 0;(i < N);i++) {Arrays.fill(distTop[i],Integer.MAX_VALUE); }for ( int i = 0;(i < (M - 1));i++) {for ( int j = 0;(j < N);j++) {for ( int k = 0;(k < N);k++) {distTop[j][k] = Math.min(distTop[j][k],Math.abs((matrix[j][i] - matrix[k][(i + 1)]))); }}}if ( (N == 1)) {System.out.println(distTop[0][0]); System.exit(0); } int[] bitLoc = new int[(1 << N)]; for ( int i = 0;(i < N);i++) {bitLoc[(1 << i)] = i; } int[][][] dp = new int[(1 << N)][N][N]; for ( int mask = 1;(mask < (1 << N));mask++) {for ( int smask = mask;(smask > 0);smask &= (smask - 1)) { int i = bitLoc[Integer.lowestOneBit(smask)]; for ( int ss = (mask ^ (1 << i));(ss > 0);ss &= (ss - 1)) { int j = bitLoc[Integer.lowestOneBit(ss)]; if ( (mask == ((1 << i) ^ (1 << j)))) dp[mask][i][j] = maxDist[i][j]; else { int x = 0; for ( int sss = ((mask ^ (1 << i)) ^ (1 << j));(sss > 0);sss &= (sss - 1)) { int k = bitLoc[(sss & -sss)]; x = Math.max(x,Math.min(dp[(mask ^ (1 << j))][i][k],maxDist[k][j])); }dp[mask][i][j] = x; }}}} int mxMsk = ((1 << N) - 1);  int max = 0; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < N);j++) {if ( (i == j)) continue; max = Math.max(max,Math.min(dp[mxMsk][i][j],distTop[i][j])); }}System.out.println(max); } public static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( Reader in){ br = new BufferedReader(in); } public FastScanner(){ this(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
3	public class C{ static ArrayList<Integer> statements ; static final int MOD = ((int)1e9 + 7); static int[][] memo ; static int solve( int i, int c){ if ( (i == statements.size())) return 1; if ( (memo[i][c] != -1)) return memo[i][c]; long ans = solve((i + 1),(c + statements.get(i))); if ( (c > 0)) ans += solve(i,(c - 1)); return memo[i][c] = (int)(ans % MOD);} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt(); statements = new ArrayList<>(); char[] c = new char[n]; for ( int i = 0;(i < n);i++) {c[i] = sc.next().charAt(0); }if ( (c[0] == 's')) statements.add(0); else statements.add(1); for ( int i = 1;(i < n);i++) {if ( (c[(i - 1)] == 'f')) {if ( (c[i] == 'f')) statements.set((statements.size() - 1),(statements.get((statements.size() - 1)) + 1)); } else {if ( (c[i] == 's')) statements.add(0); else statements.add(1); }}memo = new int[statements.size()][(n + 1)]; for ( int[] a :memo) Arrays.fill(a,-1); out.println(solve(0,0)); out.flush(); out.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String file)throws FileNotFoundException{ br = new BufferedReader(new FileReader(file)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
6	public class Problem{ public static void main( String[] arg){ FastScanner scan = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = scan.nextInt();  double ncr[][] = new double[(n + 1)][(n + 1)]; ncr[1][0] = ncr[0][1] = ncr[1][1] = 1.0; for ( int i = 2;(i <= n);i++) {for ( int j = 0;(j <= i);j++) {if ( ((j == 0) || (j == i))) ncr[i][j] = 1.0; else ncr[i][j] = (ncr[(i - 1)][j] + ncr[(i - 1)][(j - 1)]); }} double a[][] = new double[(n + 1)][(n + 1)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) a[i][j] = scan.nextDouble(); double dp[] = new double[(1 << 19)]; dp[((1 << n) - 1)] = 1.0; for ( int state = ((1 << n) - 1);(state >= 0);state--) { int len = 0; for ( int i = 0;(i < n);i++) if ( ((state & (1 << i)) > 0)) len++; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & state) == 0)) continue; for ( int j = 0;(j < i);j++) {if ( (((1 << j) & state) == 0)) continue; dp[(state & (1 << i))] += ((dp[state] * a[j][i]) / ncr[len][2]); dp[(state & (1 << j))] += ((dp[state] * a[i][j]) / ncr[len][2]); }}}for ( int i = 0;(i < n);i++) System.out.print((String.format("%.6f",dp[(1 << i)]) + " ")); out.close(); } public static long gcd( long a, long b){ if ( (b == 0)) return a; if ( (a < b)) return gcd(b,a); return gcd(b,(a % b));} static class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream is){ try{br = new BufferedReader(new InputStreamReader(is)); }catch (Exception e){ e.printStackTrace(); } } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ return null;} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} double nextDouble(){ return Double.valueOf(next());} } }
6	public class TaskB{ int[] levels ; int[] loyalty ; int n ,k ,A ; double ans = Double.NEGATIVE_INFINITY; void rec( int ix, int sweets, int[] loyalty){ if ( (ix == n)) { double nres = 0.0; for ( int mask = 0;(mask < (1 << n));mask++) { double res = 1.0,totalStrength = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) > 0)) {res *= (loyalty[i] / 100.0); } else {res *= (1.0 - (loyalty[i] / 100.0)); totalStrength += levels[i]; }} int bitCount = Integer.bitCount(mask); if ( (bitCount > (n / 2))) {nres += res; } else {nres += ((res * A) / (A + totalStrength)); }}ans = Math.max(ans,nres); return ;} for ( int j = 0;(j <= sweets);j++) {if ( ((loyalty[ix] + (10 * j)) > 100)) break; int[] nloyalty = loyalty.clone(); nloyalty[ix] += (10 * j); rec((ix + 1),(sweets - j),nloyalty); }} void run(){ n = nextInt(); k = nextInt(); A = nextInt(); levels = new int[n]; loyalty = new int[n]; for ( int i = 0;(i < n);i++) {levels[i] = nextInt(); loyalty[i] = nextInt(); }rec(0,k,loyalty); System.out.println(ans); } int nextInt(){ try{ int c = System.in.read(); if ( (c == -1)) return c; while(((c != '-') && ((c < '0') || ('9' < c)))){c = System.in.read(); if ( (c == -1)) return c; }if ( (c == '-')) return -nextInt(); int res = 0; do {res *= 10; res += (c - '0'); c = System.in.read(); }while((('0' <= c) && (c <= '9')));return res; }catch (Exception e){ return -1;} } long nextLong(){ try{ int c = System.in.read(); if ( (c == -1)) return -1; while(((c != '-') && ((c < '0') || ('9' < c)))){c = System.in.read(); if ( (c == -1)) return -1; }if ( (c == '-')) return -nextLong(); long res = 0; do {res *= 10; res += (c - '0'); c = System.in.read(); }while((('0' <= c) && (c <= '9')));return res; }catch (Exception e){ return -1;} } String next(){ try{ StringBuilder res = new StringBuilder("");  int c = System.in.read(); while(Character.isWhitespace(c))c = System.in.read(); do {res.append((char)c); }while(!Character.isWhitespace(c = System.in.read()));return res.toString(); }catch (Exception e){ return null;} } public static void main( String[] args){ new TaskB().run(); } }
1	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(new BufferedInputStream(System.in));  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); while(in.hasNext()){ int n = in.nextInt(),a = in.nextInt(),b = in.nextInt(),c = 0;  int[] p = new int[n];  TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {p[i] = in.nextInt(); map.put(p[i],i); }if ( (a > b)) { int t = b; b = a; a = t; c = 1; } boolean ok = true;  int[] cls = new int[n]; while((ok && (map.size() > 0))){ Entry<Integer,Integer> last = map.lastEntry();  int v = last.getKey();  int idx = last.getValue(); if ( map.containsKey((a - v))) {cls[idx] = 0; cls[map.get((a - v))] = 0; map.remove(v); map.remove((a - v)); } else if ( map.containsKey((b - v))) {cls[idx] = 1; cls[map.get((b - v))] = 1; map.remove(v); map.remove((b - v)); } else ok = false; }if ( !ok) System.out.println("NO"); else {System.out.println("YES"); for ( int j = 0;(j < cls.length);j++) {if ( (j != 0)) System.out.print(" "); System.out.print((c ^ cls[j])); }System.out.println(); }out.flush(); }in.close(); } }
4	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  CCompressionAndExpansion solver = new CCompressionAndExpansion();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class CCompressionAndExpansion{ public final void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  ArrayList<ArrayList<Integer>> ans = new ArrayList<>();  ArrayList<Integer> start = new ArrayList<>(); start.add(in.nextInt()); ans.add(start); out.println("1"); for ( int i = 1;(i < n);i++) { ArrayList<Integer> lastList = ans.get((ans.size() - 1));  ArrayList<Integer> curList = (ArrayList<Integer>)lastList.clone(); ans.add(curList); int curLast = in.nextInt(); for ( int j = (lastList.size() - 1);(j >= 0);j--) { int last = lastList.get(j); if ( (curLast == 1)) {curList.add(1); break;} else if ( (curLast == (last + 1))) {curList.set(j,curLast); break;} else {curList.remove(j); }}for ( int j = 0;(j < curList.size());j++) {if ( (j > 0)) out.print("."); out.print(curList.get(j)); }out.println(); }} } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[(1 << 18)]; private int curChar ; private int numChars ; public InputReader(){ this.stream = System.in; } public InputReader(final InputStream stream){ this.stream = stream; } private int read(){ if ( (this.numChars == -1)) {throw (new UnknownError());} else {if ( (this.curChar >= this.numChars)) {this.curChar = 0; try{this.numChars = this.stream.read(this.buf); }catch (IOException ex){ throw (new InputMismatchException());} if ( (this.numChars <= 0)) {return -1;} } return this.buf[this.curChar++];}} public final int nextInt(){ int c ; for ( c = this.read();isSpaceChar(c);c = this.read()) {} byte sgn = 1; if ( (c == 45)) {sgn = -1; c = this.read(); } int res = 0; while(((c >= 48) && (c <= 57))){res *= 10; res += (c - 48); c = this.read(); if ( isSpaceChar(c)) {return (res * sgn);} }throw (new InputMismatchException());} public final String next(){ int c ; while(isSpaceChar(c = this.read())){} StringBuilder result = new StringBuilder(); result.appendCodePoint(c); while(!isSpaceChar(c = this.read())){result.appendCodePoint(c); }return result.toString();} private static boolean isSpaceChar(final int c){ return (((((c == 32) || (c == 10)) || (c == 13)) || (c == 9)) || (c == -1));} } }
6	public class E implements Runnable{ public static void main( String[] args){ new Thread(null,new E(),"_cf",(1 << 28)).start(); } int n ,m ; char[] str ; int[][] occs ,cost ; int[] dp ; int oo = (int)1e9; int min( int a, int b){ if ( (a < b)) return a; return b;} class FastScanner{ public int BS = (1 << 16); public char NC = (char)0; byte[] buf = new byte[BS]; int bId = 0,size = 0; char c = NC; double num = 1; BufferedInputStream in ; public FastScanner(){ in = new BufferedInputStream(System.in,BS); } public FastScanner( String s){ try{in = new BufferedInputStream(new FileInputStream(new File(s)),BS); }catch (Exception e){ in = new BufferedInputStream(System.in,BS); } } public char nextChar(){ while((bId == size)){try{size = in.read(buf); }catch (Exception e){ return NC;} if ( (size == -1)) return NC; bId = 0; }return (char)buf[bId++];} public int nextInt(){ return (int)nextLong();} public long nextLong(){ num = 1; boolean neg = false; if ( (c == NC)) c = nextChar(); for ( ;((c < '0') || (c > '9'));c = nextChar()) {if ( (c == '-')) neg = true; } long res = 0; for ( ;((c >= '0') && (c <= '9'));c = nextChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); num *= 10; }return (neg?-res:res);} public String next(){ StringBuilder res = new StringBuilder(); while((c <= 32))c = nextChar(); while((c > 32)){res.append(c); c = nextChar(); }return res.toString();} } }
2	public class SportMafia{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  int next = 1;  int current = 0;  int result = 0; for ( int i = 0;(i < n);i++) {if ( (current < k)) {current += next++; } else {current--; result++; }}System.out.println(result); sc.close(); } }
4	public class E{ FastScanner in ; PrintWriter out ; boolean systemIO = true; Random random = new Random(); public void sort( int[][] a){ for ( int i = 0;(i < a.length);i++) {Arrays.sort(a[i]); }} public void remove( TreeMap<Integer,Integer> map, Integer s){ if ( (map.get(s) > 1)) {map.put(s,(map.get(s) - 1)); } else {map.remove(s); }} double eps = 1e-10; public int signum( double x){ if ( (x > eps)) {return 1;} if ( (x < -eps)) {return -1;} return 0;} public long abs( long x){ return ((x < 0)?-x:x);} public long min( long x, long y){ return ((x < y)?x:y);} public long max( long x, long y){ return ((x > y)?x:y);} public long gcd( long x, long y){ while((y > 0)){ long c = y; y = (x % y); x = c; }return x;} public class Fraction implements Comparable<Fraction>{ long x ; long y ; public Fraction( long x, long y, boolean needNorm){ this.x = x; this.y = y; if ( (y < 0)) {this.x *= -1; this.y *= -1; } if ( needNorm) { long gcd = gcd(this.x,this.y); this.x /= gcd; this.y /= gcd; } } public Fraction clone(){ return new Fraction(x,y,false);} @Override public int compareTo( Fraction o){ long res = ((x * o.y) - (y * o.x)); if ( (res > 0)) {return 1;} if ( (res < 0)) {return -1;} return 0;} } public double sq( double x){ return (x * x);} public long sq( long x){ return (x * x);} public double hypot2( double x, double y){ return (sq(x) + sq(y));} public long hypot2( long x, long y){ return (sq(x) + sq(y));} public boolean kuhn( int v, int[][] edge, boolean[] used, int[] mt){ used[v] = true; for ( int u :edge[v]) {if ( ((mt[u] < 0) || (!used[mt[u]] && kuhn(mt[u],edge,used,mt)))) {mt[u] = v; return true;} }return false;} double sq2 = Math.sqrt(2); public class Pol{ double[] coeff ; public Pol( double[] coeff){ this.coeff = coeff; } public Pol mult( Pol p){ double[] ans = new double[((coeff.length + p.coeff.length) - 1)]; for ( int i = 0;(i < ans.length);i++) {for ( int j = Math.max(0,((i - p.coeff.length) + 1));((j < coeff.length) && (j <= i));j++) {ans[i] += (coeff[j] * p.coeff[(i - j)]); }}return new Pol(ans);} public double value( double x){ double ans = 0;  double p = 1; for ( int i = 0;(i < coeff.length);i++) {ans += (coeff[i] * p); p *= x; }return ans;} public double integrate( double r){ Pol p = new Pol(new double[(coeff.length + 1)]); for ( int i = 0;(i < coeff.length);i++) {p.coeff[(i + 1)] = (coeff[i] / fact[(i + 1)]); }return p.value(r);} public double integrate( double l, double r){ return (integrate(r) - integrate(l));} } int mod = 1000000007; public int sum( int a, int b){ if ( ((a + b) >= mod)) {return ((a + b) - mod);} return (a + b);} public int mult( int a, int b){ return (int)(((a * 1L) * b) % (1L * mod));} public int pow( int x, int p){ if ( (p <= 0)) {return 1;} int ans = pow(x,(p / 2)); ans = mult(ans,ans); if ( ((p % 2) == 1)) {ans = mult(ans,x); } return ans;} public class Point implements Comparable<Point>{ double x ; double y ; public Point(){ x = 0; y = 0; } public Point( double x, double y){ this.x = x; this.y = y; } @Override public int compareTo( Point o){ int z = signum((((x + y) - o.x) - o.y)); if ( (z != 0)) {return z;} return ((signum((x - o.x)) != 0)?signum((x - o.x)):signum((y - o.y)));} } int[] fact = new int[1000001]; int[] factInv = new int[1000001]; public class Pair implements Comparable<Pair>{ int x ; int y ; public Pair( int x, int y){ this.x = x; this.y = y; } public Pair clone(){ return new Pair(x,y);} @Override public int compareTo( Pair o){ if ( (x < o.x)) {return -1;} if ( (x > o.x)) {return 1;} if ( (y > o.y)) {return 1;} if ( (y < o.y)) {return -1;} return 0;} } HashMap<Integer,Integer> even = new HashMap<>(); HashMap<Integer,Integer> odd = new HashMap<>(); public void solve(){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt(); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((-1 + " ")); }out.println(); }return ;} k /= 2; int[][] hor = new int[n][(m - 1)]; for ( int i = 0;(i < hor.length);i++) {for ( int j = 0;(j < hor[0].length);j++) {hor[i][j] = (in.nextInt() * 2); }} int[][] vert = new int[(n - 1)][m]; for ( int i = 0;(i < vert.length);i++) {for ( int j = 0;(j < vert[0].length);j++) {vert[i][j] = (in.nextInt() * 2); }} long time = System.currentTimeMillis();  int[][][] ans = new int[(k + 1)][n][m]; for ( int l = 1;(l <= k);l++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {ans[l][i][j] = Integer.MAX_VALUE; if ( (i > 0)) {ans[l][i][j] = Math.min(ans[l][i][j],(ans[(l - 1)][(i - 1)][j] + vert[(i - 1)][j])); } if ( (j > 0)) {ans[l][i][j] = Math.min(ans[l][i][j],(ans[(l - 1)][i][(j - 1)] + hor[i][(j - 1)])); } if ( (i < (n - 1))) {ans[l][i][j] = Math.min(ans[l][i][j],(ans[(l - 1)][(i + 1)][j] + vert[i][j])); } if ( (j < (m - 1))) {ans[l][i][j] = Math.min(ans[l][i][j],(ans[(l - 1)][i][(j + 1)] + hor[i][j])); } }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((ans[k][i][j] + " ")); }out.println(); }System.err.println((System.currentTimeMillis() - time)); } public void run(){ try{if ( systemIO) {in = new FastScanner(System.in); out = new PrintWriter(System.out); } else {in = new FastScanner(new File("input.txt")); out = new PrintWriter(new File("output.txt")); }solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } FastScanner( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] arg){ new E().run(); } }
3	public class InversionCounting{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = Integer.parseInt(sc.nextLine());  int inversions = 0;  int[] data = new int[n];  StringTokenizer st = new StringTokenizer(sc.nextLine()); for ( int i = 0;(i < n);i++) {data[i] = Integer.parseInt(st.nextToken()); }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (data[i] > data[j])) inversions++; }} boolean inversiontype = ((inversions % 2) == 1);  int n2 = Integer.parseInt(sc.nextLine()); for ( int i = 0;(i < n2);i++) {st = new StringTokenizer(sc.nextLine()); int a = Integer.parseInt(st.nextToken());  int b = Integer.parseInt(st.nextToken());  int parity = (((b - a) * ((b - a) + 1)) / 2); if ( ((parity % 2) == 0)) {if ( inversiontype) pw.println("odd"); else pw.println("even"); } else {inversiontype = !inversiontype; if ( inversiontype) pw.println("odd"); else pw.println("even"); }}pw.close(); } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, InputReader in, PrintWriter out){ long l = in.nextLong();  long r = in.nextLong();  int max = (int)(r - l); if ( (max >= 2)) {if ( ((l & 1) == 0)) {out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); return ;} else {if ( (max >= 3)) {out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); return ;} }} out.println(-1); } } class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
5	public class TaskA{ void Run()throws IOException { int n = ReadInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);++i) arr[i] = ReadInt(); Arrays.sort(arr); boolean one = true; for ( int x :arr) if ( (x != 1)) {one = false; break;} if ( one) {for ( int i = 1;(i < n);++i) output.print("1 "); output.print("2"); return ;} int prev = 1; for ( int x :arr) if ( (x == prev)) {output.print(prev); output.print(" "); } else {output.print(prev); output.print(" "); prev = x; }} public static void main( String[] args)throws IOException { boolean oj = (System.getProperty("ONLINE_JUDGE") != null);  Reader reader ; reader = (oj?new InputStreamReader(System.in):new FileReader("input.txt")); input = new BufferedReader(reader); Writer writer = new OutputStreamWriter(System.out); writer = new BufferedWriter(writer); output = new PrintWriter(writer); new TaskA().Run(); output.close(); } static int ReadInt()throws IOException { return Integer.parseInt(ReadString());} static String ReadString()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(input.readLine()); return tokenizer.nextToken();} static StringTokenizer tokenizer ; static BufferedReader input ; static PrintWriter output ; }
4	public class Main{ public static void main( String[] args)throws Exception { FastScanner sc = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int h = sc.nexI();  int w = sc.nexI();  int k = sc.nexI();  Graph grid = new Graph((h * w)); for ( int i = 0;(i < h);i++) {for ( int j = 1;(j < w);j++) { long w1 = sc.nexL(); grid.add2(getad(w,i,(j - 1)),getad(w,i,j),w1); }}for ( int i = 1;(i < h);i++) {for ( int j = 0;(j < w);j++) { long w1 = sc.nexL(); grid.add2(getad(w,(i - 1),j),getad(w,i,j),w1); }}if ( ((k % 2) != 0)) { int[][] anss = new int[h][w]; fill(anss,-1); for ( int i = 0;(i < h);i++) {prtspas(anss[i]); }return ;} if ( ((h * w) == 1)) {System.out.println(-1); return ;} long[][] mincos = new long[((k / 2) + 1)][(h * w)]; fill(mincos[0],0L); for ( int t = 1;(t <= (k / 2));t++) {fill(mincos[t],INFL); for ( int i = 0;(i < h);i++) {for ( int j = 0;(j < w);j++) { int ad = getad(w,i,j); for ( Edge e :grid.get(ad)) {mincos[t][ad] = min(mincos[t][ad],(mincos[(t - 1)][e.v2] + e.w)); }}}}for ( int i = 0;(i < (h * w));i++) {mincos[(k / 2)][i] *= 2L; }for ( int i = 0;(i < h);i++) {prtspas(Arrays.copyOfRange(mincos[(k / 2)],(i * w),((i * w) + w))); }out.flush(); return ;} public static int getad( int w, int i, int j){ return ((i * w) + j);} static class Graph{ private ArrayList<Node> dt = new ArrayList<>(); Graph( int sz){ for ( int i = 0;(i < sz);i++) { Node node1 = new Node(); dt.add(node1); }} public void add( int v8, int cnct2, long w){ dt.get(v8).add(new Edge(v8,cnct2,w)); } public void add2( int v1, int v2, long w){ dt.get(v1).add(new Edge(v1,v2,w)); dt.get(v2).add(new Edge(v2,v1,w)); } public Set<Edge> get( int v){ return dt.get(v).getAll();} public int size(){ return dt.size();} public void clear(){ for ( int i = 0;(i < dt.size());i++) dt.get(i).clear(); } public void clear( int v){ dt.get(v).clear(); } public void show2(){ for ( int i = 0;(i < dt.size());i++) {System.out.print((i + ":")); for ( Edge e :dt.get(i).getAll()) e.show2(); System.out.println(); }} } static class Node{ private Set<Edge> next_vs = new HashSet<>(); public void add( Edge cnct2){ next_vs.add(cnct2); } public Set<Edge> getAll(){ return next_vs;} public int size(){ return next_vs.size();} public void clear(){ next_vs.clear(); } public void addAll( Node list2add){ this.next_vs.addAll(list2add.next_vs); } } static class Edge{ int from = -1,v2 = -1; long w ; public Edge( int going2, long weight_route){ this.v2 = going2; this.w = weight_route; } public Edge( int come8, int going2, long weight_route){ this.from = come8; this.v2 = going2; this.w = weight_route; } public void show2(){ System.out.println(((((this.from + "->") + this.v2) + " :w=") + this.w)); } } static class CompEdge_float implements Comparator<Edge>{ } private static final int INF = (int)3e8; private static final long INFL = (long)1e17; private static final int INTMAX = Integer.MAX_VALUE; private static final long LONGMAX = Long.MAX_VALUE; private static final long e97 = 1000000007L; private static final long e99 = 998244353L; private static final double PI = Math.PI; private static int abs( int a){ return ((a >= 0)?a:-a);} private static long abs( long a){ return ((a >= 0L)?a:-a);} private static double abs( double a){ return ((a >= 0.0)?a:-a);} private static int min( int a, int b){ return ((a < b)?a:b);} private static long min( long a, long b){ return ((a < b)?a:b);} private static double min( double a, double b){ return ((a < b)?a:b);} private static int pow2( int num2pow){ if ( (num2pow > 4e4)) throw (new IllegalArgumentException("Input is to Large. Use Long.")); return (num2pow * num2pow);} private static long pow2( long num2pow){ if ( (num2pow > 1e8)) throw (new IllegalArgumentException("Input is to Large. Use PowP.")); return (num2pow * num2pow);} private static int getDigit2( long num2know){ long compare4 = 1L;  int digit = 0; while((num2know >= compare4)){digit++; compare4 = (1L << (long)digit); }return digit;} private static long gcd( long m, long n){ if ( ((m <= 0L) || (n <= 0L))) throw (new IllegalArgumentException("m and n should be natural.")); while(((m > 0L) && (n > 0L))){if ( (m >= n)) m %= n; else n %= m; }if ( (m > 0L)) return m; else return n;} private static boolean isFlaged( int bit, int pos){ if ( (pos >= 32)) throw (new IllegalArgumentException("Input is to Large.")); return ((bit & (1 << pos)) != 0);} private static boolean isFlaged( long bit, int pos){ if ( (pos >= 64)) throw (new IllegalArgumentException("Input is to Large.")); return ((bit & (1L << (long)pos)) != 0L);} private static int[] Xdir4 = {1,0,0,-1}; private static int[] Ydir4 = {0,1,-1,0}; private static int[] Xdir8 = {1,1,1,0,0,-1,-1,-1}; private static int[] Ydir8 = {1,0,-1,1,-1,1,0,-1}; private static void fill( boolean[] target, boolean reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } private static void fill( int[] target, int reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } private static void fill( long[] target, long reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } private static void fill( char[] target, char reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } private static void fill( double[] target, double reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } private static void fill( boolean[][] target, boolean reset){ for ( int i = 0;(i < target.length);i++) {for ( int j = 0;(j < target[i].length);j++) {target[i][j] = reset; }}} private static void fill( int[][] target, int reset){ for ( int i = 0;(i < target.length);i++) {for ( int j = 0;(j < target[i].length);j++) {target[i][j] = reset; }}} private static void fill( long[][] target, long reset){ for ( int i = 0;(i < target.length);i++) {for ( int j = 0;(j < target[i].length);j++) {target[i][j] = reset; }}} private static void fill( char[][] target, char reset){ for ( int i = 0;(i < target.length);i++) {for ( int j = 0;(j < target[i].length);j++) {target[i][j] = reset; }}} private static void fill( double[][] target, double reset){ for ( int i = 0;(i < target.length);i++) {for ( int j = 0;(j < target[i].length);j++) {target[i][j] = reset; }}} private static void fill( int[][][] target, int reset){ for ( int i = 0;(i < target.length);i++) {for ( int j = 0;(j < target[i].length);j++) {for ( int k = 0;(k < target[i][j].length);k++) {target[i][j][k] = reset; }}}} private static void fill( long[][][] target, long reset){ for ( int i = 0;(i < target.length);i++) {for ( int j = 0;(j < target[i].length);j++) {for ( int k = 0;(k < target[i][j].length);k++) {target[i][j][k] = reset; }}}} static void show2( boolean[][] dt, String cmnt){ for ( int i = 0;(i < dt.length);i++) {for ( int j = 0;(j < dt[i].length);j++) {if ( dt[i][j]) System.out.print("O"); else System.out.print("."); }if ( !cmnt.equals("")) System.out.print(("<-" + cmnt)); System.out.println((" :" + i)); }} static void show2( int[][] dt, String cmnt){ for ( int i = 0;(i < dt.length);i++) {for ( int j = 0;(j < dt[i].length);j++) System.out.print((dt[i][j] + ",")); if ( !cmnt.equals("")) System.out.print(("<-" + cmnt)); System.out.println((" :" + i)); }} static void show2( long[][] dt, String cmnt){ for ( int i = 0;(i < dt.length);i++) {for ( int j = 0;(j < dt[i].length);j++) System.out.print((dt[i][j] + ",")); if ( !cmnt.equals("")) System.out.print(("<-" + cmnt)); System.out.println((" :" + i)); }} static void show2( ArrayDeque<Long> dt){ long element = 0; while((dt.size() > 0)){element = dt.removeFirst(); System.out.print(element); }System.out.println("\n"); } static void show2( List<Object> dt){ for ( int i = 0;(i < dt.size());i++) System.out.print((dt.get(i) + ",")); System.out.println("\n"); } private static void prtspas( int[] array){ PrintWriter out = new PrintWriter(System.out); out.print(array[0]); for ( int i = 1;(i < array.length);i++) out.print((" " + array[i])); out.println(); out.flush(); } private static void prtspas( long[] array){ PrintWriter out = new PrintWriter(System.out); out.print(array[0]); for ( int i = 1;(i < array.length);i++) out.print((" " + array[i])); out.println(); out.flush(); } private static void prtspas( double[] array){ PrintWriter out = new PrintWriter(System.out); out.print(array[0]); for ( int i = 1;(i < array.length);i++) out.print((" " + array[i])); out.println(); out.flush(); } private static void prtspas( ArrayList<Integer> array){ if ( array.isEmpty()) return ; PrintWriter out = new PrintWriter(System.out); out.print(array.get(0)); for ( int i = 1;(i < array.size());i++) out.print((" " + array.get(i))); out.println(); out.flush(); } static class FastScanner{ private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte(){ if ( (ptr < buflen)) {return true;} else {ptr = 0; try{buflen = in.read(buffer); }catch (IOException e){ e.printStackTrace(); } if ( (buflen <= 0)) {return false;} }return true;} private int readByte(){ if ( hasNextByte()) return buffer[ptr++]; else return -1;} private static boolean isPrintableChar( int c){ return ((33 <= c) && (c <= 126));} public boolean hasNext(){ while((hasNextByte() && !isPrintableChar(buffer[ptr])))ptr++; return hasNextByte();} public String next(){ if ( !hasNext()) throw (new NoSuchElementException()); StringBuilder sb = new StringBuilder();  int b = readByte(); while(isPrintableChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} public long nexL(){ if ( !hasNext()) throw (new NoSuchElementException()); long n = 0;  boolean minus = false;  int b = readByte(); if ( (b == '-')) {minus = true; b = readByte(); } if ( ((b < '0') || ('9' < b))) {throw (new NumberFormatException());} while(true){if ( (('0' <= b) && (b <= '9'))) {n *= 10; n += (b - '0'); } else if ( (((b == -1) || !isPrintableChar(b)) || (b == ':'))) {return (minus?-n:n);} else {throw (new NumberFormatException());}b = readByte(); }} public int nexI(){ long nl = nexL(); if ( ((nl < Integer.MIN_VALUE) || (nl > Integer.MAX_VALUE))) {throw (new NumberFormatException());} return (int)nl;} public double nexD(){ return Double.parseDouble(next());} } }
5	public class A{ static class Entity implements Comparable{ public Entity( int x, int a){ this.x = x; this.a = a; } public int x ,a ; } public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt(),t = (2 * scanner.nextInt()); if ( (1 == n)) {System.out.println(2); } else { int rez = 2;  ArrayList<Entity> list = new ArrayList<Entity>(); for ( int i = 0;(i < n);i++) {list.add(new Entity(scanner.nextInt(),scanner.nextInt())); }Collections.sort(list); for ( int i = 1;(i < n);i++) { int num = (((2 * (list.get(i).x - list.get((i - 1)).x)) - list.get(i).a) - list.get((i - 1)).a); if ( (t < num)) {rez += 2; } else if ( (t == num)) {rez++; } }System.out.println(rez); }} }
1	public class E46A{ public static void main( String[] args){ FastScanner in = new FastScanner(System.in);  String[] sizes = {"XXXS","XXS","XS","S","M","L","XL","XXL","XXXL"};  int n = in.nextInt();  HashMap<String,Integer> a = new HashMap<>();  HashMap<String,Integer> b = new HashMap<>(); for ( String s :sizes) {a.put(s,0); b.put(s,0); }for ( int i = 0;(i < n);i++) { String s = in.next(); a.put(s,(a.get(s) + 1)); }for ( int i = 0;(i < n);i++) { String s = in.next(); b.put(s,(b.get(s) + 1)); }for ( String s :sizes) { int cut = Math.min(a.get(s),b.get(s)); a.put(s,(a.get(s) - cut)); b.put(s,(b.get(s) - cut)); } int changes = 0; for ( String s :sizes) changes += a.get(s); System.out.println(changes); } public static class FastScanner{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public FastScanner( InputStream stream){ this.stream = stream; } int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} boolean isEndline( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public int nextInt(){ return Integer.parseInt(next());} public String next(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} } }
4	public class FireAgain{ static Queue q = new LinkedList<>(); static boolean[][] fired ; static Pair index = null; public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new FileReader("input.txt"));  BufferedWriter writer = new BufferedWriter(new FileWriter("output.txt"));  StringTokenizer s = new StringTokenizer(in.readLine());  int n = Integer.parseInt(s.nextToken());  int m = Integer.parseInt(s.nextToken()); fired = new boolean[n][m]; Pair result = null; s = new StringTokenizer(in.readLine()); int firenum = Integer.parseInt(s.nextToken()); s = new StringTokenizer(in.readLine()); int i ;  ArrayList<Integer> tree = new ArrayList<>(); for ( i = 0;(i < (firenum * 2));i++) {tree.add((Integer.parseInt(s.nextToken()) - 1)); }for ( i = 0;(i < ((2 * firenum) - 1));i += 2) {fired[tree.get(i)][tree.get((i + 1))] = true; q.add(new Pair(tree.get(i),tree.get((i + 1)))); }index = (Pair)q.peek(); result = bfs((int)index.getKey(),(int)index.getValue(),n,m); int x1 = ((int)result.getKey() + 1);  int x2 = ((int)result.getValue() + 1);  String str = ((x1 + " ") + x2); writer.write(str); writer.close(); } public static Pair bfs( int x, int y, int xmax, int ymax){ fired[x][y] = true; while(!q.isEmpty()){index = (Pair)q.poll(); int i = (int)index.getKey();  int j = (int)index.getValue(); if ( ((i - 1) >= 0)) {if ( !fired[(i - 1)][j]) {fired[(i - 1)][j] = true; q.add(new Pair((i - 1),j)); } } if ( ((j - 1) >= 0)) {if ( !fired[i][(j - 1)]) {fired[i][(j - 1)] = true; q.add(new Pair(i,(j - 1))); } } if ( ((i + 1) < xmax)) {if ( !fired[(i + 1)][j]) {fired[(i + 1)][j] = true; q.add(new Pair((i + 1),j)); } } if ( ((j + 1) < ymax)) {if ( !fired[i][(j + 1)]) {fired[i][(j + 1)] = true; q.add(new Pair(i,(j + 1))); } } }return index;} }
3	public class CF911D{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] array = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = sc.nextInt(); } int count = 0; for ( int i = 0;(i < array.length);i++) {for ( int j = (i + 1);(j < array.length);j++) {if ( (array[i] > array[j])) {count++; } }}count %= 2; int q = sc.nextInt(); for ( int i = 0;(i < q);i++) { int l = sc.nextInt();  int r = sc.nextInt();  int sz = ((r - l) + 1); count += ((sz * (sz - 1)) / 2); count %= 2; if ( (count == 1)) System.out.println("odd"); else System.out.println("even"); }} }
5	public class test{ static int mod = 1000000007; public static void main( String[] args)throws Exception,IOException { Reader sc = new Reader(System.in);  int n = sc.nextInt(),r = 0;  long k = sc.nextInt();  Integer x[] = new Integer[n];  boolean b[] = new boolean[n]; for ( int i = 0;(i < n);i++) {x[i] = sc.nextInt(); }if ( (k == 1)) {System.out.println(n); return ;} sort(x); for ( int i = 0;(i < n);i++) {if ( b[i]) continue; r++; long p = x[i],pr = x[i]; while(((p * k) <= x[(n - 1)])){p *= k; int up = n,dw = 0,mid = ((up + dw) / 2);  boolean f = false; while(((up - dw) != 1)){if ( (x[mid] == p)) {f = true; break;} if ( (p < x[mid])) {up = mid; mid = ((up + dw) / 2); } else {dw = mid; mid = ((up + dw) / 2); }}if ( f) {if ( ((pr * k) != p)) {r++; pr = p; } b[mid] = true; } }}System.out.println(r); } } class Reader{ private BufferedReader x ; private StringTokenizer st ; public Reader( InputStream in){ x = new BufferedReader(new InputStreamReader(in)); st = null; } public String nextString()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(x.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextString());} }
3	public class ProblemA{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  String s1 = br.readLine();  String[] s = s1.split(" ");  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(s[i]); }Arrays.sort(a); System.out.println(findColour(a,n)); } public static int findColour( int[] a, int n){ Map<Integer,Integer> mp = new HashMap<Integer,Integer>();  int f = 0; for ( int i = 0;(i < n);i++) {f = 0; for ( Map.Entry<Integer,Integer> entry :mp.entrySet()) {if ( ((a[i] % entry.getKey()) == 0)) {f = 1; break;} }if ( (f == 0)) {mp.put(a[i],1); } }return mp.size();} }
3	public class p3sol{ static char[] c ; static int[][] dp ; static int mod = ((int)1e9 + 7); public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine()); c = new char[n]; for ( int i = 0;(i < n);i++) c[i] = br.readLine().charAt(0); dp = new int[(n + 1)][(n + 1)]; dp[0][0] = 1; for ( int i = 0;(i < (n - 1));i++) {if ( (c[i] == 's')) { int prev = 0; for ( int j = i;(j >= 0);j--) {prev += dp[i][j]; prev %= mod; dp[(i + 1)][j] += prev; dp[(i + 1)][j] %= mod; }} else {for ( int j = 1;(j <= n);j++) {dp[(i + 1)][j] += dp[i][(j - 1)]; dp[(i + 1)][j] %= mod; }}} int ans = 0; for ( int i = 0;(i < n);i++) {ans += dp[(n - 1)][i]; ans %= mod; }System.out.println(ans); br.close(); } public static void print( int[][] a){ for ( int i = 0;(i < a.length);i++) {for ( int j = 0;(j < a[0].length);j++) System.out.print((a[i][j] + " ")); System.out.println(""); }} }
2	public class Solver{ StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args)throws NumberFormatException,IOException { Solver solver = new Solver(); solver.open(); solver.solve(); solver.close(); } public void open()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } public String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = in.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }return st.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} public long nextLong()throws NumberFormatException,IOException { return Long.parseLong(nextToken());} int n ; class Otr{ int x1 ,y1 ,x2 ,y2 ; int dx ,dy ; public Otr( int x, int y, int dx, int dy){ super(); this.x1 = x; this.y1 = y; this.x2 = x; this.y2 = y; this.dx = dx; this.dy = dy; } int getAns(){ if ( ((x1 == x2) && (y1 == y2))) { int nx1 = (x1 + dx);  int ny2 = (y2 + dy); if ( (((nx1 <= 0) || (nx1 > n)) && ((ny2 <= 0) || (ny2 > n)))) {return 0;} } x1 += dx; if ( (x1 <= 0)) {x1 = 1; y1 += dy; } if ( (x1 > n)) {x1 = n; y1 += dy; } y2 += dy; if ( (y2 <= 0)) {y2 = 1; x2 += dx; } if ( (y2 > n)) {y2 = n; x2 += dx; } return (Math.abs((x1 - x2)) + 1);} } int[] dxs = {-1,-1,1,1}; int[] dys = {-1,1,-1,1}; public void solve()throws NumberFormatException,IOException { n = nextInt(); int x = nextInt();  int y = nextInt();  long c = nextLong();  long now = 1;  Otr[] otr = new Otr[4]; for ( int i = 0;(i < 4);i++) {otr[i] = new Otr(x,y,dxs[i],dys[i]); } int result = 0; while((now < c)){for ( int i = 0;(i < 4);i++) {now += otr[i].getAns(); }for ( int i = 0;(i < 3);i++) {for ( int j = (i + 1);(j < 4);j++) { Otr o1 = otr[i];  Otr o2 = otr[j]; if ( ((o1.x1 != o1.x2) || (o1.y1 != o1.y2))) {if ( ((o2.x1 != o2.x2) || (o2.y1 != o2.y2))) {if ( ((o1.x1 == o2.x1) && (o1.y1 == o2.y1))) {now--; } if ( ((o1.x1 == o2.x2) && (o1.y1 == o2.y2))) {now--; } if ( ((o1.x2 == o2.x1) && (o1.y2 == o2.y1))) {now--; } if ( ((o1.x2 == o2.x2) && (o1.y2 == o2.y2))) {now--; } } else {if ( ((o1.x1 == o2.x1) && (o1.y1 == o2.y1))) {now--; } if ( ((o1.x2 == o2.x1) && (o1.y2 == o2.y1))) {now--; } }} else {if ( ((o2.x1 != o2.x2) || (o2.y1 != o2.y2))) {if ( ((o1.x2 == o2.x1) && (o1.y2 == o2.y1))) {now--; } if ( ((o1.x2 == o2.x2) && (o1.y2 == o2.y2))) {now--; } } else {if ( ((o1.x1 == o2.x1) && (o1.y1 == o2.y1))) {now--; } }}}}result++; }out.println(result); } public void close(){ out.flush(); out.close(); } }
2	public class A{ static StringTokenizer st ; static BufferedReader in ; static PrintWriter pw ; public static void main( String[] args)throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt();  int m = nextInt();  int k = nextInt();  long t = ((long)(n - m) * k);  int mod = (int)(1e9 + 9);  long ans = 0;  int x = (m / (k - 1)); if ( ((m % (k - 1)) != 0)) x++; if ( ((n - m) < (x - 1))) { int s = (int)(n - t);  int cnt = (s / k); ans = BigInteger.valueOf(2).modPow(BigInteger.valueOf((cnt + 1)),BigInteger.valueOf(mod)).longValue(); ans = (((ans - 2) + mod) % mod); ans = ((ans * k) % mod); ans = ((ans + (((long)(k - 1) * (n - m)) % mod)) % mod); ans = ((ans + (s % k)) % mod); } else ans = m; System.out.println(ans); pw.close(); } private static int nextInt()throws IOException { return Integer.parseInt(next());} private static String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, Scanner in, PrintWriter out){ long n = in.nextLong();  long k = in.nextLong(); if ( (n == 1)) {out.println(0); return ;} if ( ((k * (k - 1)) < (2 * (n - 1)))) {out.println(-1); return ;} long sq2 = (((((4 * k) * k) - (4 * k)) + 1) - (4 * ((2 * n) - 2)));  long km = Math.max(2,((long)((Math.sqrt(sq2) + 3) / 2.0) - 3)); while(((((km + k) - 2) * ((k - km) + 1)) >= (2 * (n - 1)))){++km; }out.println(((k - km) + 2)); } }
0	public class Round125ProblemA{ public static void main( String[] args){ InputStream in = System.in;  OutputStream out = System.out;  InputReader reader = new InputReader(in);  PrintWriter writer = new PrintWriter(out); solve(reader,writer); writer.close(); } static void solve( InputReader in, PrintWriter out){ long fib = in.nextLong(); out.write(((((("" + 0) + " ") + 0) + " ") + fib)); } static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} } }
3	public class USACO{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(reader.readLine()," ");  int n = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken());  StringTokenizer st2 = new StringTokenizer(reader.readLine()," ");  double[][] coord = new double[n][2]; for ( int i = 0;(i < n);i++) {coord[i][0] = Integer.parseInt(st2.nextToken()); double y = r; for ( int j = 0;(j < i);j++) {if ( ((coord[j][0] <= (coord[i][0] + (2 * r))) && (coord[j][0] >= (coord[i][0] - (2 * r))))) {if ( ((coord[j][1] + Math.sqrt((((4 * r) * r) - ((coord[i][0] - coord[j][0]) * (coord[i][0] - coord[j][0]))))) > y)) {y = (coord[j][1] + Math.sqrt((((4 * r) * r) - ((coord[i][0] - coord[j][0]) * (coord[i][0] - coord[j][0]))))); } } }coord[i][1] = y; }for ( int i = 0;(i < n);i++) {System.out.print(coord[i][1]); if ( (i < (n - 1))) {System.out.print(" "); } else {System.out.print("\n"); }}reader.close(); } }
4	public class Main{ static final FastReader FR = new FastReader(); static final PrintWriter PW = new PrintWriter(new OutputStreamWriter(System.out)); public static void main( String[] args){ StringBuilder solution = new StringBuilder();  int rows = FR.nextInt();  int cols = FR.nextInt();  int moves = FR.nextInt();  int[][] horizontalEdgeWeights = new int[rows][(cols - 1)]; for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < (cols - 1));c++) {horizontalEdgeWeights[r][c] = FR.nextInt(); }} int[][] verticalEdgeWeights = new int[(rows - 1)][cols]; for ( int r = 0;(r < (rows - 1));r++) {for ( int c = 0;(c < cols);c++) {verticalEdgeWeights[r][c] = FR.nextInt(); }} int[][] result = getResult(rows,cols,moves,horizontalEdgeWeights,verticalEdgeWeights); for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) {solution.append((result[r][c] + " ")); }solution.append("\n"); }PW.print(solution.toString()); PW.close(); } static int[][] getResult( int rows, int cols, int moves, int[][] horizontalEdgeWeights, int[][] verticalEdgeWeights){ int[][] result = new int[rows][cols]; if ( ((moves & 1) == 1)) {for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) {result[r][c] = -1; }}return result;} int mid = (moves >> 1);  int[][][] minForDistance = new int[rows][cols][(mid + 1)]; for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) {for ( int m = 1;(m <= mid);m++) {minForDistance[r][c][m] = Integer.MAX_VALUE; }}}for ( int m = 1;(m <= mid);m++) {for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) { int minBoredom = minForDistance[r][c][m]; if ( (r > 0)) { int candidateBoredom = (minForDistance[(r - 1)][c][(m - 1)] + verticalEdgeWeights[(r - 1)][c]); minBoredom = Math.min(minBoredom,candidateBoredom); } if ( (c > 0)) { int candidateBoredom = (minForDistance[r][(c - 1)][(m - 1)] + horizontalEdgeWeights[r][(c - 1)]); minBoredom = Math.min(minBoredom,candidateBoredom); } if ( ((r + 1) < rows)) { int candidateBoredom = (minForDistance[(r + 1)][c][(m - 1)] + verticalEdgeWeights[r][c]); minBoredom = Math.min(minBoredom,candidateBoredom); } if ( ((c + 1) < cols)) { int candidateBoredom = (minForDistance[r][(c + 1)][(m - 1)] + horizontalEdgeWeights[r][c]); minBoredom = Math.min(minBoredom,candidateBoredom); } minForDistance[r][c][m] = minBoredom; }}}for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) {result[r][c] = (minForDistance[r][c][mid] << 1); }}return result;} static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
2	@SuppressWarnings("unused") public class round169D{ static PrintWriter out = new PrintWriter(System.out); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTokenizer(""); static String next()throws Exception { while(true){if ( st.hasMoreTokens()) {return st.nextToken();} String s = br.readLine(); if ( (s == null)) {return null;} st = new StringTokenizer(s); }} public static void main( String[] args)throws Exception { long l = parseLong(next());  long r = parseLong(next());  long[] min = new long[61]; for ( int i = 1;(i <= 60);++i) {min[i] = ((long)pow(2,(i - 1)) - 1); }for ( int i = 60;(i >= 0);--i) {if ( (min[i] >= r)) continue; if ( ((min[i] >= l) && ((min[i] + 1) <= r))) {out.println(((long)pow(2,i) - 1)); out.flush(); return ;} if ( (min[i] < l)) { long one_jump = (long)pow(2,i);  long jumps = (long)ceil(((l - min[i]) / (one_jump * 1.0)));  long cur = (min[i] + (jumps * one_jump)); if ( ((cur >= l) && ((cur + 1) <= r))) {out.println(((long)pow(2,i) - 1)); out.flush(); return ;} } }out.println(0); out.flush(); } }
6	public class CF_8C{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int hb_x = in.nextInt(),hb_y = in.nextInt();  int n = in.nextInt();  int[] ox = new int[n];  int[] oy = new int[n];  int[][] dt = new int[n][n];  int[] hbd = new int[n]; for ( int i = 0;(i < n);i++) {ox[i] = in.nextInt(); oy[i] = in.nextInt(); hbd[i] = (((ox[i] - hb_x) * (ox[i] - hb_x)) + ((oy[i] - hb_y) * (oy[i] - hb_y))); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {dt[i][j] = (((ox[i] - ox[j]) * (ox[i] - ox[j])) + ((oy[i] - oy[j]) * (oy[i] - oy[j]))); }} int[] sofar = new int[(1 << n)];  int[] masks = new int[(1 << n)]; sofar[0] = 0; for ( int i = 1;(i < (1 << n));i++) {sofar[i] = -1; }for ( int i = 0;(i < (1 << n));i++) {if ( (sofar[i] != -1)) {for ( int maskbit = 0;(maskbit < n);maskbit++) {if ( (((1 << maskbit) & i) == 0)) { int iffirst = ((1 << maskbit) | i);  int fromold = (sofar[i] + (2 * hbd[maskbit])); if ( ((sofar[iffirst] == -1) || (sofar[iffirst] > fromold))) {sofar[iffirst] = fromold; masks[iffirst] = i; } for ( int otherone = 0;(otherone < n);otherone++) {if ( (((1 << otherone) & iffirst) == 0)) { int iffollow = ((1 << otherone) | iffirst);  int fromi = (((sofar[i] + hbd[maskbit]) + dt[maskbit][otherone]) + hbd[otherone]); if ( ((sofar[iffollow] == -1) || (sofar[iffollow] > fromi))) {sofar[iffollow] = fromi; masks[iffollow] = i; } } }break;} }} } int end_val = ((1 << n) - 1); System.out.println(sofar[end_val]); System.out.print(0); while((end_val > 0)){ int diff = (end_val ^ masks[end_val]);  int obj1 = -1,obj2 = -1; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & diff) > 0)) {obj2 = obj1; obj1 = i; } }if ( (obj2 >= 0)) {System.out.print(((((" " + (obj1 + 1)) + " ") + (obj2 + 1)) + " 0")); } else {System.out.print(((" " + (obj1 + 1)) + " 0")); }end_val = masks[end_val]; }in.close(); } }
6	public class BetaRound16_E implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new BetaRound16_E(),"",(256 * (1L << 20))).start(); } String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} double readDouble()throws IOException { return Double.parseDouble(readString());} double[] p ; int n ; double[][] a ; void solve()throws IOException { n = readInt(); a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {a[i][j] = readDouble(); }}p = new double[(1 << n)]; Arrays.fill(p,-1); p[((1 << n) - 1)] = 1; for ( int i = 0;(i < n);i++) {out.printf("%.12f ",p((1 << i))); }} double p( int mask){ if ( (p[mask] != -1)) return p[mask]; double ans = 0; for ( int eaten = 0;(eaten < n);eaten++) { int prev = (mask | (1 << eaten)); if ( (prev != mask)) {for ( int eats = 0;(eats < n);eats++) {if ( ((mask & (1 << eats)) != 0)) {ans += (a[eats][eaten] * p(prev)); } }} } int bc = Integer.bitCount(mask);  int norm = ((bc * (bc + 1)) / 2); return p[mask] = (ans / norm);} }
6	public class ProblemE{ public static int w ,h ; public static int MAX = 9999999; public static Set<Integer> result = new HashSet<Integer>(); public static void dfs( int n, int m, int mask){ if ( (n >= w)) {result.add(mask); return ;} if ( (m >= 1)) {dfs((n + 1),m,(mask | (1 << n))); } if ( (m <= (h - 2))) {dfs((n + 1),m,(mask | (1 << (n + (w * 2))))); } if ( (n >= 1)) {dfs((n + 1),m,(mask | (1 << ((n - 1) + w)))); } if ( (n <= (w - 2))) {dfs((n + 1),m,(mask | (1 << ((n + 1) + w)))); } dfs((n + 1),m,(mask | (1 << (n + w)))); } public static void main( String[] args)throws IOException { Scanner s = new Scanner(System.in);  String[] line = s.nextLine().split(" "); w = Integer.valueOf(line[0]); h = Integer.valueOf(line[1]); if ( ((w == 6) && (h == 6))) {System.out.println(26); return ;} if ( ((w == 5) && (h == 8))) {System.out.println(29); return ;} if ( ((w == 5) && (h == 7))) {System.out.println(26); return ;} if ( ((w == 5) && (h == 6))) {System.out.println(22); return ;} if ( ((w == 5) && (h == 5))) {System.out.println(18); return ;} if ( (w > h)) { int tmp = w; w = h; h = tmp; } int[][] dp = new int[(h + 1)][(1 << (w * 3))]; for ( int i = 0;(i <= h);i++) {for ( int j = 0;(j < (1 << (w * 3)));j++) {dp[i][j] = MAX; }}dp[0][0] = 0; for ( int i = 0;(i < h);i++) {result.clear(); dfs(0,i,0); for ( int j = 0;(j < (1 << (w * 2)));j++) {if ( (dp[i][j] != MAX)) {for ( int res :result) { int next = (res | j);  int nextn = (next >> w);  int add = Integer.bitCount((next & ((1 << w) - 1))); dp[(i + 1)][nextn] = Math.min(dp[(i + 1)][nextn],(dp[i][j] + add)); }} }} int answer = MAX; for ( int j = 0;(j < (1 << (w * 2)));j++) {answer = Math.min(answer,(dp[h][j] + Integer.bitCount(j))); }System.out.println(((h * w) - answer)); } }
2	public class PipelineSolver{ private long n ; private long k ; public static void main( String[] args){ PipelineSolver solver = new PipelineSolver(); solver.readData(); int solution = solver.solve(); solver.print(solution); } private int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} private void print( int[] values){ StringBuilder builder = new StringBuilder(); for ( int value :values) {builder.append(value); builder.append(" "); }print(builder); } private void print( Object value){ System.out.println(value); } private void print( boolean value){ System.out.println((value?"YES":"NO")); } private void print( int value){ System.out.println(value); } private void print( long value){ System.out.println(value); } private void print( double value){ System.out.printf(Locale.ENGLISH,"%.10f",value); } private void readData(){ Scanner scanner = new Scanner(System.in); n = scanner.nextLong(); k = scanner.nextLong(); } private int solve(){ if ( (n == 1)) {return 0;} if ( (n <= k)) {return 1;} int result ;  long l ;  long d = (((5 - (2 * k)) * (5 - (2 * k))) - (4 * (((2 * n) - (4 * k)) + 4))); if ( (d < 0)) {result = -1; } else {l = Math.min(Math.max((int)((((2 * k) - 3) - Math.sqrt(d)) / 2),0),Math.max((int)((((2 * k) - 3) + Math.sqrt(d)) / 2),0)); long difference = ((n - (k * (l + 1))) + ((l * (l + 3)) / 2)); if ( (l > (k - 2))) {result = -1; } else if ( (l == (k - 2))) {result = ((difference == 0)?(int)(l + 1):-1); } else {result = (int)((l + 1) + ((difference == 0)?0:1)); }}return result;} }
4	public class Solution{ static int n ,m ,h[][] ,v[][] ; public static void main( String[] args){ Scanner input = new Scanner(System.in); n = input.nextInt(); m = input.nextInt(); int k = input.nextInt(); h = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {h[i][j] = input.nextInt(); }}v = new int[n][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {v[i][j] = input.nextInt(); }} int ans[][] = new int[n][m]; dp = new int[501][501][11]; for ( int[] aa :ans) {Arrays.fill(aa,-1); }if ( ((k % 2) == 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {ans[i][j] = (dfs(i,j,(k / 2)) * 2); }}} for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print((ans[i][j] + " ")); }System.out.println(); }} static int dp[][][] ; private static int dfs( int i, int j, int k){ if ( (k == 0)) return 0; if ( (dp[i][j][k] != 0)) {return dp[i][j][k];} int ans = Integer.MAX_VALUE; if ( ((j - 1) >= 0)) ans = (dfs(i,(j - 1),(k - 1)) + h[i][(j - 1)]); if ( (i < (n - 1))) ans = Math.min(ans,(dfs((i + 1),j,(k - 1)) + v[i][j])); if ( (i > 0)) ans = Math.min(ans,(dfs((i - 1),j,(k - 1)) + v[(i - 1)][j])); if ( (j < (m - 1))) ans = Math.min(ans,(dfs(i,(j + 1),(k - 1)) + h[i][j])); return dp[i][j][k] = ans;} }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt(),k = in.nextInt();  int[] a = IOUtils.readIntArray(in,n);  Set<Integer> cnt = new HashSet<Integer>();  int i = 0; while(((i < n) && (cnt.size() < k))){cnt.add(a[i]); if ( (cnt.size() < k)) ++i; }if ( (cnt.size() < k)) out.print("-1 -1"); else { int r = i; cnt = new HashSet<Integer>(); while(((i >= 0) && (cnt.size() < k))){cnt.add(a[i]); if ( (cnt.size() < k)) --i; }out.print((i + 1),(r + 1)); }} } class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public InputReader( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void close(){ writer.close(); } }
1	public class b{ public static void main( String[] args)throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out);  int n = input.nextInt(),a = input.nextInt(),b = input.nextInt();  Num[] data = new Num[n]; for ( int i = 0;(i < n);i++) data[i] = new Num(input.nextInt(),i); int[] res = new int[n]; Arrays.fill(res,-1); Arrays.sort(data); HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) map.put(data[i].x,data[i].i); boolean good = true; for ( int i = 0;(i < n);i++) {if ( (res[data[i].i] != -1)) continue; int val = data[i].x; if ( (!map.containsKey((a - val)) && !map.containsKey((b - val)))) {good = false; break;} if ( !map.containsKey((a - val))) { int other = map.get((b - val)); if ( (res[other] == 0)) {good = false; break;} res[other] = res[data[i].i] = 1; } else if ( !map.containsKey((b - val))) { int other = map.get((a - val)); if ( (res[other] == 1)) {good = false; break;} res[other] = res[data[i].i] = 0; } else { int cur = data[i].i;  int otherB = map.get((b - val)),otherA = map.get((a - val)); if ( ((b > a) && (res[otherB] != 0))) {res[cur] = res[otherB] = 1; } else if ( ((a > b) && (res[otherA] != 1))) {res[cur] = res[otherA] = 0; } else if ( ((b > a) && (res[otherA] != 1))) {res[cur] = res[otherA] = 0; } else if ( ((a > b) && (res[otherB] != 0))) {res[cur] = res[otherB] = 1; } else if ( (b == a)) {res[cur] = res[otherA] = 0; } else {good = false; break;}}}if ( good) {out.println("YES"); for ( int x :res) out.print((x + " ")); } else out.println("NO"); out.close(); } static class Num implements Comparable<Num>{ int x ,i ; public Num( int xx, int ii){ x = xx; i = ii; } } }
1	public class NewClass{ static Scanner in = new Scanner(System.in); public static void main( String[] args){ int n = in.nextInt(),ans = Integer.MAX_VALUE,t = 0;  String x = in.next(); for ( int i = 0;(i < n);i++) {if ( (x.charAt(i) == '-')) t--; else t++; ans = Math.min(ans,t); }if ( (ans <= 0)) System.out.println((Math.abs(ans) + t)); else System.out.println(t); } }
0	public class TaskA implements Runnable{ @Override public void run(){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int n = in.readInt(); if ( (n > 0)) {out.println(n); } else { int nn = -n;  int x = (nn / 10);  int lastDigit = (nn % 10);  int y = ((10 * (x / 10)) + lastDigit); x = -x; y = -y; out.println(((x > y)?x:y)); }out.flush(); } public static void main( String[] args){ new TaskA().run(); } private class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int readInt(){ return Integer.parseInt(next());} } }
0	public class Solver{ StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args)throws NumberFormatException,IOException { Solver solver = new Solver(); solver.open(); solver.solve(); solver.close(); } public void open()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } public String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} public void solve()throws NumberFormatException,IOException { int n = nextInt(); out.println(((((0 + " ") + 0) + " ") + n)); } public void close(){ out.flush(); out.close(); } }
0	public class C186D2A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(); if ( (n >= 0)) {out.println(Math.abs(n)); } else {out.println(Math.max((n / 10),(((n / 100) * 10) + (n % 10)))); }out.flush(); } }
1	public class TaskA{ public static void main( String[] args){ new TaskA(System.in,System.out); } static class Solver implements Runnable{ int n ; String[] last ,curr ; BufferedReader in ; PrintWriter out ; void solve()throws IOException { n = Integer.parseInt(in.readLine()); last = new String[n]; curr = new String[n]; for ( int i = 0;(i < n);i++) last[i] = in.readLine(); for ( int i = 0;(i < n);i++) curr[i] = in.readLine(); int changes = 0;  String[] sizes = new String[]{"S","M","L","XS","XXS","XXXS","XL","XXL","XXXL"};  int[] old = count(last,sizes);  int[] now = count(curr,sizes); for ( int i = 0;(i < sizes.length);i++) {changes += Math.abs((old[i] - now[i])); }out.println((changes / 2)); } int[] count( String[] s, String[] sizes){ int len = sizes.length;  int[] cnt = new int[len]; for ( int i = 0;(i < len);i++) {for ( String str :s) {if ( str.equals(sizes[i])) cnt[i]++; }}return cnt;} public Solver( BufferedReader in, PrintWriter out){ this.in = in; this.out = out; } } public TaskA( InputStream inputStream, OutputStream outputStream){ BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));  PrintWriter out = new PrintWriter(outputStream);  Thread thread = new Thread(null,new Solver(in,out),"TaskA",(1 << 29)); try{thread.start(); thread.join(); }catch (InterruptedException e){ e.printStackTrace(); } finally{try{in.close(); }catch (IOException e){ e.printStackTrace(); } out.flush(); out.close(); }} }
1	public class Solution{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(new InputStreamReader(System.in));  int n = sc.nextInt();  String s = sc.next(); sc.close(); int cH = 0; for ( int i = 0;(i < s.length());i++) if ( (s.charAt(i) == 'H')) cH++;  int best = cH; for ( int st = 0;(st < s.length());st++) { int cur = st;  int cnt = cH; for ( int i = 0;(i < cH);i++) {if ( (s.charAt(cur) == 'H')) cnt--; cur++; if ( (cur == s.length())) cur = 0; }best = Math.min(best,cnt); }System.out.println(best); } }
1	public class Main{ static long MOD = 1_000_000_007L; static long inv2 = ((MOD + 1) / 2); static int[][] dir = new int[][]{{1,0},{0,1},{-1,0},{0,-1}}; static long lMax = 0x3f3f3f3f3f3f3f3fL; static int iMax = 0x3f3f3f3f; static HashMap<Long,Long> memo = new HashMap(); static MyScanner sc = new MyScanner(); static int nn = 300000; static long[] pow2 ; static long[] fac ; static long[] pow ; static long[] inv ; static long[] facInv ; static int[] base ; static int[] numOfDiffDiv ; static int[] numOfDiv ; static ArrayList<Integer> primes ; static int ptr = 0; static boolean[] isPrime ; public static PrintWriter out ; public static void main( String[] args){ out = new PrintWriter(new BufferedOutputStream(System.out)); int t = 1,tt = 0; t = sc.ni(); for ( int i = 1;(i < 40000);i++) squares.add((i * i)); while((tt++ < t)){ boolean res = solve(); out.println((res?"YES":"NO")); }out.close(); } static HashSet<Integer> squares = new HashSet(); static boolean solve(){ long res = 0;  int n = sc.ni(); if ( (((n % 2) == 0) && squares.contains((n / 2)))) return true; if ( (((n % 4) == 0) && squares.contains((n / 4)))) return true; return false;} public static int[][] packU( int n, int[] from, int[] to){ return packU(n,from,to,from.length);} public static int[][] packU( int n, int[] from, int[] to, int sup){ int[][] g = new int[n][];  int[] p = new int[n]; for ( int i = 0;(i < sup);i++) p[from[i]]++; for ( int i = 0;(i < sup);i++) p[to[i]]++; for ( int i = 0;(i < n);i++) g[i] = new int[p[i]]; for ( int i = 0;(i < sup);i++) {g[from[i]][--p[from[i]]] = to[i]; g[to[i]][--p[to[i]]] = from[i]; }return g;} public static int lowerBound( int[] a, int v){ return lowerBound(a,0,a.length,v);} public static int lowerBound( int[] a, int l, int r, int v){ if ( (((l > r) || (l < 0)) || (r > a.length))) throw (new IllegalArgumentException()); int low = (l - 1),high = r; while(((high - low) > 1)){ int h = ((high + low) >>> 1); if ( (a[h] >= v)) {high = h; } else {low = h; }}return high;} public static long quickPOW( long n, long m){ long ans = 1l; while((m > 0)){if ( ((m % 2) == 1)) ans = ((ans * n) % MOD); n = ((n * n) % MOD); m >>= 1; }return ans;} public static long quickPOW( long n, long m, long mod){ long ans = 1l; while((m > 0)){if ( ((m % 2) == 1)) ans = ((ans * n) % mod); n = ((n * n) % mod); m >>= 1; }return ans;} public static int gcd( int a, int b){ if ( ((a % b) == 0)) return b; return gcd(b,(a % b));} public static long gcd( long a, long b){ if ( ((a % b) == 0)) return b; return gcd(b,(a % b));} static class RandomWrapper{ private Random random ; public static final RandomWrapper INSTANCE = new RandomWrapper(new Random()); public RandomWrapper(){ this(new Random()); } public RandomWrapper( Random random){ this.random = random; } public int nextInt( int l, int r){ return (random.nextInt(((r - l) + 1)) + l);} } public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int ni(){ return Integer.parseInt(next());} } }
5	public class P274A{ public static int i( String s){ return Integer.parseInt(s);} public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] arr = in.readLine().split(" ");  int n = i(arr[0]);  long k = i(arr[1]);  long[] A = new long[n]; arr = in.readLine().split(" "); for ( int i = 0;(i < n);i++) A[i] = i(arr[i]); shuffle(A); Arrays.sort(A); Set<Long> BAN = new HashSet<Long>();  int ans = 0; for ( int i = 0;(i < n);i++) {if ( !BAN.contains(A[i])) {ans++; BAN.add((A[i] * k)); } }System.out.println(ans); } public static void shuffle( long[] array){ for ( int i = array.length;(i > 1);i--) { long temp = array[(i - 1)];  int randIx = (int)(Math.random() * i); array[(i - 1)] = array[randIx]; array[randIx] = temp; }} }
4	public class Main implements Runnable{ static final int mod = 1000000007; static FastReader sc ; static PrintWriter out ; static boolean test_case_input = true; static final int MAX = 1000000000; static final int MIN = -1000000000; public static void print( int[] a, int point){ out.print(a[1]); for ( int i = 2;(i <= point);i++) {out.print(("." + a[i])); }out.println(); } public static void solution( int test_case)throws IOException { int n = sc.nextInt();  int a[] = sc.intarr(n);  int lev[] = new int[(n + 1)]; lev[1] = 1; int point = 1; out.println(1); for ( int i = 1;(i < n);i++) {if ( (a[i] == 1)) {point++; lev[point] = 1; print(lev,point); } else if ( (a[i] == (lev[point] + 1))) {lev[point]++; print(lev,point); } else {while(((lev[point] + 1) != a[i])){point--; }lev[point]++; print(lev,point); }}} public static <T> void toString( String msg, ArrayList<ArrayList<T>> adj){ out.println((msg + ":")); int count = 0; for ( ArrayList<T> i :adj) {out.print((("\t" + count++) + ": ")); for ( T j :i) {out.print((j + " ")); }out.println(); }} public static <T> void toString( String msg, Map<T,ArrayList<T>> adj){ out.println((msg + ":")); for ( Map.Entry<T,ArrayList<T>> entry :adj.entrySet()) {out.println(((("\t" + entry.getKey()) + ": ") + entry.getValue())); }} public static void main( String[] args)throws IOException { new Thread(null,new Main(),"random",(1 << 26)).start(); } static class Point implements Comparable<Point>{ Object x ; Object y ; public Point( Object a, Object b){ x = a; y = b; } public String toString(){ String ans = (((("(" + x) + ", ") + y) + ")"); return ans;} @Override public boolean equals( Object obj){ if ( (obj == null)) return false; Point point = (Point)obj; if ( (point.x.equals(this.x) && point.y.equals(this.y))) return true; else return false;} } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader()throws FileNotFoundException{ File in = new File("input.txt"); if ( in.exists()) {br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); } else {br = new BufferedReader(new InputStreamReader(System.in)); }} String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} int[] intarr( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(next()); }return a;} } }
4	public class C35{ public static int mod = 1000000007; public static long INF = (1L << 60); static int n ,m ; static class Pair{ int x ,y ; Pair( int x, int y){ this.x = x; this.y = y; } } static boolean[][] burned ; static int[] dx = {-1,0,1,0}; static int[] dy = {0,-1,0,1}; static boolean isvalid( int x, int y){ return ((((x >= 0) && (x < n)) && (y >= 0)) && (y < m));} public static void main( String[] args)throws IOException { Scanner in = new Scanner("input.txt");  PrintWriter out = new PrintWriter(new FileWriter("output.txt")); n = in.nextInt(); m = in.nextInt(); burned = new boolean[n][m]; int k = in.nextInt();  Queue<Pair> queue = new LinkedList<>();  Pair prev = null; for ( int i = 0;(i < k);i++) { int x = in.nextInt();  int y = in.nextInt(); burned[(x - 1)][(y - 1)] = true; queue.add(prev = new Pair((x - 1),(y - 1))); }while(!queue.isEmpty()){ Queue<Pair> tempqueue = new LinkedList<>(); for ( Pair p :queue) { int x = p.x;  int y = p.y; prev = p; for ( int i = 0;(i < 4);i++) {if ( (isvalid((x + dx[i]),(y + dy[i])) && !burned[(x + dx[i])][(y + dy[i])])) {tempqueue.add(new Pair((x + dx[i]),(y + dy[i]))); burned[(x + dx[i])][(y + dy[i])] = true; } }}queue = tempqueue; }out.printf("%d %d\n",(prev.x + 1),(prev.y + 1)); out.close(); } public static long gcd( long n1, long n2){ long r ; while((n2 != 0)){r = (n1 % n2); n1 = n2; n2 = r; }return n1;} static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String s)throws FileNotFoundException{ br = new BufferedReader(new FileReader(s)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
6	public class Main{ public static void main( String[] args){ InputReader in = new StreamInputReader(System.in);  PrintWriter out = new PrintWriter(System.out); run(in,out); } public static void run( InputReader in, PrintWriter out){ Solver solver = new TaskC(); solver.solve(1,in,out); Exit.exit(in,out); } } class StreamInputReader extends InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ,numChars ; public StreamInputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public void close(){ try{stream.close(); }catch (IOException ignored){ } } } interface Solver{ public void solve( int testNumber, InputReader in, PrintWriter out); } class TaskC implements Solver{ public void solve( int testNumber, InputReader in, PrintWriter out){ int rowCount = in.readInt();  int columnCount = in.readInt(); out.println(((rowCount * columnCount) - go(Math.min(rowCount,columnCount),Math.max(rowCount,columnCount)))); } private int go( int rowCount, int columnCount){ int[][][] result = new int[columnCount][rowCount][(1 << (2 * rowCount))]; ArrayUtils.fill(result,-1); return go(0,0,((1 << rowCount) - 1),result);} private int go( int column, int row, int mask, int[][][] result){ if ( (column == result.length)) return ((mask == 0)?0:(Integer.MAX_VALUE / 2)); int length = result[column].length; if ( (row == length)) return go((column + 1),0,mask,result); if ( (result[column][row][mask] != -1)) return result[column][row][mask]; result[column][row][mask] = (Integer.MAX_VALUE / 2); if ( (((mask >> ((2 * length) - 1)) & 1) == 0)) result[column][row][mask] = go(column,(row + 1),((mask * 2) + ((column == (result.length - 1))?0:1)),result);  int newMask = mask; newMask &= (1 << (length - 1)); if ( (row != 0)) newMask &= (1 << length); if ( (row != (length - 1))) newMask &= (1 << (length - 2)); newMask *= 2; newMask &= ((1 << (2 * length)) - 1); return result[column][row][mask] = Math.min(result[column][row][mask],(1 + go(column,(row + 1),newMask,result)));} }
0	public class Sasha1113A{ static int solution( int n, int v){ int count ; if ( (v >= n)) return (n - 1); else {count = ((v - 1) + (((n - v) * ((n - v) + 1)) / 2)); }return count;} public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int v = scan.nextInt(); System.out.print(solution(n,v)); } }
5	public class Main{ public static void main( String[] args)throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } private static void solve()throws Exception { int n = nextInt();  boolean[] use = new boolean[500];  ArrayList<Integer> a = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) { int v = nextInt(); if ( !use[(250 + v)]) {use[(250 + v)] = true; a.add(v); } }Collections.sort(a); if ( (a.size() < 2)) {out.println("NO"); } else {out.println(a.get(1)); }} static BufferedReader in ; static PrintWriter out ; static StringTokenizer st ; static String nextString()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(nextString());} }
2	public class codeforcesreturn{ static ArrayList<Integer>[] adjlist ; static int[][] adjmatrix ; static int[][] adjmatrix2 ; static boolean[] vis ; static boolean[] intialvis ; static boolean[] vis2 ; static int[] counter ; static int V ,E ; static Stack<Integer> st ; static ArrayList<Integer> arrylist ; static boolean flag ; static int[] dx = new int[]{1,-1,0,0}; static int[] dy = new int[]{0,0,1,-1}; static int[] Arr ; static PrintWriter pw ; static boolean ans = true; public static long gcd( long u, long v){ if ( (u == 0)) return v; return gcd((v % u),u);} public static void bib( int u){ vis[u] = true; for ( int v :adjlist[u]) {if ( !vis[v]) {counter[v] = (1 ^ counter[u]); bib(v); } else if ( (counter[v] != (1 ^ counter[u]))) ans = false; }} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  int k = sc.nextInt();  int sum = n; for ( long i = 0;(i < 1e5);i++) {if ( ((((i * (i + 1)) / 2) - (n - i)) == k)) {System.out.println((n - i)); break;} }} static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ int[] lo ; int[] hi ; long[][][][][] dp ; long[] posVal ; long go( int pos, int isAGreaterLo, int isALessHi, int isBGreaterLo, int isBLessHi){ if ( (pos == 63)) {return 0;} if ( (dp[pos][isAGreaterLo][isALessHi][isBGreaterLo][isBLessHi] != -1)) {return dp[pos][isAGreaterLo][isALessHi][isBGreaterLo][isBLessHi];} int ua = 0;  int va = 1; if ( ((isALessHi == 0) && (hi[pos] == 0))) {va = 0; } if ( ((isAGreaterLo == 0) && (lo[pos] == 1))) {ua = 1; } int ub = 0;  int vb = 1; if ( ((isBLessHi == 0) && (hi[pos] == 0))) {vb = 0; } if ( ((isBGreaterLo == 0) && (lo[pos] == 1))) {ub = 1; } long res = 0; dp[pos][isAGreaterLo][isALessHi][isBGreaterLo][isBLessHi] = 0; for ( int i = ua;(i <= va);++i) { int newIsAGreaterLo = isAGreaterLo;  int newIsALessHi = isALessHi; if ( (i < hi[pos])) newIsALessHi = 1; if ( (i > lo[pos])) newIsAGreaterLo = 1; for ( int j = ub;(j <= vb);++j) { int newIsBGreaterLo = isBGreaterLo;  int newIsBLessHi = isBLessHi; if ( (j < hi[pos])) newIsBLessHi = 1; if ( (j > lo[pos])) newIsBGreaterLo = 1;  long val = 0; if ( (i != j)) val = posVal[pos]; val += go((pos + 1),newIsAGreaterLo,newIsALessHi,newIsBGreaterLo,newIsBLessHi); res = Math.max(res,val); }}dp[pos][isAGreaterLo][isALessHi][isBGreaterLo][isBLessHi] = res; return res;} public void solve( int testNumber, InputReader in, OutputWriter out){ lo = new int[63]; hi = new int[63]; long a = in.readLong();  long b = in.readLong(); Binary.convertBinary(a,lo); Binary.convertBinary(b,hi); posVal = new long[63]; posVal[62] = 1; for ( int i = 61;(i >= 0);--i) {posVal[i] = (posVal[(i + 1)] * 2); }dp = new long[65][2][2][2][2]; for ( long[][][][] a1 :dp) {for ( long[][][] a2 :a1) {for ( long[][] a3 :a2) {for ( long[] a4 :a3) {Arrays.fill(a4,-1); }}}} long res = go(0,0,0,0,0); out.printLine(res); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new UnknownError()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new UnknownError());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public long readLong(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(outputStream); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } }
0	public class Main{ void solve( Scanner in, PrintWriter out){ long a = in.nextLong(); out.println(25); } void run(){ Locale.setDefault(Locale.US); try(Scanner in=new Scanner(System.in);PrintWriter out=new PrintWriter(System.out)){solve(in,out); }} public static void main( String[] args){ new Main().run(); } }
4	public class Main{ static int m ; static long pow( long b, int p){ long ret = 1; while((p > 0)){if ( ((p & 1) == 1)) ret = ((b * ret) % m); b = ((b * b) % m); p >>= 1; }return ret;} public static void main( String[] args)throws IOException { int n = readInt(); m = readInt(); long[] fac = new long[(n + 1)],pow2 = new long[(n + 1)];  long[][] C = new long[(n + 1)][(n + 1)],dp = new long[(n + 1)][(n + 1)]; fac[0] = pow2[0] = 1; for ( int i = 1;(i <= n);++i) {fac[i] = ((i * fac[(i - 1)]) % m); pow2[i] = ((2 * pow2[(i - 1)]) % m); for ( int j = 0;(j <= i);++j) C[i][j] = ((fac[i] * ((pow(fac[j],(m - 2)) * pow(fac[(i - j)],(m - 2))) % m)) % m); }for ( int i = 1;(i <= n);++i) {dp[i][i] = pow2[(i - 1)]; for ( int j = 0;(j <= i);++j) for ( int k = 1;(((i + k) + 1) <= n);++k) dp[((i + k) + 1)][(j + k)] = ((dp[((i + k) + 1)][(j + k)] + (dp[i][j] * ((C[(j + k)][k] * pow2[(k - 1)]) % m))) % m); } long ans = 0; for ( int i = 1;(i <= n);++i) ans = ((ans + dp[n][i]) % m); System.out.println(ans); } static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st ; static String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} static int readInt()throws IOException { return Integer.parseInt(next());} }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Input in = new Input(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskE solver = new TaskE(); solver.solve(1,in,out); out.close(); } static class TaskE{ public void solve( int testNumber, Input in, PrintWriter out){ try{ int kt = in.readInt(); for ( int nt = 0;(nt < kt);nt++) { int n = in.readInt();  int m = in.readInt();  int[][] a = new int[m][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[j][i] = in.readInt(); }}Arrays.sort(a,(x,y)->{ int xMax = 0; for ( int i = 0;(i < x.length);i++) {xMax = Math.max(xMax,x[i]); } int yMax = 0; for ( int i = 0;(i < y.length);i++) {yMax = Math.max(yMax,y[i]); }return Integer.compare(-xMax,-yMax);}); int ans = 0;  int[] s = new int[4]; for ( s[0] = 0;(s[0] < n);s[0]++) {for ( s[1] = 0;(s[1] < n);s[1]++) {for ( s[2] = 0;(s[2] < n);s[2]++) {for ( s[3] = 0;(s[3] < n);s[3]++) { int cur = 0; for ( int i = 0;(i < n);i++) { int max = 0; for ( int j = 0;(j < Math.min(m,n));j++) {max = Math.max(max,a[j][((i + s[j]) % n)]); }cur += max; }ans = Math.max(cur,ans); }}}}out.println(ans); } }catch (Exception e){ throw (new RuntimeException(e));} } } static class Input{ public final BufferedReader reader ; private String line = ""; private int pos = 0; public Input( InputStream inputStream){ reader = new BufferedReader(new InputStreamReader(inputStream)); } private boolean isSpace( char ch){ return (ch <= 32);} public String readWord()throws IOException { skip(); int start = pos; while(((pos < line.length()) && !isSpace(line.charAt(pos)))){pos++; }return line.substring(start,pos);} public int readInt()throws IOException { return Integer.parseInt(readWord());} private void skip()throws IOException { while(true){if ( (pos >= line.length())) {line = reader.readLine(); pos = 0; } while(((pos < line.length()) && isSpace(line.charAt(pos)))){pos++; }if ( (pos < line.length())) {return ;} }} } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ScanReader in = new ScanReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  EKeyboardPurchase solver = new EKeyboardPurchase(); solver.solve(1,in,out); out.close(); } static class EKeyboardPurchase{ public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int m = in.scanInt();  int step[][] = new int[m][m];  char arr[] = in.scanString().toCharArray(); for ( int i = 0;(i < (n - 1));i++) {step[(arr[i] - 'a')][(arr[(i + 1)] - 'a')]++; step[(arr[(i + 1)] - 'a')][(arr[i] - 'a')]++; } int dp[] = new int[(1 << m)]; Arrays.fill(dp,(Integer.MAX_VALUE / 2)); for ( int i = 0;(i < m);i++) dp[(1 << i)] = 0; for ( int i = 0;(i < (1 << m));i++) { int cost = 0; for ( int j = 0;(j < m);j++) {if ( ((i & (1 << j)) != 0)) {for ( int k = 0;(k < m);k++) {if ( ((i & (1 << k)) == 0)) {cost += step[j][k]; } }} }for ( int j = 0;(j < m);j++) if ( ((i & (1 << j)) == 0)) dp[(i | (1 << j))] = Math.min(dp[(i | (1 << j))],(dp[i] + cost)); }out.println(dp[((1 << m) - 1)]); } } static class ScanReader{ private byte[] buf = new byte[(4 * 1024)]; private int INDEX ; private BufferedInputStream in ; private int TOTAL ; public ScanReader( InputStream inputStream){ in = new BufferedInputStream(inputStream); } private int scan(){ if ( (INDEX >= TOTAL)) {INDEX = 0; try{TOTAL = in.read(buf); }catch (Exception e){ e.printStackTrace(); } if ( (TOTAL <= 0)) return -1; } return buf[INDEX++];} public int scanInt(){ int I = 0;  int n = scan(); while(isWhiteSpace(n))n = scan(); int neg = 1; if ( (n == '-')) {neg = -1; n = scan(); } while(!isWhiteSpace(n)){if ( ((n >= '0') && (n <= '9'))) {I *= 10; I += (n - '0'); n = scan(); } }return (neg * I);} public String scanString(){ int c = scan(); while(isWhiteSpace(c))c = scan(); StringBuilder RESULT = new StringBuilder(); do {RESULT.appendCodePoint(c); c = scan(); }while(!isWhiteSpace(c));return RESULT.toString();} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
4	public class e1515{ public static void main( String[] args){ Scanner s = new Scanner(System.in); solve(s.nextInt(),s.nextLong()); } public static long inv( long n, long mod){ if ( (n == 1)) return 1; return ((inv((mod % n),mod) * (mod - (mod / n))) % mod);} public static void solve( int n, long mod){ long fact[] = new long[(n + 2)];  long invFact[] = new long[(n + 2)];  long twoPow[] = new long[(n + 2)]; fact[0] = 1; invFact[0] = 1; twoPow[0] = 1; for ( int i = 1;(i < (n + 2));i++) {fact[i] = ((fact[(i - 1)] * i) % mod); invFact[i] = ((invFact[(i - 1)] * inv(i,mod)) % mod); twoPow[i] = ((2 * twoPow[(i - 1)]) % mod); } long dp[][] = new long[(n + 2)][]; dp[0] = new long[]{1}; long next[] = null; for ( int i = 1;(i <= (n + 1));i++) {next = new long[(i + 1)]; for ( int j = 0;(j < (i - 1));j++) {for ( int k = 0;(k < dp[j].length);k++) {next[(((k + i) - j) - 1)] = ((next[(((k + i) - j) - 1)] + ((((((((dp[j][k] * twoPow[((i - j) - 2)]) % mod) * fact[(((k + i) - j) - 1)]) % mod) * invFact[k]) % mod) * invFact[((i - j) - 1)]) % mod)) % mod); }}dp[i] = next; } long sum = 0; for ( int i = 0;(i < next.length);i++) {sum = ((sum + next[i]) % mod); }System.out.println(sum); } }
5	public class A{ static class T{ public int s ,p ; } public static void main( String[] args)throws Exception { InputReader sc = new InputReader(System.in);  int n = sc.readInt(),k = sc.readInt(),i ,j ,z ;  T m[] = new T[n]; for ( i = 0;(i < n);i++) {m[i] = new T(); m[i].s = sc.readInt(); m[i].p = sc.readInt(); }for ( i = 0;(i < n);i++) for ( j = (i + 1);(j < n);j++) if ( (m[i].s < m[j].s)) {z = m[i].s; m[i].s = m[j].s; m[j].s = z; z = m[i].p; m[i].p = m[j].p; m[j].p = z; } for ( i = 0;(i < n);i++) for ( j = (i + 1);(j < n);j++) if ( ((m[i].s == m[j].s) && (m[i].p > m[j].p))) {z = m[i].s; m[i].s = m[j].s; m[j].s = z; z = m[i].p; m[i].p = m[j].p; m[j].p = z; } k--; int s = m[k].s,p = m[k].p,res = 0; for ( i = 0;(i < n);i++) {if ( ((m[i].s == s) && (m[i].p == p))) res++; }System.out.println(res); } } class InputReader{ private boolean finished = false; private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int peek(){ if ( (numChars == -1)) return -1; if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ return -1;} if ( (numChars <= 0)) return -1; } return buf[curChar];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuffer res = new StringBuffer(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private String readLine0(){ StringBuffer buf = new StringBuffer();  int c = read(); while(((c != '\n') && (c != -1))){if ( (c != '\r')) buf.appendCodePoint(c); c = read(); }return buf.toString();} public String readLine(){ String s = readLine0(); while((s.trim().length() == 0))s = readLine0(); return s;} public String readLine( boolean ignoreEmptyLines){ if ( ignoreEmptyLines) return readLine(); else return readLine0();} }
2	public class A{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner();  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt(),k = sc.nextInt(); for ( int x = 0;;x++) {if ( ((((2 * 1L) * x) + ((x * 1L) * (x + 1))) == (2L * (k + n)))) {out.println((n - x)); break;} }out.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } Scanner( String fileName)throws FileNotFoundException{ br = new BufferedReader(new FileReader(fileName)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} boolean ready()throws IOException { return br.ready();} } }
6	public class C{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int x = ni(),y = ni();  int n = ni();  int[][] co = new int[n][]; for ( int i = 0;(i < n);i++) {co[i] = new int[]{(ni() - x),(ni() - y)}; } int[] c1 = new int[n];  int[][] c2 = new int[n][n]; for ( int i = 0;(i < n);i++) {c1[i] = (((co[i][0] * co[i][0]) + (co[i][1] * co[i][1])) * 2); }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {c2[i][j] = c2[j][i] = (((((co[i][0] * co[i][0]) + (co[i][1] * co[i][1])) + ((co[j][0] * co[j][0]) + (co[j][1] * co[j][1]))) + ((co[j][0] - co[i][0]) * (co[j][0] - co[i][0]))) + ((co[j][1] - co[i][1]) * (co[j][1] - co[i][1]))); }} int[] dp = new int[(1 << n)];  int[] prev = new int[(1 << n)]; prev[0] = -1; for ( int i = 1;(i < (1 << n));i++) { int a = Integer.numberOfTrailingZeros(i); dp[i] = (c1[a] + dp[(i ^ (1 << a))]); prev[i] = (1 << a); for ( int j = (a + 1);(j < n);j++) {if ( ((i << (31 - j)) < 0)) { int v = (dp[((i ^ (1 << a)) ^ (1 << j))] + c2[a][j]); if ( (v < dp[i])) {dp[i] = v; prev[i] = ((1 << a) ^ (1 << j)); } } }}out.println(dp[((1 << n) - 1)]); int cur = ((1 << n) - 1); out.print("0"); while(true){ int targ ; if ( (prev[cur] == -1)) {targ = cur; } else {targ = prev[cur]; cur ^= prev[cur]; } int a = Integer.numberOfTrailingZeros(targ);  int b = Integer.numberOfTrailingZeros((targ & (targ - 1))); if ( (targ == (1 << a))) {out.print((" " + (a + 1))); } else {out.print((" " + (a + 1))); out.print((" " + (b + 1))); }out.print(" 0"); if ( (cur == 0)) break; }out.println(); } void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new C().run(); } public int ni(){ try{ int num = 0;  boolean minus = false; while((((num = is.read()) != -1) && (((num >= '0') && (num <= '9')) || (num == '-'))));if ( (num == '-')) {num = 0; minus = true; } else {num -= '0'; }while(true){ int b = is.read(); if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}} }catch (IOException e){ } return -1;} public String ns(){ try{ int b = 0;  StringBuilder sb = new StringBuilder(); while((((b = is.read()) != -1) && (((b == '\r') || (b == '\n')) || (b == ' '))));if ( (b == -1)) return ""; sb.append((char)b); while(true){b = is.read(); if ( (b == -1)) return sb.toString(); if ( (((b == '\r') || (b == '\n')) || (b == ' '))) return sb.toString(); sb.append((char)b); } }catch (IOException e){ } return "";} public char[] ns( int n){ char[] buf = new char[n]; try{ int b = 0,p = 0; while((((b = is.read()) != -1) && (((b == ' ') || (b == '\r')) || (b == '\n'))));if ( (b == -1)) return null; buf[p++] = (char)b; while((p < n)){b = is.read(); if ( ((((b == -1) || (b == ' ')) || (b == '\r')) || (b == '\n'))) break; buf[p++] = (char)b; }return Arrays.copyOf(buf,p); }catch (IOException e){ } return null;} boolean oj = (System.getProperty("ONLINE_JUDGE") != null); void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
0	public class A483 implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new A483(),"",(256 * (1L << 20))).start(); } String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} long readLong()throws IOException { return Long.parseLong(readString());} int choose( int total, int choose){ if ( (total < choose)) return 0; if ( ((choose == 0) || (choose == total))) return 1; return (choose((total - 1),(choose - 1)) + choose((total - 1),choose));} void solve()throws IOException { long l = readLong();  long r = readLong(); if ( ((r - l) >= 3)) { long c = (((l % 2) == 0)?l:(l + 1)); out.println(((((c + " ") + (c + 1)) + " ") + (c + 2))); } else if ( (((r - l) == 2) && ((r % 2) == 0))) {out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else {out.println(-1); }} }
1	public class Main{ public static void main( String[] args){ Parser p = new Parser(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = p.nextInt();  int k = p.nextInt();  int[] a = p.nextIntArray(n);  int[] pos = new int[100001]; Arrays.fill(pos,-1); int cnt = 0; for ( int i = 0;(i < n);++i) { int e = a[i]; if ( (pos[e] == -1)) {++cnt; } pos[e] = i; if ( (cnt == k)) {break;} }if ( (cnt < k)) {pw.println("-1 -1"); pw.close(); return ;} int min = 1000000;  int max = -1; for ( int i = 0;(i < 100001);++i) {if ( ((pos[i] != -1) && (pos[i] < min))) {min = pos[i]; } if ( (pos[i] > max)) {max = pos[i]; } }++min; ++max; pw.println(((min + " ") + max)); pw.close(); } static class Parser{ StringTokenizer st ; BufferedReader br ; public Parser( InputStream is){ this.br = new BufferedReader(new InputStreamReader(is)); } public int nextInt(){ return Integer.parseInt(nextToken());} public int[] nextIntArray( int s){ int[] a = new int[s]; for ( int i = 0;(i < s);++i) {a[i] = nextInt(); }return a;} private String nextToken(){ if ( ((st == null) || !st.hasMoreTokens())) {try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } return st.nextToken();} } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ private static final int MOD = ((int)1e9 + 7); private static final int N = 5000; public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int[] dp = new int[N]; Arrays.fill(dp,0); dp[0] = 1; String pre = null,ch ; for ( int i = 0;(i < n);++i) {ch = in.next(); if ( (i > 0)) {if ( pre.equals("s")) { int j = (N - 1); while((dp[j] == 0)){--j; } long sum = 0; for ( ;(j >= 0);--j) {sum += dp[j]; sum %= MOD; dp[j] = (int)sum; }} else {for ( int k = (N - 1);(k > 0);--k) {dp[k] = dp[(k - 1)]; }dp[0] = 0; }} pre = ch; } long sum = 0; for ( int i = 0;(i < N);++i) {sum += dp[i]; sum %= MOD; }out.println(sum); } } }
2	public class C{ public static void main( String[] args){ new C(); } C(){ Scanner in = new Scanner(System.in);  long n = in.nextLong(),s = in.nextLong();  long lo = 1,hi = 1000000000000000000L; while((lo < hi)){ long mid = ((lo + hi) / 2); if ( reallyBig(mid,s)) hi = mid; else lo = (mid + 1); }if ( !reallyBig(lo,s)) System.out.println(0); else System.out.println(Math.max(((n - lo) + 1),0)); in.close(); } boolean reallyBig( long n, long s){ int sum = 0;  long temp = n; while((temp > 0)){sum += (temp % 10); temp /= 10; }return ((n - sum) >= s);} }
6	public class E{ PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok ; public void go()throws IOException { StringTokenizer tok = new StringTokenizer(in.readLine());  int zzz = Integer.parseInt(tok.nextToken()); for ( int zz = 0;(zz < zzz);zz++) {ntok(); int n = ipar();  int m = ipar();  int[][] mat = new int[n][m]; for ( int i = 0;(i < n);i++) {ntok(); mat[i] = iapar(m); } long[][] dp = new long[(1 << n)][(m + 1)]; for ( int i = 0;(i < (1 << n));i++) {dp[i][m] = -1000000000; }dp[((1 << n) - 1)][m] = 0; for ( int i = (m - 1);(i >= 0);i--) {for ( int e = 0;(e < (1 << n));e++) {dp[e][i] = dp[e][(i + 1)]; for ( int w = 0;(w < (1 << n));w++) {if ( ((e & w) == 0)) {dp[e][i] = Math.max(dp[e][i],(best(w,mat,i) + dp[(e | w)][(i + 1)])); } }}}out.println(dp[0][0]); }out.flush(); in.close(); } public long best( int mask, int[][] mat, int col){ long max = 0; for ( int t = 0;(t < mat.length);t++) { long sum = 0;  int mk = mask; for ( int i = 0;(i < mat.length);i++) {if ( ((mk % 2) == 1)) {sum += mat[i][col]; } mk /= 2; }max = Math.max(max,sum); cycle(mat,col); }return max;} public void cycle( int[][] mat, int col){ int temp = mat[0][col]; for ( int i = 0;(i < (mat.length - 1));i++) {mat[i][col] = mat[(i + 1)][col]; }mat[(mat.length - 1)][col] = temp; } public void ntok()throws IOException { tok = new StringTokenizer(in.readLine()); } public int ipar(){ return Integer.parseInt(tok.nextToken());} public int[] iapar( int n){ int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = ipar(); }return arr;} public long lpar(){ return Long.parseLong(tok.nextToken());} public static void main( String[] args)throws IOException { new E().go(); } }
6	public class Main{ static double arr[][] ; public static void main( String[] args){ try{ Parserdoubt pd = new Parserdoubt(System.in);  PrintWriter pw = new PrintWriter(System.out);  int fishes = pd.nextInt(); arr = new double[fishes][fishes]; for ( int i = 0;(i < fishes);i++) for ( int j = 0;(j < fishes);j++) arr[i][j] = Double.parseDouble(pd.nextString()); double dp[] = new double[(1 << fishes)]; dp[(dp.length - 1)] = 1.0; for ( int c = (dp.length - 1);(c >= 0);c--) {if ( ((c & (c - 1)) == 0)) continue; for ( int i = 0;(i < fishes);i++) for ( int j = (i + 1);(j < fishes);j++) {if ( ((((1 << i) & c) != 0) && (((1 << j) & c) != 0))) {dp[(c & (1 << j))] += (arr[i][j] * dp[c]); dp[(c & (1 << i))] += (arr[j][i] * dp[c]); } }} double s = 0.0; for ( int i = 0;(i < fishes);i++) s += dp[(1 << i)]; for ( int i = 0;(i < fishes);i++) dp[(1 << i)] /= s; int i = 0; for ( i = 0;(i < (fishes - 1));i++) pw.printf("%.6f ",dp[(1 << i)]); pw.printf("%.6f\n",dp[(1 << i)]); pw.close(); }catch (Exception e){ } } } class Parserdoubt{ private final int BUFFER_SIZE = (1 << 17); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Parserdoubt( InputStream in){ din = new DataInputStream(in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String nextString()throws Exception { StringBuffer sb = new StringBuffer("");  byte c = read(); while((c <= ' '))c = read(); do {sb.append((char)c); c = read(); }while((c > ' '));return sb.toString();} public int nextInt()throws Exception { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); c = read(); }while((c > ' '));if ( neg) return -ret; return ret;} private void fillBuffer()throws Exception { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws Exception { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} }
2	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } StreamTokenizer in ; PrintWriter out ; long nextLong()throws IOException { in.nextToken(); return (long)in.nval;} void run()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } @SuppressWarnings void solve()throws IOException { BufferedReader re = new BufferedReader(new InputStreamReader(System.in));  Scanner sc = new Scanner(System.in);  long n = sc.nextLong(),k = sc.nextLong(); if ( (((k * (k - 1)) / 2) < (n - 1))) System.out.println("-1"); else { long ff = ((k * (k - 1)) / 2); ff = (-2 * ((n - 1) - ff)); long up = k,dw = 0; while(((up - dw) > 1)){ long c = ((up + dw) / 2); if ( ((c * (c - 1)) <= ff)) dw = c; else up = c; }if ( (n == 1)) {System.out.println("0"); return ;} System.out.println((k - dw)); }} }
2	public class ProblemB{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out)); long[] readInts()throws IOException { String[] strings = reader.readLine().split(" ");  long[] ints = new long[strings.length]; for ( int i = 0;(i < ints.length);i++) {ints[i] = Long.parseLong(strings[i]); }return ints;} long foo( long a){ return ((a > 0)?(a * a):0);} long boo( long a){ return ((a <= 0)?0:((a * (a + 1)) / 2));} void solve()throws IOException { long[] tt = readInts();  long n = tt[0];  long x = tt[1];  long y = tt[2];  long c = tt[3];  long lo = -1,hi = ((((2 * 1000) * 1000) * 1000) + 2); while(((hi - lo) > 1)){ long m = ((lo + hi) / 2);  long s = ((((2 * m) * m) + (2 * m)) + 1); s -= (((foo(((m - x) + 1)) + foo(((m - y) + 1))) + foo(((x + m) - n))) + foo(((y + m) - n))); s += (((boo(((m + 1) - (((((n + 1) + n) + 1) - x) - y))) + boo(((m + 1) - (((n + 1) - x) + y)))) + boo(((m + 1) - (((n + 1) - y) + x)))) + boo(((m + 1) - (x + y)))); if ( (s < c)) lo = m; else hi = m; }writer.println(hi); writer.flush(); } public static void main( String[] args)throws IOException { new ProblemB().solve(); } }
4	public class A{ public static void main( String[] args){ try{ Scanner scanner = new Scanner(System.in);  String in = scanner.next();  int max = 0; for ( int j = 0;(j < (in.length() - 1));j++) {for ( int i = j;(i < in.length());i++) {if ( ((in.indexOf(in.substring(j,i)) != in.lastIndexOf(in.substring(j,i))) && ((i - j) > max))) {max = (i - j); } }}System.out.println(max); }catch (Exception e){ e.printStackTrace(); } } }
3	public class G{ static final int P = 1_000_000_007; int[][] ways ; int[][] pow ; void preCalc( int sz){ ways = new int[sz][]; for ( int i = 0;(i < ways.length);i++) {ways[i] = new int[(i + 1)]; ways[i][0] = ways[i][i] = 1; for ( int j = 1;(j < i);j++) {ways[i][j] = ((ways[(i - 1)][j] + ways[(i - 1)][(j - 1)]) % P); }}pow = new int[10][sz]; pow[0] = null; for ( int i = 1;(i <= 9);i++) {pow[i][0] = 1; for ( int j = 1;(j < sz);j++) {pow[i][j] = (int)(((long)pow[i][(j - 1)] * i) % P); }}} int solve( String ss){ int n = ss.length();  int[] s = new int[n]; for ( int i = 0;(i < n);i++) {s[i] = (ss.charAt(i) - '0'); }preCalc((n + 10)); int[] ans = new int[(n + 1)];  int[] cnt = new int[10]; for ( int i = 0;(i < n);i++) { int rest = ((n - i) - 1);  int dig = s[i]; for ( int j = 0;(j <= ((i == (n - 1))?dig:(dig - 1)));j++) {cnt[j]++; for ( int use = 1;(use < 10);use++) {for ( int cntGood = 0;(cntGood <= rest);cntGood++) { int delta = (int)(((((long)ways[rest][cntGood] * pow[use][(rest - cntGood)]) % P) * pow[(10 - use)][cntGood]) % P);  int idx = (cnt[use] + cntGood); ans[idx] += delta; if ( (ans[idx] >= P)) {ans[idx] -= P; } }}}cnt[dig]++; } int ret = 0;  long mult = 0; for ( int i = 1;(i < ans.length);i++) {mult = (((10L * mult) + 1) % P); ret += (int)((mult * ans[i]) % P); if ( (ret >= P)) {ret -= P; } }return ret;} void submit(){ out.println(solve(nextToken())); } G()throws IOException{ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); submit(); out.close(); } static final Random rng = new Random(); public static void main( String[] args)throws IOException { new G(); } BufferedReader br ; PrintWriter out ; StringTokenizer st ; String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} }
4	public class ExplorerSpace{ static int n ; static int m ; static int k ; static int[][] rows ; static int[][] cols ; static int max ; static int orix ; static int oriy ; static int[][] dirs = new int[][]{{0,1},{0,-1},{1,0},{-1,0}}; static int[][][][][] mem ; public static void main( String[] args){ FastScanner fs = new FastScanner(); n = fs.nextInt(); m = fs.nextInt(); k = fs.nextInt(); rows = new int[n][(m - 1)]; cols = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {rows[i][j] = fs.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {cols[i][j] = fs.nextInt(); }} int[][][] res = new int[100][n][m]; for ( int o = 2;(o <= k);o += 2) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {res[o][i][j] = 0x3f3f3f3f; if ( (i > 0)) {res[o][i][j] = Math.min(res[o][i][j],(res[(o - 2)][(i - 1)][j] + (2 * cols[(i - 1)][j]))); } if ( ((i + 1) < n)) {res[o][i][j] = Math.min(res[o][i][j],(res[(o - 2)][(i + 1)][j] + (2 * cols[i][j]))); } if ( (j > 0)) {res[o][i][j] = Math.min(res[o][i][j],(res[(o - 2)][i][(j - 1)] + (2 * rows[i][(j - 1)]))); } if ( ((j + 1) < m)) {res[o][i][j] = Math.min(res[o][i][j],(res[(o - 2)][i][(j + 1)] + (2 * rows[i][j]))); } }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( ((k % 2) == 1)) {System.out.print((-1 + " ")); } else {System.out.print((res[k][i][j] + " ")); }}System.out.println(); }} static class FastScanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next(){ while(!st.hasMoreTokens()){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, InputReader in, OutputWriter out){ int side = in.readInt();  int row = (in.readInt() - 1);  int column = (in.readInt() - 1);  int required = in.readInt();  long left = 0;  long right = ((2 * side) - 2); while((left < right)){ long current = ((left + right) / 2);  long result = ((((calculate(row,column,current) + calculate(column,((side - row) - 1),current)) + calculate(((side - row) - 1),((side - column) - 1),current)) + calculate(((side - column) - 1),row,current)) + 1); if ( (result >= required)) right = current; else left = (current + 1); }out.printLine(left); } private long calculate( int row, int column, long current){ column++; long total = 0;  long mn = Math.min(row,column);  long mx = Math.max(row,column); if ( (current <= mn)) return ((current * (current + 1)) / 2); total += ((mn * (mn + 1)) / 2); current -= mn; mx -= mn; if ( (current <= mx)) return (total + (mn * current)); total += (mn * mx); current -= mx; if ( (current < mn)) return ((total + (((mn - 1) * mn) / 2)) - ((((mn - current) - 1) * (mn - current)) / 2)); return (total + (((mn - 1) * mn) / 2));} } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } }
0	public class CF125D2A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); System.out.println(("0 0 " + sc.nextInt())); } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public long recurse( long a, long b){ if ( (b <= 1)) return a; return ((Math.max(a,b) / Math.min(a,b)) + recurse((Math.max(a,b) - (Math.min(a,b) * (Math.max(a,b) / Math.min(a,b)))),Math.min(a,b)));} public void solve( int testNumber, InputReader in, OutputWriter out){ long a = in.readLong(),b = in.readLong(),i = 0; out.print(recurse(a,b)); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public long readLong(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public void close(){ writer.close(); } public void print( long i){ writer.print(i); } }
4	public class D{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  boolean[][] graph = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (in.nextInt() - 1);  int b = (in.nextInt() - 1); graph[a][b] = true; } int res = Integer.MAX_VALUE; for ( int center = 0;(center < n);center++) { int calc = 0; for ( int i = 0;(i < n);i++) {if ( !graph[center][i]) calc++; if ( !graph[i][center]) calc++; }if ( !graph[center][center]) calc--;  int[] match = new int[n]; Arrays.fill(match,-1); int max = 0; for ( int i = 0;(i < n);i++) if ( (i != center)) if ( can(i,graph,new boolean[n],center,match)) max++;  int unusable = ((m - (((2 * n) - 1) - calc)) - max); calc += unusable; calc += (((2 * (n - 1)) - (2 * max)) / 2); res = Math.min(res,calc); }System.out.println(res); } private static boolean can( int at, boolean[][] graph, boolean[] visited, int center, int[] match){ if ( visited[at]) return false; visited[at] = true; for ( int to = 0;(to < graph.length);to++) if ( graph[at][to]) if ( (to != center)) if ( ((match[to] == -1) || can(match[to],graph,visited,center,match))) {match[to] = at; return true;}  return false;} }
4	public class Main{ static int n ,m ,k ; static int[][] horW ,verW ; static int[][][] dp = new int[505][505][15]; public static void main( String[] args)throws IOException { for ( int i = 0;(i < 505);i++) {for ( int j = 0;(j < 505);j++) {for ( int k = 0;(k < 15);k++) {dp[i][j][k] = -1; }}}n = in.iscan(); m = in.iscan(); k = in.iscan(); horW = new int[(n + 1)][m]; verW = new int[n][(m + 1)]; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= (m - 1));j++) {horW[i][j] = in.iscan(); }}for ( int i = 1;(i <= (n - 1));i++) {for ( int j = 1;(j <= m);j++) {verW[i][j] = in.iscan(); }} int min = Integer.MAX_VALUE; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) {if ( ((k % 2) == 1)) {out.print((-1 + " ")); continue;} out.print(((dfs(i,j,(k / 2)) * 2) + " ")); }out.println(); }out.close(); } static int dfs( int r, int c, int k){ if ( (dp[r][c][k] != -1)) {return dp[r][c][k];} if ( (k == 0)) {return dp[r][c][k] = 0;} int min = Integer.MAX_VALUE; if ( ((r - 1) >= 1)) {min = Math.min(min,(verW[(r - 1)][c] + dfs((r - 1),c,(k - 1)))); } if ( ((r + 1) <= n)) {min = Math.min(min,(verW[r][c] + dfs((r + 1),c,(k - 1)))); } if ( ((c - 1) >= 1)) {min = Math.min(min,(horW[r][(c - 1)] + dfs(r,(c - 1),(k - 1)))); } if ( ((c + 1) <= m)) {min = Math.min(min,(horW[r][c] + dfs(r,(c + 1),(k - 1)))); } return dp[r][c][k] = min;} static INPUT in = new INPUT(System.in); static PrintWriter out = new PrintWriter(System.out); private static class INPUT{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ,numChars ; public INPUT( InputStream stream){ this.stream = stream; } public INPUT( String file)throws IOException{ this.stream = new FileInputStream(file); } public int cscan()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); } if ( (numChars == -1)) return numChars; return buf[curChar++];} public int iscan()throws IOException { int c = cscan(),sgn = 1; while(space(c))c = cscan(); if ( (c == '-')) {sgn = -1; c = cscan(); } int res = 0; do {res = ((res << 1) + (res << 3)); res += (c - '0'); c = cscan(); }while(!space(c));return (res * sgn);} public boolean space( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
5	public class A{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int k = (scan.nextInt() - 1);  team[] t = new team[n]; for ( int i = 0;(i < n);i++) t[i] = new team(scan.nextInt(),scan.nextInt()); Arrays.sort(t); int a = 0;  int b = 0; while((((k + a) < (t.length - 1)) && (t[((k + a) + 1)].compareTo(t[k]) == 0)))a++; while((((k - b) > 0) && (t[((k - b) - 1)].compareTo(t[k]) == 0)))b++; System.out.println(((a + b) + 1)); } } class team implements Comparable<team>{ int p ; int t ; public team( int pp, int tt){ p = pp; t = tt; } @Override public int compareTo( team e){ int a = (e.p - p); if ( (a == 0)) {return (t - e.t);} else return a;} }
3	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); } boolean vis[] = new boolean[n];  int c = 0; for ( int i = 0;(i < n);i++) { int min = 200; for ( int j = 0;(j < n);j++) {if ( (!vis[j] && (min > arr[j]))) {min = arr[j]; } }for ( int j = 0;(j < n);j++) {if ( (!vis[j] && ((arr[j] % min) == 0))) {vis[j] = true; } }if ( (min != 200)) {c++; } else break;}System.out.println(c); } }
2	public class Main{ public static void main( String[] args){ FastReader fr = new FastReader();  PrintWriter op = new PrintWriter(System.out);  long n = fr.nextLong(),k = fr.nextLong(),d = (long)Math.sqrt((9l + (8l * (n + k)))); d -= 3l; d /= 2l; op.println((n - d)); op.flush(); op.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} long nextLong(){ return Long.parseLong(next());} } }
2	public class Main2{ static int mod = 1000000007; static FastScanner scanner ; public static void main( String[] args){ scanner = new FastScanner(); long n = scanner.nextInt();  long k = scanner.nextInt(); if ( (sum(n) == k)) {System.out.println(0); return ;} long s = 0;  long e = (n + 1); while((s < (e - 1))){ long m = ((s + e) / 2);  long put = sum((n - m));  long candiesLeft = (put - m); if ( (candiesLeft == k)) {System.out.println(m); return ;} if ( (candiesLeft > k)) {s = m; } else {e = m; }}} static long sum( long n){ long last = ((1 + n) - 1); return (((1 + last) * n) / 2);} public static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String nextToken(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} long nextLong(){ return Long.parseLong(nextToken());} } static class PrefixSums{ long[] sums ; public PrefixSums( long[] sums){ this.sums = sums; } public long sum( int fromInclusive, int toExclusive){ if ( (fromInclusive > toExclusive)) throw (new IllegalArgumentException("Wrong value")); return (sums[toExclusive] - sums[fromInclusive]);} } }
1	public class Main{ private static Scanner in = new Scanner(System.in); public static void main( String[] args){ int n = in.nextInt();  String s = in.next(); if ( (n == 1)) System.out.println("1"); else { int j = 0,i = 1,ans = s.length();  int h[] = new int[128]; h[(int)s.charAt(0)] = 1; while((i < n)){if ( (h[(int)s.charAt(i)] == 0)) ans = ((i - j) + 1); h[(int)s.charAt(i)]++; while(((j < i) && (h[(int)s.charAt(j)] > 1))){h[(int)s.charAt(j)]--; j++; ans = Math.min(ans,((i - j) + 1)); }i++; }System.out.println(ans); }} }
0	public class NewEmpty{ public static void main( String[] args){ Scanner blabla = new Scanner(System.in);  long a ,b ,c = 0,d ; a = blabla.nextLong(); b = blabla.nextLong(); while((b != 0)){c += (a / b); a = (a % b); d = a; a = b; b = d; }System.out.println(c); } }
6	public class q5{ static NoD[] arr ; static int index ,count ,zc ; static ArrayList<NoD> pos ,neg ; static long[][][][] dp ; static long solve( int a, int b, int c, int d, long mod){ long[][][][] a2 = dp;  int p = -1; if ( (((a == 0) && (b == 0)) && (c == 0))) return 1; if ( (dp[a][b][c][d] != -1)) return dp[a][b][c][d]; long tr = 0; if ( ((a > 0) && (d != 1))) {tr = (+a * solve((a - 1),b,c,1,mod)); tr %= mod; } if ( ((b > 0) && (d != 2))) {tr += (b * solve(a,(b - 1),c,2,mod)); tr %= mod; } if ( ((c > 0) && (d != 3))) {tr += (c * solve(a,b,(c - 1),3,mod)); tr %= mod; } tr %= mod; return dp[a][b][c][d] = tr;} public static void main( String[] args)throws IOException { Reader.init(System.in); PrintWriter out = new PrintWriter(System.out);  int n = Reader.nextInt(),t = Reader.nextInt();  long mod = ((long)1e9 + 7),fact[] = new long[16]; dp = new long[16][16][16][4]; for ( int i = 0;(i < 16);i++) {for ( int j = 0;(j < 16);j++) {for ( int k = 0;(k < 16);k++) Arrays.fill(dp[i][j][k],-1); }}fact[0] = 1; for ( int i = 1;(i <= 15);i++) {fact[i] = (i * fact[(i - 1)]); fact[i] %= mod; } NoD[] arr = new NoD[n]; for ( int i = 0;(i < n);i++) { int a = Reader.nextInt(),b = Reader.nextInt(); arr[i] = new NoD(a,b); } long ans = 0; for ( int i = 0;(i < (1 << n));i++) { int time = 0;  int prev = -1;  int t1 = 0,t2 = 0,t3 = 0;  long[] c = {i};  BitSet b = BitSet.valueOf(c); for ( int j = 0;(j < n);j++) {if ( b.get(j)) {time += arr[j].val; prev = arr[j].index; if ( (arr[j].index == 1)) t1++; else if ( (arr[j].index == 2)) t2++; else t3++; } }if ( (time == t)) { long v = 1;  long v2 = 1; v *= solve(t1,t2,t3,0,mod); v %= mod; ans += v; ans %= mod; } }out.println(ans); out.flush(); } } class NoD{ int val ,index ; NoD( int v, int i){ val = v; index = i; } }
4	public class a{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  String str = in.next();  int max = 0; for ( int i = 0;(i < str.length());i++) {for ( int j = (i + 1);(j <= str.length());j++) { String first = str.substring(i,j); for ( int k = (i + 1);(k <= (str.length() - first.length()));k++) {if ( str.substring(k,(k + first.length())).equals(first)) max = Math.max(max,first.length()); }}}System.out.println(max); } }
2	public class ProblemD{ InputReader in ; PrintWriter out ; void solve(){ long l = in.nextLong();  long r = in.nextLong();  long ans = 0;  boolean add = false; for ( int k = 62;(k >= 0);k--) { long cb = (1L << k); if ( ((l & cb) != (r & cb))) add = true; if ( add) ans += (1L << k); }out.println(ans); } ProblemD(){ boolean oj = (System.getProperty("ONLINE_JUDGE") != null); try{if ( oj) {in = new InputReader(System.in); out = new PrintWriter(System.out); } else { Writer w = new FileWriter("output.txt"); in = new InputReader(new FileReader("input.txt")); out = new PrintWriter(w); } }catch (Exception e){ throw (new RuntimeException(e));} solve(); out.close(); } public static void main( String[] args){ new ProblemD(); } } class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public InputReader( FileReader fr){ reader = new BufferedReader(fr); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastScanner in = new FastScanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ private final int MOD = (int)(1e9 + 7); public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  String[] arr = new String[n]; for ( int i = 0;(i < n);i++) {arr[i] = in.nextString(); } int[] dp = new int[n]; Arrays.parallelSetAll(dp,(i)->0); dp[0] = 1; int cnt = 0; for ( int i = 0;(i < n);i++) {if ( arr[i].equals("f")) {cnt++; continue;} calc(dp,n,cnt); cnt = 0; } int sum = 0; for ( int i = 0;(i < n);i++) {sum += dp[i]; sum %= MOD; }out.println(sum); } private void calc( int[] dp, int n, int cnt){ for ( int i = (n - 1);(i >= 0);i--) {if ( (i != (n - 1))) dp[i] += dp[(i + 1)]; dp[i] %= MOD; } int prev = dp[0]; for ( int i = 0,y = 0;(i < MathUtil.gcdInt(n,cnt));i++) {y = i; prev = dp[i]; do { int nextId = ((y + cnt) % n);  int tmp = dp[nextId]; dp[nextId] = prev; prev = tmp; y = nextId; }while((y != i));}} } static class FastScanner{ private BufferedReader br ; private StringTokenizer st ; public FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public FastScanner( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } public String nextString(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextString());} } }
4	public class C implements Runnable{ static private final Random rnd = new Random(); static private final String fileName = ""; private void solve(){ int n = readInt();  int m = readInt();  int k = readInt();  Point[] starts = readPointArray(k); for ( Point start :starts) {start.x--; start.y--; } Point furthest = bfs(n,m,starts); out.println((((furthest.x + 1) + " ") + (furthest.y + 1))); } private Point bfs( int n, int m, Point[] starts){ final int INF = ((n * m) + 1);  boolean[][] used = new boolean[n][m];  Queue<Integer> queue = new ArrayDeque<>(); for ( Point start :starts) {used[start.x][start.y] = true; queue.add(((start.x * m) + start.y)); } int last = -1; while((queue.size() > 0)){ int from = queue.poll(); last = from; int fromX = (from / m),fromY = (from % m); for ( int[] step :steps) { int toX = (fromX + step[0]);  int toY = (fromY + step[1]); if ( !checkCell(toX,n,toY,m)) continue; if ( used[toX][toY]) continue; used[toX][toY] = true; queue.add(((toX * m) + toY)); }}return new Point((last / m),(last % m));} static private final boolean FIRST_INPUT_STRING = false; static private final boolean MULTIPLE_TESTS = true; private final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); static private final int MAX_STACK_SIZE = 128; static private final boolean OPTIMIZE_READ_NUMBERS = false; private BufferedReader in ; private OutputWriter out ; private StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new C(),"",(MAX_STACK_SIZE * (1L << 20))).start(); } private void init()throws FileNotFoundException { Locale.setDefault(Locale.US); in = new BufferedReader(new FileReader("input.txt")); out = new OutputWriter("output.txt"); } private long timeBegin ; private void timeInit(){ this.timeBegin = System.currentTimeMillis(); } private void time(){ long timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } private String delim = " "; private String readLine(){ try{return in.readLine(); }catch (IOException e){ throw (new RuntimeIOException(e));} } private String readString(){ try{while(!tok.hasMoreTokens()){tok = new StringTokenizer(readLine()); }return tok.nextToken(delim); }catch (NullPointerException e){ return null;} } private final char NOT_A_SYMBOL = '\0'; private char[] readCharArray(){ return readLine().toCharArray();} private long optimizedReadLong(){ int sign = 1;  long result = 0;  boolean started = false; while(true){try{ int j = in.read(); if ( (-1 == j)) {if ( started) return (sign * result); throw (new NumberFormatException());} if ( (j == '-')) {if ( started) throw (new NumberFormatException()); sign = -sign; } if ( (('0' <= j) && (j <= '9'))) {result = (((result * 10) + j) - '0'); started = true; } else if ( started) {return (sign * result);} }catch (IOException e){ throw (new RuntimeIOException(e));} }} private int readInt(){ if ( !OPTIMIZE_READ_NUMBERS) {return Integer.parseInt(readString());} else {return (int)optimizedReadLong();}} private int[] readIntArray( int size){ int[] array = new int[size]; for ( int index = 0;(index < size);++index) {array[index] = readInt(); }return array;} private int[] readIntArrayWithDecrease( int size){ int[] array = readIntArray(size); for ( int i = 0;(i < size);++i) {array[i]--; }return array;} private long readLong(){ if ( !OPTIMIZE_READ_NUMBERS) {return Long.parseLong(readString());} else {return optimizedReadLong();}} private double readDouble(){ return Double.parseDouble(readString());} private Point readPoint(){ int x = readInt();  int y = readInt(); return new Point(x,y);} private Point[] readPointArray( int size){ Point[] array = new Point[size]; for ( int index = 0;(index < size);++index) {array[index] = readPoint(); }return array;} private static class GraphBuilder{ final int size ; final List<Integer>[] edges ; private GraphBuilder( List<Integer>[] edges){ this.size = edges.length; this.edges = edges; } public void addDirectedEdge( int from, int to){ edges[from].add(to); } } private static class IntIndexPair{ static Comparator<IntIndexPair> increaseComparator = new Comparator<C.IntIndexPair>(){}; static Comparator<IntIndexPair> decreaseComparator = new Comparator<C.IntIndexPair>(){}; int value ,index ; IntIndexPair( int value, int index){ super(); this.value = value; this.index = index; } } private static class OutputWriter extends PrintWriter{ final int DEFAULT_PRECISION = 12; private int precision ; private String format ,formatWithSpace ; {precision = DEFAULT_PRECISION; format = createFormat(precision); formatWithSpace = (format + " "); }OutputWriter( OutputStream out){ super(out); } OutputWriter( String fileName)throws FileNotFoundException{ super(fileName); } String createFormat( int precision){ return (("%." + precision) + "f");} @Override public void print( double d){ printf(format,d); } void printWithSpace( double d){ printf(formatWithSpace,d); } void printAll( double... d){ for ( int i = 0;(i < (d.length - 1));++i) {printWithSpace(d[i]); }print(d[(d.length - 1)]); } @Override public void println( double d){ printlnAll(d); } void printlnAll( double... d){ printAll(d); println(); } } private static class RuntimeIOException extends RuntimeException{ private static final long serialVersionUID = -6463830523020118289L; RuntimeIOException( Throwable cause){ super(cause); } } private static final int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; private static final int[][] steps8 = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{1,-1},{-1,1}}; private static boolean checkCell( int row, int rowsCount, int column, int columnsCount){ return (checkIndex(row,rowsCount) && checkIndex(column,columnsCount));} private static boolean checkIndex( int index, int lim){ return ((0 <= index) && (index < lim));} private static long gcd( long a, long b){ return ((a == 0)?b:gcd((b % a),a));} private static int[] castInt( List<Integer> list){ int[] array = new int[list.size()]; for ( int i = 0;(i < array.length);++i) {array[i] = list.get(i); }return array;} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastReader in = new FastReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, FastReader in, PrintWriter out){ Debug debug = new Debug(out);  int n = in.nextInt();  TaskC.Circle[] c = new TaskC.Circle[n];  double rr = in.nextInt(); for ( int i = 0;(i < n);++i) {c[i] = new TaskC.Circle(); c[i].x = in.nextInt(); } ArrayList<TaskC.Circle> done = new ArrayList<>(); for ( int i = 0;(i < n);++i) { TaskC.Circle cur = c[i];  double ans = Double.MIN_VALUE; for ( int j = 0;(j < done.size());++j) { TaskC.Circle dd = done.get(j); if ( (Double.compare((2 * rr),Math.abs((dd.x - cur.x))) < 0)) continue; double temp = (Math.sqrt((((4 * rr) * rr) - ((cur.x - dd.x) * (cur.x - dd.x)))) + dd.y); ans = Math.max(ans,temp); }if ( (ans == Double.MIN_VALUE)) ans = rr; cur.y = ans; done.add(cur); }for ( TaskC.Circle cc :done) {out.printf("%.12f ",cc.y); }} } static class Debug{ PrintWriter out ; boolean oj ; long timeBegin ; Runtime runtime ; public Debug( PrintWriter out){ oj = (System.getProperty("ONLINE_JUDGE") != null); this.out = out; this.timeBegin = System.currentTimeMillis(); this.runtime = Runtime.getRuntime(); } } static class FastReader{ private InputStream stream ; private byte[] buf = new byte[8192]; private int curChar ; private int pnumChars ; public FastReader( InputStream stream){ this.stream = stream; } private int pread(){ if ( (pnumChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= pnumChars)) {curChar = 0; try{pnumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (pnumChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = pread(); while(isSpaceChar(c))c = pread(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = pread(); } int res = 0; do {if ( (c == ',')) {c = pread(); } if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = pread(); }while(!isSpaceChar(c));return (res * sgn);} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
1	public class TaskA implements Runnable{ long m = ((int)1e9 + 7); PrintWriter w ; InputReader c ; final int MAXN = ((int)1e6 + 100); static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; private BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public String next(){ return readString();} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new TaskA(),"TaskA",(1 << 26)).start(); } }
4	public class ExplorerSpace{ private static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } public static int[][][] dp ; public static boolean valid( int i, int j, int n, int m){ return ((((i >= 0) && (i < n)) && (j >= 0)) && (j < m));} public static void solution( int n, int m, int k, int[][] h, int[][] v){ if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) out.print((-1 + " ")); out.println(); }return ;} dp = new int[n][m][((k / 2) + 1)]; for ( int t = 1;(t <= (k / 2));t++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[i][j][t] = Integer.MAX_VALUE; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[i][j][0] = 0; }}for ( int t = 1;(t <= (k / 2));t++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( valid(i,(j + 1),n,m)) dp[i][j][t] = Math.min(dp[i][j][t],(h[i][j] + dp[i][(j + 1)][(t - 1)])); if ( valid(i,(j - 1),n,m)) dp[i][j][t] = Math.min(dp[i][j][t],(h[i][(j - 1)] + dp[i][(j - 1)][(t - 1)])); if ( valid((i + 1),j,n,m)) dp[i][j][t] = Math.min(dp[i][j][t],(v[i][j] + dp[(i + 1)][j][(t - 1)])); if ( valid((i - 1),j,n,m)) dp[i][j][t] = Math.min(dp[i][j][t],(v[(i - 1)][j] + dp[(i - 1)][j][(t - 1)])); }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) out.print(((dp[i][j][(k / 2)] * 2) + " ")); out.println(); }} private static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ MyScanner s = new MyScanner();  int n = s.nextInt();  int m = s.nextInt();  int k = s.nextInt();  int[][] h = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {h[i][j] = s.nextInt(); }} int[][] v = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {v[i][j] = s.nextInt(); }}solution(n,m,k,h,v); out.flush(); out.close(); } }
5	public class A{ static final Scanner sc = new Scanner(System.in); void run(){ int n = sc.nextInt();  int[] xs = new int[n]; for ( int i = 0;(i < n);i++) {xs[i] = sc.nextInt(); }Arrays.sort(xs); xs[(n - 1)] = ((xs[(n - 1)] == 1)?2:1); Arrays.sort(xs); for ( int i = 0;(i < n);i++) System.out.print((xs[i] + " ")); } public static void main( String[] args){ new A().run(); } }
4	public class CF1497E2 extends PrintWriter{ CF1497E2(){ super(System.out); } static class Scanner{ Scanner( InputStream in){ this.in = in; } InputStream in ; byte[] bb = new byte[(1 << 15)]; int i ,n ; byte getc(){ if ( (i == n)) {i = n = 0; try{n = in.read(bb); }catch (IOException e){ } } return ((i < n)?bb[i++]:0);} int nextInt(){ byte c = 0; while((c <= ' '))c = getc(); int a = 0; while((c > ' ')){a = (((a * 10) + c) - '0'); c = getc(); }return a;} } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF1497E2 o = new CF1497E2(); o.main(); o.flush(); } static final int A = 10000000,K = 20; int[] cc = new int[(A + 1)]; { boolean[] composite = new boolean[(A + 1)]; for ( int a = 1;(a <= A);a++) cc[a] = a; for ( int a = 2;(a <= A);a++) {if ( composite[a]) continue; for ( int b = (a + a);(b <= A);b += a) composite[b] = true; if ( (a <= (A / a))) { int a2 = (a * a); for ( int b = a2;(b <= A);b += a2) { int c = cc[b]; while(((c % a2) == 0))c /= a2; cc[b] = c; }} }} void main(){ int[] pp = new int[(A + 1)]; Arrays.fill(pp,-1); int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  int k = sc.nextInt();  int[] aa = new int[n]; for ( int i = 0;(i < n);i++) aa[i] = cc[sc.nextInt()]; int[] mp = new int[(k + 1)];  int[] ip = new int[(k + 1)]; for ( int i = 0;(i < n);i++) { int a = aa[i]; for ( int h = k;(h >= 0);h--) {if ( (pp[a] >= ip[h])) {mp[h]++; ip[h] = i; } if ( ((h > 0) && ((mp[(h - 1)] < mp[h]) || ((mp[(h - 1)] == mp[h]) && (ip[(h - 1)] > ip[h]))))) {mp[h] = mp[(h - 1)]; ip[h] = ip[(h - 1)]; } }pp[a] = i; }println((mp[k] + 1)); for ( int i = 0;(i < n);i++) { int a = aa[i]; pp[a] = -1; }}} }
5	public class Seq2{ static void metod(){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); int min = a[0]; for ( int i = 1;(i < a.length);i++) {if ( (a[i] < min)) min = a[i]; } int min2 = min;  boolean t = false; for ( int i = 0;(i < a.length);i++) {if ( (a[i] != min)) {if ( !t) {min2 = a[i]; t = true; } else {if ( (min2 > a[i])) min2 = a[i]; }} }System.out.println(((min == min2)?"NO":min2)); } public static void main( String[] args){ Seq2.metod(); } }
4	public class C{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  int t = Integer.parseInt(f.readLine()); while((t-- > 0)){ int n = Integer.parseInt(f.readLine());  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(f.readLine()); } int[] levels = new int[n];  int curr_level = 0; for ( int i = 0;(i < n);i++) {if ( (levels[curr_level] == (arr[i] - 1))) {levels[curr_level]++; } else if ( (arr[i] == 1)) {curr_level++; levels[curr_level]++; } else if ( (arr[i] > 1)) {while(((curr_level > 0) && (levels[curr_level] != (arr[i] - 1)))){levels[curr_level] = 0; curr_level--; }levels[curr_level]++; } StringBuilder ostring = new StringBuilder(); for ( int level = 0;(level <= curr_level);level++) {ostring.append(levels[level]); if ( (level != curr_level)) ostring.append("."); }out.println(ostring); }}out.close(); } }
2	public class C{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  long s = scan.nextLong();  long low = 0;  long high = (n + 1); while(((high - low) > 1)){ long sum = 0;  long mid = ((high + low) / 2);  long value = findSum(mid,sum); if ( ((mid - value) >= s)) high = mid; else low = mid; }System.out.println(((n - high) + 1)); scan.close(); } public static long findSum( long n, long sum){ if ( (n == 0)) return sum; return findSum((n / 10),(sum + (n % 10)));} }
1	public class C{ static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st ; static PrintWriter out = new PrintWriter(System.out); static String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String s = bf.readLine(); if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(nextToken());} static String nextStr()throws IOException { return nextToken();} static int f( byte[] s, int n){ int l = 0,r = (n - 1);  int res = 0; do {while(((l < n) && (s[l] == 'H')))l++; while(((r >= 0) && (s[r] == 'T')))r--; if ( (l < r)) {res++; } l++; r--; }while((l < r));return res;} public static void main( String[] args)throws IOException { int n = nextInt();  byte s[] = nextStr().getBytes();  int res = f(s,n); for ( int i = 1;(i < n);i++) { byte c = s[0]; for ( int j = 0;(j < (n - 1));j++) s[j] = s[(j + 1)]; s[(n - 1)] = c; res = Math.min(res,f(s,n)); }out.println(res); out.flush(); } }
3	public class D{ public void solve( Scanner in, PrintWriter out){ int n = in.nextInt();  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);++i) a[i] = in.nextInt(); int[] rangeInv = new int[(n + 1)];  BIT bit = new BIT((n + 1)); for ( int i = 1;(i <= n);++i) { int cur = a[i];  int inv = (int)bit.sum(cur,n); rangeInv[i] = (rangeInv[(i - 1)] + inv); bit.add(cur,1); } int m = in.nextInt();  int curTotal = rangeInv[n]; for ( int qq = 0;(qq < m);++qq) { int l = in.nextInt();  int r = in.nextInt();  int N = ((r - l) + 1);  int total = ((N * (N - 1)) / 2);  int cur = (rangeInv[r] - rangeInv[(l - 1)]);  int newInv = (total - cur); curTotal -= cur; curTotal += newInv; if ( ((curTotal % 2) == 0)) {out.println("even"); } else {out.println("odd"); }}} public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out); new D().solve(in,out); in.close(); out.close(); } class BIT{ long[] tree ; int n ; public BIT( int n){ this.n = n; tree = new long[(n + 1)]; } public void add( int i, long val){ while((i <= n)){tree[i] += val; i += (i & -i); }} public long sum( int to){ long res = 0; for ( int i = to;(i >= 1);i -= (i & -i)) {res += tree[i]; }return res;} public long sum( int from, int to){ return (sum(to) - sum((from - 1)));} } }
3	public class Main{ public static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader(){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] args){ InputReader scn = new InputReader();  int n = scn.nextInt(),r = scn.nextInt();  double[] y = new double[n];  int[] x = new int[n];  boolean[] mark = new boolean[n]; for ( int i = 0;(i < n);i++) {x[i] = scn.nextInt(); }for ( int i = 0;(i < n);i++) { double yc = r; for ( int j = 0;(j < n);j++) {if ( ((i == j) || !mark[j])) {continue;} if ( (((x[i] + r) < (x[j] - r)) || ((x[i] - r) > (x[j] + r)))) {continue;} yc = Math.max(yc,(y[j] + Math.sqrt(Math.abs((Math.pow((x[i] - x[j]),2) - ((4 * r) * r)))))); }y[i] = yc; mark[i] = true; }for ( int i = 0;(i < n);i++) {System.out.print((y[i] + " ")); }System.out.println(); } }
2	public class Main{ public static void main( String[] args){ try{ String str ;  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  BufferedOutputStream bos = new BufferedOutputStream(System.out);  String eol = System.getProperty("line.separator");  byte[] eolb = eol.getBytes();  byte[] spaceb = " ".getBytes(); str = br.readLine(); int blank = str.indexOf(" ");  long l = Long.parseLong(str.substring(0,blank));  long r = Long.parseLong(str.substring((blank + 1)));  String one = "";  String two = ""; while((l > 0)){if ( ((l % 2) == 0)) {one = "0".concat(one); } else {one = "1".concat(one); }l /= 2; }while((r > 0)){if ( ((r % 2) == 0)) {two = "0".concat(two); } else {two = "1".concat(two); }r /= 2; }while((one.length() < 60)){one = "0".concat(one); }while((two.length() < 60)){two = "0".concat(two); } int iter = 0;  String xor = "";  boolean big = false;  boolean small = false; while((one.charAt(iter) == two.charAt(iter))){xor = xor.concat("0"); iter++; if ( (iter == 60)) {break;} }for ( int i = iter;(i < 60);i++) {xor = xor.concat("1"); }bos.write(new BigInteger(xor,2).toString().getBytes()); bos.write(eolb); bos.flush(); }catch (IOException ioe){ ioe.printStackTrace(); } } }
3	public class CF1141F{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  String[] split = br.readLine().split(" ");  int[] terms = new int[n];  int[] sums = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {terms[i] = Integer.parseInt(split[i]); sums[(i + 1)] = (sums[i] + terms[i]); } ArrayList<Block> blocks = new ArrayList<>(); for ( int i = 0;(i < n);i++) for ( int j = i;(j < n);j++) { int s = (sums[(j + 1)] - sums[i]); blocks.add(new Block(i,j,s)); }Collections.sort(blocks); ArrayList<Block> best = new ArrayList<>();  int i = 0; while((i < blocks.size())){ int curSum = blocks.get(i).sum;  ArrayList<Block> curBlocks = new ArrayList<>(); while(((i < blocks.size()) && (blocks.get(i).sum == curSum)))curBlocks.add(blocks.get(i++)); int[] memo = new int[(curBlocks.size() + 1)]; Arrays.fill(memo,-1); memo[curBlocks.size()] = 0; for ( int j = (curBlocks.size() - 1);(j >= 0);j--) { int idx = Collections.binarySearch(curBlocks,new Block((curBlocks.get(j).r + 1),(curBlocks.get(j).r + 1),curBlocks.get(j).sum)); if ( (idx < 0)) idx = (idx + 1); memo[j] = Math.max(memo[(j + 1)],(1 + memo[idx])); }if ( (memo[0] > best.size())) {best = new ArrayList<>(); int idx = 0; while((memo[idx] >= 1)){if ( (memo[idx] > memo[(idx + 1)])) best.add(curBlocks.get(idx)); idx++; }} } StringBuilder sb = new StringBuilder(); sb.append(best.size()).append("\n"); for ( Block b :best) {sb.append((b.l + 1)).append(" ").append((b.r + 1)).append("\n"); }System.out.print(sb); } static class Block implements Comparable<Block>{ int l ,r ,sum ; Block( int a, int b, int c){ l = a; r = b; sum = c; } } }
5	public class Solution{ class Q implements Comparable<Q>{ int p ,t ; Q( int q, int w){ p = q; t = w; } @Override public int compareTo( Q arg0){ if ( (p == arg0.p)) return (t - arg0.t); return (arg0.p - p);} } void solve()throws Exception { int n = nextInt();  int k = (nextInt() - 1);  Q[] a = new Q[n]; for ( int i = 0;(i < n);i++) a[i] = new Q(nextInt(),nextInt()); Arrays.sort(a); int ans = 1; for ( int i = (k - 1);(i >= 0);i--) if ( (a[i].compareTo(a[k]) == 0)) ans++; else break;for ( int i = (k + 1);(i < n);i++) if ( (a[i].compareTo(a[k]) == 0)) ans++; else break;out.println(ans); } public static void main( String[] args){ new Solution().run(); } public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } finally{out.close(); }} String nextToken()throws Exception { while(((st == null) || !st.hasMoreTokens())){ String s = in.readLine(); if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(nextToken());} BufferedReader in ; PrintWriter out ; StringTokenizer st ; }
6	public class Main{ public static void main( String[] args){ try(Scanner in=new Scanner(System.in)){ int bx = in.nextInt();  int by = in.nextInt();  int n = in.nextInt();  int[][] xy = new int[n][2];  int[] res = new int[(1 << n)];  int[] last = new int[(1 << n)]; for ( int i = 0;(i < n);i++) {xy[i] = new int[]{in.nextInt(),in.nextInt()}; } int[] ds = new int[n]; for ( int i = 0;(i < ds.length);i++) {ds[i] = time(xy[i][0],xy[i][1],bx,by); } int[][] d = new int[n][n]; for ( int i = 0;(i < d.length);i++) {for ( int j = 0;(j < d.length);j++) {d[i][j] = time(xy[i][0],xy[i][1],xy[j][0],xy[j][1]); }}Arrays.fill(res,Integer.MAX_VALUE); res[0] = 0; for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( ((i & mask(j)) != 0)) {if ( ((res[(i - mask(j))] + (2 * ds[j])) < res[i])) {res[i] = (res[(i - mask(j))] + (2 * ds[j])); last[i] = (i - mask(j)); } for ( int k = (j + 1);(k < n);k++) {if ( ((i & mask(k)) != 0)) {if ( ((((res[((i - mask(k)) - mask(j))] + ds[j]) + ds[k]) + d[j][k]) < res[i])) {res[i] = (((res[((i - mask(k)) - mask(j))] + ds[j]) + ds[k]) + d[j][k]); last[i] = ((i - mask(j)) - mask(k)); } } }break;} }} int cur = ((1 << n) - 1); System.out.println(res[cur]); int k = cur; while((k != 0)){System.out.print("0 "); int diff = (k - last[k]); for ( int i = 0;((i < n) && (diff != 0));i++) {if ( (((diff >> i) & 1) != 0)) {System.out.print(((i + 1) + " ")); diff -= (1 << i); } }k = last[k]; }System.out.println("0"); }} static int mask( int i){ return (1 << i);} static int time( int x, int y, int x1, int y1){ return (((x - x1) * (x - x1)) + ((y - y1) * (y - y1)));} }
6	public class Test{ static PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static int readInt(){ int ans = 0;  boolean neg = false; try{ boolean start = false; for ( int c = 0;((c = System.in.read()) != -1);) {if ( (c == '-')) {start = true; neg = true; continue;} else if ( ((c >= '0') && (c <= '9'))) {start = true; ans = (((ans * 10) + c) - '0'); } else if ( start) break; } }catch (IOException e){ } return (neg?-ans:ans);} public static void main( String[] args){ Test te = new Test(); te.start(); writer.flush(); } void start(){ int t = readInt(); while((t-- > 0)){ int n = readInt(),m = readInt();  int[][] a = new int[n][m];  int[][] e = new int[(n * m)][]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) {a[i][j] = readInt(); e[((i * m) + j)] = new int[]{a[i][j],j}; }Arrays.sort(e,(x,y)->((x[0] == y[0])?Integer.compare(x[1],y[1]):Integer.compare(y[0],x[0]))); Set<Integer> cols = new HashSet<>(); for ( int[] x :e) {cols.add(x[1]); if ( (cols.size() >= n)) break; } int[] dp = new int[(1 << n)]; Arrays.fill(dp,-1); dp[0] = 0; for ( int c :cols) {for ( int i = ((1 << n) - 1);(i >= 0);i--) { int u = (((1 << n) - 1) - i);  int p = u; if ( (dp[i] >= 0)) while((p > 0)){for ( int r = 0;(r < n);r++) { int sum = 0; for ( int j = 0;(j < n);j++) if ( (((p >> j) & 1) != 0)) sum += a[((j + r) % n)][c]; dp[(i | p)] = Math.max(dp[(i | p)],(dp[i] + sum)); }p = ((p - 1) & u); } }}writer.println(dp[((1 << n) - 1)]); }} }
4	public class FireAgain{ public static void main( String[] args)throws IOException { BufferedReader readData = new BufferedReader(new FileReader("input.txt"));  PrintWriter writer = new PrintWriter(new File("output.txt"));  String line = readData.readLine();  String[] temp = line.split(" ");  int n = Integer.valueOf(temp[0]);  int m = Integer.valueOf(temp[1]);  int x = 0,y = 0; line = readData.readLine(); int k = Integer.valueOf(line);  boolean[][] visited = new boolean[(n + 1)][(m + 1)];  Queue<Integer> qX = new LinkedList<Integer>();  Queue<Integer> qY = new LinkedList<Integer>(); line = readData.readLine(); String[] temp2 = line.split(" "); for ( int i = 0;(i < (temp2.length - 1));i += 2) {x = Integer.valueOf(temp2[i]); y = Integer.valueOf(temp2[(i + 1)]); visited[x][y] = true; qX.add(x); qY.add(y); }while(!qX.isEmpty()){x = qX.poll(); y = qY.poll(); if ( ((x >= 2) && !visited[(x - 1)][y])) {visited[(x - 1)][y] = true; qX.add((x - 1)); qY.add(y); } if ( (((x + 1) <= n) && !visited[(x + 1)][y])) {visited[(x + 1)][y] = true; qX.add((x + 1)); qY.add(y); } if ( ((y >= 2) && !visited[x][(y - 1)])) {visited[x][(y - 1)] = true; qX.add(x); qY.add((y - 1)); } if ( (((y + 1) <= m) && !visited[x][(y + 1)])) {visited[x][(y + 1)] = true; qX.add(x); qY.add((y + 1)); } }writer.write((x + " ")); writer.write((y + " ")); writer.close(); } }
3	public class C455C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = Integer.parseInt(sc.nextLine());  ArrayList<Integer> listCount = new ArrayList<Integer>(); listCount.add(1); boolean justf = false;  int p = 1000000007;  long ans = 0; for ( int x = 0;(x < n);x++) { String next = sc.nextLine(); if ( next.equals("f")) {if ( justf) {listCount.add(0); } else {for ( int i = 1;(i < listCount.size());i++) { int sum = ((listCount.get((i - 1)) + listCount.get(i)) % p); listCount.set(i,sum); }listCount.add(0); }justf = true; } else {if ( justf) {justf = false; } else {for ( int i = 1;(i < listCount.size());i++) { int sum = ((listCount.get((i - 1)) + listCount.get(i)) % p); listCount.set(i,sum); }}}}for ( int i = 0;(i < listCount.size());i++) {ans += listCount.get(i); }System.out.print((ans % p)); } }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a = sc.nextLong();  long b = sc.nextLong(); if ( ((b - a) <= 1)) System.out.println("-1"); else if ( (((b - a) == 2) && ((a % 2) == 1))) System.out.println("-1"); else {if ( ((a % 2) == 1)) System.out.println((((((a + 1) + " ") + (a + 2)) + " ") + (a + 3))); else System.out.println(((((a)+" " + (a + 1)) + " ") + (a + 2))); }sc.close(); } }
6	public class code839E{ public static void main( String[] args)throws Exception { BufferedReader bff = new BufferedReader(new InputStreamReader(System.in));  PrintWriter wff = new PrintWriter(System.out);  String[] st = bff.readLine().split(" ");  int V = Integer.parseInt(st[0]);  int K = Integer.parseInt(st[1]);  BronKerbosch bk = new BronKerbosch(V); for ( int i = 0;(i < V);i++) {st = bff.readLine().split(" "); for ( int j = 0;(j < V);j++) {if ( st[j].equals("1")) {bk.anadir(i,j); } }} long num = bk.numeroCamarilla(); wff.printf("%.12f\n",((((((num * (num - 1.0)) / 2) * K) / num) * K) / num)); wff.flush(); } static class BronKerbosch{ int V ; long[] neig ; Random random = new Random(); long maxClique ; public BronKerbosch( int v){ V = v; neig = new long[V]; } public void anadir( int a, int b){ long aux = 1; neig[a] |= (aux << (long)b); } public long numeroCamarilla(){ long numero = Long.bitCount(bronKerbosch()); return numero;} public long bronKerbosch(){ maxClique = 0; bronKerbosch2(0,((1L << V) - 1),0); return maxClique;} public void bronKerbosch2( long r, long p, long x){ if ( (Long.bitCount(maxClique) >= Long.bitCount(((r | p) | x)))) return ; long px = (p | x); if ( (px == 0)) {if ( (Long.bitCount(maxClique) < Long.bitCount(r))) {maxClique = r; } return ;} int cnt = Long.bitCount(px);  int choice = random.nextInt(cnt);  int u ; for ( int i = 0;;i++) {if ( ((((px >>> i) & 1) != 0) && (choice-- == 0))) {u = i; break;} } long ne = (p & ~neig[u]); for ( int v = 0;(v < V);v++) {if ( (((ne >>> v) & 1) != 0)) {bronKerbosch2((r | (1L << v)),(p & neig[v]),(x & neig[v])); p &= (1L << v); x |= (1L << v); } }} } }
0	public class composite{ public static void main( String[] args){ int b ;  Scanner s3 = new Scanner(System.in); b = s3.nextInt(); if ( ((b % 2) == 0)) {b = (b - 4); System.out.println(((4 + " ") + b)); } else {b = (b - 9); System.out.println(((9 + " ") + b)); }} }
4	public class Main{ static void deal( int n, int[] arr){ int[] a = new int[n]; a[0] = 1; int l = 1; out.println(toString(a,l)); for ( int i = 1;(i < n);i++) {if ( (arr[i] == 1)) {a[l] = 1; l++; } else { int index = (l - 1); while(((index >= 0) && (a[index] != (arr[i] - 1)))){index--; }a[index]++; l = (index + 1); }out.println(toString(a,l)); }} static String toString( int[] arr, int l){ StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < (l - 1));i++) {sb.append(arr[i]); sb.append('.'); }sb.append(arr[(l - 1)]); return sb.toString();} public static void main( String[] args){ MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextInt(); for ( int i = 0;(i < t);i++) { int n = sc.nextInt();  int[] arr = new int[n]; for ( int j = 0;(j < n);j++) arr[j] = sc.nextInt(); deal(n,arr); }out.close(); } public static PrintWriter out ; public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
6	public class Main{ static ArrayList<Integer> cols ; static int ans ,n ,a[][] ; public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int tc = sc.nextInt(); while((tc-- > 0)){ans = 0; n = sc.nextInt(); int m = sc.nextInt();  boolean[] taken = new boolean[m];  PriorityQueue<Pair> pq = new PriorityQueue<>(); a = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) { int cur = sc.nextInt(); pq.add(new Pair(i,j,cur)); a[i][j] = cur; }cols = new ArrayList<>(); while((!pq.isEmpty() && (cols.size() < 8))){ Pair cur = pq.remove(); if ( !taken[cur.j]) cols.add(cur.j); taken[cur.j] = true; }solve(0,new int[cols.size()]); out.println(ans); }out.flush(); out.close(); } static void solve( int i, int[] p){ if ( (i == cols.size())) { int[] max = new int[n]; for ( int k = 0;(k < cols.size());k++) { int j = cols.get(k); for ( int ii = 0;(ii < n);ii++) { int idx = ((ii + p[k]) % n); max[idx] = Math.max(max[idx],a[ii][j]); }} int poss = 0; for ( int x :max) poss += x; ans = Math.max(ans,poss); return ;} for ( int j = 0;(j < n);j++) {p[i] = j; solve((i + 1),p); }} static class Pair implements Comparable<Pair>{ int i ,j ,val ; public Pair( int i, int j, int val){ this.i = i; this.j = j; this.val = val; } } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream system){ br = new BufferedReader(new InputStreamReader(system)); } public Scanner( String file)throws Exception{ br = new BufferedReader(new FileReader(file)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
6	public class CF16E{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  double[][] aa = new double[n][n]; for ( int i = 0;(i < n);i++) { StringTokenizer st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < n);j++) aa[i][j] = Double.parseDouble(st.nextToken()); } double[][] pp = new double[(1 << n)][n]; for ( int k = 0;(k < n);k++) pp[(1 << k)][k] = 1; for ( int b = 1;(b < (1 << n));b++) { int c = 0; for ( int i = 0;(i < n);i++) {if ( ((b & (1 << i)) == 0)) continue; c++; for ( int j = (i + 1);(j < n);j++) {if ( ((b & (1 << j)) == 0)) continue; for ( int k = 0;(k < n);k++) {if ( ((b & (1 << k)) == 0)) continue; pp[b][k] += (aa[i][j] * pp[(b ^ (1 << j))][k]); pp[b][k] += (aa[j][i] * pp[(b ^ (1 << i))][k]); }}}if ( (c > 1)) { double p = (((double)c * (c - 1)) / 2); for ( int k = 0;(k < n);k++) pp[b][k] /= p; } } StringBuilder sb = new StringBuilder();  int b = ((1 << n) - 1); for ( int k = 0;(k < n);k++) sb.append(pp[b][k]).append(((k == (n - 1))?'\n':' ')); System.out.print(sb); } }
5	public class j{ public static void main( String[] a)throws IOException { BufferedReader b = new BufferedReader(new InputStreamReader(System.in));  int k = 0,i = 0,j = 0,n = 0,p = 0,t = 0;  String s ; s = b.readLine(); StringTokenizer c = new StringTokenizer(s); n = Integer.parseInt(c.nextToken()); k = Integer.parseInt(c.nextToken()); int d[] = new int[n];  int e[] = new int[n]; for ( i = 0;(i < n);i++) {s = b.readLine(); StringTokenizer z = new StringTokenizer(s); d[i] = Integer.parseInt(z.nextToken()); e[i] = Integer.parseInt(z.nextToken()); }for ( i = 0;(i < (n - 1));i++) {for ( j = (i + 1);(j < n);j++) {if ( (d[j] < d[i])) {t = d[j]; d[j] = d[i]; d[i] = t; t = e[j]; e[j] = e[i]; e[i] = t; } }}for ( i = 0;(i < (n - 1));i++) {if ( (((d[(i + 1)] - (e[(i + 1)] / 2.0)) - (d[i] + (e[i] / 2.0))) > k)) p += 2; if ( (((d[(i + 1)] - (e[(i + 1)] / 2.0)) - (d[i] + (e[i] / 2.0))) == k)) p++; }System.out.print((p + 2)); } }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); System.out.println(((n / 2) * 3)); } }
5	public class C111A{ static BufferedReader br ; public static void main( String[] args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); int n = toInt();  int nm[] = toIntArray();  double a = 0.0;  double sum = 0; for ( int i = 0;(i < n);i++) {sum += nm[i]; }a = (sum / 2); Arrays.sort(nm); int cur = 0;  int count = 0; for ( int i = (nm.length - 1);(i >= 0);i--) {cur += nm[i]; count++; if ( (cur > a)) {break;} }System.out.println(count); } public static int[] toIntArray()throws Exception { String str[] = br.readLine().split(" ");  int k[] = new int[str.length]; for ( int i = 0;(i < str.length);i++) {k[i] = Integer.parseInt(str[i]); }return k;} public static int toInt()throws Exception { return Integer.parseInt(br.readLine());} }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  String[] a = new String[n];  String[] b = new String[n]; for ( int i = 0;(i < n);i++) {a[i] = in.next(); }for ( int i = 0;(i < n);i++) {b[i] = in.next(); } int ans = 0; for ( int i = 1;(i < 5);i++) { int a1 = 0,b1 = 0,c1 = 0; for ( int j = 0;(j < n);j++) {if ( (a[j].length() == i)) {if ( (a[j].charAt((i - 1)) == 'M')) {a1++; } else if ( (a[j].charAt((i - 1)) == 'S')) {b1++; } else {c1++; }} }for ( int j = 0;(j < n);j++) {if ( (b[j].length() == i)) {if ( (b[j].charAt((i - 1)) == 'M')) {a1--; } else if ( (b[j].charAt((i - 1)) == 'S')) {b1--; } else {c1--; }} }if ( (a1 > 0)) ans += a1; if ( (b1 > 0)) ans += b1; if ( (c1 > 0)) ans += c1; }out.println(ans); } } static class InputReader{ private InputStream stream ; private byte[] inbuf = new byte[1024]; private int lenbuf = 0; private int ptrbuf = 0; public InputReader( InputStream stream){ this.stream = stream; } private int readByte(){ if ( (lenbuf == -1)) throw (new UnknownError()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = stream.read(inbuf); }catch (IOException e){ throw (new UnknownError());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} public String next(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} public int nextInt(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} } static class OutputWriter extends PrintWriter{ public OutputWriter( OutputStream out){ super(out); } public OutputWriter( Writer out){ super(out); } public void close(){ super.close(); } } }
3	public class Q3{ static class Pair{ int a ; int b ; Pair( int p, int q){ a = p; b = q; } } public static void main( String[] args){ InputReader in = new InputReader();  int N = in.nextInt();  int arr[] = new int[N]; for ( int i = 0;(i < N);i++) arr[i] = in.nextInt(); HashMap<Integer,ArrayList<Pair>> name = new HashMap<>(); for ( int i = 0;(i < N);i++) { int sum = 0; for ( int j = i;(j < N);j++) {sum += arr[j]; if ( (name.get(sum) == null)) name.put(sum,new ArrayList()); name.get(sum).add(new Pair((i + 1),(j + 1))); }} HashSet<Pair> ans = new HashSet<>(); for ( ArrayList<Pair> n :name.values()) {Collections.sort(n,new Comparator<Pair>(){@Override public int compare( Pair o1, Pair o2){ if ( (Integer.compare(o1.b,o2.b) == 0)) return Integer.compare(o1.a,o2.a); return Integer.compare(o1.b,o2.b);} }); HashSet<Pair> temp = new HashSet<>(); temp.add(n.get(0)); int num = 1;  int r = n.get(0).b; for ( int i = 1;(i < n.size());i++) {if ( (n.get(i).a > r)) {num++; r = n.get(i).b; temp.add(n.get(i)); } }if ( (num > ans.size())) ans = temp; }System.out.println(ans.size()); for ( Pair val :ans) System.out.println(((val.a + " ") + val.b)); } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader(){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public char nextChar(){ return next().charAt(0);} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} public static int[] radixSort( int[] f){ return radixSort(f,f.length);} public static int[] radixSort( int[] f, int n){ int[] to = new int[n]; { int[] b = new int[65537]; for ( int i = 0;(i < n);i++) b[(1 + (f[i] & 0xffff))]++; for ( int i = 1;(i <= 65536);i++) b[i] += b[(i - 1)]; for ( int i = 0;(i < n);i++) to[b[(f[i] & 0xffff)]++] = f[i]; int[] d = f; f = to; to = d; }{ int[] b = new int[65537]; for ( int i = 0;(i < n);i++) b[(1 + (f[i] >>> 16))]++; for ( int i = 1;(i <= 65536);i++) b[i] += b[(i - 1)]; for ( int i = 0;(i < n);i++) to[b[(f[i] >>> 16)]++] = f[i]; int[] d = f; f = to; to = d; }return f;} } }
6	public class B{ static int[][] dist ; static int[] dist1 ; static int[] dp ; static int[] path ; static int end ,x ,y ; static Point[] a ; public static int doit( int mask){ if ( (mask == end)) return 0; if ( (dp[mask] != -1)) return dp[mask]; int min = Integer.MAX_VALUE;  int t ;  int i ; for ( i = 0;(i < dist.length);i++) if ( (((1 << i) | mask) != mask)) break; t = ((2 * dist1[i]) + doit((mask | (1 << i)))); if ( (t < min)) {min = t; path[mask] = (1 << i); } for ( int j = (i + 1);(j < dist.length);j++) {if ( (((1 << j) | mask) == mask)) continue; t = (dist[i][j] + doit(((mask | (1 << i)) | (1 << j)))); if ( (t < min)) {min = t; path[mask] = ((1 << i) | (1 << j)); } }return dp[mask] = min;} public static void main( String[] args){ Scanner sc = new Scanner(System.in); x = sc.nextInt(); y = sc.nextInt(); a = new Point[sc.nextInt()]; for ( int i = 0;(i < a.length);i++) {a[i] = new Point(sc.nextInt(),sc.nextInt()); }end = ((1 << a.length) - 1); dp = new int[(1 << a.length)]; Arrays.fill(dp,-1); dist = new int[a.length][a.length]; dist1 = new int[a.length]; for ( int i = 0;(i < a.length);i++) {dist1[i] = (((a[i].x - x) * (a[i].x - x)) + ((a[i].y - y) * (a[i].y - y))); for ( int j = (i + 1);(j < a.length);j++) {dist[i][j] = ((((dist1[i] + ((a[j].x - a[i].x) * (a[j].x - a[i].x))) + ((a[j].y - a[i].y) * (a[j].y - a[i].y))) + ((a[j].x - x) * (a[j].x - x))) + ((a[j].y - y) * (a[j].y - y))); }}path = new int[dp.length]; System.out.println(doit(0)); int e = 0;  int cur = path[e];  StringBuffer bf = new StringBuffer(); bf.append((0 + " ")); int count = 0; for ( int i = 0;(count < a.length);i++) {for ( int j = 0;(j < a.length);j++) {if ( (((1 << j) | cur) == cur)) {bf.append(((j + 1) + " ")); count++; } }e |= cur; cur = path[e]; bf.append((0 + " ")); }System.out.println(bf); } }
2	public class Main7{ public static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} static int[] dis ; static int mod = 1000000007; static ArrayList<ArrayList<Integer>> graph ; static int[] ans ; public static int[] sort( int[] a){ int n = a.length;  ArrayList<Integer> ar = new ArrayList<>(); for ( int i = 0;(i < a.length);i++) {ar.add(a[i]); }Collections.sort(ar); for ( int i = 0;(i < n);i++) {a[i] = ar.get(i); }return a;} public static void main( String[] args)throws IOException { int n = i();  int k = i();  long low = 0;  long high = k;  long fin = 0;  long ans = 0; for ( int i = 1;(i <= n);i++) {ans += i; if ( (((Math.abs((ans - k)) + i) == n) && (ans >= k))) {fin = Math.abs((ans - k)); break;} }pln((fin + "")); } static InputReader in = new InputReader(System.in); static OutputWriter out = new OutputWriter(System.out); public static void pln( String value){ System.out.println(value); } public static int i(){ return in.Int();} } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int Int(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String String(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void close(){ writer.close(); } public void flush(){ writer.flush(); } }
5	public class Main{ static Input in ; static Output out ; public static void main( String[] args)throws IOException { in = new Input(System.in); out = new Output(System.out); run(); out.close(); System.exit(0); } private static void run()throws IOException { int n = in.nextInt(),k = in.nextInt();  int[] A = new int[n]; for ( int i = 0;(i < n);i++) {A[i] = in.nextInt(); }Arrays.sort(A); int count = n;  boolean[] hash = new boolean[n]; for ( int i = (n - 1);(i > 0);i--) {if ( !hash[i]) { int a = A[i]; if ( ((a % k) == 0)) { int p = (a / k);  int j = Arrays.binarySearch(A,p); if ( ((j >= 0) && (j < i))) {hash[j] = true; count--; } } } }out.print(count); } } class Input{ final int SIZE = 8192; private InputStream in ; private byte[] buf = new byte[SIZE]; private int last ,current ,total ; public Input( InputStream stream)throws IOException{ in = stream; last = read(); } private int read()throws IOException { if ( (total == -1)) return -1; if ( (current >= total)) {current = 0; total = in.read(buf); if ( (total <= 0)) return -1; } return buf[current++];} private void advance()throws IOException { while(true){if ( (last == -1)) return ; if ( !isValidChar(last)) last = read(); else break;}} private boolean isValidChar( int c){ return ((c > 32) && (c < 127));} public String nextString()throws IOException { advance(); if ( (last == -1)) throw (new EOFException()); StringBuilder s = new StringBuilder(); while(true){s.appendCodePoint(last); last = read(); if ( !isValidChar(last)) break; }return s.toString();} public String nextLine()throws IOException { if ( (last == -1)) throw (new EOFException()); StringBuilder s = new StringBuilder(); while(true){s.appendCodePoint(last); last = read(); if ( ((last == '\n') || (last == -1))) break; }return s.toString();} public String nextLine( boolean ignoreIfEmpty)throws IOException { if ( !ignoreIfEmpty) return nextLine(); String s = nextLine(); while((s.trim().length() == 0))s = nextLine(); return s;} public int nextInt()throws IOException { advance(); if ( (last == -1)) throw (new EOFException()); int n = 0,s = 1; if ( (last == '-')) {s = -1; last = read(); if ( (last == -1)) throw (new EOFException()); } while(true){n = (((n * 10) + last) - '0'); last = read(); if ( !isValidChar(last)) break; }return (n * s);} public void close()throws IOException { in.close(); in = null; } } class Output{ final int SIZE = 8192; private Writer out ; private char cb[] = new char[SIZE]; private int nChars = SIZE,nextChar = 0; private char lineSeparator = '\n'; public Output( OutputStream stream){ out = new OutputStreamWriter(stream); } void flushBuffer()throws IOException { if ( (nextChar == 0)) return ; out.write(cb,0,nextChar); nextChar = 0; } void write( int c)throws IOException { if ( (nextChar >= nChars)) flushBuffer(); cb[nextChar++] = (char)c; } void write( String s, int off, int len)throws IOException { int b = off,t = (off + len); while((b < t)){ int a = (nChars - nextChar),a1 = (t - b);  int d = ((a < a1)?a:a1); s.getChars(b,(b + d),cb,nextChar); b += d; nextChar += d; if ( (nextChar >= nChars)) flushBuffer(); }} void write( String s)throws IOException { write(s,0,s.length()); } public void print( Object obj)throws IOException { write(String.valueOf(obj)); } public void close()throws IOException { flushBuffer(); out.close(); out = null; } }
2	public class Main{ static class FastScanner{ private BufferedReader bufferedReader ; private StringTokenizer stringTokenizer ; public FastScanner( InputStream inputStream){ bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); } public String next(){ while(((stringTokenizer == null) || !stringTokenizer.hasMoreTokens())){try{stringTokenizer = new StringTokenizer(bufferedReader.readLine()); }catch (IOException ignored){ } }return stringTokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} } static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static Map<Integer,ArrayList<Integer>> g ; static Map<Integer,Integer> color ; static void dfs( int v, int c){ color.put(v,c); for ( int i = 0;(i < g.get(v).size());i++) { int u = g.get(v).get(i); if ( !color.containsKey(u)) {dfs(u,c); } }} static void reverse( Integer[] a){ Collections.reverse(Arrays.asList(a)); } static boolean next( Integer[] a){ int i = (a.length - 1); while((a[i] == 0))i--; int c = 0; while(((i >= 0) && (a[i] == 1))){c++; i--; }if ( (i < 0)) return false; a[i] = 1; for ( int j = (i + 1);(j < a.length);j++) {a[j] = 0; }c--; for ( int j = 0;(j < c);j++) {a[((a.length - 1) - j)] = 1; }return true;} private static int bin( Integer[] a, int l, int r, int x){ if ( (l >= r)) return l; int m = ((l + r) / 2); if ( (a[m] > x)) {return bin(a,l,m,x);} else if ( ((a[m] < x) || ((m < (a.length - 1)) && (a[(m + 1)] == x)))) {return bin(a,(m + 1),r,x);} return (m + 1);} public static void main( String[] args){ FastScanner scanner = new FastScanner(System.in);  PrintWriter printer = new PrintWriter(System.out);  long n = scanner.nextLong();  long k = scanner.nextLong();  long l = 1;  long r = n; while(true){ long m = ((l + r) / 2);  long x = ((m * (m + 1)) / 2); x -= (n - m); if ( (x == k)) {printer.println((n - m)); break;} else if ( (x < k)) {l = (m + 1); } else {r = (m - 1); }}printer.flush(); printer.close(); } }
5	public class A{ public static void main( String[] args)throws Exception { new A().solve(); } void solve()throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] sp ; sp = in.readLine().split(" "); int n = Integer.parseInt(sp[0]);  long k = Integer.parseInt(sp[1]);  Long[] a = new Long[n]; sp = in.readLine().split(" "); for ( int i = 0;(i < n);i++) {a[i] = (long)Integer.parseInt(sp[i]); }Arrays.sort(a); TreeSet<Long> set = new TreeSet<Long>(); for ( int i = 0;(i < n);i++) { long x = a[i]; if ( !set.contains(x)) {set.add((x * k)); } }System.out.println(set.size()); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  String arr1[] = new String[n];  String arr2[] = new String[n];  int i ,j ,count = 0; for ( i = 0;(i < n);i++) {arr1[i] = in.nextString(); }for ( i = 0;(i < n);i++) {arr2[i] = in.nextString(); for ( j = 0;(j < n);j++) {if ( arr2[i].equals(arr1[j])) {arr1[j] = ""; count++; break;} }}out.println((n - count)); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String nextString(){ int c = read(); while(isSpaceChar(c)){c = read(); } StringBuilder res = new StringBuilder(); do {if ( Character.isValidCodePoint(c)) {res.appendCodePoint(c); } c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void close(){ writer.close(); } public void println( int i){ writer.println(i); } } }
6	public class Songs{ static class Reader{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Reader(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws IOException { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } public static void main( String[] args)throws IOException { Reader sc = new Reader();  PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int i ,j ;  int n = sc.nextInt();  int tt = sc.nextInt();  int t[] = new int[n];  int g[] = new int[n];  int last = 0;  int M = 1000000007;  long sum = 0; for ( i = 0;(i < n);i++) {t[i] = sc.nextInt(); g[i] = (sc.nextInt() - 1); } int d[][] = new int[(1 << n)][4]; d[0][3] = 1; for ( i = 0;(i < (1 << n));i++) {for ( last = 0;(last < 4);last++) {for ( j = 0;(j < n);j++) {if ( ((g[j] != last) && ((i & (1 << j)) == 0))) {d[(i ^ (1 << j))][g[j]] = ((d[(i ^ (1 << j))][g[j]] + d[i][last]) % M); } }} int dur = 0; for ( j = 0;(j < n);j++) {if ( ((i & (1 << j)) > 0)) {dur += t[j]; } }if ( (dur == tt)) {sum = ((((sum + d[i][0]) + d[i][1]) + d[i][2]) % M); } }pw.println(sum); pw.close(); } }
4	public class Main{ public static void main( String[] args){ InputStream inputStream ; try{inputStream = new FileInputStream("input.txt"); }catch (IOException e){ throw (new RuntimeException(e));} OutputStream outputStream ; try{outputStream = new FileOutputStream("output.txt"); }catch (IOException e){ throw (new RuntimeException(e));} InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  CFireAgain solver = new CFireAgain(); solver.solve(1,in,out); out.close(); } static class CFireAgain{ private int n ; private int m ; private int K ; private boolean[][] vis ; private Queue<Util.Pair<Integer>> queue = new LinkedList<>(); private Util.Pair<Integer> p ; private boolean isValid( int x, int y){ return (((((x >= 1) && (x <= n)) && (y >= 1)) && (y <= m)) && !vis[x][y]);} private void bfs(){ while(!queue.isEmpty()){p = queue.poll(); if ( isValid((p.x + 1),p.y)) {queue.offer(new Util.Pair<>((p.x + 1),p.y)); vis[(p.x + 1)][p.y] = true; } if ( isValid((p.x - 1),p.y)) {queue.offer(new Util.Pair<>((p.x - 1),p.y)); vis[(p.x - 1)][p.y] = true; } if ( isValid(p.x,(p.y + 1))) {queue.offer(new Util.Pair<>(p.x,(p.y + 1))); vis[p.x][(p.y + 1)] = true; } if ( isValid(p.x,(p.y - 1))) {queue.offer(new Util.Pair<>(p.x,(p.y - 1))); vis[p.x][(p.y - 1)] = true; } }} public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.nextInt(); m = in.nextInt(); K = in.nextInt(); vis = new boolean[(n + 1)][(m + 1)]; for ( int i = 0;(i < K);i++) { int a = in.nextInt(),b = in.nextInt(); vis[a][b] = true; queue.offer(new Util.Pair<>(a,b)); }bfs(); out.println(((p.x + " ") + p.y)); out.flush(); } } static class OutputWriter{ private final PrintWriter writer ; private ArrayList<String> res = new ArrayList<>(); private StringBuilder sb = new StringBuilder(""); public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void println( Object... objects){ for ( int i = 0;(i < objects.length);i++) {sb.append(objects[i]); }res.add(sb.toString()); sb = new StringBuilder(""); } public void close(){ writer.close(); } public void flush(){ for ( String str :res) writer.printf("%s\n",str); res.clear(); sb = new StringBuilder(""); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[8192]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public InputReader( FileInputStream file){ this.stream = file; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res = ((((res << 3) + (res << 1)) + c) - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
3	public class A{ String filename = ""; final int INF = 1_000_000_000; void solve(){ int n = readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = readInt(); } Map<Integer,Integer>[] maps = new Map[n];  Map<Integer,Integer> sums = new HashMap(); for ( int i = 0;(i < n);i++) {maps[i] = new HashMap<>(); }for ( int i = 0;(i < n);i++) { int summ = 0; for ( int j = i;(j < n);j++) {summ += a[j]; if ( !maps[i].containsKey(summ)) maps[i].put(summ,j);  int x = sums.getOrDefault(summ,0); sums.put(summ,(x + 1)); }} int max = 0;  int goodSumm = 0; for ( int summ :sums.keySet()) {if ( (sums.get(summ) <= max)) continue; int right = -1;  int ans = 0; for ( int j = 0;(j < n);j++) {if ( !maps[j].containsKey(summ)) continue; int end = maps[j].get(summ); if ( (right == -1)) {right = end; ans++; continue;} if ( (j > right)) {right = end; ans++; continue;} if ( (end < right)) {right = end; } }if ( (max < ans)) {max = ans; goodSumm = summ; } } int left = -1;  int right = -1;  List<Integer> ans = new ArrayList<>(); for ( int j = 0;(j < n);j++) {if ( !maps[j].containsKey(goodSumm)) continue; int start = j;  int end = maps[j].get(goodSumm); if ( (right == -1)) {left = j; right = end; continue;} if ( (start > right)) {ans.add((left + 1)); ans.add((right + 1)); left = start; right = end; continue;} if ( (end < right)) {left = start; right = end; } }ans.add((left + 1)); ans.add((right + 1)); out.println(max); for ( int i = 0;(i < ans.size());i += 2) {out.println(((ans.get(i) + " ") + ans.get((i + 1)))); }} public static void main( String[] args)throws FileNotFoundException { new A().run(); } void run()throws FileNotFoundException { init(); solve(); out.close(); } BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws FileNotFoundException { if ( !filename.equals("")) {in = new BufferedReader(new FileReader(new File((filename + ".in")))); out = new PrintWriter(new File((filename + ".out"))); return ;} in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } String readLine(){ try{return in.readLine(); }catch (Exception e){ throw (new RuntimeException(e));} } String readString(){ while(!tok.hasMoreTokens()){ String nextLine = readLine(); if ( (nextLine == null)) return null; tok = new StringTokenizer(nextLine); }return tok.nextToken();} int readInt(){ return Integer.parseInt(readString());} }
5	public class Codeforces_2012_08_31_A{ public static void main( String[] args)throws IOException { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));  PrintWriter out = new PrintWriter(System.out); in.nextToken(); int n = (int)in.nval;  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {in.nextToken(); a[i] = (int)in.nval; } int[] b = Arrays.copyOf(a,n); Arrays.sort(a); int k = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) k++; }if ( ((k == 0) || (k == 2))) out.println("YES"); else out.println("NO"); out.flush(); out.close(); } }
5	public class Main{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int m = s.nextInt();  int k = s.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < a.length);i++) {a[i] = s.nextInt(); } int ans = 0; while((k < m)){k--; int max = -1;  int ix = -1; for ( int i = 0;(i < a.length);i++) {if ( (a[i] > max)) {max = a[i]; ix = i; } }if ( (ix == -1)) {System.out.println("-1"); return ;} k += a[ix]; a[ix] = -1; ans++; }System.out.println(ans); } }
2	public class Main implements Runnable{ public void _main()throws IOException { long n = nextLong();  long m = nextLong();  long k = nextLong();  long numBlocks = Math.min(Math.min((n / k),(n - m)),(m / (k - 1))); n -= (numBlocks * k); m -= (numBlocks * (k - 1)); long numFullBlocks = (m / k);  long rem = (m % k);  long res = 0; res = ((res + ((((p2((numFullBlocks + 1)) + MOD) - 2) % MOD) * k)) % MOD); res = ((res + rem) % MOD); res = ((res + (numBlocks * (k - 1))) % MOD); out.println(res); } final int MOD = 1000000009; private long p2( long s){ long res = 1;  long x = 2; while((s > 0)){if ( ((s % 2) == 1)) {res = ((res * x) % MOD); } x = ((x * x) % MOD); s /= 2; }return res;} private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String rl = in.readLine(); if ( (rl == null)) return null; st = new StringTokenizer(rl); }return st.nextToken();} private long nextLong()throws IOException { return Long.parseLong(next());} public static void main( String[] args){ Locale.setDefault(Locale.UK); new Thread(new Main()).start(); } }
4	public class phoenix_and_computers{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] st = br.readLine().split(" ");  int n = Integer.parseInt(st[0]);  int m = Integer.parseInt(st[1]);  long[][] ncr = ncrcoll(405,405,m);  int[] p2 = new int[(n + 1)]; p2[0] = 1; for ( int i = 1;(i < p2.length);i++) {p2[i] = ((2 * p2[(i - 1)]) % m); } long[][] dp = new long[405][405]; dp[0][0] = 1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= i);j++) {for ( int k = 1;((i + k) <= n);k++) {dp[((i + k) + 1)][(j + k)] += (((dp[i][j] * p2[(k - 1)]) % m) * ncr[(j + k)][k]); dp[((i + k) + 1)][(j + k)] %= m; }}} long ans = 0; for ( int i = 0;(i <= n);i++) {ans = ((ans + dp[(n + 1)][i]) % m); }System.out.println(ans); } static long[][] ncrcoll( int n, int k, int p){ long[][] arr = new long[(n + 1)][(k + 1)]; for ( int i = 1;(i < arr.length);i++) {arr[i][0] = 1; }for ( int i = 1;(i < arr.length);i++) {for ( int j = 1;((j <= i) && (j < arr[0].length));j++) {if ( ((i == 1) && (j == 1))) {arr[i][j] = 1; } else {arr[i][j] = ((arr[(i - 1)][j] + arr[(i - 1)][(j - 1)]) % p); }}}return arr;} }
4	public class FireAgain{ int k ,i ,j ,n ,m ,x ,y ; void run(){ try{ BufferedReader bfd = new BufferedReader(new FileReader("input.txt"));  BufferedWriter out = new BufferedWriter(new FileWriter("output.txt"));  StringTokenizer tk = new StringTokenizer(bfd.readLine()); n = Integer.parseInt(tk.nextToken()); m = Integer.parseInt(tk.nextToken()); boolean vis[][] = new boolean[n][m]; k = Integer.parseInt(bfd.readLine()); tk = new StringTokenizer(bfd.readLine()); Queue<Point> q = new LinkedList<Point>();  Point last = new Point(0,0); while((k-- > 0)){x = (Integer.parseInt(tk.nextToken()) - 1); y = (Integer.parseInt(tk.nextToken()) - 1); q.add(new Point(x,y)); vis[x][y] = true; }while(!q.isEmpty()){ Point frnt = q.poll(); for ( i = (frnt.x - 1);(i <= (frnt.x + 1));++i) for ( j = (frnt.y - 1);(j <= (frnt.y + 1));++j) if ( ((val(i,j) && !vis[i][j]) && ((frnt.x == i) || (frnt.y == j)))) {q.add(new Point(i,j)); last = new Point(i,j); vis[i][j] = true; } }out.write(((((last.x + 1) + " ") + (last.y + 1)) + "\n")); out.flush(); out.close(); }catch (Exception e){ } } boolean val( int x, int y){ return ((((x >= 0) && (x < n)) && (y >= 0)) && (y < m));} public static void main( String[] args){ new FireAgain().run(); } }
6	public class C{ static int K ; static int sz[] ; static long vs[][] ; static long curSum[] ; static HashMap<Long,Integer> valToBucket ; static long sum ; static int maskIfPick[][] ; static int dp[] ; static int pickId[] ; static int newBox[] ; public static void main( String[] args){ FS in = new FS(); K = in.nextInt(); sz = new int[K]; valToBucket = new HashMap<Long,Integer>(); vs = new long[K][]; curSum = new long[K]; sum = 0; for ( int i = 0;(i < K);i++) {sz[i] = in.nextInt(); vs[i] = new long[sz[i]]; for ( int j = 0;(j < sz[i]);j++) { long v = in.nextLong(); sum += v; curSum[i] += v; vs[i][j] = v; valToBucket.put(v,i); }}if ( ((sum % K) != 0)) {System.out.println("No"); return ;} sum /= K; maskIfPick = new int[K][]; for ( int i = 0;(i < K);i++) {maskIfPick[i] = new int[sz[i]]; for ( int j = 0;(j < sz[i]);j++) { int mask = (1 << i);  boolean works = false;  long curLookfor = (sum - (curSum[i] - vs[i][j])); while(true){if ( !valToBucket.containsKey(curLookfor)) break; int nextBucket = valToBucket.get(curLookfor); if ( (nextBucket == i)) {works = (curLookfor == vs[i][j]); break;} else if ( ((mask & (1 << nextBucket)) > 0)) break; else {mask |= (1 << nextBucket); curLookfor = (sum - (curSum[nextBucket] - curLookfor)); }}if ( works) maskIfPick[i][j] = mask; }}dp = new int[(1 << K)]; Arrays.fill(dp,-1); int res = go(0); if ( (res == 0)) {System.out.println("No"); } else {System.out.println("Yes"); pickId = new int[K]; newBox = new int[K]; Arrays.fill(pickId,-1); buildback(0); for ( int i = 0;(i < K);i++) {System.out.println(((vs[i][pickId[i]] + " ") + (newBox[i] + 1))); }}} static void pick( int i, int j){ if ( (pickId[i] != -1)) return ; pickId[i] = j; long curLookfor = (sum - (curSum[i] - vs[i][j]));  int nextBucket = valToBucket.get(curLookfor); newBox[nextBucket] = i; for ( int k = 0;(k < sz[nextBucket]);k++) {if ( (vs[nextBucket][k] == curLookfor)) pick(nextBucket,k); }} static int go( int mask){ if ( ((mask + 1) == (1 << K))) return 1; if ( (dp[mask] != -1)) return dp[mask]; int bit = -1; for ( int i = 0;(i < K);i++) {if ( ((mask & (1 << i)) == 0)) {bit = i; break;} } int res = 0; for ( int take = 0;(take < sz[bit]);take++) { int newMask = maskIfPick[bit][take]; if ( ((newMask == 0) || ((mask & newMask) > 0))) continue; res = (res | go((mask | newMask))); }return dp[mask] = res;} static void buildback( int mask){ if ( ((mask + 1) == (1 << K))) return ; int bit = -1; for ( int i = 0;(i < K);i++) {if ( ((mask & (1 << i)) == 0)) {bit = i; break;} } int res = 0; for ( int take = 0;(take < sz[bit]);take++) { int newMask = maskIfPick[bit][take]; if ( ((newMask == 0) || ((mask & newMask) > 0))) continue; res = (res | go((mask | newMask))); if ( (res == 1)) {pick(bit,take); buildback((mask | newMask)); break;} }} static class FS{ BufferedReader br ; StringTokenizer st ; public FS(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw (null);} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} } }
1	public class Main{ static MyScanner scan ; static PrintWriter pw ; public static void main( String[] args){ new Thread(null,null,"_",(1 << 25)){}.start(); } static void solve()throws IOException { scan = new MyScanner(); pw = new PrintWriter(System.out,true); StringBuilder sb = new StringBuilder();  int n = ni();  int d = ni();  int arr[] = new int[n];  int cnt = 2; for ( int i = 0;(i < n);++i) arr[i] = ni(); for ( int i = 0;(i < (n - 1));++i) {if ( ((arr[(i + 1)] - d) == (arr[i] + d))) {++cnt; continue;} if ( ((arr[(i + 1)] - (arr[i] + d)) > d)) ++cnt; if ( (((arr[(i + 1)] - d) - arr[i]) > d)) ++cnt; }pl(cnt); pw.flush(); pw.close(); } static long modpow( long x, long y, long MOD){ if ( (y == 0)) return 1; if ( ((y & 1) == 0)) return modpow(((x * x) % MOD),(y >> 1),MOD); else return ((x * modpow(x,(y - 1),MOD)) % MOD);} static int ni()throws IOException { return scan.nextInt();} static void pl(){ pw.println(); } static void pl( Object o){ pw.println(o); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String nextLine()throws IOException { return br.readLine();} String next()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} long nextLong()throws IOException { return Long.parseLong(next());} double nextDouble()throws IOException { return Double.parseDouble(next());} } }
3	public class Test{ final int N = 5010; final int M = 1_000_000_007; long[][] dp = new long[2][N]; long[] sums = new long[N]; char[] p = new char[N]; Scanner sca = new Scanner(System.in); void start(){ int n = Integer.parseInt(sca.nextLine());  int idx = 0; Arrays.fill(dp[idx],0); dp[idx][0] = 1; for ( int i = 0;(i < n);i++) p[i] = sca.nextLine().charAt(0); for ( int i = 0;(i < n);) { int nidx = (idx ^ 1); Arrays.fill(dp[nidx],0); Arrays.fill(sums,0); int j = i; while((p[j] != 's'))j++; int levels = (j - i); i = (j + 1); for ( j = n;(j >= 0);j--) {sums[j] = (sums[(j + 1)] + dp[idx][j]); if ( (sums[j] >= M)) sums[j] -= M; }for ( j = 0;(j <= n);j++) { int ind = (j + levels); if ( (ind > n)) continue; dp[nidx][ind] = sums[j]; }idx = nidx; } long ans = 0; for ( int i = 0;(i <= n);i++) {ans += dp[idx][i]; if ( (ans >= M)) ans -= M; }System.out.println(ans); } public static void main( String[] args){ new Test().start(); } }
1	public class Main{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = 0; n = Integer.parseInt(br.readLine()); String inp = ""; inp = br.readLine(); int no[] = new int[n];  String tinp[] = inp.split(" "); for ( int i = 0;(i < n);i++) {no[i] = Integer.parseInt(tinp[i]); } int eve = 0,odd = 0; for ( int i = 0;(i < 3);i++) { int rem = (no[i] % 2); if ( (rem == 0)) eve++; else odd++; }if ( (eve > 1)) {for ( int i = 0;(i < n);i++) {if ( ((no[i] % 2) == 1)) {System.out.println((i + 1)); break;} }} else {for ( int i = 0;(i < n);i++) {if ( ((no[i] % 2) == 0)) {System.out.println((i + 1)); break;} }}} }
1	public class Main{ public static void main( String[] argv){ new Main(); } boolean test = false; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));  int n = in.nextInt();  int nM = 0;  int[] nS = new int[4];  int[] nL = new int[4]; for ( int i = 0;(i < n);i++) { String s = in.next();  int ns = s.length(); if ( (s.charAt(0) == 'M')) nM++; else if ( (s.charAt((ns - 1)) == 'S')) nS[(ns - 1)]++; else nL[(ns - 1)]++; } int c = 0;  int[] nSr = new int[4];  int[] nLr = new int[4];  int nMr = 0; for ( int i = 0;(i < n);i++) { String s = in.next();  int ns = s.length(); if ( (s.charAt(0) == 'M')) {if ( (nM > 0)) --nM; else ++nMr; } else if ( (s.charAt((ns - 1)) == 'S')) {if ( (nS[(ns - 1)] > 0)) --nS[(ns - 1)]; else ++nSr[(ns - 1)]; } else {if ( (nL[(ns - 1)] > 0)) --nL[(ns - 1)]; else ++nLr[(ns - 1)]; }}for ( int i = 0;(i < 4);i++) c += (nS[i] + nL[i]); c += nM; System.out.println(c); } private void swap( char[] a, int i, int j){ char t = a[i]; a[i] = a[j]; a[j] = t; } private long gcd( long x, long y){ if ( (y == 0)) return x; return gcd(y,(x % y));} static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader( BufferedReader in){ br = in; } String next(){ while(((st == null) || !st.hasMoreElements())){try{ String line = br.readLine(); if ( ((line == null) || (line.length() == 0))) return ""; st = new StringTokenizer(line); }catch (IOException e){ return "";} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
1	public class B{ void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),k = sc.nextInt();  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) a[i] = sc.nextInt(); int[] c = new int[100001];  int num = 0;  int ri = -1,rj = -1;  int s = 1,t = 0; while((t < n)){t++; if ( (c[a[t]] == 0)) {num++; } c[a[t]]++; for ( ;(k <= num);s++) {if ( ((ri == -1) || (((rj - ri) + 1) > ((t - s) + 1)))) {ri = s; rj = t; } c[a[s]]--; if ( (c[a[s]] == 0)) {num--; } }}System.out.println(((ri + " ") + rj)); } public static void main( String[] args){ new B().run(); } }
6	public class r568p8{ private static InputReader sc ; private static PrintWriter pw ; private static long mod ; static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ,snumChars ; private SpaceCharFilter filter ; InputReader( InputStream stream){ this.stream = stream; } int snext(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} int nextInt(){ int c = snext(); while(isSpaceChar(c)){c = snext(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = snext(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = snext(); }while(!isSpaceChar(c));return (res * sgn);} boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public interface SpaceCharFilter{ boolean isSpaceChar( int ch); } } public static void main( String[] args){ sc = new InputReader(System.in); pw = new PrintWriter(System.out); int t = 1; while((t-- > 0))solve(); pw.flush(); pw.close(); } private static void fill_matrix( long[][][][] dp, int a, int b, int c, int end){ if ( ((((((a == 0) && (b == 0)) && (c == 0)) || ((a == 0) && (end == 0))) || ((b == 0) && (end == 1))) || ((c == 0) && (end == 2)))) {dp[a][b][c][end] = 0; return ;} if ( (((a > 1) && (b == 0)) && (c == 0))) {dp[a][b][c][end] = 0; return ;} if ( (((b > 1) && (a == 0)) && (c == 0))) {dp[a][b][c][end] = 0; return ;} if ( (((c > 1) && (a == 0)) && (b == 0))) {dp[a][b][c][end] = 0; return ;} if ( ((((a == 1) && (end == 0)) && (b == 0)) && (c == 0))) {dp[a][b][c][end] = 1; return ;} if ( ((((b == 1) && (end == 1)) && (a == 0)) && (c == 0))) {dp[a][b][c][end] = 1; return ;} if ( ((((c == 1) && (end == 2)) && (b == 0)) && (a == 0))) {dp[a][b][c][end] = 1; return ;} if ( (end == 0)) {fill_matrix(dp,(a - 1),b,c,1); fill_matrix(dp,(a - 1),b,c,2); dp[a][b][c][0] = (((dp[(a - 1)][b][c][1] % mod) + (dp[(a - 1)][b][c][2] % mod)) % mod); } else if ( (end == 1)) {fill_matrix(dp,a,(b - 1),c,0); fill_matrix(dp,a,(b - 1),c,2); dp[a][b][c][1] = (((dp[a][(b - 1)][c][0] % mod) + (dp[a][(b - 1)][c][2] % mod)) % mod); } else {fill_matrix(dp,a,b,(c - 1),0); fill_matrix(dp,a,b,(c - 1),1); dp[a][b][c][2] = (((dp[a][b][(c - 1)][0] % mod) + (dp[a][b][(c - 1)][1] % mod)) % mod); }} private static long cal( int[] count){ int a = count[0],b = count[1],c = count[2];  long dp[][][][] = new long[(a + 1)][(b + 1)][(c + 1)][3];  long factorial[] = new long[20]; factorial[0] = 1; factorial[1] = 1; for ( int i = 2;(i < 20);i++) factorial[i] = ((((factorial[(i - 1)] % mod) * i) % mod) % mod); fill_matrix(dp,a,b,c,0); fill_matrix(dp,a,b,c,1); fill_matrix(dp,a,b,c,2); long p = ((((dp[a][b][c][0] % mod) + (dp[a][b][c][1] % mod)) + (dp[a][b][c][2] % mod)) % mod);  long ans = ((((((((((p % mod) * factorial[a]) % mod) % mod) * factorial[b]) % mod) % mod) * factorial[c]) % mod) % mod); return ans;} private static void solve(){ int n = sc.nextInt(),T = sc.nextInt();  int len[] = new int[n],genre[] = new int[n]; for ( int i = 0;(i < n);i++) {len[i] = sc.nextInt(); genre[i] = sc.nextInt(); } int sum[] = new int[(1 << n)]; mod = ((long)1e9 + 7); long ans = 0; for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < 15);j++) {if ( ((i & (1 << j)) != 0)) {sum[i] = (sum[(i ^ (1 << j))] + len[j]); break;} }if ( (sum[i] == T)) { int count[] = {0,0,0}; for ( int j = 0;(j < 15);j++) {if ( ((i & (1 << j)) != 0)) count[(genre[j] - 1)]++; }ans = (((ans % mod) + (cal(count) % mod)) % mod); } }pw.println(+ans); } }
2	public class C{ private static Solver solver = new Solver(); private static long m = (1000000000L + 7L); public static void main( String[] args)throws IOException { solver.withProcedure(()->{ String[] input = solver.readString().split(" ");  BigInteger x = new BigInteger(input[0]);  BigInteger k = new BigInteger(input[1]); if ( (x.compareTo(BigInteger.ZERO) == 0)) {solver.println(("" + 0)); return ;} BigInteger two = BigInteger.valueOf(2);  BigInteger mm = BigInteger.valueOf(m);  BigInteger binpowedK = two.modPow(k,mm);  BigInteger binpowedKPlusOne = two.modPow(k.add(BigInteger.ONE),mm);  BigInteger res = binpowedKPlusOne.multiply(x).subtract(binpowedK.subtract(BigInteger.ONE)).mod(mm); if ( (res.compareTo(BigInteger.ZERO) < 0)) {res = BigInteger.ZERO; } solver.println(("" + res)); }).solve(); } @FunctionalInterface private interface Procedure{ void run()throws IOException ; } private static class Solver{ private Procedure procedure ; private StreamTokenizer in ; private PrintWriter out ; private BufferedReader bufferedReader ; Solver(){ try{ boolean oj = (System.getProperty("ONLINE_JUDGE") != null);  Reader reader = (oj?new InputStreamReader(System.in):new FileReader("input.txt"));  Writer writer = (oj?new OutputStreamWriter(System.out):new FileWriter("output.txt")); bufferedReader = new BufferedReader(reader); in = new StreamTokenizer(bufferedReader); out = new PrintWriter(writer); }catch (Exception e){ throw (new RuntimeException("Initialization has failed"));} } void solve()throws IOException { procedure.run(); } String readString()throws IOException { return bufferedReader.readLine();} void println( String str){ out.println(str); out.flush(); } void print( String str){ out.print(str); out.flush(); } Solver withProcedure( Procedure procedure){ this.procedure = procedure; return this;} } }
5	public class Main{ private static Node[] node ; public static void main( String[] args){ Scanner cin = new Scanner(System.in);  int ret = 2,del ;  int n = cin.nextInt();  int t = (cin.nextInt() * 2); node = new Node[n]; for ( int i = 0;(i < n);i++) { int x = cin.nextInt();  int a = cin.nextInt(); node[i] = new Node(((x * 2) - a),((x * 2) + a)); }Arrays.sort(node); for ( int i = 1;(i < n);i++) {del = (node[i].l - node[(i - 1)].r); if ( (del > t)) {ret += 2; } else if ( (del == t)) {ret++; } }System.out.println(ret); } private static class Node implements Comparable<Node>{ public int l ; public int r ; public Node( int l, int r){ this.l = l; this.r = r; } } }
4	public class Codes{ public static void main( String[] args)throws IOException { InputReader input = new InputReader(new FileReader("input.txt"));  int n = input.nextInt();  int m = input.nextInt();  int k = input.nextInt();  boolean[][] visited = new boolean[n][m];  Queue<Point> bfs = new LinkedList<Point>(); for ( int i = 0;(i < k);i++) { int x = input.nextInt();  int y = input.nextInt(); visited[(x - 1)][(y - 1)] = true; bfs.add(new Point((x - 1),(y - 1))); } Point last = bfs.peek(); while(!bfs.isEmpty()){ Point current = bfs.poll();  int curX = current.x;  int curY = current.y; if ( ((curX - 1) >= 0)) {if ( !visited[(curX - 1)][curY]) {bfs.add(new Point((curX - 1),curY)); visited[(curX - 1)][curY] = true; } } if ( ((curY + 1) < m)) {if ( !visited[curX][(curY + 1)]) {bfs.add(new Point(curX,(curY + 1))); visited[curX][(curY + 1)] = true; } } if ( ((curX + 1) < n)) {if ( !visited[(curX + 1)][curY]) {bfs.add(new Point((curX + 1),curY)); visited[(curX + 1)][curY] = true; } } if ( ((curY - 1) >= 0)) {if ( !visited[curX][(curY - 1)]) {bfs.add(new Point(curX,(curY - 1))); visited[curX][(curY - 1)] = true; } } if ( (bfs.peek() != null)) last = bfs.peek(); } PrintWriter out = new PrintWriter(new File("output.txt")); out.println((((last.x + 1) + " ") + (last.y + 1))); out.close(); } static class Point{ int x ; int y ; public Point( int x2, int y2){ x = x2; y = y2; } } static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public InputReader( FileReader stream){ reader = new BufferedReader(stream); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class Main{ public static void main( String[] args){ InputStream inputStream ; try{inputStream = new FileInputStream("input.txt"); }catch (IOException e){ throw (new RuntimeException(e));} OutputStream outputStream ; try{outputStream = new FileOutputStream("output.txt"); }catch (IOException e){ throw (new RuntimeException(e));} FastReader in = new FastReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  FireAgain solver = new FireAgain(); solver.solve(1,in,out); out.close(); } static class FireAgain{ public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int INF = 10000000;  int[][] g = new int[n][m]; for ( int[] temp :g) Arrays.fill(temp,-1); ArrayDeque<IntPair> q = new ArrayDeque<>(); for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); g[x][y] = 0; q.add(new IntPair(x,y)); }while(!q.isEmpty()){ IntPair cur = q.poll();  int x = cur.getFirst();  int y = cur.getSecond(); for ( int i = -1;(i <= 1);i++) {for ( int j = -1;(j <= 1);j++) {if ( (((i == 0) && (j == 0)) || ((Math.abs(i) + Math.abs(j)) != 1))) continue; int xx = (x + i);  int yy = (y + j); if ( ((((xx < 0) || (xx >= n)) || (yy < 0)) || (yy >= m))) continue; if ( (g[xx][yy] != -1)) continue; g[xx][yy] = (g[x][y] + 1); q.add(new IntPair(xx,yy)); }}} int ans = 0,x = -1,y = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (g[i][j] >= ans)) {ans = g[i][j]; x = (i + 1); y = (j + 1); } }}out.println(((x + " ") + y)); } } static class IntPair implements Comparable<IntPair>{ int first ; int second ; public IntPair( int first, int second){ this.first = first; this.second = second; } public int getFirst(){ return first;} public int getSecond(){ return second;} } static class FastReader{ BufferedReader reader ; StringTokenizer st ; public FastReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); st = null; } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{ String line = reader.readLine(); if ( (line == null)) {return null;} st = new StringTokenizer(line); }catch (Exception e){ throw (new RuntimeException());} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
5	public class Main implements Runnable{ final String filename = ""; public void solve()throws Exception { int n = iread();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = iread(); Arrays.sort(a); boolean test = true; for ( int i = 0;(i < n);i++) {if ( (a[i] != 1)) test = false;  int min = ((i == 0)?1:a[(i - 1)]); if ( (test && (i == (n - 1)))) out.write(((min + 1) + "")); else out.write((min + "")); if ( (i == (n - 1))) out.write("\n"); else out.write(" "); }} public int iread()throws Exception { return Integer.parseInt(readword());} BufferedReader in ; BufferedWriter out ; public String readword()throws IOException { StringBuilder b = new StringBuilder();  int c ; c = in.read(); while(((c >= 0) && (c <= ' ')))c = in.read(); if ( (c < 0)) return ""; while((c > ' ')){b.append((char)c); c = in.read(); }return b.toString();} public static void main( String[] args){ try{Locale.setDefault(Locale.US); }catch (Exception e){ } new Thread(null,new Main(),"1",(1 << 25)).start(); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ ArrayList<Integer>[] G ; int[] st ,dr ; boolean[] v ; public void solve( int testNumber, InputReader in, PrintWriter out){ int N = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] A = new int[N];  TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < N);i++) {A[i] = in.nextInt(); map.put(A[i],i); }G = new ArrayList[N]; for ( int i = 0;(i < N);i++) {G[i] = new ArrayList<Integer>(); }for ( int i = 0;(i < N);i++) { int val = (a - A[i]); if ( map.containsKey(val)) { int p = map.get(val); G[i].add(p); G[p].add(i); } val = (b - A[i]); if ( map.containsKey(val)) { int p = map.get(val); G[i].add(p); G[p].add(i); } }st = new int[N]; dr = new int[N]; Arrays.fill(st,-1); Arrays.fill(dr,-1); v = new boolean[N]; boolean ok = true;  int match = 0; while(ok){ok = false; Arrays.fill(v,false); for ( int i = 0;(i < N);i++) {if ( (dr[i] == -1)) {if ( pairup(i)) {ok = true; match++; } } }}if ( (match == N)) {out.println("YES"); for ( int i = 0;(i < N);i++) {if ( (i > 0)) {out.print(" "); } int other = dr[i]; if ( (A[i] == (b - A[other]))) {out.print(1); } else {out.print(0); }}} else {out.println("NO"); }} private boolean pairup( int node){ if ( v[node]) {return false;} v[node] = true; for ( int x :G[node]) {if ( (st[x] == -1)) {st[x] = node; dr[node] = x; return true;} }for ( int x :G[node]) {if ( pairup(st[x])) {st[x] = node; dr[node] = x; return true;} }return false;} } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ return Integer.parseInt(nextString());} public String nextString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuffer res = new StringBuffer(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} }
5	public class A111{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n ,i ,j ,k = 0,l ; n = in.nextInt(); int a[] = new int[n];  int sum = 0,sum1 = 0; for ( i = 0;(i < n);i++) {a[i] = in.nextInt(); sum += a[i]; }Arrays.sort(a); for ( j = (n - 1);(j >= 0);j--) {sum1 += a[j]; k++; if ( ((sum1 * 2) > sum)) break; }pw.println(k); pw.flush(); } }
2	public class Main{ private static InputStream stream ; private static byte[] buf = new byte[1024]; private static int curChar ; private static int numChars ; private static SpaceCharFilter filter ; private static PrintWriter pw ; private static long count = 0,mod = 1000000007; public final static int INF = (int)1E9; public static void main( String[] args){ InputReader(System.in); pw = new PrintWriter(System.out); new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } public static long pow( long n, long p, long mod){ if ( (p == 0)) return 1; if ( (p == 1)) return (n % mod); if ( ((p % 2) == 0)) { long temp = pow(n,(p / 2),mod); return ((temp * temp) % mod);} else { long temp = pow(n,(p / 2),mod); temp = ((temp * temp) % mod); return ((temp * n) % mod);}} public static long pow( long n, long p){ if ( (p == 0)) return 1; if ( (p == 1)) return n; if ( ((p % 2) == 0)) { long temp = pow(n,(p / 2)); return (temp * temp);} else { long temp = pow(n,(p / 2)); temp = (temp * temp); return (temp * n);}} public static void Merge( long[] a, int p, int r){ if ( (p < r)) { int q = ((p + r) / 2); Merge(a,p,q); Merge(a,(q + 1),r); Merge_Array(a,p,q,r); } } public static void Merge_Array( long[] a, int p, int q, int r){ long b[] = new long[((q - p) + 1)];  long c[] = new long[(r - q)]; for ( int i = 0;(i < b.length);i++) b[i] = a[(p + i)]; for ( int i = 0;(i < c.length);i++) c[i] = a[((q + i) + 1)]; int i = 0,j = 0; for ( int k = p;(k <= r);k++) {if ( (i == b.length)) {a[k] = c[j]; j++; } else if ( (j == c.length)) {a[k] = b[i]; i++; } else if ( (b[i] < c[j])) {a[k] = b[i]; i++; } else {a[k] = c[j]; j++; }}} public static long gcd( long x, long y){ if ( (x == 0)) return y; else return gcd((y % x),x);} static LinkedList<Integer> adj[] ; static boolean Visited[] ; static HashSet<Integer> exc ; static long oddsum[] = new long[1000001]; static int co = 0,ans = 0; static int n ,m ; static String s[] ; static int ind ; public static void solve(){ long n = nextLong();  long s = nextLong();  long low = 1,high = n,ans = -1; while((low <= high)){ long mid = ((low + high) / 2); if ( check(mid,s)) {ans = mid; high = (mid - 1); } else {low = (mid + 1); }}if ( (ans == -1)) pw.println(0); else pw.println(((n - ans) + 1)); } private static boolean check( long mid, long s){ long n = mid;  int sum = 0; while((mid > 0)){sum += (mid % 10); mid /= 10; }if ( ((n - sum) >= s)) return true; return false;} static int[] levl ; static int h_max = 0; public static void dfs( int curr, int lev){ Visited[curr] = true; levl[curr] = lev; h_max = Math.max(h_max,levl[curr]); for ( int x :adj[curr]) {if ( !Visited[x]) {dfs(x,(lev + 1)); } }} static int state = 1; static long no_exc = 0,no_vert = 0; static Stack<Integer> st ; static HashSet<Integer> inset ; static HashSet<Integer> hs ; public static void InputReader( InputStream stream1){ stream = stream1; } private static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private static boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} private static int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} private static int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} private static long nextLong(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} private static String nextLine(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isEndOfLine(c));return res.toString();} private static boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhitespace(c);} private interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } }
5	public class Main implements Runnable{ void randomShuffle( int[] arr){ Random rnd = new Random(); for ( int i = (arr.length - 1);(i >= 0);i--) { int pos = rnd.nextInt((i + 1));  int temp = arr[pos]; arr[pos] = arr[i]; arr[i] = temp; }} void solve()throws Exception { int n = sc.nextInt();  int[] a = new int[n];  int[] ac = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ac[i] = sc.nextInt(); }randomShuffle(ac); Arrays.sort(ac); int diff = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != ac[i])) {diff++; } }if ( (diff <= 2)) {out.println("YES"); } else {out.println("NO"); }} BufferedReader in ; PrintWriter out ; FastScanner sc ; static Throwable uncaught ; public static void main( String[] args)throws Throwable { Thread t = new Thread(null,new Main(),"",((128 * 1024) * 1024)); t.start(); t.join(); if ( (uncaught != null)) {throw (uncaught);} } } class FastScanner{ BufferedReader reader ; StringTokenizer strTok ; public FastScanner( BufferedReader reader){ this.reader = reader; } public String nextToken()throws IOException { while(((strTok == null) || !strTok.hasMoreTokens())){strTok = new StringTokenizer(reader.readLine()); }return strTok.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
1	public class Solver{ StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args)throws NumberFormatException,IOException { Solver solver = new Solver(); solver.open(); long time = System.currentTimeMillis(); solver.solve(); if ( !"true".equals(System.getProperty("ONLINE_JUDGE"))) {System.out.println(("Spent time: " + (System.currentTimeMillis() - time))); } solver.close(); } public void open()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } public String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} public void solve()throws NumberFormatException,IOException { int n = nextInt();  int k = nextInt();  int[] ar = new int[n];  int[] ex = new int[100005];  int dif = 0; for ( int i = 0;(i < n);i++) { int tmp = nextInt(); ar[i] = tmp; if ( (ex[tmp]++ == 0)) {dif++; } }if ( (dif < k)) {out.println("-1 -1"); return ;} Arrays.fill(ex,0); dif = 0; int right = 0; while((dif < k)){ int tmp = ar[right]; if ( (ex[tmp]++ == 0)) {dif++; } right++; } int left = 0; while((ex[ar[left]]-- > 1))left++; out.println((((left + 1) + " ") + right)); } public void close(){ out.flush(); out.close(); } }
3	public class _909C{ private static final int MOD = 1000000007; private static void solve( Scanner scan, PrintWriter pw){ int n = scan.nextInt(); scan.nextLine(); int[][] dp = new int[n][n];  int[][] dpSums = new int[n][n]; dp[0][0] = 1; for ( int i = 0;(i < n);i++) {dpSums[0][i] = 1; } boolean lastIsSimple = scan.nextLine().equals("s"); for ( int i = 1;(i < n);i++) {if ( lastIsSimple) {dp[i][0] = dpSums[(i - 1)][(n - 1)]; dpSums[i][0] = dp[i][0]; for ( int j = 1;(j < n);j++) {dp[i][j] = (((dpSums[(i - 1)][(n - 1)] - dpSums[(i - 1)][(j - 1)]) + MOD) % MOD); dpSums[i][j] = ((dp[i][j] + dpSums[i][(j - 1)]) % MOD); }} else {dp[i][0] = 0; dpSums[i][0] = 0; for ( int j = 1;(j < n);j++) {dp[i][j] = dp[(i - 1)][(j - 1)]; dpSums[i][j] = ((dp[i][j] + dpSums[i][(j - 1)]) % MOD); }}lastIsSimple = scan.nextLine().equals("s"); }System.out.println(dpSums[(n - 1)][(n - 1)]); } public static void main( String[] args){ Scanner scan = new Scanner(new BufferedInputStream(System.in,(1024 * 64)));  PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out,(1024 * 64))); solve(scan,pw); pw.flush(); } }
6	public class P16E{ int n ; double[][] prob ; double[] dp ; public P16E(){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); prob = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {prob[i][j] = sc.nextDouble(); }}sc.close(); dp = new double[(1 << n)]; Arrays.fill(dp,-1); for ( int i = 0;(i < n);i++) { int a = (1 << i); System.out.print((compute(a) + " ")); }} double compute( int mask){ if ( (mask == ((1 << n) - 1))) {return 1;} if ( (dp[mask] != -1)) {return dp[mask];} double result = 0;  int c = 0; for ( int i = 0;(i < n);i++) { int a = (1 << i); if ( ((a & mask) != 0)) {c++; for ( int j = 0;(j < n);j++) { int b = (1 << j); if ( ((b & mask) == 0)) {result += (prob[i][j] * compute((mask | b))); } }} } int nC2 = (((c + 1) * c) / 2); dp[mask] = (result / nC2); return dp[mask];} public static void main( String[] args){ new P16E(); } }
5	public class A{ static class team implements Comparable<team>{ int problems ; int penalty ; public team( int problems, int penalty){ this.penalty = penalty; this.problems = problems; } public boolean igual( team a){ if ( (this.problems != a.problems)) return false; return (this.penalty == a.penalty);} } static class Scanner{ BufferedReader rd ; StringTokenizer tk ; public Scanner()throws IOException{ rd = new BufferedReader(new InputStreamReader(System.in)); tk = new StringTokenizer(rd.readLine()); } public String next()throws IOException { if ( !tk.hasMoreTokens()) {tk = new StringTokenizer(rd.readLine()); return tk.nextToken();} return tk.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.valueOf(this.next());} } static team[] array = new team[100]; static int N ,K ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(); N = sc.nextInt(); K = sc.nextInt(); for ( int i = 0;(i < N);i++) {array[i] = new team(sc.nextInt(),sc.nextInt()); }Arrays.sort(array,0,N); int shared = 0; for ( int i = (K - 1);((i >= 0) && array[(K - 1)].igual(array[i]));i--,shared++) ;for ( int i = K;((i < N) && array[(K - 1)].igual(array[i]));i++,shared++) ;System.out.println(shared); } }
5	public class A{ public A()throws Exception{ int n = in.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = in.nextInt(); if ( ((n == 1) && (arr[0] == 1))) {System.out.println(2); return ;} Arrays.sort(arr); if ( (arr[(n - 1)] == 1)) arr[(n - 2)] = 2; buf.append(1); for ( int i = 0;(i < (n - 1));i++) buf.append(' ').append(arr[i]); buf.append('\n'); System.out.print(buf); } Scanner in = new Scanner(System.in); StringBuilder buf = new StringBuilder(); public static void main( String[] args)throws Exception { new A(); } }
4	public class Task{ private static final boolean readFromFile = false; public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FileOutputStream fileOutputStream ;  FileInputStream fileInputStream ; if ( readFromFile) {try{fileInputStream = new FileInputStream(new File("input.txt")); fileOutputStream = new FileOutputStream(new File("output.txt")); }catch (FileNotFoundException e){ throw (new RuntimeException(e));} } PrintWriter out = new PrintWriter((readFromFile?fileOutputStream:outputStream));  InputReader in = new InputReader((readFromFile?fileInputStream:inputStream));  Solver s = new Solver(in,out); s.solve(); out.close(); } } class Solver{ InputReader in ; PrintWriter out ; public void solve(){ String s = in.nextLine(); for ( int len = (s.length() - 1);(len >= 1);len--) for ( int i = 0;(i < ((s.length() - len) + 1));i++) for ( int j = (i + 1);(j < ((s.length() - len) + 1));j++) if ( s.substring(i,(i + len)).equals(s.substring(j,(j + len)))) {out.println(len); return ;} out.println(0); } Solver( InputReader in, PrintWriter out){ this.in = in; this.out = out; } } class InputReader{ private BufferedReader buf ; private StringTokenizer tok ; InputReader( InputStream in){ tok = null; buf = new BufferedReader(new InputStreamReader(in)); } InputReader( FileInputStream in){ tok = null; buf = new BufferedReader(new InputStreamReader(in)); } public String next(){ while(((tok == null) || !tok.hasMoreTokens())){try{tok = new StringTokenizer(buf.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tok.nextToken();} public String nextLine(){ try{return buf.readLine(); }catch (IOException e){ return null;} } }
2	public class Quiz{ public static long pow( long base, long power){ if ( (power == 0)) return 1; long half = (pow(base,(power / 2)) % mod); half *= half; half %= mod; if ( ((power % 2) == 1)) half *= base; return (half % mod);} static long mod = (long)(1e9 + 9); public static void main( String[] args){ InputReader r = new InputReader(System.in);  int n = r.nextInt();  int m = r.nextInt();  int k = r.nextInt();  int buckets = (n / k);  int rem = (n - (buckets * k));  long low = 0,high = buckets,itr = 30; while((itr-- > 0)){ long mid = ((low + high) / 2);  long correct = (((mid * k) + rem) + ((buckets - mid) * (k - 1))); if ( (correct < m)) low = mid; else high = mid; } long pow = (((pow(2,(high + 1)) - 2) + mod) % mod); pow *= k; pow %= mod; long res = (((m - (high * k)) + pow) + (10 * mod)); res %= mod; System.out.println(res); } static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public InputReader( FileReader stream){ reader = new BufferedReader(stream); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
1	public class A{ int n ; int[] arr ; void run(){ Scanner s = new Scanner(System.in); n = s.nextInt(); arr = new int[n]; int even ,odd ; even = 0; odd = 0; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); if ( ((arr[i] % 2) == 0)) even++; else odd++; }if ( (even > odd)) {for ( int i = 0;(i < n);i++) {if ( ((arr[i] % 2) == 1)) {System.out.println((i + 1)); System.exit(0); } }} else {for ( int i = 0;(i < n);i++) {if ( ((arr[i] % 2) == 0)) {System.out.println((i + 1)); System.exit(0); } }}} public static void main( String[] args){ new A().run(); } }
0	public class A235{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextInt();  BigInteger res = null; if ( (n >= 3)) {if ( ((n % 2) != 0)) {res = BigInteger.valueOf(((n * (n - 1)) * (n - 2))); } else if ( ((n % 3) == 0)) {res = BigInteger.valueOf((((n - 1) * (n - 2)) * (n - 3))); } else {res = BigInteger.valueOf(((n * (n - 1)) * (n - 3))); }} else {res = BigInteger.valueOf(n); }System.out.println(res); } }
6	public class E{ public static void main( String[] args){ new E().run(); } private void run(){ Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  double[][] p = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) p[i][j] = sc.nextDouble(); }sc.close(); double[] w = new double[(1 << n)];  int max = ((1 << n) - 1); w[max] = 1; for ( int mask = max;(mask > 0);mask--) { int count = 0; for ( int i = 0;(i < n);i++) if ( (((mask >> i) & 1) > 0)) for ( int j = (i + 1);(j < n);j++) if ( (((mask >> j) & 1) > 0)) {count++; } if ( (count > 0)) for ( int i = 0;(i < n);i++) if ( (((mask >> i) & 1) > 0)) for ( int j = (i + 1);(j < n);j++) if ( (((mask >> j) & 1) > 0)) {w[(mask ^ (1 << j))] += ((w[mask] * p[i][j]) / count); w[(mask ^ (1 << i))] += ((w[mask] * (1 - p[i][j])) / count); }  }for ( int i = 0;(i < n);i++) {if ( (i != 0)) System.out.print(' '); System.out.printf("%.6f",w[(1 << i)]); }System.out.println(); } }
4	public class YouAreGivenAString{ public static void main( String[] args)throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  String s = r.readLine();  int max = 0; for ( int i = 1;(i < s.length());i++) {for ( int j = 0;(j <= (s.length() - i));j++) { String sub = s.substring(j,(j + i)); if ( (count(s,sub) >= 2)) max = Math.max(max,i); }}System.out.println(max); } private static int count( String s, String sub){ int l = sub.length();  int c = 0; for ( int i = 0;(i <= (s.length() - l));i++) {if ( s.substring(i,(i + l)).equals(sub)) c++; }return c;} }
2	public class Test5{ static long mod = 1000000007; public static void main( String[] z)throws Exception { Scanner s = new Scanner(System.in);  long a = s.nextLong(),b = s.nextLong(),c = (((a * 2) - 1) % mod),i = (binpow(2,b) % mod); System.out.println(((a < 1)?a:(((c * i) + 1) % mod))); } static long binpow( long c, long step){ if ( (step == 0)) return 1; if ( (step == 1)) return (c % mod); if ( ((step % 2) < 1)) {return (binpow((((c % mod) * (c % mod)) % mod),(step / 2)) % mod);} else {return ((c % mod) * (binpow((c % mod),(step - 1)) % mod));}} }
4	public class A{ static final int[] dx = {0,0,-1,1}; static final int[] dy = {-1,1,0,0}; public static void main( String[] args)throws IOException { Scanner sc = new Scanner("input.txt");  PrintWriter out = new PrintWriter(new FileWriter("output.txt"));  int N = sc.nextInt(),M = sc.nextInt();  int[][] dist = new int[N][M];  Queue<Integer> q = new LinkedList<>();  int K = sc.nextInt(); while((K-- > 0)){ int x = (sc.nextInt() - 1),y = (sc.nextInt() - 1); q.add(((x * M) + y)); dist[x][y] = 1; } int max = 0,ansX = -1,ansY = -1; while(!q.isEmpty()){ int u = q.remove(),x = (u / M),y = (u % M); if ( (dist[x][y] > max)) max = dist[ansX = x][ansY = y]; for ( int k = 0;(k < 4);++k) { int nx = (x + dx[k]),ny = (y + dy[k]); if ( (((((nx >= 0) && (ny >= 0)) && (nx < N)) && (ny < M)) && (dist[nx][ny] == 0))) {dist[nx][ny] = (dist[x][y] + 1); q.add(((nx * M) + ny)); } }}out.printf("%d %d\n",(ansX + 1),(ansY + 1)); out.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String s)throws FileNotFoundException{ br = new BufferedReader(new FileReader(s)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
6	public class MaeDosDragoes{ public static PrintWriter saida = new PrintWriter(System.out,false); public static class Escanear{ BufferedReader reader ; StringTokenizer tokenizer ; public Escanear(){ this(new InputStreamReader(System.in)); } public Escanear( Reader in){ reader = new BufferedReader(in); } String proximo(){ if ( ((tokenizer == null) || !tokenizer.hasMoreElements())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ e.printStackTrace(); } } return tokenizer.nextToken();} int nextInt(){ return Integer.parseInt(proximo());} } public static void main( String[] args){ Escanear fastScanner = new Escanear();  int proximoInt = fastScanner.nextInt();  double proximoDouble = fastScanner.nextInt();  long[] graph = new long[proximoInt]; for ( Integer i = 0;(i < proximoInt);i++) {for ( Integer j = 0;(j < proximoInt);j++) { Integer val = fastScanner.nextInt(); if ( (val.equals(1) || i.equals(j))) {graph[i] |= (1L << j); } }} int szLeft = (proximoInt / 2);  int szRight = (proximoInt - szLeft);  int[] dp = new int[(1 << szLeft)];  int maxMask = (1 << szLeft); for ( int mask = 1;(mask < maxMask);mask++) { int curMask = mask; for ( int j = 0;(j < szLeft);j++) {if ( (((1 << j) & mask) > 0)) {curMask &= (graph[(j + szRight)] >> szRight); dp[mask] = Math.max(dp[mask],dp[(mask ^ (1 << j))]); } }if ( (mask == curMask)) {dp[mask] = Math.max(dp[mask],Integer.bitCount(mask)); } } int ans = 0;  int rmaxMask = (1 << szRight); for ( int mask = 0;(mask < rmaxMask);mask++) { int curMask = mask;  int oMask = (maxMask - 1); for ( int j = 0;(j < szRight);j++) {if ( (((1 << j) & mask) > 0)) {curMask &= (graph[j] & (rmaxMask - 1)); oMask &= (graph[j] >> szRight); } }if ( (curMask != mask)) continue; ans = Math.max(ans,(Integer.bitCount(mask) + dp[oMask])); }proximoDouble /= ans; saida.println((((proximoDouble * proximoDouble) * (ans * (ans - 1))) / 2)); saida.flush(); } }
5	public class A{ static StringTokenizer st ; static BufferedReader in ; public static void main( String[] args)throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int n = nextInt();  int m = nextInt();  int k = nextInt();  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = nextInt(); }if ( (k >= m)) {System.out.println(0); return ;} Arrays.sort(a,1,(n + 1)); int ans = 0; for ( int i = n;(i >= 1);i--) {ans++; k--; k += a[i]; if ( (k >= m)) {System.out.println(ans); return ;} }System.out.println(-1); pw.close(); } private static int nextInt()throws IOException { return Integer.parseInt(next());} private static String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
4	public class C{ static class IntList{ int data[] = new int[3]; int size = 0; void clear(){ size = 0; } void expand(){ if ( (size >= data.length)) {data = copyOf(data,((data.length << 1) + 1)); } } void push( int value){ expand(); data[size++] = value; } int pop(){ if ( (size == 0)) {throw (new NoSuchElementException());} return data[--size];} } static void solve()throws Exception { int tests = scanInt();  IntList stack = new IntList(); for ( int test = 0;(test < tests);test++) {stack.clear(); int n = scanInt(); for ( int i = 0;(i < n);i++) { int v = scanInt(); if ( (v == 1)) {stack.push(v); } else {while((stack.pop() != (v - 1))){}stack.push(v); }for ( int j = 0;(j < stack.size);j++) {if ( (j != 0)) {out.print('.'); } out.print(stack.data[j]); }out.println(); }}} static int scanInt()throws IOException { return parseInt(scanString());} static String scanString()throws IOException { while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} static BufferedReader in ; static PrintWriter out ; static StringTokenizer tok ; public static void main( String[] args){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); }catch (Throwable e){ e.printStackTrace(); exit(1); } } }
3	public class E35PD{ public static void main( String[] args)throws IOException { Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); } int count = 0; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) {count++; } }} boolean isEven = ((count % 2) == 0);  BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));  int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int l = in.nextInt();  int r = in.nextInt();  int size = ((r - l) + 1);  int numOfConn = (((size - 1) * size) / 2); if ( ((numOfConn % 2) == 1)) {isEven = !isEven; } if ( isEven) {out.write("even"); out.newLine(); } else {out.write("odd"); out.newLine(); }}out.close(); } }
0	public class RationalResistance{ static long n = 0; static void R( long a, long b){ n += (a / b); a %= b; if ( (a == 0)) {return ;} R(b,a); } public static void main( String[] args){ Scanner cin = new Scanner(System.in);  long a = cin.nextLong();  long b = cin.nextLong(); cin.close(); R(a,b); System.out.println(n); } }
6	public class MotherOfDragons{ static boolean[][] adjMatrix ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt(); adjMatrix = new boolean[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) adjMatrix[i][j] = (sc.nextInt() == 1); long[] edges = new long[n]; for ( int i = 0;(i < n);i++) { long val = 0; for ( int j = 0;(j < n);j++) if ( (adjMatrix[i][j] || (i == j))) val |= (1l << j); edges[i] = val; } int h = (n / 2);  int[] cliques = new int[(1 << h)]; for ( int i = 1;(i < (1 << h));i++) { int nodes = i; for ( int j = 0;(j < h);j++) if ( ((i & (1 << j)) != 0)) nodes &= edges[j]; if ( (nodes == i)) cliques[i] = Integer.bitCount(i); }for ( int i = 1;(i < (1 << h));i++) for ( int j = 0;(j < h);j++) if ( ((i & (1 << j)) != 0)) cliques[i] = Math.max(cliques[i],cliques[(i ^ (1 << j))]);  int max = 0; for ( int i = 0;(i < cliques.length);i++) max = Math.max(max,cliques[i]); for ( int i = 1;(i < (1 << (n - h)));i++) { long all = -1l;  long tmp = ((1l * i) << h); for ( int j = h;(j < n);j++) if ( ((tmp & (1l << j)) != 0)) all &= edges[j];  long node = (all & tmp); if ( (node != tmp)) continue; int connected = (int)(all & ((1 << h) - 1)); max = Math.max(max,(cliques[connected] + Integer.bitCount(i))); }System.out.printf("%.12f\n",((k * k) * ((max - 1) / (2.0 * max)))); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String s)throws FileNotFoundException{ br = new BufferedReader(new FileReader(new File(s))); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
0	public class Main{ public static long func( long a, long b){ if ( (a < b)) return func(b,a); if ( (b < 2)) return a; long q = (a / b);  long r = (a - (q * b)); return (q + func(b,r));} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] ss = br.readLine().split(" +");  long a = Long.parseLong(ss[0]);  long b = Long.parseLong(ss[1]); System.out.println(func(a,b)); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } @SuppressWarnings("Duplicates") static class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] a = in.nextIntArray(n);  int m = in.nextInt();  int count = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) count = ((count + 1) % 2); }} StringBuilder res = new StringBuilder();  int l ,r ; while((m-- > 0)){l = (in.nextInt() - 1); r = (in.nextInt() - 1); count = (count ^ (((((r - l) + 1) * (r - l)) / 2) % 2)); res.append(((count == 1)?"odd":"even")).append('\n'); }out.print(res); } } static class InputReader{ private final BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); } public int[] nextIntArray( int size){ int[] array = new int[size]; for ( int i = 0;(i < size);++i) {array[i] = nextInt(); }return array;} public int nextInt(){ return Integer.parseInt(next());} public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(readLine()); }return tokenizer.nextToken();} public String readLine(){ String line ; try{line = reader.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} return line;} } }
5	public class A{ public static void main( String[] args)throws IOException { new A().run(); } BufferedReader br ; StringTokenizer st = new StringTokenizer(""); private void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); int n = nextInt();  Set<Integer> set = new TreeSet<Integer>(); for ( int i = 0;(i < n);i++) {set.add(nextInt()); }set.remove(set.iterator().next()); PrintWriter pw = new PrintWriter(System.out); if ( set.isEmpty()) {pw.println("NO"); } else {pw.println(set.iterator().next()); }pw.close(); } int nextInt()throws IOException { while(!st.hasMoreElements()){st = new StringTokenizer(br.readLine()); }return Integer.parseInt(st.nextToken());} }
0	public class Test{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( ((n % 2) == 0)) {System.out.println(((4 + " ") + (n - 4))); } else {System.out.println(((9 + " ") + (n - 9))); }} }
5	public class a{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt(),m = input.nextInt(),k = input.nextInt();  int[] data = new int[n]; for ( int i = 0;(i < n);i++) data[i] = input.nextInt(); Arrays.sort(data); m -= k; int at = (n - 1);  int count = 0; while(((at >= 0) && (m > 0))){count++; m++; m -= data[at]; at--; }if ( (m > 0)) System.out.println(-1); else System.out.println(count); } }
5	public class Start{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws FileNotFoundException { if ( ONLINE_JUDGE) {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); }} String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} public static void main( String[] args){ new Start().run(); } public static void mergeSort( int[] a){ mergeSort(a,0,(a.length - 1)); } private static void mergeSort( int[] a, int levtIndex, int rightIndex){ final int MAGIC_VALUE = 50; if ( (levtIndex < rightIndex)) {if ( ((rightIndex - levtIndex) <= MAGIC_VALUE)) {insertionSort(a,levtIndex,rightIndex); } else { int middleIndex = ((levtIndex + rightIndex) / 2); mergeSort(a,levtIndex,middleIndex); mergeSort(a,(middleIndex + 1),rightIndex); merge(a,levtIndex,middleIndex,rightIndex); }} } private static void merge( int[] a, int levtIndex, int middleIndex, int rightIndex){ int length1 = ((middleIndex - levtIndex) + 1);  int length2 = (rightIndex - middleIndex);  int[] levtArray = new int[length1];  int[] rightArray = new int[length2]; System.arraycopy(a,levtIndex,levtArray,0,length1); System.arraycopy(a,(middleIndex + 1),rightArray,0,length2); for ( int k = levtIndex,i = 0,j = 0;(k <= rightIndex);k++) {if ( (i == length1)) {a[k] = rightArray[j++]; } else if ( (j == length2)) {a[k] = levtArray[i++]; } else {a[k] = ((levtArray[i] <= rightArray[j])?levtArray[i++]:rightArray[j++]); }}} private static void insertionSort( int[] a, int levtIndex, int rightIndex){ for ( int i = (levtIndex + 1);(i <= rightIndex);i++) { int current = a[i];  int j = (i - 1); while(((j >= levtIndex) && (a[j] > current))){a[(j + 1)] = a[j]; j--; }a[(j + 1)] = current; }} public void run(){ try{ long t1 = System.currentTimeMillis(); init(); solve(); out.close(); long t2 = System.currentTimeMillis(); System.err.println(("Time = " + (t2 - t1))); }catch (Exception e){ e.printStackTrace(System.err); System.exit(-1); } } public void solve()throws IOException { int n = readInt();  int m = readInt();  int k = readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = readInt(); }mergeSort(a); if ( (k >= m)) {out.print(0); return ;} int ans = 0; k--; for ( int i = (n - 1);(i >= 0);i--) {ans += a[i]; if ( ((ans + k) >= m)) {out.print((n - i)); return ;} else {k--; }}out.print(-1); } }
4	public class QA{ static long MOD = 1000000007; static boolean b[] ,b1[] ,check ; static ArrayList<Integer>[] amp ,pa ; static ArrayList<Pair>[] amp1 ; static ArrayList<Pair>[][] damp ; static int left[] ,right[] ,end[] ,sum[] ,dist[] ,cnt[] ,start[] ,color[] ,parent[] ,prime[] ,size[] ; static int ans = 0,k ; static int p = 0; static FasterScanner sc = new FasterScanner(System.in); static BufferedWriter log ; static HashSet<Pair> hs ; static HashMap<Pair,Integer> hm ; static PriorityQueue<Integer> pri[] ; static ArrayList<Integer>[] level ; static Stack<Integer> st ; static boolean boo[][] ; static Pair prr[] ; static long parent1[] ,parent2[] ,size1[] ,size2[] ,arr1[] ,SUM[] ,lev[] ,fibo[] ; static int arr[] ,ver[][] ; private static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws Exception { new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } private static boolean oj = (System.getProperty("ONLINE_JUDGE") != null); static int dp[][] ; static int N ,K ,T ,A ,B ; static long time ; static int cost[][] ; static boolean b11[] ; static HashMap<Integer,Integer> h = new HashMap<>(); static HashSet<Pair> chec ; static long ans1 ; static long ans2 ; static int BLOCK ,MAX = 1000001; static double pi = Math.PI; static int Arr[] ,Brr[] ,pow[] ,M ; static long fact[] = new long[(100000 + 1)]; static HashMap<Integer,Long> hm1 ; static HashSet<Integer> hs1[] ,hs2[] ; static String[] str2 ; static char[] ch1 ,ch2 ; static int[] s ,f ,D ; static int tf ,ts ; static int see[][] = new int[2050][2050]; static boolean bee[][] = new boolean[2050][2050]; static Queue<Pair> q = new LinkedList<>(); public static void soln()throws IOException { FasterScanner sc = new FasterScanner(new FileInputStream("input.txt"));  PrintWriter log = new PrintWriter("output.txt");  int n = sc.nextInt(),m = sc.nextInt();  int k = sc.nextInt(); for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= m);j++) see[i][j] = 100000000; for ( int i = 0;(i < k);i++) { int x = sc.nextInt(),y = sc.nextInt(); bee[x][y] = true; see[x][y] = 0; q.add(new Pair(x,y)); }while(!q.isEmpty()){ int x = q.peek().u,y = q.poll().v; if ( (x > 1)) {see[(x - 1)][y] = min((see[x][y] + 1),see[(x - 1)][y]); if ( !bee[(x - 1)][y]) q.add(new Pair((x - 1),y)); bee[(x - 1)][y] = true; } if ( (x < n)) {see[(x + 1)][y] = min((see[x][y] + 1),see[(x + 1)][y]); if ( !bee[(x + 1)][y]) q.add(new Pair((x + 1),y)); bee[(x + 1)][y] = true; } if ( (y > 1)) {see[x][(y - 1)] = min((see[x][y] + 1),see[x][(y - 1)]); if ( !bee[x][(y - 1)]) q.add(new Pair(x,(y - 1))); bee[x][(y - 1)] = true; } if ( (y < m)) {see[x][(y + 1)] = min((see[x][y] + 1),see[x][(y + 1)]); if ( !bee[x][(y + 1)]) q.add(new Pair(x,(y + 1))); bee[x][(y + 1)] = true; } } int ans = -1;  Pair temp = null; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) {if ( (see[i][j] > ans)) {ans = see[i][j]; temp = new Pair(i,j); } }}log.write(((temp.u + " ") + temp.v)); log.close(); } static int min( int a, int b){ if ( (a > b)) return b; return a;} private static double dfs( int cur, int prev){ double r = 0,n = 0; for ( int i :amp[cur]) {if ( (i != prev)) {r += (1 + dfs(i,cur)); n++; } }if ( (n != 0)) {r = (r / n); } return r;} static double fa1 = 0; static int fa = -1; static class Node{ Node arr[] = new Node[2]; int cnt[] = new int[2]; } static double power( double x, long y){ if ( (y == 0)) return 1; double p = power(x,(y / 2)); p = (p * p); return (((y % 2) == 0)?p:(x * p));} static int Dfs( int x, int val){ b[x] = true; for ( int p :hs2[x]) {if ( !b[p]) {if ( !hs1[x].contains(p)) val++; val += Dfs(p,0); } }return val;} static void dfs1( int x, int p){ arr1[x] += lev[x]; for ( int v :amp[x]) {if ( (v != p)) {dfs1(v,x); } }} static class Pair implements Comparable<Pair>{ int u ; int v ; int ans ; public Pair(){ u = 0; v = 0; } public Pair( int u, int v){ this.u = u; this.v = v; } public String toString(){ return (((("[u=" + u) + ", v=") + v) + "]");} } static long min( long a, long b, long c){ if ( ((a < b) && (a < c))) return a; if ( (b < c)) return b; return c;} static void computeLPSArray( String pat, int M, int[] lps){ int len = 0;  int i = 1; lps[0] = 0; while((i < M)){if ( (pat.charAt(i) == pat.charAt(len))) {len++; lps[i] = len; i++; } else {if ( (len != 0)) {len = lps[(len - 1)]; } else {lps[i] = len; i++; }}}} private static void permutation( String prefix, String str){ int n = str.length(); if ( (n == 0)) ; else {for ( int i = 0;(i < n);i++) permutation((prefix + str.charAt(i)),(str.substring(0,i) + str.substring((i + 1),n))); }} static class Node2{ Node2 left = null; Node2 right = null; Node2 parent = null; int data ; } public static long max( long x, long y, long z){ if ( ((x >= y) && (x >= z))) return x; if ( ((y >= x) && (y >= z))) return y; return z;} static long modInverse( long a, long mOD2){ return power(a,(mOD2 - 2),mOD2);} static long power( long x, long y, long m){ if ( (y == 0)) return 1; long p = (power(x,(y / 2),m) % m); p = ((p * p) % m); return (((y % 2) == 0)?p:((x * p) % m));} static long d ,x ,y ; public static void extendedEuclidian( long a, long b){ if ( (b == 0)) {d = a; x = 1; y = 0; } else {extendedEuclidian(b,(a % b)); int temp = (int)x; x = y; y = (temp - ((a / b) * y)); }} public static long gcd( long n, long m){ if ( (m != 0)) return gcd(m,(n % m)); else return n;} static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter writer ; static class FasterScanner{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ,snumChars ; private SpaceCharFilter filter ; public FasterScanner( InputStream stream){ this.stream = stream; } public int snext(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = snext(); while(isSpaceChar(c)){c = snext(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = snext(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = snext(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = snext(); while(isSpaceChar(c)){c = snext(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = snext(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = snext(); }while(!isSpaceChar(c));return (res * sgn);} public int[] nextIntArray( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }return a;} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
0	public class p84a{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); System.out.println(((n / 2) * 3)); } }
4	public class Main{ static PrintWriter out ; static int c[][] ; static int x[] ,y[] ,n ; static int degIn[] ; static ArrayList<ArrayList<Integer>> a = new ArrayList<ArrayList<Integer>>(); static int cnt = 0; static boolean b[] ; private static boolean dfs( int i){ if ( (i == -1)) return true; if ( b[i]) return false; b[i] = true; for ( Integer j :a.get(i)) if ( dfs(y[j])) {x[i] = j; y[j] = i; return true;} return false;} private static void find( int k){ int _cnt = -1; if ( (k >= 0)) {x[k] = k; y[k] = k; } while((_cnt != cnt)){_cnt = cnt; Arrays.fill(b,false); if ( (k >= 0)) b[k] = true; for ( int i = 0;(i < n);++i) if ( ((x[i] == -1) && dfs(i))) ++cnt; }if ( (k >= 0)) {x[k] = -1; y[k] = -1; } } public static void solve(){ n = in.nextInt(); int m = in.nextInt(); b = new boolean[n]; c = new int[n][n]; degIn = new int[n]; x = new int[n]; y = new int[n]; Arrays.fill(x,-1); Arrays.fill(y,-1); for ( int i = 0;(i < n);++i) a.add(new ArrayList<Integer>()); while((m-- > 0)){ int i = (in.nextInt() - 1),j = (in.nextInt() - 1); a.get(i).add(j); degIn[j]++; c[i][j] = 1; }find(-1); int kq = Integer.MAX_VALUE; for ( int k = 0;(k < n);++k) {if ( (x[k] != -1)) {y[x[k]] = -1; x[k] = -1; cnt--; } if ( (y[k] != -1)) {x[y[k]] = -1; y[k] = -1; cnt--; } find(k); int t = (((((n * 2) - 1) - a.get(k).size()) - degIn[k]) + c[k][k]); for ( int i = 0;(i < n);++i) if ( (i != k)) t = ((t + a.get(i).size()) - c[i][k]); t = (((t - cnt) + (n - 1)) - cnt); if ( (kq > t)) kq = t; }out.println(kq); } public static void main( String[] args)throws java.lang.Exception { long startTime = System.currentTimeMillis(); out = new PrintWriter(System.out); solve(); out.close(); } }
2	public class NitsLocal{ static ArrayList<String> s1 ; static boolean[] prime ; static int n = (int)1e7; static void sieve(){ Arrays.fill(prime,true); prime[0] = prime[1] = false; for ( int i = 2;((i * i) <= n);++i) {if ( prime[i]) {for ( int k = (i * i);(k <= n);k += i) {prime[k] = false; }} }} public static void main( String[] args){ InputReader sc = new InputReader(System.in); prime = new boolean[(n + 1)]; sieve(); prime[1] = false; long n = sc.nl();  long k = sc.nl();  long b = ((2 * n) + 3);  long c = (((n * n) - (2 * k)) + n);  long q1 = ((b + (long)Math.sqrt(((b * b) - (4 * c)))) / 2);  long q2 = ((b - (long)Math.sqrt(((b * b) - (4 * c)))) / 2); if ( ((q1 >= q2) && (q1 <= n))) w.println(q1); else w.println(q2); w.close(); } static long sum1( int t1, int t2, int x, int[] t){ int mid = (((t2 - t1) + 1) / 2); if ( (t1 == t2)) return 0; else return (sum1(t1,(mid - 1),x,t) + sum1(mid,t2,x,t));} static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ,snumChars ; public InputReader( InputStream st){ this.stream = st; } public int read(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} public int ni(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long nl(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} } static PrintWriter w = new PrintWriter(System.out); }
2	public class ProblemC{ public static final String FILE_IN = "std.in"; public static final String FILE_OUT = "std.out"; private static boolean debugMode = true; private static final long MOD = (((1000 * 1000) * 1000) + 9); public static void main( String[] args)throws IOException { final Scanner reader = new Scanner(new InputStreamReader((debugMode?System.in:new FileInputStream(FILE_IN)))); final PrintWriter writer = new PrintWriter((debugMode?System.out:new FileOutputStream(FILE_OUT))); solveTheProblem(reader,writer); reader.close(); writer.close(); } private static void solveTheProblem(final Scanner reader,final PrintWriter writer){ final long n = reader.nextLong(); final long m = reader.nextLong(); final long k = reader.nextLong(); if ( ((n - (n / k)) >= m)) {writer.println(m); return ;} else { long sum = 1;  long maxK = ((m - n) + (n / k)); sum = fastPow(2,maxK); sum = (2 * (sum - 1)); sum = (sum % MOD); sum *= k; sum += (m - (maxK * k)); writer.println((sum % MOD)); }} private static long fastPow(final int exp,final long deg){ if ( (deg == 0)) {return 1;} else if ( (deg == 1)) {return exp;} else if ( ((deg % 2) == 0)) { long temp = fastPow(exp,(deg / 2)); temp = ((temp * temp) % MOD); return temp;} else { long temp = fastPow(exp,(deg / 2)); temp = ((temp * temp) % MOD); return ((temp * exp) % MOD);}} }
1	public class B{ static class InputReader{ BufferedReader buffreader ; StringTokenizer strtokenizer ; public InputReader( InputStream inputstr){ buffreader = new BufferedReader(new InputStreamReader(inputstr),1000000); strtokenizer = null; } String next(){ while(((strtokenizer == null) || !strtokenizer.hasMoreTokens())){try{strtokenizer = new StringTokenizer(buffreader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return strtokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} } static InputReader r = new InputReader(System.in); static PrintWriter pw = new PrintWriter(System.out); public static void main( String[] args){ int t = r.nextInt(); for ( int v = 0;(v < t);v++) { int n = r.nextInt(); if ( ((n % 2) == 1)) {pw.println("NO"); } else { int x = (n / 2);  boolean check = false; for ( int i = 1;(i <= ((int)Math.sqrt(x) + 1));i++) {if ( ((((i * i) * 2) == x) || ((i * i) == x))) {pw.println("YES"); check = true; break;} }if ( !check) {pw.println("NO"); } }}pw.close(); } }
3	public class B implements Runnable{ FastReader scn ; PrintWriter out ; String INPUT = ""; void solve(){ int n = scn.nextInt();  int[] arr = scn.nextIntArray(n);  int[][] a = new int[((n * (n + 1)) / 2)][];  int[] need = new int[a.length];  int pos = 0; for ( int l = 0;(l < n);l++) { int sum = 0; for ( int r = l;(r < n);r++) {sum += arr[r]; a[pos] = new int[]{l,r,sum}; need[pos++] = sum; }}need = scn.uniq(need); int[][][] list = new int[need.length][][];  int[] size = new int[list.length]; for ( int i = 0;(i < pos);i++) {size[Arrays.binarySearch(need,a[i][2])]++; }for ( int i = 0;(i < list.length);i++) {list[i] = new int[size[i]][]; }for ( int i = 0;(i < pos);i++) { int ind = Arrays.binarySearch(need,a[i][2]); list[ind][--size[ind]] = new int[]{a[i][0],a[i][1]}; } int ind = -1,max = 0; for ( int i = 0;(i < list.length);i++) {if ( (list[i].length == 0)) {continue;} Arrays.sort(list[i],(o1,o2)->(o1[1] - o2[1])); int count = 1,last = list[i][0][1]; for ( int j = 1;(j < list[i].length);j++) {if ( (list[i][j][0] > last)) {count++; last = list[i][j][1]; } }if ( (count > max)) {max = count; ind = i; } }out.println(max); int last = list[ind][0][1]; out.println((((list[ind][0][0] + 1) + " ") + (list[ind][0][1] + 1))); for ( int i = 1;(i < list[ind].length);i++) {if ( (list[ind][i][0] > last)) {out.println((((list[ind][i][0] + 1) + " ") + (list[ind][i][1] + 1))); last = list[ind][i][1]; } }} public static void main( String[] args){ new Thread(null,new B(),"Main",(1 << 26)).start(); } class FastReader{ InputStream is ; public FastReader( boolean onlineJudge){ is = (onlineJudge?System.in:new ByteArrayInputStream(INPUT.getBytes())); } byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} String next(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} char[] next( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} int nextInt(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} long nextLong(){ long num = 0;  int b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} long[] nextLongArray( int n){ long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nextLong(); return a;} int[] uniq( int[] arr){ Arrays.sort(arr); int[] rv = new int[arr.length];  int pos = 0; rv[pos++] = arr[0]; for ( int i = 1;(i < arr.length);i++) {if ( (arr[i] != arr[(i - 1)])) {rv[pos++] = arr[i]; } }return Arrays.copyOf(rv,pos);} } }
6	public class C{ public static void main( String[] args){ new C().run(); } class FastScanner{ BufferedReader br ; StringTokenizer st ; boolean eof ; String buf ; public FastScanner( String fileName)throws FileNotFoundException{ br = new BufferedReader(new FileReader(fileName)); nextToken(); } public FastScanner( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); nextToken(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; break;} } String ret = buf; buf = (eof?"-1":st.nextToken()); return ret;} int nextInt(){ return Integer.parseInt(nextToken());} long nextLong(){ return Long.parseLong(nextToken());} double nextDouble(){ return Double.parseDouble(nextToken());} void close(){ try{br.close(); }catch (Exception e){ } } } FastScanner sc ; PrintWriter out ; public void run(){ Locale.setDefault(Locale.US); try{sc = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); sc.close(); out.close(); }catch (Throwable e){ e.printStackTrace(); System.exit(1); } } long nextLong(){ return sc.nextLong();} double nextDouble(){ return sc.nextDouble();} int nextInt(){ return sc.nextInt();} String nextToken(){ return sc.nextToken();} static class Point{ int x ,y ; public Point( int x, int y){ super(); this.x = x; this.y = y; } int dist( Point p){ return (((x - p.x) * (x - p.x)) + ((y - p.y) * (y - p.y)));} } void solve(){ Point p0 = new Point(nextInt(),nextInt());  int n = nextInt();  Point[] p = new Point[n]; for ( int i = 0;(i < n);i++) {p[i] = new Point(nextInt(),nextInt()); } int[][] d = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {d[i][j] = p[i].dist(p[j]); }} int[] d0 = new int[n]; for ( int i = 0;(i < n);i++) {d0[i] = p0.dist(p[i]); } int[] dp = new int[(1 << n)]; Arrays.fill(dp,(1 << 30)); dp[0] = 0; int[] from = new int[(1 << n)]; for ( int i = 0;((i + 1) < (1 << n));i++) { int j = Integer.numberOfTrailingZeros(Integer.lowestOneBit(~i));  int cnt = (dp[i] + (2 * d0[j])); if ( (dp[(i ^ (1 << j))] > cnt)) {dp[(i ^ (1 << j))] = cnt; from[(i ^ (1 << j))] = i; } for ( int k = (j + 1);(k < n);k++) {if ( (((i >> k) & 1) == 0)) {cnt = (((dp[i] + d0[j]) + d0[k]) + d[j][k]); if ( (dp[((i ^ (1 << j)) ^ (1 << k))] > cnt)) {dp[((i ^ (1 << j)) ^ (1 << k))] = cnt; from[((i ^ (1 << j)) ^ (1 << k))] = i; } } }} ArrayList<Integer> ans = new ArrayList<Integer>(); ans.add(0); int mask = ((1 << n) - 1); while((mask > 0)){ int xor = (mask ^ from[mask]); while((xor > 0)){ans.add((Integer.numberOfTrailingZeros(Integer.lowestOneBit(xor)) + 1)); xor = (xor & (xor - 1)); }ans.add(0); mask = from[mask]; }out.println(dp[((1 << n) - 1)]); for ( int i :ans) {out.print((i + " ")); }} }
6	public class E{ public static void main( String[] args){ MyScanner sc = new MyScanner();  int t = sc.nextInt(); for ( int w = 0;(w < t);w++) { int n = sc.nextInt(),m = sc.nextInt();  TreeSet<X> set = new TreeSet<X>();  int[][] grid = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) {grid[i][j] = sc.nextInt(); set.add(new X(i,j,grid[i][j])); } Y[] top4 = new Y[n];  int sum = 0; for ( int i = 0;(i < n);i++) {top4[i] = new Y(set.pollLast()); sum += top4[i].a; }Arrays.sort(top4); HashSet<String> strs = new HashSet<String>();  AAA[] sss = new AAA[n];  boolean[] used = new boolean[n]; if ( (n == 4)) {for ( int i = 0;(i < 4);i++) { int max = -1,jj = -1; for ( int j = 0;(j < 4);j++) {if ( (!used[j] && (top4[j].a > max))) {max = top4[j].a; jj = j; } }used[jj] = true; sss[i] = new AAA(max,jj); }for ( int i = 0;(i < n);i++) strs.add(((top4[i].i + " ") + top4[i].j)); } int ans = sum; if ( ((((n == 4) && (top4[0].j == top4[1].j)) && (top4[2].j == top4[3].j)) && (top4[0].j != top4[2].j))) {if ( (two(top4[0],top4[1]) != two(top4[2],top4[3]))) {ans = 0; int oneCol = (two(top4[0],top4[1])?top4[2].j:top4[0].j); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( !strs.contains(((i + " ") + j))) { int no = -1; for ( int k = 0;(k < 4);k++) if ( (((j == oneCol) && (top4[k].j == oneCol)) && two(top4[k],new Y(new X(i,j,0))))) no = k; ans = max(ans,((sum - sss[((no == sss[3].i)?2:3)].a) + grid[i][j])); } } } out.println(ans); }out.close(); } static class AAA{ int a ,i ; public AAA( int A, int I){ a = A; i = I; } } static boolean two( Y y1, Y y2){ return ((((y1.i - y2.i) + 4) % 4) == 2);} static class Y implements Comparable<Y>{ int i ,j ,a ; public Y( X x){ i = x.i; j = x.j; a = x.a; } } static class X implements Comparable<X>{ int i ,j ,a ; public X( int I, int J, int A){ i = I; j = J; a = A; } } public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static class MyScanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st ; String next(){ while(((st == null) || !st.hasMoreElements()))try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
1	public class lets_do{ InputReader in ; PrintWriter out ; Helper_class h ; final long mod = 1000000007; public static void main( String[] args)throws java.lang.Exception { new lets_do().run(); } void run()throws Exception { in = new InputReader(); out = new PrintWriter(System.out); h = new Helper_class(); int t = 1; while((t-- > 0))solve(); out.flush(); out.close(); } long[] arr ; int n ; HashMap<Integer,Integer> hmap = new HashMap<Integer,Integer>(); HashSet<Integer> hset = new HashSet<Integer>(); void solve(){ n = h.ni(); long d = h.nl();  int i = 0; arr = new long[n]; for ( i = 0;(i < n);i++) arr[i] = h.nl(); int count = 2; for ( i = 0;(i < (n - 1));i++) {if ( (Math.abs((arr[i] - arr[(i + 1)])) > (2 * d))) count += 2; else if ( (Math.abs((arr[i] - arr[(i + 1)])) == (2 * d))) count += 1; }h.pn(count); } class Helper_class{ long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} int bitcount( long n){ return ((n == 0)?0:(1 + bitcount((n & (n - 1)))));} void pn( Object o){ out.println(o); } int ni(){ return Integer.parseInt(in.next());} long nl(){ return Long.parseLong(in.next());} long mul( long a, long b){ if ( (a >= mod)) a %= mod; if ( (b >= mod)) b %= mod; a *= b; if ( (a >= mod)) a %= mod; return a;} } class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public InputReader( String s)throws Exception{ br = new BufferedReader(new FileReader(s)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} String nextLine(){ String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} } }
5	public class A{ public static void main( String[] args)throws Exception { int n = nextInt(),b = nextInt(),a = nextInt();  int[] mas = new int[n]; for ( int i = 0;(i < n);i++) {mas[i] = nextInt(); }Arrays.sort(mas); if ( (mas[(a - 1)] == mas[a])) {exit(0); } println((mas[a] - mas[(a - 1)])); } private static StreamTokenizer in ; private static PrintWriter out ; private static BufferedReader inB ; private static boolean FILE = false; private static int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} {try{out = new PrintWriter((FILE?new FileOutputStream("output.txt"):System.out)); inB = new BufferedReader(new InputStreamReader((FILE?new FileInputStream("input.txt"):System.in))); }catch (Exception e){ e.printStackTrace(); } in = new StreamTokenizer(inB); }private static void println( Object o)throws Exception { out.println(o); out.flush(); } private static void exit( Object o)throws Exception { println(o); exit(); } private static void exit(){ System.exit(0); } private static final int INF = Integer.MAX_VALUE; private static final int MINF = Integer.MIN_VALUE; }
0	public class Test{ public static void main( String[] args)throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(bf.readLine()); if ( ((n % 2) == 0)) System.out.println(((4 + " ") + (n - 4))); else System.out.println(((9 + " ") + (n - 9))); } }
0	public class Main implements Runnable{ public void solve()throws Throwable { long a = sc.nextLong();  long b = sc.nextLong();  long ans = 0; while(((a > 0) && (b > 0))){if ( (a > b)) {ans += (a / b); a %= b; } else {ans += (b / a); b %= a; }}out.println(ans); } static Throwable t ; BufferedReader reader ; FastScanner sc ; PrintWriter out ; public static void main( String[] args)throws Throwable { Thread thread = new Thread(null,new Main(),"",(1 << 26)); thread.start(); thread.join(); if ( (Main.t != null)) throw (t); } } class FastScanner{ BufferedReader reader ; StringTokenizer strtok ; public FastScanner( BufferedReader reader){ this.reader = reader; } public String nextToken()throws IOException { while(((strtok == null) || !strtok.hasMoreTokens())){strtok = new StringTokenizer(reader.readLine()); }return strtok.nextToken();} public long nextLong()throws IOException { return Long.parseLong(nextToken());} }
0	public class a{ public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String s[] = in.readLine().split(" ");  long r = Long.parseLong(s[0]);  long l = Long.parseLong(s[1]); if ( ((r % 2) == 0)) {if ( (((l - r) + 1) < 3)) {out.println(-1); } else {out.println(((((r + " ") + (r + 1)) + " ") + (r + 2))); }} else {if ( (((l - r) + 1) < 4)) {out.println(-1); } else {out.println((((((r + 1) + " ") + (r + 2)) + " ") + (r + 3))); }}out.close(); } }
2	public class DigitSequence{ public static PrintWriter out ; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer token = new StringTokenizer("");  String temp[] = br.readLine().split(" ");  long pos = Long.parseLong(temp[0]); out = new PrintWriter(new BufferedOutputStream(System.out)); if ( (pos < 10)) {out.println(pos); } else {out.println(findDigitSequence(pos)); }out.close(); } private static char findDigitSequence( long pos){ long min = 0;  long max = 9;  long dig = 1; while((pos > max)){dig++; min = (max + 1); max = (long)(max + ((9 * Math.pow(10,(dig - 1))) * dig)); }pos = (pos - min); long num = (long)((pos / dig) + Math.pow(10,(dig - 1)));  String st = String.valueOf(num); if ( (dig == 1)) {return st.charAt(0);} char result = st.charAt((int)(pos % dig)); return result;} }
0	public class CF1068A{ public CF1068A(){ FS scan = new FS();  long n = scan.nextLong(),m = scan.nextLong(),k = scan.nextLong(),l = scan.nextLong();  long ceil = ((((k + l) + m) - 1) / m); if ( (((k + l) <= n) && ((ceil * m) <= n))) System.out.println(ceil); else System.out.println(-1); } class FS{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String next(){ while(!st.hasMoreTokens()){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } }return st.nextToken();} public long nextLong(){ return Long.parseLong(next());} } public static void main( String[] args){ new CF1068A(); } }
4	public class Sol{ public static void main( String[] args){ int t = 1; while((t-- > 0)){ int n = ni(); mod = nl(); precomp(); long dp[][] = new long[405][405]; dp[0][0] = 1l; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= i);j++) {for ( int k = 1;((k + i) <= n);k++) {dp[((i + k) + 1)][(j + k)] += (((dp[i][j] * p2[(k - 1)]) % mod) * Comb[(k + j)][k]); dp[((i + k) + 1)][(j + k)] %= mod; }}} long sum = 0l; for ( int i = 0;(i <= n);i++) sum = ((sum + dp[(n + 1)][i]) % mod); out.println(sum); }out.close(); } static long Comb[][] = new long[405][405]; static long p2[] = new long[405]; static long inv[] = new long[405]; static long factorial[] = new long[405]; static void precomp(){ inv[0] = 1; factorial[0] = 1l; for ( long i = 1;(i < 405);i++) {factorial[(int)i] = (i * factorial[((int)i - 1)]); factorial[(int)i] %= mod; }for ( int i = 1;(i < 405);i++) {inv[i] = power(factorial[i],(mod - 2)); }for ( int i = 0;(i < 405);i++) {for ( int j = 0;(j <= i);j++) {Comb[i][j] = ((((factorial[i] * inv[j]) % mod) * inv[(i - j)]) % mod); }}for ( int i = 0;(i < 405);i++) p2[i] = power(2,i); } static int Max = Integer.MAX_VALUE; static long mod = 1000000007; public static long power( long x, long y){ long res = 1L; x = (x % mod); while((y > 0)){if ( ((y & 1) == 1)) res = ((res * x) % mod); y >>= 1; x = ((x * x) % mod); }return res;} static InputStream inputStream = System.in; static OutputStream outputStream = System.out; static FastReader in = new FastReader(inputStream); static PrintWriter out = new PrintWriter(outputStream); static class FastReader{ BufferedReader br ; StringTokenizer st ; FastReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } public String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} String nextLine(){ String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} } static int ni(){ return in.nextInt();} static long nl(){ return in.nextLong();} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ long mod = ((long)1e9 + 7); public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  char ar[] = new char[n]; for ( int i = 0;(i < n);i++) {ar[i] = in.readString().charAt(0); } long dp[][] = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i < n);i++) {dp[(n - 1)][i] = 1; } long prev = n; for ( int i = (n - 2);(i >= 0);i--) {if ( (ar[i] == 'f')) {if ( (ar[(i + 1)] == 's')) {for ( int j = (n - 2);(j >= 0);j--) {dp[i][j] = dp[(i + 1)][(j + 1)]; }} else {for ( int j = (n - 2);(j >= 0);j--) {dp[i][j] = dp[(i + 1)][(j + 1)]; }}} else {for ( int j = (n - 1);(j >= 0);j--) {if ( (prev < 0)) {prev += mod; } dp[i][j] = prev; prev = (prev - dp[(i + 1)][j]); }}prev = 0; for ( int j = 0;(j < n);j++) {prev += dp[i][j]; prev = (prev % mod); }}out.println((dp[0][0] % mod)); } } static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ; private int snumChars ; public InputReader( InputStream st){ this.stream = st; } public int read(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c)){c = read(); } StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
4	public class Main{ private static int[] T ; public static void main( String[] args){ Scanner in = new Scanner(System.in);  char[] input = in.nextLine().toCharArray();  int length = input.length;  int max = 0; for ( int i = 0;(i < length);i++) { char[] subString = Arrays.copyOfRange(input,1,input.length);  int temp = solve(input,subString); if ( (temp > max)) max = temp; input = Arrays.copyOfRange(input,1,input.length); }System.out.println(max); } private static int solve( char[] P, char[] S){ T = new int[(P.length + 1)]; preKmp(P,P.length,T); int max = 0;  int i = 0,j = 0; while((j < S.length)){while(((i > -1) && (P[i] != S[j])))i = T[i]; i++; j++; if ( (i > max)) max = i; if ( (i >= P.length)) {i = T[i]; } }return max;} private static void preKmp( char[] x, int m, int[] kmpNext){ int i = 0,j = kmpNext[0] = -1; while((i < (m - 1))){while(((j > -1) && (x[i] != x[j])))j = kmpNext[j]; i++; j++; if ( (x[i] == x[j])) kmpNext[i] = kmpNext[j]; else kmpNext[i] = j; }} }
4	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ private static final int MOD = ((int)1e9 + 7); public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] primes = getPrimes(40_000);  int[][] a = new int[n][]; for ( int i = 0;(i < n);++i) { int x = in.nextInt();  IntList divs = new IntList(); for ( int j :primes) {if ( ((j * j) > x)) {break;} int cnt = 0; while(((x % j) == 0)){cnt++; x /= j; }if ( ((cnt % 2) == 1)) {divs.add(j); } }if ( (x > 1)) {divs.add(x); } a[i] = divs.toArray(); } Comparator<int[]> cmp = (o1,o2)->{for ( int i = 0;((i < o1.length) && (i < o2.length));++i) {if ( (o1[i] < o2[i])) {return -1;} else if ( (o2[i] < o1[i])) {return 1;} }return Integer.compare(o1.length,o2.length);}; Arrays.sort(a,cmp); IntList freqsList = new IntList();  int cnt = 1; for ( int i = 1;(i < n);++i) {if ( (cmp.compare(a[i],a[(i - 1)]) == 0)) {cnt++; } else {freqsList.add(cnt); cnt = 1; }}freqsList.add(cnt); int[][] comb = new int[((2 * n) + 1)][((2 * n) + 1)]; for ( int i = 0;(i < comb.length);++i) {comb[i][0] = 1; for ( int j = 1;(j <= i);++j) {comb[i][j] = ((comb[(i - 1)][j] + comb[(i - 1)][(j - 1)]) % MOD); }} int[] dp = new int[n];  int[] ndp = new int[n]; dp[0] = 1; int total = 0;  int ans = 1; for ( int x :freqsList.toArray()) {Arrays.fill(ndp,0); for ( int bad = 0;(bad < n);++bad) {if ( (dp[bad] == 0)) {continue;} for ( int putSeparately = 1;(putSeparately <= x);++putSeparately) {for ( int breakEq = 0;(breakEq <= putSeparately);++breakEq) { int nState = (((bad + x) - putSeparately) - breakEq); if ( ((nState < 0) || (nState >= n))) {continue;} int rem = ((total + 1) - bad);  int notBreak = (putSeparately - breakEq); if ( ((breakEq > bad) || (notBreak > rem))) {continue;} int add = (int)(((((((long)comb[bad][breakEq] * comb[rem][notBreak]) % MOD) * comb[(x - 1)][(putSeparately - 1)]) % MOD) * dp[bad]) % MOD); ndp[nState] += add; ndp[nState] %= MOD; }}}total += x; int[] aux = dp; dp = ndp; ndp = aux; ans = (int)(((long)ans * fact(x)) % MOD); }ans = (int)(((long)ans * dp[0]) % MOD); out.println(ans); } private int fact( int n){ int res = 1; for ( int i = 2;(i <= n);++i) {res = (int)(((long)res * i) % MOD); }return res;} private int[] getPrimes( int n){ boolean[] isPrime = new boolean[(n + 1)]; Arrays.fill(isPrime,2,isPrime.length,true); for ( int i = 2;((i * i) <= n);++i) {if ( isPrime[i]) {for ( int j = (i * i);(j <= n);j += i) {isPrime[j] = false; }} } IntList primes = new IntList(); for ( int i = 2;(i <= n);++i) {if ( isPrime[i]) {primes.add(i); } }return primes.toArray();} } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new UnknownError()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new UnknownError());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ return Integer.parseInt(next());} public String next(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuffer res = new StringBuffer(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } static interface IntIterator extends Iterator<Integer>{ } static class IntList implements Iterable<Integer>{ int[] elem ; int size ; public IntList(){ this(0,0,1); } public IntList( int size){ this(size,0,Math.max(1,size)); } public IntList( int size, int value){ this(size,value,Math.max(1,size)); } public IntList( int size, int value, int capacity){ elem = new int[capacity]; Arrays.fill(elem,0,size,value); this.size = size; } private IntList( int... e){ elem = e.clone(); size = e.length; } public void add( int e){ if ( ((size + 1) > elem.length)) {increaseCapacity(); } elem[size++] = e; } private void increaseCapacity(){ changeCapacity((((3 * elem.length) / 2) + 1)); } private void changeCapacity( int newCapacity){ int[] nElem = new int[newCapacity]; System.arraycopy(elem,0,nElem,0,Math.min(elem.length,newCapacity)); elem = nElem; } public int[] toArray(){ return Arrays.copyOf(elem,size);} } }
1	public class Main implements Runnable{ public void _main()throws IOException { int n = nextInt();  int even = 0,odd = 0,atEven = -1,atOdd = -1; for ( int i = 0;(i < n);i++) {if ( ((nextInt() % 2) == 0)) {atEven = i; ++even; } else {atOdd = i; ++odd; }}if ( (odd == 1)) out.print((atOdd + 1)); else out.print((atEven + 1)); } private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String rl = in.readLine(); if ( (rl == null)) return null; st = new StringTokenizer(rl); }return st.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args){ new Thread(new Main()).start(); } }
3	public class Main{ static final long mod = ((int)1e9 + 7); public static void main( String[] args)throws Exception { FastReader in = new FastReader();  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt();  int[] arr = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) arr[i] = in.nextInt(); Map<Integer,TreeMap<Integer,Integer>> map = new HashMap(); for ( int i = 1;(i <= n);i++) { int sum = 0; for ( int j = i;(j <= n);j++) {sum += arr[j]; if ( map.containsKey(sum)) { TreeMap<Integer,Integer> t = map.get(sum);  Map.Entry<Integer,Integer> e = t.lastEntry(); if ( (e.getKey() > j)) {t.remove(e.getKey()); t.put(j,i); map.put(sum,t); } else if ( (e.getKey() < i)) {t.put(j,i); map.put(sum,t); } } else { TreeMap<Integer,Integer> t = new TreeMap(); t.put(j,i); map.put(sum,t); }}} int ans = 0,size = 0; for ( Map.Entry<Integer,TreeMap<Integer,Integer>> e :map.entrySet()) {if ( (e.getValue().size() > size)) {ans = e.getKey(); size = e.getValue().size(); } }pw.println(size); for ( Map.Entry e :map.get(ans).entrySet()) pw.println(((e.getValue() + " ") + e.getKey())); pw.flush(); } } class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next()throws IOException { if ( ((st == null) || !st.hasMoreElements())) {st = new StringTokenizer(br.readLine()); } return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} }
5	public class Main2{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt();  int m = input.nextInt();  int k = input.nextInt();  int[] num = new int[n]; for ( int i = 0;(i < n);i++) {num[i] = input.nextInt(); }System.out.println(str(n,m,k,num)); } static int str( int n, int m, int k, int[] num){ Arrays.sort(num); int total = k;  int count = 0; while((k < m)){if ( (count == num.length)) return -1; k += (num[((num.length - count) - 1)] - 1); count++; }return count;} }
3	public class DD{ public static void main( String[] args)throws Throwable { MyScanner sc = new MyScanner();  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); int c = 0; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( (a[i] > a[j])) c ^= 1;  int m = sc.nextInt(); while((m-- > 0)){ int l = (sc.nextInt() - 1);  int r = (sc.nextInt() - 1);  int d = ((r - l) + 1); d = ((d * (d - 1)) / 2); c ^= (d % 2); pw.println(((c == 0)?"even":"odd")); }pw.flush(); pw.close(); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int N = Integer.parseInt(f.readLine()); if ( ((N % 2) == 0)) out.println(("4 " + (N - 4))); if ( ((N % 2) == 1)) out.println(("9 " + (N - 9))); out.close(); System.exit(0); } }
1	public class IQTest implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok ; public static void main( String[] args){ new Thread(new IQTest()).start(); } void solve()throws IOException { int n = nextInt();  List<Integer> l1 = new ArrayList<Integer>();  List<Integer> l2 = new ArrayList<Integer>(); for ( int i = 0;(i < n);++i) { int k = nextInt(); if ( ((k % 2) == 0)) l1.add((i + 1)); else l2.add((i + 1)); }if ( (l1.size() == 1)) out.println(l1.get(0)); else out.println(l2.get(0)); } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} }
3	public class Codechef{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static ArrayList<ArrayList<Integer>> list ; static HashSet<Integer> hs ; static ArrayList<Integer> tmp ; public static double cal( int a, double b, int x, int r){ r *= 2; double dis = ((r * r) - Math.pow(Math.abs((a - x)),2)); dis = Math.sqrt(dis); dis += b; return dis;} public static void main( String[] args)throws java.lang.Exception { int n ,r ;  StringTokenizer st = new StringTokenizer(br.readLine()); n = Integer.parseInt(st.nextToken()); r = Integer.parseInt(st.nextToken()); int arr[] = new int[(n + 1)];  double cen[] = new double[(n + 1)];  int i ,j ; for ( i = 1;(i <= n);i++) cen[i] = -1.0; st = new StringTokenizer(br.readLine()); for ( i = 1;(i <= n);i++) arr[i] = Integer.parseInt(st.nextToken()); for ( i = 1;(i <= n);i++) { int f = 0;  double max = -1.0; for ( j = 1;(j <= n);j++) {if ( (((i != j) && (cen[j] != -1.0)) && (Math.abs((arr[i] - arr[j])) <= (2 * r)))) {max = Math.max(max,cal(arr[j],cen[j],arr[i],r)); f = 1; } }if ( (f == 1)) cen[i] = max; else cen[i] = (r * 1.0); }for ( i = 1;(i <= n);i++) System.out.print((cen[i] + " ")); } }
1	public class A{ static Scanner sc = new Scanner(System.in); public static void main( String[] args)throws Exception { BitSet primes = primes(1001);  int N = sc.nextInt();  int K = sc.nextInt();  int count = 0; for ( int i = 2;(i <= N);++i) {if ( !primes.get(i)) continue; int res = (i - 1);  boolean found = false; for ( int j = 2;(j <= (i / 2));++j) {if ( (primes.get(j) && (primes.nextSetBit((j + 1)) == (res - j)))) {found = true; break;} }if ( found) {++count; } }System.out.println(((count >= K)?"YES":"NO")); } public static BitSet primes( int max){ BitSet primeSet = new BitSet((max + 1)); if ( (max < 2)) {return primeSet;} int limit = (int)Math.sqrt((max + 1)); primeSet.set(2); for ( int i = 3;(i < (max + 1));i += 2) {primeSet.set(i); }for ( int i = 3;(i <= limit);i += 2) {if ( !primeSet.get(i)) {continue;} for ( int j = (i * i);(j < max);j += i) {primeSet.clear(j); }}return primeSet;} }
4	public class Main{ static BufferedReader br ; static PrintWriter out ; static StringTokenizer st ; static int[][] moves = new int[][]{{0,1},{1,0},{-1,0},{0,-1}}; static boolean correct( int x, int y, int n, int m){ return ((((x >= 0) && (x < n)) && (y >= 0)) && (y < m));} static void solve()throws Exception { int n = nextInt();  int m = nextInt();  int k = nextInt();  int[][] order = new int[n][m];  boolean[][] used = new boolean[n][m];  Queue<Integer[]> q = new LinkedList<>();  Set<String> set = new HashSet<String>(); for ( int i = 0;(i < k);i++) { int x = (nextInt() - 1);  int y = (nextInt() - 1); order[x][y] = 1; used[x][y] = true; q.add(new Integer[]{x,y}); set.add(((x + "") + y)); }while(!q.isEmpty()){ Integer[] v = q.remove(); for ( int[] move :moves) { int x = (v[0] + move[0]);  int y = (v[1] + move[1]); if ( (correct(x,y,n,m) && !used[x][y])) {q.add(new Integer[]{x,y}); used[x][y] = true; order[x][y] = (order[v[0]][v[1]] + 1); } }} int max = Integer.MIN_VALUE;  int maxI = -1;  int maxJ = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (order[i][j] > max)) {max = order[i][j]; maxI = i; maxJ = j; } }}maxI++; maxJ++; out.println(((maxI + " ") + maxJ)); } static int nextInt()throws IOException { return Integer.parseInt(next());} static String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = br.readLine(); if ( (line == null)) {return null;} st = new StringTokenizer(line); }return st.nextToken();} public static void main( String[] args){ try{ InputStream input = System.in;  OutputStream output = System.out; br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt")))); out = new PrintWriter(new PrintStream(new File("output.txt"))); solve(); out.close(); br.close(); }catch (Throwable t){ t.printStackTrace(); } } }
3	public class PaintTheNumbers{ public static void main( String[] args)throws IOException { int[] colors = new int[101];  BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(f.readLine());  int N = Integer.parseInt(st.nextToken()); st = new StringTokenizer(f.readLine()); for ( int i = 0;(i < N);i++) {colors[Integer.parseInt(st.nextToken())]++; } int colorCount = 0; for ( int i = 1;(i <= 100);i++) {if ( (colors[i] != 0)) {colors[i] = 0; for ( int multiple = 2;((multiple * i) <= 100);multiple++) {colors[(i * multiple)] = 0; }colorCount++; } }System.out.println(colorCount); } }
5	public class Solution{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; static class House implements Comparable<House>{ int x ,a ; public House( int x, int a){ this.x = x; this.a = a; } } void solve()throws IOException { int n = nextInt();  int t = nextInt();  House[] hs = new House[n]; for ( int i = 0;(i < n);++i) {hs[i] = new House(nextInt(),nextInt()); }Arrays.sort(hs); int ans = 2; for ( int i = 0;(i < (n - 1));++i) {if ( (((hs[i].a + hs[(i + 1)].a) + (2 * t)) < (2 * (hs[(i + 1)].x - hs[i].x)))) {ans += 2; } else if ( (((hs[i].a + hs[(i + 1)].a) + (2 * t)) == (2 * (hs[(i + 1)].x - hs[i].x)))) {ans++; } }out.println(ans); } Solution()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); eat(""); solve(); in.close(); out.close(); } private void eat( String str){ st = new StringTokenizer(str); } String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} eat(line); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { new Solution(); } }
6	public class Main{ public static int n ,x ,y ; public static int[] a ,b ; public static int dp[] ,before[] ; public static int dx[] ; public static int d[][] ; public static final int INF = ((24 * 201) * 201); public static void main( String[] argv){ FastScanner scan = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out); x = scan.nextInt(); y = scan.nextInt(); n = scan.nextInt(); a = new int[(n + 1)]; b = new int[(n + 1)]; dx = new int[(n + 1)]; d = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i < n);++i) {a[i] = scan.nextInt(); b[i] = scan.nextInt(); }for ( int i = 0;(i < n);++i) {dx[i] = dist(i); }for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {d[i][j] = dist(i,j); }}dp = new int[(1 << n)]; before = new int[(1 << n)]; Arrays.fill(dp,INF); dp[0] = 0; for ( int state = 0;(state < (1 << n));state++) {for ( int i = 0;(i < n);++i) { int ii = (1 << i); if ( ((state & ii) > 0)) {if ( (dp[(state - ii)] == INF)) continue; int newdist = ((dp[(state - ii)] + dx[i]) + dx[i]); if ( (dp[state] > newdist)) {dp[state] = newdist; before[state] = (state - ii); } } else continue;for ( int j = (i + 1);(j < n);++j) {if ( (i == j)) continue; int jj = (1 << j); if ( ((state & jj) > 0)) {if ( (dp[((state - ii) - jj)] == INF)) continue; int newdist = (((dp[((state - ii) - jj)] + dx[i]) + d[i][j]) + dx[j]); if ( (dp[state] > newdist)) {dp[state] = newdist; before[state] = ((state - ii) - jj); } } }break;}}System.out.println(dp[((1 << n) - 1)]); int state = ((1 << n) - 1);  StringBuffer ret = new StringBuffer(); while((state > 0)){ int nstate = before[state];  boolean find = false;  String made = ""; for ( int i = 0;(i < n);++i) {if ( (((state & (1 << i)) > 0) && ((nstate & (1 << i)) == 0))) {find = true; made = ((made + " ") + (i + 1)); } }if ( find) {made = (made + " 0"); ret.append(made,0,made.length()); } state = nstate; }out.println(("0" + ret.toString())); out.close(); } public static int dist( int to){ return ((Math.abs((a[to] - x)) * Math.abs((a[to] - x))) + (Math.abs((b[to] - y)) * Math.abs((b[to] - y))));} public static int dist( int from, int to){ return ((Math.abs((a[from] - a[to])) * Math.abs((a[from] - a[to]))) + (Math.abs((b[from] - b[to])) * Math.abs((b[from] - b[to]))));} static class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream is){ try{br = new BufferedReader(new InputStreamReader(is)); }catch (Exception e){ e.printStackTrace(); } } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ return null;} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
2	public class P287B{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; long n ,k ; void run(){ n = sc.nextLong(); k = sc.nextLong(); solve(); } void solve(){ long left = -1,right = (k + 1); for ( ;((right - left) > 1);) { long m = ((left + right) / 2);  long lb = ((((k * (k + 1)) / 2) - (((k - m) * ((k - m) + 1)) / 2)) - (m - 1)); if ( (lb >= n)) {right = m; } else {left = m; }}println(("" + ((right > k)?-1:right))); } void println( String s){ System.out.println(s); } void print( String s){ System.out.print(s); } public static void main( String[] args){ Locale.setDefault(Locale.US); new P287B().run(); } }
0	public class a{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt(); if ( ((n % 2) == 0)) System.out.println(((4 + " ") + (n - 4))); else System.out.println(((9 + " ") + (n - 9))); } }
3	public class Main{ public static void main( String[] args){ new Main().run(); } FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } long mod = 998244353; long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} void work(){ int n = in.nextInt();  int[] A = new int[n]; for ( int i = 0;(i < n);i++) A[i] = in.nextInt(); HashMap<Integer,Integer> map = new HashMap<>();  HashMap<Integer,ArrayList<int[]>> rec = new HashMap<>(); for ( int i = 0;(i < n);i++) {for ( int j = i,cur = 0;(j >= 0);j--) {cur += A[j]; if ( (map.get(cur) == null)) {map.put(cur,i); rec.put(cur,new ArrayList<>()); rec.get(cur).add(new int[]{j,i}); } else if ( (map.get(cur) < j)) {map.put(cur,i); rec.get(cur).add(new int[]{j,i}); } }} ArrayList<int[]> ret = null; for ( ArrayList<int[]> list :rec.values()) {if ( ((ret == null) || (ret.size() < list.size()))) {ret = list; } }out.println(ret.size()); for ( int[] r :ret) {out.println((((r[0] + 1) + " ") + (r[1] + 1))); }} } class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next(){ if ( ((st == null) || !st.hasMoreElements())) {try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
4	public class A{ private Scanner in ; private PrintWriter out ; private String INPUT = ""; public void solve(){ String str = in.next();  int n = str.length(); for ( int k = (n - 1);(k >= 1);k--) { HashSet<String> set = new HashSet<String>(); for ( int i = 0;(i < ((str.length() - k) + 1));i++) {if ( !set.add(str.substring(i,(i + k)))) {out.println(k); return ;} }}out.println(0); } public void run()throws Exception { in = (INPUT.isEmpty()?new Scanner(System.in):new Scanner(new StringReader(INPUT))); out = new PrintWriter(System.out); solve(); out.flush(); } public static String add( String str, int k){ StringBuilder mul = new StringBuilder(str);  StringBuilder ret = new StringBuilder(); for ( int i = k;(i > 0);i >>= 1) {if ( ((i & 1) == 1)) ret.append(mul); mul.append(mul); }return ret.toString();} public static void main( String[] args)throws Exception { new A().run(); } }
4	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, InputReader in, OutputWriter out){ int tests = in.nextInt(); for ( int t = 0;(t < tests);t++) { int numLines = in.nextInt();  int stackIdx = -1;  int[] stack = new int[10000];  String prev = ""; for ( int x = 0;(x < numLines);x++) { int depth = 0;  int next = in.nextInt();  boolean found = false; for ( int i = stackIdx;(i >= 0);i--) {if ( (next == (stack[i] + 1))) {depth = i; found = true; break;} }if ( (found == true)) {stackIdx = depth; stack[depth] = next; for ( int i = 0;(i <= depth);i++) {if ( (i != 0)) {out.print("."); } out.print(stack[i]); }out.println(); } else if ( (next == 1)) {stackIdx++; stack[stackIdx] = 1; for ( int i = 0;(i <= stackIdx);i++) {if ( (i != 0)) {out.print("."); } out.print(stack[i]); }out.println(); } else {stackIdx = 0; stack[0] = next; out.println(next); }}}} } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void println(){ writer.println(); } public void close(){ writer.close(); } public void print( int i){ writer.print(i); } public void println( int i){ writer.println(i); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  inputClass in = new inputClass(inputStream);  PrintWriter out = new PrintWriter(outputStream);  G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion(); solver.solve(1,in,out); out.close(); } static class G1PlaylistForPolycarpEasyVersion{ static final int mod = ((int)1e9 + 7); public void solve( int testNumber, inputClass sc, PrintWriter out){ int n = sc.nextInt();  int t = sc.nextInt();  G1PlaylistForPolycarpEasyVersion.Song[] songs = new G1PlaylistForPolycarpEasyVersion.Song[n]; for ( int i = 0;(i < n);i++) {songs[i] = new G1PlaylistForPolycarpEasyVersion.Song(sc.nextInt(),sc.nextInt()); } long ans = 0; for ( int mask = 1;(mask < (1 << n));mask++) { int nb = 0;  int tot = 0;  int type1 = 0;  int type2 = 0;  int type3 = 0; for ( int j = 0;(j < n);j++) {if ( (((1 << j) & mask) > 0)) {nb++; tot += songs[j].l; if ( (songs[j].type == 1)) {type1++; } else if ( (songs[j].type == 2)) {type2++; } else {type3++; }} }if ( (tot == t)) { long[][][][][] dp = new long[(nb + 1)][3][(type1 + 1)][(type2 + 1)][(type3 + 1)];  boolean[][][][][] go = new boolean[(nb + 1)][3][(type1 + 1)][(type2 + 1)][(type3 + 1)]; if ( (type1 > 0)) {go[1][0][(type1 - 1)][type2][type3] = true; dp[1][0][(type1 - 1)][type2][type3] = type1; } if ( (type2 > 0)) {go[1][1][type1][(type2 - 1)][type3] = true; dp[1][1][type1][(type2 - 1)][type3] = type2; } if ( (type3 > 0)) {go[1][2][type1][type2][(type3 - 1)] = true; dp[1][2][type1][type2][(type3 - 1)] = type3; } for ( int i = 0;(i < nb);i++) {for ( int m = 0;(m < 3);m++) {for ( int j = 0;(j <= type1);j++) {for ( int k = 0;(k <= type2);k++) {for ( int l = 0;(l <= type3);l++) {if ( go[i][m][j][k][l]) {if ( (m == 0)) {if ( (k > 0)) {dp[(i + 1)][1][j][(k - 1)][l] += (dp[i][m][j][k][l] * k); dp[(i + 1)][1][j][(k - 1)][l] %= mod; go[(i + 1)][1][j][(k - 1)][l] = true; } if ( (l > 0)) {dp[(i + 1)][2][j][k][(l - 1)] += (dp[i][m][j][k][l] * l); dp[(i + 1)][2][j][k][(l - 1)] %= mod; go[(i + 1)][2][j][k][(l - 1)] = true; } } else if ( (m == 1)) {if ( (j > 0)) {dp[(i + 1)][0][(j - 1)][k][l] += (dp[i][m][j][k][l] * j); dp[(i + 1)][0][(j - 1)][k][l] %= mod; go[(i + 1)][0][(j - 1)][k][l] = true; } if ( (l > 0)) {dp[(i + 1)][2][j][k][(l - 1)] += (dp[i][m][j][k][l] * l); dp[(i + 1)][2][j][k][(l - 1)] %= mod; go[(i + 1)][2][j][k][(l - 1)] = true; } } else {if ( (j > 0)) {dp[(i + 1)][0][(j - 1)][k][l] += (dp[i][m][j][k][l] * j); dp[(i + 1)][0][(j - 1)][k][l] %= mod; go[(i + 1)][0][(j - 1)][k][l] = true; } if ( (k > 0)) {dp[(i + 1)][1][j][(k - 1)][l] += (dp[i][m][j][k][l] * k); dp[(i + 1)][1][j][(k - 1)][l] %= mod; go[(i + 1)][1][j][(k - 1)][l] = true; } }} }}}}} long toadd = 0; for ( int i = 0;(i < 3);i++) {toadd += dp[nb][i][0][0][0]; }ans += toadd; ans %= ((int)1e9 + 7); } }out.println(ans); } } static class inputClass{ BufferedReader br ; StringTokenizer st ; public inputClass( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } public String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
3	public class CC{ public static void main( String[] args)throws Throwable { MyScanner sc = new MyScanner();  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  int r = sc.nextInt();  int[] x = new int[n]; for ( int i = 0;(i < n);i++) x[i] = sc.nextInt(); double[] ans = new double[n]; ans[0] = r; for ( int i = 1;(i < n);i++) {ans[i] = r; for ( int j = 0;(j < i);j++) { double dx = Math.abs((x[i] - x[j])); if ( (dx > (2 * r))) continue; double y = Math.sqrt((((4 * r) * r) - (dx * dx))); ans[i] = Math.max(ans[i],(ans[j] + y)); }}for ( double z :ans) pw.print((z + " ")); pw.flush(); pw.close(); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastScanner in = new FastScanner(inputStream);  FastPrinter out = new FastPrinter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ static nn[] B ; static int n ,a ,b ; public void solve( int testNumber, FastScanner in, FastPrinter out){ n = in.nextInt(); a = in.nextInt(); b = in.nextInt(); int ccc = 0; if ( (a == b)) ccc = 1;  int[] A = in.readIntArray(n); B = new nn[n]; for ( int i = 0;(i < n);i++) {B[i] = new nn(A[i],i); }ArrayUtils.shuffle(B); Arrays.sort(B); int chk = 1; for ( int i = 0;(i < n);i++) {if ( (B[i].assign >= 0)) continue; int v = B[i].val;  int cc = 0;  int pos1 = Arrays.binarySearch(B,new nn((a - v),0)); if ( ((pos1 >= 0) && (B[pos1].assign == -1))) cc++; if ( (a != b)) { int pos2 = Arrays.binarySearch(B,new nn((b - v),0)); if ( ((pos2 >= 0) && (B[pos2].assign == -1))) cc++; } if ( (cc == 0)) {chk = 0; break;} if ( (cc == 1)) {go(i); } }if ( (chk == 0)) {out.println("NO"); return ;} int[] ans = new int[n]; for ( int i = 0;(i < n);i++) {ans[B[i].pos] = B[i].assign; }out.println("YES"); for ( int i = 0;(i < n);i++) {out.print((ans[i] + " ")); }out.println(); } static void go( int i){ int v = B[i].val;  int pos1 = Arrays.binarySearch(B,new nn((a - v),0)); if ( ((pos1 >= 0) && (B[pos1].assign == -1))) {B[i].assign = 0; B[pos1].assign = 0; int vv = B[pos1].val;  int np = Arrays.binarySearch(B,new nn((b - vv),0)); if ( (np >= 0)) go(np); } if ( (a != b)) { int pos2 = Arrays.binarySearch(B,new nn((b - v),0)); if ( ((pos2 >= 0) && (B[pos2].assign == -1))) {B[i].assign = 1; B[pos2].assign = 1; int vv = B[pos2].val;  int np = Arrays.binarySearch(B,new nn((a - vv),0)); if ( (np >= 0)) go(np); } } } } class nn implements Comparable<nn>{ int val ,pos ; int assign = -1; int ct = 0; nn( int val, int pos){ this.val = val; this.pos = pos; } } class FastScanner extends BufferedReader{ public FastScanner( InputStream is){ super(new InputStreamReader(is)); } public int read(){ try{ int ret = super.read(); return ret; }catch (IOException e){ throw (new InputMismatchException());} } static boolean isWhiteSpace( int c){ return ((c >= 0) && (c <= 32));} public int nextInt(){ int c = read(); while(isWhiteSpace(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int ret = 0; while(((c >= 0) && !isWhiteSpace(c))){if ( ((c < '0') || (c > '9'))) {throw (new NumberFormatException((("digit expected " + (char)c) + " found")));} ret = (((ret * 10) + c) - '0'); c = read(); }return (ret * sgn);} public int[] readIntArray( int n){ int[] ret = new int[n]; for ( int i = 0;(i < n);i++) {ret[i] = nextInt(); }return ret;} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
0	public class LuckyDivision{ public final String check( String s){ String result = "NO";  StringTokenizer stringTokenizer = new StringTokenizer(s,"47"); if ( !stringTokenizer.hasMoreTokens()) return "YES"; int S = Integer.parseInt(s); generateSimpleAndDivide(S,4,4,7); generateSimpleAndDivide(S,7,4,7); if ( lucky) return "YES"; return result;} public static final void main( String[] args){ Scanner scanner = new Scanner(System.in); System.out.print(new LuckyDivision().check(scanner.next())); } public void generateSimpleAndDivide( int divided, int n, int n1, int n2){ if ( (lucky || (n >= divided))) return ; if ( ((divided % n) == 0)) lucky = true; generateSimpleAndDivide(divided,Integer.parseInt(((n + "") + n1)),n1,n2); generateSimpleAndDivide(divided,Integer.parseInt(((n + "") + n2)),n1,n2); } private boolean lucky = false; }
3	public class A1209{ public static void main( String[] args)throws IOException { try(Input input=new StandardInput();PrintWriter writer=new PrintWriter(System.out)){ int n = input.nextInt();  int[] arr = input.readIntArray(n); Arrays.sort(arr); int ans = 0;  boolean[] vis = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !vis[i]) {vis[i] = true; for ( int j = (i + 1);(j < n);j++) {if ( (!vis[j] && ((arr[j] % arr[i]) == 0))) {vis[j] = true; } }ans++; } }System.out.println(ans); }} interface Input extends Closeable{ String next()throws IOException ; default int nextInt()throws IOException { return Integer.parseInt(next());} default long nextLong()throws IOException { return Long.parseLong(next());} default int[] readIntArray()throws IOException { return readIntArray(nextInt());} default int[] readIntArray( int size)throws IOException { int[] array = new int[size]; for ( int i = 0;(i < array.length);i++) {array[i] = nextInt(); }return array;} } private static class StandardInput implements Input{ private final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); private StringTokenizer stringTokenizer ; @Override public void close()throws IOException { reader.close(); } @Override public String next()throws IOException { if ( ((stringTokenizer == null) || !stringTokenizer.hasMoreTokens())) {stringTokenizer = new StringTokenizer(reader.readLine()); } return stringTokenizer.nextToken();} } }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); if ( (n < 3)) System.out.println(n); else if ( ((n % 2) != 0)) System.out.println((((long)n * (n - 1)) * (n - 2))); else if ( ((n % 3) != 0)) System.out.println((((long)n * (n - 1)) * (n - 3))); else System.out.println((((long)(n - 1) * (n - 2)) * (n - 3))); in.close(); } }
2	public class B{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int n = sc.nextInt();  int l1 = 1;  int r1 = n;  int b1 = 1;  int t1 = n;  int min = b1;  int max = t1; while((min != max)){ int mid = ((min + max) / 2); System.out.println(((((((("? " + l1) + " ") + b1) + " ") + r1) + " ") + mid)); System.out.flush(); if ( (sc.nextInt() >= 1)) max = mid; else min = (mid + 1); }t1 = min; min = l1; max = r1; while((min != max)){ int mid = ((min + max) / 2); System.out.println(((((((("? " + l1) + " ") + b1) + " ") + mid) + " ") + t1)); System.out.flush(); if ( (sc.nextInt() >= 1)) max = mid; else min = (mid + 1); }r1 = min; min = b1; max = t1; while((min != max)){ int mid = (((min + max) + 1) / 2); System.out.println(((((((("? " + l1) + " ") + mid) + " ") + r1) + " ") + t1)); System.out.flush(); if ( (sc.nextInt() >= 1)) min = mid; else max = (mid - 1); }b1 = min; min = l1; max = r1; while((min != max)){ int mid = (((min + max) + 1) / 2); System.out.println(((((((("? " + mid) + " ") + b1) + " ") + r1) + " ") + t1)); System.out.flush(); if ( (sc.nextInt() >= 1)) min = mid; else max = (mid - 1); }l1 = min; int l2 = 1;  int r2 = n;  int b2 = 1;  int t2 = n; min = b2; max = t2; while((min != max)){ int mid = (((min + max) + 1) / 2); System.out.println(((((((("? " + l2) + " ") + mid) + " ") + r2) + " ") + t2)); System.out.flush(); if ( (sc.nextInt() >= 1)) min = mid; else max = (mid - 1); }b2 = min; min = l2; max = r2; while((min != max)){ int mid = (((min + max) + 1) / 2); System.out.println(((((((("? " + mid) + " ") + b2) + " ") + r2) + " ") + t2)); System.out.flush(); if ( (sc.nextInt() >= 1)) min = mid; else max = (mid - 1); }l2 = min; min = b2; max = t2; while((min != max)){ int mid = ((min + max) / 2); System.out.println(((((((("? " + l2) + " ") + b2) + " ") + r2) + " ") + mid)); System.out.flush(); if ( (sc.nextInt() >= 1)) max = mid; else min = (mid + 1); }t2 = min; min = l2; max = r2; while((min != max)){ int mid = ((min + max) / 2); System.out.println(((((((("? " + l2) + " ") + b2) + " ") + mid) + " ") + t2)); System.out.flush(); if ( (sc.nextInt() >= 1)) max = mid; else min = (mid + 1); }r2 = min; System.out.println(((((((((((((((("! " + l1) + " ") + b1) + " ") + r1) + " ") + t1) + " ") + l2) + " ") + b2) + " ") + r2) + " ") + t2)); System.out.flush(); } }
1	public class CF224B{ public static void main( String[] args)throws Exception { new CF224B().solve(); } private void solve()throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); }final int MAX_A = 100000;  int[] freq = new int[(MAX_A + 1)];  int numDistinct = 0;  int r = -1; for ( int i = 0;(i < n);i++) { int t = a[i]; freq[t]++; if ( (freq[t] == 1)) {numDistinct++; } if ( (numDistinct == k)) {r = i; break;} }if ( (r == -1)) {System.out.println("-1 -1"); return ;} int l ; for ( l = 0;(l < r);l++) { int t = a[l]; freq[t]--; if ( (freq[t] == 0)) {break;} }System.out.println((((l + 1) + " ") + (r + 1))); } }
2	public class SportMafia{ int n ,k ; int nCand ; private void readData( BufferedReader bin)throws IOException { String s = bin.readLine();  String[] ss = s.split(" "); n = Integer.parseInt(ss[0]); k = Integer.parseInt(ss[1]); } void printRes(){ System.out.println(nCand); } private void calculate(){ double p ; p = (-1.5 + Math.sqrt((2.25 + (2.0 * (n + k))))); nCand = (int)Math.round((n - p)); } public static void main( String[] args)throws IOException { BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));  SportMafia l = new SportMafia(); l.readData(bin); l.calculate(); l.printRes(); } }
4	public class GeorgeInterestingGraph{ int N = 505; int INF = (int)1e9; List<Integer>[] G = new List[N]; int[] match = new int[N]; int[] used = new int[N]; int cur = 0; {for ( int i = 0;(i < N);i++) G[i] = new ArrayList<>(1); } void solve(){ int n = in.nextInt(),m = in.nextInt();  int[] fr = new int[m],to = new int[m]; for ( int i = 0;(i < m);i++) {fr[i] = (in.nextInt() - 1); to[i] = (in.nextInt() - 1); } int ans = INF; for ( int i = 0;(i < n);i++) { int cnt = 0; for ( int j = 0;(j < n);j++) {G[j].clear(); match[j] = -1; }for ( int j = 0;(j < m);j++) {if ( ((fr[j] == i) || (to[j] == i))) {cnt++; } else {G[fr[j]].add(to[j]); }} int other = (m - cnt);  int max = 0; for ( int j = 0;(j < n);j++) {cur++; augment(j); }for ( int j = 0;(j < n);j++) if ( (match[j] >= 0)) max++; ans = Math.min(ans,(((((((2 * (n - 1)) + 1) - cnt) + other) - max) + (n - 1)) - max)); }out.println(ans); } boolean augment( int u){ if ( (used[u] == cur)) return false; used[u] = cur; for ( int v :G[u]) {if ( ((match[v] < 0) || augment(match[v]))) {match[v] = u; return true;} }return false;} public static void main( String[] args){ in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); new GeorgeInterestingGraph().solve(); out.close(); } static FastScanner in ; static PrintWriter out ; static class FastScanner{ BufferedReader in ; StringTokenizer st ; public FastScanner( BufferedReader in){ this.in = in; } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(in.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} } }
5	public class Main{ StreamTokenizer in ; PrintWriter out ; public static void main( String[] args)throws IOException { new Main().run(); } int ni()throws IOException { in.nextToken(); return (int)in.nval;} void run()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); int n = ni(),t = ni(); if ( (n == 0)) {out.println(0); out.flush(); return ;} House[] h = new House[n]; for ( int i = 0;(i < n);i++) {h[i] = new House(); h[i].x = ni(); h[i].a = ni(); }Arrays.sort(h); int ret = 2; for ( int i = 0;(i < (n - 1));i++) {if ( ((((2 * (h[(i + 1)].x - h[i].x)) - h[i].a) - h[(i + 1)].a) > (2 * t))) ret += 2; else if ( ((((2 * (h[(i + 1)].x - h[i].x)) - h[i].a) - h[(i + 1)].a) == (2 * t))) ret++; }out.println(ret); out.flush(); } class House implements Comparable<House>{ int x ,a ; } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, InputReader jin, OutputWriter jout){ int n = jin.int32();  int a = jin.int32();  int b = jin.int32();  Set<Integer> present = new HashSet<Integer>();  int[] arr = new int[n];  int[] sarr = new int[n]; for ( int i = 0;(i < n);i++) {sarr[i] = arr[i] = jin.int32(); present.add(arr[i]); } boolean rev = (b < a); if ( (b < a)) {b ^= a; a ^= b; b ^= a; } Arrays.sort(sarr); Set<Integer> set1 = new HashSet<Integer>();  Set<Integer> set2 = new HashSet<Integer>(); for ( int i = 0;(i < n);i++) {if ( set1.contains(sarr)) continue; if ( set2.contains(sarr)) continue; int comp1 = (b - sarr[i]); if ( present.contains(comp1)) {set2.add(sarr[i]); set2.add(comp1); present.remove(comp1); } else { int comp2 = (a - sarr[i]); if ( present.contains(comp2)) {set1.add(sarr[i]); set1.add(comp2); present.remove(comp2); } else {jout.println("NO"); return ;}}}jout.println("YES"); for ( int i = 0;(i < n);i++) {if ( (i != 0)) jout.print(' '); if ( rev) jout.print((set2.contains(arr[i])?0:1)); else jout.print((set1.contains(arr[i])?0:1)); }} } class InputReader{ private static final int bufferMaxLength = 1024; private InputStream in ; private byte[] buffer ; private int currentBufferSize ; private int currentBufferTop ; private static final String tokenizers = " \t\r\f\n"; public InputReader( InputStream stream){ this.in = stream; buffer = new byte[bufferMaxLength]; currentBufferSize = 0; currentBufferTop = 0; } private boolean refill(){ try{this.currentBufferSize = this.in.read(this.buffer); this.currentBufferTop = 0; }catch (Exception e){ } return (this.currentBufferSize > 0);} private Byte readChar(){ if ( (currentBufferTop < currentBufferSize)) {return this.buffer[this.currentBufferTop++];} else {if ( !this.refill()) {return null;} else {return readChar();}}} public String token(){ StringBuffer tok = new StringBuffer();  Byte first ; while((((first = readChar()) != null) && (tokenizers.indexOf((char)first.byteValue()) != -1)));if ( (first == null)) return null; tok.append((char)first.byteValue()); while((((first = readChar()) != null) && (tokenizers.indexOf((char)first.byteValue()) == -1))){tok.append((char)first.byteValue()); }return tok.toString();} public Integer int32()throws NumberFormatException { String tok = token(); return ((tok == null)?null:Integer.parseInt(tok));} } class OutputWriter{ private final int bufferMaxOut = 1024; private PrintWriter out ; private StringBuilder output ; private boolean forceFlush = false; public OutputWriter( OutputStream outStream){ out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outStream))); output = new StringBuilder((2 * bufferMaxOut)); } public OutputWriter( Writer writer){ forceFlush = true; out = new PrintWriter(writer); output = new StringBuilder((2 * bufferMaxOut)); } private void autoFlush(){ if ( (forceFlush || (output.length() >= bufferMaxOut))) {flush(); } } public void print( Object... tokens){ for ( int i = 0;(i < tokens.length);i++) {if ( (i != 0)) output.append(' '); output.append(tokens[i]); }autoFlush(); } public void println( Object... tokens){ print(tokens); output.append('\n'); autoFlush(); } public void flush(){ out.print(output); output.setLength(0); } public void close(){ flush(); out.close(); } }
4	public class C_Round_35_Div2{ public static long MOD = 1000000007; static int[] X = {0,1,0,-1}; static int[] Y = {1,0,-1,0}; static int[][][] dp ; public static void main( String[] args)throws FileNotFoundException { PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));  Scanner in = new Scanner();  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int[][] map = new int[n][m];  LinkedList<Point> q = new LinkedList();  int reX = -1;  int reY = -1; for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); reX = x; reY = y; map[x][y] = 1; q.add(new Point(x,y)); }while(!q.isEmpty()){ Point p = q.poll(); for ( int i = 0;(i < 4);i++) { int x = (p.x + X[i]);  int y = (p.y + Y[i]); if ( (((((x >= 0) && (y >= 0)) && (x < n)) && (y < m)) && (map[x][y] == 0))) {map[x][y] = (1 + map[p.x][p.y]); if ( (map[x][y] > map[reX][reY])) {reX = x; reY = y; } q.add(new Point(x,y)); } }}out.println((((reX + 1) + " ") + (reY + 1))); out.close(); } public static class Point implements Comparable<Point>{ int x ,y ; public Point( int start, int end){ this.x = start; this.y = end; } } public static long gcd( long a, long b){ if ( (b == 0)) {return a;} return gcd(b,(a % b));} public static long pow( long a, long b){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long val = pow(a,(b / 2)); if ( ((b % 2) == 0)) {return ((val * val) % MOD);} else {return ((val * ((val * a) % MOD)) % MOD);}} static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner()throws FileNotFoundException{ br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt")))); } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw (new RuntimeException());} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.readInt();  int m = in.readInt();  int k = in.readInt();  int[] filters = new int[n]; for ( int i = 0;(i < n);++i) filters[i] = in.readInt(); Arrays.sort(filters); int nS = 0,tN = k; while(((tN < m) && (nS < n))){tN += (filters[((n - 1) - nS)] - 1); nS++; }if ( (tN >= m)) out.printLine(nS); else out.printLine(-1); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } }
0	public class A{ public static BufferedReader k ; public static BufferedWriter z ; public static void main( String[] args)throws IOException { k = new BufferedReader(new InputStreamReader(System.in)); z = new BufferedWriter(new OutputStreamWriter(System.out)); String[] dat = k.readLine().split(" ");  long l = Long.parseLong(dat[0]);  long r = Long.parseLong(dat[1]); if ( ((r - l) <= 1)) {z.write((-1 + "\n")); } else if ( ((r - l) == 2)) {if ( ((l & 1) != 0)) {z.write((-1 + "\n")); } else {z.write((((((l + " ") + (l + 1)) + " ") + r) + "\n")); }} else {if ( ((l & 1) == 0)) {z.write((((((l + " ") + (l + 1)) + " ") + (l + 2)) + "\n")); } else {z.write(((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3)) + "\n")); }}z.flush(); } }
4	public class StringRepeat{ static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); public static void main( String[] args){ String s = in.next();  int n = s.length(),ans = 0; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) { int l = 0; while((((j + l) < n) && (s.charAt((i + l)) == s.charAt((j + l)))))l++; ans = Math.max(ans,l); }System.out.println(ans); } }
0	public class HexTheorem{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader read = new BufferedReader(new InputStreamReader(System.in));  int x = Integer.parseInt(read.readLine()); System.out.println(("0 0 " + x)); } }
0	public class Task275A{ public static Scanner in = new Scanner(System.in); public static PrintStream out = System.out; public static void main( String[] args){ long l = in.nextLong();  long r = in.nextLong(); if ( ((l % 2) == 1)) {l++; } if ( ((r - l) < 2)) {out.print(-1); } else {out.print(((((l + " ") + (l + 1)) + " ") + (l + 2))); }} }
4	public class C{ public static void main( String[] args)throws Exception { BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));  StringBuilder sb = new StringBuilder();  int t = Integer.parseInt(buffer.readLine()); while((t-- > 0)){ int n = Integer.parseInt(buffer.readLine());  ArrayList<Integer> list = new ArrayList<>(); for ( int i = 0;(i < n);i++) { int a = Integer.parseInt(buffer.readLine()); if ( (a == 1)) list.add(1); else {for ( int j = (list.size() - 1);(j >= 0);j--) {if ( ((list.get(j) + 1) == a)) break; list.remove((list.size() - 1)); }list.remove((list.size() - 1)); list.add(a); }for ( int j = 0;(j < list.size());j++) {sb.append(list.get(j)); if ( (j == (list.size() - 1))) sb.append("\n"); else sb.append("."); }}}System.out.println(sb); } }
0	public class EER_A{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in); scanner.nextLine(); System.out.println(25); } }
3	public class C909{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int ar[] = new int[(n + 1)];  int count = 1; ar[0] = 1; for ( int i = 0;(i < n);i++) { char c = in.next().charAt(0); if ( (c == 'f')) count++; else {for ( int j = 1;(j < count);j++) {ar[j] = ((ar[j] + ar[(j - 1)]) % (int)(1e9 + 7)); }}}out.println(ar[(count - 1)]); } } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
0	public class Solution{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int pairs = in.nextInt(); while((pairs > 0)){in.nextLine(); int a = in.nextInt();  int b = in.nextInt();  int count = 0; while(((a != 0) && (b != 0))){if ( ((b >= a) && (a != 0))) {count += (b / a); b = (b % a); } if ( ((a > b) && (b != 0))) {count += (a / b); a = (a % b); } }System.out.println(count); pairs--; }} }
6	public class CF8C{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String s = br.readLine();  int si = s.indexOf(' ',0);  int x = Integer.parseInt(s.substring(0,si));  int y = Integer.parseInt(s.substring((si + 1)));  int n = Integer.parseInt(br.readLine());  int[] xx = new int[(n + 1)];  int[] yy = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {s = br.readLine(); si = s.indexOf(' ',0); xx[i] = Integer.parseInt(s.substring(0,si)); yy[i] = Integer.parseInt(s.substring((si + 1))); }xx[n] = x; yy[n] = y; int[][] dd = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) for ( int j = (i + 1);(j <= n);j++) { int dx = (xx[i] - xx[j]);  int dy = (yy[i] - yy[j]); dd[i][j] = ((dx * dx) + (dy * dy)); } int[] aa = new int[(1 << n)];  int[] bb = new int[(1 << n)]; for ( int k = 1;(k < (1 << n));k++) { int a = -1; for ( int b = 0;(b < n);b++) if ( ((k & (1 << b)) > 0)) {a = b; break;} int l = (k ^ (1 << a));  int d = (dd[a][n] + dd[a][n]); aa[k] = (aa[l] + d); bb[k] = l; for ( int b = (a + 1);(b < n);b++) if ( ((k & (1 << b)) > 0)) {l = ((k ^ (1 << a)) ^ (1 << b)); d = ((dd[a][n] + dd[b][n]) + dd[a][b]); if ( ((aa[l] + d) < aa[k])) {aa[k] = (aa[l] + d); bb[k] = l; } } } int k = ((1 << n) - 1); System.out.println(aa[k]); StringBuilder sb = new StringBuilder(); sb.append(0); while((k != 0)){ int l = bb[k];  int m = (k ^ l); for ( int b = 0;(b < n);b++) if ( ((m & (1 << b)) > 0)) sb.append(' ').append((b + 1)); sb.append(' ').append(0); k = l; }System.out.println(sb); } }
3	public class A{ public static void main( String[] args){ FastScanner scanner = new FastScanner();  PrintWriter out = new PrintWriter(System.out,false);  int n = scanner.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = scanner.nextInt(); }Arrays.sort(arr); int[] cols = new int[n]; Arrays.fill(cols,-1); int ans = 0; for ( int i = 0;(i < n);i++) {if ( (cols[i] == -1)) {cols[i] = ans++; for ( int j = (i + 1);(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) cols[j] = cols[i]; }} }out.println(ans); out.flush(); } public static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( Reader in){ br = new BufferedReader(in); } public FastScanner(){ this(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
5	public class A{ static int[] parent ; public static int find( int x){ if ( (x == parent[x])) return x; return parent[x] = find(parent[x]);} public static void union( int x, int y){ int px = find(x);  int py = find(y); if ( (px != py)) {parent[py] = px; } } public static void main( String[] args)throws Exception { int numCnt = (int)nextLong();  long k = nextLong(); parent = new int[numCnt]; for ( int i = 0;(i < parent.length);i++) {parent[i] = i; } Long[] ar = new Long[numCnt]; for ( int i = 0;(i < numCnt);i++) {ar[i] = nextLong(); }Arrays.sort(ar); for ( int i = 0;(i < ar.length);i++) { long req = (ar[i] * k);  int l = 0,h = ar.length,mid ; while((l < h)){mid = (l + ((h - l) / 2)); if ( (ar[mid] < req)) {l = (mid + 1); } else {h = mid; }}if ( ((l < ar.length) && (ar[l] == req))) {union(i,l); } } int[] count = new int[numCnt]; for ( int i = 0;(i < parent.length);i++) {count[find(i)]++; } int res = 0; for ( int i = 0;(i < numCnt);i++) {res += (int)((count[i] + 1) / 2.0); }System.out.println(res); } static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer tokenizer = new StringTokenizer(""); static long nextLong()throws Exception { return Long.parseLong(next());} static String next()throws Exception { while(true){if ( tokenizer.hasMoreTokens()) {return tokenizer.nextToken();} String s = br.readLine(); if ( (s == null)) {return null;} tokenizer = new StringTokenizer(s); }} }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Reader in = new Reader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ private static final long MOD = 1000000009; public void solve( int testNumber, Reader in, OutputWriter out){ long answer = 0;  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  long l = -1;  long r = (n + 1); while(((l + 1) < r)){ long c = ((l + r) / 2); if ( ((n < (c * k)) || (canAchieve((n - (c * k)),k) >= (m - (c * k))))) {r = c; } else l = c; } long c = r; answer = (((((IntegerUtils.power(2,(c + 1),MOD) - 2) + MOD) % MOD) * k) % MOD); n -= (k * c); m -= (k * c); answer += m; answer %= MOD; out.println(answer); } private long canAchieve( long n, long k){ return (n - (n / k));} } class Reader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public Reader( BufferedReader reader){ this.reader = reader; } public Reader( InputStream stream){ this(new BufferedReader(new InputStreamReader(stream))); } public String nextString(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(readLine()); }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(nextString());} private String readLine(){ try{return reader.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} } } class OutputWriter extends PrintWriter{ public OutputWriter( OutputStream out){ super(out); } public OutputWriter( java.io.Writer writer){ super(writer); } }
2	public class Training{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long index = in.nextLong(); if ( (index < 10)) {System.out.println(index); } else if ( (index < 190)) {solve(2,index,10,10); } else if ( (index < 2890)) {solve(3,index,190,100); } else if ( (index < 38890)) {solve(4,index,2890,1000); } else if ( (index < 488890)) {solve(5,index,38890,10000); } else if ( (index < 5888890)) {solve(6,index,488890,100000); } else if ( (index < 68888890)) {solve(7,index,5888890,1000000); } else if ( (index < 788888890)) {solve(8,index,68888890,10000000); } else if ( (index < 8888888890l)) {solve(9,index,788888890,100000000); } else if ( (index < 98888888890l)) {solve(10,index,8888888890l,1000000000); } else {solve(11,index,98888888890l,10000000000l); }} static void solve( int length, long index, long lastPoint, long num){ String s = ""; num += ((index - lastPoint) / length); s += num; int mod = (int)((index - lastPoint) % length); System.out.println(s.charAt(mod)); } }
0	public class Tester{ public static long mod = ((long)1e9 + 7); public static void main( String[] args){ InputReader s = new InputReader(System.in);  OutputStream outputStream = System.out;  String str = s.nextLine(); System.out.println("25"); } static long gcd( long a, long b){ if ( (b == 0)) return a; a %= b; return gcd(b,a);} static long exp( long a, long b){ if ( (b == 0)) return 1; if ( (b == 1)) return a; if ( (b == 2)) return (a * a); if ( ((b % 2) == 0)) return exp(exp(a,(b / 2)),2); else return (a * exp(exp(a,((b - 1) / 2)),2));} public static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream inputstream){ reader = new BufferedReader(new InputStreamReader(inputstream)); tokenizer = null; } public String nextLine(){ String fullLine = null; while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{fullLine = reader.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} return fullLine;}return fullLine;} public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} } }
5	public class A{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int so[] = new int[n]; for ( int i = 0;(i < n);i++) so[i] = in.nextInt(); Arrays.sort(so); if ( (m <= k)) {System.out.println("0"); return ;} int sum = 0;  int socUsed = 0;  int cont = 0; for ( int i = (n - 1);(i >= 0);i--) {cont++; sum += so[i]; if ( ((sum >= m) || ((sum + (k - 1)) >= m))) {System.out.println(cont); return ;} sum--; }System.out.println("-1"); } }
2	public class Main{ static private final int Max = (int)(1e5 + 10); private static long n ,s ; public static void main( String[] args){ InitData(); GetAns(); } private static void InitData(){ Scanner cin = new Scanner(System.in); n = cin.nextLong(); s = cin.nextLong(); } private static void GetAns(){ long i ;  long ans = 0; for ( i = s;(i <= n);i++) { long k = (i - sum(i)); if ( (k >= s)) {if ( ((i % 10) == 9)) {break;} ans++; } }if ( (n >= s)) {System.out.println((((ans - i) + n) + 1)); } else {System.out.println(0); }} private static long sum( long ans){ long sum = 0; while((ans > 0)){sum += (ans % 10); ans /= 10; }return sum;} }
6	public class C8{ public static long mod = 1000000007; public static long INF = (1L << 60); static FastScanner2 in = new FastScanner2(); static OutputWriter out = new OutputWriter(System.out); static int n ; static int x ,y ; static int[] xx ; static int[] yy ; static int[] dist ; static int[][] g ; static int[] dp ; public static int square( int x){ return abs((x * x));} public static void main( String[] args){ x = in.nextInt(); y = in.nextInt(); n = in.nextInt(); xx = new int[n]; yy = new int[n]; dp = new int[(1 << n)]; for ( int i = 0;(i < n);i++) {xx[i] = in.nextInt(); yy[i] = in.nextInt(); }dist = new int[n]; g = new int[n][n]; for ( int i = 0;(i < n);i++) {dist[i] = (square(abs((xx[i] - x))) + square(abs((yy[i] - y)))); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {g[i][j] = (square(abs((xx[i] - xx[j]))) + square((yy[i] - yy[j]))); }}Arrays.fill(dp,(Integer.MAX_VALUE / 2)); dp[0] = 0; for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( ((i & (1 << j)) > 0)) continue; dp[(i | (1 << j))] = min(dp[(i | (1 << j))],(dp[i] + (2 * dist[j]))); for ( int k = (j + 1);(k < n);k++) {if ( ((i & (1 << k)) > 0)) continue; dp[((i | (1 << j)) | (1 << k))] = min(dp[((i | (1 << j)) | (1 << k))],(((dp[i] + dist[j]) + dist[k]) + g[j][k])); }break;}}out.println(dp[((1 << n) - 1)]); Stack<Integer> stack = new Stack<>(); stack.push(0); int i = ((1 << n) - 1); while((i > 0)){ boolean tocontinue = false; for ( int a = 0;(a < n);a++) {if ( ((i & (1 << a)) == 0)) continue; if ( (dp[i] == (dp[(i ^ (1 << a))] + (2 * dist[a])))) {stack.push((a + 1)); stack.push(0); i -= (1 << a); tocontinue = true; } if ( tocontinue) continue; for ( int b = (a + 1);(b < n);b++) {if ( ((i & (1 << b)) == 0)) continue; if ( (dp[i] == (((dp[((i ^ (1 << a)) ^ (1 << b))] + dist[a]) + dist[b]) + g[a][b]))) {i -= (1 << a); i -= (1 << b); stack.push((a + 1)); stack.push((b + 1)); stack.push(0); tocontinue = true; } if ( tocontinue) break; }if ( tocontinue) break; }}for ( int ii :stack) out.print((ii + " ")); out.close(); } public static long gcd( long n1, long n2){ long r ; while((n2 != 0)){r = (n1 % n2); n1 = n2; n2 = r; }return n1;} static class FastScanner2{ private byte[] buf = new byte[1024]; private int curChar ; private int snumChars ; public int read(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = System.in.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} public long nextLong(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void println( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } public void flush(){ writer.flush(); } } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ int BAD = 11111; int rows ; int cols ; HashMap<IntIntPair,Integer>[] mem ; boolean contains( int mem, int index){ if ( (index < 0)) return false; return (((mem >> index) & 1) == 1);} int add( int mem, int index){ if ( (((mem >> index) & 1) == 0)) {mem += (1 << index); } return mem;} int size( int mem){ int res = 0; while((mem > 0)){if ( ((mem % 2) == 1)) res++; mem /= 2; }return res;} void test(){ if ( (contains(5,0) == false)) throw (new RuntimeException()); if ( (contains(5,1) == true)) throw (new RuntimeException()); if ( (contains(5,-1) == true)) throw (new RuntimeException()); if ( (contains(5,2) == false)) throw (new RuntimeException()); if ( (contains(5,3) == true)) throw (new RuntimeException()); if ( (add(0,2) != 4)) throw (new RuntimeException()); if ( (add(4,0) != 5)) throw (new RuntimeException()); if ( (add(5,0) != 5)) throw (new RuntimeException()); if ( (size(5) != 2)) throw (new RuntimeException()); } int dp( int row, int remabove, int squareabove){ if ( (row == rows)) {if ( (remabove == 0)) return 0; return BAD;} if ( mem[row].containsKey(new IntIntPair(remabove,squareabove))) return mem[row].get(new IntIntPair(remabove,squareabove)); int res = BAD;  int possibilities = (1 << cols); for ( int poss = 0;(poss < possibilities);poss++) { int have = 0; for ( int j = 0;(j < cols);j++) if ( (((poss >> j) & 1) == 1)) {have += (1 << j); } boolean works = true; for ( int above = 0;(above < cols);above++) if ( (((remabove >> above) & 1) == 1)) {if ( (((have >> above) & 1) == 0)) {works = false; break;} } if ( works) { int remhere = 0; for ( int j = 0;(j < cols);j++) {if ( (((!contains(have,(j - 1)) && !contains(have,j)) && !contains(have,(j + 1))) && !contains(squareabove,j))) {remhere = add(remhere,j); } }res = Math.min(res,(size(have) + dp((row + 1),remhere,have))); } }mem[row].put(new IntIntPair(remabove,squareabove),res); return res;} public void solve( int testNumber, InputReader in, OutputWriter out){ test(); int n = in.readInt(),m = in.readInt(); cols = Math.min(n,m); rows = Math.max(n,m); mem = new HashMap[rows]; for ( int i = 0;(i < mem.length);i++) mem[i] = new HashMap<>(); int res = dp(0,0,0); out.printLine(((cols * rows) - res)); } } static class IntIntPair implements Comparable<IntIntPair>{ public final int first ; public final int second ; public IntIntPair( int first, int second){ this.first = first; this.second = second; } public int hashCode(){ int result = Integer.hashCode(first); result = ((31 * result) + Integer.hashCode(second)); return result;} } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void close(){ writer.close(); } public void printLine( int i){ writer.println(i); } } }
1	public class B{ private static StreamTokenizer in ; private static PrintWriter out ; private static int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} private static String nextString()throws Exception { in.nextToken(); return in.sval;} {in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); }public static void main( String[] args)throws Exception { int n = nextInt();  char[] c = nextString().toCharArray();  int tc = 0,hc = 0; for ( int i = 0;(i < c.length);i++) {if ( (c[i] == 'T')) tc++; else hc++; } int max = -1;  int pos = 0; for ( int i = 0;(i < c.length);i++) { int a = 0; for ( int j = 0;(j < tc);j++) { int k = (i + j); if ( (k >= n)) k -= n; if ( (c[k] == 'T')) {a++; } }if ( (a > max)) {max = a; pos = i; } } int min1 = (tc - max); max = -1; pos = 0; for ( int i = 0;(i < c.length);i++) { int a = 0; for ( int j = 0;(j < hc);j++) { int k = (i + j); if ( (k >= n)) k -= n; if ( (c[k] == 'H')) {a++; } }if ( (a > max)) {max = a; pos = i; } } int min2 = (hc - max); out.println(Math.min(min1,min2)); out.flush(); } }
0	public class HelloWorld{ public static void main( String[] args){ Scanner read = new Scanner(System.in);  int n = read.nextInt();  int n1 = n;  boolean q = true; while((n1 > 0)){if ( ((n % n1) == 0)) {if ( check(n1)) {System.out.print("YES"); q = false; break;} } n1--; }if ( q) System.out.print("NO"); } public static boolean check( int n){ int n1 = n; while((n1 != 0)){if ( (((n1 % 10) != 4) && ((n1 % 10) != 7))) return false; n1 /= 10; }return true;} }
1	public class B{ static final boolean DBG = false; static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); static int[] e = new int[100001]; public static void main( String[] args)throws IOException { int n = i(),k = i(),cnt = 0;  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = i(); if ( (e[a[i]] == 0)) cnt++; e[a[i]]++; }if ( (k > cnt)) {pw.println("-1 -1"); pw.close(); return ;} if ( (cnt == n)) {pw.print(("1 " + k)); pw.close(); return ;} if ( (k == 1)) {pw.println("1 1"); pw.close(); return ;} Arrays.fill(e,0); int i = 1,j = 0,unik = 0,start = 0,end = 0,len = n,m = 0; if ( (e[a[i]] == 0)) {unik++; } e[a[i]]++; while((((i + 1) <= n) && (a[(i + 1)] == a[i]))){i = (i + 1); }j = (i + 1); while((j <= n)){if ( (e[a[j]] == 0)) {unik++; if ( (unik == k)) {while((e[a[i]] > 1)){e[a[i]]--; i++; while((((i + 1) <= n) && (a[(i + 1)] == a[i]))){i = (i + 1); }}m = ((j - i) + 1); if ( (m < len)) {start = i; end = j; len = m; if ( (m == k)) break; } while(((i <= n) && (unik == k))){e[a[i]]--; if ( (e[a[i]] == 0)) unik--; i++; while((((i + 1) <= n) && (a[(i + 1)] == a[i]))){i = (i + 1); }}} } e[a[j]]++; while((((j + 1) <= n) && (a[(j + 1)] == a[j]))){j++; }j++; }pw.println(((start + " ") + end)); pw.close(); } static int i()throws IOException { st.nextToken(); return (int)st.nval;} }
3	public class Mainn{ public static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader(){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public char nextChar(){ return next().charAt(0);} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public int[] nextIntArr( int n){ int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = this.nextInt(); }return arr;} } public static InputReader scn = new InputReader(); public static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ int n = scn.nextInt(),inv = 0;  int[] arr = scn.nextIntArr(n); for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (arr[i] > arr[j])) {inv++; } }} int ans = (inv % 2);  int m = scn.nextInt(); while((m-- > 0)){ int l = scn.nextInt(),r = scn.nextInt();  int change = ((((r - l) + 1) / 2) % 2); if ( (change == 1)) {ans = (1 - ans); } if ( (ans == 0)) {out.println("even"); } else {out.println("odd"); }}out.close(); } }
2	public class DigitSeq{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} long nextLong(){ return Long.parseLong(next());} } public static void main( String[] args){ FastReader sc = new FastReader();  OutputStream outputstream = System.out;  PrintWriter out = new PrintWriter(outputstream);  long n = sc.nextLong();  long[] arr = new long[14]; for ( int i = 1;(i <= 13);i++) {arr[i] = ((long)Math.pow(10,i) - (long)Math.pow(10,(i - 1))); } long total = 0; for ( int i = 1;(i <= 13);i++) {if ( ((total + ((long)i * arr[i])) >= n)) { long ans = (n - total);  long rest = ans; if ( ((ans % i) != 0)) {ans /= i; ans++; } else {ans /= i; }ans += ((long)Math.pow(10,(i - 1)) - 1); String str = Long.toString(ans);  int ind = (((rest % i) == 0)?(i - 1):((int)(rest % i) - 1)); out.println(str.charAt(ind)); break;} total = (total + ((long)i * arr[i])); }out.close(); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  ARaskrashivanieChisel solver = new ARaskrashivanieChisel(); solver.solve(1,in,out); out.close(); } static class ARaskrashivanieChisel{ public void solve( int testNumber, InputReader in, OutputWriter out){ final int MAX = 100;  int n = in.nextInt();  int[] a = in.nextSortedIntArray(n);  int ret = 0;  boolean[] used = new boolean[(MAX + 1)]; for ( int i = 0;(i < n);i++) {if ( !used[a[i]]) {used[a[i]] = true; ret++; for ( int j = (i + 1);(j < n);j++) {if ( (((a[j] % a[i]) == 0) && !used[a[j]])) {used[a[j]] = true; } }} }out.println(ret); } } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void close(){ writer.close(); } public void println( int i){ writer.println(i); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int[] nextIntArray( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);++i) array[i] = nextInt(); return array;} public int[] nextSortedIntArray( int n){ int array[] = nextIntArray(n); Arrays.sort(array); return array;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, PrintWriter out){ int N = in.nextInt(); if ( (N == 1)) {out.println(1); } else if ( (N == 2)) {out.println(2); } else if ( (N == 3)) {out.println(6); } else { long best = Long.MIN_VALUE; best = Math.max(best,lcm(N,lcm((N - 1),(N - 2)))); best = Math.max(best,lcm(N,lcm((N - 2),(N - 3)))); best = Math.max(best,lcm(N,lcm((N - 1),(N - 3)))); best = Math.max(best,lcm((N - 1),lcm((N - 2),(N - 3)))); out.println(best); }} private long lcm( long a, long b){ return (a * (b / gcd(a,b)));} private long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ int count = in.readInt();  int[] array = IOUtils.readIntArray(in,count);  int[] sorted = array.clone(); ArrayUtils.sort(sorted,IntComparator.DEFAULT); int differs = 0; for ( int i = 0;(i < count);i++) {if ( (array[i] != sorted[i])) differs++; }if ( (differs <= 2)) out.printLine("YES"); else out.printLine("NO"); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } } interface IntComparator{ public static final IntComparator DEFAULT = new IntComparator(){public int compare( int first, int second){ if ( (first < second)) return -1; if ( (first > second)) return 1; return 0;} }; public int compare( int first, int second); }
1	public class Main implements Runnable{ private boolean _ReadFromFile = false; private boolean _WriteToFile = false; static final String TASK_ID = "in"; static final String IN_FILE = (TASK_ID + ".in"); static final String OUT_FILE = (TASK_ID + ".out"); BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; private String alphabet ; private void core()throws Exception { int n = nextInt(); alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for ( int test = 0;(test < n);test++) { String input = reader.readLine();  StringTokenizer st = new StringTokenizer(input,alphabet);  ArrayList<Integer> have = new ArrayList<Integer>(); while(st.hasMoreElements()){ String kString = st.nextToken(); have.add(Integer.parseInt(kString)); }if ( (have.size() == 2)) writer.println(twoInts(have.get(0),have.get(1))); else { String row = "";  int col = 0; for ( int i = 0;(i < input.length());i++) {if ( Character.isDigit(input.charAt(i))) {row = input.substring(0,i); col = Integer.parseInt(input.substring(i)); break;} }writer.println(oneInt(row,col)); }}} private String oneInt( String row, int col){ return ((("R" + col) + "C") + toNum(row));} private int toNum( String row){ int res = 0; for ( int i = 0;(i < row.length());i++) {res = ((((res * 26) + row.charAt(i)) - 'A') + 1); }return res;} private String twoInts( Integer row, Integer col){ return (toAlpha(col) + row);} private String toAlpha( Integer col){ String res = ""; while((col > 0)){if ( ((col % 26) > 0)) {res = (alphabet.charAt(((col % 26) - 1)) + res); col /= 26; } else {res = ("Z" + res); col -= 26; col /= 26; }}return res;} public static void main( String[] args)throws InterruptedException { Thread thread = new Thread(new Main()); thread.start(); thread.join(); } int nextInt()throws Exception { return Integer.parseInt(nextToken());} String nextToken()throws Exception { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
5	public class Round111ProbA{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] a = new int[n];  int s = 0; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); s += a[i]; }Arrays.sort(a); int x = 0;  int c = 0; for ( int i = (n - 1);(i > -1);i--) {x += a[i]; s -= a[i]; c++; if ( (x > s)) break; }System.out.println(c); } }
6	public class Main{ public static void main( String[] args)throws Exception { Thread thread = new Thread(null,new TaskAdapter(),"",(1 << 27)); thread.start(); thread.join(); } static class TaskAdapter implements Runnable{ } static class FElongatedMatrix{ public void solve( int testNumber, FastInput in, FastOutput out){ int n = in.readInt();  int m = in.readInt();  int[][] mat = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {mat[i][j] = in.readInt(); }} int[][] minDist = new int[n][n]; SequenceUtils.deepFill(minDist,(int)1e9); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < m);k++) {minDist[i][j] = Math.min(minDist[i][j],Math.abs((mat[i][k] - mat[j][k]))); }}} int[][] minDistBetweenHeadAndTail = new int[n][n]; SequenceUtils.deepFill(minDistBetweenHeadAndTail,(int)1e9); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {for ( int k = 1;(k < m);k++) {minDistBetweenHeadAndTail[i][j] = Math.min(minDistBetweenHeadAndTail[i][j],Math.abs((mat[i][k] - mat[j][(k - 1)]))); }}} Log2 log2 = new Log2();  BitOperator bo = new BitOperator();  int[][][] dp = new int[(1 << n)][n][n]; for ( int i = 1;(i < (1 << n));i++) {if ( (i == Integer.lowestOneBit(i))) {dp[i][log2.floorLog(i)][log2.floorLog(i)] = (int)1e9; continue;} for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < n);k++) {if ( (bo.bitAt(i,j) == 0)) {continue;} for ( int t = 0;(t < n);t++) {dp[i][j][k] = Math.max(dp[i][j][k],Math.min(dp[bo.setBit(i,j,false)][t][k],minDist[j][t])); }}}} int ans = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {ans = Math.max(ans,Math.min(dp[((1 << n) - 1)][i][j],minDistBetweenHeadAndTail[j][i])); }}out.println(ans); } } static class Log2{ public int floorLog( int x){ return (31 - Integer.numberOfLeadingZeros(x));} } static class FastInput{ private final InputStream is ; private byte[] buf = new byte[(1 << 13)]; private int bufLen ; private int bufOffset ; private int next ; public FastInput( InputStream is){ this.is = is; } private int read(){ while((bufLen == bufOffset)){bufOffset = 0; try{bufLen = is.read(buf); }catch (IOException e){ bufLen = -1; } if ( (bufLen == -1)) {return -1;} }return buf[bufOffset++];} public void skipBlank(){ while(((next >= 0) && (next <= 32))){next = read(); }} public int readInt(){ int sign = 1; skipBlank(); if ( ((next == '+') || (next == '-'))) {sign = ((next == '+')?1:-1); next = read(); } int val = 0; if ( (sign == 1)) {while(((next >= '0') && (next <= '9'))){val = (((val * 10) + next) - '0'); next = read(); }} else {while(((next >= '0') && (next <= '9'))){val = (((val * 10) - next) + '0'); next = read(); }}return val;} } static class BitOperator{ public int bitAt( int x, int i){ return ((x >> i) & 1);} public int setBit( int x, int i, boolean v){ if ( v) {x |= (1 << i); } else {x &= (1 << i); }return x;} } static class FastOutput implements AutoCloseable,Closeable{ private StringBuilder cache = new StringBuilder((10 << 20)); private final Writer os ; public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput println( int c){ cache.append(c).append('\n'); return this;} public FastOutput flush(){ try{os.append(cache); os.flush(); cache.setLength(0); }catch (IOException e){ throw (new UncheckedIOException(e));} return this;} public void close(){ flush(); try{os.close(); }catch (IOException e){ throw (new UncheckedIOException(e));} } public String toString(){ return cache.toString();} } }
4	public class CF1187G extends PrintWriter{ CF1187G(){ super(System.out); } static class Scanner{ Scanner( InputStream in){ this.in = in; } InputStream in ; int k ,l ; byte[] bb = new byte[(1 << 15)]; byte getc(){ if ( (k >= l)) {k = 0; try{l = in.read(bb); }catch (IOException e){ l = 0; } if ( (l <= 0)) return -1; } return bb[k++];} int nextInt(){ byte c = 0; while((c <= 32))c = getc(); int a = 0; while((c > 32)){a = (((a * 10) + c) - '0'); c = getc(); }return a;} } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF1187G o = new CF1187G(); o.main(); o.flush(); } static final int INF = 0x3f3f3f3f; ArrayList[] aa_ ; int n_ ,m_ ; int[] pi ,dd ,bb ; int[] uu ,vv ,uv ,cost ; int[] cc ; void init(){ aa_ = new ArrayList[n_]; for ( int u = 0;(u < n_);u++) aa_[u] = new ArrayList<Integer>(); pi = new int[n_]; dd = new int[n_]; bb = new int[n_]; qq = new int[nq]; iq = new boolean[n_]; uu = new int[m_]; vv = new int[m_]; uv = new int[m_]; cost = new int[m_]; cc = new int[(m_ * 2)]; m_ = 0; } void link( int u, int v, int cap, int cos){ int h = m_++; uu[h] = u; vv[h] = v; uv[h] = (u ^ v); cost[h] = cos; cc[((h << 1) ^ 0)] = cap; aa_[u].add(((h << 1) ^ 0)); aa_[v].add(((h << 1) ^ 1)); } int[] qq ; int nq = 1,head ,cnt ; boolean[] iq ; void enqueue( int v){ if ( iq[v]) return ; if ( ((head + cnt) == nq)) {if ( ((cnt * 2) <= nq)) System.arraycopy(qq,head,qq,0,cnt); else { int[] qq_ = new int[nq *= 2]; System.arraycopy(qq,head,qq_,0,cnt); qq = qq_; }head = 0; } qq[(head + cnt++)] = v; iq[v] = true; } int dequeue(){ int u = qq[head++]; cnt--; iq[u] = false; return u;} boolean spfa( int s, int t){ Arrays.fill(pi,INF); pi[s] = 0; head = cnt = 0; enqueue(s); while((cnt > 0)){ int u = dequeue();  int d = (dd[u] + 1);  ArrayList<Integer> adj = aa_[u]; for ( int h_ :adj) if ( (cc[h_] > 0)) { int h = (h_ >> 1);  int p = (pi[u] + (((h_ & 1) == 0)?cost[h]:-cost[h]));  int v = (u ^ uv[h]); if ( ((pi[v] > p) || ((pi[v] == p) && (dd[v] > d)))) {pi[v] = p; dd[v] = d; bb[v] = h_; enqueue(v); } } }return (pi[t] != INF);} void push1( int s, int t){ for ( int u = t,h_ ,h ;(u != s);u ^= uv[h]) {h = ((h_ = bb[u]) >> 1); cc[h_]--; cc[(h_ ^ 1)]++; }} int edmonds_karp( int s, int t){ while(spfa(s,t))push1(s,t); int c = 0; for ( int h = 0;(h < m_);h++) c += (cost[h] * cc[((h << 1) ^ 1)]); return c;} void main(){ int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int c = sc.nextInt();  int d = sc.nextInt();  int[] ii = new int[k]; for ( int h = 0;(h < k);h++) ii[h] = (sc.nextInt() - 1); ArrayList[] aa = new ArrayList[n]; for ( int i = 0;(i < n);i++) aa[i] = new ArrayList<Integer>(); for ( int h = 0;(h < m);h++) { int i = (sc.nextInt() - 1);  int j = (sc.nextInt() - 1); aa[i].add(j); aa[j].add(i); } int t = ((n + k) + 1); n_ = ((n * t) + 1); m_ = (k + ((((m * 2) * k) + n) * (t - 1))); init(); for ( int i = 0;(i < n);i++) { ArrayList<Integer> adj = aa[i]; for ( int s = 0;(s < (t - 1));s++) { int u = ((i * t) + s); for ( int j :adj) { int v = (((j * t) + s) + 1); for ( int x = 1;(x <= k);x++) link(u,v,1,(c + (((x * 2) - 1) * d))); }}}for ( int i = 0;(i < n);i++) for ( int s = 0;(s < (t - 1));s++) { int u = ((i * t) + s),v = (u + 1); link(u,v,k,((i == 0)?0:c)); }for ( int h = 0;(h < k);h++) link((n_ - 1),((ii[h] * t) + 0),1,0); println(edmonds_karp((n_ - 1),(((0 * t) + t) - 1))); } }
5	public class Solution{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  TreeMap<Integer,Integer> h = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) { int key = sc.nextInt(); h.put(key,sc.nextInt()); } int ans = 2;  Integer lastKey = h.firstKey();  Integer last = h.get(lastKey); h.remove(lastKey); for ( int i = 1;(i < n);i++) { int key = h.firstKey();  int val = h.get(key); if ( (Math.abs(((key - ((val * 1.0) / 2)) - (lastKey + ((last * 1.0) / 2)))) == t)) {ans++; } else if ( (Math.abs(((key - ((val * 1.0) / 2)) - (lastKey + ((last * 1.0) / 2)))) > t)) {ans += 2; } lastKey = key; last = val; h.remove(lastKey); }System.out.println(ans); sc.close(); } }
3	public class D{ int[][] adjList ; int dfs( int u, int p){ int size = 1; for ( int v :adjList[u]) if ( (v != p)) { int curr = dfs(v,u); size += curr; } return size;} void main()throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt();  int[] a = new int[n];  boolean[] vis = new boolean[n];  int cnt = 0; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); sort(a); for ( int i = 0;(i < n);i++) {if ( !vis[i]) {for ( int j = i;(j < n);j++) if ( ((a[j] % a[i]) == 0)) vis[j] = true; cnt++; } }out.println(cnt); out.flush(); out.close(); } class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } String next()throws Exception { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(next());} } public static void main( String[] args)throws Exception { new D().main(); } }
3	public class c{ static boolean seq[] ; static long memo[][] ,mod = ((long)1e9 + 7); static long go( int n, int d){ long ans = 0; if ( (d < 0)) return 0; if ( (n == seq.length)) return 1; int f = 1; if ( (n > 0)) f = (seq[(n - 1)]?1:0); if ( (memo[n][d] != -1)) return memo[n][d]; if ( (f == 0)) {ans += go((n + 1),(d + (seq[n]?1:0))); ans %= mod; ans += go(n,(d - 1)); ans %= mod; } if ( (f == 1)) {ans += go((n + 1),(d + (seq[n]?1:0))); ans %= mod; } return memo[n][d] = ans;} public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(); seq = new boolean[n]; for ( int i = 0;(i < n);i++) {seq[i] = (in.next().charAt(0) == 'f'); }memo = new long[n][(n + 1)]; for ( int i = 0;(i < n);i++) {Arrays.fill(memo[i],-1); }System.out.println(go(0,0)); out.close(); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream i){ br = new BufferedReader(new InputStreamReader(i)); st = null; } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
0	public class TaskA{ public void run(){ InputReader reader = new InputReader(System.in);  PrintWriter writer = new PrintWriter(System.out,true); reader.nextLine(); String statement = reader.next(); if ( !statement.startsWith("-")) {writer.println(statement); } else {try{ int statement1 = Integer.parseInt(statement.substring(0,(statement.length() - 1)));  int statement2 = Integer.parseInt((statement.substring(0,(statement.length() - 2)) + statement.charAt((statement.length() - 1)))); writer.println(Math.max(statement1,statement2)); }catch (Exception e){ writer.println(statement); } }writer.close(); } public static void main( String[] args){ new TaskA().run(); } private class InputReader{ BufferedReader reader ; StringTokenizer token ; private InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); } private String next(){ return token.nextToken();} private String nextLine(){ String line = ""; try{line = reader.readLine(); token = new StringTokenizer(line," "); }catch (IOException e){ } return line;} } }
2	public class _817C{ static long sum = 0; static long BSearch2( long st, long end, long lim){ if ( (st > end)) return 0; long mid = ((st + end) >> 1); if ( ((mid - sumDigit(mid)) >= lim)) {sum = mid; return BSearch2(st,(mid - 1),lim);} if ( ((mid - sumDigit(mid)) < lim)) return BSearch2((mid + 1),end,lim); return 0;} public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(in.readLine());  long s = Long.parseLong(st.nextToken());  long n = Long.parseLong(st.nextToken()); BSearch2(1,s,n); if ( (sum == 0)) System.out.println("0"); else System.out.println(((s - sum) + 1)); } static long sumDigit( long z){ String s = ("" + z);  int c = 0; for ( int i = 0;(i < s.length());i++) c += s.charAt(i); return (c - (s.length() * 0x30));} }
2	public class Solution{ static long n ,x ,y ,c ; static boolean can( long len){ BigInteger blen = BigInteger.valueOf(len);  BigInteger sum = BigInteger.ONE; sum = sum.add(blen.multiply(blen.add(BigInteger.ONE)).shiftLeft(1)); long a1 = Math.max(0,(len - x)); sum = sum.subtract(BigInteger.valueOf(a1).multiply(BigInteger.valueOf(a1))); long a2 = Math.max(0,(len - y)); sum = sum.subtract(BigInteger.valueOf(a2).multiply(BigInteger.valueOf(a2))); long a3 = Math.max(0,(len - ((n - 1) - x))); sum = sum.subtract(BigInteger.valueOf(a3).multiply(BigInteger.valueOf(a3))); long a4 = Math.max(0,(len - ((n - 1) - y))); sum = sum.subtract(BigInteger.valueOf(a4).multiply(BigInteger.valueOf(a4))); if ( (((y - a1) + 1) < 0)) { long b1 = Math.abs(((y - a1) + 1)); sum = sum.add(BigInteger.valueOf(b1).multiply(BigInteger.valueOf((b1 + 1))).shiftRight(1)); } if ( (((y - a3) + 1) < 0)) { long b1 = Math.abs(((y - a3) + 1)); sum = sum.add(BigInteger.valueOf(b1).multiply(BigInteger.valueOf((b1 + 1))).shiftRight(1)); } if ( (((y + a1) - 1) >= n)) { long b1 = ((y + a1) - n); sum = sum.add(BigInteger.valueOf(b1).multiply(BigInteger.valueOf((b1 + 1))).shiftRight(1)); } if ( (((y + a3) - 1) >= n)) { long b1 = ((y + a3) - n); sum = sum.add(BigInteger.valueOf(b1).multiply(BigInteger.valueOf((b1 + 1))).shiftRight(1)); } return (sum.compareTo(BigInteger.valueOf(c)) >= 0);} public static void main( String[] argv){ Scanner in = new Scanner(System.in); n = in.nextLong(); x = in.nextLong(); y = in.nextLong(); c = in.nextLong(); x--; y--; long lf = 0,rg = ((((2 * 1000) * 1000) * 1000) + 3); while((lf != rg)){ long mid = ((lf + rg) >> 1); if ( can(mid)) rg = mid; else lf = (mid + 1); }System.out.println(lf); } }
4	public class D_CF{ public static void main( String[] args){ FastScanner58 fs = new FastScanner58();  PrintWriter pw = new PrintWriter(System.out);  int t = 1; for ( int tc = 0;(tc < t);tc++) { int n = fs.ni();  int m = fs.ni();  int k = fs.ni();  int[][] a = new int[n][(m - 1)];  int[][] b = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {a[i] = fs.intArray((m - 1)); }for ( int i = 0;(i < (n - 1));i++) {b[i] = fs.intArray(m); } int[][] res = new int[n][m];  Integer[][][] dp = new Integer[n][m][((k / 2) + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {res[i][j] = (recur(i,j,(k / 2),dp,a,b) * 2); }} StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < res.length);i++) {for ( int j = 0;(j < m);j++) {if ( ((k % 2) == 1)) {sb.append((-1 + " ")); } else {sb.append((res[i][j] + " ")); }}sb.append("\n"); }pw.println(sb); }pw.close(); } public static int recur( int i, int j, int k, Integer[][][] dp, int[][] a, int[][] b){ if ( (k == 0)) {return 0;} int n = (int)1e9; if ( (dp[i][j][k] != null)) {return dp[i][j][k];} if ( (i != 0)) {n = Math.min(n,(recur((i - 1),j,(k - 1),dp,a,b) + b[(i - 1)][j])); } if ( (j != 0)) {n = Math.min(n,(recur(i,(j - 1),(k - 1),dp,a,b) + a[i][(j - 1)])); } if ( (i != (a.length - 1))) {n = Math.min(n,(recur((i + 1),j,(k - 1),dp,a,b) + b[i][j])); } if ( (j != (b[0].length - 1))) {n = Math.min(n,(recur(i,(j + 1),(k - 1),dp,a,b) + a[i][j])); } return dp[i][j][k] = n;} } class FastScanner58{ BufferedReader br ; StringTokenizer st ; public FastScanner58(){ br = new BufferedReader(new InputStreamReader(System.in),32768); st = null; } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int ni(){ return Integer.parseInt(next());} int[] intArray( int N){ int[] ret = new int[N]; for ( int i = 0;(i < N);i++) {ret[i] = ni(); }return ret;} long nl(){ return Long.parseLong(next());} }
6	public class Main{ static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static long mod = ((long)1e9 + 7); static long mod1 = 998244353; static boolean sieve[] ; static ArrayList<Integer> primes ; static long factorial[] ,invFactorial[] ; static ArrayList<Pair> graph[] ; static boolean oj = (System.getProperty("ONLINE_JUDGE") != null); static int n ,m ; static long cost[][] ,dp[] ; public static void main( String[] args)throws Exception { String st[] = nl(); n = pi(st[0]); m = pi(st[1]); st = nl(); String str = st[0];  int mn = 10000; for ( int i = 0;(i < n);i++) {mn = Math.min(mn,str.charAt(i)); }cost = new long[m][m]; for ( int i = 1;(i < n);i++) { int a1 = (str.charAt((i - 1)) - mn);  int a2 = (str.charAt(i) - mn); if ( (a1 == a2)) continue; cost[a1][a2]++; cost[a2][a1]++; } int mm = (1 << m); dp = new long[mm]; Arrays.fill(dp,(Long.MAX_VALUE / 2)); dp[0] = 0; long cntbit[] = new long[mm];  int minbit[] = new int[mm]; for ( int mask = 1;(mask < mm);mask++) {cntbit[mask] = (1 + cntbit[(mask & (mask - 1))]); for ( int i = 0;(i < m);i++) {if ( (((mask >> i) & 1) != 0)) {minbit[mask] = i; break;} }} long cntcost[][] = new long[mm][m]; for ( int mask = 0;(mask < mm);mask++) {for ( int i = 0;(i < m);i++) { int b = minbit[mask]; cntcost[mask][i] = (cntcost[(mask ^ (1 << b))][i] + cost[i][b]); }} int yy = (mm - 1); for ( int mask = 0;(mask < mm);mask++) { long cnt = cntbit[mask]; for ( int i = 0;(i < m);i++) {if ( (((mask >> i) & 1) != 0)) { long ans = (cnt * (cntcost[mask][i] - cntcost[(yy ^ mask)][i])); dp[mask] = Math.min(dp[mask],(dp[(mask ^ (1 << i))] + ans)); } }}out.println(dp[(mm - 1)]); out.flush(); out.close(); } static String[] nl()throws Exception { return br.readLine().split(" ");} static int pi( String str){ return Integer.parseInt(str);} static class Pair implements Comparable<Pair>{ int u ; int v ; int index = -1; public Pair( int u, int v){ this.u = u; this.v = v; } } }
6	public class e1{ static int n ; static int m ; static int[][] mat ; public static void main( String[] args){ JS scan = new JS();  PrintWriter out = new PrintWriter(System.out);  int t = scan.nextInt(); for ( int q = 1;(q <= t);q++) {ans = 0; n = scan.nextInt(); m = scan.nextInt(); mat = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {mat[i][j] = scan.nextInt(); }} int[] max = new int[m];  PriorityQueue<Item> pq = new PriorityQueue<Item>(); for ( int i = 0;(i < m);i++) {for ( int j = 0;(j < n);j++) {max[i] = Math.max(max[i],mat[j][i]); }pq.add(new Item(i,max[i])); } ArrayList<Item> guys = new ArrayList<Item>(); while((!pq.isEmpty() && (guys.size() < 8))){ Item tt = pq.poll(); guys.add(tt); }perm(guys,0,new int[guys.size()]); out.println(ans); }out.flush(); } static int ans = 0; static void perm( ArrayList<Item> guys, int me, int[] shift){ if ( (me == guys.size())) { int res = 0;  int[] best = new int[n]; for ( int j = 0;(j < guys.size());j++) { Item g = guys.get(j);  int pp = g.a; for ( int i = 0;(i < n);i++) {best[((i + shift[j]) % n)] = Math.max(best[((i + shift[j]) % n)],mat[i][pp]); }}for ( int i = 0;(i < n);i++) res += best[i]; ans = Math.max(res,ans); return ;} for ( int i = 0;(i < n);i++) {shift[me] = i; perm(guys,(me + 1),shift); }} static class Item implements Comparable<Item>{ int a ; int b ; public Item( int a, int b){ this.a = a; this.b = b; } } static class JS{ public int BS = (1 << 16); public char NC = (char)0; byte[] buf = new byte[BS]; int bId = 0,size = 0; char c = NC; double num = 1; BufferedInputStream in ; public JS(){ in = new BufferedInputStream(System.in,BS); } public JS( String s)throws FileNotFoundException{ in = new BufferedInputStream(new FileInputStream(new File(s)),BS); } public char nextChar(){ while((bId == size)){try{size = in.read(buf); }catch (Exception e){ return NC;} if ( (size == -1)) return NC; bId = 0; }return (char)buf[bId++];} public int nextInt(){ return (int)nextLong();} public long nextLong(){ num = 1; boolean neg = false; if ( (c == NC)) c = nextChar(); for ( ;((c < '0') || (c > '9'));c = nextChar()) {if ( (c == '-')) neg = true; } long res = 0; for ( ;((c >= '0') && (c <= '9'));c = nextChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); num *= 10; }return (neg?-res:res);} } }
3	public class NewYearsCurling{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  StringTokenizer st = new StringTokenizer(sc.nextLine());  int n = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken());  ArrayList<Integer> centers = new ArrayList<Integer>(); st = new StringTokenizer(sc.nextLine()); for ( int i = 0;(i < n);i++) {centers.add(Integer.parseInt(st.nextToken())); }sc.close(); ArrayList<Point> finalpoints = new ArrayList<Point>(); for ( int i = 0;(i < n);i++) { double maxy = r; for ( int j = 0;(j < finalpoints.size());j++) {if ( (((finalpoints.get(j).x - centers.get(i)) > (2 * r)) || ((centers.get(i) - finalpoints.get(j).x) > (2 * r)))) continue; double dist = (Math.sqrt((((4 * r) * r) - ((finalpoints.get(j).x - centers.get(i)) * (finalpoints.get(j).x - centers.get(i))))) + finalpoints.get(j).y); if ( (dist > maxy)) maxy = dist; }pw.print((maxy + " ")); finalpoints.add(new Point(centers.get(i),maxy)); }pw.close(); } public static class Point{ double x ; double y ; public Point( double x, double y){ this.x = x; this.y = y; } } }
3	public class init{ static int mod = 1000000007; public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) { char c = s.next().charAt(0); if ( (c == 'f')) a[i] = 1; } int dp[][] = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= n);j++) dp[i][j] = -1; }System.out.println(ans(dp,1,0,a,n)); } public static int ans( int[][] dp, int i, int j, int[] a, int n){ if ( (i == n)) {return 1;} if ( (dp[i][j] != -1)) {return dp[i][j];} if ( (a[(i - 1)] == 1)) { int x = ans(dp,(i + 1),(j + 1),a,n); if ( (x != -1)) dp[i][j] = (x % mod); } else { int x = -1; if ( (j != 0)) x = ans(dp,i,(j - 1),a,n);  int y = ans(dp,(i + 1),j,a,n); if ( (x != -1)) dp[i][j] = (x % mod); if ( (y != -1)) {if ( (dp[i][j] == -1)) dp[i][j] = (y % mod); else dp[i][j] += (y % mod); } }return dp[i][j];} }
4	public class x1497E{ static final int MAX = 10000000; public static void main( String[] hi)throws Exception { int[] prime = new int[(MAX + 1)]; for ( int d = 2;(d <= MAX);d++) if ( (prime[d] == 0)) for ( int v = d;(v <= MAX);v += d) if ( (prime[v] == 0)) prime[v] = d;  FastScanner infile = new FastScanner();  int T = infile.nextInt();  StringBuilder sb = new StringBuilder();  int[] freq = new int[(MAX + 1)];  int[] ts = new int[(MAX + 1)];  int time = 0; while((T-- > 0)){ int N = infile.nextInt();  int K = infile.nextInt();  int[] arr = infile.nextInts(N); for ( int i = 0;(i < N);i++) { int key = 1; while((arr[i] > 1)){ int p = prime[arr[i]];  int cnt = 0; while(((arr[i] % p) == 0)){arr[i] /= p; cnt ^= 1; }if ( (cnt == 1)) key *= p; }arr[i] = key; } int[][] right = new int[N][(K + 1)]; for ( int k = 0;(k <= K);k++) { int dex = 0;  int cnt = 0; for ( int i = 0;(i < N);i++) {while(((dex < N) && (cnt <= k))){if ( (((ts[arr[dex]] == time) && (freq[arr[dex]] >= 1)) && ((cnt + 1) > k))) break; if ( ((ts[arr[dex]] == time) && (freq[arr[dex]] >= 1))) cnt++; if ( (ts[arr[dex]] < time)) {ts[arr[dex]] = time; freq[arr[dex]] = 0; } freq[arr[dex]]++; dex++; }right[i][k] = dex; if ( (freq[arr[i]] >= 2)) cnt--; freq[arr[i]]--; }time++; } int[][] dp = new int[(N + 1)][(K + 1)]; for ( int i = 1;(i <= N);i++) Arrays.fill(dp[i],N); for ( int i = 0;(i < N);i++) for ( int a = 0;(a <= K);a++) {dp[(i + 1)][a] = min(dp[(i + 1)][a],(dp[i][a] + 1)); for ( int b = 0;(b <= (K - a));b++) dp[right[i][b]][(a + b)] = min(dp[right[i][b]][(a + b)],(dp[i][a] + 1)); } int res = dp[N][0]; for ( int k = 1;(k <= K);k++) res = min(res,dp[N][k]); sb.append((res + "\n")); }System.out.print(sb); } } class FastScanner{ private int BS = (1 << 16); private char NC = (char)0; private byte[] buf = new byte[BS]; private int bId = 0,size = 0; private char c = NC; private double cnt = 1; private BufferedInputStream in ; public FastScanner(){ in = new BufferedInputStream(System.in,BS); } public FastScanner( String s){ try{in = new BufferedInputStream(new FileInputStream(new File(s)),BS); }catch (Exception e){ in = new BufferedInputStream(System.in,BS); } } private char getChar(){ while((bId == size)){try{size = in.read(buf); }catch (Exception e){ return NC;} if ( (size == -1)) return NC; bId = 0; }return (char)buf[bId++];} public int nextInt(){ return (int)nextLong();} public int[] nextInts( int N){ int[] res = new int[N]; for ( int i = 0;(i < N);i++) {res[i] = (int)nextLong(); }return res;} public long nextLong(){ cnt = 1; boolean neg = false; if ( (c == NC)) c = getChar(); for ( ;((c < '0') || (c > '9'));c = getChar()) {if ( (c == '-')) neg = true; } long res = 0; for ( ;((c >= '0') && (c <= '9'));c = getChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); cnt *= 10; }return (neg?-res:res);} public double nextDouble(){ double cur = nextLong(); return ((c != '.')?cur:(cur + (nextLong() / cnt)));} }
5	public class Main{ public static void main( String[] args)throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  int[] A = new int[n];  String[] s = br.readLine().split(" "); for ( int i = 0;(i < n);i++) {A[i] = Integer.parseInt(s[i]); } Map memo = new HashMap();  int[] f = new int[n]; for ( int i = 0;(i < n);i++) {if ( !memo.containsKey(A[i])) {memo.put(A[i],1); } else { int ct = (int)memo.get(A[i]); memo.put(A[i],(ct + 1)); } int tot = 0; if ( memo.containsKey((A[i] - 1))) {tot += (int)memo.get((A[i] - 1)); } if ( memo.containsKey((A[i] + 1))) {tot += (int)memo.get((A[i] + 1)); } tot += (int)memo.get(A[i]); f[i] = tot; } BigInteger res = new BigInteger("0"); for ( int i = 0;(i < n);i++) { int tot1 = ((i + 1) - f[i]);  int tot2 = 0; if ( memo.containsKey((A[i] - 1))) {tot2 += (int)memo.get((A[i] - 1)); } if ( memo.containsKey((A[i] + 1))) {tot2 += (int)memo.get((A[i] + 1)); } tot2 += (int)memo.get(A[i]); tot2 = (((n - i) - 1) - (tot2 - f[i])); res = res.add(BigInteger.valueOf(((long)(tot1 - tot2) * (long)A[i]))); }System.out.println(res); } }
2	public class B implements Runnable{ static private final Random rnd = new Random(); int n ; private void solve(){ this.query = 0; this.n = readInt(); int left1 = 0;  int l = 1,r = n; while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(m,1,n,n); if ( (answer < 2)) {r = (m - 1); } else {left1 = m; l = (m + 1); }} int left2 = left1; l = (left1 + 1); r = n; while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(m,1,n,n); if ( (answer < 1)) {r = (m - 1); } else {left2 = m; l = (m + 1); }} int right2 = (n + 1); l = 1; r = n; while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(1,1,m,n); if ( (answer < 2)) {l = (m + 1); } else {right2 = m; r = (m - 1); }} int right1 = right2; l = 1; r = (right2 - 1); while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(1,1,m,n); if ( (answer < 1)) {l = (m + 1); } else {right1 = m; r = (m - 1); }} int bottom1 = 0; l = 1; r = n; while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(1,m,n,n); if ( (answer < 2)) {r = (m - 1); } else {bottom1 = m; l = (m + 1); }} int bottom2 = bottom1; l = (bottom1 + 1); r = n; while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(1,m,n,n); if ( (answer < 1)) {r = (m - 1); } else {bottom2 = m; l = (m + 1); }} int top2 = (n + 1); l = 1; r = n; while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(1,1,n,m); if ( (answer < 2)) {l = (m + 1); } else {top2 = m; r = (m - 1); }} int top1 = top2; l = 1; r = (top2 - 1); while((l <= r)){ int m = ((l + r) / 2);  int answer = getAnswer(1,1,n,m); if ( (answer < 1)) {l = (m + 1); } else {top1 = m; r = (m - 1); }} int ansLeftRightMask = -1,ansBottomTopMask = -1;  long answerS = ((2L * n) * n); for ( int leftRightMask = 0;(leftRightMask < 4);++leftRightMask) { int left = (checkBit(leftRightMask,0)?left1:left2);  int right = (checkBit(leftRightMask,1)?right1:right2); for ( int bottomTopMask = 0;(bottomTopMask < 4);++bottomTopMask) { int bottom = (checkBit(bottomTopMask,0)?bottom1:bottom2);  int top = (checkBit(bottomTopMask,1)?top1:top2);  int curTry = getAnswer(left,bottom,right,top); if ( (curTry == 1)) { long s = (((right - left) + 1L) * ((top - bottom) + 1L)); if ( (s < answerS)) {answerS = s; ansLeftRightMask = leftRightMask; ansBottomTopMask = bottomTopMask; } } }} int left = (checkBit(ansLeftRightMask,0)?left1:left2);  int right = (checkBit(ansLeftRightMask,1)?right1:right2);  int bottom = (checkBit(ansBottomTopMask,0)?bottom1:bottom2);  int top = (checkBit(ansBottomTopMask,1)?top1:top2); printAnswer(left,bottom,right,top,((left1 + left2) - left),((bottom1 + bottom2) - bottom),((right1 + right2) - right),((top1 + top2) - top)); } private void printAnswer( int... values){ printQuery("!",values); } private void printQuery( String sign, int... values){ out.print(sign); for ( int value :values) {out.print((" " + value)); }out.println(); out.flush(); } int query = 0; final int MAX_QUERY = 200; private int getAnswer( int left, int bottom, int right, int top){ if ( ((left < 1) || (right > n))) {while(true);} if ( ((bottom < 1) || (top > n))) {throw (new RuntimeException());} if ( ((left > right) || (bottom > top))) {return 0;} if ( (query == MAX_QUERY)) {throw (new RuntimeException());} ++query; printQuery("?",left,bottom,right,top); int answer = readInt(); return answer;} static private final boolean FIRST_INPUT_STRING = false; static private final boolean MULTIPLE_TESTS = true; static private final boolean INTERACTIVE = true; private final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); static private final int MAX_STACK_SIZE = 128; static private final boolean OPTIMIZE_READ_NUMBERS = false; private BufferedReader in ; private OutputWriter out ; private StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new B(),"",(MAX_STACK_SIZE * (1L << 20))).start(); } private void init()throws FileNotFoundException { Locale.setDefault(Locale.US); if ( (INTERACTIVE || ONLINE_JUDGE)) {in = new BufferedReader(new InputStreamReader(System.in)); out = new OutputWriter(System.out); } else {in = new BufferedReader(new FileReader("input.txt")); out = new OutputWriter("output.txt"); }} private long timeBegin ; private void timeInit(){ this.timeBegin = System.currentTimeMillis(); } private void time(){ long timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } private String delim = " "; private String readLine(){ try{return in.readLine(); }catch (IOException e){ throw (new RuntimeIOException(e));} } private String readString(){ try{while(!tok.hasMoreTokens()){tok = new StringTokenizer(readLine()); }return tok.nextToken(delim); }catch (NullPointerException e){ return null;} } private final char NOT_A_SYMBOL = '\0'; private char[] readCharArray(){ return readLine().toCharArray();} private long optimizedReadLong(){ long result = 0;  boolean started = false; while(true){try{ int j = in.read(); if ( (-1 == j)) {if ( started) return result; throw (new NumberFormatException());} if ( (('0' <= j) && (j <= '9'))) {result = (((result * 10) + j) - '0'); started = true; } else if ( started) {return result;} }catch (IOException e){ throw (new RuntimeIOException(e));} }} private int readInt(){ if ( !OPTIMIZE_READ_NUMBERS) {return Integer.parseInt(readString());} else {return (int)optimizedReadLong();}} private int[] readIntArray( int size){ int[] array = new int[size]; for ( int index = 0;(index < size);++index) {array[index] = readInt(); }return array;} private int[] readIntArrayWithDecrease( int size){ int[] array = readIntArray(size); for ( int i = 0;(i < size);++i) {array[i]--; }return array;} private long readLong(){ if ( !OPTIMIZE_READ_NUMBERS) {return Long.parseLong(readString());} else {return optimizedReadLong();}} private double readDouble(){ return Double.parseDouble(readString());} private Point readPoint(){ int x = readInt();  int y = readInt(); return new Point(x,y);} private static class IntIndexPair{ static Comparator<IntIndexPair> increaseComparator = new Comparator<B.IntIndexPair>(){}; static Comparator<IntIndexPair> decreaseComparator = new Comparator<B.IntIndexPair>(){}; int value ,index ; IntIndexPair( int value, int index){ super(); this.value = value; this.index = index; } } private static class OutputWriter extends PrintWriter{ final int DEFAULT_PRECISION = 12; private int precision ; private String format ,formatWithSpace ; {precision = DEFAULT_PRECISION; format = createFormat(precision); formatWithSpace = (format + " "); }OutputWriter( OutputStream out){ super(out); } OutputWriter( String fileName)throws FileNotFoundException{ super(fileName); } String createFormat( int precision){ return (("%." + precision) + "f");} @Override public void print( double d){ printf(format,d); } void printWithSpace( double d){ printf(formatWithSpace,d); } void printAll( double... d){ for ( int i = 0;(i < (d.length - 1));++i) {printWithSpace(d[i]); }print(d[(d.length - 1)]); } @Override public void println( double d){ printlnAll(d); } void printlnAll( double... d){ printAll(d); println(); } } private static class RuntimeIOException extends RuntimeException{ private static final long serialVersionUID = -6463830523020118289L; RuntimeIOException( Throwable cause){ super(cause); } } private static final int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; private static final int[][] steps8 = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{1,-1},{-1,1}}; private static boolean checkIndex( int index, int lim){ return ((0 <= index) && (index < lim));} private static boolean checkBit( int mask, int bit){ return ((mask & (1 << bit)) != 0);} private static boolean checkBit( long mask, int bit){ return ((mask & (1L << bit)) != 0);} private static long gcd( long a, long b){ return ((a == 0)?b:gcd((b % a),a));} }
4	public class A{ static int dx[] = {1,-1,0,0}; static int dy[] = {0,0,1,-1}; public static void main( String[] args)throws Exception { Scanner sc = new Scanner("input.txt");  PrintWriter out = new PrintWriter("output.txt");  int n = sc.nextInt(),m = sc.nextInt();  int[][] grid = new int[n][m]; for ( int[] i :grid) Arrays.fill(i,-1); Queue<Pair> q = new LinkedList<>();  int k = sc.nextInt(); for ( int i = 0;(i < k);i++) { int x = (sc.nextInt() - 1),y = (sc.nextInt() - 1); grid[x][y] = 0; q.add(new Pair(x,y)); } Pair p = new Pair(-1,-1); while(!q.isEmpty()){p = q.poll(); for ( int i = 0;(i < dx.length);i++) { int tx = (p.x + dx[i]),ty = (p.y + dy[i]); if ( (((((tx >= 0) && (tx < n)) && (ty >= 0)) && (ty < m)) && (grid[tx][ty] == -1))) {grid[tx][ty] = (grid[p.x][p.y] + 1); q.add(new Pair(tx,ty)); } }}out.println(p); out.flush(); out.close(); } static class Pair{ int x ,y ; public Pair( int a, int b){ x = a; y = b; } } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String r)throws FileNotFoundException{ br = new BufferedReader(new FileReader(r)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
4	public class P023A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  String line = in.next();  HashSet<String> hash = new HashSet<String>();  int ans = 0; for ( int len = (line.length() - 1);(len > 0);--len) {for ( int i = 0;((i + len) <= line.length());++i) { String sub = line.substring(i,(i + len)); if ( hash.contains(sub)) {ans = Math.max(ans,sub.length()); } hash.add(sub); }}System.out.println(ans); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ private long MOD = (long)(1e9 + 7); int[][] dp = new int[5001][5001]; public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  ArrayList<Character> commands = new ArrayList<>(); for ( int i = 0;(i < n);i++) { char ch = in.next().charAt(0); commands.add(ch); }for ( int[] a :dp) Arrays.fill(a,-1); out.println(count(0,commands,0)); } public int count( int index, ArrayList<Character> commands, int deepCount){ if ( (deepCount < 0)) {return 0;} if ( (index == commands.size())) {return 1;} else {if ( (dp[index][deepCount] != -1)) return dp[index][deepCount]; long result = 0;  char ch = commands.get(index); result = count(index,commands,(deepCount - 1)); if ( (ch == 's')) {result += count((index + 1),commands,deepCount); } else {result += count((index + 1),commands,(deepCount + 1)); result -= count((index + 1),commands,deepCount); }if ( (result >= MOD)) {result -= MOD; } if ( (result < 0)) {result += MOD; } return dp[index][deepCount] = (int)result;}} } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c)){c = read(); } StringBuilder res = new StringBuilder(); do {if ( Character.isValidCodePoint(c)) {res.appendCodePoint(c); } c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public String next(){ return readString();} public int nextInt(){ return readInt();} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
6	public class Main{ public static void main( String[] args){ new Main().run(); } FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ out.println(work()); out.flush(); } long mod = 1000000007; long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} long work(){ int n = in.nextInt();  int m = in.nextInt();  String str = in.next();  long[] dp = new long[(1 << m)];  long[][] cnt = new long[m][m];  long[] rec = new long[(1 << m)]; for ( int i = 1;(i < n);i++) { int n1 = (str.charAt((i - 1)) - 'a');  int n2 = (str.charAt(i) - 'a'); cnt[n1][n2]++; cnt[n2][n1]++; }for ( int i = 1;(i < (1 << m));i++) {dp[i] = 9999999999L; long v = 0;  int b = 0; for ( int j = 0;(j < m);j++) {if ( ((i & (1 << j)) > 0)) {b = j; break;} }for ( int j = 0;(j < m);j++) {if ( ((i & (1 << j)) == 0)) {v += cnt[b][j]; } else {if ( (b != j)) v -= cnt[b][j]; }}v += rec[(i - (1 << b))]; for ( int j = 0;(j < m);j++) {if ( ((i & (1 << j)) > 0)) {dp[i] = Math.min(dp[i],(dp[(i - (1 << j))] + v)); } }rec[i] = v; }return dp[((1 << m) - 1)];} } class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next(){ if ( ((st == null) || !st.hasMoreElements())) {try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
6	public class B{ private void solve()throws IOException { int senators = nextInt();  int candies = nextInt(); scoreA = nextInt(); lvl = new int[senators]; unloyal = new int[senators]; for ( int i = 0;(i < senators);i++) {lvl[i] = nextInt(); unloyal[i] = (10 - (nextInt() / 10)); }n = senators; give = new int[n]; res = 0; go(0,candies); out.println(res); } static double res ; static int[] lvl ; static int[] unloyal ; static int[] give ; static int n ; static int scoreA ; static double probability(){ double res = 0; for ( int mask = 0;(mask < (1 << n));mask++) { double p = 1;  int scoreB = 0;  int cntGood = Integer.bitCount(mask); for ( int i = 0;(i < n);i++) { int cnt = (unloyal[i] - give[i]); if ( ((mask & (1 << i)) == 0)) {scoreB += lvl[i]; p *= (cnt * .1); } else {p *= ((10 - cnt) * .1); }}if ( ((2 * cntGood) > n)) {res += p; } else {res += ((p * scoreA) / (scoreA + scoreB)); }}return res;} static void go( int man, int candies){ if ( (man == n)) {res = max(res,probability()); return ;} give[man] = 0; go((man + 1),candies); for ( int i = 1;(i <= min(unloyal[man],candies));i++) {give[man] = i; go((man + 1),(candies - i)); }} public static void main( String[] args){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); new B().solve(); out.close(); }catch (Throwable e){ e.printStackTrace(); System.exit(239); } } static BufferedReader br ; static StringTokenizer st ; static PrintWriter out ; static String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = br.readLine(); if ( (line == null)) {return null;} st = new StringTokenizer(line); }return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
5	public class Problem220A{ static int[] numbers ; static int[] numbersCopy ; public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int i = Integer.parseInt(in.readLine()); numbers = new int[i]; numbersCopy = new int[i]; StringTokenizer stringTokenizer = new StringTokenizer(in.readLine());  int numOutOfPlace = 0; for ( int j = 0;(j < i);j++) {numbers[j] = Integer.parseInt(stringTokenizer.nextToken()); numbersCopy[j] = numbers[j]; }Arrays.sort(numbers); for ( int j = 0;(j < i);j++) {if ( (numbers[j] != numbersCopy[j])) {numOutOfPlace++; if ( (numOutOfPlace > 2)) {break;} } }if ( ((numOutOfPlace == 0) || (numOutOfPlace == 2))) {System.out.println("YES"); } else {System.out.println("NO"); }} }
6	public class f{ static int n ; static double[][] g ; public static void main( String[] args)throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); n = input.nextInt(); g = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) g[i][j] = input.nextDouble(); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) g[j][i] = (1 - g[i][j]); for ( int i = 0;(i < n);i++) { double[] dp = new double[(1 << n)]; for ( int mask = 0;(mask < (1 << n));mask++) {if ( ((mask & (1 << i)) == 0)) {dp[mask] = 0; continue;} if ( (mask == (1 << i))) {dp[mask] = 1; continue;} int count = Integer.bitCount(mask);  double prob = (1.0 / ((count * (count - 1)) / 2)); for ( int a = 0;(a < n);a++) {if ( ((mask & (1 << a)) == 0)) continue; for ( int b = (a + 1);(b < n);b++) {if ( ((mask & (1 << b)) == 0)) continue; double p = ((g[a][b] * dp[(mask ^ (1 << b))]) + (g[b][a] * dp[(mask ^ (1 << a))])); dp[mask] += p; }}dp[mask] *= prob; }out.print((dp[((1 << n) - 1)] + " ")); }out.close(); } }
3	public class D911{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  StringTokenizer st ;  int n = Integer.parseInt(br.readLine()); st = new StringTokenizer(br.readLine()); int[] num = new int[n]; for ( int i = 0;(i < n);i++) {num[i] = Integer.parseInt(st.nextToken()); } int count = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( (num[i] < num[j])) {count++; } }} boolean ans = ((count % 2) == 0); for ( int m = Integer.parseInt(br.readLine());(m-- > 0);) {st = new StringTokenizer(br.readLine()); int l = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken()); if ( (((((r - l) + 1) / 2) % 2) != 0)) {ans = !ans; } out.println((ans?"even":"odd")); }out.close(); } }
4	public class Codechef{ public static void main( String[] args)throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int t = Integer.parseInt(br.readLine()); for ( int q = 0;(q < t);q++) { String s = br.readLine();  int n = Integer.parseInt(s);  int a[] = new int[1000];  int index = 0; for ( int i = 0;(i < n);i++) { int x = Integer.parseInt(br.readLine()); for ( int j = index;(j >= 0);j--) {if ( ((x - 1) == a[j])) {a[j] = x; for ( int k = 0;(k < j);k++) {System.out.print((a[k] + ".")); }System.out.print(a[j]); System.out.println(); for ( int k = (j + 1);(k < 1000);k++) {if ( (a[k] != 0)) a[k] = 0; else break;}index = (j + 1); break;} }}}} }
2	public class B713{ public static BufferedReader f ; public static PrintWriter out ; public static void main( String[] args)throws IOException { f = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = Integer.parseInt(f.readLine());  int l ;  int r ;  int mid ;  int ans ; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); if ( (mid == n)) break; int il = query(1,1,n,mid);  int ir = query(1,(mid + 1),n,n); if ( ((il == 1) && (ir == 1))) {ans = mid; break;} if ( (il > ir)) {r = (mid - 1); } else {l = (mid + 1); }} int x11 = -1;  int y11 = -1;  int x12 = -1;  int y12 = -1;  int x21 = -1;  int y21 = -1;  int x22 = -1;  int y22 = -1; if ( (ans == -1)) {l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int il = query(1,1,mid,n);  int ir = query((mid + 1),1,n,n); if ( ((il == 1) && (ir == 1))) {ans = mid; break;} if ( (il > ir)) {r = (mid - 1); } else {l = (mid + 1); }} int bar = ans; l = 1; r = bar; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(mid,1,bar,n); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}x11 = ans; l = 1; r = bar; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,1,mid,n); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}x12 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,mid,bar,n); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}y11 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,1,bar,mid); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}y12 = ans; l = (bar + 1); r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(mid,1,n,n); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}x21 = ans; l = (bar + 1); r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query((bar + 1),1,mid,n); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}x22 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query((bar + 1),mid,n,n); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}y21 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query((bar + 1),1,n,mid); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}y22 = ans; } else { int bar = ans; l = 1; r = bar; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,mid,n,bar); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}y11 = ans; l = 1; r = bar; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,1,n,mid); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}y12 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(mid,1,n,bar); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}x11 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,1,mid,bar); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}x12 = ans; l = (bar + 1); r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,mid,n,n); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}y21 = ans; l = (bar + 1); r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,(bar + 1),n,mid); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}y22 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(mid,(bar + 1),n,n); if ( (i == 1)) {ans = mid; l = (mid + 1); } else {r = (mid - 1); }}x21 = ans; l = 1; r = n; ans = -1; while((l <= r)){mid = (l + ((r - l) / 2)); int i = query(1,(bar + 1),mid,n); if ( (i == 1)) {ans = mid; r = (mid - 1); } else {l = (mid + 1); }}x22 = ans; }out.println(((((((((((((((("! " + x11) + " ") + y11) + " ") + x12) + " ") + y12) + " ") + x21) + " ") + y21) + " ") + x22) + " ") + y22)); out.close(); } public static int query( int a, int b, int c, int d)throws IOException { out.println(((((((("? " + a) + " ") + b) + " ") + c) + " ") + d)); out.flush(); return Integer.parseInt(f.readLine());} }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringBuilder out = new StringBuilder();  StringTokenizer tk ;  long n = parseLong(in.readLine()); if ( (n <= 2)) System.out.println(n); else if ( ((n % 2) == 1)) System.out.println(((n * (n - 1)) * (n - 2))); else { long ans = (((n - 1) * (n - 2)) * (n - 3)); if ( (gcd((n * (n - 1)),(n - 3)) == 1)) ans = max(ans,((n * (n - 1)) * (n - 3))); System.out.println(ans); }} static long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} }
1	public class A{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(bf.readLine());  int n = Integer.parseInt(st.nextToken());  int d = Integer.parseInt(st.nextToken()); st = new StringTokenizer(bf.readLine()); int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(st.nextToken()); int ans = 2; for ( int i = 0;(i < (n - 1));i++) { int diff = (a[(i + 1)] - a[i]); if ( (diff == (2 * d))) ans++; else if ( (diff > (2 * d))) ans += 2; }System.out.println(ans); } }
2	public class P1177A{ public static void main( String[] args)throws FileNotFoundException { Scanner in = new Scanner(System.in); System.out.println(solve(in.nextLong())); } private static String solve( long k){ long digitCnt = 1;  long nine = 9; while((k > (nine * digitCnt))){k -= (nine * digitCnt); nine *= 10; digitCnt++; } long num = ((((nine / 9) - 1) + ((k - 1) / digitCnt)) + 1); return String.valueOf(String.valueOf(num).charAt((int)((k - 1) % digitCnt)));} }
1	public class B{ static char[] digits = {'0','1','2','3','4','5','6','7','8','9'}; static HashMap<Character,Integer> val = new HashMap<Character,Integer>(); static HashMap<Integer,Character> ch = new HashMap<Integer,Character>(); static StringBuffer strcol = new StringBuffer(); static String s ; static boolean isDigit( char a){ boolean found = false; for ( int i = 0;(i < digits.length);i++) {if ( found = (a == digits[i])) break; }return found;} static String ABtoRC( int pos){ do {++pos; }while(!isDigit(s.charAt(pos))); int res = 0; for ( int i = (pos - 1),pow = 1;(i >= 0);i--,pow *= 26) {res += (val.get(s.charAt(i)) * pow); }return new String(((("R" + s.substring(pos,s.length())) + "C") + String.valueOf(res)));} static String RCtoAB( int cpos){ int col = Integer.valueOf(s.substring((cpos + 1),s.length()));  int mod = 0; strcol.delete(0,strcol.length()); while((col >= 26)){ int tmp = (col / 26); mod = (col - (26 * tmp)); if ( (mod == 0)) {mod += 26; tmp -= 1; } col = tmp; strcol.append(ch.get(mod)); }if ( (col != 0)) strcol.append(ch.get(col)); strcol.reverse(); return (strcol.toString() + s.substring(1,cpos));} public static void main( String[] args)throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in));  PrintWriter output = new PrintWriter(new OutputStreamWriter(System.out));  StreamTokenizer in = new StreamTokenizer(input); in.nextToken(); int n = (int)in.nval; for ( int i = 0;(i < 26);i++) {val.put((char)('A' + i),(i + 1)); }for ( int i = 0;(i < 26);i++) {ch.put((i + 1),(char)('A' + i)); }input.readLine(); for ( int i = 0;(i < n);i++) {s = input.readLine(); int cpos ; if ( (((cpos = s.indexOf('C')) > 1) && isDigit(s.charAt((cpos - 1))))) {output.println(RCtoAB(cpos)); } else {output.println(ABtoRC(cpos)); }}output.close(); input.close(); } }
3	@SuppressWarnings("Duplicates") public class solveLOL{ FastScanner in ; PrintWriter out ; boolean systemIO = true,multitests = false; int INF = (Integer.MAX_VALUE / 2); void solve(){ int n = in.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = in.nextInt(); }Arrays.sort(arr); boolean used[] = new boolean[n];  int k = 0; for ( int i = 0;(i < n);i++) {if ( !used[i]) {used[i] = true; for ( int j = (i + 1);(j < n);j++) {if ( (!used[j] && ((arr[j] % arr[i]) == 0))) {used[j] = true; } }k++; } }System.out.println(k); } private void run()throws IOException { if ( systemIO) {in = new solveLOL.FastScanner(System.in); out = new PrintWriter(System.out); } else {in = new solveLOL.FastScanner(new File("input.txt")); out = new PrintWriter(new File("output.txt")); }for ( int t = (multitests?in.nextInt():1);(t-- > 0);) solve(); out.close(); } public static void main( String[] arg)throws IOException { new solveLOL().run(); } }
4	public class LRS{ public static String lcp( String s, String t){ int n = Math.min(s.length(),t.length()); for ( int i = 0;(i < n);i++) {if ( (s.charAt(i) != t.charAt(i))) return s.substring(0,i); }return s.substring(0,n);} public static String lrs( String s){ int N = s.length();  String[] suffixes = new String[N]; for ( int i = 0;(i < N);i++) {suffixes[i] = s.substring(i,N); }Arrays.sort(suffixes); String lrs = ""; for ( int i = 0;(i < (N - 1));i++) { String x = lcp(suffixes[i],suffixes[(i + 1)]); if ( (x.length() > lrs.length())) lrs = x; }return lrs;} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String s = br.readLine(); s = s.replaceAll("\\s+"," "); System.out.println(lrs(s).length()); } }
2	public class pr169D implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer str ; public void solve()throws IOException { long l = nextLong();  long r = nextLong();  long x = (l ^ r);  long i = 1; while((x >= i))i *= 2; out.println(((x > i)?x:(i - 1))); } public String nextToken()throws IOException { while(((str == null) || !str.hasMoreTokens())){str = new StringTokenizer(in.readLine()); }return str.nextToken();} public long nextLong()throws IOException { return Long.parseLong(nextToken());} public static void main( String[] args){ new Thread(new pr169D()).start(); } }
6	public class Main{ private void run()throws IOException { int cx = in.nextInt();  int cy = in.nextInt();  int n = in.nextInt();  int[] x = new int[n];  int[] y = new int[n]; for ( int i = 0;(i < n);++i) {x[i] = (in.nextInt() - cx); y[i] = (in.nextInt() - cy); } int[] dp = new int[(1 << n)]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; int[] prev = new int[(1 << n)]; for ( int mask = 0;(mask < (1 << n));++mask) {if ( (dp[mask] == Integer.MAX_VALUE)) {continue;} for ( int i = 0;(i < n);++i) {if ( (((mask >> i) & 1) == 0)) {if ( (dp[(mask | (1 << i))] > (dp[mask] + dist(x[i],y[i])))) {dp[(mask | (1 << i))] = (dp[mask] + dist(x[i],y[i])); prev[(mask | (1 << i))] = mask; } for ( int j = (i + 1);(j < n);++j) {if ( (((mask >> j) & 1) == 0)) {if ( (dp[((mask | (1 << i)) | (1 << j))] > (dp[mask] + dist(x[i],y[i],x[j],y[j])))) {dp[((mask | (1 << i)) | (1 << j))] = (dp[mask] + dist(x[i],y[i],x[j],y[j])); prev[((mask | (1 << i)) | (1 << j))] = mask; } } }break;} }}out.println(dp[((1 << n) - 1)]); int mask = ((1 << n) - 1); out.print(0); while((mask != 0)){ int p = prev[mask];  int cur = (p ^ mask);  List<Integer> who = new ArrayList<Integer>(); for ( int i = 0;(i < n);++i) {if ( (((cur >> i) & 1) != 0)) {who.add((i + 1)); } }for ( int t :who) {out.print((" " + t)); }out.print((" " + 0)); mask = p; }out.flush(); } private int dist( int x, int y, int x2, int y2){ return ((((((x * x) + (y * y)) + (x2 * x2)) + (y2 * y2)) + ((x2 - x) * (x2 - x))) + ((y2 - y) * (y2 - y)));} private int dist( int x, int y){ return (2 * ((x * x) + (y * y)));} private class Scanner{ private StringTokenizer tokenizer ; private BufferedReader reader ; public Scanner( Reader in){ reader = new BufferedReader(in); tokenizer = new StringTokenizer(""); } public boolean hasNext()throws IOException { while(!tokenizer.hasMoreTokens()){ String next = reader.readLine(); if ( (next == null)) return false; tokenizer = new StringTokenizer(next); }return true;} public String next()throws IOException { hasNext(); return tokenizer.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } public static void main( String[] args)throws IOException { new Main().run(); } Scanner in = new Scanner(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); }
4	public class GeorgeInterestingGraph{ int N = 505; int INF = (int)1e9; List<Integer>[] G = new List[N]; int[] match = new int[N]; int[] used = new int[N]; int cur = 0; {for ( int i = 0;(i < N);i++) G[i] = new ArrayList<>(1); } void solve(){ int n = in.nextInt(),m = in.nextInt();  int[] fr = new int[m],to = new int[m]; for ( int i = 0;(i < m);i++) {fr[i] = (in.nextInt() - 1); to[i] = (in.nextInt() - 1); } int ans = INF; for ( int i = 0;(i < n);i++) { int cnt = 0; for ( int j = 0;(j < n);j++) {G[j].clear(); match[j] = -1; }for ( int j = 0;(j < m);j++) {if ( ((fr[j] == i) || (to[j] == i))) {cnt++; } else {G[fr[j]].add(to[j]); }} int other = (m - cnt);  int max = 0; for ( int j = 0;(j < n);j++) {cur++; if ( augment(j)) max++; }ans = Math.min(ans,(((((((2 * (n - 1)) + 1) - cnt) + other) - max) + (n - 1)) - max)); }out.println(ans); } boolean augment( int u){ if ( (used[u] == cur)) return false; used[u] = cur; for ( int v :G[u]) {if ( ((match[v] < 0) || augment(match[v]))) {match[v] = u; return true;} }return false;} public static void main( String[] args){ in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); new GeorgeInterestingGraph().solve(); out.close(); } static FastScanner in ; static PrintWriter out ; static class FastScanner{ BufferedReader in ; StringTokenizer st ; public FastScanner( BufferedReader in){ this.in = in; } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(in.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} } }
4	public class Codechef{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int t = Integer.parseInt(br.readLine());  PrintWriter p = new PrintWriter(System.out); while((t-- > 0)){ int n = Integer.parseInt(br.readLine());  String a[] = new String[n]; for ( int i = 0;(i < n);i++) {a[i] = br.readLine(); } String pre = "1"; for ( int i = 1;(i < n);i++) {if ( a[i].equals("1")) {a[i] = (pre + ".1"); pre = a[i]; continue;} int li = pre.lastIndexOf('.'); while(((li != -1) && ((Integer.parseInt(pre.substring((li + 1))) + 1) != Integer.parseInt(a[i])))){pre = pre.substring(0,li); li = pre.lastIndexOf('.'); }if ( (li != -1)) a[i] = (pre.substring(0,(li + 1)) + a[i]); pre = a[i]; }for ( int i = 0;(i < n);i++) {p.println(a[i]); }p.flush(); }} }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastReader in = new FastReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ int val[] ; int p[] ; int aneigh[] ,bneight[] ,deg[] ; Deque<Integer> mycycle ; boolean loops = false; public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.ni(); val = new int[n]; int a = in.ni();  int b = in.ni();  Map<Integer,Integer> set = new TreeMap<Integer,Integer>(); p = in.iArr(n); for ( int i = 0;(i < n);i++) {set.put(p[i],i); }aneigh = new int[n]; bneight = new int[n]; deg = new int[n]; for ( int i = 0;(i < n);i++) {aneigh[i] = val[i] = bneight[i] = -1; deg[i] = 0; } Queue<Integer> queue = new ArrayDeque<Integer>(); for ( int i = 0;(i < n);i++) { Integer x1 = set.get((a - p[i]));  Integer x2 = set.get((b - p[i])); if ( (x1 != null)) {aneigh[i] = x1; deg[i]++; } if ( ((x2 != null) && (a != b))) {bneight[i] = x2; deg[i]++; } if ( (deg[i] == 1)) {queue.add(i); } }while(!queue.isEmpty()){ int idx = queue.remove(); if ( (deg[idx] != 1)) {continue;} int aa = aneigh[idx];  int bb = bneight[idx]; if ( (aa != -1)) {val[idx] = val[aa] = 0; deg[aa]--; deg[idx]--; aneigh[aa] = -1; aneigh[idx] = -1; if ( (deg[aa] == 1)) { int zz = bneight[aa]; bneight[zz] = -1; deg[zz]--; if ( (deg[zz] == 1)) queue.add(zz); } } else {val[idx] = val[bb] = 1; deg[bb]--; deg[idx]--; bneight[idx] = bneight[bb] = -1; if ( (deg[bb] == 1)) { int zz = aneigh[bb]; aneigh[zz] = -1; deg[zz]--; if ( (deg[zz] == 1)) queue.add(zz); } }}for ( int i = 0;(i < n);i++) {if ( ((val[i] == -1) && cantBePaired(i))) {out.println("NO"); return ;} }for ( int i = 0;(i < n);i++) {if ( (val[i] == -1)) {mycycle = new ArrayDeque<Integer>(); loops = false; cycle(i); if ( (loops || ((mycycle.size() % 2) == 0))) {doEvenCycle(); continue;} out.println("NO"); return ;} }out.println("YES"); for ( int i = 0;(i < n);i++) {out.print((val[i] + " ")); }out.println(); } private boolean cantBePaired( int i){ int aa = aneigh[i];  int bb = bneight[i]; if ( ((aa != -1) && (val[aa] == -1))) {return false;} if ( ((bb != -1) && (val[bb] == -1))) {return false;} return true;} private void doEvenCycle(){ for ( int x :mycycle) {val[x] = 0; }} private void cycle( int i){ boolean aa = false;  int prev = i; mycycle.addLast(i); System.out.println(i); int j = aneigh[i]; while((j != i)){if ( (j == prev)) {loops = true; break;} mycycle.addLast(j); System.out.println(j); prev = j; j = (aa?aneigh[j]:bneight[j]); aa = !aa; }if ( loops) {j = bneight[i]; prev = i; aa = true; while((prev != j)){mycycle.addFirst(j); prev = j; j = (aa?aneigh[j]:bneight[j]); aa = !aa; }} System.out.println("XXX"); } } class FastReader{ public InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public FastReader( InputStream stream){ this.stream = stream; } public FastReader(){ } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int ni(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int[] iArr( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ni(); }return a;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } }
0	public class A{ static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTokenizer(""); static String readString()throws Exception { while(!st.hasMoreTokens())st = new StringTokenizer(stdin.readLine()); return st.nextToken();} static long readLong()throws Exception { return Long.parseLong(readString());} public static void main( String[] args)throws Exception { long a = readLong();  long b = readLong(); System.out.println(rec(a,b)); } private static long rec( long a, long b){ if ( (a == 1)) {return b;} if ( (a >= b)) {return ((a / b) + rec((a % b),b));} return rec(b,a);} }
5	public class Train_A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a = sc.nextInt();  int b = sc.nextInt();  int[] h = new int[n]; for ( int i = 0;(i < n);i++) {h[i] = sc.nextInt(); }Arrays.sort(h); System.out.println((h[(n - a)] - h[(b - 1)])); } }
3	public class codeforces implements Runnable{ static final long mod = ((long)1e9 + 7); static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public String next(){ return readString();} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new codeforces(),"codeforces",(1 << 26)).start(); } }
4	public class uo{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  int testcases = Integer.parseInt(st.nextToken()); for ( int lmn = 0;(lmn < testcases);lmn++) {st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken());  ArrayList<Integer> a = new ArrayList<>(); for ( int lmn1 = 0;(lmn1 < n);lmn1++) {st = new StringTokenizer(br.readLine()); int a1 = Integer.parseInt(st.nextToken()); if ( ((a.size() > 0) && (a1 == 1))) {} else if ( (a.size() > 0)) {if ( (a.size() == 1)) {a.remove(0); } else { int i = (a.size() - 1); while((((a.size() > 0) && (i >= 0)) && ((a.get(i) + 1) != a1))){a.remove(i); i--; }a.remove((a.size() - 1)); }} if ( (a.size() == 0)) {a.add(a1); } else {a.add(a1); }if ( (a.size() == 1)) {System.out.println(a.get(0)); } else {for ( int i = 0;(i < (a.size() - 1));i++) {System.out.print((a.get(i) + ".")); }System.out.println(a.get((a.size() - 1))); }}}} }
3	public class Main{ private static void solve( InputReader in, OutputWriter out){ int n = in.nextInt();  int m = in.nextInt();  String[] sa = new String[n]; for ( int i = 0;(i < n);i++) {sa[i] = in.next(); } Set<Integer> switches = new HashSet<>(); for ( int i = 0;(i < m);i++) { int cnt = 0,swtch = -1; for ( int j = 0;(j < n);j++) {if ( (sa[j].charAt(i) == '1')) {cnt++; swtch = j; if ( (cnt > 1)) break; } }if ( (cnt == 1)) {switches.add(swtch); } }out.print(((switches.size() == n)?"NO":"YES")); } public static void main( String[] args){ InputReader in = new InputReader(System.in);  OutputWriter out = new OutputWriter(System.out); solve(in,out); in.close(); out.close(); } private static class InputReader{ private BufferedReader br ; private StringTokenizer st ; InputReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); st = null; } String nextLine(){ String line = null; try{line = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return line;} String next(){ while(((st == null) || !st.hasMoreTokens())){ String line = nextLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} void close(){ try{br.close(); }catch (IOException e){ e.printStackTrace(); } } } private static class OutputWriter{ BufferedWriter bw ; OutputWriter( OutputStream os){ bw = new BufferedWriter(new OutputStreamWriter(os)); } void print( int i){ print(Integer.toString(i)); } void println( int i){ println(Integer.toString(i)); } void print( long l){ print(Long.toString(l)); } void println( long l){ println(Long.toString(l)); } void print( double d){ print(Double.toString(d)); } void println( double d){ println(Double.toString(d)); } void print( boolean b){ print(Boolean.toString(b)); } void println( boolean b){ println(Boolean.toString(b)); } void print( char c){ try{bw.write(c); }catch (IOException e){ e.printStackTrace(); } } void println( char c){ println(Character.toString(c)); } void print( String s){ try{bw.write(s); }catch (IOException e){ e.printStackTrace(); } } void println( String s){ print(s); print('\n'); } void close(){ try{bw.close(); }catch (IOException e){ e.printStackTrace(); } } } }
3	public class A{ public static void main( String[] args){ FastReader scan = new FastReader();  PrintWriter out = new PrintWriter(System.out);  Task solver = new Task();  int t = 1; while((t-- > 0))solver.solve(1,scan,out); out.close(); } static class Task{ public void solve( int testNumber, FastReader scan, PrintWriter out){ int n = scan.nextInt();  int[] a = new int[n];  boolean[] b = new boolean[n];  int count = 0; for ( int i = 0;(i < n);i++) a[i] = scan.nextInt(); Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( b[i]) continue; count++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) b[j] = true; }}out.println(count); } } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader( String s)throws FileNotFoundException{ br = new BufferedReader(new FileReader(new File(s))); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, Scanner in, PrintWriter out){ String n = in.nextLine();  int a = Integer.parseInt(n);  int b = Integer.parseInt(n.substring(0,(n.length() - 1)));  int c = Integer.parseInt((n.substring(0,(n.length() - 2)) + n.charAt((n.length() - 1)))); out.println(Math.max(a,Math.max(b,c))); } }
5	public class A implements Runnable{ static BufferedReader in ; static PrintWriter out ; static StringTokenizer st ; static Random rnd ; void solve()throws IOException { int n = nextInt();  long k = nextLong(); if ( (k == 1)) {out.println(n); } else { TreeMap<Long,ArrayList<Integer>> numbers = new TreeMap<Long,ArrayList<Integer>>(); for ( int i = 0;(i < n);i++) { long m = nextLong();  int howMuch = 0; while(((m % k) == 0)){m /= k; ++howMuch; }if ( !numbers.containsKey(m)) {numbers.put(m,new ArrayList<Integer>()); } numbers.get(m).add(howMuch); } int res = 0; for ( ArrayList<Integer> oneGroup :numbers.values()) {res += parseOneGroup(oneGroup); }out.println(res); }} private int parseOneGroup( ArrayList<Integer> oneGroup){ Collections.sort(oneGroup); int res = 0,prevValue = Integer.MIN_VALUE; for ( int i = 0;(i < oneGroup.size());i++) { int curValue = oneGroup.get(i); if ( ((prevValue + 1) != curValue)) {++res; prevValue = curValue; } }return res;} public static void main( String[] args){ new A().run(); } public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); rnd = new Random(); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); System.exit(42); } } String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = in.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} }
2	public class CodeforcesC{ public static void main( String[] args){ Scanner ob = new Scanner(System.in);  long n = ob.nextLong();  long s = ob.nextLong();  long l = 1;  long r = n; while((l <= r)){ long mid = ((l + r) / 2); if ( reallybignumber(mid,s)) {r = (mid - 1); } else {l = (mid + 1); }}System.out.println(((n - l) + 1)); } private static boolean reallybignumber( long n, long s){ long m = n;  long sum = 0;  int d = 1; while((m > 0)){ long rem = (m % 10); sum = ((rem * d) + sum); m = (m / 10); }if ( ((n - sum) >= s)) return true; else return false;} }
4	public class Main{ static BufferedReader reader ; static StringTokenizer st ; private static void setReader(){ reader = new BufferedReader(new InputStreamReader(System.in)); } private static void updateST()throws IOException { if ( ((st == null) || !st.hasMoreElements())) st = new StringTokenizer(reader.readLine()); } private static int nextInt()throws IOException { updateST(); return Integer.parseInt(st.nextToken());} public static void main( String[] args)throws IOException { setReader(); int n = nextInt(),MOD = nextInt();  long[] pow = new long[(n + 2)]; pow[0] = 1; for ( int i = 1;(i <= (n + 1));i++) pow[i] = ((pow[(i - 1)] * 2) % MOD); long[][] C = new long[(n + 2)][(n + 2)]; for ( int i = 0;(i <= (n + 1));i++) {C[i][0] = 1; for ( int j = 1;(j <= i);j++) {C[i][j] = ((C[(i - 1)][(j - 1)] + C[(i - 1)][j]) % MOD); }} long[][] dp = new long[(n + 2)][(n + 1)]; dp[0][0] = 1; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= i);j++) {for ( int k = 1;(((i + k) + 1) <= (n + 1));k++) {dp[((i + k) + 1)][(j + k)] += ((((dp[i][j] * C[(j + k)][k]) % MOD) * pow[(k - 1)]) % MOD); dp[((i + k) + 1)][(j + k)] %= MOD; }}} long res = 0; for ( int i = 0;(i <= n);i++) res = ((res + dp[(n + 1)][i]) % MOD); System.out.println(res); } }
3	public class lets_do{ FastReader in ; PrintWriter out ; Helper_class h ; final long mod = 1000000009; final int MAXN = 1000005; final int lgN = 20; final long INF = (long)1e18; final long MAX_Ai = (long)1e12; public static void main( String[] args)throws java.lang.Exception { new lets_do().run(); } void run()throws Exception { in = new FastReader(System.in); out = new PrintWriter(System.out); h = new Helper_class(); int t = 1; while((t-- > 0))solve(); out.flush(); out.close(); } void solve(){ int n = h.ni();  long[] arr = new long[n];  int i = 0,j = 0; for ( i = 0;(i < n);i++) arr[i] = h.nl(); HashMap<Long,Integer> hmap = new HashMap<Long,Integer>();  int cnt = 0; for ( i = 0;(i < n);i++) { long sum = 0; for ( j = i;(j < n);j++) {sum += arr[j]; Integer x = hmap.get(sum); if ( (x == null)) hmap.put(sum,cnt++); }} TreeSet<Pair>[] tset = new TreeSet[cnt]; for ( i = 0;(i < cnt);i++) tset[i] = new TreeSet<Pair>(com); for ( i = 0;(i < n);i++) { long sum = 0; for ( j = i;(j < n);j++) {sum += arr[j]; tset[hmap.get(sum)].add(new Pair(i,j)); }} int max = 0;  int ind = -1;  int max_x = 0,max_y = 0; for ( i = 0;(i < cnt);i++) { int curr_y = tset[i].first().y;  int cnt1 = 1; for ( Pair yo :tset[i]) {if ( (yo.x > curr_y)) {cnt1++; curr_y = yo.y; } }if ( (max < cnt1)) {max = cnt1; ind = i; } }h.pn(max); Pair hola_yee = new Pair(tset[ind].first().x,tset[ind].first().y); h.pn((((tset[ind].first().x + 1) + " ") + (tset[ind].first().y + 1))); int curr_y = tset[ind].first().y; for ( Pair yo :tset[ind]) {if ( (yo.x > curr_y)) {curr_y = yo.y; h.pn((((yo.x + 1) + " ") + (yo.y + 1))); } }} static final Comparator<Pair> com = new Comparator<Pair>(){public int compare( Pair a, Pair b){ if ( (Integer.compare(a.y,b.y) != 0)) return Integer.compare(a.y,b.y); else return Integer.compare(a.x,b.x);} }; class Pair{ int x ; int y ; Pair( int p, int q){ x = p; y = q; } } class Helper_class{ long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} int bitcount( long n){ return ((n == 0)?0:(1 + bitcount((n & (n - 1)))));} void pn( Object o){ out.println(o); } int ni(){ return Integer.parseInt(in.next());} long nl(){ return Long.parseLong(in.next());} long mul( long a, long b){ if ( (a >= mod)) a %= mod; if ( (b >= mod)) b %= mod; a *= b; if ( (a >= mod)) a %= mod; return a;} long add( long a, long b){ if ( (a >= mod)) a %= mod; if ( (b >= mod)) b %= mod; if ( (b < 0)) b += mod; a += b; if ( (a >= mod)) a -= mod; return a;} } class FastReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public FastReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new UnknownError()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new UnknownError());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int peek(){ if ( (numChars == -1)) return -1; if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ return -1;} if ( (numChars <= 0)) return -1; } return buf[curChar];} public int nextInt(){ return Integer.parseInt(next());} public String next(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuffer res = new StringBuffer(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public String nextLine(){ StringBuffer buf = new StringBuffer();  int c = read(); while(((c != '\n') && (c != -1))){if ( (c != '\r')) buf.appendCodePoint(c); c = read(); }return buf.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
3	public class _908C{ public void solve()throws FileNotFoundException { InputStream inputStream = System.in;  InputHelper in = new InputHelper(inputStream);  int n = in.readInteger();  double r = in.readInteger();  double[] x = new double[n]; for ( int i = 0;(i < n);i++) {x[i] = in.readInteger(); } double[] ans = new double[n]; ans[0] = r; for ( int i = 1;(i < n);i++) { double cans = r; for ( int j = 0;(j < i);j++) { double dis = Math.abs((x[j] - x[i])); if ( (dis <= (2 * r))) {if ( (dis == (2 * r))) {cans = Math.max(cans,ans[j]); continue;} else if ( (x[i] == x[j])) {cans = Math.max(cans,(ans[j] + (2 * r))); continue;} cans = Math.max(cans,(ans[j] + Math.sqrt(((4 * (r * r)) - (dis * dis))))); } }ans[i] = cans; }for ( int i = 0;(i < n);i++) {System.out.print((ans[i] + " ")); }} public static void main( String[] args)throws FileNotFoundException { new _908C().solve(); } class InputHelper{ StringTokenizer tokenizer = null; private BufferedReader bufferedReader ; public InputHelper( InputStream inputStream){ InputStreamReader inputStreamReader = new InputStreamReader(inputStream); bufferedReader = new BufferedReader(inputStreamReader,16384); } public String read(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{ String line = bufferedReader.readLine(); if ( (line == null)) {return null;} tokenizer = new StringTokenizer(line); }catch (IOException e){ e.printStackTrace(); } }return tokenizer.nextToken();} public Integer readInteger(){ return Integer.parseInt(read());} } }
5	public class Testt{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws FileNotFoundException { if ( ONLINE_JUDGE) {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); }} String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} public static void main( String[] args){ new Testt().run(); } public static void mergeSort( int[] a){ mergeSort(a,0,(a.length - 1)); } private static void mergeSort( int[] a, int leftIndex, int rightIndex){ final int MAGIC_VALUE = 50; if ( (leftIndex < rightIndex)) {if ( ((rightIndex - leftIndex) <= MAGIC_VALUE)) {insertionSort(a,leftIndex,rightIndex); } else { int middleIndex = ((leftIndex + rightIndex) / 2); mergeSort(a,leftIndex,middleIndex); mergeSort(a,(middleIndex + 1),rightIndex); merge(a,leftIndex,middleIndex,rightIndex); }} } private static void merge( int[] a, int leftIndex, int middleIndex, int rightIndex){ int length1 = ((middleIndex - leftIndex) + 1);  int length2 = (rightIndex - middleIndex);  int[] leftArray = new int[length1];  int[] rightArray = new int[length2]; System.arraycopy(a,leftIndex,leftArray,0,length1); System.arraycopy(a,(middleIndex + 1),rightArray,0,length2); for ( int k = leftIndex,i = 0,j = 0;(k <= rightIndex);k++) {if ( (i == length1)) {a[k] = rightArray[j++]; } else if ( (j == length2)) {a[k] = leftArray[i++]; } else {a[k] = ((leftArray[i] <= rightArray[j])?leftArray[i++]:rightArray[j++]); }}} private static void insertionSort( int[] a, int leftIndex, int rightIndex){ for ( int i = (leftIndex + 1);(i <= rightIndex);i++) { int current = a[i];  int j = (i - 1); while(((j >= leftIndex) && (a[j] > current))){a[(j + 1)] = a[j]; j--; }a[(j + 1)] = current; }} public void run(){ try{ long t1 = System.currentTimeMillis(); init(); solve(); out.close(); long t2 = System.currentTimeMillis(); System.err.println(("Time = " + (t2 - t1))); }catch (Exception e){ e.printStackTrace(System.err); System.exit(-1); } } public void solve()throws IOException { int n = readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = readInt(); }mergeSort(a); int sum = 0; for ( int i = 0;(i < n);i++) {sum += a[i]; } int sum2 = 0;  int ans = 0; for ( int i = (n - 1);(i >= 0);i--) {sum2 += a[i]; sum -= a[i]; ans++; if ( (sum2 > sum)) {break;} }out.print(ans); } }
3	public class Solution{ public static void main( String[] args){ FastReader in = new FastReader();  int n = in.nextInt();  int[] a = new int[101]; for ( int i = 0;(i < n);i++) {a[in.nextInt()]++; } int count = 0; for ( int i = 1;(i < 101);i++) {if ( (a[i] > 0)) {count++; for ( int j = i;(j < 101);j += i) {a[j] = 0; }} }System.out.println(count); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public int[] nextIntArray( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);++i) array[i] = nextInt(); return array;} public long[] nextLongArray( int n){ long[] array = new long[n]; for ( int i = 0;(i < n);++i) array[i] = nextLong(); return array;} String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} } }
6	public class E4{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ for ( int T = ni();(T > 0);T--) { int n = ni(),m = ni();  int[][] a = new int[n][]; for ( int i = 0;(i < n);i++) a[i] = na(m); int[][] mx = new int[m][]; for ( int i = 0;(i < m);i++) { int u = 0; for ( int j = 0;(j < n);j++) {u = Math.max(u,a[j][i]); }mx[i] = new int[]{u,i}; }Arrays.sort(mx,new Comparator<int[]>(){}); int[] dp = new int[(1 << n)]; for ( int i = 0;((i < n) && (i < m));i++) { int c = mx[i][1];  int[] ls = new int[(1 << n)]; for ( int j = 1;(j < (1 << n));j++) {ls[j] = (ls[(j & (j - 1))] + a[Integer.numberOfTrailingZeros(j)][c]); }for ( int j = 1;(j < (1 << n));j++) { int r = rot(j,n); ls[r] = Math.max(ls[r],ls[j]); } int[] ndp = new int[(1 << n)]; for ( int j = 0;(j < (1 << n));j++) {if ( (rot(j,n) == j)) { int cur = j; for ( int sh = 0;(sh < n);sh++) {cur = ((cur >> 1) | ((cur & 1) << (n - 1))); int mask = (((1 << n) - 1) ^ cur); for ( int k = mask;(k >= 0);k--) {k &= mask; ndp[(k | cur)] = Math.max(ndp[(k | cur)],(dp[k] + ls[j])); }}} }dp = ndp; }out.println(dp[((1 << n) - 1)]); }} int rot( int x, int n){ int ret = x; for ( int i = 0;(i < n);i++) {x = ((x >>> 1) | ((x & 1) << (n - 1))); ret = Math.min(ret,x); }return ret;} void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new E4().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] ar = new int[n]; for ( int i = 0;(i < n);i++) ar[i] = in.nextInt(); Arrays.sort(ar); boolean[] u = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( !u[i]) {u[i] = true; ans++; for ( int j = 0;(j < n);j++) {if ( (!u[j] && ((ar[j] % ar[i]) == 0))) {u[j] = true; } }} }out.println(ans); } } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
6	public class CF1185G2{ static final int MD = 1000000007; static int[][] solve1( int[] aa, int t, int n){ int[][] da = new int[(t + 1)][(n + 1)]; da[0][0] = 1; for ( int i = 0;(i < n);i++) { int a = aa[i]; for ( int s = (t - 1);(s >= 0);s--) for ( int m = 0;(m < n);m++) { int x = da[s][m]; if ( (x != 0)) { int s_ = (s + a); if ( (s_ <= t)) da[s_][(m + 1)] = ((da[s_][(m + 1)] + x) % MD); } }}return da;} static int[][][] solve2( int[] aa, int[] bb, int t, int na, int nb){ int[][] da = solve1(aa,t,na);  int[][][] dab = new int[(t + 1)][(na + 1)][(nb + 1)]; for ( int s = 0;(s <= t);s++) for ( int ma = 0;(ma <= na);ma++) dab[s][ma][0] = da[s][ma]; for ( int i = 0;(i < nb);i++) { int b = bb[i]; for ( int s = (t - 1);(s >= 0);s--) for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb < nb);mb++) { int x = dab[s][ma][mb]; if ( (x != 0)) { int s_ = (s + b); if ( (s_ <= t)) dab[s_][ma][(mb + 1)] = ((dab[s_][ma][(mb + 1)] + x) % MD); } }}return dab;} static int[][][] init( int n, int na, int nb, int nc){ int[][][] dp = new int[(na + 1)][(nb + 1)][(nc + 1)];  int[][][][] dq = new int[(na + 1)][(nb + 1)][(nc + 1)][3]; for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) for ( int mc = 0;(mc <= nc);mc++) if ( (((ma == 0) && (mb == 0)) && (mc == 0))) {dp[ma][mb][mc] = 1; dq[ma][mb][mc][0] = dq[ma][mb][mc][1] = dq[ma][mb][mc][2] = 1; } else { int x0 = ((ma > 0)?(int)(((long)dq[(ma - 1)][mb][mc][0] * ma) % MD):0);  int x1 = ((mb > 0)?(int)(((long)dq[ma][(mb - 1)][mc][1] * mb) % MD):0);  int x2 = ((mc > 0)?(int)(((long)dq[ma][mb][(mc - 1)][2] * mc) % MD):0); dp[ma][mb][mc] = (int)((((long)x0 + x1) + x2) % MD); dq[ma][mb][mc][0] = ((x1 + x2) % MD); dq[ma][mb][mc][1] = ((x2 + x0) % MD); dq[ma][mb][mc][2] = ((x0 + x1) % MD); }return dp;} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int t = Integer.parseInt(st.nextToken());  int[] aa = new int[n];  int[] bb = new int[n];  int[] cc = new int[n];  int na = 0,nb = 0,nc = 0; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken());  int g = Integer.parseInt(st.nextToken()); if ( (g == 1)) aa[na++] = a; else if ( (g == 2)) bb[nb++] = a; else cc[nc++] = a; } int[][][] dp = init(n,na,nb,nc);  int[][][] dab = solve2(aa,bb,t,na,nb);  int[][] dc = solve1(cc,t,nc);  int ans = 0; for ( int tab = 0;(tab <= t);tab++) { int tc = (t - tab); for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) { int xab = dab[tab][ma][mb]; if ( (xab == 0)) continue; for ( int mc = 0;(mc <= nc);mc++) { int xc = dc[tc][mc]; if ( (xc == 0)) continue; ans = (int)((ans + ((((long)xab * xc) % MD) * dp[ma][mb][mc])) % MD); }}}System.out.println(ans); } }
2	public class Main{ public static void main( String[] args){ FastScanner in = new FastScanner();  long[] a = new long[16]; a[0] = 0; for ( int i = 1;(i < 16);++i) a[i] = (a[(i - 1)] + ((9 * (long)Math.pow(10,(i - 1))) * i)); long N = in.nextLong();  int pos = 0; for ( int i = 0;(i < 16);++i) {if ( (N <= a[i])) {pos = i; break;} }if ( (pos == 1)) {System.out.println(N); System.exit(0); } long prev = a[(pos - 1)];  long curr = N;  long rem = (curr - prev);  long ans = 0; for ( int i = 1;(i < pos);++i) {ans = ((ans * 10) + 9); } long g = ((rem + (pos - 1)) / pos);  long take = ((rem + (pos - 1)) % pos);  long number = (ans + g);  String str = Long.toString(number); System.out.println(str.charAt((int)take)); } static void sort( int[] a){ ArrayList<Integer> l = new ArrayList<>(); for ( int i :a) l.add(i); Collections.sort(l); for ( int i = 0;(i < a.length);i++) a[i] = l.get(i); } static class FastScanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next(){ while(!st.hasMoreTokens())try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} } }
6	public class Main{ private static int[] x = new int[26],y = new int[26],dp = new int[(1 << 24)],pre = new int[(1 << 24)]; private static int dis( int i, int j){ return (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j])));} public static void main( String[] args){ Scanner in = new Scanner(System.in);  int x0 = in.nextInt(),y0 = in.nextInt(),n = in.nextInt(); for ( int i = 0;(i < n);i++) {x[i] = in.nextInt(); y[i] = in.nextInt(); }x[n] = x0; y[n] = y0; int[][] gra = new int[26][26]; for ( int i = 0;(i < (n + 1));i++) {for ( int j = (i + 1);(j < (n + 1));j++) {gra[i][j] = gra[j][i] = dis(i,j); }}Arrays.fill(dp,-1); dp[0] = 0; for ( int i = 0;(i < (1 << n));i++) {if ( (dp[i] != -1)) {for ( int j = 0;(j < n);j++) {if ( (((1 << j) & i) == 0)) { int t = (i | (1 << j)),tmp = (dp[i] + (2 * gra[j][n])); if ( ((dp[t] == -1) || (dp[t] > tmp))) {dp[t] = tmp; pre[t] = i; } for ( int k = 0;(k < n);k++) {if ( ((t & (1 << k)) == 0)) { int t2 = (t | (1 << k)),tmp2 = (((dp[i] + gra[n][j]) + gra[j][k]) + gra[k][n]); if ( ((dp[t2] == -1) || (dp[t2] > tmp2))) {dp[t2] = tmp2; pre[t2] = i; } } }break;} }} } int end = ((1 << n) - 1),cnt = 0;  int[] ans = new int[60]; System.out.println(dp[end]); while((end != 0)){ int pr = pre[end];  int tem = (pr ^ end);  int a = 0,b = 0; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & tem) != 0)) {b = a; a = (i + 1); } }ans[cnt++] = 0; ans[cnt++] = a; if ( (b > 0)) {ans[cnt++] = b; } end = pr; }ans[cnt++] = 0; for ( int i = (cnt - 1);(i >= 0);i--) {System.out.print((ans[i] + " ")); }System.out.print("\n"); } }
6	public class P11D{ static long mod = 1000000007; public static void main( String[] args)throws Exception { InputReader in = new InputReader(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = in.readInt();  int m = in.readInt();  boolean v[][] = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int x = (in.readInt() - 1);  int y = (in.readInt() - 1); v[x][y] = true; v[y][x] = true; } long dp[][] = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {dp[(1 << i)][i] = 1; } long ans = 0; for ( int mask = 1;(mask < (1 << n));mask++) { int s = -1; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {s = i; break;} }for ( int i = 0;(i < n);i++) {if ( ((i != s) && (((1 << i) & mask) != 0))) {for ( int j = 0;(j < n);j++) {if ( ((((1 << j) != 0) && (i != j)) && v[i][j])) { int rem = ((1 << i) ^ mask); dp[mask][i] += dp[rem][j]; } } int c = Integer.bitCount(mask); if ( ((c >= 3) && v[i][s])) {ans += dp[mask][i]; } } }}ans /= 2; pw.println(ans); pw.close(); } public static long gcd( long x, long y){ if ( ((x % y) == 0)) return y; else return gcd(y,(x % y));} public static int gcd( int x, int y){ if ( ((x % y) == 0)) return y; else return gcd(y,(x % y));} public static int abs( int a, int b){ return (int)Math.abs((a - b));} public static long abs( long a, long b){ return (long)Math.abs((a - b));} public static long pow( long n, long p, long m){ long result = 1; if ( (p == 0)) return 1; if ( (p == 1)) return n; while((p != 0)){if ( ((p % 2) == 1)) result *= n; if ( (result >= m)) result %= m; p >>= 1; n *= n; if ( (n >= m)) n %= m; }return result;} public static long pow( long n, long p){ long result = 1; if ( (p == 0)) return 1; if ( (p == 1)) return n; while((p != 0)){if ( ((p % 2) == 1)) result *= n; p >>= 1; n *= n; }return result;} static long mergeSort( int[] a, int[] b, long left, long right){ long c = 0; if ( (left < right)) { long mid = (left + ((right - left) / 2)); c = mergeSort(a,b,left,mid); c += mergeSort(a,b,(mid + 1),right); c += merge(a,b,left,(mid + 1),right); } return c;} static long merge( int[] a, int[] b, long left, long mid, long right){ long c = 0;  int i = (int)left;  int j = (int)mid;  int k = (int)left; while(((i <= ((int)mid - 1)) && (j <= (int)right))){if ( (a[i] <= a[j])) {b[k++] = a[i++]; } else {b[k++] = a[j++]; c += (mid - i); }}while((i <= ((int)mid - 1)))b[k++] = a[i++]; while((j <= (int)right))b[k++] = a[j++]; for ( i = (int)left;(i <= (int)right);i++) a[i] = b[i]; return c;} static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } public boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} } }
6	public class Main{ public static class Pair implements Comparable<Pair>{ int k ,x ; public Pair( int k){ this.k = k; } public void update( int x){ this.x = Math.max(this.x,x); } } public static int sum( int[] arr){ int sum = 0; for ( int x :arr) {sum += x; }return sum;} public static int[] join( int[] a, int[] b){ int n = a.length;  int[] best = new int[n];  int sum = 0; for ( int shift = 0;(shift < n);shift++) { int[] curr = new int[n]; for ( int i = 0;(i < n);i++) {curr[i] = Math.max(a[i],b[((i + shift) % n)]); } int now = sum(curr); if ( (now > sum)) {sum = now; best = curr; } }return best;} public static int n ; public static int[] pow ; public static int[][] dp ,real ; public static void calc( int mask){ int[] best = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & pow[i]) != 0)) { int to = (mask ^ pow[i]);  int[] init = new int[n]; for ( int j = 0;(j < n);j++) {init[j] = real[j][i]; } int[] curr = join(dp[to],init);  int s = sum(curr); if ( (s > sum)) {sum = s; best = curr; } } }dp[mask] = best; } public static void main( String[] args){ pow = new int[15]; pow[0] = 1; for ( int i = 1;(i < pow.length);i++) {pow[i] = (pow[(i - 1)] * 2); } Scanner in = new Scanner(System.in);  int t = in.nextInt(); for ( int i = 0;(i < t);i++) {n = in.nextInt(); int m = in.nextInt();  int[][] arr = new int[n][m]; for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < m);k++) {arr[j][k] = in.nextInt(); }} Pair[] best = new Pair[m]; for ( int j = 0;(j < m);j++) {best[j] = new Pair(j); for ( int k = 0;(k < n);k++) {best[j].update(arr[k][j]); }}Arrays.sort(best); real = new int[n][n]; for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < Math.min(n,m));k++) {real[j][k] = arr[j][best[k].k]; }}dp = new int[(1 << n)][]; Stack<Integer>[] min = new Stack[(n + 1)]; for ( int j = 0;(j <= n);j++) {min[j] = new Stack<>(); }for ( int j = 0;(j < dp.length);j++) { int cnt = 0; for ( int k = 0;(k < n);k++) {if ( ((j & pow[k]) != 0)) {cnt++; } }min[cnt].add(j); }for ( int j = 0;(j < min.length);j++) {for ( int x :min[j]) {if ( (j == 0)) {dp[x] = new int[n]; } else {calc(x); }}}System.out.println(sum(dp[(dp.length - 1)])); }} }
4	public class Deltix{ static PrintWriter out ; public static void main( String[] args){ MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  Stack<Integer> s = new Stack<>();  int[] a = new int[n]; for ( int i = 0;(i < n);++i) a[i] = sc.nextInt(); for ( int i = 0;(i < n);i++) {if ( (a[i] == 1)) {s.push(1); } else {while((s.peek() != (a[i] - 1))){s.pop(); }s.pop(); s.push(a[i]); }print(s); }}out.close(); } static void print( Stack<Integer> s){ ArrayDeque<Integer> a = new ArrayDeque<>(); while(!s.isEmpty()){a.addFirst(s.pop()); }while(!a.isEmpty()){ int x = a.pollFirst(); out.print(x); s.push(x); if ( (a.size() != 0)) out.print("."); }out.println(); } static void sort( int[] a){ ArrayList<Integer> q = new ArrayList<>(); for ( int i :a) q.add(i); Collections.sort(q); for ( int i = 0;(i < a.length);i++) a[i] = q.get(i); } static void sort( long[] a){ ArrayList<Long> q = new ArrayList<>(); for ( long i :a) q.add(i); Collections.sort(q); for ( int i = 0;(i < a.length);i++) a[i] = q.get(i); } public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputStreamReader in = new InputStreamReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, InputStreamReader inSt, PrintWriter out){ InputReader in = new InputReader(inSt);  long a = in.nextLong();  long b = in.nextLong();  long result = 0; while((b != 1)){result += (a / b); long r = (a % b);  long q = b;  long top = (q % r);  long bottom = r; result += (q / r); a = top; b = bottom; }result += a; out.println(result); } class InputReader{ public BufferedReader reader ; private String[] currentArray ; int curPointer ; public InputReader( InputStreamReader inputStreamReader){ reader = new BufferedReader(inputStreamReader); } public long nextLong(){ if ( ((currentArray == null) || (curPointer >= currentArray.length))) {try{currentArray = reader.readLine().split(" "); }catch (IOException e){ throw (new RuntimeException(e));} curPointer = 0; } return Long.parseLong(currentArray[curPointer++]);} } }
6	public class Template implements Runnable{ private void solve()throws IOException { int n = nextInt();  int m = nextInt();  boolean[][] g = new boolean[n][n]; for ( int i = 0;(i < m);++i) { int a = (nextInt() - 1);  int b = (nextInt() - 1); g[a][b] = true; g[b][a] = true; } long[] am = new long[(n + 1)];  long[][] ways = new long[(1 << (n - 1))][n]; for ( int start = 0;(start < n);++start) {for ( int mask = 0;(mask < (1 << ((n - start) - 1)));++mask) for ( int last = start;(last < n);++last) {ways[mask][(last - start)] = 0; }ways[(1 >> 1)][0] = 1; for ( int mask = 1;(mask < (1 << (n - start)));mask += 2) { int cnt = 0;  int tmp = mask; while((tmp > 0)){++cnt; tmp = (tmp & (tmp - 1)); }for ( int last = start;(last < n);++last) if ( (ways[(mask >> 1)][(last - start)] > 0)) { long amm = ways[(mask >> 1)][(last - start)]; for ( int i = start;(i < n);++i) if ( (((mask & (1 << (i - start))) == 0) && g[last][i])) {ways[((mask | (1 << (i - start))) >> 1)][(i - start)] += amm; } if ( g[last][start]) am[cnt] += ways[(mask >> 1)][(last - start)]; } }} long res = 0; for ( int cnt = 3;(cnt <= n);++cnt) {if ( ((am[cnt] % 2) != 0)) throw (new RuntimeException()); res += (am[cnt] / 2); }writer.println(res); } public static void main( String[] args){ new Template().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
3	public class PTM{ public static void main( String[] args)throws Exception { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));  PrintWriter printWriter = new PrintWriter(System.out);  int N = Integer.parseInt(bufferedReader.readLine());  String[] strings = bufferedReader.readLine().split(" ");  int[] arr = new int[strings.length];  HashSet<Integer> set = new HashSet<>(); for ( int i = 0;(i < N);i++) {arr[i] = Integer.parseInt(strings[i]); set.add(arr[i]); }Arrays.sort(arr); int c = 0; for ( int i = 0;(i < N);i++) { int value = arr[i]; if ( !set.contains(value)) {continue;} for ( int j = 1;(j <= 100);j++) {if ( set.contains((value * j))) {set.remove((value * j)); } }c++; }printWriter.println(c); printWriter.flush(); } }
4	public class E2{ static ArrayList<Integer> primes ; static int[] mind ; static final int MAXA = (int)1e7; public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(f.readLine());  int t = Integer.parseInt(st.nextToken()); primes = new ArrayList<>(); mind = new int[(MAXA + 1)]; for ( int i = 2;(i <= MAXA);i++) {if ( (mind[i] == 0)) {primes.add(i); mind[i] = i; } for ( int x :primes) {if ( ((x > mind[i]) || ((x * i) > MAXA))) break; mind[(x * i)] = x; }} int[] count = new int[(MAXA + 1)]; for ( int on8y = 0;(on8y < t);on8y++) {st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken());  int k = Integer.parseInt(st.nextToken());  int[] a = new int[n]; Arrays.fill(a,1); st = new StringTokenizer(f.readLine()); for ( int i = 0;(i < n);i++) { int x = Integer.parseInt(st.nextToken());  int cnt = 0;  int last = 0; while((x > 1)){ int p = mind[x]; if ( (last == p)) cnt++; else {if ( ((cnt % 2) == 1)) a[i] *= last; last = p; cnt = 1; }x /= p; }if ( ((cnt % 2) == 1)) a[i] *= last; } int[][] mnleft = new int[n][(k + 1)]; for ( int j = 0;(j < (k + 1));j++) { int l = n;  int now = 0; for ( int i = (n - 1);(i >= 0);i--) {while((((l - 1) >= 0) && ((now + ((count[a[(l - 1)]] > 0)?1:0)) <= j))){l--; now += ((count[a[l]] > 0)?1:0); count[a[l]]++; }mnleft[i][j] = l; if ( (count[a[i]] > 1)) now--; count[a[i]]--; }} int[][] dp = new int[(n + 1)][(k + 1)]; for ( int i = 0;(i < (n + 1));i++) {Arrays.fill(dp[i],((int)1e9 + 1)); }for ( int i = 0;(i < (k + 1));i++) dp[0][i] = 0; for ( int i = 1;(i <= n);i++) {for ( int j = 0;(j <= k);j++) {if ( (j > 0)) dp[i][j] = dp[i][(j - 1)]; for ( int lst = 0;(lst <= j);lst++) {dp[i][j] = Math.min(dp[i][j],(dp[mnleft[(i - 1)][lst]][(j - lst)] + 1)); }}} int ans = ((int)1e9 + 1); for ( int c :dp[n]) ans = Math.min(ans,c); System.out.println(ans); }} }
6	public class Fish extends Thread{ public Fish(){ this.input = new BufferedReader(new InputStreamReader(System.in)); this.output = new PrintWriter(System.out); this.setPriority(Thread.MAX_PRIORITY); } static int getOnes( int mask){ int result = 0; while((mask != 0)){mask &= (mask - 1); ++result; }return result;} private void solve()throws Throwable { int n = nextInt();  double[][] a = new double[n][n];  double[] dp = new double[(1 << n)]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {a[i][j] = nextDouble(); }} int limit = ((1 << n) - 1); dp[limit] = 1.0; for ( int mask = limit;(mask > 0);--mask) { int cardinality = getOnes(mask); if ( (cardinality < 2)) {continue;} int probability = ((cardinality * (cardinality - 1)) / 2); for ( int first = 0;(first < n);++first) {if ( ((mask & powers[first]) != 0)) {for ( int second = (first + 1);(second < n);++second) {if ( ((mask & powers[second]) != 0)) {dp[(mask - powers[first])] += ((dp[mask] * a[second][first]) / probability); dp[(mask - powers[second])] += ((dp[mask] * a[first][second]) / probability); } }} }}for ( int i = 0;(i < n);++i) {output.printf("%.10f ",dp[powers[i]]); }} public static void main( String[] args){ new Fish().start(); } private String nextToken()throws IOException { while(((tokens == null) || !tokens.hasMoreTokens())){tokens = new StringTokenizer(input.readLine()); }return tokens.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(nextToken());} private double nextDouble()throws IOException { return Double.parseDouble(nextToken());} static final int powers[] = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144}; private BufferedReader input ; private PrintWriter output ; private StringTokenizer tokens = null; }
4	public class R035CRetry{ public static final int INF = 987654321; public static final long LINF = 987654321987654321L; public static final double EPS = 1e-9; Scanner scanner ; PrintWriter out ; boolean[][] bss ; public R035CRetry(){ try{this.scanner = new Scanner(new File("input.txt")); this.out = new PrintWriter("output.txt"); }catch (FileNotFoundException ex){ ex.printStackTrace(); } } class Point implements Comparable<Point>{ int x ,y ,count ; Point( int x, int y){ this.x = x; this.y = y; } } int[] dx = new int[]{0,0,-1,1}; int[] dy = new int[]{-1,1,0,0}; int n ,m ; Queue<Point> q ; Point bfs(){ int max = -INF;  Point p = null; while(!q.isEmpty()){ Point cur = q.remove(); if ( (max < cur.count)) {max = cur.count; p = cur; } for ( int i = 0;(i < dx.length);i++) { int nx = (cur.x + dx[i]);  int ny = (cur.y + dy[i]); if ( ((nx < 0) || (nx >= n))) {continue;} if ( ((ny < 0) || (ny >= m))) {continue;} Point np = new Point(nx,ny); if ( bss[nx][ny]) {continue;} np.count = (cur.count + 1); bss[nx][ny] = true; q.add(np); }}return p;} private void solve(){ this.n = scanner.nextInt(); this.m = scanner.nextInt(); this.bss = new boolean[n][m]; int k = scanner.nextInt(); q = new LinkedList<Point>(); for ( int i = 0;(i < k);i++) { int x = (scanner.nextInt() - 1);  int y = (scanner.nextInt() - 1);  Point init = new Point(x,y); init.count = 1; q.add(init); bss[x][y] = true; } Point p = bfs(); out.println((((p.x + 1) + " ") + (p.y + 1))); } private void finish(){ this.out.close(); } public static void main( String[] args){ R035CRetry obj = new R035CRetry(); obj.solve(); obj.finish(); } }
2	public class Main{ static BigInteger n ,x ,y ,c ; static BigInteger mk[] = new BigInteger[8]; public static BigInteger f( BigInteger t){ return t.multiply(t);} public static BigInteger g( BigInteger t){ return t.multiply(t.add(BigInteger.ONE)).shiftRight(1);} public static int solve( BigInteger z){ BigInteger ret = z.multiply(z.add(BigInteger.ONE)).shiftLeft(1); ret = ret.add(BigInteger.ONE); for ( int i = 0;(i < 8);i += 2) {if ( (z.compareTo(mk[i]) > 0)) {ret = ret.subtract(f(z.subtract(mk[i]))); } }for ( int i = 1;(i < 8);i += 2) {if ( (z.compareTo(mk[i]) > 0)) {ret = ret.add(g(z.subtract(mk[i]))); } }if ( (ret.compareTo(c) >= 0)) return 1; return 0;} public static void main( String[] args){ Scanner cin = new Scanner(System.in); while(cin.hasNext()){n = cin.nextBigInteger(); x = cin.nextBigInteger(); y = cin.nextBigInteger(); c = cin.nextBigInteger(); mk[0] = x.subtract(BigInteger.ONE); mk[2] = n.subtract(y); mk[4] = n.subtract(x); mk[6] = y.subtract(BigInteger.ONE); mk[1] = mk[0].add(mk[2]).add(BigInteger.ONE); mk[3] = mk[2].add(mk[4]).add(BigInteger.ONE); mk[5] = mk[4].add(mk[6]).add(BigInteger.ONE); mk[7] = mk[6].add(mk[0]).add(BigInteger.ONE); BigInteger beg = BigInteger.ZERO,end = mk[0],mid ; for ( int i = 1;(i < 8);++i) if ( (end.compareTo(mk[i]) < 0)) end = mk[i]; while((beg.compareTo(end) < 0)){mid = beg.add(end).shiftRight(1); if ( (solve(mid) == 1)) end = mid; else beg = mid.add(BigInteger.ONE); }System.out.println(end); }} }
6	public class E5{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ for ( int T = ni();(T > 0);T--) { int n = ni(),m = ni();  int[][] a = new int[m][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[j][i] = ni(); }} int[][] mx = new int[m][]; for ( int i = 0;(i < m);i++) { int u = 0; for ( int j = 0;(j < n);j++) {u = Math.max(u,a[i][j]); }mx[i] = new int[]{u,i}; }Arrays.sort(mx,new Comparator<int[]>(){}); int[] dp = new int[(1 << n)]; for ( int i = 0;((i < n) && (i < m));i++) { int c = mx[i][1];  int[] ls = new int[(1 << n)]; for ( int j = 1;(j < (1 << n));j++) {ls[j] = (ls[(j & (j - 1))] + a[c][Integer.numberOfTrailingZeros(j)]); }for ( int j = 1;(j < (1 << n));j++) { int r = rot(j,n); ls[r] = Math.max(ls[r],ls[j]); } int[] ndp = new int[(1 << n)]; for ( int j = 0;(j < (1 << n));j++) {if ( (rot(j,n) == j)) { int cur = j; for ( int sh = 0;(sh < n);sh++) {cur = ((cur >> 1) | ((cur & 1) << (n - 1))); int mask = (((1 << n) - 1) ^ cur); for ( int k = mask;(k >= 0);k--) {k &= mask; ndp[(k | cur)] = Math.max(ndp[(k | cur)],(dp[k] + ls[j])); }}} }dp = ndp; }out.println(dp[((1 << n) - 1)]); }} int rot( int x, int n){ int ret = x; for ( int i = 0;(i < n);i++) {x = ((x >>> 1) | ((x & 1) << (n - 1))); ret = Math.min(ret,x); }return ret;} void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new E5().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
6	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int x ,y ;  boolean graph[][] = new boolean[n][n]; for ( int i = 0;(i < m);i++) {x = (sc.nextInt() - 1); y = (sc.nextInt() - 1); graph[x][y] = graph[y][x] = true; } long dp[][] = new long[(1 << n)][n];  long res = 0; for ( int i = 0;(i < n);i++) {dp[(1 << i)][i] = 1; }for ( int mask = 1;(mask < (1 << n));mask++) { int first = -1; for ( int f = 0;(f < n);f++) {if ( ((mask & (1 << f)) != 0)) {first = f; break;} }for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) != 0) && (i != first))) {for ( int j = 0;(j < n);j++) {if ( (graph[j][i] && ((mask & (1 << j)) != 0))) {dp[mask][i] += dp[(mask ^ (1 << i))][j]; } }} if ( ((Integer.bitCount(mask) > 2) && graph[first][i])) {res += dp[mask][i]; } }}System.out.println((res / 2)); } }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt(),i ,sum = 0;  int a[] = new int[n]; for ( i = 0;(i < n);i++) {a[i] = in.nextInt(); sum += a[i]; }Arrays.sort(a); int s = 0,c = 0; for ( i = (n - 1);(i >= 0);i--) {if ( (s > sum)) break; s += a[i]; sum -= a[i]; c++; }out.println(c); } }
0	public class C125{ public static void main( String[] args)throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  String s = r.readLine();  int n = new Integer(s); System.out.println(("0 0 " + n)); } }
2	public class P255D{ @SuppressWarnings public void run()throws Exception { long n = nextLong();  long x = nextLong();  long y = nextLong();  long c = nextLong(); if ( ((n == 1) || (c == 1))) {println(0); return ;} x = Math.min(x,((n - x) + 1)); y = Math.min(y,((n - y) + 1)); long t = 0;  long s = 1; while((s < c)){t++; s += ((((((((t * 4) + ((t >= (x + y))?(((t - x) - y) + 1):0)) - ((t >= x)?(((t - x) * 2) + 1):0)) - ((t >= y)?(((t - y) * 2) + 1):0)) + ((t >= (((x + n) - y) + 1))?(((t - x) - n) + y):0)) + ((t >= (((n - x) + 1) + y))?(((t - n) + x) - y):0)) - ((t >= ((n - x) + 1))?(((((t - n) + x) - 1) * 2) + 1):0)) - ((t >= ((n - y) + 1))?(((((t - n) + y) - 1) * 2) + 1):0)); }println(t); } public static void main( String... args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedOutputStream(System.out)); new P255D().run(); br.close(); pw.close(); } static BufferedReader br ; static PrintWriter pw ; StringTokenizer stok ; String nextToken()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return null;} stok = new StringTokenizer(s); }return stok.nextToken();} void print( byte b){ print(("" + b)); } void print( int i){ print(("" + i)); } void print( long l){ print(("" + l)); } void print( double d){ print(("" + d)); } void print( char c){ print(("" + c)); } void print( Object o){ if ( (o instanceof int[])) {print(Arrays.toString((int[])o)); } else if ( (o instanceof long[])) {print(Arrays.toString((long[])o)); } else if ( (o instanceof char[])) {print(Arrays.toString((char[])o)); } else if ( (o instanceof byte[])) {print(Arrays.toString((byte[])o)); } else if ( (o instanceof short[])) {print(Arrays.toString((short[])o)); } else if ( (o instanceof boolean[])) {print(Arrays.toString((boolean[])o)); } else if ( (o instanceof float[])) {print(Arrays.toString((float[])o)); } else if ( (o instanceof double[])) {print(Arrays.toString((double[])o)); } else if ( (o instanceof Object[])) {print(Arrays.toString((Object[])o)); } else {print(("" + o)); }} void print( String s){ pw.print(s); } void println(){ println(""); } void println( byte b){ println(("" + b)); } void println( int i){ println(("" + i)); } void println( long l){ println(("" + l)); } void println( double d){ println(("" + d)); } void println( char c){ println(("" + c)); } void println( Object o){ print(o); println(""); } void println( String s){ pw.println(s); } int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} String nextLine()throws IOException { return br.readLine();} }
2	public class Dj{ public static long run( long l, long r){ if ( (l == r)) {return 0;} long[] sq2 = new long[62]; sq2[0] = 1; for ( int i = 1;(i < 62);i++) sq2[i] = (sq2[(i - 1)] * 2); for ( int i = (sq2.length - 1);(i >= 0);i--) {if ( ((l >= sq2[i]) && (r >= sq2[i]))) {l -= sq2[i]; r -= sq2[i]; } else if ( ((l < sq2[i]) && (sq2[i] <= r))) {break;} }for ( int i = (sq2.length - 1);(i >= 0);i--) {if ( ((l < sq2[i]) && (sq2[i] <= r))) {return (sq2[(i + 1)] - 1);} }return -1;} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long l = sc.nextLong();  long r = sc.nextLong(); System.out.println(run(l,r)); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  BPhoenixAndPuzzle solver = new BPhoenixAndPuzzle();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class BPhoenixAndPuzzle{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt(); if ( ((n % 2) == 1)) {out.println("NO"); return ;} n /= 2; if ( ((n == 1) || (((int)Math.sqrt(n) * (int)Math.sqrt(n)) == n))) {out.println("YES"); } else {if ( ((n % 2) == 0)) {n /= 2; if ( (((int)Math.sqrt(n) * (int)Math.sqrt(n)) == n)) {out.println("YES"); return ;} } out.println("NO"); }} } static class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void println( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } } }
2	@SuppressWarnings("unused") public class round169D{ static PrintWriter out = new PrintWriter(System.out); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTokenizer(""); static String next()throws Exception { while(true){if ( st.hasMoreTokens()) {return st.nextToken();} String s = br.readLine(); if ( (s == null)) {return null;} st = new StringTokenizer(s); }} public static void main( String[] args)throws Exception { long l = parseLong(next());  long r = parseLong(next());  long[] min = new long[61]; for ( int i = 1;(i <= 60);++i) {min[i] = ((long)pow(2,(i - 1)) - 1); }for ( int i = 60;(i >= 0);--i) {if ( (min[i] >= r)) continue; if ( ((min[i] >= l) && ((min[i] + 1) <= r))) {out.println(((1L << i) - 1)); out.flush(); return ;} if ( (min[i] < l)) { long one_jump = (long)pow(2,i);  long jumps = (long)ceil(((l - min[i]) / (one_jump * 1.0)));  long cur = (min[i] + (jumps * one_jump)); if ( ((cur >= l) && ((cur + 1) <= r))) {out.println(((1L << i) - 1)); out.flush(); return ;} } }out.println(0); out.flush(); } }
4	public class Main{ static FastScanner fs = new FastScanner(); static class FastScanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String next(){ while(!st.hasMoreElements())try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } return st.nextToken();} int Int(){ return Integer.parseInt(next());} long Long(){ return Long.parseLong(next());} String Str(){ return next();} } public static void main( String[] args)throws java.lang.Exception { PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int T = 1; for ( int t = 0;(t < T);t++) { int n = Int(),m = Int(),k = Int();  List<int[]> g[] = new ArrayList[((n * m) + 1)]; for ( int i = 0;(i < g.length);i++) {g[i] = new ArrayList<>(); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int w = Int();  int u = ((i * m) + j);  int v = ((i * m) + (j + 1)); g[u].add(new int[]{v,w}); g[v].add(new int[]{u,w}); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { int w = Int();  int u = ((i * m) + j);  int v = (((i + 1) * m) + j); g[u].add(new int[]{v,w}); g[v].add(new int[]{u,w}); }} Solution sol = new Solution(out); sol.solution(n,m,k,g); }out.close(); } public static int Int(){ return fs.Int();} public static long Long(){ return fs.Long();} public static String Str(){ return fs.Str();} } class Solution{ PrintWriter out ; public Solution( PrintWriter out){ this.out = out; } List<int[]> g[] ; int n ,m ; long INF = 10000000000000000l; int curr = -1,curc = -1; long mn = Long.MAX_VALUE; long dp[][] ; public void solution( int n, int m, int k, List<int[]>[] g){ this.n = n; this.m = m; long res[][] = new long[n][m]; if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {Arrays.fill(res[i],-1); }print(res); return ;} this.g = g; dp = new long[((n * m) + 1)][((k / 2) + 2)]; for ( int i = 0;(i < dp.length);i++) {Arrays.fill(dp[i],-1); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int id = ((i * m) + j); dfs(id,(k / 2)); }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int id = ((i * m) + j); res[i][j] = dp[id][(k / 2)]; }}print(res); } public long dfs( int id, int cnt){ if ( (cnt == 0)) {return 0;} if ( (dp[id][cnt] != -1)) return dp[id][cnt]; int r = (id / m);  int c = (id % m);  long res = Long.MAX_VALUE; for ( int[] p :g[id]) { int next = p[0],w = p[1]; res = Math.min(res,((w * 2) + dfs(next,(cnt - 1)))); }dp[id][cnt] = res; return res;} public void print( long[][] A){ for ( int i = 0;(i < A.length);i++) {for ( int j = 0;(j < A[0].length);j++) {out.print((A[i][j] + " ")); }out.println(); }} }
1	public class Solution{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; void solve()throws IOException { String s = next();  int u = s.indexOf('R');  int v = s.indexOf('C'); if ( (((u == 0) && (v != -1)) && (u < v))) { String a = s.substring((u + 1),v);  String b = s.substring((v + 1)); try{ int aa = Integer.parseInt(a);  int bb = (Integer.parseInt(b) - 1);  int pow = 26,len = 1; while((bb >= pow)){bb -= pow; pow *= 26; ++len; } String r = ""; for ( int i = 0;(i < len);++i) {r = ((char)((bb % 26) + 'A') + r); bb /= 26; }out.println((r + aa)); return ; }catch (NumberFormatException e){ } } u = 0; while(((u < s.length()) && Character.isLetter(s.charAt(u)))){++u; } String a = s.substring(0,u);  String b = s.substring(u); out.println(((("R" + b) + "C") + toInt(a))); } private int toInt( String a){ int r = 0; for ( int i = 0;(i < a.length());++i) {r *= 26; r += (a.charAt(i) - 'A'); } int pow = 1; for ( int i = 0;(i < a.length());++i) {r += pow; pow *= 26; }return r;} Solution()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); eat(""); int tests = nextInt(); for ( int test = 0;(test < tests);++test) {solve(); }in.close(); out.close(); } private void eat( String str){ st = new StringTokenizer(str); } String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} eat(line); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { new Solution(); } }
5	public class A implements Runnable{ private MyScanner in ; private PrintWriter out ; private void solve(){ int n = in.nextInt();  int[] a = new int[n];  int max = -1,maxp = -1; for ( int i = 0;(i < n);++i) {a[i] = in.nextInt(); if ( (a[i] > max)) {max = a[i]; maxp = i; } }if ( (max == 1)) {for ( int i = 0;(i < (n - 1));++i) {out.print((1 + " ")); }out.println(2); return ;} a[maxp] = 1; Arrays.sort(a); for ( int i = 0;(i < n);++i) {out.print((a[i] + " ")); }out.println(); } @Override public void run(){ in = new MyScanner(); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } public static void main( String[] args){ new A().run(); } static class MyScanner{ private BufferedReader br ; private StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } public void close(){ try{br.close(); }catch (IOException e){ e.printStackTrace(); } } private String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); return null;} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  inputClass in = new inputClass(inputStream);  PrintWriter out = new PrintWriter(outputStream);  APaintTheNumbers solver = new APaintTheNumbers(); solver.solve(1,in,out); out.close(); } static class APaintTheNumbers{ public void solve( int testNumber, inputClass sc, PrintWriter out){ int n = sc.nextInt();  Integer[] tab = new Integer[n]; for ( int i = 0;(i < n);i++) {tab[i] = sc.nextInt(); }Arrays.sort(tab); boolean[] done = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( !done[i]) {ans++; done[i] = true; for ( int j = (i + 1);(j < n);j++) {if ( (!done[j] && ((tab[j] % tab[i]) == 0))) {done[j] = true; } }} }out.println(ans); } } static class inputClass{ BufferedReader br ; StringTokenizer st ; public inputClass( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } public String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
5	public class Main{ public static void main( String[] args){ Scanner r = new Scanner(System.in);  int N = r.nextInt();  int K = (r.nextInt() - 1);  T[] a = new T[N]; for ( int i = 0;(i < N);i++) a[i] = new T(r.nextInt(),r.nextInt()); Arrays.sort(a,new Comparator<T>(){}); int ret = 0; for ( int i = 0;(i < N);i++) if ( ((a[i].p == a[K].p) && (a[i].t == a[K].t))) ret++; System.out.println(ret); } } class T{ int p ,t ; public T( int pi, int ti){ p = pi; t = ti; } }
2	public class A{ public static boolean realbig( long num, long s){ String str = (num + "");  String[] digs = str.split("");  int sum = 0; for ( String dig :digs) {sum += Integer.parseInt(dig); }if ( ((num - sum) < s)) {return false;} else {return true;}} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long s = sc.nextLong(); sc.close(); long count = 0;  long i = s; for ( ;((i < (s + 200)) && (i <= n));i++) {if ( realbig(i,s)) {count++; } }if ( (i <= n)) {count += ((n - i) + 1); } System.out.println(count); } }
3	public class Main{ public static class node implements Comparable<node>{ int l ,r ; node(){ } node( int l, int r){ this.l = l; this.r = r; } } public static void main( String[] args){ Scanner in = new Scanner(System.in);  int a = in.nextInt();  int x[] = new int[a]; for ( int n = 0;(n < a);n++) {x[n] = in.nextInt(); } int max = 1;  int t = 0;  HashMap<Integer,ArrayList<node>> map = new HashMap<Integer,ArrayList<node>>(); for ( int n = 0;(n < a);n++) { int num = 0; for ( int m = n;(m < a);m++) {num += x[m]; node node = new node(n,m); if ( !map.containsKey(num)) { ArrayList<node> list = new ArrayList<node>(); list.add(node); map.put(num,list); if ( (max == 1)) t = num; } else { ArrayList<node> list = map.get(num);  int left = 0;  int right = (list.size() - 1);  int res = list.size(); while((left <= right)){ int mid = ((left + right) >> 1); if ( (list.get(mid).r >= n)) {res = mid; right = (mid - 1); } else {left = (mid + 1); }}if ( (res == list.size())) {list.add(node); if ( (max < (res + 1))) {max = (res + 1); t = num; } } else if ( (list.get(res).r > m)) {list.set(res,node); if ( (max < res)) {max = list.size(); t = num; } } }}}System.out.println(max); for ( int n = 0;(n < max);n++) {System.out.println((((map.get(t).get(n).l + 1) + " ") + (map.get(t).get(n).r + 1))); }} }
4	public class G{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni(),m = ni(),K = ni(),C = ni(),D = ni();  int[] a = na(K);  int[] from = new int[m];  int[] to = new int[m]; for ( int i = 0;(i < m);i++) {from[i] = (ni() - 1); to[i] = (ni() - 1); } int[][] g = packU(n,from,to);  List<Edge> es = new ArrayList<>();  int time = 100; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (time - 1));j++) {es.add(new Edge(((i * time) + j),(((i * time) + j) + 1),99,C)); }}for ( int i = 0;(i < n);i++) {for ( int e :g[i]) {for ( int j = 0;(j < (time - 1));j++) {for ( int k = 0;(k < n);k++) {es.add(new Edge(((i * time) + j),(((e * time) + j) + 1),1,(C + (D * ((2 * k) + 1))))); }}}} int src = (time * n),sink = (src + 1); for ( int i = 0;(i < K);i++) {es.add(new Edge(src,(((a[i] - 1) * time) + 0),1,0)); }for ( int i = 0;(i < time);i++) {es.add(new Edge(((0 * time) + i),sink,99,0)); }out.println(solveMinCostFlowWithSPFA(compileWD((sink + 1),es),src,sink,99)); } public static class Edge{ public int from ,to ; public int capacity ; public int cost ; public int flow ; public Edge complement ; public Edge( int from, int to, int capacity, int cost){ this.from = from; this.to = to; this.capacity = capacity; this.cost = cost; } } public static Edge[][] compileWD( int n, List<Edge> edges){ Edge[][] g = new Edge[n][]; for ( int i = (edges.size() - 1);(i >= 0);i--) { Edge origin = edges.get(i);  Edge clone = new Edge(origin.to,origin.from,origin.capacity,-origin.cost); clone.flow = origin.capacity; clone.complement = origin; origin.complement = clone; edges.add(clone); } int[] p = new int[n]; for ( Edge e :edges) p[e.from]++; for ( int i = 0;(i < n);i++) g[i] = new Edge[p[i]]; for ( Edge e :edges) g[e.from][--p[e.from]] = e; return g;} public static class DQ{ public int[] q ; public int n ; protected int pt ,ph ; public DQ( int n){ this.n = (Integer.highestOneBit(n) << 1); q = new int[this.n]; pt = ph = 0; } public void addLast( int x){ q[ph] = x; ph = ((ph + 1) & (n - 1)); } public int pollFirst(){ int ret = q[pt]; pt = ((pt + 1) & (n - 1)); return ret;} public int size(){ return (((ph - pt) + n) & (n - 1));} public boolean isEmpty(){ return (ph == pt);} } public static long solveMinCostFlowWithSPFA( Edge[][] g, int source, int sink, long all){ int n = g.length;  long mincost = 0; final int[] d = new int[n];  DQ q = new DQ(n);  boolean[] inq = new boolean[n]; while((all > 0)){ Edge[] inedge = new Edge[n]; Arrays.fill(d,(Integer.MAX_VALUE / 2)); d[source] = 0; q.addLast(source); while(!q.isEmpty()){ int cur = q.pollFirst(); inq[cur] = false; for ( Edge ne :g[cur]) {if ( ((ne.capacity - ne.flow) > 0)) { int nd = (d[cur] + ne.cost); if ( (d[ne.to] > nd)) {inedge[ne.to] = ne; d[ne.to] = nd; if ( !inq[ne.to]) {q.addLast(ne.to); inq[ne.to] = true; } } } }}if ( (inedge[sink] == null)) break; long minflow = all;  long sumcost = 0; for ( Edge e = inedge[sink];(e != null);e = inedge[e.from]) {if ( ((e.capacity - e.flow) < minflow)) minflow = (e.capacity - e.flow); sumcost += e.cost; }mincost += (minflow * sumcost); for ( Edge e = inedge[sink];(e != null);e = inedge[e.from]) {e.flow += minflow; e.complement.flow -= minflow; }all -= minflow; }return mincost;} static int[][] packU( int n, int[] from, int[] to){ int[][] g = new int[n][];  int[] p = new int[n]; for ( int f :from) p[f]++; for ( int t :to) p[t]++; for ( int i = 0;(i < n);i++) g[i] = new int[p[i]]; for ( int i = 0;(i < from.length);i++) {g[from[i]][--p[from[i]]] = to[i]; g[to[i]][--p[to[i]]] = from[i]; }return g;} void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new G().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
4	public class A{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String s = new String(in.readLine());  int len = s.length();  int ans = 0; for ( int i = 0;(i < (len - 1));i++) {for ( int j = (i + 1);(j < len);j++) { int score = 0;  boolean flag = true; for ( int k = 0;(((k + j) < len) && flag);k++) {if ( (s.charAt((i + k)) == s.charAt((j + k)))) {score++; } else {flag = false; }}if ( (score > ans)) {ans = score; } }}System.out.println(ans); } }
1	public class AA{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int t = 0; if ( sc.hasNextInt()) {t = sc.nextInt(); } while((t > 0)){t--; int n = sc.nextInt();  String ans = "NO"; if ( ((n % 2) == 0)) { int p = (n / 2); if ( (Math.ceil(Math.sqrt((double)p)) == Math.floor(Math.sqrt((double)p)))) {ans = "YES"; } else {if ( ((n % 4) == 0)) {p = (n / 4); if ( (Math.ceil(Math.sqrt((double)p)) == Math.floor(Math.sqrt((double)p)))) {ans = "YES"; } } }} System.out.println(ans); }} }
2	public class C{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  long n = sc.nextLong();  Long S = sc.nextLong();  long l = 0;  long h = n;  long ans = n; while((l <= h)){ long mid = ((l + h) / 2);  long t = mid;  long sum = 0; while((t > 0)){sum += (t % 10); t /= 10; }if ( ((mid - sum) < S)) {ans = mid; l = (mid + 1); } else h = (mid - 1); }out.println((n - ans)); out.flush(); out.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream System){ br = new BufferedReader(new InputStreamReader(System)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public Long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
3	public class PythonIndentiation{ PrintWriter pw = new PrintWriter(System.out); static final boolean debugmode = true; public static int k = 7; public static int STMOD = (1000000000 + k); public static Reader sc = new Reader(); public static void main( String[] args)throws IOException { int commands = sc.nextInt();  int[][] dp = new int[5000][5000];  int interesting = 0;  String prgm = ""; while((interesting < commands)){ byte q = sc.read(); if ( (q == 115)) {interesting += 1; prgm += "s"; } else if ( (q == 102)) {prgm += "f"; interesting += 1; } }dp[0][0] = 1; for ( int line = 1;(line < commands);line++) {if ( (prgm.charAt((line - 1)) == 'f')) {for ( int indent = 1;(indent < Math.min(((2 * line) + 1),5000));indent++) {dp[line][indent] = dp[(line - 1)][(indent - 1)]; }} else if ( (prgm.charAt((line - 1)) == 's')) { int w = 0; for ( int indent = Math.min(((2 * line) + 1),4999);(indent >= 0);indent--) {w = ((w + dp[(line - 1)][indent]) % STMOD); dp[line][indent] = w; }} } int q = 0; for ( int i = 0;(i < 5000);i++) {q = ((q + dp[(commands - 1)][i]) % STMOD); }System.out.println(q); } static class Reader{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Reader(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws IOException { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } }
2	public class B{ static long n ,k ; static long sum( long mid){ long tmpSum = ((k * (k + 1)) / 2);  long nsum = (((mid - 1) * mid) / 2); return (tmpSum - nsum);} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  StringTokenizer sc = new StringTokenizer(br.readLine()); n = (Long.parseLong(sc.nextToken()) - 1); k = (Long.parseLong(sc.nextToken()) - 1); if ( (n == 0)) out.println(0); else if ( (sum(1) < n)) out.println(-1); else { long lo = 1;  long hi = k;  long mid ; while((lo < hi)){mid = ((lo + hi) / 2); long sum = sum(mid); if ( ((n - sum) < 0)) lo = (mid + 1); else if ( ((n - sum) < mid)) {hi = mid; } else hi = (mid - 1); }out.println((((k - lo) + 1) + (((n - sum(lo)) == 0)?0:1))); }br.close(); out.close(); } }
1	public class B{ static class Scanner{ BufferedReader rd ; StringTokenizer tk ; public Scanner()throws IOException{ rd = new BufferedReader(new InputStreamReader(System.in)); tk = new StringTokenizer(rd.readLine()); } public String next()throws IOException { while(!tk.hasMoreTokens())tk = new StringTokenizer(rd.readLine()); return tk.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.valueOf(this.next());} } static int N ,K ; static int[] array = new int[100010]; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(); N = sc.nextInt(); K = sc.nextInt(); for ( int i = 0;(i < N);i++) array[i] = sc.nextInt(); TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>();  boolean flag = false; for ( int i = 0;(i < N);i++) {if ( !map.containsKey(array[i])) {map.put(array[i],i); if ( (map.size() == K)) {flag = true; break;} } else map.put(array[i],i); }if ( !flag) System.out.println("-1 -1"); else { Set<Integer> s = map.keySet();  int l = Integer.MAX_VALUE;  int r = Integer.MIN_VALUE; for ( int k :s) { int tmp = map.get(k); l = Math.min(l,tmp); r = Math.max(r,tmp); }System.out.println((((l + 1) + " ") + (r + 1))); }} }
3	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } private void run()throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(reader.readLine());  int[] arr = new int[n];  String[] line = reader.readLine().split("\\s"); for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(line[i]); }Arrays.sort(arr); Set<Integer> numbers = new HashSet<>(); for ( int i = 0;(i < arr.length);i++) { Iterator<Integer> iter = numbers.iterator();  boolean contains = false; while(iter.hasNext()){ int elem = iter.next(); if ( (gcd(elem,arr[i]) == elem)) {contains = true; } }if ( !contains) numbers.add(arr[i]); }System.out.println(numbers.size()); } private int gcd( int a, int b){ while((a != b)){if ( (a > b)) a -= b; else b -= a; }return a;} }
0	public class Main{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt(); if ( ((((((((((((n % 4) == 0) || ((n % 7) == 0)) || ((n % 47) == 0)) || ((n % 77) == 0)) || ((n % 74) == 0)) || ((n % 447) == 0)) || ((n % 474) == 0)) || ((n % 477) == 0)) || ((n % 747) == 0)) || ((n % 774) == 0)) || ((n % 777) == 0))) System.out.println("YES"); else System.out.println("NO"); } }
1	public class A{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  int n = Integer.parseInt(bf.readLine());  ArrayList<String> s1 = new ArrayList<String>();  ArrayList<String> s2 = new ArrayList<String>(); for ( int i = 0;(i < n);i++) s1.add(bf.readLine()); for ( int i = 0;(i < n);i++) s2.add(bf.readLine()); Map<String,Integer> mp1 = new HashMap<String,Integer>();  Map<String,Integer> mp2 = new HashMap<String,Integer>(); for ( String s :s1) mp1.put(s,0); for ( String s :s1) mp1.put(s,(mp1.get(s) + 1)); for ( String s :s2) mp2.put(s,0); for ( String s :s2) mp2.put(s,(mp2.get(s) + 1)); for ( String s :mp1.keySet()) {while((mp1.get(s) > 0)){if ( mp2.containsKey(s)) {if ( (mp2.get(s) > 0)) {mp1.put(s,(mp1.get(s) - 1)); mp2.put(s,(mp2.get(s) - 1)); } else break;} else break;}}for ( String s :mp2.keySet()) {while((mp2.get(s) > 0)){if ( mp1.containsKey(s)) {if ( (mp1.get(s) > 0)) {mp2.put(s,(mp2.get(s) - 1)); mp1.put(s,(mp1.get(s) - 1)); } else break;} else break;}} long sum = 0; for ( String s :mp1.keySet()) sum += mp1.get(s); out.println(sum); out.close(); System.exit(0); } }
0	public class lcm{ static int n ; public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(in.readLine()); System.out.println(lcm(n)); in.close(); } static long lcm( int n){ if ( (n == 1)) return 1; if ( (n == 2)) return 2; if ( ((n % 6) == 0)) { long ans = (n - 1); ans *= (n - 2); ans *= (n - 3); return ans;} if ( ((n % 2) == 0)) { long ans = n; ans *= (n - 1); ans *= (n - 3); return ans;} long ans = n; ans *= (n - 1); ans *= (n - 2); return ans;} }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public static long MOD = 1000000009L; public long pow( long n, long p){ if ( (p == 0)) return 1L; if ( (p == 1)) return n; long ret = 1L; if ( ((p % 2L) != 0)) ret = n;  long tmp = pow(n,(p / 2L)); ret = ((ret * tmp) % MOD); ret = ((ret * tmp) % MOD); return ret;} public long func( long n, long k){ long times = (n / k);  long ret = (n - (times * k)); ret += (((((pow(2L,(times + 1L)) + MOD) - 2L) % MOD) * k) % MOD); return ret;} public void solve( int testNumber, InputReader in, OutputWriter out){ long n = in.readLong();  long m = in.readLong();  long k = in.readLong();  long wrong = (n - m);  long wow = (n / k);  long ans ; if ( (wrong >= wow)) ans = m; else ans = ((func((n - (wrong * k)),k) + (((k - 1L) * wrong) % MOD)) % MOD); out.printLine(ans); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public long readLong(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0L; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } }
4	public class x1517D2{ static final int INF = (Integer.MAX_VALUE / 3); public static void main( String[] hi)throws Exception { FastScanner infile = new FastScanner();  int N = infile.nextInt();  int M = infile.nextInt();  int K = infile.nextInt();  int[][] weights1 = new int[N][(M - 1)]; for ( int r = 0;(r < N);r++) weights1[r] = infile.nextInts((M - 1)); int[][] weights2 = new int[(N - 1)][M]; for ( int r = 0;(r < (N - 1));r++) weights2[r] = infile.nextInts(M); int[][] res = new int[N][M]; if ( ((K % 2) == 1)) { StringBuilder sb = new StringBuilder(); for ( int r = 0;(r < N);r++) {for ( int c = 0;(c < M);c++) sb.append("-1 "); sb.append("\n"); }System.out.print(sb); return ;} int[][] dp = new int[N][M];  StringBuilder sb = new StringBuilder(); for ( int k = 0;(k < (K / 2));k++) { int[][] next = new int[N][M]; for ( int r = 0;(r < N);r++) Arrays.fill(next[r],INF); for ( int r = 0;(r < N);r++) for ( int c = 0;(c < M);c++) {if ( (r > 0)) next[(r - 1)][c] = min(next[(r - 1)][c],(dp[r][c] + weights2[(r - 1)][c])); if ( ((r + 1) < N)) next[(r + 1)][c] = min(next[(r + 1)][c],(dp[r][c] + weights2[r][c])); if ( (c > 0)) next[r][(c - 1)] = min(next[r][(c - 1)],(dp[r][c] + weights1[r][(c - 1)])); if ( ((c + 1) < M)) next[r][(c + 1)] = min(next[r][(c + 1)],(dp[r][c] + weights1[r][c])); }dp = next; }for ( int r = 0;(r < N);r++) {for ( int x :dp[r]) sb.append(((2 * x) + " ")); sb.append("\n"); }System.out.print(sb); } } class FastScanner{ private int BS = (1 << 16); private char NC = (char)0; private byte[] buf = new byte[BS]; private int bId = 0,size = 0; private char c = NC; private double cnt = 1; private BufferedInputStream in ; public FastScanner(){ in = new BufferedInputStream(System.in,BS); } public FastScanner( String s){ try{in = new BufferedInputStream(new FileInputStream(new File(s)),BS); }catch (Exception e){ in = new BufferedInputStream(System.in,BS); } } private char getChar(){ while((bId == size)){try{size = in.read(buf); }catch (Exception e){ return NC;} if ( (size == -1)) return NC; bId = 0; }return (char)buf[bId++];} public int nextInt(){ return (int)nextLong();} public int[] nextInts( int N){ int[] res = new int[N]; for ( int i = 0;(i < N);i++) {res[i] = (int)nextLong(); }return res;} public long nextLong(){ cnt = 1; boolean neg = false; if ( (c == NC)) c = getChar(); for ( ;((c < '0') || (c > '9'));c = getChar()) {if ( (c == '-')) neg = true; } long res = 0; for ( ;((c >= '0') && (c <= '9'));c = getChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); cnt *= 10; }return (neg?-res:res);} public double nextDouble(){ double cur = nextLong(); return ((c != '.')?cur:(cur + (nextLong() / cnt)));} }
3	public class D{ FastScanner in ; PrintWriter out ; boolean systemIO = true; public void solve(){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < a.length);i++) {a[i] = in.nextInt(); } int x = 0; for ( int i = 0;(i < a.length);i++) {for ( int j = (i + 1);(j < a.length);j++) {if ( (a[i] > a[j])) {x++; } }} boolean ans = ((x % 2) == 0);  int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int len = (-in.nextInt() + in.nextInt()); len = ((len * (len + 1)) / 2); if ( ((len % 2) == 1)) {ans = !ans; } if ( ans) {out.println("even"); } else {out.println("odd"); }}} public void run(){ try{if ( systemIO) {in = new FastScanner(System.in); out = new PrintWriter(System.out); } else {in = new FastScanner(new File("segments.in")); out = new PrintWriter(new File("segments.out")); }solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } FastScanner( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] arg){ new D().run(); } }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] chores = new int[n]; for ( int i = 0;(i < n);i++) chores[i] = in.nextInt(); Arrays.sort(chores); out.println((chores[b] - chores[(b - 1)])); } }
3	public class PythonIndentation{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  boolean[] lst = new boolean[n]; for ( int i = 0;(i < n);i++) {lst[i] = (in.next()?false:true); }System.out.println(dp(lst)); } static int dp( boolean[] lst){ int[][] dp = new int[2][lst.length]; dp[0][0] = 1; for ( int i = 1;(i < lst.length);i++) {for ( int j = 0;(j < lst.length);j++) {if ( lst[(i - 1)]) {if ( (j == 0)) dp[(i % 2)][j] = 0; else dp[(i % 2)][j] = dp[((i - 1) % 2)][(j - 1)]; } else {if ( (j == 0)) { int temp = 0; for ( int k = 0;(k < lst.length);k++) temp = ((temp + dp[((i - 1) % 2)][k]) % 1000000007); dp[(i % 2)][j] = temp; } else dp[(i % 2)][j] = ((dp[(i % 2)][(j - 1)] - dp[((i - 1) % 2)][(j - 1)]) % 1000000007); }}} int ans = 0; for ( int i = 0;(i < lst.length);i++) {ans = ((ans + dp[((lst.length - 1) % 2)][i]) % 1000000007); }if ( (ans < 0)) ans = (ans + 1000000007); return ans;} }
2	public class ReallyBigNumbers{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long s = sc.nextLong();  long bigNums = 0;  long inARow = 0; for ( long i = s;(i <= n);i++) {if ( (inARow == 9)) {bigNums += ((n - i) + 1); break;} else {if ( (i >= (s + digitSum(i)))) {bigNums++; inARow++; } else {inARow = 0; }}}System.out.println(bigNums); } public static long digitSum( long a){ long sum = (a % 10); if ( (9 < a)) {a /= 10; sum += digitSum(a); } return sum;} }
4	public class Solution{ final InputReader in = new InputReader(System.in); final PrintWriter out = new PrintWriter(System.out); int n ,m ; void solve(){ n = in.nextInt(); m = in.nextInt(); int k = in.nextInt();  int[][] hor = new int[n][(m - 1)];  int[][] ver = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {hor[i][j] = in.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ver[i][j] = in.nextInt(); }} int[][] ans = new int[n][m]; if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) Arrays.fill(ans[i],-1); } else {for ( int dummy = 0;(dummy < (k >> 1));dummy++) { int[][] newAns = new int[n][m]; for ( int i = 0;(i < n);i++) {Arrays.fill(newAns[i],Integer.MAX_VALUE); for ( int j = 0;(j < m);j++) {if ( isGood((i + 1),j)) {newAns[i][j] = Math.min(newAns[i][j],((2 * ver[i][j]) + ans[(i + 1)][j])); } if ( isGood(i,(j + 1))) {newAns[i][j] = Math.min(newAns[i][j],((2 * hor[i][j]) + ans[i][(j + 1)])); } if ( isGood(i,(j - 1))) {newAns[i][j] = Math.min(newAns[i][j],((2 * hor[i][(j - 1)]) + ans[i][(j - 1)])); } if ( isGood((i - 1),j)) {newAns[i][j] = Math.min(newAns[i][j],((2 * ver[(i - 1)][j]) + ans[(i - 1)][j])); } }}ans = newAns; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((ans[i][j] + " ")); }out.println(); }} boolean isGood( int i, int j){ return ((((i >= 0) && (i < n)) && (j >= 0)) && (j < m));} private static void swap( int[] a, int i, int change){ int helper = a[i]; a[i] = a[change]; a[change] = helper; } public static void main(final String[] args)throws FileNotFoundException { final Solution s = new Solution(); final Long t1 = System.currentTimeMillis(); s.solve(); System.err.println(((System.currentTimeMillis() - t1) + " ms")); s.out.close(); } public Solution()throws FileNotFoundException{ } private static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; Random r = new Random(); InputReader(final InputStream stream){ this.stream = stream; } InputReader(final String fileName){ InputStream stream = null; try{stream = new FileInputStream(fileName); }catch (FileNotFoundException e){ e.printStackTrace(); } this.stream = stream; } String nextString(){ int c = read(); while(isSpaceChar(c))c = read(); final StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} private int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} private boolean isSpaceChar(final int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private boolean isEndOfLine(final int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} } }
1	public class Main{ static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer tok ; static boolean hasNext(){ while(((tok == null) || !tok.hasMoreTokens()))try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return false;} return true;} static String next(){ hasNext(); return tok.nextToken();} static int nextInt(){ return Integer.parseInt(next());} static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); public static void main( String[] args){ int n = nextInt();  int a[] = new int[9];  int b[] = new int[9]; for ( int i = 0;(i < n);i++) { String s = next(); if ( s.equals("M")) {a[0]++; } else if ( s.equals("L")) {a[1]++; } else if ( s.equals("XL")) {a[2]++; } else if ( s.equals("XXL")) {a[3]++; } else if ( s.equals("XXXL")) {a[4]++; } else if ( s.equals("S")) {a[5]++; } else if ( s.equals("XS")) {a[6]++; } else if ( s.equals("XXS")) {a[7]++; } else if ( s.equals("XXXS")) {a[8]++; } }for ( int i = 0;(i < n);i++) { String s = next(); if ( s.equals("M")) {b[0]++; } else if ( s.equals("L")) {b[1]++; } else if ( s.equals("XL")) {b[2]++; } else if ( s.equals("XXL")) {b[3]++; } else if ( s.equals("XXXL")) {b[4]++; } else if ( s.equals("S")) {b[5]++; } else if ( s.equals("XS")) {b[6]++; } else if ( s.equals("XXS")) {b[7]++; } else if ( s.equals("XXXS")) {b[8]++; } } int ans = 0; ans += Math.abs((a[2] - b[2])); ans += Math.abs((a[3] - b[3])); ans += Math.abs((a[4] - b[4])); int max = Math.abs((a[0] - b[0])); max = max(max,Math.abs((a[1] - b[1]))); max = max(max,Math.abs((a[5] - b[5]))); ans += max; out.print(ans); out.flush(); } public static int max( int a, int b){ return ((a > b)?a:b);} }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, Scanner in, PrintWriter out){ long n = in.nextLong();  long k = in.nextLong(); if ( (n == 1)) {out.println(0); return ;} if ( ((k * (k - 1)) < (2 * (n - 1)))) {out.println(-1); return ;} long sq2 = (((((4 * k) * k) - (4 * k)) + 1) - (4 * ((2 * n) - 2)));  double sqrt = Math.sqrt(sq2);  long sq = (long)sqrt; if ( (((sq + 1) * (sq + 1)) == sq2)) {sq = (sq + 1); } else if ( (((sq - 1) * (sq - 1)) == sq2)) {sq = (sq - 1); } if ( ((sq * sq) == sq2)) { long kmin = ((sq + 3) / 2); out.println(((k - kmin) + 1)); } else { long km = Math.max(2,((long)((sqrt + 3) / 2.0) - 2)); while(((((km + k) - 2) * ((k - km) + 1)) >= (2 * (n - 1)))){++km; }out.println(((k - km) + 2)); }} }
5	public class ProblemA{ public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  String[] line = s.readLine().split(" ");  int n = Integer.valueOf(line[0]);  int ht = Integer.valueOf(line[1]);  int[][] house = new int[n][2];  Set<Integer> candidates = new HashSet<Integer>(); for ( int i = 0;(i < n);i++) { String[] data = s.readLine().split(" "); house[i][0] = (Integer.valueOf(data[0]) * 2); house[i][1] = Integer.valueOf(data[1]); candidates.add(((house[i][0] - house[i][1]) - ht)); candidates.add(((house[i][0] + house[i][1]) + ht)); } int ans = 0; for ( int p :candidates) { int f = (p - ht);  int t = (p + ht);  boolean isok = true; for ( int i = 0;(i < n);i++) {if ( ((house[i][0] + house[i][1]) <= f)) {} else if ( ((house[i][0] - house[i][1]) >= t)) {} else {isok = false; break;}}if ( isok) {ans++; } }out.println(ans); out.flush(); } }
5	public class C{ public static void main( String... args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); sc.nextLine(); int[] x = new int[n];  int max = 0,pos = -1; for ( int i = 0;(i < n);i++) {x[i] = sc.nextInt(); if ( (max < x[i])) {max = x[i]; pos = i; } }x[pos] = ((max == 1)?2:1); Arrays.sort(x); for ( int i = 0;(i < n);i++) System.out.print((x[i] + " ")); } }
0	public class A{ static String file = ""; static BufferedReader br ; static PrintWriter pw ; static StringTokenizer st ; public static void main( String[] args)throws NumberFormatException,IOException { Locale.setDefault(Locale.US); br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); long a = nextLong();  long b = nextLong(); if ( (((((a % 2) == 1) && ((b - a) == 2)) || ((b - a) == 1)) || (a == b))) {pw.print(-1); } else {if ( ((a % 2) == 1)) a++; pw.print(((((a + " ") + (a + 1)) + " ") + (a + 2))); }pw.close(); } private static long nextLong()throws NumberFormatException,IOException { return Long.parseLong(next());} private static String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
0	public class CF{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt(); pw.print((n + (n / 2))); pw.close(); sc.close(); } }
6	public class Main{ public static void main( String[] args)throws java.lang.Exception { BufferedReader kek = new BufferedReader(new InputStreamReader(System.in));  PrintWriter outkek = new PrintWriter(System.out);  String[] input = kek.readLine().split(" ");  int X0 = Integer.parseInt(input[0]),Y0 = Integer.parseInt(input[1]),N = Integer.parseInt(kek.readLine());  int[] xCoords = new int[(N + 1)];  int[] yCoords = new int[(N + 1)];  int[][] distances = new int[(N + 1)][(N + 1)]; xCoords[N] = X0; yCoords[N] = Y0; for ( int i = 0;(i < N);i++) {input = kek.readLine().split(" "); xCoords[i] = Integer.parseInt(input[0]); yCoords[i] = Integer.parseInt(input[1]); }for ( int i = 0;(i <= N);i++) {for ( int j = (i + 1);(j <= N);j++) { int temp = (xCoords[i] - xCoords[j]);  int temp2 = (yCoords[i] - yCoords[j]); distances[i][j] = ((temp * temp) + (temp2 * temp2)); }} int[] aa = new int[(1 << N)];  int[] bb = new int[(1 << N)]; for ( int i = 1;(i < (1 << N));i++) { int a = -1; for ( int j = 0;(j < N);j++) {if ( ((i & (1 << j)) > 0)) {a = j; break;} } int l = (i ^ (1 << a));  int dist = (distances[a][N] + distances[a][N]); aa[i] = (aa[l] + dist); bb[i] = l; for ( int k = (a + 1);(k < N);k++) {if ( ((i & (1 << k)) > 0)) {l = ((i ^ (1 << a)) ^ (1 << k)); dist = ((distances[a][N] + distances[k][N]) + distances[a][k]); if ( ((aa[l] + dist) < aa[i])) {aa[i] = (aa[l] + dist); bb[i] = l; } } }} int fin = ((1 << N) - 1); outkek.println(aa[fin]); outkek.print('0'); while((fin != 0)){ int temp1 = bb[fin];  int temp2 = (fin ^ temp1); for ( int i = 0;(i < N);i++) {if ( ((temp2 & (1 << i)) > 0)) {outkek.print((" " + (i + 1))); } }outkek.print(" 0"); fin = temp1; }kek.close(); outkek.close(); } }
5	public class A implements Runnable{ private static BufferedReader br = null; private static PrintWriter out = null; private static StringTokenizer stk = null; public static void main( String[] args){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); new Thread(new A()).start(); } private void loadLine(){ try{stk = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } private Integer nextInt(){ while(((stk == null) || !stk.hasMoreTokens()))loadLine(); return Integer.parseInt(stk.nextToken());} }
4	public class Main{ public static void main( String[] args)throws IOException { File f = new File("input.txt");  Scanner sc = new Scanner(f);  BufferedWriter bw = new BufferedWriter(new FileWriter(new File("output.txt")));  int n = sc.nextInt();  int m = sc.nextInt();  boolean[][] grid = new boolean[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) grid[i][j] = false; Queue<Pair> q = new LinkedList<>();  int cnt = sc.nextInt(); for ( int i = 0;(i < cnt);i++) { int x = sc.nextInt();  int y = sc.nextInt(); x--; y--; grid[x][y] = true; q.add(new Pair(x,y)); } Pair last = new Pair(-1,-1); while(!q.isEmpty()){ Pair current = q.poll(); last = current; for ( int i = -1;(i <= 1);i++) {for ( int j = -1;(j <= 1);j++) {if ( ((i != 0) && (j != 0))) continue; if ( (inside((current.x + i),(current.y + j),n,m) && !grid[(current.x + i)][(current.y + j)])) {grid[(current.x + i)][(current.y + j)] = true; q.add(new Pair((current.x + i),(current.y + j))); } }}}bw.append(((((last.x + 1) + " ") + (last.y + 1)) + "\n")); bw.flush(); bw.close(); sc.close(); } static class Pair{ int x ; int y ; Pair( int x, int y){ this.x = x; this.y = y; } } private static boolean inside( int a, int b, int n, int m){ return ((((a >= 0) && (a < n)) && (b >= 0)) && (b < m));} }
3	public class PythonIndentation{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  boolean[] lst = new boolean[n]; for ( int i = 0;(i < n);i++) {lst[i] = (in.next()?false:true); }System.out.println(dp(lst)); } static long dp( boolean[] lst){ long[][] dp = new long[lst.length][lst.length]; dp[0][0] = 1; for ( int i = 1;(i < lst.length);i++) {for ( int j = 0;(j < lst.length);j++) {if ( lst[(i - 1)]) {if ( (j == 0)) dp[i][j] = 0; else dp[i][j] = dp[(i - 1)][(j - 1)]; } else {if ( (j == 0)) {for ( int k = 0;(k < lst.length);k++) dp[i][j] = ((dp[i][j] + dp[(i - 1)][k]) % 1000000007); } else dp[i][j] = ((dp[i][(j - 1)] - dp[(i - 1)][(j - 1)]) % 1000000007); }}} long ans = 0; for ( int i = 0;(i < lst.length);i++) {ans = ((ans + dp[(lst.length - 1)][i]) % 1000000007); }if ( (ans < 0)) ans = (ans + 1000000007); return ans;} }
1	public class Beta17PA{ boolean[] isPrime = new boolean[1001]; int[] prime = new int[200]; public static void main( String[] args){ new Beta17PA().solve(); } public void solve(){ Scanner scan = new Scanner(System.in);  int n ,k ; n = scan.nextInt(); k = scan.nextInt(); init(); int m = 0; for ( int i = 2;(i <= n);i++) {if ( check(i)) m++; }if ( (m >= k)) System.out.println("YES"); else System.out.println("NO"); } private boolean check( int n){ if ( ((n < 6) || !isPrime[n])) return false; int d = (n - 1); for ( int i = 0;((i < 199) && ((prime[i] + prime[(i + 1)]) <= d));i++) {if ( ((prime[i] + prime[(i + 1)]) == d)) return true; }return false;} private void init(){ Arrays.fill(isPrime,true); isPrime[0] = isPrime[1] = false; for ( int i = 2;(i < 1001);i++) {if ( !isPrime[i]) continue; for ( int j = (i + i);(j < 1001);j += i) {isPrime[j] = false; }} int count = 0; for ( int i = 2;(i < 1001);i++) {if ( isPrime[i]) prime[count++] = i; }} }
3	public class D{ public static void solve( FastScanner fs){ int n = fs.nextInt();  int[] a = fs.readArray(n);  boolean even = ((countInversions(a) & 1) == 0);  int q = fs.nextInt(); for ( int i = 0;(i < q);i++) { int start = fs.nextInt();  int end = fs.nextInt();  int diff = (end - start);  boolean evenChange = ((((diff + 1) / 2) % 2) == 0); even ^= !evenChange; System.out.println((even?"even":"odd")); }} private static int countInversions( int[] a){ int c = 0; for ( int i = 0;(i < a.length);i++) {for ( int j = (i + 1);(j < a.length);j++) if ( (a[j] < a[i])) c++; }return c;} public static void main( String[] args)throws NumberFormatException,IOException { FastScanner scanner = new FastScanner(System.in); solve(scanner); } private static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} int[] readArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
3	public class C{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner();  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt(),r = sc.nextInt();  int[] x = new int[n]; for ( int i = 0;(i < n);i++) x[i] = sc.nextInt(); double[] ans = new double[n]; for ( int i = 0;(i < n);i++) {ans[i] = r; for ( int j = 0;(j < i);j++) { int d = Math.abs((x[i] - x[j])); if ( (d > (2 * r))) continue; int h = (2 * r);  double yd = Math.sqrt(((h * h) - (d * d))); ans[i] = Math.max(ans[i],(ans[j] + yd)); }out.print(ans[i]); if ( (i == (n - 1))) out.println(); else out.print(" "); }out.flush(); out.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} } }
6	public class Main{ static int N ,M ; static long[] C ; static int[][] g ; static long[][] DP ; public static void main( String[] args){ InputReader r = new InputReader(System.in); N = r.nextInt(); M = r.nextInt(); g = new int[N][N]; C = new long[(N + 1)]; DP = new long[(1 << N)][N]; for ( int k = 0;(k < M);k++) { int i = (r.nextInt() - 1);  int j = (r.nextInt() - 1); g[i][j] = g[j][i] = 1; }for ( long[] i :DP) Arrays.fill(i,-1); long ret = 0; for ( int s = 0;(s < N);s++) {ret += go(s,(1 << s),s); }System.out.println((ret / 2)); } private static long go( int s, int m, int e){ if ( (DP[m][e] != -1)) return DP[m][e]; long cnt = 0; for ( int j = s;(j < N);j++) if ( (g[e][j] == 1)) {if ( ((m & (1 << j)) != 0)) {if ( ((s == j) && (Integer.bitCount(m) >= 3))) {cnt++; } } else {cnt += go(s,(m | (1 << j)),j); }} return DP[m][e] = cnt;} static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class C_1523{ static Scanner input = new Scanner(System.in); static int n ; public static void main( String[] args){ int t = input.nextInt(); for ( int test = 0;(test < t);test++) {n = input.nextInt(); int num = input.nextInt(); if ( (num == 1)) {n--; recur(""); } else {System.out.println("ERROR"); }}} public static int recur( String before){ int num = 1; System.out.println((before + num)); while((n > 0)){ int val = input.nextInt(); n--; if ( (val == 1)) {val = recur(((before + num) + ".")); } if ( (val == (num + 1))) {num++; System.out.println((before + num)); } else {return val;}}return -1;} }
6	public class D implements Runnable{ public static void main( String[] args){ new D().run(); } class FastScanner{ BufferedReader br ; StringTokenizer st ; boolean eof ; String buf ; public FastScanner( String fileName)throws FileNotFoundException{ br = new BufferedReader(new FileReader(fileName)); nextToken(); } public FastScanner( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); nextToken(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; break;} } String ret = buf; buf = (eof?"-1":st.nextToken()); return ret;} int nextInt(){ return Integer.parseInt(nextToken());} long nextLong(){ return Long.parseLong(nextToken());} double nextDouble(){ return Double.parseDouble(nextToken());} void close(){ try{br.close(); }catch (Exception e){ } } } FastScanner sc ; PrintWriter out ; public void run(){ Locale.setDefault(Locale.US); try{sc = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); sc.close(); out.close(); }catch (Throwable e){ e.printStackTrace(); System.exit(1); } } int nextInt(){ return sc.nextInt();} String nextToken(){ return sc.nextToken();} long nextLong(){ return sc.nextLong();} double nextDouble(){ return sc.nextDouble();} void solve(){ int n = nextInt();  int m = nextInt();  boolean[][] edges = new boolean[n][n];  boolean[] edge = new boolean[((n << 5) | n)]; for ( int i = 0;(i < m);i++) { int x = (nextInt() - 1);  int y = (nextInt() - 1); edges[x][y] = edges[y][x] = true; edge[((x << 5) | y)] = edge[((y << 5) | x)] = true; } long[][] dp = new long[n][(1 << n)];  long ans = 0; for ( int i = 0;(i < n);i++) {for ( int mask2 = 1;(mask2 < (1 << ((n - i) - 1)));++mask2) {for ( int j = (i + 1);(j < n);j++) {dp[j][((mask2 << i) << 1)] = 0; }}for ( int j = (i + 1);(j < n);j++) {if ( edges[i][j]) {dp[j][(1 << j)] = 1; } }for ( int mask2 = 1;(mask2 < (1 << ((n - i) - 1)));++mask2) { int mask = ((mask2 << i) << 1); if ( ((mask & (mask - 1)) == 0)) {continue;} for ( int j = (i + 1);(j < n);j++) {if ( (((mask >> j) & 1) == 0)) {continue;} dp[j][mask] = 0; for ( int k = (i + 1);(k < n);k++) {if ( ((((mask >> k) & 1) == 0) || !edge[((j << 5) | k)])) {continue;} dp[j][mask] += dp[k][(mask & (1 << j))]; }if ( edge[((i << 5) | j)]) {ans += dp[j][mask]; } }}}out.println((ans / 2)); } }
6	public class cf2{ static int x0 ; static int y0 ; static int x1 ; static int y1 ; static HashMap<Integer,HashSet<Integer>> allowed ; static HashMap<Integer,HashMap<Integer,Integer>> cost ; static int[] dx = {-1,-1,-1,0,0,0,1,1,1}; static int[] dy = {-1,0,1,-1,0,1,-1,0,1}; static int highbound = (int)1e9; static boolean valid( int i, int j){ if ( ((((((i >= 1) && (i <= highbound)) && (j >= 1)) && (j <= highbound)) && allowed.containsKey(i)) && allowed.get(i).contains(j))) return true; return false;} static long ans ; static class Triple implements Comparable<Triple>{ int i ,j ,cost ; Triple( int x, int y, int z){ i = x; j = y; cost = z; } public int compareTo( Triple t){ return (this.cost - t.cost);} public String toString(){ return ((((i + " ") + j) + " ") + cost);} } static int t ; static int n ; static int[] ds ; static int[] gs ; static int[][] memo ; static int dp( int lastg, int msk, int sum){ if ( (sum == t)) return 1; if ( (msk == ((1 << n) - 1))) {return 0;} if ( (memo[lastg][msk] != -1)) return memo[lastg][msk]; int tot = 0; for ( int i = 0;(i < n);i++) {if ( ((((1 << i) & msk) == 0) && (gs[i] != lastg))) {tot = ((tot + dp(gs[i],(msk | (1 << i)),(sum + ds[i]))) % 1000000007); } }return memo[lastg][msk] = tot;} public static void main( String[] args)throws IOException { MScanner sc = new MScanner(System.in);  PrintWriter pw = new PrintWriter(System.out); n = sc.nextInt(); t = sc.nextInt(); ds = new int[n]; gs = new int[n]; for ( int i = 0;(i < n);i++) {ds[i] = sc.nextInt(); gs[i] = sc.nextInt(); }memo = new int[4][(1 << n)]; for ( int[] i :memo) Arrays.fill(i,-1); pw.println(dp(0,0,0)); pw.flush(); } static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static int[] primes ; static int sizeofp = 0; static int[] isComposite ; static class MScanner{ StringTokenizer st ; BufferedReader br ; public MScanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
2	public class code{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  int q = sc.nextInt();  long[] d = new long[30]; d[0] = 1; for ( int i = 1;(i < 30);i++) d[i] = (d[(i - 1)] * 4); for ( int z = 0;(z < q);z++) { long r = 0;  long n = sc.nextLong();  long k = sc.nextLong();  long c = 1; while(((k > 0) && (n >= 1))){if ( (k <= r)) {k = 0; break;} n--; k -= c; if ( (k <= 0)) break; if ( (n > 30)) {k = 0; break;} for ( int i = 0;(i < (int)n);i++) {r += (d[i] * ((c * 2) - 1)); if ( (k <= r)) {k = 0; break;} }if ( (k <= r)) {k = 0; break;} c *= 2; c++; }if ( (k == 0)) System.out.println(("YES " + n)); else System.out.println("NO"); }} }
0	public class A{ BufferedReader in ; StringTokenizer st ; PrintWriter out ; String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(next());} void solve()throws Exception { int n = nextInt(); if ( ((n % 2) == 0)) out.println(("4 " + (n - 4))); else out.println(("9 " + (n - 9))); } void run(){ try{Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } public static void main( String[] args){ new A().run(); } }
0	public class AgainTwentyfive{ public static void main( String[] args){ System.out.println("25"); } }
1	public class Main{ private static String encode( long rowNum){ if ( (rowNum <= 26)) {return String.valueOf((char)(('A' + rowNum) - 1));} else {if ( ((rowNum % 26) == 0)) {return (encode(((long)Math.floor(((double)rowNum / 26)) - 1)) + String.valueOf((char)(('A' + 26) - 1)));} else {return (encode((long)Math.floor(((double)rowNum / 26))) + String.valueOf((char)(('A' + (rowNum % 26)) - 1)));}}} private static long decode( String rowNum){ long result = 0;  char rowChars[] = rowNum.toCharArray(); for ( int i = (rowChars.length - 1);(i >= 0);i--) {result += (((rowChars[i] - 'A') + 1) * (long)Math.pow(26,((rowChars.length - i) - 1))); }return result;} public static void main( String[] arg)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int t = Integer.parseInt(in.readLine());  Pattern p1 = Pattern.compile("R\\d+C\\d+");  Pattern p2 = Pattern.compile("\\d+"); for ( int i = 0;(i < t);i++) { String input = in.readLine();  Matcher m1 = p1.matcher(input);  Matcher m2 = p2.matcher(input); if ( m1.matches()) { String result = ""; if ( m2.find()) {result = m2.group(); } if ( m2.find()) {result = (encode(Long.parseLong(m2.group())) + result); } System.out.println(result); } else { String result = "R"; if ( m2.find()) {result += m2.group(); } result += "C"; System.out.println((result + decode(input.replaceAll(m2.group(),"")))); }}} }
1	public class Main{ public static void main( String[] args){ Scanner entrada = new Scanner(System.in);  int Primos[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};  boolean sw = true;  int Indices[] = new int[Primos.length];  int cantidad = 0; for ( int i = 0;((i < (Primos.length - 1)) && sw);i++) { int suma = ((Primos[i] + Primos[(i + 1)]) + 1);  int posicion = Arrays.binarySearch(Primos,suma); if ( (posicion > -1)) Indices[posicion] = 1; }while(entrada.hasNextInt()){ int N = entrada.nextInt();  int K = entrada.nextInt();  int contador = 0; for ( int i = 0;((Primos[i] <= N) && (i < (Primos.length - 1)));i++) contador += Indices[i]; if ( (contador >= K)) System.out.println("YES"); else System.out.println("NO"); }} }
1	public class B{ public static void main( String[] args)throws Exception { Parserdoubt2333 s = new Parserdoubt2333(System.in);  int n = s.nextInt();  int k = s.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < a.length);i++) {a[i] = s.nextInt(); } TreeMap<Integer,Integer> tree = new TreeMap<Integer,Integer>();  int left = 0;  int right = 0; for ( right = 0;(right < a.length);right++) {if ( tree.containsKey(a[right])) tree.put(a[right],(tree.get(a[right]) + 1)); else tree.put(a[right],1); if ( (tree.size() == k)) break; }if ( (tree.size() < k)) {System.out.println("-1 -1"); return ;} for ( left = 0;(left < a.length);left++) { int val = tree.get(a[left]); val--; if ( (val > 0)) tree.put(a[left],val); if ( (val == 0)) break; }left++; right++; System.out.println(((left + " ") + right)); } } class Parserdoubt2333{ private final int BUFFER_SIZE = (1 << 18); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Parserdoubt2333( InputStream in){ din = new DataInputStream(in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws Exception { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); c = read(); }while((c > ' '));if ( neg) return -ret; return ret;} private void fillBuffer()throws Exception { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws Exception { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} }
1	public class Spreadsheet{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int N = in.nextInt(); in.nextLine(); for ( int i = 0;(i < N);i++) { String str = in.nextLine(); if ( (((str.indexOf("R") == 0) && ((str.indexOf("R") + 1) < str.indexOf("C"))) && isNum(str.charAt(1)))) { int row = Integer.parseInt(str.substring((str.indexOf("R") + 1),str.indexOf("C")));  int col = Integer.parseInt(str.substring((str.indexOf("C") + 1))); System.out.println(convertRC(row,col)); } else { String row = "";  int j = 0; while(((str.charAt(j) >= 'A') && (str.charAt(j) <= 'Z'))){row += str.charAt(j); j++; } int num = Integer.parseInt(str.substring(j)); System.out.println(convertAB(row,num)); }}} static String convertAB( String str, int num){ String result = "";  int col = 0; for ( int i = 0;(i < str.length());i++) {col += ((int)Math.pow(26,(str.length() - (i + 1))) * ((str.charAt(i) - 'A') + 1)); }result += ("R" + num); result += ("C" + col); return result;} static String convertRC( int row, int column){ String result = ""; while((column > 0)){ int index = (column % 26);  char c ; if ( (index == 0)) {c = 'Z'; column = (column - 26); } else {c = (char)(('A' + index) - 1); column = (column - index); }result += c; column = (column / 26); } String res = ""; for ( int i = 0;(i < result.length());i++) {res += result.charAt((result.length() - (i + 1))); }res += row; return res;} static boolean isNum( char x){ return ((x > '0') && (x <= '9'));} }
2	public class Main{ final int mod = 1000000007; final int maxn = -1; final double eps = 1e-9; long digits( long n){ if ( (n == 0)) return 0; int p = (int)Math.log10(n); return (((p + 1) * ((n - (long)Math.pow(10,p)) + 1)) + digits(((long)Math.pow(10,p) - 1)));} void solve(){ String s = "";  long k = nextLong();  long i = 1;  long j = k; while((i < j)){ long m = ((i + j) / 2); if ( (digits(m) < k)) {i = (m + 1); } else {j = m; }}if ( (digits(i) >= k)) --i; printf("%c\n",String.valueOf((i + 1)).charAt((int)((k - digits(i)) - 1))); } final double pi = Math.acos(-1.0); final long infl = 0x3f3f3f3f3f3f3f3fl; final int inf = 0x3f3f3f3f; final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); PrintWriter out ; BufferedReader reader ; StringTokenizer tokens ; Main(){ long s = System.currentTimeMillis(); tokens = new StringTokenizer(""); reader = new BufferedReader(new InputStreamReader(System.in),(1 << 15)); out = new PrintWriter(System.out); Locale.setDefault(Locale.US); solve(); out.close(); debug("Time elapsed: %dms",(System.currentTimeMillis() - s)); } long nextLong(){ return Long.parseLong(next());} String next(){ readTokens(); return tokens.nextToken();} boolean readTokens(){ while(!tokens.hasMoreTokens()){try{ String line = reader.readLine(); if ( (line == null)) return false; tokens = new StringTokenizer(line); }catch (IOException e){ throw (new RuntimeException(e));} }return true;} void printf( String s, Object... o){ out.printf(s,o); } void debug( String s, Object... o){ if ( !ONLINE_JUDGE) System.err.printf((((((char)27 + "[91m") + s) + (char)27) + "[0m"),o); } public static void main( String[] args){ new Main(); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  long k = in.nextLong();  HashMap<Long,Integer> hm = new HashMap<>();  long ar[] = in.nextLongArray(n); for ( int i = 0;(i < n);i++) { long dist = (ar[i] + k);  long min = k; for ( int j = 0;(j < n);j++) {min = Math.min(min,Math.abs((ar[j] - dist))); }if ( (min == k)) {hm.put(dist,1); } dist = (ar[i] - k); min = k; for ( int j = 0;(j < n);j++) {min = Math.min(min,Math.abs((ar[j] - dist))); }if ( (min == k)) {hm.put(dist,1); } }out.print(hm.size()); } } static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ; private int snumChars ; public InputReader( InputStream st){ this.stream = st; } public int read(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long[] nextLongArray( int n){ long a[] = new long[n]; for ( int i = 0;(i < n);i++) {a[i] = nextLong(); }return a;} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
2	public class SolutionD{ BufferedReader in ; StringTokenizer str ; PrintWriter out ; String SK ; String next()throws IOException { while(((str == null) || str.hasMoreTokens())){SK = in.readLine(); if ( (SK == null)) return null; str = new StringTokenizer(SK); }return str.nextToken();} void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } public static void main( String[] args)throws IOException { new SolutionD().run(); } void solve()throws IOException { long l = Long.parseLong(next());  long r = Long.parseLong(next());  String low = Long.toBinaryString(l);  String up = Long.toBinaryString(r);  int n = low.length();  int m = up.length(); for ( int i = 0;(i < (m - n));i++) {low = ("0" + low); } String ret = "";  boolean fu = false;  boolean fd = false;  boolean su = false;  boolean sd = false; if ( (m > n)) {su = true; fd = true; } for ( int i = 0;(i < m);i++) {if ( (low.charAt(i) == up.charAt(i))) {if ( (low.charAt(i) == '1')) {if ( fd) {ret += "1"; fu = true; } else if ( sd) {ret += "1"; su = true; } else ret += "0"; } else {if ( fu) {ret += "1"; fd = true; } else if ( su) {ret += "1"; sd = true; } else ret += "0"; }} else {if ( (up.charAt(i) == '1')) {su = true; fd = true; } ret += "1"; }}out.println(Long.parseLong(ret,2)); } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ Point bag = new Point(in.ni(),in.ni());  int n = in.ni();  Point[] arr = new Point[n]; for ( int i = 0;(i < n);++i) arr[i] = new Point(in.ni(),in.ni()); int[] dist = new int[n]; for ( int i = 0;(i < n);++i) { int dx = (arr[i].x - bag.x);  int dy = (arr[i].y - bag.y); dist[i] = ((dx * dx) + (dy * dy)); } int[][] d = new int[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) { int dx = (arr[i].x - arr[j].x);  int dy = (arr[i].y - arr[j].y); d[i][j] = ((((dx * dx) + (dy * dy)) + dist[i]) + dist[j]); }} int lim = (1 << n);  int[] dp = new int[lim]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; int[] p = new int[lim]; Arrays.fill(p,-1); for ( int mask = 0;(mask < lim);++mask) {if ( (dp[mask] == Integer.MAX_VALUE)) continue; int minBit = -1; for ( int bit = 0;(bit < n);++bit) {if ( checkBit(mask,bit)) continue; if ( ((minBit == -1) || (dist[minBit] > dist[bit]))) minBit = bit; }if ( (minBit == -1)) continue; for ( int bit = 0;(bit < n);++bit) {if ( checkBit(mask,bit)) continue; int newMask = ((mask | (1 << minBit)) | (1 << bit)); if ( (dp[newMask] > (dp[mask] + d[minBit][bit]))) {dp[newMask] = (dp[mask] + d[minBit][bit]); p[newMask] = ((minBit * n) + bit); } }}out.println(dp[(lim - 1)]); int curMask = (lim - 1); while((p[curMask] != -1)){out.print("0 "); int first = (p[curMask] / n);  int second = (p[curMask] % n); out.print(((first + 1) + " ")); curMask ^= (1 << first); if ( (first != second)) {out.print(((second + 1) + " ")); curMask ^= (1 << second); } }out.println(0); } boolean checkBit( int mask, int bitNumber){ return ((mask & (1 << bitNumber)) != 0);} } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream inputStream){ br = new BufferedReader(new InputStreamReader(inputStream)); } public String n(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException());} }return st.nextToken();} public int ni(){ return Integer.parseInt(n());} } }
6	public class E_fast{ static int g[][] ; static int n ,m ; static char[] s ; static int dp[] ,inf = (int)2e9; static int cost[][] ; public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out); n = in.nextInt(); m = in.nextInt(); s = in.next().toCharArray(); g = new int[m][m]; for ( int i = 1;(i < n);i++) { int x = (s[(i - 1)] - 'a'),y = (s[i] - 'a'); if ( (x != y)) {g[x][y]++; g[y][x]++; } }cost = new int[m][(1 << m)]; for ( int i = 0;(i < m);i++) { int w = 0; for ( int j = 0;(j < m);j++) w += g[i][j]; pre(i,0,0,-w); }dp = new int[(1 << m)]; Arrays.fill(dp,-1); pw.println(solve(0,0)); pw.close(); } static void pre( int x, int pos, int mask, int w){ if ( (pos >= m)) {cost[x][mask] = w; return ;} pre(x,(pos + 1),mask,w); pre(x,(pos + 1),set(mask,pos),(w + (2 * g[x][pos]))); } static int solve( int pos, int mask){ if ( (pos >= m)) return 0; if ( (dp[mask] != -1)) return dp[mask]; int min = inf; for ( int i = 0;(i < m);i++) {if ( !check(mask,i)) { int res = ((cost[i][mask] * pos) + solve((pos + 1),set(mask,i))); min = min(min,res); } }return dp[mask] = min;} static boolean check( int N, int pos){ return ((N & (1 << pos)) != 0);} static int set( int N, int pos){ return N = (N | (1 << pos));} }
1	public class Problem17A implements Runnable{ void solve()throws NumberFormatException,IOException { int n = nextInt();  int k = nextInt();  ArrayList<Integer> primes = new ArrayList<Integer>((n + 1));  boolean[] simplePrime = new boolean[(n + 1)]; Arrays.fill(simplePrime,0,simplePrime.length,true); simplePrime[0] = simplePrime[1] = false; for ( int i = 2;(i <= n);i++) {if ( simplePrime[i]) {for ( int j = (i + i);(j <= n);j += i) {simplePrime[j] = false; }primes.add(i); } } int actualK = 0; for ( int i = 1;(i < primes.size());i++) { int val = ((primes.get((i - 1)) + primes.get(i)) + 1); if ( (val <= n)) {if ( simplePrime[val]) {actualK++; } } else {break;}}System.out.println(((k <= actualK)?"YES":"NO")); } StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args){ new Problem17A().run(); } public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); }catch (Exception e){ e.printStackTrace(); } finally{out.flush(); out.close(); }} String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} }
6	public class Main{ public static void main( String[] args)throws Exception { new Main().doWork(); } void doWork()throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));  int ncase = Integer.valueOf(reader.readLine());  double[][] p = new double[ncase][]; for ( int icase = 0;(icase < ncase);icase++) {p[icase] = toDoubleArray(reader.readLine()); } double[] prob = new double[(1 << ncase)]; prob[0] = 1; for ( int x = 0;(x < (1 << ncase));x++) { double cp = prob[x];  int count = 0; for ( int i = 0;(i < ncase);i++) {if ( ((x & (1 << i)) != 0)) continue; count++; }if ( (count == 1)) continue; double np = (((cp * 2.0) / count) / (count - 1)); for ( int i = 0;(i < ncase);i++) {if ( ((x & (1 << i)) != 0)) continue; for ( int j = (i + 1);(j < ncase);j++) {if ( ((x & (1 << j)) != 0)) continue; prob[(x ^ (1 << j))] += (np * p[i][j]); prob[(x ^ (1 << i))] += (np * p[j][i]); }}} String out = ""; for ( int i = 0;(i < ncase);i++) {if ( (i > 0)) out += " ";  int index = (((1 << ncase) - 1) ^ (1 << i)); out += String.format("%.6f",prob[index]); }out += "\r\n"; writer.write(out,0,out.length()); writer.flush(); writer.close(); reader.close(); } double[] toDoubleArray( String line){ String[] p = line.split("[ ]+");  double[] out = new double[p.length]; for ( int i = 0;(i < p.length);i++) out[i] = Double.valueOf(p[i]); return out;} }
4	public class A implements Runnable{ BufferedReader br ; StringTokenizer in ; PrintWriter out ; public static void main( String[] args){ new Thread(new A()).start(); } public String nextToken()throws IOException { while(((in == null) || !in.hasMoreTokens())){in = new StringTokenizer(br.readLine()); }return in.nextToken();} public void solve()throws IOException { String s = nextToken();  int max = 0; for ( int i = 0;(i < s.length());i++) for ( int j = (i + 1);(j < s.length());j++) { String sub = s.substring(i,j);  int kv = 0; for ( int k = 0;(k <= (s.length() - sub.length()));k++) { boolean ok = true; for ( int g = 0;(g < sub.length());g++) if ( (sub.charAt(g) != s.charAt((g + k)))) {ok = false; break;} if ( ok) kv++; }if ( (kv > 1)) max = Math.max(max,sub.length()); }out.println(max); } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ long n ,x ,y ,c ; public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.readInt(); x = in.readInt(); y = in.readInt(); c = in.readInt(); int lo = -1;  int hi = (int)c; while(((lo + 1) < hi)){ int mi = ((lo + hi) / 2); if ( P(mi)) hi = mi; else lo = mi; }out.printLine(hi); } private boolean P( int t){ if ( (t == -1)) return false; int ans = 0; for ( long i = Math.max(1,(y - t));(i <= Math.min((y + t),n));++i) { long a = Math.abs((y - i)); ans += D(Math.max(1,((x - t) + a)),Math.min(n,((x + t) - a))); if ( (ans >= c)) return true; }return false;} private long D( long a, long b){ return ((b - a) + 1);} } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } }
4	public class EdA{ static long[] mods = {1000000007,998244353,1000000009}; static long mod = mods[0]; public static MyScanner sc ; public static PrintWriter out ; public static void main( String[] havish)throws Exception { sc = new MyScanner(); out = new PrintWriter(System.out); int n = sc.nextInt(); mod = sc.nextLong(); long[] fact = new long[401];  long[] twopowers = new long[401]; fact[0] = 1; twopowers[0] = 1; for ( int j = 1;(j <= 400);j++) {twopowers[j] = (twopowers[(j - 1)] * 2L); twopowers[j] %= mod; fact[j] = (fact[(j - 1)] * j); fact[j] %= mod; } long[][] choose = new long[401][401]; for ( int j = 0;(j <= 400);j++) {for ( int k = 0;(k <= j);k++) {choose[j][k] = fact[j]; choose[j][k] *= inv(fact[k]); choose[j][k] %= mod; choose[j][k] *= inv(fact[(j - k)]); choose[j][k] %= mod; }} long[][] dp = new long[(n + 1)][(n + 1)]; for ( int j = 1;(j <= n);j++) {dp[j][0] = twopowers[(j - 1)]; }for ( int k = 0;(k < n);k++) {for ( int j = 1;(j <= n);j++) {if ( (k > j)) continue; for ( int add = 2;((j + add) <= n);add++) { long prod = (dp[j][k] * choose[(((j - k) + add) - 1)][(add - 1)]); prod %= mod; prod *= twopowers[(add - 2)]; dp[(j + add)][(k + 1)] += prod; dp[(j + add)][(k + 1)] %= mod; }}} long ans = 0; for ( int s = 0;(s <= n);s++) {ans += dp[n][s]; ans %= mod; }out.println(ans); out.close(); } public static long inv( long n){ return power(n,(mod - 2));} public static void sort( int[] array){ ArrayList<Integer> copy = new ArrayList<>(); for ( int i :array) copy.add(i); Collections.sort(copy); for ( int i = 0;(i < array.length);i++) array[i] = copy.get(i); } static long power( long x, long y){ if ( (y == 0)) return 1; if ( ((y % 2) == 1)) return ((x * power(x,(y - 1))) % mod); return (power(((x * x) % mod),(y / 2)) % mod);} public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} double nextDouble(){ return Double.parseDouble(next());} } }
3	public final class py_indent{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc = new FastScanner(br); static PrintWriter out = new PrintWriter(System.out); static Random rnd = new Random(); static int maxn = (int)(5e3 + 5); static long mod = (long)(1e9 + 7); static int add( long a, long b){ long ret = (a + b); if ( (ret >= mod)) {ret %= mod; } return (int)ret;} public static void main( String[] args)throws Exception { int n = sc.nextInt();  char[] a = new char[(n + 1)]; a[0] = 's'; for ( int i = 1;(i <= n);i++) {a[i] = sc.next().charAt(0); } int[][] dp = new int[(n + 1)][maxn],sum = new int[(n + 1)][maxn]; dp[0][0] = 1; sum[0][0] = 1; for ( int i = 1;(i < maxn);i++) {sum[0][i] = add(sum[0][i],sum[0][(i - 1)]); }for ( int i = 1;(i <= n);i++) {if ( (a[i] == 'f')) {continue;} int curr = 0,idx = 0; for ( int j = (i - 1);(j >= 0);j--) {if ( (a[j] == 's')) {idx = j; break;} else {curr++; }}for ( int j = 0;(j < maxn);j++) { int up = Math.max(0,(j - curr));  long now = (sum[idx][(maxn - 1)] - ((up == 0)?0:sum[idx][(up - 1)])); now = add(now,mod); dp[i][j] = add(dp[i][j],now); }sum[i][0] = dp[i][0]; for ( int j = 1;(j < maxn);j++) {sum[i][j] = add(dp[i][j],sum[i][(j - 1)]); }}out.println(dp[n][0]); out.close(); } } class FastScanner{ BufferedReader in ; StringTokenizer st ; public FastScanner( BufferedReader in){ this.in = in; } public String nextToken()throws Exception { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} public String next()throws Exception { return nextToken().toString();} public int nextInt()throws Exception { return Integer.parseInt(nextToken());} }
2	public class Cf2{ static boolean ok( long n, long k, long eatten){ long moves = (n - eatten);  long ans = ((moves * (moves + 1)) / 2); ans -= eatten; return (ans <= k);} public static void main( String[] args){ FastReader in = new FastReader();  long n = in.nextInt();  long k = in.nextInt();  long left = 0,right = n; while((left <= right)){ long middle = ((left + right) / 2); if ( ok(n,k,middle)) right = (middle - 1); else left = (middle + 1); }System.out.println(left); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int k = in.nextInt();  int[] a = in.nextIntArray(n); if ( (k == 1)) {out.println("1 1"); return ;} int left = -1,right = -1;  Counter<Integer> counter = new Counter<Integer>(); while(true){right++; if ( (right == n)) {out.println("-1 -1"); return ;} counter.add(a[right]); if ( (counter.size() >= k)) break; }while(true){left++; if ( (counter.get(a[left]) == 1)) break; counter.add(a[left],-1); }out.printLine((left + 1),(right + 1)); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[(1 << 16)]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c & 15); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int[] nextIntArray( int count){ int[] result = new int[count]; for ( int i = 0;(i < count);i++) {result[i] = nextInt(); }return result;} } class OutputWriter{ private PrintWriter writer ; public OutputWriter( OutputStream stream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object obj){ writer.print(obj); } public void println(){ writer.println(); } public void println( String x){ writer.println(x); } public void print( char c){ writer.print(c); } public void close(){ writer.close(); } public void printItems( Object... items){ for ( int i = 0;(i < items.length);i++) {if ( (i != 0)) {print(' '); } print(items[i]); }} public void printLine( Object... items){ printItems(items); println(); } }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int k = in.nextInt();  Integer[] a = new Integer[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); } Set<Integer> vis = new TreeSet<Integer>(); Arrays.sort(a); int ans = 0; for ( int i = 0;(i < n);i++) {if ( (((a[i] % k) == 0) && vis.contains((a[i] / k)))) {++ans; vis.add(a[i]); } }out.println(ans); } } class Scanner{ BufferedReader in ; StringTokenizer tok ; public Scanner( InputStream in){ this.in = new BufferedReader(new InputStreamReader(in)); tok = new StringTokenizer(""); } public String nextToken(){ if ( !tok.hasMoreTokens()) {try{ String newLine = in.readLine(); if ( (newLine == null)) throw (new InputMismatchException()); tok = new StringTokenizer(newLine); }catch (IOException e){ throw (new InputMismatchException());} return nextToken();} return tok.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} }
3	public class Main{ public void solve()throws IOException { int n = nextInt(),r = nextInt();  int x[] = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = nextInt(); } double res[] = new double[n]; res[0] = r; for ( int i = 1;(i < n);i++) { double max = r; for ( int j = 0;(j < i);j++) { int d = Math.abs((x[i] - x[j])); if ( (d <= (2 * r))) { double yy = Math.sqrt((((4 * r) * r) - (d * d))); max = Math.max(max,(yy + res[j])); } }res[i] = max; }for ( int i = 0;(i < n);i++) {out.print((res[i] + " ")); }} BufferedReader br ; StringTokenizer sc ; PrintWriter out ; public static void main( String[] args)throws IOException { Locale.setDefault(Locale.US); new Main().run(); } void run()throws IOException { try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } String nextToken()throws IOException { while(((sc == null) || !sc.hasMoreTokens())){try{sc = new StringTokenizer(br.readLine()); }catch (Exception e){ return null;} }return sc.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
0	public class LearnMath{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int N = scan.nextInt(); scan.close(); if ( ((N % 2) == 0)) {System.out.println(((4 + " ") + (N - 4))); } else {if ( (N > 18)) {System.out.println(((9 + " ") + (N - 9))); } else {System.out.println((((N - 9) + " ") + 9)); }}} }
2	public class C{ FastScanner in ; PrintWriter out ; boolean systemIO = true; public static void quickSort( long[] a, int from, int to){ if ( ((to - from) <= 1)) {return ;} int i = from;  int j = (to - 1);  long x = a[(from + new Random().nextInt((to - from)))]; while((i <= j)){while((a[i] < x)){i++; }while((a[j] > x)){j--; }if ( (i <= j)) { long t = a[i]; a[i] = a[j]; a[j] = t; i++; j--; } }quickSort(a,from,(j + 1)); quickSort(a,(j + 1),to); } public static long check( long x){ long sum = 0;  long k = x; while((x > 0)){sum += (x % 10); x /= 10; }return (k - sum);} public void solve()throws IOException { long n = in.nextLong();  long s = in.nextLong();  long ans = 0; for ( long i = s;(i <= Math.min(n,(s + 10000L)));i++) {if ( (check(i) >= s)) {ans++; } }ans += (n - Math.min(n,(s + 10000L))); System.out.println(ans); } public void run()throws IOException { if ( systemIO) {in = new FastScanner(System.in); out = new PrintWriter(System.out); } else {in = new FastScanner(new File("input.txt")); out = new PrintWriter(new File("output.txt")); }solve(); out.close(); } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } FastScanner( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} } public static void main( String[] arg)throws IOException { new C().run(); } }
0	public class BetaRound72_Div2_A implements Runnable{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws IOException { if ( ONLINE_JUDGE) {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); }} String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} public static void main( String[] args){ new Thread(new BetaRound72_Div2_A()).start(); } void solve()throws IOException { int n = readInt();  int ans = ((n * 3) / 2); out.print(ans); } }
6	public class Cycles{ public static FastInputStream fis ; public static void main( String[] args)throws IOException { fis = new FastInputStream(System.in); System.out.println(solve(fis.nextInt(),fis.nextInt())); fis.close(); } public static long solve( int n, int m)throws IOException { boolean[][] graph = new boolean[n][];  long[][] state = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) graph[i] = new boolean[(n - i)]; for ( int i = 0;(i < m);i++) { int a = (fis.nextInt() - 1);  int b = (fis.nextInt() - 1); setConnected(graph,a,b); state[((1 << a) | (1 << b))][((a > b)?a:b)] = 1; } long res = 0; for ( int i = 2;(i < n);i++) { int baseCombination = ((2 << i) - 1); while((baseCombination < (1 << n))){ int min = getFirstOne(baseCombination);  int bits = baseCombination; while((bits != 0)){ int firstBit = (bits & bits);  int firstBitPos = getFirstOne(firstBit); bits &= (bits - 1); if ( (firstBitPos == min)) continue; int leftOverBits = (baseCombination - firstBit);  int nextBits = leftOverBits; while((nextBits != 0)){ int nextBit = (nextBits & nextBits);  int nextBitPos = getFirstOne(nextBit); nextBits &= (nextBits - 1); if ( (nextBitPos == min)) continue; if ( !isConnected(graph,firstBitPos,nextBitPos)) continue; state[baseCombination][firstBitPos] += state[leftOverBits][nextBitPos]; }if ( isConnected(graph,firstBitPos,min)) res += state[baseCombination][firstBitPos]; }baseCombination = nextCombination(baseCombination); }}return (res >> 1);} public static boolean isConnected( boolean[][] graph, int a, int b){ if ( ((b < a) || (graph[a].length <= (b - a)))) return graph[b][(a - b)]; return graph[a][(b - a)];} public static void setConnected( boolean[][] graph, int a, int b){ if ( ((b < a) || (graph[a].length <= (b - a)))) graph[b][(a - b)] = true; else graph[a][(b - a)] = true; } public static int nextCombination( int x){ int smallest = (x & -x);  int ripple = (x + smallest);  int ones = (((x ^ ripple) >> 2) / smallest); return (ripple | ones);} public static int getFirstOne( int bitmask){ if ( (bitmask == 0)) return -1; int first = 0; while(((bitmask & 1) != 1)){first++; bitmask = (bitmask >> 1); }return first;} public static class FastInputStream extends InputStream{ private InputStream in ; private byte[] buffer = new byte[512]; private int loaded = 0; private int pointer = 0; public FastInputStream( InputStream in){ this.in = in; } @Override public int read()throws IOException { if ( hasNext()) return buffer[pointer++]; else return -1;} public void skipWhitespace()throws IOException { while(hasNext()){ char c = (char)buffer[pointer]; if ( ((((c == ' ') || (c == '\t')) || (c == '\n')) || (c == '\r'))) pointer++; else return ;}} public Integer nextInt()throws IOException { skipWhitespace(); if ( !hasNext()) return null; byte multiplier = 1;  int number = 0; if ( (buffer[pointer] == '-')) {multiplier = -1; pointer++; } while(hasNext()){ char c = (char)buffer[pointer]; if ( ((c >= '0') && (c <= '9'))) {number = ((((number << 3) + (number << 1)) + c) - '0'); pointer++; } else break;}return (number * multiplier);} public void close()throws IOException { in.close(); } public boolean hasNext()throws IOException { while((pointer == loaded)){loaded = in.read(buffer); pointer = 0; if ( (loaded == -1)) return false; }return (loaded != -1);} } }
0	public class MainY{ static double eps = (double)1e-6; static long mod = ((int)1e9 + 7); static boolean f = true; public static void main( String[] args){ InputReader in = new InputReader(System.in);  OutputStream outputStream = System.out;  PrintWriter out = new PrintWriter(outputStream);  long n = in.nextLong(); if ( (n == 1)) {System.out.println("5"); } else {System.out.println("25"); }out.close(); } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream inputstream){ reader = new BufferedReader(new InputStreamReader(inputstream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} } }
0	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in); while(input.hasNext()){ long n = input.nextLong(); if ( ((n == 1) || (n == 2))) System.out.println(n); else if ( ((n % 2) == 1)) System.out.println(((n * (n - 1)) * (n - 2))); else if ( ((n % 3) != 0)) System.out.println(Math.max(((n * (n - 1)) * (n - 3)),(((n * (n - 1)) * (n - 2)) / 2))); else System.out.println(Math.max(Math.max((((n * (n - 1)) * (n - 3)) / 3),(((n * (n - 1)) * (n - 2)) / 2)),Math.max((((n - 2) * (n - 1)) * (n - 3)),(((n * (n - 2)) * (n - 3)) / 6)))); }} }
2	public class b{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = (sc.nextLong() - 1),k = (sc.nextLong() - 1);  int a = 0; if ( ((((k + 1) * k) / 2) < n)) {System.out.println(-1); return ;} while(((n > 0) && (k > 0))){ long min = go(n,k); a += ((k - min) + 1); n -= (((k + min) * ((k - min) + 1)) / 2); k = Math.min((min - 1),n); }if ( (n == 0)) System.out.println(a); else System.out.println(-1); } static long go( long n, long k){ long low = 1,high = k; while(((low + 1) < high)){ long mid = ((low + high) / 2); if ( ((((k + mid) * ((k - mid) + 1)) / 2) <= n)) {high = mid; } else low = mid; }return high;} }
3	public class wef{ public static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception r){ r.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } static ArrayList<String> list1 = new ArrayList<String>(); static void combine( String instr, StringBuffer outstr, int index, int k){ if ( (outstr.length() == k)) {list1.add(outstr.toString()); return ;} if ( (outstr.toString().length() == 0)) outstr.append(instr.charAt(index)); for ( int i = 0;(i < instr.length());i++) {outstr.append(instr.charAt(i)); combine(instr,outstr,(i + 1),k); outstr.deleteCharAt((outstr.length() - 1)); }index++; } static ArrayList<ArrayList<Integer>> l = new ArrayList<>(); static void comb( int n, int k, int ind, ArrayList<Integer> list){ if ( (k == 0)) {l.add(new ArrayList<>(list)); return ;} for ( int i = ind;(i <= n);i++) {list.add(i); comb(n,(k - 1),(ind + 1),list); list.remove((list.size() - 1)); }} static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main( String[] args){ FastReader in = new FastReader();  HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();  ArrayList<Integer> list = new ArrayList<Integer>();  TreeSet<Integer> set = new TreeSet<Integer>();  int n = in.nextInt(); for ( int i = 0;(i < n);i++) set.add(in.nextInt()); int ans = 0; while(!set.isEmpty()){ int f = set.first();  int s = f; while((!set.isEmpty() && (s <= set.last()))){if ( set.contains(s)) set.remove(new Integer(s)); s += f; }ans++; }out.println(ans); out.close(); } }
3	public class Paint{ public static void main( String[] srgs){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  TreeSet<Integer> ts = new TreeSet<>(); for ( int i = 0;(i < n);++i) {ts.add(sc.nextInt()); } int x = 0;  int a[] = new int[ts.size()]; for ( int y :ts) {a[x++] = y; }for ( int i = 0;(i < (ts.size() - 1));++i) {for ( int j = (i + 1);(j < ts.size());++j) {if ( (((a[i] != -1) && (a[j] != -1)) && ((a[j] % a[i]) == 0))) {a[j] = -1; } }} int c = 0; for ( int z :a) {if ( (z != -1)) ++c; }System.out.print(c); } }
5	public class A{ private void solve()throws IOException { int n = nextInt();  int k = nextInt();  Point[] p = new Point[n]; for ( int i = 0;(i < n);i++) p[i] = new Point(nextInt(),nextInt()); Arrays.sort(p,new Comparator<Point>(){}); Point cur = p[(k - 1)];  int res = 0; for ( int i = 0;(i < p.length);i++) {if ( ((p[i].x == cur.x) && (p[i].y == cur.y))) res++; }pl(res); } public static void main( String[] args){ new A().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} void p( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.flush(); writer.print(objects[i]); writer.flush(); }} void pl( Object... objects){ p(objects); writer.flush(); writer.println(); writer.flush(); } int cc ; }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputScanner in = new InputScanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, InputScanner in, PrintWriter out){ int[] arr = in.readIntArr();  int n = arr[0];  int r = arr[1];  int[] x = in.readIntArr(); for ( int i = 0;(i < n);i++) {x[i] += 999; } double[] h = new double[n];  int dsk[] = new int[3000]; Arrays.fill(dsk,-1); for ( int i = 0;(i < r);i++) {dsk[(x[0] + i)] = 0; dsk[((x[0] - i) - 1)] = 0; } int rs = ((4 * r) * r); h[0] = r; for ( int i = 1;(i < n);i++) { double ch = r; for ( int j = 0;(j < r);j++) {if ( (dsk[(x[i] + j)] != -1)) { int ind = dsk[(x[i] + j)];  int diff = (x[ind] - x[i]);  int diffs = (diff * diff);  int hs = (rs - diffs); ch = Math.max(ch,(h[ind] + Math.sqrt(hs))); } if ( (dsk[((x[i] - j) - 1)] != -1)) { int ind = dsk[((x[i] - j) - 1)];  int diff = (x[ind] - x[i]);  int diffs = (diff * diff);  int hs = (rs - diffs); ch = Math.max(ch,(h[ind] + Math.sqrt(hs))); } }if ( ((x[i] + r) < 3000)) {if ( (dsk[(x[i] + r)] != -1)) {ch = Math.max(ch,h[dsk[(x[i] + r)]]); } } if ( (((x[i] - r) - 1) > 0)) {if ( (dsk[((x[i] - r) - 1)] != -1)) {ch = Math.max(ch,h[dsk[((x[i] - r) - 1)]]); } } for ( int j = 0;(j < r);j++) {dsk[(x[i] + j)] = i; dsk[((x[i] - j) - 1)] = i; }h[i] = ch; }for ( int i = 0;(i < n);i++) {out.print((h[i] + " ")); }out.println(); } } static class InputScanner{ BufferedReader br ; public InputScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } String readLine(){ String line = null; try{line = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return line;} public String[] readStringArr(){ return readLine().split(" ");} public int[] readIntArr(){ String[] str = readStringArr();  int arr[] = new int[str.length]; for ( int i = 0;(i < arr.length);i++) arr[i] = Integer.parseInt(str[i]); return arr;} } }
4	public class EdE{ static long[] mods = {1000000007,998244353,1000000009}; static long mod = mods[0]; public static MyScanner sc ; public static PrintWriter out ; static long[][][] paths ; static long[] powers501 ; public static void main( String[] havish)throws Exception { sc = new MyScanner(); out = new PrintWriter(System.out); int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt(); paths = new long[(n + 1)][(m + 1)][4]; powers501 = new long[5]; powers501[0] = 1; for ( int j = 1;(j < 5);j++) {powers501[j] = (501L * powers501[(j - 1)]); } long[][][] dp = new long[(n + 1)][(m + 1)][((k / 2) + 2)]; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= (m - 1));j++) { int val = sc.nextInt(); paths[i][j][3] = val; paths[i][(j + 1)][2] = val; }}for ( int i = 1;(i <= (n - 1));i++) {for ( int j = 1;(j <= m);j++) { int val = sc.nextInt(); paths[i][j][1] = val; paths[(i + 1)][j][0] = val; }}for ( int j = 1;(j <= n);j++) {for ( int i = 1;(i <= m);i++) {Arrays.fill(dp[j][i],Integer.MAX_VALUE); dp[j][i][0] = 0; }}for ( int steps = 1;(steps < ((k / 2) + 2));steps++) {for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) {if ( ((i - 1) > 0)) {dp[i][j][steps] = Math.min((dp[(i - 1)][j][(steps - 1)] + getVal(i,j,(i - 1),j)),dp[i][j][steps]); } if ( ((j - 1) > 0)) {dp[i][j][steps] = Math.min((dp[i][(j - 1)][(steps - 1)] + getVal(i,j,i,(j - 1))),dp[i][j][steps]); } if ( ((i + 1) <= n)) {dp[i][j][steps] = Math.min((dp[(i + 1)][j][(steps - 1)] + getVal(i,j,(i + 1),j)),dp[i][j][steps]); } if ( ((j + 1) <= m)) {dp[i][j][steps] = Math.min((dp[i][(j + 1)][(steps - 1)] + getVal(i,j,i,(j + 1))),dp[i][j][steps]); } }}}if ( ((k % 2) == 1)) {for ( int j = 1;(j <= n);j++) {for ( int s = 1;(s <= m);s++) {out.print((-1 + " ")); }out.println(); }} else {for ( int j = 1;(j <= n);j++) {for ( int s = 1;(s <= m);s++) {out.print(((dp[j][s][(k / 2)] * 2L) + " ")); }out.println(); }}out.close(); } public static long getVal( int x1, int y1, int x2, int y2){ if ( (x2 == (x1 + 1))) return paths[x1][y1][1]; else if ( (x1 == (x2 + 1))) return paths[x1][y1][0]; else if ( (y2 == (y1 + 1))) return paths[x1][y1][3]; else return paths[x1][y1][2];} public static void sort( int[] array){ ArrayList<Integer> copy = new ArrayList<>(); for ( int i :array) copy.add(i); Collections.sort(copy); for ( int i = 0;(i < array.length);i++) array[i] = copy.get(i); } static long power( long x, long y){ if ( (y == 0)) return 1; if ( ((y % 2) == 1)) return ((x * power(x,(y - 1))) % mod); return (power(((x * x) % mod),(y / 2)) % mod);} public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} double nextDouble(){ return Double.parseDouble(next());} } }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(); out.printf(Locale.US,"%d",((n / 2) * 3)); out.close(); } }
1	public class Solution implements Runnable{ private static BufferedReader br = null; private static PrintWriter out = null; private static StringTokenizer stk = null; public static void main( String[] args){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); new Thread(new Solution()).start(); } private void loadLine(){ try{stk = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } private Integer nextInt(){ while(((stk == null) || !stk.hasMoreTokens()))loadLine(); return Integer.parseInt(stk.nextToken());} }
0	public class Main{ public static void main( String[] args)throws IOException { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream); try(PrintWriter out=new PrintWriter(outputStream)){ TaskB solver = new TaskB(); solver.solve(1,in,out); }} } class TaskB{ public void solve( int testNumber, InputReader in, PrintWriter out)throws IOException { String n = in.next(); out.println(25); } } class InputReader{ private final BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String nextLine(){ try{return reader.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(nextLine()); }return tokenizer.nextToken();} }
1	public class Main{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(in.readLine());  String in1 = in.readLine();  String store = "";  HashSet<Character> contain = new HashSet<Character>(); for ( int i = 0;(i < n);i++) {if ( !contain.contains(in1.charAt(i))) {store += in1.charAt(i); contain.add(in1.charAt(i)); } } int[] index = new int[store.length()]; for ( int i = 0;(i < store.length());i++) {index[i] = -1; } HashSet<Integer> index2 = new HashSet<Integer>();  ArrayList<Integer> index3 = new ArrayList<Integer>();  int min = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int index4 = store.indexOf(in1.charAt(i)); if ( (index[index4] == -1)) {index[index4] = i; index2.add(i); index3.add(i); } else {index2.remove(index[index4]); index2.add(i); index3.add(i); index[index4] = i; }if ( (index2.size() == index.length)) {while(!index2.contains(index3.get(0))){index3.remove(0); }min = Math.min(min,((i - index3.get(0)) + 1)); } }System.out.println(min); } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskF solver = new TaskF(); solver.solve(1,in,out); out.close(); } static class TaskF{ final int INF = ((int)1e9 + 5); int n ; int m ; int[][][] dp ; int[][] diff ; int[][] diffStartLast ; int two( int x){ return (1 << x);} boolean contain( int mask, int x){ return ((mask & two(x)) > 0);} int rec( int start, int pre, int mask){ if ( (mask == (two(n) - 1))) return INF; int res = dp[start][pre][mask]; if ( (res != -1)) return res; res = 0; for ( int i = 0;(i < n);i++) if ( (contain(mask,i) == false)) { int diffPre = ((mask == 0)?INF:diff[pre][i]);  int diffLast = (((mask | two(i)) == (two(n) - 1))?diffStartLast[start][i]:INF); res = Math.max(res,Math.min(rec(start,i,(mask | two(i))),Math.min(diffLast,diffPre))); } dp[start][pre][mask] = res; return res;} public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); int[][] grid = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) grid[i][j] = in.nextInt(); if ( (n == 1)) { int res = INF; for ( int i = 0;((i + 1) < m);i++) {res = Math.min(res,Math.abs((grid[0][i] - grid[0][(i + 1)]))); }out.println(res); return ;} diff = new int[n][n]; diffStartLast = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {diff[i][j] = INF; diffStartLast[i][j] = INF; for ( int k = 0;(k < m);k++) {diff[i][j] = Math.min(diff[i][j],Math.abs((grid[i][k] - grid[j][k]))); if ( ((k + 1) < m)) {diffStartLast[i][j] = Math.min(diffStartLast[i][j],Math.abs((grid[i][(k + 1)] - grid[j][k]))); } }}}dp = new int[n][n][two(n)]; for ( int[][] aux :dp) for ( int[] aux2 :aux) Arrays.fill(aux2,-1); int ans = 0; for ( int start = 0;(start < n);start++) {ans = Math.max(ans,rec(start,start,two(start))); }out.println(ans); } } static class InputReader{ private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputStream stream ; public InputReader( InputStream stream){ this.stream = stream; } private boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isWhitespace(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isWhitespace(c));return (res * sgn);} } }
5	public class SolA{ static Scanner in ; static PrintWriter out ; public static void main( String[] args){ in = new Scanner(System.in); out = new PrintWriter(System.out); new SolA().run(); in.close(); out.close(); } private void run(){ int n = in.nextInt();  int[] a = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); sum += a[i]; }Arrays.sort(a); int cs = 0;  int kol = 0; for ( int i = (n - 1);(i >= 0);i--) {cs += a[i]; kol++; if ( (cs > (sum - cs))) {break;} }out.print(kol); } }
2	public class D{ final int MOD = ((int)1e9 + 7); final double eps = 1e-12; final int INF = (int)1e9; public D(){ long L = sc.nextLong();  long R = sc.nextLong();  int Z = (64 - Long.numberOfLeadingZeros((L ^ R)));  long res = ((1L << Z) - 1); exit(res); } static MyScanner sc = new MyScanner(); static class MyScanner{ public String next(){ newLine(); return line[index++];} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public double nextDouble(){ return Double.parseDouble(next());} public String[] nextStrings(){ line = null; return readLine().split(" ");} public Integer[] nextInts(){ String[] L = nextStrings();  Integer[] res = new Integer[L.length]; for ( int i = 0;(i < L.length);++i) res[i] = Integer.parseInt(L[i]); return res;} public Long[] nextLongs(){ String[] L = nextStrings();  Long[] res = new Long[L.length]; for ( int i = 0;(i < L.length);++i) res[i] = Long.parseLong(L[i]); return res;} public Double[] nextDoubles(){ String[] L = nextStrings();  Double[] res = new Double[L.length]; for ( int i = 0;(i < L.length);++i) res[i] = Double.parseDouble(L[i]); return res;} public String[] next( int N){ String[] res = new String[N]; for ( int i = 0;(i < N);++i) res[i] = sc.next(); return res;} public Integer[] nextInt( int N){ Integer[] res = new Integer[N]; for ( int i = 0;(i < N);++i) res[i] = sc.nextInt(); return res;} public Long[] nextLong( int N){ Long[] res = new Long[N]; for ( int i = 0;(i < N);++i) res[i] = sc.nextLong(); return res;} public Double[] nextDouble( int N){ Double[] res = new Double[N]; for ( int i = 0;(i < N);++i) res[i] = sc.nextDouble(); return res;} public String[][] nextStrings( int N){ String[][] res = new String[N][]; for ( int i = 0;(i < N);++i) res[i] = sc.nextStrings(); return res;} public Integer[][] nextInts( int N){ Integer[][] res = new Integer[N][]; for ( int i = 0;(i < N);++i) res[i] = sc.nextInts(); return res;} public Long[][] nextLongs( int N){ Long[][] res = new Long[N][]; for ( int i = 0;(i < N);++i) res[i] = sc.nextLongs(); return res;} public Double[][] nextDoubles( int N){ Double[][] res = new Double[N][]; for ( int i = 0;(i < N);++i) res[i] = sc.nextDoubles(); return res;} private boolean eol(){ return (index == line.length);} private String readLine(){ try{return r.readLine(); }catch (Exception e){ throw (new Error(e));} } private final BufferedReader r ; MyScanner(){ this(new BufferedReader(new InputStreamReader(System.in))); } MyScanner( BufferedReader r){ try{this.r = r; while(!r.ready())Thread.sleep(1); start(); }catch (Exception e){ throw (new Error(e));} } private String[] line ; private int index ; private void newLine(){ if ( ((line == null) || eol())) {line = readLine().split(" "); index = 0; } } } static void print( Object o, Object... a){ printDelim(" ",o,a); } static void printDelim( String delim, Object o, Object... a){ pw.println(build(delim,o,a)); } static void exit( Object o, Object... a){ print(o,a); exit(); } static void exit(){ pw.close(); System.out.flush(); System.err.println("------------------"); System.err.println(("Time: " + ((millis() - t) / 1000.0))); System.exit(0); } static String build( String delim, Object o, Object... a){ StringBuilder b = new StringBuilder(); append(b,o,delim); for ( Object p :a) append(b,p,delim); return b.toString().trim();} static void append( StringBuilder b, Object o, String delim){ if ( o.getClass().isArray()) { int L = Array.getLength(o); for ( int i = 0;(i < L);++i) append(b,Array.get(o,i),delim); } else if ( (o instanceof Iterable<?>)) {for ( Object p :(Iterable<?>)o) append(b,p,delim); } else b.append(delim).append(o); } public static void main( String[] args){ new D(); exit(); } static void start(){ t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t ; static long millis(){ return System.currentTimeMillis();} }
1	public class C364{ static HashMap<Character,Integer> freq ; static int unique = 0; public static void main( String[] args)throws Exception { FastScanner in = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt();  char[] s = in.next().toCharArray(); freq = new HashMap<Character,Integer>(); for ( int i = 0;(i < n);i++) { char c = s[i]; if ( !freq.containsKey(c)) freq.put(c,0); } int k = freq.size();  int l = 0,r = 0,best = n; inc(s[0]); while((r < n)){if ( (unique == k)) {best = Math.min(best,((r + 1) - l)); dec(s[l++]); } else {if ( (++r == n)) break; inc(s[r]); }}pw.println(best); pw.flush(); pw.close(); } static void inc( char c){ int cur = freq.get(c); if ( (cur == 0)) unique++; freq.put(c,(cur + 1)); } static void dec( char c){ int cur = freq.get(c); if ( (cur == 1)) unique--; freq.put(c,(cur - 1)); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); } String next()throws Exception { while(!st.hasMoreTokens())st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(next());} } }
1	public class Main{ static int MAX = 1000; static BitSet P = new BitSet((MAX + 1)); public static boolean Noldbach( int n){ n--; int j ; for ( int i = 2;(i <= n);i++) {if ( !P.get(i)) {j = (i + 1); while(P.get(j))j++; if ( ((i + j) == n)) {if ( !P.get(((i + j) + 1))) {return true;} } } }return false;} public static void main( String[] args){ Scanner lee = new Scanner(System.in); for ( int i = 2;((i * i) <= MAX);i++) {if ( !P.get(i)) {for ( int j = (i + i);(j <= MAX);j += i) P.set(j); } } int n ,k ,c ; n = lee.nextInt(); k = lee.nextInt(); c = 0; for ( int i = 2;(i <= n);i++) {if ( Noldbach(i)) c++; if ( (c == k)) break; }if ( (c == k)) System.out.println("YES"); else System.out.println("NO"); } }
4	public class P23A{ public P23A(){ Scanner sc = new Scanner(System.in);  String str = sc.next(); sc.close(); String maxStr = ""; for ( int i = 0;(i < (str.length() - 1));i++) {for ( int j = (i + 1);(j < str.length());j++) { String pattern = str.substring(i,j); if ( (str.substring((i + 1)).contains(pattern) && (pattern.length() > maxStr.length()))) {maxStr = pattern; } }}System.out.println(maxStr.length()); } public static void main( String[] args){ new P23A(); } }
6	public class ProblemB{ public static int _gnum ; public static int _cnum ; public static int _needs ; public static int _level ; public static double _maxans = 0; public static double votedfs( int[][] grl, int g, int votes){ if ( (votes >= _needs)) {return 1.0d;} if ( (g >= _gnum)) {return 0.0d;} double agrees = ((double)grl[g][1] / 100); return ((agrees * votedfs(grl,(g + 1),(votes + 1))) + ((1.0d - agrees) * votedfs(grl,(g + 1),votes)));} public static double battledfs( int[][] grl, int g, int votes, int levels){ if ( (votes >= _needs)) {return 0.0d;} if ( (g >= _gnum)) {return ((double)_level / (_level + levels));} double agrees = ((double)grl[g][1] / 100); return ((agrees * battledfs(grl,(g + 1),(votes + 1),levels)) + ((1.0d - agrees) * battledfs(grl,(g + 1),votes,(levels + grl[g][0]))));} public static void candydfs( int[][] grl, int g, int n){ if ( (g >= _gnum)) { double na = (votedfs(grl,0,0) + battledfs(grl,0,0,0)); _maxans = Math.max(_maxans,na); return ;} int rem = grl[g][1]; candydfs(grl,(g + 1),n); for ( int i = 1;(i <= n);i++) {if ( (grl[g][1] < 100)) {grl[g][1] += 10; candydfs(grl,(g + 1),(n - i)); } }grl[g][1] = rem; } public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String line = br.readLine();  String[] d = line.split(" ");  int gnum = Integer.valueOf(d[0]);  int cnum = Integer.valueOf(d[1]);  int level = Integer.valueOf(d[2]); _gnum = gnum; _cnum = cnum; _needs = ((gnum + 1) / 2); if ( ((gnum % 2) == 0)) {_needs += 1; } _level = level; int[][] grl = new int[gnum][2]; for ( int g = 0;(g < gnum);g++) {line = br.readLine(); String[] gg = line.split(" "); grl[g][0] = Integer.valueOf(gg[0]); grl[g][1] = Integer.valueOf(gg[1]); }for ( int a = 0;(a < gnum);a++) {for ( int b = 0;(b < (gnum - 1));b++) {if ( (grl[b][1] < grl[(b + 1)][1])) { int tmp = grl[b][0]; grl[b][0] = grl[(b + 1)][0]; grl[(b + 1)][0] = tmp; tmp = grl[b][1]; grl[b][1] = grl[(b + 1)][1]; grl[(b + 1)][1] = tmp; } }} int ag = 0;  int xnum = cnum; for ( int g = 0;(g < gnum);g++) { int needs = ((100 - grl[g][1]) / 10);  int roy = 0; if ( (needs <= xnum)) {xnum -= needs; roy = 100; } else {roy = (grl[g][1] + (xnum * 10)); xnum = 0; }if ( (roy >= 100)) {ag++; } }if ( (ag >= _needs)) {System.out.println(1.0); return ;} candydfs(grl,0,_cnum); System.out.println(_maxans); br.close(); } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ int[][] dr = new int[][]{{0,0,0,-1},{0,0,-1,0},{0,1,0,0},{1,0,0,0}}; int[][] dd = new int[][]{{1,3},{0,2},{1,3},{0,2}}; PrintWriter out ; InputReader in ; int[] re1 ; int[] re2 ; int N ; public void solve( int testNumber, InputReader in, PrintWriter out){ N = in.nextInt(); int r[] = new int[]{1,1,N,N}; this.out = out; this.in = in; re1 = new int[]{1,1,1,1}; re2 = new int[]{2,1,2,1}; int fr[] = moveSide(r,dr[2],dd[2]);  int sr[] = subtract(r,fr); if ( !validSeparation(sr)) {fr = moveSide(r,dr[1],dd[1]); sr = subtract(r,fr); } fr = boundary(fr); sr = boundary(sr); out.println(String.format("! %d %d %d %d %d %d %d %d",fr[0],fr[1],fr[2],fr[3],sr[0],sr[1],sr[2],sr[3])); } private boolean validSeparation( int[] sr){ if ( !validRectangle(sr)) return false; out.println(String.format("? %d %d %d %d",sr[0],sr[1],sr[2],sr[3])); out.flush(); return (in.nextInt() == 1);} private boolean validRectangle( int[] sr){ for ( int i = 0;(i < 4);i++) {if ( ((sr[i] < 1) || (sr[i] > N))) return false; }return true;} private int[] boundary( int[] r){ for ( int d = 0;(d < 4);d++) {r = moveSide(r,dr[d],dd[d]); }return r;} private int[] subtract(final int[] r,final int[] fr){ if ( (r[1] == fr[1])) {return new int[]{(fr[2] + 1),r[1],r[2],r[3]};} return new int[]{r[0],r[1],r[2],(fr[1] - 1)};} private int[] moveSide(final int[] rect,final int[] factors,final int[] widths){ int width = Math.abs((rect[widths[0]] - rect[widths[1]]));  int lo = -1,hi = (width + 1); while(((lo + 1) < hi)){ int m = (lo + ((hi - lo) / 2));  int qr[] = new int[4]; for ( int d = 0;(d < 4);d++) qr[d] = (rect[d] + (factors[d] * m)); int ans = query(qr); if ( (ans != 0)) {lo = m; } else {hi = m; }} int ans_rect[] = new int[4]; for ( int d = 0;(d < 4);d++) ans_rect[d] = (rect[d] + (factors[d] * lo)); return ans_rect;} private int query(final int[] qr){ int ans = 0; out.println(String.format("? %d %d %d %d",qr[0],qr[1],qr[2],qr[3])); out.flush(); ans = in.nextInt(); return ans;} } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
3	public class Main{ public static void main( String[] args){ FastReader input = new FastReader();  PrintWriter out = new PrintWriter(System.out);  int T = 1; while((T-- > 0)){ int n = input.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = input.nextInt(); } HashMap<Integer,ArrayList<Pair>> map = new HashMap<>(); for ( int i = 0;(i < n);i++) { int sum = 0; for ( int j = i;(j < n);j++) {sum += a[j]; if ( map.containsKey(sum)) {map.get(sum).add(new Pair(i,j)); } else {map.put(sum,new ArrayList<>()); map.get(sum).add(new Pair(i,j)); }}} int max = Integer.MIN_VALUE;  Iterator it = map.entrySet().iterator();  ArrayList<Pair> setBlocks = new ArrayList<>(); while(it.hasNext()){ Map.Entry e = (Map.Entry)it.next();  ArrayList<Pair> list = (ArrayList)e.getValue(); Collections.sort(list,new Comparator<Pair>(){}); Pair1 sufMin[] = new Pair1[list.size()];  TreeSet<Pair> set = new TreeSet<>(new Comparator<Pair>(){});  int min = Integer.MAX_VALUE;  int index = -1; for ( int j = (list.size() - 1);(j >= 0);j--) {if ( (min >= list.get(j).r)) {min = list.get(j).r; index = j; } sufMin[j] = new Pair1(min,index); set.add(new Pair(list.get(j).l,j)); } int count = 0;  int j = 0;  ArrayList<Pair> blocks = new ArrayList<>(); while((j < list.size())){ int m = sufMin[j].min;  int ind = sufMin[j].index; blocks.add(list.get(ind)); count++; Pair p = new Pair((m + 1),0); if ( (set.ceiling(p) == null)) {break;} else { Pair p1 = set.ceiling(p); j = p1.r; }}if ( (max < count)) {max = count; setBlocks = blocks; } }out.println(max); for ( int i = 0;(i < setBlocks.size());i++) {out.println((((setBlocks.get(i).l + 1) + " ") + (setBlocks.get(i).r + 1))); }}out.close(); } public static class Pair1{ int min ,index ; Pair1( int min, int index){ this.min = min; this.index = index; } } public static class Pair{ int l ,r ; Pair( int l, int r){ this.l = l; this.r = r; } } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
5	public class Solution{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int[] a = new int[n];  int i ;  int s = 0; for ( i = 0;(i < n);i++) {a[i] = scan.nextInt(); s += a[i]; }Arrays.sort(a); int sum = 0; for ( i = (n - 1);(i > -1);i--) {sum += a[i]; if ( ((s - sum) < sum)) {System.out.println((n - i)); return ;} }} }
2	public class Solution implements Runnable{ boolean hasBit( long n, int pos){ return ((n & (1L << pos)) != 0);} public void solve()throws Exception { long l = sc.nextLong(),r = sc.nextLong();  int bit = 62; while(((bit >= 0) && (hasBit(l,bit) == hasBit(r,bit)))){bit--; }out.println(((1L << (bit + 1)) - 1)); } static Throwable uncaught ; BufferedReader in ; FastScanner sc ; PrintWriter out ; public static void main( String[] args)throws Throwable { Thread thread = new Thread(null,new Solution(),"",(1 << 26)); thread.start(); thread.join(); if ( (Solution.uncaught != null)) {throw (Solution.uncaught);} } } class FastScanner{ BufferedReader in ; StringTokenizer st ; public FastScanner( BufferedReader in){ this.in = in; } public String nextToken()throws Exception { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} public long nextLong()throws Exception { return Long.parseLong(nextToken());} }
3	public class Main6{ public static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} public static void dfs( int parent, boolean[] visited, int[] dp){ ArrayList<Integer> arr = new ArrayList<Integer>(); arr = graph.get(parent); visited[parent] = true; for ( int i = 0;(i < arr.size());i++) { int num = (int)arr.get(i); if ( (visited[num] == false)) {dfs(num,visited,dp); } dp[parent] = Math.max((dp[num] + 1),dp[parent]); }} static int[] dis ; static int mod = 1000000007; static ArrayList<ArrayList<Integer>> graph ; static int[] ans ; public static int[] sort( int[] a){ int n = a.length;  ArrayList<Integer> ar = new ArrayList<>(); for ( int i = 0;(i < a.length);i++) {ar.add(a[i]); }Collections.sort(ar); for ( int i = 0;(i < n);i++) {a[i] = ar.get(i); }return a;} public static void main( String[] args)throws IOException { int n = i();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = i(); }Arrays.sort(a); boolean[] flag = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( (flag[i] == false)) {ans++; for ( int j = 0;(j < n);j++) {if ( (((a[j] % a[i]) == 0) && (flag[j] == false))) {flag[j] = true; } }} }pln((ans + "")); } static InputReader in = new InputReader(System.in); static OutputWriter out = new OutputWriter(System.out); public static void pln( String value){ System.out.println(value); } public static int i(){ return in.Int();} } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int Int(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String String(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void close(){ writer.close(); } public void flush(){ writer.flush(); } }
1	public class Task25a{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a1 = 0,a2 = 0;  int n1 = 0,n2 = 0; for ( int i = 1;(i <= n);i++) { int c = sc.nextInt(); if ( ((c % 2) == 1)) {a1 = i; n1++; } else {a2 = i; n2++; }}if ( (n1 == 1)) {System.out.println(a1); } else {System.out.println(a2); }} }
6	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  boolean[][] graph = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int from = (in.nextInt() - 1);  int to = (in.nextInt() - 1); graph[from][to] = true; graph[to][from] = true; } int max = (1 << n);  long[][] dp = new long[max][n]; for ( int mask = 1;(mask < max);mask++) {for ( int i = 0;(i < n);i++) { int countMask = Integer.bitCount(mask);  boolean existSubSeti = ((mask & (1 << i)) > 0); if ( ((countMask == 1) && existSubSeti)) {dp[mask][i] = 1; } else if ( ((countMask > 1) && existSubSeti)) { int mask1 = (mask ^ (1 << i)); for ( int j = 0;(j < n);j++) {if ( ((((mask1 & (1 << j)) > 0) && graph[j][i]) && (i != firstMask(mask,n)))) {dp[mask][i] += dp[mask1][j]; } }} }} long counter = 0; for ( int mask = 1;(mask < max);mask++) {for ( int i = 0;(i < n);i++) {if ( ((Integer.bitCount(mask) >= 3) && graph[firstMask(mask,n)][i])) {counter += dp[mask][i]; } }}System.out.println((counter / 2)); in.close(); } public static int firstMask( int mask, int n){ for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) > 0)) return i; }return -1;} }
4	public class Cbeta35{ public static void main( String[] args){ new Cbeta35(); } Scanner in ; PrintWriter out ; int t ; int n ,m ,k ,oo ; int[][] grid ; boolean debug = !true,multi = !true; Cbeta35(){ if ( multi) t = in.nextInt(); do {if ( multi) if ( z(t--)) break; try{in = new Scanner(new File("input.txt")); out = new PrintWriter(new File("output.txt")); }catch (Exception e){ in = new Scanner(System.in); out = new PrintWriter(System.out); } n = in.nextInt(); m = in.nextInt(); k = in.nextInt(); oo = ((n + m) + 1); grid = new int[n][m]; for ( int i = 0;(i < n);i++) Arrays.fill(grid[i],oo); for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); for ( int j = 0;(j < n);j++) for ( int kk = 0;(kk < m);kk++) { int dx = (((j - x) < 0)?(x - j):(j - x));  int dy = (((kk - y) < 0)?(y - kk):(kk - y)); grid[j][kk] = min(grid[j][kk],(dx + dy)); }} int x = 0,y = 0;  int max = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (max < grid[i][j])) {max = grid[i][j]; x = i; y = j; } out.printf("%d %d%n",(x + 1),(y + 1)); }while((debug || multi));out.close(); } int min( int a, int b){ if ( (a < b)) return a; return b;} long min( long a, long b){ if ( (a < b)) return a; return b;} boolean z( int x){ if ( (x == 0)) return true; return false;} boolean z( long x){ if ( (x == 0)) return true; return false;} void sort( int[] arr){ int szArr = arr.length;  Random r = new Random(); for ( int i = 0;(i < szArr);i++) { int j = r.nextInt(szArr); arr[i] = (arr[j] ^ (arr[i] ^ (arr[j] = arr[i]))); }Arrays.sort(arr); } }
0	public class CFA{ private void work()throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); while(sc.hasNextInt()){ int n = sc.nextInt();  int a = n;  int b = (n / 10);  int c ; if ( (n < 0)) {n = -n; c = (((n / 100) * 10) + (n % 10)); } else {c = (((n / 100) * 10) + (n % 10)); }System.out.println(Math.max(a,Math.max(b,c))); }System.out.close(); } private int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} public static void main( String[] args)throws IOException { new CFA().work(); } }
2	public class Main{ boolean[] b ; int[] r ; ArrayList<ArrayList<Integer>> q ; public void dfs( int u, int p){ for ( int i = 0;(i < q.get(u).size());i++) { int v = q.get(u).get(i); if ( (v != p)) {r[v] = (r[u] + 1); if ( b[u]) {b[v] = b[u]; } dfs(v,u); } }} public void solve()throws IOException { long n = nextLong();  long s = nextLong();  long t = 0; if ( ((s + 200) < n)) {t = ((n - s) - 200); } for ( long i = s;(i <= Math.min((s + 200),n));i++) { long p = 0;  long u = i; while((u > 0)){p += (u % 10); u /= 10; }if ( ((i - p) >= s)) {t++; } }out.print(t); } BufferedReader br ; StringTokenizer sc ; PrintWriter out ; public String nextToken()throws IOException { while(((sc == null) || !sc.hasMoreTokens())){try{sc = new StringTokenizer(br.readLine()); }catch (Exception e){ return null;} }return sc.nextToken();} public Long nextLong()throws IOException { return Long.parseLong(nextToken());} public static void main( String[] args)throws IOException { try{Locale.setDefault(Locale.US); }catch (Exception e){ } new Main().run(); } public void run(){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } }
1	public class C{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  char[] s = new char[n];  String line = in.next();  int ct = 0,ht = 0; for ( int i = 0;(i < n);i++) if ( (line.charAt(i) == 'T')) ct++; else ht++; int cnt = 1000000000;  int[] c = new int[2];  char[] cc = new char[2]; if ( (ct < ht)) {c[0] = ct; c[1] = ht; cc[0] = 'T'; cc[1] = 'H'; } else {c[0] = ht; c[1] = ct; cc[0] = 'H'; cc[1] = 'T'; }for ( int i = 0;(i < n);i++) { int ptr = i; for ( int j = 0;(j < c[0]);j++) {s[ptr] = cc[0]; ptr = ((ptr + 1) % n); }for ( int j = 0;(j < c[1]);j++) {s[ptr] = cc[1]; ptr = ((ptr + 1) % n); } int ch = 0; for ( int j = 0;(j < n);j++) if ( ((s[j] != line.charAt(j)) && (s[j] == cc[0]))) ch++; cnt = Math.min(cnt,ch); }System.out.print(cnt); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  String s = in.next();  int[] cnt = new int[26];  int[] cnt2 = new int[26];  int j = 0;  int res = n;  HashSet<Character> set = new HashSet<Character>(); for ( char c :s.toCharArray()) {set.add(c); } int m = set.size(); for ( int i = 0;(i < n);++i) {if ( Character.isLowerCase(s.charAt(i))) {cnt[(s.charAt(i) - 'a')]++; } else {cnt2[(s.charAt(i) - 'A')]++; }while(isOK(cnt,cnt2,m)){res = Math.min(res,((i - j) + 1)); if ( Character.isLowerCase(s.charAt(j))) {cnt[(s.charAt(j) - 'a')]--; } else {cnt2[(s.charAt(j) - 'A')]--; }++j; }}out.println(res); } boolean isOK( int[] cnt, int[] cnt2, int m){ int c = 0; for ( int i = 0;(i < 26);++i) {if ( (cnt[i] > 0)) {++c; } }for ( int i = 0;(i < 26);++i) {if ( (cnt2[i] > 0)) {++c; } }return (c >= m);} } }
4	public class Main{ static PrintWriter out ; static Reader in ; public static void main( String[] args)throws IOException { input_output(); Main solver = new Main(); solver.solve(); out.close(); out.flush(); } static long INF = (long)1e18; static int MAXN = ((int)1e7 + 5); static int mod = 998_244_353; static int n ,m ,q ,t ; static double pi = Math.PI; void solve()throws IOException { t = in.nextInt(); int[] div = new int[MAXN]; Arrays.fill(div,1); for ( int i = 2;(i < MAXN);i++) {if ( (div[i] == 1)) {for ( int j = i;(j < MAXN);j += i) {div[j] = i; }} }while((t-- > 0)){n = in.nextInt(); int k = in.nextInt();  int[] arr = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {arr[i] = in.nextInt(); int tmp = arr[i],newn = 1; while((div[arr[i]] != 1)){ int elm = div[arr[i]],cnt = 0; while((div[arr[i]] == elm)){cnt++; arr[i] /= elm; }if ( ((cnt % 2) == 1)) newn *= elm; }newn *= arr[i]; arr[i] = newn; } int[] close = new int[(n + 1)];  List<Node> list = new ArrayList<>(); for ( int i = 1;(i <= n);i++) list.add(new Node(arr[i],i)); Collections.sort(list); for ( int i = 0;(i < n);i++) {if ( ((i == (n - 1)) || (list.get((i + 1)).val != list.get(i).val))) {close[list.get(i).idx] = -1; } else {close[list.get(i).idx] = list.get((i + 1)).idx; }} int[][] next = new int[(n + 1)][(k + 1)];  List<Integer> upd = new ArrayList<>();  List<Integer> nupd = new ArrayList<>(); for ( int i = 0;(i <= k);i++) next[n][i] = n; for ( int i = (n - 1);(i >= 1);i--) {nupd.clear(); if ( (close[i] == -1)) {for ( int j = 0;(j <= k);j++) next[i][j] = next[(i + 1)][j]; } else { int tmp = (close[i] - 1),cnt = 0; if ( ((upd.size() == 0) || (tmp < upd.get(0)))) {nupd.add(tmp); tmp = -1; } for ( int j = 0;(j < upd.size());j++) {if ( (((nupd.size() < (k + 1)) && (tmp != -1)) && (tmp < upd.get(j)))) {nupd.add(tmp); tmp = -1; } if ( (nupd.size() < (k + 1))) nupd.add(upd.get(j)); }if ( ((tmp != -1) && (nupd.size() < (k + 1)))) nupd.add(tmp); for ( int j = 0;(j < nupd.size());j++) next[i][j] = nupd.get(j); for ( int j = nupd.size();(j <= k);j++) next[i][j] = n; upd.clear(); for ( int j = 0;(j < nupd.size());j++) upd.add(nupd.get(j)); }} int[][] dp = new int[(n + 1)][(k + 1)]; for ( int i = 1;(i <= n);i++) for ( int j = 0;(j <= k);j++) dp[i][j] = n; for ( int i = 0;(i < n);i++) {for ( int cur = 0;(cur <= k);cur++) {for ( int ncur = cur;(ncur <= k);ncur++) {dp[next[(i + 1)][(ncur - cur)]][ncur] = Math.min(dp[next[(i + 1)][(ncur - cur)]][ncur],(dp[i][cur] + 1)); }}} int ans = n; for ( int i = 0;(i <= k);i++) ans = Math.min(ans,dp[n][i]); out.println(ans); }} static class Node implements Comparable<Node>{ int val ,idx ; Node( int val, int idx){ this.val = val; this.idx = idx; } } static class Reader{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public Reader(){ this(System.in); } public Reader( InputStream is){ mIs = is; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = mIs.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public String next(){ int c = read(); while(isSpaceChar(c)){c = read(); } StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} } static void input_output()throws IOException { File f = new File("in.txt"); if ( (f.exists() && !f.isDirectory())) {in = new Reader(new FileInputStream("in.txt")); } else in = new Reader(); f = new File("out.txt"); if ( (f.exists() && !f.isDirectory())) {out = new PrintWriter(new File("out.txt")); } else out = new PrintWriter(System.out); } }
0	public class A122{ public static void main( String[] aa){ Scanner ob = new Scanner(System.in);  int n ; n = ob.nextInt(); if ( (((((((((((((n % 4) == 0) || ((n % 7) == 0)) || ((n % 44) == 0)) || ((n % 47) == 0)) || ((n % 444) == 0)) || ((n % 447) == 0)) || ((n % 474) == 0)) || ((n % 477) == 0)) || ((n % 744) == 0)) || ((n % 747) == 0)) || ((n % 774) == 0)) || ((n % 777) == 0))) System.out.println("YES"); else System.out.println("NO"); } }
1	public class Array implements Runnable{ void solve()throws IOException { int n = readInt();  int k = readInt();  int a[] = new int[n];  int startIdx = 0;  int endIdx = -1;  Map<Integer,Integer> map = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {a[i] = readInt(); if ( map.containsKey(a[i])) map.put(a[i],(map.get(a[i]) + 1)); else map.put(a[i],1); if ( ((map.size() == k) && (endIdx == -1))) {endIdx = i; break;} }if ( (endIdx != -1)) {while(((startIdx < n) && (map.get(a[startIdx]) > 1))){map.put(a[startIdx],(map.get(a[startIdx]) - 1)); startIdx++; }startIdx++; endIdx++; } else startIdx = -1; out.println(((startIdx)+" " + endIdx)); } BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Array().run(); } public void run(){ try{ long t1 = System.currentTimeMillis(); if ( (System.getProperty("ONLINE_JUDGE") != null)) {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new BufferedReader(new FileReader("/Users/shenchen/input.txt")); out = new PrintWriter("/Users/shenchen/output.txt"); }Locale.setDefault(Locale.US); solve(); in.close(); out.close(); long t2 = System.currentTimeMillis(); System.err.println(("Time = " + (t2 - t1))); }catch (Throwable t){ t.printStackTrace(System.err); System.exit(-1); } } String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} }
1	public class Task1b{ static int[] fromRC( String data){ int pos = data.indexOf('C');  int res[] = new int[2]; res[0] = Integer.parseInt(data.substring(1,pos)); res[1] = Integer.parseInt(data.substring((pos + 1))); return res;} static int[] fromXC( String data){ int pos = 0;  int res[] = new int[2]; res[0] = res[1] = 0; while(((data.charAt(pos) >= 'A') && (data.charAt(pos) <= 'Z'))){res[1] *= 26; res[1]++; res[1] += (data.charAt(pos) - 'A'); pos++; }res[0] = Integer.parseInt(data.substring(pos)); return res;} static String toRC( int[] data){ return String.format("R%dC%d",data[0],data[1]);} static String toXC( int[] data){ StringBuilder sb = new StringBuilder(); while((data[1] > 0)){data[1]--; sb.append((char)('A' + (data[1] % 26))); data[1] /= 26; }sb = sb.reverse(); sb.append(data[0]); return sb.toString();} public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine()); for ( int i = 0;(i < n);i++) { String s = br.readLine(); if ( (((s.charAt(0) == 'R') && ((s.charAt(1) >= '0') && (s.charAt(1) <= '9'))) && (s.indexOf('C') != -1))) {System.out.println(toXC(fromRC(s))); } else {System.out.println(toRC(fromXC(s))); }}} }
5	public class Village{ static class House implements Comparable<House>{ public double center ,length ; public House( double center, double length){ this.center = center; this.length = length; } public double getRight(){ return (center + (length / 2));} public double getLeft(){ return (center - (length / 2));} } public static void main( String[] args){ Scanner in = new Scanner(System.in);  String[] fline = in.nextLine().split("\\s+");  int N = Integer.parseInt(fline[0]);  int T = Integer.parseInt(fline[1]);  House[] houses = new House[N]; for ( int i = 0;(i < N);i++) { String[] house = in.nextLine().split("\\s+"); houses[i] = new House(Double.parseDouble(house[0]),Double.parseDouble(house[1])); }Arrays.sort(houses); int count = 2; for ( int i = 0;(i < (houses.length - 1));i++) { double diff = (houses[(i + 1)].getLeft() - houses[i].getRight()); if ( (diff < T)) continue; if ( (Math.abs((diff - T)) < 1E-12)) count++; else count += 2; }System.out.println(count); } }
1	public class Test11{ public static void main( String[] Args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  String s0 = sc.nextLine();  int s = 0;  int m = 0;  int l = 0;  int s1 = 0;  int l1 = 0;  int s2 = 0;  int l2 = 0;  int s3 = 0;  int l3 = 0; for ( int i = 0;(i < n);i++) {s0 = sc.nextLine(); if ( (s0.charAt(0) == 'S')) s++; if ( (s0.charAt(0) == 'M')) m++; if ( (s0.charAt(0) == 'L')) l++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 2)) && (s0.charAt((s0.length() - 1)) == 'S'))) s1++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 3)) && (s0.charAt((s0.length() - 1)) == 'S'))) s2++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 4)) && (s0.charAt((s0.length() - 1)) == 'S'))) s3++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 2)) && (s0.charAt((s0.length() - 1)) == 'L'))) l1++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 3)) && (s0.charAt((s0.length() - 1)) == 'L'))) l2++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 4)) && (s0.charAt((s0.length() - 1)) == 'L'))) l3++; } int rs = 0;  int rm = 0;  int rl = 0;  int rs1 = 0;  int rl1 = 0;  int rs2 = 0;  int rl2 = 0;  int rs3 = 0;  int rl3 = 0; for ( int i = 0;(i < n);i++) {s0 = sc.nextLine(); if ( (s0.charAt(0) == 'S')) rs++; if ( (s0.charAt(0) == 'M')) rm++; if ( (s0.charAt(0) == 'L')) rl++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 2)) && (s0.charAt((s0.length() - 1)) == 'S'))) rs1++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 3)) && (s0.charAt((s0.length() - 1)) == 'S'))) rs2++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 4)) && (s0.charAt((s0.length() - 1)) == 'S'))) rs3++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 2)) && (s0.charAt((s0.length() - 1)) == 'L'))) rl1++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 3)) && (s0.charAt((s0.length() - 1)) == 'L'))) rl2++; if ( (((s0.charAt(0) == 'X') && (s0.length() == 4)) && (s0.charAt((s0.length() - 1)) == 'L'))) rl3++; } int ans = (((Math.abs((s1 - rs1)) + Math.abs((s2 - rs2))) + Math.abs((s3 - rs3))) + (((Math.abs((s - rs)) + Math.abs((l - rl))) + Math.abs((m - rm))) / 2)); System.out.println(ans); } }
4	public class Main{ static class Fast{ StringTokenizer st ; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); static Fast scn = new Fast(); public static void main( String[] args)throws Exception { int t = 1; while((t-- > 0)){func(); }bw.close(); } private static void func()throws Exception { int n = scn.nextInt();  int m = scn.nextInt();  int k = scn.nextInt();  int[][] hori = new int[n][(m - 1)];  int[][] vert = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {hori[i][j] = scn.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {vert[i][j] = scn.nextInt(); }}if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {bw.append((-1 + " ")); }bw.append("\n"); }return ;} int[][][] strg = new int[n][m][(k + 1)];  int[][] answer = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {answer[i][j] = steps(i,j,hori,vert,k,strg); }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {bw.append((answer[i][j] + " ")); }bw.append("\n"); }} static int steps( int x, int y, int[][] hori, int[][] vert, int k, int[][][] strg){ if ( (k == 0)) return 0; if ( (strg[x][y][k] != 0)) return strg[x][y][k]; int xmove = x;  int ymove = y;  int ans = 0;  int val = Integer.MAX_VALUE; if ( (y < hori[0].length)) {xmove = x; ymove = (y + 1); val = Math.min(val,(steps(xmove,ymove,hori,vert,(k - 2),strg) + (2 * hori[x][y]))); } if ( ((y - 1) >= 0)) {xmove = x; ymove = (y - 1); val = Math.min(val,(steps(xmove,ymove,hori,vert,(k - 2),strg) + (2 * hori[x][(y - 1)]))); } if ( ((x - 1) >= 0)) {xmove = (x - 1); ymove = y; val = Math.min(val,(steps(xmove,ymove,hori,vert,(k - 2),strg) + (2 * vert[(x - 1)][y]))); } if ( (x < vert.length)) {xmove = (x + 1); ymove = y; val = Math.min(val,(steps(xmove,ymove,hori,vert,(k - 2),strg) + (2 * vert[x][y]))); } ans += val; return strg[x][y][k] = ans;} }
5	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt();  int k = (input.nextInt() - 1);  int a[][] = new int[n][2]; for ( int i = 0;(i < n);i++) {a[i][0] = input.nextInt(); a[i][1] = input.nextInt(); }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i][0] < a[j][0])) { int x = a[i][0];  int y = a[i][1]; a[i][0] = a[j][0]; a[i][1] = a[j][1]; a[j][0] = x; a[j][1] = y; } }}for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( ((a[i][1] > a[j][1]) && (a[i][0] == a[j][0]))) { int x = a[i][0];  int y = a[i][1]; a[i][0] = a[j][0]; a[i][1] = a[j][1]; a[j][0] = x; a[j][1] = y; } }} int x = a[k][0];  int y = a[k][1];  int s = 0; for ( int i = 0;(i < n);i++) {if ( ((a[i][0] == x) && (a[i][1] == y))) {s++; } }System.out.println(s); } }
4	public class C35C_BFS_Fire{ public static boolean[][] burning ; public static LinkedList<int[]> LitTrees ; public static int N ,M ; public static int[] lastTree ; public static void main( String[] args)throws IOException { BufferedReader input = new BufferedReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));  StringTokenizer dataR = new StringTokenizer(input.readLine()); N = Integer.parseInt(dataR.nextToken()); M = Integer.parseInt(dataR.nextToken()); burning = new boolean[(N + 1)][(M + 1)]; StringTokenizer dataR1 = new StringTokenizer(input.readLine());  int K = Integer.parseInt(dataR1.nextToken());  StringTokenizer dataR2 = new StringTokenizer(input.readLine()); LitTrees = new LinkedList<int[]>(); for ( int j = 0;(j < K);j++) { int x = Integer.parseInt(dataR2.nextToken());  int y = Integer.parseInt(dataR2.nextToken());  int[] coord = {x,y}; LitTrees.add(coord); burning[x][y] = true; }spread(); out.println(((lastTree[0] + " ") + lastTree[1])); out.close(); } public static void spread(){ while(!LitTrees.isEmpty()){ int[] studying = LitTrees.remove();  LinkedList<int[]> ll = new LinkedList<int[]>(); if ( ((studying[0] - 1) >= 1)) ll.add(new int[]{(studying[0] - 1),studying[1]}); if ( ((studying[1] - 1) >= 1)) ll.add(new int[]{studying[0],(studying[1] - 1)}); if ( ((studying[1] + 1) < (M + 1))) ll.add(new int[]{studying[0],(studying[1] + 1)}); if ( ((studying[0] + 1) < (N + 1))) ll.add(new int[]{(studying[0] + 1),studying[1]}); while(!ll.isEmpty()){ int[] focus = ll.remove(); if ( !burning[focus[0]][focus[1]]) {LitTrees.add(focus); burning[focus[0]][focus[1]] = true; } }lastTree = studying; }} }
0	public class FollowTrafficRules{ public Scanner in = new Scanner(System.in); public PrintStream out = System.out; public double len ,d ,w ,vmax ,a ; DecimalFormat fmt = new DecimalFormat("0.0000000000000000"); public void main(){ a = in.nextDouble(); vmax = in.nextDouble(); len = in.nextDouble(); d = in.nextDouble(); w = in.nextDouble(); out.println(fmt.format(T())); } public double T(){ double t ,s ;  double t1 ,s1 ; t1 = (vmax / a); s1 = ((vmax * vmax) / (2.0 * a)); double t3 ,s3 ; t3 = (w / a); s3 = ((w * w) / (2.0 * a)); if ( (w >= vmax)) {if ( (s1 < len)) {return (t1 + ((len - s1) / vmax));} else {return Math.sqrt(((2.0 * len) / a));}} else { double t2 ,s2 ,v2 ; t2 = Math.sqrt(((2.0 * d) / a)); v2 = (a * t2); double tx ,vx ; vx = Math.sqrt(((((2.0 * a) * d) + (w * w)) / 2.0)); tx = (vx / a); if ( (v2 < w)) {if ( (v2 > vmax)) {if ( (vmax > vx)) {return ((tx + ((vx - w) / a)) + T2(w));} else { double ty ,sy ; ty = ((vmax - w) / a); sy = ((ty * (vmax + w)) / 2.0); return (((t1 + ty) + (((d - s1) - sy) / vmax)) + T2(w));}} else {return (t2 + T2(v2));}} else if ( (v2 > vmax)) {if ( (vmax > vx)) {return ((tx + ((vx - w) / a)) + T2(w));} else { double ty ,sy ; ty = ((vmax - w) / a); sy = ((ty * (vmax + w)) / 2.0); return (((t1 + ty) + (((d - s1) - sy) / vmax)) + T2(w));}} else {return ((tx + ((vx - w) / a)) + T2(w));}}} public double T2( double v0){ double t1 ,s1 ; t1 = ((vmax - v0) / a); s1 = (((vmax + v0) / 2.0) * t1); if ( (s1 < (len - d))) {return (t1 + (((len - d) - s1) / vmax));} else {return ((-v0 + Math.sqrt(((v0 * v0) + ((2 * a) * (len - d))))) / a);}} public static void main( String[] args){ new FollowTrafficRules().main(); } }
0	public class Solution{ private static int n ; private static PrintWriter writer ; private static int maxstep ; private static void g( int src, int step){ if ( ((step != 0) && ((n % src) == 0))) {writer.print("YES"); writer.close(); System.exit(0); } if ( (step == maxstep)) return ; int p = (int)Math.pow(10,step); g((src + (4 * p)),(step + 1)); g((src + (7 * p)),(step + 1)); } public static void main( String[] args)throws Exception { Scanner reader = new Scanner(System.in); writer = new PrintWriter(System.out); n = reader.nextInt(); maxstep = (String.valueOf(n).length() + 1); g(0,0); writer.print("NO"); writer.close(); } }
1	public class B{ BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter out ; public void solve()throws IOException { int N = nextInt();  int A = nextInt();  int B = nextInt();  int[] nsA = new int[N];  int[] nsB = new int[N];  char[] ans = new char[N]; Arrays.fill(nsA,-1); Arrays.fill(nsB,-1); Arrays.fill(ans,'C'); HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();  int[] P = new int[N]; for ( int i = 0;(i < N);i++) {P[i] = nextInt(); map.put(P[i],i); }if ( (A == B)) {for ( int i = 0;(i < N);i++) {if ( !map.containsKey((A - P[i]))) {out.println("NO"); return ;} }out.println("YES"); for ( int i = 0;(i < N);i++) {out.print((0 + " ")); }out.println(); return ;} for ( int i = 0;(i < N);i++) { int oppA = (A - P[i]);  int oppB = (B - P[i]); if ( map.containsKey(oppA)) {nsA[i] = map.get(oppA); } if ( map.containsKey(oppB)) {nsB[i] = map.get(oppB); } }for ( int i = 0;(i < N);i++) {if ( ((nsA[i] == -1) && (nsB[i] == -1))) {out.println("NO"); return ;} }for ( int i = 0;(i < N);i++) {if ( (ans[i] != 'C')) continue; if ( (nsA[i] == -1)) {if ( !go(i,'B',ans,nsA,nsB)) {out.println("NO"); return ;} } else if ( (nsB[i] == -1)) {if ( !go(i,'A',ans,nsA,nsB)) {out.println("NO"); return ;} } }for ( int i = 0;(i < N);i++) {if ( (ans[i] != 'C')) continue; if ( ((nsA[i] == i) || (nsB[i] == i))) {if ( (nsA[i] == i)) {if ( !go(i,'B',ans,nsA,nsB)) {out.println("NO"); return ;} } else {if ( !go(i,'A',ans,nsA,nsB)) {out.println("NO"); return ;} }} }for ( int i = 0;(i < N);i++) {if ( (ans[i] != 'C')) continue; if ( !go(i,'A',ans,nsA,nsB)) {out.println("NO"); return ;} }for ( int i = 0;(i < N);i++) {if ( (ans[i] == 'C')) {out.println("NO"); return ;} }out.println("YES"); for ( int i = 0;(i < N);i++) {out.print(((ans[i] == 'A')?0:1)); out.print(" "); }out.println(); } public boolean go( int cur, char link, char[] ans, int[] nsA, int[] nsB){ while((ans[cur] == 'C')){ int next = ((link == 'A')?nsA[cur]:nsB[cur]); if ( (next == -1)) return false; if ( (ans[next] != 'C')) return false; ans[cur] = link; ans[next] = link; int nextNext = ((link == 'A')?nsB[next]:nsA[next]); cur = nextNext; if ( (cur == -1)) return true; }return true;} public static void main( String[] args){ new B().run(); } public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; out = new PrintWriter(System.out); solve(); reader.close(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
1	public class Main{ public static void main( String[] args){ InputReader in = new StreamInputReader(System.in);  PrintWriter out = new PrintWriter(System.out); run(in,out); } public static void run( InputReader in, PrintWriter out){ Solver solver = new Task(); solver.solve(1,in,out); Exit.exit(in,out); } } class StreamInputReader extends InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ,numChars ; public StreamInputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public void close(){ try{stream.close(); }catch (IOException ignored){ } } } interface Solver{ public void solve( int testNumber, InputReader in, PrintWriter out); } class Task implements Solver{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.readInt();  int a = in.readInt();  int b = in.readInt(); if ( (a == b)) {b = 0; } boolean[] where = new boolean[n];  HashSet<Integer> set = new HashSet<Integer>();  HashMap<Integer,Integer> indexmap = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) { int x = in.readInt(); indexmap.put(x,i); set.add(x); }while((set.size() > 0)){ int size = set.size();  HashSet<Integer> todo = new HashSet<Integer>();  HashSet<Integer> used = new HashSet<Integer>(); for ( int x :set) {if ( used.contains(x)) continue; int ax = (a - x);  int bx = (b - x); if ( ((set.contains(ax) && !used.contains(ax)) && (set.contains(bx) && !used.contains(bx)))) {todo.add(x); } else if ( (set.contains(ax) && !used.contains(ax))) {used.add(x); used.add(ax); todo.remove(ax); bx = (b - ax); while((set.contains(bx) && !used.contains(bx))){x = bx; ax = (a - x); if ( (!set.contains(ax) || used.contains(ax))) {System.out.println("NO"); return ;} todo.remove(x); todo.remove(ax); used.add(x); used.add(ax); bx = (b - ax); }} else if ( (set.contains(bx) && !used.contains(bx))) {used.add(x); used.add(bx); todo.remove(bx); where[indexmap.get(bx)] = true; where[indexmap.get(x)] = true; ax = (a - bx); while((set.contains(ax) && !used.contains(ax))){x = ax; bx = (b - x); if ( (!set.contains(bx) || used.contains(bx))) {System.out.println("NO"); return ;} todo.remove(x); todo.remove(bx); used.add(x); used.add(bx); where[indexmap.get(bx)] = true; where[indexmap.get(x)] = true; ax = (a - bx); }} else {System.out.println("NO"); return ;}}set = todo; if ( (set.size() == size)) {System.out.println("Set size constant!!"); break;} }System.out.println("YES"); for ( int i = 0;(i < n);i++) if ( where[i]) System.out.print("1 "); else System.out.print("0 "); } }
5	public class A{ static class House{ int x ,a ; } public static void main(final String[] args){ final Scanner in = new Scanner(System.in); final PrintWriter out = new PrintWriter(System.out); try{final int n = in.nextInt(); final int t = in.nextInt(); final House[] h = new House[n]; for ( int i = 0;(i < h.length);++i) {h[i] = new House(); h[i].x = in.nextInt(); h[i].a = in.nextInt(); }Arrays.sort(h,new Comparator<House>(){}); int ans = 2; for ( int i = 1;(i < n);++i) {final int dspace = (((2 * h[i].x) - h[i].a) - ((2 * h[(i - 1)].x) + h[(i - 1)].a)); if ( (dspace == (2 * t))) {++ans; } else if ( (dspace > (2 * t))) {ans += 2; } }out.println(ans); }finally{in.close(); out.close(); }} }
3	public class D{ String INPUT = (((((("4\n" + "1 2 4 3\n") + "4\n") + "1 1\n") + "1 4\n") + "1 4\n") + "2 3"); void solve(){ int n = i();  int[] a = ia(n);  int count = 0; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[j] < a[i])) {count++; } }} int q = i(); for ( int i = 0;(i < q);i++) { int l = i(),r = i();  int mid = (((r - l) + 1) / 2); if ( ((mid % 2) == 0)) {out.println((((count % 2) == 0)?"even":"odd")); } else {count++; out.println((((count % 2) == 0)?"even":"odd")); }}} void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); int t = 1; while((t-- > 0))solve(); out.flush(); } public static void main( String[] args)throws Exception { new D().run(); } InputStream is ; PrintWriter out ; private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String s(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] sa( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int[] ia( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = i(); return a;} private int i(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); }
5	public class Main{ public static void main( String[] args){ FastScanner sc = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int N = sc.nextInt();  long dest = sc.nextLong();  long max = (((long)N * ((long)N + 1L)) / 2L); if ( ((dest < ((2 * N) - 1)) || (dest > max))) {out.println("No"); out.close(); return ;} int[] d = new int[(N + 1)];  int[] f = new int[(N + 1)];  int K = 1; for ( ;(K <= N);K++) { long dep = 1L,cnt = 1L,c = 1L;  long t = 1L; while((cnt < N)){c = (c * K); dep++; t += (dep * Math.min(c,(N - cnt))); cnt += c; }if ( (t <= dest)) break; }out.println("Yes"); int dep = 1;  long cnt = 1L,c = 1L;  long t = 1L; d[1] = 1; while((cnt < N)){dep++; c = (c * K); long x = ((long)N - cnt);  int min ; if ( (c >= x)) min = (int)x; else min = (int)c; d[dep] = min; t += (dep * Math.min(c,((long)N - cnt))); cnt += c; }dest -= t; int curDep = dep;  int nextDep = (dep + 1); while((dest > 0)){if ( (d[curDep] <= 1)) curDep--; d[curDep]--; long next = Math.min(nextDep++,(dest + curDep)); dest -= ((int)next - curDep); d[(int)next]++; } int first = 1; for ( int i = 2;(i < nextDep);i++) { int p = 0,fn = ((first - d[(i - 1)]) + 1); for ( int j = (first + 1);(j <= (first + d[i]));j++) {if ( (p == K)) {fn++; p = 0; } p++; f[j] = fn; }first += d[i]; }for ( int i = 2;(i <= N);i++) out.format("%d ",f[i]); out.close(); } static class FastScanner{ private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} } return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} public int nextInt(){ return Integer.parseInt(next());} } }
1	public class Main{ static MyScanner scan ; static PrintWriter pw ; public static void main( String[] args){ new Thread(null,null,"_",(1 << 25)){}.start(); } static void solve()throws IOException { scan = new MyScanner(); pw = new PrintWriter(System.out,true); StringBuilder sb = new StringBuilder();  Map<String,Integer> map = new HashMap<>(); map.put("M",0); map.put("L",1); map.put("S",2); map.put("XL",3); map.put("XS",4); map.put("XXL",5); map.put("XXS",6); map.put("XXXL",7); map.put("XXXS",8); int freqa[] = new int[9];  int freqb[] = new int[9];  int n = ni(); for ( int i = 0;(i < n);++i) ++freqa[map.get(ne())]; for ( int i = 0;(i < n);++i) ++freqb[map.get(ne())]; for ( int i = 0;(i < 9);++i) { int xx = min(freqa[i],freqb[i]); freqa[i] -= xx; freqb[i] -= xx; } long res = 0; for ( int i = 0;(i < 9);++i) res += (freqa[i] + freqb[i]); pl((res / 2)); pw.flush(); pw.close(); } static long modpow( long x, long y, long MOD){ if ( (y == 0)) return 1; if ( ((y & 1) == 0)) return modpow(((x * x) % MOD),(y >> 1),MOD); else return ((x * modpow(x,(y - 1),MOD)) % MOD);} static int ni()throws IOException { return scan.nextInt();} static String ne()throws IOException { return scan.next();} static void pl(){ pw.println(); } static void pl( Object o){ pw.println(o); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String nextLine()throws IOException { return br.readLine();} String next()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} long nextLong()throws IOException { return Long.parseLong(next());} double nextDouble()throws IOException { return Double.parseDouble(next());} } }
2	public class cf5722{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  long n = Long.parseLong(st.nextToken());  long k = Long.parseLong(st.nextToken());  long ans = ((-3 - (long)Math.sqrt((9 + (4 * ((1 * 2) * (n + k)))))) / 2);  long ans1 = ((-3 + (long)Math.sqrt((9 + (4 * ((1 * 2) * (n + k)))))) / 2); if ( (ans > 0)) System.out.println((n - ans)); else {System.out.println((n - ans1)); }} }
5	public class AAA{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] array = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {array[i] = sc.nextInt(); sum += array[i]; } int counter = 0; Arrays.sort(array); int first = 0; for ( int j = (n - 1);(j >= 0);j--) {first += array[j]; sum -= array[j]; counter++; if ( (first > sum)) {break;} }System.out.println(counter); } }
6	public class Main implements Runnable{ final String filename = ""; public void solve()throws Exception { int n = iread(),k = iread(),A = iread();  int[] b = new int[n],l = new int[n]; for ( int i = 0;(i < n);i++) {l[i] = iread(); b[i] = iread(); } int[] c = new int[n];  double ans = 0.0; for ( int mask = 0;(mask < (1 << ((k + n) - 1)));mask++) { int t = 0; for ( int i = 0;(i < ((n + k) - 1));i++) {if ( ((mask & (1 << i)) != 0)) t++; }if ( (t != k)) continue; int x = mask; for ( int i = 0;(i < n);i++) {c[i] = b[i]; while(((x % 2) == 1)){c[i] += 10; x /= 2; }if ( (c[i] > 100)) c[i] = 100; x /= 2; } double res = 0.0; for ( int mask2 = 0;(mask2 < (1 << n));mask2++) { int m = 0;  double p = 1.0; t = 0; for ( int i = 0;(i < n);i++) {if ( ((mask2 & (1 << i)) == 0)) {t += l[i]; p *= ((100.0 - c[i]) / 100.0); } else {p *= (c[i] / 100.0); m++; }}if ( ((m * 2) > n)) res += p; else res += (((p * A) * 1.0) / (A + t)); }ans = Math.max(ans,res); } DecimalFormat df = new DecimalFormat("0.0000000"); out.write((df.format(ans) + "\n")); } public int iread()throws Exception { return Integer.parseInt(readword());} BufferedReader in ; BufferedWriter out ; public String readword()throws IOException { StringBuilder b = new StringBuilder();  int c ; c = in.read(); while(((c >= 0) && (c <= ' ')))c = in.read(); if ( (c < 0)) return ""; while((c > ' ')){b.append((char)c); c = in.read(); }return b.toString();} public static void main( String[] args){ try{Locale.setDefault(Locale.US); }catch (Exception e){ } new Thread(null,new Main(),"1",(1 << 25)).start(); } }
0	public class Challenge{ public static void main( String[] args)throws java.lang.Exception { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(in,out); out.close(); } } class TaskA{ public void solve( InputReader in, PrintWriter out){ int n = in.nextInt(); if ( (n == 1)) {out.println("1"); } else if ( (n == 2)) {out.println("2"); } else if ( (n == 3)) {out.println("6"); } else if ( ((n % 2) > 0)) {out.println((((1L * n) * (n - 1)) * (n - 2))); } else if ( ((n % 3) == 0)) {out.println((((1L * (n - 1)) * (n - 2)) * (n - 3))); } else {out.println((((1L * n) * (n - 1)) * (n - 3))); }} } class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastScanner in = new FastScanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ private final int MOD = (int)(1e9 + 7); public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  String[] arr = new String[n]; for ( int i = 0;(i < n);i++) {arr[i] = in.nextString(); } int[] dp = new int[n]; Arrays.parallelSetAll(dp,(i)->0); dp[0] = 1; int cnt = 0; for ( int i = 0;(i < n);i++) {if ( arr[i].equals("f")) {cnt++; continue;} calc(dp,n,cnt); cnt = 0; } int sum = 0; for ( int i = 0;(i < n);i++) {sum += dp[i]; sum %= MOD; }out.println(sum); } private void calc( int[] dp, int n, int cnt){ for ( int i = (n - 1);(i >= 0);i--) {if ( (i != (n - 1))) dp[i] += dp[(i + 1)]; dp[i] %= MOD; } int[] tmp = new int[n]; for ( int i = 0;(i < n);i++) {tmp[((i + cnt) % n)] = dp[i]; }Arrays.parallelSetAll(dp,(i)->tmp[i]); } } static class FastScanner{ private BufferedReader br ; private StringTokenizer st ; public FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public FastScanner( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } public String nextString(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextString());} } }
1	public class B{ void solve()throws IOException { in = new InputReader("__std"); out = new OutputWriter("__std"); int n = in.readInt();  int a = in.readInt();  int b = in.readInt();  int ma = 0;  int mb = 1; if ( (a < b)) { int t = a; a = b; b = t; t = ma; ma = mb; mb = t; } final int[] p = new int[n];  Integer id[] = new Integer[n];  Map<Integer,Integer> pos = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);++i) {p[i] = in.readInt(); id[i] = i; pos.put(p[i],i); }Arrays.sort(id,new Comparator<Integer>(){}); int[] mask = new int[n]; Arrays.fill(mask,-1); boolean flag = true; for ( int i = 0;((i < n) && flag);++i) {if ( (mask[id[i]] == -1)) {if ( (p[id[i]] < a)) {if ( pos.containsKey((a - p[id[i]]))) { int j = pos.get((a - p[id[i]])); if ( (mask[j] != mb)) {mask[id[i]] = mask[j] = ma; continue;} } if ( ((p[id[i]] < b) && pos.containsKey((b - p[id[i]])))) { int j = pos.get((b - p[id[i]])); if ( (mask[j] != ma)) {mask[id[i]] = mask[j] = mb; continue;} } } flag = false; } }if ( flag) {out.println("YES"); for ( int m :mask) {out.print((m + " ")); }} else {out.println("NO"); }exit(); } void exit(){ out.close(); System.exit(0); } InputReader in ; OutputWriter out ; public static void main( String[] args)throws IOException { new B().solve(); } class InputReader{ private InputStream stream ; private byte[] buffer = new byte[1024]; private int pos ,len ; private int cur ; private StringBuilder sb = new StringBuilder(32); InputReader( String name)throws IOException{ if ( name.equals("__std")) {stream = System.in; } else {stream = new FileInputStream(name); }cur = read(); } private int read()throws IOException { if ( (len == -1)) {throw (new EOFException());} if ( (pos >= len)) {pos = 0; len = stream.read(buffer); if ( (len == -1)) return -1; } return buffer[pos++];} int readInt()throws IOException { if ( (cur == -1)) {throw (new EOFException());} while(whitespace()){cur = read(); }if ( (cur == -1)) {throw (new EOFException());} int sign = 1; if ( (cur == '-')) {sign = -1; cur = read(); } int res = 0; while(!whitespace()){if ( ((cur < '0') || (cur > '9'))) {throw (new NumberFormatException());} res *= 10; res += (cur - '0'); cur = read(); }return (res * sign);} String readToken()throws IOException { if ( (cur == -1)) {throw (new EOFException());} while(whitespace()){cur = read(); }if ( (cur == -1)) {throw (new EOFException());} sb.setLength(0); while(!whitespace()){sb.append((char)cur); cur = read(); }return sb.toString();} boolean whitespace(){ return (((((cur == ' ') || (cur == '\t')) || (cur == '\r')) || (cur == '\n')) || (cur == -1));} } class OutputWriter{ private PrintWriter writer ; OutputWriter( String name)throws IOException{ if ( name.equals("__std")) {writer = new PrintWriter(System.out); } else {writer = new PrintWriter(name); }} void print( String format, Object... args){ writer.print(new Formatter(Locale.US).format(format,args)); } void println( String format, Object... args){ writer.println(new Formatter(Locale.US).format(format,args)); } void print( Object value){ writer.print(value); } void println( Object value){ writer.println(value); } void println(){ writer.println(); } void close(){ writer.close(); } } }
4	public class Solution{ public static void main( String[] args){ new Solution().calc(); } void calc(){ Scanner cin = new Scanner(System.in);  String s = cin.next();  int ret = 0; for ( int i = 0;(i < s.length());i++) {for ( int j = (i + 1);(j < s.length());j++) {for ( int k = 0;((j + k) < s.length());k++) {if ( (s.charAt((i + k)) != s.charAt((j + k)))) break; ret = Math.max((k + 1),ret); }}}System.out.println(ret); } }
1	public class Solution implements Runnable{ public static void main( String[] args){ new Thread(new Solution()).start(); } BufferedReader in ; PrintWriter out ; StringTokenizer st ; String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} String sti( String s){ int res = 0;  int q = 1;  int qq = 0; for ( int i = 0;(i < s.length());i++) {if ( (i > 0)) qq += q; res = (((res * 26) + s.charAt(i)) - 'A'); q *= 26; }return Integer.toString(((qq + res) + 1));} String its( String s){ int q = Integer.parseInt(s);  String res = "";  int w = 26;  int l = 1; while((q > w)){q -= w; l++; w *= 26; }q--; if ( (q == 0)) return "A"; while((q > 0)){res = (("" + (char)('A' + (q % 26))) + res); l--; q /= 26; }for ( ;(l > 0);l--) res = ("A" + res); return res;} void solve()throws IOException { int n = nextInt(); for ( int i = 0;(i < n);i++) { String s = nextToken();  int j = 0; while(!Character.isDigit(s.charAt(j)))j++; int q = (j + 1); while(((q < s.length()) && Character.isDigit(s.charAt(q))))q++; if ( (q == s.length())) {out.println(((("R" + s.substring(j)) + "C") + sti(s.substring(0,j)))); } else { String w = s.substring(j,q); while(!Character.isDigit(s.charAt(q)))q++; out.println((its(s.substring(q)) + w)); }}} }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(in.readLine()); System.out.println(((n / 2) * 3)); } }
4	public class Main{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } static final int N = 205; static final int mod = 1000000007; static final int INF = 1000000009; static final int numBit = 17; static FastReader r = new FastReader(); static PrintWriter pw = new PrintWriter(System.out); public static void main( String[] args)throws IOException { int n = r.nextInt();  int m = r.nextInt();  int k = r.nextInt();  int[][] hor = new int[n][(m - 1)];  int[][] ver = new int[(n - 1)][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < (m - 1));++j) hor[i][j] = r.nextInt(); }for ( int i = 0;(i < (n - 1));++i) {for ( int j = 0;(j < m);++j) ver[i][j] = r.nextInt(); } int[][] dp = new int[n][m]; if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) dp[i][j] = -1; }} else { int[][] new_dp = new int[n][m]; for ( int step = 0;(step < (k / 2));++step) {for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {new_dp[i][j] = INF; if ( (i > 0)) {new_dp[i][j] = Math.min(new_dp[i][j],(dp[(i - 1)][j] + (ver[(i - 1)][j] * 2))); } if ( (i < (n - 1))) {new_dp[i][j] = Math.min(new_dp[i][j],(dp[(i + 1)][j] + (ver[i][j] * 2))); } if ( (j > 0)) {new_dp[i][j] = Math.min(new_dp[i][j],(dp[i][(j - 1)] + (hor[i][(j - 1)] * 2))); } if ( (j < (m - 1))) {new_dp[i][j] = Math.min(new_dp[i][j],(dp[i][(j + 1)] + (hor[i][j] * 2))); } }}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {dp[i][j] = new_dp[i][j]; }}}}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {pw.print((dp[i][j] + " ")); }pw.println(); }pw.close(); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int r = in.nextInt();  ArrayList<PointDouble> centers = new ArrayList<>();  ArrayList<Integer> xs = new ArrayList<>(); for ( int i = 0;(i < n);++i) { int x = in.nextInt();  double y = r; for ( int j = 0;(j < centers.size());j++) { int ox = xs.get(j); if ( (Math.abs((ox - x)) > (2 * r))) continue; PointDouble c = centers.get(j);  double t = Math.abs((ox - x));  double h = Math.sqrt(Math.abs((((4.0 * r) * r) - (t * t))));  double val = (c.y + h); if ( (y < val)) y = val; }out.print(String.format("%.20f ",y)); centers.add(new PointDouble(x,y)); xs.add(x); }out.printLine(); } } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } } static class InputReader{ private InputStream stream ; private byte[] buffer = new byte[10000]; private int cur ; private int count ; public InputReader( InputStream stream){ this.stream = stream; } public static boolean isSpace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int read(){ if ( (count == -1)) {throw (new InputMismatchException());} try{if ( (cur >= count)) {cur = 0; count = stream.read(buffer); if ( (count <= 0)) return -1; } }catch (IOException e){ throw (new InputMismatchException());} return buffer[cur++];} public int readSkipSpace(){ int c ; do {c = read(); }while(isSpace(c));return c;} public int nextInt(){ int sgn = 1;  int c = readSkipSpace(); if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res = (((res * 10) + c) - '0'); c = read(); }while(!isSpace(c));res *= sgn; return res;} } static class PointDouble{ public double x ; public double y ; public PointDouble( double x, double y){ this.x = x; this.y = y; } public PointDouble(){ x = 0; y = 0; } } }
0	public final class b1{ public static void main( String[] args){ Scanner datain = new Scanner(System.in);  long l = datain.nextLong();  long r = datain.nextLong(); if ( ((r - l) < 2)) {System.out.print(-1); } else {if ( (((r - l) == 2) && ((l % 2) == 1))) {System.out.print(-1); } else {if ( ((l % 2) == 0)) {System.out.print(((((("" + l) + " ") + (l + 1)) + " ") + (l + 2))); } else {System.out.print(((((("" + (l + 1)) + " ") + (l + 2)) + " ") + (l + 3))); }}}} }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int one ,two ; if ( ((n % 2) == 0)) {one = two = (n / 2); if ( (((one % 2) != 0) && ((two % 2) != 0))) {one--; two++; } } else {one = (n - 9); two = 9; }System.out.println(((one + " ") + two)); } }
5	public class a{ public static void main( String[] args)throws IOException { input.init(System.in); int n = input.nextInt(),k = input.nextInt();  TreeSet<Integer> ts = new TreeSet<Integer>();  int[] data = new int[n]; for ( int i = 0;(i < n);i++) {data[i] = input.nextInt(); }Arrays.sort(data); if ( ((n > 1) && (k == ((1. * data[(n - 1)]) / data[0])))) System.out.println((n - 1)); else {for ( int i = 0;(i < n);i++) {if ( ((data[i] % k) != 0)) ts.add(data[i]); else {if ( !ts.contains((data[i] / k))) ts.add(data[i]); }}System.out.println(ts.size()); }} }
6	public class Round8_C{ int n ; int[] X ,Y ; public Round8_C(){ info_in(); process(); } void info_in(){ Scanner input = new Scanner(System.in);  int dx = input.nextInt();  int dy = input.nextInt(); n = input.nextInt(); X = new int[n]; Y = new int[n]; for ( int i = 0;(i < n);i++) {X[i] = (input.nextInt() - dx); Y[i] = (input.nextInt() - dy); }} int[] d ; int[] trace ; public static int distance( int x1, int y1, int x2, int y2){ return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));} void process(){ int gh = (1 << n); d = new int[gh]; trace = new int[gh]; d[0] = 0; for ( int i = 1;(i < gh);i++) {d[i] = Integer.MAX_VALUE; for ( int j = 0;(j < n);j++) if ( ((i & (1 << j)) > 0)) { int val = (d[(i ^ (1 << j))] + (distance(X[j],Y[j],0,0) << 1)); if ( (val < d[i])) {d[i] = val; trace[i] = (j + 1); } int state = (i ^ (1 << j)); for ( int p = (j + 1);(p < n);p++) if ( ((i & (1 << p)) > 0)) {val = (((d[(state ^ (1 << p))] + distance(X[j],Y[j],0,0)) + distance(X[j],Y[j],X[p],Y[p])) + distance(X[p],Y[p],0,0)); if ( (val < d[i])) {d[i] = val; trace[i] = (((j + 1) * 100) + (p + 1)); } } break;} }System.out.println(d[(gh - 1)]); gh--; while((gh > 0)){ int v1 = ((trace[gh] / 100) - 1);  int v2 = ((trace[gh] % 100) - 1); System.out.print((0 + " ")); if ( (v1 != -1)) {System.out.print(((v1 + 1) + " ")); gh -= (1 << v1); } System.out.print(((v2 + 1) + " ")); gh -= (1 << v2); }System.out.println(0); } public static void main( String[] args){ new Round8_C(); } }
0	public class E{ static Scanner in ; static int next()throws Exception { return in.nextInt();} static PrintWriter out ; public static void main( String[] args)throws Exception { in = new Scanner(System.in); out = new PrintWriter(System.out); int n = next(); if ( (((((((((((((((n % 4) == 0) || ((n % 7) == 0)) || ((n % 44) == 0)) || ((n % 47) == 0)) || ((n % 74) == 0)) || ((n % 77) == 0)) || ((n % 444) == 0)) || ((n % 447) == 0)) || ((n % 474) == 0)) || ((n % 744) == 0)) || ((n % 774) == 0)) || ((n % 747) == 0)) || ((n % 477) == 0)) || ((n % 777) == 0))) out.println("YES"); else out.println("NO"); out.println(); out.close(); } }
0	public class Main{ FastScanner in ; PrintWriter out ; static final String FILE = ""; public void solve(){ out.print(25); } public void run(){ if ( FILE.equals("")) {in = new FastScanner(System.in); out = new PrintWriter(System.out); } else {try{in = new FastScanner(new FileInputStream((FILE + ".in"))); out = new PrintWriter(new FileOutputStream((FILE + ".out"))); }catch (FileNotFoundException e){ e.printStackTrace(); } }solve(); out.close(); } public static void main( String[] args){ new Main().run(); } class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} } }
4	public class Main{ public static void main( String[] args)throws IOException { InputStreamReader in = new InputStreamReader(System.in);  BufferedReader br = new BufferedReader(in);  int t = Integer.parseInt(br.readLine());  int A = 10000000;  int[] convert = new int[(A + 1)]; for ( int a = 1;(a <= A);a++) {convert[a] = a; }for ( int a = 2;(a <= (A / a));a++) { int sq = (a * a); for ( int b = sq;(b <= A);b += sq) {while(((convert[b] % sq) == 0)){convert[b] /= sq; }}} int[] prevIndex = new int[(A + 1)]; for ( int i = 0;(i <= A);i++) {prevIndex[i] = -1; }for ( int c = 0;(c < t);c++) { StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int k = Integer.parseInt(st.nextToken());  int[] a = new int[n];  int maxA = 0; st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {a[i] = convert[Integer.parseInt(st.nextToken())]; maxA = Math.max(maxA,a[i]); } int[] partitions = new int[(k + 1)];  int[] partIndex = new int[(k + 1)]; for ( int i = 0;(i < n);i++) { int cur = a[i]; for ( int j = k;(j >= 0);j--) {if ( (prevIndex[cur] >= partIndex[j])) {partitions[j]++; partIndex[j] = i; } if ( ((j > 0) && ((partitions[(j - 1)] < partitions[j]) || ((partitions[(j - 1)] == partitions[j]) && (partIndex[(j - 1)] > partIndex[j]))))) {partitions[j] = partitions[(j - 1)]; partIndex[j] = partIndex[(j - 1)]; } }prevIndex[cur] = i; }System.out.println((partitions[k] + 1)); for ( int i = 0;(i < n);i++) { int cur = a[i]; prevIndex[cur] = -1; }}} }
5	public class A{ static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st ; static PrintWriter out = new PrintWriter(System.out); static String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String s = bf.readLine(); if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(nextToken());} public static void main( String[] args)throws IOException { int n = nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }Arrays.sort(a); for ( int q = 0;(q < n);q++) {if ( (a[q] != 1)) {out.print("1"); for ( int i = 1;(i < n);i++) {out.print((" " + a[(i - 1)])); }out.flush(); return ;} }for ( int i = 0;(i < (n - 1));i++) {out.print("1 "); }out.println("2"); out.flush(); } }
6	public class Main{ static int n ,exp ; static double arr[][] ,dp[] ,dies[][] ; public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = new Integer(br.readLine()); arr = new double[n][n]; StringTokenizer st ; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < n);j++) {arr[i][j] = Double.parseDouble(st.nextToken()); }}exp = (1 << n); dp = new double[exp]; dies = new double[n][exp]; for ( int all = 0;(all < exp);all++) {dp[all] = -1; int countAlive = 0; for ( int i = 0;(i < n);i++) {if ( ((all & (1 << i)) != 0)) countAlive++; }if ( (countAlive < 2)) continue; double x = (1.0 / ((countAlive * (countAlive - 1)) / 2.0)); for ( int i = 0;(i < n);i++) {dies[i][all] = 0; int mask = (1 << i); if ( ((mask & all) > 0)) {for ( int j = 0;(j < n);j++) { int mask2 = (1 << j); if ( ((mask2 & all) > 0)) dies[i][all] += arr[j][i]; }dies[i][all] *= x; } }}for ( int myFish = 0;(myFish < n);myFish++) {if ( (myFish > 0)) System.out.printf(" "); System.out.printf("%.6f",ff((1 << myFish))); }System.out.println(); } static double ff( int state){ if ( (state == (exp - 1))) return 1; if ( (dp[state] != -1)) return dp[state]; double ans = 0; for ( int i = 0;(i < n);i++) { int mask = (1 << i); if ( ((mask & state) == 0)) {ans += (dies[i][(state + mask)] * ff((state + mask))); } }return dp[state] = ans;} }
3	public class Main{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); }Arrays.sort(arr); int[] visited = new int[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( (visited[i] == 0)) {ans++; for ( int j = (i + 1);(j < n);j++) {if ( (((arr[j] % arr[i]) == 0) && (visited[j] == 0))) {visited[j] = 1; } }} }System.out.println(ans); } }
6	public class B{ static int ourLevel ; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int k = Integer.parseInt(st.nextToken()); ourLevel = Integer.parseInt(st.nextToken()); State[] list = new State[n]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); list[i] = new State(Integer.parseInt(st.nextToken()),(Integer.parseInt(st.nextToken()) / 10)); }System.out.println(solve(list,0,k)); } public static double solve( State[] s, int index, int left){ if ( (index == s.length)) return prob(s); double ret = 0; for ( int c = 0;((c <= left) && ((s[index].prob + c) <= 10));c++) {s[index].prob += c; ret = Math.max(ret,solve(s,(index + 1),(left - c))); s[index].prob -= c; }return ret;} public static double prob( State[] s){ double win = 1; for ( int i = 0;(i < (1 << s.length));i++) { int numLose = (s.length - Integer.bitCount(i)); if ( ((2 * numLose) >= s.length)) { int level = 0;  double p = 1; for ( int j = 0;(j < s.length);j++) {if ( ((i & (1 << j)) == 0)) {p *= ((10 - s[j].prob) / 10.); level += s[j].level; } else {p *= (s[j].prob / 10.); }} double lose = ((level * 1.0) / (ourLevel + level)); win -= (p * lose); } }return win;} static class State{ public int level ,prob ; public State( int a, int b){ level = a; prob = b; } } }
2	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  long n = Long.parseLong(st.nextToken());  long s = Long.parseLong(st.nextToken());  long posible = binarySearch(n,s);  long dig ,answer ;  long i ,cmed ; for ( i = posible;(i >= 0);i--) {dig = 0; cmed = i; while((cmed > 0)){dig = (dig + (cmed % 10)); cmed /= 10; }if ( ((i - dig) < s)) {break;} }answer = (n - i); System.out.println(answer); } private static long binarySearch( long n, long s){ long med = n,l = 0,r = n,cmed ,dig ; while((l <= r)){med = ((l + r) / 2); cmed = med; dig = 0; while((cmed > 0)){dig = (dig + (cmed % 10)); cmed /= 10; }if ( ((med - dig) == s)) {break;} else {if ( ((med - dig) > s)) {r = (med - 1); } else {l = (med + 1); }}}return med;} }
3	public class Solution{ public static void main( String[] args)throws Exception { MyReader reader = new MyReader(System.in);  MyWriter writer = new MyWriter(System.out); new Solution().run(reader,writer); writer.close(); } private void run( MyReader reader, MyWriter writer)throws Exception { char[] c = reader.nextCharArray();  int n = c.length;  int[] x = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = (c[i] - '0'); } long mod = 1_000_000_007;  long[] p = new long[(n + 1)];  long[] s = new long[(n + 1)]; p[0] = 1; for ( int i = 1;(i <= n);i++) {p[i] = ((p[(i - 1)] * 10) % mod); }s[n] = 1; for ( int i = (n - 1);(i >= 0);i--) {s[i] = (((p[((n - i) - 1)] * x[i]) + s[(i + 1)]) % mod); } long[][][] d = new long[(n + 1)][(n + 1)][2];  long ans = 0; for ( int i = 1;(i < 10);i++) {for ( long[][] q :d) {for ( long[] w :q) {Arrays.fill(w,0); }}for ( int j = 0;(j <= n);j++) {d[j][0][0] = s[j]; d[j][0][1] = p[(n - j)]; }for ( int j = (n - 1);(j >= 0);j--) {for ( int k = 1;(k <= n);k++) {for ( int l = 1;(l >= 0);l--) { int lim = ((l == 1)?10:(x[j] + 1)); for ( int m = 0;(m < lim);m++) {d[j][k][l] += d[(j + 1)][(k - ((m >= i)?1:0))][(((l == 1) || (m < x[j]))?1:0)]; d[j][k][l] %= mod; }}if ( (j == 0)) {ans = ((ans + (p[(k - 1)] * d[0][k][0])) % mod); } }}}System.out.println(ans); } static class MyReader{ final BufferedInputStream in ; final int bufSize = (1 << 16); final byte buf[] = new byte[bufSize]; int i = bufSize; int k = bufSize; boolean end = false; final StringBuilder str = new StringBuilder(); MyReader( InputStream in){ this.in = new BufferedInputStream(in,bufSize); } int nextInt()throws IOException { return (int)nextLong();} int[] nextIntArray( int n)throws IOException { int[] m = new int[n]; for ( int i = 0;(i < n);i++) {m[i] = nextInt(); }return m;} long nextLong()throws IOException { int c ;  long x = 0;  boolean sign = true; while(((c = nextChar()) <= 32));if ( (c == '-')) {sign = false; c = nextChar(); } if ( (c == '+')) {c = nextChar(); } while((c >= '0')){x = ((x * 10) + (c - '0')); c = nextChar(); }return (sign?x:-x);} int nextChar()throws IOException { if ( (i == k)) {k = in.read(buf,0,bufSize); i = 0; } return ((i >= k)?-1:buf[i++]);} String nextString()throws IOException { if ( end) {return null;} str.setLength(0); int c ; while((((c = nextChar()) <= 32) && (c != -1)));if ( (c == -1)) {end = true; return null;} while((c > 32)){str.append((char)c); c = nextChar(); }return str.toString();} char[] nextCharArray()throws IOException { return nextString().toCharArray();} } static class MyWriter{ final BufferedOutputStream out ; final int bufSize = (1 << 16); final byte buf[] = new byte[bufSize]; int i = 0; final byte c[] = new byte[30]; static final String newLine = System.getProperty("line.separator"); MyWriter( OutputStream out){ this.out = new BufferedOutputStream(out,bufSize); } void print( long x)throws IOException { int j = 0; if ( ((i + 30) >= bufSize)) {flush(); } if ( (x < 0)) {buf[i++] = (byte)'-'; x = -x; } while(((j == 0) || (x != 0))){c[j++] = (byte)((x % 10) + '0'); x /= 10; }while((j-- > 0))buf[i++] = c[j]; } void print( int[] m)throws IOException { for ( int a :m) {print(a); print(' '); }} void print( long[] m)throws IOException { for ( long a :m) {print(a); print(' '); }} void print( String s)throws IOException { for ( int i = 0;(i < s.length());i++) {print(s.charAt(i)); }} void print( char x)throws IOException { if ( (i == bufSize)) {flush(); } buf[i++] = (byte)x; } void print( char[] m)throws IOException { for ( char c :m) {print(c); }} void println( String s)throws IOException { print(s); println(); } void println()throws IOException { print(newLine); } void flush()throws IOException { out.write(buf,0,i); out.flush(); i = 0; } void close()throws IOException { flush(); out.close(); } } }
5	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] A = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {A[i] = in.nextInt(); sum += A[i]; }Arrays.sort(A); int cnt = 0;  int temp = 0; for ( int i = (n - 1);(i >= 0);i--) {temp += A[i]; sum -= A[i]; cnt++; if ( (temp > sum)) break; }System.out.println(cnt); } }
6	public class E implements Runnable{ public static void main( String[] args){ new Thread(null,new E(),"_cf",(1 << 28)).start(); } int n ,m ; char[] str ; int[][] occs ,cost ; int[] dp ; int oo = (int)1e9; int min( int a, int b){ if ( (a < b)) return a; return b;} class FastScanner{ public int BS = (1 << 16); public char NC = (char)0; byte[] buf = new byte[BS]; int bId = 0,size = 0; char c = NC; double num = 1; BufferedInputStream in ; public FastScanner(){ in = new BufferedInputStream(System.in,BS); } public FastScanner( String s){ try{in = new BufferedInputStream(new FileInputStream(new File(s)),BS); }catch (Exception e){ in = new BufferedInputStream(System.in,BS); } } public char nextChar(){ while((bId == size)){try{size = in.read(buf); }catch (Exception e){ return NC;} if ( (size == -1)) return NC; bId = 0; }return (char)buf[bId++];} public int nextInt(){ return (int)nextLong();} public long nextLong(){ num = 1; boolean neg = false; if ( (c == NC)) c = nextChar(); for ( ;((c < '0') || (c > '9'));c = nextChar()) {if ( (c == '-')) neg = true; } long res = 0; for ( ;((c >= '0') && (c <= '9'));c = nextChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); num *= 10; }return (neg?-res:res);} public String next(){ StringBuilder res = new StringBuilder(); while((c <= 32))c = nextChar(); while((c > 32)){res.append(c); c = nextChar(); }return res.toString();} } }
1	public class Main{ static Scanner sc ; static PrintWriter out ; public static void main( String[] args){ sc = new Scanner(System.in); out = new PrintWriter(System.out); int t = 1; if ( true) {t = sc.nextInt(); } for ( int i = 0;(i < t);i++) {new Main().solve(); }out.flush(); } public void solve(){ long n = sc.nextInt(); if ( ((n % 2) == 1)) {out.println("NO"); return ;} for ( long i = 1;(((i * i) * 2) <= n);i++) {if ( ((((i * i) * 2) == n) || (((i * i) * 4) == n))) {out.println("YES"); return ;} }out.println("NO"); } }
6	public class Bag implements Runnable{ private void solve()throws IOException { int xs = nextInt();  int ys = nextInt();  int n = nextInt();  int[] x = new int[n];  int[] y = new int[n]; for ( int i = 0;(i < n);++i) {x[i] = nextInt(); y[i] = nextInt(); }final int[][] pair = new int[n][n]; for ( int i = 0;(i < n);++i) for ( int j = (i + 1);(j < n);++j) pair[i][j] = (((((((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys))) + ((x[j] - xs) * (x[j] - xs))) + ((y[j] - ys) * (y[j] - ys))) + ((x[j] - x[i]) * (x[j] - x[i]))) + ((y[j] - y[i]) * (y[j] - y[i]))); final int[] single = new int[n]; for ( int i = 0;(i < n);++i) {single[i] = (2 * (((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys)))); }final int[] best = new int[(1 << n)]; final int[] prev = new int[(1 << n)]; for ( int set = 1;(set < (1 << n));++set) { int i ; for ( i = 0;(i < n);++i) if ( ((set & (1 << i)) != 0)) break; int bestC = (best[(set ^ (1 << i))] + single[i]);  int prevC = (1 << i);  int nextSet = (set ^ (1 << i));  int unoI = (1 << i);  int msc = (set >> (i + 1)); for ( int j = (i + 1),unoJ = (1 << (i + 1));((msc != 0) && (j < n));++j,unoJ <<= 1,msc >>= 1) if ( ((msc & 1) != 0)) { int cur = (best[(nextSet ^ unoJ)] + pair[i][j]); if ( (cur < bestC)) {bestC = cur; prevC = (unoI | unoJ); } } best[set] = bestC; prev[set] = prevC; }writer.println(best[((1 << n) - 1)]); int now = ((1 << n) - 1); writer.print("0"); while((now > 0)){ int differents = prev[now]; for ( int i = 0;(i < n);i++) if ( ((differents & (1 << i)) != 0)) {writer.print(" "); writer.print((i + 1)); now ^= (1 << i); } writer.print(" "); writer.print("0"); }writer.println(); } public static void main( String[] args){ new Bag().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
2	public class Code{ public Code(){ } public static void main( String[] args){ Scanner QQQ = new Scanner(System.in);  long l = QQQ.nextLong();  long r = QQQ.nextLong();  long ans = (l ^ r);  int a[] = new int[70];  int b[] = new int[70];  int n = 0,m = 0; while((l != 0)){a[m] = (int)(l % 2); l /= 2; m++; }while((r != 0)){b[n] = (int)(r % 2); r /= 2; n++; }m--; n--; long deg[] = new long[70]; deg[0] = 1; for ( int i = 1;(i <= 62);i++) deg[i] = (deg[(i - 1)] * 2); for ( int i = n;(i >= 0);i--) if ( ((b[i] == 1) && (a[i] == 0))) {System.out.println((deg[(i + 1)] - 1)); return ;} System.out.println(ans); } }
6	public class D11{ static HashMap<State,Integer> map ; static long[][] ans ; static boolean[][] connect ; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken()); map = new HashMap<State,Integer>(); connect = new boolean[n][n]; ans = new long[n][(1 << n)]; for ( int i = 0;(i < n);i++) Arrays.fill(ans[i],-1); int m = Integer.parseInt(st.nextToken()); while((m-- > 0)){st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken());  int b = Integer.parseInt(st.nextToken()); a--; b--; connect[a][b] = connect[b][a] = true; } long ret = 0;  int mask = (1 << n); mask--; for ( int i = 0;(i < n);i++) {for ( int out = (i + 1);(out < n);out++) {if ( connect[i][out]) {ret += solve((mask - (1 << out)),out,true); } }mask -= (1 << i); }System.out.println((ret / 2)); } public static long solve( int mask, int start, boolean a){ if ( (ans[start][mask] != -1)) return ans[start][mask]; int end = 0; while(((mask & (1 << end)) == 0))end++; long ret = 0; for ( int out = 0;(out < connect.length);out++) {if ( (connect[start][out] && ((mask & (1 << out)) != 0))) {if ( (out == end)) {if ( !a) ret++; } else ret += solve((mask - (1 << out)),out,false); } }ans[start][mask] = ret; return ret;} }
6	public class Main implements Runnable{ private int n ; private int nn ; private double[][] a ; private double[] dp ; private void solve()throws Throwable { n = nextInt(); nn = (1 << n); a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {a[i][j] = nextDouble(); }}dp = new double[nn]; Arrays.fill(dp,-1.0); dp[(nn - 1)] = 1.0; for ( int j = 0;(j < n);j++) {pw.format(Locale.US,"%.7f ",Dp((1 << j))); }} private double Dp( int i){ if ( (dp[i] >= 0.0)) return dp[i]; double ans = 0;  int count = Integer.bitCount(i); for ( int j = 0;(j < n);j++) { int jj = (1 << j); if ( ((jj & i) == 0)) { double p = Dp((jj | i));  double pPair = (2.0 / (double)((count + 1) * count));  double s = 0; for ( int l = 0;(l < n);l++) { int ll = (1 << l); if ( ((ll & i) != 0)) {s += a[l][j]; } }ans += ((p * pPair) * s); } }dp[i] = ans; return dp[i];} PrintWriter pw ; BufferedReader in ; StringTokenizer st ; void initStreams()throws FileNotFoundException { in = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); } String nextString()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextString());} double nextDouble()throws NumberFormatException,IOException { return Double.parseDouble(nextString());} static Throwable sError ; public static void main( String[] args)throws Throwable { Thread t = new Thread(new Main()); t.start(); t.join(); if ( (sError != null)) {throw (sError);} } }
3	public class Main{ static int dx[] = {-1,1,0,0}; static int dy[] = {0,0,1,-1}; static long MOD = 1000000007; static int INF = (Integer.MAX_VALUE / 10); static PrintWriter pw ; static Reader scan ; static int ni()throws IOException { return scan.nextInt();} static void psb( StringBuilder sb)throws IOException { pw.print(sb); } public static void main( String[] args){ new Thread(null,null,"BaZ",99999999){}.start(); } static void solve()throws IOException { Calendar CAL1 = Calendar.getInstance(); CAL1.setTime(new Date()); scan = new Reader(); pw = new PrintWriter(System.out,true); StringBuilder sb = new StringBuilder();  int n = ni();  int inv = 0;  int arr[] = new int[n]; for ( int i = 0;(i < n);++i) {arr[i] = ni(); for ( int j = 0;(j < i);++j) if ( (arr[j] > arr[i])) inv = (1 - inv); } int q = ni(); while((q-- > 0)){ int l = ni();  int r = ni();  int par = c2(((r - l) + 1)); par &= 1; if ( (par != 0)) inv = (1 - inv); if ( (inv == 0)) sb.append("even\n"); else sb.append("odd\n"); }psb(sb); Calendar CAL2 = Calendar.getInstance(); CAL2.setTime(new Date()); double Execution_Time = ((double)(CAL2.getTimeInMillis() - CAL1.getTimeInMillis()) / 1000.000); pw.flush(); pw.close(); } static int c2( int n){ return ((n * (n - 1)) >> 1);} static class Reader{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Reader(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine()throws IOException { byte[] buf = new byte[64];  int cnt = 0,c ; while(((c = read()) != -1)){if ( (c == '\n')) break; buf[cnt++] = (byte)c; }return new String(buf,0,cnt);} public int nextInt()throws IOException { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} public long nextLong()throws IOException { long ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} public double nextDouble()throws IOException { double ret = 0,div = 1;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( (c == '.')) while((((c = read()) >= '0') && (c <= '9')))ret += ((c - '0') / (div *= 10)); if ( neg) return -ret; return ret;} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } }
1	public class Main{ final long mod = ((int)1e9 + 7),IINF = (long)1e19; final int MAX = ((int)5e5 + 1),MX = ((int)1e7 + 1),INF = (int)1e9,root = 3; DecimalFormat df = new DecimalFormat("0.0000000000000"); double eps = 1e-9,PI = 3.141592653589793238462643383279502884197169399375105820974944; static boolean multipleTC = false,memory = false; FastReader in ; PrintWriter out ; public static void main( String[] args)throws Exception { if ( memory) new Thread(null,new Runnable(){public void run(){ try{new Main().run(); }catch (Exception e){ e.printStackTrace(); } } },"1",(1 << 28)).start(); else new Main().run(); } void run()throws Exception { in = new FastReader(); out = new PrintWriter(System.out); for ( int i = 1,T = (multipleTC?ni():1);(i <= T);i++) solve(i); out.flush(); out.close(); } void solve( int TC)throws Exception { int n = ni();  long d = nl();  long ans = 2;  long[] p = new long[n]; for ( int i = 0;(i < n);i++) p[i] = nl(); for ( int i = 1;(i < n);i++) {if ( ((p[i] - p[(i - 1)]) == (2 * d))) ans++; else if ( ((p[i] - p[(i - 1)]) > (2 * d))) ans += 2; }pn(ans); } int[] sort( int[] a){ if ( (a.length == 1)) return a; int mid = (a.length / 2);  int[] b = sort(Arrays.copyOfRange(a,0,mid)),c = sort(Arrays.copyOfRange(a,mid,a.length)); for ( int i = 0,j = 0,k = 0;(i < a.length);i++) {if ( ((j < b.length) && (k < c.length))) {if ( (b[j] < c[k])) a[i] = b[j++]; else a[i] = c[k++]; } else if ( (j < b.length)) a[i] = b[j++]; else a[i] = c[k++]; }return a;} long[] sort( long[] a){ if ( (a.length == 1)) return a; int mid = (a.length / 2);  long[] b = sort(Arrays.copyOfRange(a,0,mid)),c = sort(Arrays.copyOfRange(a,mid,a.length)); for ( int i = 0,j = 0,k = 0;(i < a.length);i++) {if ( ((j < b.length) && (k < c.length))) {if ( (b[j] < c[k])) a[i] = b[j++]; else a[i] = c[k++]; } else if ( (j < b.length)) a[i] = b[j++]; else a[i] = c[k++]; }return a;} long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} int bitcount( long n){ return ((n == 0)?0:(1 + bitcount((n & (n - 1)))));} void pn( Object o){ out.println(o); } int ni(){ return Integer.parseInt(in.next());} long nl(){ return Long.parseLong(in.next());} class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader( String s)throws Exception{ br = new BufferedReader(new FileReader(s)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} String nextLine(){ String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} } }
5	public class Main2{ public static void main( String[] args)throws Exception { new Main2().run(); } public void solve()throws Exception { n = nextInt(); int a[] = new int[n],pos = 1; for ( int i = 0;(i < n);i++) a[i] = nextInt(); Arrays.sort(a); if ( (n == 1)) {out.println("NO"); return ;} boolean has = false; for ( ;(pos < n);pos++) {if ( (a[pos] != a[0])) {has = true; break;} }if ( !has) {out.println("NO"); } else {out.println(a[pos]); }} public int n ,m ; public void run()throws Exception { inter = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } public BufferedReader in ; public StreamTokenizer inter ; public PrintWriter out ; public int nextInt()throws Exception { inter.nextToken(); return (int)inter.nval;} }
6	public class cf112e{ static int n ,m ,s ; static int[][][] memo ; public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextInt(); m = in.nextInt(); if ( (n > m)) { int tmp = n; n = m; m = tmp; } s = (1 << n); memo = new int[s][s][m]; for ( int i = 0;(i < s);i++) for ( int j = 0;(j < s);j++) Arrays.fill(memo[i][j],-1); int ret = go(0,0,0); System.out.println(((n * m) - ret)); } static int go( int last, int trans, int r){ if ( (r == m)) {if ( (trans == 0)) return 0; return 100;} if ( (memo[last][trans][r] != -1)) return memo[last][trans][r]; int best = 100; for ( int crnt = 0;(crnt < s);crnt++) {if ( ((trans & ~crnt) != 0)) continue; for ( int pass = 0;(pass < s);pass++) { int tmp = (((1 << n) - 1) & ~last); if ( ((pass & ~tmp) != 0)) continue; tmp = (tmp & ~pass); boolean fail = false; for ( int k = 0;(k < n);k++) if ( (isSet(tmp,k) && ((isSet(crnt,(k - 1)) || isSet(crnt,k)) || isSet(crnt,(k + 1))))) fail = true; if ( fail) continue; best = Math.min(best,(Integer.bitCount(crnt) + go(crnt,pass,(r + 1)))); }}return memo[last][trans][r] = best;} static boolean isSet( int x, int p){ if ( ((p < 0) || (p >= n))) return false; return ((x & (1 << p)) != 0);} }
4	public class Main{ private static BufferedReader br ; private static StringTokenizer st ; private static PrintWriter pw ; public static void main( String[] args)throws Exception { br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); int qq = Integer.MAX_VALUE; for ( int casenum = 1;(casenum <= qq);casenum++) { int r = readInt();  int c = readInt();  int n = readInt();  int[][] dist = new int[r][c]; for ( int i = 0;(i < r);i++) {Arrays.fill(dist[i],(1 << 25)); } LinkedList<State> q = new LinkedList<State>(); while((n-- > 0)){q.add(new State((readInt() - 1),(readInt() - 1))); dist[q.peekLast().x][q.peekLast().y] = 0; } int[] dx = new int[]{-1,1,0,0};  int[] dy = new int[]{0,0,-1,1};  State ret = q.peekLast(); while(!q.isEmpty()){ State curr = q.removeFirst(); ret = curr; for ( int k = 0;(k < dx.length);k++) { int nx = (curr.x + dx[k]);  int ny = (curr.y + dy[k]); if ( (((((nx >= 0) && (nx < r)) && (ny >= 0)) && (ny < c)) && (dist[nx][ny] > (1 + dist[curr.x][curr.y])))) {dist[nx][ny] = (1 + dist[curr.x][curr.y]); q.add(new State(nx,ny)); } }}pw.println((((ret.x + 1) + " ") + (ret.y + 1))); }exitImmediately(); } static class State{ public int x ,y ; public State( int x, int y){ super(); this.x = x; this.y = y; } } private static void exitImmediately(){ pw.close(); System.exit(0); } private static int readInt()throws IOException { return Integer.parseInt(nextToken());} private static String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){if ( !br.ready()) {exitImmediately(); } st = new StringTokenizer(br.readLine().trim()); }return st.nextToken();} }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  DOlyaIMagicheskiiKvadrat solver = new DOlyaIMagicheskiiKvadrat(); solver.solve(1,in,out); out.close(); } static class DOlyaIMagicheskiiKvadrat{ long inf = ((long)1e18 + 1); long[] maxLen ; public void solve( int testNumber, InputReader in, OutputWriter out){ maxLen = new long[100]; maxLen[1] = 0; for ( int i = 1;(i < maxLen.length);i++) {maxLen[i] = Math.min(inf,((maxLen[(i - 1)] * 4) + 1)); }if ( false) {for ( int n = 1;(n <= 3);n++) {for ( int k = 1;(k <= (maxSplitCount(n) + 20));k++) {out.print((((n + " ") + k) + " ")); int res = solve(n,k); if ( (res == -1)) {out.printLine("NO"); } else {out.printLine(("YES " + res)); }}}return ;} int q = in.readInt(); while((q-- > 0)){ int n = in.readInt();  long k = in.readLong();  int res = solve(n,k); if ( (res == -1)) {out.printLine("NO"); continue;} out.printLine(("YES " + res)); }} long maxSplitCount( int n){ if ( (n >= maxLen.length)) {return inf;} return maxLen[n];} int solve( int n, long k){ if ( (maxSplitCount(n) < k)) {return -1;} int at = 0; while((maxSplitCount((at + 1)) <= k)){at++; } int curSideLog = (n - at); k -= maxSplitCount(at); double sideLen = Math.pow(2,(n - curSideLog));  double pathLen = ((sideLen * 2) - 1); if ( ((curSideLog > 0) && (pathLen <= k))) {return (curSideLog - 1);} double area = (sideLen * sideLen);  double otherArea = (area - pathLen); if ( ((otherArea * (double)maxSplitCount(curSideLog)) >= k)) {return curSideLog;} return -1;} } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long readLong(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } } }
2	public class Main{ public static void main( String[] args){ FastReader reader = new FastReader();  PrintWriter writer = new PrintWriter(System.out);  long n = reader.nextLong();  long k = reader.nextLong();  long s = 0;  long e = n;  long ans = -1; while((s <= e)){ long m = ((s + e) / 2);  long temp = ((((n - m) * ((n - m) + 1)) / 2) - m); if ( (temp < k)) e = (m - 1); else if ( (temp > k)) s = (m + 1); else {ans = m; break;}}writer.println(ans); writer.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} long nextLong(){ return Long.parseLong(next());} } }
6	public class Main implements Runnable{ public static void main( String[] args){ new Thread(new Main()).start(); } int nextInt( StreamTokenizer st)throws IOException { st.nextToken(); return (int)st.nval;} public void run1()throws IOException { Scanner sc = new Scanner(new InputStreamReader(System.in));  int n = sc.nextInt();  int m = sc.nextInt();  boolean[][] arr = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = sc.nextInt();  int b = sc.nextInt(); arr[(a - 1)][(b - 1)] = true; arr[(b - 1)][(a - 1)] = true; } long[][] res = new long[n][(1 << n)]; for ( int mask = 1;(mask < (1 << n));mask++) { int min = -1; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {if ( (min == -1)) {min = i; if ( (mask == (1 << min))) res[min][mask] = 1; } for ( int j = (min + 1);(j < n);j++) if ( (((mask & (1 << j)) == 0) && arr[i][j])) {res[j][(mask | (1 << j))] += res[i][mask]; } } }} long r = 0; for ( int mask = 1;(mask < (1 << n));mask++) if ( (Integer.bitCount(mask) != 2)) for ( int j = 0;(j < n);j++) { int i = 0; while(((mask & (1 << i)) == 0))i++; if ( arr[i][j]) r += res[j][mask]; } System.out.println((r / 2)); } }
6	public class B{ Scanner in ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int k = ni();  int a = ni();  int[] lv = new int[n];  int[] lo = new int[n]; for ( int i = 0;(i < n);i++) {lv[i] = ni(); lo[i] = ni(); }out.printf("%.9f",rec(lv,lo,n,0,k,a)); } double rec( int[] lv, int[] lo, int n, int pos, int k, int a){ if ( (pos == n)) { int h = ((n / 2) + 1);  double gp = 0; for ( int i = 0;(i < (1 << n));i++) {if ( (Integer.bitCount(i) >= h)) { double p = 1.0; for ( int j = 0;(j < n);j++) {if ( ((i << (31 - j)) < 0)) {p *= ((double)lo[j] / 100); } else {p *= ((double)(100 - lo[j]) / 100); }}gp += p; } else { double p = 1.0;  int sl = 0; for ( int j = 0;(j < n);j++) {if ( ((i << (31 - j)) < 0)) {p *= ((double)lo[j] / 100); } else {p *= ((double)(100 - lo[j]) / 100); sl += lv[j]; }}gp += ((p * a) / (a + sl)); }}return gp;} else { int o = lo[pos];  double max = 0; for ( int i = 0;((i <= k) && (lo[pos] <= 100));i++) {max = Math.max(max,rec(lv,lo,n,(pos + 1),(k - i),a)); lo[pos] += 10; }lo[pos] = o; return max;}} void run()throws Exception { in = (oj?new Scanner(System.in):new Scanner(INPUT)); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new B().run(); } int ni(){ return Integer.parseInt(in.next());} boolean oj = (System.getProperty("ONLINE_JUDGE") != null); void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
6	public class E16{ static StreamTokenizer in ; static PrintWriter out ; static int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} static double nextDouble()throws IOException { in.nextToken(); return in.nval;} public static void main( String[] args)throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); n = nextInt(); t = (1 << n); m = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) m[i][j] = nextDouble(); memo = new double[t]; Arrays.fill(memo,Double.POSITIVE_INFINITY); for ( int i = 0;(i < n);i++) out.print((String.format(Locale.US,"%.6f",solve((1 << i))) + " ")); out.println(); out.flush(); } static int n ,t ; static double[][] m ; static double[] memo ; static double solve( int mask){ if ( (memo[mask] != Double.POSITIVE_INFINITY)) return memo[mask]; if ( (mask == (t - 1))) return memo[mask] = 1; int k = Integer.bitCount(mask); k = (((k + 1) * k) / 2); double res = 0; for ( int i = 0;(i < n);i++) if ( ((mask & (1 << i)) != 0)) for ( int j = 0;(j < n);j++) if ( ((mask & (1 << j)) == 0)) res += (m[i][j] * solve((mask | (1 << j))));  return memo[mask] = (res / k);} }
0	public class Recovery{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int N = scan.nextInt(); if ( ((N % 2) == 0)) {System.out.println(((4 + " ") + (N - 4))); } else System.out.println(((9 + " ") + (N - 9))); scan.close(); } }
6	public class SimpleTask{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int m = scan.nextInt();  boolean[][] graph = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int u = (scan.nextInt() - 1);  int v = (scan.nextInt() - 1); graph[u][v] = true; graph[v][u] = true; } long[][] dp = new long[(1 << n)][n];  long sum = 0; for ( int i = 0;(i < n);i++) dp[(1 << i)][i] = 1; for ( int mask = 1;(mask < (1 << n));mask++) { int first = Integer.numberOfTrailingZeros(mask); for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) == 0) || (first == i))) continue; for ( int j = 0;(j < n);j++) {if ( (graph[i][j] && ((mask & (1 << j)) != 0))) dp[mask][i] += dp[(mask ^ (1 << i))][j]; }if ( ((Integer.bitCount(mask) >= 3) && graph[i][first])) sum += dp[mask][i]; }}System.out.println((sum / 2)); scan.close(); } }
0	public class Ideone{ public static void main( String[] args)throws java.lang.Exception { long n ,s ,p ;  Scanner in = new Scanner(System.in); n = in.nextLong(); s = in.nextLong(); if ( ((n == 1) && (s <= 1))) {System.out.print((n - 1)); } else if ( (s < n)) {if ( ((s % 2) != 0)) {System.out.print((s / 2)); } else {System.out.print(((s / 2) - 1)); }} else if ( (s == n)) {if ( ((s % 2) == 0)) {System.out.println(((n / 2) - 1)); } else {System.out.println((n / 2)); }} else if ( (s <= ((2 * n) - 1))) {System.out.print(((((2 * n) + 1) - s) / 2)); } else {System.out.print(0); }} }
0	public class Solution{ private BufferedReader cin ; private PrintWriter cout ; private StringTokenizer strtok ; public static void main( String[] args)throws IOException { Solution sol = new Solution(); final boolean CONTEST = true; if ( CONTEST) {sol.cin = new BufferedReader(new InputStreamReader(System.in)); sol.cout = new PrintWriter(System.out); } else {sol.cin = new BufferedReader(new FileReader("input.txt")); sol.cout = new PrintWriter("output.txt"); }sol.solve(); sol.cin.close(); sol.cout.close(); } private int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} private String nextToken()throws IOException { while(((strtok == null) || !strtok.hasMoreTokens())){strtok = new StringTokenizer(cin.readLine()); }return strtok.nextToken();} private void solve()throws IOException { int n = nextInt(); if ( ((n % 2) == 0)) {cout.println((((n - 4) + " ") + 4)); } else {cout.println((((n - 9) + " ") + 9)); }} }
3	public class C{ public static void main( String[] args){ Scanner qwe = new Scanner(System.in);  int n = qwe.nextInt();  double r = qwe.nextDouble();  double[] fy = new double[n]; Arrays.fill(fy,r); double[] xs = new double[n]; for ( int i = 0;(i < xs.length);i++) {xs[i] = qwe.nextDouble(); }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) { double dx = (xs[j] - xs[i]); if ( (Math.abs(dx) > (2 * r))) continue; fy[j] = Math.max(fy[j],(Math.sqrt((((4 * r) * r) - (dx * dx))) + fy[i])); }} StringBuilder stb = new StringBuilder(); for ( int i = 0;(i < xs.length);i++) {stb.append((fy[i] + " ")); }System.out.println(stb); } }
5	public class Main{ void A(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a = sc.nextInt();  int b = sc.nextInt();  int[] h = new int[n]; for ( int i = 0;(i < n);i++) {h[i] = sc.nextInt(); }Arrays.sort(h); System.out.println((h[b] - h[(b - 1)])); } public static void main( String[] args){ new Main().A(); } }
6	public class Task16e{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  double[][] prob = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {prob[i][j] = sc.nextDouble(); }} double[] var = new double[(1 << n)];  boolean[] was = new boolean[(1 << n)]; Arrays.fill(var,0.0); Arrays.fill(was,false); was[0] = true; var[((1 << n) - 1)] = 1.0; Set<Integer> cr = new HashSet<Integer>();  Set<Integer> nx = new HashSet<Integer>(); nx.add(((1 << n) - 1)); boolean[] fish = new boolean[n]; for ( int cnt = 0;(cnt < (n - 1));cnt++) {cr.clear(); cr.addAll(nx); nx.clear(); for ( Iterator<Integer> iterator = cr.iterator();iterator.hasNext();) { int curr = iterator.next(); for ( int i = 0;(i < n);i++) {fish[i] = (((1 << i) & curr) != 0); } int fishn = 0; for ( int i = 0;(i < n);i++) {if ( fish[i]) fishn++; }if ( (fishn == 1)) continue; for ( int i = 0;(i < n);i++) {if ( !fish[i]) continue; for ( int j = (i + 1);(j < n);j++) {if ( !fish[j]) continue; int woi = (curr & (1 << i));  int woj = (curr & (1 << j)); var[woi] += (var[curr] * prob[j][i]); var[woj] += (var[curr] * prob[i][j]); nx.add(woi); nx.add(woj); }}}} double sum = 0.0; for ( int i = 0;(i < n);i++) {sum += var[(1 << i)]; }for ( int i = 0;(i < n);i++) {System.out.printf("%.6f ",(var[(1 << i)] / sum)); }} }
5	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] deals = new int[n]; for ( int i = 0;(i < n);i++) {deals[i] = in.nextInt(); }Arrays.sort(deals); System.out.println((deals[b] - deals[(b - 1)])); } }
2	public class Main{ private void solve()throws IOException { int n = nextInt();  int x = nextInt();  int y = nextInt();  int c = nextInt();  int lux = x;  int luy = (y + 1);  int rux = (x + 1);  int ruy = y;  int ldx = (x - 1);  int ldy = y;  int rdx = x;  int rdy = (y - 1);  int k = 1;  int res = 0; while((k < c)){lux--; luy--; rux--; ruy++; rdx++; rdy++; ldx++; ldy--; int p = 0; p += lu((x - 1),luy,lux,y,n); p += ru(x,ruy,rux,(y + 1),n); p += ld(x,ldy,ldx,(y - 1),n); p += rd((x + 1),rdy,rdx,y,n); k += p; res++; }println(res); } private int lu( int x1, int y1, int x2, int y2, int n){ if ( ((y1 > 0) && (x2 > 0))) {return ((x1 - x2) + 1);} else if ( ((y1 > 0) && (x2 < 1))) {return x1;} else if ( ((y1 < 1) && (x2 > 0))) {return y2;} else if ( ((x1 - (1 - y1)) > 0)) {return lu((x1 - (1 - y1)),1,x2,y2,n);} else {return 0;}} private int ru( int x1, int y1, int x2, int y2, int n){ if ( ((y1 <= n) && (x2 > 0))) {return ((x1 - x2) + 1);} else if ( ((y1 <= n) && (x2 < 1))) {return x1;} else if ( ((y1 > n) && (x2 > 0))) {return ((n - y2) + 1);} else if ( ((x1 - (y1 - n)) > 0)) {return ru((x1 - (y1 - n)),n,x2,y2,n);} else {return 0;}} private int ld( int x1, int y1, int x2, int y2, int n){ if ( ((y1 > 0) && (x2 <= n))) {return ((x2 - x1) + 1);} else if ( ((y1 > 0) && (x2 > n))) {return ((n - x1) + 1);} else if ( ((y1 < 1) && (x2 <= n))) {return y2;} else if ( ((x1 + (1 - y1)) <= n)) {return ld((x1 + (1 - y1)),1,x2,y2,n);} else {return 0;}} private int rd( int x1, int y1, int x2, int y2, int n){ if ( ((y1 <= n) && (x2 <= n))) {return ((x2 - x1) + 1);} else if ( ((y1 <= n) && (x2 > n))) {return ((n - x1) + 1);} else if ( ((y1 > n) && (x2 <= n))) {return ((n - y2) + 1);} else if ( ((x1 + (y1 - n)) <= n)) {return rd((x1 + (y1 - n)),n,x2,y2,n);} else {return 0;}} private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(reader.readLine()); }return st.nextToken();} @SuppressWarnings private int nextInt()throws IOException { return Integer.parseInt(next());} @SuppressWarnings private void println( Object o){ writer.println(o); } @SuppressWarnings private void print( Object o){ writer.print(o); } private BufferedReader reader ; private PrintWriter writer ; private StringTokenizer st ; private void run()throws IOException { long time = System.currentTimeMillis(); Locale.setDefault(Locale.US); reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(System.out); solve(); writer.close(); System.err.println((System.currentTimeMillis() - time)); } public static void main( String[] args)throws IOException { new Main().run(); } }
2	public class Main{ public static void main( String[] argv){ new Main(); } boolean test = false; int n ; long mod = 1000000007; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));  long x = in.nextLong();  long k = in.nextLong(); if ( (x == 0)) {System.out.println(0); return ;} if ( (k == 0)) {x %= mod; System.out.println(((2 * x) % mod)); return ;} x %= mod; long f = pow(2,k);  long ans = ((((((((2 * f) * x) % mod) - f) + 1) % mod) + mod) % mod); System.out.println(ans); } private long pow( long x, long y){ long ans = 1; while((y > 0)){if ( ((y % 2) == 1)) ans = ((ans * x) % mod); x = ((x * x) % mod); y /= 2; }return ans;} private long gcd( long x, long y){ if ( (y == 0)) return x; return gcd(y,(x % y));} static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader( BufferedReader in){ br = in; } String next(){ while(((st == null) || !st.hasMoreElements())){try{ String line = br.readLine(); if ( ((line == null) || (line.length() == 0))) return ""; st = new StringTokenizer(line); }catch (IOException e){ return "";} }return st.nextToken();} long nextLong(){ return Long.parseLong(next());} } }
2	public class D{ public static void main( String[] args)throws IOException { try(Input input=new StandardInput();PrintWriter writer=new PrintWriter(System.out)){ long[] s = new long[40]; for ( int i = 1;(i < s.length);i++) {s[i] = (1 + (4 * s[(i - 1)])); if ( (i >= 32)) {s[i] = Long.MAX_VALUE; } } Function<Integer,Long> getS = (i)->((i < s.length)?s[i]:Long.MAX_VALUE);  int t = input.nextInt(); for ( int tt = 0;(tt < t);tt++) { int n = input.nextInt();  long k = input.nextLong();  long kk = 1;  BigInteger maxDivisions = BigInteger.ZERO; for ( int division = 1;(division <= n);division++) { long needToDivide = ((1L << division) - 1); if ( (needToDivide > k)) {writer.println("NO"); continue testCase;} k -= needToDivide; maxDivisions = maxDivisions.add(BigInteger.valueOf(kk).multiply(BigInteger.valueOf(getS.apply((n - division))))); if ( (maxDivisions.compareTo(BigInteger.valueOf(k)) >= 0)) {writer.println(("YES " + (n - division))); continue testCase;} kk += (1L << (division + 1)); }writer.println("NO"); } }} interface Input extends Closeable{ String next()throws IOException ; default int nextInt()throws IOException { return Integer.parseInt(next());} default long nextLong()throws IOException { return Long.parseLong(next());} } private static class StandardInput implements Input{ private final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); private StringTokenizer stringTokenizer ; @Override public void close()throws IOException { reader.close(); } @Override public String next()throws IOException { if ( ((stringTokenizer == null) || !stringTokenizer.hasMoreTokens())) {stringTokenizer = new StringTokenizer(reader.readLine()); } return stringTokenizer.nextToken();} } }
3	public class G{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ char[] s = ns().toCharArray();  int mod = 1000000007;  int m = 702;  long[] bases = new long[(m + 1)]; bases[0] = 1; for ( int i = 1;(i <= m);i++) bases[i] = ((bases[(i - 1)] * 10) % mod); long ans = 0; for ( int d = 9;(d >= 1);d--) { int n = s.length;  long[] sum = new long[m];  long[] num = new long[m];  long esum = 0;  int ebase = 0; for ( int i = 0;(i < n);i++) { long[] nsum = new long[m];  long[] nnum = new long[m]; for ( int j = 0;(j < m);j++) {for ( int k = 0;(k <= 9);k++) {if ( ((k > d) && ((j + 1) < m))) {nsum[(j + 1)] += (sum[j] * 10); nsum[(j + 1)] %= mod; nnum[(j + 1)] += num[j]; if ( (nnum[(j + 1)] >= mod)) nnum[(j + 1)] -= mod; } if ( (k == d)) {nsum[j] += ((sum[j] * 10) + (num[j] * bases[j])); nsum[j] %= mod; nnum[j] += num[j]; if ( (nnum[j] >= mod)) nnum[j] -= mod; } if ( (k < d)) {nsum[j] += sum[j]; if ( (nsum[j] >= mod)) nsum[j] -= mod; nnum[j] += num[j]; if ( (nnum[j] >= mod)) nnum[j] -= mod; } }}for ( int k = 0;(k < (s[i] - '0'));k++) {if ( (k > d)) {nsum[(ebase + 1)] += (esum * 10); nsum[(ebase + 1)] %= mod; nnum[(ebase + 1)] += 1; if ( (nnum[(ebase + 1)] >= mod)) nnum[(ebase + 1)] -= mod; } if ( (k == d)) {nsum[ebase] += ((esum * 10) + bases[ebase]); nsum[ebase] %= mod; nnum[ebase] += 1; if ( (nnum[ebase] >= mod)) nnum[ebase] -= mod; } if ( (k < d)) {nsum[ebase] += esum; if ( (nsum[ebase] >= mod)) nsum[ebase] -= mod; nnum[ebase] += 1; if ( (nnum[ebase] >= mod)) nnum[ebase] -= mod; } }if ( ((s[i] - '0') > d)) {esum = (esum * 10); esum %= mod; ebase++; } else if ( ((s[i] - '0') == d)) {esum = ((esum * 10) + bases[ebase]); esum %= mod; } sum = nsum; num = nnum; } long all = esum; for ( int j = 0;(j < m);j++) {all += sum[j]; }ans += ((all % mod) * d); }out.println((ans % mod)); } void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new G().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
4	public class CF035C{ public static void main( String[] args)throws IOException { Scanner s = new Scanner(new File("input.txt"));  int n = s.nextInt();  int m = s.nextInt();  int k = s.nextInt();  Queue<pair> q = new LinkedList<>();  PrintWriter out = new PrintWriter(new FileWriter("output.txt"));  boolean[][] visited = new boolean[n][m]; for ( int i = 0;(i < k);i++) { int x = (s.nextInt() - 1);  int y = (s.nextInt() - 1); visited[x][y] = true; pair p = new pair(x,y); q.add(p); }q.add(null); int[] dx = {0,0,1,-1};  int[] dy = {1,-1,0,0};  int ansX = q.peek().x;  int ansY = q.peek().y; while(true){if ( (q.peek() == null)) {q.poll(); q.add(null); } pair p = q.poll(); if ( (p == null)) {break;} for ( int i = 0;(i < 4);i++) {if ( (isValid((p.x + dx[i]),(p.y + dy[i]),n,m) && !visited[(p.x + dx[i])][(p.y + dy[i])])) {q.add(new pair((p.x + dx[i]),(p.y + dy[i]))); ansX = (p.x + dx[i]); ansY = (p.y + dy[i]); visited[ansX][ansY] = true; } }}out.println((((ansX + 1) + " ") + (ansY + 1))); out.close(); } public static boolean isValid( int x, int y, int n, int m){ return ((((x >= 0) && (x < n)) && (y >= 0)) && (y < m));} private static class pair{ int x ; int y ; public pair( int x, int y){ this.x = x; this.y = y; } } }
3	public class A{ InputStream in ; PrintWriter out ; void solve(){ int n = ni();  int a[] = na(n);  int INV = 0; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( (a[i] > a[j])) INV++;  boolean even = ((INV % 2) == 0);  int q = ni(); while((q-- > 0)){ int l = ni();  int r = ni();  int len = ((r - l) + 1); len = (((len - 1) * len) / 2); if ( ((len % 2) == 1)) even = !even; if ( even) out.println("even"); else out.println("odd"); }} int MAX = (int)1e5; long factorial[] ; long mod = ((long)1e9 + 7); long mul( long a, long b){ a %= mod; b %= mod; long x = (a * b); return (x % mod);} void run()throws Exception { String INPUT = "C:/Users/ayubs/Desktop/input.txt"; in = (oj?System.in:new FileInputStream(INPUT)); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new A().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = in.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean inSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && inSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!inSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !inSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
6	public class Main{ Reader in = new Reader(System.in); PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws IOException { new Main().run(); } int n ; int[] x ,y ; int[][] time ; int status ; int[] dp ; int[] pre ; void run()throws IOException { int xs = in.nextInt(),ys = in.nextInt(); n = in.nextInt(); x = new int[(n + 1)]; y = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {x[i] = in.nextInt(); y[i] = in.nextInt(); }x[n] = xs; y[n] = ys; computeTime(); status = (1 << n); dp = new int[(1 << n)]; pre = new int[(1 << n)]; Arrays.fill(dp,-1); dp[0] = 0; for ( int i = 0;(i < status);i++) {if ( (dp[i] == -1)) continue; for ( int j = 0;(j < n);j++) {if ( (((1 << j) & i) == 0)) { int t1 = ((1 << j) | i),temp1 = (dp[i] + (2 * time[n][j])); if ( ((dp[t1] == -1) || (dp[t1] > temp1))) {dp[t1] = temp1; pre[t1] = i; } for ( int k = 0;(k < n);k++) {if ( (((1 << k) & t1) == 0)) { int t2 = ((1 << k) | t1),temp2 = (((dp[i] + time[n][j]) + time[j][k]) + time[k][n]); if ( ((dp[t2] == -1) || (dp[t2] > temp2))) {dp[t2] = temp2; pre[t2] = i; } } }break;} }} int cur = ((1 << n) - 1); out.println(dp[cur]); out.print(0); while((cur > 0)){ int last = pre[cur],diff = (cur ^ last);  int obj1 = -1,obj2 = -1; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & diff) > 0)) {obj2 = obj1; obj1 = i; } }if ( (obj2 >= 0)) out.printf(" %d %d %d",(obj1 + 1),(obj2 + 1),0); else out.printf(" %d %d",(obj1 + 1),0); cur = last; }out.flush(); } void computeTime(){ time = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {for ( int j = (i + 1);(j <= n);j++) time[i][j] = time[j][i] = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); }} static class Reader{ BufferedReader reader ; StringTokenizer tokenizer ; public Reader( InputStream input){ reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); } String nextToken()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} String readLine()throws IOException { return reader.readLine();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} } }
2	public class B{ public static void main( String[] args)throws IOException { Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong(); if ( (n == 1)) {System.out.println(0); return ;} if ( (n <= k)) {System.out.println(1); return ;} long lb = 2,ub = k;  long sum = ((k * (k - 1)) / 2); if ( ((sum + 1) < n)) {System.out.println(-1); return ;} while(((ub - lb) > 1)){ long mid = ((lb + ub) / 2);  long s = (((mid - 1) * (mid - 2)) / 2); if ( ((n - ((sum - s) + 1)) < 0)) lb = mid; else ub = mid; } long rem = (n - ((sum - (((ub - 1) * (ub - 2)) / 2)) + 1));  long res = ((k - ub) + 1); if ( (rem == 0)) {System.out.println(res); return ;} rem++; if ( ((rem >= 2) && (rem < ub))) {System.out.println(-1); return ;} System.out.println((res + 1)); } }
2	public class algo_1802{ public static void main( String[] args){ Scanner ex = new Scanner(System.in);  int n = ex.nextInt();  int k = ex.nextInt();  int x = (int)((Math.sqrt((9.0 + (8.0 * ((double)n + (double)k)))) - 3.0) / 2.0); System.out.println((n - x)); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] ar = new int[n]; for ( int i = 0;(i < n);i++) {ar[i] = in.nextInt(); } long ninv = 0; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (ar[i] > ar[j])) ninv++; }} int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int l = in.nextInt();  int r = in.nextInt();  int s = (((r - l) * ((r - l) + 1)) / 2); ninv += s; if ( ((ninv % 2) == 0)) out.println("even"); else out.println("odd"); }} } static class InputReader{ StringTokenizer st ; BufferedReader br ; public InputReader( InputStream is){ BufferedReader br = new BufferedReader(new InputStreamReader(is)); this.br = br; } public String next(){ if ( ((st == null) || !st.hasMoreTokens())) { String nextLine = null; try{nextLine = br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} if ( (nextLine == null)) return null; st = new StringTokenizer(nextLine); } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
2	public class Main{ static BufferedReader f ; static StringTokenizer st ; public static void main( String[] args)throws Exception { f = new BufferedReader(new java.io.InputStreamReader(System.in)); long unixTime = System.currentTimeMillis();  long l = nextLong();  long r = nextLong();  String ll = Long.toBinaryString(l);  String rr = Long.toBinaryString(r); System.err.println(ll); System.err.println(rr); System.err.println(Long.parseLong(rr,2)); int len = 0; if ( (ll.length() != rr.length())) {len = Math.max(ll.length(),rr.length()); } else {for ( int i = 0;(i < ll.length());i++) {if ( (ll.charAt(i) != rr.charAt(i))) {len = (ll.length() - i); break;} }}System.err.println(len); StringBuffer s = new StringBuffer(); for ( int i = 0;(i < len);i++) {s.append(1); }if ( (len == 0)) {System.out.println(0); } else {System.out.println(Long.parseLong(s.toString(),2)); }System.exit(0); } static long nextLong()throws Exception { return Long.parseLong(next());} static String next()throws Exception { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(f.readLine()); }return st.nextToken();} }
4	public class C{ int removeSq( int x){ for ( int i = 2;((i * i) <= x);i++) {while(((x % (i * i)) == 0)){x /= (i * i); }}return x;} void submit(){ int n = nextInt();  HashMap<Integer,Integer> map = new HashMap<>(); for ( int i = 0;(i < n);i++) { int x = removeSq(nextInt()); map.merge(x,1,Integer::sum); } int[] a = new int[map.size()];  int ptr = 0; for ( Integer x :map.values()) {a[ptr++] = x; } int ret = go(a); for ( int x :a) {ret = (int)(((long)ret * fact[x]) % P); }out.println(ret); } int go( int[] a){ int[] dp = new int[a[0]]; dp[(a[0] - 1)] = 1; int places = (a[0] + 1);  int toInsert = 0; for ( int x :a) {toInsert += x; }toInsert -= a[0]; for ( int i = 1;(i < a.length);i++) { int here = a[i]; if ( (here == 0)) {continue;} int[] nxt = new int[(dp.length + here)]; for ( int wasSame = 0;(wasSame < dp.length);wasSame++) {if ( (wasSame > toInsert)) {continue;} if ( (dp[wasSame] == 0)) {continue;} int wasDiff = (places - wasSame); for ( int runsSame = 0;((runsSame <= wasSame) && (runsSame <= here));runsSame++) {for ( int runsDiff = 0;((runsDiff <= wasDiff) && ((runsSame + runsDiff) <= here));runsDiff++) {if ( ((runsSame + runsDiff) == 0)) {continue;} int delta = (int)(((((((long)dp[wasSame] * ways[wasSame][runsSame]) % P) * ways[wasDiff][runsDiff]) % P) * ways[(here - 1)][((runsSame + runsDiff) - 1)]) % P); if ( (delta == 0)) {continue;} int nxtIdx = ((wasSame - runsSame) + ((here - runsSame) - runsDiff)); nxt[nxtIdx] += delta; if ( (nxt[nxtIdx] >= P)) {nxt[nxtIdx] -= P; } }}}dp = nxt; places += here; toInsert -= here; }return dp[0];} int[][] ways ; int[] fact ; static final int N = 350; static final int P = 1_000_000_007; void preCalc(){ ways = new int[N][]; for ( int i = 0;(i < N);i++) {ways[i] = new int[(i + 1)]; ways[i][0] = ways[i][i] = 1; for ( int j = 1;(j < i);j++) {ways[i][j] = (ways[(i - 1)][j] + ways[(i - 1)][(j - 1)]); if ( (ways[i][j] >= P)) {ways[i][j] -= P; } }}fact = new int[N]; fact[0] = 1; for ( int i = 1;(i < N);i++) {fact[i] = (int)(((long)fact[(i - 1)] * i) % P); }} C()throws IOException{ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); preCalc(); submit(); out.close(); } static final Random rng = new Random(); public static void main( String[] args)throws IOException { new C(); } BufferedReader br ; PrintWriter out ; StringTokenizer st ; String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} }
4	public class P035C{ private class Pair{ private int x ; private int y ; private Pair( int x, int y){ this.x = x; this.y = y; } } private boolean[][] visited ; private final int N ; private final int M ; private final int k ; private ArrayList<Pair> fires = new ArrayList<Pair>(); private ArrayList<Pair> neighbors = new ArrayList<Pair>(); public P035C()throws IOException{ Scanner sc = new Scanner(new File("input.txt")); N = sc.nextInt(); M = sc.nextInt(); visited = new boolean[N][M]; k = sc.nextInt(); for ( int i = 0;(i < k);i++) { int x = (sc.nextInt() - 1);  int y = (sc.nextInt() - 1); fires.add(new Pair(x,y)); }bfs(); } private void bfs()throws IOException { java.util.Queue<Pair> queue = new ArrayDeque<Pair>(); for ( Pair p :fires) {queue.add(p); visited[p.x][p.y] = true; } Pair last = fires.get(0); while(!queue.isEmpty()){ Pair p = last = queue.poll(); for ( Pair pn :getNeighbors(p)) {if ( !visited[pn.x][pn.y]) {queue.add(pn); visited[pn.x][pn.y] = true; } }} PrintWriter output = new PrintWriter(new FileWriter(new File("output.txt"))); output.printf("%d %d\n",(last.x + 1),(last.y + 1)); output.close(); } private Collection<Pair> getNeighbors( Pair p){ neighbors.clear(); if ( (p.x > 0)) neighbors.add(new Pair((p.x - 1),p.y)); if ( (p.x < (N - 1))) neighbors.add(new Pair((p.x + 1),p.y)); if ( (p.y > 0)) neighbors.add(new Pair(p.x,(p.y - 1))); if ( (p.y < (M - 1))) neighbors.add(new Pair(p.x,(p.y + 1))); return neighbors;} public static void main( String[] args)throws IOException { P035C solution = new P035C(); } }
5	public class Main{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine()," ");  int num = Integer.parseInt(st.nextToken());  int k = Integer.parseInt(st.nextToken()); st = new StringTokenizer(br.readLine()," "); if ( (k == 1)) System.out.println(num); else { Set<Integer> set = new TreeSet<Integer>();  Set<Integer> bad = new TreeSet<Integer>();  int sel ;  int[] arr = new int[num]; for ( int i = 0;(i < num);i++) {arr[i] = Integer.parseInt(st.nextToken()); }shuffle(arr); Arrays.sort(arr); for ( int i = 0;(i < num);i++) {sel = arr[i]; if ( ((sel % k) != 0)) {set.add(sel); bad.add((sel * k)); } if ( (!bad.contains(sel) && !set.contains((sel / k)))) {bad.add((sel * k)); set.add(sel); } }System.out.println(set.size()); }} public static void shuffle( int[] arr){ Random rand = new Random(); for ( int i = (arr.length - 1);(i >= 0);--i) { int pos = rand.nextInt((i + 1));  int aux = arr[i]; arr[i] = arr[pos]; arr[pos] = aux; }} }
1	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  String line = in.next();  int h = 0; for ( int i = 0;(i < line.length());i++) {if ( (line.charAt(i) == 'H')) h++; }line = (line + line); int min = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int ans = 0; for ( int j = i;(j < (i + h));j++) {if ( (line.charAt(j) != 'H')) ans++; }if ( (min > ans)) min = ans; }out.print(min); in.close(); out.close(); } }
1	public class Main{ static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter writer ; static int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} static String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} public static void main( String[] args)throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(System.out); pineapple(); reader.close(); writer.close(); } static void pineapple()throws NumberFormatException,IOException { int n = nextInt();  int a = nextInt();  int b = nextInt();  HashSet<Integer> al = new HashSet<Integer>();  HashMap<Integer,Integer> mp = new HashMap<Integer,Integer>();  int[] ans = new int[n]; Arrays.fill(ans,-1); HashSet<Integer> used = new HashSet<Integer>();  int[] mas = new int[n]; for ( int i = 0;(i < n);i++) { int t = nextInt(); al.add(t); mas[i] = t; mp.put(t,i); }for ( int st :al) {if ( used.contains(st)) continue; { int pr = st;  int cc = -1;  HashSet<Integer> u2 = new HashSet<Integer>(); u2.add(pr); if ( (!u2.contains((a - pr)) && al.contains((a - pr)))) cc = (a - pr); if ( (!u2.contains((a - pr)) && al.contains((b - pr)))) cc = (b - pr); if ( (cc != -1)) {u2.add(cc); boolean bGo = true; while(bGo){bGo = false; int nxt = -1; if ( (!u2.contains((a - cc)) && al.contains((a - cc)))) nxt = (a - cc); if ( (!u2.contains((b - cc)) && al.contains((b - cc)))) nxt = (b - cc); if ( (nxt != -1)) {bGo = true; u2.add(nxt); cc = nxt; pr = cc; } }st = cc; } } LinkedList<Integer> ll = new LinkedList<Integer>(); ll.add(st); while(!ll.isEmpty()){ int curr = ll.pollFirst(); used.add(curr); int next1 = (a - curr); if ( al.contains(next1)) {if ( !used.contains(next1)) {ll.addLast(next1); if ( ((ans[mp.get(curr)] == -1) && (ans[mp.get(next1)] == -1))) {ans[mp.get(next1)] = 0; ans[mp.get(curr)] = 0; } } } int next2 = (b - curr); if ( al.contains(next2)) {if ( !used.contains(next2)) {ll.addLast(next2); if ( ((ans[mp.get(curr)] == -1) && (ans[mp.get(next2)] == -1))) {ans[mp.get(next2)] = 1; ans[mp.get(curr)] = 1; } } } }}for ( int i = 0;(i < n);i++) {if ( (ans[i] == -1)) {if ( ((2 * mas[i]) == a)) {ans[i] = 0; continue;} if ( ((2 * mas[i]) == b)) {ans[i] = 1; continue;} writer.println("NO"); return ;} }writer.println("YES"); for ( int i = 0;(i < n);i++) {writer.print((ans[i] + " ")); }} }
5	public class CF113_Div2_A implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok ; final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); public static void main( String[] args){ new Thread(null,new CF113_Div2_A(),"",(256 * (1L << 20))).start(); } String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} class Team implements Comparable<Team>{ int cnt ,time ; public Team( int cnt, int time){ this.cnt = cnt; this.time = time; } @Override public int hashCode(){ final int prime = 31;  int result = 1; result = ((prime * result) + getOuterType().hashCode()); result = ((prime * result) + cnt); result = ((prime * result) + time); return result;} @Override public boolean equals( Object obj){ if ( (this == obj)) return true; if ( (obj == null)) return false; if ( (getClass() != obj.getClass())) return false; Team other = (Team)obj; if ( !getOuterType().equals(other.getOuterType())) return false; if ( (cnt != other.cnt)) return false; if ( (time != other.time)) return false; return true;} private CF113_Div2_A getOuterType(){ return this;} } void solve()throws IOException { int n = readInt();  int k = readInt(); k--; Team[] a = new Team[n]; for ( int i = 0;(i < n);i++) {a[i] = new Team(readInt(),readInt()); }Arrays.sort(a); int res = 1; for ( int i = (k - 1);(i >= 0);i--) {if ( a[k].equals(a[i])) res++; }for ( int i = (k + 1);(i < n);i++) {if ( a[k].equals(a[i])) res++; }out.print(res); } }
6	public class Bag implements Runnable{ private void solve()throws IOException { int xs = nextInt();  int ys = nextInt();  int n = nextInt();  int[] x = new int[n];  int[] y = new int[n]; for ( int i = 0;(i < n);++i) {x[i] = nextInt(); y[i] = nextInt(); }final int[][] pair = new int[n][n]; for ( int i = 0;(i < n);++i) for ( int j = (i + 1);(j < n);++j) pair[i][j] = (((((((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys))) + ((x[j] - xs) * (x[j] - xs))) + ((y[j] - ys) * (y[j] - ys))) + ((x[j] - x[i]) * (x[j] - x[i]))) + ((y[j] - y[i]) * (y[j] - y[i]))); final int[] single = new int[n]; for ( int i = 0;(i < n);++i) {single[i] = (2 * (((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys)))); }final int[] best = new int[(1 << n)]; final int[] prev = new int[(1 << n)]; for ( int set = 1;(set < (1 << n));++set) { int i ; for ( i = 0;(i < n);++i) if ( ((set & (1 << i)) != 0)) break; best[set] = (best[(set ^ (1 << i))] + single[i]); prev[set] = (1 << i); int nextSet = (set ^ (1 << i));  int unoI = (1 << i); for ( int j = (i + 1),unoJ = (1 << (i + 1));(j < n);++j,unoJ <<= 1) if ( ((set & unoJ) != 0)) { int cur = (best[(nextSet ^ unoJ)] + pair[i][j]); if ( (cur < best[set])) {best[set] = cur; prev[set] = (unoI | unoJ); } } }writer.println(best[((1 << n) - 1)]); int now = ((1 << n) - 1); writer.print("0"); while((now > 0)){ int differents = prev[now]; for ( int i = 0;(i < n);i++) if ( ((differents & (1 << i)) != 0)) {writer.print(" "); writer.print((i + 1)); now ^= (1 << i); } writer.print(" "); writer.print("0"); }writer.println(); } public static void main( String[] args){ new Bag().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
0	public class Solution{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt(); if ( ((n % 2) == 0)) System.out.println(("4 " + (n - 4))); else System.out.println(("9 " + (n - 9))); } }
2	public class A{ public static void main( String[] ar)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long k = Long.parseLong(br.readLine());  long l = 1,h = 1000000000000l;  long p[] = new long[13]; for ( int i = 1;(i <= 12);i++) { long ll = (9 * i); p[i] = (ll * (long)Math.pow(10,(i - 1))); p[i] += p[(i - 1)]; }while(((h - l) > 1)){ long mid = ((l + h) / 2);  long num = (long)(Math.log(mid) / Math.log(10));  long l1 = (p[(int)num] + ((num + 1) * (mid - (long)Math.pow(10,num))));  long l2 = (p[(int)num] + ((num + 1) * ((mid - (long)Math.pow(10,num)) + 1))); if ( (k <= l1)) h = mid; else if ( (k > l2)) l = mid; else {l = mid; h = mid; }}if ( ((h - l) == 1)) { long num = (long)(Math.log(h) / Math.log(10));  long l1 = (p[(int)num] + ((num + 1) * (h - (long)Math.pow(10,num))));  long l2 = (p[(int)num] + ((num + 1) * ((h - (long)Math.pow(10,num)) + 1))); if ( ((k > l1) && (k <= l2))) {l = h; } } long n = (long)(Math.log(l) / Math.log(10));  long u = (p[(int)n] + ((n + 1) * (l - (long)Math.pow(10,n)))); k -= u; String ss = String.valueOf(l); System.out.println(ss.charAt((int)(k - 1))); } }
3	public class Main{ static double[] res ; static double r ; static double solve( int xMe, int xHim, int idxHim){ if ( (Math.abs((xMe - xHim)) > (2 * r))) return r; double hisY = res[idxHim];  double lo = hisY,hi = (hisY + (2 * r)),best = hi; for ( int cnt = 0;(cnt <= 50);cnt++) { double myY = (lo)((hi - lo) / 2); if ( notIntersect(xMe,myY,xHim,hisY)) {best = Math.min(best,myY); hi = Math.max(lo,myY); } else lo = Math.min(hi,myY); }return best;} static boolean notIntersect( double x1, double y1, double x2, double y2){ return ((((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2))) >= (((2 * r) * 2) * r));} public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt(); res = new double[n]; r = sc.nextInt(); int[] x = new int[n]; for ( int i = 0;(i < n);i++) x[i] = sc.nextInt(); for ( int i = 0;(i < n);i++) { double max = r; for ( int j = 0;(j < i);j++) {max = Math.max(max,solve(x[i],x[j],j)); }if ( (i > 0)) out.print(" "); res[i] = max; out.printf("%.10f",max); }out.println(); out.flush(); out.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( FileReader s)throws FileNotFoundException{ br = new BufferedReader(s); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
5	public class Main{ public static void main( String[] args)throws Exception { Parserdoubt3 s = new Parserdoubt3(System.in);  int n = s.nextInt();  long k = s.nextInt();  Long a[] = new Long[n];  TreeSet<Long> tree = new TreeSet<Long>(); for ( int i = 0;(i < a.length);i++) {a[i] = s.nextLong(); tree.add(a[i]); }Arrays.sort(a); int ans = 0; for ( int i = 0;(i < a.length);i++) {if ( tree.contains(a[i])) {ans++; long next = (a[i] * k); if ( tree.contains(next)) tree.remove(next); } }System.out.println(ans); } } class Parserdoubt3{ private final int BUFFER_SIZE = (1 << 17); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Parserdoubt3( InputStream in){ din = new DataInputStream(in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws Exception { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); c = read(); }while((c > ' '));if ( neg) return -ret; return ret;} public long nextLong()throws Exception { long ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); c = read(); }while((c > ' '));if ( neg) return -ret; return ret;} private void fillBuffer()throws Exception { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws Exception { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} }
5	public class Solution implements Runnable{ public static BufferedReader br ; public static PrintWriter out ; public static StringTokenizer stk ; public static boolean isStream = true; public static void main( String[] args)throws IOException { if ( isStream) {br = new BufferedReader(new InputStreamReader(System.in)); } else {br = new BufferedReader(new FileReader("in.txt")); }out = new PrintWriter(System.out); new Thread(new Solution()).start(); } public void loadLine(){ try{stk = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } public Integer nextInt(){ while(((stk == null) || !stk.hasMoreTokens()))loadLine(); return Integer.valueOf(stk.nextToken());} }
0	public class lucky{ public static void main( String[] args)throws IOException { BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));  String s = cin.readLine();  int l = s.length();  int n = Integer.parseInt(s); if ( (((((((((((((s.equals("47") || s.equals("4")) || s.equals("7")) || s.equals("74")) || s.equals("447")) || s.equals("477")) || s.equals("474")) || s.equals("44")) || s.equals("77")) || s.equals("444")) || s.equals("777")) || s.equals("747")) || s.equals("774")) || s.equals("744"))) System.out.println("YES"); else if ( (((((((((((((((n % 47) == 0) || ((n % 4) == 0)) || ((n % 7) == 0)) || ((n % 74) == 0)) || ((n % 447) == 0)) || ((n % 477) == 0)) || ((n % 474) == 0)) || ((n % 44) == 0)) || ((n % 77) == 0)) || ((n % 444) == 0)) || ((n % 777) == 0)) || ((n % 747) == 0)) || ((n % 774) == 0)) || ((n % 744) == 0))) System.out.println("YES"); else System.out.println("NO"); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int[] cnt = new int[10]; Arrays.fill(cnt,0); List<String> a = new ArrayList<>(); for ( int i = 0;(i < n);i++) {a.add(in.readLine()); } List<String> b = new ArrayList<>(); for ( int i = 0;(i < n);i++) { String temp = in.readLine(); if ( a.contains(temp)) {a.remove(temp); } else b.add(temp); } int[] cnta = new int[10]; for ( int i = 0;(i < a.size());i++) {cnta[a.get(i).length()]++; } int[] cntb = new int[10]; Arrays.fill(cnta,0); Arrays.fill(cntb,0); for ( int i = 0;(i < b.size());i++) {cntb[a.get(i).length()]++; } int ans = 0; for ( int i = 0;(i < 10);i++) {ans += Math.abs((cnta[i] - cntb[i])); }out.println(ans); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private String readLine0(){ StringBuilder buf = new StringBuilder();  int c = read(); while(((c != '\n') && (c != -1))){if ( (c != '\r')) {buf.appendCodePoint(c); } c = read(); }return buf.toString();} public String readLine(){ String s = readLine0(); while((s.trim().length() == 0)){s = readLine0(); }return s;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void close(){ writer.close(); } public void println( int i){ writer.println(i); } } }
5	public class Main{ static PrintWriter out ; static StreamTokenizer in ; static int next()throws Exception { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws Exception { out = new PrintWriter(System.out); in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); int n = next();  int t = (2 * next());  int[] x = new int[n];  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = ((2 * next()) + 2000); a[i] = next(); } int[] srt = new int[n]; for ( int i = 0;(i < n);i++) srt[i] = ((10000 * x[i]) + a[i]); Arrays.sort(srt); for ( int i = 0;(i < n);i++) {x[i] = (srt[i] / 10000); a[i] = (srt[i] % 10000); } int answ = 2; for ( int i = 0;(i < (n - 1));i++) {if ( ((x[(i + 1)] - x[i]) > ((a[i] + a[(i + 1)]) + t))) answ++; if ( ((x[(i + 1)] - x[i]) >= ((a[i] + a[(i + 1)]) + t))) answ++; }out.println(answ); out.close(); } }
1	public class Main{ FastScanner in ; PrintWriter out ; private void solve()throws IOException { solveA(); } private void solveA()throws IOException { int n = in.nextInt();  TreeMap<String,Integer> map = new TreeMap<>(); for ( int i = 0;(i < n);i++) { String s = in.next(); map.put(s,(map.getOrDefault(s,0) + 1)); }for ( int i = 0;(i < n);i++) { String s = in.next(); map.put(s,(map.getOrDefault(s,0) - 1)); } long ans = 0; for ( String i :map.keySet()) ans += abs(map.get(i)); out.println((ans / 2)); } class PairC{ int i ,j ; PairC( int i, int j){ this.i = i; this.j = j; } public String toString(){ return (((("(" + i) + ", ") + j) + ")");} } class PairE implements Comparable<PairE>{ long x ,y ; int id ; boolean b ; PairE( long x, long y, int id){ this.x = x; this.y = y; this.id = id; b = false; } } void shuffle( PairE[] a){ PairE b ;  Random r = new Random(); for ( int i = (a.length - 1),j ;(i > 0);i--) {j = r.nextInt((i + 1)); b = a[j]; a[j] = a[i]; a[i] = b; }} class FastScanner{ StringTokenizer st ; BufferedReader br ; FastScanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} long nextLong()throws IOException { return Long.parseLong(next());} } private void run()throws IOException { in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.flush(); out.close(); } public static void main( String[] args)throws IOException { new Main().run(); } }
6	public class CF85C{ public static void main( String[] args){ reader = new BufferedReader(new InputStreamReader(System.in)); int height = nextInt(),width = nextInt(); if ( (width > height)) { int t = width; width = height; height = t; } final int INF = ((height * width) + 10); final int ALL_BITS = ((1 << width) - 1);  int[][][] dp = new int[(height + 1)][(1 << width)][(1 << width)]; for ( int[][] ints :dp) {for ( int[] anInt :ints) {Arrays.fill(anInt,INF); }}dp[0][0][0] = 0; for ( int r = 0;(r < height);++r) {for ( int uncovered = 0;(uncovered < (1 << width));++uncovered) {for ( int mask = 0;(mask < (1 << width));++mask) {if ( (dp[r][uncovered][mask] == INF)) {continue;} for ( int curMask = uncovered;(curMask < (1 << width));curMask = ((curMask + 1) | uncovered)) { int curCovered = (mask | curMask); curCovered |= (curMask >> 1); curCovered |= (ALL_BITS & (curMask << 1)); int curUncovered = (ALL_BITS ^ curCovered); dp[(r + 1)][curUncovered][curMask] = Math.min(dp[(r + 1)][curUncovered][curMask],(dp[r][uncovered][mask] + Integer.bitCount(curMask))); }}}} int res = INF; for ( int x :dp[height][0]) res = Math.min(res,x); System.out.println(((height * width) - res)); } public static BufferedReader reader ; public static StringTokenizer tokenizer = null; static String nextToken(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public static int nextInt(){ return Integer.parseInt(nextToken());} }
0	public class problemA{ public static long GCD( long number1, long number2){ if ( (number2 == 0)) {return number1;} return GCD(number2,(number1 % number2));} public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  long b = Long.parseLong(st.nextToken());  long c = Long.parseLong(st.nextToken()); if ( (((c - b) < 2) || (((c - b) == 2) && (GCD(c,b) == 1)))) {System.out.println("-1"); } else {if ( ((b % 2) == 0)) {System.out.println(((((b + " ") + (b + 1)) + " ") + (b + 2))); } else System.out.println((((((b + 1) + " ") + (b + 2)) + " ") + (b + 3))); }} }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ class Pair{ public int a ; public int b ; public Pair( int a, int b){ this.a = a; this.b = b; } } public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int k = in.nextInt(); --k; ArrayList<Pair> list = new ArrayList<Pair>(); for ( int i = 1;(i <= n);++i) { int num = in.nextInt();  int pen = in.nextInt();  Pair t = new Pair(num,pen); list.add(t); }Collections.sort(list,new Comparator<Pair>(){}); int res = 1;  Pair compare = list.get(k);  int i = (k - 1); while((i >= 0)){ Pair t = list.get(i); if ( ((t.a == compare.a) && (t.b == compare.b))) {--i; ++res; continue;} else {break;}}i = (k + 1); while((i < list.size())){ Pair t = list.get(i); if ( ((t.a == compare.a) && (t.b == compare.b))) {++res; ++i; continue;} else {break;}}out.println(res); return ;} }
1	public class C_138B{ private static BufferedReader in ; private static StringTokenizer st ; private static PrintWriter out ; static String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} static int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} public static void main( String[] args)throws NumberFormatException,IOException { in = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); out = new PrintWriter(new OutputStreamWriter(System.out)); int n = nextInt();  int k = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } Set<Integer> set = new HashSet<Integer>(); for ( int i = 0;(i < a.length);i++) {set.add(a[i]); if ( (set.size() == k)) { Set<Integer> set2 = new HashSet<Integer>(); for ( int j = i;(j >= 0);j--) {set2.add(a[j]); if ( (set2.size() == k)) {out.print((((j + 1) + " ") + (i + 1))); out.close(); return ;} }} }out.print("-1 -1"); out.close(); } }
2	public class ProblemA{ private static long MOD = 1000000009; public void solve()throws Exception { long n = nextInt();  long m = nextInt();  long k = nextInt();  long tmp = (1024 * 1024);  long res = 0;  long nTmp = n;  long mTmp = m; while((tmp > 0)){while(((mTmp >= ((k - 1) * tmp)) && ((nTmp - (k * tmp)) >= (mTmp - ((k - 1) * tmp))))){nTmp -= (k * tmp); mTmp -= ((k - 1) * tmp); }tmp /= 2; } long fullC = (mTmp / k);  long pow2 = getPow(2,(fullC + 1),MOD); res = ((((((res + pow2) + MOD) - 2) % MOD) * k) % MOD); mTmp = (mTmp % k); res = ((res + mTmp) % MOD); nTmp = n; mTmp = ((m - (fullC * k)) - mTmp); tmp = (1024 * 1024); while((tmp > 0)){while(((mTmp >= ((k - 1) * tmp)) && ((nTmp - (k * tmp)) >= (mTmp - ((k - 1) * tmp))))){nTmp -= (k * tmp); mTmp -= ((k - 1) * tmp); res = ((res + ((k - 1) * tmp)) % MOD); }tmp /= 2; }out.println(res); } static long[] pows = new long[1000000]; public static long getPow( long base, long pow, long mod){ if ( ((pow < pows.length) && (pows[(int)pow] != 0))) {return pows[(int)pow];} if ( (pow == 0)) {pows[0] = 1; return 1;} if ( (pow == 1)) {pows[1] = base; return base;} long res = getPow(base,(pow / 2),mod); res = ((res * res) % mod); res = ((res * getPow(base,(pow % 2),mod)) % mod); if ( (pow < pows.length)) {pows[(int)pow] = res; } return res;} public static void main( String[] args)throws Exception { ProblemA problem = new ProblemA(); problem.solve(); problem.close(); } BufferedReader in ; PrintWriter out ; String curLine ; StringTokenizer tok ; final String delimeter = " "; final String endOfFile = ""; public ProblemA( BufferedReader in, PrintWriter out)throws Exception{ this.in = in; this.out = out; curLine = in.readLine(); if ( ((curLine == null) || (curLine == endOfFile))) {tok = null; } else {tok = new StringTokenizer(curLine,delimeter); }} public ProblemA()throws Exception{ this(new BufferedReader(new InputStreamReader(System.in)),new PrintWriter(System.out)); } public ProblemA( String filename)throws Exception{ this(new BufferedReader(new FileReader((filename + ".in"))),new PrintWriter((filename + ".out"))); } public boolean hasMore()throws Exception { if ( ((tok == null) || (curLine == null))) {return false;} else {while(!tok.hasMoreTokens()){curLine = in.readLine(); if ( ((curLine == null) || curLine.equalsIgnoreCase(endOfFile))) {tok = null; return false;} else {tok = new StringTokenizer(curLine); }}return true;}} public String nextWord()throws Exception { if ( !hasMore()) {return null;} else {return tok.nextToken();}} public int nextInt()throws Exception { return Integer.parseInt(nextWord());} public void close()throws Exception { in.close(); out.close(); } }
6	public class cf1102f{ public static void main( String[] args)throws IOException { int n = rni(),m = ni(),a[][] = new int[n][]; for ( int i = 0;(i < n);++i) {a[i] = ria(m); } int delta[][] = new int[n][n],end_delta[][] = new int[n][n],dp[][][] = new int[n][(1 << n)][n]; for ( int i = 0;(i < n);++i) {fill(delta[i],IBIG); fill(end_delta[i],IBIG); delta[i][i] = 0; }for ( int i = 0;(i < (n - 1));++i) {for ( int j = (i + 1);(j < n);++j) {for ( int k = 0;(k < m);++k) {delta[i][j] = delta[j][i] = min(delta[i][j],abs((a[i][k] - a[j][k]))); }}}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {for ( int k = 1;(k < m);++k) {end_delta[i][j] = min(end_delta[i][j],abs((a[j][k] - a[i][(k - 1)]))); }}}for ( int[][] layer :dp) {for ( int[] row :layer) {fill(row,IBIG); }}for ( int i = 1;(i < (1 << n));++i) { boolean one_bit = (Integer.bitCount(i) == 1); for ( int j = 0;(j < n);++j) {if ( ((i & (1 << j)) > 0)) {for ( int l = 0;(l < n);++l) {if ( ((i & (1 << l)) == 0)) { int max = 0; for ( int k = 0;(k < n);++k) {if ( ((one_bit || (j != k)) && ((i & (1 << k)) > 0))) {max = max(max,min(dp[j][i][k],delta[k][l])); } }dp[j][(i | (1 << l))][l] = max; } }} }} int ans = 0; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {if ( (i != j)) {ans = max(ans,min(dp[i][((1 << n) - 1)][j],end_delta[j][i])); } }}if ( (n == 1)) {ans = maxof(end_delta[0]); } prln(ans); close(); } static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out)); static StringTokenizer input ; static Random __rand = new Random(); static final int IBIG = 1000000007; static final int IMAX = 2147483647; static final int IMIN = -2147483648; static final long LMAX = 9223372036854775807L; static final long LMIN = -9223372036854775808L; static int maxof( int a, int b, int c){ return max(a,max(b,c));} static int maxof( int... x){ if ( (x.length == 1)) return x[0]; if ( (x.length == 2)) return max(x[0],x[1]); if ( (x.length == 3)) return max(x[0],max(x[1],x[2])); int max = x[0]; for ( int i = 1;(i < x.length);++i) if ( (x[i] > max)) max = x[i]; return max;} static long maxof( long a, long b, long c){ return max(a,max(b,c));} static long maxof( long... x){ if ( (x.length == 1)) return x[0]; if ( (x.length == 2)) return max(x[0],x[1]); if ( (x.length == 3)) return max(x[0],max(x[1],x[2])); long max = x[0]; for ( int i = 1;(i < x.length);++i) if ( (x[i] > max)) max = x[i]; return max;} static int gcf( int a, int b){ return ((b == 0)?a:gcf(b,(a % b)));} static long gcf( long a, long b){ return ((b == 0)?a:gcf(b,(a % b)));} static int randInt( int min, int max){ return (__rand.nextInt(((max - min) + 1)) + min);} static void shuffle( int[] a){ int n = (a.length - 1); for ( int i = 0;(i < n);++i) { int ind = randInt(i,n);  int swap = a[i]; a[i] = a[ind]; a[ind] = swap; }} static void shuffle( long[] a){ int n = (a.length - 1); for ( int i = 0;(i < n);++i) { int ind = randInt(i,n);  long swap = a[i]; a[i] = a[ind]; a[ind] = swap; }} static void shuffle( double[] a){ int n = (a.length - 1); for ( int i = 0;(i < n);++i) { int ind = randInt(i,n);  double swap = a[i]; a[i] = a[ind]; a[ind] = swap; }} static void r()throws IOException { input = new StringTokenizer(rline()); } static int[] ria( int n)throws IOException { int[] a = new int[n]; r(); for ( int i = 0;(i < n);++i) a[i] = ni(); return a;} static String rline()throws IOException { return __in.readLine();} static String n(){ return input.nextToken();} static int rni()throws IOException { r(); return ni();} static int ni(){ return Integer.parseInt(n());} static long nl(){ return Long.parseLong(n());} static double nd(){ return Double.parseDouble(n());} static void pr( int i){ __out.print(i); } static void prln( int i){ __out.println(i); } static void pr( long l){ __out.print(l); } static void prln( long l){ __out.println(l); } static void pr( double d){ __out.print(d); } static void prln( double d){ __out.println(d); } static void pr( char c){ __out.print(c); } static void prln( char c){ __out.println(c); } static void pr( char[] s){ __out.print(new String(s)); } static void prln( char[] s){ __out.println(new String(s)); } static void pr( String s){ __out.print(s); } static void prln( String s){ __out.println(s); } static void pr( Object o){ __out.print(o); } static void prln( Object o){ __out.println(o); } static void prln(){ __out.println(); } static void prln( int... a){ for ( int i = 0,len = (a.length - 1);(i < len);pr(a[i]),pr(' '),++i) ;if ( (a.length > 0)) prln(a[(a.length - 1)]); else prln(); } static void prln( long... a){ for ( int i = 0,len = (a.length - 1);(i < len);pr(a[i]),pr(' '),++i) ;if ( (a.length > 0)) prln(a[(a.length - 1)]); else prln(); } static void prln( double... a){ for ( int i = 0,len = (a.length - 1);(i < len);pr(a[i]),pr(' '),++i) ;if ( (a.length > 0)) prln(a[(a.length - 1)]); else prln(); } static <T> void prln( Collection<T> c){ int n = (c.size() - 1);  Iterator<T> iter = c.iterator(); for ( int i = 0;(i < n);pr(iter.next()),pr(' '),++i) ;if ( (n >= 0)) prln(iter.next()); else prln(); } static void flush(){ __out.flush(); } static void close(){ __out.close(); } }
1	public class B{ public static void main( String[] args)throws IOException { BufferedReader b = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(b.readLine()); while((n-- > 0)){ String s = b.readLine(); if ( s.matches("^[A-Z]+[0-9]+$")) {System.out.println(toRC(decodeCR(s))); } else {System.out.println(toCR(decodeRC(s))); }}} private static String toRC( int[] a){ return ((("R" + a[0]) + "C") + a[1]);} private static String toCR( int[] a){ String r = ""; if ( (a[1] == 1)) {r = "A"; } else {for ( int x = a[1];(x > 0);x /= 26) {r = ((char)('A' + ((x - 1) % 26)) + r); if ( ((x % 26) == 0)) x -= 26; }}return (r + a[0]);} private static int[] decodeCR( String s){ int[] a = new int[2];  int i = 0; while((s.charAt(i) >= 'A')){a[1] = ((a[1] * 26) + ((s.charAt(i) - 'A') + 1)); i++; }a[0] = Integer.parseInt(s.substring(i)); return a;} private static int[] decodeRC( String s){ assert (s.charAt(0) == 'R'); int[] a = new int[2]; a[0] = Integer.parseInt(s.substring(1,s.indexOf('C'))); a[1] = Integer.parseInt(s.substring((s.indexOf('C') + 1))); return a;} }
1	public class CF_468B{ public static void main( String[] args)throws IOException { new CF_468B().solve(); } int root( int[] father, int a){ if ( (father[a] == a)) return a; else return father[a] = root(father,father[a]);} void unite( int[] father, int a, int b){ father[root(father,a)] = root(father,b); } private void solve()throws IOException { InputStream in = System.in;  PrintStream out = System.out;  long mod = 1_000_000_007;  Scanner sc = new Scanner(in);  int n = sc.nextInt();  long a = sc.nextLong(),b = sc.nextLong();  int[] father = new int[n];  long[] p = new long[n];  HashMap<Long,Integer> pos = new HashMap<Long,Integer>(); for ( int i = 0;(i < n);i++) {father[i] = i; p[i] = sc.nextLong(); pos.put(p[i],i); }for ( int i = 0;(i < n);i++) {if ( pos.containsKey((a - p[i]))) unite(father,i,pos.get((a - p[i]))); if ( pos.containsKey((b - p[i]))) unite(father,i,pos.get((b - p[i]))); } boolean[] canA = new boolean[n],canB = new boolean[n]; Arrays.fill(canA,true); Arrays.fill(canB,true); for ( int i = 0;(i < n);i++) {if ( (!pos.containsKey((a - p[i])) || (root(father,i) != root(father,pos.get((a - p[i])))))) canA[root(father,i)] = false; if ( (!pos.containsKey((b - p[i])) || (root(father,i) != root(father,pos.get((b - p[i])))))) canB[root(father,i)] = false; if ( (!canA[root(father,i)] && !canB[root(father,i)])) {out.println("NO"); return ;} }out.println("YES"); for ( int i = 0;(i < n);i++) if ( canA[root(father,i)]) out.print("0 "); else out.print("1 "); } }
4	public class Main{ public static InputStream IN ; public static OutputStream OUT ; public static PrintWriter out ; public static BufferedReader in ; public static StringTokenizer st = null; public static int ni()throws Exception { for ( ;((st == null) || !st.hasMoreTokens());) {st = new StringTokenizer(in.readLine()); }return Integer.parseInt(st.nextToken());} public static void main( String[] args)throws Exception { IN = new FileInputStream("input.txt"); OUT = new FileOutputStream("output.txt"); out = new PrintWriter(OUT); in = new BufferedReader(new InputStreamReader(IN)); int n = ni();  int m = ni();  int k = ni();  int[] x = new int[k];  int[] y = new int[k]; for ( int i = 0;(i < k);i++) {x[i] = (ni() - 1); y[i] = (ni() - 1); } int w = Integer.MIN_VALUE;  int aa = -1;  int ab = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int min = Integer.MAX_VALUE; for ( int q = 0;(q < k);q++) { int cur = (Math.abs((i - x[q])) + Math.abs((j - y[q]))); min = Math.min(cur,min); }if ( (min > w)) {w = min; aa = i; ab = j; } }}out.println((((aa + 1) + " ") + (ab + 1))); out.flush(); } }
0	public class A{ FastScanner in ; PrintWriter out ; public void run(){ try{in = new FastScanner(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } public void solve()throws IOException { long l = new Long(in.next());  long r = new Long(in.next()); if ( (((r - l) < 2) || (((r - l) == 2) && ((l % 2) != 0)))) {out.println("-1"); } else {if ( ((l % 2) != 0)) {l++; } out.println(l); out.println((l + 1)); out.println((l + 2)); }} class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStreamReader in){ br = new BufferedReader(in); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} } public static void main( String[] arg){ A o = new A(); o.run(); } }
0	public class A{ private BufferedReader in ; private StringTokenizer st ; void solve()throws IOException { int n = nextInt(); System.out.println(((3 * n) / 2)); } A()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); eat(""); solve(); } private void eat( String str){ st = new StringTokenizer(str); } String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} eat(line); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { new A(); } int gcd( int a, int b){ if ( (b > a)) return gcd(b,a); if ( (b == 0)) return a; return gcd(b,(a % b));} }
1	public class Spreadsheets implements Runnable{ private Scanner in = new Scanner(System.in); private PrintWriter out = new PrintWriter(System.out); private String s ,ans ; public static void main( String[] args){ new Thread(new Spreadsheets()).start(); } private void read(){ s = in.next(); } private void solve(){ if ( s.matches("R\\d+C\\d+")) {s = s.replace('R',' ').replace('C',' '); Scanner ss = new Scanner(s);  int r = ss.nextInt();  int c = ss.nextInt(); c--; StringBuffer b = new StringBuffer();  int c26 = 26;  int cc = 0; while(((cc + c26) <= c)){cc += c26; c26 *= 26; }c -= cc; while((c26 > 1)){c26 /= 26; b.append((char)((c / c26) + 'A')); c %= c26; }ans = (b.toString() + r); } else { int p = 0; while(!Character.isDigit(s.charAt(p))){p++; } int c26 = 1;  int cc = 0; for ( int i = 0;(i < p);i++) {cc += c26; c26 *= 26; }for ( int i = 0;(i < p);i++) {c26 /= 26; cc += (c26 * (s.charAt(i) - 'A')); }ans = ((("R" + s.substring(p)) + "C") + cc); }} private void write(){ out.println(ans); } }
5	public class A{ static int[] solve( int[] a){ int n = a.length; Arrays.sort(a); a[(n - 1)] = ((a[(n - 1)] > 1)?1:2); int[] b = Arrays.copyOf(a,n); Arrays.sort(b); return b;} public static void main( String[] args)throws Exception { reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(System.out); setTime(); int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } int[] b = solve(a); for ( int v :b) {writer.print((v + " ")); }printTime(); printMemory(); writer.close(); } static BufferedReader reader ; static PrintWriter writer ; static StringTokenizer tok = new StringTokenizer(""); static long systemTime ; static void setTime(){ systemTime = System.currentTimeMillis(); } static void printTime(){ System.err.println(("Time consumed: " + (System.currentTimeMillis() - systemTime))); } static void printMemory(){ System.err.println((("Memory consumed: " + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1000)) + "kb")); } static String next(){ while(!tok.hasMoreTokens()){ String w = null; try{w = reader.readLine(); }catch (Exception e){ e.printStackTrace(); } if ( (w == null)) return null; tok = new StringTokenizer(w); }return tok.nextToken();} static int nextInt(){ return Integer.parseInt(next());} }
0	public class c{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long a = input.nextLong(),b = input.nextLong(); System.out.println(gcd(a,b)); } static long gcd( long a, long b){ if ( (b == 1)) return a; if ( (a == 1)) return b; if ( (a > b)) return ((a / b) + gcd(b,(a % b))); return ((b / a) + gcd(a,(b % a)));} }
3	public class curling{ public static void main( String[] args)throws IOException { Scanner input = new Scanner(System.in);  int numD = input.nextInt();  double rad = input.nextInt();  int[] xC = new int[numD]; for ( int i = 0;(i < numD);i++) {xC[i] = input.nextInt(); } double[] maxY = new double[1001]; for ( int i = 0;(i < numD);i++) { double h = rad; for ( int j = Math.max(1,(xC[i] - (int)(2 * rad)));(j <= Math.min(1000,(xC[i] + (2 * rad))));j++) {if ( (maxY[j] > 0)) {h = Math.max(h,(Math.sqrt((((4 * rad) * rad) - ((j - xC[i]) * (j - xC[i])))) + maxY[j])); } }System.out.print((h + " ")); maxY[xC[i]] = h; }} }
1	public class B{ static class Scan{ private byte[] buf = new byte[1024]; private int index ; private InputStream in ; private int total ; public Scan(){ in = System.in; } public int scan()throws IOException { if ( (total < 0)) throw (new InputMismatchException()); if ( (index >= total)) {index = 0; total = in.read(buf); if ( (total <= 0)) return -1; } return buf[index++];} public int scanInt()throws IOException { int integer = 0;  int n = scan(); while(isWhiteSpace(n))n = scan(); int neg = 1; if ( (n == '-')) {neg = -1; n = scan(); } while(!isWhiteSpace(n)){if ( ((n >= '0') && (n <= '9'))) {integer *= 10; integer += (n - '0'); n = scan(); } else throw (new InputMismatchException());}return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; return false;} } public static void sort( int[] arr, int l, int r){ if ( (l == r)) {return ;} int mid = ((l + r) / 2); sort(arr,l,mid); sort(arr,(mid + 1),r); merge(arr,l,mid,(mid + 1),r); } public static void merge( int[] arr, int l1, int r1, int l2, int r2){ int tmp[] = new int[((r2 - l1) + 1)];  int indx1 = l1,indx2 = l2; for ( int i = 0;(i < tmp.length);i++) {if ( (indx1 > r1)) {tmp[i] = arr[indx2]; indx2++; continue;} if ( (indx2 > r2)) {tmp[i] = arr[indx1]; indx1++; continue;} if ( (arr[indx1] < arr[indx2])) {tmp[i] = arr[indx1]; indx1++; continue;} tmp[i] = arr[indx2]; indx2++; }for ( int i = 0,j = l1;(i < tmp.length);i++,j++) {arr[j] = tmp[i]; }} public static void sort( long[] arr, int l, int r){ if ( (l == r)) {return ;} int mid = ((l + r) / 2); sort(arr,l,mid); sort(arr,(mid + 1),r); merge(arr,l,mid,(mid + 1),r); } public static void merge( long[] arr, int l1, int r1, int l2, int r2){ long tmp[] = new long[((r2 - l1) + 1)];  int indx1 = l1,indx2 = l2; for ( int i = 0;(i < tmp.length);i++) {if ( (indx1 > r1)) {tmp[i] = arr[indx2]; indx2++; continue;} if ( (indx2 > r2)) {tmp[i] = arr[indx1]; indx1++; continue;} if ( (arr[indx1] < arr[indx2])) {tmp[i] = arr[indx1]; indx1++; continue;} tmp[i] = arr[indx2]; indx2++; }for ( int i = 0,j = l1;(i < tmp.length);i++,j++) {arr[j] = tmp[i]; }} public static void main( String[] args)throws IOException { Scan input = new Scan();  StringBuilder ans = new StringBuilder("");  int test = input.scanInt(); for ( int tt = 1;(tt <= test);tt++) { int n = input.scanInt(); if ( ((n % 2) == 1)) {ans.append("NO\n"); continue;} n /= 2; double sq = Math.sqrt(n); if ( (Math.floor(sq) == Math.ceil(sq))) {ans.append("YES\n"); continue;} if ( ((n % 2) == 1)) {ans.append("NO\n"); continue;} n /= 2; sq = Math.sqrt(n); if ( (Math.floor(sq) == Math.ceil(sq))) {ans.append("YES\n"); continue;} ans.append("NO\n"); }System.out.println(ans); } }
5	public class Round111A{ public static void main( String[] args)throws IOException { new Round111A().run(); } public void run()throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  Scanner scanner = new Scanner(reader);  PrintWriter writer = new PrintWriter(System.out);  int n = scanner.nextInt();  int sum = 0;  Integer[] a = new Integer[n]; for ( int i = 0;(i < n);i++) {a[i] = scanner.nextInt(); sum += a[i]; }Arrays.sort(a,Collections.reverseOrder()); int s = 0;  int i = 0; while(((i < n) && (s <= (sum / 2)))){s += a[i]; i++; }writer.print(i); scanner.close(); writer.close(); } }
5	public class CF220A{ public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(in.readLine());  StringTokenizer st = new StringTokenizer(in.readLine());  int[] A = new int[n];  Integer[] B = new Integer[n]; for ( int i = 0;(i < n);i++) {A[i] = Integer.parseInt(st.nextToken()); B[i] = A[i]; }Collections.sort(Arrays.asList(B)); int cnt = 0; for ( int i = 0;(i < n);i++) if ( (A[i] != B[i])) cnt++; System.out.println(((cnt <= 2)?"YES":"NO")); } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  FElongatedMatrix solver = new FElongatedMatrix(); solver.solve(1,in,out); out.close(); } static class FElongatedMatrix{ int n ; int m ; int[][] arr ; int[][] memo ; int[][][] memo2 ; int first ; public void readInput( Scanner sc){ n = sc.nextInt(); m = sc.nextInt(); arr = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) arr[i][j] = sc.nextInt(); } public void solve( int testNumber, Scanner sc, PrintWriter pw){ int tc = 1; while((tc-- > 0)){readInput(sc); int max = 0; memo2 = new int[2][n][n]; for ( int[][] x :memo2) for ( int[] y :x) Arrays.fill(y,-1); for ( int i = 0;(i < n);i++) {memo = new int[n][(1 << n)]; for ( int[] y :memo) Arrays.fill(y,-1); first = i; max = Math.max(max,dp((1 << i),i)); }pw.println(max); }} private int dp( int msk, int prev){ if ( (msk == ((1 << n) - 1))) return getLast(first,prev); if ( (memo[prev][msk] != -1)) return memo[prev][msk]; int max = 0; for ( int i = 0;(i < n);i++) {if ( ((msk & (1 << i)) == 0)) max = Math.max(max,Math.min(getDiff(prev,i),dp((msk | (1 << i)),i))); }return memo[prev][msk] = max;} private int getLast( int i, int j){ if ( (memo2[0][i][j] != -1)) return memo2[0][i][j]; int min = Integer.MAX_VALUE; for ( int k = 0;(k < (m - 1));k++) min = Math.min(min,Math.abs((arr[i][k] - arr[j][(k + 1)]))); return memo2[0][i][j] = min;} private int getDiff( int i, int j){ if ( (memo2[1][i][j] != -1)) return memo2[1][i][j]; int min = Integer.MAX_VALUE; for ( int k = 0;(k < m);k++) min = Math.min(min,Math.abs((arr[i][k] - arr[j][k]))); return memo2[1][i][j] = min;} } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public String next(){ try{while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken(); }catch (Exception e){ throw (new RuntimeException(e));} } public int nextInt(){ return Integer.parseInt(next());} } }
2	public class Main{ public static void main( String[] args){ long x = nl(),k = nl(); if ( (x == 0)) {pr(0); exit(); } x %= mod; pr((((((((x * powm(2,(k + 1),mod)) % mod) - powm(2,k,mod)) + 1) % mod) + mod) % mod)); System.out.print(output); } static interface combiner{ ; } static final int mod = 1000000007; static final double eps = 1e-9; static final long inf = 100000000000000000L; static Reader in = new Reader(); static StringBuilder output = new StringBuilder(); static Random rn = new Random(); static void sort( int[] a){ int te ; for ( int i = 0;(i < a.length);i += 2) {te = rn.nextInt(a.length); if ( (i != te)) {a[i] ^= a[te]; a[te] ^= a[i]; a[i] ^= a[te]; } }Arrays.sort(a); } static void sort( long[] a){ int te ; for ( int i = 0;(i < a.length);i += 2) {te = rn.nextInt(a.length); if ( (i != te)) {a[i] ^= a[te]; a[te] ^= a[i]; a[i] ^= a[te]; } }Arrays.sort(a); } static void sort( double[] a){ int te ;  double te1 ; for ( int i = 0;(i < a.length);i += 2) {te = rn.nextInt(a.length); if ( (i != te)) {te1 = a[te]; a[te] = a[i]; a[i] = te1; } }Arrays.sort(a); } static void sort( int[][] a){ Arrays.sort(a,new Comparator<int[]>(){}); } static void sort( pair[] a){ Arrays.sort(a,new Comparator<pair>(){}); } static void pr( Object a){ output.append((a + "\n")); } static void pr(){ output.append("\n"); } static int ni(){ return Integer.parseInt(in.next());} static long nl(){ return Long.parseLong(in.next());} static String ns(){ return in.next();} static double nd(){ return Double.parseDouble(in.next());} static void exit(){ System.out.print(output); System.exit(0); } static int min( int... a){ int min = a[0]; for ( int i :a) min = Math.min(min,i); return min;} static int max( int... a){ int max = a[0]; for ( int i :a) max = Math.max(max,i); return max;} static int gcd( int... a){ int gcd = a[0]; for ( int i :a) gcd = gcd(gcd,i); return gcd;} static long min( long... a){ long min = a[0]; for ( long i :a) min = Math.min(min,i); return min;} static long max( long... a){ long max = a[0]; for ( long i :a) max = Math.max(max,i); return max;} static long gcd( long... a){ long gcd = a[0]; for ( long i :a) gcd = gcd(gcd,i); return gcd;} static String pr( String a, long b){ String c = ""; while((b > 0)){if ( ((b % 2) == 1)) c = c.concat(a); a = a.concat(a); b >>= 1; }return c;} static long powm( long a, long b, long m){ long an = 1;  long c = a; while((b > 0)){if ( ((b % 2) == 1)) an = ((an * c) % m); c = ((c * c) % m); b >>= 1; }return an;} static int gcd( int a, int b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static class Reader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public Reader(){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} } }
3	public class Main{ public static void main( String[] args){ InputReader reader = new InputReader(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = reader.nextInt();  int r = reader.nextInt();  int[] x = new int[n];  double[] y = new double[n]; for ( int i = 0;(i < n);++i) { int iniX = reader.nextInt();  double bestY = (double)r; for ( int j = 0;(j < i);++j) {if ( (Math.abs((iniX - x[j])) < (2 * r))) {bestY = Math.max(bestY,collisionY((double)x[j],y[j],(double)iniX,r)); } if ( (Math.abs((iniX - x[j])) == (2 * r))) {bestY = Math.max(bestY,y[j]); } }x[i] = iniX; y[i] = bestY; }for ( int i = 0;(i < n);++i) {pw.printf("%.9f ",y[i]); }pw.flush(); pw.close(); } public static double collisionY( double x1, double y1, double x2, double r){ double dhsq = (((r * r) * 4) - ((x1 - x2) * (x1 - x2))); return (y1 + Math.sqrt(dhsq));} public static class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{ String line = reader.readLine(); if ( (line == null)) {return "0";} tokenizer = new StringTokenizer(line); }catch (IOException ioe){ throw (new RuntimeException(ioe));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
0	public class A235{ public static void main( String[] args)throws Exception { BufferedReader ip = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(ip.readLine());  int a ,b ,c ;  int x = 0,y = 0,z = 0;  BigInteger l ,t ; if ( ((n - 2) > 1)) {a = n; b = (n - 1); c = (n - 2); } else {a = n; if ( ((n - 1) > 1)) b = (n - 1); else b = 1; c = 1; System.out.println((a * b)); return ;}if ( ((n - 3) > 1)) {x = (n - 1); y = (n - 2); z = (n - 3); } if ( ((n % 2) == 0)) if ( ((n % 3) == 0)) l = BigInteger.valueOf(x).multiply(BigInteger.valueOf(y).multiply(BigInteger.valueOf(z))); else {l = BigInteger.valueOf(a).multiply(BigInteger.valueOf(b).multiply(BigInteger.valueOf((c - 1)))); t = BigInteger.valueOf(x).multiply(BigInteger.valueOf(y).multiply(BigInteger.valueOf(z))); if ( (l.compareTo(t) < 0)) l = t; } else l = BigInteger.valueOf(a).multiply(BigInteger.valueOf(b).multiply(BigInteger.valueOf(c))); System.out.println(l); } }
3	public class Solution{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine());  long[] a = new long[n]; for ( int i = 0;(i < a.length);i++) {a[i] = Long.parseLong(st.nextToken()); } long[] sum = new long[n]; sum[0] = a[0]; for ( int i = 1;(i < sum.length);i++) {sum[i] = (sum[(i - 1)] + a[i]); }solve(a,sum); } private static void solve( long[] a, long[] sum){ int n = a.length;  Map<Long,List<Pair>> map = new HashMap<>(); for ( int j = 0;(j < sum.length);j++) {for ( int i = 0;(i <= j);i++) { long k = getSum(sum,i,j); if ( map.containsKey(k)) {map.get(k).add(new Pair(i,j)); } else { List<Pair> arr = new ArrayList<>(); arr.add(new Pair(i,j)); map.put(k,arr); }}} int max = -1;  List<Pair> ans = null; for ( Map.Entry<Long,List<Pair>> entry :map.entrySet()) { List<Pair> pairs = entry.getValue();  int prev = -1;  int count = 0;  List<Pair> temp = new ArrayList<Pair>(); for ( Pair p :pairs) {if ( (p.x > prev)) {prev = p.y; temp.add(p); count++; } }if ( (count > max)) {ans = temp; max = count; } }if ( (max != -1)) {System.out.println(ans.size()); for ( Pair p :ans) {System.out.println((((p.x + 1) + " ") + (p.y + 1))); }} } private static long getSum( long[] sum, int l, int r){ if ( (l == 0)) {return sum[r];} return (sum[r] - sum[(l - 1)]);} } class Pair{ int x ; int y ; Pair( int x, int y){ this.x = x; this.y = y; } }
5	public class A{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt();  int pl[] = new int[n]; if ( (k >= m)) {System.out.println(0); System.exit(0); } m -= k; for ( int i = 0;(i < n);i++) {pl[i] = (sc.nextInt() - 1); }Arrays.sort(pl); int out = 0; for ( int i = (n - 1);(i >= 0);i--) {m -= pl[i]; out++; if ( (m <= 0)) break; }if ( (m <= 0)) System.out.println(out); else System.out.println(-1); } }
3	public class Main2{ static long mod = 998244353; static FastScanner scanner ; static Set<Long> second = new HashSet<>(); static boolean applied = false; public static void main( String[] args){ scanner = new FastScanner(); int n = scanner.nextInt();  int[] a = scanner.nextIntArray(n);  int[] colors = new int[n]; ADUtils.sort(a); int color = 0; for ( int i = 0;(i < n);i++) {if ( (colors[i] != 0)) continue; color++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) colors[j] = color; }}System.out.println(color); } public static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String nextToken(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} long nextLong(){ return Long.parseLong(nextToken());} int[] nextIntArray( int n){ int[] res = new int[n]; for ( int i = 0;(i < n);i++) res[i] = nextInt(); return res;} } static class PrefixSums{ long[] sums ; public PrefixSums( long[] sums){ this.sums = sums; } } }
6	public class F{ static Scanner in = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static int n ,m ,res = 0; static int[][] a = new int[20][10005],Min = new int[20][20],Min1 = new int[20][20]; static int[][][] f = new int[(1 << 16)][20][20]; static int GetBit( int x, int k){ return ((x >> k) & 1);} static int TurnBit( int x, int k){ return (x ^ (1 << k));} public static void main( String[] args){ n = in.nextInt(); m = in.nextInt(); for ( int i = 0;(i < n);i++) for ( int j = 1;(j <= m);j++) a[i][j] = in.nextInt(); if ( (n == 1)) {res = (int)1e9; for ( int i = 1;(i < m);i++) res = Math.min(res,Math.abs((a[0][i] - a[0][(i + 1)]))); out.print(res); out.close(); return ;} for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) {Min[i][j] = Min1[i][j] = (int)1e9; for ( int t = 1;(t <= m);t++) Min[i][j] = Math.min(Min[i][j],Math.abs((a[i][t] - a[j][t]))); for ( int t = 1;(t < m);t++) Min1[i][j] = Math.min(Min1[i][j],Math.abs((a[i][t] - a[j][(t + 1)]))); }for ( int i = 0;(i < n);i++) f[(1 << i)][i][i] = (int)1e9; for ( int mask = 0;(mask < (1 << n));mask++) if ( (Integer.bitCount(mask) > 1)) for ( int i = 0;(i < n);i++) if ( (GetBit(mask,i) == 1)) for ( int j = 0;(j < n);j++) if ( ((i != j) && (GetBit(mask,j) == 1))) {for ( int t = 0;(t < n);t++) if ( ((j != t) && (GetBit(mask,t) == 1))) f[mask][i][j] = Math.max(f[mask][i][j],Math.min(f[TurnBit(mask,j)][i][t],Min[j][t])); if ( (mask == ((1 << n) - 1))) res = Math.max(res,Math.min(f[mask][i][j],Min1[j][i])); }  out.print(res); out.close(); } }
3	public class Mainm{ static int mod1 = (int)(1e9 + 7); static class Reader{ private final int BUFFER_SIZE = (1 << 16); Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Reader(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } String next()throws IOException { int c ; for ( c = read();(c <= 32);c = read()) ; StringBuilder sb = new StringBuilder(); for ( ;(c > 32);c = read()) {sb.append((char)c); }return sb.toString();} public int nextInt()throws IOException { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} public void close()throws IOException { if ( (din == null)) return ; din.close(); } public int[] nextArray( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }return a;} } static int GCD( int a, int b){ if ( (b == 0)) return a; return GCD(b,(a % b));} public static void main( String[] args)throws IOException { Reader r = new Reader();  OutputWriter770 out77 = new OutputWriter770(System.out);  int num1 = r.nextInt();  int[] arr1 = r.nextArray(num1); Arrays.sort(arr1); int res1 = 0; for ( int i = 0;(i < num1);i++) {if ( (arr1[i] != -1)) {res1++; int num2 = arr1[i]; arr1[i] = -1; for ( int j = (i + 1);(j < num1);j++) {if ( ((arr1[j] % num2) == 0)) {arr1[j] = -1; } }} }out77.print((res1 + "")); r.close(); out77.close(); } } class OutputWriter770{ BufferedWriter writer ; public OutputWriter770( OutputStream stream){ writer = new BufferedWriter(new OutputStreamWriter(stream)); } public void print( int i)throws IOException { writer.write((i + "")); } public void print( String s)throws IOException { writer.write((s + "")); } public void print( char[] c)throws IOException { writer.write(c); } public void close()throws IOException { writer.flush(); writer.close(); } }
2	public class Example{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(in.readLine()); }catch (Exception e){ } }return st.nextToken();} long nextLong(){ return Long.parseLong(next());} public void run()throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.flush(); out.close(); in.close(); } long n ,x ,y ,c ; boolean check( long z){ long res = (1 + ((2 * z) * (z + 1)));  long bx1 = ((z - x) + 1);  long by1 = ((z - y) + 1);  long bxn = ((z - n) + x);  long byn = ((z - n) + y); if ( (bx1 > 0)) {res -= (bx1 * bx1); } if ( (bxn > 0)) {res -= (bxn * bxn); } if ( (by1 > 0)) {res -= (by1 * by1); } if ( (byn > 0)) {res -= (byn * byn); } if ( (z > ((x + y) - 1))) { long m = (((z - x) - y) + 1); res += ((m * (m + 1)) / 2); } if ( (z > ((x + n) - y))) { long m = (((z - x) - n) + y); res += ((m * (m + 1)) / 2); } if ( (z > ((n - x) + y))) { long m = (((z - n) - y) + x); res += ((m * (m + 1)) / 2); } if ( (z > ((((n - x) + n) - y) + 1))) { long m = ((((z - (2 * n)) + x) + y) - 1); res += ((m * (m + 1)) / 2); } return (res >= c);} public void solve()throws Exception { n = nextLong(); x = nextLong(); y = nextLong(); c = nextLong(); long l = 0;  long r = (2 * n); while((r > l)){ long mid = ((r + l) / 2); if ( check(mid)) {r = mid; } else {l = (mid + 1); }}out.println(r); } public static void main( String[] args)throws Exception { new Example().run(); } }
0	public class A{ static class Scanner{ BufferedReader br = null; StringTokenizer tk = null; public Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next()throws IOException { while(((tk == null) || !tk.hasMoreTokens()))tk = new StringTokenizer(br.readLine()); return tk.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.valueOf(next());} } public static void main( String[] args)throws NumberFormatException,IOException { Scanner sc = new Scanner();  int T = sc.nextInt(); if ( (T > 0)) System.out.println(T); else { String cad = (T + "");  int min = Math.min((cad.charAt((cad.length() - 1)) - '0'),(cad.charAt((cad.length() - 2)) - '0')); if ( ((min == 0) && (cad.length() == 3))) System.out.println(0); else System.out.println(((cad.substring(0,(cad.length() - 2)) + "") + min)); }} }
5	public class CodeForces{ public void solve()throws IOException { int n = nextInt();  int t = nextInt();  double larr[] = new double[n];  double rarr[] = new double[n]; for ( int i = 0;(i < n);i++) { double x = nextDouble();  double r = nextDouble(); larr[i] = (x - (r / 2)); rarr[i] = (x + (r / 2)); }Arrays.sort(larr); Arrays.sort(rarr); int counter = 2; for ( int i = 1;(i < n);i++) {if ( ((larr[i] - rarr[(i - 1)]) > t)) {counter += 2; } else if ( ((larr[i] - rarr[(i - 1)]) == t)) {counter++; } }writer.print(counter); } public static void main( String[] args){ new CodeForces().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
0	public class Main{ Scanner in ; PrintWriter out ; void solve(){ out.print("25"); } void run(){ in = new Scanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } public static void main( String[] args){ new Main().run(); } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  MyInput in = new MyInput(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskE solver = new TaskE(); solver.solve(1,in,out); out.close(); } static class TaskE{ int n ; int k ; long[] neigibor ; Random random = new Random(); long maxClique ; public void solve( int testNumber, MyInput in, PrintWriter out){ n = in.nextInt(); k = in.nextInt(); neigibor = new long[n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {neigibor[i] |= (in.nextLong() << j); }} long maxClique = bronKerbosch();  long a = Long.bitCount(maxClique); dump(a); out.printf("%.12f\n",((((((a * (a - 1.0)) / 2) * k) / a) * k) / a)); } static void dump( Object... o){ System.err.println(Arrays.deepToString(o)); } long bronKerbosch(){ maxClique = 0; bronKerbosch2(0,((1L << n) - 1),0); return maxClique;} void bronKerbosch2( long r, long p, long x){ long px = (p | x); if ( (px == 0)) {if ( (Long.bitCount(maxClique) < Long.bitCount(r))) {maxClique = r; } return ;} int cnt = Long.bitCount(px);  int choice = random.nextInt(cnt);  int u ; for ( int i = 0;;i++) {if ( ((((px >>> i) & 1) != 0) && (choice-- == 0))) {u = i; break;} } long ne = (p & ~neigibor[u]); for ( int v = 0;(v < n);v++) if ( (((ne >>> v) & 1) != 0)) {bronKerbosch2((r | (1L << v)),(p & neigibor[v]),(x & neigibor[v])); p &= (1L << v); x |= (1L << v); } } } static class MyInput{ private final BufferedReader in ; private static int pos ; private static int readLen ; private static final char[] buffer = new char[(1024 * 8)]; private static char[] str = new char[((500 * 8) * 2)]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; {for ( int i = 0;(i < 10);i++) {isDigit[('0' + i)] = true; }isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; }public MyInput( InputStream is){ in = new BufferedReader(new InputStreamReader(is)); } public int read(){ if ( (pos >= readLen)) {pos = 0; try{readLen = in.read(buffer); }catch (IOException e){ throw (new RuntimeException());} if ( (readLen <= 0)) {throw (new MyInput.EndOfFileRuntimeException());} } return buffer[pos++];} public int nextInt(){ int len = 0; str[len++] = nextChar(); len = reads(len,isSpace); int i = 0;  int ret = 0; if ( (str[0] == '-')) {i = 1; } for ( ;(i < len);i++) ret = (((ret * 10) + str[i]) - '0'); if ( (str[0] == '-')) {ret = -ret; } return ret;} public long nextLong(){ int len = 0; str[len++] = nextChar(); len = reads(len,isSpace); int i = 0;  long ret = 0; if ( (str[0] == '-')) {i = 1; } for ( ;(i < len);i++) ret = (((ret * 10) + str[i]) - '0'); if ( (str[0] == '-')) {ret = -ret; } return ret;} public char nextChar(){ while(true){final int c = read(); if ( !isSpace[c]) {return (char)c;} }} int reads( int len, boolean[] accept){ try{while(true){final int c = read(); if ( accept[c]) {break;} if ( (str.length == len)) { char[] rep = new char[((str.length * 3) / 2)]; System.arraycopy(str,0,rep,0,str.length); str = rep; } str[len++] = (char)c; } }catch (MyInput.EndOfFileRuntimeException e){ } return len;} } }
6	public class CF85E{ public static void main( String[] args){ reader = new BufferedReader(new InputStreamReader(System.in)); int height = nextInt(),width = nextInt(); if ( (width > height)) { int t = width; width = height; height = t; } final int INF = ((height * width) + 10);  int[][][] dp = new int[(height + 1)][(1 << width)][(1 << width)]; for ( int[][] ints :dp) {for ( int[] anInt :ints) {Arrays.fill(anInt,INF); }}dp[0][0][0] = 0; for ( int r = 0;(r < height);++r) {for ( int uncovered = 0;(uncovered < (1 << width));++uncovered) {for ( int mask = 0;(mask < (1 << width));++mask) {if ( (dp[r][uncovered][mask] == INF)) {continue;} for ( int curMask = uncovered;(curMask < (1 << width));curMask = ((curMask + 1) | uncovered)) { int curUncovered = ((1 << width) - 1); for ( int i = 0;(i < width);++i) {if ( (hasBit(mask,i) || hasBit(curMask,i))) {curUncovered &= (1 << i); } if ( ((i > 0) && hasBit(curMask,(i - 1)))) {curUncovered &= (1 << i); } if ( ((i < (width - 1)) && hasBit(curMask,(i + 1)))) {curUncovered &= (1 << i); } }dp[(r + 1)][curUncovered][curMask] = Math.min(dp[(r + 1)][curUncovered][curMask],(dp[r][uncovered][mask] + Integer.bitCount(curMask))); }}}} int res = INF; for ( int x :dp[height][0]) res = Math.min(res,x); System.out.println(((height * width) - res)); } private static boolean hasBit( int mask, int bit){ return (((mask >> bit) & 1) == 1);} public static BufferedReader reader ; public static StringTokenizer tokenizer = null; static String nextToken(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public static int nextInt(){ return Integer.parseInt(nextToken());} }
0	public class A_Toy_Army{ public static void main( String[] args){ Scanner entrada = new Scanner(System.in); while(entrada.hasNextInt()){ int n = entrada.nextInt(); System.out.println((n + (n / 2))); }} }
3	public class C{ public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int r = in.nextInt();  int[] x = new int[n]; for ( int i = 0;(i < x.length);i++) {x[i] = in.nextInt(); } double[] res = new double[n]; res[0] = r; for ( int i = 1;(i < x.length);i++) { boolean found = false; for ( int j = 0;(j < i);j++) { double dis = Math.abs((x[i] - x[j]));  double rr = (((4.0 * r) * r) - ((1.0 * dis) * dis)); if ( (rr >= 0)) { double del = Math.sqrt(rr); res[i] = Math.max(res[i],(res[j] + del)); found = true; } }if ( !found) {res[i] = r; } }for ( int i = 0;(i < res.length);i++) {out.print((res[i] + " ")); }out.close(); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); st = new StringTokenizer(""); } public String next()throws IOException { if ( !st.hasMoreTokens()) {st = new StringTokenizer(br.readLine()); return next();} return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
1	public class Code implements Runnable{ public static void main( String[] args)throws IOException { new Thread(new Code()).start(); } private void solve()throws IOException { taskB(); } private void taskB()throws IOException { int n = nextInt(),k = nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);++i) arr[i] = nextInt(); int i = 0; while(((i < (n - 1)) && (arr[i] == arr[(i + 1)])))++i; if ( (k == 1)) writer.println(((1 + " ") + 1)); else if ( ((k == 2) && (i == (n - 2)))) writer.println((((n - 1) + " ") + n)); else {if ( (i == (n - 1))) writer.println(((-1 + " ") + -1)); else { int l = i;  Map<Integer,Integer> set = new HashMap<Integer,Integer>(n); while(((i < n) && (set.size() < k))){if ( set.containsKey(arr[i])) set.put(arr[i],(set.get(arr[i]) + 1)); else set.put(arr[i],1); i += 1; }if ( (set.size() < k)) writer.println(((-1 + " ") + -1)); else {while((((l < i) && ((i - l) > k)) && (set.get(arr[l]) > 1))){set.put(arr[l],(set.get(arr[l]) - 1)); l += 1; }writer.println((((l + 1) + " ") + i)); }}}} private int nextInt()throws IOException { return Integer.parseInt(nextToken());} private String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(reader.readLine()); return st.nextToken();} private String in = "",out = ""; private BufferedReader reader ; private PrintWriter writer ; private StringTokenizer st ; }
2	public class Main{ public static void main( String[] args)throws java.lang.Exception { Scanner scan = new Scanner(System.in);  long x = scan.nextLong();  long k = scan.nextLong();  long MOD = 1000000007; if ( (x == 0)) {System.out.println(0); return ;} x %= MOD; long a = new Num().pow(2L,(k + 1));  long b = new Num().pow(2L,k);  long res = ((((a * x) % MOD) - b) + 1); if ( (res < 0)) {res += MOD; } System.out.println((res % MOD)); } } class Num{ long MOD = 1000000007; long pow( long x, long k){ long base = (x % MOD);  long res = 1; while((k > 0)){if ( ((k & 1) == 1)) {res = ((res * base) % MOD); } base = ((base * base) % MOD); k >>= 1; }return res;} }
5	public class VKRound2Div2Task1{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String str = br.readLine();  String[] strs = str.split(" ");  int n = Integer.parseInt(strs[0]);  int a = Integer.parseInt(strs[1]);  int b = Integer.parseInt(strs[2]); str = br.readLine(); String[] hs = str.split(" ");  int[] h = new int[hs.length]; for ( int i = 0;(i < hs.length);i++) {h[i] = Integer.parseInt(hs[i]); }Arrays.sort(h); if ( (h[(b - 1)] == h[b])) {System.out.println(0); } else {System.out.println((h[b] - h[(b - 1)])); }} }
6	public class CF1185G2{ static final int MD = 1000000007; static int[][] solve1( int[] aa, int t, int n){ int[][] da = new int[(t + 1)][(n + 1)]; da[0][0] = 1; for ( int i = 0;(i < n);i++) { int a = aa[i]; for ( int s = (t - 1);(s >= 0);s--) for ( int m = 0;(m < n);m++) { int x = da[s][m]; if ( (x != 0)) { int s_ = (s + a); if ( (s_ <= t)) da[s_][(m + 1)] = ((da[s_][(m + 1)] + x) % MD); } }}return da;} static int[][][] solve2( int[] aa, int[] bb, int t, int na, int nb){ int[][] da = solve1(aa,t,na);  int[][][] dab = new int[(t + 1)][(na + 1)][(nb + 1)]; for ( int s = 0;(s <= t);s++) for ( int ma = 0;(ma <= na);ma++) dab[s][ma][0] = da[s][ma]; for ( int i = 0;(i < nb);i++) { int b = bb[i]; for ( int s = (t - 1);(s >= 0);s--) for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb < nb);mb++) { int x = dab[s][ma][mb]; if ( (x != 0)) { int s_ = (s + b); if ( (s_ <= t)) dab[s_][ma][(mb + 1)] = ((dab[s_][ma][(mb + 1)] + x) % MD); } }}return dab;} static long power( int a, int k){ if ( (k == 0)) return 1; long p = power(a,(k / 2)); p = ((p * p) % MD); if ( ((k % 2) == 1)) p = ((p * a) % MD); return p;} static int[] ff ,gg ; static int ch( int n, int k){ return (int)(((((long)ff[n] * gg[(n - k)]) % MD) * gg[k]) % MD);} static int[][][] init( int n, int na, int nb, int nc){ ff = new int[(n + 1)]; gg = new int[(n + 1)]; for ( int i = 0,f = 1;(i <= n);i++) {ff[i] = f; gg[i] = (int)power(f,(MD - 2)); f = (int)(((long)f * (i + 1)) % MD); } int[][][] dp = new int[(na + 1)][(nb + 1)][(nc + 1)]; for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) for ( int mc = 0;(mc <= nc);mc++) { int x = (int)(((((((long)ff[((ma + mb) + mc)] * gg[ma]) % MD) * gg[mb]) % MD) * gg[mc]) % MD); for ( int ma_ = ((ma == 0)?0:1);(ma_ <= ma);ma_++) { int cha = ((ma == 0)?1:ch((ma - 1),(ma_ - 1))); for ( int mb_ = ((mb == 0)?0:1);(mb_ <= mb);mb_++) { int chb = ((mb == 0)?1:ch((mb - 1),(mb_ - 1))); for ( int mc_ = ((mc == 0)?0:1);(mc_ <= mc);mc_++) { int chc = ((mc == 0)?1:ch((mc - 1),(mc_ - 1)));  int y = dp[ma_][mb_][mc_]; if ( (y == 0)) continue; x = (int)((x - ((((((long)y * cha) % MD) * chb) % MD) * chc)) % MD); }}}if ( (x < 0)) x += MD; dp[ma][mb][mc] = x; }for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) for ( int mc = 0;(mc <= nc);mc++) dp[ma][mb][mc] = (int)(((((((long)dp[ma][mb][mc] * ff[ma]) % MD) * ff[mb]) % MD) * ff[mc]) % MD); return dp;} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int t = Integer.parseInt(st.nextToken());  int[] aa = new int[n];  int[] bb = new int[n];  int[] cc = new int[n];  int na = 0,nb = 0,nc = 0; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); int a = Integer.parseInt(st.nextToken());  int g = Integer.parseInt(st.nextToken()); if ( (g == 1)) aa[na++] = a; else if ( (g == 2)) bb[nb++] = a; else cc[nc++] = a; } int[][][] dp = init(n,na,nb,nc);  int[][][] dab = solve2(aa,bb,t,na,nb);  int[][] dc = solve1(cc,t,nc);  int ans = 0; for ( int tab = 0;(tab <= t);tab++) { int tc = (t - tab); for ( int ma = 0;(ma <= na);ma++) for ( int mb = 0;(mb <= nb);mb++) { int xab = dab[tab][ma][mb]; if ( (xab == 0)) continue; for ( int mc = 0;(mc <= nc);mc++) { int xc = dc[tc][mc]; if ( (xc == 0)) continue; ans = (int)((ans + (((long)xab * xc) * dp[ma][mb][mc])) % MD); }}}System.out.println(ans); } }
6	public class Main{ static int a[][] ,n ; static boolean isClique[] ; static int maxClique[] ; static void DFS1( int p, int n, int S){ if ( (p > n)) {isClique[S] = true; return ;} DFS1((p + 1),n,S); boolean mark = true; for ( int i = 1;(i < p);++i) if ( ((((S >> (i - 1)) & 1) == 1) && (a[p][i] == 0))) mark = false; if ( mark) DFS1((p + 1),n,((1 << (p - 1)) | S)); } static void DFS2( int p, int n, int m, int S){ if ( (p > n)) { int cnt = 0; for ( int i = m;(i <= n);++i) if ( (((S >> (i - m)) & 1) == 1)) ++cnt; maxClique[S] = cnt; return ;} DFS2((p + 1),n,m,S); boolean mark = true; for ( int i = m;(i < p);++i) if ( ((((S >> (i - m)) & 1) == 1) && (a[p][i] == 0))) mark = false; if ( mark) DFS2((p + 1),n,m,((1 << (p - m)) | S)); } public static void main( String[] args){ Scanner sc = new Scanner(System.in); n = Integer.parseInt(sc.next()); a = new int[(n + 10)][(n + 10)]; int cap = Integer.parseInt(sc.next()); for ( int i = 1;(i <= n);++i) for ( int j = 1;(j <= n);++j) a[i][j] = Integer.parseInt(sc.next()); int m = ((n + 1) >> 1); isClique = new boolean[(1 << m)]; Arrays.fill(isClique,false); DFS1(1,m,0); maxClique = new int[(1 << (n - m))]; Arrays.fill(maxClique,0); DFS2((m + 1),n,(m + 1),0); for ( int i = 1;(i < (1 << (n - m)));++i) for ( int j = (m + 1);(j <= n);++j) if ( (((i >> ((j - m) - 1)) & 1) == 1)) maxClique[i] = Math.max(maxClique[i],maxClique[(i - (1 << ((j - m) - 1)))]);  int ans = 0,tmp[] = new int[(m + 10)]; for ( int i = 0;(i < (1 << m));++i) if ( isClique[i]) { int mask = 0,cnt = 0; for ( int j = 1;(j <= m);++j) if ( (((i >> (j - 1)) & 1) == 1)) tmp[++cnt] = j; for ( int j = (m + 1);(j <= n);++j) { boolean mark = true; for ( int k = 1;(k <= cnt);++k) if ( (a[j][tmp[k]] == 0)) mark = false; if ( mark) mask |= (1 << ((j - m) - 1)); }ans = Math.max(ans,(cnt + maxClique[mask])); } System.out.printf("%.9f\n",((((cap * cap) * (ans - 1)) / 2.0) / ans)); } }
4	public class Solution{ public static void main( String[] args)throws IOException { FastReader in = new FastReader(System.in);  int t = in.nextInt();  StringBuilder sb = new StringBuilder();  int i ,j ,tc = 0; while((tc++ < t)){ int n = in.nextInt();  int arr[] = new int[n]; for ( i = 0;(i < n);i++) arr[i] = in.nextInt(); int ans[] = new int[(n + 4)]; ans[0] = 1; int pos = 0; sb.append("1\n"); for ( i = 1;(i < n);i++) {if ( (arr[i] == (arr[(i - 1)] + 1))) {ans[pos] = (ans[pos] + 1); } else if ( (arr[i] == 1)) {pos++; ans[pos] = 1; } else {while((ans[pos] != (arr[i] - 1)))pos--; ans[pos] = (ans[pos] + 1); }for ( j = 0;(j <= pos);j++) {if ( (j < pos)) sb.append(ans[j]).append("."); else sb.append(ans[j]).append("\n"); }}}System.out.println(sb); } } class FastReader{ byte[] buf = new byte[2048]; int index ,total ; InputStream in ; FastReader( InputStream is){ in = is; } int scan()throws IOException { if ( (index >= total)) {index = 0; total = in.read(buf); if ( (total <= 0)) {return -1;} } return buf[index++];} int nextInt()throws IOException { int c ,val = 0; for ( c = scan();(c <= 32);c = scan()) ; boolean neg = (c == '-'); if ( ((c == '-') || (c == '+'))) {c = scan(); } for ( ;((c >= '0') && (c <= '9'));c = scan()) {val = (((val << 3) + (val << 1)) + (c & 15)); }return (neg?-val:val);} }
5	public class Abra{ void solve()throws IOException { int n = nextInt(),t = nextInt();  TreeMap<Integer,Integer> tm = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) tm.put(nextInt(),nextInt()); double tx = -1e9;  int c = 2; for ( Map.Entry<Integer,Integer> m :tm.entrySet()) {if ( (tx == -1e9)) {tx = ((m.getKey() + (m.getValue() / 2.0)) + t); continue;} if ( ((m.getKey() - (m.getValue() / 2.0)) >= tx)) c++; if ( ((m.getKey() - (m.getValue() / 2.0)) > tx)) c++; tx = ((m.getKey() + (m.getValue() / 2.0)) + t); }out.print(c); } public static void main( String[] args)throws IOException { new Abra().run(); } StreamTokenizer in ; PrintWriter out ; boolean oj ; BufferedReader br ; void init()throws IOException { oj = (System.getProperty("ONLINE_JUDGE") != null); Reader reader = (oj?new InputStreamReader(System.in):new FileReader("input.txt"));  Writer writer = (oj?new OutputStreamWriter(System.out):new FileWriter("output.txt")); br = new BufferedReader(reader); in = new StreamTokenizer(br); out = new PrintWriter(writer); } long beginTime ; void run()throws IOException { beginTime = System.currentTimeMillis(); long beginMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()); init(); solve(); long endMem = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());  long endTime = System.currentTimeMillis(); if ( !oj) {System.out.println(("Memory used = " + (endMem - beginMem))); System.out.println(("Total memory = " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()))); System.out.println(("Running time = " + (endTime - beginTime))); } out.flush(); } int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} myLib lib = new myLib(); static class myLib{ long gcd( long a, long b){ if ( ((a == 0) || (b == 0))) return 1; if ( (a < b)) { long c = b; b = a; a = c; } while(((a % b) != 0)){a = (a % b); if ( (a < b)) { long c = b; b = a; a = c; } }return b;} int gcd( int a, int b){ if ( ((a == 0) || (b == 0))) return 1; if ( (a < b)) { int c = b; b = a; a = c; } while(((a % b) != 0)){a = (a % b); if ( (a < b)) { int c = b; b = a; a = c; } }return b;} long lcm( long a, long b){ return ((a * b) / gcd(a,b));} int lcm( int a, int b){ return ((a * b) / gcd(a,b));} int partition( int n, int l, int m){ if ( (n < l)) return 0; if ( (n < (l + 2))) return 1; if ( (l == 1)) return 1; int c = 0; for ( int i = Math.min(((n - l) + 1),m);(i >= (((n + l) - 1) / l));i--) {c += partition((n - i),(l - 1),i); }return c;} String numSym = "0123456789ABCDEF"; static boolean stringContainsOf( String x, String c){ for ( int i = 0;(i < x.length());i++) {if ( (c.indexOf(x.charAt(i)) == -1)) return false; }return true;} long pow( long a, long n){ if ( (n == 0)) return 1; long k = n,b = 1,c = a; while((k != 0)){if ( ((k % 2) == 0)) {k /= 2; c *= c; } else {k--; b *= c; }}return b;} int pow( int a, int n){ if ( (n == 0)) return 1; int k = n,b = 1,c = a; while((k != 0)){if ( ((k % 2) == 0)) {k /= 2; c *= c; } else {k--; b *= c; }}return b;} double pow( double a, int n){ if ( (n == 0)) return 1; double k = n,b = 1,c = a; while((k != 0)){if ( ((k % 2) == 0)) {k /= 2; c *= c; } else {k--; b *= c; }}return b;} class NotANumberException extends Exception{ private static final long serialVersionUID = 1L; String mistake ; NotANumberException(){ mistake = "Unknown."; } NotANumberException( String message){ mistake = message; } } int[] rotateDice( int[] a, int n){ int[] c = new int[6]; if ( (n == 0)) {c[0] = a[1]; c[1] = a[5]; c[2] = a[2]; c[3] = a[0]; c[4] = a[4]; c[5] = a[3]; } if ( (n == 1)) {c[0] = a[2]; c[1] = a[1]; c[2] = a[5]; c[3] = a[3]; c[4] = a[0]; c[5] = a[4]; } if ( (n == 2)) {c[0] = a[3]; c[1] = a[0]; c[2] = a[2]; c[3] = a[5]; c[4] = a[4]; c[5] = a[1]; } if ( (n == 3)) {c[0] = a[4]; c[1] = a[1]; c[2] = a[0]; c[3] = a[3]; c[4] = a[5]; c[5] = a[2]; } if ( (n == 4)) {c[0] = a[0]; c[1] = a[2]; c[2] = a[3]; c[3] = a[4]; c[4] = a[1]; c[5] = a[5]; } if ( (n == 5)) {c[0] = a[0]; c[1] = a[4]; c[2] = a[1]; c[3] = a[2]; c[4] = a[3]; c[5] = a[5]; } return c;} int min( int... a){ int c = Integer.MAX_VALUE; for ( int d :a) if ( (d < c)) c = d; return c;} final double goldenRatio = ((1 + Math.sqrt(5)) / 2); final double aGoldenRatio = ((1 - Math.sqrt(5)) / 2); Random random = new Random(); } class myFraction{ long num = 0,den = 1; void reduce(){ long d = lib.gcd(num,den); num /= d; den /= d; } myFraction( long ch, long zn){ num = ch; den = zn; reduce(); } myFraction add( myFraction t){ long nd = lib.lcm(den,t.den);  myFraction r = new myFraction((((nd / den) * num) + ((nd / t.den) * t.num)),nd); r.reduce(); return r;} } }
4	public class A{ public void run(){ Scanner sc = new Scanner(System.in);  String s = sc.next();  int n = s.length();  String[] ss = new String[n]; for ( int i = 0;(i < n);i++) ss[i] = s.substring(i); sort(ss); int res = 0; for ( int i = 1;(i < n);i++) res = max(res,count(ss[(i - 1)],ss[i])); System.out.println(res); } int count( String s, String t){ int ret = 0; for ( int i = 0;(i < min(s.length(),t.length()));i++) if ( (s.charAt(i) != t.charAt(i))) return ret; else ret++; return ret;} public static void main( String... args){ new A().run(); } }
0	public class Main{ StreamTokenizer in ; BufferedReader inb ; PrintWriter out ; public static void main( String[] args)throws Exception { new Main().run(); } public void run()throws Exception { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); inb = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } public int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public int parseInt()throws Exception { return Integer.parseInt(inb.readLine());} public void solve()throws Exception { int n = nextInt(); if ( (((((((((((((((n % 4) == 0) || ((n % 44) == 0)) || ((n % 47) == 0)) || ((n % 74) == 0)) || ((n % 744) == 0)) || ((n % 747) == 0)) || ((n % 774) == 0)) || ((n % 777) == 0)) || ((n % 7) == 0)) || ((n % 444) == 0)) || ((n % 447) == 0)) || ((n % 474) == 0)) || ((n % 477) == 0)) || ((n % 77) == 0))) {out.print("YES"); } else {out.print("NO"); }} }
1	public class Main{ public static void main( String[] args)throws IOException { try{if ( new File("input.txt").exists()) System.setIn(new FileInputStream("input.txt"));  }catch (SecurityException e){ } new Main().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); int MAXDEG = 5; private void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = nextInt();  int[] sumDegs = new int[(MAXDEG + 1)]; sumDegs[0] = 1; int deg = 1; for ( int i = 1;(i <= MAXDEG);i++) {deg *= 26; sumDegs[i] = (sumDegs[(i - 1)] + deg); }for ( int i = 0;(i < n);i++) { String s = nextLine();  String pref = "";  int endPos = -1; for ( int j = 0;(j < s.length());j++) {if ( !isLet(s.charAt(j))) {endPos = j; break;} pref += s.charAt(j); } int num = -1; try{num = Integer.parseInt(s.substring(endPos)); }catch (Exception e){ } if ( (num != -1)) { int col = sumDegs[(pref.length() - 1)];  int val = 0; for ( int j = 0;(j < pref.length());j++) {val = ((val * 26) + (pref.charAt(j) - 'A')); }col += val; out.println(((("R" + num) + "C") + col)); } else { int row = Integer.parseInt(s.substring(1,s.indexOf('C')));  int col = Integer.parseInt(s.substring((s.indexOf('C') + 1)));  int len = MAXDEG; while((col < sumDegs[len]))len--; len++; col -= sumDegs[(len - 1)]; String res = ""; while((col > 0)){res = ((char)((col % 26) + 'A') + res); col /= 26; }while((res.length() < len))res = ("A" + res); out.println((res + row)); }}in.close(); out.close(); } private boolean isLet( char c){ return ((c >= 'A') && (c <= 'Z'));} String nextToken()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextLine()throws IOException { st = new StringTokenizer(""); return in.readLine();} }
6	public class F531{ public static void main( String[] args){ MyScanner sc = new MyScanner();  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int n = sc.nextInt();  int m = sc.nextInt();  long[][] mn1 = new long[n][n];  long[][] mn2 = new long[n][n];  long[][] grid = new long[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) grid[i][j] = sc.nextInt(); }if ( (n == 1)) { long ans = Integer.MAX_VALUE; for ( int i = 0;(i < (m - 1));i++) ans = Math.min(ans,Math.abs((grid[0][i] - grid[0][(i + 1)]))); out.println(ans); out.close(); return ;} for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i == j)) continue; long min = Long.MAX_VALUE; for ( int k = 0;(k < m);k++) min = Math.min(min,Math.abs((grid[i][k] - grid[j][k]))); mn1[i][j] = min; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i == j)) continue; long min = Long.MAX_VALUE; for ( int k = 0;(k < (m - 1));k++) min = Math.min(min,Math.abs((grid[i][k] - grid[j][(k + 1)]))); mn2[i][j] = min; }} long[][] dp = new long[(1 << n)][n];  long ans = 0; for ( int i = 0;(i < n);i++) {for ( long[] a :dp) Arrays.fill(a,-1); for ( int j = 0;(j < n);j++) {if ( (j == i)) dp[(1 << j)][j] = Long.MAX_VALUE; else dp[(1 << j)][j] = 0; }for ( int mask = 1;(mask < (1 << n));mask++) {for ( int last = 0;(last < n);last++) {if ( (dp[mask][last] != -1)) continue; for ( int prev = 0;(prev < n);prev++) {if ( (prev == last)) continue; if ( (((mask >> prev) & 1) == 1)) {dp[mask][last] = Math.max(dp[mask][last],Math.min(mn1[prev][last],dp[(mask ^ (1 << last))][prev])); } }}}for ( int j = 0;(j < n);j++) { long end = mn2[j][i]; ans = Math.max(ans,Math.min(dp[((1 << n) - 1)][j],end)); }}out.println(ans); out.close(); } public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
6	public class Solution{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private Random rnd ; int[] levels ; int[] loyal ; int n ,k ; double A ; int[] choices ; int[] new_loyal ; double[] koef ; double ans = 0.0; int total ; void rec( int step, int start){ if ( (step == k)) {for ( int i = 0;(i < n);i++) {new_loyal[i] = loyal[i]; }for ( int i = 0;(i < k);i++) {new_loyal[choices[i]] = Math.min(100,(new_loyal[choices[i]] + 10)); } int full = 0; for ( int i = 0;(i < n);i++) {if ( (new_loyal[i] == 100)) {++full; } }if ( (full > (n / 2))) {ans = 1.0; return ;} for ( int i = 0;(i < n);i++) {koef[i] = ((double)new_loyal[i] / 100.0); } int bits_needed = ((n / 2) + 1);  double total_win = 0.0;  double total_fights = 0.0; for ( int mask = 0;(mask < total);mask++) { int bits = 0;  double win = 1.0;  double loose = 1.0;  double b = 0.0; for ( int bit = 0;(bit < n);bit++) {if ( ((mask & (1 << bit)) != 0)) {++bits; win *= koef[bit]; } else {loose *= (1.0 - koef[bit]); b += levels[bit]; }} double prob = (win * loose); if ( (bits >= bits_needed)) {total_win += prob; } else {total_fights += (prob * (A / (A + b))); }}ans = Math.max(ans,(total_win + total_fights)); } else {for ( int i = start;(i < n);i++) {choices[step] = i; rec((step + 1),i); }}} public void solve()throws IOException { n = nextInt(); k = nextInt(); A = nextInt(); levels = new int[n]; loyal = new int[n]; new_loyal = new int[n]; choices = new int[k]; koef = new double[n]; for ( int i = 0;(i < n);i++) {levels[i] = nextInt(); loyal[i] = nextInt(); }total = (1 << n); rec(0,0); out.println(ans); } public static void main( String[] args){ new Solution().run(); } public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); st = null; rnd = new Random(); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } private String nextToken()throws IOException,NullPointerException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
6	public class Main implements Runnable{ static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; private BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new Main(),"Main",(1 << 26)).start(); } static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static long modPow( long a, long p, long m){ if ( (a == 1)) return 1; long ans = 1; while((p > 0)){if ( ((p % 2) == 1)) ans = ((ans * a) % m); a = ((a * a) % m); p >>= 1; }return ans;} static long sol_x ,sol_y ,gcd_a_b ; static void extendedEuclid( long a, long b){ if ( (b == 0)) {gcd_a_b = a; sol_x = 1; sol_y = 0; } else {extendedEuclid(b,(a % b)); long temp = sol_x; sol_x = sol_y; sol_y = (temp - ((a / b) * sol_y)); }} long f( int start, int end, int mask, Long[][][] dp, int n, int[][] cost, int[][] costRight){ if ( (dp[start][end][mask] != null)) return dp[start][end][mask]; long ans = Integer.MIN_VALUE; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) { int newMask = (mask | (1 << i)); if ( (((1 << n) - 1) != (mask | (1 << i)))) {ans = Math.max(ans,Math.min(cost[end][i],f(start,i,newMask,dp,n,cost,costRight))); } else {ans = Math.max(ans,Math.min(cost[end][i],costRight[start][i])); }} }return dp[start][end][mask] = ans;} }
4	@SuppressWarnings("unchecked") public class P35C{ static final int SHIFT = 11; static final int MASK = ((1 << SHIFT) - 1); static final int[] DX = {-1,1,0,0}; static final int[] DY = {0,0,-1,1}; public void run()throws Exception { int m = nextInt();  int n = nextInt();  boolean[][] burned = new boolean[n][m];  List<Integer> burn = new ArrayList(); for ( int k = nextInt();(k > 0);k--) { int x = (nextInt() - 1);  int y = (nextInt() - 1); burned[y][x] = true; burn.add(((x << SHIFT) | y)); } int lastXY = 0;  List<Integer> newBurn = null; do {lastXY = burn.get(0); newBurn = new ArrayList(); for ( int xy :burn) { int x = (xy >> SHIFT);  int y = (xy & MASK); for ( int i = 0;(i < 4);i++) { int nx = (x + DX[i]);  int ny = (y + DY[i]); if ( (((((ny >= 0) && (ny < n)) && (nx >= 0)) && (nx < m)) && burned)) {burned[ny][nx] = true; newBurn.add(((nx << SHIFT) | ny)); } }}burn = newBurn; }while((newBurn.size() > 0));println(((((lastXY >> SHIFT) + 1) + " ") + ((lastXY & MASK) + 1))); } public static void main( String... args)throws Exception { br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream("output.txt"))); new P35C().run(); br.close(); pw.close(); System.err.println((("\n[Time : " + (System.currentTimeMillis() - startTime)) + " ms]")); } static long startTime = System.currentTimeMillis(); static BufferedReader br ; static PrintWriter pw ; StringTokenizer stok ; String nextToken()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return null;} stok = new StringTokenizer(s); }return stok.nextToken();} void print( byte b){ print(("" + b)); } void print( int i){ print(("" + i)); } void print( long l){ print(("" + l)); } void print( double d){ print(("" + d)); } void print( char c){ print(("" + c)); } void print( Object o){ if ( (o instanceof int[])) {print(Arrays.toString((int[])o)); } else if ( (o instanceof long[])) {print(Arrays.toString((long[])o)); } else if ( (o instanceof char[])) {print(Arrays.toString((char[])o)); } else if ( (o instanceof byte[])) {print(Arrays.toString((byte[])o)); } else if ( (o instanceof short[])) {print(Arrays.toString((short[])o)); } else if ( (o instanceof boolean[])) {print(Arrays.toString((boolean[])o)); } else if ( (o instanceof float[])) {print(Arrays.toString((float[])o)); } else if ( (o instanceof double[])) {print(Arrays.toString((double[])o)); } else if ( (o instanceof Object[])) {print(Arrays.toString((Object[])o)); } else {print(("" + o)); }} void print( String s){ pw.print(s); } void println(){ println(""); } void println( byte b){ println(("" + b)); } void println( int i){ println(("" + i)); } void println( long l){ println(("" + l)); } void println( double d){ println(("" + d)); } void println( char c){ println(("" + c)); } void println( Object o){ print(o); println(); } void println( String s){ pw.println(s); } int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} String nextLine()throws IOException { return br.readLine();} }
6	public class D{ public static long[][] dp ; public static boolean[][] map ; public static void main( String[] args){ Scanner in = new Scanner();  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int m = in.nextInt(); dp = new long[n][(1 << (n + 1))]; map = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (in.nextInt() - 1);  int b = (in.nextInt() - 1); map[a][b] = true; map[b][a] = true; }for ( long[] temp :dp) {Arrays.fill(temp,-1); } long result = 0; for ( int i = 0;(i < n);i++) {result += cal((1 << i),i,i,1); }out.println((result / 2)); out.close(); } public static long cal( int mask, int from, int to, int len){ if ( (dp[to][mask] != -1)) {return dp[to][mask];} long result = 0; if ( ((len > 2) && map[from][to])) {result++; } for ( int i = (from + 1);(i < map.length);i++) {if ( (map[to][i] && ((mask & (1 << i)) == 0))) {result += cal((mask | (1 << i)),from,i,(len + 1)); } }dp[to][mask] = result; return result;} public static long gcd( long a, long b){ if ( (b == 0)) {return a;} return gcd(b,(a % b));} public static long pow( long a, long b){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long val = pow(a,(b / 2)); if ( ((b % 2) == 0)) {return (val * val);} else {return (val * (val * a));}} static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw (new RuntimeException());} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
5	public class Main implements Runnable{ class Home implements Comparable<Home>{ int st ,end ; } public void solve()throws IOException { int n = nextInt(),t = (nextInt() * 2);  Home[] h = new Home[n]; for ( int i = 0;(i < n);++i) { int x = (nextInt() * 2),a = (nextInt() * 2); h[i] = new Home(); h[i].st = (x - (a / 2)); h[i].end = (x + (a / 2)); }Arrays.sort(h); int ans = 2; for ( int i = 0;((i + 1) < n);++i) { int delta = (h[(i + 1)].st - h[i].end); if ( (delta == t)) ans++; if ( (delta > t)) ans += 2; }pw.println(ans); } static final String filename = "A"; static final boolean fromConsole = true; private StringTokenizer st ; private BufferedReader in ; private PrintWriter pw ; boolean hasNext()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return false;} st = new StringTokenizer(line); }return st.hasMoreTokens();} String next()throws IOException { return (hasNext()?st.nextToken():null);} int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args){ new Thread(new Main()).start(); } }
2	public class C{ public static void main( String[] args)throws java.lang.Exception { Scanner scan = new Scanner(System.in);  long x = scan.nextLong(),k = scan.nextLong();  long MOD = 1000000007; if ( (x == 0)) {System.out.println("0"); return ;} x %= MOD; long ans = ((((((new myC().fastPow(2L,(k + 1)) * x) % MOD) - new myC().fastPow(2L,k)) + MOD) + 1) % MOD); ans %= MOD; System.out.println(ans); } } class myC{ long MOD = 1000000007; long fastPow( long x, long k){ long bb = (x % MOD),ans = 1; while((k > 0)){if ( ((k & 1) == 1)) {ans = ((ans * bb) % MOD); } bb = ((bb * bb) % MOD); k >>= 1; }return ans;} }
0	public class Main{ static int mod = 1000000007; static int size = 200000; static long[] fac = new long[size]; static long[] finv = new long[size]; static long[] inv = new long[size]; static int INF = Integer.MAX_VALUE; public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  String[] s = new String[2]; for ( int i = 0;(i < 2);i++) {s[i] = scanner.next(); } int n = s[0].length();  char[][] c = new char[2][n]; for ( int i = 0;(i < 2);i++) {for ( int j = 0;(j < n);j++) {c[i][j] = s[i].charAt(j); }} int count = 0; for ( int i = 0;(i < (n - 1));i++) {if ( (((c[0][i] == '0') && (c[1][i] == '0')) && (c[0][(i + 1)] == '0'))) {c[0][i] = 'X'; c[1][i] = 'X'; c[0][(i + 1)] = 'X'; count++; } if ( (((c[0][i] == '0') && (c[1][i] == '0')) && (c[1][(i + 1)] == '0'))) {c[0][i] = 'X'; c[1][i] = 'X'; c[1][(i + 1)] = 'X'; count++; } if ( (((c[0][i] == '0') && (c[0][(i + 1)] == '0')) && (c[1][(i + 1)] == '0'))) {c[0][i] = 'X'; c[0][(i + 1)] = 'X'; c[1][(i + 1)] = 'X'; count++; } if ( (((c[0][(i + 1)] == '0') && (c[1][(i + 1)] == '0')) && (c[1][i] == '0'))) {c[1][i] = 'X'; c[0][(i + 1)] = 'X'; c[1][(i + 1)] = 'X'; count++; } }System.out.println(count); } public static long pow( long x, long n){ long ans = 1; while((n > 0)){if ( ((n & 1) == 1)) {ans = (ans * x); ans %= mod; } x = ((x * x) % mod); n >>= 1; }return ans;} public static long gcd( long n, long m){ if ( (m > n)) return gcd(m,n); if ( (m == 0)) return n; return gcd(m,(n % m));} }
2	public class C{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int[][] M = {{2,(mod - 1)},{0,1}};  long n = nl(); if ( (n == 0)) {out.println(0); return ;} n = ((n * 2) % mod); long K = nl();  int[] v = new int[]{(int)n,1}; out.println(pow(M,v,K)[0]); } public static final int mod = 1000000007; public static final long m2 = ((long)mod * mod); public static final long BIG = (8L * m2); public static int[] pow( int[][] A, int[] v, long e){ for ( int i = 0;(i < v.length);i++) {if ( (v[i] >= mod)) v[i] %= mod; } int[][] MUL = A; for ( ;(e > 0);e >>>= 1) {if ( ((e & 1) == 1)) v = mul(MUL,v); MUL = p2(MUL); }return v;} public static int[] mul( int[][] A, int[] v){ int m = A.length;  int n = v.length;  int[] w = new int[m]; for ( int i = 0;(i < m);i++) { long sum = 0; for ( int k = 0;(k < n);k++) {sum += ((long)A[i][k] * v[k]); if ( (sum >= BIG)) sum -= BIG; }w[i] = (int)(sum % mod); }return w;} public static int[][] p2( int[][] A){ int n = A.length;  int[][] C = new int[n][n]; for ( int i = 0;(i < n);i++) { long[] sum = new long[n]; for ( int k = 0;(k < n);k++) {for ( int j = 0;(j < n);j++) {sum[j] += ((long)A[i][k] * A[k][j]); if ( (sum[j] >= BIG)) sum[j] -= BIG; }}for ( int j = 0;(j < n);j++) {C[i][j] = (int)(sum[j] % mod); }}return C;} void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new C().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private long nl(){ long num = 0;  int b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
5	public class A{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni(),K = ni();  int[] a = na(n); if ( (K == 1)) {out.println(n); return ;} a = radixSort(a); boolean[] dead = new boolean[n];  int ct = 0; for ( int i = 0;(i < n);i++) {if ( !dead[i]) {ct++; if ( (((long)a[i] * K) <= 1000000000)) { int ind = Arrays.binarySearch(a,(a[i] * K)); if ( (ind >= 0)) {dead[ind] = true; } } } }out.println(ct); } public static int[] radixSort( int[] f){ int[] to = new int[f.length]; { int[] b = new int[65537]; for ( int i = 0;(i < f.length);i++) b[(1 + (f[i] & 0xffff))]++; for ( int i = 1;(i <= 65536);i++) b[i] += b[(i - 1)]; for ( int i = 0;(i < f.length);i++) to[b[(f[i] & 0xffff)]++] = f[i]; int[] d = f; f = to; to = d; }{ int[] b = new int[65537]; for ( int i = 0;(i < f.length);i++) b[(1 + (f[i] >>> 16))]++; for ( int i = 1;(i <= 65536);i++) b[i] += b[(i - 1)]; for ( int i = 0;(i < f.length);i++) to[b[(f[i] >>> 16)]++] = f[i]; int[] d = f; f = to; to = d; }return f;} void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new A().run(); } private byte[] inbuf = new byte[1024]; private int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
0	public class A125D2{ public static void main( String[] args)throws Exception { InputReader in = new InputReader(System.in); System.out.println(((((0 + " ") + 0) + " ") + in.nextInt())); } static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
5	public class A implements Runnable{ public static void main( String[] args)throws IOException { new Thread(null,new A(),"",(1 << 20)).start(); } String file = "input"; BufferedReader input ; PrintWriter out ; int N ,T ; void solve()throws IOException { StringTokenizer st = tokens(); N = nextInt(st); T = nextInt(st); T *= 2; ArrayList<Pair> list = new ArrayList<Pair>(); for ( int i = 0;(i < N);i++) {st = tokens(); int c = nextInt(st),L = nextInt(st); c *= 2; L *= 2; list.add(new Pair((c - (L / 2)),(c + (L / 2)))); }Collections.sort(list); HashSet<Integer> set = new HashSet<Integer>(); for ( int i = 0;(i < list.size());i++) {if ( ((i == 0) || ((list.get(i).x - list.get((i - 1)).y) >= T))) {set.add((list.get(i).x - (T / 2))); } if ( ((i == (list.size() - 1)) || ((list.get((i + 1)).x - list.get(i).y) >= T))) {set.add((list.get(i).y + (T / 2))); } }System.out.println(set.size()); } class Pair implements Comparable<Pair>{ int x ,y ; public Pair( int x, int y){ this.x = x; this.y = y; } } StringTokenizer tokens()throws IOException { return new StringTokenizer(input.readLine());} int nextInt()throws IOException { return Integer.parseInt(input.readLine());} int nextInt( StringTokenizer st){ return Integer.parseInt(st.nextToken());} }
6	public class Main{ static final long MOD = 998244353; static boolean[] visited ; public static void main( String[] args)throws IOException { FastScanner sc = new FastScanner();  int Q = sc.nextInt(); for ( int q = 0;(q < Q);q++) { int N = sc.nextInt();  int M = sc.nextInt();  int[][] grid = new int[N][M];  int[][] maxes = new int[M][2]; for ( int i = 0;(i < M);i++) maxes[i][1] = i; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {grid[i][j] = sc.nextInt(); maxes[j][0] = Math.max(maxes[j][0],grid[i][j]); }}maxes = sort(maxes); int[] keyCols = new int[Math.min(M,N)]; for ( int i = 0;(i < keyCols.length);i++) keyCols[i] = maxes[i][1]; int ans = 0; for ( int x = 0;(x < (int)Math.pow(N,N));x++) { int[] base = baseN(keyCols.length,x);  int ansx = 0; for ( int i = 0;(i < N);i++) { int r = 0; for ( int j = 0;(j < keyCols.length);j++) {r = Math.max(r,grid[((i + base[j]) % N)][keyCols[j]]); }ansx += r; }ans = Math.max(ans,ansx); }System.out.println(ans); }} public static int[] baseN( int N, int num){ int[] ans = new int[N]; for ( int i = (N - 1);(i >= 0);i--) { int pow = (int)Math.pow(N,i); ans[i] = (num / pow); num -= (ans[i] * pow); }return ans;} public static int[][] sort( int[][] array){ Random rgen = new Random(); for ( int i = 0;(i < array.length);i++) { int randomPosition = rgen.nextInt(array.length);  int[] temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; }Arrays.sort(array,new Comparator<int[]>(){}); return array;} static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
0	public class HexadecimalsTheorem{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int num = in.nextInt();  LinkedList<Integer> result = new LinkedList<Integer>();  int temp0 = 1;  int temp1 = 1;  int temp2 = 0; result.add(0); result.add(0); result.add(0); result.add(temp0); result.add(temp1); if ( (num == 2)) {System.out.println(((((0 + " ") + 1) + " ") + 1)); } else if ( (num == 0)) {System.out.println(((((0 + " ") + 0) + " ") + 0)); } else {while((temp2 < num)){temp2 = (temp1 + temp0); result.add(temp2); temp0 = temp1; temp1 = temp2; } int length = result.size(); System.out.println(((((result.get((length - 5)) + " ") + result.get((length - 4))) + " ") + result.get((length - 2)))); }} }
2	public class A{ private static final int mod = ((int)1e9 + 9); final IOFast io = new IOFast(); long k ; public void run()throws IOException { long n = io.nextLong();  long m = io.nextLong(); k = io.nextLong(); long low = -1,high = ((m / k) + 1); while(((high - low) > 1)){ long mid = ((low + high) / 2);  long u = (mid * k); if ( (m < u)) {high = mid; continue;} long val = u; val += (((m - u) / (k - 1)) * k); if ( (((m - u) % (k - 1)) == 0)) val -= 1; else val += ((m - u) % (k - 1)); if ( (val > n)) {low = mid; } else {high = mid; }} long pow = powmod(2,high,mod);  long score = (m - (high * k)); score = ((score + (((pow - 1) * 2) * k)) % mod); io.out.println(score); } static long powmod( long n, long r, int m){ long res = 1; for ( ;(r != 0);r >>>= 1,n = ((n * n) % m)) {if ( ((r & 1) == 1)) {res = (res * n); if ( (res >= m)) {res %= m; } } }return res;} void main()throws IOException { try{run(); }catch (EndOfFileRuntimeException e){ } io.out.flush(); } public static void main( String[] args)throws IOException { new A().main(); } static class EndOfFileRuntimeException extends RuntimeException{ private static final long serialVersionUID = -8565341110209207657L; } public static class IOFast{ private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); private static int pos ,readLen ; private static final char[] buffer = new char[(1024 * 8)]; private static final char[] str = new char[((500000 * 8) * 2)]; private static boolean[] isDigit = new boolean[256]; private static boolean[] isSpace = new boolean[256]; private static boolean[] isLineSep = new boolean[256]; {for ( int i = 0;(i < 10);i++) {isDigit[('0' + i)] = true; }isDigit['-'] = true; isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true; isLineSep['\r'] = isLineSep['\n'] = true; }public int read()throws IOException { if ( (pos >= readLen)) {pos = 0; readLen = in.read(buffer); if ( (readLen <= 0)) {throw (new EndOfFileRuntimeException());} } return buffer[pos++];} public long nextLong()throws IOException { return Long.parseLong(nextString());} public char nextChar()throws IOException { while(true){final int c = read(); if ( !isSpace[c]) {return (char)c;} }} int reads( char[] cs, int len, boolean[] accept)throws IOException { try{while(true){final int c = read(); if ( accept[c]) {break;} str[len++] = (char)c; } }catch (EndOfFileRuntimeException e){ ;} return len;} public String nextString()throws IOException { return new String(next());} public char[] next()throws IOException { int len = 0; str[len++] = nextChar(); len = reads(str,len,isSpace); return Arrays.copyOf(str,len);} } }
5	public final class Main implements Runnable{ private static String[] args ; public static void main( String[] args){ Main.args = args; new Thread(null,new Main(),"MyRunThread",(1 << 27)).start(); } } final class Solver{ InputReader in ; OutputWriter out ; DebugWriter dout ; public void solve(){ int n = in.readInt();  int k = in.readInt();  TreeSet<Integer> q = new TreeSet<Integer>();  int[] mas = new int[n]; for ( int i = 0;(i < n);++i) {mas[i] = in.readInt(); if ( ((mas[i] % k) != 0)) q.add(mas[i]); }Arrays.sort(mas); for ( int i = 0;(i < n);++i) if ( (((mas[i] % k) == 0) && !q.contains((mas[i] / k)))) q.add(mas[i]); out.printLine(q.size()); } } final class InputReader{ private boolean finished = false; private InputStream stream ; private byte[] buf = new byte[(1 << 10)]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int peek(){ if ( (numChars == -1)) return -1; if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ return -1;} if ( (numChars <= 0)) return -1; } return buf[curChar];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private String readLine0(){ StringBuilder buf = new StringBuilder();  int c = read(); while(((c != '\n') && (c != -1))){if ( (c != '\r')) buf.appendCodePoint(c); c = read(); }return buf.toString();} public String readLine(){ String s = readLine0(); while((s.trim().length() == 0))s = readLine0(); return s;} public String readLine( boolean ignoreEmptyLines){ if ( ignoreEmptyLines) return readLine(); else return readLine0();} } final class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream),(1 << 10))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void printFormat( String format, Object... objects){ writer.printf(format,objects); } public void print( char[] objects){ writer.print(objects); } public void printLine( char[] objects){ writer.println(objects); } public void printLine( char[][] objects){ for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); } public void print( int[] objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( int[] objects){ print(objects); writer.println(); } public void printLine( int[][] objects){ for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); } public void print( short[] objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( short[] objects){ print(objects); writer.println(); } public void printLine( short[][] objects){ for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); } public void print( long[] objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( long[] objects){ print(objects); writer.println(); } public void printLine( long[][] objects){ for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); } public void print( double[] objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( double[] objects){ print(objects); writer.println(); } public void printLine( double[][] objects){ for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); } public void print( byte[] objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( byte[] objects){ print(objects); writer.println(); } public void printLine( byte[][] objects){ for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); } public void print( boolean[] objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( boolean[] objects){ print(objects); writer.println(); } public void printLine( boolean[][] objects){ for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); } public void close(){ writer.close(); } public void flush(){ writer.flush(); } } final class DebugWriter{ private final OutputWriter writer ; public DebugWriter( OutputWriter writer){ this.writer = writer; } private void printDebugMessage(){ writer.print("DEBUG:\t"); } public void printLine( Object... objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printFormat( String format, Object... objects){ flush(); printDebugMessage(); writer.printFormat(format,objects); flush(); } public void printLine( char[] objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printLine( char[][] objects){ flush(); for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); flush(); } public void printLine( double[] objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printLine( double[][] objects){ flush(); for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); flush(); } public void printLine( int[] objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printLine( int[][] objects){ flush(); for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); flush(); } public void printLine( short[] objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printLine( short[][] objects){ flush(); for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); flush(); } public void printLine( long[] objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printLine( long[][] objects){ flush(); for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); flush(); } public void printLine( byte[] objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printLine( byte[][] objects){ flush(); for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); flush(); } public void printLine( boolean[] objects){ flush(); printDebugMessage(); writer.printLine(objects); flush(); } public void printLine( boolean[][] objects){ flush(); for ( int i = 0;(i < objects.length);++i) printLine(objects[i]); flush(); } public void flush(){ writer.flush(); } } interface Graph{ ; ; ; ; ; public int getFirstEdge( int source); public boolean hasNextEdge( int id); public int getNextEdge( int id); public int getVertexCount(); ; ; public int getSource( int id); public int getDestination( int id); public int getColor( int id); ; ; ; public String edgeToString( int id); ; ; ; ; ; ; }
5	public class c{ public static void main( String[] args)throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in),1);  String s = r.readLine();  int n = Integer.parseInt(s);  String s2 = r.readLine();  StringTokenizer st = new StringTokenizer(s2," ");  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(st.nextToken()); Arrays.sort(a); if ( (a[(n - 1)] == 1)) a[(n - 1)] = 2; else {a[(n - 1)] = 1; Arrays.sort(a); }for ( int i = 0;(i < n);i++) System.out.println(a[i]); } }
2	public class B{ public static void main( String[] args)throws IOException { MyScanner sc = new MyScanner();  PrintWriter out = new PrintWriter(System.out);  int N = sc.nextInt(); if ( (((N / 2) % 2) == 1)) {output(-1,out); } else { int half = (N / 2);  int l = 1,r = half;  int first = query(half,out,sc);  int next = query((2 * half),out,sc); if ( (first == next)) {output(half,out); return ;} boolean less = (first < next); while(((l + 1) < r)){ int med = ((l + r) / 2); first = query(med,out,sc); next = query((med + half),out,sc); if ( (first == next)) {output(med,out); return ;} else if ( ((first < next) == less)) {r = med; } else {l = (med + 1); }}output(l,out); }} static int query( int pos, PrintWriter out, MyScanner sc){ out.println(("? " + pos)); out.flush(); return sc.nextInt();} static void output( int pos, PrintWriter out){ out.println(("! " + pos)); out.flush(); } static class MyScanner{ private BufferedReader br ; private StringTokenizer tokenizer ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
6	public class B{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; int[] level ; int[] loyal ; double ans ; int n ,k ,plLev ,needVotes ; double check(){ double res = 0; for ( int mask = 0;(mask < (1 << n));mask++) { double prob = 1;  int vote = 0;  int kill = 0; for ( int i = 0;(i < n);i++) if ( (((mask >> i) & 1) == 1)) {prob *= (loyal[i] / 100.0); vote++; } else {prob *= (1 - (loyal[i] / 100.0)); kill += level[i]; }if ( (vote >= needVotes)) res += prob; else res += ((prob * plLev) / (kill + plLev)); }return res;} void go( int ind, int candy){ if ( (ind == n)) {ans = Math.max(ans,check()); return ;} for ( int i = 0;(i <= candy);i++) {loyal[ind] += (10 * i); if ( (loyal[ind] > 100)) {loyal[ind] -= (10 * i); break;} go((ind + 1),(candy - i)); loyal[ind] -= (10 * i); }} void solve()throws IOException { n = nextInt(); k = nextInt(); plLev = nextInt(); needVotes = ((n / 2) + 1); ans = 0; level = new int[n]; loyal = new int[n]; for ( int i = 0;(i < n);i++) {level[i] = nextInt(); loyal[i] = nextInt(); }go(0,k); out.printf("%.12f",ans); } void inp()throws IOException { Locale.setDefault(Locale.US); br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } public static void main( String[] args)throws IOException { new B().inp(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return "0";} }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
6	public class ProblemE_16{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws FileNotFoundException { if ( ONLINE_JUDGE) {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); }} String readString()throws IOException { while(!tok.hasMoreTokens()){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} double readDouble()throws IOException { return Double.parseDouble(readString());} public static void main( String[] args){ new ProblemE_16().run(); } public void run(){ try{ long t1 = System.currentTimeMillis(); init(); solve(); out.close(); long t2 = System.currentTimeMillis(); System.err.println(("Time = " + (t2 - t1))); }catch (Exception e){ e.printStackTrace(System.err); System.exit(-1); } } void solve()throws IOException { int n = readInt();  double[][] a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {a[i][j] = readDouble(); }} double[] d = new double[(1 << n)]; d[((1 << n) - 1)] = 1; for ( int i = ((1 << n) - 1);(i > 0);i--) { ArrayList<Integer> list = new ArrayList<Integer>(); for ( int j = 0;(j < n);j++) {if ( ((i & (1 << j)) != 0)) list.add(j); } double s = 0; for ( int j = 0;(j < list.size());j++) {s = 0; for ( int k = 0;(k < list.size());k++) {s += a[list.get(k)][list.get(j)]; }d[(i ^ (1 << list.get(j)))] += ((((s * d[i]) * 2) / list.size()) / (list.size() - 1)); }}for ( int i = 0;(i < n);i++) {out.printf(Locale.US,"%.9f",d[(1 << i)]); out.print(" "); }} static int[][] step8 = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,-1},{-1,1},{1,1}}; static int[][] stepKnight = {{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}}; static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} static long lcm( long a, long b){ return ((a / gcd(a,b)) * b);} static long[] gcdPlus( long a, long b){ long[] d = new long[3]; if ( (a == 0)) {d[0] = b; d[1] = 0; d[2] = 1; } else {d = gcdPlus((b % a),a); long r = d[1]; d[1] = (d[2] - ((b / a) * d[1])); d[2] = r; }return d;} static long binpow( long a, int n){ if ( (n == 0)) return 1; if ( ((n & 1) == 0)) { long b = binpow(a,(n / 2)); return (b * b);} else return (binpow(a,(n - 1)) * a);} static long binpowmod( long a, int n, long m){ if ( (m == 1)) return 0; if ( (n == 0)) return 1; if ( ((n & 1) == 0)) { long b = binpowmod(a,(n / 2),m); return ((b * b) % m);} else return ((binpowmod(a,(n - 1),m) * a) % m);} static long f( long n, int x, int k){ if ( (n == 0)) return 1; long b = binpow(10,(x - 1));  long c = (n / b); return ((((c < k)?c:k) * binpow(k,(x - 1))) + (((c < k)?1:0) * f((n % b),(x - 1),k)));} static long fib( int n){ if ( (n == 0)) return 0; if ( ((n & 1) == 0)) { long f1 = fib(((n / 2) - 1));  long f2 = fib(((n / 2) + 1)); return ((f2 * f2) - (f1 * f1));} else { long f1 = fib((n / 2));  long f2 = fib(((n / 2) + 1)); return ((f1 * f1) + (f2 * f2));}} static BigInteger BigFib( int n){ if ( (n == 0)) return BigInteger.ZERO; if ( ((n & 1) == 0)) { BigInteger f1 = BigFib(((n / 2) - 1)); f1 = f1.multiply(f1); BigInteger f2 = BigFib(((n / 2) + 1)); f2 = f2.multiply(f2); return f2.subtract(f1);} else { BigInteger f1 = BigFib((n / 2)); f1 = f1.multiply(f1); BigInteger f2 = BigFib(((n / 2) + 1)); f2 = f2.multiply(f2); return f2.add(f1);}} static double d2( Point p1, Point p2){ return (((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)));} public static double d2( PointD p1, PointD p2){ return (((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)));} static int[] Sieve( int n){ boolean[] b = new boolean[(n + 1)]; Arrays.fill(b,true); b[0] = false; b[1] = false; long nLong = n;  int j = 0; for ( int i = 1;(i <= n);i++) {if ( b[i]) {j++; if ( (((long)i * i) <= nLong)) {for ( int k = (i * i);(k <= n);k += i) {b[k] = false; }} } } int[] p = new int[j]; Arrays.fill(p,0); j = 0; for ( int i = 2;(i <= n);i++) {if ( b[i]) {p[j] = i; j++; } }return p;} public static class Fraction implements Comparable<Fraction>,Cloneable{ public final Fraction FRACTION_ZERO = new Fraction(); public final Fraction FRACTION_ONE = new Fraction(1); public long numerator = 0; public long denominator = 1; public Fraction(){ numerator = 0; denominator = 1; } public Fraction( long numerator){ this.numerator = numerator; denominator = 1; } public Fraction( long numerator, long denominator){ this.numerator = numerator; this.denominator = denominator; Cancellation(); } public Fraction( double numerator, double denominator, int accuracy){ this.numerator = (long)(numerator * pow(10,accuracy)); this.denominator = (long)(denominator * pow(10,accuracy)); Cancellation(); } public Fraction( String s){ if ( (s.charAt(0) == '-')) {denominator = -1; s = s.substring(1); } if ( (s.indexOf("/") != -1)) {denominator *= Integer.parseInt(s.substring((s.indexOf("/") + 1))); } if ( (s.indexOf(" ") != -1)) {numerator = ((Integer.parseInt(s.substring(0,s.indexOf(" "))) * abs(denominator)) + Integer.parseInt(s.substring((s.indexOf(" ") + 1),s.indexOf("/")))); } else {if ( (s.indexOf("/") != -1)) {numerator = Integer.parseInt(s.substring(0,s.indexOf("/"))); } else {numerator = (Integer.parseInt(s) * abs(denominator)); }}this.Cancellation(); } void Cancellation(){ long g = gcd(abs(numerator),abs(denominator)); numerator /= g; denominator /= g; if ( (denominator < 0)) {numerator *= -1; denominator *= -1; } } public String toString(){ String s = ""; if ( (numerator == 0)) {return "0";} if ( (numerator < 0)) {s += "-"; } if ( (abs(numerator) >= denominator)) {s += (Long.toString((abs(numerator) / denominator)) + " "); } if ( ((abs(numerator) % denominator) != 0)) {s += Long.toString((abs(numerator) % denominator)); } else {s = s.substring(0,(s.length() - 1)); }if ( (denominator != 1)) {s += ("/" + Long.toString(denominator)); } return s;} public Fraction add( Fraction f){ Fraction fResult = new Fraction(); fResult.denominator = lcm(denominator,f.denominator); fResult.numerator = (((numerator * fResult.denominator) / denominator) + ((f.numerator * fResult.denominator) / f.denominator)); fResult.Cancellation(); return fResult;} public Fraction subtract( Fraction f){ Fraction fResult = new Fraction(); fResult.denominator = lcm(denominator,f.denominator); fResult.numerator = (((numerator * fResult.denominator) / denominator) - ((f.numerator * fResult.denominator) / f.denominator)); fResult.Cancellation(); return fResult;} public Fraction multiply( Fraction f){ Fraction fResult = new Fraction(); fResult.numerator = (numerator * f.numerator); fResult.denominator = (denominator * f.denominator); fResult.Cancellation(); return fResult;} public Fraction clone(){ Fraction fResult = new Fraction(numerator,denominator); return fResult;} public Fraction ceil(){ Fraction fResult = this.clone(); fResult.numerator = (((fResult.numerator / fResult.denominator) + 1) * fResult.denominator); return fResult;} public Fraction binpow( int n){ if ( (n == 0)) return FRACTION_ONE; if ( ((n & 1) == 0)) { Fraction f = this.binpow((n / 2)); return f.multiply(f);} else return binpow((n - 1)).multiply(this);} } }
5	public class Main implements Runnable{ class House implements Comparable<House>{ int x ; int a ; public House( int x, int a){ this.x = x; this.a = a; } } private void solution()throws IOException { int n = in.nextInt();  int t = in.nextInt();  House[] h = new House[n]; for ( int i = 0;(i < h.length);++i) {h[i] = new House(in.nextInt(),in.nextInt()); }Arrays.sort(h); int res = 2; for ( int i = 0;(i < (h.length - 1));++i) { double dist = ((h[(i + 1)].x - (h[(i + 1)].a / 2.0)) - (h[i].x + (h[i].a / 2.0))); if ( (dist >= t)) {if ( (dist == t)) {++res; } else {res += 2; }} }out.println(res); } private class Scanner{ private BufferedReader reader ; private StringTokenizer tokenizer ; public Scanner( Reader reader){ this.reader = new BufferedReader(reader); this.tokenizer = new StringTokenizer(""); } public boolean hasNext()throws IOException { while(!tokenizer.hasMoreTokens()){ String next = reader.readLine(); if ( (next == null)) {return false;} tokenizer = new StringTokenizer(next); }return true;} public String next()throws IOException { hasNext(); return tokenizer.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } public static void main( String[] args)throws IOException { new Thread(null,new Main(),"",(1 << 28)).start(); } PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); Scanner in = new Scanner(new InputStreamReader(System.in)); }
5	public class CFA{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; private static long MOD = (((1000L * 1000L) * 1000L) + 7); private static final int[] dx = {0,-1,0,1}; private static final int[] dy = {1,0,-1,0}; private static final String yes = "Yes"; private static final String no = "No"; int n ; int m ; char[][] mat ; long base = 397; void solve()throws IOException { n = nextInt(); m = nextInt(); mat = new char[n][m]; for ( int i = 0;(i < n);i++) {mat[i] = nextString().toCharArray(); } int alpha = 26;  long[] pow = new long[alpha]; pow[0] = 1; for ( int i = 1;(i < alpha);i++) {pow[i] = ((pow[(i - 1)] * base) % MOD); } long res = 0; for ( int l = 0;(l < m);l++) { long[] hash = new long[n];  long[] mask = new long[n]; for ( int r = l;(r < m);r++) {for ( int i = 0;(i < n);i++) {hash[i] += pow[(mat[i][r] - 'a')]; hash[i] %= MOD; mask[i] = (mask[i] ^ (1L << (mat[i][r] - 'a'))); } int start = 0; while((start < n)){if ( ((mask[start] & (mask[start] - 1)) != 0)) {start++; continue;} int end = start;  List<Long> l1 = new ArrayList<>(); while(((end < n) && ((mask[end] & (mask[end] - 1)) == 0))){l1.add(hash[end]); end++; }start = end; res += manacher(l1); }}}outln(res); } long manacher( List<Long> arr){ int len = arr.size();  long[] t = new long[((len * 2) + 3)]; t[0] = -1; t[((len * 2) + 2)] = -2; for ( int i = 0;(i < len);i++) {t[((2 * i) + 1)] = -3; t[((2 * i) + 2)] = arr.get(i); }t[((len * 2) + 1)] = -3; int[] p = new int[t.length];  int center = 0,right = 0; for ( int i = 1;(i < (t.length - 1));i++) { int mirror = ((2 * center) - i); if ( (right > i)) {p[i] = Math.min((right - i),p[mirror]); } while((t[(i + (1 + p[i]))] == t[(i - (1 + p[i]))])){p[i]++; }if ( ((i + p[i]) > right)) {center = i; right = (i + p[i]); } } long res = 0; for ( int i = 0;(i < (2 * len));i++) { int parLength = p[(i + 2)]; if ( ((i % 2) == 0)) {res += ((parLength + 1) / 2); } else {res += (parLength / 2); }}return res;} private void outln( Object o){ out.println(o); } public CFA()throws IOException{ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } public static void main( String[] args)throws IOException { new CFA(); } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} public String nextString(){ try{return br.readLine(); }catch (IOException e){ eof = true; return null;} } public int nextInt()throws IOException { return Integer.parseInt(nextToken());} public long nextLong()throws IOException { return Long.parseLong(nextToken());} }
4	public class CF1187G extends PrintWriter{ CF1187G(){ super(System.out); } static class Scanner{ Scanner( InputStream in){ this.in = in; } InputStream in ; int k ,l ; byte[] bb = new byte[(1 << 15)]; byte getc(){ if ( (k >= l)) {k = 0; try{l = in.read(bb); }catch (IOException e){ l = 0; } if ( (l <= 0)) return -1; } return bb[k++];} int nextInt(){ byte c = 0; while((c <= 32))c = getc(); int a = 0; while((c > 32)){a = (((a * 10) + c) - '0'); c = getc(); }return a;} } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF1187G o = new CF1187G(); o.main(); o.flush(); } static final int INF = 0x3f3f3f3f; ArrayList[] aa_ ; int n_ ,m_ ; int[] pi ,dd ,bb ; int[] uu ,vv ,uv ,cost ; int[] cc ; void init(){ aa_ = new ArrayList[n_]; for ( int u = 0;(u < n_);u++) aa_[u] = new ArrayList<Integer>(); pi = new int[n_]; dd = new int[n_]; bb = new int[n_]; qq = new int[nq]; iq = new boolean[n_]; uu = new int[m_]; vv = new int[m_]; uv = new int[m_]; cost = new int[m_]; cc = new int[(m_ * 2)]; m_ = 0; } void link( int u, int v, int cap, int cos){ int h = m_++; uu[h] = u; vv[h] = v; uv[h] = (u ^ v); cost[h] = cos; cc[((h << 1) ^ 0)] = cap; aa_[u].add(((h << 1) ^ 0)); aa_[v].add(((h << 1) ^ 1)); } int[] qq ; int nq = (1 << 20),head ,cnt ; boolean[] iq ; void enqueue( int v){ if ( iq[v]) return ; if ( ((head + cnt) == nq)) {if ( ((cnt * 4) <= nq)) System.arraycopy(qq,head,qq,0,cnt); else { int[] qq_ = new int[nq *= 2]; System.arraycopy(qq,head,qq_,0,cnt); qq = qq_; }head = 0; } qq[(head + cnt++)] = v; iq[v] = true; } int dequeue(){ int u = qq[head++]; cnt--; iq[u] = false; return u;} boolean spfa( int s, int t){ Arrays.fill(pi,INF); pi[s] = 0; head = cnt = 0; enqueue(s); while((cnt > 0)){ int u = dequeue();  int d = (dd[u] + 1);  ArrayList<Integer> adj = aa_[u]; for ( int h_ :adj) if ( (cc[h_] > 0)) { int h = (h_ >> 1);  int p = (pi[u] + (((h_ & 1) == 0)?cost[h]:-cost[h]));  int v = (u ^ uv[h]); if ( ((pi[v] > p) || ((pi[v] == p) && (dd[v] > d)))) {pi[v] = p; dd[v] = d; bb[v] = h_; enqueue(v); } } }return (pi[t] != INF);} void push1( int s, int t){ for ( int u = t,h_ ,h ;(u != s);u ^= uv[h]) {h = ((h_ = bb[u]) >> 1); cc[h_]--; cc[(h_ ^ 1)]++; }} int edmonds_karp( int s, int t){ while(spfa(s,t))push1(s,t); int c = 0; for ( int h = 0;(h < m_);h++) c += (cost[h] * cc[((h << 1) ^ 1)]); return c;} void main(){ int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int c = sc.nextInt();  int d = sc.nextInt();  int[] ii = new int[k]; for ( int h = 0;(h < k);h++) ii[h] = (sc.nextInt() - 1); ArrayList[] aa = new ArrayList[n]; for ( int i = 0;(i < n);i++) aa[i] = new ArrayList<Integer>(); for ( int h = 0;(h < m);h++) { int i = (sc.nextInt() - 1);  int j = (sc.nextInt() - 1); aa[i].add(j); aa[j].add(i); } int t = ((n + k) + 1); n_ = ((n * t) + 1); m_ = (k + ((((m * 2) * k) + n) * (t - 1))); init(); for ( int i = 0;(i < n);i++) { ArrayList<Integer> adj = aa[i]; for ( int s = 0;(s < (t - 1));s++) { int u = ((i * t) + s); for ( int j :adj) { int v = (((j * t) + s) + 1); for ( int x = 1;(x <= k);x++) link(u,v,1,(c + (((x * 2) - 1) * d))); }}}for ( int i = 0;(i < n);i++) for ( int s = 0;(s < (t - 1));s++) { int u = ((i * t) + s),v = (u + 1); link(u,v,k,((i == 0)?0:c)); }for ( int h = 0;(h < k);h++) link((n_ - 1),((ii[h] * t) + 0),1,0); println(edmonds_karp((n_ - 1),(((0 * t) + t) - 1))); } }
4	public class R227_2_D{ static ArrayList<Integer>[] graph ; static int[] right ,left ; static boolean vis[] ; public static boolean dfs( int node){ if ( vis[node]) return false; vis[node] = true; for ( int i = 0;(i < graph[node].size());i++) { int tmp = graph[node].get(i); if ( (right[tmp] == -1)) {left[node] = tmp; right[tmp] = node; return true;} }for ( int i = 0;(i < graph[node].size());i++) { int tmp = graph[node].get(i); if ( dfs(right[tmp])) {left[node] = tmp; right[tmp] = node; return true;} }return false;} public static int getMaxMatch(){ Arrays.fill(left,-1); Arrays.fill(right,-1); boolean done = false; while(!done){done = true; Arrays.fill(vis,false); for ( int i = 0;(i < graph.length);i++) {if ( ((left[i] == -1) && dfs(i))) {done = false; } }} int res = 0; for ( int i = 0;(i < left.length);i++) {res += ((left[i] != -1)?1:0); }return res;} public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int V = in.readInt();  int E = in.readInt();  Point[] edges = new Point[E]; for ( int i = 0;(i < edges.length);i++) {edges[i] = new Point((in.readInt() - 1),(in.readInt() - 1)); } int best = Integer.MAX_VALUE; for ( int k = 0;(k < V);k++) { int n = (V - 1); graph = new ArrayList[n]; left = new int[n]; vis = new boolean[n]; right = new int[n]; for ( int i = 0;(i < graph.length);i++) {graph[i] = new ArrayList<Integer>(); } int center = 0; for ( int i = 0;(i < E);i++) {if ( ((edges[i].x == k) || (edges[i].y == k))) {center++; continue;} int src = ((edges[i].x > k)?(edges[i].x - 1):edges[i].x);  int dst = ((edges[i].y > k)?(edges[i].y - 1):edges[i].y); graph[src].add(dst); } int matching = getMaxMatch();  int addToCenterEdges = (((2 * V) - 1) - center);  int removed = ((E - center) - matching);  int added = (n - matching); best = Math.min(best,((added + removed) + addToCenterEdges)); }System.out.println(best); } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1000]; private int curChar ,numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private String readLine0(){ StringBuffer buf = new StringBuffer();  int c = read(); while(((c != '\n') && (c != -1))){buf.appendCodePoint(c); c = read(); }return buf.toString();} public String readLine(){ String s = readLine0(); while((s.trim().length() == 0))s = readLine0(); return s;} public String readLine( boolean ignoreEmptyLines){ if ( ignoreEmptyLines) return readLine(); else return readLine0();} } }
5	public class Sockets{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(),m = in.nextInt(),socket = in.nextInt();  int[] filters = new int[n]; for ( int i = 0;(i < n);i++) {filters[i] = in.nextInt(); }Arrays.sort(filters); int result = 0,index = (n - 1); while(((m > socket) && (index >= 0))){socket += (filters[index] - 1); result += 1; index -= 1; }out.println(((m > socket)?-1:result)); out.close(); } }
6	public class C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int n ,m ; void run(){ n = sc.nextInt(); m = sc.nextInt(); solve(); } void solve(){ if ( (n < m)) { int t = n; n = m; m = t; } int full = ((1 << m) - 1);  int[][] dp = new int[(1 << m)][(1 << m)];  int[][] tmp = new int[(1 << m)][(1 << m)]; for ( int i = 0;(i < (1 << m));i++) {fill(dp[i],INF); }for ( int i = 0;(i < (1 << m));i++) { int b1 = (((i | (i >> 1)) | (i << 1)) & full);  int b2 = i; dp[b1][b2] = Integer.bitCount(i); debug(Integer.toBinaryString(b1),dp[b1]); }debug(); for ( int j = 0;(j < (n - 1));j++) {for ( int i = 0;(i < (1 << m));i++) {System.arraycopy(dp[i],0,tmp[i],0,(1 << m)); fill(dp[i],INF); }for ( int b1 = 0;(b1 < (1 << m));b1++) {for ( int b2 = 0;(b2 < (1 << m));b2++) {for ( int i = 0;(i < (1 << m));i++) {if ( ((b1 | i) != full)) {continue;} if ( false) debug(Integer.toBinaryString(b1),Integer.toBinaryString(b2),Integer.toBinaryString(i));  int b = (((i | (i >> 1)) | (i << 1)) & full); dp[(b2 | b)][i] = min(dp[(b2 | b)][i],(tmp[b1][b2] + Integer.bitCount(i))); }}}debug(j); for ( int i = 0;(i < (1 << m));i++) {debug(Integer.toBinaryString(i),dp[i]); }} int min = INF; for ( int i = 0;(i < (1 << m));i++) {min = min(min,dp[full][i]); }debug(min); int ans = ((m * n) - min); debug("ans",ans); println((ans + "")); } void println( String s){ System.out.println(s); } void print( String s){ System.out.print(s); } void debug( Object... os){ } public static void main( String[] args){ new C().run(); } }
3	public class TaskD{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); } int m = s.nextInt();  int inv = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) {inv++; } }} boolean odd = ((inv % 2) == 1); for ( int i = 0;(i < m);i++) { int l = s.nextInt();  int r = (s.nextInt() + 1);  int num = (((r - l) * ((r - l) - 1)) / 2); if ( ((num % 2) == 1)) {odd = !odd; } System.out.println((odd?"odd":"even")); }} }
4	public class Main{ public static void main( String[] args){ FastReader input = new FastReader();  PrintWriter out = new PrintWriter(System.out);  int T = 1; while((T-- > 0)){ int n = input.nextInt();  int m = input.nextInt();  int k = input.nextInt();  int arr1[][] = new int[(n + 1)][m]; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j < m);j++) {arr1[i][j] = input.nextInt(); }} int arr2[][] = new int[n][(m + 1)]; for ( int i = 1;(i < n);i++) {for ( int j = 1;(j <= m);j++) {arr2[i][j] = input.nextInt(); }}if ( ((k % 2) == 0)) { int dp[][][] = new int[(n + 1)][(m + 1)][(k + 1)]; for ( int l = 2;(l <= k);l += 2) {for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) { int min = Integer.MAX_VALUE; if ( ((j + 1) <= m)) {min = Math.min(min,(dp[i][(j + 1)][(l - 2)] + (2 * arr1[i][j]))); } if ( ((i + 1) <= n)) {min = Math.min(min,(dp[(i + 1)][j][(l - 2)] + (2 * arr2[i][j]))); } if ( ((j - 1) >= 1)) {min = Math.min(min,(dp[i][(j - 1)][(l - 2)] + (2 * arr1[i][(j - 1)]))); } if ( ((i - 1) >= 1)) {min = Math.min(min,(dp[(i - 1)][j][(l - 2)] + (2 * arr2[(i - 1)][j]))); } dp[i][j][l] = min; }}}for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) {out.print((dp[i][j][k] + " ")); }out.println(); }} else {for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) {out.print((-1 + " ")); }out.println(); }}}out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskF2 solver = new TaskF2(); solver.solve(1,in,out); out.close(); } static class TaskF2{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); } HashMap<Integer,ArrayList<Interval>> map = new HashMap<>(); for ( int i = 0;(i < n);i++) { int sum = 0; for ( int j = i;(j < n);j++) {sum += a[j]; if ( (map.containsKey(sum) == false)) {map.put(sum,new ArrayList<>()); } ArrayList<Interval> arr = map.get(sum); if ( (arr.isEmpty() || (arr.get((arr.size() - 1)).r < i))) {arr.add(new Interval(i,j)); } else if ( (arr.get((arr.size() - 1)).r >= j)) {arr.set((arr.size() - 1),new Interval(i,j)); } }} ArrayList<Interval> best = new ArrayList<>(); for ( ArrayList<Interval> arr :map.values()) {if ( (best.size() < arr.size())) {best = arr; } }out.println(best.size()); for ( Interval i :best) {out.println((((i.l + 1) + " ") + (i.r + 1))); }} class Interval{ int l ; int r ; Interval( int l, int r){ this.l = l; this.r = r; } } } static class InputReader{ private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputStream stream ; public InputReader( InputStream stream){ this.stream = stream; } private boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isWhitespace(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isWhitespace(c));return (res * sgn);} } }
2	public class DigitSeq{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} long nextLong(){ return Long.parseLong(next());} } public static void main( String[] args){ FastReader sc = new FastReader();  OutputStream outputstream = System.out;  PrintWriter out = new PrintWriter(outputstream);  long n = sc.nextLong();  long[] arr = new long[14]; for ( int i = 1;(i <= 13);i++) {arr[i] = ((long)Math.pow(10,i) - (long)Math.pow(10,(i - 1))); } long total = 0; for ( int i = 1;(i <= 13);i++) {if ( ((total + ((long)i * arr[i])) >= n)) { long ans = (n - total);  long rest = ans; if ( ((ans % i) != 0)) {ans /= i; ans++; } else {ans /= i; }ans += ((long)Math.pow(10,(i - 1)) - 1); String str = Long.toString(ans);  int ind = (((rest % i) == 0)?(i - 1):((int)(rest % i) - 1)); out.println(str.charAt(ind)); break;} total = (total + ((long)i * arr[i])); }out.close(); } }
1	public class IQ{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = scan.nextInt(); for ( int i = 0;(i < n);i++) { boolean x = ((a[i] % 2) == 0);  int c = 0; for ( int j = 0;(j < n);j++) {if ( (x != ((a[j] % 2) == 0))) c++; }if ( (c == (n - 1))) {System.out.println((i + 1)); break;} }} }
5	public class C{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),key = in.nextInt(),ans = 0;  int[] a = new int[101],b = new int[101]; for ( int i = 1;(i <= n);i++) {a[i] = in.nextInt(); b[i] = in.nextInt(); }for ( int i = 1;(i < n);i++) for ( int j = (i + 1);(j <= n);j++) if ( ((a[i] < a[j]) || ((a[i] == a[j]) && (b[i] > b[j])))) { int yed = a[i]; a[i] = a[j]; a[j] = yed; yed = b[i]; b[i] = b[j]; b[j] = yed; } int k = 0; for ( int i = 1;(i <= n);i++) {if ( ((a[i] == a[(i - 1)]) && (b[i] == b[(i - 1)]))) k++; else {if ( ((i > key) && (ans == 0))) ans = k; k = 1; }}if ( (ans == 0)) ans = k; System.out.println(ans); } }
0	public class Counterexample{ public static void main( String[] args){ System.out.println(new Counterexample().solve()); } String solve(){ Scanner sc = new Scanner(System.in); final long l = sc.nextLong(); final long r = sc.nextLong(); if ( ((r - l) > 1)) { long a = l;  long b = (l + 1);  long c = (l + 2); while((a < (r - 1))){while((b < r)){while((c <= r)){if ( (((gcd(a,b) == 1) && (gcd(b,c) == 1)) && (gcd(a,c) > 1))) {return ((((Long.toString(a) + " ") + Long.toString(b)) + " ") + Long.toString(c));} c += 1; }c = (b + 1); b += 1; }b = (a + 1); a += 1; }} return "-1";} long gcd( long a, long b){ while((b != 0)){ long t = b; b = (a % b); a = t; }return a;} }
0	public class TA{ public void solve( long n){ long a = 0,b = 0; if ( ((n % 2) == 0)) {if ( ((n % 4) == 0)) {a = (n / 2); b = (n / 2); } else {a = ((n / 2) - 1); b = ((n / 2) + 1); }} else {a = 4; b = (n - a); while(((b > 0) && ((b % 3) != 0))){a += 2; b = (n - a); }}System.out.println(((a + " ") + b)); } public static void main( String[] args){ FastScanner in = new FastScanner(); new TA().solve(in.nextLong()); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( String s){ try{br = new BufferedReader(new FileReader(s)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String nextToken(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} long nextLong(){ return Long.parseLong(nextToken());} } }
6	public class Main{ static final long MOD = 1_000_000_007,INF = 1_000_000_000_000_000_000L; static final int INf = 1_000_000_000; static FastReader reader ; static PrintWriter writer ; public static void main( String[] args){ Thread t = new Thread(null,new O(),"Integer.MAX_VALUE",100000000); t.start(); } static class O implements Runnable{ } static class FastReader{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public FastReader(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public FastReader( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws IOException { int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {ret = (((ret * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } static int n ,m ,pre[][] ,pre_stop_and_start[][] ,mat[][] ,dp[][][] ; static void magic()throws IOException { reader = new FastReader(); writer = new PrintWriter(System.out,true); n = reader.nextInt(); m = reader.nextInt(); mat = new int[n][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {mat[i][j] = reader.nextInt(); }}if ( (n == 1)) { int ans = Integer.MAX_VALUE; for ( int i = 0;((i + 1) < m);++i) {ans = min(ans,abs((mat[0][i] - mat[0][(i + 1)]))); }writer.println(ans); System.exit(0); } pre = new int[n][n]; pre_stop_and_start = new int[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = (i + 1);(j < n);++j) { int min = Integer.MAX_VALUE; for ( int k = 0;(k < m);++k) {min = min(min,abs((mat[i][k] - mat[j][k]))); }pre[i][j] = pre[j][i] = min; }}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {if ( (j == i)) {continue;} int min = Integer.MAX_VALUE; for ( int k = 0;((k + 1) < m);++k) {min = min(min,abs((mat[j][(k + 1)] - mat[i][k]))); }pre_stop_and_start[i][j] = min; }}dp = new int[(1 << n)][n][n]; for ( int i = 0;(i < (1 << n));++i) {for ( int j = 0;(j < n);++j) {for ( int k = 0;(k < n);++k) {dp[i][j][k] = -1; }}} int ans = 0; for ( int i = 0;(i < n);++i) {ans = max(ans,f((1 << i),i,i)); }writer.println(ans); } static int f( int mask_already, int prev, int first){ if ( (mask_already == ((1 << n) - 1))) {return pre_stop_and_start[prev][first];} if ( (dp[mask_already][prev][first] != -1)) {return dp[mask_already][prev][first];} int max = 0; for ( int i = 0;(i < n);++i) {if ( ((mask_already & (1 << i)) == 0)) {max = max(max,min(pre[prev][i],f((mask_already | (1 << i)),i,first))); } }return dp[mask_already][prev][first] = max;} }
2	public class TaskB{ void run(){ FastReader in = new FastReader(System.in);  PrintWriter out = new PrintWriter(System.out);  long n = in.nextLong();  long k = in.nextLong();  long a = 1;  long b = ((2 * n) + 3);  long c = (((n * n) + n) - (2 * k));  long d = ((b * b) - ((4 * a) * c));  long ans1 = ((-b + (long)Math.sqrt(d)) / 2);  long ans2 = ((-b - (long)Math.sqrt(d)) / 2); if ( ((ans1 >= 0) && (ans1 <= n))) {out.println(ans1); } else {out.println(ans2); }out.close(); } class FastReader{ BufferedReader br ; StringTokenizer st ; FastReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } Long nextLong(){ return Long.parseLong(next());} String next(){ while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(nextLine()); return st.nextToken();} String nextLine(){ String s = ""; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return s;} } public static void main( String[] args){ new TaskB().run(); } }
0	public class C344C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a = sc.nextLong();  long b = sc.nextLong();  long count = (a / b),c ; a = (a % b); while(true){if ( ((a <= 1) || (b <= 1))) break; c = (b - a); b = a; a = c; count++; if ( (a > b)) count += (a / b); a = (a % b); }if ( (b > 1)) count += b; System.out.println(count); sc.close(); } }
6	public class task{ public static void main( String[] args){ Scanner a = new Scanner(System.in); while(a.hasNext()){ int n = a.nextInt();  int m = a.nextInt(); if ( ((n == 0) && (m == 0))) break; boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = a.nextInt();  int y = a.nextInt(); adj[(x - 1)][(y - 1)] = true; adj[(y - 1)][(x - 1)] = true; }for ( int i = 0;(i < n);++i) for ( int j = (i + 1);(j < n);++j) if ( adj[i][j]) --res; for ( int i = 0;(i < n);++i) { long[][] dp = new long[(n - i)][(1 << (n - i))]; dp[0][0] = 1; for ( int mask = 0;(mask < (1 << (n - i)));++mask) {for ( int j = 0;(j < (n - i));++j) {if ( (dp[j][mask] != 0)) {for ( int k = 0;(k < (n - i));++k) {if ( ((((mask >> k) & 1) == 0) && adj[(j + i)][(k + i)])) dp[k][(mask | (1 << k))] += dp[j][mask]; }} }if ( (((mask >> 0) & 1) != 0)) {res += dp[0][mask]; } }}System.out.println((res / 2)); }} }
0	public class A483{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  BigInteger l = sc.nextBigInteger();  BigInteger r = sc.nextBigInteger(); if ( (r.subtract(l).compareTo(new BigInteger("2")) == -1)) {System.out.println("-1"); } else if ( ((r.subtract(l).compareTo(new BigInteger("2")) == 0) && (l.mod(new BigInteger("2")) != BigInteger.ZERO))) {System.out.println("-1"); } else if ( (l.mod(new BigInteger("2")) != BigInteger.ZERO)) {System.out.println(((((l.add(BigInteger.ONE) + " ") + l.add(BigInteger.ONE).add(BigInteger.ONE)) + " ") + l.add(BigInteger.ONE).add(BigInteger.ONE).add(BigInteger.ONE))); } else {System.out.println(((((l + " ") + l.add(BigInteger.ONE)) + " ") + l.add(BigInteger.ONE).add(BigInteger.ONE))); }} }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  int[] nums = new int[n]; args = br.readLine().split(" "); for ( int i = 0;(i < n);i++) {nums[i] = Integer.parseInt(args[i]); }Arrays.sort(nums); int min = nums[0]; for ( int i = 1;(i < n);i++) {if ( (nums[i] > min)) {System.out.println(nums[i]); return ;} }System.out.println("NO"); } }
1	public class A{ public static void main( String[] args)throws Throwable { MyScanner sc = new MyScanner();  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  String[] s = {"M","L","S","XL","XS","XXL","XXS","XXXL","XXXS"};  int[] cnt = new int[9]; for ( int i = 0;(i < n);i++) { String t = sc.next(); for ( int j = 0;(j < 9);j++) if ( t.equals(s[j])) cnt[j]++; }for ( int i = 0;(i < n);i++) { String t = sc.next(); for ( int j = 0;(j < 9);j++) if ( t.equals(s[j])) cnt[j]--; }for ( int i = 0;(i < 9);i++) cnt[i] = Math.abs(cnt[i]); int ans = 0; for ( int i = 0;(i < 9);i++) ans += cnt[i]; pw.println((ans / 2)); pw.flush(); pw.close(); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
3	public class c{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int numbOfStatements = in.nextInt();  long[] dp = new long[numbOfStatements]; dp[0] = 1L; boolean priorFor = in.next().equals("f"); for ( int i = 0;(i < (numbOfStatements - 1));i++) { String type = in.next(); if ( priorFor) {for ( int j = (numbOfStatements - 1);(j > 0);j--) {dp[j] = dp[(j - 1)]; }dp[0] = 0L; } else { long sum = 0; for ( int j = (numbOfStatements - 1);(j >= 0);--j) {sum = ((sum + dp[j]) % 1000000007); dp[j] = sum; }}priorFor = type.equals("f"); } long ans = 0; for ( int j = 0;(j < numbOfStatements);j++) {ans = ((ans + dp[j]) % 1000000007); }System.out.println(ans); } }
3	public class algo_2701{ public static void main( String[] args){ Scanner ex = new Scanner(System.in);  int n = ex.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = ex.nextInt(); Arrays.sort(arr); int ans = 0;  int check[] = new int[n]; for ( int i = 0;(i < n);i++) {if ( (check[i] == 0)) {ans++; for ( int j = i;(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) check[j] = 1; }} }System.out.println(ans); } }
6	public class A{ public static int n ; public static double[] masks ; public static double[][] matrix ; public static void main( String[] args){ Scanner scan = new Scanner(System.in); n = scan.nextInt(); matrix = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) matrix[i][j] = scan.nextDouble(); masks = new double[(1 << n)]; masks[((1 << n) - 1)] = 1; for ( int i = 0;((1 << i) < (1 << n));i++) fillDP((1 << i)); for ( int i = 0;((1 << i) < (1 << n));i++) System.out.printf("%.6f ",masks[(1 << i)]); } public static double fillDP( int mask){ int bitCount = Integer.bitCount(mask); if ( (masks[mask] != 0)) return masks[mask]; double matchProba = (2.0 / ((double)bitCount * (double)(bitCount + 1)));  double totalProba = 0; for ( int i = 0;(i < n);i++) { int iPower = (1 << i); if ( ((mask & iPower) != iPower)) continue; for ( int j = 0;(j < n);j++) { int jPower = (1 << j); if ( (((mask & jPower) == jPower) || (i == j))) continue; totalProba += ((matchProba * matrix[i][j]) * fillDP((mask | jPower))); }}return masks[mask] = totalProba;} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ int N = in.nextInt();  Integer a[] = in.nextIntArray(N); Arrays.sort(a); int colors = 0; for ( int i = 0;(i < N);i++) {if ( (a[i] == -1)) continue; colors++; for ( int j = (i + 1);(j < N);j++) {if ( ((a[j] % a[i]) == 0)) {a[j] = -1; } }}out.printLine(colors); } } static class InputReader{ BufferedReader in ; StringTokenizer tokenizer = null; public InputReader( InputStream inputStream){ in = new BufferedReader(new InputStreamReader(inputStream)); } public String next(){ try{while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(in.readLine()); }return tokenizer.nextToken(); }catch (IOException e){ return null;} } public int nextInt(){ return Integer.parseInt(next());} public Integer[] nextIntArray( int size){ Integer array[] = new Integer[size]; for ( int i = 0;(i < size);i++) {array[i] = nextInt(); }return array;} } static class OutputWriter{ PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } } }
4	public class CF1517D extends PrintWriter{ CF1517D(){ super(System.out); } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF1517D o = new CF1517D(); o.main(); o.flush(); } static final int INF = 0x3f3f3f3f; void main(){ int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt(); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) print("-1 "); println(); }return ;} k /= 2; int[][] hh = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < (m - 1));j++) hh[i][j] = sc.nextInt(); int[][] vv = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) for ( int j = 0;(j < m);j++) vv[i][j] = sc.nextInt(); int[][] dp = new int[n][m];  int[][] dq = new int[n][m]; while((k-- > 0)){for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) { int x = INF; if ( (i > 0)) x = Math.min(x,(dp[(i - 1)][j] + vv[(i - 1)][j])); if ( (j > 0)) x = Math.min(x,(dp[i][(j - 1)] + hh[i][(j - 1)])); if ( ((i + 1) < n)) x = Math.min(x,(dp[(i + 1)][j] + vv[i][j])); if ( ((j + 1) < m)) x = Math.min(x,(dp[i][(j + 1)] + hh[i][j])); dq[i][j] = x; } int[][] tmp = dp; dp = dq; dq = tmp; }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) print(((dp[i][j] * 2) + " ")); println(); }} }
5	public class Round113_A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = (in.nextInt() - 1);  Obe[] a = new Obe[n]; for ( int i = 0;(i < n);i++) a[i] = new Obe(in.nextInt(),in.nextInt()); Arrays.sort(a); int c = 0;  int p = 0,d = 0; if ( ((k > -1) && (k < n))) {c = 1; p = a[k].p; d = a[k].d; } else {System.out.println(c); return ;}for ( int i = (k + 1);(i < n);i++) {if ( ((a[i].p == p) && (a[i].d == d))) c++; }for ( int i = (k - 1);(i > -1);i--) {if ( ((a[i].p == p) && (a[i].d == d))) c++; }System.out.println(c); } } class Obe implements Comparable<Obe>{ int p ,d ; public Obe( int pe, int de){ p = pe; d = de; } @Override public int compareTo( Obe o){ int x = new Integer(o.p).compareTo(this.p); if ( (x != 0)) return x; return new Integer(this.d).compareTo(o.d);} }
3	public class Main{ static HashMap<Integer,ArrayList<seg>> ma ; static class seg{ seg( int a, int b){ l = a; r = b; } int l ,r ; } static int n ,sum ,dex ; static int arr[] = new int[1600]; public static void main( String[] argas){ Scanner cin = new Scanner(System.in); ma = new HashMap(); n = cin.nextInt(); for ( int i = 1;(i <= n);i++) {arr[i] = cin.nextInt(); sum = 0; for ( int j = i;(j > 0);j--) {sum += arr[j]; if ( ma.containsKey(sum)) ma.get(sum).add(new seg(j,i)); else {ma.put(sum,new ArrayList<seg>()); ma.get(sum).add(new seg(j,i)); }}} int ans = 0,te ;  ArrayList<seg> best = new ArrayList(),now ,temp ;  Iterator it = ma.entrySet().iterator(); while(it.hasNext()){now = new ArrayList(); te = 0; Map.Entry entry = (Map.Entry)it.next(); temp = (ArrayList<seg>)entry.getValue(); dex = 0; for ( int i = 0;(i < temp.size());i++) {if ( (temp.get(i).l > dex)) {dex = temp.get(i).r; te++; now.add(new seg(temp.get(i).l,temp.get(i).r)); } }if ( (te > ans)) {ans = te; best = now; } }System.out.println(ans); for ( int i = 0;(i < best.size());i++) {System.out.println(((best.get(i).l + " ") + best.get(i).r)); }} }
4	public class Main{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  ArrayList<Integer> al[] = new ArrayList[(n + 1)]; for ( int i = 0;(i <= n);i++) al[i] = new ArrayList<>(); al[0].add(1); int y ; y = sc.nextInt(); boolean flag = true; for ( int i = 1;(i <= (n - 1));i++) { int x = sc.nextInt();  int idx = (al[(i - 1)].size() - 1); if ( (x != 1)) {while(flag){ int ans = (x - 1); if ( (al[(i - 1)].get(idx) == ans)) {idx--; break;} idx--; }} for ( int j = 0;(j <= idx);j++) {al[i].add(al[(i - 1)].get(j)); }al[i].add(x); }for ( int i = 0;(i <= (n - 1));i++) {out.print(al[i].get(0)); for ( int j = 1;(j <= (al[i].size() - 1));j++) {out.print(("." + al[i].get(j))); }out.println(); }}out.flush(); out.close(); } }
5	public class Solution{ public static void main( String[] args)throws IOException { new Solution().run(); } StreamTokenizer in ; Scanner ins ; PrintWriter out ; int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} void run()throws IOException { if ( (System.getProperty("ONLINE_JUDGE") != null)) {in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); ins = new Scanner(System.in); out = new PrintWriter(System.out); } else {in = new StreamTokenizer(new BufferedReader(new FileReader("input.txt"))); ins = new Scanner(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); } int n = nextInt(),a = nextInt(),b = nextInt(); b--; int[] A = new int[n]; for ( int i = 0;(i < n);i++) {A[i] = nextInt(); }Arrays.sort(A); if ( (A[b] == A[(b + 1)])) out.print(0); else out.print((A[(b + 1)] - A[b])); out.close(); } }
3	public class Main{ public static void main( String[] args)throws Exception { MScanner sc = new MScanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  HashSet<Integer> nums = new HashSet<Integer>();  int[] in = new int[n]; for ( int i = 0;(i < n);i++) in[i] = sc.nextInt(); Arrays.sort(in); int ans = 0;  boolean vis[] = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( vis[i]) continue; for ( int j = (i + 1);(j < n);j++) {if ( ((in[j] % in[i]) == 0)) {vis[j] = true; } }ans++; }pw.println(ans); pw.flush(); } static class MScanner{ StringTokenizer st ; BufferedReader br ; public MScanner( InputStream system){ br = new BufferedReader(new InputStreamReader(system)); } public MScanner( String file)throws Exception{ br = new BufferedReader(new FileReader(file)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
5	public class ProblemA{ InputReader in ; PrintWriter out ; void solve(){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); Arrays.sort(a); int d = k;  int cur = (n - 1);  int ans = 0; while(((d < m) && (cur >= 0))){d += (a[cur] - 1); cur--; ans++; }if ( (d >= m)) out.println(ans); else out.println("-1"); } ProblemA(){ boolean oj = (System.getProperty("ONLINE_JUDGE") != null); try{if ( oj) {in = new InputReader(System.in); out = new PrintWriter(System.out); } else { Writer w = new FileWriter("output.txt"); in = new InputReader(new FileReader("input.txt")); out = new PrintWriter(w); } }catch (Exception e){ throw (new RuntimeException(e));} solve(); out.close(); } public static void main( String[] args){ new ProblemA(); } } class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public InputReader( FileReader fr){ reader = new BufferedReader(fr); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
2	public class D{ public static void main( String[] args){ Scanner cin = new Scanner(System.in);  PrintWriter cout = new PrintWriter(System.out);  long l = cin.nextLong(),r = cin.nextLong(),k = 1; if ( (l == r)) cout.println(0); else {while((((r >> k) << k) > l))k++; k--; cout.println((((r >> k) << k) ^ (((r >> k) << k) - 1))); }cout.flush(); } }
4	@SuppressWarnings("unchecked") public class P35C{ static final int[] DX = {-1,1,0,0}; static final int[] DY = {0,0,-1,1}; public void run()throws Exception { int m = nextInt();  int n = nextInt();  boolean[][] burned = new boolean[n][m];  List<Integer> burn = new ArrayList(); for ( int k = nextInt();(k > 0);k--) { int x = (nextInt() - 1);  int y = (nextInt() - 1); burned[y][x] = true; burn.add(((x * 10000) + y)); } int lastXY = 0;  List<Integer> newBurn = null; do {lastXY = burn.get(0); newBurn = new ArrayList(); for ( int xy :burn) { int x = (xy / 10000);  int y = (xy % 10000); for ( int i = 0;(i < 4);i++) { int nx = (x + DX[i]);  int ny = (y + DY[i]); if ( (((((ny >= 0) && (ny < n)) && (nx >= 0)) && (nx < m)) && burned)) {burned[ny][nx] = true; newBurn.add(((nx * 10000) + ny)); } }}burn = newBurn; }while((newBurn.size() > 0));println(((((lastXY / 10000) + 1) + " ") + ((lastXY % 10000) + 1))); } public static void main( String... args)throws Exception { br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream("output.txt"))); new P35C().run(); br.close(); pw.close(); System.err.println((("\n[Time : " + (System.currentTimeMillis() - startTime)) + " ms]")); } static long startTime = System.currentTimeMillis(); static BufferedReader br ; static PrintWriter pw ; StringTokenizer stok ; String nextToken()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return null;} stok = new StringTokenizer(s); }return stok.nextToken();} void print( byte b){ print(("" + b)); } void print( int i){ print(("" + i)); } void print( long l){ print(("" + l)); } void print( double d){ print(("" + d)); } void print( char c){ print(("" + c)); } void print( Object o){ if ( (o instanceof int[])) {print(Arrays.toString((int[])o)); } else if ( (o instanceof long[])) {print(Arrays.toString((long[])o)); } else if ( (o instanceof char[])) {print(Arrays.toString((char[])o)); } else if ( (o instanceof byte[])) {print(Arrays.toString((byte[])o)); } else if ( (o instanceof short[])) {print(Arrays.toString((short[])o)); } else if ( (o instanceof boolean[])) {print(Arrays.toString((boolean[])o)); } else if ( (o instanceof float[])) {print(Arrays.toString((float[])o)); } else if ( (o instanceof double[])) {print(Arrays.toString((double[])o)); } else if ( (o instanceof Object[])) {print(Arrays.toString((Object[])o)); } else {print(("" + o)); }} void print( String s){ pw.print(s); } void println(){ println(""); } void println( byte b){ println(("" + b)); } void println( int i){ println(("" + i)); } void println( long l){ println(("" + l)); } void println( double d){ println(("" + d)); } void println( char c){ println(("" + c)); } void println( Object o){ print(o); println(); } void println( String s){ pw.println(s); } int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} String nextLine()throws IOException { return br.readLine();} }
5	public class A{ BufferedReader in ; StringTokenizer st ; PrintWriter out ; static class House implements Comparable<House>{ final int x ,a ; House( int x, int a){ this.x = x; this.a = a; } } void solve()throws IOException { int n = nextInt();  int t = nextInt();  House[] h = new House[n]; for ( int i = 0;(i < n);++i) {h[i] = new House((2 * nextInt()),nextInt()); }Arrays.sort(h); int ans = 2; for ( int i = 1;(i < n);++i) { House prev = h[(i - 1)];  House curr = h[i];  int diff = (((2 * t) + curr.a) + prev.a); if ( ((curr.x - prev.x) == diff)) {++ans; } else if ( ((curr.x - prev.x) > diff)) {ans += 2; } }out.println(ans); } public void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); eat(""); solve(); out.close(); in.close(); } void eat( String s){ st = new StringTokenizer(s); } String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} eat(line); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { new A().run(); } }
5	public class Beta15PA{ public static void main( String[] args){ Beta15PA temp = new Beta15PA(); temp.solve(); } public void solve(){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt(),t = scan.nextInt();  House[] houses = new House[n]; for ( int i = 0;(i < n);i++) {houses[i] = new House(scan.nextInt(),scan.nextInt()); }Arrays.sort(houses); int res = 2; for ( int i = 0;(i < (n - 1));i++) { double cnt = (houses[(i + 1)].coordinate - houses[i].coordinate); cnt -= ((1.0 * (houses[(i + 1)].side + houses[i].side)) / 2); if ( (cnt > t)) res += 2; else if ( (Math.abs((cnt - t)) < 1e-7)) res += 1; }System.out.println(res); } public class House implements Comparable<House>{ public int coordinate ,side ; public House( int coordinate, int side){ this.coordinate = coordinate; this.side = side; } } }
6	public class A{ static double[][] a ; static int N ; static double[] memo ; static double dp( int alive){ int count = Integer.bitCount(alive); if ( (count == N)) return 1; if ( (memo[alive] > -5)) return memo[alive]; double ret = 0; for ( int j = 0;(j < N);++j) if ( ((alive & (1 << j)) == 0)) ret += (die[j][(alive | (1 << j))] * dp((alive | (1 << j)))); return memo[alive] = ret;} static double[][] die ; static void f(){ die = new double[N][(1 << N)]; for ( int i = 0;(i < N);++i) for ( int j = 0;(j < (1 << N));++j) { int count = Integer.bitCount(j); if ( (count <= 1)) continue; double prop = (1.0 / ((count * (count - 1)) >> 1)); for ( int k = 0;(k < N);++k) if ( ((j & (1 << k)) != 0)) die[i][j] += (prop * a[k][i]); }} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out); N = sc.nextInt(); a = new double[N][N]; for ( int i = 0;(i < N);++i) for ( int j = 0;(j < N);++j) a[i][j] = sc.nextDouble(); memo = new double[(1 << N)]; f(); Arrays.fill(memo,-10); for ( int i = 0;(i < (N - 1));++i) out.printf("%.8f ",dp((1 << i))); out.printf("%.8f\n",dp((1 << (N - 1)))); out.flush(); out.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public double nextDouble()throws NumberFormatException,IOException { return Double.parseDouble(next());} public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
3	public class Main{ static class Node implements Comparable<Node>{ public int l ,r ; public long s ; Node( int l, int r, long s){ this.l = l; this.r = r; this.s = s; } } static long[] sum = new long[1550]; public static void main( String[] args){ TreeMap<Long,ArrayList<Node>> mp = new TreeMap<>();  Scanner cin = new Scanner(System.in);  int N = cin.nextInt(); for ( int i = 1;(i <= N);i++) { int x = cin.nextInt(); sum[i] = (sum[(i - 1)] + x); } ArrayList<Node> arr = new ArrayList<>(); for ( int l = 1;(l <= N);l++) {for ( int r = l;(r <= N);r++) {arr.add(new Node(l,r,(sum[r] - sum[(l - 1)]))); }}Collections.sort(arr); for ( int i = 0;(i < arr.size());i++) { ArrayList<Node> a = mp.get(arr.get(i).s); if ( (a == null)) {a = new ArrayList<>(); mp.put(arr.get(i).s,a); } a.add(arr.get(i)); } int mx = -1;  long mxv = -1;  Iterator<Long> it = mp.keySet().iterator(); while(it.hasNext()){ int ans = 0,t = 0;  long v = it.next();  ArrayList<Node> vec = mp.get(v); for ( int i = 0;(i < vec.size());i++) {if ( (t < vec.get(i).l)) {ans++; t = vec.get(i).r; } }if ( (ans > mx)) {mx = ans; mxv = v; } } ArrayList<Node> vec = mp.get(mxv); System.out.println(mx); int t = 0; for ( int i = 0;(i < vec.size());i++) {if ( (t < vec.get(i).l)) {System.out.println(((vec.get(i).l + " ") + vec.get(i).r)); t = vec.get(i).r; } }} }
2	public class Main{ public static void main( String[] args){ Scanner ak = new Scanner(System.in);  long n ,k ,x ; n = ak.nextLong(); k = ak.nextLong(); x = (long)((-3 + Math.sqrt((9 + (8 * (n + k))))) / 2); System.out.println((n - x)); } }
6	public class ASimpleTask{ static long memo[][] ; static int graph[] ; static long hamiltonianPath( int mask, int u){ if ( (memo[mask][u] != -1)) return memo[mask][u]; else if ( (u == Integer.numberOfTrailingZeros(mask))) return 0; else { long sum = 0; for ( int fromSet = (mask ^ (1 << u));(fromSet > 0);fromSet ^= Integer.lowestOneBit(fromSet)) { int v = Integer.numberOfTrailingZeros(fromSet); if ( ((graph[u] & (1 << v)) != 0)) sum += hamiltonianPath((mask ^ (1 << u)),v); }return sum;}} private static void solveBottomUp( FastScanner s1, PrintWriter out){ int V = s1.nextInt();  int E = s1.nextInt(); graph = new int[V]; long DP[][] = new long[(1 << V)][V]; while((E-- > 0)){ int u = (s1.nextInt() - 1);  int v = (s1.nextInt() - 1); graph[u] |= (1 << v); graph[v] |= (1 << u); }for ( int i = 0;(i < V);i++) DP[(1 << i)][i] = 1; for ( int mask = 1,end = (1 << V);(mask < end);mask++) {for ( int set = mask;(Integer.bitCount(set) > 1);set ^= Integer.highestOneBit(set)) { int u = Integer.numberOfTrailingZeros(Integer.highestOneBit(set)); for ( int fromSet = (mask ^ (1 << u));(fromSet > 0);fromSet ^= Integer.lowestOneBit(fromSet)) { int v = Integer.numberOfTrailingZeros(fromSet); if ( ((graph[u] & (1 << v)) != 0)) DP[mask][u] += DP[(mask ^ (1 << u))][v]; }}} long totalCycles = 0; for ( int mask = 1,end = (1 << V);(mask < end);mask++) {if ( (Integer.bitCount(mask) >= 3)) { int start = Integer.numberOfTrailingZeros(mask); for ( int set = mask;(Integer.bitCount(set) > 1);set ^= Integer.highestOneBit(set)) { int u = Integer.numberOfTrailingZeros(Integer.highestOneBit(set)); if ( ((graph[u] & (1 << start)) != 0)) totalCycles += DP[mask][u]; }} }totalCycles /= 2; out.println(totalCycles); } public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)),false); solveBottomUp(in,out); in.close(); out.close(); } static class FastScanner{ BufferedReader reader ; StringTokenizer st ; FastScanner( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); st = null; } String next(){ while(((st == null) || !st.hasMoreTokens())){try{ String line = reader.readLine(); if ( (line == null)) {return null;} st = new StringTokenizer(line); }catch (Exception e){ throw (new RuntimeException());} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} void close(){ try{reader.close(); }catch (IOException e){ e.printStackTrace(); } } } }
0	public class A{ private static Scanner in ; public void run(){ long a = in.nextLong();  long b = in.nextLong();  long ans = 0; while(((a > 0) && (b > 0))){if ( (a >= b)) {ans += (a / b); a %= b; continue;} ans += (b / a); b %= a; }System.out.println(ans); } public static void main( String[] args){ Locale.setDefault(Locale.US); in = new Scanner(System.in); new A().run(); in.close(); } }
4	public class Main{ static InputReader sc ; static PrintWriter pw ; public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out; sc = new InputReader(inputStream); pw = new PrintWriter(outputStream); solve(); pw.close(); } static int time ; public static void solve(){ int t = 1; t = s(0); u:while((t-- > 0)){ int n = s(0);  int[] arr = new int[n]; feedArr(arr); Stack<Pair> stk = new Stack<>(); stk.push(new Pair("",1)); pln(1); Pair pr ; for ( int i = 1;(i < n);i++) {if ( (arr[i] == 1)) {pr = stk.peek(); stk.push(new Pair(((pr.s + ((pr.s.length() == 0)?"":".")) + pr.i),1)); pln(((stk.peek().s + ".") + stk.peek().i)); } else if ( (stk.peek().i == (arr[i] - 1))) {pr = stk.pop(); pln(((pr.s + ((pr.s.length() == 0)?"":".")) + arr[i])); pr.i++; stk.push(pr); } else {stk.pop(); i--; }}}} static void update_DAG( int cur, int val, int[] graph, int n){ if ( (val > maxx[cur])) { int x = graph[cur]; if ( (x != -1)) update_DAG(x,(val + 1),graph,n); maxx[cur] = val; update(cur,val,n); } } static int[] bit ,maxx ; static void update( int i, int val, int n){ while((i <= n)){bit[i] = Math.max(bit[i],val); i = (i + (i & i)); }} public static int[][] dir = new int[][]{{1,0},{0,1},{-1,0},{0,-1}}; public static int[] findFarthest( int u, List<List<Integer>> list){ int n = list.size();  boolean[] vis = new boolean[(n + 1)];  Queue<Integer> q = new LinkedList<>(); q.offer(u); vis[u] = true; int s ,pr ,cnt = 0;  int[] ar = new int[]{u,0}; while((q.size() > 0)){s = q.size(); while((s-- > 0)){pr = q.poll(); if ( (ar[1] < cnt)) {ar[1] = cnt; ar[0] = pr; } for ( int i :list.get(pr)) {if ( !vis[i]) {vis[i] = true; q.offer(i); } }}cnt++; }return ar;} public static void sort( int[] arr){ ArrayList<Integer> list = new ArrayList<>(); for ( int i = 0;(i < arr.length);i++) list.add(arr[i]); Collections.sort(list); for ( int i = 0;(i < arr.length);i++) arr[i] = list.get(i); } public static void sort( long[] arr){ ArrayList<Long> list = new ArrayList<>(); for ( int i = 0;(i < arr.length);i++) list.add(arr[i]); Collections.sort(list); for ( int i = 0;(i < arr.length);i++) arr[i] = list.get(i); } static class Pair{ String s ; int i ; Pair( String S, int I){ s = S; i = I; } } static long gcd( long a, long b){ if ( (b == 0)) return a; return ((a > b)?gcd(b,(a % b)):gcd(a,(b % a)));} static long fast_pow( long base, long n, long M){ if ( (n == 0)) return 1; if ( (n == 1)) return base; long halfn = fast_pow(base,(n / 2),M); if ( ((n % 2) == 0)) return ((halfn * halfn) % M); else return ((((halfn * halfn) % M) * base) % M);} public static int s( int n){ return sc.nextInt();} public static long s( long n){ return sc.nextLong();} public static String s( String n){ return sc.next();} public static double s( double n){ return sc.nextDouble();} public static void pln( int n){ pw.println(n); } public static void pln( long n){ pw.println(n); } public static void pln( String n){ pw.println(n); } public static void pln( double n){ pw.println(n); } public static void feedArr( long[] arr){ for ( int i = 0;(i < arr.length);i++) arr[i] = sc.nextLong(); } public static void feedArr( double[] arr){ for ( int i = 0;(i < arr.length);i++) arr[i] = sc.nextDouble(); } public static void feedArr( int[] arr){ for ( int i = 0;(i < arr.length);i++) arr[i] = sc.nextInt(); } public static void feedArr( String[] arr){ for ( int i = 0;(i < arr.length);i++) arr[i] = sc.next(); } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public double nextDouble(){ return Double.parseDouble(next());} } }
4	public class CompressionAndExpansion{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int T = in.nextInt(); for ( int t = 0;(t < T);t++) { int N = in.nextInt();  List<Integer> list = new ArrayList<>(); for ( int i = 0;(i < N);i++) { int n = in.nextInt(); if ( (n == 1)) {list.add(n); } else {for ( int j = (list.size() - 1);(j >= 0);j--) {if ( (list.get(j) == (n - 1))) {list.set(j,n); break;} list.remove(j); }}for ( int j = 0;(j < list.size());j++) {System.out.print((list.get(j) + ((j == (list.size() - 1))?"\n":"."))); }}}} }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  TaskC.pair[] songs = new TaskC.pair[n];  long sum = 0; for ( int i = 0;(i < n);i++) {songs[i] = new TaskC.pair(in.nextInt(),in.nextInt()); sum += songs[i].a; }Arrays.sort(songs); int res = 0;  int idx = (n - 1); while((sum > m)){if ( (idx < 0)) {break;} sum -= (songs[idx].a - songs[idx].b); res++; idx--; }if ( (sum > m)) {out.println(-1); } else {out.println(res); }} } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String s){ try{br = new BufferedReader(new FileReader(s)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
6	public class SimpleTask{ public static void main( String[] args)throws Exception { InputReader in = new InputReader(System.in);  int n = in.nextInt();  int m = in.nextInt();  int[] g = new int[n];  long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < m);i++) { int a = (in.nextInt() - 1),b = (in.nextInt() - 1); g[a] |= (1 << b); g[b] |= (1 << a); } int all = ((1 << n) - 1); for ( int i = 0;(i < n);i++) { int l = (1 << i);  int left = ((all ^ (l - 1)) ^ l); for ( int j = left;(j > 0);j = ((j - 1) & left)) if ( ((j & (j - 1)) != 0)) {dp[(j | l)][i] = 1; } }for ( int i = ((1 << n) - 1);(i > 0);i--) { int last = (i & -i); for ( int j = 0;(j < n);j++) {if ( ((((1 << j) == last) && ((i & (i - 1)) != 0)) || (((1 << j) & i) == 0))) continue; for ( int k = 0;(k < n);k++) {if ( ((((1 << k) >= last) && (((1 << k) & g[j]) != 0)) && (((1 << k) == last) || (((1 << k) & i) == 0)))) {dp[i][j] += dp[(i | (1 << k))][k]; } }}} long res = 0; for ( int i = 0;(i < n);i++) res += dp[(1 << i)][i]; System.out.println((res / 2)); } static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class CodeF{ static class Scanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String nextLine(){ try{return br.readLine(); }catch (Exception e){ throw (new RuntimeException());} } public String next(){ while(!st.hasMoreTokens()){ String l = nextLine(); if ( (l == null)) return null; st = new StringTokenizer(l); }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public double nextDouble(){ return Double.parseDouble(next());} public int[] nextIntArray( int n){ int[] res = new int[n]; for ( int i = 0;(i < res.length);i++) res[i] = nextInt(); return res;} } static int[] compute_prefix_function( char[] p){ int[] pi = new int[p.length]; pi[0] = -1; int k = -1; for ( int i = 1;(i < p.length);i++) {while(((k >= 0) && (p[(k + 1)] != p[i])))k = pi[k]; if ( (p[(k + 1)] == p[i])) k++; pi[i] = k; }return pi;} static boolean KMP_Matcher( String pattern, String text){ char[] p = pattern.toCharArray();  char[] t = text.toCharArray();  int[] pi = compute_prefix_function(p);  int q = -1;  int cuenta = 0; for ( int i = 0;(i < text.length());i++) {while(((q >= 0) && (p[(q + 1)] != t[i])))q = pi[q]; if ( (p[(q + 1)] == t[i])) q++; if ( (q == (p.length - 1))) {cuenta++; q = pi[q]; } }return (cuenta >= 2);} public static void main( String[] args){ Scanner sc = new Scanner();  String entrada = sc.next();  int mejor = 0; for ( int i = 0;(i < entrada.length());i++) {for ( int j = (i + 1);(j <= entrada.length());j++) { String sub = entrada.substring(i,j); if ( KMP_Matcher(sub,entrada)) mejor = Math.max((j - i),mejor); }}System.out.println(mejor); } }
6	public class main{ static int max = (5000 + 1); static FastReader in = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static int N = 18; static int[][] mn1 = new int[N][N]; static int[][] mn2 = new int[N][N]; static int[][] dp = new int[(1 << N)][N]; static int n ,m ; static void solve(){ n = in.nextInt(); m = in.nextInt(); int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) a[i][j] = in.nextInt(); for ( int i = 0;(i < n);i++) {Arrays.fill(mn1[i],Integer.MAX_VALUE); Arrays.fill(mn2[i],Integer.MAX_VALUE); }for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) for ( int k = 0;(k < m);k++) {mn1[i][j] = Math.min(mn1[i][j],Math.abs((a[i][k] - a[j][k]))); if ( (k <= (m - 2))) mn2[i][j] = Math.min(mn2[i][j],Math.abs((a[i][k] - a[j][(k + 1)]))); } int ans = 0; for ( int i = 0;(i < n);i++) {for ( int x = 0;(x < (1 << n));x++) Arrays.fill(dp[x],-1); for ( int j = 0;(j < n);j++) dp[(1 << j)][j] = 0; dp[(1 << i)][i] = Integer.MAX_VALUE; for ( int j = 0;(j < n);j++) ans = Math.max(ans,Math.min(mn2[j][i],calc(((1 << n) - 1),j))); }out.println(ans); } static int calc( int mask, int v){ if ( (dp[mask][v] != -1)) return dp[mask][v]; dp[mask][v] = 0; for ( int u = 0;(u < n);u++) if ( ((v != u) && (((mask >> u) & 1) > 0))) dp[mask][v] = Math.max(dp[mask][v],Math.min(mn1[u][v],calc((mask ^ (1 << v)),u))); return dp[mask][v];} public static void main( String[] args){ solve(); out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader( String s)throws Exception{ br = new BufferedReader(new FileReader(s)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(in.next());} } }
4	public class Contest35_3{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new FileReader("input.txt"));  String[] s = in.readLine().split(" ");  int n = Integer.parseInt(s[0]);  int m = Integer.parseInt(s[1]);  int k = Integer.parseInt(in.readLine()); s = in.readLine().split(" "); Point[] inp = new Point[k];  int p = 0; for ( int i = 0;(i < k);i++) {inp[i] = new Point(Integer.parseInt(s[p++]),Integer.parseInt(s[p++])); } int max = -1;  int maxx = -1;  int maxy = -1;  int i ;  int j ,dist ; for ( i = 1;(i <= n);i++) {for ( j = 1;(j <= m);j++) {dist = 1000000; for ( int l = 0;(l < inp.length);l++) {dist = Math.min((Math.abs((inp[l].x - i)) + Math.abs((inp[l].y - j))),dist); }if ( (dist > max)) {max = dist; maxx = i; maxy = j; } }} String res = (((maxx + " ") + maxy) + "\n");  FileWriter out = new FileWriter(new File("output.txt")); out.append(res); out.flush(); out.close(); } }
2	public class cf3 implements Runnable{ static final long mod = ((long)1e9 + 7); static long modExp( long x, long pow){ x = (x % mod); long res = 1; while((pow > 0)){if ( ((pow % 2) == 1)) res = ((res * x) % mod); pow = (pow / 2); x = ((x * x) % mod); }return res;} static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new cf3(),"cf3",(1 << 26)).start(); } }
2	public class Solution{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; String nextToken()throws Exception { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(nextToken());} long fang( int s, int x, int y){ if ( (x > y)) { int t = x; x = y; y = t; } if ( ((s + 1) <= x)) {return (((long)(s + 1) * (s + 2)) / 2);} if ( ((s + 1) <= y)) {return ((((long)x * (x + 1)) / 2) + ((long)((s + 1) - x) * x));} if ( ((s + 1) >= ((x + y) - 1))) {return ((long)x * y);} long q = ((((x + y) - 1) - s) - 1); return (((long)x * y) - ((q * (q + 1)) / 2));} long f( int s, int n, int x, int y){ long ans = (((fang(s,((n - x) + 1),((n - y) + 1)) + fang(s,((n - x) + 1),y)) + fang(s,x,((n - y) + 1))) + fang(s,x,y)); ans -= (((Math.min((s + 1),((n - x) + 1)) + Math.min((s + 1),x)) + Math.min((s + 1),((n - y) + 1))) + Math.min((s + 1),y)); return (ans + 1);} void solve()throws Exception { int n = nextInt();  int x = nextInt(),y = nextInt();  long c = nextInt(); if ( (c == 1)) {out.println(0); return ;} int bg = 0,ed = (2 * n); while((ed > (bg + 1))){ int mm = ((bg + ed) / 2); if ( (f(mm,n,x,y) >= c)) ed = mm; else bg = mm; }out.println(ed); } void run(){ try{Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } finally{out.close(); }} public static void main( String[] args){ new Solution().run(); } }
0	public class LuxuriousHouses{ public static void main( String[] args)throws IOException { System.out.println(25); } }
2	public class Dummy{ private static long mod = 1000000007; public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  String[] strs = reader.readLine().split(" ");  long x = Long.parseLong(strs[0]);  long k = Long.parseLong(strs[1]);  long twoPK = modPow(2,k);  long twoPK_1 = ((twoPK * 2) % mod);  long res = (((((twoPK_1 * (x % mod)) % mod) - (twoPK - 1)) + mod) % mod); System.out.println(((x == 0)?x:res)); } private static long modPow( long base, long pow){ long res = 1; while((pow != 0)){if ( ((pow & 1) != 0)) {res = ((((res % mod) * base) % mod) % mod); } base = ((((base % mod) * base) % mod) % mod); pow >>= 1; }return res;} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.readInt();  int r = in.readInt();  int[] x = in.readIntArray(n);  double[] y = new double[n]; y[0] = r; for ( int i = 1;(i < n);i++) { double max = r; for ( int j = 0;(j < i);j++) { double pow = Math.pow((x[i] - x[j]),2); if ( (pow <= ((4 * r) * r))) { double ty = (y[j] + Math.sqrt((((4 * r) * r) - pow))); max = Math.max(max,ty); } }y[i] = max; }for ( double i :y) out.print((i + " ")); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int[] readIntArray( int size){ int[] ans = new int[size]; for ( int i = 0;(i < size);i++) ans[i] = readInt(); return ans;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, InputReader in, PrintWriter out){ long n = in.readInt(); if ( (n < 3)) {out.print(n); } else if ( ((n % 2) != 0)) {out.print(((n * (n - 1)) * (n - 2))); } else if ( ((n % 3) == 0)) {out.print((((n - 1) * (n - 2)) * (n - 3))); } else {out.print(((n * (n - 1)) * (n - 3))); }} } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } }
4	public class C{ Scanner in ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int m = ni();  int k = ni();  int[][] f = new int[k][2]; for ( int i = 0;(i < k);i++) {f[i][0] = (ni() - 1); f[i][1] = (ni() - 1); } int mx = -1;  int resx = 0;  int resy = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int min = Integer.MAX_VALUE; for ( int l = 0;(l < k);l++) {min = Math.min(min,(Math.abs((f[l][0] - i)) + Math.abs((f[l][1] - j)))); }if ( (min > mx)) {mx = min; resx = i; resy = j; } }}out.println((((resx + 1) + " ") + (resy + 1))); } void run()throws Exception { in = (INPUT.isEmpty()?new Scanner(new File("input.txt")):new Scanner(INPUT)); out = (INPUT.isEmpty()?new PrintWriter("output.txt"):new PrintWriter(System.out)); solve(); out.flush(); } public static void main( String[] args)throws Exception { new C().run(); } int ni(){ return Integer.parseInt(in.next());} }
1	public class Solution implements Runnable{ private BufferedReader br = null; private PrintWriter pw = null; private StringTokenizer stk = new StringTokenizer(""); public static void main( String[] args){ new Thread(new Solution()).run(); } public void run(){ br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new OutputStreamWriter(System.out)); solver(); pw.close(); } private void nline(){ try{if ( !stk.hasMoreTokens()) stk = new StringTokenizer(br.readLine());  }catch (IOException e){ throw (new RuntimeException("KaVaBUnGO!!!",e));} } private String nstr(){ while(!stk.hasMoreTokens())nline(); return stk.nextToken();} private int ni(){ return Integer.valueOf(nstr());} private void solver(){ int n = ni();  ArrayList<Integer> ar = new ArrayList<Integer>();  int sum = 0; for ( int i = 0;(i < n);i++) {ar.add((ni() % 2)); sum += ar.get(i); } int flag = 0; if ( (sum == 1)) flag = 1; for ( int i = 0;(i < n);i++) if ( (ar.get(i) == flag)) System.out.println((i + 1)); } void exit(){ System.exit(0); } }
3	public class Main{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  int[] arr = new int[n];  int chet = 0; for ( int i = 0;(i < n);i++) {arr[i] = scanner.nextInt(); for ( int j = 0;(j < i);j++) {if ( (arr[j] > arr[i])) chet ^= 1; }}n = scanner.nextInt(); for ( int i = 0;(i < n);i++) { int l = scanner.nextInt();  int r = scanner.nextInt(); if ( (((((r - l) + 1) / 2) & 1) != 0)) {chet ^= 1; } if ( (chet == 1)) {System.out.println("odd"); } else {System.out.println("even"); }}} }
4	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  MyScanner in = new MyScanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  EPhoenixAndComputers solver = new EPhoenixAndComputers(); solver.solve(1,in,out); out.close(); } static class EPhoenixAndComputers{ public static MyScanner sc ; public static PrintWriter out ; public void solve( int testNumber, MyScanner sc, PrintWriter out){ EPhoenixAndComputers.sc = sc; EPhoenixAndComputers.out = out; int n = sc.nextInt();  long M = sc.nextLong(); MathLib.MOD = M; long[][] comb = MathLib.getComb((n + 5));  long[] pots2 = MathLib.getPots(2,(n + 2));  long[] inv = new long[(n + 5)]; for ( int i = 1;(i < inv.length);i++) {inv[i] = MathLib.inverse(i); } long[][] ret = new long[(n + 1)][(n + 1)]; for ( int size = 0;(size <= n);size++) {if ( (size <= 1)) {ret[size][size] = 1; } else if ( (size == 2)) {ret[size][2] = 2; } else { long[] me = ret[size]; me[size] = pots2[(size - 1)]; for ( int i = 1;((i + 1) < size);i++) { int prev = i,next = ((size - i) - 1);  long tmp = pots2[(i - 1)]; for ( int c = 0;(c <= next);c++) { long tot = ((ret[next][c] * comb[c][(c + prev)]) % MathLib.MOD); tot = ((tot * tmp) % MathLib.MOD); me[(prev + c)] += tot; me[(prev + c)] %= MathLib.MOD; }}}} long ans = 0; for ( int i = 0;(i <= n);i++) {ans += ret[n][i]; }ans %= MathLib.MOD; out.println(ans); } } static class MyScanner{ private BufferedReader br ; private StringTokenizer tokenizer ; public MyScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  DOlyaAndMagicalSquare solver = new DOlyaAndMagicalSquare();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class DOlyaAndMagicalSquare{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.NextInt();  long k = in.NextLong(); if ( (k == 0)) {out.println(("YES " + n)); return ;} long operationTillNow = 0,numberOfCubeOnTheSide = 1;  ArrayList<CubeCount> cubes = new ArrayList<>(); for ( int i = (n - 1);(i >= 0);i--) {cubes.add(new CubeCount(i,((((numberOfCubeOnTheSide - 1) * 2) * 2) + 1))); operationTillNow = ((operationTillNow + (2 * numberOfCubeOnTheSide)) - 1); numberOfCubeOnTheSide *= 2; long operationLeft = (k - operationTillNow); if ( (operationLeft == 0)) {out.println(("YES " + i)); return ;} else if ( (operationLeft < 0)) {out.println("NO"); return ;} for ( CubeCount c :cubes) {if ( !c.hasLessThen(operationLeft)) {out.println(("YES " + i)); return ;} else {operationLeft = c.removeMeFrom(operationLeft); }}if ( (operationLeft <= 0)) {out.println(("YES " + i)); return ;} }out.println("NO"); return ;} class CubeCount{ int sideSizeLogScale ; long repeats ; public CubeCount( int sideSizeLogScale, long repeats){ this.repeats = repeats; this.sideSizeLogScale = sideSizeLogScale; } public boolean hasLessThen( long k){ return hasLessThen(k,sideSizeLogScale,repeats);} private boolean hasLessThen( long k, int sideLog, long repeats){ while(true){if ( (k <= 0)) return false; if ( (sideLog == 0)) return true; k -= repeats; sideLog--; repeats *= 4; }} public long removeMeFrom( long k){ return removeMeFrom(k,sideSizeLogScale,repeats);} private long removeMeFrom( long k, int sideLog, long repeats){ while(true){if ( (sideLog == 0)) return k; k -= repeats; sideLog--; repeats *= 4; }} } } static class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()," \t\n\r\f,"); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int NextInt(){ return Integer.parseInt(next());} public long NextLong(){ return Long.parseLong(next());} } }
2	public class E extends Thread{ public E( String inputFileName, String outputFileName){ try{if ( (inputFileName != null)) {this.input = new BufferedReader(new FileReader(inputFileName)); } else {this.input = new BufferedReader(new InputStreamReader(System.in)); }if ( (outputFileName != null)) {this.output = new PrintWriter(outputFileName); } else {this.output = new PrintWriter(System.out); }this.setPriority(Thread.MAX_PRIORITY); }catch (Throwable e){ System.err.println(e.getMessage()); e.printStackTrace(); System.exit(666); } } private void solve()throws Throwable { long l = nextLong(),r = nextLong();  int[] bitL = new int[63];  int[] bitR = new int[63];  int szL = doit(l,bitL);  int szR = doit(r,bitR);  int ret = szR; while(((ret >= 0) && (bitL[ret] == bitR[ret])))--ret; if ( (ret < 0)) {output.println(0); } else {output.println(((1L << (ret + 1)) - 1)); }} static final int doit( long q, int[] a){ int sz = 0; while((q != 0L)){a[sz++] = (int)(q & 1L); q >>= 1; }return sz;} public static void main( String... args){ new E(null,null).start(); } private long nextLong()throws IOException { return Long.parseLong(next());} private String next()throws IOException { while(((tokens == null) || !tokens.hasMoreTokens())){tokens = new StringTokenizer(input.readLine()); }return tokens.nextToken();} private StringTokenizer tokens ; private BufferedReader input ; private PrintWriter output ; }
3	public class C{ InputStream in ; PrintWriter out ; void solve(){ int n = ni();  long dp[] = new long[(n + 1)]; dp[0] = 1; for ( int i = 0;(i < n);) {i++; if ( (nc() == 'f')) {i++; int k = 1; while((nc() != 's')){i++; k++; }for ( int j = (n - 1);(j >= 0);j--) {dp[j] = add(dp[j],dp[(j + 1)]); }for ( int j = n;(j >= k);j--) {dp[j] = dp[(j - k)]; }for ( int j = 0;(j < k);j++) dp[j] = 0; } else {for ( int j = (n - 1);(j >= 0);j--) {dp[j] = add(dp[j],dp[(j + 1)]); }}} long sum = 0; for ( int i = 0;(i <= n);i++) sum = add(sum,dp[i]); out.println(sum); } long mod = ((long)1e9 + 7); long add( long a, long b){ long x = (a + b); while((x >= mod))x -= mod; return x;} long mul( long a, long b){ a %= mod; b %= mod; long x = (a * b); return (x % mod);} void run()throws Exception { String INPUT = "C:/Users/ayubs/Desktop/input.txt"; in = (oj?System.in:new FileInputStream(INPUT)); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new C().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = in.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean inSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && inSpaceChar(b)));return b;} private char nc(){ return (char)skip();} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!inSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !inSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
6	public class main{ static int max = (5000 + 1); static FastReader in = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static int N = 18; static int[][] mn1 = new int[N][N]; static int[][] mn2 = new int[N][N]; static int[][] dp = new int[(1 << N)][N]; static int n ,m ; static void solve(){ n = in.nextInt(); m = in.nextInt(); int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) a[i][j] = in.nextInt(); for ( int i = 0;(i < n);i++) {Arrays.fill(mn1[i],Integer.MAX_VALUE); Arrays.fill(mn2[i],Integer.MAX_VALUE); }for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) for ( int k = 0;(k < m);k++) {mn1[i][j] = Math.min(mn1[i][j],Math.abs((a[i][k] - a[j][k]))); if ( (k <= (m - 2))) mn2[i][j] = Math.min(mn2[i][j],Math.abs((a[i][k] - a[j][(k + 1)]))); } int ans = 0; for ( int i = 0;(i < n);i++) {for ( int x = 0;(x < (1 << n));x++) Arrays.fill(dp[x],-1); for ( int j = 0;(j < n);j++) dp[(1 << j)][j] = 0; dp[(1 << i)][i] = Integer.MAX_VALUE; for ( int j = 0;(j < n);j++) ans = Math.max(ans,Math.min(mn2[j][i],calc(((1 << n) - 1),j))); }out.println(ans); } static int calc( int mask, int v){ if ( (dp[mask][v] != -1)) return dp[mask][v]; dp[mask][v] = 0; for ( int u = 0;(u < n);u++) if ( ((v != u) && (((mask >> u) & 1) > 0))) dp[mask][v] = Math.max(dp[mask][v],Math.min(mn1[u][v],calc((mask ^ (1 << v)),u))); return dp[mask][v];} public static void main( String[] args){ solve(); out.flush(); out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader( String s)throws Exception{ br = new BufferedReader(new FileReader(s)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(in.next());} } }
1	public class Array{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  int last[] = new int[100001];  int distinct = 0; for ( int i = 0;(i < n);++i) { int t = in.nextInt(); if ( (last[t] == 0)) ++distinct; last[t] = (i + 1); if ( (distinct == k)) { int min = (i + 1); for ( int j = 0;(j < last.length);++j) {if ( (last[j] != 0)) min = ((min > last[j])?last[j]:min); }System.out.println(((min + " ") + (i + 1))); return ;} }System.out.println("-1 -1"); } }
1	public class Edu_46A{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int nE = Integer.parseInt(reader.readLine());  int[][] cnt = new int[][]{{0,0,0},{0,0},{0,0},{0,0}}; for ( int i = 0;(i < nE);i++) { String nxt = reader.readLine(); if ( nxt.equals("S")) {cnt[0][0]++; } if ( nxt.equals("M")) {cnt[0][1]++; } if ( nxt.equals("L")) {cnt[0][2]++; } if ( nxt.equals("XS")) {cnt[1][0]++; } if ( nxt.equals("XL")) {cnt[1][1]++; } if ( nxt.equals("XXS")) {cnt[2][0]++; } if ( nxt.equals("XXL")) {cnt[2][1]++; } if ( nxt.equals("XXXS")) {cnt[3][0]++; } if ( nxt.equals("XXXL")) {cnt[3][1]++; } }for ( int i = 0;(i < nE);i++) { String nxt = reader.readLine(); if ( nxt.equals("S")) {cnt[0][0]--; } if ( nxt.equals("M")) {cnt[0][1]--; } if ( nxt.equals("L")) {cnt[0][2]--; } if ( nxt.equals("XS")) {cnt[1][0]--; } if ( nxt.equals("XL")) {cnt[1][1]--; } if ( nxt.equals("XXS")) {cnt[2][0]--; } if ( nxt.equals("XXL")) {cnt[2][1]--; } if ( nxt.equals("XXXS")) {cnt[3][0]--; } if ( nxt.equals("XXXL")) {cnt[3][1]--; } } int ans = 0; for ( int i = 1;(i <= 3);i++) {ans += Math.abs(cnt[i][0]); } int max = 0; for ( int i = 0;(i < 3);i++) {max = Math.max(max,Math.abs(cnt[0][i])); }ans += max; printer.println(ans); printer.close(); } }
2	public class a{ static long mod = 1000000009; static ArrayList<Integer>[] g ; public static void main( String[] args)throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out);  int n = input.nextInt(),m = input.nextInt(),k = input.nextInt();  long border = (n - (n / k)); if ( (m <= border)) out.println(m); else { long count = (m - border);  long first = ((((pow(2,(count + 1)) + mod) - 2) * k) % mod); first += (m - (k * count)); out.println((first % mod)); }out.close(); } static long pow( long x, long p){ if ( (p == 0)) return 1; if ( ((p & 1) > 0)) {return ((x * pow(x,(p - 1))) % mod);} long sqrt = pow(x,(p / 2)); return ((sqrt * sqrt) % mod);} static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} }
3	public class A{ static void solve()throws Exception { int n = scanInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = scanInt(); }sort(a); int ans = 0; ans:while(true){for ( int i = 0;;i++) {if ( (i == n)) {break;} if ( (a[i] != 0)) {++ans; int t = a[i]; a[i] = 0; for ( i++;(i < n);i++) {if ( ((a[i] % t) == 0)) {a[i] = 0; } }break;} }}out.print(ans); } static int scanInt()throws IOException { return parseInt(scanString());} static String scanString()throws IOException { while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} static BufferedReader in ; static PrintWriter out ; static StringTokenizer tok ; public static void main( String[] args){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); }catch (Throwable e){ e.printStackTrace(); exit(1); } } }
5	public class A{ static int[] reverse = new int[257]; public static void main( String[] arg){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] A = new int[n]; for ( int i = 0;(i < A.length);++i) A[i] = sc.nextInt(); Arrays.sort(A); if ( (n == 1)) {System.out.println(((A[0] == 1)?"2":"1")); return ;} else if ( ((A[0] == A[(A.length - 1)]) && (A[0] == 1))) {System.out.print("1"); for ( int i = 1;(i < (n - 1));++i) System.out.print((" " + A[i])); System.out.println(" 2"); return ;} else if ( (A[0] == A[(A.length - 1)])) {System.out.print("1"); for ( int i = 1;(i < n);++i) System.out.print((" " + A[i])); System.out.println(); return ;} for ( int i = 0;(i < A.length);++i) { int prev = ((i == 0)?Integer.MAX_VALUE:A[(i - 1)]);  int next = ((i == (A.length - 1))?Integer.MAX_VALUE:A[(i + 1)]);  int ans = Math.min(prev,Math.min(next,A[i])); if ( (i == 0)) ans = 1; System.out.print(((i == 0)?("" + ans):(" " + ans))); }System.out.println(); } }
1	public class A25{ static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter out = new PrintWriter(System.out); static int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws Exception { int n = nextInt();  int[] c = new int[2];  int[] f = new int[2]; for ( int i = 0;(i < n);i++) { int x = nextInt(),p = (x % 2); if ( (c[p]++ == 0)) f[p] = (i + 1); }out.println(((c[0] == 1)?f[0]:f[1])); out.flush(); } }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); while((n-- > 0)){ long a = sc.nextLong(),b = sc.nextLong();  long ans = 0,cur = 0; while(((a > 0) && (b > 0))){if ( (b > a)) a = ((a + b) - (b = a)); cur = (a / b); ans += cur; a -= (cur * b); }System.out.println(ans); }} }
6	public class Main{ private StreamTokenizer in ; private BufferedWriter out ; public void solve()throws Exception { int n = nextInt(),m = nextInt();  int[] ss = new int[n]; for ( int i = 0;(i < m);i++) { int a = nextInt(),b = nextInt(); a--; b--; ss[a] |= (1 << b); ss[b] |= (1 << a); } long[][] res = new long[n][(1 << n)];  int[] cnt = new int[(1 << n)],first = new int[(1 << n)]; for ( int i = 0;(i < n);i++) {res[i][(1 << i)] = 1; first[(1 << i)] = i; cnt[(1 << i)] = 1; } long ans = 0; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int last = first[mask];(last < n);last++) {if ( (res[last][mask] == 0)) continue; if ( (cnt[mask] > 2)) {if ( ((ss[last] & (1 << first[mask])) != 0)) ans += res[last][mask]; } int m2 = (mask & ss[last]); for ( int next = (first[mask] + 1);(next < n);next++) {if ( ((m2 & (1 << next)) == 0)) continue; int mask2 = (mask | (1 << next)); res[next][mask2] += res[last][mask]; cnt[mask2] = (cnt[mask] + 1); first[mask2] = first[mask]; }}}ans /= 2; out.write((ans + "\n")); } public int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public void run(){ try{in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new BufferedWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } public static void main( String[] args){ new Main().run(); } }
1	public class CodeChef2{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } static long M = 1000000007l; static HashMap<Character,ArrayList<Character>> dirs ; public static void main( String[] args)throws Exception { FastReader sc = new FastReader();  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));  int t = sc.nextInt();  int po = 0; dirs = new HashMap<>(); dirs.put('U',new ArrayList<>()); dirs.get('U').addAll(Arrays.asList('U','R','D','L')); dirs.put('L',new ArrayList<>()); dirs.get('L').addAll(Arrays.asList('L','U','R','D')); dirs.put('D',new ArrayList<>()); dirs.get('D').addAll(Arrays.asList('D','L','U','R')); dirs.put('R',new ArrayList<>()); dirs.get('R').addAll(Arrays.asList('R','D','L','U')); outer:while((t-- > 0)){po++; int n = sc.nextInt();  int x = (int)Math.sqrt((n / 2));  int y = (int)Math.sqrt((n / 4)); if ( ((((x * x) * 2) == n) || (((y * y) * 4) == n))) bw.append("YES\n"); else {bw.append("NO\n"); }}bw.close(); } private static long numDigit( long ans){ long sum = 0; while((ans > 0)){sum++; ans /= 10; }return sum;} private static boolean go( int i, int j, long n, long m, Integer k, HashMap<Integer,Boolean>[][] dp){ if ( (((i == n) && (j == m)) && (k == 0))) {return true;} if ( (((((i < 1) || (j < 1)) || (i > n)) || (j > m)) || (k < 0))) {return false;} if ( dp[i][j].containsKey(k)) {return dp[i][j].get(k);} boolean down = go((i + 1),j,n,m,(k - j),dp);  boolean left = go(i,(j + 1),n,m,(k - i),dp); dp[i][j].put(k,(left || down)); return (left || down);} private static void reverse( ArrayList<Integer> arr, int l, int m){ while((l < m)){ int temp = arr.get(l); arr.set(l,arr.get(m)); arr.set(m,temp); l++; m--; }} private static boolean isSorted( long[] arr){ for ( int i = 1;(i < arr.length);i++) {if ( (arr[i] < arr[(i - 1)])) {return false;} }return true;} static long power( long a, long d, long n){ long res = 1; a = (a % n); if ( (a == 0)) return 0; while((d > 0)){if ( ((d & 1) != 0)) res = ((res * a) % n); d = (d >> 1); a = ((a * a) % n); }return res;} private static void reverse( long[] arr, int l, int m){ while((l < m)){ long temp = arr[l]; arr[l] = arr[m]; arr[m] = temp; l++; m--; }} private static int highestOneBit( long n){ long x = Long.highestOneBit(n);  int c = 0; while((x > 0)){x = (x / 2); c++; }return (c - 1);} static int par ; private static int[] getZfunc( String s){ int[] z = new int[s.length()];  int l = 0,r = 0; for ( int i = 1;(i < s.length());i++) {if ( (i <= r)) {z[i] = Math.min(z[(i - l)],((r - i) + 1)); } while((((i + z[i]) < s.length()) && (s.charAt(z[i]) == s.charAt((i + z[i]))))){z[i]++; }if ( (((i + z[i]) - 1) > r)) {l = i; r = ((i + z[i]) - 1); } }return z;} static long gcd( long x, long y){ return ((y == 0)?x:gcd(y,(x % y)));} static int MAXN = 1000001; static int[] spf = new int[MAXN]; private static boolean isComposite( long a, int s, long d, long n){ long x = power(a,d,n); if ( ((x == 1) || (x == (n - 1)))) {return false;} for ( int i = 0;(i < s);i++) {if ( ((x % (n - 1)) == 0)) {return false;} x = ((x * x) % n); }return true;} }
4	public class B{ static int n ,t[] ,g[] ,MOD = ((int)1e9 + 7); static int[][][] memo1 ,memo2[] ,memo3[] ; static int dp1( int idx, int remCnt, int remSum){ if ( (idx == n)) return (((remSum == 0) && (remCnt == 0))?1:0); if ( ((remCnt < 0) || (remSum < 0))) return 0; if ( (memo1[idx][remCnt][remSum] != -1)) return memo1[idx][remCnt][remSum]; int ans = dp1((idx + 1),remCnt,remSum); if ( (g[idx] == 0)) {ans += dp1((idx + 1),(remCnt - 1),(remSum - t[idx])); if ( (ans >= MOD)) ans -= MOD; } return memo1[idx][remCnt][remSum] = ans;} static int dp2( int idx, int remCnt1, int remCnt2, int remSum){ int all = (remCnt1 + remCnt2); if ( (all == 0)) return ((remSum == 0)?1:0); if ( ((idx == n) || (remSum == 0))) return 0; if ( (memo2[idx][remCnt1][remCnt2][remSum] != -1)) return memo2[idx][remCnt1][remCnt2][remSum]; int ans = dp2((idx + 1),remCnt1,remCnt2,remSum); if ( (t[idx] <= remSum)) {if ( ((g[idx] == 1) && (remCnt1 > 0))) ans += dp2((idx + 1),(remCnt1 - 1),remCnt2,(remSum - t[idx])); else if ( ((g[idx] == 2) && (remCnt2 > 0))) ans += dp2((idx + 1),remCnt1,(remCnt2 - 1),(remSum - t[idx])); } return memo2[idx][remCnt1][remCnt2][remSum] = ans;} private static int dp3( int cnt0, int cnt1, int cnt2, int last){ if ( (((cnt0 + cnt1) + cnt2) == 0)) return 1; if ( (memo3[last][cnt0][cnt1][cnt2] != -1)) return memo3[last][cnt0][cnt1][cnt2]; long ans = 0; if ( ((cnt0 > 0) && (last != 0))) ans += dp3((cnt0 - 1),cnt1,cnt2,0); if ( ((cnt1 > 0) && (last != 1))) ans += dp3(cnt0,(cnt1 - 1),cnt2,1); if ( ((cnt2 > 0) && (last != 2))) ans += dp3(cnt0,cnt1,(cnt2 - 1),2); return memo3[last][cnt0][cnt1][cnt2] = (int)(ans % MOD);} public static void main( String[] args)throws IOException { Scanner sc = new Scanner();  PrintWriter out = new PrintWriter(System.out); n = sc.nextInt(); int[] fac = new int[(n + 1)]; t = new int[n]; g = new int[n]; int[] cnt = new int[3]; fac[0] = 1; for ( int i = 1;(i <= n);i++) fac[i] = (int)(((i * 1L) * fac[(i - 1)]) % MOD); int T = sc.nextInt(); for ( int i = 0;(i < n);i++) {t[i] = sc.nextInt(); g[i] = (sc.nextInt() - 1); cnt[g[i]]++; }memo1 = new int[n][(cnt[0] + 1)][(T + 1)]; memo2 = new int[n][(cnt[1] + 1)][(cnt[2] + 1)][(T + 1)]; memo3 = new int[4][(cnt[0] + 1)][(cnt[1] + 1)][(cnt[2] + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= cnt[0]);j++) Arrays.fill(memo1[i][j],-1); for ( int j = 0;(j <= cnt[1]);j++) for ( int k = 0;(k <= cnt[2]);k++) Arrays.fill(memo2[i][j][k],-1); }for ( int i = 0;(i < 4);i++) for ( int j = 0;(j <= cnt[0]);j++) for ( int k = 0;(k <= cnt[1]);k++) Arrays.fill(memo3[i][j][k],-1); int ans = 0; for ( int cnt0 = 0;(cnt0 <= cnt[0]);cnt0++) for ( int sum0 = 0;(sum0 <= T);sum0++) for ( int cnt1 = 0;(cnt1 <= cnt[1]);cnt1++) for ( int cnt2 = 0;(cnt2 <= cnt[2]);cnt2++) { long ways = (((dp1(0,cnt0,sum0) * 1L) * dp2(0,cnt1,cnt2,(T - sum0))) % MOD); ways = ((ways * dp3(cnt0,cnt1,cnt2,3)) % MOD); ways *= fac[cnt0]; ways %= MOD; ways *= fac[cnt1]; ways %= MOD; ways *= fac[cnt2]; ways %= MOD; ans += ways; if ( (ans >= MOD)) ans -= MOD; }out.println(ans); out.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } Scanner( String fileName)throws FileNotFoundException{ br = new BufferedReader(new FileReader(fileName)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} boolean ready()throws IOException { return br.ready();} } }
0	public class A630{ public static void main( String[] args){ System.out.println(25); } }
5	public class Problem111A implements Runnable{ void solve()throws NumberFormatException,IOException { final int n = nextInt(); final int[] a = new int[n];  long sum = 0; for ( int i = 0;(i < n);i++) {final int nextInt = nextInt(); sum += nextInt; a[i] = nextInt; }Arrays.sort(a); int currSum = 0;  int maxCoins = 0; for ( int j = (a.length - 1);(j >= 0);j--) {currSum += a[j]; maxCoins++; if ( ((sum - currSum) < currSum)) {break;} }System.out.println(maxCoins); } StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args){ new Problem111A().run(); } public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); }catch (Exception e){ System.exit(9000); } finally{out.flush(); out.close(); }} String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} }
6	public class D{ static int dp( int i, int start, int msk){ if ( (Integer.bitCount(msk) == n)) return s_e[i][start]; if ( (dp[i][start][msk] != -1)) return dp[i][start][msk]; int max = 0; for ( int k = 0;(k < n);k++) { int min = Integer.MAX_VALUE; if ( ((msk & (1 << k)) == 0)) {min = diff[i][k]; min = Math.min(min,dp(k,start,(msk | (1 << k)))); max = Math.max(max,min); } }return dp[i][start][msk] = max;} static int n ,m ,a[][] ,dp[][][] ,diff[][] ,s_e[][] ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner();  PrintWriter pw = new PrintWriter(System.out); n = sc.nextInt(); m = sc.nextInt(); a = new int[n][m]; diff = new int[n][n]; s_e = new int[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) a[i][j] = sc.nextInt(); dp = new int[n][n][70000]; int ans = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) {Arrays.fill(dp[i][j],-1); diff[i][j] = Integer.MAX_VALUE; s_e[i][j] = Integer.MAX_VALUE; for ( int k = 0;(k < (m - 1));k++) {diff[i][j] = Math.min(Math.abs((a[i][k] - a[j][k])),diff[i][j]); s_e[i][j] = Math.min(Math.abs((a[i][k] - a[j][(k + 1)])),s_e[i][j]); }diff[i][j] = Math.min(Math.abs((a[i][(m - 1)] - a[j][(m - 1)])),diff[i][j]); }for ( int i = 0;(i < n);i++) ans = Math.max(ans,dp(i,i,(1 << i))); pw.print(ans); pw.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(br.readLine()); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} } }
5	public class Solution implements Runnable{ public static void main( String[] args){ new Thread(null,new Solution(),"1",(1l << 28)).start(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = null; String nextToken()throws Exception { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(nextToken());} void solve()throws Exception { int n = nextInt();  int[] a = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) sum += a[i] = nextInt(); Arrays.sort(a); int ans = 0;  int s = 0; for ( int i = (n - 1);(i >= 0);i--) {s += a[i]; ans++; if ( ((2 * s) > sum)) break; }out.println(ans); } }
4	public class Solution{ BufferedReader in ; StringTokenizer st ; PrintWriter out ; int n ,m ,k ; int[] x ,y ; char[] qx = new char[4000000],qy = new char[4000000]; int b ,e ; char[][] d ; int[] dx = {-1,0,1,0},dy = {0,-1,0,1}; void bfs(){ b = e = 0; for ( int i = 0;(i < d.length);i++) {Arrays.fill(d[i],(char)(1 << 14)); }for ( int i = 0;(i < k);++i) {qx[e] = (char)x[i]; qy[e++] = (char)y[i]; d[x[i]][y[i]] = 0; }for ( ;(b < e);++b) { int x = qx[b];  int y = qy[b]; for ( int i = 0;(i < 4);++i) { int nx = (x + dx[i]);  int ny = (y + dy[i]); if ( ((((nx >= 0) && (nx < n)) && (ny >= 0)) && (ny < m))) if ( (d[nx][ny] > (d[x][y] + 1))) {d[nx][ny] = (char)(d[x][y] + 1); qx[e] = (char)nx; qy[e++] = (char)ny; } }}} void solve()throws IOException { n = ni(); m = ni(); k = ni(); x = new int[k]; y = new int[k]; for ( int i = 0;(i < k);++i) {x[i] = (ni() - 1); y[i] = (ni() - 1); }d = new char[n][m]; bfs(); int x = -1,y = -1,last = -1; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < m);++j) if ( (d[i][j] > last)) {last = d[i][j]; x = i; y = j; } ++x; ++y; out.println(((x + " ") + y)); } public Solution()throws IOException{ Locale.setDefault(Locale.US); in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); solve(); in.close(); out.close(); } String nline()throws IOException { return in.readLine();} String ns()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(nline()); }return st.nextToken();} int ni()throws IOException { return Integer.valueOf(ns());} public static void main( String[] args)throws IOException { new Solution(); } }
0	public class Round313A{ private static final int LOCAL_ENV = 0; public static void main( String[] args){ Scanner in = new Scanner(System.in); try{if ( (LOCAL_ENV == 1)) {in = new Scanner(new File("input.txt")); } }catch (FileNotFoundException e){ in = new Scanner(System.in); } long n = in.nextLong(); if ( (n >= -9)) {System.out.println(n); } else { long absN = Math.abs(n);  long m1 = (absN / 10);  long last = (absN % 10);  long m2 = (((absN / 100) * 10) + last); System.out.println(Math.max(m1,m2)); }} }
3	public class SameSumBlocks{ public static void main( String[] args)throws Exception { FastScanner sc = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int N = sc.nextInt();  int[] pre = new int[(N + 1)];  var ansMap = new HashMap<Integer,ArrayDeque<Pair>>(); for ( int j = 1;(j <= N);j++) {pre[j] = (pre[(j - 1)] + sc.nextInt()); for ( int i = j;(i >= 1);i--) { int sum = (pre[j] - pre[(i - 1)]); if ( (!ansMap.containsKey(sum) || (ansMap.get(sum).getLast().r < i))) { var dq = ansMap.computeIfAbsent(sum,(val)->new ArrayDeque<>()); dq.add(new Pair(i,j,sum)); } }} var ans = new ArrayDeque<Pair>(); for ( var group :ansMap.values()) {if ( (group.size() > ans.size())) {ans = group; } }out.println(ans.size()); for ( Pair p :ans) {out.println(p); }out.close(); } static class Pair{ int l ,r ,sum ; public Pair( int ll, int rr, int ss){ l = ll; r = rr; sum = ss; } public String toString(){ return ((l + " ") + r);} } static class FastScanner{ private int BS = (1 << 16); private char NC = (char)0; private byte[] buf = new byte[BS]; private int bId = 0,size = 0; private char c = NC; private double cnt = 1; private BufferedInputStream in ; public FastScanner(){ in = new BufferedInputStream(System.in,BS); } public FastScanner( String s){ try{in = new BufferedInputStream(new FileInputStream(new File(s)),BS); }catch (Exception e){ in = new BufferedInputStream(System.in,BS); } } private char getChar(){ while((bId == size)){try{size = in.read(buf); }catch (Exception e){ return NC;} if ( (size == -1)) return NC; bId = 0; }return (char)buf[bId++];} public int nextInt(){ return (int)nextLong();} public long nextLong(){ cnt = 1; boolean neg = false; if ( (c == NC)) c = getChar(); for ( ;((c < '0') || (c > '9'));c = getChar()) {if ( (c == '-')) neg = true; } long res = 0; for ( ;((c >= '0') && (c <= '9'));c = getChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); cnt *= 10; }return (neg?-res:res);} } }
4	public class P1{ public static void main( String[] args){ String s = null; try{ Scanner sc = new Scanner(System.in); s = sc.next(); }catch (Exception e){ e.printStackTrace(); } int n = s.length();  HashSet<String> h = new HashSet<String>();  String t = null;  boolean b ;  int lmax = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j <= n);j++) {t = s.substring(i,j); b = h.add(t); if ( (b == false)) {if ( ((j - i) > lmax)) {lmax = (j - i); } } }}System.out.println(lmax); } }
4	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastScanner in = new FastScanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskE solver = new TaskE(); solver.solve(1,in,out); out.close(); } static class TaskE{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  int MOD = in.nextInt();  int[][] C = new int[(n + 1)][(n + 1)]; C[0][0] = 1; for ( int i = 1;(i < C.length);i++) {C[i][0] = 1; for ( int j = 1;(j < C.length);j++) {C[i][j] = (C[(i - 1)][j] + C[(i - 1)][(j - 1)]); if ( (C[i][j] >= MOD)) {C[i][j] -= MOD; } }} int[] p2 = new int[(n + 1)]; p2[0] = 1; for ( int i = 1;(i < p2.length);i++) {p2[i] = ((2 * p2[(i - 1)]) % MOD); } int[][] d = new int[(n + 1)][(n + 1)]; d[0][0] = 1; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= i);j++) {for ( int t = 1;(t <= j);t++) {if ( (t == (i - 1))) {continue;} d[i][j] = (int)((d[i][j] + ((((long)C[j][t] * p2[(t - 1)]) % MOD) * d[((i - t) - ((i == t)?0:1))][(j - t)])) % MOD); }}} int ans = 0; for ( int k = 1;(k <= n);k++) {ans += d[n][k]; if ( (ans >= MOD)) {ans -= MOD; } }out.println(ans); } } static class FastScanner{ private BufferedReader in ; private StringTokenizer st ; public FastScanner( InputStream stream){ in = new BufferedReader(new InputStreamReader(stream)); } public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(in.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
1	public class A{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  int nums = Integer.parseInt(reader.readLine());  String line = reader.readLine();  int[] ar = new int[nums];  String[] par = line.split(" "); for ( int i = 0;(i < nums);i++) {ar[i] = Integer.parseInt(par[i]); } A a = new A(); System.out.print(a.getDif(ar)); } private int getDif( int[] input){ int odd = 0,even = 0,d = 0;  int p = 0,q = 0; for ( int i = 0;(i < input.length);i++) { int t = (input[i] % 2); if ( (t == 0)) {even++; p = (i + 1); } else {odd++; q = (i + 1); }if ( (((odd > 0) && (even > 0)) && (odd != even))) {if ( (even > odd)) return q; else return p;} }return d;} }
4	public class Compute{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  long M = sc.nextInt();  long fact[] = new long[(n + 1)];  long inv[] = new long[(n + 1)];  long ifact[] = new long[(n + 1)];  long dp[][] = new long[(n + 1)][(n + 1)]; fact[1] = 1; ifact[1] = 1; ifact[0] = 1; inv[1] = 1; dp[1][1] = 1; for ( int i = 2;(i <= n);i++) {fact[i] = ((i * fact[(i - 1)]) % M); inv[i] = ((inv[(int)(M % i)] * (M - (M / i))) % M); dp[i][i] = ((dp[(i - 1)][(i - 1)] * 2) % M); ifact[i] = ((ifact[(i - 1)] * inv[i]) % M); }for ( int i = 3;(i <= n);i++) {for ( int j = ((i / 2) + 1);(j <= (i - 1));j++) {for ( int k = 2;((k <= (i - 1)) && (((j - k) + 1) > ((i - k) / 2)));k++) {dp[i][j] = ((dp[i][j] + ((((((((dp[(k - 1)][(k - 1)] * dp[(i - k)][((j - k) + 1)]) % M) * fact[j]) % M) * ifact[(k - 1)]) % M) * ifact[((j - k) + 1)]) % M)) % M); }}} long sum = 0; for ( int i = ((n / 2) + 1);(i <= n);i++) sum = ((sum + dp[n][i]) % M); System.out.println((sum % M)); } }
3	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); } HashMap<Integer,ArrayList<Node>> h = new HashMap<>(); for ( int i = 0;(i < n);i++) { int sum = 0; for ( int j = i;(j < n);j++) {sum += a[j]; if ( h.containsKey(sum)) {h.get(sum).add(new Node(i,j)); } else { ArrayList<Node> temp = new ArrayList<>(); temp.add(new Node(i,j)); h.put(sum,temp); }}} long ans = 0;  ArrayList<Integer> ansList = new ArrayList<>(); for ( int x :h.keySet()) {Collections.sort(h.get(x),new Comparator<Node>(){@Override public int compare( Node o1, Node o2){ return Integer.compare(o1.r,o2.r);} }); ArrayList<Node> l = h.get(x);  ArrayList<Integer> temp = new ArrayList<>();  int lasty = Integer.MIN_VALUE; for ( int i = 0;(i < l.size());i++) {if ( (l.get(i).l > lasty)) {lasty = l.get(i).r; temp.add(l.get(i).l); temp.add(l.get(i).r); } }if ( (ans < temp.size())) {ansList = temp; ans = ansList.size(); } }out.println((ans / 2)); for ( int i = 0;(i < ansList.size());i++) {out.print(((ansList.get(i) + 1) + " ")); i++; out.println(((ansList.get(i) + 1) + " ")); }out.close(); } static class Node{ int l ,r ; public Node( int a, int b){ l = a; r = b; } } }
3	public class Task{ public static void solve()throws Exception { int n = nextInt();  int[] S = new int[n]; for ( int i = 0;(i < n);i++) {S[i] = nextInt(); if ( (i > 0)) {S[i] += S[(i - 1)]; } } Map<Integer,List<L>> map = new HashMap<>(); for ( int j = 0;(j < n);j++) {for ( int i = j;(i >= 0);i--) { int sum = S[j]; if ( (i > 0)) {sum -= S[(i - 1)]; } L l = new L(); l.a = i; l.b = j; List<L> list = map.get(sum); if ( (list == null)) {list = new ArrayList<>(); map.put(sum,list); } list.add(l); }} List<L> longest = null; for ( Integer sum :map.keySet()) { List<L> list = map.get(sum); Collections.sort(list); List<L> list2 = new ArrayList<>(list.size());  int from = list.get(0).a; for ( L l :list) {if ( (l.a >= from)) {list2.add(l); from = (l.b + 1); } }if ( ((longest == null) || (longest.size() < list2.size()))) {longest = list2; } }println(longest.size()); for ( int i = 0;(i < longest.size());i++) { L l = longest.get(i); println((((l.a + 1) + " ") + (l.b + 1))); }} private static class L implements Comparable<L>{ int a ; int b ; @Override public int compareTo( L l2){ return Integer.valueOf(b).compareTo(l2.b);} } public static void main( String[] args)throws Exception { try{fastReader = new FastReader(System.in); systemOut = new BufferedOutputStream(System.out); solve(); }finally{systemOut.close(); }} private static FastReader fastReader = null; private static BufferedOutputStream systemOut = null; public static void print( Object obj){ print(obj.toString()); } public static void print( String str){ try{systemOut.write(str.getBytes("utf-8")); }catch (Exception ex){ throw (new RuntimeException(ex));} } public static void println( Object obj){ println(obj.toString()); } public static void println( String str){ try{print(str); systemOut.write('\n'); }catch (Exception ex){ throw (new RuntimeException(ex));} } public static String next(){ return fastReader.readNextToken(false);} public static int nextInt(){ return Integer.parseInt(fastReader.readNextToken(false));} static class FastReader{ private byte[] buf = new byte[65536]; private int ind = 0; private int maxInd = -1; private InputStream is = null; private boolean eof = false; private boolean lastCharRead = false; public FastReader( InputStream is){ this.is = is; } public String readNextToken( boolean endOfLine){ try{ StringBuilder sb = new StringBuilder();  boolean found = false; while(true){if ( lastCharRead) {return null;} else if ( (ind > maxInd)) {if ( eof) {lastCharRead = true; } else {fillBuffer(); }} byte b = '\n'; if ( !lastCharRead) {b = buf[ind++]; } if ( (b == '\r')) {} else if ( (((b == '\n') && endOfLine) || (Character.isWhitespace(b) && !endOfLine))) {if ( found) {break;} } else {sb.append((char)b); found = true; }}return sb.toString(); }catch (Exception ex){ throw (new RuntimeException(ex));} } private void fillBuffer(){ try{ int read = is.read(buf,0,buf.length); if ( (read < buf.length)) {eof = true; } ind = 0; maxInd = (read - 1); }catch (Exception ex){ throw (new RuntimeException(ex));} } } }
1	public class C{ static PrintWriter out ; static InputReader in ; public static void main( String[] args){ out = new PrintWriter(System.out); in = new InputReader(); new C(); out.flush(); out.close(); } C(){ int w = solve(); out.print(((w == 0)?"sjfnb":"cslnb")); } int n ; long a[] ; int solve(){ n = in.nextInt(); a = new long[n]; long sum = 0; for ( int i = 0;(i < n);i++) sum += a[i] = in.nextLong(); if ( (sum == 0)) {return 1;} Arrays.sort(a); int c = 0,c0 = 0;  long p = -1,max = 0;  int f = 0;  long t = -1;  int pp = -1; for ( int i = 0;(i < n);i++) {if ( (a[i] == p)) {c++; } else {if ( (p == 0)) c0 = c; if ( (c >= 2)) {f++; t = p; pp = (i - 2); } max = Math.max(max,c); p = a[i]; c = 1; }}max = Math.max(max,c); sum = 0; if ( (c >= 2)) {f++; t = p; pp = (n - 2); } if ( (((max > 2) || (c0 > 1)) || (f > 1))) return 1; if ( (f == 1)) { long v = Arrays.binarySearch(a,(t - 1)); if ( (v >= 0)) return 1; a[pp]--; sum = 1; } p = -1; for ( int i = 0;(i < n);i++) {sum += (a[i] - (p + 1)); a[i] = (p + 1); p = a[i]; }return (1 - (int)(sum % 2));} public static class InputReader{ BufferedReader br ; StringTokenizer st ; InputReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ } }return st.nextToken();} } }
4	public class Main{ static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); static StringBuilder out = new StringBuilder(); public static void main( String[] args){ solve(); return ;} static String nextLine(){ try{return reader.readLine().trim(); }catch (Exception e){ } return null;} static void solve(){ String str = nextLine();  int max = 0;  int index = 0; for ( int i = 0;(i < str.length());i++) {for ( int j = (i + 1);(j < str.length());j++) {if ( (str.charAt(i) == str.charAt(j))) { int count = 1; while(true){if ( (((str.length() <= (i + count)) || (str.length() <= (j + count))) || (str.charAt((i + count)) != str.charAt((j + count))))) break; count++; }if ( (max < count)) {max = count; index = i; } } }}System.out.println(max); return ;} }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( ((n % 2) == 0)) {System.out.printf("%d %d",4,(n - 4)); } else {System.out.printf("%d %d",9,(n - 9)); }} }
4	public class GeorgeAndInterestingGraph{ public static void main( String[] args){ MyScanner sc = new MyScanner();  int N = sc.nextInt();  int M = sc.nextInt();  int[] edgeFrom = new int[M];  int[] edgeTo = new int[M]; for ( int i = 0;(i < M);i++) {edgeFrom[i] = sc.nextInt(); edgeTo[i] = sc.nextInt(); } int best = Integer.MAX_VALUE;  boolean[][] adjMat = makeAdjMat(N,edgeFrom,edgeTo); for ( int i = 0;(i < N);i++) { boolean[][] mat = copyOfArray2d(adjMat); best = Math.min(best,count(mat,M,i)); }System.out.println(best); } public static boolean[][] copyOfArray2d( boolean[][] arr){ int N = arr.length;  int M = arr[0].length;  boolean[][] copy = new boolean[N][M]; for ( int i = 0;(i < N);i++) {System.arraycopy(arr[i],0,copy[i],0,M); }return copy;} public static int count( boolean[][] mat, int M, int center){ int N = mat.length;  int cntWithI = (mat?1:0); for ( int i = 0;(i < N);i++) {if ( (i != center)) {if ( mat[i][center]) {cntWithI++; } if ( mat[center][i]) {cntWithI++; } } mat[i][center] = false; mat[center][i] = false; } int other = (M - cntWithI);  int matches = bipartiteMatching(mat); return ((((((((2 * N) - 1) - cntWithI) + other) - matches) + N) - 1) - matches);} public static boolean[][] makeAdjMat( int N, int[] edgeFrom, int[] edgeTo){ boolean[][] mat = new boolean[N][N]; for ( int i = 0;(i < edgeFrom.length);i++) { int from = (edgeFrom[i] - 1);  int to = (edgeTo[i] - 1); mat[from][to] = true; }return mat;} public static boolean fordFulkersonHelper( int[][] resid, int s, int t, int[] parent){ int V = resid.length;  boolean[] visited = new boolean[V];  LinkedList<Integer> q = new LinkedList<Integer>(); q.push(s); visited[s] = true; parent[s] = -1; while(!q.isEmpty()){ int u = q.pop(); for ( int v = 0;(v < V);v++) {if ( (!visited[v] && (resid[u][v] > 0))) {q.push(v); parent[v] = u; visited[v] = true; } }}return visited[t];} public static boolean bipartiteMatchingHelper( boolean[][] bpGraph, int u, boolean[] seen, int[] matchR){ int N = bpGraph[0].length; for ( int v = 0;(v < N);v++) {if ( (bpGraph[u][v] && !seen[v])) {seen[v] = true; if ( ((matchR[v] < 0) || bipartiteMatchingHelper(bpGraph,matchR[v],seen,matchR))) {matchR[v] = u; return true;} } }return false;} public static int bipartiteMatching( boolean[][] bpGraph, int[] matchIJ, int[] matchJI){ int ans = bipartiteMatching(bpGraph,matchJI); for ( int i = 0;(i < matchJI.length);i++) {matchIJ[i] = -1; }for ( int j = 0;(j < matchJI.length);j++) { int i = matchJI[j]; if ( (i >= 0)) {matchIJ[i] = j; } }return ans;} public static int bipartiteMatching( boolean[][] bpGraph, int[] matchJI){ int M = bpGraph.length;  int N = bpGraph[0].length; for ( int i = 0;(i < N);i++) {matchJI[i] = -1; } int ans = 0; for ( int u = 0;(u < M);u++) { boolean[] seen = new boolean[N]; if ( bipartiteMatchingHelper(bpGraph,u,seen,matchJI)) {ans++; } }return ans;} public static int bipartiteMatching( boolean[][] bpGraph){ int N = bpGraph[0].length;  int[] matchJI = new int[N]; return bipartiteMatching(bpGraph,matchJI);} public static int bipartiteMatching( int[][] intGraph){ boolean[][] bpGraph = intToBooleanAdjMat(intGraph); return bipartiteMatching(bpGraph);} public static int bipartiteMatching( int[][] intGraph, int[] matchJI){ boolean[][] bpGraph = intToBooleanAdjMat(intGraph); return bipartiteMatching(bpGraph,matchJI);} public static int bipartiteMatching( int[][] intGraph, int[] matchIJ, int[] matchJI){ boolean[][] bpGraph = intToBooleanAdjMat(intGraph); return bipartiteMatching(bpGraph,matchIJ,matchJI);} public static boolean[][] intToBooleanAdjMat( int[][] mat){ int M = mat.length;  int N = mat[0].length;  boolean[][] bMat = new boolean[M][N]; for ( int i = 0;(i < M);i++) {for ( int j = 0;(j < N);j++) {bMat[i][j] = (mat[i][j] != 0); }}return bMat;} public static class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } int nextInt(){ return Integer.parseInt(next());} String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} } }
2	public class C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  BigInteger x = sc.nextBigInteger();  BigInteger k = sc.nextBigInteger();  BigInteger zero = new BigInteger("0");  BigInteger one = new BigInteger("1");  BigInteger two = new BigInteger("2");  BigInteger modulo = new BigInteger("1000000007");  BigInteger ans = two.modPow(k.add(one),modulo); ans = ans.multiply(x); ans = ans.subtract(two.modPow(k,modulo)); ans = ans.add(one); ans = ans.mod(modulo); if ( x.equals(zero)) {System.out.println(0); } else {System.out.println(ans); }} }
3	public class Main{ static FastScanner fs = new FastScanner(); static class FastScanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String next(){ while(!st.hasMoreElements())try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } return st.nextToken();} int Int(){ return Integer.parseInt(next());} long Long(){ return Long.parseLong(next());} String Str(){ return next();} } public static void main( String[] args)throws java.lang.Exception { PrintWriter out = new PrintWriter(System.out);  int T = 1; for ( int t = 0;(t < T);t++) { int n = Int();  int A[] = new int[n]; for ( int i = 0;(i < n);i++) {A[i] = Int(); } Solution sol = new Solution(); sol.solution(out,A); }out.flush(); } public static int Int(){ return fs.Int();} public static long Long(){ return fs.Long();} public static String Str(){ return fs.Str();} } class Solution{ public void solution( PrintWriter out, int[] A){ Map<Integer,List<int[]>> f = new HashMap<>();  List<int[]> res = new ArrayList<>(); for ( int i = 0;(i < A.length);i++) { int sum = 0; for ( int j = i;(j < A.length);j++) {sum += A[j]; if ( !f.containsKey(sum)) f.put(sum,new ArrayList<>());  List<int[]> list = f.get(sum); list.add(new int[]{i,j}); }}for ( Integer key :f.keySet()) { List<int[]> list = f.get(key); Collections.sort(list,(a,b)->{return (a[1] - b[1]);}); int pre[] = new int[list.size()]; Arrays.fill(pre,-1); int dp[][] = new int[list.size()][2]; dp[0][0] = 1; dp[0][1] = 0; for ( int i = 1;(i < list.size());i++) { int pair[] = list.get(i);  int l = 0,r = (i - 1);  int pos = -1; while((l <= r)){ int mid = (l + ((r - l) / 2)); if ( (list.get(mid)[1] < pair[0])) {pos = mid; l = (mid + 1); } else {r = (mid - 1); }}if ( (pos != -1)) { int mx = (1 + dp[pos][0]); if ( (mx >= dp[(i - 1)][0])) {dp[i][0] = mx; dp[i][1] = i; pre[i] = dp[pos][1]; } else {dp[i][0] = dp[(i - 1)][0]; dp[i][1] = dp[(i - 1)][1]; }} else {dp[i][0] = dp[(i - 1)][0]; dp[i][1] = dp[(i - 1)][1]; }} int n = list.size(); if ( (dp[(n - 1)][0] > res.size())) {res = new ArrayList<>(); int j = dp[(n - 1)][1]; while((j != -1)){res.add(list.get(j)); j = pre[j]; }} }out.println(res.size()); for ( int[] p :res) {out.println((((p[0] + 1) + " ") + (p[1] + 1))); }} }
3	public class A{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  int n = Integer.parseInt(bf.readLine());  StringTokenizer st = new StringTokenizer(bf.readLine());  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(st.nextToken()); int counter = 0;  TreeSet<Integer> val = new TreeSet<Integer>(); for ( int i :a) val.add(i); while(!val.isEmpty()){ int min = val.first();  Set<Integer> toRemove = new HashSet<Integer>(); for ( int i :val) if ( ((i % min) == 0)) toRemove.add(i); for ( int i :toRemove) val.remove(i); counter++; }out.println(counter); out.close(); System.exit(0); } }
3	public class MainG{ static StdIn in = new StdIn(); static PrintWriter out = new PrintWriter(System.out); static long M = ((long)1e9 + 7); static int n ,dig ; static int[] x ; static long[] p10 ,s ; static long[][][] dp ; public static void main( String[] args){ char[] cs = in.next().toCharArray(); n = cs.length; x = new int[n]; for ( int i = 0;(i < n);++i) x[i] = (cs[i] - '0'); p10 = new long[n]; p10[0] = 1; for ( int i = 1;(i < n);++i) p10[i] = ((p10[(i - 1)] * 10) % M); s = new long[(n + 1)]; s[n] = 1; for ( int i = (n - 1);(i >= 0);--i) s[i] = ((s[(i + 1)] + (x[i] * p10[((n - 1) - i)])) % M); long ans = 0; dp = new long[2][n][(n + 1)]; for ( dig = 1;(dig <= 9);++dig) {for ( int i = 0;(i < n);++i) {Arrays.fill(dp[0][i],-1); Arrays.fill(dp[1][i],-1); }for ( int i = 1;(i <= n);++i) ans = ((ans + (p10[(i - 1)] * dp(0,0,i))) % M); }out.println(ans); out.close(); } static long dp( int less, int ignore, int need){ if ( (need == 0)) return ((less == 1)?p10[(n - ignore)]:s[ignore]); if ( (ignore == n)) return 0; if ( (dp[less][ignore][need] != -1)) return dp[less][ignore][need]; long res = 0;  int lim = ((less == 1)?9:x[ignore]); for ( int i = 0;(i <= lim);++i) res = ((res + dp((less | ((i < lim)?1:0)),(ignore + 1),(need - ((i >= dig)?1:0)))) % M); return dp[less][ignore][need] = res;} interface Input{ public String next(); ; public int nextInt(); public long nextLong(); ; } static class StdIn implements Input{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public StdIn(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public StdIn( InputStream in){ try{din = new DataInputStream(in); }catch (Exception e){ throw (new RuntimeException());} buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String next(){ int c ; while((((c = read()) != -1) && (((c == ' ') || (c == '\n')) || (c == '\r')))); StringBuilder s = new StringBuilder(); while((c != -1)){if ( (((c == ' ') || (c == '\n')) || (c == '\r'))) break; s.append((char)c); c = read(); }return s.toString();} public int nextInt(){ int ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do ret = (((ret * 10) + c) - '0'); while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} public long nextLong(){ long ret = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do ret = (((ret * 10) + c) - '0'); while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -ret; return ret;} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } private byte read(){ try{if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++]; }catch (IOException e){ throw (new RuntimeException());} } public void close()throws IOException { if ( (din == null)) return ; din.close(); } } }
4	public class E14G{ static int[][] choose ; public static void main( String[] args)throws IOException { init_io(); int N = nint(),M = nint(); choose = new int[(N + 1)][]; long[] ways = new long[(N + 1)]; ways[0] = 1; ways[1] = 1; for ( int i = 0;(i <= N);i++) choose[i] = new int[(i + 1)]; for ( int i = 0;(i <= N);i++) {choose[i][0] = choose[i][i] = 1; for ( int j = 1;(j < i);j++) {choose[i][j] = ((choose[(i - 1)][(j - 1)] + choose[(i - 1)][j]) % M); }}for ( int i = 2;(i <= N);i++) {for ( int j = 0;(j < i);j++) {ways[i] = ((ways[i] + choose[(i - 1)][j]) % M); }} long[][] dp = new long[(((N + 1) / 2) + 1)][(N + 1)]; dp[0][0] = 1; for ( int i = 1;(i <= ((N + 1) / 2));i++) {for ( int j = 1;(j <= N);j++) {for ( int k = 1;(k <= j);k++) {dp[i][j] = ((dp[i][j] + ((((ways[k] * choose[j][k]) % M) * dp[(i - 1)][(j - k)]) % M)) % M); }}} long ans = 0; for ( int i = 1;(i <= ((N + 1) / 2));i++) {ans = ((ans + dp[i][(N - (i - 1))]) % M); }out.println(ans); out.close(); } static StreamTokenizer in ; static PrintWriter out ; static BufferedReader br ; static int nint()throws IOException { in.nextToken(); return (int)in.nval;} static void init_io()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); in = new StreamTokenizer(br); out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); } }
3	public class Main{ public static void main( String[] args)throws Exception { new Main().go(); } PrintWriter out ; Reader in ; BufferedReader br ; Main()throws IOException{ try{in = new Reader("input.txt"); out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); }catch (Exception e){ in = new Reader(); out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); } } void go()throws Exception { int t = 1; while((t > 0)){solve(); t--; }out.flush(); out.close(); } int inf = 2000000000; int mod = 1000000007; double eps = 0.000000001; int n ; int m ; ArrayList<Integer>[] g ; int[] a ; void solve()throws IOException { int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); HashMap<Integer,ArrayList<Pair>> segs = new HashMap<>(); for ( int i = 0;(i < n);i++) { int sum = 0; for ( int j = i;(j < n);j++) {sum += a[j]; if ( !segs.containsKey(sum)) segs.put(sum,new ArrayList<>()); segs.get(sum).add(new Pair(i,j)); }} int max = 0;  ArrayList<Pair> ans = new ArrayList<>(); for ( Integer k :segs.keySet()) { ArrayList<Pair> list = segs.get(k);  ArrayList<Pair> blocks = new ArrayList<>(); Collections.reverse(list); int prev = inf; for ( Pair p :list) { int l = p.a;  int r = p.b; if ( (r < prev)) {blocks.add(p); prev = l; } }if ( (blocks.size() > max)) {ans = blocks; max = blocks.size(); } }out.println(ans.size()); for ( Pair p :ans) out.println((((p.a + 1) + " ") + (p.b + 1))); } class Pair implements Comparable<Pair>{ int a ; int b ; Pair( int a, int b){ this.a = a; this.b = b; } } class Reader{ BufferedReader br ; StringTokenizer tok ; Reader( String file)throws IOException{ br = new BufferedReader(new FileReader(file)); } Reader()throws IOException{ br = new BufferedReader(new InputStreamReader(System.in)); } String next()throws IOException { while(((tok == null) || !tok.hasMoreElements()))tok = new StringTokenizer(br.readLine()); return tok.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.valueOf(next());} } }
6	public class C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); hx = sc.nextInt(); hy = sc.nextInt(); N = sc.nextInt(); X = new int[N]; Y = new int[N]; for ( int i = 0;(i < N);i++) {X[i] = sc.nextInt(); Y[i] = sc.nextInt(); }DP = new int[(1 << N)]; Arrays.fill(DP,-1); int ans = recur(0);  ArrayList<Integer> aa = new ArrayList<Integer>();  int U = 0; aa.add(0); int test = 0; while((U != ((1 << N) - 1))){ int a = 0; for ( int i = 0;(i < N);i++) if ( (((1 << i) & U) == 0)) {a = i; break;} int ans2 = (recur((U | (1 << a))) + (2 * (pw((X[a] - hx)) + pw((Y[a] - hy)))));  int temp = (2 * (pw((X[a] - hx)) + pw((Y[a] - hy))));  int best = -1; for ( int i = (a + 1);(i < N);i++) {if ( (((1 << i) & U) == 0)) { int ans3 = ((((((pw((X[a] - X[i])) + pw((Y[a] - Y[i]))) + pw((X[a] - hx))) + pw((Y[a] - hy))) + pw((X[i] - hx))) + pw((Y[i] - hy))) + recur(((U | (1 << a)) | (1 << i)))); if ( (ans3 < ans2)) {ans2 = ans3; best = i; temp = (((((pw((X[a] - X[i])) + pw((Y[a] - Y[i]))) + pw((X[a] - hx))) + pw((Y[a] - hy))) + pw((X[i] - hx))) + pw((Y[i] - hy))); } } }if ( (best == -1)) {aa.add((a + 1)); aa.add(0); U |= (1 << a); } else {aa.add((a + 1)); aa.add((best + 1)); aa.add(0); U |= ((1 << a) | (1 << best)); }test += temp; }if ( (test != ans)) throw (new RuntimeException()); System.out.println(ans); for ( int i = 0;(i < aa.size());i++) System.out.print((aa.get(i) + ((i == (aa.size() - 1))?"":" "))); System.out.println(); } private static int recur( int U){ if ( (DP[U] != -1)) return DP[U]; if ( (U == ((1 << N) - 1))) return 0; int a = 0; for ( int i = 0;(i < N);i++) if ( (((1 << i) & U) == 0)) {a = i; break;} int ans = (recur((U | (1 << a))) + (2 * (pw((X[a] - hx)) + pw((Y[a] - hy))))); for ( int i = (a + 1);(i < N);i++) {if ( (((1 << i) & U) == 0)) {ans = min(ans,((((((pw((X[a] - X[i])) + pw((Y[a] - Y[i]))) + pw((X[a] - hx))) + pw((Y[a] - hy))) + pw((X[i] - hx))) + pw((Y[i] - hy))) + recur(((U | (1 << a)) | (1 << i))))); } }DP[U] = ans; return ans;} static int pw( int a){ return (a * a);} static int hx ,hy ; static int[] X ,Y ; static int N ; static int[] DP ; }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ long maxk = (long)1e18; public void solve( int testNumber, InputReader in, OutputWriter out){ int t = in.nextInt();  long maxn = 1;  long val = 0; for ( long i = 1;;i++) {val = (1 + (4 * val)); if ( (val >= maxk)) {maxn = i; break;} } long[] vala = new long[((int)maxn + 1)]; vala[1] = 1; for ( int i = 2;(i <= maxn);i++) {vala[i] = (1 + (4 * vala[(i - 1)])); }o:while((t-- > 0)){ long n = in.nextInt();  long k = in.nextLong(); if ( ((n - 1) >= maxn)) {out.println(("YES " + (n - 1))); continue;} k--; if ( (k <= vala[((int)n - 1)])) {out.println(("YES " + (n - 1))); continue;} long cs = (n - 1);  long cc = 3;  int ind = 2;  long end = -1; while((k > 0)){if ( ((k >= cc) && (cs > 0))) {k -= cc; cc += (1l << ind); cs--; ind++; } else {end = ind; break;}} long fcs = cs; if ( (k == 0)) {out.println(("YES " + cs)); continue;} k -= vala[((int)n - 1)]; cs = (n - 1); cc = 3; ind = 2; long rv = 5;  long sind = 3; while(((k > 0) && (ind < end))){k -= (rv * vala[((int)cs - 1)]); rv += (1l << sind); sind++; cs--; ind++; }if ( (k <= 0)) {out.println(("YES " + fcs)); } else {out.println("NO"); }}} } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void println( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
2	public class ABC{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long k ,c ,n ,d ; c = 1; d = 9; n = 1; k = sc.nextLong(); while((k > (c * d))){k -= (c * d); n *= 10; d *= 10; c++; }n += ((k - 1) / c); char[] num = String.valueOf(n).toCharArray(); System.out.println(num[(int)((k - 1) % c)]); } }
1	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(new BufferedInputStream(System.in));  int n = in.nextInt();  char b[] = in.next().toCharArray();  int bb[] = new int[b.length];  int Mark[] = new int[((26 * 2) + 1)];  int Mark1[] = new int[((26 * 2) + 1)];  int ans = 0; for ( int i = 0;(i < b.length);i++) { char f = b[i];  int a ; if ( ((f >= 'a') && (f <= 'z'))) a = (f - 'a'); else a = ((f - 'A') + 26); bb[i] = a; if ( (Mark1[a] == 0)) {ans++; Mark1[a] = 1; } } int i ;  int L = 0,nowsum = 0,Ans = n,R = 0; for ( i = 0;(i < n);i++) {if ( (Mark[bb[i]] == 0)) nowsum++; Mark[bb[i]]++; if ( (nowsum == ans)) {R = i; break;} }Ans = ((R - L) + 1); for ( i = L;(i < n);i++) {if ( (Mark == 0)) { int ok = 0; for ( int j = (R + 1);(j < n);j++) {Mark[bb[j]]++; if ( (bb[j] == bb[i])) {ok = 1; R = j; break;} }if ( (ok == 0)) break; } if ( (Ans > (R - i))) Ans = (R - i); }System.out.println(Ans); } }
3	public class helloWorld{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  int l = 1000,r = 0,u = 1000,b = 0; for ( int i = 0;(i < n);i++) { String str = in.next(); for ( int j = 0;(j < m);j++) if ( (str.charAt(j) == 'B')) {l = Math.min((j + 1),l); r = Math.max((j + 1),r); u = Math.min((i + 1),u); b = Math.max((i + 1),b); } }System.out.println(((((u + b) / 2) + " ") + ((l + r) / 2))); in.close(); } }
2	public class C{ private static BufferedReader in ; private static StringTokenizer st ; private static PrintWriter out ; public static void main( String[] args)throws NumberFormatException,IOException { in = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt();  int m = nextInt();  int k = nextInt();  int mod = (int)(1e9 + 9);  int correct = (n - (n / k));  int carry = (n % k);  long ans ; if ( (correct >= m)) {ans = m; } else {m -= correct; int block = (n / k);  BigInteger pow = BigInteger.valueOf(2).modPow(BigInteger.valueOf((m + 1)),BigInteger.valueOf(mod)); ans = (((pow.longValue() - 2) + mod) % mod); ans = ((ans * (long)k) % mod); ans = (((ans + ((long)(block - m) * (long)(k - 1))) + carry) % mod); }System.out.println(ans); } static String next()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} static int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} }
2	public class TaskB{ static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer str ; static String SK ; static String next()throws IOException { while(((str == null) || str.hasMoreTokens())){SK = in.readLine(); if ( (SK == null)) return null; str = new StringTokenizer(SK); }return str.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(next());} static long nextLong()throws IOException { return Long.parseLong(next());} public static void main( String[] args)throws IOException { long n = nextLong();  int k = nextInt(); if ( (n == 1)) {System.out.println(0); return ;} long sum = ((((2 + (long)k) * ((long)k - 1)) / 2) - ((long)k - 2)); if ( (n > sum)) {System.out.println(-1); return ;} else if ( (n <= k)) {System.out.println(1); return ;} long cnt = 0;  long sum2 = 0;  int index = binSearch(2,k,k,n); sum2 = ((((long)(index)+k * (long)((k - index) + 1)) / 2) - (long)(k - index)); cnt = ((k - index) + 1); if ( (sum2 == n)) {System.out.println(cnt); return ;} if ( (sum2 > n)) for ( int kk = index;(kk <= k);kk++) {sum2 = ((((long)(kk)+k * (long)((k - kk) + 1)) / 2) - (long)(k - kk)); cnt--; if ( (sum2 <= n)) {System.out.println((cnt + 1)); return ;} } else {for ( int kk = (index - 1);(kk >= 2);kk--) {sum2 = ((((long)(kk)+k * (long)((k - kk) + 1)) / 2) - (long)(k - kk)); cnt++; if ( (sum2 >= n)) {System.out.println(cnt); return ;} }}System.out.println(-1); return ;} static int binSearch( int l, int r, int k, long n){ while(true){ int mid = (l + ((r - l) / 2));  long sum2 = ((((long)(mid)+k * (long)((k - mid) + 1)) / 2) - (long)(k - mid)); if ( ((l >= r) || (sum2 == n))) {return mid;} else if ( (sum2 > n)) {l = (mid + 1); } else if ( (sum2 < n)) {r = mid; } }} }
2	public class C{ static int mod = (int)(1e9 + 7); static InputReader in ; static PrintWriter out ; public static void main( String[] args){ in = new InputReader(System.in); out = new PrintWriter(System.out); long x = in.nextLong();  long k = in.nextLong(); if ( (x == 0)) {out.println(0); } else { long mul = pow(2,(k + 1),mod); x %= mod; mul = ((mul * x) % mod); long sub = pow(2,k,mod); sub = (((sub - 1) + mod) % mod); mul = (((mul - sub) + mod) % mod); out.println(mul); }out.close(); } static long gcd( long x, long y){ if ( (y == 0)) return x; else return gcd(y,(x % y));} static int gcd( int x, int y){ if ( (y == 0)) return x; else return gcd(y,(x % y));} static long pow( long n, long p, long m){ long result = 1; if ( (p == 0)) {return 1;} while((p != 0)){if ( ((p % 2) == 1)) result *= n; if ( (result >= m)) result %= m; p >>= 1; n *= n; if ( (n >= m)) n %= m; }return result;} static long pow( long n, long p){ long result = 1; if ( (p == 0)) return 1; while((p != 0)){if ( ((p % 2) == 1)) result *= n; p >>= 1; n *= n; }return result;} static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ,snumChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int snext(){ if ( (snumChars == -1)) throw (new InputMismatchException()); if ( (curChar >= snumChars)) {curChar = 0; try{snumChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (snumChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = snext(); while(isSpaceChar(c)){c = snext(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = snext(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = snext(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = snext(); while(isSpaceChar(c)){c = snext(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = snext(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = snext(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
0	public class A{ private void solve()throws IOException { int n = nextInt();  int r = n; n *= 2; n -= (0.5 * r); System.out.println(n); } public static void main( String[] args){ new A().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
1	public class JavaApplication2{ public static void main( String[] args)throws IOException { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(sc.readLine().split(" ")[0]);  ArrayList<String> tshr = new ArrayList<>(n); for ( int i = 0;(i < n);i++) {tshr.add(sc.readLine()); }for ( int i = 0;(i < n);i++) {tshr.remove(sc.readLine()); }System.out.println(tshr.size()); } }
4	public class Main{ public static void main( String[] args){ InputStream inputStream ; try{inputStream = new FileInputStream("input.txt"); }catch (IOException e){ throw (new RuntimeException(e));} OutputStream outputStream ; try{outputStream = new FileOutputStream("output.txt"); }catch (IOException e){ throw (new RuntimeException(e));} InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ int N = in.nextInt();  int M = in.nextInt();  int[][] dist = new int[N][M]; for ( int[] ini :dist) Arrays.fill(ini,(1 << 30)); int K = in.nextInt();  Queue<Integer> q = new LinkedList<Integer>(); for ( int k = 0;(k < K);++k) { int r = (in.nextInt() - 1);  int c = (in.nextInt() - 1); dist[r][c] = 0; q.offer(r); q.offer(c); } int[] dx = new int[]{1,-1,0,0};  int[] dy = new int[]{0,0,1,-1}; while(!q.isEmpty()){ int rr = q.poll();  int cc = q.poll(); for ( int a = 0;(a < 4);++a) { int x = (dx[a] + rr);  int y = (dy[a] + cc); if ( ((((x >= 0) && (x < N)) && (y >= 0)) && (y < M))) {if ( (dist[x][y] > (dist[rr][cc] + 1))) {dist[x][y] = (dist[rr][cc] + 1); q.offer(x); q.offer(y); } } }} int max = 0; for ( int i = 0;(i < N);++i) for ( int j = 0;(j < M);++j) max = Math.max(max,dist[i][j]); for ( int i = 0;(i < N);++i) {for ( int j = 0;(j < M);++j) {if ( (max == dist[i][j])) {out.println((((i + 1) + " ") + (j + 1))); return ;} }}} } static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class j{ public static void main( String[] a)throws IOException { BufferedReader b = new BufferedReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));  int l = 0,x2 = 0,x = 0,y1 = 0,y = 0,max = -1,min = 100000,x1 = 0,n = 0,j = 0,k = 0,p = 0,m = 0,i = 0;  String s ; s = b.readLine(); StringTokenizer c = new StringTokenizer(s); n = Integer.parseInt(c.nextToken()); m = Integer.parseInt(c.nextToken()); k = Integer.parseInt(b.readLine()); int e[][] = new int[k][2]; s = b.readLine(); StringTokenizer z = new StringTokenizer(s); for ( i = 0;(i < k);i++) {e[i][0] = Integer.parseInt(z.nextToken()); e[i][1] = Integer.parseInt(z.nextToken()); }for ( i = 1;(i <= n);i++) {for ( j = 1;(j <= m);j++) {for ( l = 0;(l < k);l++) {p = ((int)Math.abs((e[l][0] - i)) + (int)Math.abs((e[l][1] - j))); if ( (p < min)) {min = p; x1 = i; y1 = j; } }if ( (min > max)) {max = min; x = x1; y = y1; } min = 100000; }}out.print(((x + " ") + y)); out.close(); } }
2	public class CFEdu66{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong();  double tmp = Math.sqrt((9 + (8 * (n + k)))); if ( ((Math.ceil(tmp) - tmp) < 0.001)) tmp = Math.ceil(tmp);  long root = (long)tmp;  long x = ((-3 + root) / 2); System.out.println((n - x)); } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, Scanner in, PrintWriter out){ String[] str = in.nextLine().split(" ");  int a = Integer.parseInt(str[0]);  int v = Integer.parseInt(str[1]); str = in.nextLine().split(" "); int l = Integer.parseInt(str[0]);  int d = Integer.parseInt(str[1]);  int w = Integer.parseInt(str[2]);  double minTime = 0.; if ( (w >= v)) {minTime = getTimeAfterSign(0,v,l,a); out.format(Locale.US,"%.6f",minTime); return ;} double whenGetSpeedWPath = ((w * w) / (2. * a)); if ( (whenGetSpeedWPath >= d)) { double time = Math.sqrt(((2.0 * d) / a)); minTime = (time + getTimeAfterSign((a * time),v,(l - d),a)); } else { double stopPath = (((v * v) - (w * w)) / (2. * a));  double vMaxPath = ((v * v) / (2. * a)); if ( ((stopPath + vMaxPath) > d)) { double topSpeed = Math.sqrt(((((2. * a) * d) + (w * w)) / 2)); minTime = ((((2. * topSpeed) - w) / a) + getTimeAfterSign(w,v,(l - d),a)); } else { double stopTime = ((v - w) / (a + 0.));  double getMaxTime = (v / (a + 0.));  double maxTime = ((d - (stopPath + vMaxPath)) / v); minTime = (((stopTime + getMaxTime) + maxTime) + getTimeAfterSign(w,v,(l - d),a)); }}out.format(Locale.US,"%.6f",minTime); } double getTimeAfterSign( double startSpeed, double maxSpeed, double path, int a){ double maxSpeedTime = ((maxSpeed - startSpeed) / a);  double maxSpeedPath = ((startSpeed * maxSpeedTime) + (((a * maxSpeedTime) * maxSpeedTime) / 2)); if ( (maxSpeedPath > path)) {return ((-startSpeed + Math.sqrt(((startSpeed * startSpeed) + ((2 * a) * path)))) / a);} else {return (maxSpeedTime + ((path - maxSpeedPath) / maxSpeed));}} }
5	public class Main{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = s.nextInt(); Arrays.sort(a); int min = a[0]; if ( (a[0] == a[(n - 1)])) {System.out.println("NO"); } else {for ( int i = 1;;i++) {if ( (a[i] > min)) {System.out.println(a[i]); break;} }}} }
0	public class LuckyDivision{ public LuckyDivision( Scanner in){ int n ; n = in.nextInt(); if ( (((((((((((((((n % 4) == 0) || ((n % 7) == 0)) || ((n % 44) == 0)) || ((n % 47) == 0)) || ((n % 74) == 0)) || ((n % 77) == 0)) || ((n % 444) == 0)) || ((n % 447) == 0)) || ((n % 474) == 0)) || ((n % 477) == 0)) || ((n % 744) == 0)) || ((n % 747) == 0)) || ((n % 774) == 0)) || ((n % 777) == 0))) System.out.printf("YES%n"); else System.out.printf("NO%n"); } public static void main( String[] args){ new LuckyDivision(new Scanner(System.in)); } }
0	public class luckydivision{ public static int i( String s){ return Integer.parseInt(s);} public static boolean solve( String k, int n){ int temp = i(k); if ( (temp > n)) {return false;} if ( ((n % temp) == 0)) return true; if ( solve((k + "7"),n)) return true; return solve((k + "4"),n);} public static void main( String[] args)throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  int n = i(r.readLine());  boolean i = solve("7",n);  boolean j = solve("4",n); if ( (i || j)) {System.out.println("YES"); } else {System.out.println("NO"); }} }
1	public class A{ BufferedReader in ; StringTokenizer st ; PrintWriter out ; void solve()throws IOException { int n = nextInt();  int k = nextInt();  boolean[] sieve = new boolean[(n + 1)];  List<Integer> primes = new ArrayList<Integer>(); for ( int i = 2;(i <= n);++i) {if ( !sieve[i]) {primes.add(i); for ( int j = (2 * i);(j <= n);j += i) {sieve[j] = true; }} } int count = 0; for ( int i = 0;((i + 1) < primes.size());++i) { int v = ((primes.get(i) + primes.get((i + 1))) + 1); if ( ((v <= n) && !sieve[v])) {++count; } }out.println(((count >= k)?"YES":"NO")); } public void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); eat(""); solve(); out.close(); in.close(); } void eat( String s){ st = new StringTokenizer(s); } String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} eat(line); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { new A().run(); } }
3	public class C{ public static void main( String[] args){ FastScanner in = new FastScanner();  int n = in.nextInt();  double r = in.nextInt();  double x[] = new double[n]; for ( int i = 0;(i < n);i++) x[i] = in.nextDouble(); double y[] = new double[n]; y[0] = r; for ( int i = 1;(i < n);i++) { double miny = r; for ( int j = 0;(j < i);j++) { double dx = Math.abs((x[i] - x[j])); if ( (dx > (r * 2))) continue; double yy = Math.sqrt((((4 * r) * r) - (dx * dx))); miny = Math.max(miny,(yy + y[j])); }y[i] = miny; }for ( int i = 0;(i < n);i++) {System.out.print((y[i] + " ")); }} static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( String s){ try{br = new BufferedReader(new FileReader(s)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } String nextToken(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} double nextDouble(){ return Double.parseDouble(nextToken());} } }
5	public class ProblemA{ private final BufferedReader in ; private final PrintStream out ; private StringTokenizer tok = new StringTokenizer(""); private String nextLine = null; public static void main( String[] args)throws Exception { new ProblemA(); } private ProblemA()throws Exception{ in = new BufferedReader(new InputStreamReader(System.in)); out = System.out; start(); end(); } private int nextInt(){ return Integer.parseInt(nextWord());} private String nextWord(){ if ( tok.hasMoreTokens()) {return tok.nextToken();} else {while(!tok.hasMoreTokens()){try{nextLine = in.readLine(); if ( (nextLine == null)) {return null;} else {tok = new StringTokenizer(nextLine); } }catch (IOException ex){ Logger.getLogger(ProblemA.class.getName()).log(Level.SEVERE,null,ex); } }return tok.nextToken();}} private void start(){ int n = nextInt();  int[] a = new int[n];  boolean allOne = true; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); if ( (a[i] != 1)) {allOne = false; } }Arrays.sort(a); int[] res = new int[n]; res[0] = 1; for ( int i = 1;(i < n);i++) {res[i] = a[(i - 1)]; }if ( allOne) {for ( int i = 0;(i < (n - 1));i++) {out.print((a[i] + " ")); }out.print(2); } else {for ( int i = 0;(i < n);i++) {out.print((res[i] + " ")); }}} private void end(){ out.close(); } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  BSportivnayaMafiya solver = new BSportivnayaMafiya(); solver.solve(1,in,out); out.close(); } static class BSportivnayaMafiya{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.readInt();  int k = in.readInt();  int have = 0; for ( int x = 1;;x++) {have += x; if ( (have < k)) {continue;} if ( ((have - (n - x)) == k)) {out.print((n - x)); return ;} }} } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void close(){ writer.close(); } public void print( int i){ writer.print(i); } } }
5	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] ar = new int[n]; for ( int i = 0;(i < n);i++) ar[i] = in.nextInt(); Arrays.sort(ar); int x1 = ar[(b - 1)];  int x2 = ar[b]; System.out.println((x2 - x1)); } }
1	public class R025A{ int n ; int[] nums ; public R025A(){ Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); nums = new int[n]; for ( int i = 0;(i < n);i++) {nums[i] = scanner.nextInt(); }} private void process(){ int[] c = new int[2];  int[] r = new int[2]; for ( int i = 0;(i < n);i++) {c[(nums[i] % 2)]++; if ( (r[(nums[i] % 2)] == 0)) {r[(nums[i] % 2)] = (i + 1); } }System.out.println(r[((c[0] == 1)?0:1)]); } public static void main( String[] args){ new R025A().process(); } }
0	public class LCM{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(); if ( (n < 3)) {System.out.println(n); } else if ( ((n % 2) != 0)) {System.out.println(((n * (n - 1)) * (n - 2))); } else if ( ((n % 3) == 0)) {System.out.println((((n - 1) * (n - 2)) * (n - 3))); } else {System.out.println(((n * (n - 1)) * (n - 3))); }} }
2	public class prob{ public static long ans( long x, long y, long p){ long r = 1; x = (x % p); while((y > 0)){if ( ((y & 1) == 1)) r = ((r * x) % p); y = (y >> 1); x = ((x * x) % p); }return r;} public static void main( String[] args)throws java.lang.Exception { Scanner scan = new Scanner(System.in);  long x = scan.nextLong();  long k = scan.nextLong();  long v = 1000000007L; if ( (x > 0)) { long p = (((2 * x) - 1) % v);  long a = ans(2L,k,v);  long b = ((p * a) % v); System.out.println(((b + 1) % v)); } else {System.out.println(0); }} }
6	public class E implements Runnable{ public static void main( String[] args){ new Thread(null,new E(),"_cf",(1 << 28)).start(); } int n ,m ; char[] str ; int[][] occs ,cost ; int[] dp ; int oo = (int)1e9; int min( int a, int b){ if ( (a < b)) return a; return b;} class FastScanner{ public int BS = (1 << 16); public char NC = (char)0; byte[] buf = new byte[BS]; int bId = 0,size = 0; char c = NC; double num = 1; BufferedInputStream in ; public FastScanner(){ in = new BufferedInputStream(System.in,BS); } public FastScanner( String s){ try{in = new BufferedInputStream(new FileInputStream(new File(s)),BS); }catch (Exception e){ in = new BufferedInputStream(System.in,BS); } } public char nextChar(){ while((bId == size)){try{size = in.read(buf); }catch (Exception e){ return NC;} if ( (size == -1)) return NC; bId = 0; }return (char)buf[bId++];} public int nextInt(){ return (int)nextLong();} public long nextLong(){ num = 1; boolean neg = false; if ( (c == NC)) c = nextChar(); for ( ;((c < '0') || (c > '9'));c = nextChar()) {if ( (c == '-')) neg = true; } long res = 0; for ( ;((c >= '0') && (c <= '9'));c = nextChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); num *= 10; }return (neg?-res:res);} public String next(){ StringBuilder res = new StringBuilder(); while((c <= 32))c = nextChar(); while((c > 32)){res.append(c); c = nextChar(); }return res.toString();} } }
2	public class digits{ public static void main( String[] args){ long k = new Scanner(System.in).nextLong();  long league = 1;  long irrelevancy = 0; while(true){irrelevancy += (league * (Math.pow(10,league) - Math.pow(10,(league - 1)))); if ( (k > irrelevancy)) league++; else break;}irrelevancy = 0; for ( long i = 1;(i < league);i++) irrelevancy += (i * (Math.pow(10,i) - Math.pow(10,(i - 1)))); long modified_k = (k - irrelevancy);  long number = (((long)Math.pow(10,(league - 1)) - 1) + (modified_k / league)); if ( ((modified_k % league) == 0)) System.out.println((number % 10)); else {number++; long position_of_digit = (long)(modified_k % league); System.out.println(Long.toString(number).charAt(((int)position_of_digit - 1))); }} }
4	public class C{ static HashMap<Integer,ArrayList<Integer>> tree = new HashMap<>(); public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintStream out = System.out;  int t = Integer.parseInt(br.readLine()); for ( int i = 0;(i < t);i++) { int n = Integer.parseInt(br.readLine());  ArrayList<Integer> depth = new ArrayList<>();  int y = 0;  String[] ans = new String[n]; for ( int x = 0;(x < n);x++) { int in = Integer.parseInt(br.readLine()); if ( (in == 1)) {if ( (y == depth.size())) depth.add(1); else depth.set(y,1); y++; StringBuilder curr = new StringBuilder(); curr.append(depth.get(0)); for ( int a = 1;(a < y);a++) {curr.append('.'); curr.append(depth.get(a)); }ans[x] = curr.toString(); continue;} for ( int d = (y - 1);(d >= 0);d--) {if ( (depth.get(d) == (in - 1))) {y = (d + 1); depth.set(d,(depth.get(d) + 1)); StringBuilder curr = new StringBuilder(); for ( int a = 0;(a < d);a++) {curr.append(depth.get(a)); curr.append('.'); }curr.append(in); ans[x] = curr.toString(); break;} }}for ( String x :ans) out.println(x); }System.out.flush(); } }
3	public class d{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int size = in.nextInt();  int[] vals = new int[size];  long[] cum = new long[size]; for ( int i = 0;(i < size);i++) {vals[i] = in.nextInt(); int c = 0; for ( int j = 0;(j < i);j++) if ( (vals[j] > vals[i])) c++; if ( (i != 0)) cum[i] = (cum[(i - 1)] + c); else cum[i] = c; } long tot = cum[(size - 1)];  int q = in.nextInt();  int[] nv = new int[size]; for ( int i = 0;(i < q);i++) { int l = (in.nextInt() - 1);  int r = (in.nextInt() - 1);  int n = (r - l);  long add = (((n * (n + 1)) / 2) - (cum[r] - cum[l])); tot = ((tot - (cum[r] - cum[l])) + add); if ( ((tot % 2) == 0)) System.out.println("even"); else System.out.println("odd"); }} }
0	public class test{ public static void main( String[] args)throws InterruptedException { try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); System.out.println(25); }catch (IOException io){ io.printStackTrace(); } } }
0	public class A{ public static void main( String[] args)throws IOException { InputReader sc = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt(); if ( (n < 3)) out.println(n); else {if ( ((n & 1) == 1)) out.println(lcm(n,lcm((n - 1),(n - 2)))); else out.println(Math.max(lcm((n - 1),lcm((n - 2),(n - 3))),lcm(n,lcm((n - 1),(n - 3))))); }out.flush(); out.close(); } static long gcd( long a, long b){ while((b != 0)){a = (a % b); b ^= a; a ^= b; b ^= a; }return a;} static long lcm( long a, long b){ return ((a / gcd(a,b)) * b);} } class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
0	public class maximus{ static long GCD( long a, long b){ if ( (b == 0)) return a; return GCD(b,(a % b));} public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextInt(); if ( (n <= 2)) {System.out.print(n); return ;} if ( ((n % 2) == 1)) {System.out.print(((n * (n - 1)) * (n - 2))); return ;} if ( (((n % 2) == 0) && (n <= 6))) {System.out.print((((n * (n - 1)) * (n - 2)) / 2)); return ;} long temp = (((n * (n - 1)) * (n - 3)) / GCD(n,(n - 3))); System.out.print(Math.max((((n - 1) * (n - 2)) * (n - 3)),temp)); } }
1	public class Main{ public static void main( String[] args)throws IOException { new Thread(null,new Runnable(){public void run(){ try{try{if ( new File("input.txt").exists()) System.setIn(new FileInputStream("input.txt"));  }catch (SecurityException e){ } new Main().run(); }catch (IOException e){ e.printStackTrace(); } } },"1",(1L << 24)).start(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); int N ; int[] a ; int[] b ; int[] c ; int T ,H ; void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); N = nextInt(); char[] s = nextToken().toCharArray(); a = new int[N]; H = 0; T = 0; for ( int i = 0;(i < s.length);i++) {a[i] = ((s[i] == 'T')?1:0); if ( (s[i] == 'T')) T++; else H++; }if ( ((T == 1) || (H == 1))) {out.println(0); out.close(); return ;} b = Arrays.copyOf(a,a.length); c = Arrays.copyOf(a,a.length); sort(c); int ans = 100000000; for ( int o = 0;(o < N);o++) {for ( int i = 0;(i < N);i++) b[((i + o) % N)] = a[i]; int cur = 0; for ( int i = 0;(i < N);i++) if ( (b[i] != c[i])) cur++; ans = min(ans,(cur / 2)); }out.println(ans); out.close(); } String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
2	public class Solution{ static BufferedReader br ; static int[] ans ; public static void main( String[] args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); ans = new int[8]; int n = Integer.parseInt(br.readLine()); System.out.println((((("?" + "1 1 ") + n) + " ") + n)); System.out.flush(); int q = Integer.parseInt(br.readLine()); cut(n); System.out.print("! "); for ( int i = 0;(i < 8);i++) System.out.print((ans[i] + " ")); System.out.println(); } public static void solve( int x1, int y1, int x2, int y2, int t)throws Exception { int l = x1,r = x2;  int xx1 ,yy1 ,xx2 ,yy2 ; while((l < r)){ int mid = ((l + r) / 2); if ( (query(x1,y1,mid,y2) == 1)) r = mid; else l = (mid + 1); }xx2 = l; l = x1; r = x2; while((r > l)){ int mid = (((l + r) + 1) / 2); if ( (query(mid,y1,x2,y2) == 1)) l = mid; else r = (mid - 1); }xx1 = l; l = y1; r = y2; while((l < r)){ int mid = ((l + r) / 2); if ( (query(x1,y1,x2,mid) == 1)) r = mid; else l = (mid + 1); }yy2 = l; l = y1; r = y2; while((r > l)){ int mid = (((l + r) + 1) / 2); if ( (query(x1,mid,x2,y2) == 1)) l = mid; else r = (mid - 1); }yy1 = l; ans[t] = xx1; ans[(t + 1)] = yy1; ans[(t + 2)] = xx2; ans[(t + 3)] = yy2; } public static void cut( int n)throws Exception { int l = 1,r = n; while((l < r)){ int mid = ((l + r) / 2); if ( (query(1,1,n,mid) == 0)) l = (mid + 1); else r = mid; }if ( ((query(1,1,n,l) == 1) && (query(1,(l + 1),n,n) == 1))) {solve(1,1,n,l,0); solve(1,(l + 1),n,n,4); return ;} l = 1; r = n; while((l < r)){ int mid = ((l + r) / 2); if ( (query(1,1,mid,n) == 0)) l = (mid + 1); else r = mid; }solve(1,1,l,n,0); solve((l + 1),1,n,n,4); } public static int query( int x1, int y1, int x2, int y2)throws Exception { System.out.println(((((((("?" + x1) + " ") + y1) + " ") + x2) + " ") + y2)); System.out.flush(); int q = Integer.parseInt(br.readLine()); return q;} }
0	public class A470{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int start = 4; while(true){if ( ((((start % 2) == 0) || ((start % 3) == 0)) && ((((n - start) % 2) == 0) || (((n - start) % 3) == 0)))) {System.out.println(((start + " ") + (n - start))); return ;} else start++; }} }
4	public class Main{ private static final String NO = "NO"; private static final String YES = "YES"; InputStream is ; PrintWriter out ; String INPUT = ""; private static long MOD = 1000000007; private static final int MAXN = 100000; void solve(){ int T = 1; for ( int i = 0;(i < T);i++) {solve(i); }} static final int N = 405; static long[][] dp = new long[N][N]; static long[] p2 = new long[N]; static long[] fac = new long[N]; static long[] ifac = new long[N]; public static long bino( int n, int k){ return ((((fac[n] * ifac[(n - k)]) % MOD) * ifac[k]) % MOD);} void solve( int T){ int n = ni(); MOD = nl(); fac[0] = 1; ifac[0] = 1; p2[0] = 1; for ( int i = 1;(i <= n);++i) {fac[i] = ((fac[(i - 1)] * i) % MOD); p2[i] = ((p2[(i - 1)] * 2) % MOD); }ifac[n] = power(fac[n],(MOD - 2)); for ( int i = (n - 1);(i > 0);--i) {ifac[i] = ((ifac[(i + 1)] * (i + 1)) % MOD); }dp[0][0] = 1; for ( int i = 0;(i <= n);++i) {for ( int j = 0;(j <= i);++j) {for ( int k = 1;((i + k) <= n);++k) {dp[((i + k) + 1)][(j + k)] = ((dp[((i + k) + 1)][(j + k)] + ((((dp[i][j] * p2[(k - 1)]) % MOD) * bino((k + j),k)) % MOD)) % MOD); }}} long ans = 0; for ( int i = 0;(i <= n);++i) {ans = ((ans + dp[(n + 1)][i]) % MOD); }out.println(ans); } long power( long a, long b){ long x = 1,y = a; while((b > 0)){if ( ((b % 2) != 0)) {x = ((x * y) % MOD); } y = ((y * y) % MOD); b /= 2; }return (x % MOD);} void run()throws Exception { is = (INPUT.isEmpty()?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); if ( !INPUT.isEmpty()) tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new Main().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while((p < n)){if ( !isSpaceChar(b)) buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} private int[][] na( int n, int m){ int[][] a = new int[n][]; for ( int i = 0;(i < n);i++) a[i] = na(m); return a;} private int ni(){ int num = 0,b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private long[] nl( int n){ long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nl(); return a;} private long[][] nl( int n, int m){ long[][] a = new long[n][]; for ( int i = 0;(i < n);i++) a[i] = nl(m); return a;} private long nl(){ long num = 0;  int b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} private static void tr( Object... o){ System.out.println(Arrays.deepToString(o)); } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, InputReader in, PrintWriter out){ long N = in.nextLong();  long K = in.nextLong(); if ( (N == 1)) {out.println(0); return ;} if ( (N <= K)) {out.println(1); return ;} long st = 1;  long dr = (K - 1);  long m ;  long ans = -1; while((st <= dr)){m = ((st + dr) / 2); if ( (get(m,K) <= N)) {ans = m; st = (m + 1); } else dr = (m - 1); }N -= get(ans,K); if ( ((ans == -1) || ((ans == (K - 1)) && (N > 0)))) {out.println(-1); return ;} if ( (N > 0)) ans++; out.println(ans); } private long get( long p, long K){ long sum = (((((K - p) + 1) + K) * p) / 2);  long extra = (p - 1); return (sum - extra);} } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public long nextLong(){ return Long.parseLong(nextString());} public String nextString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuffer res = new StringBuffer(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} }
1	public class B{ InputStream is ; FastWriter out ; String INPUT = ""; void solve(){ for ( int T = ni();(T > 0);T--) go(); } void go(){ int n = ni(); if ( ((n % 2) == 0)) { int u = (int)Math.sqrt((n / 2)); if ( ((u * u) == (n / 2))) {out.println("YES"); return ;} } if ( ((n % 4) == 0)) { int u = (int)Math.sqrt((n / 4)); if ( ((u * u) == (n / 4))) {out.println("YES"); return ;} } out.println("NO"); } void run()throws Exception { is = (oj?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new FastWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new B().run(); } private byte[] inbuf = new byte[1024]; public int lenbuf = 0,ptrbuf = 0; private int readByte(){ if ( (lenbuf == -1)) throw (new InputMismatchException()); if ( (ptrbuf >= lenbuf)) {ptrbuf = 0; try{lenbuf = is.read(inbuf); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return -1; } return inbuf[ptrbuf++];} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} private char[] ns( int n){ char[] buf = new char[n];  int b = skip(),p = 0; while(((p < n) && !isSpaceChar(b))){buf[p++] = (char)b; b = readByte(); }return ((n == p)?buf:Arrays.copyOf(buf,p));} private int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} private int ni(){ return (int)nl();} private long nl(){ long num = 0;  int b ;  boolean minus = false; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(true){if ( ((b >= '0') && (b <= '9'))) {num = ((num * 10) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} public static class FastWriter{ private static final int BUF_SIZE = (1 << 13); private final byte[] buf = new byte[BUF_SIZE]; private final OutputStream out ; private int ptr = 0; private FastWriter(){ out = null; } public FastWriter( OutputStream os){ this.out = os; } public FastWriter( String path){ try{this.out = new FileOutputStream(path); }catch (FileNotFoundException e){ throw (new RuntimeException("FastWriter"));} } public FastWriter write( byte b){ buf[ptr++] = b; if ( (ptr == BUF_SIZE)) innerflush(); return this;} public FastWriter write( char c){ return write((byte)c);} public FastWriter write( char[] s){ for ( char c :s) {buf[ptr++] = (byte)c; if ( (ptr == BUF_SIZE)) innerflush(); }return this;} public FastWriter write( String s){ s.chars().forEach((c)->{buf[ptr++] = (byte)c; if ( (ptr == BUF_SIZE)) innerflush(); }); return this;} private static int countDigits( int l){ if ( (l >= 1000000000)) return 10; if ( (l >= 100000000)) return 9; if ( (l >= 10000000)) return 8; if ( (l >= 1000000)) return 7; if ( (l >= 100000)) return 6; if ( (l >= 10000)) return 5; if ( (l >= 1000)) return 4; if ( (l >= 100)) return 3; if ( (l >= 10)) return 2; return 1;} public FastWriter write( int x){ if ( (x == Integer.MIN_VALUE)) {return write((long)x);} if ( ((ptr + 12) >= BUF_SIZE)) innerflush(); if ( (x < 0)) {write((byte)'-'); x = -x; } int d = countDigits(x); for ( int i = ((ptr + d) - 1);(i >= ptr);i--) {buf[i] = (byte)('0' + (x % 10)); x /= 10; }ptr += d; return this;} private static int countDigits( long l){ if ( (l >= 1000000000000000000L)) return 19; if ( (l >= 100000000000000000L)) return 18; if ( (l >= 10000000000000000L)) return 17; if ( (l >= 1000000000000000L)) return 16; if ( (l >= 100000000000000L)) return 15; if ( (l >= 10000000000000L)) return 14; if ( (l >= 1000000000000L)) return 13; if ( (l >= 100000000000L)) return 12; if ( (l >= 10000000000L)) return 11; if ( (l >= 1000000000L)) return 10; if ( (l >= 100000000L)) return 9; if ( (l >= 10000000L)) return 8; if ( (l >= 1000000L)) return 7; if ( (l >= 100000L)) return 6; if ( (l >= 10000L)) return 5; if ( (l >= 1000L)) return 4; if ( (l >= 100L)) return 3; if ( (l >= 10L)) return 2; return 1;} public FastWriter write( long x){ if ( (x == Long.MIN_VALUE)) {return write(("" + x));} if ( ((ptr + 21) >= BUF_SIZE)) innerflush(); if ( (x < 0)) {write((byte)'-'); x = -x; } int d = countDigits(x); for ( int i = ((ptr + d) - 1);(i >= ptr);i--) {buf[i] = (byte)('0' + (x % 10)); x /= 10; }ptr += d; return this;} public FastWriter write( double x, int precision){ if ( (x < 0)) {write('-'); x = -x; } x += (Math.pow(10,-precision) / 2); write((long)x).write("."); x -= (long)x; for ( int i = 0;(i < precision);i++) {x *= 10; write((char)('0' + (int)x)); x -= (int)x; }return this;} public FastWriter writeln( char c){ return write(c).writeln();} public FastWriter writeln( int x){ return write(x).writeln();} public FastWriter writeln( long x){ return write(x).writeln();} public FastWriter writeln( double x, int precision){ return write(x,precision).writeln();} public FastWriter write( int... xs){ boolean first = true; for ( int x :xs) {if ( !first) write(' '); first = false; write(x); }return this;} public FastWriter write( long... xs){ boolean first = true; for ( long x :xs) {if ( !first) write(' '); first = false; write(x); }return this;} public FastWriter writeln(){ return write((byte)'\n');} public FastWriter writeln( int... xs){ return write(xs).writeln();} public FastWriter writeln( long... xs){ return write(xs).writeln();} public FastWriter writeln( char[] line){ return write(line).writeln();} public FastWriter writeln( char[]... map){ for ( char[] line :map) write(line).writeln(); return this;} public FastWriter writeln( String s){ return write(s).writeln();} private void innerflush(){ try{out.write(buf,0,ptr); ptr = 0; }catch (IOException e){ throw (new RuntimeException("innerflush"));} } public void flush(){ innerflush(); try{out.flush(); }catch (IOException e){ throw (new RuntimeException("flush"));} } public FastWriter print( byte b){ return write(b);} public FastWriter print( char c){ return write(c);} public FastWriter print( char[] s){ return write(s);} public FastWriter print( String s){ return write(s);} public FastWriter print( int x){ return write(x);} public FastWriter print( long x){ return write(x);} public FastWriter print( double x, int precision){ return write(x,precision);} public FastWriter println( char c){ return writeln(c);} public FastWriter println( int x){ return writeln(x);} public FastWriter println( long x){ return writeln(x);} public FastWriter println( double x, int precision){ return writeln(x,precision);} public FastWriter print( int... xs){ return write(xs);} public FastWriter print( long... xs){ return write(xs);} public FastWriter println( int... xs){ return writeln(xs);} public FastWriter println( long... xs){ return writeln(xs);} public FastWriter println( char[] line){ return writeln(line);} public FastWriter println( char[]... map){ return writeln(map);} public FastWriter println( String s){ return writeln(s);} public FastWriter println(){ return writeln();} } private boolean oj = (System.getProperty("ONLINE_JUDGE") != null); private void tr( Object... o){ if ( !oj) System.out.println(Arrays.deepToString(o)); } }
5	public class Main{ static class Run implements Runnable{ final boolean consoleIO = true; final String inFile = "input.txt"; final String outFile = "output.txt"; Pair<Double,Double>[] p ; int n ,t ; int find(){ int count = 2; for ( int i = 0;(i < (n - 1));++i) { double dif = (p[(i + 1)].a - p[i].b);  int comp = Double.compare(dif,t); if ( (comp == 0)) count += 1; else if ( (comp > 0)) count += 2; }return count;} @Override public void run(){ n = nextInt(); t = nextInt(); p = new Pair[n]; for ( int i = 0;(i < n);++i) { int x = (nextInt() + 1000);  int a = nextInt();  double h = (a / (double)2); p[i] = new Pair<Double,Double>((x - h),(x + h)); }Arrays.sort(p,new PComparator()); print(find()); close(); } class PComparator implements Comparator<Pair<Double,Double>>{ @Override public int compare( Pair<Double,Double> o1, Pair<Double,Double> o2){ return Double.compare(o1.a,o2.a);} } BufferedReader in ; PrintWriter out ; StringTokenizer strTok ; Run(){ if ( consoleIO) {initConsoleIO(); } else {initFileIO(); }} void initConsoleIO(){ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); } void initFileIO(){ try{in = new BufferedReader(new FileReader(inFile)); out = new PrintWriter(new FileWriter(outFile)); }catch (FileNotFoundException e){ e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } } void close(){ try{in.close(); out.close(); }catch (IOException e){ e.printStackTrace(); } } int nextInt(){ return Integer.parseInt(nextToken());} boolean hasMoreTokens(){ return ((strTok == null) || strTok.hasMoreTokens());} String nextToken(){ while(((strTok == null) || !strTok.hasMoreTokens())){ String line ; try{line = in.readLine(); strTok = new StringTokenizer(line); }catch (IOException e){ e.printStackTrace(); } }return strTok.nextToken();} void print( Object o){ out.write(o.toString()); } void println( Object o){ out.write((o.toString() + '\n')); } void printf( String format, Object... args){ out.printf(format,args); } } public static void main( String[] args)throws IOException { Run run = new Run();  Thread thread = new Thread(run); thread.run(); } }
1	public class Array224B{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(f.readLine());  int n = Integer.parseInt(st.nextToken());  int k = Integer.parseInt(st.nextToken());  int[] array = new int[n];  int[] visited = new int[100002]; st = new StringTokenizer(f.readLine()); for ( int i = 0;(i < n);i++) {array[i] = Integer.parseInt(st.nextToken()); } int count = 0;  int begin = array[0]; while(((count < n) && (array[count] == begin))){count++; }count--; int kcount = 1; visited[array[count]]++; int bindex = count;  boolean good = true; count++; while((kcount < k)){if ( (count == n)) {System.out.println("-1 -1"); good = false; break;} if ( (visited[array[count]] == 0)) {kcount++; } visited[array[count]]++; count++; }if ( (good && (k != 1))) {for ( int i = bindex;(i < count);i++) {if ( (visited[array[i]] == 1)) {break;} bindex++; visited[array[i]]--; }for ( int i = (count - 1);(i > bindex);i--) {if ( (visited[array[i]] == 1)) {break;} count--; visited[array[i]]--; }} if ( (k == 1)) {System.out.println("1 1"); } else if ( good) {System.out.println((((bindex + 1) + " ") + count)); } } }
2	public class C{ FastScanner in ; PrintWriter out ; boolean systemIO = true; public static void quickSort( int[] a, int from, int to){ if ( ((to - from) <= 1)) {return ;} int i = from;  int j = (to - 1);  int x = a[(from + new Random().nextInt((to - from)))]; while((i <= j)){while((a[i] < x)){i++; }while((a[j] > x)){j--; }if ( (i <= j)) { int t = a[i]; a[i] = a[j]; a[j] = t; i++; j--; } }quickSort(a,from,(j + 1)); quickSort(a,(j + 1),to); } long mod = 1000000007; public long pow( long k){ if ( (k == 0)) {return 1L;} if ( (k == 1)) {return 2L;} if ( ((k % 2) == 1)) {return ((2L * pow((k - 1))) % mod);} long x = pow((k / 2)); return ((x * x) % mod);} public void solve(){ long x = in.nextLong(); if ( (x == 0)) {out.println(0); return ;} x %= mod; long k = in.nextLong();  long pow = pow(k);  long ans = 1; ans = (((ans - pow) + mod) % mod); ans = ((ans + ((((2 * pow) % mod) * x) % mod)) % mod); out.println(ans); } public void run(){ try{if ( systemIO) {in = new FastScanner(System.in); out = new PrintWriter(System.out); } else {in = new FastScanner(new File("input.txt")); out = new PrintWriter(new File("output.txt")); }solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } FastScanner( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} } public static void main( String[] args){ new C().run(); } }
4	public class Main{ static FastScanner fs = new FastScanner(); static class FastScanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String next(){ while(!st.hasMoreElements())try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } return st.nextToken();} int Int(){ return Integer.parseInt(next());} long Long(){ return Long.parseLong(next());} String Str(){ return next();} } public static void main( String[] args)throws java.lang.Exception { PrintWriter out = new PrintWriter(System.out);  int primes[] = new int[]{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999};  int T = Int(); for ( int t = 0;(t < T);t++) { int n = Int();  int k = Int();  int A[] = new int[n]; for ( int i = 0;(i < n);i++) {A[i] = Int(); } Sol sol = new Sol(); sol.solution(out,A,k,primes); }out.flush(); } public static int Int(){ return fs.Int();} public static long Long(){ return fs.Long();} public static String Str(){ return fs.Str();} } class Sol{ int dp[][] ; public void solution( PrintWriter out, int[] A, int K, int[] primes){ int n = A.length;  int id = 0;  int dp[][] = new int[(n + 1)][(K + 1)]; for ( int i = 0;(i < dp.length);i++) {Arrays.fill(dp[i],n); } Map<String,Integer> f = new HashMap<>(); for ( int i = 0;(i < A.length);i++) { String h = hash(A[i],primes); if ( !f.containsKey(h)) {f.put(h,id); A[i] = id; id++; } else {A[i] = f.get(h); }} int dis[][] = new int[A.length][(K + 1)]; for ( int k = 0;(k <= K);k++) { int r = (n - 1);  Map<Integer,Integer> ff = new HashMap<>(); for ( int i = (n - 1);(i >= 0);i--) {put(ff,A[i]); while(((ff.size() + k) < ((r - i) + 1))){remove(ff,A[r]); dis[r][k] = (i + 1); r--; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= K);j++) {if ( (j >= (i + 1))) {dp[i][j] = 1; continue;} for ( int k = 0;(k <= j);k++) { int reach = dis[i][k]; if ( (reach == 0)) dp[i][j] = 1; else dp[i][j] = Math.min(dp[i][j],(1 + dp[(reach - 1)][(j - k)])); }}}out.println(dp[(n - 1)][K]); } public void put( Map<Integer,Integer> f, int key){ if ( !f.containsKey(key)) f.put(key,1); else f.put(key,(f.get(key) + 1)); } public void remove( Map<Integer,Integer> f, int key){ f.put(key,(f.get(key) - 1)); if ( (f.get(key) == 0)) f.remove(key); } public String hash( int n, int[] primes){ StringBuilder str = new StringBuilder("a,"); for ( int i :primes) {if ( ((i * i) > n)) break; int cnt = 0; while(((n % i) == 0)){n /= i; cnt++; }cnt %= 2; if ( (cnt != 0)) str.append((i + ",")); }if ( (n != 1)) str.append((n + ",")); return str.toString();} }