1	public class E_2{ public static void main( String[] args)throws Exception { FastReader in = new FastReader(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt(),k = in.nextInt(),N = ((int)5e6 + 1);  int left = 0,right = 0;  int a[] = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = in.nextInt(); if ( (a[i] == k)) left++; } int f[] = new int[(N + 1)];  int ans = 0; for ( int i = n;(i >= 1);i--) {if ( (a[i] == k)) left--; f[a[i]]++; f[a[i]] = max(f[a[i]],(1 + right)); ans = max(ans,(f[a[i]] + left)); if ( (a[i] == k)) right++; }pw.println(ans); pw.close(); } static class FastReader{ InputStream is ; private byte[] inbuf = new byte[1024]; private int lenbuf = 0,ptrbuf = 0; public FastReader( InputStream is){ this.is = is; } public 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++];} 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 << 3) + (num << 1)) + (b - '0')); } else {return (minus?-num:num);}b = readByte(); }} } }
6	public class MainC{ private FastScanner in ; private PrintWriter out ; private int N ; private Dist[] dists ; private int countDists ; private int[][] minLeft ; private int[] minOrder ; private int minOrderCount = 10000000; public void solve()throws IOException { int xb = in.nextInt();  int yb = in.nextInt(); N = in.nextInt(); int[] x ,y ;  boolean isOdd ; if ( ((N % 2) == 0)) {x = new int[N]; y = new int[N]; isOdd = false; } else {x = new int[(N + 1)]; y = new int[(N + 1)]; isOdd = true; }for ( int i = 0;(i < N);i++) {x[i] = (in.nextInt() - xb); y[i] = (in.nextInt() - yb); }if ( ((N % 2) == 1)) {N++; x[(N - 1)] = 0; y[(N - 1)] = 0; } countDists = ((N * (N - 1)) / 2); dists = new Dist[countDists]; int c = 0;  int commonSum = 0; for ( int i = 0;(i < N);i++) {for ( int j = (i + 1);(j < N);j++) {dists[c] = new Dist(); dists[c].from = i; dists[c].to = j; dists[c].dist = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); dists[c].dist = Math.min(dists[c].dist,((((x[i] * x[i]) + (y[i] * y[i])) + (x[j] * x[j])) + (y[j] * y[j]))); c++; }commonSum += ((x[i] * x[i]) + (y[i] * y[i])); }Arrays.sort(dists); minLeft = new int[countDists][(N + 1)]; for ( int i = 0;(i < countDists);i++) { int sum = 0; for ( int j = 1;(j <= N);j++) {if ( (((i + j) - 1) < countDists)) {sum = (sum + dists[((i + j) - 1)].dist); minLeft[i][j] = sum; } else {minLeft[i][j] = 100000000; }}}order(0,new int[N],0,0); out.println((minOrderCount + commonSum)); for ( int i = 1;(i <= (N / 2));i++) { int first = -1;  int second = -1; for ( int j = 0;(j < N);j++) {if ( (minOrder[j] == i)) {if ( (first == -1)) {first = j; } else {second = j; }} }if ( (isOdd && ((first == (N - 1)) || (second == (N - 1))))) {first++; second++; out.print((("0 " + ((first + second) - N)) + " ")); } else if ( (((((x[first] * x[first]) + (y[first] * y[first])) + (x[second] * x[second])) + (y[second] * y[second])) < (((x[first] - x[second]) * (x[first] - x[second])) + ((y[first] - y[second]) * (y[first] - y[second]))))) {first++; second++; out.print((((("0 " + first) + " 0 ") + second) + " ")); } else {first++; second++; out.print((((("0 " + first) + " ") + second) + " ")); }}out.println("0"); } private void order( int countOrdered, int[] order, int startsFrom, int sum){ if ( (countOrdered == N)) {if ( (sum < minOrderCount)) {minOrder = Arrays.copyOf(order,N); minOrderCount = sum; } return ;} while((startsFrom < countDists)){if ( ((order[dists[startsFrom].from] == 0) && (order[dists[startsFrom].to] == 0))) {if ( ((minLeft[startsFrom][((N - countOrdered) / 2)] + sum) >= minOrderCount)) {break;} order[dists[startsFrom].from] = ((countOrdered / 2) + 1); order[dists[startsFrom].to] = ((countOrdered / 2) + 1); order((countOrdered + 2),order,(startsFrom + 1),(sum + dists[startsFrom].dist)); order[dists[startsFrom].from] = 0; order[dists[startsFrom].to] = 0; } startsFrom++; }} private class Dist implements Comparable<Dist>{ int from ; int to ; int dist ; } public void run(){ try{in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } 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 MainC().run(); } }
0	public class Composite{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); if ( (n == 12)) System.out.println("4 8"); else if ( ((n % 2) == 1)) System.out.println(((n - 9) + " 9")); else System.out.println(((n - 6) + " 6")); } }
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();} } }
1	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 cprime = 0;  int[] prime = new int[1000]; for ( int i = 2;(i < 1001);i++) { boolean f = false; for ( int j = 2;((j * j) <= i);j++) if ( ((i % j) == 0)) {f = true; break;} if ( !f) prime[cprime++] = i; } int n = ni(),k = ni();  int last = 0;  int count = 0; for ( int i = 0;((i < cprime) && (prime[i] <= n));i++) {for ( int j = 0;(j < (cprime - 1));j++) if ( (((prime[j] + prime[(j + 1)]) + 1) == prime[i])) {count++; break;} else if ( (((prime[j] + prime[(j + 1)]) + 1) > prime[i])) break; }if ( (count >= k)) out.print("YES"); else out.print("NO"); out.flush(); } }
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(); } } }
0	public class MAIN{ public static void main( String[] args){ Scanner sn = new Scanner(System.in);  int n ,n1 ,n2 ,n3 ;  int arr[] = {0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170}; n = sn.nextInt(); if ( (n == 2)) {n1 = n2 = 1; n3 = 0; } else if ( (n == 1)) {n3 = n2 = 0; n1 = 1; } else if ( (n == 0)) {n1 = n2 = n3 = 0; } else if ( (n == 3)) {n1 = n2 = n3 = 1; } else { int index = bsearch(arr,0,(arr.length - 1),n); n1 = arr[(index - 1)]; n2 = arr[(index - 3)]; n3 = arr[(index - 4)]; }System.out.println(((((n3 + " ") + n2) + " ") + n1)); } static int bsearch( int[] arr, int l, int h, int n){ if ( (l > h)) return -1; int mid = ((l + h) / 2); if ( (n == arr[mid])) return mid; else if ( (n > arr[mid])) return bsearch(arr,(mid + 1),h,n); else return bsearch(arr,l,(mid - 1),n);} }
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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ double special( int[] loyalties, int[] levels, int playerlevelsum){ int poss = (1 << loyalties.length);  double res = 0; for ( int pos = 0;(pos < poss);pos++) { double occurs = 1;  int happy = 0;  int badlevelssum = 0; for ( int i = 0;(i < loyalties.length);i++) {if ( (((pos >> i) & 1) == 1)) {happy++; occurs *= ((double)loyalties[i] / 100); } else {badlevelssum += levels[i]; occurs *= ((double)(100 - loyalties[i]) / 100); }} double winprob = ((happy <= (levels.length / 2))?((double)playerlevelsum / (playerlevelsum + badlevelssum)):1); res += (occurs * winprob); }return res;} public void solve( int testNumber, InputReader in, OutputWriter out){ int senators = in.readInt();  int sweets = in.readInt();  int playerlevelsum = in.readInt();  int[] levels = new int[senators];  int[] loyalties = new int[senators]; IOUtils.readIntArrays(in,levels,loyalties); ArrayList<ArrayList<Integer>> possibilities = new ArrayList<>(Arrays.asList(new ArrayList<>())); for ( int senator = 0;(senator < senators);senator++) { ArrayList<ArrayList<Integer>> newpossibilities = new ArrayList<>(); for ( ArrayList<Integer> al :possibilities) { int sumsofar = 0; for ( int val :al) sumsofar += val; int minadd = ((senator == (senators - 1))?(sweets - sumsofar):0); for ( int moar = minadd;(moar <= (sweets - sumsofar));moar++) { ArrayList<Integer> copy = new ArrayList<>(al); copy.add(moar); newpossibilities.add(copy); }}possibilities = newpossibilities; } double res = 0; for ( ArrayList<Integer> al :possibilities) { int[] newloyalties = new int[senators]; for ( int i = 0;(i < senators);i++) newloyalties[i] = Math.min(100,(loyalties[i] + (10 * al.get(i)))); double special = special(newloyalties,levels,playerlevelsum);  double tot = special; res = Math.max(res,tot); }out.printLine(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 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 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(); } } }
5	public class A implements Runnable{ String file = "input"; boolean TEST = (System.getProperty("ONLINE_JUDGE") == null); void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); int[] b = a.clone(); qsort(b); int count = 0; for ( int i = 0;(i < a.length);i++) if ( (a[i] != b[i])) count++; if ( ((count == 0) || (count == 2))) out.println("YES"); else out.println("NO"); } void qsort( int[] a){ List<Integer> as = new ArrayList<Integer>(); for ( int x :a) as.add(x); Collections.shuffle(as); int j = 0; for ( int x :as) a[j++] = x; sort(a); } Random rnd = new Random(); void sortInt( int[] a){ sortInt(a,0,(a.length - 1)); } void sortInt( int[] a, int from, int to){ if ( (from >= to)) return ; int i = (from - 1);  int p = (rnd.nextInt(((to - from) + 1)) + from);  int t = a[p]; a[p] = a[to]; a[to] = t; for ( int j = from;(j < to);j++) if ( (a[j] <= a[to])) {i++; t = a[i]; a[i] = a[j]; a[j] = t; } t = a[(i + 1)]; a[(i + 1)] = a[to]; a[to] = t; sortInt(a,(i + 2),to); while(((i >= 0) && (a[i] == a[(i + 1)])))i--; sortInt(a,from,i); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(input.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} BufferedReader input ; PrintWriter out ; StringTokenizer st ; int test ; void init()throws IOException { if ( TEST) input = new BufferedReader(new FileReader((file + ".in"))); else input = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new BufferedOutputStream(System.out)); } public static void main( String[] args)throws IOException { new Thread(null,new A(),"",(1 << 22)).start(); } }
6	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);  TaskE2 solver = new TaskE2(); solver.solve(1,in,out); out.close(); } static class TaskE2{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int numTests = in.nextInt(); for ( int test = 0;(test < numTests);test++) { int n = in.nextInt();  int 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(); }} int[] maxInColumn = new int[m]; for ( int j = 0;(j < m);j++) {for ( int i = 0;(i < n);i++) {maxInColumn[j] = Math.max(maxInColumn[j],a[i][j]); }} Integer[] cols = new Integer[m]; for ( int i = 0;(i < m);i++) {cols[i] = i; }Arrays.sort(cols,(u,v)->(maxInColumn[u] - maxInColumn[v])); if ( (m > n)) { int[][] na = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {na[i][j] = a[i][cols[j]]; }}m = n; a = na; } int[] buf = new int[n];  int[][] sums = new int[m][(1 << n)];  int[] sumsCur = new int[(1 << n)]; for ( int j = 0;(j < m);j++) {for ( int shift = 0;(shift < n);shift++) {for ( int i = 0;(i < n);i++) {buf[i] = a[((i + shift) % n)][j]; }for ( int mask = 0;(mask < (1 << n));mask++) {if ( (mask > 0)) { int k = Integer.numberOfTrailingZeros(mask); sumsCur[mask] = (sumsCur[(mask ^ (1 << k))] + buf[k]); sums[j][mask] = Math.max(sums[j][mask],sumsCur[mask]); } }}} int[] d = new int[(1 << n)];  int[] nd = new int[(1 << n)]; for ( int j = 0;(j < m);j++) {System.arraycopy(d,0,nd,0,d.length); for ( int mask = 0;(mask < (1 << n));mask++) {for ( int submask = mask;(submask > 0);submask = ((submask - 1) & mask)) {nd[mask] = Math.max(nd[mask],(d[(mask ^ submask)] + sums[j][submask])); }} int[] t = d; d = nd; nd = t; } int ans = 0; for ( int x :d) {ans = Math.max(ans,x); }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());} } }
0	public class LCM235A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(); if ( (n == 1)) {System.out.println(1); return ;} if ( (n == 2)) {System.out.println(2); return ;} if ( (n == 3)) {System.out.println(6); return ;} if ( (n == 4)) {System.out.println(12); return ;} if ( ((n % 2) == 1)) {System.out.println(((n * (n - 1)) * (n - 2))); return ;} if ( ((n % 3) == 0)) {System.out.println((((n - 1) * (n - 2)) * (n - 3))); } else {System.out.println(((n * (n - 1)) * (n - 3))); }} }
5	public class Main{ Scanner in ; PrintWriter out ; static class House implements Comparable<House>{ int len ; int pos ; House( Scanner in){ pos = (in.nextInt() * 2); len = (in.nextInt() * 2); } } void solve(){ int n = in.nextInt();  int size = in.nextInt();  House[] h = new House[n]; for ( int i = 0;(i < h.length);i++) {h[i] = new House(in); }Arrays.sort(h); int ans = 2; for ( int i = 0;(i < (h.length - 1));i++) { int next = (i + 1);  int sz = ((h[next].pos - h[i].pos) - ((h[next].len + h[i].len) / 2)); if ( (sz == (size * 2))) {ans++; } else if ( (sz > (size * 2))) {ans += 2; } }out.println(ans); } public void run(){ in = new Scanner(System.in); out = new PrintWriter(System.out); try{solve(); }finally{out.close(); }} public static void main( String[] args){ new Main().run(); } }
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 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)); } }
4	public class C{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(in,out); out.close(); } static class Task{ int M ; public void solve( InputReader in, PrintWriter out){ int n = in.nextInt(); M = in.nextInt(); if ( (n <= 1)) {out.println(n); return ;} int[] pow2 = new int[(n + 1)]; pow2[0] = 1; for ( int i = 1;(i <= n);i++) pow2[i] = mul(2,pow2[(i - 1)]); int[][] Ckn = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {Ckn[i][i] = 1; Ckn[0][i] = 1; for ( int j = (i - 1);(j >= 1);j--) {Ckn[j][i] = add(Ckn[(j - 1)][(i - 1)],Ckn[j][(i - 1)]); }} int ans = 0;  int[][] dp = new int[(n + 1)][(n + 1)]; dp[1][1] = 1; for ( int i = 2;(i <= n);i++) {dp[i][i] = pow2[(i - 1)]; for ( int j = 1;(j <= (i - 1));j++) {for ( int k = 1;(k <= j);k++) {dp[i][j] = add(dp[i][j],mul(mul(pow2[(k - 1)],dp[((i - k) - 1)][(j - k)]),Ckn[k][j])); }}}for ( int i = 0;(i <= n);i++) ans = add(ans,dp[n][i]); out.println(ans); } public int add( int a, int b){ a += b; if ( (a >= M)) a -= M; return a;} public int mul( int a, int b){ long res = ((long)a * (long)b); res %= M; return (int)res;} } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){ String line = null; try{line = br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} if ( (line == null)) {return null;} st = new StringTokenizer(line); }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} } }
6	public class C3{ Scanner in ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int m = ni(); if ( (n < m)) { int d = n; n = m; m = d; } if ( (m == 1)) {out.println((n - ((n + 2) / 3))); return ;} int[][] dp = new int[(n + 1)][(1 << (2 * m))];  int[] fill = new int[(1 << m)];  int mask = ((1 << m) - 1); for ( int i = 0;(i < (1 << m));i++) {fill[i] = ((((i << 1) | i) | (i >> 1)) & mask); }for ( int i = 0;(i < (1 << (2 * m)));i++) { int lower = (i & mask);  int upper = (i >> m); dp[0][i] = (((fill[lower] | upper) == mask)?Integer.bitCount(i):99999); }for ( int i = 1;(i <= (n - 2));i++) {for ( int j = 0;(j < (1 << (2 * m)));j++) { int lower = (j & mask);  int upper = (j >> m);  int min = 99999; for ( int k = 0;(k < (1 << m));k++) {if ( (((upper | fill[lower]) | k) == mask)) {min = Math.min(min,dp[(i - 1)][((lower << m) | k)]); } }dp[i][j] = (min + Integer.bitCount(upper)); }} int gmin = 99999; for ( int i = 0;(i < (1 << (2 * m)));i++) { int lower = (i & mask);  int upper = (i >> m); if ( ((fill[upper] | lower) == mask)) {gmin = Math.min(gmin,dp[(n - 2)][i]); } }out.println(((n * m) - gmin)); } 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 C3().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)); } }
4	public class Main{ public static void main( String[] args)throws Exception { final long mod = (long)(1e9 + 7); final long mod1 = (long)998244353;  Reader s = new Reader();  PrintWriter pt = new PrintWriter(System.out);  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int T = s.nextInt(); while((T-- > 0)){ int n = s.nextInt();  int arr[] = new int[n];  int brr[] = new int[n];  int e = -1; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); if ( (e == -1)) {brr[(e + 1)] = arr[i]; e++; } else {if ( (arr[i] == 1)) {e++; brr[e] = arr[i]; } else { int j = e; for ( j = e;(j >= 0);j--) {if ( ((arr[i] - 1) == brr[j])) break; }e = j; brr[e] = arr[i]; }}pt.print(brr[0]); for ( int j = 1;(j <= e);j++) {pt.print(("." + brr[j])); }pt.println(); }}pt.close(); } static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static void reverse( int[] arr, int start, int end){ int temp ; while((start < end)){temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; }} static void reverse( long[] arr, int start, int end){ long temp ; while((start < end)){temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; }} 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(); }} static int max( int x, int y){ return ((x > y)?x:y);} static long power( long x, long y, long p){ long res = 1; x = (x % p); while((y > 0)){if ( ((y % 2) == 1)) res = ((res * x) % p); y = (y >> 1); x = ((x * x) % p); }return res;} static long modInverse( long n, long p){ return power(n,(p - 2),p);} static String reverse( String str){ return new StringBuffer(str).reverse().toString();} static long fastpow( long x, long y, long m){ if ( (y == 0)) return 1; long p = (fastpow(x,(y / 2),m) % m); p = ((p * p) % m); if ( ((y % 2) == 0)) return p; else return ((x * p) % m);} static void merge( long[] arr, int l, int m, int r){ int n1 = ((m - l) + 1);  int n2 = (r - m);  long L[] = new long[n1];  long R[] = new long[n2]; for ( int i = 0;(i < n1);++i) L[i] = arr[(l + i)]; for ( int j = 0;(j < n2);++j) R[j] = arr[((m + 1) + j)]; int i = 0,j = 0;  int k = l; while(((i < n1) && (j < n2))){if ( (L[i] <= R[j])) {arr[k] = L[i]; i++; } else {arr[k] = R[j]; j++; }k++; }while((i < n1)){arr[k] = L[i]; i++; k++; }while((j < n2)){arr[k] = R[j]; j++; k++; }} static void sort( int[] arr, int l, int r){ if ( (l < r)) { int m = ((l + r) / 2); sort(arr,l,m); sort(arr,(m + 1),r); merge(arr,l,m,r); } } static void merge( int[] arr, int l, int m, int r){ int n1 = ((m - l) + 1);  int n2 = (r - m);  int L[] = new int[n1];  int R[] = new int[n2]; for ( int i = 0;(i < n1);++i) L[i] = arr[(l + i)]; for ( int j = 0;(j < n2);++j) R[j] = arr[((m + 1) + j)]; int i = 0,j = 0;  int k = l; while(((i < n1) && (j < n2))){if ( (L[i] <= R[j])) {arr[k] = L[i]; i++; } else {arr[k] = R[j]; j++; }k++; }while((i < n1)){arr[k] = L[i]; i++; k++; }while((j < n2)){arr[k] = R[j]; j++; k++; }} static void sort( long[] arr, int l, int r){ if ( (l < r)) { int m = ((l + r) / 2); sort(arr,l,m); sort(arr,(m + 1),r); merge(arr,l,m,r); } } 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(); } } }
1	public class _G14{ public static void main( String[] args){ MyScanner sc = new MyScanner();  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int t = sc.nextInt();  Set<Long> square = new HashSet<>(); for ( long i = 1;(i <= (long)1e5);i++) square.add((i * i)); while((t-- > 0)){ long n = sc.nextLong(); if ( ((((n % 2) == 0) && square.contains((n / 2))) || (((n % 4) == 0) && square.contains((n / 4))))) {out.println("YES"); } else {out.println("NO"); }}out.close(); } 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());} long nextLong(){ return Long.parseLong(next());} } }
3	public class D{ static class FastWriter{ private final BufferedWriter bw ; public FastWriter(){ this.bw = new BufferedWriter(new OutputStreamWriter(System.out)); } public void print( Object object)throws IOException { bw.append(("" + object)); } public void println( Object object)throws IOException { print(object); bw.append("\n"); } public void close()throws IOException { bw.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());} String nextLine(){ String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} } public static void main( String[] args)throws IOException { FastReader fr = new FastReader();  FastWriter fw = new FastWriter();  int n = fr.nextInt();  int m = fr.nextInt(); for ( int r = 0;(r < (n / 2));r++) {for ( int c = 0;(c < m);c++) {fw.println((((r + 1) + " ") + (c + 1))); fw.println((((n - r) + " ") + (m - c))); }}if ( ((n % 2) != 0)) { int r = (n / 2); for ( int c = 0;(c < (m / 2));c++) {fw.println((((r + 1) + " ") + (c + 1))); fw.println((((r + 1) + " ") + (m - c))); }if ( ((m % 2) != 0)) fw.println((((r + 1) + " ") + ((m / 2) + 1))); } fw.close(); } }
4	public class CF1515E{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int md = sc.nextInt();  int k = ((n + 1) / 2);  int[][] dp = new int[(k + 1)][(n + 1)]; dp[0][0] = 1; for ( int h = 1;(h <= k);h++) for ( int l = h;(l <= ((n - h) + 1));l++) dp[h][l] = (int)((((dp[h][(l - 1)] * 2L) + dp[(h - 1)][(l - 1)]) * h) % md); int ans = 0; for ( int h = 1;(h <= k);h++) ans = ((ans + dp[h][((n - h) + 1)]) % md); System.out.println(ans); } }
3	public class Problem_A{ public static void main( String[] args){ MyScanner scan = new MyScanner();  int n = scan.nextInt();  int[] elements = new int[n]; for ( int i = 0;(i < n);i++) elements[i] = scan.nextInt(); int x = 0; Arrays.sort(elements); while((n > 0)){x++; int[] temp = new int[n];  int j = 0;  int size = n;  int min = elements[0]; n--; for ( int i = 1;(i < size);i++) {if ( ((elements[i] % min) == 0)) {n--; } else {temp[j++] = elements[i]; }}elements = temp; }out.println(x); out.close(); } 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());} } }
2	public class Main{ public static void main( String[] args)throws IOException { Scanner c = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  long N = (c.nextLong() - 1);  long K = (c.nextLong() - 1);  long tot = ((K * (K + 1)) / 2); if ( (N > tot)) {System.out.println(-1); return ;} long lo = 1;  long hi = K; while(((hi - lo) >= 10)){ long mid = ((hi + lo) / 2);  long sum = ((mid * (mid - 1)) / 2);  long left = ((mid * K) - sum); if ( (left >= N)) hi = (mid + 1); else lo = (mid - 1); }for ( int num = ((int)lo - 1000);(num < (lo + 1000));num++) {if ( (num >= 0)) { long sum = (((long)num * (num - 1)) / 2);  long left = (((long)num * K) - sum); if ( (left >= N)) {System.out.println(num); return ;} } }out.close(); } }
1	public class Round42CC{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = Integer.parseInt(sc.nextLine());  String s = sc.nextLine();  int k = 0; for ( int i = 0;(i < n);i++) {if ( (s.charAt(i) == 'H')) {k++; } }s = (s + s.substring(0,k)); String ss = "";  int max = 0; for ( int i = 0;(i < (s.length() - k));i++) {ss = s.substring(i,(i + k)); int count = 0; for ( int j = 0;(j < ss.length());j++) {if ( (ss.charAt(j) == 'H')) {count++; } }if ( (count > max)) {max = count; } }System.out.println((k - max)); } }
5	public class A{ public static void main( String[] args){ new A().solve(); } public void solve(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  float[] left = new float[n];  float[] right = new float[n]; for ( int i = 0;(i < n);++i) { int c = sc.nextInt();  int w = sc.nextInt(); left[i] = (float)(c - (((float)w * 1.0) / 2)); right[i] = (float)(c + (((float)w * 1.0) / 2)); }for ( int i = 0;(i < n);++i) for ( int j = (i + 1);(j < n);++j) if ( (left[j] < left[i])) { float tmp = left[i]; left[i] = left[j]; left[j] = tmp; tmp = right[i]; right[i] = right[j]; right[j] = tmp; } int res = 2; for ( int i = 1;(i < n);++i) { float dis = (left[i] - right[(i - 1)]); if ( (Math.abs((dis - t)) < 0.000001)) res++; if ( ((dis - t) > 0.000001)) res += 2; }System.out.println(res); } }
1	public class Main{ private PrintWriter out ; private Map<Integer,Integer> map ; private int arr[] ,ans[] ; int n ,a ,b ; class DSU{ private int[] p ,size ; public DSU( int n){ p = new int[n]; size = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = i; size[i] = 1; }} public int find( int i){ if ( (p[i] == i)) {return i;} return p[i] = find(p[i]);} public void union( int a, int b){ a = find(a); b = find(b); if ( (size[a] > size[b])) {p[b] = a; size[a] += size[b]; } else {p[a] = b; size[b] += size[a]; }} } private void solve()throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); StringTokenizer st = new StringTokenizer(in.readLine()); n = Integer.valueOf(st.nextToken()); a = Integer.valueOf(st.nextToken()); b = Integer.valueOf(st.nextToken()); map = new HashMap<Integer,Integer>(n); String line = in.readLine();  StringTokenizer st1 = new StringTokenizer(line); arr = new int[n]; ans = new int[n]; DSU dsu = new DSU(n); for ( int i = 0;(i < n);i++) {arr[i] = Integer.valueOf(st1.nextToken()); map.put(arr[i],i); }in.close(); for ( int i = 0;(i < n);i++) { boolean f = false; if ( (map.get((a - arr[i])) != null)) {f = true; dsu.union(i,map.get((a - arr[i]))); } if ( (map.get((b - arr[i])) != null)) {f = true; dsu.union(i,map.get((b - arr[i]))); } if ( !f) {out.println("NO"); out.flush(); return ;} }for ( int i = 0;(i < n);i++) { int p = dsu.find(i); if ( (map.get((a - arr[i])) == null)) {ans[p] = 1; } else if ( (map.get((b - arr[i])) == null)) {ans[p] = 0; } }for ( int i = 0;(i < n);i++) { int p = dsu.find(i); if ( ((ans[p] == 0) && (map.get((a - arr[i])) == null))) {out.println("NO"); out.flush(); return ;} if ( ((ans[p] == 1) && (map.get((b - arr[i])) == null))) {out.println("NO"); out.flush(); return ;} }out.println("YES"); for ( int i = 0;(i < n);i++) {out.print((ans[dsu.find(i)] + " ")); }out.flush(); out.close(); } public static void main( String[] args)throws Exception { new Main().solve(); } }
2	public class BT{ Scanner in ; PrintWriter out ; String INPUT = ""; int q( int r1, int c1, int r2, int c2){ out.printf("? %d %d %d %d\n",(r1 + 1),(c1 + 1),(r2 + 1),(c2 + 1)); out.flush(); return ni();} void e( int r1, int c1, int r2, int c2, int r3, int c3, int r4, int c4){ out.printf("! %d %d %d %d %d %d %d %d\n",(r1 + 1),(c1 + 1),(r2 + 1),(c2 + 1),(r3 + 1),(c3 + 1),(r4 + 1),(c4 + 1)); out.flush(); } void solve(){ int n = ni();  int cu = -1,cv = -1; { int low = -1,high = (n - 1); while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(0,0,(n - 1),h) >= 2)) {high = h; } else {low = h; }}cu = high; }{ int low = -1,high = (n - 1); while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(0,0,(n - 1),h) >= 1)) {high = h; } else {low = h; }}cv = high; } int du = -1,dv = -1; { int low = 0,high = n; while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(0,h,(n - 1),(n - 1)) >= 2)) {low = h; } else {high = h; }}du = low; }{ int low = 0,high = n; while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(0,h,(n - 1),(n - 1)) >= 1)) {low = h; } else {high = h; }}dv = low; } int eu = -1,ev = -1; { int low = -1,high = (n - 1); while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(0,0,h,(n - 1)) >= 2)) {high = h; } else {low = h; }}eu = high; }{ int low = -1,high = (n - 1); while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(0,0,h,(n - 1)) >= 1)) {high = h; } else {low = h; }}ev = high; } int fu = -1,fv = -1; { int low = 0,high = n; while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(h,0,(n - 1),(n - 1)) >= 2)) {low = h; } else {high = h; }}fu = low; }{ int low = 0,high = n; while(((high - low) > 1)){ int h = ((high + low) >> 1); if ( (q(h,0,(n - 1),(n - 1)) >= 1)) {low = h; } else {high = h; }}fv = low; } int[][][] canc = {{{du,cu},{dv,cv}},{{du,cv},{dv,cu}}};  int[][][] canr = {{{fu,eu},{fv,ev}},{{fu,ev},{fv,eu}}}; for ( int[][] cr :canr) {if ( (cr[0][0] > cr[0][1])) continue; if ( (cr[1][0] > cr[1][1])) continue; for ( int[][] cc :canc) {if ( (cc[0][0] > cc[0][1])) continue; if ( (cc[1][0] > cc[1][1])) continue; for ( int z = 0;(z < 2);z++) {if ( ((q(cr[0][0],cc[(0 ^ z)][0],cr[0][1],cc[(0 ^ z)][1]) == 1) && (q(cr[1][0],cc[(1 ^ z)][0],cr[1][1],cc[(1 ^ z)][1]) == 1))) {e(cr[0][0],cc[(0 ^ z)][0],cr[0][1],cc[(0 ^ z)][1],cr[1][0],cc[(1 ^ z)][0],cr[1][1],cc[(1 ^ z)][1]); return ;} }}}throw (new RuntimeException());} 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 BT().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)); } }
0	public class A{ public static void main( String[] args){ Scanner x = new Scanner(System.in);  int n = x.nextInt(); if ( ((n % 2) == 0)) {System.out.println((((n - 4) + " ") + "4")); } else {System.out.println((((n - 9) + " ") + "9")); }} }
4	@SuppressWarnings("unused") public class Solution{ static long mod = -1; static long[] fact ,invfact ,pow ; static long[][] C ; static long[][] dp ; static final int N = 405; static int n ; public static void main( String[] args)throws IOException { FastScanner fs = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int tt = 1; outer:while((tt-- > 0)){n = fs.nextInt(); mod = fs.nextLong(); dp = new long[N][N]; precompute(); 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] * pow[(k - 1)]) % mod) * C[(j + k)][k]) % mod); dp[((i + k) + 1)][(j + k)] %= mod; }}} long ans = 0; for ( int i = 0;(i <= n);i++) {ans = ((ans + dp[(n + 1)][i]) % mod); }out.println(ans); }out.close(); } static void precompute(){ fact = new long[N]; invfact = new long[N]; C = new long[N][N]; pow = new long[N]; fact[0] = 1; for ( int i = 1;(i <= n);i++) fact[i] = ((fact[(i - 1)] * i) % mod); invfact[n] = inv(fact[n]); for ( int i = (n - 1);(i >= 0);i--) invfact[i] = ((invfact[(i + 1)] * (i + 1)) % mod); pow[0] = 1; for ( int i = 1;(i <= n);i++) pow[i] = ((pow[(i - 1)] * 2) % mod); for ( int i = 1;(i <= n);i++) {for ( int j = 0;(j <= i);j++) {if ( ((j == 0) || (j == i))) C[i][j] = 1; else C[i][j] = ((C[(i - 1)][(j - 1)] + C[(i - 1)][j]) % mod); }}} static long exp( long a, long n){ long res = 1; while((n > 0)){if ( ((n & 1) == 1)) res = ((res * a) % mod); a = ((a * a) % mod); n = (n >> 1); }return res;} static long inv( long n){ return exp(n,(mod - 2));} static final Random random = new Random(); 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();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} } }
1	public class A25{ public void run(){ try{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(in.readLine().trim());  String[] toks = in.readLine().trim().split("[ ]+");  int counter = 0;  boolean even = true;  int e = -1,o = -1;  int ec = 0,oc = 0; for ( int i = 0;(i < toks.length);i++) { int x = Integer.parseInt(toks[i]); if ( ((x % 2) == 0)) {ec++; if ( (e == -1)) {e = (i + 1); } } else {oc++; if ( (o == -1)) {o = (i + 1); } }}if ( (ec == 1)) {System.out.println(e); } else if ( (oc == 1)) {System.out.println(o); } }catch (Exception e){ e.printStackTrace(); } } public static void main( String[] args){ new A25().run(); } }
0	public class d{ double a ,v ,l ,d ,w ; private void solve()throws Exception { a = nextInt(); v = nextInt(); l = nextInt(); d = nextInt(); w = nextInt(); double ans ; if ( (w >= v)) {ans = fromSign(0,l); } else { double tToW = (w / a);  double dToW = (((tToW * tToW) * a) / 2.); if ( (dToW > d)) { double curT = Math.sqrt(((d * 2.) / a)); ans = curT; double curV = (a * curT); ans += fromSign(curV,(l - d)); } else { double tToMax = (v / a);  double dToMax = (((tToMax * tToMax) * a) / 2.);  double tFromMax = ((v - w) / a);  double dFromMax = ((tFromMax * v) - (((tFromMax * tFromMax) * a) / 2.)); if ( ((dToMax + dFromMax) <= d)) {ans = ((tToMax + tFromMax) + (((d - dToMax) - dFromMax) / v)); } else { double lo = w,hi = v; for ( int i = 0;(i < 1000);++i) { double mi = ((lo + hi) / 2.);  double tTo = (mi / a);  double dTo = (((tTo * tTo) * a) / 2.);  double tFrom = ((mi - w) / a);  double dFrom = ((tFrom * mi) - (((tFrom * tFrom) * a) / 2.)); if ( ((dTo + dFrom) <= d)) lo = mi; else hi = mi; }ans = ((lo / a) + ((lo - w) / a)); }ans += fromSign(w,(l - d)); }}out.printf("%.8f",ans); } private double fromSign( double curV, double d){ double tToMax = ((v - curV) / a);  double dToMax = ((tToMax * curV) + (((tToMax * tToMax) * a) / 2.)); if ( (dToMax <= d)) {return (tToMax + ((d - dToMax) / v));} else { double lo = 0,hi = tToMax; for ( int i = 0;(i < 1000);++i) { double mi = ((lo + hi) / 2.);  double curD = ((mi * curV) + (((mi * mi) * a) / 2.)); if ( (curD <= d)) lo = mi; else hi = mi; }return lo;}} public void run(){ try{solve(); }catch (Exception e){ NOO(e); } finally{out.close(); }} PrintWriter out ; BufferedReader in ; StringTokenizer St ; void NOO( Exception e){ e.printStackTrace(); System.exit(1); } int nextInt(){ return Integer.parseInt(nextToken());} String nextToken(){ while(!St.hasMoreTokens()){try{ String line = in.readLine(); St = new StringTokenizer(line); }catch (Exception e){ NOO(e); } }return St.nextToken();} private d( String name){ try{in = new BufferedReader(new FileReader((name + ".in"))); St = new StringTokenizer(""); out = new PrintWriter(new FileWriter((name + ".out"))); }catch (Exception e){ NOO(e); } } private d(){ try{in = new BufferedReader(new InputStreamReader(System.in)); St = new StringTokenizer(""); out = new PrintWriter(System.out); }catch (Exception e){ NOO(e); } } public static void main( String[] args){ Locale.setDefault(Locale.US); new d().run(); } }
0	public class A630{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  String s = sc.nextLine(); System.out.println("25"); } }
5	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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); } int[] b = a.clone(); ArrayUtils.sort(b); int count = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) {++count; } }out.println(((count <= 2)?"YES":"NO")); } } class FastScanner extends BufferedReader{ boolean isEOF ; public FastScanner( InputStream is){ super(new InputStreamReader(is)); } public int read(){ try{ int ret = super.read(); if ( (isEOF && (ret < 0))) {throw (new InputMismatchException());} isEOF = (ret == -1); return ret; }catch (IOException e){ throw (new InputMismatchException());} } static boolean isWhiteSpace( int c){ return ((c >= -1) && (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(!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);} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
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);  int T = in.nextInt(); for ( int cT = 1;(cT <= T);cT++) { Task solver = new Task(); solver.solve(cT,in,out); }out.close(); } static class data{ int val ,col ; data( int _val, int _col){ val = _val; col = _col; } } static class Task{ int[][] a ; int[][] b ; int[][] dp ; int[][] mb ; ArrayList<data> all = new ArrayList<>(); Set<Integer> st = new HashSet<>(); int n ,m ; int cal( int col, int mask){ if ( (col == m)) {if ( (Integer.bitCount(mask) == n)) return 0; return (int)1e9;} int ret = dp[col][mask]; if ( (ret != -1)) return ret; int rmask = (mask ^ ((1 << n) - 1)); for ( int mask2 = rmask;(mask2 > 0);mask2 = (rmask & (mask2 - 1))) { int now = (cal((col + 1),(mask | mask2)) + mb[col][mask2]); ret = Math.max(ret,now); }ret = Math.max(ret,cal((col + 1),mask)); dp[col][mask] = ret; return ret;} void prepMb(){ for ( int col = 0;(col < m);col++) {for ( int mask = 1;(mask < (1 << n));mask++) { int nmask = mask; while(((nmask & 1) == 0))nmask >>= 1; if ( (nmask == mask)) {for ( int shift = 0;(shift < n);shift++) { int sum = 0;  int tmask = mask; while((tmask > 0)){ int i = Integer.numberOfTrailingZeros(tmask); sum += b[((i + shift) % n)][col]; tmask ^= (1 << i); }mb[col][mask] = Math.max(mb[col][mask],sum); }} else {mb[col][mask] = mb[col][nmask]; }}}} void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); a = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[i][j] = in.nextInt(); all.add(new data(a[i][j],j)); }}Collections.sort(all,new Comparator<data>(){}); for ( data it :all) {if ( (st.size() == n)) break; st.add(it.col); }b = new int[n][st.size()]; int rcol = 0; for ( int col :st) {for ( int row = 0;(row < n);row++) b[row][rcol] = a[row][col]; rcol++; }m = st.size(); dp = new int[n][(1 << n)]; mb = new int[m][(1 << n)]; prepMb(); for ( int i = 0;(i < n);i++) Arrays.fill(dp[i],-1); System.out.println(cal(0,0)); } } 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());} } }
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 LCMChallenge{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  long n = Long.parseLong(f.readLine()); if ( ((n == 1) || (n == 2))) System.out.println(n); else if ( ((n % 2) == 1)) System.out.println(((n * (n - 1)) * (n - 2))); else { long prod = (n * (n - 1));  long x = (n - 2); while((((x > 0) && (gcd(n,x) > 1)) || (gcd((n - 1),x) > 1)))x--; prod *= x; if ( ((((n - 1) * (n - 2)) * (n - 3)) > prod)) prod = (((n - 1) * (n - 2)) * (n - 3)); System.out.println(prod); }} public static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} }
2	public class Main{ public static void main( String[] args)throws IOException { FastScanner sc = new FastScanner();  long K = sc.nextLong();  long nums = 9;  int digits = 1; while((K > (nums * digits))){K -= (nums * digits); nums *= 10; digits++; } long removal = ((K - 1) / digits);  int pos = (int)((K - 1) % digits);  long base = (long)Math.pow(10,(digits - 1));  String num = Long.toString((base + removal)); System.out.println(num.charAt(pos)); } 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();} long nextLong(){ return Long.parseLong(next());} } }
4	public class B{ public static void main( String[] args){ FastScanner fs = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int t = fs.nextInt(); for ( int tt = 0;(tt < t);tt++) { int n = fs.nextInt();  int[] arr = fs.readArray(n);  List<String> ans = new ArrayList();  List<Integer> temp = new ArrayList(); temp.add(arr[0]); ans.add(("" + arr[0])); for ( int i = 1;(i < n);i++) { int ch = arr[i]; if ( (ch == 1)) {temp.add(1); StringBuilder sb = new StringBuilder(); for ( int j = 0;(j < temp.size());j++) {sb.append(temp.get(j)); if ( (j != (temp.size() - 1))) {sb.append('.'); } }ans.add(sb.toString()); } else { int j = (temp.size() - 1); while((j >= 0)){if ( ((ch - temp.get(j)) == 1)) {temp.set(j,ch); break;} else {j--; }} int extra = (temp.size() - 1); while((extra > j)){temp.remove((temp.size() - 1)); extra--; } StringBuilder sb = new StringBuilder(); for ( int jj = 0;(jj < temp.size());jj++) {sb.append(temp.get(jj)); if ( (jj != (temp.size() - 1))) {sb.append('.'); } }ans.add(sb.toString()); }}for ( String str :ans) {out.println(str); }}out.close(); } 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());} int[] readArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } public static int[] sort( int[] arr){ List<Integer> temp = new ArrayList(); for ( int i :arr) temp.add(i); Collections.sort(temp); int start = 0; for ( int i :temp) arr[start++] = i; return arr;} }
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{ static private 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;} static private 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;} static private 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)); } }
1	public class A{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int odd = -1;  int even = -1;  int oc = 0;  int ec = 0; for ( int i = 0;(i < n);i++) {if ( ((scan.nextInt() % 2) == 0)) {ec++; even = (i + 1); } else {oc++; odd = (i + 1); }}if ( (ec == 1)) System.out.println(even); else System.out.println(odd); } }
3	public class Tt{ public static void main( String[] args)throws IOException { FastScanner fs = new FastScanner(System.in);  int j = fs.nextInt();  ArrayList<Integer> a = new ArrayList<Integer>(); for ( int i = 0;(i < j);i++) {a.add(fs.nextInt()); }Collections.sort(a); Collections.reverse(a); int c = 0; while((a.size() != 0)){ int f = a.get((a.size() - 1)); c += 1; for ( int q = (a.size() - 1);(q > -1);q--) if ( ((a.get(q) % f) == 0)) {a.remove(q); } }System.out.println(c); } 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());} } }
3	public class Main{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out); IntStream.range(0,1).forEach((tc)->{new Solver(tc,in,out).solve(); out.flush(); }); out.close(); } } class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; InputReader( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); } String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} int nextInt(){ return Integer.valueOf(next());} } class Solver{ private InputReader in ; private PrintWriter out ; private Integer tc ; Solver( Integer tc, InputReader in, PrintWriter out){ this.in = in; this.out = out; this.tc = tc; } void solve(){ Integer n = in.nextInt();  TreeSet<Integer> list = IntStream.range(0,n).map((i)->in.nextInt()).boxed().collect(Collectors.toCollection(TreeSet::new));  Integer answer = 0; while(!list.isEmpty()){ Integer x = list.pollFirst(); list = list.stream().filter((y)->((y % x) != 0)).collect(Collectors.toCollection(TreeSet::new)); answer++; }out.println(answer); } }
5	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){ int n = in.nextInt();  long k = in.nextLong();  long[] a = new long[n]; for ( int i = 0;(i < n);++i) a[i] = in.nextLong(); Arrays.sort(a); boolean[] take = new boolean[n]; Arrays.fill(take,true); int j = 0;  int res = n; for ( int i = 0;(i < n);++i) {while(((j < i) && ((a[j] * k) < a[i])))++j; if ( (((j < i) && take[j]) && ((a[j] * k) == a[i]))) {take[i] = false; --res; } }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 int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} }
2	public class History{ static final int INF = (int)1E9; static final double EPS = 1E-9; static final long MOD = (INF + 9); static long powmod( long p){ long res = 1;  long d = 2; while((p > 0)){if ( ((p % 2) == 1)) {res = ((res * d) % MOD); p--; } else {d = ((d * d) % MOD); p /= 2; }}return (res % MOD);} public static void main( String[] args){ InputReader in = new InputReader(System.in);  long n = in.nextLong();  long m = in.nextLong();  long k = in.nextLong();  long ans = 0;  long t = ((k - 1) * (n - m)); if ( (t <= m)) {n -= (k * (n - m)); long g = (n / k); ans = (((2 * k) * (powmod(g) - 1)) + (n % k)); ans = ((ans + t) % MOD); } else {ans = m; }System.out.println((ans % MOD)); } } 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());} }
1	public class CF_1515_B{ void pre()throws Exception { } void solve( int TC)throws Exception { long N = nl(); if ( ((N % 2) == 1)) {pn("NO"); return ;} N /= 2; boolean yes = ps(N); if ( ((N % 2) == 0)) yes |= ps((N / 2)); pn((yes?"YES":"NO")); } boolean ps( long N){ long T = (long)Math.sqrt(N); while(((T * T) > N))T--; while(((T * T) < N))T++; return ((T * T) == N);} void exit( boolean b){ if ( !b) System.exit(0); } final long IINF = (long)1e17; final int INF = ((int)1e9 + 2); DecimalFormat df = new DecimalFormat("0.00000000000"); double PI = 3.141592653589793238462643383279502884197169399,eps = 1e-8; static boolean multipleTC = true,memory = true,fileIO = false; FastReader in ; PrintWriter out ; void run()throws Exception { long ct = System.currentTimeMillis(); if ( fileIO) {in = new FastReader(""); out = new PrintWriter(""); } else {in = new FastReader(); out = new PrintWriter(System.out); } int T = (multipleTC?ni():1); pre(); for ( int t = 1;(t <= T);t++) solve(t); out.flush(); out.close(); System.err.println((System.currentTimeMillis() - ct)); } public static void main( String[] args)throws Exception { if ( memory) new Thread(null,new Runnable(){public void run(){ try{new CF_1515_B().run(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } },"1",(1 << 28)).start(); else new CF_1515_B().run(); } int find( int[] set, int u){ return set[u] = ((set[u] == u)?u:find(set,set[u]));} 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 bit( long n){ return ((n == 0)?0:(1 + bit((n & (n - 1)))));} void pn( Object... o){ for ( int i = 0;(i < o.length);i++) out.print((o[i] + (((i + 1) < o.length)?" ":"\n"))); } int ni()throws Exception { return Integer.parseInt(in.next());} long nl()throws Exception { 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()throws Exception { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new Exception(e.toString()));} }return st.nextToken();} String nextLine()throws Exception { String str ; try{str = br.readLine(); }catch (IOException e){ throw (new Exception(e.toString()));} return str;} } }
1	public class Q3a{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); in.nextLine(); String s = in.nextLine();  HashMap<Integer,Integer> seen = new HashMap<>(); for ( int i = 0;(i < n);i++) { Character c = s.charAt(i);  int ci = (int)c.charValue(); seen.put(ci,((seen.get(ci) == null)?1:(seen.get(ci) + 1))); } HashMap<Integer,Integer> sub = new HashMap<Integer,Integer>();  int start = 0;  int min = 10000000; for ( int i = 0;(i < n);i++) { Character c = s.charAt(i);  int ci = (int)c.charValue(); sub.put(ci,((sub.get(ci) == null)?1:(sub.get(ci) + 1))); while((sub.size() == seen.size())){min = Math.min(min,((i - start) + 1)); c = s.charAt(start); start++; ci = (int)c.charValue(); if ( (sub.get(ci) == 1)) sub.remove(ci); else sub.put(ci,(sub.get(ci) - 1)); }}System.out.print(min); in.close(); } }
0	public class A275{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a = sc.nextLong();  long b = sc.nextLong(); if ( ((b - a) < 2)) {System.out.println(-1); } else if ( (((b - a) == 2) && ((a % 2) == 1))) {System.out.println(-1); } else if ( (((b - a) == 2) && ((a % 2) == 0))) {System.out.println(((((a + " ") + (a + 1)) + " ") + (a + 2))); } else {if ( ((a % 2) == 0)) {System.out.println(((((a + " ") + (a + 1)) + " ") + (a + 2))); } else {System.out.println((((((a + 1) + " ") + (a + 2)) + " ") + (a + 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{ 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); } }
6	public class e2{ 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();  long start = System.currentTimeMillis(); for ( int q = 1;(q <= t);q++) {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] = max(max[i],mat[j][i]); }pq.add(new Item(i,max[i])); } ArrayList<Item> guys = new ArrayList<Item>(); while((!pq.isEmpty() && (guys.size() < n))){ Item tt = pq.poll(); guys.add(tt); } int[][] cost = new int[guys.size()][(1 << n)]; for ( int i = 0;(i < guys.size());i++) { int g = guys.get(i).a; for ( int s = 0;(s < n);s++) {for ( int j = 0;(j < (1 << n));j++) { int sum = 0; for ( int k = 0;(k < n);k++) {if ( ((j & (1 << k)) > 0)) {sum += mat[((k + s) % n)][g]; } }cost[i][j] = max(cost[i][j],sum); }}} int full = ((1 << n) - 1);  int[][] dp = new int[(guys.size() + 1)][(1 << n)];  int ans = 0; for ( int c = 0;(c < guys.size());c++) {for ( int j = 0;(j < (1 << n));j++) {for ( int i = j;(i < (1 << n));i = ((i + 1) | j)) {dp[(c + 1)][i] = max(dp[(c + 1)][i],(cost[c][j] + dp[c][(i ^ j)])); ans = max(ans,dp[(c + 1)][i]); }}}out.println(ans); }out.flush(); } static int max( int a, int b){ return ((a > b)?a:b);} 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);} } }
1	public class C46{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int number = in.nextInt();  String s = in.next();  int cH = 0;  int n = s.length(); for ( int i = 0;(i < n);i++) if ( (s.charAt(i) == 'H')) cH++;  String ss = ""; for ( int i = 0;(i < cH);i++) ss += "H"; for ( int i = 0;(i < (n - cH));i++) ss += "T"; int res = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int cur = countDifference(ss,s); res = Math.min(res,cur); ss = (ss.substring(1) + ss.charAt(0)); }System.out.println(res); } public static int countDifference( String ss, String s){ int cnt = 0; for ( int i = 0;(i < ss.length());i++) if ( (ss.charAt(i) != s.charAt(i))) cnt++; return (cnt / 2);} }
6	public class Main implements Runnable{ private void solution()throws IOException { int n = in.nextInt();  int m = in.nextInt();  boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = in.nextInt();  int y = in.nextInt(); adj[(x - 1)][(y - 1)] = true; adj[(y - 1)][(x - 1)] = true; }final long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);++i) { int Limit = (1 << (n - i));  int nn = (n - i); for ( int mask = 0;(mask < Limit);++mask) {for ( int j = 0;(j < nn);++j) {dp[mask][j] = 0; }}dp[0][0] = 1; for ( int mask = 0;(mask < Limit);++mask) {for ( int j = 0;(j < nn);++j) {if ( (dp[mask][j] != 0)) { long am = dp[mask][j]; for ( int k = 0;(k < nn);++k) {if ( ((((mask >> k) & 1) == 0) && adj[(j + i)][(k + i)])) {dp[(mask | (1 << k))][k] += am; } }} }if ( (((mask >> 0) & 1) != 0)) {res += dp[mask][0]; } }}out.println(((res - m) / 2)); } private class Scanner{ BufferedReader reader ; 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)); }
0	public class LCM{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong(); if ( (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((((n - 1) * (n - 2)) * (n - 3))); else System.out.println(((n * (n - 1)) * (n - 3))); } }
6	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[] omkar)throws Exception { sc = new MyScanner(); out = new PrintWriter(System.out); int n = sc.nextInt();  int m = sc.nextInt();  int[][] cnt = new int[m][m];  String s = sc.next(); for ( int j = 0;(j < (n - 1));j++) {if ( (s.charAt(j) != s.charAt((j + 1)))) {cnt[(s.charAt(j) - 'a')][(s.charAt((j + 1)) - 'a')]++; cnt[(s.charAt((j + 1)) - 'a')][(s.charAt(j) - 'a')]++; } } int[] st = new int[(m + 1)]; for ( int j = 0;(j <= m);j++) {st[j] = (1 << j); } int[][] arr = new int[m][(1 << m)]; for ( int j = 0;(j < m);j++) {for ( int k = 1;(k < (1 << m));k++) { int z = Integer.lowestOneBit(k);  int count = 0; while(((z != 0) && ((z % 2) == 0))){z /= 2; count++; }arr[j][k] = (arr[j][(k ^ Integer.lowestOneBit(k))] + cnt[j][count]); }} int[] dp = new int[(1 << m)]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; for ( int j = 1;(j < st[m]);j++) {for ( int k = 0;(k < m);k++) { int y = st[k]; if ( ((y & j) != 0)) { int sum = ((2 * arr[k][j]) - arr[k][((1 << m) - 1)]); dp[j] = Math.min(dp[j],(dp[(y ^ j)] + (sum * Integer.bitCount(j)))); } }}out.println(dp[((1 << m) - 1)]); out.close(); } public static void sort( int[] array){ ArrayList<Integer> copy = new ArrayList<Integer>(); 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());} } }
1	public class CF364C{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  int n = Integer.parseInt(br.readLine());  String input = br.readLine();  Set<Character> set = new HashSet<Character>(); for ( int i = 0;(i < input.length());i++) {set.add(input.charAt(i)); } StringBuilder sb = new StringBuilder(); for ( char x :set) {sb.append(x); } String substring1 = sb.toString(); System.out.println(solve(input,substring1).length()); pw.close(); br.close(); } public static String solve( String S, String T){ HashMap<Character,Integer> D = new HashMap<>();  HashMap<Character,Integer> GET = new HashMap<>();  int B ,E ; for ( int i = 0;(i < T.length());i++) { char c = T.charAt(i); if ( !D.containsKey(c)) {D.put(c,1); } else {D.put(c,(D.get(c) + 1)); }} int ccc = 0; B = 0; E = 0; int min = Integer.MAX_VALUE;  String RESULT = ""; while((E < S.length())){ char c = S.charAt(E); if ( D.containsKey(c)) {if ( GET.containsKey(c)) {if ( (GET.get(c) < D.get(c))) ccc++; GET.put(c,(GET.get(c) + 1)); } else {GET.put(c,1); ccc++; }} if ( (ccc == T.length())) { char test = S.charAt(B); while((!GET.containsKey(test) || (GET.get(test) > D.get(test)))){if ( (GET.containsKey(test) && (GET.get(test) > D.get(test)))) GET.put(test,(GET.get(test) - 1)); B++; test = S.charAt(B); }if ( (((E - B) + 1) < min)) {RESULT = S.substring(B,(E + 1)); min = ((E - B) + 1); } } E++; }return RESULT;} }
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 EhabAndAComponentChoosingProblem{ long INF = (long)1e18; int n ; int[] a ; int[][] G ; void solve(){ n = in.nextInt(); a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); int[] fr = new int[(n - 1)],to = new int[(n - 1)]; for ( int i = 0;(i < (n - 1));i++) {fr[i] = (in.nextInt() - 1); to[i] = (in.nextInt() - 1); }G = build_graph(n,fr,to); int[][] ret = bfs(G,0);  int[] par = ret[0],ord = ret[2];  long best = -INF;  long[] dp = new long[n]; for ( int i = (n - 1);(i >= 0);i--) { int u = ord[i]; dp[u] = a[u]; for ( int v :G[u]) {if ( (v != par[u])) {if ( (dp[v] > 0)) dp[u] += dp[v]; } }best = Math.max(best,dp[u]); } int k = 0; for ( int i = (n - 1);(i >= 0);i--) { int u = ord[i]; dp[u] = a[u]; for ( int v :G[u]) {if ( (v != par[u])) {if ( (dp[v] > 0)) dp[u] += dp[v]; } }if ( (dp[u] == best)) {dp[u] = -INF; k++; } }out.printf("%d %d%n",(best * k),k); } int[][] bfs( int[][] G, int root){ int n = G.length;  int[] par = new int[n]; Arrays.fill(par,-1); int[] dep = new int[n]; dep[root] = 0; int[] qu = new int[n]; qu[0] = root; for ( int l = 0,r = 1;(l < r);l++) { int u = qu[l]; for ( int v :G[u]) {if ( (v != par[u])) {qu[r++] = v; par[v] = u; dep[v] = (dep[u] + 1); } }}return new int[][]{par,dep,qu};} int[][] build_graph( int n, int[] from, int[] to){ int[][] G = new int[n][];  int[] cnt = new int[n]; for ( int i = 0;(i < from.length);i++) {cnt[from[i]]++; cnt[to[i]]++; }for ( int i = 0;(i < n);i++) G[i] = new int[cnt[i]]; for ( int i = 0;(i < from.length);i++) {G[from[i]][--cnt[from[i]]] = to[i]; G[to[i]][--cnt[to[i]]] = from[i]; }return G;} public static void main( String[] args){ in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); new EhabAndAComponentChoosingProblem().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());} } }
1	public class A{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int N = s.nextInt();  int K = s.nextInt();  int[] primes = getPrimesFast(N);  Set<Integer> ints = new HashSet<Integer>(); for ( int i = 0;(i < primes.length);i++) {ints.add(primes[i]); }for ( int i = 1;(i < primes.length);i++) {ints.remove(((primes[i] + primes[(i - 1)]) + 1)); } boolean res = ((primes.length - ints.size()) >= K); System.out.print((res?"YES":"NO")); } public static int[] getPrimesFast( int n){ if ( (n <= 1)) {return new int[0];} boolean[] b = new boolean[(n + 1)];  int m = (n - 1); for ( int i = 2;((i * i) <= n);i++) {if ( !b[i]) {for ( int j = (i + i);(j <= n);j += i) {if ( !b[j]) {m--; b[j] = true; } }} } int[] primes = new int[m];  int j = 0; for ( int i = 2;(i <= n);i++) {if ( !b[i]) {primes[j++] = i; } }return primes;} }
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{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt(),k = in.nextInt();  int a[] = new int[n];  int i ; for ( i = 0;(i < n);i++) a[i] = in.nextInt(); HashSet<Integer> hs = new HashSet<Integer>();  boolean status = false;  int index = -1; for ( i = 0;(i < n);i++) {hs.add(a[i]); if ( (hs.size() == k)) {index = i; status = true; break;} }if ( !status) {out.println(((-1 + " ") + -1)); return ;} HashSet<Integer> hash = new HashSet<Integer>(); for ( i = index;(i >= 0);i--) {hash.add(a[i]); if ( (hash.size() == k)) {break;} }out.println((((i + 1) + " ") + (index + 1))); } } 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());} }
3	public class C extends PrintWriter{ void run(){ int n = nextInt();  int r = nextInt();  int[] x = nextArray(n);  double[] y = new double[n]; Arrays.fill(y,r); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) { int dx = abs((x[i] - x[j]));  int sdy = (((4 * r) * r) - (dx * dx)); if ( (sdy >= 0)) { double dy = sqrt(sdy); y[i] = max(y[i],(y[j] + dy)); } }}for ( double v :y) {printf(Locale.ENGLISH,"%.10f ",v); }} String next(){ while(!tokenizer.hasMoreTokens())tokenizer = new StringTokenizer(nextLine()); return tokenizer.nextToken();} boolean hasNext(){ while(!tokenizer.hasMoreTokens()){ String line = nextLine(); if ( (line == null)) {return false;} tokenizer = new StringTokenizer(line); }return true;} int[] nextArray( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = nextInt(); }return array;} int nextInt(){ return Integer.parseInt(next());} String nextLine(){ try{return reader.readLine(); }catch (IOException err){ return null;} } public C( OutputStream outputStream){ super(outputStream); } static BufferedReader reader ; static StringTokenizer tokenizer = new StringTokenizer(""); static Random rnd = new Random(); static boolean OJ ; public static void main( String[] args)throws IOException { OJ = (System.getProperty("ONLINE_JUDGE") != null); C solution = new C(System.out); if ( OJ) {reader = new BufferedReader(new InputStreamReader(System.in)); solution.run(); } else {reader = new BufferedReader(new FileReader(new File((C.class.getName() + ".txt")))); long timeout = System.currentTimeMillis(); while(solution.hasNext()){solution.run(); solution.println(); solution.println("----------------------------------"); }solution.println(("time: " + (System.currentTimeMillis() - timeout))); }solution.close(); reader.close(); } }
2	public class ReallyBigNumbers817c{ static long sd( String s){ long c = 0; for ( int i = 0;(i < s.length());i++) {c += s.charAt(i); }return (c - (s.length() * 0x30));} public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(in.readLine());  long n = Long.parseLong(st.nextToken());  long s = Long.parseLong(st.nextToken());  long i = (((s / 10) + 1) * 10); if ( ((n < 10) || ((n - sd((n + ""))) < s))) {System.out.println(0); return ;} while(((i - sd(("" + i))) >= s)){i += 10; }System.out.println(((n - i) + 1)); } }
4	public class Solution{ static int[] dx = {1,-1,0,0}; static int[] dy = {0,0,1,-1}; static Queue<Pair> q ; static boolean[][] visited ; static Pair result = new Pair(0,0); static int n ,m ,k ; public static void main( String[] args){ try(BufferedReader in=new BufferedReader(new FileReader("input.txt"));BufferedWriter out=new BufferedWriter(new FileWriter("output.txt"))){ StringTokenizer s = new StringTokenizer(in.readLine()); n = Integer.parseInt(s.nextToken()); m = Integer.parseInt(s.nextToken()); k = Integer.parseInt(in.readLine()); visited = new boolean[n][m]; q = new LinkedList<>(); s = new StringTokenizer(in.readLine()); for ( int i = 0;(i < k);i++) { int x = Integer.parseInt(s.nextToken());  int y = Integer.parseInt(s.nextToken()); q.add(new Pair(--x,--y)); }bfs(); String ans = ((("" + (result.x + 1)) + " ") + (result.y + 1)); out.write(ans); }catch (IOException e){ } } static void bfs(){ while(!q.isEmpty()){ Pair temp = q.poll(); if ( visited[temp.x][temp.y]) continue; visited[temp.x][temp.y] = true; result.x = temp.x; result.y = temp.y; for ( int i = 0;(i < 4);i++) { int x = (temp.x + dx[i]);  int y = (temp.y + dy[i]); if ( (((((x >= 0) && (x < n)) && (y >= 0)) && (y < m)) && !visited[x][y])) q.add(new Pair(x,y)); }}} } class Pair{ int x ,y ; public Pair( int x, int y){ this.x = x; this.y = y; } }
1	public class Main{ static int n = 5; static int[] arr = new int[5]; 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(); }for ( int i = 0;(i < n);i++) {if ( (arr[i] >= 0)) {arr[i] = (-arr[i] - 1); } }if ( ((n % 2) != 0)) { int min = 0; for ( int i = 1;(i < n);i++) {if ( (arr[i] < arr[min])) min = i; }arr[min] = (-arr[min] - 1); } for ( int x :arr) {System.out.print((x + " ")); }} }
2	public class CodeForces{ static boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); private final long MOD = 1000000009; long power( long a, long b){ long res = 1; while((b > 0)){if ( ((b & 1) == 1)) {res *= a; if ( (res >= MOD)) res %= MOD; } a *= a; if ( (a >= MOD)) a %= MOD; b >>= 1; }return res;} void runCase( int caseNum)throws IOException { long n = nextLong();  long m = nextLong();  long k = nextLong(); if ( ((n - m) >= (n / k))) {System.out.println(m); return ;} long res = 0;  long rem = ((k - 1) * (n - m)); m -= rem; long bound = (m / k); res = (((power(2,(bound + 1)) + MOD) - 2) % MOD); res *= k; res %= MOD; res += rem; res += (m % k); res %= MOD; System.out.println(res); } public static void main( String[] args)throws IOException { if ( ONLINE_JUDGE) {System.out.println(); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(System.out); }new CodeForces().runIt(); out.flush(); out.close(); return ;} static BufferedReader in ; private StringTokenizer st ; static PrintWriter out ; static int pos ; static String curInput = ""; String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} st = new StringTokenizer(line); }return st.nextToken();} long nextLong()throws IOException { return Long.parseLong(next());} void runIt()throws IOException { st = new StringTokenizer(""); runCase(0); out.flush(); } }
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){ String[] response = {"even","odd"};  int n = in.nextInt();  int[] arr = in.nextIntArray(0,n);  int swaps = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (arr[i] > arr[j])) swaps = ((swaps + 1) % 2); }} int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int l = in.nextInt(),r = in.nextInt(),combinaisons = (((r - l) * ((r - l) + 1)) / 2); if ( ((combinaisons % 2) == 1)) {swaps ^= 1; } out.println(response[swaps]); }} } static class InputReader{ private StringTokenizer tokenizer ; private BufferedReader reader ; public InputReader( InputStream inputStream){ reader = new BufferedReader(new InputStreamReader(inputStream)); } private void fillTokenizer(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} } } public String next(){ fillTokenizer(); return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public int[] nextIntArray( int offset, int length){ int[] arr = new int[(offset + length)]; for ( int i = offset;(i < (offset + length));i++) {arr[i] = nextInt(); }return arr;} } }
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;} }
2	public class C{ public static void main( String[] args)throws InterruptedException { FastScanner scan = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  long n = scan.nextLong(),s = scan.nextLong();  long lo = 1,hi = (n + 1); for ( int bs = 0;(bs < 100);bs++) { long mid = ((lo + hi) >> 1);  long mid2 = mid;  long c = 0; while((mid > 0)){c += (mid % 10); mid /= 10; }if ( ((mid2 - c) < s)) lo = mid2; else hi = mid2; }out.println((n - lo)); out.close(); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ try{br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } public String next(){ if ( st.hasMoreTokens()) return st.nextToken(); try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public double nextDouble(){ return Double.parseDouble(next());} } }
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]); } }
0	public class D5{ static int a ,v ,l ,d ; static double w ; static double afterMark( int s, double w){ if ( (((2 * s) * a) > ((v * v) - (w * w)))) {return ((((v - w) * 1.0) / a) + ((s - ((((v * v) - (w * w)) * 1.0) / (2 * a))) / v));} else { double megav = Math.sqrt(((((2 * a) * s) + (w * w)) * 1.0)); return ((megav - w) / a);}} public static void main( String[] args)throws IOException { boolean online = (System.getProperty("ONLINE_JUDGE") != null);  Scanner in = (online?new Scanner(System.in):new Scanner(new FileReader("input.txt")));  PrintWriter out = (online?new PrintWriter(System.out):new PrintWriter(new FileWriter("output.txt"))); a = in.nextInt(); v = in.nextInt(); l = in.nextInt(); d = in.nextInt(); w = (double)in.nextInt(); double t ,t1 ,t2 ; if ( (v > w)) {if ( (((2 * d) * a) > (((2 * v) * v) - (w * w)))) {t1 = (((((2 * v) - w) * 1.0) / a) + ((d - (((((2 * v) * v) - (w * w)) * 1.0) / (2 * a))) / v)); } else if ( (((2 * d) * a) > (w * w))) { double topv = Math.sqrt(((d * a) + (((w * w) * 1.0) / 2))); t1 = ((((2 * topv) - w) * 1.0) / a); } else {t1 = Math.sqrt((((2 * d) * 1.0) / a)); w = Math.sqrt((((2 * a) * d) * 1.0)); }t2 = afterMark((l - d),w); t = (t1 + t2); } else {t = afterMark(l,0.0); }out.println(t); out.flush(); return ;} }
1	public class Main{ static Scanner sc = new Scanner(System.in); public static void main( String[] args){ int n = sc.nextInt();  int k = sc.nextInt();  char str[][] = new char[5][n]; for ( int i = 0;(i < 4);i++) {for ( int j = 0;(j < n);j++) str[i][j] = '.'; }if ( ((k % 2) == 0)) {k /= 2; for ( int i = 1;(i <= 2);i++) {for ( int j = 1;(j <= k);j++) str[i][j] = '#'; }} else {str[1][(n / 2)] = '#'; if ( (k != 1)) { int tmp = (n / 2); if ( (k <= (n - 2))) {for ( int i = 1;(i <= ((k - 1) / 2));i++) {str[1][i] = '#'; str[1][((n - 1) - i)] = '#'; }} else {for ( int i = 1;(i <= (n - 2));i++) str[1][i] = '#'; k -= (n - 2); for ( int i = 1;(i <= (k / 2));i++) {str[2][i] = '#'; str[2][((n - 1) - i)] = '#'; }}} }System.out.println("YES"); for ( int i = 0;(i < 4);i++) {System.out.println(str[i]); }} }
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());} } }
2	public class Main{ static int inf = (int)1e9; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); int n = nextInt();  int k = nextInt();  long l = -1;  long r = 100000; while((l != (r - 1))){ long mid = ((l + r) / 2); if ( ((((mid * (mid + 1)) / 2) - (n - mid)) > k)) r = mid; else l = mid; }pw.println((n - l)); pw.close(); } static BufferedReader br ; static StringTokenizer st = new StringTokenizer(""); static PrintWriter pw ; static String next()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(br.readLine()); return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(next());} }
6	public class A558{ static BufferedReader in = null; static PrintWriter out = null; static StringTokenizer st = new StringTokenizer(""); public static void main( String[] args){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); } } public static String readString(){ while(!st.hasMoreTokens()){try{st = new StringTokenizer(in.readLine()," \n\r\t:"); }catch (Exception e){ e.printStackTrace(); } }return st.nextToken();} public static int readInt(){ return Integer.parseInt(readString());} static private int MAX_VALUE = (Integer.MAX_VALUE - 10000000); static private int[] dp ; static private int[] parents ; static private int[] powers ; static private int[] x ; static private int[] y ; static private int[][] dist ; static private int[] distFrom0 ; static private void solve()throws IOException { int x0 = readInt();  int y0 = readInt();  int n = readInt();  long time = System.currentTimeMillis(); x = new int[n]; y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = (readInt() - x0); y[i] = (readInt() - y0); }dist = new int[n][n]; distFrom0 = new int[n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {dist[i][j] = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); }}for ( int i = 0;(i < n);i++) {distFrom0[i] = ((x[i] * x[i]) + (y[i] * y[i])); }powers = new int[(n + 1)]; powers[0] = 1; for ( int i = 1;(i < (n + 1));i++) {powers[i] = (powers[(i - 1)] * 2); } int maxMask = (1 << n); dp = new int[maxMask]; parents = new int[maxMask]; Arrays.fill(dp,MAX_VALUE); dp[0] = 0; for ( int i = 0;(i < maxMask);i++) {if ( (dp[i] != MAX_VALUE)) { int curMask = i;  int notUsed = 0; for ( int j = 0;(j < n);j++) {if ( ((curMask & powers[j]) == 0)) {notUsed = j; break;} } int mask = (curMask | powers[notUsed]); for ( int j = notUsed;(j < n);j++) {if ( (((powers[j] & curMask) == 0) || (j == notUsed))) { int nextMask = (mask | powers[j]);  int minDist = (((dp[curMask] + distFrom0[notUsed]) + dist[notUsed][j]) + distFrom0[j]); if ( (dp[nextMask] > minDist)) {dp[nextMask] = minDist; parents[nextMask] = curMask; } } }} }maxMask--; out.println(dp[maxMask]); while((maxMask != 0)){out.print("0 "); int[] diffBits = getBits(n,maxMask,parents[maxMask]); for ( int i = 1;(i <= diffBits[0]);i++) {out.print(((diffBits[i] + 1) + " ")); }maxMask = parents[maxMask]; }out.print(0); } static private boolean hasBit( int x, int index){ return ((powers[index] & x) != 0);} static private int setBit( int x, int index){ return (x | powers[index]);} static private int getDist( int xFrom, int yFrom, int xTo, int yTo){ return (((xTo - xFrom) * (xTo - xFrom)) + ((yTo - yFrom) * (yTo - yFrom)));} static private int[] getBits( int n, int nextMask, int curMask){ int[] res = new int[3]; for ( int i = 0;(i < n);i++) {if ( (hasBit(nextMask,i) ^ hasBit(curMask,i))) {res[++res[0]] = i; } }return res;} static private void brute( int n, int mask){ List<Integer> listNotTaken = new ArrayList<>(); for ( int i = 0;(i < n);i++) {if ( !hasBit(mask,i)) {listNotTaken.add(i); } }for ( int first :listNotTaken) { int temp = setBit(mask,first); for ( int second :listNotTaken) { int nextMask = setBit(temp,second);  int minDist = (((dp[mask] + getDist(0,0,x[first],y[first])) + getDist(x[first],y[first],x[second],y[second])) + getDist(x[second],y[second],0,0)); if ( (dp[nextMask] > minDist)) {dp[nextMask] = minDist; parents[nextMask] = mask; brute(n,nextMask); } }}} }
2	public class cf337c{ static long mod ,n ,m ,k ; public static void main( String[] args){ FastIO in = new FastIO(),out = in; n = in.nextLong(); m = in.nextLong(); k = in.nextLong(); mod = ((long)1e9 + 9); long x = ((m - (((n - (n % k)) / k) * (k - 1))) - (n % k)); if ( (x < 0)) x = 0;  long ans = ((((pow(2,(x + 1)) - 2) * k) + m) - (x * k)); ans = (((ans % mod) + mod) % mod); out.println(ans); out.close(); } static long pow( long x, long p){ if ( (p == 0)) return (1 % mod); long ans = pow(x,(p / 2)); ans = ((ans * ans) % mod); if ( ((p % 2) == 1)) ans = ((ans * x) % mod); return ans;} static class FastIO extends PrintWriter{ BufferedReader br ; StringTokenizer st ; public FastIO(){ this(System.in,System.out); } public FastIO( InputStream in, OutputStream out){ super(new BufferedWriter(new OutputStreamWriter(out))); br = new BufferedReader(new InputStreamReader(in)); scanLine(); } public void scanLine(){ try{st = new StringTokenizer(br.readLine().trim()); }catch (Exception e){ throw (new RuntimeException(e.getMessage()));} } public int numTokens(){ if ( !st.hasMoreTokens()) {scanLine(); return numTokens();} return st.countTokens();} public String next(){ if ( !st.hasMoreTokens()) {scanLine(); return next();} return st.nextToken();} public long nextLong(){ return Long.parseLong(next());} } }
1	public class SequenceTransformation{ void solve(){ int p = 1,n = in.nextInt(); while((n > 0)){if ( (n == 1)) {out.print((p + " ")); break;} if ( (n == 2)) {out.print((p + " ")); out.print(((2 * p) + " ")); break;} if ( (n == 3)) {out.print((p + " ")); out.print((p + " ")); out.print(((3 * p) + " ")); break;} for ( int i = 0;(i < ((n + 1) / 2));i++) {out.print((p + " ")); }p *= 2; n /= 2; }} public static void main( String[] args){ in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); new SequenceTransformation().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());} } }
1	public class Main{ static private void solve( InputReader in, OutputWriter out){ int n = in.nextInt(); if ( (n < 6)) {out.println(-1); } else { int m = (n - 2); for ( int i = 2;(i <= m);i++) {out.println(("1 " + i)); }out.println(((m + " ") + (m + 1))); out.println(((m + " ") + (m + 2))); }for ( int i = 2;(i <= n);i++) {out.println(("1 " + i)); }} 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(); } static private 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(); } } } static private 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(); } } } }
1	public class LectureSleep{ static class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } 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 InputReader r = new InputReader(System.in); static PrintWriter pw = new PrintWriter(System.out); public static void main( String[] args){ int n = r.nextInt();  int k = r.nextInt();  int[] theorems = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {theorems[i] = r.nextInt(); } int[] mishka = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {mishka[i] = r.nextInt(); } int[] sums = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {if ( (mishka[i] == 0)) {sums[i] = (sums[(i - 1)] + theorems[i]); } else {sums[i] = sums[(i - 1)]; }} int max = 0; for ( int i = 1;(i <= ((n - k) + 1));i++) { int sum = (sums[((i + k) - 1)] - sums[(i - 1)]); max = Math.max(max,sum); } int totalSum = 0; for ( int i = 1;(i <= n);i++) {if ( (mishka[i] == 1)) {totalSum += theorems[i]; } }pw.println((totalSum + max)); pw.close(); } }
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 place = (in.readInt() - 1); final int[] points = new int[count]; final int[] time = new int[count]; IOUtils.readIntArrays(in,points,time); Comparator<Integer> comparator = new Comparator<Integer>(){public int compare( Integer o1, Integer o2){ if ( (points[o1] != points[o2])) return (points[o2] - points[o1]); return (time[o1] - time[o2]);} };  Integer[] order = ArrayUtils.order(count,comparator);  int answer = 0; for ( int i = 0;(i < count);i++) {if ( (comparator.compare(order[place],order[i]) == 0)) answer++; }out.printLine(answer); } } 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 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 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 A{ public static void main( String[] args)throws FileNotFoundException { Scanner s = new Scanner(System.in);  int T = s.nextInt(); System.out.println(("0 0 " + T)); } }
2	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } StreamTokenizer in ; PrintWriter out ; int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} static int nn ; void run()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } static long MOD = 1000000009; static long modPow( long a, int pow){ long res = 1; while((pow > 0)){if ( ((pow & 1) != 0)) {res = ((res * a) % MOD); } pow >>= 1; a = ((a * a) % MOD); }return res;} void solve()throws IOException { int n = nextInt(),m = nextInt(),k = nextInt();  int an = (((n / k) * (k - 1)) + (n % k));  long ans = 0; if ( (an >= m)) {System.out.println(m); return ;} int rem = (m - an); ans = (modPow(2,(rem + 1)) - 2); ans *= k; ans += (m - (rem * k)); ans %= MOD; if ( (ans < 0)) ans += MOD; System.out.println(ans); } }
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());} }
0	public class Main{ public static void main( String[] args)throws Exception { int n = nextInt();  String nn = Integer.toString(n); if ( (n >= 0)) {println(n); } else {println(Math.max(Integer.parseInt(nn.substring(0,(nn.length() - 1))),Integer.parseInt((nn.substring(0,(nn.length() - 2)) + nn.charAt((nn.length() - 1)))))); }} static private PrintWriter out = new PrintWriter(System.out); static private BufferedReader inB = new BufferedReader(new InputStreamReader(System.in)); static private StreamTokenizer in = new StreamTokenizer(inB); static private void exit( Object o)throws Exception { out.println(o); out.flush(); System.exit(0); } static private void println( Object o)throws Exception { out.println(o); out.flush(); } static private void print( Object o)throws Exception { out.print(o); out.flush(); } static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} }
4	public class Pjar{ static int a[][] ; public static void main( String[] args)throws FileNotFoundException { Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter("output.txt");  int N = in.nextInt();  int M = in.nextInt(); a = new int[N][M]; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {a[i][j] = Integer.MAX_VALUE; }} int k = in.nextInt(); in.nextLine(); for ( int i = 0;(i < k);i++) { int x = in.nextInt();  int y = in.nextInt(); a[(x - 1)][(y - 1)] = 1; burn((x - 1),(y - 1)); } int max = Integer.MIN_VALUE;  int x = 0;  int y = 0; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {if ( (a[i][j] > max)) {max = a[i][j]; x = (i + 1); y = (j + 1); } }}out.printf("%d %d",x,y); out.close(); in.close(); } static void burn( int i, int j){ for ( int k = 0;(k < a.length);k++) {for ( int l = 0;(l < a[k].length);l++) {if ( (a[k][l] > (Math.abs((k - i)) + Math.abs((l - j))))) {a[k][l] = (Math.abs((k - i)) + Math.abs((l - j))); } }}} }
3	public class ProblemD{ public static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static StringTokenizer tok = null; public static void main( String[] args)throws IOException { tok = new StringTokenizer(in.readLine()); int n = Integer.parseInt(tok.nextToken());  int tab[] = new int[n]; tok = new StringTokenizer(in.readLine()); for ( int i = 0;(i < n);i++) tab[i] = Integer.parseInt(tok.nextToken()); int inversions = countInversions(tab);  boolean isOdd = ((inversions % 2) == 1); tok = new StringTokenizer(in.readLine()); int k = Integer.parseInt(tok.nextToken());  int start ,end ,len ; for ( int i = 0;(i < k);i++) {tok = new StringTokenizer(in.readLine()); start = Integer.parseInt(tok.nextToken()); end = Integer.parseInt(tok.nextToken()); len = (((end - start) + 1) % 4); if ( ((len == 2) || (len == 3))) isOdd = !isOdd; out.println((isOdd?"odd":"even")); }out.close(); } static private int countInversions( int[] tab){ int n = tab.length;  int auxTab[] = new int[(n + 1)]; return _countInversions(tab,0,n,auxTab);} static private int _countInversions( int[] tab, int start, int end, int[] auxTab){ if ( ((start + 1) >= end)) return 0; int mid = ((start + end) / 2);  int lowerFound = 0;  int higherFound = 0;  int count = 0; for ( int i = start;(i < end);i++) {if ( (tab[i] < (mid + 1))) {count += higherFound; auxTab[(start + lowerFound)] = tab[i]; lowerFound++; } else {auxTab[(mid + higherFound)] = tab[i]; higherFound++; }}for ( int i = start;(i < end);i++) tab[i] = auxTab[i]; count += _countInversions(tab,start,mid,auxTab); count += _countInversions(tab,mid,end,auxTab); return count;} }
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);}} }
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))); }} }
0	public class fuck{ public static int[] a ; public static void main( String[] args){ Scanner input = new Scanner(System.in);  long r = input.nextLong();  long l = input.nextLong(); if ( (((l - r) + 1) < 3)) {System.out.println(-1); } else {if ( ((r % 2) == 0)) System.out.println(((((r + " ") + (r + 1)) + " ") + (r + 2))); else {if ( (((l - r) + 1) > 3)) {++r; System.out.println(((((r + " ") + (r + 1)) + " ") + (r + 2))); } else System.out.println(-1); }}} }
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 ,kk ,bb ; int[] uu ,vv ,uv ,cost ,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_]; kk = new int[n_]; bb = new int[n_]; uu = new int[m_]; vv = new int[m_]; uv = new int[m_]; cost = 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)); } boolean dijkstra( int s, int t){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((kk[u] != kk[v])?(kk[u] - kk[v]):(u - v)))); pq.add(s); Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first;  int k = (kk[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) && (kk[v] > k)))) {if ( (pi[v] != INF)) pq.remove(v); pi[v] = p; kk[v] = k; bb[v] = h_; pq.add(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){ System.arraycopy(cost,0,cost_,0,m_); while(dijkstra(s,t)){push1(s,t); for ( int h = 0;(h < m_);h++) { int u = uu[h],v = vv[h]; if ( ((pi[u] != INF) && (pi[v] != INF))) cost_[h] += (pi[u] - pi[v]); }} 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 C2{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = na(n); for ( int i = 0;(i < n);i++) { int v = a[i]; for ( int j = 2;((j * j) <= v);j++) {while(((v % (j * j)) == 0)){v /= (j * j); }}a[i] = v; }Arrays.sort(a); int[] f = new int[n];  int p = 0; for ( int i = 0;(i < n);i++) {if ( ((i > 0) && (a[i] != a[(i - 1)]))) {p++; } f[p]++; }f = Arrays.copyOf(f,(p + 1)); int mod = 1000000007;  int[][] fif = enumFIF(1000,mod);  long[] res = countSameNeighborsSequence(f,fif,mod);  long ans = res[0]; for ( int v :f) {ans = ((ans * fif[0][v]) % mod); }out.println(ans); } public static int[][] enumFIF( int n, int mod){ int[] f = new int[(n + 1)];  int[] invf = new int[(n + 1)]; f[0] = 1; for ( int i = 1;(i <= n);i++) {f[i] = (int)(((long)f[(i - 1)] * i) % mod); } long a = f[n];  long b = mod;  long p = 1,q = 0; while((b > 0)){ long c = (a / b);  long d ; d = a; a = b; b = (d % b); d = p; p = q; q = (d - (c * q)); }invf[n] = (int)((p < 0)?(p + mod):p); for ( int i = (n - 1);(i >= 0);i--) {invf[i] = (int)(((long)invf[(i + 1)] * (i + 1)) % mod); }return new int[][]{f,invf};} public static long[] countSameNeighborsSequence( int[] a, int[][] fif, int mod){ int n = a.length;  int bef = a[0];  int aft = a[0];  long[] dp = new long[bef]; dp[(bef - 1)] = 1; for ( int u = 1;(u < n);u++) { int v = a[u]; aft += v; long[][] ldp = new long[bef][aft]; for ( int i = 0;(i < dp.length);i++) {ldp[i][0] = dp[i]; }for ( int i = 0;(i < v);i++) { long[][] ndp = new long[bef][aft]; for ( int j = 0;(j < bef);j++) {for ( int k = 0;((j + k) < aft);k++) {if ( (ldp[j][k] == 0)) continue; if ( (j > 0)) {ndp[(j - 1)][k] += (ldp[j][k] * j); ndp[(j - 1)][k] %= mod; } ndp[j][(k + 1)] += (ldp[j][k] * ((2 * i) - k)); ndp[j][(k + 1)] %= mod; ndp[j][k] += (ldp[j][k] * (((((bef + i) + 1) - j) - k) - (2 * (i - k)))); ndp[j][k] %= mod; }}ldp = ndp; }dp = new long[aft]; for ( int j = 0;(j < bef);j++) {for ( int k = 0;((j + k) < aft);k++) {dp[(j + k)] += ldp[j][k]; if ( (dp[(j + k)] >= mod)) dp[(j + k)] -= mod; }}for ( int j = 0;(j < aft);j++) dp[j] = ((dp[j] * fif[1][v]) % mod); bef = aft; }return dp;} 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 C2().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 Practice{ public static long mod = ((long)Math.pow(10,9) + 7); public static long[][][] dp ; public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  String[] s2 = br.readLine().split(" ");  int n = Integer.parseInt(s2[0]);  int m = Integer.parseInt(s2[1]);  int k = Integer.parseInt(s2[2]); dp = new long[n][m][(k + 1)]; int[][] hori = new int[n][(m - 1)];  int[][] verti = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) { String str = br.readLine();  String[] s1 = str.split(" "); for ( int j = 0;(j < (m - 1));j++) {hori[i][j] = Integer.parseInt(s1[j]); }}for ( int i = 0;(i < (n - 1));i++) { String str = br.readLine();  String[] s1 = str.split(" "); for ( int j = 0;(j < m);j++) {verti[i][j] = Integer.parseInt(s1[j]); }} long[][] ans = new long[n][m]; if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {ans[i][j] = -1; }}} else {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {ans[i][j] = findAns(i,j,k,hori,verti,n,m,Integer.MAX_VALUE); }}}for ( int i = 0;(i < n);i++) { StringBuilder str = new StringBuilder(); for ( int j = 0;(j < m);j++) {str.append((ans[i][j] + " ")); }pw.println(str.toString()); }pw.close(); } static private long findAns( int i, int j, int k, int[][] hori, int[][] verti, int n, int m, int last){ if ( (k == 0)) {return 0;} if ( ((((i < n) && (j < m)) && (i >= 0)) && (j >= 0))) {} else {return 100000000;}if ( (dp[i][j][k] != 0)) {return dp[i][j][k];} long ans = (k * (long)last); if ( (j > 0)) { long curr = (2 * hori[i][(j - 1)]); curr += findAns(i,(j - 1),(k - 2),hori,verti,n,m,hori[i][(j - 1)]); ans = Math.min(ans,curr); } if ( (j < (m - 1))) { long curr = (2 * hori[i][j]); curr += findAns(i,(j + 1),(k - 2),hori,verti,n,m,hori[i][j]); ans = Math.min(ans,curr); } if ( (i > 0)) { long curr = (2 * verti[(i - 1)][j]); curr += findAns((i - 1),j,(k - 2),hori,verti,n,m,verti[(i - 1)][j]); ans = Math.min(ans,curr); } if ( (i < (n - 1))) { long curr = (2 * verti[i][j]); curr += findAns((i + 1),j,(k - 2),hori,verti,n,m,verti[i][j]); ans = Math.min(ans,curr); } dp[i][j][k] = ans; return ans;} }
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.nextInt();  int[] a = in.nextIntArray(n);  int[] b = a.clone(); Collections.sort(ArrayUtils.asList(b)); int diff = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) diff++; }out.println(((diff <= 2)?"YES":"NO")); } } 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 println( String x){ writer.println(x); } public void close(){ writer.close(); } }
5	public class ProblemA{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out)); int[] readInts()throws IOException { String[] strings = reader.readLine().split(" ");  int[] ints = new int[strings.length]; for ( int i = 0;(i < ints.length);i++) {ints[i] = Integer.parseInt(strings[i]); }return ints;} void solve()throws IOException { int[] tt = readInts();  int n = tt[0];  int m = tt[1];  int k = tt[2];  int[] a = readInts(); Arrays.sort(a); for ( int i = 0,j = (a.length - 1);(i < j);i++,j--) { int t = a[i]; a[i] = a[j]; a[j] = t; } int ix = 0; while(((k < m) && (ix < n))){k += (a[ix++] - 1); }if ( (k < m)) {writer.println(-1); } else {writer.println(ix); }writer.flush(); } public static void main( String[] args)throws IOException { new ProblemA().solve(); } }
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());} }
3	public class cf573{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = 0; if ( scan.hasNext()) n = scan.nextInt();  TreeSet<Integer> set = new TreeSet<>(); for ( int i = 0;(i < n);i++) {if ( scan.hasNext()) set.add(scan.nextInt()); } int[] arr = new int[set.size()];  Iterator<Integer> it = set.iterator();  int j = 0; while(it.hasNext()){arr[j++] = it.next(); } int tot = 1,flag ; for ( int i = 1;(i < arr.length);i++) {flag = 0; for ( int k = 0;(k < i);k++) {if ( ((arr[i] % arr[k]) == 0)) {flag = 1; break;} }if ( (flag == 0)) {tot++; } }System.out.println(tot); } }
2	@SuppressWarnings("unused") public class round176B{ 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 n = parseLong(next());  long k = parseLong(next()); if ( (n == 1)) {System.out.println(0); return ;} if ( (n <= k)) {System.out.println(1); return ;} if ( (((((k * (k + 1)) / 2) - 1) - (k - 2)) < n)) {System.out.println(-1); } else { long lo = 1;  long hi = (k + 1);  int best = Integer.MAX_VALUE; while((lo < hi)){ long mid = (lo + ((hi - lo) / 2));  long first = (((mid * (2 + (2 + (mid - 1)))) / 2) - (mid - 1));  long last = (((mid * (((k - mid) + 1) + k)) / 2) - (mid - 1)); if ( (n < first)) {hi = mid; } else {if ( ((n >= first) && (n <= last))) {hi = mid; best = min(best,(int)mid); } else lo = (mid + 1); }}System.out.println(best); }} }
1	public class C{ void solve(){ int n = readInt();  int q = readInt();  int max = 0;  int[] a = new int[n];  Deque<Integer> deque = new ArrayDeque<>(); for ( int i = 0;(i < n);i++) {a[i] = readInt(); deque.addLast(a[i]); max = Math.max(max,a[i]); } List<String> ans = new ArrayList<>(); while((deque.peekFirst() != max)){ int one = deque.pollFirst();  int two = deque.pollFirst(); ans.add(((one + " ") + two)); deque.addFirst(((one > two)?one:two)); deque.addLast(((one > two)?two:one)); if ( (one == max)) break; }for ( int i = 0;(i < n);i++) {a[i] = deque.pollFirst(); }for ( int i = 0;(i < q);i++) { long x = readLong(); if ( (x <= ans.size())) {out.println(ans.get(((int)x - 1))); continue;} x -= ans.size(); int y = (((int)(((x % (n - 1)) - (1 % (n - 1))) + (n - 1)) % (n - 1)) + 1); out.println(((max + " ") + a[y])); }} public static void main( String[] args){ new C().run(); } void run(){ init(); solve(); out.close(); } BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init(){ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } String readLine(){ try{return in.readLine(); }catch (Exception ex){ throw (new RuntimeException(ex));} } 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());} long readLong(){ return Long.parseLong(readString());} }
0	public class TaskA1{ void run(){ int n = nextInt();  int ans = ((2 * n) - (n / 2)); 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 TaskA1().run(); } }
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());} } }
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 Main{ InputStreamReader inp = new InputStreamReader(System.in); BufferedReader in = new BufferedReader(inp); boolean test = false; String[] inData = {"9","HTHTHTHHT"}; static int id = -1; public String readLine()throws IOException { id++; if ( test) return inData[id]; else return in.readLine();} public Main()throws Throwable{ int animalNr = Integer.valueOf(readLine());  String animals = readLine();  boolean[] state = new boolean[animalNr];  int tigerCount = 0; for ( int i = 0;(i < animals.length());i++) {if ( ('T' == animals.charAt(i))) {state[i] = true; tigerCount++; } } int best = Integer.MAX_VALUE; for ( int i = 0;(i < state.length);i++) { int swaps = 0; for ( int j = i;(j < (i + tigerCount));j++) {if ( (state[(j % animalNr)] == false)) {swaps++; } }if ( (swaps < best)) {best = swaps; } }System.out.println(best); } public static void main( String[] args)throws Throwable { new Main(); } }
5	public class A implements Runnable{ 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 Thread(null,new A(),"",(256 * (1L << 20))).start(); } void solve()throws IOException { int n = readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = readInt(); }Arrays.sort(a); a[(n - 1)] = ((a[(n - 1)] == 1)?2:1); Arrays.sort(a); for ( int i = 0;(i < n);i++) {out.print((a[i] + " ")); }} }
3	public class utkarsh{ BufferedReader br ; PrintWriter out ; int game( int s, int mid, int e, int[] a){ int i ,j ,n ,m ; n = ((mid - s) + 1); m = (e - mid); int b[] = new int[n];  int c[] = new int[m]; for ( i = 0;(i < n);i++) b[i] = a[(s + i)]; for ( j = 0;(j < m);j++) c[j] = a[((mid + 1) + j)]; i = j = 0; int ans = 0; for ( int k = s;(k <= e);k++) {if ( (i == n)) {a[k] = c[j++]; } else if ( (j == m)) {a[k] = b[i++]; } else {if ( (b[i] < c[j])) {a[k] = b[i++]; } else {a[k] = c[j++]; ans += (n - i); }}}return ans;} int play( int s, int e, int[] a){ if ( (s >= e)) return 0; int m = ((s + e) >> 1); return ((play(s,m,a) + play((m + 1),e,a)) + game(s,m,e,a));} void solve(){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int i ,j ,k ,l ,r ,n ; n = ni(); int a[] = new int[n];  int d[] = new int[n]; for ( i = 0;(i < n);i++) {a[i] = ni(); d[i] = a[i]; } int ans = (play(0,(n - 1),d) & 1);  int q = ni(); while((q-- > 0)){l = ni(); r = ni(); ans ^= ((((r - l) + 1) * (r - l)) / 2); if ( ((ans & 1) > 0)) out.println("odd"); else out.println("even"); }out.flush(); } int ni(){ return Integer.parseInt(ns());} String ip[] ; int len ,sz ; String ns(){ if ( (len >= sz)) {try{ip = br.readLine().split(" "); len = 0; sz = ip.length; }catch (IOException e){ throw (new InputMismatchException());} if ( (sz <= 0)) return "-1"; } return ip[len++];} public static void main( String[] args){ new utkarsh().solve(); } }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {mds = choosed; return ;} long s = covered; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); s |= ((1L << i) | g[i]); }if ( (s != ((1L << n) - 1))) return ; int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) k = i; }if ( (k == -1)) return ; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } void println( String s){ System.out.println(s); } public static void main( String[] args){ Locale.setDefault(Locale.US); new P111C().run(); } }
6	public class CF{ void realSolve(){ int n = in.nextInt();  int m = in.nextInt();  boolean[][] f = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int fr = (in.nextInt() - 1);  int to = (in.nextInt() - 1); f[fr][to] = f[to][fr] = true; } long[][] dp = new long[n][(1 << n)]; for ( int i = 0;(i < n);i++) dp[i][(1 << i)] = 1; long res = 0;  int[] len = new int[(n + 1)]; for ( int st = 0;(st < (1 << n));st++) { int from = Integer.lowestOneBit(st); for ( int i = 0;(i < n);i++) if ( (((1 << i) & st) != 0)) {from = i; break;} for ( int to = 0;(to < n);to++) if ( (dp[to][st] != 0)) for ( int next = from;(next < n);next++) if ( (f[to][next] && ((((1 << next) & st) == 0) || (next == from)))) if ( (next == from)) {if ( (Integer.bitCount(st) > 2)) {res += dp[to][st]; len[Integer.bitCount(st)] += dp[to][st]; } } else {dp[next][(st | (1 << next))] += dp[to][st]; } }out.println((res / 2)); } private class InputReader{ StringTokenizer st ; BufferedReader br ; 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)); } String next(){ while(((st == null) || !st.hasMoreElements())){ String s ; try{s = br.readLine(); }catch (IOException e){ return null;} if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} boolean hasMoreElements(){ while(((st == null) || !st.hasMoreElements())){ String s ; try{s = br.readLine(); }catch (IOException e){ return false;} st = new StringTokenizer(s); }return st.hasMoreElements();} } InputReader in ; PrintWriter out ; void solveIO(){ in = new InputReader(System.in); out = new PrintWriter(System.out); realSolve(); out.close(); } public static void main( String[] args){ new CF().solveIO(); } }
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()); } }
2	public class answertillD{ 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 ; public static long gcd( long u, long v){ if ( (u == 0)) return v; return gcd((v % u),u);} public static int dfs( int u){ vis[u] = true; int a = 0; for ( int v :adjlist[u]) if ( !vis[v]) a += dfs(v); return (1 + a);} public static void dfs( int u, int num){ vis2[u] = true; counter[u] = num; for ( int v :adjlist[u]) if ( !vis2[v]) dfs(v,num); } static long diff = Long.MAX_VALUE; static boolean check( long num, long k){ int n = ((num + "") - 1);  long m = 1;  long sum = 0;  int i = 1; while((n-- > 0)){sum += ((9 * m) * i); m *= 10; }sum += (((num - m) * i) + 1); if ( (sum <= k)) diff = Math.min(diff,(k - sum)); return (sum <= k);} static long bin( long k){ long left = 1;  long right = (k + 1);  long mid ;  long ans = 1; while((left <= right)){mid = ((left + right) / 2); if ( check(mid,k)) {ans = mid; left = (mid + 1); } else right = (mid - 1); }return ans;} static int m ; static int calculate( int[] Arrs, int[] Arre, int index, boolean left, boolean targetleft){ int ans = 0;  int n = (m + 2); if ( left) {ans = Arre[(index - 1)]; if ( (index != (E + 1))) ans += (targetleft?Arre[(index - 1)]:((n - Arre[(index - 1)]) - 1)); } else {ans = ((n - Arrs[(index - 1)]) - 1); if ( (index != (E + 1))) ans += (targetleft?Arrs[(index - 1)]:((n - Arrs[(index - 1)]) - 1)); }return ans;} static int min = Integer.MAX_VALUE; static void backtrack( int[] Arrs, int[] Arre, int soFarMin, int index, boolean left){ if ( (index == E)) {min = Math.min(min,(soFarMin - 1)); return ;} int newmin1 = calculate(Arrs,Arre,index,left,left);  int newmin2 = calculate(Arrs,Arre,index,left,!left); backtrack(Arrs,Arre,((soFarMin + newmin1) + 1),(index - 1),left); backtrack(Arrs,Arre,((soFarMin + newmin2) + 1),(index - 1),!left); } public static String add( String str1, String str2){ Stack<String> st = new Stack<String>();  int n = str1.length();  int m = str2.length();  int max = Math.max(n,m);  int sum = 0,carry = 0; for ( int i = 0;(i < max);i++) { int num1 = 0,num2 = 0; if ( (n >= i)) num1 = Integer.parseInt((str1.charAt((n - i)) + "")); if ( (m >= i)) num2 = Integer.parseInt((str2.charAt((m - i)) + ""));  int z = ((num1 + num2) + carry); if ( (z >= 10)) {sum = (z / 10); carry = (z % 10); } else {sum = z; carry = 0; }st.add((sum + "")); } StringBuilder sb = new StringBuilder(); while(!st.isEmpty()){sb.append(st.pop()); }return (sb + "");} public static void main( String[] args)throws IOException,InterruptedException { Scanner sc = new Scanner(System.in);  long k = sc.nextLong();  long bi = bin(k);  String str = (bi + ""); System.out.println(str.charAt((int)diff)); } 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 long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
3	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);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int r = in.scanInt(),temp ;  double max1 ;  double high[] = new double[1002]; for ( int i = 0;(i < n);i++) {temp = in.scanInt(); max1 = (high[temp] + ((high[temp] == 0)?r:(2 * r))); for ( int j = (temp - 1);((j > (temp - (2 * r))) && (j > 0));j--) {if ( (high[j] == 0)) continue; max1 = Math.max(max1,(high[j] + Math.sqrt((((4 * r) * r) - ((temp - j) * (temp - j)))))); }for ( int j = (temp + 1);((j <= 1000) && (j < (temp + (2 * r))));j++) {if ( (high[j] == 0)) continue; max1 = Math.max(max1,(high[j] + Math.sqrt((((4d * r) * r) - ((j - temp) * (j - temp)))))); }if ( ((temp - (2 * r)) > 0)) max1 = Math.max(high[(temp - (2 * r))],max1); if ( ((temp + (2 * r)) <= 1000)) max1 = Math.max(high[(temp + (2 * r))],max1); high[temp] = max1; out.print((max1 + " ")); }} } 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
5	public class A{ void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] a = new int[n];  boolean dif = false; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); if ( (n == 1)) {System.out.println(((a[0] == 1)?2:1)); return ;} int[] m = new int[n]; for ( int i = 1;(i < n);i++) if ( (a[i] != a[(i - 1)])) dif = true; m[0] = 1; for ( int i = 1;(i < n);i++) m[i] = a[(i - 1)]; if ( (!dif && (a[0] == 1))) m[(n - 1)]++; for ( int i = 0;(i < n);i++) System.out.print((m[i] + ((i == (n - 1))?"\n":" "))); } public static void main( String[] args){ new A().run(); } }
4	public class Problem implements Runnable{ static private final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); private BufferedReader in ; private PrintWriter out ; private StringTokenizer tok = new StringTokenizer(""); private void init()throws FileNotFoundException { Locale.setDefault(Locale.US); String fileName = ""; in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); } String readString(){ while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken();} int readInt(){ return Integer.parseInt(readString());} public static void main( String[] args){ new Problem().run(); } long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } @Override public void run(){ try{timeBegin = System.currentTimeMillis(); init(); solve(); out.close(); time(); }catch (Exception e){ e.printStackTrace(); System.exit(-1); } } int[][] dist ; int n ,m ; P v ; ArrayDeque<P> q = new ArrayDeque<>(); private void solve()throws IOException { n = readInt(); m = readInt(); int k = readInt(); dist = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) dist[i][j] = -1; for ( int i = 0;(i < k);i++) { int x = (readInt() - 1),y = (readInt() - 1); dist[x][y] = 0; q.add(new P(x,y)); }bfs(); out.println((((v.x + 1) + " ") + (v.y + 1))); } public void bfs(){ int[] dx = {0,1,0,-1};  int[] dy = {1,0,-1,0}; while(!q.isEmpty()){v = q.poll(); for ( int i = 0;(i < 4);i++) { int nx = (v.x + dx[i]);  int ny = (v.y + dy[i]); if ( (inside(nx,ny) && (dist[nx][ny] == -1))) {q.add(new P(nx,ny)); dist[nx][ny] = (dist[v.x][v.y] + 1); } }}} public boolean inside( int x, int y){ if ( ((((x < n) && (y < m)) && (x >= 0)) && (y >= 0))) {return true;} return false;} } class P{ int x ,y ; public P( int x, int y){ this.x = x; this.y = y; } }
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); } static private 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; } } }}} static private 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()); } static private 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)); }}} }
5	public class Main{ public static void main( String[] args){ Scanner cin = new Scanner(new BufferedInputStream(System.in));  int n = cin.nextInt(),m = cin.nextInt(),k = cin.nextInt();  int[] a = new int[51]; for ( int i = 0;(i < n);i++) {a[i] = -cin.nextInt(); }Arrays.sort(a); if ( (m <= k)) {System.out.println(0); return ;} for ( int i = 0;(i < Math.min(k,n));i++) {m += a[i]; if ( ((m - ((k - 1) - i)) <= 0)) {System.out.println((i + 1)); return ;} }for ( int i = k;(i < n);i++) {m += (a[i] + 1); if ( (m <= 0)) {System.out.println((i + 1)); return ;} }System.out.println(-1); cin.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{ private int n ; private InputReader in ; private PrintWriter out ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); this.in = in; this.out = out; query(new Point(1,1),new Point(n,n),new Rectangle()); } private boolean query( Point bottomLeft, Point topRight, Rectangle rectangle){ if ( ((bottomLeft.r > topRight.r) || (bottomLeft.c > topRight.c))) return false; int low = bottomLeft.c,high = topRight.c; while((low < high)){ int mid = (low + ((high - low) / 2));  int answer = ask(bottomLeft.r,bottomLeft.c,topRight.r,mid); if ( (answer > 0)) high = mid; else low = (mid + 1); } int rightCol = low; low = bottomLeft.c; high = topRight.c; while((low < high)){ int mid = (low + (((high - low) + 1) / 2));  int answer = ask(bottomLeft.r,mid,topRight.r,topRight.c); if ( (answer > 0)) low = mid; else high = (mid - 1); } int leftCol = low; low = bottomLeft.r; high = topRight.r; while((low < high)){ int mid = (low + ((high - low) / 2));  int answer = ask(bottomLeft.r,bottomLeft.c,mid,topRight.c); if ( (answer > 0)) high = mid; else low = (mid + 1); } int topRow = low; low = bottomLeft.r; high = topRight.r; while((low < high)){ int mid = (low + (((high - low) + 1) / 2));  int answer = ask(mid,bottomLeft.c,topRight.r,topRight.c); if ( (answer > 0)) low = mid; else high = (mid - 1); } int bottomRow = low; if ( (leftCol > rightCol)) { Rectangle first = new Rectangle(); query(new Point(1,leftCol),new Point(n,n),first); Rectangle second = new Rectangle(); query(new Point(1,1),new Point(n,rightCol),second); out.printf("! %d %d %d %d %d %d %d %d\n",first.bottomLeft.r,first.bottomLeft.c,first.topRight.r,first.topRight.c,second.bottomLeft.r,second.bottomLeft.c,second.topRight.r,second.topRight.c); return true;} if ( (bottomRow > topRow)) { Rectangle first = new Rectangle(); query(new Point(bottomRow,1),new Point(n,n),first); Rectangle second = new Rectangle(); query(new Point(1,1),new Point(topRow,n),second); out.printf("! %d %d %d %d %d %d %d %d\n",first.bottomLeft.r,first.bottomLeft.c,first.topRight.r,first.topRight.c,second.bottomLeft.r,second.bottomLeft.c,second.topRight.r,second.topRight.c); return true;} rectangle.bottomLeft.r = bottomRow; rectangle.bottomLeft.c = leftCol; rectangle.topRight.r = topRow; rectangle.topRight.c = rightCol; return true;} private int ask( int r1, int c1, int r2, int c2){ out.printf("? %d %d %d %d\n",r1,c1,r2,c2); out.flush(); return in.nextInt();} private class Point{ private int r ; private int c ; public Point( int r, int c){ this.r = r; this.c = c; } } private class Rectangle{ private Point bottomLeft ; private Point topRight ; public Rectangle(){ bottomLeft = new Point(-1,-1); topRight = new Point(-1,-1); } } } static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; static private final int BUFFER_SIZE = 32768; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),BUFFER_SIZE); 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 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(); } static private 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;} static private 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++; }}}} static private 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); } } }
2	public class Main{ FastScanner in ; PrintWriter out ; private void solve()throws IOException { solveB(); } private void solveB()throws IOException { long n = in.nextLong();  long c = ((n + in.nextLong()) * 2);  long l = 0,r = (long)1e9; while(((l + 1) < r)){ long m = ((l + r) / 2); if ( (((m * m) + (3 * m)) >= c)) r = m; else l = m; }out.println((n - r)); } 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); for ( int t = 1;(t-- > 0);) solve(); out.flush(); out.close(); } public static void main( String[] args)throws IOException { new Main().run(); } }
0	public class Main{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long n = scanner.nextLong();  long x = scanner.nextLong(),y = scanner.nextLong();  long whiteSteps ,blackSteps ; if ( ((x == 1) || (y == 1))) {whiteSteps = ((x - 1) + (y - 1)); } else {whiteSteps = Math.min(((x - 1) + Math.abs((y - x))),((y - 1) + Math.abs((y - x)))); }if ( ((x == n) || (y == n))) {blackSteps = ((n - x) + (n - y)); } else {blackSteps = Math.min(((n - x) + Math.abs((y - x))),((n - y) + Math.abs((y - x)))); }if ( (whiteSteps <= blackSteps)) {System.out.println("White"); } else {System.out.println("Black"); }} }
4	public class x1523C{ public static void main( String[] hi)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int T = Integer.parseInt(st.nextToken());  StringBuilder sb = new StringBuilder(); while((T-- > 0)){st = new StringTokenizer(infile.readLine()); int N = Integer.parseInt(st.nextToken());  int[] arr = new int[N]; for ( int i = 0;(i < N);i++) arr[i] = Integer.parseInt(infile.readLine()); ArrayList<Integer>[] buckets = new ArrayList[N]; buckets[0] = new ArrayList<Integer>(); buckets[0].add(arr[0]); for ( int i = 1;(i < N);i++) { ArrayList<Integer> ls = new ArrayList<Integer>(); if ( (arr[i] == 1)) {for ( int x :buckets[(i - 1)]) ls.add(x); ls.add(1); } else { int dex = -1; for ( int a = 0;(a < buckets[(i - 1)].size());a++) if ( (buckets[(i - 1)].get(a) == (arr[i] - 1))) dex = a; for ( int a = 0;(a < dex);a++) ls.add(buckets[(i - 1)].get(a)); ls.add(arr[i]); }buckets[i] = ls; }for ( int a = 0;(a < N);a++) {for ( int i = 0;(i < (buckets[a].size() - 1));i++) {sb.append(buckets[a].get(i)); sb.append("."); }sb.append(arr[a]); sb.append("\n"); }}System.out.print(sb); } }
6	public class CodeD{ 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 final Scanner sc ; static final int n ; static final int[][] distancias ; static final int[] distancia ; static final int[] dp ; static final int[] dpNext ; static final int X ; static final int Y ; {sc = new Scanner(); X = sc.nextInt(); Y = sc.nextInt(); n = sc.nextInt(); distancias = new int[n][n]; distancia = new int[n]; dp = new int[(1 << n)]; Arrays.fill(dp,-1); dpNext = new int[(1 << n)]; }static int dp( int mascara){ if ( (dp[mascara] != -1)) return dp[mascara]; int highest = -1; for ( int i = 0,tmp = mascara;(tmp != 0);i++,tmp >>= 1) {if ( ((tmp & 1) == 1)) {highest = i; break;} }if ( (highest == -1)) return 0; int nextMsc = (mascara ^ (1 << highest));  int costHighest = distancia[highest];  int best = ((costHighest << 1) + dp(nextMsc));  int bestNext = nextMsc; for ( int i = 0,tmp = nextMsc,iC = 1;(tmp != 0);i++,tmp >>= 1,iC <<= 1) {if ( ((tmp & 1) == 1)) { int msc = (nextMsc ^ iC);  int possibleA = (((costHighest + distancias[highest][i]) + distancia[i]) + dp(msc)); if ( (possibleA < best)) {best = possibleA; bestNext = msc; } } }dpNext[mascara] = bestNext; return dp[mascara] = best;} public static void main( String[] args){ int[][] objetos = new int[n][2]; for ( int i = 0;(i < n);i++) {objetos[i][0] = sc.nextInt(); objetos[i][1] = sc.nextInt(); distancia[i] = (((X - objetos[i][0]) * (X - objetos[i][0])) + ((Y - objetos[i][1]) * (Y - objetos[i][1]))); }for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) distancias[i][j] = (((objetos[i][0] - objetos[j][0]) * (objetos[i][0] - objetos[j][0])) + ((objetos[i][1] - objetos[j][1]) * (objetos[i][1] - objetos[j][1]))); int ans = dp(((1 << n) - 1)); System.out.println(ans); int current = ((1 << n) - 1); while((current != 0)){ int next = dpNext[current];  int differents = (next ^ current); System.out.print("0 "); for ( int i = 0;(i < n);i++) if ( ((differents & (1 << i)) != 0)) System.out.print(((i + 1) + " ")); current = next; }System.out.println("0"); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ int n ; ArrayList<Integer>[] adj ; long[] mem ; long cycles( int cur, int start, int visited){ if ( ((cur == start) && (visited > 0))) {return ((Integer.bitCount(visited) >= 3)?1:0);} int index = ((n * visited) + cur); if ( (mem[index] != -1)) return mem[index]; long res = 0;  int newvisited = (visited | (1 << cur)); for ( int nxt :adj[cur]) {if ( ((nxt >= start) && ((nxt == start) || (((visited >> nxt) & 1) == 0)))) {res += cycles(nxt,start,newvisited); } }return mem[index] = res;} public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.readInt(); int m = in.readInt(); adj = new ArrayList[n]; mem = new long[(n * (1 << n))]; for ( int i = 0;(i < adj.length);i++) adj[i] = new ArrayList<>(); for ( int i = 0;(i < m);i++) { int a = (in.readInt() - 1),b = (in.readInt() - 1); adj[a].add(b); adj[b].add(a); } long res = 0; for ( int start = 0;(start < n);start++) {Arrays.fill(mem,-1); res += (cycles(start,start,0) / 2); }out.printLine(res); } } 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( long 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 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); } } }
1	public class Solution{ public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int tc = sc.ni(); for ( int rep = 0;(rep < tc);rep++) {pw.println(solve(sc,pw)); }pw.close(); } public static String solve( FastScanner sc, PrintWriter pw){ int n = sc.ni();  long cur1 = 2;  long cur2 = 4;  long block = 2;  long block2 = 4;  int tmp = 3; while(((cur1 <= n) || (cur2 <= n))){if ( ((cur1 == n) || (cur2 == n))) {return "YES";} if ( (cur1 < n)) {cur1 += (block * tmp); } if ( (cur2 < n)) {cur2 += (block2 * tmp); } tmp += 2; }return "NO";} static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} } class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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());} long nl(){ return Long.parseLong(next());} String nextLine(){ String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} }
6	public class Template implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws FileNotFoundException { try{in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); }catch (Exception e){ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } } class GraphBuilder{ int n ,m ; int[] x ,y ; int index ; int[] size ; GraphBuilder( int n, int m){ this.n = n; this.m = m; x = new int[m]; y = new int[m]; size = new int[n]; } void add( int u, int v){ x[index] = u; y[index] = v; size[u]++; size[v]++; index++; } int[][] build(){ int[][] graph = new int[n][]; for ( int i = 0;(i < n);i++) {graph[i] = new int[size[i]]; }for ( int i = (index - 1);(i >= 0);i--) { int u = x[i];  int v = y[i]; graph[u][--size[u]] = v; graph[v][--size[v]] = u; }return graph;} } String readString()throws IOException { while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} long readLong()throws IOException { return Long.parseLong(readString());} public static void main( String[] args){ new Template().run(); } long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } long memoryTotal ,memoryFree ; void memory(){ memoryFree = Runtime.getRuntime().freeMemory(); System.err.println((("Memory = " + ((memoryTotal - memoryFree) >> 10)) + " KB")); } public void run(){ try{timeBegin = System.currentTimeMillis(); memoryTotal = Runtime.getRuntime().freeMemory(); init(); solve(); out.close(); if ( (System.getProperty("ONLINE_JUDGE") == null)) {time(); memory(); } }catch (Exception e){ e.printStackTrace(); System.exit(-1); } } void solve()throws IOException { int n = readInt();  int m = readInt();  int max = (1 << n);  long[][] dp = new long[n][max]; for ( int i = 0;(i < n);i++) {dp[i][(1 << i)] = 1; } GraphBuilder gb = new GraphBuilder(n,m); for ( int i = 0;(i < m);i++) {gb.add((readInt() - 1),(readInt() - 1)); } int[][] graph = gb.build(); for ( int mask = 1;(mask < max);mask++) { int firstBit = -1; for ( int i = 0;(i < n);i++) {if ( hasBit(mask,i)) {firstBit = i; break;} }for ( int last = 0;(last < n);last++) {if ( (dp[last][mask] == 0)) continue; for ( int y :graph[last]) {if ( (!hasBit(mask,y) && (y > firstBit))) {dp[y][(mask | (1 << y))] += dp[last][mask]; } }}} long answer = 0; for ( int i = 1;(i < max);i++) {if ( (Integer.bitCount(i) < 3)) continue; int firstBit = -1; for ( int j = 0;(j < n);j++) {if ( hasBit(i,j)) {firstBit = j; break;} }for ( int y :graph[firstBit]) {answer += dp[y][i]; }}out.println((answer / 2)); } boolean hasBit( int mask, int bit){ return ((mask & (1 << bit)) != 0);} }
4	public class SolutionD extends Thread{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ 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 parseInt(next());} } static private final FastReader scanner = new FastReader(); static private final PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ solve(); out.close(); } static private void solve(){ int n = scanner.nextInt();  int m = scanner.nextInt();  int k = scanner.nextInt();  int[][] hori = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int xij = scanner.nextInt(); hori[i][j] = xij; }} int[][] vert = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { int xij = scanner.nextInt(); vert[i][j] = xij; }}if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) { StringBuilder s = new StringBuilder(); for ( int j = 0;(j < m);j++) {s.append("-1 "); }out.println(s); }return ;} k /= 2; long[][][] dp = new long[n][m][(k + 1)]; for ( int kTmp = 1;(kTmp <= k);kTmp++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[i][j][kTmp] = Integer.MAX_VALUE; if ( (i > 0)) {dp[i][j][kTmp] = Math.min(dp[i][j][kTmp],(dp[(i - 1)][j][(kTmp - 1)] + (2L * vert[(i - 1)][j]))); } if ( (j > 0)) {dp[i][j][kTmp] = Math.min(dp[i][j][kTmp],(dp[i][(j - 1)][(kTmp - 1)] + (2L * hori[i][(j - 1)]))); } if ( ((i + 1) < n)) {dp[i][j][kTmp] = Math.min(dp[i][j][kTmp],(dp[(i + 1)][j][(kTmp - 1)] + (2L * vert[i][j]))); } if ( ((j + 1) < m)) {dp[i][j][kTmp] = Math.min(dp[i][j][kTmp],(dp[i][(j + 1)][(kTmp - 1)] + (2L * hori[i][j]))); } }}}for ( int i = 0;(i < n);i++) { StringBuilder s = new StringBuilder(); for ( int j = 0;(j < m);j++) {s.append(dp[i][j][k]).append(" "); }out.println(s); }} }
3	public class Solution{ 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());} } public static void main( String[] args){ FastReader sc = new FastReader();  int n = sc.nextInt();  int m = sc.nextInt();  int[] arr = new int[105]; for ( int i = 0;(i < m);i++) { int a = sc.nextInt(); arr[a]++; }for ( int i = 1;(i <= 1000);i++) { int sum = 0; for ( int a :arr) {if ( (a != 0)) {sum += (a / i); } }if ( (sum < n)) {System.out.println((i - 1)); return ;} }} }
5	public class Main{ public static void main( String[] args)throws Exception { MyScanner scan = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n = scan.nextInt();  int[] vals = new int[n]; for ( int i = 0;(i < n);i++) {vals[i] = scan.nextInt(); }for ( int i = 0;(i < n);i++) {if ( solve(i,vals)) {out.print('A'); } else {out.print('B'); }}out.close(); } static HashMap<Integer,Boolean> dpResult = new HashMap<>(); static private boolean solve( int pos, int[] vals){ if ( dpResult.containsKey(pos)) return dpResult.get(pos); int val = vals[pos];  boolean hasLose = false; for ( int i = pos;(i < vals.length);i += val) {if ( (i == pos)) continue; if ( (vals[i] <= vals[pos])) continue; if ( hasLose) break; if ( !solve(i,vals)) {hasLose = true; } }for ( int i = pos;(i >= 0);i -= val) {if ( (i == pos)) continue; if ( (vals[i] <= vals[pos])) continue; if ( hasLose) break; if ( !solve(i,vals)) {hasLose = true; } }dpResult.put(pos,hasLose); return hasLose;} 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());} } }
0	public class N1_CF_199A{ public static void main( String[] args){ int n = new Scanner(System.in).nextInt(); if ( (n == 0)) {System.out.println(0); System.out.println(0); System.out.println(0); return ;} int i = 0,j = 1; while(true){ int t = (i + j); if ( (t == n)) break; i = j; j = t; }System.out.println(i); System.out.println(j); System.out.println(0); } }
5	public class Village{ static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); public static void main( String[] args){ int n = in.nextInt(),t = (2 * in.nextInt()),h[][] = new int[n][2],ans = 2; for ( int i = 0;(i < n);i++) {h[i][0] = (2 * in.nextInt()); h[i][1] = in.nextInt(); }Arrays.sort(h,new Comp()); for ( int i = 1;(i < n);i++) { int d = ((h[i][0] - h[i][1]) - (h[(i - 1)][0] + h[(i - 1)][1])); if ( (d > t)) ans += 2; if ( (d == t)) ans++; }System.out.println(ans); } static class Comp implements Comparator<int[]>{ } }
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); } }
0	public class A{ static private BufferedReader in ; static private StringTokenizer st ; static private 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 max = n; max = Math.max(max,(n / 10)); max = Math.max(max,(((n / 100) * 10) + (n % 10))); System.out.println(max); } 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());} }
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 ProblemD{ static int n ; static int m ; static boolean[][] fire ; public static void main( String[] args)throws FileNotFoundException { Scanner sc = new Scanner(new File("input.txt")); n = sc.nextInt(); m = sc.nextInt(); int k = sc.nextInt(); fire = new boolean[n][m]; Queue<Pos> q = new LinkedList<Pos>(); for ( int i = 0;(i < k);i++) { int x = sc.nextInt();  int y = sc.nextInt(); q.add(new Pos((x - 1),(y - 1))); fire[(x - 1)][(y - 1)] = true; } int[] di = new int[]{1,-1,0,0};  int[] dj = new int[]{0,0,1,-1};  Pos last = null; while((q.size() > 0)){ Pos pos = q.poll(); last = pos; for ( int kk = 0;(kk < 4);kk++) { int ni = (pos.i + di[kk]);  int nj = (pos.j + dj[kk]); if ( ((((ni >= 0) && (nj >= 0)) && (ni < n)) && (nj < m))) {if ( !fire[ni][nj]) {fire[ni][nj] = true; q.add(new Pos(ni,nj)); } } }} PrintWriter out = new PrintWriter(new File("output.txt")); out.println((((last.i + 1) + " ") + (last.j + 1))); out.flush(); out.close(); } } class Pos{ int i ,j ; public Pos( int i, int j){ super(); this.i = i; this.j = j; } }
0	public class J472A{ static private Scanner scan = new Scanner(System.in); public static void main( String[] args){ int a = scan.nextInt(); if ( ((a % 2) == 0)) {System.out.println(((4 + " ") + (a - 4))); } else {System.out.println(((9 + " ") + (a - 9))); }} }
5	public class CF915E{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  int n = Integer.parseInt(br.readLine());  int q = Integer.parseInt(br.readLine());  TreeMap<Integer,Integer> mp = new TreeMap<>();  int ans = 0; while((q-- > 0)){ StringTokenizer st = new StringTokenizer(br.readLine());  int l = (Integer.parseInt(st.nextToken()) - 1);  int r = Integer.parseInt(st.nextToken());  int t = Integer.parseInt(st.nextToken());  Map.Entry<Integer,Integer> e ;  int l_ ,r_ ; if ( (t == 1)) {if ( (((e = mp.floorEntry(l)) != null) && ((r_ = e.getValue()) >= l))) {l_ = e.getKey(); ans -= (r_ - l_); l = l_; r = Math.max(r,r_); } while((((e = mp.higherEntry(l)) != null) && ((l_ = e.getKey()) <= r))){r_ = e.getValue(); ans -= (r_ - l_); r = Math.max(r,r_); mp.remove(l_); }ans += (r - l); mp.put(l,r); } else {r_ = l; if ( (((e = mp.floorEntry(l)) != null) && ((r_ = e.getValue()) > l))) {l_ = e.getKey(); if ( (l_ < l)) mp.put(l_,l); else mp.remove(l_); ans -= (r_ - l); } while((((e = mp.higherEntry(l)) != null) && ((l_ = e.getKey()) < r))){r_ = e.getValue(); mp.remove(l_); ans -= (r_ - l_); }if ( (r_ > r)) {mp.put(r,r_); ans += (r_ - r); } }pw.println((n - ans)); }pw.close(); } }
2	public class P{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  long N = sc.nextLong(),S = sc.nextLong();  long lo = 0,hi = N;  long pivot = 0; while((lo <= hi)){ long mid = (lo + ((hi - lo) / 2));  int sumOfDigits = 0;  long saveMid = mid; while((saveMid > 0)){sumOfDigits += (saveMid % 10); saveMid /= 10; }if ( ((mid - sumOfDigits) < S)) {pivot = mid; lo = (mid + 1); } else hi = (mid - 1); }System.out.println((N - pivot)); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String f)throws FileNotFoundException{ br = new BufferedReader(new FileReader(f)); } 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 long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} public int[] nextIntArray( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} public int[] shuffle( int[] a, int n){ int[] b = new int[n]; for ( int i = 0;(i < n);i++) b[i] = a[i]; Random r = new Random(); for ( int i = 0;(i < n);i++) { int j = (i + r.nextInt((n - i)));  int t = b[i]; b[i] = b[j]; b[j] = t; }return b;} public long[] nextLongArray( int n)throws IOException { long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nextLong(); return a;} } }
0	public class ToyArmy{ int N ; BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] tok ; String s ; private int getInt()throws IOException { return Integer.valueOf(br.readLine());} private int[] getInt( int N)throws IOException { int[] data = new int[N]; tok = br.readLine().split(" "); for ( int i = 0;(i < N);i++) data[i] = Integer.valueOf(tok[i]); return data;} public void solve()throws IOException { int i = 0,j = 0; N = getInt(); long kill = ((3 * N) / 2); System.out.printf("%d\n",kill); } public static void main( String[] args)throws IOException { new ToyArmy().solve(); } }
6	public class Main implements Runnable{ private void solution()throws IOException { int n = in.nextInt();  int m = in.nextInt();  boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = in.nextInt();  int y = in.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[(1 << (n - i))][(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[mask][j] != 0)) {for ( int k = 0;(k < (n - i));++k) {if ( ((((mask >> k) & 1) == 0) && adj[(j + i)][(k + i)])) {dp[(mask | (1 << k))][k] += dp[mask][j]; } }} }if ( (((mask >> 0) & 1) != 0)) {res += dp[mask][0]; } }}out.println((res / 2)); } private class Scanner{ BufferedReader reader ; 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)); }
0	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long x = input.nextLong(); if ( ((x == 1) || (x == 2))) {System.out.println(x); } else if ( ((((x % 2) == 0) && (x > 2)) && ((x % 3) != 0))) {System.out.println(((x * (x - 1)) * (x - 3))); } else if ( (((x % 2) == 0) && ((x % 3) == 0))) {System.out.println((((x - 1) * (x - 2)) * (x - 3))); } else {System.out.println(((x * (x - 1)) * (x - 2))); }} }
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());} } }
6	public class T{ static Scanner in = new Scanner(); static PrintWriter out = new PrintWriter(System.out); static boolean adj[][] ; static int n ,m ,from ; static long memo[][] ; static long Num_Cycle ; public static void main( String[] args)throws IOException { n = in.nextInt(); m = in.nextInt(); adj = new boolean[n][n]; memo = new long[n][(1 << n)]; for ( int i = 0;(i < m);i++) { int u = (in.nextInt() - 1);  int v = (in.nextInt() - 1); adj[u][v] = adj[v][u] = true; }for ( long[] arr :memo) {Arrays.fill(arr,-1); }Num_Cycle = 0L; for ( int i = 0;(i < n);i++) {from = i; Num_Cycle += dp(from,(1 << i)); }out.println((Num_Cycle / 2)); out.flush(); out.close(); } static long dp( int start, int mask){ if ( (memo[start][mask] != -1)) {return memo;} long ans = 0L; if ( (adj[start][from] && (Integer.bitCount(mask) >= 3))) {ans++; } for ( int i = (from + 1);(i < n);i++) {if ( (adj[start][i] && ((mask & (1 << i)) == 0))) {ans += dp(i,(mask | (1 << i))); } }return memo[start][mask] = ans;} static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } Scanner( String file)throws FileNotFoundException{ br = new BufferedReader(new FileReader(file)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} } }
1	public class Solution{ static boolean canWinFromOneMove( char[] s, int k){ int prefix = 0;  int n = s.length; for ( int i = 0;((i < n) && (s[i] == s[0]));i++) prefix++; int suffix = 0; for ( int i = (n - 1);((i >= 0) && (s[i] == s[(n - 1)]));i--) suffix++; return (((s[0] == s[(n - 1)]) && (((prefix + suffix) + k) >= n)) || ((Math.max(prefix,suffix) + k) >= n));} 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();  char[] s = sc.next().toCharArray(); if ( canWinFromOneMove(s,k)) {System.out.println("tokitsukaze"); return ;} int[] suff = new int[(n + 1)]; suff[(n - 1)] = 1; for ( int i = (n - 2);(i >= 0);i--) {suff[i] = (1 + ((s[(i + 1)] == s[i])?suff[(i + 1)]:0)); }for ( int i = (n - 2);(i >= 0);i--) suff[i] = Math.max(suff[i],suff[(i + 1)]); int max = 0,curr = 0;  boolean draw = false;  int ones = 0; for ( int i = 0;((i + k) <= n);i++) { int prefix = ((ones == i)?(k + ones):max);  int suffix = (((i + k) == n)?k:(((s[(i + k)] == '1') && (suff[(i + k)] == (n - (i + k))))?(k + suff[(i + k)]):suff[(i + k)]));  char first = ((i == 0)?'1':s[0]),last = (((i + k) == n)?'1':s[(n - 1)]);  boolean zero = (((first == last) && (((prefix + suffix) + k) >= n)) || ((Math.max(prefix,suffix) + k) >= n)); prefix = ((ones == 0)?(k + ones):max); suffix = (((i + k) == n)?k:(((s[(i + k)] == '0') && (suff[(i + k)] == (n - (i + k))))?(k + suff[(i + k)]):suff[(i + k)])); first = ((i == 0)?'0':s[0]); last = (((i + k) == n)?'0':s[(n - 1)]); boolean one = (((first == last) && (((prefix + suffix) + k) >= n)) || ((Math.max(prefix,suffix) + k) >= n)); if ( (!zero || !one)) {draw = true; } if ( (s[i] == '1')) ones++; if ( ((i > 0) && (s[i] == s[(i - 1)]))) curr++; else curr = 1; max = Math.max(max,curr); }out.println((draw?"once again":"quailty")); 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();} } }
4	public class Practice{ public static long mod = ((long)Math.pow(10,9) + 7); public static long[][] dp ; public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  String[] s2 = br.readLine().split(" ");  int n = (int)Long.parseLong(s2[0]);  long m = Long.parseLong(s2[1]); dp = new long[(n + 2)][(n + 2)]; long[] power = new long[(n + 1)]; mod = m; long[][] choose = new long[(n + 2)][(n + 2)]; getPow(power,(n + 1)); getChoose(choose,(n + 2),(n + 2)); dp[0][0] = 1; 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 + k) + 1)][(j + k)] + ((((dp[i][j] * power[(k - 1)]) % mod) * choose[(j + k)][k]) % mod)) % mod); }}} long ans = 0; for ( int i = 0;(i <= n);i++) {ans = ((ans + dp[(n + 1)][i]) % mod); }pw.println(ans); pw.close(); } static private void getChoose( long[][] choose, int up, int dow){ for ( int i = 1;(i < up);i++) {for ( int j = 1;(j <= i);j++) {if ( ((j == 1) && (i == 1))) {choose[i][j] = 1; } else if ( (j == 1)) {choose[i][j] = i; } else {choose[i][j] = ((choose[(i - 1)][j] + choose[(i - 1)][(j - 1)]) % mod); }}}} static private void getPow( long[] power, int l){ for ( int i = 0;(i < l);i++) {if ( (i == 0)) {power[i] = 1; } else {power[i] = ((power[(i - 1)] * 2) % mod); }}} }
3	public class Main{ static PrintWriter out ; static InputReader ir ; static void solve(){ int n = ir.nextInt();  int[] a = ir.nextIntArray(n); Arrays.sort(a); boolean[] used = new boolean[n];  int ct = 0; for ( int i = 0;(i < n);i++) {if ( used[i]) continue; for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) used[j] = true; }ct++; }out.println(ct); } public static void main( String[] args){ ir = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static class InputReader{ private InputStream in ; private byte[] buffer = new byte[1024]; private int curbuf ; private int lenbuf ; public InputReader( InputStream in){ this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte(){ if ( (curbuf >= lenbuf)) {curbuf = 0; try{lenbuf = in.read(buffer); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return false; } return true;} private int readByte(){ if ( hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private void skip(){ while((hasNextByte() && isSpaceChar(buffer[curbuf])))curbuf++; } public boolean hasNext(){ skip(); return hasNextByte();} public String next(){ if ( !hasNext()) throw (new NoSuchElementException()); StringBuilder sb = new StringBuilder();  int b = readByte(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} public int nextInt(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public long nextLong(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
2	public class ehab4{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int a = 0,b = 0; System.out.println("? 0 0 "); System.out.flush(); int c = in.nextInt(); for ( int i = 29;(i >= 0);i--) {System.out.println(((("? " + (a + (1 << i))) + " ") + b)); System.out.flush(); int q1 = in.nextInt(); System.out.println(((("? " + a) + " ") + (b + (1 << i)))); System.out.flush(); int q2 = in.nextInt(); if ( (q1 == q2)) {if ( (c == 1)) a += (1 << i); else if ( (c == -1)) b += (1 << i); c = q1; } else if ( (q1 == -1)) {a += (1 << i); b += (1 << i); } else if ( (q1 == -2)) return ; }System.out.println(((("! " + a) + " ") + b)); System.out.flush(); } }
4	public class A_GENERAL{ static StringBuilder sb = new StringBuilder(); static long seive_size = (long)1e6; static String alpha = "abcdefghijklmnopqrstuvwxyz"; static ArrayList<Integer> primes = new ArrayList<>(); static boolean[] seive_set = new boolean[((int)seive_size + 1)]; static int n ,m ,k ; static ArrayList<Integer>[] adj ; static boolean[] vis ; static ArrayDeque<Integer> q = new ArrayDeque<>(); static final long MOD = 998244353; static int[] dx = new int[]{1,0,-1,0,1,-1,1,-1}; static int[] dy = new int[]{0,1,0,-1,-1,1,1,-1}; static long[][] arr ; static int[] rank ; static int[] parent ; static int[] s ; static long[] a ; public static void main( String[] args)throws FileNotFoundException { Scanner sc = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter("output.txt"); n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); ArrayDeque<iPair> qq = new ArrayDeque<>();  boolean[][] vis = new boolean[(n + 1)][(m + 1)]; for ( int i = 0;(i < k);i++) { int u = sc.nextInt();  int v = sc.nextInt(); qq.add(new iPair(u,v)); vis[u][v] = true; } iPair last = null; while(!qq.isEmpty()){ iPair pp = qq.poll();  int i = pp.f;  int j = pp.s; if ( (isValid((i - 1),j) && !vis[(i - 1)][j])) {qq.add(new iPair((i - 1),j)); vis[(i - 1)][j] = true; } if ( (isValid((i + 1),j) && !vis[(i + 1)][j])) {qq.add(new iPair((i + 1),j)); vis[(i + 1)][j] = true; } if ( (isValid(i,(j - 1)) && !vis[i][(j - 1)])) {qq.add(new iPair(i,(j - 1))); vis[i][(j - 1)] = true; } if ( (isValid(i,(j + 1)) && !vis[i][(j + 1)])) {qq.add(new iPair(i,(j + 1))); vis[i][(j + 1)] = true; } last = pp; }out.println(((last.f + " ") + last.s)); sc.close(); out.close(); } public static boolean isValid( int i, int j){ if ( ((((i < 1) || (i > n)) || (j < 1)) || (j > m))) return false; return true;} public static class iPair implements Comparable<iPair>{ int f ; int s ; iPair( int f, int s){ this.f = f; this.s = s; } } public static long choose( long n, long k){ return ((k == 0)?1:((n * choose((n - 1),(k - 1))) / k));} public static long gcd( long a, long b){ return ((a == 0)?b:gcd((b % a),a));} public static long max( long... as){ long max = Long.MIN_VALUE; for ( long a :as) max = Math.max(a,max); return max;} public static long min( int... as){ long min = Long.MAX_VALUE; for ( long a :as) min = Math.min(a,min); return min;} public static long modpow( long x, long n, long mod){ if ( (n == 0)) return (1 % mod); long u = modpow(x,(n / 2),mod); u = ((u * u) % mod); if ( ((n % 2) == 1)) u = ((u * x) % mod); return u;} public static void permute( String str){ permute(str,0,(str.length() - 1)); } public static void permute( String str, int l, int r){ if ( (l == r)) System.out.println(str); else {for ( int i = l;(i <= r);i++) {str = swap(str,l,i); permute(str,(l + 1),r); str = swap(str,l,i); }}} public static String swap( String a, int i, int j){ char temp ;  char[] charArray = a.toCharArray(); temp = charArray[i]; charArray[i] = charArray[j]; charArray[j] = temp; return String.valueOf(charArray);} public static int find( int u){ if ( (parent[u] == u)) return u; int v = find(parent[u]); parent[u] = v; return v;} }
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); } }
0	public class Main{ public static void main( String[] args){ Scanner read = new Scanner(System.in);  double a = (double)read.nextInt();  double v = (double)read.nextInt();  double l = (double)read.nextInt();  double d = (double)read.nextInt();  double w = (double)read.nextInt();  double t = 0; if ( (w >= v)) { double d1 = ((v * v) / (2 * a)); if ( (d1 > l)) {t += Math.sqrt(((2 * l) / a)); } else {t += ((v / a) + ((l - d1) / v)); }} else { double temp = ((v - w) / a);  double d1 = ((v * v) / (2 * a));  double d2 = ((d - (v * temp)) + (((a * temp) * temp) / 2)); if ( (d1 > d2)) { double temp2 = Math.sqrt(((2 * a) * d)); if ( (temp2 < w)) {w = temp2; temp = ((v - w) / a); t += (temp2 / a); } else { double vx = Math.sqrt((((v * v) / 2) + (a * d2))); t += ((vx / a) + ((vx - w) / a)); }} else {t += (((v / a) + ((d2 - d1) / v)) + temp); } double d3 = ((d + (w * temp)) + (((a * temp) * temp) / 2)); if ( (d3 > l)) {t += ((-w + Math.sqrt(((w * w) + ((2 * a) * (l - d))))) / a); } else {t += (temp)((l - d3) / v); }}System.out.printf("%.6f",t); read.close(); } }
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))); }
6	public class ASimpleTask{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[][] d = new int[n][n]; for ( int i = 0,m = sc.nextInt();(i < m);i++) { int a = (sc.nextInt() - 1),b = (sc.nextInt() - 1); d[a][b] = 1; d[b][a] = 1; } long[][] dp = new long[(1 << n)][n]; for ( int mask = 1;(mask < (1 << n));mask++) { int start = numberOfTrailingZeros(mask); if ( (bitCount(mask) == 1)) {dp[mask][start] = 1; continue;} for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) > 0) && (i != start))) { int xmask = (mask ^ (1 << i)); for ( int j = 0;(j < n);j++) {if ( (d[j][i] > 0)) {dp[mask][i] += dp[xmask][j]; } }} }} long sum = 0; for ( int mask = 1;(mask < (1 << n));mask++) {if ( (bitCount(mask) >= 3)) {for ( int i = 0;(i < n);i++) {if ( (d[numberOfTrailingZeros(mask)][i] > 0)) {sum += dp[mask][i]; } }} }out.print((sum / 2)); } }
0	public final class FollowTrafficRules{ static private double[] acce( double i, double a, double v){ double[] r = new double[2]; r[0] = ((v - i) / a); r[1] = ((((1d / 2d) * a) * pow(r[0],2)) + (i * r[0])); return r;} static private double solve( double i, double a, double l){ double e = sqrt((pow(i,2) + ((2d * a) * l))); e = ((a > 0)?e:(-1d * e)); return ((e - i) / a);} static private double time( double i, double a, double v, double l){ double[] r = acce(i,a,v); if ( (r[1] >= l)) return solve(i,a,l); return (r[0] + ((l - r[1]) / v));} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  double a = sc.nextDouble();  double v = sc.nextDouble();  double l = sc.nextDouble();  double d = sc.nextDouble();  double w = sc.nextDouble();  double t = 0d; if ( (v <= w)) t = time(0,a,v,l); else { double[] r = acce(0,a,w); if ( (r[1] >= d)) t = time(0,a,v,l); else {t += r[0]; t += (2d * time(w,a,v,((d - r[1]) / 2d))); t += time(w,a,v,(l - d)); }}System.out.println(t); } }
0	public class Contests{ public static void main( String[] args){ Scanner clavier = new Scanner(System.in);  long a = clavier.nextLong(); clavier.close(); if ( (a == 1)) System.out.println(5); else System.out.println(25); } }
5	public class a111{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] a = new int[n];  int su = 0; for ( int i = 0;(i < n);i++) {a[i] = -sc.nextInt(); su += (-1 * a[i]); }Arrays.sort(a); int ss = 0; for ( int i = 0;(i < n);i++) {ss += (-1 * a[i]); su -= (-1 * a[i]); if ( (ss > su)) {System.out.println((i + 1)); return ;} }} }
0	public class codeforces{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int test = 1; for ( int ind = 0;(ind < test);ind++) { int[] a = new int[3]; a[0] = sc.nextInt(); a[1] = sc.nextInt(); a[2] = sc.nextInt(); Arrays.sort(a); int k1 = a[0];  int k2 = a[1];  int k3 = a[2]; if ( (((k1 == 1) || (k2 == 1)) || (k3 == 1))) {out.println("YES"); } else if ( (((k1 == 2) && (k2 == 2)) || ((k2 == 2) && (k3 == 2)))) {out.println("YES"); } else if ( (((k1 == 3) && (k2 == 3)) && (k3 == 3))) {out.println("YES"); } else if ( (((k1 == 2) && (k2 == 4)) && (k3 == 4))) {out.println("YES"); } else out.println("NO"); }out.flush(); } static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} } class Scanner{ public BufferedReader reader ; public StringTokenizer st ; public Scanner( 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());} }
0	public class Main{ boolean eof ; String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return "-1";} }return st.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} void solve(){ long n = nextInt(),ans = n; if ( ((n % 6) == 0)) {ans = Math.max((((n - 1) * (n - 2)) * (n - 3)),ans); } else if ( ((n % 2) == 0)) {ans = Math.max(ans,((n * (n - 1)) * (n - 3))); } else {ans = Math.max(((n * (n - 1)) * (n - 2)),ans); }out.print(ans); } BufferedReader br ; StringTokenizer st ; PrintWriter out ; void run(){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); br.close(); out.close(); }catch (Throwable e){ e.printStackTrace(); System.exit(1); } } public static void main( String[] args){ new Main().run(); } }
1	public class LightItUp{ 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 previous = 0;  int array[] = new int[(n + 1)];  int answer = 0;  StringTokenizer st1 = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {array[i] = Integer.parseInt(st1.nextToken()); if ( ((i % 2) == 0)) {answer += (array[i] - previous); } previous = array[i]; }if ( ((n % 2) == 0)) {answer += (m - previous); } previous = m; int max = Integer.MAX_VALUE; while((n-- != 0)){ int temp = array[n]; if ( ((n % 2) == 0)) {array[n] = (array[(n + 1)] - (previous - array[n])); } else {array[n] = (array[(n + 1)] + (previous - array[n])); }previous = temp; max = Math.min(max,array[n]); }if ( (max >= -1)) {System.out.println(answer); } else {System.out.println((answer - (max + 1))); }} }
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);  C909 solver = new C909(); solver.solve(1,in,out); out.close(); } static class C909{ int N ; long MOD = 1_000_000_007; boolean[] type ; long[][] memo ; long dp( int cmd, int dep){ if ( (dep < 0)) return 0; if ( (cmd == N)) return 1; if ( (memo[cmd][dep] != -1)) return memo[cmd][dep]; boolean safe = ((cmd == 0)?true:!type[(cmd - 1)]);  int d = (type[cmd]?1:0);  long ways = 0; if ( !safe) {ways += dp((cmd + 1),(dep + d)); ways %= MOD; } else {ways += dp((cmd + 1),(dep + d)); ways %= MOD; ways += dp(cmd,(dep - 1)); ways %= MOD; }return memo[cmd][dep] = ways;} public void solve( int testNumber, FastScanner s, PrintWriter out){ N = s.nextInt(); type = new boolean[N]; for ( int i = 0;(i < N);i++) {type[i] = (s.next().charAt(0) == 'f'); }memo = new long[N][(N + 1)]; for ( long[] a :memo) Arrays.fill(a,-1); out.println(dp(0,0)); } } 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));} 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();} } }
2	public class B{ public static void main( String[] args){ MScanner sc = new MScanner();  PrintWriter out = new PrintWriter(System.out);  long N = sc.nextLong();  long X = sc.nextLong();  long Y = sc.nextLong();  long C = sc.nextLong();  long low = 0;  long high = (N * 2);  long mid = 0;  long ans = 0; while((low <= high)){mid = ((low + high) >> 1); long painted = F(mid,(X - 1),(Y - 1),N); if ( (painted < C)) {low = (mid + 1); } else {ans = mid; high = (mid - 1); }}out.println(ans); out.close(); } static private long F( long mid, long x, long y, long n){ long base = (((2 * mid) * (mid + 1)) + 1); base -= excess((mid - x)); base -= excess((mid - y)); base -= excess((mid - ((n - 1) - x))); base -= excess((mid - ((n - 1) - y))); base += corner((mid - ((x + y) + 1))); base += corner((mid - ((x + ((n - y) - 1)) + 1))); base += corner((mid - ((((n - x) - 1) + y) + 1))); base += corner((mid - ((1 + ((n - 1) - y)) + ((n - 1) - x)))); return base;} static private long corner( long a){ if ( (a < 0)) return 0; return (((a * a) + a) >> 1);} static private long excess( long thing){ if ( (thing < 0)) return 0; return (thing * thing);} static class MScanner{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public MScanner(){ stream = System.in; } 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));} int nextInt(){ return Integer.parseInt(next());} int[] nextInt( int N){ int[] ret = new int[N]; for ( int a = 0;(a < N);a++) ret[a] = nextInt(); return ret;} int[][] nextInt( int N, int M){ int[][] ret = new int[N][M]; for ( int a = 0;(a < N);a++) ret[a] = nextInt(M); return ret;} long nextLong(){ return Long.parseLong(next());} long[] nextLong( int N){ long[] ret = new long[N]; for ( int a = 0;(a < N);a++) ret[a] = nextLong(); return ret;} double nextDouble(){ return Double.parseDouble(next());} double[] nextDouble( int N){ double[] ret = new double[N]; for ( int a = 0;(a < N);a++) ret[a] = nextDouble(); return ret;} 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();} String[] next( int N){ String[] ret = new String[N]; for ( int a = 0;(a < N);a++) ret[a] = next(); return ret;} String nextLine(){ int c = read(); while(isEndline(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isEndline(c));return res.toString();} String[] nextLine( int N){ String[] ret = new String[N]; for ( int a = 0;(a < N);a++) ret[a] = nextLine(); return ret;} } }
5	public class A2{ 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(),a = next(),b = next();  int h[] = new int[n]; for ( int i = 0;(i < n);i++) h[i] = next(); Arrays.sort(h); int res = (h[b] - h[(b - 1)]); out.println(res); out.println(); out.close(); } }
3	public class A{ FastScanner in ; PrintWriter out ; boolean systemIO = true; public int gcd( int x, int y){ if ( (y == 0)) {return x;} if ( (x == 0)) {return y;} return gcd(y,(x % y));} public class Edge{ int to ; long s ; public Edge( int to, long s){ this.to = to; this.s = s; } } public long dfs( int v, int prev, long sumth, long minsum, long s){ tin[v] = timer; timer++; up[v][0] = new Edge(prev,s); for ( int i = 1;(i <= l);i++) { Edge e = up[v][(i - 1)]; up[v][i] = new Edge(up[e.to][(i - 1)].to,(up[e.to][(i - 1)].s + e.s)); }minsum = Math.min(minsum,sumth); maxup[v] = (sumth - minsum); long mxdown = sumth; for ( Edge e :list[v]) {if ( (e.to != prev)) {mxdown = Math.max(mxdown,dfs(e.to,v,(sumth + e.s),minsum,e.s)); } }tout[v] = timer; timer++; maxdown[v] = (mxdown - sumth); return mxdown;} public boolean upper( int a1, int b1){ return ((tin[a1] <= tin[b1]) && (tout[a1] >= tout[b1]));} int n ; int l ; int[] tin ; int[] tout ; int timer = 0; long[] maxup ; long[] maxdown ; Edge[][] up ; ArrayList<Edge>[] list ; public void solve(){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < a.length);i++) {a[i] = in.nextInt(); }Arrays.sort(a); int ans = 0;  boolean[] used = new boolean[n]; for ( int i = 0;(i < used.length);i++) {if ( !used[i]) {ans++; for ( int j = i;(j < used.length);j++) {if ( ((a[j] % a[i]) == 0)) {used[j] = true; } }} }out.print(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());} } public static void main( String[] arg){ new A().run(); } }
6	public final class CF_599_D1_C{ static boolean verb = true; static void log( Object X){ if ( verb) System.err.println(X); } static void log( Object[] X){ if ( verb) {for ( Object U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X){ if ( verb) {for ( int U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X, int L){ if ( verb) {for ( int i = 0;(i < L);i++) System.err.print((X[i] + " ")); System.err.println(""); } } static void log( long[] X){ if ( verb) {for ( long U :X) System.err.print((U + " ")); System.err.println(""); } } static void output( Object o){ outputWln((("" + o) + "\n")); } static void outputWln( Object o){ try{out.write(("" + o)); }catch (Exception e){ } } static long mod = 1000000007; static BufferedWriter out ; static InputReader reader ; static void explore( ArrayList<Integer>[] components, ArrayList<Integer> bob, int[][] move, ArrayList<int[]>[] howto, int[][] list){ for ( int x :bob) {if ( (components[x].size() == 1)) { int tm[] = howto[x].get(0);  int L = howto[x].size(); howto[x].add(tm); for ( int i = 0;(i < L);i++) { int[] cur = howto[x].get(i);  int[] nx = howto[x].get((i + 1));  int a = cur[0];  int a2 = nx[0];  int b2 = nx[1]; move[a2][0] = list[a2][b2]; move[a2][1] = a; }} else {explore(components,components[x],move,howto,list); }}} static void process()throws Exception { out = new BufferedWriter(new OutputStreamWriter(System.out)); reader = new InputReader(System.in); int k = reader.readInt();  int[][] list = new int[k][];  long[] sum = new long[k];  int[] L = new int[k];  HashMap<Integer,int[]> target = new HashMap<Integer,int[]>();  long tot = 0; for ( int i = 0;(i < k);i++) {L[i] = reader.readInt(); list[i] = new int[L[i]]; for ( int j = 0;(j < L[i]);j++) {list[i][j] = reader.readInt(); sum[i] += list[i][j]; target.put(list[i][j],new int[]{i,j}); }tot += sum[i]; } int MX = (1 << k);  int AX = 1000000001;  ArrayList<int[]>[] howto = new ArrayList[MX]; log("ok with the data"); if ( ((tot % k) != 0)) {output("No"); } else {tot /= k; for ( int i = 0;(i < k);i++) {if ( (sum[i] == tot)) { int mask = (1 << i);  ArrayList<int[]> cand = new ArrayList<int[]>(); cand.add(new int[]{i,0}); howto[mask] = cand; } else for ( int j = 0;(j < L[i]);j++) { int u = i;  int v = j;  boolean ok = true;  int src_u = u;  int src_v = v;  int mask = 0;  boolean goon = true;  ArrayList<int[]> cand = new ArrayList<int[]>(); while(goon){cand.add(new int[]{u,v}); ok = false; goon = false; long need = (tot - ((long)sum[u] - (long)list[u][v])); if ( (Math.abs(need) <= AX)) { int nd = (int)need;  int[] tm = target.get(nd); if ( (tm != null)) { int nxu = tm[0];  int nxv = tm[1]; if ( ((mask & (1 << nxu)) == 0)) {mask |= (1 << nxu); if ( (nxu == src_u)) {if ( (nxv == src_v)) ok = true; } else {u = nxu; v = nxv; ok = true; goon = true; }} } } }if ( ok) {if ( (howto[mask] == null)) {howto[mask] = cand; } } }}log("step 1 done"); ArrayList[] components = new ArrayList[MX];  int[] msk = new int[MX];  int w = 0; for ( int m = 0;(m < MX);m++) {if ( (howto[m] != null)) {components[m] = new ArrayList<Integer>(); components[m].add(m); msk[w++] = m; } } int base = w; for ( int e = 0;(e < base);e++) { int a = msk[e];  int ww = w; for ( int i = 0;(i < ww);i++) { int b = msk[i]; if ( ((b & a) == 0)) { int c = (b | a); if ( (components[c] == null)) {components[c] = new ArrayList<Integer>(); components[c].add(a); components[c].add(b); msk[w++] = c; } } }}if ( (components[(MX - 1)] != null)) {output("Yes"); int[][] move = new int[k][2]; explore(components,components[(MX - 1)],move,howto,list); for ( int i = 0;(i < k);i++) {output(((move[i][0] + " ") + (move[i][1] + 1))); }} else {output("No"); }}try{out.close(); }catch (Exception e){ } } public static void main( String[] args)throws Exception { process(); } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
4	public class x35C{ public static void main( String[] hi)throws Exception { BufferedReader infile = new BufferedReader(new FileReader("input.txt"));  StringTokenizer st = new StringTokenizer(infile.readLine());  int N = Integer.parseInt(st.nextToken());  int M = Integer.parseInt(st.nextToken());  int K = Integer.parseInt(infile.readLine());  int[][] grid = new int[N][M]; for ( int i = 0;(i < N);i++) Arrays.fill(grid[i],-1); ArrayDeque<Integer> q = new ArrayDeque<Integer>(); st = new StringTokenizer(infile.readLine()); while((K-- > 0)){ int a = (Integer.parseInt(st.nextToken()) - 1);  int b = (Integer.parseInt(st.nextToken()) - 1); grid[a][b] = 0; q.add(a); q.add(b); }while((q.size() > 0)){ int x = q.poll();  int y = q.poll(); if ( ((x > 0) && (grid[(x - 1)][y] == -1))) {grid[(x - 1)][y] = (grid[x][y] + 1); q.add((x - 1)); q.add(y); } if ( ((y > 0) && (grid[x][(y - 1)] == -1))) {grid[x][(y - 1)] = (grid[x][y] + 1); q.add(x); q.add((y - 1)); } if ( (((x + 1) < N) && (grid[(x + 1)][y] == -1))) {grid[(x + 1)][y] = (grid[x][y] + 1); q.add((x + 1)); q.add(y); } if ( (((y + 1) < M) && (grid[x][(y + 1)] == -1))) {grid[x][(y + 1)] = (grid[x][y] + 1); q.add(x); q.add((y + 1)); } } int r = 0;  int c = 0; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) if ( (grid[r][c] < grid[i][j])) {r = i; c = j; } r++; c++; System.setOut(new PrintStream(new File("output.txt"))); System.out.println(((r + " ") + c)); } }
0	public class Task483A{ public static void main( String... args)throws NumberFormatException,IOException { Solution.main(System.in,System.out); } static class Scanner{ private final BufferedReader br ; private String[] cache ; private int cacheIndex ; Scanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); cache = new String[0]; cacheIndex = 0; } long nextLong()throws IOException { if ( (cacheIndex >= cache.length)) {cache = br.readLine().split(" "); cacheIndex = 0; } return Long.parseLong(cache[cacheIndex++]);} void close()throws IOException { br.close(); } } static class Solution{ public static void main( InputStream is, OutputStream os)throws NumberFormatException,IOException { PrintWriter pw = new PrintWriter(os);  Scanner sc = new Scanner(is);  long l = sc.nextLong();  long r = sc.nextLong();  long interval = (r - l); if ( (((interval == 0) || (interval == 1)) || ((interval == 2) && ((l % 2) == 1)))) {pw.println(-1); } else {if ( ((l % 2) == 1)) {l++; } pw.print(l); pw.print(" "); pw.print((l + 1)); pw.print(" "); pw.print((l + 2)); }pw.flush(); sc.close(); } } }
6	public class TaskC{ final int INF = 123456; int[][][] memo ; int N ,M ; int solve( int row, int prevFreeMask, int curStayMask){ if ( (row == N)) return ((curStayMask == 0)?0:-INF); if ( (memo[row][prevFreeMask][curStayMask] != -1)) return memo[row][prevFreeMask][curStayMask]; int res = 0; for ( int mask = 0;(mask < (1 << M));mask++) {if ( ((mask & curStayMask) == curStayMask)) { int freeCellsMask = (((1 << M) - 1) - mask);  int toMoveMask = freeCellsMask; for ( int i = 0;(i < M);i++) {if ( ((toMoveMask & (1 << i)) > 0)) {if ( (i > 0)) {if ( ((mask & (1 << (i - 1))) > 0)) {toMoveMask -= (1 << i); continue;} } if ( (i < (M - 1))) {if ( ((mask & (1 << (i + 1))) > 0)) {toMoveMask -= (1 << i); continue;} } } }if ( (row > 0)) {for ( int prevFillMask = toMoveMask;(prevFillMask > 0);prevFillMask = ((prevFillMask - 1) & toMoveMask)) { int bc1 = Integer.bitCount(freeCellsMask);  int bc2 = Integer.bitCount((prevFreeMask & prevFillMask)); res = Math.max(res,((bc1 - bc2) + solve((row + 1),freeCellsMask,(toMoveMask ^ prevFillMask)))); }} res = Math.max(res,(Integer.bitCount(freeCellsMask) + solve((row + 1),freeCellsMask,toMoveMask))); } }return memo[row][prevFreeMask][curStayMask] = res;} void run(){ N = nextInt(); M = nextInt(); if ( (M > N)) { int temp = M; M = N; N = temp; } this.memo = new int[(N + 1)][(1 << M)][(1 << M)]; for ( int[][] g :memo) for ( int[] f :g) Arrays.fill(f,-1); System.out.println(solve(0,0,0)); } 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 TaskC().run(); } }
1	public class Main{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),k = sc.nextInt(),kol = 0,prev ;  boolean ok ;  ArrayList<Integer> al = new ArrayList<Integer>(); al.add(2); prev = 2; for ( int i = 3;(i <= n);i += 2) {ok = true; for ( Integer x :al) if ( ((i % x) == 0)) {ok = false; break;} if ( ok) {for ( Integer x :al) if ( ok) {prev = x; ok = false; } else {if ( (((x + prev) + 1) == i)) {kol++; break;} if ( (((x + prev) + 1) > i)) break; prev = x; }al.add(i); } }if ( (kol >= k)) System.out.print("YES"); else System.out.print("NO"); } }
1	public class Solution{ static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws Exception { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); in.nextToken(); int n = (int)in.nval; in.nextToken(); String st = in.sval;  char[] a = new char[n]; for ( int i = 0;(i < n);i++) a[i] = st.charAt(i); int kH = 0;  int kT = 0; for ( int i = 0;(i < n);i++) if ( (a[i] == 'T')) kT++; else kH++; int kol = 0;  int min = Integer.MAX_VALUE;  int poz ; for ( int i = 0;(i < n);i++) {kol = 0; if ( (a[i] == 'T')) {for ( int j = 0;(j < kT);j++) {poz = ((i + j) % n); if ( (a[poz] == 'H')) kol++; }if ( (kol < min)) min = kol; } else {for ( int j = 0;(j < kH);j++) {poz = ((i + j) % n); if ( (a[poz] == 'T')) kol++; }if ( (kol < min)) min = kol; }}out.print(min); out.flush(); } }
1	public class test{ static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter out = new PrintWriter(System.out); static int nextInt(){ try{in.nextToken(); }catch (IOException ex){ Logger.getLogger(test.class.getName()).log(Level.SEVERE,null,ex); } return (int)in.nval;} public static void main( String[] args)throws Exception { int n = nextInt();  long k = nextInt();  long a[] = new long[(n + 1)];  Map<Long,Long> drb = new HashMap<Long,Long>();  int elso = 1;  long sk = 0;  long sm = 0;  long minjo = Long.MAX_VALUE;  long minjoh = Long.MAX_VALUE;  Vector<long[]> ret = new Vector<long[]>(); for ( int i = 1;(i <= n);i++) {a[i] = nextInt(); if ( true) {sm += a[i]; if ( drb.containsKey(a[i])) {drb.put(a[i],(drb.get(a[i]) + 1)); } else {drb.put(a[i],(long)1); sk++; }while(((sk > k) || (drb.get(a[elso]) > 1))){ long s = drb.get(a[elso]); if ( (s == 1)) {drb.remove(a[elso]); sk--; } else {drb.put(a[elso],(s - 1)); }sm -= a[elso]; elso++; }if ( (sk == k)) {if ( (minjo > sm)) {minjo = sm; ret.clear(); minjoh = (i - elso); } if ( (minjo == sm)) {if ( (minjoh > (i - elso))) {ret.clear(); minjoh = (i - elso); } ret.add(new long[]{elso,i}); } } } else {elso = i; drb.clear(); drb.put(a[i],(long)1); sk = 1; sm = a[i]; if ( (k == 1)) {if ( (minjo > sm)) {minjo = sm; ret.clear(); } if ( (minjo == sm)) {ret.add(new long[]{elso,i}); } } }}for ( long[] r :ret) {System.out.print((r[0] + " ")); System.out.print((r[1] + " ")); break;}if ( (ret.size() == 0)) {System.out.print((-1 + " ")); System.out.print((-1 + " ")); } } }
0	public class composite{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int a = s.nextInt(); if ( ((a % 2) == 0)) {a = (a - 4); System.out.println(((4 + " ") + a)); } else {a = (a - 9); System.out.println(((9 + " ") + a)); }} }
6	public class B{ static int n ,t[] ,g[] ,MOD = ((int)1e9 + 7); static int[][] memo ; static int dp( int msk, int rem, int lastG){ if ( (rem == 0)) return 1; if ( (memo[lastG][msk] != -1)) return memo[lastG][msk]; int ans = 0; for ( int i = 0;(i < n);i++) {if ( ((((msk & (1 << i)) == 0) && (rem >= t[i])) && (g[i] != lastG))) ans += dp((msk | (1 << i)),(rem - t[i]),g[i]); if ( (ans >= MOD)) ans -= MOD; }return memo[lastG][msk] = ans;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner();  PrintWriter out = new PrintWriter(System.out); n = sc.nextInt(); int T = sc.nextInt(); t = new int[n]; g = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = sc.nextInt(); g[i] = (sc.nextInt() - 1); }memo = new int[4][(1 << n)]; for ( int[] x :memo) Arrays.fill(x,-1); out.println(dp(0,T,3)); 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();} } }
1	public class MinimumDiameterTree{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int s = in.nextInt();  int deg[] = new int[n]; for ( int i = 1;(i < n);++i) {deg[(in.nextInt() - 1)]++; deg[(in.nextInt() - 1)]++; } int l = 0; for ( int i = 0;(i < n);++i) if ( (deg[i] == 1)) l++; out.println((((double)2 * s) / l)); out.close(); } public 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)throws java.lang.Exception { Scanner sc = new Scanner(System.in);  int numSupply = sc.nextInt();  int dev = sc.nextInt();  int socket = sc.nextInt();  int[] sockInSu = new int[numSupply]; for ( int i = 0;(i < sockInSu.length);i++) {sockInSu[i] = sc.nextInt(); }Arrays.sort(sockInSu); if ( (socket >= dev)) {System.out.println(0); } else { int count = 0; for ( int i = (sockInSu.length - 1);(i >= 0);i--) {socket += (sockInSu[i] - 1); count++; if ( (socket >= dev)) {System.out.println(count); break;} }if ( (socket < dev)) System.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();} } }
1	public class Main{ FastScanner in ; PrintWriter out ; static final String FILE = ""; public void solve(){ int n = in.nextInt();  TreeMap<Character,Integer> map = new TreeMap<>();  ArrayList<Integer> list = new ArrayList<>();  String s = in.next(); for ( int i = 0;(i < n);i++) { char ch = s.charAt(i); if ( !map.containsKey(ch)) map.put(ch,map.size()); list.add(map.get(ch)); } int l = 0;  int ans = Integer.MAX_VALUE;  int nad = map.size();  int cnt[] = new int[n]; for ( int i = 0;(i < list.size());i++) {if ( (cnt[list.get(i)] == 0)) nad--; cnt[list.get(i)]++; if ( (nad == 0)) {ans = min(ans,((i - l) + 1)); while(true){if ( (cnt[list.get(l)] == 1)) {ans = min(ans,((i - l) + 1)); cnt[list.get(l)]--; l++; nad++; break;} else {cnt[list.get(l)]--; l++; }}} }out.print(ans); } 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();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class C2{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new File("input.txt"));  PrintWriter pw = new PrintWriter(new File("output.txt"));  int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int[] x = new int[(k + 1)],y = new int[(k + 1)]; for ( int i = 1;(i <= k);i++) {y[i] = sc.nextInt(); x[i] = sc.nextInt(); } int max = -1,y0 = 0,x0 = 0; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) { int min = ((n + m) + 2); for ( int j2 = 1;(j2 <= k);j2++) {min = Math.min(min,(Math.abs((i - y[j2])) + Math.abs((j - x[j2])))); }if ( (min > max)) {max = min; y0 = i; x0 = j; } }}pw.println(((y0 + " ") + x0)); pw.close(); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ int n ; ArrayList<Integer>[] adj ; long[] mem ; int start ; long cycles( int cur, int visited){ if ( ((cur == start) && (visited > 0))) {return ((Integer.bitCount(visited) >= 3)?1:0);} int index = ((visited * n) + cur); if ( (mem[index] != -1)) return mem[index]; long res = 0;  int newvisited = (visited | (1 << cur)); for ( int nxt :adj[cur]) {if ( ((nxt >= start) && ((nxt == start) || (((visited >> nxt) & 1) == 0)))) {res += cycles(nxt,newvisited); } }return mem[index] = res;} public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.readInt(); int m = in.readInt(); adj = new ArrayList[n]; mem = new long[(n * (1 << n))]; for ( int i = 0;(i < adj.length);i++) adj[i] = new ArrayList<>(); for ( int i = 0;(i < m);i++) { int a = (in.readInt() - 1),b = (in.readInt() - 1); adj[a].add(b); adj[b].add(a); } long res = 0; for ( int start = 0;(start < n);start++) {Arrays.fill(mem,-1); this.start = start; res += (cycles(start,0) / 2); }out.printLine(res); } } 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( long 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 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); } } }
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)); } }
3	public class Main implements Runnable{ static final double time = 1e9; static final int MOD = ((int)1e9 + 7); static final long mh = Long.MAX_VALUE; static final Reader in = new Reader(); static final PrintWriter out = new PrintWriter(System.out); StringBuilder answer = new StringBuilder(); long start = System.nanoTime(); public static void main( String[] args){ new Thread(null,new Main(),"persefone",(1 << 28)).start(); } void solve(){ int n = in.nextInt();  int[] a = in.nextIntArray(n);  int invertions = 0; for ( int i = 1;(i < n);i++) {for ( int j = (i - 1);(j > -1);j--) {if ( (a[j] > a[i])) invertions++; }}invertions %= 2; for ( int q = in.nextInt();(q > 0);q--) { int l = in.nextInt();  int r = in.nextInt();  int k = ((r - l) + 1); k = (((k * (k - 1)) >> 1) % 2); if ( (invertions == k)) {invertions = 0; add("even",'\n'); } else {invertions = 1; add("odd",'\n'); }}} void printf(){ out.print(answer); } void close(){ out.close(); } void printf( Stream<?> str){ str.forEach((o)->add(o," ")); add("\n"); } void printf( Object... obj){ printf(false,obj); } private void printf( boolean b, Object... obj){ if ( (obj.length > 1)) {for ( int i = 0;(i < obj.length);i++) {if ( b) add(obj[i].getClass().getSimpleName()," - "); if ( (obj[i] instanceof Collection<?>)) {printf((Collection<?>)obj[i]); } else if ( (obj[i] instanceof int[][])) {printf((int[][])obj[i]); } else if ( (obj[i] instanceof long[][])) {printf((long[][])obj[i]); } else if ( (obj[i] instanceof double[][])) {printf((double[][])obj[i]); } else printf(obj[i]); }return ;} if ( b) add(obj[0].getClass().getSimpleName()," - "); printf(obj[0]); } void printf( Object o){ if ( (o instanceof int[])) printf(Arrays.stream((int[])o).boxed()); else if ( (o instanceof char[])) printf(new String((char[])o)); else if ( (o instanceof long[])) printf(Arrays.stream((long[])o).boxed()); else if ( (o instanceof double[])) printf(Arrays.stream((double[])o).boxed()); else if ( (o instanceof boolean[])) {for ( boolean b :(boolean[])o) add(b," "); add("\n"); } else add(o,"\n"); } void printf( int[]... obj){ for ( int i = 0;(i < obj.length);i++) printf(obj[i]); } void printf( long[]... obj){ for ( int i = 0;(i < obj.length);i++) printf(obj[i]); } void printf( double[]... obj){ for ( int i = 0;(i < obj.length);i++) printf(obj[i]); } void printf( boolean[]... obj){ for ( int i = 0;(i < obj.length);i++) printf(obj[i]); } void printf( Collection<?> col){ printf(col.stream()); } <T,K> void add( T t, K k){ if ( (t instanceof Collection<?>)) {(Collection<?>)t; } else if ( (t instanceof Object[])) {Arrays.stream((Object[])t).forEach((i)->add(i," ")); } else add(t); add(k); } <T> void add( T t){ answer.append(t); } int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} int[] ext_gcd( int a, int b){ if ( (b == 0)) return new int[]{a,1,0}; int[] vals = ext_gcd(b,(a % b));  int d = vals[0];  int p = vals[2];  int q = (vals[1] - ((a / b) * vals[2])); return new int[]{d,p,q};} int mod( int x){ return (x % MOD);} int mod( int x, int y){ return mod((mod(x) + mod(y)));} long mod( long x){ return (x % MOD);} long mod( long x, long y){ return mod((mod(x) + mod(y)));} long calc( int base, int exponent){ if ( (exponent == 0)) return 1; if ( (exponent == 1)) return (base % MOD); long m = calc(base,(exponent / 2)); if ( ((exponent % 2) == 0)) return ((m * m) % MOD); return ((base * ((m * m) % MOD)) % MOD);} long calc( int base, long exponent){ if ( (exponent == 0)) return 1; if ( (exponent == 1)) return (base % MOD); long m = calc(base,(exponent / 2)); if ( ((exponent % 2) == 0)) return ((m * m) % MOD); return ((base * ((m * m) % MOD)) % MOD);} long calc( long base, long exponent){ if ( (exponent == 0)) return 1; if ( (exponent == 1)) return (base % MOD); long m = calc(base,(exponent / 2)); if ( ((exponent % 2) == 0)) return ((m * m) % MOD); return ((base * ((m * m) % MOD)) % MOD);} long power( int base, int exponent){ if ( (exponent == 0)) return 1; long m = power(base,(exponent / 2)); if ( ((exponent % 2) == 0)) return (m * m); return ((base * m) * m);} static class Reader{ private BufferedReader br ; private StringTokenizer st ; Reader(){ br = new BufferedReader(new InputStreamReader(System.in)); } String next(){ try{while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(br.readLine()); } }catch (IOException e){ e.printStackTrace(); } return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} int[] nextIntArray( int n){ int[] arr = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = nextInt(); return arr;} } }
3	public class Main{ public static void main( String[] args){ Scanner scn = new Scanner(System.in);  int n = scn.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = scn.nextInt(); scn.close(); Arrays.sort(a); ArrayList<Integer> cyka = new ArrayList<>(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) { boolean add = true; for ( int k :cyka) {if ( ((a[i] % k) == 0)) {add = false; break;} }if ( add) {cyka.add(a[i]); } } }}System.out.println(cyka.size()); } }
4	public final class C{ static class Node{ int val ; String path ; Node node ; Node( String p, int t){ path = p; val = t; } } public static void main( String[] args){ final FastScanner fs = new FastScanner(); final int t = fs.nextInt(); final StringBuilder sb = new StringBuilder(); for ( int test = 0;(test < t);test++) {final int n = fs.nextInt(); final Deque<Node> dq = new ArrayDeque<>(); dq.offerLast(new Node("",0)); for ( int i = 0;(i < n);i++) {final int next = fs.nextInt(); if ( ((dq.getFirst().val + 1) != next)) {if ( (next == 1)) {final Node peek = dq.getFirst(); final String p = (peek.path.isEmpty()?String.valueOf(peek.val):((peek.path + '.') + peek.val)); dq.addFirst(new Node(p,1)); } else {while(((dq.getFirst().val + 1) != next)){dq.removeFirst(); }dq.getFirst().val++; }} else {dq.getFirst().val++; }add(sb,dq.getFirst(),dq.getFirst().val); }}System.out.println(sb); } static private void add( StringBuilder sb, Node node, int val){ final String p = (node.path.isEmpty()?String.valueOf(val):((node.path + '.') + val)); sb.append(p); sb.append('\n'); } static class FastScanner{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); private 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());} } }
0	public class A{ static Scanner scan = new Scanner(System.in); static PrintStream out = System.out; static void go( int n){ if ( (n == 0)) {System.out.println(((((0 + " ") + 0) + " ") + 0)); return ;} int a = 0,b = 1;  int c = (a + b); while((n > c)){a = b; b = c; c = (a + b); }System.out.println(((((0 + " ") + a) + " ") + b)); } public static void main( String[] args){ int n = scan.nextInt(); go(n); } }
1	public class SpreadSheet{ public void run(){ try{ Scanner s = new Scanner(System.in);  int tests = s.nextInt(); for ( int i = 0;(i < tests);i++) { String line = s.next();  String regex = "R[\\d]+C[\\d]+";  Pattern pattern = Pattern.compile(regex);  Matcher matcher = pattern.matcher(line); if ( matcher.matches()) { int r = Integer.parseInt(line.substring(1,line.indexOf("C")));  int c = Integer.parseInt(line.substring((line.indexOf("C") + 1))); System.out.println(toFormula(r,c)); } else { int index = -1; for ( int j = 0;(j < line.length());j++) {if ( ((line.charAt(j) >= '0') && (line.charAt(j) <= '9'))) {index = j; break;} } String c = line.substring(0,index);  int r = Integer.parseInt(line.substring(index)); System.out.println(fromFormula(c,r)); }} }catch (Exception e){ e.printStackTrace(); } } private String toFormula( int r, int c){ StringBuffer buff = new StringBuffer();  char ch ; while((c != 0)){ int m = (c % 26); if ( (m == 0)) {ch = 'Z'; c = ((c / 26) - 1); } else {ch = (char)((m + 'A') - 1); c /= 26; }buff.append(ch); }return (buff.reverse().toString() + r);} private String fromFormula( String c, int r){ int ret = 0;  int power = 1; for ( int i = (c.length() - 1);(i >= 0);i--) {ret += (((c.charAt(i) - 'A') + 1) * power); power *= 26; }return ((("R" + r) + "C") + ret);} public static void main( String[] args){ new SpreadSheet().run(); } }
5	public class round159A{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTokenizer(""); static int nextInt()throws Exception { return Integer.parseInt(next());} 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 { int n = nextInt();  int m = nextInt();  int k = nextInt();  int[] supply = new int[n]; for ( int i = 0;(i < n);++i) supply[i] = nextInt(); if ( (m <= k)) {System.out.println(0); } else { int have = k; Arrays.sort(supply); for ( int i = (n - 1);(i >= 0);--i) {have--; have += supply[i]; if ( (have >= m)) {System.out.println((n - i)); return ;} }System.out.println(-1); }} }
0	public class BankAccount{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String s = in.readLine();  int n = Integer.parseInt(s); if ( (s.charAt(0) == '-')) if ( (Integer.parseInt(s.substring(0,(s.length() - 1))) > Integer.parseInt((s.substring(0,(s.length() - 2)) + s.charAt((s.length() - 1)))))) s = s.substring(0,(s.length() - 1)); else s = (s.substring(0,(s.length() - 2)) + s.charAt((s.length() - 1))); System.out.println(Integer.parseInt(s)); in.close(); } }
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++; }} StringBuilder res = new StringBuilder();  int l ,r ,temp ,c1 ,c2 ; while((m-- > 0)){l = (in.nextInt() - 1); r = (in.nextInt() - 1); c1 = c2 = 0; for ( int i = 0;(i < (((r - l) + 1) / 2));i++) {if ( (a[(l + i)] > a[(r - i)])) c1++; else c2++; temp = a[(l + i)]; a[(l + i)] = a[(r - i)]; a[(r - i)] = temp; }count = ((count + c1) - c2); res.append((((Math.abs(count) % 2) == 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;} } }
0	public class CF125D2A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); System.out.println(("0 0 " + sc.nextInt())); } }
2	public class C817{ void solve(){ long n = nl(),s = nl();  long l = 0,r = n; while((l < r)){ long mid = ((l + r) / 2); if ( ((mid - digSum(mid)) < s)) l = (mid + 1); else r = mid; }out.println((((l - digSum(l)) >= s)?((n - l) + 1):0)); } int digSum( long k){ int sum = 0; while((k != 0)){sum += (k % 10); k /= 10; }return sum;} public static void main( String[] args){ new C817().run(); } private byte[] bufferArray = new byte[1024]; private int bufLength = 0; private int bufCurrent = 0; InputStream inputStream ; PrintWriter out ; public void run(){ inputStream = System.in; out = new PrintWriter(System.out); solve(); out.flush(); } int nextByte(){ if ( (bufLength == -1)) throw (new InputMismatchException()); if ( (bufCurrent >= bufLength)) {bufCurrent = 0; try{bufLength = inputStream.read(bufferArray); }catch (IOException e){ throw (new InputMismatchException());} if ( (bufLength <= 0)) return -1; } return bufferArray[bufCurrent++];} boolean isSpaceChar( int x){ return ((x < 33) || (x > 126));} boolean isDigit( int x){ return ((x >= '0') && (x <= '9'));} int nextNonSpace(){ int x ; while((((x = nextByte()) != -1) && isSpaceChar(x)));return x;} int ni(){ long ans = nl(); if ( ((Integer.MIN_VALUE <= ans) && (ans <= Integer.MAX_VALUE))) return (int)ans; throw (new InputMismatchException());} long nl(){ long ans = 0;  boolean neg = false;  int x = nextNonSpace(); if ( (x == '-')) {neg = true; x = nextByte(); } while(!isSpaceChar(x)){if ( isDigit(x)) {ans = (((ans * 10) + x) - '0'); x = nextByte(); } else throw (new InputMismatchException());}return (neg?-ans:ans);} String ns(){ StringBuilder sb = new StringBuilder();  int x = nextNonSpace(); while(!isSpaceChar(x)){sb.append((char)x); x = nextByte(); }return sb.toString();} }
3	public class test{ public static void main( String[] args)throws IOException { Scanner s = new Scanner(System.in);  StringTokenizer st = new StringTokenizer(s.nextLine());  int n = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken()); st = new StringTokenizer(s.nextLine()); int[] array = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = Integer.parseInt(st.nextToken()); } ArrayList<State> list = new ArrayList<State>(); for ( int i = 0;(i < n);i++) { double currY = r; for ( int j = 0;(j < list.size());j++) { double xDiff = Math.abs((list.get(j).getX() - array[i])); if ( (xDiff <= (2 * r))) {if ( (currY < (list.get(j).getY() + Math.sqrt((((4 * r) * r) - (xDiff * xDiff)))))) {currY = (list.get(j).getY() + Math.sqrt((((4 * r) * r) - (xDiff * xDiff)))); } } }list.add(new State(array[i],currY)); System.out.print((currY + " ")); }s.close(); } static class State{ double x ; double y ; public State( double a, double b){ x = a; y = b; } public double getX(){ return x;} public double getY(){ return y;} } }
6	public class KeyboardPurchase{ static final int INF = 1000000000; public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out,false);  int N = in.nextInt(),M = in.nextInt();  String str = in.next();  int[][] count = new int[M][M]; for ( int i = 1;(i < N);i++) { char c1 = str.charAt((i - 1)),c2 = str.charAt(i); count[(c1 - 'a')][(c2 - 'a')]++; count[(c2 - 'a')][(c1 - 'a')]++; } int[] dp = new int[(1 << M)]; Arrays.fill(dp,INF); dp[0] = 0; for ( int mask = 1;(mask < (1 << M));mask++) { int slow = 0; for ( int i = 0;(i < M);i++) {if ( ((mask & (1 << i)) != 0)) {for ( int j = 0;(j < M);j++) {if ( ((mask & (1 << j)) == 0)) {slow += count[i][j]; } }} }for ( int i = 0;(i < M);i++) {if ( ((mask & (1 << i)) != 0)) {dp[mask] = Math.min(dp[mask],(slow + dp[(mask ^ (1 << i))])); } }}out.println(dp[((1 << M) - 1)]); out.close(); System.exit(0); } 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 ProblemD{ static int mod = (int)(1e9 + 7); static InputReader in ; static PrintWriter out ; static void update( int i, int val, int[] bit){ for ( ;(i < bit.length);i += (i & -i)) bit[i] += val; } static int query( int i, int[] bit){ int ans = 0; for ( ;(i > 0);i -= (i & -i)) ans += bit[i]; return ans;} static void solve(){ in = new InputReader(System.in); out = new PrintWriter(System.out); int n = in.nextInt();  int[] arr = new int[(n + 1)];  int[] bit = new int[(n + 2)]; for ( int i = 1;(i <= n);i++) {arr[i] = in.nextInt(); } int cnt = 0; for ( int i = n;(i > 0);i--) {cnt += query(arr[i],bit); update(arr[i],1,bit); }cnt %= 2; int q = in.nextInt(); while((q-- > 0)){ int l = in.nextInt();  int r = in.nextInt();  int length = ((r - l) + 1);  int x = ((length * (length - 1)) / 2); x %= 2; cnt ^= x; out.println(((cnt == 0)?"even":"odd")); }out.close(); } public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } 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 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); } } }
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());} } }
4	public class Main{ void run(){ Locale.setDefault(Locale.US); boolean oj = (System.getProperty("ONLINE_JUDGE") != null); try{if ( oj) {sc = new FastScanner(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); } else {sc = new FastScanner(new FileReader("in.txt")); out = new PrintWriter(new FileWriter("out.txt")); } }catch (Exception e){ System.exit(-1); } long tB = System.currentTimeMillis(); solve(); if ( !oj) System.err.println(("Time: " + ((System.currentTimeMillis() - tB) / 1e3))); out.flush(); } class FastScanner{ BufferedReader br ; StringTokenizer st = new StringTokenizer(""); FastScanner( InputStreamReader a){ br = new BufferedReader(a); } FastScanner( FileReader a){ br = new BufferedReader(a); } String next(){ while(!st.hasMoreTokens())try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ return null;} return st.nextToken();} String readLine(){ try{return br.readLine(); }catch (Exception e){ return null;} } int nextInt(){ return Integer.parseInt(next());} } FastScanner sc ; PrintWriter out ; public static void main( String[] args){ new Main().run(); } void exit( int val){ out.flush(); System.exit(val); } int n ,m ; boolean[][] grid ; ArrayList<Integer>[] gr ; int c ; int[] mt ; boolean[] u ; boolean try_kuhn( int v){ if ( u[v]) return false; u[v] = true; for ( int to :gr[v]) {if ( ((to == c) || !grid[v][to])) continue; if ( ((mt[to] == -1) || try_kuhn(mt[to]))) {mt[to] = v; return true;} }return false;} void solve(){ n = sc.nextInt(); m = sc.nextInt(); grid = new boolean[(n + 1)][(n + 1)]; gr = new ArrayList[(n + 1)]; for ( int v = 1;(v <= n);++v) gr[v] = new ArrayList<Integer>(); for ( int it = 0;(it < m);++it) { int a = sc.nextInt();  int b = sc.nextInt(); grid[a][b] = true; gr[a].add(b); } int ans = Integer.MAX_VALUE; for ( c = 1;(c <= n);++c) { int curAns = 0; for ( int v = 1;(v <= n);++v) if ( (v != c)) {if ( !grid[c][v]) ++curAns; if ( !grid[v][c]) ++curAns; } if ( !grid[c][c]) ++curAns; mt = new int[(n + 1)]; fill(mt,-1); for ( int i = 1;(i <= n);++i) if ( (i != c)) {u = new boolean[(n + 1)]; try_kuhn(i); } int szMt = 0; for ( int i = 1;(i <= n);++i) if ( (mt[i] != -1)) ++szMt; curAns += ((n - 1) - szMt); for ( int a = 1;(a <= n);++a) {for ( int b = 1;(b <= n);++b) {if ( (((a == c) || (b == c)) || !grid[a][b])) continue; if ( (a == mt[b])) ++curAns; }}ans = min(ans,curAns); }out.println(ans); } }
5	public class A{ public A()throws IOException{ String input = r.readLine();  int N = Integer.parseInt(input);  int[] A = new int[N]; input = r.readLine(); String[] S = input.split(" "); for ( int i = 0;(i < N);++i) A[i] = Integer.parseInt(S[i]); solve(N,A); } public void solve( int N, int[] A){ t = millis(); Arrays.sort(A); if ( (A[(N - 1)] > 1)) A[(N - 1)] = 1; else A[(N - 1)] = 2; Arrays.sort(A); System.out.print(A[0]); for ( int i = 1;(i < N);++i) System.out.print((" " + A[i])); System.out.println(); } static BufferedReader r ; static long t ; static void print2( Object o){ System.out.println(o); } static void print( Object o){ print2(o); System.exit(0); } static void run()throws IOException { r = new BufferedReader(new InputStreamReader(System.in)); new A(); } public static void main( String[] args)throws IOException { run(); } static long millis(){ return System.currentTimeMillis();} }
0	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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, FastScanner in, FastPrinter out){ long a = in.nextLong();  long b = in.nextLong(); if ( (a < b)) { long t = a; a = b; b = t; } long ans = 0; while((b > 0)){ans += (a / b); long t = (a % b); a = b; b = t; }out.println(ans); } } 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());} } public String next(){ StringBuilder sb = new StringBuilder();  int c = read(); while(isWhiteSpace(c)){c = read(); }if ( (c < 0)) {return null;} while(((c >= 0) && !isWhiteSpace(c))){sb.appendCodePoint(c); c = read(); }return sb.toString();} static boolean isWhiteSpace( int c){ return ((c >= 0) && (c <= 32));} public long nextLong(){ return Long.parseLong(next());} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
5	public class Main{ static class Scanner{ StreamTokenizer in ; boolean forceMode = false; Scanner( InputStream is, String codePage, boolean forceMode){ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is))); if ( !forceMode) {in.resetSyntax(); in.wordChars(33,255); in.whitespaceChars(0,32); } } Scanner( InputStream is, String codePage){ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is))); if ( !forceMode) {in.resetSyntax(); in.wordChars(33,255); in.whitespaceChars(0,32); } } String next(){ try{in.nextToken(); return in.sval; }catch (Exception e){ throw (new Error());} } int nextInt(){ if ( forceMode) {try{in.nextToken(); return (int)in.nval; }catch (Exception e){ throw (new Error());} } else {return Integer.parseInt(next());}} } Scanner in ; PrintWriter out ; class Int implements Comparable<Int>{ int value ; int pos ; public Int( int value, int pos){ this.value = value; this.pos = pos; } } void solve(){ int n = in.nextInt();  Int ar[] = new Int[n]; for ( int i = 0;(i < ar.length);i++) {ar[i] = new Int(in.nextInt(),i); }Arrays.sort(ar); int cnt = 0; for ( int i = 0;(i < ar.length);i++) {if ( (ar[i].value != ar[ar[i].pos].value)) {cnt++; } }if ( ((cnt == 2) || (cnt == 0))) {out.println("YES"); } else {out.println("NO"); }} static final String fileName = ""; void run(){ in = new Scanner(System.in,""); out = new PrintWriter(System.out); try{solve(); }catch (Exception e){ throw (new Error(e));} finally{out.close(); }} public static void main( String[] args){ new Main().run(); } }
3	public class PythonIndentation{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int t = sc.nextInt();  int a[] = new int[t];  int c = 0; a[0] = 1; long mod = (long)(1e9 + 7); sc.nextLine(); for ( int i = 0;(i < t);i++) { String s = sc.nextLine(); if ( s.equals("f")) c++; else {for ( int j = 1;(j <= c);j++) {a[j] = (int)(((a[j] % mod) + (a[(j - 1)] % mod)) % mod); }}}System.out.println(a[c]); sc.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);  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[] a = in.readIntArray(n); ArrayUtils.radixSort(a); int answer = 0;  boolean[] used = new boolean[a.length]; for ( int i = 0;(i < a.length);++i) {if ( used[i]) continue; used[i] = true; answer++; for ( int j = (i + 1);(j < a.length);++j) if ( ((a[j] % a[i]) == 0)) used[j] = true; }out.println(answer); } } static class OutputWriter extends PrintWriter{ public OutputWriter( OutputStream outputStream){ super(outputStream); } public OutputWriter( Writer writer){ super(writer); } public OutputWriter( String filename)throws FileNotFoundException{ super(filename); } public void close(){ super.close(); } } static class InputReader extends BufferedReader{ StringTokenizer tokenizer ; public InputReader( InputStream inputStream){ super(new InputStreamReader(inputStream),32768); } public InputReader( String filename){ super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename))); } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(readLine()); }catch (IOException e){ throw (new RuntimeException());} }return tokenizer.nextToken();} public Integer nextInt(){ return Integer.valueOf(next());} public int[] readIntArray( int size){ int[] array = new int[size]; for ( int i = 0;(i < size);i++) array[i] = nextInt(); return array;} } }
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; } }
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;} } }
6	public class D{ static boolean[][] adj ; static int n ; static int first ; public static void main( String[] args)throws IOException { InputReader in = new InputReader(); n = in.nextInt(); int m = in.nextInt(); adj = new boolean[n][n]; dp = new long[(1 << n)][n]; for ( int i = 0;(i < m);i++) { int f = (in.nextInt() - 1);  int t = (in.nextInt() - 1); adj[f][t] = adj[t][f] = true; } boolean[] v = new boolean[(1 << n)];  long res = 0; for ( int f = 0;(f < n);f++) {first = f; int cnt ; for ( int i = 0;(i < (1 << n));i += (1 << first)) if ( ((i & (1 << first)) == 0)) for ( int j = 0;(j < n);j++) dp[i][j] = -1; for ( int i = 0;(i < (1 << n));i += (1 << first)) {cnt = Integer.bitCount(i); if ( ((((i & (1 << first)) == 0) && !v[(i | (1 << first))]) && (cnt > 1))) {v[(i | (1 << first))] = true; res += solve(i,first,cnt); } }}System.out.println((res / 2)); } static long[][] dp ; public static long solve( int msk, int lst, int cnt){ if ( (cnt == 0)) return (adj?1:0); if ( (dp[msk][lst] != -1)) return dp[msk][lst]; long res = 0; for ( int i = 0;(i < n);i++) if ( (adj[lst][i] && ((msk & (1 << i)) > 0))) res += solve((msk ^ (1 << i)),i,(cnt - 1)); return dp[msk][lst] = res;} static class InputReader{ BufferedReader in ; StringTokenizer st ; public InputReader()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(in.readLine()); } public String next()throws IOException { while(!st.hasMoreElements())st = new StringTokenizer(in.readLine()); return st.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} } }
6	public class PetyaSpiders implements Runnable{ public static void main( String[] args)throws Exception { new Thread(null,new PetyaSpiders(),": )",(1 << 28)).start(); } static int N ,M ; static int oo = 999; static int[] dr = {1,0,-1,0},dc = {0,1,0,-1}; static boolean isValid( int prev, int curr, int next){ boolean[][] grid = new boolean[N][3];  int[] subsets = {prev,curr,next}; for ( int r = 0;(r < N);r++) {for ( int c = 0;(c < 3);c++) {if ( ((subsets[c] & 1) > 0)) {grid[r][c] = true; for ( int k = 0;(k < 4);k++) { int r2 = (r + dr[k]);  int c2 = (c + dc[k]); if ( ((((0 <= r2) && (r2 <= (N - 1))) && (0 <= c2)) && (c2 <= 2))) {grid[r2][c2] = true; } }} subsets[c] >>= 1; }}for ( int r = 0;(r < N);r++) {if ( !grid[r][1]) {return false;} }return true;} 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);} public double nextDouble(){ double cur = nextLong(); return ((c != '.')?cur:(cur + (nextLong() / cnt)));} } }
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); } }
5	public class A{ final int MOD = ((int)1e9 + 7); final double eps = 1e-12; final int INF = (int)1e9; public A(){ int N = sc.nextInt();  int K = sc.nextInt();  Long[] A = sc.nextLongs(); sort(A); Set<Long> S = new HashSet<Long>(); for ( long a :A) {if ( (((a % K) == 0) && S.contains(H((a / K))))) continue; S.add(H(a)); } int res = S.size(); exit(res); } long P = probablePrime(60,new Random()).longValue(); long Q = probablePrime(60,new Random()).longValue(); long H( long x){ return ((P * x) % Q);} 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 A(); exit(); } static void start(){ t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t ; static long millis(){ return System.currentTimeMillis();} }
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(); } public static void solve(){ int t = 1; u:while((t-- > 0)){ int n = s(0);  int m = s(0);  int k = s(0);  long[][][] arr = new long[n][m][4]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { long v = s(0l); arr[i][j][0] = v; arr[i][(j + 1)][2] = v; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { long v = s(0l); arr[i][j][1] = v; arr[(i + 1)][j][3] = v; }} Long[][][] dp = new Long[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) for ( int p = 1;(p <= k);p++) helper(i,j,p,dp,arr,n,m); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) p((dp[i][j][k] + " ")); pln(""); }}} static int[][] dir = new int[][]{{0,1},{1,0},{0,-1},{-1,0}}; public static long helper( int i, int j, int k, Long[][][] dp, long[][][] arr, int n, int m){ if ( (k < 0)) return -1; if ( (k == 0)) return 0; if ( (dp[i][j][k] != null)) return dp[i][j][k]; int x ,y ;  long ans = Long.MAX_VALUE,val ; for ( int d = 0;(d < 4);d++) {x = (i + dir[d][0]); y = (j + dir[d][1]); if ( ((((x < 0) || (x >= n)) || (y < 0)) || (y >= m))) continue; val = helper(x,y,(k - 2),dp,arr,n,m); if ( (val != -1)) ans = Math.min(ans,(val + (2 * arr[i][j][d]))); }return dp[i][j][k] = ((ans == Long.MAX_VALUE)?-1:ans);} 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( 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 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 p( int n){ pw.print(n); } public static void p( long n){ pw.print(n); } public static void p( String n){ pw.print(n); } public static void p( double n){ pw.print(n); } 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); } 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());} } }
1	public class codef8{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int num = sc.nextInt();  int beacon[] = new int[1000001];  int pos[] = new int[num]; for ( int i = 0;(i < num);i++) { int position = sc.nextInt(); beacon[position] = sc.nextInt(); pos[i] = position; } int dp[] = new int[1000001];  int max = 1; if ( (beacon[0] != 0)) dp[0] = 1; for ( int i = 1;(i <= 1000000);i++) {if ( (beacon[i] == 0)) {dp[i] = dp[(i - 1)]; } else { int j = ((i - beacon[i]) - 1); if ( (j < 0)) {dp[i] = 1; } else {dp[i] = (dp[j] + 1); }}max = Math.max(max,dp[i]); }System.out.println((num - max)); } }
3	public class A{ public static void main( String[] args)throws Exception { new A().run(); } public void run()throws Exception { FastIO file = new FastIO();  int n = file.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = file.nextInt(); Arrays.sort(a); boolean[] used = new boolean[n];  int count = 0; for ( int i = 0;(i < n);i++) {if ( !used[i]) {count++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {used[j] = true; } }} }System.out.println(count); } public static class FastIO{ BufferedReader br ; StringTokenizer st ; public FastIO(){ 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 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 - 1) / 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 - 1) / 2)); temp = (temp * temp); return (temp * n);}} public static long gcd( long x, long y){ if ( (x == 0)) return y; else return gcd((y % x),x);} }
3	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(){ solve(); } public void solve(){ int n = io.readInt();  int[] data = new int[n]; for ( int i = 0;(i < n);i++) {data[i] = io.readInt(); }Arrays.sort(data); boolean[] paint = new boolean[n];  int cnt = 0; for ( int i = 0;(i < n);i++) {if ( paint[i]) {continue;} cnt++; for ( int j = i;(j < n);j++) {if ( ((data[j] % data[i]) == 0)) {paint[j] = true; } }}io.cache.append(cnt); } } 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 + " = ")); } } }
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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }Arrays.sort(a); int nc = 0; for ( int i = 0;(i < n);i++) { boolean divs = false; for ( int j = 0;(j < i);j++) {if ( ((a[i] % a[j]) == 0)) {divs = true; break;} }if ( !divs) {nc++; } }out.println(nc); } } }
0	public class taskA{ void solve()throws IOException { long a = nextLong();  long b = nextLong();  long ans = 0; while(((a != 0) && (b != 0))){if ( (a > b)) {ans += (a / b); a %= b; } else { long c = (b % a); ans += (b / a); b = a; a = c; }}out.println(ans); } BufferedReader br ; StringTokenizer st ; PrintWriter out ; void run(){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } public static void main( String[] args){ new taskA().run(); } String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} long nextLong()throws NumberFormatException,IOException { return Long.parseLong(nextToken());} }
0	public class HexadecimalTheorem{ public static void main( String[] args){ Scanner read = new Scanner(System.in);  int num = read.nextInt();  int zero ,one ,two ,three ; zero = 0; one = 1; two = 1; three = 2; if ( (num == 0)) System.out.println("0 0 0"); else if ( (num == 1)) System.out.println("0 0 1"); else {while((num != three)){zero = one; one = two; two = three; three = (three + one); }System.out.println(((((zero + " ") + one) + " ") + one)); }} }
4	public class codeforces{ static final long MOD2 = 998_244_353; public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int tc = sc.ni(); for ( int rep = 0;(rep < tc);rep++) { int N = sc.ni();  int[] arr = sc.intArray(N); pw.println(solve(arr)); }pw.close(); } static String solve( int[] arr){ StringBuilder sb = new StringBuilder();  List<Integer> list = new ArrayList(); list.add(0); for ( int i = 0;(i < arr.length);i++) { int x = arr[i]; for ( int j = (list.size() - 1);(j >= 0);j--) {if ( ((x - 1) == list.get(j))) {list.set(j,x); while((list.size() > (j + 1))){list.remove((list.size() - 1)); }list.add(0); for ( int idx = 0;(idx < (list.size() - 1));idx++) {sb.append((list.get(idx) + ".")); }sb.setLength((sb.length() - 1)); sb.append("\n"); break;} }}sb.setLength((sb.length() - 1)); return sb.toString();} static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} public static void sort( int[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( long[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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());} }
0	public class CF275Ad2{ public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in);  long l = scan.nextLong();  long r = scan.nextLong();  long diff = (r - l);  boolean exists = false; if ( (diff >= 3)) {if ( ((l % 2) == 1)) {l++; } exists = true; } else if ( ((diff == 2) && ((l % 2) == 0))) {exists = true; } else if ( ((diff == 2) && (gcd(l,r) > 1))) {exists = true; } if ( !exists) {System.out.println("-1"); } else {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); }} static private long gcd( long a, long b){ if ( (b == 0)) {return 1;} return gcd(b,(a % b));} }
2	public class ProblemA{ InputReader in ; PrintWriter out ; long power( long a, long b, long mod){ long ret = 1;  long mul = a; while((b > 0)){if ( ((b % 2) == 1)) {ret = ((ret * mul) % mod); } mul = ((mul * mul) % mod); b = (b / 2); }return ret;} void solve(){ long n = in.nextLong();  long m = in.nextLong();  long k = in.nextLong();  long mod = 1000000009;  long x = (m - (n - (n / k))); if ( (x <= 0)) {out.println(m); } else { long score = 1; score = power(2,(x + 1),mod); score = (((score + mod) - 2) % mod); long ans = (((((score * k) + m) - (x * k)) + mod) % mod); out.println(ans); }} 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 long nextLong(){ return Long.parseLong(next());} }
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);} static private 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; } } static private 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(); } } static private class RuntimeIOException extends RuntimeException{ static private final long serialVersionUID = -6463830523020118289L; RuntimeIOException( Throwable cause){ super(cause); } } static private final int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; static private final int[][] steps8 = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{1,-1},{-1,1}}; static private boolean checkIndex( int index, int lim){ return ((0 <= index) && (index < lim));} static private boolean checkBit( int mask, int bit){ return ((mask & (1 << bit)) != 0);} static private boolean checkBit( long mask, int bit){ return ((mask & (1L << bit)) != 0);} static private long gcd( long a, long b){ return ((a == 0)?b:gcd((b % a),a));} }
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(); } 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]))); 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)))); } int[] best = new int[(1 << n)];  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] = (i + 1); for ( int j = (i + 1);(j < n);++j) if ( ((set & (1 << j)) != 0)) { int cur = (best[((set ^ (1 << i)) ^ (1 << j))] + pair[i][j]); if ( (cur < best[set])) {best[set] = cur; prev[set] = (((i + 1) * 100) + (j + 1)); } } }writer.println(best[((1 << n) - 1)]); int now = ((1 << n) - 1); writer.print("0"); while((now > 0)){ int what = prev[now];  int wa = ((what % 100) - 1);  int wb = ((what / 100) - 1); if ( (wa >= 0)) {writer.print(" "); writer.print((wa + 1)); now ^= (1 << wa); } if ( (wb >= 0)) {writer.print(" "); writer.print((wb + 1)); now ^= (1 << wb); } 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();} }
1	public class B{ public static void main( String[] args){ FastScanner sc = new FastScanner();  int T = sc.nextInt(); while((T-- > 0)){ int n = sc.nextInt(); if ( (((n % 2) == 0) && issq((n / 2)))) {System.out.println("YES"); } else if ( (((n % 4) == 0) && issq((n / 4)))) {System.out.println("YES"); } else {System.out.println("NO"); }}} static boolean issq( long x){ long rx = (long)Math.sqrt(x); return ((rx * rx) == x);} static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
1	public class Solution{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader( String s){ try{br = new BufferedReader(new FileReader(s)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public FastReader(){ 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 FastReader f = new FastReader(); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st ; static StringBuilder sb = new StringBuilder(); static long[] fact ; static long gcd( long a, long b){ if ( ((a == 0) || (b == 0))) {return Math.max(a,b);} if ( ((a % b) == 0)) {return b;} return gcd(b,(a % b));} static long mult( long a, long b){ return ((a * b) % mod);} static long modPow( long a, int step){ long ans = 1; while((step != 0)){if ( ((step & 1) != 0)) ans = mult(ans,a); a = mult(a,a); step >>= 1; }return ans;} static private final int mod = (int)(1e9 + 7); static int MAX_N = (int)Math.sqrt(1e9); public static void main( String[] args)throws IOException { int test = f.nextInt();  TreeSet<Integer> set = new TreeSet<>(); for ( int i = 1;(i <= MAX_N);i++) {set.add(((i * i) * 2)); set.add(((i * i) * 4)); }for ( int t = 1;(t <= test);t++) { int n = f.nextInt(); if ( set.contains(n)) {sb.append("YES").append("\n"); } else {sb.append("NO").append("\n"); }}System.out.println(sb); } }
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)); }} } }
6	public class Main{ static double[] dp ; static double[][] P ; public static void main( String[] args){ Scanner r = new Scanner(System.in);  int n = r.nextInt();  double[][] g = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) g[i][j] = r.nextDouble(); dp = new double[(1 << n)]; P = new double[(1 << n)][n]; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int d = 0;(d < n);d++) if ( ((mask & (1 << d)) == 0)) for ( int i = 0;(i < n);i++) if ( ((mask & (1 << i)) == 0)) {if ( (i == d)) continue; P[mask][d] += g[i][d]; } }for ( int i = 0;(i < n);i++) {Arrays.fill(dp,-1); double res = go(i,0,g,n,n); System.out.println(res); }} static private double go( int a, int v, double[][] g, int cnt, int n){ if ( (dp[v] != -1)) return dp[v]; if ( (cnt == 1)) {return 1;} else { double ret = 0; for ( int d = 0;(d < n);d++) if ( (((v & (1 << d)) == 0) && (d != a))) { double current = (P[v][d] * go(a,(v | (1 << d)),g,(cnt - 1),n)); ret += current; } return dp[v] = (ret / ((cnt * (cnt - 1)) / 2));}} }
2	public class CodeForces{ static private int gcd( int a, int b){ if ( (b == 0)) return a; return gcd(b,(a % b));} private long pow( long a, long p){ if ( (p == 0)) return 1; long b = pow(a,(p / 2)); b = (b * b); if ( ((p % 2) == 1)) b *= a; return (b % mod);} static private int countOne( int a){ if ( (a == 0)) return 0; return (countOne((a & (a - 1))) + 1);} int N ; int R ; int[][] C = new int[10][10]; int M ; int mod = 1_000_000_007; long IMPO ; int ans ; int[] dx = new int[]{1,0,-1,0}; int[] dy = new int[]{0,-1,0,1}; Map<String,Boolean> dp = new HashMap<>(); List<List<Integer>> graph = new ArrayList<>(); List<Edge> edges = new ArrayList<>(); int[] parent ; boolean[] visited ; public void run( Scanner scanner)throws IOException { long k = scanner.nextLong();  int len = 1;  long number = 9; for ( int i = 0;true;i++) {if ( ((len * number) < k)) {k -= (len * number); len++; number *= 10; } else {break;}}number /= 9; StringBuilder sb = new StringBuilder(); for ( int i = 1;(i <= 9);i++) {if ( ((len * number) < k)) {k -= (len * number); } else {sb.append(i); break;}}for ( int i = 1;(i < len);i++) {number /= 10; for ( int j = 0;(j <= 9);j++) {if ( ((len * number) < k)) {k -= (len * number); } else {sb.append(j); break;}}}System.out.println(sb.charAt(((int)k - 1))); } public static void main( String[] args)throws NumberFormatException,IOException { Scanner scanner = new Scanner(System.in);  CodeForces jam = new CodeForces(); jam.run(scanner); } }
6	public class Main{ StreamTokenizer in ; PrintWriter out ; public static void main( String[] args)throws Exception { new Main().run(); } public void run()throws Exception { Locale.setDefault(Locale.US); in = new StreamTokenizer(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;} class Senator{ int b ; int l ; public Senator( int b, int l){ this.b = b; this.l = l; } } int n ,k ,A ; double max = Integer.MIN_VALUE; Senator[] a ; public void check( int step, int candy){ if ( (step == n)) { double tmp = 0.0; for ( int mask = 0;(mask < (1 << n));mask++) { double P = 1.0;  int q = 0; for ( int i = 0;(i < n);i++) {if ( (((mask >> i) & 1) != 0)) {P *= (a[i].l / 100.); } else {P *= (1.0 - (a[i].l / 100.)); q += a[i].b; }}if ( (Integer.bitCount(mask) > (n / 2))) {tmp += P; } else {tmp += ((P * A) / (A + q)); }max = Math.max(tmp,max); }} else {for ( int i = 0;(i <= Math.min(k,((100 - a[step].l) / 10)));i++) {a[step].l += (10 * i); check((step + 1),(k - i)); a[step].l -= (10 * i); }}} public void solve()throws Exception { n = nextInt(); k = nextInt(); A = nextInt(); a = new Senator[n]; for ( int i = 0;(i < n);i++) { Senator q = new Senator(nextInt(),nextInt()); a[i] = q; } double ans = 0; for ( int mask = 0;(mask < (1 << ((n + k) - 1)));mask++) {if ( (Integer.bitCount(mask) != k)) continue; int[] b = new int[n];  int x = mask; for ( int i = 0;(i < n);i++) {b[i] = a[i].l; while(((x % 2) == 1)){b[i] += 10; x /= 2; }b[i] = Math.min(b[i],100); x /= 2; } double tmp = 0; for ( int w = 0;(w < (1 << n));w++) { double p = 1.;  double B = 0; for ( int i = 0;(i < n);i++) if ( (((w >> i) & 1) != 0)) p *= (b[i] / 100.); else {p *= (1 - (b[i] / 100.)); B += a[i].b; }if ( (Integer.bitCount(w) > (n / 2))) tmp += p; else tmp += (p * (A / (A + B))); }ans = Math.max(ans,tmp); }out.printf("%.10f\n",ans); } }
3	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int count = sc.nextInt();  HashSet<Integer> set = new HashSet<>(); for ( int i = 0;(i < count);i++) {set.add(sc.nextInt()); } ArrayList<Integer> list = new ArrayList<>(set); Collections.sort(list); for ( int i = 0;(i < list.size());i++) {for ( int j = (i + 1);(j < list.size());j++) {if ( (((list.get(i) % list.get(j)) == 0) || ((list.get(j) % list.get(i)) == 0))) {list.remove(j); j--; } }}System.out.println(list.size()); } }
0	public class Main{ FastScanner in ; PrintWriter out ; public void solve()throws IOException { double a = in.nextInt();  double v = in.nextInt();  double l = in.nextInt();  double d = in.nextInt();  double w = in.nextInt(); if ( ((((w * w) / (a * 2)) > d) || (v < w))) {if ( (((v * v) / (a * 2)) > l)) {out.println(Math.sqrt(((l * 2) / a))); } else { double t = (v / a);  double s = (l - ((t * v) / 2)); t = (t + (s / v)); out.println(t); }return ;} double t = solveD(a,v,w,d); if ( ((((v + w) * (v - w)) / (a * 2)) > (l - d))) { double dis = ((w * w) + ((a * (l - d)) * 2));  double t1 = ((Math.sqrt(dis) - w) / a); System.out.println((t + t1)); } else { double t1 = ((v - w) / a);  double s = ((l - d) - (((v + w) * t1) / 2));  double t2 = (s / v); System.out.println(((t + t1) + t2)); }} public double solveD( double a, double vMax, double wBound, double s){ double v = Math.sqrt(((a * s) + ((wBound * wBound) / 2))); if ( (v > vMax)) {v = vMax; } double t1 = (v / a);  double t2 = ((v - wBound) / a);  double s1 = ((v * t1) / 2);  double s2 = (((v + wBound) * t2) / 2);  double sr = ((s - s1) - s2);  double tr = (sr / v); return ((t1 + t2) + tr);} public void run(){ try{in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } 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 Main().run(); } }
4	public class Main{ 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());} int[] nextArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} long[] nextArray( long n){ long[] a = new long[(int)n]; for ( int i = 0;(i < n);i++) a[i] = nextLong(); return a;} long nextLong(){ return Long.parseLong(next());} } static class FastWriter extends PrintWriter{ FastWriter(){ super(System.out); } void println( int[] array){ for ( int i = 0;(i < array.length);i++) {print((array[i] + " ")); }println(); } void println( long[] array){ for ( int i = 0;(i < array.length);i++) {print((array[i] + " ")); }println(); } } static int x ,y ; public static void main( String[] args){ FastScanner in = new FastScanner();  FastWriter out = new FastWriter();  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int[][] right = new int[n][(m - 1)];  int[][] down = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {right[i] = in.nextArray((m - 1)); }for ( int i = 0;(i < (n - 1));i++) {down[i] = in.nextArray(m); }if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print("-1 "); }out.println(); }} else { int[][] dp = new int[n][m];  int[][] dp1 = new int[n][m]; for ( int i = 0;(i < (k / 2));i++) {for ( int j = 0;(j < n);j++) {for ( int l = 0;(l < m);l++) { int ans = Integer.MAX_VALUE; if ( (j > 0)) {ans = Math.min(ans,(dp[(j - 1)][l] + down[(j - 1)][l])); } if ( (l > 0)) {ans = Math.min(ans,(dp[j][(l - 1)] + right[j][(l - 1)])); } if ( (j != (n - 1))) {ans = Math.min(ans,(dp[(j + 1)][l] + down[j][l])); } if ( (l != (m - 1))) {ans = Math.min(ans,(dp[j][(l + 1)] + right[j][l])); } dp1[j][l] = ans; }}dp = dp1; dp1 = new int[n][m]; }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.println(((2 * dp[i][j]) + " ")); }out.println(); }}out.close(); } }
6	public class Main{ InputReader input ; PrintWriter output ; void run(){ output = new PrintWriter(new OutputStreamWriter(System.out)); input = new InputReader(System.in); solve(); output.flush(); } public static void main( String[] args){ new Main().run(); } boolean isBitSet( int mask, int i){ return ((mask & (1 << i)) != 0);} int unSet( int mask, int i){ return (mask & (1 << i));} void solve(){ int n = input.ni();  double[][] prb = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {prb[i][j] = input.readDouble(); }} double[] dp = new double[(1 << n)]; dp[0] = 1.0; for ( int i = 0;(i < (1 << n));i++) { int remaining = (n - Integer.bitCount(i));  double remainingProbability = ((remaining * (remaining - 1)) / 2); for ( int j = 0;(j < n);j++) {if ( !isBitSet(i,j)) {for ( int k = 0;(k < n);k++) {if ( !isBitSet(i,k)) dp[(i | (1 << j))] += ((dp[i] * prb[k][j]) / remainingProbability); }} }}for ( int i = 0;(i < n);i++) {output.printf("%.7f ",dp[unSet(((1 << n) - 1),i)]); }output.println(); } class InputReader{ private boolean finished = false; 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 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 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 String ns(){ 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 isWhitespace(c);} public 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 String readLine( boolean ignoreEmptyLines){ if ( ignoreEmptyLines) return readLine(); else return readLine0();} public double readDouble(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } double res = 0; while((!isSpaceChar(c) && (c != '.'))){if ( ((c == 'e') || (c == 'E'))) return (res * Math.pow(10,ni())); if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }if ( (c == '.')) {c = read(); double m = 1; while(!isSpaceChar(c)){if ( ((c == 'e') || (c == 'E'))) return (res * Math.pow(10,ni())); if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); m /= 10; res += ((c - '0') * m); c = read(); }} return (res * sgn);} } public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } }
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();} } }
5	public class A{ public static void main( String[] args)throws IOException { new A().solveProblem(); out.close(); } static Scanner in = new Scanner(new InputStreamReader(System.in)); static PrintStream out = new PrintStream(new BufferedOutputStream(System.out)); public void solveProblem(){ int n = in.nextInt();  E[] get = new E[n]; for ( int i = 0;(i < n);i++) {get[i] = new E(i,in.nextInt()); }sort(get); if ( (get[(n - 1)].g == 1)) {get[(n - 1)].g = 2; } else {get[(n - 1)].g = 1; }sort(get); for ( int i = 0;(i < (n - 1));i++) out.print((get[i].g + " ")); out.println(get[(n - 1)].g); } class E implements Comparable<E>{ int g ; int index ; public E( int index, int g){ this.g = g; this.index = index; } } }
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());} } }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}candidate = new int[n]; xs = new Xorshift(); mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; int[] candidate ; Xorshift xs ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {if ( (Long.bitCount(choosed) < Long.bitCount(mds))) mds = choosed; return ;} { long s = covered; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); s |= ((1L << i) | g[i]); }if ( (s != ((1L << n) - 1))) {return ;} } int index = 0;  int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) {index = 0; candidate[index++] = i; k = i; } else if ( (Long.bitCount((g[i] & ~covered)) == Long.bitCount((g[k] & ~covered)))) {candidate[index++] = i; } }if ( (k == -1)) return ; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } class Xorshift{ int x ,y ,z ,w ; public Xorshift(){ x = 123456789; y = 362436069; z = 521288629; w = 88675123; } public Xorshift( int seed){ x = _(seed,0); y = _(x,1); z = _(y,2); w = _(z,3); } int _( int s, int i){ return (((1812433253 * (s ^ (s >>> 30))) + i) + 1);} public int nextInt(){ int t = (x ^ (x << 11)); x = y; y = z; z = w; return w = (((w ^ (w >>> 19)) ^ t) ^ (t >>> 8));} public int nextInt( int n){ return (int)(n * nextDouble());} public double nextDouble(){ int a = (nextInt() >>> 5),b = (nextInt() >>> 6); return (((a * 67108864.0) + b) * (1.0 / (1L << 53)));} } 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 P111C().run(); } }
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 "); } }
2	public class A{ static private 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{ static private final long serialVersionUID = -8565341110209207657L; } public static class IOFast{ private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); static private int pos ,readLen ; static private final char[] buffer = new char[(1024 * 8)]; static private final char[] str = new char[((500000 * 8) * 2)]; static private boolean[] isDigit = new boolean[256]; static private boolean[] isSpace = new boolean[256]; static private 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 class CF274A{ public static void main( String[] args)throws Exception { new CF274A().solve(); } private void solve()throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  long k = sc.nextInt();  Integer[] a = new Integer[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); }Arrays.sort(a); HashSet<Integer> used = new HashSet<>(n);  int count = 0; for ( int i = 0;(i < n);i++) { Integer v = a[i]; if ( !used.contains(v)) {count++; long next = (v * k); if ( (next <= 1000000000)) used.add((int)next); } }System.out.println(count); } }
2	public class B{ public static BufferedReader in ; public static PrintWriter out ; public static void main( String[] args)throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); boolean showLineError = true; if ( showLineError) {solve(); out.close(); } else {try{solve(); }catch (Exception e){ } finally{out.close(); }}} static private void solve()throws IOException { String[] line = in.readLine().split(" ");  long n = (Long.parseLong(line[0]) - 1);  long k = (Long.parseLong(line[1]) - 1); if ( (f(1,k) < n)) {out.println(-1); return ;} if ( (n == 0)) {out.println(0); return ;} long lo = 0l;  long hi = k; while(((lo + 1l) < hi)){ long m = ((lo + hi) / 2l);  long f = f(((k - m) + 1),k); if ( (f < n)) {lo = m; } else {hi = m; }}out.println(hi); } static private long f( long lo, long hi){ return (((lo + hi) * ((hi - lo) + 1l)) / 2l);} }
4	public class E2_SquareFreeFast{ static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ int T = sc.nextInt();  int MAX = (int)1e7;  int[] canonical = new int[(MAX + 1)]; canonical[1] = 1; for ( int factor = 2;(factor <= MAX);factor++) {if ( (canonical[factor] == 0)) {for ( int mult = factor;(mult <= MAX);mult += factor) { int prev = canonical[(mult / factor)]; if ( ((prev % factor) == 0)) {canonical[mult] = (prev / factor); } else {canonical[mult] = (prev * factor); }}} } int[] last = new int[(MAX + 1)]; while((T-- > 0)){ int N = sc.nextInt();  int K = sc.nextInt();  int[] a = new int[(N + 1)];  int[][] dp = new int[2][(K + 1)];  int[][] start = new int[2][(K + 1)];  int ptr = 0; for ( int i = 1;(i <= N);i++) { int nxt = (1 ^ ptr); a[i] = canonical[sc.nextInt()]; for ( int k = 0;(k <= K);k++) {if ( (start[ptr][k] > last[a[i]])) {dp[nxt][k] = dp[ptr][k]; start[nxt][k] = start[ptr][k]; } else {dp[nxt][k] = (dp[ptr][k] + 1); start[nxt][k] = i; }if ( (((i > 1) && (k > 0)) && (start[ptr][(k - 1)] <= last[a[i]]))) {if ( ((dp[ptr][(k - 1)] < dp[nxt][k]) || ((dp[ptr][(k - 1)] == dp[nxt][k]) && (start[ptr][(k - 1)] > start[nxt][k])))) {dp[nxt][k] = dp[ptr][(k - 1)]; start[nxt][k] = start[ptr][(k - 1)]; } } }last[a[i]] = i; ptr = nxt; }for ( int v :a) {last[v] = 0; }out.println(dp[ptr][K]); }out.close(); } 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); } } 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++];} int nextInt(){ return (int)nextLong();} 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);} } }
5	public class p1096f{ static long MOD = 998244353; public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  BIT invert = new BIT((n + 5));  BIT neg = new BIT((n + 5));  long res = 0;  int[] arr = new int[n];  boolean[] has = new boolean[(n + 1)];  long num1 = 0; for ( int i = 0;(i < n);i++) {arr[i] = in.nextInt(); if ( (arr[i] != -1)) {res += (invert.read((n + 5)) - invert.read(arr[i])); res %= MOD; invert.update(arr[i],1); has[arr[i]] = true; } else num1++; }if ( (num1 == 0)) {System.out.println(res); return ;} for ( int i = 1;(i <= n);i++) if ( !has[i]) neg.update(i,1);  long invertNum1 = modInv(num1,MOD); res += (((num1 * (num1 - 1)) % MOD) * modInv(4,MOD)); res %= MOD; long cnt = 0; for ( int i = 0;(i < n);i++) {if ( (arr[i] == -1)) {cnt++; continue;} res += ((((neg.read((n + 5)) - neg.read(arr[i])) * cnt) % MOD) * invertNum1); res %= MOD; }cnt = 0; for ( int i = (n - 1);(i >= 0);i--) {if ( (arr[i] == -1)) {cnt++; continue;} res += (((neg.read(arr[i]) * cnt) % MOD) * invertNum1); res %= MOD; }System.out.println(res); } static class BIT{ int n ; int[] tree ; public BIT( int n){ this.n = n; tree = new int[(n + 1)]; } int read( int i){ int sum = 0; while((i > 0)){sum += tree[i]; i -= (i & -i); }return sum;} void update( int i, int val){ while((i <= n)){tree[i] += val; i += (i & -i); }} } static long modInv( long x, long mod){ return BigInteger.valueOf(x).longValue();} static long modInv( long a, long b, long y0, long y1, long q0, long q1){ long y2 = (y0 - (y1 * q0)); return ((b == 0)?y2:modInv(b,(a % b),y1,y2,q1,(a / b)));} static long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} }
0	public class pregunta1{ public static void main( String[] args){ System.out.println("25"); } }
5	public class A{ final String filename = new String("C").toLowerCase(); void solve()throws Exception { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }if ( isSorted(a)) {out.println("YES"); return ;} int pos1 = -1; for ( int i = 0;(i < (n - 1));i++) {if ( (a[i] > a[(i + 1)])) { int j = i; while(((j >= 0) && (a[j] == a[i]))){j--; }pos1 = (j + 1); break;} } int pos2 = -1; for ( int i = (n - 2);(i >= 0);i--) {if ( (a[i] > a[(i + 1)])) { int j = (i + 1); while(((j < n) && (a[j] == a[(i + 1)]))){j++; }pos2 = (j - 1); break;} } int tmp = a[pos1]; a[pos1] = a[pos2]; a[pos2] = tmp; if ( isSorted(a)) {out.println("YES"); } else {out.println("NO"); }} boolean isSorted( int[] a){ for ( int i = 0;(i < (a.length - 1));i++) {if ( (a[i] > a[(i + 1)])) {return false;} }return true;} void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } BufferedReader in ; StringTokenizer st ; PrintWriter out ; 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());} public static void main( String[] args){ new A().run(); } }
5	public class A implements Runnable{ String file = "input"; boolean TEST = (System.getProperty("ONLINE_JUDGE") == null); void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); int[] b = a.clone(); sortInt(b); int count = 0; for ( int i = 0;(i < a.length);i++) if ( (a[i] != b[i])) count++; if ( ((count == 0) || (count == 2))) out.println("YES"); else out.println("NO"); } Random rnd = new Random(); void sortInt( int[] a){ sortInt(a,0,(a.length - 1)); } void sortInt( int[] a, int from, int to){ if ( (from >= to)) return ; int i = (from - 1);  int p = (rnd.nextInt(((to - from) + 1)) + from);  int t = a[p]; a[p] = a[to]; a[to] = t; for ( int j = from;(j < to);j++) if ( (a[j] <= a[to])) {i++; t = a[i]; a[i] = a[j]; a[j] = t; } t = a[(i + 1)]; a[(i + 1)] = a[to]; a[to] = t; sortInt(a,(i + 2),to); while(((i >= 0) && (a[i] == a[(i + 1)])))i--; sortInt(a,from,i); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(input.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} BufferedReader input ; PrintWriter out ; StringTokenizer st ; int test ; void init()throws IOException { if ( TEST) input = new BufferedReader(new FileReader((file + ".in"))); else input = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new BufferedOutputStream(System.out)); } public static void main( String[] args)throws IOException { new Thread(null,new A(),"",(1 << 22)).start(); } }
6	public class C599{ static ArrayList<Integer>[] adj ; static long[] a ; static int[] type ; static Map<Long,Integer> map ; static int[] vis ; static HashSet<Integer> cy ; static boolean[] good ; static int[] dp ; static HashSet<Integer>[] nodes ; public static void main( String[] args){ MyScanner sc = new MyScanner();  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int k = sc.nextInt();  int cur = 0; a = new long[75007]; long sum = 0; type = new int[75007]; map = new HashMap<>(); long[] typeSum = new long[k]; for ( int i = 0;(i < k);i++) { int n = sc.nextInt();  long temp = sum; for ( int j = 0;(j < n);j++) {cur++; a[cur] = sc.nextLong(); type[cur] = i; map.put(a[cur],cur); sum += a[cur]; }typeSum[i] = (sum - temp); } boolean notDiv = ((sum % k) != 0);  long need = (sum / k);  int n = cur; adj = new ArrayList[(n + 1)]; for ( int i = 1;(i <= n);i++) adj[i] = new ArrayList<>(); for ( int i = 1;(i <= n);i++) { long delta = (need - typeSum[type[i]]);  long find = (a[i] + delta); if ( map.containsKey(find)) {if ( ((type[map.get(find)] != type[i]) || (delta == 0))) adj[i].add(map.get(find)); } }vis = new int[(n + 1)]; good = new boolean[(1 << k)]; good[0] = true; nodes = new HashSet[(1 << k)]; for ( int i = 1;(i <= n);i++) {if ( (vis[i] == 0)) {cy = new HashSet<>(); boolean b = dfs(i);  int mask = 0; for ( Integer node :cy) {mask |= (1 << type[node]); }if ( (mask != 0)) nodes[mask] = cy; good[mask] = true; } }dp = new int[(1 << k)]; Arrays.fill(dp,-1); int possible = solve(((1 << k) - 1)); if ( ((possible == 1) && !notDiv)) { ArrayList<Integer> masks = dfs2(((1 << k) - 1));  long[] num = new long[k];  int[] ret = new int[k]; for ( Integer mask :masks) {for ( Integer node :nodes[mask]) {num[type[node]] = a[node]; ret[type[adj[node].get(0)]] = (type[node] + 1); }} boolean good = true;  Set<Integer> soFar = new HashSet<>(); for ( int i = 0;(i < ret.length);i++) {if ( soFar.contains(ret[i])) good = false; soFar.add(ret[i]); }if ( !good) {out.println("No"); out.close(); return ;} out.println("Yes"); for ( int i = 0;(i < k);i++) {out.println(((num[i] + " ") + ret[i])); }} else {out.println("No"); }out.close(); } static int solve( int mask){ if ( (dp[mask] != -1)) return dp[mask]; if ( good[mask]) return dp[mask] = 1; int ret = 0; for ( int i = ((mask - 1) & mask);(i > 0);i = ((i - 1) & mask)) {ret = (solve(i) & solve((mask ^ i))); if ( (ret == 1)) break; }return dp[mask] = ret;} static ArrayList<Integer> dfs2( int mask){ ArrayList<Integer> ret = new ArrayList<>(); if ( good[mask]) {ret.add(mask); return ret;} for ( int i = ((mask - 1) & mask);(i > 0);i = ((i - 1) & mask)) {if ( ((dp[i] == 1) && (dp[(mask ^ i)] == 1))) { ArrayList<Integer> one = dfs2(i);  ArrayList<Integer> two = dfs2((mask ^ i)); ret.addAll(one); ret.addAll(two); break;} }return ret;} static boolean dfs( int cur){ vis[cur] = 1; boolean ret = false; for ( Integer next :adj[cur]) {if ( (vis[next] == 0)) { boolean cycle = dfs(next); if ( cycle) {if ( !cy.contains(cur)) {cy.add(cur); ret = true; break;} } } else if ( (vis[next] == 1)) {cy.add(next); cy.add(cur); if ( (next != cur)) ret = true; break;} }vis[cur] = 2; return ret;} 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());} } }
2	public class BBi implements Runnable{ public static void main( String[] args){ new Thread(new BBi()).run(); } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer in ; PrintWriter out = new PrintWriter(System.out); public String nextToken()throws IOException { while(((in == null) || !in.hasMoreTokens())){in = new StringTokenizer(br.readLine()); }return in.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} public long nextLong()throws IOException { return Long.parseLong(nextToken());} int n ,x ,y ; public long count( long z){ long total = 0;  long[][] c = new long[][]{{x,y},{y,((n - x) + 1)},{((n - x) + 1),((n - y) + 1)},{((n - y) + 1),x}}; for ( int i = 0;(i < c.length);i++) { long inside = z; for ( int j = 0;(j < c[i].length);j++) {if ( (z > c[i][j])) {total += (Math.min((z - c[i][j]),c[i][(1 - j)]) * c[i][j]); inside -= (z - c[i][j]); } }if ( ((z > c[i][0]) && (z > c[i][1]))) {total -= (Math.min((z - c[i][0]),c[i][1]) * Math.min((z - c[i][1]),c[i][0])); } if ( (inside > 0)) total += ((inside * (inside + 1)) / 2); }for ( int i = 0;(i < c.length);i++) {total -= Math.min(z,c[i][0]); }return (total + 1);} public long solve( int n, int x, int y, long c)throws IOException { this.n = n; this.x = x; this.y = y; long l = 0;  long r = ((2L * n) + 2); while(((r - l) > 1)){ long z = ((l + r) / 2); if ( (c <= count(z))) {r = z; } else {l = z; }}return (r - 1);} public void run(){ try{out.println(solve(nextInt(),nextInt(),nextInt(),nextLong())); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } }
4	public class SolutionC{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int t = sc.nextInt();  int[] arr = new int[10000002]; for ( int i = 0;(i < arr.length);i++) {arr[i] = i; }for ( int i = 2;((i * i) < arr.length);i++) { int b = (i * i); for ( int j = b;(j < arr.length);j += b) {arr[j] = (j / b); }} int[] pp = new int[10000001]; Arrays.fill(pp,-1); while((t-- > 0)){ int n = sc.nextInt();  int k = sc.nextInt();  int[] aa = new int[n]; for ( int i = 0;(i < n);i++) { int a = sc.nextInt(); aa[i] = arr[a]; } 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; }out.println((mp[k] + 1)); for ( int i = 0;(i < n);i++) {pp[aa[i]] = -1; }}out.close(); } }
6	public class Main implements Runnable{ StreamTokenizer ST ; PrintWriter out ; BufferedReader br ; Scanner in ; static final int inf = (1000000000 + 10); 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[] x = new int[32];  int[] y = new int[32]; x[0] = nextInt(); y[0] = nextInt(); int n = nextInt(); for ( int i = 1;(i <= n);i++) {x[i] = nextInt(); y[i] = nextInt(); }n++; int[][] a = new int[n][n];  int[][] b = new int[(n - 1)][(n - 1)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) a[i][j] = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); for ( int i = 1;(i < n);i++) for ( int j = 1;(j < n);j++) if ( (i != j)) b[(i - 1)][(j - 1)] = ((a[0][i] + a[i][j]) + a[j][0]); else b[(i - 1)][(j - 1)] = (2 * a[0][i]); n--; int sz = (1 << n);  int[] d = new int[sz];  int[] p = new int[sz]; d[1] = 0; for ( int msk = 1;(msk < sz);msk++) { int j = 0; while(((msk & (1 << j)) == 0))j++; int t = inf; for ( int i = 0;(i < n);i++) if ( ((msk & (1 << i)) > 0)) if ( (t > (d[(msk ^ ((1 << i) | (1 << j)))] + b[i][j]))) {t = (d[(msk ^ ((1 << i) | (1 << j)))] + b[i][j]); p[msk] = ((i * n) + j); } d[msk] = t; }out.println(d[(sz - 1)]); out.print("0 "); int t = (sz - 1); while((t > 0)){ int hz = p[t];  int i = (hz / n);  int j = (hz % n); if ( (i != j)) out.print(((((i + 1) + " ") + (j + 1)) + " 0 ")); else out.print(((i + 1) + " 0 ")); t ^= ((1 << i) | (1 << j)); }} }
1	public class Noldbach{ public Scanner in = new Scanner(System.in); public PrintStream out = System.out; public boolean[] yes ; public int n ,k ; public void main(){ n = in.nextInt(); k = in.nextInt(); genPrime(); int i ; yes = new boolean[(n + 1)]; int x ; for ( i = 0;((i + 1) < prime.length);++i) {x = ((prime[i] + prime[(i + 1)]) + 1); if ( ((x <= n) && (fac[x] == x))) yes[x] = true; } int count = 0; for ( i = 0;(i < yes.length);++i) if ( yes[i]) ++count; out.println(((count >= k)?"YES":"NO")); } public int N = (100000 + 100); public int[] fac ,rest ; public int[] prime ; public void genPrime(){ ArrayList<Integer> ap = new ArrayList<Integer>(); fac = new int[N]; rest = new int[N]; int x ,y ; for ( x = 0;(x < N);++x) {fac[x] = x; rest[x] = 1; }for ( x = 2;(x < N);++x) if ( (fac[x] == x)) {ap.add(x); for ( y = (x + x);(y < N);y += x) if ( (fac[y] == y)) {fac[y] = x; rest[y] = (y / x); } } prime = new int[ap.size()]; for ( int i = 0;(i < prime.length);++i) prime[i] = ap.get(i); } public static void main( String[] args){ new Noldbach().main(); } }
4	public class C{ static FastIO f ; public static void main( String[] args)throws IOException { f = new FastIO(); int t ,n ,a ,i ;  Node r ,p ,c ; t = f.ni(); while((t-- > 0)){n = f.ni(); r = p = new Node(-1,null); for ( i = 0;(i < n);i++) {a = f.ni(); if ( (a != 1)) {while((a != (p.i + 1)))p = p.p; p = p.p; } c = new Node(a,p); p.c.add(c); p = c; }dfs(r,""); }f.flush(); } public static void dfs( Node n, String s)throws IOException { String t ; if ( (n.i == -1)) t = s; else {t = ((s + n.i) + "."); f.out(((s + n.i) + "\n")); }for ( Node c :n.c) dfs(c,t); } static class Node{ int i ; Node p ; ArrayList<Node> c ; Node( int x, Node y){ i = x; p = y; c = new ArrayList<>(); } } public static class FastIO{ BufferedReader br ; BufferedWriter bw ,be ; StringTokenizer st ; public FastIO(){ br = new BufferedReader(new InputStreamReader(System.in)); bw = new BufferedWriter(new OutputStreamWriter(System.out)); be = new BufferedWriter(new OutputStreamWriter(System.err)); st = new StringTokenizer(""); } private void read()throws IOException { st = new StringTokenizer(br.readLine()); } public String ns()throws IOException { while(!st.hasMoreTokens())read(); return st.nextToken();} public int ni()throws IOException { return Integer.parseInt(ns());} public long nl()throws IOException { return Long.parseLong(ns());} public void out( String s)throws IOException { bw.write(s); } public void flush()throws IOException { bw.flush(); be.flush(); } } }
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(); } }
5	public class Cottage{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  List<Point> houses = new ArrayList<Point>(); for ( int i = 0;(i < n);i++) { int x = sc.nextInt();  int a = sc.nextInt(); houses.add(new Point(x,a)); }Collections.sort(houses,new Comparator<Point>(){}); int pos = 2; for ( int i = 0;(i < (n - 1));i++) { double end = (houses.get(i).x + ((houses.get(i).y + 0.0) / 2));  double start = (houses.get((i + 1)).x - ((houses.get((i + 1)).y + 0.0) / 2));  double diff = (start - end); if ( (Math.abs((diff - t)) < 0.0000001)) {pos++; } if ( (diff > t)) {pos += 2; } }System.out.println(pos); } }
5	public class Main{ FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ Main task = new Main(); task.solve(); task.close(); } public void close(){ in.close(); out.close(); } public void solve(){ int n = in.nextInt();  int k = in.nextInt();  Team[] teams = new Team[n]; for ( int i = 0;(i < n);i++) { Team t = new Team(); t.tasks = in.nextInt(); t.penalty = in.nextInt(); teams[i] = t; }Arrays.sort(teams); Team t = teams[(k - 1)];  int ans = 0; for ( int i = 0;(i < teams.length);i++) {if ( teams[i].equals(t)) ans++; }System.out.println(ans); } class Team implements Comparable<Team>{ int tasks ; int penalty ; @Override public int hashCode(){ final int prime = 31;  int result = 1; result = ((prime * result) + getOuterType().hashCode()); result = ((prime * result) + penalty); result = ((prime * result) + tasks); 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 ( (penalty != other.penalty)) return false; if ( (tasks != other.tasks)) return false; return true;} private Main getOuterType(){ return this;} } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ System.err.println(e); return "";} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} void close(){ try{br.close(); }catch (IOException e){ } } }
3	public class Codeforces455Div2C{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] sp = br.readLine().split(" ");  int n = Integer.parseInt(sp[0]);  char[] list = new char[n]; for ( int i = 0;(i < n);i++) {sp = br.readLine().split(" "); list[i] = sp[0].charAt(0); } int[] list2 = new int[n];  int counter = 0; for ( int i = 0;(i < n);i++) {if ( (list[i] == 's')) {counter++; } else {list2[counter]++; }} int[][] dp = new int[counter][((n - counter) + 1)];  int[][] dpsum = new int[counter][((n - counter) + 1)];  int[] count = new int[counter]; count[0] = list2[0]; for ( int i = 1;(i < counter);i++) {count[i] = (count[(i - 1)] + list2[i]); }for ( int i = 0;(i <= count[0]);i++) {dp[0][i] = 1; dpsum[0][i] = (i + 1); }for ( int i = 1;(i < counter);i++) {for ( int j = 0;(j <= count[i]);j++) {dp[i][j] = dpsum[(i - 1)][Math.min(j,count[(i - 1)])]; }dpsum[i][0] = dp[i][0]; for ( int j = 1;(j <= count[i]);j++) {dpsum[i][j] = ((dpsum[i][(j - 1)] + dp[i][j]) % 1000000007); }}System.out.println(dp[(counter - 1)][(n - counter)]); } }
4	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 COnTheBench{ Modular mod = new Modular((1e9 + 7)); Factorial fact = new Factorial(1000,mod); Combination comb = new Combination(fact); Debug debug = new Debug(true); public int f( int i, int j){ int ans = mod.mul(fact.fact(i),comb.combination((((i + j) - 1) - j),(j - 1))); ans = mod.mul(ans,fact.invFact(j)); return ans;} public void solve( int testNumber, FastInput in, FastOutput out){ int n = in.readInt();  DSU dsu = new DSU(n);  long[] a = new long[n]; for ( int i = 0;(i < n);i++) {a[i] = in.readInt(); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( square((a[j] * a[i]))) {dsu.merge(j,i); break;} }} IntegerList list = new IntegerList(); for ( int i = 0;(i < n);i++) {if ( (dsu.find(i) == i)) {list.add(dsu.size[dsu.find(i)]); } } int[] cnts = list.toArray(); debug.debug("cnts",cnts); int m = cnts.length;  int[][] dp = new int[(m + 1)][(n + 1)]; dp[0][0] = 1; for ( int i = 1;(i <= m);i++) { int way = cnts[(i - 1)]; for ( int j = 0;(j <= n);j++) {dp[i][j] = 0; for ( int k = 1;((k <= j) && (k <= way));k++) { int contrib = mod.mul(f(way,k),dp[(i - 1)][(j - k)]); dp[i][j] = mod.plus(dp[i][j],contrib); }}}debug.debug("dp",dp); int ans = 0; for ( int i = 0;(i <= n);i++) { int local = mod.mul(dp[m][i],fact.fact(i)); if ( (((n - i) % 2) == 1)) {local = mod.valueOf(-local); } ans = mod.plus(ans,local); }out.println(ans); } public boolean square( long x){ long l = 1;  long r = (long)1e9; while((l < r)){ long m = ((l + r) / 2); if ( ((m * m) < x)) {l = (m + 1); } else {r = m; }}return ((l * l) == x);} } static class IntegerList implements Cloneable{ private int size ; private int cap ; private int[] data ; static private final int[] EMPTY = new int[0]; public IntegerList( int cap){ this.cap = cap; if ( (cap == 0)) {data = EMPTY; } else {data = new int[cap]; }} public IntegerList( IntegerList list){ this.size = list.size; this.cap = list.cap; this.data = Arrays.copyOf(list.data,size); } public IntegerList(){ this(0); } public void ensureSpace( int req){ if ( (req > cap)) {while((cap < req)){cap = Math.max((cap + 10),(2 * cap)); }data = Arrays.copyOf(data,cap); } } public void add( int x){ ensureSpace((size + 1)); data[size++] = x; } public void addAll( int[] x, int offset, int len){ ensureSpace((size + len)); System.arraycopy(x,offset,data,size,len); size += len; } public void addAll( IntegerList list){ addAll(list.data,0,list.size); } public int[] toArray(){ return Arrays.copyOf(data,size);} public String toString(){ return Arrays.toString(toArray());} public int hashCode(){ int h = 1; for ( int i = 0;(i < size);i++) {h = ((h * 31) + Integer.hashCode(data[i])); }return h;} } static class Combination implements IntCombination{ final Factorial factorial ; final Modular modular ; public Combination( Factorial factorial){ this.factorial = factorial; this.modular = factorial.getModular(); } public Combination( int limit, Modular modular){ this(new Factorial(limit,modular)); } public int combination( int m, int n){ if ( (n > m)) {return 0;} return modular.mul(modular.mul(factorial.fact(m),factorial.invFact(n)),factorial.invFact((m - n)));} } 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 interface IntCombination{ } static class FastOutput implements AutoCloseable,Closeable,Appendable{ private StringBuilder cache = new StringBuilder((10 << 20)); private final Writer os ; public FastOutput append( CharSequence csq){ cache.append(csq); return this;} public FastOutput append( CharSequence csq, int start, int end){ cache.append(csq,start,end); return this;} public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput append( char c){ cache.append(c); return this;} public FastOutput append( int c){ cache.append(c); return this;} public FastOutput println( int c){ return append(c).println();} public FastOutput println(){ cache.append(System.lineSeparator()); 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();} } static class InverseNumber{ int[] inv ; public InverseNumber( int[] inv, int limit, Modular modular){ this.inv = inv; inv[1] = 1; int p = modular.getMod(); for ( int i = 2;(i <= limit);i++) { int k = (p / i);  int r = (p % i); inv[i] = modular.mul(-k,inv[r]); }} public InverseNumber( int limit, Modular modular){ this(new int[(limit + 1)],limit,modular); } } static class Debug{ private boolean offline ; private PrintStream out = System.err; static int[] empty = new int[0]; public Debug( boolean enable){ offline = (enable && (System.getSecurityManager() == null)); } public Debug debug( String name, Object x){ return debug(name,x,empty);} public Debug debug( String name, Object x, int... indexes){ if ( offline) {if ( ((x == null) || !x.getClass().isArray())) {out.append(name); for ( int i :indexes) {out.printf("[%d]",i); }out.append("=").append(("" + x)); out.println(); } else {indexes = Arrays.copyOf(indexes,(indexes.length + 1)); if ( (x instanceof byte[])) { byte[] arr = (byte[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else if ( (x instanceof short[])) { short[] arr = (short[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else if ( (x instanceof boolean[])) { boolean[] arr = (boolean[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else if ( (x instanceof char[])) { char[] arr = (char[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else if ( (x instanceof int[])) { int[] arr = (int[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else if ( (x instanceof float[])) { float[] arr = (float[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else if ( (x instanceof double[])) { double[] arr = (double[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else if ( (x instanceof long[])) { long[] arr = (long[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }} else { Object[] arr = (Object[])x; for ( int i = 0;(i < arr.length);i++) {indexes[(indexes.length - 1)] = i; debug(name,arr[i],indexes); }}}} return this;} } static class Factorial{ int[] fact ; int[] inv ; Modular modular ; public Modular getModular(){ return modular;} public Factorial( int[] fact, int[] inv, InverseNumber in, int limit, Modular modular){ this.modular = modular; this.fact = fact; this.inv = inv; fact[0] = inv[0] = 1; for ( int i = 1;(i <= limit);i++) {fact[i] = modular.mul(fact[(i - 1)],i); inv[i] = modular.mul(inv[(i - 1)],in.inv[i]); }} public Factorial( int limit, Modular modular){ this(new int[(limit + 1)],new int[(limit + 1)],new InverseNumber(limit,modular),limit,modular); } public int fact( int n){ return fact[n];} public int invFact( int n){ return inv[n];} } static class DSU{ protected int[] p ; protected int[] rank ; int[] size ; public DSU( int n){ p = new int[n]; rank = new int[n]; size = new int[n]; reset(); } public final void reset(){ for ( int i = 0;(i < p.length);i++) {p[i] = i; rank[i] = 0; size[i] = 1; }} public final int find( int a){ if ( (p[a] == p[p[a]])) {return p[a];} return p[a] = find(p[a]);} public final void merge( int a, int b){ a = find(a); b = find(b); if ( (a == b)) {return ;} if ( (rank[a] == rank[b])) {rank[a]++; } if ( (rank[a] < rank[b])) { int tmp = a; a = b; b = tmp; } size[a] += size[b]; p[b] = a; } } static class Modular{ int m ; public int getMod(){ return m;} public Modular( int m){ this.m = m; } public Modular( long m){ this.m = (int)m; if ( (this.m != m)) {throw (new IllegalArgumentException());} } public Modular( double m){ this.m = (int)m; if ( (this.m != m)) {throw (new IllegalArgumentException());} } public int valueOf( int x){ x %= m; if ( (x < 0)) {x += m; } return x;} public int valueOf( long x){ x %= m; if ( (x < 0)) {x += m; } return (int)x;} public int mul( int x, int y){ return valueOf(((long)x * y));} public int plus( int x, int y){ return valueOf((x + y));} public String toString(){ return ("mod " + m);} } }
2	public class CF{ long mod = ((long)1e9 + 9); int k ; long pow( long n, long k){ if ( (k == 0)) return 1; long m1 = pow(n,(k / 2)); m1 = ((m1 * m1) % mod); if ( ((k % 2) != 0)) m1 = ((m1 * n) % mod); return m1;} long mysol( int n, int m, int k){ this.k = k; int parts = (n / k); if ( (parts > (n - m))) { long ost = (n - ((n - m) * k));  long power = (ost / k);  long res = pow(2,(power + 1));  long cur = ((((res - 2) + mod) % mod) * k); cur %= mod; cur += Math.max(0,(m - (power * k))); cur %= mod; return cur;} else {return m;}} void realSolve()throws IOException { int n = in.nextInt();  int m = in.nextInt(); k = in.nextInt(); out.println(mysol(n,m,k)); } private class InputReader{ StringTokenizer st ; BufferedReader br ; 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)); } String next(){ while(((st == null) || !st.hasMoreElements())){ String s ; try{s = br.readLine(); }catch (IOException e){ return null;} if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} boolean hasMoreElements(){ while(((st == null) || !st.hasMoreElements())){ String s ; try{s = br.readLine(); }catch (IOException e){ return false;} st = new StringTokenizer(s); }return st.hasMoreElements();} } InputReader in ; PrintWriter out ; void solveIO()throws IOException { in = new InputReader(System.in); out = new PrintWriter(System.out); realSolve(); out.close(); } public static void main( String[] args)throws IOException { new CF().solveIO(); } }
6	public class Fish{ double memo[] = new double[(1 << 18)]; int N ,FULL ; double prob[][] = new double[18][18]; Fish(){ Scanner in = new Scanner(System.in); Arrays.fill(memo,-1); N = in.nextInt(); FULL = ((1 << N) - 1); for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < N);j++) {prob[i][j] = in.nextDouble(); }}for ( int i = 0;(i < N);i++) {System.out.printf("%.6f ",go((1 << i))); }System.out.println(); } public double go( int mask){ if ( (mask == FULL)) return 1.0; if ( (memo[mask] >= 0)) return memo[mask]; double ret = 0;  double mult = (Integer.bitCount(mask) + 1); mult *= ((mult - 1) / 2.0); for ( int i = 0;(i < N);i++) {if ( (((1 << i) & mask) != 0)) {for ( int j = 0;(j < N);j++) {if ( (((1 << j) & mask) == 0)) {ret += (go((mask | (1 << j))) * prob[i][j]); } }} }ret /= mult; memo[mask] = ret; return ret;} public static void main( String[] args){ new Fish(); } }
1	public class B{ static long sqr( long a){ return (a * a);} static void solve()throws Exception { int tests = scanInt(); for ( int test = 0;(test < tests);test++) { int n = scanInt(); out.println((((n == (2 * sqr(round(sqrt((n / 2)))))) || (n == (4 * sqr(round(sqrt((n / 4)))))))?"YES":"NO")); }} 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); } } }
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(); } }
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 int mod = ((int)Math.pow(10,9) + 7); public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ((in.readString().charAt(0) == 'f')?1:0); } long[][] ans = new long[n][(n + 2)]; ans[0][0] = 1; int indent = 0; if ( (a[0] == 1)) indent++; for ( int i = 1;(i < n);i++) {if ( (a[(i - 1)] == 1)) {for ( int j = (indent - 1);(j >= 1);j--) {ans[i][j] = ans[(i - 1)][(j - 1)]; }ans[i][indent] = 1; } else {for ( int j = indent;(j >= 0);j--) {ans[i][j] = ((ans[i][(j + 1)] + ans[(i - 1)][j]) % mod); }}indent += a[i]; } long aa = 0; for ( int i = 0;(i < (n + 2));i++) {aa = ((aa + ans[(n - 1)][i]) % mod); }out.println(aa); } } static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read(){ try{if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) return -1; } }catch (IOException e){ throw (new RuntimeException(e));} return buf[curChar++];} public int readInt(){ return (int)readLong();} public long readLong(){ int c = read(); while(isSpaceChar(c)){c = read(); if ( (c == -1)) throw (new RuntimeException()); } boolean negative = false; if ( (c == '-')) {negative = true; 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 (negative?res:res);} public String readString(){ int c = read(); while(isSpaceChar(c))c = read(); StringBuilder res = new StringBuilder(); do {res.append((char)c); c = read(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
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(); } } }
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(); } }
0	public class A235{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  long n = Long.parseLong(reader.readLine()); if ( (n <= 2)) System.out.println(n); else if ( (n == 3)) System.out.println("6"); else if ( ((n % 2) == 0)) {if ( ((n % 3) == 0)) {System.out.println((((n - 3) * (n - 1)) * (n - 2))); } else System.out.println(((n * (n - 1)) * (n - 3))); } else System.out.println(((n * (n - 1)) * (n - 2))); } }
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);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ int digitsum( long n){ int ans = 0; while((n > 0)){ans += (n % 10); n /= 10; }return ans;} public void solve( int testNumber, InputReader in, PrintWriter out){ long n = in.nextLong();  long s = in.nextLong(); if ( (s >= n)) {out.println(0); return ;} long ans = s; while((ans < (s + digitsum(ans)))){ans++; }if ( (n >= ans)) {out.println(((n - ans) + 1)); } else {out.println(0); }} } 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 long nextLong(){ return Long.parseLong(next());} } }
3	public class C{ static int sqr( int x){ return (x * x);} static void solve()throws Exception { int n = scanInt();  int r = scanInt();  int x[] = new int[n];  double y[] = new double[n]; for ( int i = 0;(i < n);i++) { int cx = x[i] = scanInt();  double cy = r; for ( int j = 0;(j < i);j++) {if ( (abs((cx - x[j])) <= (2 * r))) {cy = max(cy,(y[j] + sqrt((sqr((2 * r)) - sqr((cx - x[j])))))); } }y[i] = cy; if ( (i > 0)) {out.print(' '); } out.printf(Locale.US,"%.9f",cy); }} 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); } } }
6	public class Main implements Runnable{ final String filename = ""; public void solve()throws Exception { int n = iread(),m = iread();  int INF = -1; if ( (m > n)) { int t = m; m = n; n = t; } int[][][] d = new int[2][(1 << m)][(1 << m)]; for ( int i = 0;(i < (1 << m));i++) Arrays.fill(d[0][i],INF); int[] cnt = new int[(1 << m)]; for ( int i = 0;(i < (1 << m));i++) cnt[i] = (cnt[(i / 2)] + (i % 2)); int step = 0; d[0][0][0] = 0; for ( int u = 0;(u < n);u++) {for ( int i = 0;(i < (1 << m));i++) Arrays.fill(d[(step ^ 1)][i],INF); for ( int mask1 = 0;(mask1 < (1 << m));mask1++) for ( int mask2 = 0;(mask2 < (1 << m));mask2++) { int t = d[step][mask1][mask2]; if ( (t == INF)) continue; for ( int mask = 0;(mask < (1 << m));mask++) {if ( ((mask1 & mask) != mask1)) continue; int mask01 = (((1 << m) - 1) & ~mask2); for ( int j = 0;(j < m);j++) if ( ((mask & (1 << j)) != 0)) {if ( (j > 0)) mask01 &= (1 << (j - 1)); mask01 &= (1 << j); if ( ((j + 1) < m)) mask01 &= (1 << (j + 1)); } int mask02 = mask;  int t2 = (t + cnt[(((1 << m) - 1) & ~mask)]); if ( (d[(step ^ 1)][mask01][mask02] < t2)) {d[(step ^ 1)][mask01][mask02] = t2; } }}step ^= 1; } int ans = INF; for ( int mask = 0;(mask < (1 << m));mask++) {ans = Math.max(ans,d[step][0][mask]); }out.write((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(); } }
6	public class F{ public static void main( String[] hi)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int N = Integer.parseInt(st.nextToken());  int M = Integer.parseInt(st.nextToken());  int[][] grid = new int[N][M]; for ( int i = 0;(i < N);i++) grid[i] = readArr(M,infile,st); int[][] mindiff = new int[N][N]; for ( int a = 0;(a < N);a++) for ( int b = (a + 1);(b < N);b++) { int val = Integer.MAX_VALUE; for ( int i = 0;(i < M);i++) val = Math.min(val,Math.abs((grid[a][i] - grid[b][i]))); mindiff[a][b] = mindiff[b][a] = val; } int res = 0; for ( int start = 0;(start < N);start++) { int[][] dp = new int[(1 << N)][N]; Arrays.fill(dp[0],Integer.MAX_VALUE); for ( int mask = 0;(mask < (1 << N));mask++) {if ( ((Integer.bitCount(mask) == 1) && (mask != (1 << start)))) continue; for ( int prev = 0;(prev < N);prev++) if ( (((mask & (1 << prev)) > 0) || (mask == 0))) {for ( int b = 0;(b < N);b++) if ( ((mask & (1 << b)) == 0)) { int submask = (mask | (1 << b)); if ( (mask == 0)) dp[submask][b] = Integer.MAX_VALUE; else dp[submask][b] = Math.max(dp[submask][b],Math.min(dp[mask][prev],mindiff[prev][b])); } } }for ( int b = 0;(b < N);b++) { int temp = dp[((1 << N) - 1)][b]; for ( int i = 0;(i < (M - 1));i++) temp = Math.min(temp,Math.abs((grid[b][i] - grid[start][(i + 1)]))); res = Math.max(res,temp); }}System.out.println(res); } public static int[] readArr( int N, BufferedReader infile, StringTokenizer st)throws Exception { int[] arr = new int[N]; st = new StringTokenizer(infile.readLine()); for ( int i = 0;(i < N);i++) arr[i] = Integer.parseInt(st.nextToken()); return arr;} }
6	public class G extends PrintWriter{ void run(){ long mod = (1_000_000_000 + 7);  int n = nextInt();  int m = nextInt();  int[] t = new int[n];  int[] g = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = nextInt(); g[i] = (nextInt() - 1); } int k = (1 << n);  long[][] dp = new long[k][n]; for ( int i = 0;(i < n);i++) {dp[(1 << i)][i] = 1; }for ( int mask = 0;(mask < k);mask++) {if ( (Integer.bitCount(mask) <= 1)) {continue;} for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {for ( int j = 0;(j < n);j++) {if ( (((mask & (1 << j)) == 0) || (g[i] == g[j]))) {continue;} dp[mask][i] = ((dp[mask][i] + dp[(mask ^ (1 << i))][j]) % mod); }} }} long ans = 0; for ( int mask = 0;(mask < k);mask++) { int sum = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {sum += t[i]; } }if ( (sum == m)) {for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {ans = ((ans + dp[mask][i]) % mod); } }} }println(ans); } String next(){ while(!tokenizer.hasMoreTokens())tokenizer = new StringTokenizer(nextLine()); return tokenizer.nextToken();} boolean hasNext(){ while(!tokenizer.hasMoreTokens()){ String line = nextLine(); if ( (line == null)) {return false;} tokenizer = new StringTokenizer(line); }return true;} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} String nextLine(){ try{return reader.readLine(); }catch (IOException err){ return null;} } public G( OutputStream outputStream){ super(outputStream); } static BufferedReader reader ; static StringTokenizer tokenizer = new StringTokenizer(""); static Random rnd = new Random(); static boolean OJ ; public static void main( String[] args)throws IOException { OJ = (System.getProperty("ONLINE_JUDGE") != null); G solution = new G(System.out); if ( OJ) {reader = new BufferedReader(new InputStreamReader(System.in)); solution.run(); } else {reader = new BufferedReader(new FileReader(new File((G.class.getName() + ".txt")))); long timeout = System.currentTimeMillis(); while(solution.hasNext()){solution.run(); solution.println(); solution.println("----------------------------------"); }solution.println(("time: " + (System.currentTimeMillis() - timeout))); }solution.close(); reader.close(); } }
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)]); } }
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); } }
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 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; } } }
6	public class CodeD{ 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 final Scanner sc ; static final int n ; static final int[][] distancias ; static final int[] distancia ; static final int[] dp ; static final int[] dpNext ; static final int X ; static final int Y ; {sc = new Scanner(); X = sc.nextInt(); Y = sc.nextInt(); n = sc.nextInt(); distancias = new int[n][n]; distancia = new int[n]; dp = new int[(1 << n)]; Arrays.fill(dp,-1); dpNext = new int[(1 << n)]; }static int dp( int mascara){ if ( (dp[mascara] != -1)) return dp[mascara]; int highest = -1; for ( int i = 0,tmp = mascara;(tmp != 0);i++,tmp >>= 1) {if ( ((tmp & 1) == 1)) highest = i; }if ( (highest == -1)) return 0; int nextMsc = (mascara ^ (1 << highest));  int costHighest = distancia[highest];  int best = ((costHighest << 1) + dp(nextMsc));  int bestNext = nextMsc; for ( int i = 0,tmp = nextMsc,iC = 1;(tmp != 0);i++,tmp >>= 1,iC <<= 1) {if ( ((tmp & 1) == 1)) { int msc = (nextMsc ^ iC);  int possibleA = (((costHighest + distancias[highest][i]) + distancia[i]) + dp(msc)); if ( (possibleA < best)) {best = possibleA; bestNext = msc; } } }dpNext[mascara] = bestNext; return dp[mascara] = best;} public static void main( String[] args){ int[][] objetos = new int[n][2]; for ( int i = 0;(i < n);i++) {objetos[i][0] = sc.nextInt(); objetos[i][1] = sc.nextInt(); distancia[i] = (((X - objetos[i][0]) * (X - objetos[i][0])) + ((Y - objetos[i][1]) * (Y - objetos[i][1]))); }for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) distancias[i][j] = (((objetos[i][0] - objetos[j][0]) * (objetos[i][0] - objetos[j][0])) + ((objetos[i][1] - objetos[j][1]) * (objetos[i][1] - objetos[j][1]))); int ans = dp(((1 << n) - 1)); System.out.println(ans); int current = ((1 << n) - 1); while((current != 0)){ int next = dpNext[current];  int differents = (next ^ current); System.out.print("0 "); for ( int i = 0;(i < n);i++) if ( ((differents & (1 << i)) != 0)) System.out.print(((i + 1) + " ")); current = next; }System.out.println("0"); } }
1	public class B{ BufferedReader in ; PrintStream out ; StringTokenizer tok ; public B()throws NumberFormatException,IOException{ in = new BufferedReader(new InputStreamReader(System.in)); out = System.out; run(); } void run()throws NumberFormatException,IOException { int n = nextInt();  int k = nextInt();  int[] num = new int[n]; for ( int i = 0;(i < n);i++) num[i] = nextInt(); int[] cant = new int[100001];  int cnt = 0;  int r = 0; for ( ;(r < n);r++) {if ( (cant[num[r]] == 0)) cnt++; cant[num[r]]++; if ( (cnt == k)) break; }if ( (cnt < k)) {out.println("-1 -1"); return ;} int l = 0; for ( ;(l < r);l++) {cant[num[l]]--; if ( (cant[num[l]] == 0)) cnt--; if ( (cnt < k)) break; }out.println((((l + 1) + " ") + (r + 1))); } public static void main( String[] args)throws NumberFormatException,IOException { new B(); } String nextToken()throws IOException { if ( ((tok == null) || !tok.hasMoreTokens())) tok = new StringTokenizer(in.readLine()); return tok.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));  String line = stdin.readLine();  int n = Integer.parseInt(line); if ( (n >= 0)) {System.out.println(n); } else if ( (n > -10)) {System.out.println(0); } else { String sa = line.substring(0,(line.length() - 1));  int a = Integer.parseInt(sa);  String sb = (line.substring(0,(line.length() - 2)) + line.charAt((line.length() - 1)));  int b = Integer.parseInt(sb); System.out.println(Math.max(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);  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());} } }
1	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); do { int n = Integer.parseInt(br.readLine());  int[] ns = new int[args = br.readLine().split(" ")];  int evenCount = 0,oddCount = 0,evI = 1,oddI = 1; for ( int i = 0;(i < ns.length);i++) {if ( (((ns[i] = Integer.parseInt(args[i])) % 2) == 0)) {evenCount++; evI = i; } else {oddCount++; oddI = i; }}if ( (evenCount == 1)) System.out.println((evI + 1)); else System.out.println((oddI + 1)); }while(br.ready());} }
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(); } }
5	public class A274{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  Long a[] = new Long[n];  Hashtable<Long,Boolean> hash = new Hashtable<Long,Boolean>(); for ( int i = 0;(i < n);i++) {a[i] = in.nextLong(); }Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( !hash.containsKey(a[i])) {hash.put((a[i] * k),true); } }System.out.println(hash.size()); } }
1	public class Main{ public static void main( String[] args)throws NumberFormatException,IOException { Scanner sc = new Scanner(new InputStreamReader(System.in));  int n = sc.nextInt(),even = 0,odd = 0,evI = 0,OdI = 0; for ( int i = 0;(i < n);i++) {if ( ((sc.nextInt() % 2) == 1)) {odd++; OdI = (i + 1); } else {even++; evI = (i + 1); }}if ( (even < odd)) System.out.println(evI); else System.out.println(OdI); } }
0	public class ProA{ static long n ; public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextLong(); System.out.println(25); } }
2	public class P1177A{ public static void main( String[] args){ try(Scanner sc=new Scanner(System.in)){ long k = sc.nextLong();  int pow = 1; while(((long)((Math.pow(10,pow) - Math.pow(10,(pow - 1))) * pow) < k)){k -= (long)((Math.pow(10,pow) - Math.pow(10,(pow - 1))) * pow); pow++; }k--; long n = ((long)Math.pow(10,(pow - 1)) + (k / pow)); k %= pow; System.out.println(String.valueOf(n).charAt((int)k)); }catch (Exception e){ e.printStackTrace(); } } }
6	public class LookingForOrder{ static int[] dp = new int[(int)(1 << 24)]; static int[][] points ; static int[] sol = new int[(1 << 24)]; static int sx = 0,sy = 0; public static void main( String[] args){ sx = in.nextInt(); sy = in.nextInt(); Arrays.fill(dp,-2); int n = in.nextInt(); points = new int[n][3]; for ( int i = 0;(i < n);i++) {points[i][0] = in.nextInt(); points[i][1] = in.nextInt(); points[i][2] = (((sx - points[i][0]) * (sx - points[i][0])) + ((sy - points[i][1]) * (sy - points[i][1]))); }System.out.println(solve(0)); int mask = 0; while(true){System.out.print((0 + " ")); if ( (mask == ((1 << n) - 1))) break; int x = sol[mask];  int count = 0; for ( int i = 0;(i < n);i++) {if ( ((x & (1 << i)) != 0)) {count++; System.out.print(((i + 1) + " ")); mask |= (1 << i); } if ( (count == 2)) break; }}System.out.println(); } public static int solve( int mask){ if ( (dp[mask] != -2)) return dp[mask]; int n = points.length; if ( (mask == ((1 << n) - 1))) {return dp[mask] = 0;} int here = -1; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) {here = i; break;} } int ans = ((2 * points[here][2]) + solve((mask | (1 << here)))); sol[mask] = (1 << here); int x1 = points[here][0];  int y1 = points[here][1]; for ( int i = (here + 1);(i < n);i++) {if ( ((mask & (1 << i)) == 0)) { int x2 = points[i][0];  int y2 = points[i][1];  int p = (mask | (1 << here)); p = (p | (1 << i)); if ( (ans > ((((points[here][2] + points[i][2]) + ((x1 - x2) * (x1 - x2))) + ((y1 - y2) * (y1 - y2))) + solve(p)))) {ans = ((((points[here][2] + points[i][2]) + ((x1 - x2) * (x1 - x2))) + ((y1 - y2) * (y1 - y2))) + solve(p)); sol[mask] = ((1 << here) | (1 << i)); } } }return dp[mask] = ans;} 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());} } static MyScanner in = new MyScanner(); }
0	public class TaskA{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  PrintWriter writer = new PrintWriter(System.out);  String[] input = reader.readLine().split(" ");  long l = Long.parseLong(input[0]);  long r = Long.parseLong(input[1]); if ( ((l % 2) == 0)) {if ( (r >= (l + 2))) {writer.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else {writer.println(-1); }} else {if ( (r >= (l + 3))) {writer.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); } else {writer.println(-1); }}writer.close(); } }
6	public class A{ FastScanner in ; PrintWriter out ; void solve(){ int tc = in.nextInt(); for ( int t = 0;(t < tc);t++) { int n = in.nextInt();  int m = in.nextInt();  O[] a = new O[(n * m)];  int[][] cols = new int[m][(n + n)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {cols[j][i] = cols[j][(i + n)] = in.nextInt(); a[((i * m) + j)] = new O(i,j,cols[j][i]); }}Arrays.sort(a); boolean[] used = new boolean[m];  int cntUsed = 0; for ( O o :a) {if ( !used[o.y]) {used[o.y] = true; cntUsed++; if ( (cntUsed == n)) {break;} } } int[] dp = new int[(1 << n)];  int[] ndp = new int[(1 << n)];  int[] maxndp = new int[(1 << n)]; for ( int col = 0;(col < m);col++) {if ( !used[col]) {continue;} int[] curColumn = cols[col]; for ( int shift = 0;(shift < n);shift++) {System.arraycopy(dp,0,ndp,0,ndp.length); for ( int mask = 0;(mask < (1 << n));mask++) {for ( int bit = 0;(bit < n);bit++) {if ( (((1 << bit) & mask) == 0)) { int nmask = (mask | (1 << bit)); ndp[nmask] = Math.max(ndp[nmask],(ndp[mask] + curColumn[(bit + shift)])); } }}for ( int i = 0;(i < ndp.length);i++) {maxndp[i] = Math.max(maxndp[i],ndp[i]); }} int[] tmp = dp; dp = maxndp; maxndp = tmp; }out.println(dp[(dp.length - 1)]); }} class O implements Comparable<O>{ int x ,y ,value ; public O( int x, int y, int value){ this.x = x; this.y = y; this.value = value; } } void runIO(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } class FastScanner{ BufferedReader br ; 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)); } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] args){ new A().runIO(); } }
2	public class ReallyBigNumbers817c{ static long sd( String s){ long c = 0; for ( int i = 0;(i < s.length());i++) {c += s.charAt(i); }return (c - (s.length() * 0x30));} public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long s = in.nextLong();  long i = (((s / 10) + 1) * 10); if ( ((n < 10) || ((n - sd((n + ""))) < s))) {System.out.println(0); return ;} while(((i - sd((i + ""))) >= s)){i += 10; }System.out.println(((n - i) + 1)); } }
5	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){ int n = in.nextInt();  long k = in.nextLong();  long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); Arrays.sort(a); boolean[] ok = new boolean[n]; Arrays.fill(ok,true); if ( (k > 1)) for ( int i = 0;(i < n);i++) {if ( (ok[i] == false)) continue; int pos = Arrays.binarySearch(a,(a[i] * k)); if ( (pos >= 0)) {ok[pos] = false; } } int ans = 0; for ( boolean x :ok) if ( x) ans++; out.println(ans); } } 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 int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} }
5	public class A{ static Comparator<Point> cmp = new Comparator<Point>(){}; public static void main( String[] args){ Scanner scan = new Scanner(System.in); while(scan.hasNextInt()){ int n = scan.nextInt();  int k = scan.nextInt();  Point[] a = new Point[n]; for ( int i = 0;(i < n);i++) {a[i] = new Point(); a[i].x = scan.nextInt(); a[i].y = scan.nextInt(); }Arrays.sort(a,cmp); int rtn = 0;  ArrayList<Double> ans = new ArrayList<Double>(); for ( int i = 0;(i < n);i++) { double lb = ((a[i].x - (a[i].y / 2.0)) - k);  double pos = (lb + (k / 2.0));  boolean good = true; for ( int j = 0;(j < ans.size());j++) if ( (Math.abs((ans.get(j) - pos)) < 0.0000001)) good = false; if ( (good && ((i == 0) || ((a[(i - 1)].x + (a[(i - 1)].y / 2.0)) <= lb)))) {rtn++; ans.add(pos); } double rb = ((a[i].x + (a[i].y / 2.0)) + k); pos = (rb - (k / 2.0)); good = true; for ( int j = 0;(j < ans.size());j++) if ( (Math.abs((ans.get(j) - pos)) < 0.0000001)) good = false; if ( (good && ((i == (n - 1)) || ((a[(i + 1)].x - (a[(i + 1)].y / 2.0)) >= rb)))) {rtn++; ans.add(pos); } }System.out.println(rtn); }} }
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 x111C{ public static void main( String[] omkar)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int R = Integer.parseInt(st.nextToken());  int C = Integer.parseInt(st.nextToken()); if ( (R > C)) { int t = R; R = C; C = t; } int[][][] dp = new int[(C + 1)][(1 << R)][(1 << R)]; for ( int i = 0;(i <= C);i++) for ( int mask = 0;(mask < (1 << R));mask++) Arrays.fill(dp[i][mask],69); for ( int mask = 0;(mask < (1 << R));mask++) dp[0][0][mask] = 0; for ( int c = 1;(c <= C);c++) for ( int mask1 = 0;(mask1 < (1 << R));mask1++) for ( int mask2 = 0;(mask2 < (1 << R));mask2++) for ( int mask3 = 0;(mask3 < (1 << R));mask3++) { boolean works = true; for ( int b = 0;(b < R);b++) if ( ((mask2 & (1 << b)) == 0)) {if ( ((b > 0) && ((mask2 & (1 << (b - 1))) > 0))) ; else if ( (((b + 1) < R) && ((mask2 & (1 << (b + 1))) > 0))) ; else if ( ((mask1 & (1 << b)) > 0)) ; else if ( ((mask3 & (1 << b)) > 0)) ; else works = false; } if ( works) dp[c][mask2][mask3] = Math.min(dp[c][mask2][mask3],(dp[(c - 1)][mask1][mask2] + Integer.bitCount(mask1))); } int res = 0; for ( int mask = 0;(mask < (1 << R));mask++) res = Math.max(res,((R * C) - (dp[C][mask][0] + Integer.bitCount(mask)))); System.out.println(res); } }
3	public class A{ InputStream is ; PrintWriter out ; String INPUT = ""; public void solve(){ int n = ni();  char[] arr = new char[n]; for ( int i = 0;(i < n);i++) {arr[i] = ns().charAt(0); } long mod = 1000000007;  long[][] memo = new long[n][n]; memo[0][0] = 1L; int k = 0; for ( int i = 1;(i < n);i++) {if ( (((arr[i] == 'f') && (arr[(i - 1)] == 's')) || ((arr[i] == 's') && (arr[(i - 1)] == 's')))) { long sum = 0; for ( int j = k;(j >= 0);j--) {sum = ((sum + (memo[(i - 1)][j] % mod)) % mod); memo[i][j] = sum; }} else {k += 1; for ( int j = 1;(j <= k);j++) {memo[i][j] = (memo[(i - 1)][(j - 1)] % mod); }}} long sum = 0; for ( int i = 0;(i <= k);i++) {sum = ((sum + (memo % mod)) % mod); }out.println(sum); } void print( int n, long[][] memo){ for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {out.print((memo[i][j] + " ")); }out.println(); }} void run(){ is = new DataInputStream(System.in); out = new PrintWriter(System.out); int t = 1; while((t-- > 0))solve(); out.flush(); } 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 = 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(); }} static int i( long x){ return (int)Math.round(x);} }
5	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();} class House{ int x ,t ; public House( int x, int t){ this.x = x; this.t = t; } } void solve(){ int n = nextInt();  int t = nextInt();  House[] h = new House[n]; for ( int i = 0;(i < n);i++) {h[i] = new House(nextInt(),nextInt()); }Arrays.sort(h,new Comparator<House>(){}); int ans = 0; for ( int i = 0;(i < n);i++) {if ( ((i == 0) || (((((h[i].x - h[(i - 1)].x) * 2) - h[i].t) - h[(i - 1)].t) >= (2 * t)))) {++ans; } if ( ((i == (n - 1)) || (((((h[(i + 1)].x - h[i].x) * 2) - h[(i + 1)].t) - h[i].t) > (2 * t)))) {++ans; } }out.println(ans); } }
6	public class f{ public static void main( String[] args){ MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n = sc.nextInt();  int m = sc.nextInt();  int[][] arr = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {arr[i][j] = sc.nextInt(); }}if ( (n == 1)) { int min = Integer.MAX_VALUE; for ( int i = 0;(i < (m - 1));i++) {min = Math.min(min,Math.abs((arr[0][i] - arr[0][(i + 1)]))); }out.println(min); out.close(); } int[][] adj = new int[n][n];  int[][] edgeadj = 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 = Math.min(min,Math.abs((arr[i][k] - arr[j][k]))); }adj[i][j] = min; adj[j][i] = min; int min1 = Integer.MAX_VALUE;  int min2 = Integer.MAX_VALUE; for ( int k = 0;(k < (m - 1));k++) {min1 = Math.min(min1,Math.abs((arr[i][k] - arr[j][(k + 1)]))); min2 = Math.min(min2,Math.abs((arr[i][(k + 1)] - arr[j][k]))); }edgeadj[i][j] = min1; edgeadj[j][i] = min2; }} int power = (int)Math.pow(2,n);  int[][][] dp = new int[power][n][n]; for ( int i = 0;(i < n);i++) {dp[(int)Math.pow(2,i)][i][i] = Integer.MAX_VALUE; }for ( int bit = 0;(bit < power);bit++) {for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < n);k++) {if ( ((((bit & (1 << j)) > 0) && ((bit & (1 << k)) > 0)) && (j != k))) { int temp = bit; temp &= (1 << k); int ans = 0; for ( int l = 0;(l < n);l++) {if ( ((temp & (1 << l)) > 0)) { int min = Math.min(dp[temp][j][l],adj[l][k]); ans = Math.max(ans,min); } }if ( (j != k)) {dp[bit][j][k] = ans; } } }}} int answer = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i != j)) { int ans = Math.min(dp[(power - 1)][i][j],edgeadj[i][j]); answer = Math.max(answer,ans); } }}out.println(answer); 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());} } }
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)); } static private 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); }} } static private 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++]); }}} static private 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); } }
6	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{ int n ; int[] bitCount ; long neededSum ; long[] sums ; Map<Long,Integer> where ; public void solve( int testNumber, FastScanner in, PrintWriter out){ n = in.nextInt(); int[][] a = new int[n][]; neededSum = 0; sums = new long[n]; for ( int i = 0;(i < n);i++) { int k = in.nextInt(); a[i] = new int[k]; for ( int j = 0;(j < k);j++) {a[i][j] = in.nextInt(); neededSum += a[i][j]; sums[i] += a[i][j]; }}if ( ((neededSum % n) != 0)) {out.println("No"); return ;} neededSum /= n; where = new HashMap<>(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < a[i].length);j++) {where.put((long)a[i][j],i); }}bitCount = new int[(1 << n)]; for ( int i = 0;(i < bitCount.length);i++) {bitCount[i] = Integer.bitCount(i); } Entry[][] cycleSol = new Entry[(1 << n)][];  List<Entry> sol = new ArrayList<>(); for ( int i = 0;(i < n);i++) {for ( int x :a[i]) {search(i,i,x,x,0,0,sol,cycleSol); }} boolean[] can = new boolean[(1 << n)];  int[] via = new int[(1 << n)]; can[0] = true; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int submask = mask;(submask > 0);submask = ((submask - 1) & mask)) {if ( ((cycleSol[submask] != null) && can[(mask ^ submask)])) {can[mask] = true; via[mask] = submask; } }}if ( !can[((1 << n) - 1)]) {out.println("No"); return ;} int[][] ans = new int[n][2]; for ( int mask = ((1 << n) - 1);(mask > 0);) { int sm = via[mask]; mask ^= sm; for ( Entry e :cycleSol[sm]) {ans[e.from][0] = e.what; ans[e.from][1] = (e.to + 1); }}out.println("Yes"); for ( int i = 0;(i < n);i++) {out.println(((ans[i][0] + " ") + ans[i][1])); }} private void search( int start, int cur, long fromStart, long fromCur, int hasIn, int hasOut, List<Entry> sol, Entry[][] cycleSol){ for ( int i = start;(i < n);i++) {if ( ((hasIn & (1 << i)) > 0)) {continue;} if ( ((hasOut & (1 << cur)) > 0)) {continue;} long fromI = ((sums[i] + fromCur) - neededSum);  Integer w = where.get(fromI); if ( ((w == null) || (w != i))) {continue;} sol.add(new Entry(cur,i,(int)fromCur)); int nHasIn = (hasIn | (1 << i));  int nHasOut = (hasOut | (1 << cur)); if ( ((i == start) && (fromI == fromStart))) {cycleSol[nHasOut] = sol.toArray(new Entry[0]); } search(start,i,fromStart,fromI,nHasIn,nHasOut,sol,cycleSol); sol.remove((sol.size() - 1)); }} class Entry{ int from ; int to ; int what ; Entry( int from, int to, int what){ this.from = from; this.to = to; this.what = what; } } } 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{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
2	public class Main{ static final int MAXN = 100005; static int n ; static Scanner cin ; static int[] a ; static boolean[] used ; public static int Query( int x){ System.out.print("? "); System.out.println(x); System.out.flush(); int a = cin.nextInt(); return a;} public static int Q( int x){ if ( used[x]) return a[x]; used[x] = true; a[x] = (Query(x) - Query((x + (n / 2)))); if ( (a[x] == 0)) {System.out.print("! "); System.out.println(x); System.out.flush(); cin.close(); System.exit(0); } return a[x];} public static void main( String[] args){ cin = new Scanner(System.in); n = cin.nextInt(); a = new int[MAXN]; used = new boolean[MAXN]; if ( ((n % 4) != 0)) {System.out.println("! -1\n"); System.out.flush(); cin.close(); return ;} int l = 1,r = (n / 2),mid ; while((l <= r)){mid = ((l + r) / 2); int x = Q(mid); if ( ((Q(l) * x) < 0)) {r = (mid - 1); } else if ( ((x * Q(r)) < 0)) {l = (mid + 1); } }System.out.println("! -1\n"); System.out.flush(); cin.close(); } }
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)); } }
1	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt(); if ( ((n % 2) == 1)) {System.out.println("NO"); continue;} int num = (n / 2);  int root = (int)Math.sqrt(num); if ( ((root * root) == num)) {System.out.println("YES"); continue;} if ( ((n % 4) != 0)) {System.out.println("NO"); continue;} num = (n / 4); root = (int)Math.sqrt(num); if ( ((root * root) == num)) {System.out.println("YES"); } else {System.out.println("NO"); }}} }
5	public class Main{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(),m = 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 ans = 0,r = k,p = (n - 1); while(((r < m) && (p >= 0))){r = ((r - 1) + a[p]); p--; ans++; }if ( (r < m)) out.println("-1"); else out.println(ans); out.flush(); } }
0	public class A{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); System.out.println(((2 * n) - (n / 2))); } }
1	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n ; n = sc.nextInt(); int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); } int min = 1000000000,temp ; for ( int i = 0;(i < n);i++) {temp = (arr[i] / Math.max(i,((n - 1) - i))); if ( (temp < min)) min = temp; }System.out.println(min); } }
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 Sellerman(); 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++];} @Override public void close(){ try{stream.close(); }catch (IOException ignored){ } } } interface Solver{ public void solve( int testNumber, InputReader in, PrintWriter out); } class Sellerman implements Solver{ public void solve( int testNumber, InputReader in, PrintWriter out){ int x0 = in.nextInt();  int y0 = in.nextInt();  int n = (in.nextInt() + 1);  int[] x = new int[n];  int[] y = new int[n]; x[(n - 1)] = x0; y[(n - 1)] = y0; for ( int i = 0;(i < (n - 1));++i) {x[i] = in.nextInt(); y[i] = in.nextInt(); } int[][] g = new int[n][n]; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);++j) {g[i][j] = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); }--n; int[] dm = new int[(1 << n)];  int[] prev = new int[(1 << n)];  byte[] bit = new byte[(1 << n)];  byte[] item0 = new byte[(1 << n)];  byte[] item1 = new byte[(1 << n)]; for ( int i = 0;(i < n);++i) {bit[(1 << i)] = (byte)i; }Arrays.fill(dm,-1); dm[0] = 0; int tt[][] = new int[n][n]; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);++j) {tt[i][j] = Math.min(((g[n][i] + g[i][j]) + g[j][n]),((g[n][j] + g[i][j]) + g[i][n])); }for ( int i = 0;(i < (1 << n));++i) {if ( (dm[i] == -1)) continue; int t = (i ^ ((1 << n) - 1));  int left = bit[(t - (t & (t - 1)))]; for ( int j = left;(j < n);++j) {if ( ((i & (1 << j)) > 0)) continue; int nm = ((i | (1 << left)) | (1 << j)); if ( ((dm[nm] == -1) || (dm[nm] > (dm[i] + tt[left][j])))) {dm[nm] = (dm[i] + tt[left][j]); prev[nm] = i; item0[nm] = (byte)left; item1[nm] = (byte)j; } }}out.println(dm[((1 << n) - 1)]); Vector<Vector<Integer>> path = new Vector<Vector<Integer>>();  int cmask = ((1 << n) - 1); while((cmask > 0)){ int p = prev[cmask];  Vector<Integer> tmp = new Vector<Integer>(); tmp.add(0); tmp.add((item0[cmask] + 1)); tmp.add((item1[cmask] + 1)); cmask = prev[cmask]; path.add(tmp); }Collections.reverse(path); int len = 0; for ( Vector<Integer> vec :path) len += vec.size(); int ans[] = new int[len];  boolean[] valid = new boolean[len]; Arrays.fill(valid,true); len = 0; for ( Vector<Integer> vec :path) {for ( int ttt :vec) {ans[len++] = ttt; }}for ( int i = 0;(i < (len - 1));++i) {if ( (ans[i] == ans[(i + 1)])) valid[i] = false; }for ( int i = 0;(i < len);++i) {if ( valid[i]) {out.print((ans[i] + " ")); } }out.print("0"); } }
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();} }
6	public class Main implements Runnable{ int n ; double[] prob ; double[][] a ; void solve()throws IOException { n = nextInt(); a = new double[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {a[i][j] = nextDouble(); }}prob = new double[(1 << n)]; Arrays.fill(prob,0.0); prob[((1 << n) - 1)] = 1.0; for ( int i = ((1 << n) - 1);(i > 1);--i) { int c = 0; for ( int bit = 0;(bit < n);++bit) {if ( (((1 << bit) & i) > 0)) {++c; } } double k = ((c * (c - 1)) / 2.0); for ( int f = 0;(f < n);++f) {if ( (((1 << f) & i) > 0)) {for ( int s = (f + 1);(s < n);++s) {if ( (((1 << s) & i) > 0)) {prob[(i ^ (1 << f))] += ((prob[i] * a[s][f]) / k); prob[(i ^ (1 << s))] += ((prob[i] * a[f][s]) / k); } }} }}for ( int i = 0;(i < n);++i) {writer.printf(Locale.US,"%.6f ",prob[(1 << i)]); }} public static void main( String[] args)throws InterruptedException { new Thread(null,new Runnable(){public void run(){ new Main().run(); } },"1",(1 << 25)).start(); } @Override public void run(){ try{ boolean fromStandart = true; reader = new BufferedReader((fromStandart?new InputStreamReader(System.in):new FileReader(INFILE))); writer = new PrintWriter(new BufferedWriter((fromStandart?new OutputStreamWriter(System.out):new FileWriter(OUTFILE)))); tokenizer = null; solve(); writer.flush(); }catch (Exception error){ error.printStackTrace(); System.exit(1); } } static final String INFILE = "input.txt"; static final String OUTFILE = "output.txt"; BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; 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();} }
2	public class CFB{ static int n ; static FastScanner in ; public static void main( String[] args)throws Exception { in = new FastScanner(System.in); n = in.nextInt(); int a = query(1); if ( ((((a % 2) + 2) % 2) == 1)) {System.out.println("! -1"); return ;} if ( (a == 0)) {System.out.println("! 1"); return ;} bins(1,((n / 2) + 1),a,-a); } static void bins( int lo, int hi, int losign, int hisign){ int mid = ((lo + hi) / 2);  int k = query(mid); if ( (k == 0)) {System.out.println(("! " + mid)); System.exit(0); } if ( (((k > 0) && (losign > 0)) || ((k < 0) && (losign < 0)))) {bins(mid,hi,k,hisign); } else {bins(lo,mid,losign,k); }} static int query( int i){ System.out.println(("? " + i)); int a1 = in.nextInt(); System.out.println(("? " + (((i + (n / 2)) > n)?(i - (n / 2)):(i + (n / 2))))); int a2 = in.nextInt(); return (a1 - a2);} 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();} } }
6	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())){ String r = in.readLine(); if ( (r == null)) return null; st = new StringTokenizer(r); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} int count( int q, int n){ int ans = 0; for ( int i = 0;(i < n);i++) {if ( ((q % 3) != 1)) ans++; q /= 3; }return ans;} int count2( int q, int n){ int ans = 0; for ( int i = 0;(i < n);i++) {if ( ((q % 3) == 2)) ans++; q /= 3; }return ans;} int sz ; int[] decode( int q, int n){ int[] res = new int[n]; for ( int i = 0;(i < n);i++) {res[i] = (q % 3); q /= 3; }return res;} boolean[][] precalc( int n, int m){ boolean[][] res = new boolean[sz][sz]; for ( int i = 0;(i < sz);i++) { int[] ai = decode(i,n); for ( int j = 0;(j < sz);j++) { int[] aj = decode(j,n);  boolean f = true; for ( int k = 0;((k < n) && f);k++) {if ( (aj[k] == 0)) {f = false; if ( ((k > 0) && (aj[(k - 1)] == 1))) f = true; if ( ((k < (n - 1)) && (aj[(k + 1)] == 1))) f = true; if ( (ai[k] == 1)) f = true; } if ( (f && (ai[k] == 2))) f = (aj[k] == 1); }res[i][j] = f; }}return res;} void solve()throws Exception { int n = nextInt();  int m = nextInt(); if ( (n > m)) { int t = n; n = m; m = t; } sz = 1; for ( int i = 0;(i < n);i++) sz *= 3; boolean[][] a = precalc(n,m);  int[][] d = new int[(m + 1)][sz]; Arrays.fill(d[0],-1); d[0][0] = 0; for ( int i = 1;(i <= m);i++) {Arrays.fill(d[i],-1); for ( int j = 0;(j < sz);j++) {if ( (d[(i - 1)][j] != -1)) {for ( int k = 0;(k < sz);k++) {if ( a[j][k]) {d[i][k] = Math.max(d[i][k],(d[(i - 1)][j] + count(k,n))); } }} }} int ans = 0; for ( int i = 0;(i < sz);i++) if ( (count2(i,n) == 0)) ans = Math.max(ans,d[m][i]); out.println(ans); } }
1	public class BT{ 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());} public static void main( String[] args)throws IOException { int n ,k ; n = nextInt(); k = nextInt(); HashSet<Integer> hs = new HashSet<Integer>();  HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();  int[] ar = new int[n];  int ii = 0,jj = -1; for ( int i = 0;(i < n);i++) {ar[i] = nextInt(); Integer iii = hm.get(ar[i]); if ( (iii != null)) hm.put(ar[i],++iii); else hm.put(ar[i],1); hs.add(ar[i]); if ( (hs.size() == k)) {jj = i; break;} }if ( (jj == -1)) {System.out.println(((-1 + " ") + 1)); System.exit(0); } for ( int i = 0;(i < ar.length);i++) { Integer iii = hm.get(ar[i]); if ( ((iii != null) && ((iii - 1) > 0))) {hm.put(ar[i],--iii); ii++; } else {break;}}System.out.println((((ii + 1) + " ") + (jj + 1))); } }
5	public class Solution implements Runnable{ public void solve()throws Exception { int n = sc.nextInt();  int k = sc.nextInt();  TreeSet<Integer> bad = new TreeSet<>();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Random rnd = new Random(); for ( int i = 1;(i < n);i++) { int j = rnd.nextInt((i + 1));  int t = a[i]; a[i] = a[j]; a[j] = t; }Arrays.sort(a); int result = 0; for ( int i = 0;(i < n);i++) {if ( !bad.contains(a[i])) {result++; long next = ((long)a[i] * k); if ( (next <= 1000000000)) bad.add((int)next); } }out.println(result); } BufferedReader in ; PrintWriter out ; FastScanner sc ; static Throwable uncaught ; public static void main( String[] args)throws Throwable { Thread t = new Thread(null,new Solution(),"",(1 << 26)); 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());} }
5	public class Solution implements Runnable{ static private BufferedReader br = null; static private PrintWriter out = null; static private 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());} private Double nextDouble(){ while(((stk == null) || !stk.hasMoreTokens()))loadLine(); return Double.parseDouble(stk.nextToken());} }
4	public class Main{ static FastReader in ; static PrintWriter out ; static Random rand = new Random(); static final int oo = ((int)1e9 + 10); static final long OO = ((long)1e18 + 10); static final int MOD = ((int)1e9 + 7); static int M ; static long[] f ,fi ,two ; static long pow( long a, long b){ long res = 1; while((b != 0)){if ( ((b & 1) == 1)) res = ((res * a) % M); a = ((a * a) % M); b >>= 1; }return res;} static long C( int n, int k){ return ((((f[n] * fi[k]) % M) * fi[(n - k)]) % M);} static void prepare( int n){ f = new long[n]; f[0] = 1; for ( int i = 1;(i < n);i++) {f[i] = ((f[(i - 1)] * i) % M); }fi = new long[n]; for ( int i = 0;(i < n);i++) {fi[i] = pow(f[i],(M - 2)); }two = new long[n]; two[0] = 1; for ( int i = 1;(i < n);i++) {two[i] = ((two[(i - 1)] * 2) % M); }} static void solve(){ int n = in.nextInt(); M = in.nextInt(); prepare((n + 10)); long[][] dp = new long[(n + 1)][n]; for ( int i = 1;(i <= n);i++) {dp[i][1] = two[(i - 1)]; }for ( int i = 1;(i <= n);i++) {for ( int j = 2;(j < n);j++) {for ( int k = 1;(k <= (i - 2));k++) {if ( (k < (j - 2))) continue; int len = ((i - k) - 1); dp[i][j] = ((dp[i][j] + ((((dp[k][(j - 1)] * two[(len - 1)]) % M) * C(((k - (j - 2)) + len),len)) % M)) % M); }}} long ans = 0; for ( int j = 1;(j < n);j++) {ans = ((ans + dp[n][j]) % M); }out.println(ans); } public static void main( String[] args){ in = new FastReader(); out = new PrintWriter(System.out); int t = 1; while((t-- > 0)){solve(); }out.flush(); out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; FastReader(){ this(System.in); } FastReader( String file)throws FileNotFoundException{ this(new FileInputStream(file)); } FastReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } int nextInt(){ return Integer.parseInt(next());} String next(){ while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(nextLine()); }return st.nextToken();} String nextLine(){ String line ; try{line = br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} return line;} } }
6	public class E{ public static void main( String[] args){ new E(new Scanner(System.in)); } int N ,M ; int[][][] memo ; int go( int i, int j, int mask){ if ( (i == N)) return go(0,(j + 1),mask); if ( (j == M)) { int mm = (mask % (1 << N)); if ( (mm != ((1 << N) - 1))) return (N * M); return 0;} if ( (memo[i][j][mask] != -1)) return memo[i][j][mask]; int nMask = mask;  int prevMask = 0; if ( (i > 0)) prevMask = (1 << (N - 1));  int nextMask = 0; if ( (i < (N - 1))) nextMask = (1 << (N + 1));  int curMask = (1 << N);  int nextRowMask = (1 << (N + N)); nMask = ((((nMask | prevMask) | nextMask) | curMask) | nextRowMask); nMask = (nMask / 2); int res = (1 + go((i + 1),j,nMask));  int pr = (mask % 2); if ( (pr == 1)) { int rr = go((i + 1),j,(mask / 2)); if ( (rr < res)) res = rr; } memo[i][j][mask] = res; return res;} public E( Scanner in){ int[] vals = new int[2]; vals[0] = in.nextInt(); vals[1] = in.nextInt(); Arrays.sort(vals); N = vals[0]; M = vals[1]; memo = new int[N][M][(1 << ((N + N) + 1))]; fill3(memo,-1); int r1 = go(0,0,((1 << N) - 1));  int res = ((N * M) - r1); System.out.printf("%d%n",res); } void fill3( int[][][] vvv, int val){ for ( int[][] vv :vvv) for ( int[] v :vv) Arrays.fill(v,val); } }
6	public class C{ static int[] dx = new int[]{0,1,0,-1,0}; static int[] dy = new int[]{0,0,-1,0,1}; static int[][] g ; static int ans ; static void fill(){ cache[1][1] = 0; cache[1][1] = 0; cache[2][1] = 1; cache[1][2] = 1; cache[2][2] = 2; cache[2][2] = 2; cache[3][1] = 2; cache[1][3] = 2; cache[3][2] = 4; cache[2][3] = 4; cache[3][3] = 6; cache[3][3] = 6; cache[4][1] = 2; cache[1][4] = 2; cache[4][2] = 5; cache[2][4] = 5; cache[4][3] = 8; cache[3][4] = 8; cache[4][4] = 12; cache[4][4] = 12; cache[5][1] = 3; cache[1][5] = 3; cache[5][2] = 7; cache[2][5] = 7; cache[5][3] = 11; cache[3][5] = 11; cache[5][4] = 14; cache[4][5] = 14; cache[5][5] = 18; cache[5][5] = 18; cache[6][1] = 4; cache[1][6] = 4; cache[6][2] = 8; cache[2][6] = 8; cache[6][3] = 13; cache[3][6] = 13; cache[6][4] = 17; cache[4][6] = 17; cache[6][5] = 22; cache[5][6] = 22; cache[6][6] = 26; cache[6][6] = 26; cache[7][1] = 4; cache[1][7] = 4; cache[7][2] = 10; cache[2][7] = 10; cache[7][3] = 15; cache[3][7] = 15; cache[7][4] = 21; cache[4][7] = 21; cache[7][5] = 26; cache[5][7] = 26; cache[8][1] = 5; cache[1][8] = 5; cache[8][2] = 11; cache[2][8] = 11; cache[8][3] = 17; cache[3][8] = 17; cache[8][4] = 24; cache[4][8] = 24; cache[8][5] = 29; cache[5][8] = 29; cache[9][1] = 6; cache[1][9] = 6; cache[9][2] = 13; cache[2][9] = 13; cache[9][3] = 20; cache[3][9] = 20; cache[9][4] = 26; cache[4][9] = 26; cache[10][1] = 6; cache[1][10] = 6; cache[10][2] = 14; cache[2][10] = 14; cache[10][3] = 22; cache[3][10] = 22; cache[10][4] = 30; cache[4][10] = 30; cache[11][1] = 7; cache[1][11] = 7; cache[11][2] = 16; cache[2][11] = 16; cache[11][3] = 24; cache[3][11] = 24; cache[12][1] = 8; cache[1][12] = 8; cache[12][2] = 17; cache[2][12] = 17; cache[12][3] = 26; cache[3][12] = 26; cache[13][1] = 8; cache[1][13] = 8; cache[13][2] = 19; cache[2][13] = 19; cache[13][3] = 29; cache[3][13] = 29; cache[14][1] = 9; cache[1][14] = 9; cache[14][2] = 20; cache[2][14] = 20; cache[15][1] = 10; cache[1][15] = 10; cache[15][2] = 22; cache[2][15] = 22; cache[16][1] = 10; cache[1][16] = 10; cache[16][2] = 23; cache[2][16] = 23; cache[17][1] = 11; cache[1][17] = 11; cache[17][2] = 25; cache[2][17] = 25; cache[18][1] = 12; cache[1][18] = 12; cache[18][2] = 26; cache[2][18] = 26; cache[19][1] = 12; cache[1][19] = 12; cache[19][2] = 28; cache[2][19] = 28; cache[20][1] = 13; cache[1][20] = 13; cache[20][2] = 29; cache[2][20] = 29; cache[21][1] = 14; cache[1][21] = 14; cache[22][1] = 14; cache[1][22] = 14; cache[23][1] = 15; cache[1][23] = 15; cache[24][1] = 16; cache[1][24] = 16; cache[25][1] = 16; cache[1][25] = 16; cache[26][1] = 17; cache[1][26] = 17; cache[27][1] = 18; cache[1][27] = 18; cache[28][1] = 18; cache[1][28] = 18; cache[29][1] = 19; cache[1][29] = 19; cache[30][1] = 20; cache[1][30] = 20; cache[31][1] = 20; cache[1][31] = 20; cache[32][1] = 21; cache[1][32] = 21; cache[33][1] = 22; cache[1][33] = 22; cache[34][1] = 22; cache[1][34] = 22; cache[35][1] = 23; cache[1][35] = 23; cache[36][1] = 24; cache[1][36] = 24; cache[37][1] = 24; cache[1][37] = 24; cache[38][1] = 25; cache[1][38] = 25; cache[39][1] = 26; cache[1][39] = 26; cache[40][1] = 26; cache[1][40] = 26; } static void go( int n, int m, long used, long left){ if ( (left == 0)) {ans = max(ans,((n * m) - Long.bitCount(used))); return ;} if ( (((n * m) - Long.bitCount(used)) <= ans)) return ; int who = Long.numberOfTrailingZeros(left); for ( int w :g[who]) { long nused = (used | (1L << w));  long nleft = left; for ( int v :g[w]) {nleft &= (1L << v); }go(n,m,nused,nleft); }} static int[][] cache ; public static void main( String[] args){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); cache = new int[41][41]; fill(); int n = nextInt();  int m = nextInt(); out.println(cache[n][m]); out.close(); }catch (Throwable e){ e.printStackTrace(); System.exit(1); } } static BufferedReader in ; static PrintWriter out ; static StringTokenizer tok ; static long launchTimer ; static boolean hasMoreTokens()throws IOException { while(((tok == null) || !tok.hasMoreTokens())){ String line = in.readLine(); if ( (line == null)) {return false;} tok = new StringTokenizer(line); }return true;} static String next()throws IOException { return (hasMoreTokens()?tok.nextToken():null);} static int nextInt()throws IOException { return Integer.parseInt(next());} }
4	public class C_CF{ public static void main( String[] args){ FastScanner57 fs = new FastScanner57();  PrintWriter pw = new PrintWriter(System.out);  int t = fs.ni(); for ( int tc = 0;(tc < t);tc++) { int n = fs.ni();  int[] q = new int[(n + 5)];  int ind = 0; q[0] = 1; for ( int i = 0;(i < n);i++) { int a = fs.ni(); while((q[ind] != a))ind--; StringBuilder sb = new StringBuilder(); for ( int j = 0;(j < ind);j++) {sb.append((q[j] - 1)); sb.append("."); }sb.append(a); q[ind]++; q[(ind + 1)] = 1; ind++; pw.println(sb); }}pw.close(); } public static long recur( int ind, int p, int prev, long[] v, Long[][] dp, long[][] lr, List<List<Integer>> list){ long last = v[0];  long ls = 0L;  long rs = 0L; if ( (p == 1)) {last = v[1]; } if ( (ind != 0)) {ls += (long)Math.abs((last - lr[ind][0])); } if ( (ind != 0)) {rs += (long)Math.abs((last - lr[ind][1])); } if ( (dp[ind][p] != null)) {return dp[ind][p];} long[] cur = lr[ind];  List<Integer> temp = list.get(ind); for ( int val :temp) {if ( (prev == val)) {continue;} ls += recur(val,0,ind,cur,dp,lr,list); rs += recur(val,1,ind,cur,dp,lr,list); }return dp[ind][p] = Math.max(ls,rs);} public static void sort( long[] a){ List<Long> list = new ArrayList(); for ( int i = 0;(i < a.length);i++) {list.add(a[i]); }Collections.sort(list); for ( int i = 0;(i < a.length);i++) {a[i] = list.get(i); }} public static long gcd( long n1, long n2){ if ( (n2 == 0)) {return n1;} return gcd(n2,(n1 % n2));} } class FastScanner57{ BufferedReader br ; StringTokenizer st ; public FastScanner57(){ 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());} long nl(){ return Long.parseLong(next());} }
3	public class Main3{ static PrintWriter pr ; static Scanner scan ; static BufferedReader br ; static StringTokenizer st ; public static void main( String[] args)throws Exception { pr = new PrintWriter(System.out); scan = new Scanner(System.in); br = new BufferedReader(new InputStreamReader(System.in)); int n = inputInt();  int[] a = new int[n];  int[] b = new int[n]; st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(st.nextToken()); }Arrays.sort(a); int ans = 0; for ( int i = 0;(i < n);i++) {if ( (b[i] != 1)) {ans++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {b[j] = 1; } }} }System.out.println(ans); } public static int inputInt()throws IOException { return Integer.parseInt(br.readLine());} public static long gcd( long a, long b){ if ( (b == 0)) {return a;} else {return gcd(b,(a % b));}} public long max( long a, long b, long c){ return Math.max(a,Math.max(b,c));} }
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)))); res %= 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(); } } }
1	public class Watermelon{ static class Passengers{ public int floor ; public int time ; public Passengers( int floor, int time){ this.floor = floor; this.time = time; } } public static void main( String[] args){ Scanner in = new Scanner(System.in);  int x = in.nextInt(),y = in.nextInt();  ArrayList<Passengers> list = new ArrayList<>(); for ( int i = 1;(i <= x);++i) {list.add(new Passengers(in.nextInt(),in.nextInt())); } int sum = 0; for ( int i = (list.size() - 1);(i >= 0);--i) { int s = (y - list.get(i).floor); sum = (sum + s); if ( (sum < list.get(i).time)) {sum = (sum + (list.get(i).time - sum)); } y = list.get(i).floor; }if ( (list.get((list.size() - 1)).floor != 0)) {sum = (sum + list.get(0)); } System.out.println(sum); } }
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 Village{ private class House implements Comparable<House>{ Double Coordinate ; Double Sidelength ; public House( double coordinate, double sidelength){ Coordinate = coordinate; Sidelength = sidelength; } public int compareTo( House o){ return Coordinate.compareTo(o.Coordinate);} } public static void main( String[] args){ Village v = new Village(); v.solve(); } public void solve(){ Scanner in = new Scanner(System.in);  int numhouse = in.nextInt();  double requireside = in.nextDouble();  ArrayList<House> coordinate = new ArrayList<House>();  ArrayList<Double> sidelength = new ArrayList<Double>(); while(in.hasNext()){ double coo = in.nextDouble();  double side = in.nextDouble(); coordinate.add(new House(coo,side)); sidelength.add(side); }Collections.sort(coordinate); ArrayList<Double> edges = new ArrayList<Double>();  int count = 2; for ( int i = 0;(i < coordinate.size());i++) {edges.add((coordinate.get(i).Coordinate - ((double)coordinate.get(i).Sidelength / (double)2))); edges.add((coordinate.get(i).Coordinate + ((double)coordinate.get(i).Sidelength / (double)2))); } ArrayList<Double> difference = new ArrayList<Double>(); for ( int i = 1;(i < (edges.size() - 1));i++) {difference.add(Math.abs((edges.get(i) - edges.get((i + 1))))); }for ( int i = 0;(i < difference.size());i += 2) {if ( (difference.get(i) == requireside)) count++; else if ( (difference.get(i) > requireside)) count += 2; }System.out.println(count); } }
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.nextInt();  int r = in.nextInt();  int[] x = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = in.nextInt(); } double res = 0;  double[] y = new double[n]; for ( int i = 0;(i < n);i++) { double curY = r; for ( int j = 0;(j < i);j++) { int d = Math.abs((x[i] - x[j])); if ( (d <= (2 * r))) { int a2 = (((4 * r) * r) - (d * d)); curY = Math.max(curY,(y[j] + Math.sqrt(a2))); } }y[i] = curY; out.printf("%.14f",y[i]); if ( (i < (n - 1))) {out.print(" "); } else {out.println(); }}} } static class InputReader{ final InputStream is ; final byte[] buf = new byte[1024]; int pos ; int size ; public InputReader( InputStream is){ this.is = is; } public int nextInt(){ int c = read(); while(isWhitespace(c))c = read(); int sign = 1; if ( (c == '-')) {sign = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = read(); }while(!isWhitespace(c));return (res * sign);} int read(){ if ( (size == -1)) throw (new InputMismatchException()); if ( (pos >= size)) {pos = 0; try{size = is.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (size <= 0)) return -1; } return (buf[pos++] & 255);} static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
1	public class main{ public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter pw = new PrintWriter(System.out); public static String line ; public static StringTokenizer st ; public static ArrayList<ArrayList<Integer>> adjList ; public static int[] dr = {-1,0,1,0,-1,1,1,-1}; public static int[] dc = {0,1,0,-1,1,1,-1,-1}; public static void main( String[] args)throws Exception { int N = Integer.parseInt(br.readLine());  char[] A = br.readLine().toCharArray();  HashSet<Character> cndD = new HashSet<Character>(); for ( int i = 0;(i < N);i++) {cndD.add(A[i]); } int cnt = cndD.size();  int a = 0;  int b = 0;  int ans = (1 << 30);  HashMap<Character,Integer> d = new HashMap<Character,Integer>(); while((b < N)){if ( d.containsKey(A[b])) {if ( (A[a] == A[b])) {a++; while((d.get(A[a]) > 1)){d.put(A[a],(d.get(A[a]) - 1)); a++; }} else {d.put(A[b],(d.get(A[b]) + 1)); }} else {d.put(A[b],1); }if ( (d.size() == cnt)) {ans = Math.min(((b - a) + 1),ans); } b++; }pw.print((ans + "\n")); pw.close(); br.close(); } }
1	public class B{ static Scanner in ; static void put( TreeMap<Integer,Integer> m, int key){ if ( m.containsKey(key)) {m.put(key,(m.get(key) + 1)); } else {m.put(key,1); }} static void remove( TreeMap<Integer,Integer> m, int key){ if ( !m.containsKey(key)) return ; m.put(key,(m.get(key) - 1)); if ( (m.get(key) == 0)) {m.remove(key); } } public static void main( String[] args){ in = new Scanner(System.in); int n = in.nextInt();  int k = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); } int i = 0; while((((i + 1) < n) && (a[(i + 1)] == a[0]))){i++; } int left = i;  TreeMap<Integer,Integer> used = new TreeMap<Integer,Integer>(); for ( ;(i < n);i++) {put(used,a[i]); if ( (used.size() == k)) {while((used.get(a[left]) > 1)){remove(used,a[left]); left++; }System.out.println((((left + 1) + " ") + (i + 1))); return ;} }System.out.println("-1 -1"); } }
0	public class CodeForce275A{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer token = new StringTokenizer(in.readLine());  long l = Long.parseLong(token.nextToken());  long r = Long.parseLong(token.nextToken()); if ( ((r - l) < 2)) {System.out.println(-1); return ;} if ( (((l % 2) == 1) && ((r - l) < 3))) {System.out.println(-1); return ;} if ( ((l % 2) == 0)) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); return ;} if ( ((l % 2) == 1)) {System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); } } }
3	public class paintNumbers{ public static int minIndex( List<Integer> list){ int min = list.get(0);  int minIndex = 0; for ( int i = 0;(i < list.size());i++) {if ( (list.get(i) < min)) {min = list.get(i); minIndex = i; } }return minIndex;} public static void main( String[] args)throws IOException { FastScanner sc = new FastScanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  List<Integer> list = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {list.add(sc.nextInt()); } int count = 0; while((list.size() > 0)){count++; int temp = list.get(minIndex(list)); for ( int j = 0;(j < list.size());j++) {if ( ((list.get(j) % temp) == 0)) {list.remove(j); j--; } }}pw.println(count); pw.close(); } static class FastScanner{ private boolean finished = false; private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public FastScanner( 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 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 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));} 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();}} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } public int[] nextIntArray( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);++i) array[i] = nextInt(); return array;} public ArrayList<Integer>[] nextGraph( int n, int m){ ArrayList<Integer>[] adj = new ArrayList[n]; for ( int i = 0;(i < n);i++) {adj[i] = new ArrayList<Integer>(); }for ( int i = 0;(i < m);i++) { int u = nextInt();  int v = nextInt(); u--; v--; adj[u].add(v); adj[v].add(u); }return adj;} public long[] nextLongArray( int n){ long[] array = new long[n]; for ( int i = 0;(i < n);++i) array[i] = nextLong(); return array;} } }
3	public class C{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int r = in.nextInt();  double pos[][] = new double[n][2]; for ( int i = 0;(i < n);i++) {pos[i][0] = in.nextInt(); double y = r; for ( int j = 0;(j < i);j++) {if ( (Math.abs((pos[i][0] - pos[j][0])) <= (2 * r))) { double tempy = (pos[j][1] + Math.sqrt((Math.pow((2 * r),2) - Math.pow(Math.abs((pos[i][0] - pos[j][0])),2)))); if ( (tempy > y)) y = tempy; } }pos[i][1] = y; System.out.print((y + " ")); }} }
6	public class ElongatedMatrix{ static int[][][] memo ; static int mn1[][] ; static int mn2[][] ; static int r ,c ; static int dp( int mask, int first, int lastvisited){ if ( (memo[first][lastvisited][mask] != -1)) return memo[first][lastvisited][mask]; int ans = 0; for ( int i = 0;(i < r);i++) {if ( ((mask & (1 << i)) == 0)) {if ( (Integer.bitCount(mask) != (r - 1))) {ans = Math.max(ans,Math.min(mn1[lastvisited][i],dp((mask | (1 << i)),first,i))); } else ans = Math.max(ans,Math.min(mn2[first][i],mn1[lastvisited][i])); } }return memo[first][lastvisited][mask] = ans;} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  PrintWriter out = new PrintWriter(System.out); r = Integer.parseInt(st.nextToken()); c = Integer.parseInt(st.nextToken()); int[][] arr = new int[r][c]; memo = new int[r][r][(1 << r)]; mn1 = new int[r][r]; mn2 = new int[r][r]; for ( int i = 0;(i < r);i++) {st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < c);j++) {arr[i][j] = Integer.parseInt(st.nextToken()); }}for ( int i = 0;(i < r);i++) {Arrays.fill(mn1[i],(int)1e9); Arrays.fill(mn2[i],(int)1e9); }for ( int i = 0;(i < r);i++) {for ( int j = 0;(j < r);j++) {Arrays.fill(memo[i][j],-1); }}for ( int i = 0;(i < r);i++) {for ( int j = 0;(j < r);j++) {for ( int k = 0;(k < c);k++) {mn1[i][j] = Math.min(mn1[i][j],Math.abs((arr[i][k] - arr[j][k]))); }}}for ( int i = 0;(i < r);i++) {for ( int j = 0;(j < r);j++) {for ( int k = 0;(k < (c - 1));k++) {mn2[i][j] = Math.min(mn2[i][j],Math.abs((arr[j][k] - arr[i][(k + 1)]))); }}} int ans = 0; for ( int i = 0;(i < r);i++) {ans = Math.max(ans,dp((1 << i),i,i)); }if ( (r == 1)) ans = mn2[0][0]; out.println(ans); out.flush(); } }
5	public class _P015A{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int n ,t ; int[][] a ; void run(){ n = sc.nextInt(); t = sc.nextInt(); a = new int[n][2]; for ( int i = 0;(i < n);i++) {a[i][0] = sc.nextInt(); a[i][1] = sc.nextInt(); }solve(); } void solve(){ sort(a,new Comparator<int[]>(){}); int ans = 2; for ( int i = 0;(i < (n - 1));i++) { int s = (((a[(i + 1)][0] * 2) - a[(i + 1)][1]) - ((a[i][0] * 2) + a[i][1])); if ( (s > (t * 2))) {ans += 2; } else if ( (s == (t * 2))) {ans++; } }println((ans + "")); } void println( String s){ System.out.println(s); } void print( String s){ System.out.print(s); } public static void main( String[] args){ new _P015A().run(); } }
0	public class Main{ public static void main( String[] args){ Scanner r = new Scanner(System.in);  int N = r.nextInt(); System.out.println(((((N + " ") + 0) + " ") + 0)); } }
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 odd = 0;  int even = 0;  int lastOdd = 0;  int lastEven = 0; for ( int i = 0;(i < n);i++) {if ( ((nums[i] % 2) == 0)) {even++; lastEven = (i + 1); } else {odd++; lastOdd = (i + 1); }}if ( (odd == 1)) System.out.println(lastOdd); else System.out.println(lastEven); } public static void main( String[] args){ new R025A().process(); } }
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());} } }
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))); }} }
3	public class RGBSubstring{ public static void main( String[] args){ FastScanner scanner = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int Q = scanner.nextInt(); while((Q-- > 0)){ int N = scanner.nextInt();  int K = scanner.nextInt();  String s1 = "RGB";  String s2 = "GBR";  String s3 = "BRG";  char[] arr = scanner.next().toCharArray();  int[] cnts = new int[3]; for ( int i = 0;(i < K);i++) { int ind = (i % 3); if ( (arr[i] != s1.charAt(ind))) cnts[0]++; if ( (arr[i] != s2.charAt(ind))) cnts[1]++; if ( (arr[i] != s3.charAt(ind))) cnts[2]++; } int ans = Math.min(Math.min(cnts[0],cnts[1]),cnts[2]); for ( int i = K;(i < N);i++) { int ind = ((K - 1) % 3);  int[] nextCnts = new int[3]; nextCnts[1] = cnts[0]; nextCnts[2] = cnts[1]; nextCnts[0] = cnts[2]; if ( ('R' != arr[(i - K)])) nextCnts[1]--; if ( ('G' != arr[(i - K)])) nextCnts[2]--; if ( ('B' != arr[(i - K)])) nextCnts[0]--; if ( (arr[i] != s1.charAt(ind))) nextCnts[0]++; if ( (arr[i] != s2.charAt(ind))) nextCnts[1]++; if ( (arr[i] != s3.charAt(ind))) nextCnts[2]++; cnts = nextCnts; for ( int j = 0;(j < 3);j++) ans = Math.min(ans,cnts[j]); }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());} } }
3	public class GB17C{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));  String[] dir = sc.readLine().split(" ");  int n = Integer.parseInt(dir[0]);  int r = Integer.parseInt(dir[1]);  String[] t = sc.readLine().split(" ");  int[] list = new int[n]; for ( int x = 0;(x < n);x++) {list[x] = Integer.parseInt(t[x]); } double[] yCoords = new double[n]; for ( int x = 0;(x < n);x++) { double stop = (double)r;  int dist = (2 * r);  int xCoordNew = list[x]; for ( int y = 0;(y < x);y++) { int xCoordOld = list[y]; if ( (Math.abs((xCoordNew - xCoordOld)) == dist)) {stop = Math.max(stop,yCoords[y]); } else if ( (Math.abs((xCoordNew - xCoordOld)) < dist)) { double extra = Math.pow(((double)(dist * dist) - (double)((xCoordNew - xCoordOld) * (xCoordNew - xCoordOld))),0.5); stop = Math.max(stop,(yCoords[y] + extra)); } }yCoords[x] = stop; System.out.print((stop + " ")); }} }
5	public class Chores{ public static void main( String[] args)throws IOException { InputStreamReader isr = new InputStreamReader(System.in);  BufferedReader br = new BufferedReader(isr);  String[] line = br.readLine().split("\\W");  int n = Integer.parseInt(line[0]);  int a = Integer.parseInt(line[1]);  int b = Integer.parseInt(line[2]);  int[] num = new int[n]; line = br.readLine().split("\\W"); for ( int i = 0;(i < n);i++) num[i] = Integer.parseInt(line[i]); Arrays.sort(num); System.out.println((num[b] - num[(b - 1)])); } }
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); } }
1	public class AnnoyingPresent{ 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()),m = Long.parseLong(st.nextToken());  long sum = 0; for ( int i = 0;(i < m);i++) { StringTokenizer st1 = new StringTokenizer(br.readLine()); sum += (n * Long.parseLong(st1.nextToken())); Long a = Long.parseLong(st1.nextToken()); if ( (a < 0)) {if ( ((n % 2) == 0)) sum += (((n * n) / 4) * a); else {sum += (((n / 2) * ((n / 2) + 1)) * a); }} else sum += (((a * n) * (n - 1)) / 2); }System.out.println(((double)sum / n)); } }
3	public class vas2{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  String st = in.next();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = (st.charAt(i) - 48); boolean c = false; for ( int i = 1;(!c && (i < n));i++) { int s = 0; for ( int j = 0;(j < i);j++) s += a[j]; int t = 0; for ( int j = i;(j < n);j++) {t += a[j]; if ( (t > s)) if ( ((t - a[j]) != s)) break; else t = a[j]; }if ( (t == s)) c = true; }System.out.println((c?"YES":"NO")); } }
5	public class Main implements Runnable{ static private String[] args ; public static void main( String[] args){ Main.args = args; new Thread(null,new Main(),"MyRunThread",(1 << 26)).start(); } } final class Solver{ InputReader in ; OutputWriter out ; DebugWriter debug ; public void solve(){ int n = in.readInt();  int[] mas = new int[n];  int[] sorted = new int[n]; for ( int i = 0;(i < n);++i) sorted[i] = mas[i] = in.readInt(); Random rnd = new Random(System.nanoTime()); for ( int i = 1;(i < n);++i) { int j = rnd.nextInt(i);  int tmp = sorted[j]; sorted[j] = sorted[i]; sorted[i] = tmp; }Arrays.sort(sorted); int id1 = -1; for ( int i = 0;(i < n);++i) if ( (mas[i] != sorted[i])) {id1 = i; break;} int id2 = -1; for ( int i = (n - 1);(i >= 0);--i) if ( (mas[i] != sorted[i])) {id2 = i; break;} if ( (((id1 != -1) && (id2 != -1)) && (id1 != id2))) { int tmp = mas[id1]; mas[id1] = mas[id2]; mas[id2] = tmp; } for ( int i = 0;(i < n);++i) if ( (mas[i] != sorted[i])) {out.printLine("NO"); return ;} out.printLine("YES"); } } 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; } 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();} } 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 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( 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(); } } 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( 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(); } public void close(){ writer.close(); } }
5	public class Sockets{ 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());} void solve()throws Exception { int n = nextInt();  int m = nextInt();  int k = nextInt();  List<Integer> fs = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) fs.add(nextInt()); Collections.sort(fs); Collections.reverse(fs); int c = k; for ( int i = 0;(i < fs.size());i++) {if ( (c >= m)) {out.println(i); return ;} c += (fs.get(i) - 1); }if ( (c >= m)) out.println(fs.size()); else out.println(-1); } 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(); }} public static void main( String[] args){ new Sockets().run(); } }
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 m ,n ,k ; n = in.readInt(); m = in.readInt(); k = in.readInt(); int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = (in.readInt() - 1); Arrays.sort(a); int ans = -1; if ( (k >= m)) ans = 0; else for ( int i = 0;(i < n);i++) {k += a[((n - i) - 1)]; if ( (k >= m)) {ans = (i + 1); break;} }System.out.println(ans); } } 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();} public static 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();} } 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(); } }
3	public class ProblemD{ static int mod = (int)(1e9 + 7); static InputReader in ; static PrintWriter out ; static void solve(){ in = new InputReader(System.in); out = new PrintWriter(System.out); int n = in.nextInt();  int r = in.nextInt();  double[] x = new double[n];  double[] y = new double[n]; for ( int i = 0;(i < n);i++) { int xx = in.nextInt(); x[i] = xx; y[i] = r; for ( int j = 0;(j < i);j++) { double delx = Math.abs((x[i] - x[j])); if ( (delx <= (2 * r))) { double tmp = (((4 * r) * r) - (delx * delx)); tmp = Math.sqrt(tmp); tmp = (y[j] + tmp); y[i] = Math.max(y[i],tmp); } }out.print((y[i] + " ")); }out.close(); } public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } 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 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); } } }
1	public class b{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt(),k = input.nextInt();  int[] data = new int[n]; for ( int i = 0;(i < n);i++) data[i] = input.nextInt(); int[] freq = new int[100001];  int count = 0; for ( int i = 0;(i < n);i++) {if ( (freq[data[i]] == 0)) count++; freq[data[i]]++; }if ( (count < k)) System.out.println("-1 -1"); else { int start = 0; for ( int i = 0;(i < n);i++) {if ( (count > k)) {freq[data[i]]--; if ( (freq[data[i]] == 0)) count--; } else {if ( (freq[data[i]] > 1)) {freq[data[i]]--; } else {start = i; break;}}} int end = (n - 1); for ( int i = (n - 1);(i >= 0);i--) {if ( (freq[data[i]] == 1)) {end = i; break;} else freq[data[i]]--; }start++; end++; if ( (start <= end)) System.out.println(((start + " ") + end)); else System.out.println(((-1 + " ") + -1)); }} }
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();  List<List<Integer>> horizontalEdgeWeights = new ArrayList<List<Integer>>(rows); for ( int r = 0;(r < rows);r++) {horizontalEdgeWeights.add(new ArrayList<Integer>((cols - 1))); for ( int c = 0;(c < (cols - 1));c++) {horizontalEdgeWeights.get(r).add(FR.nextInt()); }} List<List<Integer>> verticalEdgeWeights = new ArrayList<List<Integer>>((rows - 1)); for ( int r = 0;(r < (rows - 1));r++) {verticalEdgeWeights.add(new ArrayList<Integer>(cols)); for ( int c = 0;(c < cols);c++) {verticalEdgeWeights.get(r).add(FR.nextInt()); }} List<List<Integer>> result = getResult(rows,cols,moves,horizontalEdgeWeights,verticalEdgeWeights); for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) { int value = ((result != null)?result.get(r).get(c):-1); solution.append((value + " ")); }solution.append("\n"); }PW.print(solution.toString()); PW.close(); } static List<List<Integer>> getResult( int rows, int cols, int moves, List<List<Integer>> horizontalEdgeWeights, List<List<Integer>> verticalEdgeWeights){ if ( ((moves & 1) == 1)) {return null;} int mid = (moves >> 1);  List<List<List<Integer>>> minForDistance = new ArrayList<List<List<Integer>>>(rows); for ( int r = 0;(r < rows);r++) {minForDistance.add(new ArrayList<List<Integer>>(cols)); for ( int c = 0;(c < cols);c++) {minForDistance.get(r).add(new ArrayList<Integer>(Collections.nCopies((mid + 1),Integer.MAX_VALUE))); minForDistance.get(r).get(c).set(0,0); }}for ( int m = 1;(m <= mid);m++) {for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) { int minBoredom = minForDistance.get(r).get(c).get(m); if ( (r > 0)) {if ( (minForDistance.get((r - 1)).get(c).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get((r - 1)).get(c).get((m - 1)) + verticalEdgeWeights.get((r - 1)).get(c)); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( (c > 0)) {if ( (minForDistance.get(r).get((c - 1)).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get(r).get((c - 1)).get((m - 1)) + horizontalEdgeWeights.get(r).get((c - 1))); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( ((r + 1) < rows)) {if ( (minForDistance.get((r + 1)).get(c).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get((r + 1)).get(c).get((m - 1)) + verticalEdgeWeights.get(r).get(c)); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( ((c + 1) < cols)) {if ( (minForDistance.get(r).get((c + 1)).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get(r).get((c + 1)).get((m - 1)) + horizontalEdgeWeights.get(r).get(c)); minBoredom = Math.min(minBoredom,candidateBoredom); } } minForDistance.get(r).get(c).set(m,minBoredom); }}} List<List<Integer>> result = new ArrayList<List<Integer>>(rows); for ( int r = 0;(r < rows);r++) {result.add(new ArrayList<Integer>(cols)); for ( int c = 0;(c < cols);c++) {result.get(r).add((minForDistance.get(r).get(c).get(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());} } }
1	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);  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 static MyScanner sc ; public static PrintWriter out ; public void solve( int testNumber, MyScanner sc, PrintWriter out){ BPhoenixAndPuzzle.sc = sc; BPhoenixAndPuzzle.out = out; long n = sc.nextLong();  boolean can = true; if ( ((n % 2) != 0)) can = false; n /= 2; while(((n > 1) && ((n % 2) == 0)))n /= 2; long sq = Math.round(Math.pow(n,0.5)); if ( ((sq * sq) != n)) can = false; out.println((can?"YES":"NO")); } } 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 long nextLong(){ return Long.parseLong(next());} } }
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(); } }
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(); } } class TaskC{ public void solve( int testNumber, InputReader in, OutputWriter out){ int xs = in.readInt();  int ys = in.readInt();  int n = in.readInt();  int[] x = new int[n];  int[] y = new int[n]; IOUtils.readIntArrays(in,x,y); int[] res = new int[(1 << n)];  int[] last = new int[(1 << n)]; Arrays.fill(res,Integer.MAX_VALUE); int[] ds = new int[n]; for ( int i = 0;(i < n);i++) {ds[i] = (((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys))); } int[][] d = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) d[i][j] = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); }res[0] = 0; for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( (((i >> j) & 1) != 0)) {if ( ((res[(i - (1 << j))] + (2 * ds[j])) < res[i])) {res[i] = (res[(i - (1 << j))] + (2 * ds[j])); last[i] = (i - (1 << j)); } for ( int k = (j + 1);(k < n);k++) {if ( (((i >> k) & 1) != 0)) {if ( ((((res[((i - (1 << j)) - (1 << k))] + ds[j]) + ds[k]) + d[j][k]) < res[i])) {res[i] = (((res[((i - (1 << j)) - (1 << k))] + ds[j]) + ds[k]) + d[j][k]); last[i] = ((i - (1 << j)) - (1 << k)); } } }break;} }} int cur = ((1 << n) - 1); out.printLine(res[cur]); while((cur != 0)){out.print("0 "); int dif = (cur - last[cur]); for ( int i = 0;((i < n) && (dif != 0));i++) {if ( (((dif >> i) & 1) != 0)) {out.print(((i + 1) + " ")); dif -= (1 << i); } }cur = last[cur]; }out.printLine("0"); } } 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(); } }
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);} }
3	public class D{ public static void main( String[] args)throws Exception { new D().run(); } int[] BIT ; public void run()throws Exception { FastScanner f = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int n = f.nextInt();  int[] arr = new int[n]; BIT = new int[(n + 10)]; int inv = 0; for ( int i = 0;(i < n);i++) {arr[i] = f.nextInt(); inv ^= ((i - query(arr[i])) & 1); add(arr[i]); } int k = f.nextInt(); while((k-- > 0)){ int diff = ((-f.nextInt() + f.nextInt()) + 1); inv ^= (((diff * (diff - 1)) / 2) & 1); out.println(((inv == 1)?"odd":"even")); }out.flush(); } public int query( int i){ i++; int res = 0; while((i > 0)){res += BIT[i]; i -= (i & -i); }return res;} public void add( int i){ i++; while((i < BIT.length)){BIT[i]++; i += (i & -i); }} static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
2	public class Main{ public static void main( String[] args){ new Main().run(); } FastReader in = new FastReader(); PrintWriter out = new PrintWriter(System.out); void run(){ int q = in.nextInt(); for ( int i = 0;(i < q);i++) {work(); }out.flush(); } long mod = 1000000007; long gcd( long a, long b){ return ((a == 0)?b:((b > a)?gcd((b % a),a):gcd(b,a)));} void work(){ long n = in.nextLong();  long k = in.nextLong(); if ( (k == 0)) {out.println((("YES" + " ") + n)); } long a = 0,b = 0,c = 1,d = 1; while(((--n >= 0) && (a <= k))){b += c; c *= 4; a += d; d = ((d * 2) + 1); long t = count((c - d),n); if ( ((a <= k) && (b >= (k - t)))) {out.println((("YES" + " ") + n)); return ;} }out.println("NO"); } private long count( long l, long n){ if ( (n == 0)) return 0; n--; long ret = l; for ( int i = 1;(i <= n);i++) { long t = ret; ret *= 4; if ( ((ret / 4) != t)) return Long.MAX_VALUE; }return ret;} } 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());} public long nextLong(){ return Long.parseLong(next());} }
1	public class Main{ static Graph graph[] ; public static void dfs( int index){ Graph z = graph[index]; z.vis = 1; Graph v ; for ( int i = 0;(i < z.adj.size());i++) {v = z.adj.get(i); if ( (v.vis == 0)) {v.dist = (z.dist + 1); v.parent = z.val; dfs(v.val); } }} 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());} long nextLong(){ return Long.parseLong(next());} } public static void main( String[] args){ FastReader sc = new FastReader();  int n = sc.nextInt();  Pair arr[] = new Pair[n];  Pair pref[] = new Pair[n];  Pair suff[] = new Pair[n]; for ( int i = 0;(i < n);i++) { long u = sc.nextLong();  long v = sc.nextLong(); arr[i] = new Pair(u,v); pref[i] = new Pair(0,0); suff[i] = new Pair(0,0); }pref[0].x = arr[0].x; pref[0].y = arr[0].y; for ( int i = 1;(i < n);i++) {pref[i].x = (long)Math.max(pref[(i - 1)].x,arr[i].x); pref[i].y = (long)Math.min(pref[(i - 1)].y,arr[i].y); }suff[(n - 1)].x = arr[(n - 1)].x; suff[(n - 1)].y = arr[(n - 1)].y; for ( int i = (n - 2);(i >= 0);i--) {suff[i].x = (long)Math.max(suff[(i + 1)].x,arr[i].x); suff[i].y = (long)Math.min(suff[(i + 1)].y,arr[i].y); } long max = Long.MIN_VALUE;  long ans = 0; for ( int i = 0;(i < n);i++) { long val = Long.MAX_VALUE;  long val1 = Long.MAX_VALUE; if ( ((i != 0) && (i != (n - 1)))) {val = ((long)Math.min(pref[(i - 1)].y,suff[(i + 1)].y) - (long)Math.max(pref[(i - 1)].x,suff[(i + 1)].x)); } else if ( (i != (n - 1))) {val = (suff[(i + 1)].y - suff[(i + 1)].x); } else val = (pref[(i - 1)].y - pref[(i - 1)].x); ans = val; if ( (ans < 0)) ans = 0; max = (long)Math.max(ans,max); }System.out.println(max); } } class Pair{ long x ,y ; Pair( long x, long y){ this.x = x; this.y = y; } }
1	public class B{ public static void main( String[] args){ FastScanner in = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int t = in.nextInt(),tt = 0; while((t-- > 0)){ int n = in.nextInt(); if ( ((n % 2) != 0)) out.println("NO"); else {n /= 2; if ( (Math.sqrt(n) == Math.ceil(Math.sqrt(n)))) out.println("YES"); else {if ( ((n % 2) != 0)) out.println("NO"); else {n /= 2; if ( (Math.sqrt(n) == Math.ceil(Math.sqrt(n)))) out.println("YES"); else out.println("NO"); }}}}out.flush(); } 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){ } return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } static final Random random = new Random(); }
2	public class A{ private long pow( long num, long pow, long mod){ if ( (pow <= 0)) {return 1;} if ( ((pow & 1) != 0)) {return ((num * pow(num,(pow - 1),mod)) % mod);} else { long tmp = (pow(num,(pow >> 1),mod) % mod); return ((tmp * tmp) % mod);}} public void run(){ long MOD = 1000000009;  long n = nextInt();  long m = nextInt();  long k = nextInt();  long critical = (n / k); if ( ((n - critical) >= m)) {out.println(m); } else { long doubles = (m - (n - critical));  long ans = (((pow(2,(doubles + 1),MOD) - 2) + MOD) % MOD); ans = ((ans * k) % MOD); ans = ((ans + (m - (doubles * k))) % MOD); out.println(ans); }out.flush(); } static private BufferedReader br = null; static private StringTokenizer stk = null; static private PrintWriter out = null; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); new A().run(); } private void loadLine(){ try{stk = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } private int nextInt(){ while(((stk == null) || !stk.hasMoreElements()))loadLine(); return Integer.parseInt(stk.nextToken());} }
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 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(); } }
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); }
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(); } }
2	public class Main{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  double n = s.nextLong();  double k = s.nextLong();  double num = ((-3 + Math.sqrt((9 + (8 * (n + k))))) / 2); System.out.println((long)(n - num)); } }
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 Solution implements Runnable{ public long gcd( long a, long b){ long tmp ; while((b > 0)){a %= b; tmp = a; a = b; b = tmp; }return a;} public void solve()throws Exception { long a = sc.nextLong();  long b = sc.nextLong();  long ans = 0;  long k = 0; if ( ((a == 1) || (b == 1))) {out.println(max(a,b)); return ;} while(((a > 1) && (b > 1))){if ( (a > b)) {k = (a / b); ans += k; a -= (k * b); } else {k = (b / a); ans += k; b -= (k * a); }k = gcd(a,b); a /= k; b /= k; }if ( (a == 1)) ans += b; else ans += a; out.println(ans); } static Throwable throwable ; BufferedReader in ; PrintWriter out ; FastScanner sc ; public static void main( String[] args)throws Throwable { Thread thread = new Thread(null,new Solution(),"",(1 << 26)); thread.start(); thread.join(); if ( (throwable != null)) {throw (throwable);} } } class FastScanner{ BufferedReader reader ; StringTokenizer strTok ; public FastScanner( BufferedReader reader){ this.reader = reader; } public String nextToken()throws Exception { while(((strTok == null) || !strTok.hasMoreTokens())){strTok = new StringTokenizer(reader.readLine()); }return strTok.nextToken();} public long nextLong()throws Exception { return Long.parseLong(nextToken());} }
3	public class Main{ public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));  String[] line = in.readLine().split(" ");  int n = Integer.parseInt(line[0]);  int r = Integer.parseInt(line[1]); line = in.readLine().split(" "); int[] x = new int[(n + 1)];  double[] y = new double[(n + 1)]; for ( int i = 1;(i <= n);++i) {x[i] = Integer.parseInt(line[(i - 1)]); double maxy = -1.0; for ( int j = 1;(j < i);++j) { double x2 = x[i];  double x1 = x[j];  double y1 = y[j];  double a = 1;  double b = (-2 * y1);  double c = (((((x1 * x1) + (x2 * x2)) - ((2 * x1) * x2)) + (y1 * y1)) - ((4.0 * r) * r));  double D = ((b * b) - ((4 * a) * c)); if ( (D >= 0)) { double y2 = ((-b + Math.sqrt(D)) / (2 * a)); maxy = Math.max(maxy,y2); } }if ( (maxy < 0)) {maxy = r; } y[i] = maxy; if ( (i > 1)) {System.out.print(" "); } System.out.printf("%.13f",y[i]); }System.out.println(); } }
6	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{ int n ; long neededSum ; long[] sums ; Map<Long,Integer> where ; public void solve( int testNumber, FastScanner in, PrintWriter out){ n = in.nextInt(); int[][] a = new int[n][]; neededSum = 0; sums = new long[n]; for ( int i = 0;(i < n);i++) { int k = in.nextInt(); a[i] = new int[k]; for ( int j = 0;(j < k);j++) {a[i][j] = in.nextInt(); neededSum += a[i][j]; sums[i] += a[i][j]; }}if ( ((neededSum % n) != 0)) {out.println("No"); return ;} neededSum /= n; where = new HashMap<>(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < a[i].length);j++) {where.put((long)a[i][j],i); }} Entry[][] cycleSol = new Entry[(1 << n)][];  List<Entry> sol = new ArrayList<>(); for ( int i = 0;(i < n);i++) {for ( int x :a[i]) {search(i,i,x,x,0,0,sol,cycleSol); }} boolean[] can = new boolean[(1 << n)];  int[] via = new int[(1 << n)]; can[0] = true; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int submask = mask;(submask > 0);submask = ((submask - 1) & mask)) {if ( ((cycleSol[submask] != null) && can[(mask ^ submask)])) {can[mask] = true; via[mask] = submask; } }}if ( !can[((1 << n) - 1)]) {out.println("No"); return ;} int[][] ans = new int[n][2]; for ( int mask = ((1 << n) - 1);(mask > 0);) { int sm = via[mask]; mask ^= sm; for ( Entry e :cycleSol[sm]) {ans[e.from][0] = e.what; ans[e.from][1] = (e.to + 1); }}out.println("Yes"); for ( int i = 0;(i < n);i++) {out.println(((ans[i][0] + " ") + ans[i][1])); }} private void search( int start, int cur, long fromStart, long fromCur, int hasIn, int hasOut, List<Entry> sol, Entry[][] cycleSol){ for ( int i = start;(i < n);i++) {if ( ((hasIn & (1 << i)) > 0)) {continue;} if ( ((hasOut & (1 << cur)) > 0)) {continue;} long fromI = ((sums[i] + fromCur) - neededSum);  Integer w = where.get(fromI); if ( ((w == null) || (w != i))) {continue;} sol.add(new Entry(cur,i,(int)fromCur)); int nHasIn = (hasIn | (1 << i));  int nHasOut = (hasOut | (1 << cur)); if ( ((i == start) && (fromI == fromStart))) {cycleSol[nHasOut] = sol.toArray(new Entry[0]); } search(start,i,fromStart,fromI,nHasIn,nHasOut,sol,cycleSol); sol.remove((sol.size() - 1)); }} class Entry{ int from ; int to ; int what ; Entry( int from, int to, int what){ this.from = from; this.to = to; this.what = what; } } } 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{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class CodeForces{ public static void main( String[] args)throws FileNotFoundException { FastIO io = new FastIO();  int width = io.nextInt();  int height = io.nextInt();  int initials = io.nextInt();  boolean[][] visited = new boolean[width][height];  Queue<Coordinate> q = new ArrayDeque<>(); for ( int i = 0;(i < initials);i++) {q.add(new Coordinate((io.nextInt() - 1),(io.nextInt() - 1))); } Coordinate oneOfLast = null; while(!q.isEmpty()){ int len = q.size(); for ( int times = 0;(times < len);times++) { Coordinate c = q.poll(); if ( visited[c.x][c.y]) {continue;} oneOfLast = c; visited[c.x][c.y] = true; int[][] deltas = new int[][]{{-1,0},{0,-1},{1,0},{0,1}}; for ( int[] delta :deltas) { int ci = (c.y + delta[0]);  int cj = (c.x + delta[1]); if ( ((((ci >= 0) && (cj >= 0)) && (ci < height)) && (cj < width))) {q.add(new Coordinate(cj,ci)); } }}}io.println((((oneOfLast.x + 1) + " ") + (oneOfLast.y + 1))); io.close(); } static class Coordinate{ int x ; int y ; public Coordinate( int x, int y){ this.x = x; this.y = y; } } static class FastIO extends PrintWriter{ BufferedReader br ; StringTokenizer st ; public FastIO()throws FileNotFoundException{ super(new BufferedOutputStream(new FileOutputStream("output.txt"))); br = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); } 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());} String nextToken(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} } }
4	public class Main{ static final FastReader FR = new FastReader(); static final BufferedWriter BW = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main( String[] args)throws IOException { StringBuilder solution = new StringBuilder();  int rows = FR.nextInt();  int cols = FR.nextInt();  int moves = FR.nextInt();  Map<Integer,Integer> horizontalEdgeWeights = new HashMap<Integer,Integer>(); for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < (cols - 1));c++) { int hash = getHash(r,c); horizontalEdgeWeights.put(hash,FR.nextInt()); }} Map<Integer,Integer> verticalEdgeWeights = new HashMap<Integer,Integer>(); for ( int r = 0;(r < (rows - 1));r++) {for ( int c = 0;(c < cols);c++) { int hash = getHash(r,c); verticalEdgeWeights.put(hash,FR.nextInt()); }} List<List<Integer>> result = getResult(rows,cols,moves,horizontalEdgeWeights,verticalEdgeWeights); for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) { int value = ((result != null)?result.get(r).get(c):-1); solution.append((value + " ")); }solution.append("\n"); }BW.write(solution.toString()); BW.close(); } static List<List<Integer>> getResult( int rows, int cols, int moves, Map<Integer,Integer> horizontalEdgeWeights, Map<Integer,Integer> verticalEdgeWeights){ if ( ((moves & 1) == 1)) {return null;} int mid = (moves >> 1);  List<List<List<Integer>>> minForDistance = new ArrayList<List<List<Integer>>>(rows); for ( int r = 0;(r < rows);r++) {minForDistance.add(new ArrayList<List<Integer>>(cols)); for ( int c = 0;(c < cols);c++) {minForDistance.get(r).add(new ArrayList<Integer>(Collections.nCopies((mid + 1),Integer.MAX_VALUE))); minForDistance.get(r).get(c).set(0,0); }}for ( int m = 1;(m <= mid);m++) {for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) { int minBoredom = minForDistance.get(r).get(c).get(m);  int hash = getHash(r,c); if ( (r > 0)) {if ( (minForDistance.get((r - 1)).get(c).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get((r - 1)).get(c).get((m - 1)) + verticalEdgeWeights.get(getHash((r - 1),c))); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( (c > 0)) {if ( (minForDistance.get(r).get((c - 1)).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get(r).get((c - 1)).get((m - 1)) + horizontalEdgeWeights.get(getHash(r,(c - 1)))); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( ((r + 1) < rows)) {if ( (minForDistance.get((r + 1)).get(c).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get((r + 1)).get(c).get((m - 1)) + verticalEdgeWeights.get(hash)); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( ((c + 1) < cols)) {if ( (minForDistance.get(r).get((c + 1)).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get(r).get((c + 1)).get((m - 1)) + horizontalEdgeWeights.get(hash)); minBoredom = Math.min(minBoredom,candidateBoredom); } } minForDistance.get(r).get(c).set(m,minBoredom); }}} List<List<Integer>> result = new ArrayList<List<Integer>>(rows); for ( int r = 0;(r < rows);r++) {result.add(new ArrayList<Integer>(cols)); for ( int c = 0;(c < cols);c++) {result.get(r).add((minForDistance.get(r).get(c).get(mid) << 1)); }}return result;} static int getHash( int row, int col){ return ((row * 1000) + col);} 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());} } }
6	public class Main{ static long dp[][][][] = new long[16][16][16][4]; static void ini(){ for ( int i = 0;(i < 16);i++) {for ( int j = 0;(j < 16);j++) {for ( int k = 0;(k < 16);k++) {for ( int l = 0;(l < 4);l++) {dp[i][j][k][l] = -1L; }}}}} static int chk( long i){ if ( (i == 0L)) return 1; else return 0;} static long f( long a, long b, long c, int taken){ int got = (int)((a + b) + c);  int have = ((chk(a) + chk(b)) + chk(c)); if ( (have == 2)) {if ( (got == 1)) return 1L; else return 0L;} if ( (dp[(int)a][(int)b][(int)c][taken] != -1)) {return dp[(int)a][(int)b][(int)c][taken];} long ans = 0L; if ( (taken == 0)) {if ( (a != 0)) ans += ((a * f((a - 1),b,c,1)) % mod); ans %= mod; if ( (b != 0)) ans += ((b * f(a,(b - 1),c,2)) % mod); ans %= mod; if ( (c != 0)) ans += ((c * f(a,b,(c - 1),3)) % mod); ans %= mod; } else {ans += ((((taken == 1) || (a == 0))?0L:((a * f((a - 1),b,c,1)) % mod)) % mod); ans %= mod; ans += ((((taken == 2) || (b == 0))?0L:((b * f(a,(b - 1),c,2)) % mod)) % mod); ans %= mod; ans += ((((taken == 3) || (c == 0))?0L:((c * f(a,b,(c - 1),3)) % mod)) % mod); ans %= mod; }dp[(int)a][(int)b][(int)c][taken] = ans; return ans;} public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt();  int total = in.nextInt();  int t[] = new int[n];  int g[] = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = in.nextInt(); g[i] = in.nextInt(); } long ans = 0L; for ( int i = 0;(i < (1 << n));i++) { int sum = 0;  int a[] = new int[4]; for ( int j = 0;(j < n);j++) {if ( (((i >> j) & 1) == 1)) {sum += t[j]; a[g[j]]++; } }if ( (sum == total)) {ini(); ans = ((ans + f(a[1],a[2],a[3],0)) % mod); } }pw.println(ans); pw.flush(); pw.close(); } 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 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); } } public static long mod = 1000000007; public static int d ; public static int p ; public static int q ; public static int GCD( int a, int b){ if ( (b == 0)) return a; else return GCD(b,(a % b));} public static long GCD( long a, long b){ if ( (b == 0)) return a; else return GCD(b,(a % b));} public static void extendedEuclid( int A, int B){ if ( (B == 0)) {d = A; p = 1; q = 0; } else {extendedEuclid(B,(A % B)); int temp = p; p = q; q = (temp - ((A / B) * q)); }} public static int modularExponentiation( int x, int n, int M){ int result = 1; while((n > 0)){if ( ((n % 2) == 1)) result = ((result * x) % M); x = (((x % M) * x) % M); n = (n / 2); }return result;} public static long modularExponentiation( long x, long n, long M){ long result = 1; while((n > 0)){if ( ((n % 2) == 1)) result = ((((result % M) * x) % M) % M); x = ((((x % M) * x) % M) % M); n = (n / 2); }return result;} }
5	public class A{ int INF = (1 << 28); void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a = sc.nextInt();  int b = sc.nextInt();  long[] chores = new long[n]; for ( int i = 0;(i < n);i++) chores[i] = sc.nextLong(); sort(chores); System.out.println((chores[b] - chores[(b - 1)])); } public static void main( String[] args){ new A().run(); } }
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());} } }
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;} }}} }
0	public class first{ int max( int a1, int a2, int a3){ int max = a1; if ( (a2 >= max)) max = a2; if ( (a3 >= max)) max = a3; return max;} public static void main( String[] args){ int num = 0;  Scanner sc = new Scanner(System.in); num = sc.nextInt(); int num2 = (num / 10);  int num3 = (num % 10);  int num4 = (((num2 / 10) * 10) + num3);  first fs = new first();  int result = fs.max(num,num2,num4); System.out.println(result); } }
4	public class D{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); StringTokenizer stringTokenizer ; String next()throws IOException { while(((stringTokenizer == null) || !stringTokenizer.hasMoreTokens())){stringTokenizer = new StringTokenizer(reader.readLine()); }return stringTokenizer.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} final int MOD = (((1000 * 1000) * 1000) + 7); @SuppressWarnings void solve()throws IOException { final int n = nextInt();  int m = nextInt();  int[] from = new int[m];  int[] to = new int[m]; for ( int i = 0;(i < m);i++) {from[i] = nextInt(); to[i] = nextInt(); } int ans = solve(n,m,from,to); writer.println(ans); writer.close(); } private int solve(final int n, int m, int[] from, int[] to){ final List<List<Integer>> g = new ArrayList<>(); for ( int i = 0;(i <= n);i++) {g.add(new ArrayList<Integer>()); } int[] c = new int[(n + 1)];  int[] loop = new int[(n + 1)]; for ( int i = 0;(i < m);i++) { int u = from[i];  int v = to[i]; g.get(u).add(v); c[u]++; c[v]++; if ( (u == v)) {loop[u]++; } } class Utils{ int[] prev = new int[(n + 1)]; int[] used = new int[(n + 1)]; int mark ; int forbidden ; int maxMatch(){ maxMatch = 0; for ( int i = 1;(i <= n);i++) {mark = i; if ( findPath(i)) {maxMatch++; } }return maxMatch;} boolean findPath( int u){ if ( (u == forbidden)) {return false;} used[u] = mark; for ( int v :g.get(u)) {if ( (v == forbidden)) {continue;} if ( ((prev[v] == 0) || ((used[prev[v]] != mark) && findPath(prev[v])))) {prev[v] = u; return true;} }return false;} int maxMatch = 0; } int ans = Integer.MAX_VALUE; for ( int i = 1;(i <= n);i++) { Utils utils = new Utils(); utils.forbidden = i; utils.maxMatch(); ans = Math.min(ans,((((((2 * n) - 1) - c[i]) + loop[i]) + (((m - c[i]) + loop[i]) - utils.maxMatch)) + ((n - 1) - utils.maxMatch))); }return ans;} public static void main( String[] args)throws IOException { new D().solve(); } }
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; }} }
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(); } }
1	public class Solution implements Runnable{ static private BufferedReader br = null; static private PrintWriter out = null; static private 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());} }
4	public class Main{ static int n ,m ,k ; static int inf = (int)1e9; static class Pair{ int x ,y ; Pair( int a, int b){ x = a; y = b; } } static int[] dx = {1,-1,0,0},dy = {0,0,1,-1}; static boolean valid( 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();  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int x[] = new int[k];  int y[] = new int[k];  int trees[][] = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) trees[i][j] = Integer.MAX_VALUE; for ( int i = 0;(i < k);i++) {x[i] = (in.nextInt() - 1); y[i] = (in.nextInt() - 1); trees[x[i]][y[i]] = 0; } int dis = Integer.MIN_VALUE; ; int xp = 0; ; int yp = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (trees[i][j] != 0)) for ( int j2 = 0;(j2 < k);j2++) trees[i][j] = Math.min(trees[i][j],(Math.abs((i - x[j2])) + Math.abs((j - y[j2])))); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (trees[i][j] > dis)) {dis = trees[i][j]; xp = (i + 1); yp = (j + 1); } PrintWriter out = new PrintWriter("output.txt"); out.printf("%d %d\n",xp,yp); out.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner()throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt")); } 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());} } }
3	public class Main{ public static void main( String[] args)throws Exception { FastReader sc = new FastReader();  OutputStream outputStream = System.out;  PrintWriter out = new PrintWriter(outputStream);  int n = sc.nextInt();  int[] font = new int[n];  int[] cost = new int[n]; for ( int i = 0;(i < n);i++) {font[i] = sc.nextInt(); }for ( int i = 0;(i < n);i++) {cost[i] = sc.nextInt(); } int[] dou = new int[n]; for ( int i = 0;(i < n);i++) { int min = Integer.MAX_VALUE; for ( int j = 0;(j < i);j++) {if ( (font[j] < font[i])) {if ( (min > (cost[i] + cost[j]))) {min = (cost[i] + cost[j]); } } }dou[i] = min; } int ans = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int min = Integer.MAX_VALUE; for ( int j = 0;(j < i);j++) {if ( ((dou[j] != Integer.MAX_VALUE) && (font[j] < font[i]))) {if ( (min > (dou[j] + cost[i]))) {min = (dou[j] + cost[i]); } } }if ( (min < ans)) {ans = min; } }if ( (ans == Integer.MAX_VALUE)) {System.out.println(-1); } else {System.out.println(ans); }} } 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	public class Main2{ 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 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;} 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 z = new Reader();  long n = z.nextLong(),k = z.nextLong(),x ; x = (9L + (8L * (k + n))); x = (long)Math.sqrt(x); x = ((x - 3) / 2); System.out.println((n - x)); } }
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(); } }
6	public class Main{ static final boolean debug = false; static final String fileName = ""; static final boolean useFiles = false; public static void main( String[] args)throws FileNotFoundException { long start ; if ( debug) start = System.nanoTime();  InputStream inputStream ;  OutputStream outputStream ; if ( useFiles) {inputStream = new FileInputStream((fileName + ".in")); outputStream = new FileOutputStream((fileName + ".out")); } else {inputStream = System.in; outputStream = System.out; } InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(in,out); solver.solve(); if ( debug) out.println(((System.nanoTime() - start) / 1e+9)); out.close(); } } 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 double nextDouble(){ return Double.parseDouble(next());} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} } class Task{ boolean get( int mask, int i){ return ((mask & (1 << i)) > 0);} int zero( int mask, int i){ return (mask & (1 << i));} public void solve(){ int n = in.nextInt();  double[][] a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) a[i][j] = in.nextDouble(); } double[] d = new double[(1 << n)]; d[((1 << n) - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask >= 0);mask--) { int bits = Integer.bitCount(mask);  double transfer = (1.0 / ((bits * (bits - 1)) / 2)); for ( int i = 0;(i < n);i++) {if ( get(mask,i)) {for ( int j = (i + 1);(j < n);j++) {if ( get(mask,j)) {d[zero(mask,j)] += ((a[i][j] * transfer) * d[mask]); d[zero(mask,i)] += ((a[j][i] * transfer) * d[mask]); } }} }}for ( int i = 0;(i < n);i++) out.print((d[(1 << i)] + " ")); } private InputReader in ; private PrintWriter out ; Task( InputReader in, PrintWriter out){ this.in = in; this.out = out; } }
5	public class Solution{ private StringTokenizer st ; private BufferedReader in ; private PrintWriter out ; public void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);++i) {a[i] = nextInt(); } int[] b = a.clone(); Arrays.sort(b); int diff = 0; for ( int i = 0;(i < n);++i) {if ( (a[i] != b[i])) {diff++; } }out.println(((diff <= 2)?"YES":"NO")); } public void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); eat(""); solve(); out.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 { Locale.setDefault(Locale.US); new Solution().run(); } }
4	public class Main{ static int[][][] memo ; static int inf = (int)1e9; static int n ,m ,down[][] ,right[][] ; static int dp( int i, int j, int k){ if ( (k <= 0)) return 0; if ( (memo[i][j][k] != -1)) return memo[i][j][k]; int ans = inf; if ( ((i + 1) < n)) {ans = Math.min(ans,(down[i][j] + dp((i + 1),j,(k - 1)))); } if ( ((i - 1) >= 0)) {ans = Math.min(ans,(down[(i - 1)][j] + dp((i - 1),j,(k - 1)))); } if ( ((j + 1) < m)) {ans = Math.min(ans,(right[i][j] + dp(i,(j + 1),(k - 1)))); } if ( ((j - 1) >= 0)) {ans = Math.min(ans,(right[i][(j - 1)] + dp(i,(j - 1),(k - 1)))); } return memo[i][j][k] = ans;} static void main()throws Exception { n = sc.nextInt(); m = sc.nextInt(); int k = sc.nextInt(); if ( ((k & 1) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {pw.print((1 + " ")); }pw.println(); }return ;} k >>= 1; right = new int[n][]; down = new int[(n - 1)][]; for ( int i = 0;(i < n);i++) {right[i] = sc.intArr((m - 1)); }for ( int i = 0;(i < (n - 1));i++) {down[i] = sc.intArr(m); }memo = new int[n][m][(k + 1)]; int inf = (int)1e9; for ( int i = 0;(i <= k);i++) {for ( int j = 0;(j < n);j++) {for ( int o = 0;(o < m);o++) {memo[j][o][i] = -1; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {pw.print(((dp(i,j,k) << 1) + " ")); }pw.println(); }} public static void main( String[] args)throws Exception { sc = new MScanner(System.in); pw = new PrintWriter(System.out); int tc = 1; for ( int i = 1;(i <= tc);i++) {main(); }pw.flush(); } static PrintWriter pw ; static MScanner sc ; 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[] intArr( int n)throws IOException { int[] in = new int[n]; for ( int i = 0;(i < n);i++) in[i] = nextInt(); return in;} public int nextInt()throws IOException { return Integer.parseInt(next());} public long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } static void sort( int[] in){ shuffle(in); Arrays.sort(in); } static void sort( long[] in){ shuffle(in); Arrays.sort(in); } static void shuffle( int[] in){ for ( int i = 0;(i < in.length);i++) { int idx = (int)(Math.random() * in.length);  int tmp = in[i]; in[i] = in[idx]; in[idx] = tmp; }} static void shuffle( long[] in){ for ( int i = 0;(i < in.length);i++) { int idx = (int)(Math.random() * in.length);  long tmp = in[i]; in[i] = in[idx]; in[idx] = tmp; }} }
4	public class _1517_D{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  StringTokenizer line = new StringTokenizer(in.readLine());  int n = Integer.parseInt(line.nextToken());  int m = Integer.parseInt(line.nextToken());  int k = Integer.parseInt(line.nextToken());  int[][] edges1 = new int[n][(m - 1)];  int[][] edges2 = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {line = new StringTokenizer(in.readLine()); for ( int j = 0;(j < (m - 1));j++) {edges1[i][j] = Integer.parseInt(line.nextToken()); }}for ( int i = 0;(i < (n - 1));i++) {line = new StringTokenizer(in.readLine()); for ( int j = 0;(j < m);j++) {edges2[i][j] = Integer.parseInt(line.nextToken()); }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) { StringBuilder sb = new StringBuilder(); for ( int j = 0;(j < m);j++) {sb.append(-1); if ( (j < (m - 1))) sb.append(' '); }out.println(sb.toString()); }} else { int[][][] dp = new int[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {Arrays.fill(dp[i][j],Integer.MAX_VALUE); dp[i][j][0] = 0; }}for ( int a = 2;(a <= k);a += 2) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (i > 0)) {dp[i][j][a] = Math.min(dp[i][j][a],(dp[(i - 1)][j][(a - 2)] + (2 * edges2[(i - 1)][j]))); } if ( (i < (n - 1))) {dp[i][j][a] = Math.min(dp[i][j][a],(dp[(i + 1)][j][(a - 2)] + (2 * edges2[i][j]))); } if ( (j > 0)) {dp[i][j][a] = Math.min(dp[i][j][a],(dp[i][(j - 1)][(a - 2)] + (2 * edges1[i][(j - 1)]))); } if ( (j < (m - 1))) {dp[i][j][a] = Math.min(dp[i][j][a],(dp[i][(j + 1)][(a - 2)] + (2 * edges1[i][j]))); } }}}for ( int i = 0;(i < n);i++) { StringBuilder sb = new StringBuilder(); for ( int j = 0;(j < m);j++) {sb.append(dp[i][j][k]); if ( (j < (m - 1))) sb.append(' '); }out.println(sb.toString()); }}in.close(); out.close(); } }
0	public class Solution implements Runnable{ public static void main( String[] args){ new Thread(new Solution()).start(); } private void solve()throws Exception { int n = nextInt(); pw.print((n + (n / 2))); } private BufferedReader br ; private PrintWriter pw ; private StringTokenizer tok ; private String next()throws Exception { while(((tok == null) || !tok.hasMoreElements()))tok = new StringTokenizer(br.readLine()); return tok.nextToken();} private int nextInt()throws Exception { return Integer.parseInt(next());} }
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){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),r = in.nextInt();  double[] x = new double[n]; for ( int i = 0;(i < n);i++) x[i] = in.nextInt(); double[] y = new double[n]; for ( int i = 0;(i < n);i++) {y[i] = r; for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[j] - x[i])) <= (2 * r))) {y[i] = Math.max(y[i],(y[j] + Math.sqrt((((4 * r) * r) - ((x[i] - x[j]) * (x[i] - x[j])))))); } }}for ( int i = 0;(i < n);i++) System.out.print((y[i] + " ")); } }
0	public class A912{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int A = scan.nextInt();  int B = scan.nextInt();  long x = scan.nextInt();  long y = scan.nextInt();  long z = scan.nextInt();  long requiredA = ((x * 2) + y);  long requiredB = (y + (z * 3));  long neededA = Math.max(0,(requiredA - A));  long neededB = Math.max(0,(requiredB - B)); System.out.print((neededA + neededB)); } }
5	public class Main2{ private FastScanner scanner = new FastScanner(); public static void main( String[] args){ new Main2().solve(); } private void solve(){ int n = scanner.nextInt();  int a[][] = new int[n][3]; for ( int i = 0;(i < n);i++) {a[i][0] = scanner.nextInt(); a[i][1] = scanner.nextInt(); a[i][2] = i; } int l = -1,r = -1; Arrays.sort(a,(o1,o2)->{if ( (o1[0] != o2[0])) {return (o1[0] - o2[0]);} else {return (o2[1] - o1[1]);}}); int maxr = -1,maxi = -1; for ( int i = 0;(i < n);i++) {if ( (a[i][1] <= maxr)) {l = (a[i][2] + 1); r = (maxi + 1); break;} if ( (a[i][1] > maxr)) {maxi = a[i][2]; maxr = a[i][1]; } }System.out.println(((l + " ") + r)); } class FastScanner{ BufferedReader reader ; StringTokenizer tokenizer ; FastScanner(){ reader = new BufferedReader(new InputStreamReader(System.in),32768); tokenizer = null; } String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
3	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a[] = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) a[i] = sc.nextInt(); int cnt = 0; for ( int i = 1;(i <= n);i++) {for ( int j = (i - 1);(j >= 1);j--) {if ( (a[i] < a[j])) ++cnt; }} int q = sc.nextInt(); cnt = (cnt % 2); while((q-- > 0)){ int x = sc.nextInt();  int y = sc.nextInt();  int r = ((y - x) + 1);  long ok = ((r * (r - 1)) / 2); if ( ((ok % 2) == 0)) {} else {cnt ^= 1; }System.out.println(((cnt == 0)?"even":"odd")); }} }
2	public class B{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); public static void main( String[] args)throws Exception { String[] split = br.readLine().split(" ");  long n = Long.parseLong(split[0]);  long k = Long.parseLong(split[1]);  long left = -1;  long right = (n + 1); while(((right - left) >= 2)){ long mid = ((left + right) / 2);  long newN = (n - mid);  long temp = ((newN * (newN + 1)) / 2);  long eh = ((temp - k) - mid); if ( (eh == 0)) {pw.println(mid); break;} else if ( (eh < 0)) right = mid; else left = mid; }pw.close(); } }
2	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(); } static class TaskB{ FastReader in ; PrintWriter out ; int n ; public void solve( int testNumber, FastReader in, PrintWriter out){ this.in = in; this.out = out; n = in.nextInt(); if ( ((n % 4) != 0)) {out.println("! -1"); return ;} int low = 0;  int high = (n >> 1);  int fSign = Integer.signum(BValue(low)); if ( (fSign == 0)) {out.println(("! " + (low + 1))); return ;} while(((high - low) > 1)){ int mid = ((high + low) >> 1);  int mSign = Integer.signum(BValue(mid)); if ( (mSign == 0)) {out.println(("! " + (mid + 1))); return ;} if ( (mSign == -fSign)) {high = mid; } else {low = mid; }}out.println("! -1"); } public int BValue( int index){ out.println(("? " + (index + 1))); out.flush(); int f = in.nextInt(); out.println(("? " + ((index + 1) + (n >> 1)))); out.flush(); int s = in.nextInt(); return (f - s);} } 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 Main{ Scanner cin ; int[] prime ; int top ; void work(){ cin = new Scanner(System.in); int n = cin.nextInt();  int k = cin.nextInt(); top = 0; prime = new int[2000]; for ( int i = 2;(i <= n);i++) {if ( isprime(i)) prime[top++] = i; } int cnt = 0; for ( int i = 0;(i < top);i++) {if ( cando(prime[i])) cnt++; }if ( (cnt >= k)) System.out.println("YES"); else System.out.println("NO"); } boolean cando( int n){ for ( int i = 0;(i < (top - 1));i++) {if ( (((prime[i] + prime[(i + 1)]) + 1) == n)) return true; }return false;} boolean isprime( int n){ for ( int i = 2;((i * i) <= n);i++) if ( ((n % i) == 0)) return false; return true;} public static void main( String[] args)throws Exception { new Main().work(); } }
3	public class D{ int[][] fast( int n, int m){ int[][] ans = new int[2][(n * m)];  int c = 0; for ( int left = 1,right = m;(left < right);left++,right--) {for ( int l = 1,r = n;((l <= n) && (r >= 1));l++,r--) {ans[0][c] = l; ans[1][c++] = left; ans[0][c] = r; ans[1][c++] = right; }}if ( ((m % 2) == 1)) { int x = ((m / 2) + 1); for ( int l = 1,r = n;(l < r);l++,r--) {ans[0][c] = l; ans[1][c++] = x; ans[0][c] = r; ans[1][c++] = x; if ( (((n % 2) == 1) && ((l + 2) == r))) {ans[0][c] = (l + 1); ans[1][c++] = x; } }} if ( ((n == 1) && ((m % 2) == 1))) {ans[0][c] = 1; ans[1][c] = ((m / 2) + 1); } return ans;} void stress(){ for ( int i = 3;(i <= 5);i++) {for ( int j = 2;(j <= 5);j++) { int[][] ans = new int[2][]; try{ans = fast(i,j); }catch (Exception e){ out.println("ошибка"); out.print(((i + " ") + j)); return ;} boolean[][] check = new boolean[i][j]; for ( int c = 0;(c < ans[0].length);c++) { int x = (ans[0][c] - 1);  int y = (ans[1][c] - 1); check[x][y] = true; }for ( int c = 0;(c < i);c++) {for ( int q = 0;(q < j);q++) {if ( !check[c][q]) {out.println(((i + " ") + j)); out.println("точки"); for ( int w = 0;(w < ans[0].length);w++) {out.println(((ans[0][w] + " ") + ans[1][w])); }return ;} }} HashSet<String> set = new HashSet<>(); for ( int c = 1;(c < ans[0].length);c++) { int x = (ans[0][c] - ans[0][(c - 1)]);  int y = (ans[1][c] - ans[1][(c - 1)]); set.add(((x + " ") + y)); }if ( (set.size() < ((i * j) - 1))) {out.println(((i + " ") + j)); out.println("вектора"); for ( int w = 0;(w < ans[0].length);w++) {out.println(((ans[0][w] + " ") + ans[1][w])); }return ;} }}} void normal(){ int n = readInt();  int m = readInt();  int[][] ans = fast(n,m); for ( int i = 0;(i < ans[0].length);i++) {out.println(((ans[0][i] + " ") + ans[1][i])); }} boolean stress = false; void solve(){ if ( stress) stress(); else normal(); } public static void main( String[] args){ new D().run(); } void run(){ init(); solve(); out.close(); } BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init(){ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } String readLine(){ try{return in.readLine(); }catch (Exception ex){ throw (new RuntimeException(ex));} } 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());} }
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(); } }
1	public class Main{ void change( int[] all, char c, int val){ if ( Character.isUpperCase(c)) all[((c - 'A') + 26)] += val; else all[(c - 'a')] += val; } int countDistinct( int[] a){ int res = 0; for ( int i = 0;(i < a.length);i++) {if ( (a[i] > 0)) res++; }return res;} public void solve()throws IOException { int n = nextInt();  String s = next();  int[] all = new int[52]; for ( int i = 0;(i < s.length());i++) { char c = s.charAt(i); change(all,c,1); } int distinct = countDistinct(all);  int[] window = new int[52];  int best = n; for ( int i = 0,j = 0;(i < s.length());i++) {if ( (i > 0)) {change(window,s.charAt((i - 1)),-1); } while((j < s.length())){if ( (countDistinct(window) == distinct)) break; change(window,s.charAt(j),1); j++; }if ( (countDistinct(window) < distinct)) break; best = Math.min(best,(j - i)); }out.println(best); } BufferedReader bf ; StringTokenizer st ; PrintWriter out ; public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(bf.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} public Main()throws IOException{ bf = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); bf.close(); out.close(); } public static void main( String[] args)throws IOException { new Main(); } }
5	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int t = in.nextInt();  pt[] P = new pt[n]; for ( int i = 0;(i < n);++i) P[i] = new pt(in.nextInt(),in.nextInt()); Arrays.sort(P); int res = 2; for ( int i = 0;((i + 1) < n);++i) { double d = (((P[(i + 1)].x - P[i].x) - (P[(i + 1)].a / 2.)) - (P[i].a / 2.)); if ( (Math.abs((d - t)) <= 1e-11)) ++res; else if ( (d > t)) res += 2; }System.out.println(res); } } class pt implements Comparable<pt>{ int x ,a ; pt( int x, int a){ this.x = x; this.a = a; } }
5	public class AA implements Runnable{ public static void main( String[] args){ new Thread(new AA()).run(); } BufferedReader br ; StringTokenizer str = new StringTokenizer(""); PrintWriter pw ; public Integer ni(){ return Integer.parseInt(nextToken());} public String nextToken(){ while(!str.hasMoreTokens())try{str = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } return str.nextToken();} @Override public void run(){ br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new OutputStreamWriter(System.out)); solve(); pw.close(); } public void solve(){ int n = ni();  int[] a = new int[n];  int total = 0; for ( int i = 0;(i < n);i++) {a[i] = ni(); total += a[i]; }Arrays.sort(a); int c = 0;  int left = 0; for ( int i = (n - 1);(i >= 0);i--) {if ( (left <= total)) {c++; left += a[i]; total -= a[i]; } }pw.print(c); } }
0	public class Main{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  String s = (n + ""); if ( (n >= 0)) System.out.println(n); else { int a = n,b = Integer.parseInt(s.substring(0,(s.length() - 1))),c = Integer.parseInt((s.substring(0,(s.length() - 2)) + s.charAt((s.length() - 1)))); System.out.println(Math.max(a,Math.max(b,c))); }} }
6	public class Cycle{ public static void main( String[] args){ Locale.setDefault(Locale.US); InputStream inputstream = System.in;  OutputStream outputstream = System.out;  FastReader in = new FastReader(inputstream);  PrintWriter out = new PrintWriter(outputstream);  TaskA solver = new TaskA(); for ( int i = 0;(i < 1);i++) solver.solve(i,in,out); out.close(); } } class TaskA{ public void solve( int testnumber, FastReader in, PrintWriter out){ int n = in.ni();  int m = in.ni();  boolean graph[][] = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (in.ni() - 1);  int b = (in.ni() - 1); graph[a][b] = true; graph[b][a] = true; } long dp[][] = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {dp[(1 << i)][i] = 1; } long answer = 0; for ( int mask = 1;(mask < (1 << n));mask++) { int start = Integer.numberOfTrailingZeros(mask); for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) {continue;} for ( int j = (start + 1);(j < n);j++) {if ( (graph[i][j] && ((mask & (1 << j)) == 0))) {dp[(mask + (1 << j))][j] += dp[mask][i]; } }if ( graph[i][start]) {answer += dp[mask][i]; } }}out.println(((answer - m) / 2)); } } 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 String ns(){ 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 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); } }
2	public class Quiz{ public static int mod = 1000000009; public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(f.readLine());  long n = Long.parseLong(st.nextToken());  long m = Long.parseLong(st.nextToken());  long k = Long.parseLong(st.nextToken());  long d = (n - m); n -= (d * k); if ( (n <= 0)) {System.out.println(m); return ;} long sum = ((n % k) + (d * (k - 1))); sum += ((2 * k) * (pow(2,(n / k)) - 1)); sum %= mod; System.out.println(sum); } public static long pow( long a, long n){ if ( (n == 0)) return 1; long pow = pow(a,(n / 2)); pow = ((pow * pow) % mod); if ( ((n % 2) == 1)) pow = ((pow * a) % mod); return pow;} }
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>{ } static private final int INF = (int)3e8; static private final long INFL = (long)1e17; static private final int INTMAX = Integer.MAX_VALUE; static private final long LONGMAX = Long.MAX_VALUE; static private final long e97 = 1000000007L; static private final long e99 = 998244353L; static private final double PI = Math.PI; static private int abs( int a){ return ((a >= 0)?a:-a);} static private long abs( long a){ return ((a >= 0L)?a:-a);} static private double abs( double a){ return ((a >= 0.0)?a:-a);} static private int min( int a, int b){ return ((a < b)?a:b);} static private long min( long a, long b){ return ((a < b)?a:b);} static private double min( double a, double b){ return ((a < b)?a:b);} static private int pow2( int num2pow){ if ( (num2pow > 4e4)) throw (new IllegalArgumentException("Input is to Large. Use Long.")); return (num2pow * num2pow);} static private long pow2( long num2pow){ if ( (num2pow > 1e8)) throw (new IllegalArgumentException("Input is to Large. Use PowP.")); return (num2pow * num2pow);} static private int getDigit2( long num2know){ long compare4 = 1L;  int digit = 0; while((num2know >= compare4)){digit++; compare4 = (1L << (long)digit); }return digit;} static private 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;} static private boolean isFlaged( int bit, int pos){ if ( (pos >= 32)) throw (new IllegalArgumentException("Input is to Large.")); return ((bit & (1 << pos)) != 0);} static private boolean isFlaged( long bit, int pos){ if ( (pos >= 64)) throw (new IllegalArgumentException("Input is to Large.")); return ((bit & (1L << (long)pos)) != 0L);} static private int[] Xdir4 = {1,0,0,-1}; static private int[] Ydir4 = {0,1,-1,0}; static private int[] Xdir8 = {1,1,1,0,0,-1,-1,-1}; static private int[] Ydir8 = {1,0,-1,1,-1,1,0,-1}; static private void fill( boolean[] target, boolean reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } static private void fill( int[] target, int reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } static private void fill( long[] target, long reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } static private void fill( char[] target, char reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } static private void fill( double[] target, double reset){ for ( int i = 0;(i < target.length);i++) target[i] = reset; } static private 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; }}} static private 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; }}} static private 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; }}} static private 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; }}} static private 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; }}} static private 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; }}}} static private 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"); } static private 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(); } static private 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(); } static private 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(); } static private 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;} static private 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());} } }
2	public class A{ public static void main( String[] args)throws Exception { int n = nextInt();  int m = nextInt();  int k = nextInt();  int wa = (n - m); if ( ((n / k) <= wa)) {System.out.println(m); } else { int notFull = wa;  int full = ((n / k) - wa);  long res = 1;  int power = (full + 1);  int mod = 1000000009;  long powTwo = 2; while((power > 0)){if ( ((power & 1) == 1)) {res = ((res * powTwo) % mod); } power >>= 1; powTwo = ((powTwo * powTwo) % mod); }res = (((((res - 2) + mod) % mod) * k) % mod); res = ((((res + (notFull * (k - 1))) % mod) + (n % k)) % mod); System.out.println(res); }} static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer tokenizer = new StringTokenizer(""); static int nextInt()throws Exception { return Integer.parseInt(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); }} }
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);} }
2	public class ReallyBigNumbers1{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  PrintWriter out = new PrintWriter(System.out);  long n = Long.parseLong(st.nextToken());  long s = Long.parseLong(st.nextToken());  int r = 0;  long l = 0L;  long u = n; if ( (((l - sumDigits(l)) < s) && ((u - sumDigits(u)) < s))) {out.println(0); out.flush(); out.close(); return ;} long specified = 0L; while(true){ long m = ((l + u) / 2L); if ( (((m - sumDigits(m)) >= s) && (((m - 1) - sumDigits((m - 1))) < s))) {specified = m; break;} if ( (l > u)) break; else {if ( ((m - sumDigits(m)) >= s)) u = (m - 1); else l = (m + 1); }}out.println(((n - specified) + 1)); out.flush(); out.close(); } public static int sumDigits( long n){ char[] a = (n + "");  int sum = 0; for ( int k = 0;(k < a.length);k++) {sum += Integer.parseInt((a[k] + "")); }return sum;} }
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;} }
0	public class D implements Runnable{ public static void main( String[] args){ new Thread(new D()).start(); } BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return "0";} }return st.nextToken();} double nextDouble(){ return Double.parseDouble(nextToken());} static final double EPS = 1e-9; static double qEq( double a, double b, double c){ double d = ((b * b) - ((4 * a) * c)); if ( (d < -EPS)) {return Double.NaN;} return Math.max(((-b + Math.sqrt(d)) / (2 * a)),((-b - Math.sqrt(d)) / (2 * a)));} static int compare( double a, double b){ return ((Math.abs((a - b)) < EPS)?0:Double.compare(a,b));} void solve(){ double a = nextDouble();  double v = nextDouble();  double l = nextDouble();  double d = nextDouble();  double w = nextDouble(); if ( (compare(w,v) >= 0)) { double t1 = (v / a);  double d1 = (((a * t1) * t1) * .5); if ( (compare(d1,l) >= 0)) {out.println(Math.sqrt(((2 * l) / a))); } else {out.println((t1 + ((l - d1) / v))); }return ;} double t1 = (w / a);  double d1 = (((a * t1) * t1) * .5); if ( (compare(d1,d) >= 0)) { double t2 = (v / a);  double d2 = (((a * t2) * t2) * .5); if ( (compare(d2,l) >= 0)) {out.println(Math.sqrt(((2 * l) / a))); } else {out.println((t2 + ((l - d2) / v))); }return ;} double left = (d - d1);  double timeToV = ((v - w) / a);  double distToV = ((((a * timeToV) * timeToV) * .5) + (w * timeToV)); if ( (compare(distToV,(left * .5)) >= 0)) { double t2 = qEq((a * .5),w,(-left * .5)); t2 += (t1 + t2); if ( (compare(distToV,(l - d)) >= 0)) {out.println((t2 + qEq((a * .5),w,(d - l)))); } else {out.println(((t2 + timeToV) + (((l - d) - distToV) / v))); }return ;} double t2 = ((t1 + (2 * timeToV)) + ((left - (2 * distToV)) / v)); if ( (compare(distToV,(l - d)) >= 0)) {out.println((t2 + qEq((a * .5),w,(d - l)))); } else {out.println(((t2 + timeToV) + (((l - d) - distToV) / v))); }} }
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(); } }
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);} } }
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(); } }
0	public class Main{ private BufferedReader in ; private BufferedWriter out ; double time( double a, double l, double v0, double v){ double t = ((v - v0) / a);  double s = ((((a * t) * t) / 2) + (v0 * t)); if ( (s <= l)) {return (t + ((l - s) / v));} double B = v0,C = -l;  double D = Math.sqrt(((B * B) - ((2 * a) * C))); return ((-B + D) / a);} public void solve()throws Exception { StreamTokenizer st = new StreamTokenizer(in); st.nextToken(); double a = st.nval; st.nextToken(); double v = st.nval; st.nextToken(); double l = st.nval; st.nextToken(); double d = st.nval; st.nextToken(); double w = st.nval;  double ttt = Math.sqrt(((2 * d) / a));  double ans = 0.0; if ( ((w > v) || ((ttt * a) < w))) {ans = time(a,l,0,v); } else { double B = ((2 * w) / a),C = (((-w * w) / (a * a)) - ((4 * d) / a));  double D = Math.sqrt(((B * B) - (4 * C))); ans = ((-B + D) / 2); if ( ((((a * ans) + w) / 2.0) > v)) { double t1 = (v / a);  double t2 = ((v - w) / a);  double s = ((((a * t1) * t1) / 2.0) + ((v * t2) - (((a * t2) * t2) / 2.0))); ans = ((t1 + t2) + ((d - s) / v)); } ans += time(a,(l - d),w,v); } DecimalFormat df = new DecimalFormat("0.000000000"); out.write((df.format(ans) + "\n")); } public void run(){ try{in = 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){ try{Locale.setDefault(Locale.US); }catch (Exception e){ } new Main().run(); } }
2	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);  D solver = new D(); solver.solve(1,in,out); out.close(); } static class D{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int T = in.ni(); for ( int t = 0;(t < T);t++) { long n = in.nl(),k = in.nl(); if ( ((n == 2) && (k == 3))) {out.println("NO"); continue;} boolean possible = false;  long size = n;  long rem = k; for ( int i = 0;(((i <= 31) && (size > 0)) && (rem > 0));i++) { long splits = (1L << (i * 2)); rem -= splits; size--; }if ( (rem > 0)) {out.println("NO"); continue;} long path = 1;  long i = 0; size = n; long ans = 0; while(((path <= k) && (size > 0))){k -= path; path = ((1L << (i + 2)) - 1); size--; i++; }out.println(("YES " + size)); }} } static class FastScanner{ private BufferedReader in ; private StringTokenizer st ; public FastScanner( InputStream stream){ in = new BufferedReader(new InputStreamReader(stream)); } public String ns(){ while(((st == null) || !st.hasMoreTokens())){try{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int ni(){ return Integer.parseInt(ns());} public long nl(){ return Long.parseLong(ns());} } }
5	public class CottageVillage{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int size = sc.nextInt();  int side = sc.nextInt();  ArrayList<Pair> lis = new ArrayList<Pair>(); for ( int x = 0;(x < size);x++) {lis.add(new Pair(sc.nextInt(),sc.nextInt())); }Collections.sort(lis); int count = 2; for ( int x = 0;(x < (lis.size() - 1));x++) { Pair a = lis.get(x);  Pair b = lis.get((x + 1));  double na = (a.x + (a.len / 2));  double nb = (b.x - (b.len / 2)); if ( (na < nb)) { double dif = Math.abs((nb - na)); if ( (dif == side)) count++; else if ( (dif > side)) count += 2; } }System.out.println(count); } } class Pair implements Comparable<Pair>{ int x ; double len ; public Pair( int a, int b){ x = a; len = b; } }
4	public class Main{ public static void main( String[] args)throws FileNotFoundException { Scanner sc = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  ArrayList<ArrayList<Integer>> fire = new ArrayList<ArrayList<Integer>>(); while((k-- != 0)){ ArrayList<Integer> t = new ArrayList<Integer>(); t.add(sc.nextInt()); t.add(sc.nextInt()); fire.add(t); } int maxI = 0,maxJ = 0,maxManhatten = -1; for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= m);j++) { int curManhatten = Integer.MAX_VALUE; for ( int u = 0;(u < fire.size());u++) curManhatten = Math.min(curManhatten,manhatten(i,j,fire.get(u).get(0),fire.get(u).get(1))); if ( (curManhatten > maxManhatten)) {maxManhatten = curManhatten; maxI = i; maxJ = j; } }out.print(((maxI + " ") + maxJ)); out.flush(); out.close(); } static private int manhatten( int i, int j, Integer a, Integer b){ return (Math.abs((i - a)) + Math.abs((j - b)));} }
0	public class A{ public static void main( String[] args)throws IOException { final Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); if ( ((n % 2) == 0)) {System.out.println(((4 + " ") + (n - 4))); } else {System.out.println(((9 + " ") + (n - 9))); }} }
1	public class AB{ private InputStream input ; private PrintStream output ; private Scanner inputSc ; public AB( InputStream input, PrintStream output){ this.input = input; this.output = output; init(); } private void init(){ inputSc = new Scanner(input); } static int lineToInt( String line){ return Integer.parseInt(line);} public void solve(){ solveTestCase(); } HashMap<Integer,Integer> mat ; long dist[] ; int vec[] ; int ar[] ; Set<Integer> st ; boolean isDone[] ; final long INF = 100000000000000000L; @SuppressWarnings private void solveTestCase(){ int i ,j ,k ,n ,m ,d ,l ,b ,p ,q ,r ;  long N ,M ,K ;  int x1 ,y1 ,x2 ,y2 ,x ;  int a1 ,a2 ,b1 ,b2 ,a ;  DecimalFormat df = new DecimalFormat("#,###,##0.00");  String str = inputSc.nextLine();  String delims = "[ ]+";  String tokens[] = str.split(delims); n = lineToInt(tokens[0]); a = lineToInt(tokens[1]); b = lineToInt(tokens[2]); mat = new HashMap<Integer,Integer>(); st = new TreeSet<Integer>(); ar = new int[(n + 4)]; vec = new int[(n + 4)]; str = inputSc.nextLine(); tokens = str.split(delims); for ( i = 1;(i <= n);i++) {ar[i] = lineToInt(tokens[(i - 1)]); mat.put(ar[i],i); st.add(ar[i]); vec[i] = i; }vec[(n + 1)] = (n + 1); vec[(n + 2)] = (n + 2); for ( i = 1;(i <= n);i++) {x = ar[i]; if ( st.contains((a - x))) {Bing(mat.get(x),mat.get((a - x))); } else Bing((n + 1),mat.get(x)); if ( st.contains((b - x))) {Bing(mat.get(x),mat.get((b - x))); } else Bing((n + 2),mat.get(x)); }if ( (find((n + 1)) == find((n + 2)))) {output.println("NO"); return ;} output.println("YES"); for ( i = 1;(i <= n);i++) {if ( (find(i) == find((n + 1)))) output.print("1 "); else output.print("0 "); }output.println(); } int find( int x){ if ( (x == vec[x])) return x; return vec[x] = find(vec[x]);} void Bing( int a, int b){ int A = find(a);  int B = find(b); if ( (A == B)) return ; vec[B] = A; } public static void main( String[] args){ FileInputStream in = null;  FileOutputStream out = null;  PrintStream ps = null;  InputStream is = null; try{is = new FileInputStream("file.in"); out = new FileOutputStream("file.out"); ps = new PrintStream(out); }catch (Exception e){ } AB sd = new AB(System.in,System.out); sd.solve(); try{if ( (is != null)) {is.close(); } if ( (out != null)) {out.close(); } if ( (ps != null)) {ps.close(); } }catch (Exception e){ } } }
5	public class Main{ public Main(){ super(); } public static void main( String... args){ Main main = new Main(); main.start(); } public void start(){ Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int n = in.nextInt();  int t = in.nextInt();  House list[] = new House[n]; for ( int i = 0;(i < n);i++) { int x = in.nextInt();  int a = in.nextInt(); list[i] = new House(x,a); }Arrays.sort(list); int c = 2; for ( int i = 1;(i < n);i++) { float d = (list[i].left - list[(i - 1)].right); if ( (d == t)) c++; else if ( (d > t)) c += 2; }System.out.println(c); } } class House implements Comparable<House>{ public int x ; public float left ,right ; public House( int x, int a){ this.x = x; float h = (a / 2f); this.left = (x - h); this.right = (x + h); } }
5	public class Solution{ static class Data{ int x ,i ; Data( int x, int i){ this.x = x; this.i = i; } } public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] s = br.readLine().split("\\s");  int N = Integer.parseInt(s[0]);  int K = Integer.parseInt(s[1]); s = br.readLine().split("\\s"); int[] arr = new int[N]; for ( int i = 0;(i < N);++i) arr[i] = Integer.parseInt(s[i]); solve(N,K,arr); } static private void solve( int N, int K, int[] arr){ PriorityQueue<Data> pq = new PriorityQueue<Data>(2000,(a,b)->(((a.x - b.x) == 0)?(b.i - a.i):(b.x - a.x))); for ( int i = 0;(i < arr.length);++i) {pq.offer(new Data(arr[i],i)); } int tot_sum = 0;  List<Integer> ls = new ArrayList<>();  Set<Integer> set = new HashSet<>(); for ( int i = 1;(i <= K);++i) { Data t = pq.poll(); tot_sum += t.x; set.add(t.i); } int last = -1; for ( int i = 0;(i < arr.length);++i) {if ( set.contains(i)) {K--; if ( (K == 0)) ls.add(((arr.length - last) - 1)); else ls.add((i - last)); last = i; } }System.out.println(tot_sum); int size = ls.size(); for ( int i = 0;(i < size);++i) {System.out.print((ls.get(i) + " ")); }} }
6	public class C0008{ public static void main( String[] args)throws Exception { new C0008(); } int n ; int target ; int pow[] ; int dp[] ; int next[] ; int dist[][] ; C0008()throws Exception{ PandaScanner sc = null;  PrintWriter out = null; try{sc = new PandaScanner(System.in); out = new PrintWriter(System.out); }catch (Exception ignored){ } pow = new int[26]; for ( int i = 0;(i < 26);i++) {pow[i] = (1 << i); }dist = new int[26][26]; int[][] p = new int[26][]; p[25] = new int[]{sc.nextInt(),sc.nextInt()}; n = sc.nextInt(); target = ((1 << n) - 1); for ( int i = 0;(i < n);i++) {p[i] = new int[]{sc.nextInt(),sc.nextInt()}; dist[i][25] = getDist(p[i],p[25]); for ( int j = 0;(j < i);j++) {dist[j][i] = getDist(p[j],p[i]); }}next = new int[(1 << n)]; dp = new int[(1 << n)]; Arrays.fill(dp,-1); out.println(go(0)); ArrayList<Integer> paths = new ArrayList<Integer>(); paths.add(0); int curr = 0; while((curr != target)){for ( Integer i :getBits(next[curr],true)) {paths.add((i + 1)); }paths.add(0); curr |= next[curr]; }out.println(paths.toString().replaceAll("[^ 0-9]","")); out.close(); System.exit(0); } int go( int mask){ if ( (mask == target)) {return 0;} if ( (dp[mask] != -1)) {return dp[mask];} ArrayList<Integer> notDone = getBits(mask,false); dp[mask] = Integer.MAX_VALUE; for ( Integer i :notDone) { int oneD = ((dist[i][25] << 1) + go((mask | pow[i]))); if ( (dp[mask] > oneD)) {dp[mask] = oneD; next[mask] = (1 << i); } for ( Integer j :notDone) {if ( (j == i)) continue; int d = (((dist[j][25] + dist[i][j]) + dist[i][25]) + go(((mask | pow[i]) | pow[j]))); if ( (dp[mask] > d)) {dp[mask] = d; next[mask] = ((1 << i) | (1 << j)); } }break;}return dp[mask];} int getDist( int[] p1, int[] p2){ return (sq((p1[0] - p2[0])) + sq((p1[1] - p2[1])));} int sq( int a){ return (a * a);} ArrayList<Integer> getBits( int mask, boolean on){ ArrayList<Integer> res = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) == 0) ^ on)) {res.add(i); } }return res;} public class PandaScanner{ BufferedReader br ; StringTokenizer st ; InputStream in ; PandaScanner( InputStream in)throws Exception{ br = new BufferedReader(new InputStreamReader(this.in = in)); } public String next()throws Exception { if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(br.readLine().trim()); return next();} return st.nextToken();} public int nextInt()throws Exception { return Integer.parseInt(next());} } }
0	public class EER_A{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in); scanner.nextLine(); System.out.println(25); } }
2	public class C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long s = sc.nextLong();  BigInteger k = findFirst(BigInteger.valueOf(s)); if ( (BigInteger.valueOf(n).compareTo(k) >= 0)) {System.out.println(((n - k.longValue()) + 1)); } else {System.out.println("0"); }} public static BigInteger findFirst( BigInteger s){ BigInteger b = BigInteger.ZERO; while((cd(b).compareTo(b.subtract(s)) > 0)){ BigInteger c = BigInteger.ONE; while((cd(b.add(c)).compareTo(b.add(c).subtract(s)) > 0)){c = c.multiply(BigInteger.TEN); }c = c.divide(BigInteger.TEN); if ( (c.compareTo(BigInteger.TEN) < 0)) c = BigInteger.TEN; b = b.add(c); }return b;} public static BigInteger cd( BigInteger n){ BigInteger t = BigInteger.ZERO; while((n.compareTo(BigInteger.ZERO) > 0)){t = t.add(n.mod(BigInteger.TEN)); n = n.divide(BigInteger.TEN); }return t;} }
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());} }
4	public class D{ static long[][][] dp ; static int[][] hor ,ver ; static int n ,m ; static int[][] dir = {{0,1},{1,0},{0,-1},{-1,0}}; public static boolean isValid( int row, int col){ return ((((row >= 0) && (col >= 0)) && (row < n)) && (col < m));} public static void minCost( int row, int col, int k){ if ( (k == 0)) return ; if ( (k == 2)) { long min = Long.MAX_VALUE; for ( int i = 0;(i < 4);i++) {if ( isValid((row + dir[i][0]),(col + dir[i][1]))) {if ( ((row + dir[i][0]) == row)) {if ( ((col + dir[i][1]) > col)) {min = Math.min(min,hor[row][col]); } else {min = Math.min(min,hor[row][(col - 1)]); }} else {if ( ((row + dir[i][0]) > row)) {min = Math.min(min,ver[row][col]); } else {min = Math.min(min,ver[(row - 1)][col]); }}} }dp[row][col][k] = (2 * min); return ;} if ( (dp[row][col][k] != Long.MAX_VALUE)) return ; long min = Long.MAX_VALUE; for ( int i = 0;(i < 4);i++) {if ( isValid((row + dir[i][0]),(col + dir[i][1]))) {if ( (k >= 4)) {minCost((row + dir[i][0]),(col + dir[i][1]),(k - 2)); int edge = 0; if ( ((row + dir[i][0]) == row)) {if ( ((col + dir[i][1]) > col)) {edge = hor[row][col]; } else {edge = hor[row][(col - 1)]; }} else {if ( ((row + dir[i][0]) > row)) {edge = ver[row][col]; } else {edge = ver[(row - 1)][col]; }}min = Math.min(min,((2 * edge) + dp[(row + dir[i][0])][(col + dir[i][1])][(k - 2)])); } } }dp[row][col][k] = min; } public static void main( String[] args){ Scanner input = new Scanner(System.in); n = input.nextInt(); m = input.nextInt(); int k = input.nextInt(); hor = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {hor[i][j] = input.nextInt(); }}ver = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ver[i][j] = input.nextInt(); }}if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print((-1 + " ")); }System.out.println(""); }} else {dp = new long[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) for ( int x = 0;(x <= k);x++) {dp[i][j][x] = Long.MAX_VALUE; }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {minCost(i,j,k); System.out.print((dp[i][j][k] + " ")); }System.out.println(""); }}input.close(); } }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); if ( ((n % 2) == 1)) {System.out.println(((9 + " ") + (n - 9))); } else {System.out.println(((4 + " ") + (n - 4))); }} }
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 ; }
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 G{ 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.flush(); out.close(); } static class TaskE{ class MinCostMaxFlow{ ArrayList<Edge> al[] ; Edge ja[][] ; int d[] ; int N ,S ,T ,maxFlow ; int minCost ; final int gmax = (Integer.MAX_VALUE / 100); int edges = 0; class Edge{ int u ,flow ,rid ,cost ; Edge( int a, int b, int c, int d){ u = a; flow = b; cost = c; rid = d; } } void addEdge( int u, int v, int flow, int cost){ int lu = al[u].size(),lv = al[v].size(); al[u].add(new Edge(v,flow,cost,lv)); al[v].add(new Edge(u,0,-cost,lu)); } void convertToArray(){ ja = new Edge[N][]; for ( int i = 0;(i < N);i++) { int sz = al[i].size(); ja[i] = new Edge[sz]; for ( int j = 0;(j < sz);j++) {ja[i][j] = al[i].get(j); }al[i].clear(); }} MinCostMaxFlow( int n, int source, int sink){ N = n; S = source; T = sink; maxFlow = 0; minCost = 0; al = new ArrayList[N]; d = new int[N]; for ( int i = 0;(i < N);i++) {al[i] = new ArrayList<>(); }} int node[] ; int visit[] ; int prv[] ,prve[] ; int dist[] ; boolean simple(){ node = new int[N]; visit = new int[N]; prv = new int[N]; prve = new int[N]; dist = new int[N]; Arrays.fill(dist,gmax); node[0] = S; dist[0] = 0; int front = 1,back = 0; while((front != back)){ int u = node[back++];  int distu = dist[u]; if ( (back == N)) back = 0; visit[u] = 2; for ( int i = 0;(i < ja[u].length);i++) { Edge e = ja[u][i]; if ( (e.flow == 0)) continue; int cdist = (distu + e.cost); if ( (cdist < dist[e.u])) {if ( (visit[e.u] == 0)) {node[front] = e.u; if ( (++front == N)) front = 0; } else if ( (visit[e.u] == 2)) {if ( (--back == -1)) back += N; node[back] = e.u; } visit[e.u] = 1; prve[e.u] = i; prv[e.u] = u; dist[e.u] = cdist; } }}return (visit[T] != 0);} class pair{ int F ; int S ; pair( int a, int b){ F = a; S = b; } } boolean dijkstra(){ visit = new int[N]; prv = new int[N]; prve = new int[N]; dist = new int[N]; Arrays.fill(dist,gmax); PriorityQueue<pair> pq = new PriorityQueue<>((A,B)->Double.compare(A.S,B.S)); pq.add(new pair(S,0)); dist[0] = 0; o:while(!pq.isEmpty()){ pair p = pq.poll(); while((dist[p.F] < p.S)){if ( pq.isEmpty()) break; p = pq.poll(); }visit[p.F] = 2; for ( int i = 0;(i < ja[p.F].length);i++) { Edge e = ja[p.F][i]; if ( (e.flow == 0)) continue; int cdist = (p.S + ((e.cost + d[p.F]) - d[e.u])); if ( (cdist < dist[e.u])) {if ( (visit[e.u] == 2)) return false; pq.add(new pair(e.u,cdist)); dist[e.u] = cdist; prv[e.u] = p.F; prve[e.u] = i; visit[e.u] = 1; } }}return (visit[T] != 0);} int augment(){ int p = T;  int min = gmax; while((p != 0)){ int pp = prv[p],pe = prve[p];  int val = ja[pp][pe].flow; min = Math.min(min,val); p = pp; }p = T; while((p != 0)){ int pp = prv[p],pe = prve[p]; ja[pp][pe].flow -= min; ja[p][ja[pp][pe].rid].flow += min; p = pp; }maxFlow += min; return min;} boolean calSimple(){ while(simple()){minCost += (dist[T] * augment()); }return true;} void updPotential(){ for ( int i = 0;(i < N);i++) {if ( (visit[i] != 0)) {d[i] += (dist[i] - dist[S]); } }} } int n ,m ,k ,c ,d ,a[] ,f[] ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); k = in.nextInt(); c = in.nextInt(); d = in.nextInt(); int maxl = (n + k),T = ((n * maxl) + 1);  MinCostMaxFlow ans = new MinCostMaxFlow((T + 1),0,T); a = new int[(k + 1)]; f = new int[(n + 1)]; for ( int i = 1;(i <= k);i++) {a[i] = in.nextInt(); f[a[i]]++; }for ( int i = 1;(i <= n);i++) {if ( (f[i] == 0)) continue; ans.addEdge(0,i,f[i],0); }for ( int i = 2;(i <= n);i++) {for ( int l = 0;(l < (maxl - 1));l++) {ans.addEdge(((l * n) + i),(((l + 1) * n) + i),k,c); }}for ( int i = 1;(i <= m);i++) { int a = in.nextInt(),b = in.nextInt(); for ( int l = 0;(l < (maxl - 1));l++) {for ( int p = 1;(p <= k);p++) {if ( (a != 1)) ans.addEdge(((n * l) + a),((n * (l + 1)) + b),1,((d * ((2 * p) - 1)) + c)); if ( (b != 1)) ans.addEdge(((n * l) + b),((n * (l + 1)) + a),1,((d * ((2 * p) - 1)) + c)); }}}for ( int l = 1;(l < maxl);l++) {ans.addEdge(((l * n) + 1),T,k,0); }ans.convertToArray(); ans.calSimple(); if ( (ans.maxFlow != k)) {out.println("BUG"); } else {out.println((int)ans.minCost); }} } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); st = null; } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} public int nextInt(){ return Integer.parseInt(next());} } }
2	public class CF338A extends PrintWriter{ CF338A(){ super(System.out,true); } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF338A o = new CF338A(); o.main(); o.flush(); } static final int MD = 1000000009; 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;} void main(){ int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int z = (n - m); if ( (z >= (((n + k) - 1) / k))) {println(m); return ;} int d = ((n - (z * k)) / k); println(((((((power(2,(d + 1)) - 2) + MD) * k) + m) - (d * k)) % MD)); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  boolean[][] map = new boolean[n][n];  int m = in.nextInt();  int[] us = new int[m];  int[] vs = new int[m]; for ( int i = 0;(i < m);++i) { int u = (in.nextInt() - 1);  int v = (in.nextInt() - 1); map[u][v] = true; us[i] = u; vs[i] = v; } int ans = Integer.MAX_VALUE; for ( int center = 0;(center < n);++center) { int fixed = 0; for ( int i = 0;(i < n);++i) {if ( !map[center][i]) {++fixed; } if ( (!map[i][center] && (i != center))) {++fixed; } } MaxFlow flow = new MaxFlow(((n * 2) + 2),(n * 2),((n * 2) + 1)); for ( int i = 0;(i < n);++i) {if ( (i == center)) continue; flow.insert((n * 2),i,1); flow.insert((i + n),((n * 2) + 1),1); }for ( int i = 0;(i < m);++i) {if ( ((us[i] == center) || (vs[i] == center))) {continue;} flow.insert(us[i],(vs[i] + n),1); ++fixed; }ans = Math.min(ans,((fixed + (n - 1)) - (2 * flow.maxFlow()))); }out.println(ans); } } class InputReader{ BufferedReader reader ; 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 (Exception e){ throw (new UnknownError());} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } class MaxFlow{ public class Edge{ public int u ,v ,c ; public Edge next ,r ; public Edge( int u, int v, int c){ this.u = u; this.v = v; this.c = c; next = r = null; } } public Edge vertex[] ; public int height[] ,nheight[] ; public int s ,t ,n ; public void init( int n, int s, int t){ height = new int[(n + 1)]; nheight = new int[(n + 1)]; vertex = new Edge[(n + 1)]; this.s = s; this.t = t; this.n = n; } public MaxFlow( int n, int s, int t){ init(n,s,t); } public void insert( int u, int v, int c){ Edge e = new Edge(u,v,c);  Edge r = new Edge(v,u,0); e.r = r; r.r = e; e.next = vertex[u]; vertex[u] = e; r.next = vertex[v]; vertex[v] = r; } public int augPath( int u, int push){ if ( (u == t)) return push; int flow = push,minheight = (n - 1); for ( Edge e = vertex[u];(e != null);e = e.next) if ( (e.c != 0)) {if ( ((height[e.v] + 1) == height[e.u])) { int delta = ((flow < e.c)?flow:e.c); if ( (delta > 0)) delta = augPath(e.v,delta); e.c -= delta; e.r.c += delta; flow -= delta; if ( ((0 == flow) || (height[s] >= n))) return (push - flow); } minheight = Math.min(minheight,height[e.v]); } if ( (push == flow)) {--nheight[height[u]]; if ( (0 == nheight[height[u]])) height[s] = n; height[u] = ++minheight; ++nheight[height[u]]; } return (push - flow);} public int maxFlow(){ Arrays.fill(height,0); Arrays.fill(nheight,0); nheight[0] = n; int flow = 0; while((height[s] < n))flow += augPath(s,Integer.MAX_VALUE); return flow;} }
3	public class D{ public static void main( String[] args){ FastScanner scan = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int n = scan.nextInt();  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) a[i] = scan.nextInt(); BIT bit = new BIT(n);  int p = 0; for ( int i = 1;(i <= n);i++) {p ^= (bit.atOrAbove(a[i]) & 1); bit.add(a[i],1); } int m = scan.nextInt(); for ( int i = 0;(i < m);i++) { int l = scan.nextInt(),r = scan.nextInt();  int s = ((r - l) + 1);  int in = ((s * (s - 1)) / 2); if ( ((in & 1) == 1)) p ^= 1; out.println(((p == 0)?"even":"odd")); }out.close(); } static class BIT{ int[] a ; int n ; public BIT( int n){ this.n = n; a = new int[(n + 1)]; } public void add( int i, int val){ while((i <= n)){a[i] += val; i += (i & -i); }} public int sum( int j){ int res = 0; for ( int i = j;(i >= 1);i -= (i & -i)) res += a[i]; return res;} public int sum( int i, int j){ return (sum(j) - sum((i - 1)));} public int atOrAbove( int index){ int sub = 0; if ( (index > 0)) sub = sum((index - 1)); return (sum(n) - sub);} } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ try{br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } public String next(){ if ( st.hasMoreTokens()) return st.nextToken(); try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public double nextDouble(){ return Double.parseDouble(next());} } }
3	public class Codeforces{ static int n ; static double max ; static int[] pre ; public static void findIntensity( int l){ for ( int i = 0,j = (i + l);(j < (n + 1));i++,j++) { double res = ((pre[j] - pre[i]) / (double)l); max = Math.max(max,res); }} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine()); n = Integer.parseInt(st.nextToken()); int k = Integer.parseInt(st.nextToken());  int[] heat = new int[n]; st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {heat[i] = Integer.parseInt(st.nextToken()); }max = 0; pre = new int[(n + 1)]; pre[0] = 0; for ( int i = 0;(i < n);i++) {pre[(i + 1)] = (pre[i] + heat[i]); }for ( int i = k;(i <= n);i++) {findIntensity(i); }System.out.println(max); } }
1	public class Solution{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine());  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(st.nextToken()); int ind = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] == n)) {ind = i; break;} } boolean ok = true; for ( int i = (ind + 1);(i < n);i++) if ( (a[i] > a[(i - 1)])) ok = false; for ( int i = (ind - 1);(i >= 0);i--) if ( (a[i] > a[(i + 1)])) ok = false; if ( ok) System.out.println("YES"); else System.out.println("NO"); } }
1	public class C{ MyScanner in ; PrintWriter out ; public static void main( String[] args)throws Exception { new C().run(); } public void run()throws Exception { in = new MyScanner(); out = new PrintWriter(System.out); solve(); out.close(); } public void solve()throws Exception { int n = in.nextInt();  char[] a = in.next().toCharArray();  int h = 0; for ( int i = 0;(i < a.length);i++) {if ( (a[i] == 'H')) h++; } char[] b = new char[((2 * a.length) - 1)]; for ( int i = 0;(i < b.length);i++) {b[i] = a[(i % a.length)]; } int maxh = 0;  int hh = 0; for ( int i = 0;(i < (b.length - h));i++) {hh = 0; for ( int j = 0;(j < h);j++) {if ( (b[(i + j)] == 'H')) hh++; }maxh = Math.max(maxh,hh); }out.println((h - maxh)); } class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner()throws Exception{ br = new BufferedReader(new InputStreamReader(System.in)); } String next()throws Exception { if ( ((st == null) || st.hasMoreTokens())) {st = new StringTokenizer(br.readLine()); } return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(next());} } }
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;} }
0	public class Main{ public static void main( String[] args)throws IOException,InterruptedException { PrintWriter pw = new PrintWriter(System.out);  Scanner sc = new Scanner(System.in);  HashSet<String> hs = new HashSet<String>();  int[] Arr = new int[14];  long max = 0; for ( int i = 0;(i < 14);i++) {Arr[i] = sc.nextInt(); }for ( int i = 0;(i < 14);i++) { int[] arr = Arr.clone();  long sum = 0;  int r = arr[i]; arr[i] = 0; for ( int j = (i + 1);((j < arr.length) && (r > 0));j++) {arr[j]++; r--; }for ( int j = 0;(j < arr.length);j++) {arr[j] += (r / 14); if ( ((j + 1) <= (r % 14))) {arr[j]++; } if ( ((arr[j] % 2) == 0)) {sum += arr[j]; } }max = Math.max(max,sum); }System.out.println(max); } 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 A{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long K = Long.valueOf(br.readLine());  long n = 0;  long k = 0;  long len = 0; while(true){len++; long preK = k;  long preN = n; k += ((len * Math.pow(10,len)) * 0.9); n += (Math.pow(10,len) * 0.9); if ( (K < k)) {k = preK; n = preN; break;} } long step = (len - 1); while(true){while((k <= K)){ long preK = k;  long preN = n; if ( (step == 0)) {k += len; n++; } else {k += ((len * Math.pow(10,step)) * 0.9); n += (Math.pow(10,step) * 0.9); }if ( ((k == K) || ((k >= K) && ((k - K) < len)))) { String nStr = Long.toString(n); System.out.println(nStr.charAt(((nStr.length() - (int)(k - K)) - 1))); return ;} if ( (K < k)) {k = preK; n = preN; break;} }step--; }} }
4	public class Solution{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); for ( int i = 0,t = sc.nextInt();(i < t);i++) { int n = sc.nextInt();  LinkedList<Set<Integer>> stack = new LinkedList<>(); for ( int j = 0;(j < n);j++) {printStack(stack); int val = sc.nextInt(); if ( (val == 1)) { Set<Integer> branch = new HashSet<>(); branch.add(val); stack.push(branch); continue;} Set<Integer> branch = stack.peek(); assert (branch != null); while((branch.contains(val) || ((branch.stream().max(Integer::compareTo).get() + 1) != val))){stack.pop(); branch = stack.peek(); }branch.add(val); }printStack(stack); }} public static void printStack( LinkedList<Set<Integer>> stack){ if ( (stack.size() == 0)) {return ;} StringBuilder sb = new StringBuilder(); for ( int i = (stack.size() - 1);(i >= 0);i--) {sb.append(stack.get(i).stream().max(Integer::compareTo).get()).append("."); }System.out.println(sb.substring(0,(sb.length() - 1))); } }
0	public class D{ public static void main( String[] args){ new D(); } D(){ Scanner in = new Scanner(System.in);  double a = in.nextDouble();  double v = in.nextDouble();  double l = in.nextDouble();  double d = in.nextDouble();  double w = in.nextDouble(); if ( (w > v)) w = v;  double dx = (((v * v) - (w * w)) / (2 * a));  double d0 = ((w * w) / (2 * a));  double t = 0; if ( (d0 > d)) {if ( (d0 >= l)) {t = (Math.sqrt(((2 * a) * l)) / a); } else {t = (w / a); if ( ((d0 + dx) >= l)) {t += ((-w + Math.sqrt(((w * w) + ((2 * a) * (l - d0))))) / a); } else {t += ((v - w) / a); t += ((l - (d0 + dx)) / v); }}} else {t = (w / a); if ( ((d + dx) > l)) {t += ((-w + Math.sqrt(((w * w) + ((2 * a) * (l - d))))) / a); } else {t += ((v - w) / a); t += ((l - (d + dx)) / v); }if ( ((d0 + (2 * dx)) > d)) { double half = ((d - d0) / 2); t += ((2 * (-w + Math.sqrt(((w * w) + ((2 * a) * half))))) / a); } else {t += ((2 * (v - w)) / a); t += (((d - (2 * dx)) - d0) / v); }}System.out.printf("%.12f%n",(t + 1e-11)); } }
3	public class cfs584A{ static long LINF = (Long.MAX_VALUE / 4); static long IING = (Integer.MAX_VALUE / 4); public static void main( String[] args){ FastScanner sc = new FastScanner();  StringBuilder sb = new StringBuilder();  int N = sc.nextInt();  int[] nums = sc.readIntArray(N);  ArrayList<Integer> num = new ArrayList<>(); for ( int i = 0;(i < N);i++) {num.add(nums[i]); } int count = 0; while(!num.isEmpty()){count++; int size = num.size();  int min = 200; for ( int j = (size - 1);(j >= 0);j--) {if ( (num.get(j) < min)) {min = num.get(j); } }for ( int j = (size - 1);(j >= 0);j--) { int div = (num.get(j) / min); if ( ((div * min) == num.get(j))) {num.remove(j); } }}sb.append(count); System.out.print(sb); } 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());} long nextLong(){ return Long.parseLong(next());} int[] readIntArray( int n){ int[] a = new int[n]; for ( int idx = 0;(idx < n);idx++) {a[idx] = nextInt(); }return a;} } }
6	public class B{ static double max ; static int n ,A ,b[] ,l[] ; static int sw[] ; public static void main( String[] args){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); int k = sc.nextInt(); A = sc.nextInt(); b = new int[n]; l = new int[n]; sw = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = sc.nextInt(); l[i] = sc.nextInt(); }max = 0; search(k,0); System.out.println(max); } static void search( int k, int m){ if ( (max == 1)) return ; if ( (m == n)) {if ( (k > 0)) return ; double pr[] = new double[n]; for ( int i = 0;(i < n);i++) {pr[i] = ((Math.min(100,(l[i] + (10 * sw[i]))) * 1.) / 100); } double ex = 0; for ( int i = 0;(i < (1 << n));i++) { double p = 1;  int cnt = 0;  int lv = 0; for ( int j = 0;(j < n);j++) {if ( ((i & (1 << j)) > 0)) {p *= pr[j]; cnt++; } else {p *= (1 - pr[j]); lv += b[j]; }}if ( (cnt > (n / 2))) {ex += p; } else {ex += ((p * A) / (A + lv)); }}max = Math.max(max,ex); return ;} for ( int i = k;(i >= 0);i--) {sw[m] = i; search((k - i),(m + 1)); }} static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); eat(""); } void eat( String s){ st = new StringTokenizer(s); } String nextLine(){ try{return br.readLine(); }catch (IOException e){ throw (new IOError(e));} } boolean hasNext(){ while(!st.hasMoreTokens()){ String s = nextLine(); if ( (s == null)) return false; eat(s); }return true;} String next(){ hasNext(); return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
5	public class P15A_CottageVillage{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  int t = scanner.nextInt(); scanner.nextLine(); int[] x = new int[n];  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = scanner.nextInt(); a[i] = scanner.nextInt(); scanner.nextLine(); }scanner.close(); for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (x[i] > x[j])) {swap(x,i,j); swap(a,i,j); } }} int countPositions = 2; for ( int i = 1;(i < n);i++) { double left = (x[(i - 1)] + ((a[(i - 1)] * 1.0) / 2));  double right = (x[i] - ((a[i] * 1.0) / 2));  double length = (right - left); if ( (length == (double)t)) {countPositions++; } else if ( (length > t)) {countPositions += 2; } }System.out.println(countPositions); } static private void swap( int[] numbers, int i, int j){ int temp = numbers[i]; numbers[i] = numbers[j]; numbers[j] = temp; } }
3	public class Kaudo{ static Reader in = new Reader(); static StringBuilder Sd = new StringBuilder(); static long ans ,res ,lot ,max ; static List<Integer> gr[] ; static ArrayList<Integer> A = new ArrayList(); static String ch[] ; public static void main( String[] args){ int n = in.nextInt(),a[] = new int[n],g = 0; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); if ( (a[i] == 1)) {System.out.println("1"); return ;} }ans = 0; Arrays.sort(a); for ( int i = 0;(i < n);i++) { int x = a[i]; if ( (x > 0)) {ans++; for ( int u = i;(u < n);u++) {if ( ((a[u] % x) == 0)) {a[u] = 0; } }} }System.out.println(ans); } static int gcd( int a, int b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static class Reader{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ,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 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));} } }
3	public class Main{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  int[] colors = new int[n]; for ( int i = 0;(i < n);i++) {colors[i] = scanner.nextInt(); }Arrays.sort(colors); int amountOfColors = 0; for ( int i = 0;(i < n);i++) {if ( (colors[i] != 0)) {amountOfColors++; int color = colors[i]; for ( int j = i;(j < n);j++) {if ( ((colors[j] % color) == 0)) {colors[j] = 0; } }} }System.out.println(amountOfColors); } }
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();} } }
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){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion(); solver.solve(1,in,out); out.close(); } static class G1PlaylistForPolycarpEasyVersion{ public static final int GENRES_COUNT = 3; private int songsCount ; private int totalDuration ; private Song[] songs ; private int[][][] mem ; static final int mod = 1000000007; public void solve( int testNumber, InputReader in, PrintWriter out){ songsCount = in.nextInt(); totalDuration = in.nextInt(); songs = new Song[songsCount]; for ( int i = 0;(i < songsCount);i++) {songs[i] = new Song(in.nextInt(),(in.nextInt() - 1)); } long ret = 0;  int chosenSongs = 0; mem = new int[(GENRES_COUNT + 1)][][]; for ( int i = 0;(i < GENRES_COUNT);i++) {mem[i] = new int[(totalDuration + 1)][]; for ( int j = 0;(j <= totalDuration);j++) {mem[i][j] = new int[(1 << songsCount)]; for ( int k = 0;(k < (1 << songsCount));k++) {mem[i][j][k] = -1; }}}for ( int i = 0;(i < songsCount);i++) {chosenSongs = (1 << i); ret += search((totalDuration - songs[i].duration),songs[i].genre,chosenSongs); }out.println((ret % mod)); } private long search( int timeLeft, int lastGenre, int chosen){ if ( (timeLeft < 0)) {return 0;} if ( (timeLeft == 0)) {return 1;} if ( (mem[lastGenre][timeLeft][chosen] != -1)) {return mem[lastGenre][timeLeft][chosen];} long ret = 0; for ( int i = 0;(i < songsCount);i++) {if ( ((((1 << i) & chosen) == 0) && (songs[i].genre != lastGenre))) {ret += search((timeLeft - songs[i].duration),songs[i].genre,(chosen | (1 << i))); if ( (ret > mod)) {ret = (ret % mod); } } }mem[lastGenre][timeLeft][chosen] = (int)(ret % mod); return mem[lastGenre][timeLeft][chosen];} class Song{ public int duration ; public int genre ; public Song( int duration, int genre){ this.duration = duration; this.genre = genre; } } } 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 TaskA{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  Set<Integer> set = new HashSet<>(); for ( int i = 0;(i < n);i++) { int a = sc.nextInt();  boolean flag = false;  List<Integer> toRemove = new ArrayList<>(); for ( int b :set) {if ( ((a % b) == 0)) {flag = true; break;} else if ( (((b % a) == 0) && (a < b))) {toRemove.add(b); } }for ( int r :toRemove) {set.remove(r); }if ( !flag) {set.add(a); } }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);  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){ int n = in.readInt();  int a = in.readInt();  int b = in.readInt();  TreeMap<Integer,Integer> mp = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < n);++i) {mp.put(in.readInt(),i); } int aname = 0;  int bname = 1; if ( (a > b)) { int t = a; a = b; b = t; aname = 1; bname = 0; } int[] res = new int[n]; while((mp.size() > 0)){ Map.Entry<Integer,Integer> e = mp.firstEntry();  int val = e.getKey(); if ( mp.containsKey((b - val))) {res[mp.get(val)] = res[mp.get((b - val))] = bname; mp.remove(val); mp.remove((b - val)); } else if ( mp.containsKey((a - val))) {res[mp.get(val)] = res[mp.get((a - val))] = aname; mp.remove(val); mp.remove((a - val)); } else {break;}}if ( (mp.size() > 0)) {out.println("NO"); } else {out.println("YES"); for ( int i = 0;(i < n);++i) {if ( (i > 0)) out.print(" "); out.print(res[i]); }out.println(); }} } 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 readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } else if ( (c == '+')) {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 static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} }
3	public class Solution{ static MyScanner sc ; static private PrintWriter out ; static long M2 = (1_000_000_000L + 7); static private HashMap<Long,Long>[] mods ; public static void main( String[] s)throws Exception { StringBuilder stringBuilder = new StringBuilder(); if ( (stringBuilder.length() == 0)) {sc = new MyScanner(System.in); } else {sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString()))); }out = new PrintWriter(new OutputStreamWriter(System.out)); initData(); solve(); out.flush(); } static private void solve()throws IOException { int n = sc.nextInt();  boolean[] k = new boolean[n]; for ( int r = 0;(r < n);r++) {k[r] = (sc.next().charAt(0) == 'f'); }if ( k[(n - 1)]) {out.println(0); return ;} long[][] res = new long[(n + 1)][(n + 1)]; res[0][0] = 1; for ( int t = 0;(t < n);t++) { boolean pl = ((t != 0) && k[(t - 1)]); if ( pl) {System.arraycopy(res[t],0,res[(t + 1)],1,n); } else { long last = 0; for ( int f = n;(f >= 0);f--) {last += res[t][f]; last %= M2; res[(t + 1)][f] = last; }}} long pp = 0; for ( long kk :res[n]) {pp += kk; pp %= M2; }out.println(pp); } static private void initData(){ } static char[][] data ; static String cmd ; static private long gcd( long l, long l1){ if ( (l > l1)) return gcd(l1,l); if ( (l == 0)) return l1; return gcd((l1 % l),l);} static private long pow( long a, long b, long m){ if ( (b == 0)) return 1; if ( (b == 1)) return a; long pp = pow(a,(b / 2),m); pp *= pp; pp %= m; return ((pp * (((b % 2) == 0)?1:a)) % m);} static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner( BufferedReader br){ this.br = br; } public MyScanner( InputStream in){ this(new BufferedReader(new InputStreamReader(in))); } void findToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }} String next(){ findToken(); return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} int fi(){ String t = next();  int cur = 0;  boolean n = (t.charAt(0) == '-'); for ( int a = (n?1:0);(a < t.length());a++) {cur = (((cur * 10) + t.charAt(a)) - '0'); }return (n?-cur:cur);} long nextLong(){ return Long.parseLong(next());} } }
3	public class Main{ public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  double eps = 1e-12; while(sc.hasNext()){ int n = sc.nextInt();  int r = sc.nextInt();  double[] shu = new double[n]; for ( int i = 0;(i < n);i++) shu[i] = sc.nextDouble(); double[] res = new double[n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) { double temp = Math.abs((shu[i] - shu[j])); if ( ((temp < (2 * r)) || (Math.abs((temp - (2 * r))) < eps))) {res[i] = Math.max(res[i],(res[j] + Math.sqrt((((4 * r) * r) - (temp * temp))))); } }res[i] = Math.max(res[i],r); }for ( int i = 0;(i < n);i++) {pw.print((res[i] + " ")); }pw.flush(); }} } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); } String nextLine(){ String s = ""; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return s;} boolean hasNext(){ String s = ""; while(!st.hasMoreTokens()){s = nextLine(); if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} String next(){ String s = ""; while(!st.hasMoreTokens()){s = nextLine(); st = new StringTokenizer(s); }return st.nextToken();} int nextInt(){ return Integer.valueOf(next());} double nextDouble(){ return Double.valueOf(next());} }
6	public class G1{ public static void main( String[] args)throws Exception { new G1().run(); } int MOD = 1_000_000_007; public void run()throws Exception { FastScanner f = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int n = f.nextInt(),t = f.nextInt();  int[][] dp = new int[(1 << n)][3];  int[] tarr = new int[n];  int[] garr = new int[n]; for ( int i = 0;(i < n);i++) {tarr[i] = f.nextInt(); garr[i] = (f.nextInt() - 1); if ( (tarr[i] <= t)) dp[(1 << i)][garr[i]] = 1; } int[] time = new int[(1 << n)]; for ( int i = 0;(i < dp.length);i++) {for ( int bi = 0;(bi < n);bi++) if ( ((i & (1 << bi)) != 0)) time[i] += tarr[bi]; }for ( int i = 0;(i < dp.length);i++) { int j = time[i]; for ( int k = 0;(k < 3);k++) {if ( (dp[i][k] == 0)) continue; for ( int bi = 0;(bi < n);bi++) if ( ((((tarr[bi] + j) <= t) && ((i & (1 << bi)) == 0)) && (garr[bi] != k))) {dp[(i | (1 << bi))][garr[bi]] = ((dp[(i | (1 << bi))][garr[bi]] + dp[i][k]) % MOD); } }} long ans = 0; for ( int i = 0;(i < dp.length);i++) for ( int j = 0;(j < 3);j++) if ( (time[i] == t)) ans = ((ans + dp[i][j]) % MOD); out.println(ans); out.flush(); } static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
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;} }
5	public class Main implements Runnable{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private void eat( String line){ st = new StringTokenizer(line); } private String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) return null; eat(line); }return st.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args){ new Thread(new Main()).start(); } public void go()throws IOException { int n = nextInt(),t = nextInt();  int[] x = new int[n],a = new int[n]; for ( int i = 0;(i < n);++i) {x[i] = nextInt(); a[i] = nextInt(); }out.println(new Algo().solve(n,t,x,a)); } } final class Algo{ public int solve( int n, int t,final int[] x,final int[] a){ Integer[] order = new Integer[n]; for ( int i = 0;(i < n);++i) order[i] = i; Arrays.sort(order,new Comparator<Integer>(){}); int result = 2; for ( int i = 0;((i + 1) < n);++i) { int u = order[i],v = order[(i + 1)];  int dist = ((2 * (x[v] - x[u])) - (a[v] + a[u])); if ( (dist > (2 * t))) result += 2; else if ( (dist == (2 * t))) ++result; }return result;} }
5	public class A{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void solve()throws IOException { int n = readInt();  long k = readInt();  Long[] a = new Long[n]; for ( int i = 0;(i < n);i++) {a[i] = readLong(); }Arrays.sort(a); TreeSet<Long> set = new TreeSet<Long>(); for ( int i = 0;(i < n);i++) {set.add(a[i]); }if ( (k == 1)) {out.println(n); return ;} int res = 0;  TreeSet<Long> used = new TreeSet<Long>(); for ( Long cur :set) {if ( !used.contains(cur)) { int num = 1; used.add(cur); Long temp = (cur * 1); while(true){if ( set.contains((k * temp))) {num++; used.add((k * temp)); temp *= k; } else {res += ((num + 1) / 2); break;}}} }out.println(res); } 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());} long readLong()throws IOException { return Long.parseLong(readString());} public static void main( String[] args){ new A().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); } } }
5	public class TaskA implements Runnable{ long m = ((int)1e9 + 7); PrintWriter w ; InputReader c ; static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} public int[] scanArrayI( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = c.nextInt(); return a;} 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 interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new TaskA(),"TaskA",(1 << 26)).start(); } }
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();} }
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;} }
0	public class TwentyFive{ public static void main( String[] args){ System.out.println("25"); } }
2	public class Solution{ public static void main( String[] args)throws IOException { boolean online = "true".equals(System.getProperty("ONLINE_JUDGE")); if ( online) {in = new InputReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new InputReader(new FileReader("input.txt")); out = new PrintWriter(new File("output.txt")); }new Solution().run(); out.close(); } long sum( int x){ return (((x * 1l) * (x + 1)) / 2);} int bins( long n, int k){ int l = 1,r = k; while((l < r)){ int w = ((l + r) / 2);  long s = (sum(k) - sum((w - 1))); if ( (s == n)) return w; if ( (s < n)) r = w; else l = (w + 1); }return l;} private void run(){ long n = in.nextLong();  int k = in.nextInt(); if ( (n == 1)) {out.println(0); return ;} if ( ((1 + sum((k - 1))) < n)) {out.println(-1); return ;} int c = bins((n - 1),(k - 1)); if ( (((1 + sum((k - 1))) - sum((c - 1))) == n)) out.println((k - c)); else out.println(((k - c) + 1)); } static private InputReader in ; static private PrintWriter out ; } class InputReader{ public InputReader( Reader r){ buff = new BufferedReader(r); try{str = new StringTokenizer(buff.readLine()); }catch (IOException e){ e.printStackTrace(); } } public String next(){ while(!str.hasMoreTokens())try{str = new StringTokenizer(buff.readLine()); }catch (IOException e){ e.printStackTrace(); } return str.nextToken();} public int nextInt(){ return Integer.parseInt(this.next());} public long nextLong(){ return Long.parseLong(this.next());} static private BufferedReader buff ; static private StringTokenizer str ; }
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));} }
3	public class P1196D2{ static boolean multipleIndependent = true; void run(){ int n = in.nextInt();  int k = in.nextInt();  char[] s = in.next().toCharArray();  int[] dp = new int[3];  char[] c = {'R','G','B'};  int min = Integer.MAX_VALUE; for ( int i = 0;(i < k);i++) {dp[0] += ((s[i] == c[((i + 0) % 3)])?0:1); dp[1] += ((s[i] == c[((i + 1) % 3)])?0:1); dp[2] += ((s[i] == c[((i + 2) % 3)])?0:1); }min = Math.min(Math.min(Math.min(dp[0],dp[1]),dp[2]),min); for ( int i = k;(i < n);i++) {dp[0] += (((s[i] == c[((i + 0) % 3)])?0:1) - ((s[(i - k)] == c[(((i - k) + 0) % 3)])?0:1)); dp[1] += (((s[i] == c[((i + 1) % 3)])?0:1) - ((s[(i - k)] == c[(((i - k) + 1) % 3)])?0:1)); dp[2] += (((s[i] == c[((i + 2) % 3)])?0:1) - ((s[(i - k)] == c[(((i - k) + 2) % 3)])?0:1)); min = Math.min(Math.min(Math.min(dp[0],dp[1]),dp[2]),min); }System.out.println(min); } static InputReader in = new InputReader(System.in); public static void main( String[] args){ P1196D2 p = new P1196D2();  int q = (multipleIndependent?in.nextInt():1); while((q-- > 0)){p.run(); }} <R> long binarySearch( long lowerBound, long upperBound, R value, Function<Long,R> generatorFunction, Comparator<R> comparator){ if ( (lowerBound <= upperBound)) { long mid = ((lowerBound + upperBound) / 2);  int compare = comparator.compare(generatorFunction.apply(mid),value); if ( (compare == 0)) {return mid;} else if ( (compare < 0)) {return binarySearch((mid + 1),upperBound,value,generatorFunction,comparator);} else {return binarySearch(lowerBound,(mid - 1),value,generatorFunction,comparator);}} else {return -1;}} void reorder( Integer[] indices, Object[] arr){ if ( (indices.length != arr.length)) {throw (new RuntimeException("Arrays must have equals lengths"));} int n = arr.length;  Object[] copy = new Object[n]; for ( int i = 0;(i < n);i++) {copy[i] = arr[indices[i]]; }System.arraycopy(copy,0,arr,0,n); } int prodMod( int a, int b, int mod){ return (int)(((long)a * b) % mod);} long prodMod( long a, long b, long mod){ long res = 0; a %= mod; b %= mod; while((b > 0)){if ( ((b & 1) > 0)) {res = ((res + a) % mod); } a = ((a << 1) % mod); b >>= 1; }return res;} long sumMod( int[] b, long mod){ long res = 0; for ( int i = 0;(i < b.length);i++) {res = ((res + (b[i] % mod)) % mod); }return res;} long sumMod( long[] a, long mod){ long res = 0; for ( int i = 0;(i < a.length);i++) {res = ((res + (a[i] % mod)) % mod); }return res;} int[] toPrimitive( Integer[] arr){ int[] res = new int[arr.length]; for ( int i = 0;(i < arr.length);i++) {res[i] = arr[i]; }return res;} int[][] toPrimitive( Integer[][] arr){ int[][] res = new int[arr.length][]; for ( int i = 0;(i < arr.length);i++) {res[i] = toPrimitive(arr[i]); }return res;} long[] toPrimitive( Long[] arr){ long[] res = new long[arr.length]; for ( int i = 0;(i < arr.length);i++) {res[i] = arr[i]; }return res;} long[][] toPrimitive( Long[][] arr){ long[][] res = new long[arr.length][]; for ( int i = 0;(i < arr.length);i++) {res[i] = toPrimitive(arr[i]); }return res;} Integer[] toWrapper( int[] arr){ Integer[] res = new Integer[arr.length]; for ( int i = 0;(i < arr.length);i++) {res[i] = arr[i]; }return res;} Integer[][] toWrapper( int[][] arr){ Integer[][] res = new Integer[arr.length][]; for ( int i = 0;(i < arr.length);i++) {res[i] = toWrapper(arr[i]); }return res;} Long[] toWrapper( long[] arr){ Long[] res = new Long[arr.length]; for ( int i = 0;(i < arr.length);i++) {res[i] = arr[i]; }return res;} Long[][] toWrapper( long[][] arr){ Long[][] res = new Long[arr.length][]; for ( int i = 0;(i < arr.length);i++) {res[i] = toWrapper(arr[i]); }return res;} 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 int[] nextIntArray( int n){ int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextInt(); }return arr;} public <T> T[] nextIntArray( int n, Function<Integer,T> function, Class<T> c){ T[] arr = (T[])Array.newInstance(c,n); for ( int i = 0;(i < n);i++) {arr[i] = function.apply(nextInt()); }return arr;} public long[] nextLongArray( int n){ long[] arr = new long[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextLong(); }return arr;} public <T> T[] nextLongArray( int n, Function<Long,T> function, Class<T> c){ T[] arr = (T[])Array.newInstance(c,n); for ( int i = 0;(i < n);i++) {arr[i] = function.apply(nextLong()); }return arr;} public <T> T read( Class<T> c){ throw (new UnsupportedOperationException("To be implemented"));} } }
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;} }
2	public class ProblemB{ public static void main( String[] args)throws IOException { ProblemB solver = new ProblemB(); solver.init(); solver.solve(); } private void init(){ } private void solve()throws IOException { Reader in = new Reader(System.in);  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int n = in.nextInt();  int x = in.nextInt();  int y = in.nextInt();  int c = in.nextInt();  long lo = 0;  long hi = (2 * n); while((lo < hi)){ long mid = ((lo + hi) / 2);  long r = count(n,x,y,mid); if ( (r < c)) {lo = (mid + 1); } else {hi = mid; ;}}out.println(lo); out.flush(); out.close(); } private long count( int n, int x, int y, long steps){ long r = (1 + ((2 * steps) * (1 + steps))); r -= countWall(((x - 1) - steps)); r -= countWall(((y - 1) - steps)); r -= countWall((n - (x + steps))); r -= countWall((n - (y + steps))); r += countCorner((((steps - (x - 1)) - (y - 1)) - 1)); r += countCorner((((steps - (y - 1)) - (n - x)) - 1)); r += countCorner((((steps - (n - x)) - (n - y)) - 1)); r += countCorner((((steps - (x - 1)) - (n - y)) - 1)); return r;} private long countCorner( long x){ if ( (x <= 0)) return 0; return ((x * (x + 1)) / 2);} private long countWall( long x){ if ( (x >= 0)) return 0; return (x * x);} static private class Reader{ BufferedReader reader ; StringTokenizer tokenizer ; Reader( InputStream input){ reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); } public String next()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
5	public class Main{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));  String out = "";  String[] p = br.readLine().split("[ ]");  int n = Integer.valueOf(p[0]);  double t = Double.valueOf(p[1]);  int offset = 5000;  boolean[] flags = new boolean[(offset + 5000)]; for ( int i = 0;(i < n);i++) { int[] q = toIntArray(br.readLine());  int c = (2 * q[0]); for ( int j = -q[1];(j < q[1]);j++) {flags[((c + offset) + j)] = true; }} int buf = 0;  int last = -1;  int index = 0; for ( ;(index < flags.length);index++) {if ( flags[index]) {if ( (last == -1)) {buf++; } else {if ( (Math.abs(((index - last) - ((2 * t) + 1))) < 1e-10)) buf++; else if ( ((index - last) > ((2 * t) + 1))) buf += 2; }last = index; } }buf++; out = (("" + buf) + "\r\n"); bw.write(out,0,out.length()); br.close(); bw.close(); } static int[] toIntArray( String line){ String[] p = line.trim().split("\\s+");  int[] out = new int[p.length]; for ( int i = 0;(i < out.length);i++) out[i] = Integer.valueOf(p[i]); return out;} }
2	public class Main{ public static void main( String[] args){ Scanner sca = new Scanner(System.in);  long k ,n ;  long ans ;  long[] pw = new long[33]; pw[1] = 4; pw[0] = 1; for ( int i = 2;(i <= 31);i++) pw[i] = (pw[(i - 1)] << 2); int t ; t = sca.nextInt(); for ( int cas = 1;(cas <= t);cas++) {n = sca.nextLong(); k = sca.nextLong(); ans = n; long last ,path = 1; for ( int i = 0;;i++) {if ( (((pw[(i + 1)] - 1) / 3) > k)) {ans -= i; last = (k - ((pw[i] - 1) / 3)); break;} path *= 2; } long sp = ((path * 2) - 1); if ( ((ans < 0) || ((ans == 0) && (last > 0)))) {System.out.println("NO"); continue;} BigInteger sq = BigInteger.valueOf(path).multiply(BigInteger.valueOf(path)).subtract(BigInteger.valueOf(sp)); if ( (((ans == 1) && (sq.compareTo(BigInteger.valueOf(last)) == -1)) && (last < sp))) {System.out.println("NO"); continue;} else if ( ((ans == 1) && (last >= sp))) {ans--; } System.out.println(("YES " + ans)); }} }
0	public class Berland implements Runnable{ private void solve()throws IOException { double a = nextInt();  double v = nextInt();  double l = nextInt();  double d = nextInt();  double w = nextInt();  double res ; if ( (v <= w)) {res = simpleCase(a,v,l,0); } else { double vMax = Math.sqrt(((2 * d) * a)); if ( (vMax <= w)) {res = simpleCase(a,v,l,0); } else { double tFullSpeed = (v / a);  double tSlowdown = ((v - w) / a); if ( ((((((a * tFullSpeed) * tFullSpeed) / 2) + (v * tSlowdown)) - (((a * tSlowdown) * tSlowdown) / 2)) <= d)) {res = (((tFullSpeed + tSlowdown) + ((d - (((((a * tFullSpeed) * tFullSpeed) / 2) + (v * tSlowdown)) - (((a * tSlowdown) * tSlowdown) / 2))) / v)) + simpleCase(a,v,(l - d),w)); } else { double min = w;  double max = v; for ( int i = 0;(i < 1000);++i) { double cur = ((min + max) / 2);  double cFullSpeed = (cur / a);  double cSlowdown = ((cur - w) / a); if ( ((((((a * cFullSpeed) * cFullSpeed) / 2) + (cur * cSlowdown)) - (((a * cSlowdown) * cSlowdown) / 2)) <= d)) min = cur; else max = cur; }res = (((min / a) + ((min - w) / a)) + simpleCase(a,v,(l - d),w)); }}}writer.printf("%.20f\n",res); } private double simpleCase( double a, double v, double l, double v0){ double tFullSpeed = ((v - v0) / a); if ( (((v0 * tFullSpeed) + (((a * tFullSpeed) * tFullSpeed) / 2)) <= l)) {return (tFullSpeed + ((l - ((v0 * tFullSpeed) + (((a * tFullSpeed) * tFullSpeed) / 2))) / v));} else { double min = 0;  double max = tFullSpeed; for ( int i = 0;(i < 1000);++i) { double cur = ((min + max) / 2); if ( (((v0 * cur) + (((a * cur) * cur) / 2)) <= l)) min = cur; else max = cur; }return min;}} public static void main( String[] args){ new Berland().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();} }
6	public class EdC{ static long[] mods = {1000000007,998244353,1000000009}; static long mod = mods[0]; public static MyScanner sc ; public static PrintWriter out ; static char[][] grid ; static int n ; static int t ; static int[][] dp ; static int[] times ; static int[] genre ; public static void main( String[] omkar)throws Exception { sc = new MyScanner(); out = new PrintWriter(System.out); n = sc.nextInt(); t = sc.nextInt(); times = new int[n]; genre = new int[n]; for ( int j = 0;(j < n);j++) {times[j] = sc.nextInt(); genre[j] = sc.nextInt(); }dp = new int[(1 << n)][4]; for ( int j = 0;(j < (1 << n));j++) Arrays.fill(dp[j],-1); int ans = 0; for ( int j = 0;(j < (1 << n));j++) { int time = 0; for ( int k = 0;(k < n);k++) {if ( (((1 << k) & j) != 0)) {time += times[k]; } }if ( (time == t)) {letsgodp(j,1); letsgodp(j,2); letsgodp(j,3); ans += dp[j][1]; ans %= mod; ans += dp[j][2]; ans %= mod; ans += dp[j][3]; ans %= mod; } }out.println(ans); out.close(); } public static void letsgodp( int mask, int dg){ if ( (dp[mask][dg] != -1)) return ; dp[mask][dg] = 0; for ( int j = 0;(j < n);j++) {if ( ((((1 << j) & mask) != 0) && (genre[j] == dg))) { int submask = (mask - (1 << j));  int og1 = (((genre[j] + 1) > 3)?(genre[j] - 2):(genre[j] + 1));  int og2 = (((genre[j] + 2) > 3)?(genre[j] - 1):(genre[j] + 2)); if ( (submask != 0)) {letsgodp(submask,og1); letsgodp(submask,og2); dp[mask][dg] += (dp[submask][og1] + dp[submask][og2]); dp[mask][dg] %= mod; } else {dp[mask][dg] = 1; }} }} public static void sort( int[] array){ ArrayList<Integer> copy = new ArrayList<Integer>(); 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 class Solution{ static MyScanner sc ; static private PrintWriter out ; static long M2 = (1_000_000_000L + 7); static private HashMap<Long,Long>[] mods ; public static void main( String[] s)throws Exception { StringBuilder stringBuilder = new StringBuilder(); if ( (stringBuilder.length() == 0)) {sc = new MyScanner(System.in); } else {sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString()))); }out = new PrintWriter(new OutputStreamWriter(System.out)); initData(); solve(); out.flush(); } static private void solve()throws IOException { int n = sc.nextInt();  int[] data = sc.na(n);  boolean ev = true; for ( int t = 0;(t < (n - 1));t++) {for ( int x = (t + 1);(x < n);x++) {if ( (data[t] > data[x])) {ev = !ev; } }} int m = sc.nextInt(); for ( int i = 0;(i < m);i++) { int dd = (-sc.nextInt() + sc.nextInt());  int dm = (((dd + 1) * dd) / 2); if ( ((dm % 2) == 1)) {ev = !ev; } out.println((ev?"even":"odd")); }} static private void initData(){ } static private long gcd( long l, long l1){ if ( (l > l1)) return gcd(l1,l); if ( (l == 0)) return l1; return gcd((l1 % l),l);} static private long pow( long a, long b, long m){ if ( (b == 0)) return 1; if ( (b == 1)) return a; long pp = pow(a,(b / 2),m); pp *= pp; pp %= m; return ((pp * (((b % 2) == 0)?1:a)) % m);} static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner( BufferedReader br){ this.br = br; } public MyScanner( InputStream in){ this(new BufferedReader(new InputStreamReader(in))); } void findToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }} String next(){ findToken(); return st.nextToken();} int[] na( int n){ int[] k = new int[n]; for ( int i = 0;(i < n);i++) {k[i] = sc.fi(); }return k;} int nextInt(){ return Integer.parseInt(next());} int fi(){ String t = next();  int cur = 0;  boolean n = (t.charAt(0) == '-'); for ( int a = (n?1:0);(a < t.length());a++) {cur = (((cur * 10) + t.charAt(a)) - '0'); }return (n?-cur:cur);} long nextLong(){ return Long.parseLong(next());} } }
0	public class practice{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  String str = in.nextLine();  long n = Long.parseLong(str.substring(0,str.indexOf(" ")));  long m = Long.parseLong(str.substring((str.indexOf(" ") + 1))); if ( ((m - n) < 2)) {System.out.println("-1"); } else {if ( (((m - n) == 2) && ((m % 2) == 1))) {System.out.println("-1"); } else {System.out.println((((((n + (n % 2)) + " ") + ((n + 1) + (n % 2))) + " ") + ((n + 2) + (n % 2)))); }}} }
4	public class D{ public static void main( String[] args){ FastScanner sc = new FastScanner();  int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int[][] lr = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {lr[i][j] = sc.nextInt(); }} int[][] ud = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ud[i][j] = sc.nextInt(); }}if ( ((k % 2) == 1)) { StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {sb.append((-1 + " ")); }sb.replace((sb.length() - 1),sb.length(),"\n"); } PrintWriter pw = new PrintWriter(System.out); pw.println(sb.toString().trim()); pw.flush(); } else { int[][] dir = {{0,1},{0,-1},{1,0},{-1,0}};  long[][][] dp = new long[((k / 2) + 1)][n][m]; for ( int s = 1;(s <= (k / 2));s++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[s][i][j] = Long.MAX_VALUE; for ( int[] d :dir) { int u = (i + d[0]),v = (j + d[1]); if ( ((((u >= 0) && (u < n)) && (v >= 0)) && (v < m))) { long w = calc(i,j,u,v,lr,ud); dp[s][i][j] = Math.min(dp[s][i][j],(dp[(s - 1)][u][v] + (2 * w))); } }}}} StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {sb.append((dp[(k / 2)][i][j] + " ")); }sb.replace((sb.length() - 1),sb.length(),"\n"); } PrintWriter pw = new PrintWriter(System.out); pw.println(sb.toString().trim()); pw.flush(); }} static long calc( int i, int j, int u, int v, int[][] lr, int[][] ud){ if ( (i == u)) {return lr[i][Math.min(j,v)];} else {return ud[Math.min(i,u)][j];}} static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
1	public class Ideone{ public static void main( String[] args)throws java.lang.Exception { Scanner sc = new Scanner(System.in);  String a = sc.next();  String b = sc.next();  int m = a.length();  int n = b.length();  int[] zero = new int[n];  int[] one = new int[n]; for ( int i = 0;(i < n);i++) {if ( (i == 0)) {if ( (b.charAt(i) == '0')) zero[i]++; else one[i]++; } else {zero[i] = zero[(i - 1)]; one[i] = one[(i - 1)]; if ( (b.charAt(i) == '0')) zero[i]++; else one[i]++; }} long res = 0; for ( int i = 0;(i < m);i++) { int x = ((n - m) + i); if ( (a.charAt(i) == '0')) res += one[x]; else res += zero[x]; if ( (i > 0)) {if ( (a.charAt(i) == '0')) res -= one[(i - 1)]; else res -= zero[(i - 1)]; } }System.out.println(res); } }
4	public class C2{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = na(n); for ( int i = 0;(i < n);i++) { int v = a[i]; for ( int j = 2;((j * j) <= v);j++) {while(((v % (j * j)) == 0)){v /= (j * j); }}a[i] = v; }Arrays.sort(a); int[] f = new int[n];  int p = 0; for ( int i = 0;(i < n);i++) {if ( ((i > 0) && (a[i] != a[(i - 1)]))) {p++; } f[p]++; }f = Arrays.copyOf(f,(p + 1)); int mod = 1000000007;  int[][] fif = enumFIF(1000,mod);  long[] res = countSameNeighborsSequence(f,fif,mod);  long ans = res[0]; for ( int v :f) {ans = ((ans * fif[0][v]) % mod); }out.println(ans); } public static int[][] enumFIF( int n, int mod){ int[] f = new int[(n + 1)];  int[] invf = new int[(n + 1)]; f[0] = 1; for ( int i = 1;(i <= n);i++) {f[i] = (int)(((long)f[(i - 1)] * i) % mod); } long a = f[n];  long b = mod;  long p = 1,q = 0; while((b > 0)){ long c = (a / b);  long d ; d = a; a = b; b = (d % b); d = p; p = q; q = (d - (c * q)); }invf[n] = (int)((p < 0)?(p + mod):p); for ( int i = (n - 1);(i >= 0);i--) {invf[i] = (int)(((long)invf[(i + 1)] * (i + 1)) % mod); }return new int[][]{f,invf};} public static long[] countSameNeighborsSequence( int[] a, int[][] fif, int mod){ int n = a.length;  int bef = a[0];  int aft = a[0];  long[] dp = new long[bef]; dp[(bef - 1)] = 1; for ( int u = 1;(u < n);u++) { int v = a[u]; aft += v; long[][] ldp = new long[bef][aft]; for ( int i = 0;(i < dp.length);i++) {ldp[i][0] = dp[i]; }for ( int i = 0;(i < v);i++) { long[][] ndp = new long[bef][aft]; for ( int j = 0;(j < bef);j++) {for ( int k = 0;((j + k) < aft);k++) {if ( (ldp[j][k] == 0)) continue; if ( (j > 0)) {ndp[(j - 1)][k] += (ldp[j][k] * j); ndp[(j - 1)][k] %= mod; } ndp[j][(k + 1)] += (ldp[j][k] * ((2 * i) - k)); ndp[j][(k + 1)] %= mod; ndp[j][k] += (ldp[j][k] * (((((bef + i) + 1) - j) - k) - (2 * (i - k)))); ndp[j][k] %= mod; }}ldp = ndp; }dp = new long[aft]; for ( int j = 0;(j < bef);j++) {for ( int k = 0;((j + k) < aft);k++) {dp[(j + k)] += ldp[j][k]; }}for ( int j = 0;(j < aft);j++) dp[j] = (((dp[j] % mod) * fif[1][v]) % mod); bef = aft; }return dp;} 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 C2().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)); } }
2	public class P817C{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  long s = scan.nextLong();  long ans = 0; if ( (s > n)) {System.out.println(0); return ;} if ( (n > (s + 200))) {ans += (n - (s + 200)); n = (s + 200); } for ( long i = s;(i <= n);i++) { char[] num = ("" + i);  int sum = 0; for ( int j = 0;(j < num.length);j++) sum += (num[j] - '0'); if ( ((i - sum) >= s)) ans++; }System.out.println(ans); } }
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());} } }
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; } } }
6	public class C{ static int[] nm ; static int ans = 0; static int rows ,cols ; static boolean[][] cae ; static int[][] ca ; public static void main( String[] args)throws IOException { nm = readIntArray(); rows = Math.max(nm[0],nm[1]); cols = Math.min(nm[0],nm[1]); long s = System.currentTimeMillis(); cae = new boolean[1000][50]; ca = new int[1000][50]; StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < cols);i++) {sb.append('1'); } int startingState = Integer.parseInt(sb.toString(),3); ans = solve(startingState,0); System.out.println(((nm[0] * nm[1]) - ans)); } static int solve( int state, int row){ if ( (row == rows)) {return 0;} if ( cae[state][row]) {return ca[state][row];} int ans = Integer.MAX_VALUE; for ( int i = 0;(i < Math.pow(3,cols));i++) { boolean isCover = covers(i,state); if ( (isCover && ((row < (rows - 1)) || coversTotally(i,state)))) { int p = placed(i);  int s = solve(i,(row + 1)); ans = Math.min(ans,(s + p)); } }cae[state][row] = true; ca[state][row] = ans; return ans;} static private boolean coversTotally( int i, int state){ String bottom = decode(i); for ( int j = 0;(j < bottom.length());j++) {if ( (bottom.charAt(j) == '0')) {return false;} }return true;} static private boolean covers( int i, int state){ String top = decode(state);  String bottom = decode(i); for ( int j = 0;(j < top.length());j++) {if ( ((top.charAt(j) == '0') && (bottom.charAt(j) != '2'))) {return false;} if ( ((top.charAt(j) == '2') && (bottom.charAt(j) == '0'))) {return false;} }for ( int j = 0;(j < top.length());j++) {if ( ((bottom.charAt(j) == '1') && (((top.charAt(j) != '2') && ((j > 0) && (bottom.charAt((j - 1)) == '2'))) && ((j < (top.length() - 1)) && (bottom.charAt((j + 1)) == '2'))))) {return false;} }return true;} static private int placed( int i){ String s = decode(i);  int cnt = 0; for ( int j = 0;(j < s.length());j++) {if ( (s.charAt(j) == '2')) {cnt++; } }return cnt;} static private String decode( int state){ String tmp = Integer.toString(state,3); if ( (tmp.length() < cols)) { StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < (cols - tmp.length()));i++) {sb.append('0'); }sb.append(tmp); return sb.toString();} else {return tmp;}} static InputStreamReader isr = new InputStreamReader(System.in); static BufferedReader br = new BufferedReader(isr); static int[] readIntArray()throws IOException { String[] v = br.readLine().split(" ");  int[] ans = new int[v.length]; for ( int i = 0;(i < ans.length);i++) {ans[i] = Integer.valueOf(v[i]); }return ans;} }
4	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; for ( int i = 1;(i < 40000);i++) squares.add((i * i)); while((tt++ < t)){ boolean res = solve(); }out.close(); } static HashSet<Integer> squares = new HashSet(); static boolean solve(){ long res = 0;  int n = sc.ni();  long m = sc.nl();  long[][][] dp = new long[2][5][5];  long[][][] dp2 = new long[2][5][5]; dp[0][2][1] = dp[1][2][2] = dp2[0][1][1] = 1L; for ( int i = 3;(i <= n);i++) { long[][] bef = dp[0];  long[][] aft = dp[1];  long[][] nbef = new long[(i + 3)][(i + 3)];  long[][] naft = new long[(i + 3)][(i + 3)]; for ( int len = 1;(len <= i);len++) {for ( int ind = 1;(ind <= len);ind++) {nbef[(len + 1)][1] += bef[len][ind]; nbef[(len + 1)][(ind + 1)] -= bef[len][ind]; naft[(len + 1)][(ind + 1)] += bef[len][ind]; naft[(len + 1)][(ind + 1)] += aft[len][ind]; nbef[(len + 1)][1] += (dp2[0][len][ind] + dp2[1][len][ind]); }}for ( int len = 1;(len <= i);len++) {for ( int ind = 1;(ind <= len);ind++) {nbef[len][ind] = (((nbef[len][ind] + nbef[len][(ind - 1)]) + (10000000L * m)) % m); naft[len][ind] = (((naft[len][ind] + naft[len][(ind - 1)]) + (10000000L * m)) % m); }}dp2 = dp; dp = new long[][][]{nbef,naft}; }for ( long[] row :dp[0]) for ( long i :row) res += i; for ( long[] row :dp[1]) for ( long i :row) res += i; out.println((res % m)); 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());} long nl(){ return Long.parseLong(next());} } }
1	public class MSpreadSheet{ public int toNum( String x){ int result = 0;  int pow = 0; for ( int i = (x.length() - 1);(i >= 0);i--) {result += (((x.charAt(i) - 'A') + 1) * Math.pow(26,pow)); pow++; }return result;} public String toString( int x){ if ( (x <= 26)) return String.valueOf((char)((x + 'A') - 1)); String result = ""; while((x != 0)){if ( ((x % 26) == 0)) {result = ('Z' + result); x = ((x / 26) - 1); } else {result = ((char)(((x % 26) + 'A') - 1) + result); x = (x / 26); }}return result;} public boolean check( String x){ if ( (x.charAt(0) != 'R')) return false; int in = x.indexOf('C'); if ( (in == -1)) return false; if ( (Character.isDigit(x.charAt((in - 1))) && Character.isDigit(x.charAt((in + 1))))) return true; return false;} public void solve( String x){ String r = "";  String c = ""; if ( check(x)) { int in = x.indexOf('C'); r = x.substring(1,in); c = x.substring((in + 1)); System.out.println((toString(Integer.parseInt(c)) + r)); } else { int i = 0; while(!Character.isDigit(x.charAt(i)))c += x.charAt(i++); while((i < x.length()))r += x.charAt(i++); System.out.println(((("R" + r) + "C") + toNum(c))); }} public static void main( String[] args){ MSpreadSheet sh = new MSpreadSheet();  Scanner s = new Scanner(System.in);  int n = s.nextInt();  int i = 0; while((i < n)){sh.solve(s.next()); i++; }} }
3	public class inversioncounting{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] permutation = new int[n]; for ( int i = 0;(i < n);i++) {permutation[i] = sc.nextInt(); } int m = sc.nextInt();  int[][] reverse = new int[m][2]; for ( int i = 0;(i < m);i++) {reverse[i][0] = sc.nextInt(); reverse[i][1] = sc.nextInt(); } int counter = 0; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (permutation[i] > permutation[j])) {counter++; } }} boolean bayus = true; if ( ((counter % 2) == 1)) {bayus = false; } for ( int i = 0;(i < m);i++) { int bobib = ((reverse[i][1] - reverse[i][0]) + 1);  int bafry = nChoose2(bobib); if ( ((bafry % 2) == 1)) {bayus = !bayus; } if ( bayus) {System.out.println("even"); } else {System.out.println("odd"); }}} static private int nChoose2( int n){ return ((n * (n - 1)) / 2);} }
3	public class Solution2{ private void solve()throws IOException { int n = in.nextInt();  double r = in.nextDouble();  List<Double> xes = new ArrayList<>(n);  List<Double> yes = new ArrayList<>(n); for ( int i = 0;(i < n);i++) {xes.add(in.nextDouble()); }for ( int i = 0;(i < n);i++) { double max = r; for ( int j = 0;(j < i);j++) { double x = xes.get(j);  double y = yes.get(j); if ( ((xes.get(i) <= (x + (2 * r))) && (xes.get(i) >= (x - (2 * r))))) {max = Math.max(max,(y + Math.sqrt((((4 * r) * r) - (Math.abs((x - xes.get(i))) * Math.abs((x - xes.get(i)))))))); } }yes.add(max); }for ( double y :yes) {System.out.print((y + " ")); }System.out.println(); System.out.flush(); } static private String filename = ""; private PrintWriter out ; private MyScanner in ; private void run()throws IOException { in = new MyScanner(); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } private class MyScanner{ private BufferedReader br ; private StringTokenizer st ; MyScanner()throws IOException{ this.br = new BufferedReader(new InputStreamReader(System.in)); } public MyScanner( String fileTitle)throws IOException{ this.br = new BufferedReader(new FileReader(fileTitle)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return "-1";} st = new StringTokenizer(s); }return st.nextToken();} public Integer nextInt()throws IOException { return Integer.parseInt(this.next());} public Double nextDouble()throws IOException { return Double.parseDouble(this.next());} void close()throws IOException { this.br.close(); } } public static void main( String[] args)throws IOException { Locale.setDefault(Locale.US); new Solution2().run(); } }
0	public class Traffic extends Template{ public double search1( int a, int w, int d){ double s = 0;  double l = ((2 * w) + ((2 * a) * d));  int repeat = 100; while((repeat-- > 0)){ double x = ((s + l) / 2); if ( (((((((a * a) * x) * x) + (((2 * a) * w) * x)) - (w * w)) - ((4 * a) * d)) > 0)) {l = x; } else {s = x; }}return l;} public double search2( int a, double lim, int k){ double s = 0;  double l = (lim + ((2 * a) * k));  int repeat = 100; while((repeat-- > 0)){ double x = ((s + l) / 2); if ( (((((a * x) * x) + ((2 * lim) * x)) - (2 * k)) > 0)) {l = x; } else {s = x; }}return l;} public void solve()throws IOException { int a = nextInt();  int v = nextInt();  int l = nextInt();  int d = nextInt();  int w = nextInt(); if ( (w > v)) {w = v; } double time_max = Math.sqrt((((double)2 * d) / a));  double time_d = search1(a,w,d);  double t1 = (((time_max * a) < w)?time_max:((v >= ((w + (a * time_d)) / 2))?time_d:((w < v)?((double)(((((2 * v) * v) - ((2 * v) * w)) + ((2 * a) * d)) + (w * w)) / ((2 * a) * v)):(((double)v / a) + ((double)(d - (((double)v * v) / (2 * a))) / v)))));  double lim = (((time_max * a) < w)?(time_max * a):w);  double t3 = Math.min(((double)(v - lim) / a),search2(a,lim,(l - d)));  double dist2 = (((l - d) - (((t3 * t3) * a) / 2)) - (t3 * lim));  double t4 = (dist2 / v); writer.println(((t1 + t3) + t4)); } public static void main( String[] args){ new Traffic().run(); } }
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); }} }
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);  CChessboard solver = new CChessboard(); solver.solve(1,in,out); out.close(); } static class CChessboard{ int[] nextPermutation( int[] array){ int i = (array.length - 1); while(((i > 0) && (array[(i - 1)] >= array[i]))){i--; }if ( (i <= 0)) {return null;} int j = (array.length - 1); while((array[j] <= array[(i - 1)])){j--; } int temp = array[(i - 1)]; array[(i - 1)] = array[j]; array[j] = temp; j = (array.length - 1); while((i < j)){temp = array[i]; array[i] = array[j]; array[j] = temp; i++; j--; }return array;} public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int arr[][][] = new int[4][n][n];  int sum[] = new int[4]; for ( int k = 0;(k < 4);k++) {for ( int i = 0;(i < n);i++) { String str = in.next(); for ( int j = 0;(j < n);j++) {arr[k][i][j] = (str.charAt(j) - '0'); }}}for ( int k = 0;(k < 4);k++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (((i + j) % 2) == arr[k][i][j])) sum[k]++; }}} int perm[] = new int[4]; for ( int i = 0;(i < 4);i++) perm[i] = i; int min = Integer.MAX_VALUE; while(true){perm = nextPermutation(perm); if ( (perm == null)) break; int sm = 0; for ( int j = 0;(j < 4);j++) {if ( ((j % 2) == 0)) {sm += sum; } else {sm += ((n * n) - sum[perm[j]]); }}min = Math.min(min,sm); sm = 0; for ( int j = 0;(j < 4);j++) {if ( ((j % 2) == 0)) {sm += ((n * n) - sum[perm[j]]); } else {sm += sum; }}min = Math.min(sm,min); }out.printLine(min); } } 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); } } 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 & 15); c = read(); }while(!isSpaceChar(c));return (res * sgn);} 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 boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
0	public class A{ 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))); }} }
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.nextInt();  long k = in.nextInt(); if ( (k == 1)) {out.println(n); return ;} long[] a = in.nextLongArray(n); ArrayUtils.safeSort(a); Map<Long,Integer> map = new TreeMap<Long,Integer>(); for ( int i = 0;(i < n);i++) {map.put(a[i],i); } int answer = 0;  boolean[] visited = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !visited[i]) {visited[i] = true; int count = 1;  long cur = a[i]; while(true){cur *= k; Integer index = map.get(cur); if ( (index == null)) break; visited[index] = true; count++; }answer += NumberUtils.upDiv(count,2); } }out.println(answer); } } 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 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 & 15); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public long[] nextLongArray( int count){ long[] result = new long[count]; for ( int i = 0;(i < count);i++) {result[i] = nextLong(); }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 println( int i){ writer.println(i); } public void close(){ writer.close(); } }
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); } } }
3	public class Main implements Runnable{ boolean multiiple = false; void solve()throws Exception { int n = sc.nextInt();  ArrayList<Integer> list = new ArrayList<>(); for ( int i = 0;(i < n);i++) list.add(sc.nextInt()); Collections.sort(list); int ans = 0; while(!list.isEmpty()){ans++; int next = list.get(0); for ( int i = (list.size() - 1);(i >= 1);i--) {if ( ((list.get(i) % next) == 0)) list.remove(i); }list.remove(0); }System.out.println(ans); } public static void main( String[] args)throws Throwable { Thread thread = new Thread(null,new Main(),"",(1 << 26)); thread.start(); thread.join(); if ( (Main.uncaught != null)) {throw (Main.uncaught);} } static Throwable uncaught ; BufferedReader in ; FastScanner sc ; PrintWriter out ; } 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 int nextInt()throws Exception { return Integer.parseInt(nextToken());} }
2	public class Codeforces{ 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 input = new FastReader();  long n = input.nextLong();  long K = input.nextLong();  long root = (long)Math.sqrt(((8 * (K + n)) + 9)); if ( ((root * root) != ((8 * (K + n)) + 9))) {root++; if ( ((root * root) != ((8 * (K + n)) + 9))) root -= 2; } System.out.println((n - ((root - 3) / 2))); } }
3	public class Ideone{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n ,i ,j ,k ,temp ; n = ni(br.readLine()); int[] a = nia(br); Arrays.sort(a); int c = 0; for ( i = 0;(i < n);i++) {if ( (a[i] > 0)) {c++; temp = a[i]; for ( j = (i + 1);(j < n);j++) {if ( ((a[j] % temp) == 0)) a[j] = 0; }} }System.out.println(c); } static int[] nia( BufferedReader br)throws Exception { String sa[] = br.readLine().split(" ");  int[] a = new int[sa.length]; for ( int i = 0;(i < sa.length);i++) {a[i] = ni(sa[i]); }return a;} static int ni( String s){ return Integer.parseInt(s);} }
0	public class A{ public static void main( String[] args){ Account acnt = new Account(); acnt.solve(); acnt.print(); } } class Account{ Account(){ Scanner scr = new Scanner(System.in); n = scr.nextInt(); } void solve(){ if ( (n > 0)) {ans = n; } else { int nn = -n;  int ans1 = (nn / 10);  int ans2 = ((nn % 10) + ((nn / 100) * 10)); if ( (ans1 < ans2)) {ans = -ans1; } else {ans = -ans2; }}} void print(){ System.out.println(ans); } int ans ; int n ; }
6	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNextInt()){ int n = sc.nextInt();  long m = sc.nextInt();  boolean edge[][] = new boolean[n][n];  long dp[][] = new long[(1 << n)][n]; for ( long i = 1;(i <= m);++i) { int u = sc.nextInt();  int v = sc.nextInt(); --u; --v; edge[u][v] = edge[v][u] = true; }for ( int i = 0;(i < n);++i) {dp[(1 << i)][i] = 1; } long res = 0; for ( int i = 1;(i < (1 << n));++i) { int first = cal(i); for ( int j = 0;(j < n);++j) {if ( (dp[i][j] == 0)) {continue;} for ( int k = first;(k < n);++k) {if ( ((j == k) || !edge[j][k])) {continue;} if ( ((k == first) && ((i & (1 << k)) != 0))) {res += dp[i][j]; } if ( ((i & (1 << k)) == 0)) {dp[(i | (1 << k))][k] += dp[i][j]; } }}}res -= m; System.out.println((res / 2)); }} public static int cal( int x){ int ord = 0; while(true){if ( ((x & (1 << ord)) != 0)) {break;} ++ord; }return ord;} }
1	public class Main implements Runnable{ public void _main()throws IOException { int n = nextInt();  int[] a = new int[n];  String s = next(); for ( int i = 0;(i < n);i++) a[i] = ((s.charAt(i) == 'H')?1:0); int res = (10 * n); for ( int i = 0;(i < n);i++) { int[] b = new int[n]; for ( int j = 0;(j < n);j++) b[j] = a[((i + j) % n)]; res = Math.min(res,solve(b,0)); res = Math.min(res,solve(b,1)); }out.print(res); } private int solve( int[] a, int x){ int n = a.length;  int j ; for ( j = (n - 1);(j >= 0);j--) if ( (a[j] == x)) break; if ( (a[j] != x)) return 0; int res = 0; for ( int i = 0;(i < j);i++) if ( (a[i] != x)) {--j; while(((j >= i) && (a[j] != x)))--j; ++res; } 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 int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args){ Locale.setDefault(Locale.UK); new Thread(new Main()).start(); } }
5	public class Solution{ void solve()throws Exception { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); ArrayList<Integer> list = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) list.add(a[i]); Collections.shuffle(list); int[] b = new int[n]; for ( int i = 0;(i < n);i++) b[i] = list.get(i); Arrays.sort(b); int cnt = 0; for ( int i = 0;(i < n);i++) if ( (a[i] != b[i])) cnt++; if ( (cnt <= 2)) System.out.println("YES"); else System.out.println("NO"); } private void mySort( int[] a){ if ( (a.length <= 1)) return ; int n = a.length;  int[] left = new int[(n / 2)];  int[] right = new int[(n - (n / 2))]; for ( int i = 0;(i < n);i++) if ( (i < left.length)) left[i] = a[i]; else right[(i - left.length)] = a[i]; mySort(left); mySort(right); int i = 0;  int j = 0; while(((i < left.length) || (j < right.length))){if ( (i == left.length)) a[(i + j)] = right[j++]; else if ( (j == right.length)) a[(i + j)] = left[i++]; else if ( (left[i] < right[j])) a[(i + j)] = left[i++]; else a[(i + j)] = right[j++]; }} BufferedReader reader ; PrintWriter writer ; StringTokenizer stk ; void run()throws Exception { reader = new BufferedReader(new InputStreamReader(System.in)); stk = null; solve(); reader.close(); } int nextInt()throws Exception { return Integer.parseInt(nextToken());} String nextLine()throws Exception { return reader.readLine();} String nextToken()throws Exception { if ( ((stk == null) || !stk.hasMoreTokens())) {stk = new StringTokenizer(nextLine()); return nextToken();} return stk.nextToken();} public static void main( String[] args)throws Exception { new Solution().run(); } }
4	public class Round568G{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni(),T = ni();  int mod = 1000000007;  int[][] a = new int[3][n];  int[] ap = new int[3]; for ( int i = 0;(i < n);i++) { int t = ni();  int k = (ni() - 1); a[k][ap[k]++] = t; }for ( int i = 0;(i < 3);i++) a[i] = Arrays.copyOf(a[i],ap[i]); long[][][][] com = new long[3][(ap[0] + 2)][(ap[1] + 2)][(ap[2] + 2)]; com[0][1][0][0] = com[1][0][1][0] = com[2][0][0][1] = 1; for ( int i = 0;(i <= ap[0]);i++) {for ( int j = 0;(j <= ap[1]);j++) {for ( int k = 0;(k <= ap[2]);k++) {for ( int u = 0;(u < 3);u++) {if ( (u != 0)) {com[0][(i + 1)][j][k] += com[u][i][j][k]; if ( (com[0][(i + 1)][j][k] >= mod)) com[0][(i + 1)][j][k] -= mod; } if ( (u != 1)) {com[1][i][(j + 1)][k] += com[u][i][j][k]; if ( (com[1][i][(j + 1)][k] >= mod)) com[1][i][(j + 1)][k] -= mod; } if ( (u != 2)) {com[2][i][j][(k + 1)] += com[u][i][j][k]; if ( (com[2][i][j][(k + 1)] >= mod)) com[2][i][j][(k + 1)] -= mod; } }}}} int[][] fif = enumFIF(200,mod);  long[][][] dp = new long[3][][]; for ( int i = 0;(i < 3);i++) { int s = 0; for ( int v :a[i]) s += v; dp[i] = new long[(ap[i] + 1)][(s + 1)]; dp[i][0][0] = 1; for ( int v :a[i]) {for ( int j = (ap[i] - 1);(j >= 0);j--) {for ( int k = (s - v);(k >= 0);k--) {dp[i][(j + 1)][(k + v)] += dp[i][j][k]; if ( (dp[i][(j + 1)][(k + v)] >= mod)) dp[i][(j + 1)][(k + v)] -= mod; }}}} long[][][] con = new long[(ap[0] + 1)][(ap[1] + 1)][2501]; for ( int i = 0;(i <= ap[0]);i++) {for ( int j = 0;(j <= ap[1]);j++) {for ( int k = 0;(k < dp[0][i].length);k++) {if ( (dp[0][i][k] == 0)) continue; for ( int l = 0;(l < dp[1][j].length);l++) {con[i][j][(k + l)] += (dp[0][i][k] * dp[1][j][l]); con[i][j][(k + l)] %= mod; }}}} long ans = 0; for ( int i = 0;(i <= ap[0]);i++) {for ( int j = 0;(j <= ap[1]);j++) {for ( int k = 0;(k <= ap[2]);k++) { long base = ((((((((com[0][i][j][k] + com[1][i][j][k]) + com[2][i][j][k]) * fif[0][i]) % mod) * fif[0][j]) % mod) * fif[0][k]) % mod);  long ls = 0; for ( int l = 0;(l <= T);l++) {if ( ((T - l) < dp[2][k].length)) {ls += (con[i][j][l] * dp[2][k][(T - l)]); ls %= mod; } }ans += (base * ls); ans %= mod; }}}out.println(ans); } public static int[][] enumFIF( int n, int mod){ int[] f = new int[(n + 1)];  int[] invf = new int[(n + 1)]; f[0] = 1; for ( int i = 1;(i <= n);i++) {f[i] = (int)(((long)f[(i - 1)] * i) % mod); } long a = f[n];  long b = mod;  long p = 1,q = 0; while((b > 0)){ long c = (a / b);  long d ; d = a; a = b; b = (d % b); d = p; p = q; q = (d - (c * q)); }invf[n] = (int)((p < 0)?(p + mod):p); for ( int i = (n - 1);(i >= 0);i--) {invf[i] = (int)(((long)invf[(i + 1)] * (i + 1)) % mod); }return new int[][]{f,invf};} 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 Round568G().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 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();  Solution sol = new Solution(out); sol.solution(n,m); }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; } public void solution( int n, int mod){ long res = 0;  long ncr[][] = new long[501][501];  long pow[] = new long[501]; pow[0] = 1; for ( int i = 1;(i < pow.length);i++) {pow[i] = ((pow[(i - 1)] * 2) % mod); }ncr[0][0] = 1; for ( int i = 1;(i < ncr.length);i++) {ncr[i][0] = 1; for ( int j = 1;(j < ncr[0].length);j++) {ncr[i][j] = ((ncr[(i - 1)][j] + ncr[(i - 1)][(j - 1)]) % mod); }} long dp[][] = new long[(n + 1)][(n + 1)]; for ( int i = 1;(i < dp.length);i++) {dp[i][i] = pow[(i - 1)]; for ( int j = 1;(j < i);j++) {for ( int k = 1;(k < i);k++) {if ( ((((i - k) - 1) >= 1) && (j >= k))) {dp[i][j] = (dp[i][j] + (dp[((i - k) - 1)][(j - k)] * ((ncr[j][k] * pow[(k - 1)]) % mod))); dp[i][j] %= mod; } }}}for ( int i = 1;(i <= n);i++) {res += dp[n][i]; res %= mod; }out.println(res); } }
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 "); } }
2	public class ReallyBigNumbers{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  long s = scan.nextLong();  long ans = 0;  long l = 0;  long r = n; while((l <= r)){ long mid = (l + ((r - l) / 2)); if ( isReallyBig(mid,s)) {ans = mid; r = (mid - 1); } else l = (mid + 1); }if ( (ans == 0)) System.out.println(ans); else System.out.println(((n - ans) + 1)); } static boolean isReallyBig( long m, long s){ String x = (m + "");  long sum = 0; for ( int i = 0;(i < x.length());i++) {sum += (x.charAt(i) - '0'); }if ( ((m - sum) >= s)) return true; return false;} }
5	public class Main{ private void solve(){ int n = in.nextInt();  int k = in.nextInt(); final int[] p = new int[n]; final int[] t = new int[n]; for ( int i = 0;(i < n);++i) {p[i] = in.nextInt(); t[i] = in.nextInt(); } Integer[] ord = new Integer[n]; for ( int i = 0;(i < n);++i) ord[i] = i; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < (n - 1));++j) {if ( Less(ord[j],ord[(j + 1)],p,t)) { Integer tx = ord[j]; ord[j] = ord[(j + 1)]; ord[(j + 1)] = tx; } }}for ( int i = 0,j = 0;(i < n);i = j) {for ( j = i;(((j < n) && (p[ord[i]] == p[ord[j]])) && (t[ord[i]] == t[ord[j]]));++j) ; int first = (i + 1);  int second = j; if ( ((first <= k) && (k <= second))) {out.print((j - i)); return ;} }out.print(0); } private boolean Less( Integer i, Integer j, int[] p, int[] t){ return ((p[i] < p[j]) || ((p[i] == p[j]) && (t[i] > t[j])));} private void run(){ try{in = new FastScanner(); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); }catch (Exception e){ e.printStackTrace(); } } public static void main( String[] args){ new Main().run(); } FastScanner in ; PrintWriter out ; class FastScanner{ public BufferedReader reader ; private StringTokenizer tokenizer ; public FastScanner( String file){ try{reader = new BufferedReader(new FileReader(new File(file))); tokenizer = null; }catch (FileNotFoundException e){ e.printStackTrace(); } } public FastScanner(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; }catch (Exception e){ e.printStackTrace(); } } public String nextToken(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (Exception e){ e.printStackTrace(); } }return tokenizer.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} } }
5	public class VK2A{ public static void main( String[] args){ Scanner S = new Scanner(System.in);  int n = S.nextInt();  int a = S.nextInt();  int b = S.nextInt();  int[] A = new int[n]; for ( int i = 0;(i < n);i++) A[i] = S.nextInt(); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < ((n - i) - 1));j++) {if ( (A[j] < A[(j + 1)])) { int temp = A[j]; A[j] = A[(j + 1)]; A[(j + 1)] = temp; } }System.out.println((A[(a - 1)] - A[a])); } }
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());} }
0	public class A{ public static void main( String[] args)throws Throwable { new A().go(); } void go()throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] t = in.readLine().split(" ");  long a = Long.parseLong(t[0]),b = Long.parseLong(t[1]);  long mv = 0; while(((a > 1) && (b > 1))){if ( (a > b)) { long tt = a; a = b; b = tt; } mv += (b / a); b %= a; }System.out.println((mv + Math.max(a,b))); } }
3	public class Sample implements Runnable{ public static void solve(){ int n = i();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = i(); int temp = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[j] < a[i])) temp++; }} boolean even = (((temp % 2) == 0)?true:false);  int m = i(); while((m-- > 0)){ int l = i();  int r = i();  long tt = (long)(Math.floor(((r - l) + 1)) / 2); if ( ((tt % 2) == 1)) {if ( even) {out.println("odd"); even = false; } else {out.println("even"); even = true; }} else {if ( even) {out.println("even"); } else {out.println("odd"); }}}} public static void main( String[] args)throws IOException { new Thread(null,new Sample(),"whatever",(1 << 26)).start(); } static int gcd( int a, int b){ return ((a == 0)?b:gcd((b % a),a));} static long gcdExtended( long a, long b, long[] x){ if ( (a == 0)) {x[0] = 0; x[1] = 1; return b;} long[] y = new long[2];  long gcd = gcdExtended((b % a),a,y); x[0] = (y[1] - ((b / a) * y[0])); x[1] = y[0]; return gcd;} boolean findSum( int[] set, int n, long sum){ if ( (sum == 0)) return true; if ( ((n == 0) && (sum != 0))) return false; if ( (set[(n - 1)] > sum)) return findSum(set,(n - 1),sum); return (findSum(set,(n - 1),sum) || findSum(set,(n - 1),(sum - set[(n - 1)])));} public static long modPow( long base, long exp, long mod){ base = (base % mod); long result = 1; while((exp > 0)){if ( ((exp % 2) == 1)) {result = ((result * base) % mod); } base = ((base * base) % mod); exp = (exp >> 1); }return result;} static long[] fac ; static long[] inv ; static long mod = ((long)1e9 + 7); static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); 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 int[] nextIntArray( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }return a;} public long[] nextLongArray( int n){ long a[] = new long[n]; for ( int i = 0;(i < n);i++) {a[i] = nextLong(); }return a;} public String nextLine(){ int c = snext(); while(isSpaceChar(c))c = snext(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = snext(); }while(!isEndOfLine(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));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static int i(){ return sc.nextInt();} }
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(); } }
1	public class Main{ static private 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); }} }
3	public class C{ static char[] arr ; static int mod = ((int)1e9 + 7); static int[][] memo ; static int n ; static int solve( int idx, int depth){ if ( (idx == n)) {return ((depth == 0)?1:0);} if ( (memo[idx][depth] != -1)) return memo[idx][depth]; int ret = 0; if ( (arr[idx] == 's')) {if ( (depth > 0)) ret = (ret + solve(idx,(depth - 1))); ret = ((ret + solve((idx + 1),depth)) % mod); } if ( ((arr[idx] == 'f') || (arr[idx] == 'z'))) ret = ((ret + solve((idx + 1),(depth + 1))) % mod); return memo[idx][depth] = ret;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in); n = sc.nextInt(); arr = new char[n]; for ( int i = 0;(i < n);i++) arr[i] = sc.next().charAt(0); memo = new int[(n + 1)][(n + 1)]; for ( int[] x :memo) Arrays.fill(x,-1); System.out.println(solve(0,0)); } 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();} } }
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"); } }
5	public class main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int houses = sc.nextInt();  int size = sc.nextInt();  hizzy[] array = new hizzy[houses];  long total = 2; for ( int a = 0;(a < houses);a++) array[a] = new hizzy(sc.nextInt(),sc.nextInt()); Arrays.sort(array); for ( int a = 0;(a < (houses - 1));a++) { double L = (array[a].loc + (array[a].size / 2));  double R = (array[(a + 1)].loc - (array[(a + 1)].size / 2)); if ( ((R - L) > size)) total += 2; else if ( ((R - L) == size)) total++; }System.out.println(total); } } class hizzy implements Comparable{ double loc ; double size ; hizzy( double l, double s){ this.loc = l; this.size = s; } }
5	public class A{ public static void main( String[] args){ new A(new Scanner(System.in)); } public A( Scanner in){ int n = in.nextInt();  int t = in.nextInt();  int tt = (2 * t);  rect[] rs = new rect[n]; for ( int i = 0;(i < n);i++) rs[i] = new rect(in.nextInt(),in.nextInt()); Arrays.sort(rs); int res = 2; for ( int i = 1;(i < n);i++) { rect a = rs[(i - 1)];  rect b = rs[i];  int d = (b.p - a.p);  int dd = (a.t + b.t);  int tv = ((2 * d) - dd); if ( (tt == tv)) res++; if ( (tv > tt)) res += 2; }System.out.printf("%d%n",res); } } class rect implements Comparable<rect>{ int p ; int t ; public rect( int pp, int tt){ p = pp; t = tt; } }
3	public final class PythonIndentation{ public static void main( String[] args){ new PythonIndentation(System.in,System.out); } static class Solver implements Runnable{ static final int MOD = ((int)1e9 + 7); int n ; char[] arr ; long[][] dp ; BufferedReader in ; PrintWriter out ; void solve()throws IOException { n = Integer.parseInt(in.readLine()); arr = new char[n]; dp = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i < n);i++) arr[i] = in.readLine().charAt(0); for ( int i = 0;(i <= n);i++) Arrays.fill(dp[i],-1); dp[0][0] = 1; if ( (arr[0] == 's')) out.println(find(1,0)); else out.println(find(1,1)); } long find( int curr, int backIndents){ if ( (backIndents < 0)) return 0; if ( (curr == n)) return 1; if ( (dp[curr][backIndents] != -1)) return dp[curr][backIndents]; long ans ; if ( (arr[curr] == 's')) ans = find((curr + 1),backIndents); else ans = find((curr + 1),(backIndents + 1)); if ( (arr[(curr - 1)] != 'f')) ans = CMath.mod((ans + find(curr,(backIndents - 1))),MOD); return dp[curr][backIndents] = ans;} public Solver( BufferedReader in, PrintWriter out){ this.in = in; this.out = out; } } private PythonIndentation( 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),"PythonIndentation",(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(); }} }
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){ if ( (idx == n)) return ((((remSum == 0) && (remCnt1 == 0)) && (remCnt2 == 0))?1:0); if ( (((remSum < 0) || (remCnt1 < 0)) || (remCnt2 < 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 ( (g[idx] == 1)) ans += dp2((idx + 1),(remCnt1 - 1),remCnt2,(remSum - t[idx])); else if ( (g[idx] == 2)) ans += dp2((idx + 1),remCnt1,(remCnt2 - 1),(remSum - t[idx])); return memo2[idx][remCnt1][remCnt2][remSum] = ans;} static private 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();} } }
1	public class CF903F{ static final int INF = 0x3f3f3f3f; static void fill( int[][][][] aa, int a){ for ( int h0 = 0;(h0 <= 4);h0++) for ( int h1 = 0;(h1 <= 4);h1++) for ( int h2 = 0;(h2 <= 4);h2++) for ( int h3 = 0;(h3 <= 4);h3++) aa[h0][h1][h2][h3] = a; } public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine());  int a1 = Integer.parseInt(st.nextToken());  int a2 = Integer.parseInt(st.nextToken());  int a3 = Integer.parseInt(st.nextToken());  int a4 = Integer.parseInt(st.nextToken());  int[] aa = new int[10]; aa[0] = aa[1] = aa[2] = aa[3] = a1; aa[4] = aa[5] = aa[6] = a2; aa[7] = aa[8] = a3; aa[9] = a4; int[][] ww = new int[10][4]; ww[0][0] = 1; ww[1][1] = 1; ww[2][2] = 1; ww[3][3] = 1; ww[4][0] = ww[4][1] = 2; ww[5][1] = ww[5][2] = 2; ww[6][2] = ww[6][3] = 2; ww[7][0] = ww[7][1] = ww[7][2] = 3; ww[8][1] = ww[8][2] = ww[8][3] = 3; ww[9][0] = ww[9][1] = ww[9][2] = ww[9][3] = 4; char[][] cc = new char[4][(n + 8)]; for ( int k = 0;(k < 4);k++) { char[] c_ = cc[k]; br.readLine().getChars(0,n,c_,4); c_[0] = c_[1] = c_[2] = c_[3] = c_[(n + 4)] = c_[(n + 5)] = c_[(n + 6)] = c_[(n + 7)] = '.'; } int[][][][] dp = new int[5][5][5][5];  int[][][][] dq = new int[5][5][5][5]; fill(dp,INF); dp[4][4][4][4] = 0; int[] hh = new int[4]; for ( int i = 0;(i < (n + 4));i++) {for ( int h0 = 0;(h0 <= 4);h0++) for ( int h1 = 0;(h1 <= 4);h1++) for ( int h2 = 0;(h2 <= 4);h2++) for ( int h3 = 0;(h3 <= 4);h3++) for ( int s = 0;(s < 10);s++) {hh[0] = h0; hh[1] = h1; hh[2] = h2; hh[3] = h3; for ( int k = 0;(k < 4);k++) { int h = ww[s][k]; if ( (hh[k] < h)) {while(((h < 4) && (cc[k][(i + h)] == '.')))h++; hh[k] = h; } } int x = (dp[h0][h1][h2][h3] + aa[s]); if ( (dp[hh[0]][hh[1]][hh[2]][hh[3]] > x)) dp[hh[0]][hh[1]][hh[2]][hh[3]] = x; }fill(dq,INF); for ( int h0 = 1;(h0 <= 4);h0++) {hh[0] = (((h0 < 4) || (cc[0][(i + 4)] == '*'))?(h0 - 1):4); for ( int h1 = 1;(h1 <= 4);h1++) {hh[1] = (((h1 < 4) || (cc[1][(i + 4)] == '*'))?(h1 - 1):4); for ( int h2 = 1;(h2 <= 4);h2++) {hh[2] = (((h2 < 4) || (cc[2][(i + 4)] == '*'))?(h2 - 1):4); for ( int h3 = 1;(h3 <= 4);h3++) {hh[3] = (((h3 < 4) || (cc[3][(i + 4)] == '*'))?(h3 - 1):4); int x = dp[h0][h1][h2][h3]; if ( (dq[hh[0]][hh[1]][hh[2]][hh[3]] > x)) dq[hh[0]][hh[1]][hh[2]][hh[3]] = x; }}}} int[][][][] tmp = dp; dp = dq; dq = tmp; }System.out.println(dp[4][4][4][4]); } }
4	public class Main{ public static void main( String[] args)throws IOException { Scanner scan = new Scanner("input.txt");  PrintWriter out = new PrintWriter(new FileWriter("output.txt"));  int n ,m ; n = scan.nextInt(); m = scan.nextInt(); boolean visited[][] = new boolean[n][m];  int numOfStartingPoints ; numOfStartingPoints = scan.nextInt(); int resX = 0,resY = 0;  Queue<Point> que = new LinkedList<Point>(); for ( int i = 0;(i < numOfStartingPoints);i++) { int x = (scan.nextInt() - 1);  int y = (scan.nextInt() - 1); que.add(new Point(x,y)); visited[x][y] = true; }while(true){ Point current = que.poll(); if ( (current == null)) {break;} else {resX = current.x; resY = current.y; if ( (((current.x + 1) < n) && !visited[(current.x + 1)][current.y])) {que.add(new Point((current.x + 1),current.y)); visited[(current.x + 1)][current.y] = true; } if ( (((current.y + 1) < m) && !visited[current.x][(current.y + 1)])) {que.add(new Point(current.x,(current.y + 1))); visited[current.x][(current.y + 1)] = true; } if ( (((current.x - 1) >= 0) && !visited[(current.x - 1)][current.y])) {que.add(new Point((current.x - 1),current.y)); visited[(current.x - 1)][current.y] = true; } if ( (((current.y - 1) >= 0) && !visited[current.x][(current.y - 1)])) {que.add(new Point(current.x,(current.y - 1))); visited[current.x][(current.y - 1)] = true; } }}out.printf("%d %d\n",++resX,++resY); 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();} } }
1	public class B{ public B(){ int N = sc.nextInt();  int a = sc.nextInt();  int b = sc.nextInt();  int[] P = sc.nextInts();  TreeSet<Integer> S = new TreeSet<>();  Set<Integer> A = new HashSet<>();  Set<Integer> B = new HashSet<>(); for ( int p :P) S.add(p); while(!S.isEmpty()){ int q = S.first();  int x = (a - q),y = (b - q); if ( (S.contains(x) && S.contains(y))) {if ( (x > y)) {S.remove(q); S.remove(x); A.add(q); A.add(x); } else {S.remove(q); S.remove(y); B.add(q); B.add(y); }} else if ( S.contains(x)) {S.remove(q); S.remove(x); A.add(q); A.add(x); } else if ( S.contains(y)) {S.remove(q); S.remove(y); B.add(q); B.add(y); } else exit("NO"); } int[] res = new int[N]; for ( int i :rep(N)) if ( B.contains(P[i])) res[i] = 1; print("YES"); exit(res); } static private int[] rep( int N){ return rep(0,N);} static private int[] rep( int S, int T){ if ( (T <= S)) return new int[0]; int[] res = new int[(T - S)]; for ( int i = S;(i < T);++i) res[(i - S)] = i; return res;} static private final IOUtils.MyScanner sc = new IOUtils.MyScanner(); static private void print( Object o, Object... A){ IOUtils.print(o,A); } static private void exit( Object o, Object... A){ IOUtils.print(o,A); IOUtils.exit(); } public static void main( String[] args){ new B(); IOUtils.exit(); } }
5	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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, MyScanner in, PrintWriter out){ int n = in.nextInt();  int[] as = new int[n]; for ( int i = 0;(i < n);i++) as[i] = in.nextInt(); int[] sorted = as.clone(); ArrayUtils.sort(sorted); int diff = 0; for ( int i = 0;(i < n);i++) if ( (as[i] != sorted[i])) diff++; if ( (diff <= 2)) out.println("YES"); else out.println("NO"); } } class MyScanner{ private final InputStream in ; public MyScanner( InputStream in){ this.in = in; } public int nextInt(){ try{ int c = in.read(); if ( (c == -1)) return c; while(((c != '-') && ((c < '0') || ('9' < c)))){c = in.read(); if ( (c == -1)) return c; }if ( (c == '-')) return -nextInt(); int res = 0; do {res *= 10; res += (c - '0'); c = in.read(); }while((('0' <= c) && (c <= '9')));return res; }catch (Exception e){ return -1;} } }
5	public class TaskA{ class Contest implements Comparable<Contest>{ int problems ; int penalty ; Contest( int problems, int penalty){ this.problems = problems; this.penalty = penalty; } } void run(){ int n = nextInt(),k = nextInt();  Contest[] c = new Contest[n]; for ( int i = 0;(i < n);i++) {c[i] = new Contest(nextInt(),nextInt()); }Arrays.sort(c); int cproblem = c[(k - 1)].problems,cpenalty = c[(k - 1)].penalty;  int ans = 0; for ( int i = 0;(i < n);i++) {if ( ((c[i].problems == cproblem) && (c[i].penalty == cpenalty))) ans++; }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 TaskA().run(); } }
3	public class A{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int n = sc.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); int ans = 0;  boolean[] v = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( v[i]) continue; v[i] = true; ans++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) v[j] = true; }}System.out.println(ans); } }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n ,b = 0; n = in.nextInt(); if ( ((n % 2) == 0)) {b = (n + (n / 2)); System.out.println(b); } } }
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());} } }
3	public class TestClass{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int arr[] = new int[(n + 1)]; for ( int i = 0;(i < n);i++) arr[(i + 1)] = in.nextInt(); long sum[] = new long[(n + 1)]; for ( int i = 1;(i <= n);i++) sum[i] = (sum[(i - 1)] + arr[i]); long dp[] = new long[(n + 1)]; for ( int i = 1;(i <= n);i++) {for ( int j = i;((j > (i - m)) && (j >= 1));j--) { long val = (((sum[i] - sum[(j - 1)]) + dp[(j - 1)]) - k); dp[i] = Math.max(dp[i],val); }} long max = 0; for ( int i = 1;(i <= n);i++) max = Math.max(max,dp[i]); System.out.println(max); } }
0	public class MainA{ static StringTokenizer ST ; static BufferedReader IN ; static BufferedWriter OUT ; {IN = new BufferedReader(new InputStreamReader(System.in)); OUT = new BufferedWriter(new OutputStreamWriter(System.out)); }public static void main( String[] args)throws IOException { pl("25"); cAll(); } static String nlnt()throws IOException { String l ; while((((l = IN.readLine()) != null) && ((l = l.trim()) == 0))){}return l;} static void pl( String s)throws IOException { OUT.write(s); OUT.newLine(); } static void pl( char c)throws IOException { OUT.write(c); OUT.newLine(); } static void pl( char[] s)throws IOException { OUT.write(s); OUT.newLine(); } static void pl()throws IOException { OUT.newLine(); } static void cAll()throws IOException { IN.close(); OUT.close(); } }
6	public class E{ static Scanner sc = new Scanner(System.in); static int N ; static double[][] p ; static DecimalFormat format = new DecimalFormat("0.000000"); public static void main( String[] args)throws Exception { N = sc.nextInt(); p = new double[N][N]; for ( int i = 0;(i < N);++i) {for ( int j = 0;(j < N);++j) {p[i][j] = sc.nextDouble(); }} double[] memo = new double[(1 << N)]; memo[(memo.length - 1)] = 1; for ( int i = N;(i >= 2);--i) { int[] live = new int[N]; for ( int j = 0;(j < i);++j) {live[((N - 1) - j)] = 1; }do { int n = toInt(live);  double norm = ((2.0 / i) / (i - 1)); for ( int f1 = 0;(f1 < N);++f1) {if ( (live[f1] == 0)) continue; for ( int f2 = (f1 + 1);(f2 < N);++f2) {if ( (live[f2] == 0)) continue; memo[(n - (1 << f1))] += ((memo[n] * p[f2][f1]) * norm); memo[(n - (1 << f2))] += ((memo[n] * p[f1][f2]) * norm); }}}while(nextPermutation(live));}for ( int i = 0;(i < N);++i) {System.out.print(format.format(memo[(1 << i)])); if ( (i < (N - 1))) {System.out.print(" "); } }} static int toInt( int[] a){ int ret = 0; for ( int i = 0;(i < N);++i) {ret += ((1 << i) * a[i]); }return ret;} public static boolean nextPermutation( int[] a){ for ( int i = (a.length - 1);(i > 0);--i) {if ( (a[(i - 1)] < a[i])) { int swapIndex = find(a[(i - 1)],a,i,(a.length - 1));  int temp = a[swapIndex]; a[swapIndex] = a[(i - 1)]; a[(i - 1)] = temp; Arrays.sort(a,i,a.length); return true;} }return false;} static private int find( int dest, int[] a, int s, int e){ if ( (s == e)) {return s;} int m = (((s + e) + 1) / 2); return ((a[m] <= dest)?find(dest,a,s,(m - 1)):find(dest,a,m,e));} }
2	public class A{ public static BufferedReader in ; public static PrintWriter out ; public static void main( String[] args)throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); boolean showLineError = true; if ( showLineError) {solve(); out.close(); } else {try{solve(); }catch (Exception e){ } finally{out.close(); }}} static private void solve()throws IOException { String[] line = in.readLine().split(" ");  String l = Long.toBinaryString(Long.parseLong(line[0]));  String r = Long.toBinaryString(Long.parseLong(line[1])); if ( l.equals(r)) {out.println(0); return ;} int dif = (r.length() - l.length()); for ( int i = 0;(i < dif);i++) l = ("0" + l); int index = 0; for ( ;(index < r.length());index++) {if ( (l.charAt(index) != r.charAt(index))) break; } long ret = 1; for ( int i = 0;(i < (l.length() - index));i++) ret += ret; ret--; out.println(ret); } }
0	public class p481a{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long l = sc.nextLong();  long r = sc.nextLong(); if ( ((r - l) <= 1)) {System.out.println("-1"); } else if ( ((r - l) >= 3)) {if ( ((l % 2) == 0)) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else {System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); }} else { long g1 = GCD(l,(l + 1));  long g2 = GCD((l + 1),(l + 2));  long g3 = GCD(l,r); if ( (((g1 == 1) && (g2 == 1)) && (g3 != 1))) {System.out.println(((((l + " ") + (l + 1)) + " ") + r)); } else {System.out.println("-1"); }}} public static long GCD( long a, long b){ if ( (b == 0)) return a; return GCD(b,(a % b));} }
4	public class C1523{ public static void print( Stack<Integer> st, PrintWriter pw){ for ( int i = 0;(i < st.size());i++) {pw.print(st.get(i)); if ( (i != (st.size() - 1))) {pw.print("."); } }pw.println(); } public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  int[] arr = sc.nextIntArr(n);  Stack<Integer> st = new Stack<Integer>(); st.add(arr[0]); print(st,pw); for ( int i = 1;(i < n);i++) {if ( (arr[i] == 1)) {st.add(arr[i]); } else {while((st.peek() != (arr[i] - 1))){st.pop(); }st.pop(); st.add(arr[i]); }print(st,pw); }}pw.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( FileReader f){ br = new BufferedReader(f); } 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 int[] nextIntArr( int n)throws IOException { int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(next()); }return arr;} } }
6	public class Main{ static private FastScanner sc = new FastScanner(); static private long mod = 1000000007; public static void main( String[] args){ int n = sc.nextInt();  int T = sc.nextInt();  int[] t = new int[n];  int[] g = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = sc.nextInt(); g[i] = (sc.nextInt() - 1); } long[][][] dp = new long[(T + 1)][3][(1 << 15)]; for ( int i = 1;(i <= T);i++) {for ( int j = 0;(j < n);j++) {if ( ((i - t[j]) == 0)) {dp[i][g[j]][(1 << j)] = ((dp[i][g[j]][(1 << j)] + 1) % mod); } else if ( ((i - t[j]) > 0)) {for ( int k = 0;(k < (1 << 15));k++) {if ( (((k >> j) & 1) == 1)) {continue;} dp[i][g[j]][(k + (1 << j))] = (((dp[i][g[j]][(k + (1 << j))] + dp[(i - t[j])][((g[j] + 1) % 3)][k]) + dp[(i - t[j])][((g[j] + 2) % 3)][k]) % mod); }} }} long ans = 0; for ( int j = 0;(j < 3);j++) {for ( int k = 0;(k < (1 << 15));k++) {ans = ((ans + dp[T][j][k]) % mod); }}System.out.println(ans); } static long power( long m, long n){ if ( (n == 0)) {return 1;} else if ( (n == 1)) {return m;} else if ( ((n % 2) == 0)) { long s = power(m,(n / 2)); return (((s % mod) * (s % mod)) % mod);} else {return (((m % mod) * (power(m,(n - 1)) % mod)) % mod);}} 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;} static private boolean isPrintableChar( int c){ return ((33 <= c) && (c <= 126));} private void skipUnprintable(){ while((hasNextByte() && !isPrintableChar(buffer[ptr])))ptr++; } public boolean hasNext(){ skipUnprintable(); 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 int nextInt(){ return Integer.parseInt(next());} } }
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(); } }
6	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] parsedString ;  int objectNum = 0;  int xStart = 0;  int yStart = 0; parsedString = in.readLine().split(" "); xStart = Integer.parseInt(parsedString[0]); yStart = Integer.parseInt(parsedString[1]); objectNum = Integer.parseInt(in.readLine()); int[] xLocs = new int[(objectNum + 1)];  int[] yLocs = new int[(objectNum + 1)];  int[] bitMasks = new int[(1 << objectNum)]; Arrays.fill(bitMasks,-1); int[] previous = new int[(1 << objectNum)]; xLocs[objectNum] = xStart; yLocs[objectNum] = yStart; for ( int i = 0;(i < objectNum);i++) {parsedString = in.readLine().split(" "); xLocs[i] = Integer.parseInt(parsedString[0]); yLocs[i] = Integer.parseInt(parsedString[1]); } int[][] times = new int[(objectNum + 1)][(objectNum + 1)]; for ( int i = 0;(i <= objectNum);i++) {for ( int j = 0;(j <= objectNum);j++) {times[i][j] = times[j][i] = (((xLocs[i] - xLocs[j]) * (xLocs[i] - xLocs[j])) + ((yLocs[i] - yLocs[j]) * (yLocs[i] - yLocs[j]))); }}bitMasks[0] = 0; for ( int i = 0;(i < (1 << objectNum));i++) {if ( (bitMasks[i] == -1)) {} else {for ( int j = 0;(j < objectNum);j++) {if ( (((1 << j) & i) == 0)) { int curState = ((1 << j) | i);  int curTime = (bitMasks[i] + (2 * times[objectNum][j])); if ( ((bitMasks[curState] == -1) || (curTime < bitMasks[curState]))) {bitMasks[curState] = curTime; previous[curState] = i; } for ( int k = 0;(k < objectNum);k++) {if ( (((1 << k) & curState) == 0)) { int kState = ((1 << k) | curState);  int kTime = (((bitMasks[i] + times[objectNum][j]) + times[j][k]) + times[k][objectNum]); if ( ((bitMasks[kState] == -1) || (kTime < bitMasks[kState]))) {bitMasks[kState] = kTime; previous[kState] = i; } } }break;} }}} int finalState = ((1 << objectNum) - 1); System.out.println(bitMasks[finalState]); Deque<Integer> outputQ = new ArrayDeque<Integer>(); outputQ.add(0); int curState = finalState; while((curState > 0)){ int difference = (curState ^ previous[curState]);  int firstItem = -1;  int secondItem = -1; for ( int i = 0;(i < objectNum);i++) {if ( (((1 << i) & difference) > 0)) {secondItem = firstItem; firstItem = i; } }if ( (secondItem != -1)) {outputQ.add((firstItem + 1)); outputQ.add((secondItem + 1)); outputQ.add(0); } else {outputQ.add((firstItem + 1)); outputQ.add(0); }curState = previous[curState]; }System.out.print(outputQ.removeLast()); while(!outputQ.isEmpty()){System.out.print(" "); System.out.print(outputQ.removeLast()); }} }
1	public class p2{ static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static private String ss()throws IOException { return br.readLine();} static private int stoi( String x){ return Integer.parseInt(x);} static private int si()throws IOException { return stoi(ss());} public static void main(final String[] args)throws IOException { Set<Integer> poss = new HashSet<>(); for ( int i = 1;((2 * (i * i)) <= 1000000000);++i) {poss.add((2 * (i * i))); poss.add((4 * (i * i))); } int t = si(); for ( int i = 0;(i < t);++i) { int n = si(); if ( poss.contains(n)) System.out.println("YES"); else System.out.println("NO"); }} }
4	public class BetaRound35_C implements Runnable{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws IOException { 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 BetaRound35_C()).start(); } void solve()throws IOException { int n = readInt();  int m = readInt();  int k = readInt();  Queue<Point> q = new ArrayDeque<Point>();  boolean[][] visited = new boolean[(n + 2)][(m + 2)]; for ( int j = 0;(j < (m + 2));j++) {visited[0][j] = true; visited[(n + 1)][j] = true; }for ( int i = 0;(i < (n + 2));i++) {visited[i][0] = true; visited[i][(m + 1)] = true; }for ( int i = 0;(i < k);i++) { int x = readInt();  int y = readInt(); q.add(new Point(x,y)); visited[x][y] = true; } Point p = null; while(!q.isEmpty()){p = q.poll(); int x = p.x,y = p.y; if ( !visited[(x + 1)][y]) {q.add(new Point((x + 1),y)); visited[(x + 1)][y] = true; } if ( !visited[(x - 1)][y]) {q.add(new Point((x - 1),y)); visited[(x - 1)][y] = true; } if ( !visited[x][(y + 1)]) {q.add(new Point(x,(y + 1))); visited[x][(y + 1)] = true; } if ( !visited[x][(y - 1)]) {q.add(new Point(x,(y - 1))); visited[x][(y - 1)] = true; } }out.print(((p.x + " ") + p.y)); } }
5	public class TaskA implements Runnable{ private InputReader in ; private PrintWriter out ; public static void main( String[] args){ new Thread(new TaskA()).start(); } public TaskA(){ in = new InputReader(System.in); out = new PrintWriter(System.out); } static private 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);} 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))){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();} } }
4	public class Main{ static int[][] l ,r ,u ,d ; static int[][][] dist ; static int inf = Integer.MAX_VALUE; public static void process()throws IOException { int n = ni();  int m = ni();  int k = ni(); dist = new int[n][m][((k / 2) + 1)]; l = new int[n][m]; r = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < (m - 1));j++) l[i][j] = r[i][(j + 1)] = ni(); u = new int[n][m]; d = new int[n][m]; for ( int i = 0;(i < (n - 1));i++) for ( int j = 0;(j < m);j++) d[i][j] = u[(i + 1)][j] = ni(); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) p("-1 "); pn(""); }return ;} k /= 2; for ( int kk = 1;(kk <= k);kk++) for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dist[i][j][kk] = inf; if ( (i != 0)) dist[i][j][kk] = Math.min(dist[i][j][kk],(dist[(i - 1)][j][(kk - 1)] + u[i][j])); if ( (i != (n - 1))) dist[i][j][kk] = Math.min(dist[i][j][kk],(dist[(i + 1)][j][(kk - 1)] + d[i][j])); if ( (j != 0)) dist[i][j][kk] = Math.min(dist[i][j][kk],(dist[i][(j - 1)][(kk - 1)] + r[i][j])); if ( (j != (m - 1))) dist[i][j][kk] = Math.min(dist[i][j][kk],(dist[i][(j + 1)][(kk - 1)] + l[i][j])); }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) p(((2 * dist[i][j][k]) + " ")); pn(""); }} static AnotherReader sc ; static PrintWriter out ; public static void main( String[] args)throws IOException { boolean oj = (System.getProperty("ONLINE_JUDGE") != null); if ( oj) {sc = new AnotherReader(); out = new PrintWriter(System.out); } else {sc = new AnotherReader(100); out = new PrintWriter("output.txt"); } int t = 1; while((t-- > 0)){process(); }out.flush(); out.close(); } static void pn( Object o){ out.println(o); } static void p( Object o){ out.print(o); } static int ni()throws IOException { return sc.nextInt();} static long nl()throws IOException { return sc.nextLong();} static long gcd( long a, long b)throws IOException { return ((b == 0)?a:gcd(b,(a % b)));} static int gcd( int a, int b)throws IOException { return ((b == 0)?a:gcd(b,(a % b)));} static int bit( long n)throws IOException { return ((n == 0)?0:(1 + bit((n & (n - 1)))));} static class AnotherReader{ BufferedReader br ; StringTokenizer st ; AnotherReader()throws FileNotFoundException{ br = new BufferedReader(new InputStreamReader(System.in)); } AnotherReader( int a)throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt")); } String next()throws IOException { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }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());} String nextLine()throws IOException { String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} } }
1	public class C{ public static void main( String[] args){ CIO io = new CIO(); try{ Csolver solver = new Csolver(io); solver.solve(); }finally{io.close(); }} } class Csolver{ CIO io ; public Csolver( CIO io){ this.io = io; } public void solve(){ int n = io.nextInt();  String input = io.next();  int[] count = new int[1000];  int pokemonsInRange = 0;  int answer = Integer.MAX_VALUE;  int a = 0;  int b = 0; for ( ;(b < n);b++) { char end = input.charAt(b); if ( (count[end] == 0)) {pokemonsInRange++; answer = Integer.MAX_VALUE; } count[end]++; while((count[input.charAt(a)] > 1)){count[input.charAt(a)]--; a++; }answer = Math.min(answer,((b - a) + 1)); }io.println(answer); } } class CIO extends PrintWriter{ private InputStreamReader r ; static private final int BUFSIZE = (1 << 15); private char[] buf ; private int bufc ; private int bufi ; private StringBuilder sb ; public CIO(){ super(new BufferedOutputStream(System.out)); r = new InputStreamReader(System.in); buf = new char[BUFSIZE]; bufc = 0; bufi = 0; sb = new StringBuilder(); } private void fillBuf()throws IOException { bufi = 0; bufc = 0; while((bufc == 0)){bufc = r.read(buf,0,BUFSIZE); if ( (bufc == -1)) {bufc = 0; return ;} }} private boolean pumpBuf()throws IOException { if ( (bufi == bufc)) {fillBuf(); } return (bufc != 0);} private boolean isDelimiter( char c){ return (((((c == ' ') || (c == '\t')) || (c == '\n')) || (c == '\r')) || (c == '\f'));} private void eatDelimiters()throws IOException { while(true){if ( (bufi == bufc)) {fillBuf(); if ( (bufc == 0)) throw (new RuntimeException("IO: Out of input.")); } if ( !isDelimiter(buf[bufi])) break; ++bufi; }} public String next(){ try{sb.setLength(0); eatDelimiters(); int start = bufi; while(true){if ( (bufi == bufc)) {sb.append(buf,start,(bufi - start)); fillBuf(); start = 0; if ( (bufc == 0)) break; } if ( isDelimiter(buf[bufi])) break; ++bufi; }sb.append(buf,start,(bufi - start)); return sb.toString(); }catch (IOException e){ throw (new RuntimeException("IO.next: Caught IOException."));} } public int nextInt(){ try{ int ret = 0; eatDelimiters(); boolean positive = true; if ( (buf[bufi] == '-')) {++bufi; if ( !pumpBuf()) throw (new RuntimeException("IO.nextInt: Invalid int.")); positive = false; } boolean first = true; while(true){if ( !pumpBuf()) break; if ( isDelimiter(buf[bufi])) {if ( first) throw (new RuntimeException("IO.nextInt: Invalid int.")); break;} first = false; if ( ((buf[bufi] >= '0') && (buf[bufi] <= '9'))) {if ( (ret < -214748364)) throw (new RuntimeException("IO.nextInt: Invalid int.")); ret *= 10; ret -= (int)(buf[bufi] - '0'); if ( (ret > 0)) throw (new RuntimeException("IO.nextInt: Invalid int.")); } else {throw (new RuntimeException("IO.nextInt: Invalid int."));}++bufi; }if ( positive) {if ( (ret == -2147483648)) throw (new RuntimeException("IO.nextInt: Invalid int.")); ret = -ret; } return ret; }catch (IOException e){ throw (new RuntimeException("IO.nextInt: Caught IOException."));} } }
1	public class C364C{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; static int n ; static int[] a ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); n = nextInt(); int ans = n,cc ,cur = 0; a = new int[52]; char[] c = next().toCharArray();  int l = 0,len = 0; for ( int i = 0;(i < n);++i) {if ( Character.isUpperCase(c[i])) {cur = ((26 + c[i]) - 'A'); } else cur = (c[i] - 'a'); if ( (a[cur] == 0)) {a[cur]++; len++; ans = ((i - l) + 1); } else {a[cur]++; for ( ;(l < i);++l) {if ( Character.isUpperCase(c[l])) {cc = ((26 + c[l]) - 'A'); } else cc = (c[l] - 'a'); if ( (a[cc] > 1)) {--a[cc]; } else break;}if ( (((i - l) + 1) < ans)) {ans = ((i - l) + 1); } }}pw.print(ans); pw.close(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
5	public class Main{ public static void main( String[] args)throws Exception { int n = nextInt();  int[] mas = new int[n]; for ( int i = 0;(i < n);i++) {mas[i] = nextInt(); }Arrays.sort(mas); if ( (mas[(n - 1)] == 1)) {for ( int i = 0;(i < (n - 1));i++) {out.print((1 + " ")); }out.println(2); out.flush(); exit(); } out.print("1 "); for ( int i = 0;(i < (n - 1));i++) {out.print((mas[i] + " ")); }out.println(); out.flush(); } static private StreamTokenizer in ; static private PrintWriter out ; static private BufferedReader inB ; static private boolean FILE = false; static private 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); }static private void println( Object o)throws Exception { out.println(o); out.flush(); } static private void exit( Object o)throws Exception { println(o); exit(); } static private void exit(){ System.exit(0); } static private final int INF = Integer.MAX_VALUE; static private final int MINF = Integer.MIN_VALUE; }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  List<Long> fi = new ArrayList<Long>(); fi.add((long)0); fi.add((long)1); while((fi.get((fi.size() - 1)) < n)){fi.add((fi.get((fi.size() - 1)) + fi.get((fi.size() - 2)))); } int last = (fi.size() - 1);  long z = (((last - 1) >= 0)?fi.get((last - 1)):0);  long y = (((last - 3) >= 0)?fi.get((last - 3)):0);  long x = (((last - 4) >= 0)?fi.get((last - 4)):0); if ( (((x + y) + z) < n)) x = 1; System.out.println(((((x + " ") + y) + " ") + z)); } }
6	public class cf1238e{ public static void main( String[] args)throws IOException { int n = rni(),m = ni(),cnt[][] = new int[m][m],dp[] = new int[(1 << m)],all = ((1 << m) - 1);  char[] s = rcha(); for ( int i = 1;(i < n);++i) {++cnt[(s[i] - 'a')][(s[(i - 1)] - 'a')]; ++cnt[(s[(i - 1)] - 'a')][(s[i] - 'a')]; }fill(dp,IBIG); dp[0] = 0; int cnt_bit[] = new int[(1 << m)],min_bit[] = new int[(1 << m)],d[][] = new int[(1 << m)][m]; for ( int mask = 1;(mask <= all);++mask) {cnt_bit[mask] = (1 + cnt_bit[(mask & (mask - 1))]); for ( int i = 0;(i < n);++i) {if ( ((mask & (1 << i)) > 0)) {min_bit[mask] = i; break;} }}for ( int mask = 1;(mask <= all);++mask) {for ( int i = 0;(i < m);++i) {d[mask][i] = (d[(mask ^ (1 << min_bit[mask]))][i] + cnt[i][min_bit[mask]]); }}for ( int mask = 0;(mask <= all);++mask) {for ( int i = 0;(i < m);++i) {if ( ((mask & (1 << i)) > 0)) {continue;} int pos = cnt_bit[mask],next = (mask | (1 << i)); dp[next] = min(dp[next],(dp[mask] + (pos * (d[mask][i] - d[(all ^ next)][i])))); }}prln(dp[all]); 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 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 List<List<Integer>> g( int n){ List<List<Integer>> g = new ArrayList<>(); for ( int i = 0;(i < n);++i) g.add(new ArrayList<>()); return g;} static List<Set<Integer>> sg( int n){ List<Set<Integer>> g = new ArrayList<>(); for ( int i = 0;(i < n);++i) g.add(new HashSet<>()); return g;} static void c( List<? extends Collection<Integer>> g, int u, int v){ g.get(u).add(v); g.get(v).add(u); } static void cto( List<? extends Collection<Integer>> g, int u, int v){ g.get(u).add(v); } static void r()throws IOException { input = new StringTokenizer(rline()); } static char[] rcha()throws IOException { return rline().toCharArray();} 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(); } }
2	public class Main{ static private final long MOD = 998244353; public static void main( String[] args)throws FileNotFoundException { InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int n = in.nextInt(); if ( (((n / 2) % 2) != 0)) {out.println("! -1"); out.flush(); out.close(); return ;} int[] a = new int[n]; Arrays.fill(a,Integer.MAX_VALUE); int l1 = 0;  int r1 = (l1 + (n / 2));  int l2 = r1;  int r2 = n;  int ans = -1; while(true){getValue(in,out,a,l1); getValue(in,out,a,r1); getValue(in,out,a,l2); getValue(in,out,a,(r2 % n)); if ( (a[l1] == a[l2])) {ans = l1; break;} if ( (a[r1] == a[(r2 % n)])) {ans = r1; break;} int m1 = ((l1 + r1) / 2); getValue(in,out,a,m1); int m2 = ((l2 + r2) / 2); getValue(in,out,a,m2); if ( (a[m1] == a[m2])) {ans = m1; break;} if ( (((a[l1] <= a[m1]) && (a[l2] <= a[m2])) || ((a[l1] >= a[m1]) && (a[l2] >= a[m2])))) {if ( ((a[l1] <= a[l2]) && (a[m1] >= a[m2]))) {r1 = m1; r2 = m2; continue;} if ( ((a[l1] >= a[l2]) && (a[m1] <= a[m2]))) {r1 = m1; r2 = m2; continue;} } if ( ((((a[l1] <= a[m1]) && (a[l2] >= a[m2])) && (a[l1] <= a[l2])) && (a[m1] >= a[m2]))) {r1 = m1; r2 = m2; continue;} if ( ((((a[l1] >= a[m1]) && (a[l2] <= a[m2])) && (a[l1] >= a[l2])) && (a[m1] <= a[m2]))) {r1 = m1; r2 = m2; continue;} l1 = m1; l2 = m2; }out.println(("! " + (ans + 1))); out.close(); } static private void getValue( InputReader in, PrintWriter out, int[] a, int l){ if ( (a[l] == Integer.MAX_VALUE)) {out.println(("? " + (l + 1))); out.flush(); a[l] = in.nextInt(); } } static int binSearchRight( List<Long> list, long key, int start, int end){ int l = (start - 1);  int r = end; while((l < (r - 1))){ int m = ((l + r) / 2); if ( (list.get(m) <= key)) {l = m; } else {r = m; }}return l;} static private 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());} private List<Integer>[] readGraph( int n, int m){ List<Integer>[] result = new ArrayList[n]; for ( int i = 0;(i < n);i++) {result[i] = new ArrayList<>(); }for ( int i = 0;(i < m);i++) { int u = (nextInt() - 1);  int v = (nextInt() - 1); result[u].add(v); result[v].add(u); }return result;} } }
0	public class a extends Thread{ BufferedReader bf ; PrintWriter out ; FastScanner in ; void solve()throws Exception { long n = in.nextLong();  long f[] = new long[2001];  int i = 2; f[0] = 0; f[1] = 1; while(true){f[i] = (f[(i - 1)] + f[(i - 2)]); if ( (f[i] < n)) i++; else break;}if ( (n == 1)) out.println("1 0 0"); else if ( (n == 0)) out.println("0 0 0"); else if ( ((i - 3) >= 0)) out.println(((((f[(i - 2)] + " ") + f[(i - 2)]) + " ") + f[(i - 3)])); else out.println("I'm too stupid to solve this problem"); } public static void main( String[] args){ new a().start(); } class FastScanner{ BufferedReader bf ; StringTokenizer st ; public FastScanner( BufferedReader bf){ this.bf = bf; } public String nextToken()throws Exception { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(bf.readLine()); }return st.nextToken();} public long nextLong()throws Exception { return Long.parseLong(nextToken());} } }
0	public class Main{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine()); System.out.println(("0 0 " + n)); } }
2	public class Solution{ long sum( long n){ long sm = 0; while((n != 0)){sm += (n % 10); n /= 10; }return sm;} void solve()throws IOException { long n = in.nextLong();  long s = in.nextLong();  long l = 0;  long h = (n + 1);  long ans = -1; while((l < h)){ long mid = ((l + h) / 2);  long sum = sum(mid); if ( ((mid - sum) >= s)) {ans = mid; h = mid; } else l = (mid + 1); }if ( (ans == -1)) out.println("0"); else out.println(((n + 1) - ans)); } class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); } public int nextInt()throws IOException { if ( st.hasMoreTokens()) return Integer.parseInt(st.nextToken()); else {st = new StringTokenizer(br.readLine()); return nextInt();}} public long nextLong()throws IOException { if ( st.hasMoreTokens()) return Long.parseLong(st.nextToken()); else {st = new StringTokenizer(br.readLine()); return nextLong();}} public String readLine()throws IOException { return br.readLine();} } FastScanner in = new FastScanner(); static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); public static void main( String[] args)throws IOException { new Solution().solve(); out.close(); } }
1	public class Main{ BufferedReader in ; StringTokenizer str = null; PrintWriter out ; private String next()throws Exception { while(((str == null) || !str.hasMoreElements()))str = new StringTokenizer(in.readLine()); return str.nextToken();} private int nextInt()throws Exception { return Integer.parseInt(next());} Map<Integer,Integer> map ; int[] p ,rank ; public void run()throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); map = new HashMap<Integer,Integer>(); int n = nextInt();  int x = nextInt(),y = nextInt();  int[] a = new int[n]; p = new int[n]; for ( int i = 1;(i < n);++i) p[i] = i; rank = new int[n]; for ( int i = 0;(i < n);++i) {a[i] = nextInt(); map.put(a[i],i); } int mask[] = new int[n]; for ( int i = 0;(i < n);++i) {if ( map.containsKey((x - a[i]))) {union(map.get((x - a[i])),i); mask[i] |= 1; } if ( map.containsKey((y - a[i]))) {union(map.get((y - a[i])),i); mask[i] |= 2; } } int[] b = new int[n]; Arrays.fill(b,3); for ( int i = 0;(i < n);++i) b[find(i)] &= mask[i]; for ( int i = 0;(i < n);++i) {if ( (b[i] == 0)) {out.println("NO"); out.close(); return ;} }out.println("YES"); for ( int i = 0;(i < n);++i) {out.print((((b[find(i)] & 1) == 1)?0:1)); if ( (i != (n - 1))) out.print(" "); }out.println(); out.close(); } private int find( int x){ if ( (x != p[x])) return p[x] = find(p[x]); return x;} private void union( int a, int b){ a = find(a); b = find(b); if ( (rank[a] < rank[b])) { int tmp = a; a = b; b = tmp; } p[b] = a; if ( (rank[a] == rank[b])) ++rank[a]; } public static void main( String[] args)throws Exception { new Main().run(); } }
0	public class A{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer tb ;  int n = Integer.parseInt(br.readLine());  int x = 0,y = 0; if ( ((n % 2) == 0)) {x = (n - 4); y = 4; } else {x = (n - 9); y = 9; }System.out.println(((x + " ") + y)); } }
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;} }}}} }
1	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{ public int[] parse( FastScanner in, int n){ String s = in.next();  int[] temp = new int[n]; for ( int i = 0;(i < n);++i) {temp[i] = (s.charAt(i) - 'A'); }return temp;} public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  int[] s = parse(in,n);  Map<Integer,TreeSet<Integer>> map = new HashMap<>(); for ( int i = 0;(i < n);++i) {if ( map.containsKey(s[i])) {map.get(s[i]).add(i); } else { TreeSet<Integer> temp = new TreeSet<>(); temp.add(i); map.put(s[i],temp); }} int ans = Integer.MAX_VALUE; for ( int i = 0;(i < n);++i) { int finalI = i; final Int integer = new Int(); integer.x = i; map.forEach((Integer x,TreeSet set)->{if ( (x != s[finalI])) { Integer temp = (Integer)set.higher(finalI); if ( (temp == null)) {integer.x = -2; } else {if ( (integer.x != -2)) integer.x = Integer.max(integer.x,temp); }} else {}}); if ( (integer.x != -2)) {ans = Integer.min(ans,((integer.x - i) + 1)); } }out.print(ans); } public class Int{ int x ; public Int(){ x = -1; } } } 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 inputStream){ br = new BufferedReader(new InputStreamReader(inputStream)); } 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());} } }
1	public class CTask{ public static void main( String[] args)throws IOException { MyInputReader in = new MyInputReader(System.in);  HashMap<Character,Integer> m = new HashMap<Character,Integer>();  int n = in.nextInt();  char[] s = in.next().toCharArray(); for ( int i = 0;(i < n);i++) {m.put(s[i],0); } int mx = m.size();  int start = 0;  int end = 0;  int min = Integer.MAX_VALUE;  int cur = 0; while((end < n)){while(((end < n) && (cur != mx))){ int x = m.get(s[end]); if ( (x == 0)) {cur += 1; } m.put(s[end],(x + 1)); end += 1; }while(((start <= end) && (cur == mx))){ int x = m.get(s[start]); m.put(s[start],(x - 1)); if ( ((x - 1) == 0)) {cur -= 1; } start += 1; }min = Math.min(min,((end - start) + 1)); }System.out.println(min); } static class MyInputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public MyInputReader( 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 N72A{ StreamTokenizer in ; PrintWriter out ; int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} public void init()throws Exception { boolean oj = (System.getProperty("ONLINE_JUDGE") != null);  Reader reader = (oj?new InputStreamReader(System.in):new FileReader(new File("input.txt")));  Writer writer = (oj?new OutputStreamWriter(System.out):new FileWriter(new File("output.txt"))); in = new StreamTokenizer(reader); out = new PrintWriter(writer); } public void solve()throws Exception { int n = nextInt(); out.print(((2 * n) - (n / 2))); } public void print()throws Exception { out.flush(); } public void run()throws Exception { init(); solve(); print(); } public static void main( String[] args)throws Exception { new N72A().run(); } }
4	public class Main{ public static int n ; public static int m ; public static int k ; public static int[][] right ; public static int[][] down ; public static int[][][] dp ; public static void recur( int i, int j, int depth){ if ( (dp[i][j][depth] != -1)) return ; int min = Integer.MAX_VALUE; if ( (j > 0)) {recur(i,(j - 1),(depth - 1)); min = Math.min(min,(dp[i][(j - 1)][(depth - 1)] + right[i][(j - 1)])); } if ( (j < (m - 1))) {recur(i,(j + 1),(depth - 1)); min = Math.min(min,(dp[i][(j + 1)][(depth - 1)] + right[i][j])); } if ( (i > 0)) {recur((i - 1),j,(depth - 1)); min = Math.min(min,(dp[(i - 1)][j][(depth - 1)] + down[(i - 1)][j])); } if ( (i < (n - 1))) {recur((i + 1),j,(depth - 1)); min = Math.min(min,(dp[(i + 1)][j][(depth - 1)] + down[i][j])); } dp[i][j][depth] = min; } public static void main( String[] args)throws java.lang.Exception { Scanner sc = new Scanner(System.in); n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); right = new int[n][(m - 1)]; down = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < (m - 1));j++) right[i][j] = sc.nextInt(); for ( int i = 0;(i < (n - 1));i++) for ( int j = 0;(j < m);j++) down[i][j] = sc.nextInt(); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);j++) System.out.print((-1 + " ")); System.out.println(); }} else {k /= 2; dp = new int[n][m][(k + 1)]; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < m);j++) for ( int z = 1;(z <= k);z++) dp[i][j][z] = -1; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < m);j++) recur(i,j,k); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);j++) System.out.print(((dp[i][j][k] * 2) + " ")); System.out.println(); }}} }
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(); } }
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(); } }
0	public class Main{ static private BufferedReader in ; static private BufferedWriter out ; public static void main( String[] args)throws NumberFormatException,IOException { boolean file = false; if ( file) in = new BufferedReader(new FileReader("input.txt")); else in = new BufferedReader(new InputStreamReader(System.in)); out = new BufferedWriter(new FileWriter("output.txt")); StringTokenizer tok ;  int n = Integer.parseInt(in.readLine()); if ( ((n % 2) == 0)) System.out.println(((4 + " ") + (n - 4))); else System.out.println(((9 + " ") + (n - 9))); } }
5	public class a{ private void solve()throws Exception { int n = nextInt(),t = nextInt();  int[] x = new int[n],a = new int[n]; for ( int i = 0;(i < n);++i) {x[i] = nextInt(); a[i] = nextInt(); }for ( int i = 0;(i < n);++i) for ( int j = 0;(j < (n - 1));++j) {if ( (x[j] > x[(j + 1)])) { int tmp = x[j]; x[j] = x[(j + 1)]; x[(j + 1)] = tmp; tmp = a[j]; a[j] = a[(j + 1)]; a[(j + 1)] = tmp; } } int res = 2; for ( int i = 1;(i < n);++i) { int betw = ((((x[i] - x[(i - 1)]) * 2) - a[i]) - a[(i - 1)]); if ( (betw == (t * 2))) ++res; else if ( (betw > (t * 2))) res += 2; }out.print(res); } public void run(){ try{solve(); }catch (Exception e){ NOO(e); } finally{out.close(); }} PrintWriter out ; BufferedReader in ; StringTokenizer St ; void NOO( Exception e){ e.printStackTrace(); System.exit(1); } int nextInt(){ return Integer.parseInt(nextToken());} String nextToken(){ while(!St.hasMoreTokens()){try{ String line = in.readLine(); St = new StringTokenizer(line); }catch (Exception e){ NOO(e); } }return St.nextToken();} private a( String name){ try{in = new BufferedReader(new FileReader((name + ".in"))); St = new StringTokenizer(""); out = new PrintWriter(new FileWriter((name + ".out"))); }catch (Exception e){ NOO(e); } } private a(){ try{in = new BufferedReader(new InputStreamReader(System.in)); St = new StringTokenizer(""); out = new PrintWriter(System.out); }catch (Exception e){ NOO(e); } } public static void main( String[] args){ new a().run(); } }
0	public class ProblemD{ public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  String[] data = s.readLine().split(" ");  double a = Double.valueOf(data[0]);  double v = Double.valueOf(data[1]);  String[] line = s.readLine().split(" ");  double l = Double.valueOf(line[0]);  double d = Double.valueOf(line[1]);  double w = Double.valueOf(line[2]);  double ans = solve(a,v,l,d,w); out.println(String.format("%.07f",ans)); out.flush(); } static private double solve( double a, double v, double l, double d, double w){ double maxSpeedAtD = (Math.sqrt(((2 * d) / a)) * a); if ( ((v <= w) || (maxSpeedAtD <= w))) { double maxSpeedAtL = (Math.sqrt(((2 * l) / a)) * a); if ( (maxSpeedAtL <= v)) {return Math.sqrt(((2 * l) / a));} else { double timeToMaxSpeed = (v / a);  double leftDist = (l - (((0.5 * a) * timeToMaxSpeed) * timeToMaxSpeed)); return (timeToMaxSpeed + (leftDist / v));}} double time = 0.0d;  double maxSpeedTime = Math.sqrt(((d / a) + ((w * w) / ((2 * a) * a))));  double maxSpeed = (maxSpeedTime * a); if ( (maxSpeed <= v)) {time = (maxSpeedTime + (((a * maxSpeedTime) - w) / a)); } else { double vtime = (((((2 * a) * d) + (w * w)) - ((2 * v) * v)) / ((2 * a) * v)); time = (((v / a) + vtime) + ((v - w) / a)); } double timeToV = ((v - w) / a);  double timeToVLen = ((timeToV * w) + ((0.5 * timeToV) * (v - w))); if ( (timeToVLen <= (l - d))) { double leftLen = ((l - d) - timeToVLen); time += (timeToV + (leftLen / v)); } else {time += ((-w + Math.sqrt(((w * w) + (a * ((2 * l) - (2 * d)))))) / a); }return time;} }
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--) { int count = Integer.bitCount(c); if ( (count <= 1)) 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++];} }
5	public class Village{ static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); public static void main( String[] args){ int n = in.nextInt(),t = (2 * in.nextInt()),h[][] = new int[n][2],ans = 2; for ( int i = 0;(i < n);i++) {h[i][0] = (2 * in.nextInt()); h[i][1] = in.nextInt(); }Arrays.sort(h,new Comp()); for ( int i = 1;(i < n);i++) { int d = ((h[i][0] - h[i][1]) - (h[(i - 1)][0] + h[(i - 1)][1])); if ( (d > t)) ans += 2; else if ( (d == t)) ans++; }System.out.println(ans); } static class Comp implements Comparator<int[]>{ } }
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(){ int t = in.nextInt(); for ( int i = 0;(i < t);i++) {out.println(work()); }out.flush(); } long mod = 1000000007; long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} int work(){ int n = in.nextInt();  int m = in.nextInt();  int[][] A = new int[n][m];  int[][] B = new int[n][m];  int[][] R = new int[m][2]; for ( int i = 0;(i < m);i++) R[i][1] = i; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {A[i][j] = in.nextInt(); R[j][0] = Math.max(R[j][0],A[i][j]); }}Arrays.sort(R,new Comparator<int[]>(){}); for ( int j = 0;(j < m);j++) { int index = R[j][1]; for ( int i = 0;(i < n);i++) {B[i][j] = A[i][index]; }}m = Math.min(n,m); int[][] dp = new int[m][(1 << n)];  int[][] rec = new int[m][(1 << n)]; for ( int j = 0;(j < m);j++) {for ( int s = 0;(s < n);s++) {for ( int i = 1;(i < (1 << n));i++) { int sum = 0; for ( int b = 0;(b < n);b++) {if ( (((1 << b) & i) > 0)) {sum += B[((b + s) % n)][j]; } }rec[j][i] = Math.max(sum,rec[j][i]); }}}for ( int j = 0;(j < m);j++) {for ( int i = 0;(i < (1 << n));i++) {if ( (j == 0)) {dp[j][i] = rec[j][i]; } else {for ( int p = i;(p < (1 << n));p++) {p = (p | i); dp[j][p] = Math.max(dp[j][p],(rec[j][i] + dp[(j - 1)][(p ^ i)])); }}}}return dp[(m - 1)][((1 << n) - 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());} }
2	public class P1195B{ public static void main( String[] args){ SimpleScanner scanner = new SimpleScanner(System.in);  PrintWriter writer = new PrintWriter(System.out);  int n = scanner.nextInt();  int k = scanner.nextInt();  int l = 0;  int r = n;  int ans = 0; while((l <= r)){ int eat = ((l + r) >> 1);  int lastPut = (n - eat);  long totalPut = (((long)(lastPut + 1) * lastPut) / 2);  long remain = (totalPut - eat); if ( (remain == k)) {ans = eat; break;} else if ( (remain > k)) l = (eat + 1); else r = (eat - 1); }writer.println(ans); writer.close(); } static private class SimpleScanner{ static private final int BUFFER_SIZE = 10240; private Readable in ; private CharBuffer buffer ; private boolean eof ; SimpleScanner( InputStream in){ this.in = new BufferedReader(new InputStreamReader(in)); buffer = CharBuffer.allocate(BUFFER_SIZE); buffer.limit(0); eof = false; } private char read(){ if ( !buffer.hasRemaining()) {buffer.clear(); int n ; try{n = in.read(buffer); }catch (IOException e){ n = -1; } if ( (n <= 0)) {eof = true; return '\0';} buffer.flip(); } return buffer.get();} void checkEof(){ if ( eof) throw (new NoSuchElementException()); } String next(){ char b ; do {b = read(); checkEof(); }while(Character.isWhitespace(b)); StringBuilder sb = new StringBuilder(); do {sb.append(b); b = read(); }while((!eof && !Character.isWhitespace(b)));return sb.toString();} int nextInt(){ return Integer.valueOf(next());} } }
4	public class a{ static BufferedReader br ; static PrintWriter pw ; static int N ,M ,K ; static ArrayList<Integer> graph[][] ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(br.readLine()); N = Integer.parseInt(st.nextToken()); M = Integer.parseInt(st.nextToken()); K = Integer.parseInt(st.nextToken()); if ( ((K % 2) == 1)) {for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {pw.print("-1 "); }pw.println(); }br.close(); pw.close(); return ;} graph = new ArrayList[N][M]; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {graph[i][j] = new ArrayList<Integer>(); }}for ( int i = 0;(i < N);i++) {st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < (M - 1));j++) { int w = Integer.parseInt(st.nextToken()); graph[i][j].add(w); }}for ( int i = 0;(i < N);i++) {graph[i][(M - 1)].add(0); }for ( int i = 0;(i < (N - 1));i++) {st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < M);j++) { int w = Integer.parseInt(st.nextToken()); graph[i][j].add(w); }}K /= 2; for ( int i = 0;(i < M);i++) graph[(N - 1)][i].add(0); long ans[][][] = new long[(K + 1)][N][M]; for ( int i = 0;(i < N);i++) {Arrays.fill(ans[0][i],0); }for ( int i = 1;(i <= K);i++) {for ( int x = 0;(x < N);x++) {for ( int y = 0;(y < M);y++) { long cur = (long)1e17; if ( (x < (N - 1))) {cur = (long)Math.min(cur,(graph[x][y].get(1) + ans[(i - 1)][(x + 1)][y])); } if ( (y < (M - 1))) {cur = (long)Math.min(cur,(graph[x][y].get(0) + ans[(i - 1)][x][(y + 1)])); } if ( (x > 0)) {cur = (long)Math.min(cur,(graph[(x - 1)][y].get(1) + ans[(i - 1)][(x - 1)][y])); } if ( (y > 0)) {cur = (long)Math.min(cur,(graph[x][(y - 1)].get(0) + ans[(i - 1)][x][(y - 1)])); } ans[i][x][y] = cur; }}}for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {pw.print(((ans[K][i][j] * 2) + " ")); }pw.println(); }br.close(); pw.close(); } }
2	public class Solution{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long itrIdx = 0;  long itr = 0;  long num = 0; while((itrIdx < n)){itrIdx += ((itr + 1) * (Math.pow(10,(itr + 1)) - Math.pow(10,itr))); num += (Math.pow(10,(itr + 1)) - Math.pow(10,itr)); itr++; }itrIdx -= (itr * (Math.pow(10,itr) - Math.pow(10,(itr - 1)))); num -= (Math.pow(10,itr) - Math.pow(10,(itr - 1))); long lastNum = (num + ((n - itrIdx) / itr));  long lastNumIndex = (itrIdx + (itr * (lastNum - num))); if ( (lastNumIndex == n)) {lastNumIndex = (lastNumIndex - itr); lastNum -= 1; } String nextNum = String.valueOf(lastNum += 1); System.out.println(nextNum.charAt((int)((n - lastNumIndex) - 1))); } }
0	public class Test{ static PrintWriter pw = new PrintWriter(System.out); public static void main( String[] args)throws Exception { Reader.init(System.in); int n = Reader.nextInt();  int p = Reader.nextInt();  int L = Reader.nextInt();  int R = Reader.nextInt();  int a = 1;  int b = n;  int res = 0; if ( ((a == L) && (b == R))) {res = 0; } else if ( ((((L != a) && (R != b)) && (p >= L)) && (p <= R))) {res = Math.min((p - L),(R - p)); res += ((R - L) + 2); } else if ( (((L != a) && (R != b)) && (p < L))) {res += ((L - p) + 1); res += ((R - L) + 1); } else if ( (((L != a) && (R != b)) && (p > R))) {res += ((p - R) + 1); res += ((R - L) + 1); } else if ( (((a == L) && (p >= L)) && (p <= R))) {res += ((R - p) + 1); } else if ( (((R == b) && (p >= L)) && (p <= R))) {res += ((p - L) + 1); } else if ( ((a == L) && (p > R))) {res += ((p - R) + 1); } else if ( ((R == b) && (p < L))) {res += ((L - p) + 1); } pw.print(res); pw.close(); } }
4	public class C{ public static void main( String[] args)throws Exception { final int fuck = 2001;  Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = in.nextInt(),m = in.nextInt();  int[] D = new int[(fuck * fuck)],dx = new int[]{1,-1,0,0},dy = new int[]{0,0,-1,1}; Arrays.fill(D,-1); ArrayDeque<Integer> Q = new ArrayDeque<>();  int k = in.nextInt(),ans = 0; for ( int i = 0;(i < k);++i) { int x = in.nextInt(),y = in.nextInt(); D[ans = ((x * fuck) + y)] = 0; Q.offer(ans); }while(!Q.isEmpty()){ int idx = Q.poll();  int x = (idx / fuck),y = (idx % fuck); for ( int i = 0;(i < 4);++i) { int wtf = (((dx[i] + x) * fuck) + (dy[i] + y)); if ( ((((((dx[i] + x) <= n) && ((dx[i] + x) >= 1)) && ((dy[i] + y) <= m)) && ((dy[i] + y) >= 1)) && (D[wtf] == -1))) {D[wtf] = (D[idx] + 1); Q.offer(wtf); if ( (D[wtf] >= D[ans])) ans = wtf; } }}out.println((((ans / fuck) + " ") + (ans % fuck))); out.close(); in.close(); } }
2	public class TestClass{ static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String s[] = in.readLine().split(" ");  long n = Long.parseLong(s[0]);  long k = Long.parseLong(s[1]);  long x = bs(n,k); out.println(((n - x) + 1)); out.close(); } public static long bs( long n, long k){ long l = 0,h = n; while((l <= h)){ long mid = (l + ((h - l) / 2));  long x = (mid - sum(mid)); if ( (x >= k)) {h = (mid - 1); } else {l = (mid + 1); }}return l;} public static long sum( long x){ long ans = 0; while((x > 0)){ans += (x % 10); x = (x / 10); }return ans;} }
3	public class c{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int num = in.nextInt();  int rad = in.nextInt();  int[] start = new int[num]; for ( int i = 0;(i < num);i++) start[i] = in.nextInt(); double[] finalY = new double[num];  double hyp = (rad * 2); for ( int cur = 0;(cur < num);cur++) { double stopAt = rad; for ( int comp = 0;(comp < cur);comp++) {if ( (Math.abs((start[comp] - start[cur])) > (rad * 2))) continue; double base = Math.abs((start[comp] - start[cur]));  double ny = (Math.sqrt(((hyp * hyp) - (base * base))) + finalY[comp]); stopAt = Math.max(ny,stopAt); }finalY[cur] = stopAt; }for ( int i = 0;(i < num);i++) System.out.print((finalY[i] + " ")); System.out.println(); } }
2	public class A2{ public static void main( String[] args)throws Exception { uu.s1(); uu.out.close(); } static private class MOD{ public long mod = -1; public MOD( long k1){ mod = k1; } public long cl( long n1){ long fin = (n1 % mod); if ( (fin < 0)) fin += mod; return fin;} public long s( long n1, long n2){ long k1 = ((n1 - n2) % mod); if ( (k1 < 0)) k1 += mod; return k1;} public long t( long n1, long n2){ long k1 = ((n1 * n2) % mod); if ( (k1 < 0)) k1 += mod; return k1;} public long pow( long n1, long pow){ if ( (pow == 0)) return 1; else if ( (pow == 1)) return t(1l,n1); else if ( ((pow & 1) == 0)) { long half = pow(n1,(pow >> 1)); return t(half,half);} else { long half = pow(n1,(pow >> 1)); return t(half,t(half,n1));}} } static private class BR{ BufferedReader k1 = null; StringTokenizer k2 = null; public BR(){ k1 = new BufferedReader(new InputStreamReader(System.in)); } public String nx()throws Exception { for ( ;;) {if ( ((k2 == null) || !k2.hasMoreTokens())) { String temp = k1.readLine(); if ( (temp == null)) return null; k2 = new StringTokenizer(temp); } else break;}return k2.nextToken();} public int ni()throws Exception { return Integer.parseInt(nx());} } }
2	public class Quiz{ public static final int MOD = 1000000009; public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextInt();  long m = in.nextInt();  long k = in.nextInt();  long low = Math.min((n - (k * (n - m))),m); if ( (low < 0)) {low = 0; } long result = 0; if ( (low >= k)) { long b = (low / k); result += fastExp(2,(b + 1)); result -= 2; if ( (result < 0)) {result += MOD; } result *= k; result %= MOD; } result += (low % k); result %= MOD; result += (m - low); result %= MOD; System.out.println(result); } public static long fastExp( int x, long pow){ if ( (pow == 0)) {return 1;} long result = fastExp(x,(pow / 2)); result *= result; result %= MOD; if ( ((pow % 2) == 1)) {result *= x; result %= MOD; } return result;} }
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); } }
6	public class Main{ public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } void solve(){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ScanReader in = new ScanReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  E2RotateColumnsHardVersion solver = new E2RotateColumnsHardVersion();  int testCount = in.scanInt(); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class E2RotateColumnsHardVersion{ int[][] dp ; int[] cur ; public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int m = in.scanInt();  int[][] ar = new int[n][m];  int[][] max = new int[m][2]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) ar[i][j] = in.scanInt(); for ( int i = 0;(i < m);i++) {for ( int j = 0;(j < n);j++) max[i][0] = Math.max(max[i][0],ar[j][i]); max[i][1] = i; }CodeHash.shuffle(max); Arrays.sort(max,(o1,o2)->(-o1[0] + o2[0])); dp = new int[2][(1 << n)]; cur = new int[(1 << n)]; for ( int i = 0;(i < Math.min(m,n));i++) {Arrays.fill(dp[(i & 1)],0); for ( int k = 0;(k < n);k++) {System.arraycopy(dp[((i - 1) & 1)],0,cur,0,(1 << n)); for ( int l = 0;(l < n);l++) {for ( int j = 0;(j < (1 << n));j++) {if ( ((j & (1 << l)) == 0)) {cur[(j ^ (1 << l))] = Math.max(cur[(j ^ (1 << l))],(cur[j] + ar[((k + l) % n)][max[i][1]])); } }}for ( int j = 0;(j < (1 << n));j++) dp[(i & 1)][j] = Math.max(dp[(i & 1)][j],cur[j]); }}out.println(dp[((Math.min(n,m) & 1) ^ 1)][((1 << n) - 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a = sc.nextLong(); if ( ((a % 4) == 0)) {System.out.println((((a / 2) + " ") + (a / 2))); } if ( ((a % 4) == 1)) {System.out.println(((9 + " ") + (a - 9))); } if ( ((a % 4) == 2)) {System.out.println(((6 + " ") + (a - 6))); } if ( (((a % 4) == 3) && (a > 15))) {System.out.println(((15 + " ") + (a - 15))); } if ( (a == 15)) {System.out.println("6 9"); } } }
6	public class DarkAssembly extends Thread{ public DarkAssembly(){ this.input = new BufferedReader(new InputStreamReader(System.in)); this.output = new PrintWriter(System.out); this.setPriority(Thread.MAX_PRIORITY); } class Senator{ int loyalty ; int level ; public Senator( int level, int loyalty){ this.level = level; this.loyalty = loyalty; } } static private double doIt( Senator[] senators, int A){ double probability = .0; for ( int mask = 0;(mask < (1 << senators.length));++mask) { int sum = A;  double current = 1.0; for ( int i = 0;(i < senators.length);++i) {if ( ((mask & (1 << i)) != 0)) {current *= (.01 * Math.min(senators[i].loyalty,100)); } else {current *= (.01 * (100 - Math.min(senators[i].loyalty,100))); sum += senators[i].level; }}if ( (getOnes(mask) > (senators.length / 2))) {probability += current; } else {probability += ((current * (double)A) / sum); }}return probability;} static private double go( Senator[] senators, int candies, int A, int current){ if ( (current == senators.length)) {return doIt(senators,A);} else { double result = Double.MIN_VALUE; if ( (candies > 0)) {senators[current].loyalty += 10; result = Math.max(result,go(senators,(candies - 1),A,current)); senators[current].loyalty -= 10; } result = Math.max(result,go(senators,candies,A,(current + 1))); return result;}} static int getOnes( int mask){ int result = 0; while((mask != 0)){mask &= (mask - 1); ++result; }return result;} public static void main( String[] args){ new DarkAssembly().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 BufferedReader input ; private PrintWriter output ; private StringTokenizer tokens = null; }
2	public class C817{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ long n = nl();  long s = nl();  long l = 1;  long r = n;  long ans = 0; while((l <= r)){ long mid = ((l + r) / 2);  long sum = 0;  long temp = mid; while((temp != 0)){sum += (temp % 10); temp /= 10; }if ( ((mid - sum) < s)) {ans = mid; l = (mid + 1); } else r = (mid - 1); }out.println((n - ans)); } 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 Thread(null,new Runnable(){public void run(){ try{new C817().run(); }catch (Exception e){ e.printStackTrace(); } } },"1",(1 << 26)).start(); } 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 void tr( Object... o){ System.out.println(Arrays.deepToString(o)); } }
4	public class Main{ public static void main( String[] args)throws Exception { FastIO io = new FastIO();  int test = io.nextInt(); while((test > 0)){ int n = io.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = io.nextInt(); List<int[]> list = new ArrayList<>();  Stack<int[]> stk = new Stack<>();  int temp[] = {1}; list.add(temp); stk.push(temp); for ( int i = 1;(i < n);i++) {if ( (arr[i] == 1)) { int t[] = stk.peek();  int nt[] = new int[(t.length + 1)]; for ( int j = 0;(j < t.length);j++) nt[j] = t[j]; nt[(nt.length - 1)] = arr[i]; stk.push(nt); list.add(nt); continue;} while((stk.size() > 0)){ int t[] = stk.peek(); if ( ((t[(t.length - 1)] + 1) == arr[i])) { int nt[] = new int[t.length]; for ( int j = 0;(j < (t.length - 1));j++) nt[j] = t[j]; nt[(t.length - 1)] = arr[i]; stk.pop(); stk.push(nt); list.add(nt); break;} else {stk.pop(); }}}for ( int i = 0;(i < list.size());i++) { StringBuilder sb = new StringBuilder(); sb.append(list.get(i)[0]); for ( int j = 1;(j < list.get(i).length);j++) {sb.append(("." + list.get(i)[j])); }io.println(sb.toString()); }test--; }io.close(); } } class FastIO extends PrintWriter{ private InputStream stream ; private byte[] buf = new byte[(1 << 16)]; private int curChar ,numChars ; public FastIO(){ this(System.in,System.out); } public FastIO( InputStream i, OutputStream o){ super(o); stream = i; } public FastIO( String i, String o)throws IOException{ super(new FileWriter(o)); stream = new FileInputStream(i); } private int nextByte(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars == -1)) return -1; } return buf[curChar++];} public String next(){ int c ; do {c = nextByte(); }while((c <= ' ')); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = nextByte(); }while((c > ' '));return res.toString();} public int nextInt(){ int c ; do {c = nextByte(); }while((c <= ' ')); int sgn = 1; if ( (c == '-')) {sgn = -1; c = nextByte(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((10 * res) + c) - '0'); c = nextByte(); }while((c > ' '));return (res * sgn);} }
6	public class CFContest{ public static void main( String[] args)throws Exception { boolean local = (System.getProperty("ONLINE_JUDGE") == null);  boolean async = false;  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)1e9 + 2); BitOperator bitOperator = new BitOperator(); Modular modular = new Modular(((int)1e9 + 7)); public Task( FastIO io, Debug debug){ this.io = io; this.debug = debug; } @Override public void run(){ solve(); } int[][][] f ; int n ; int t ; int[] songTimes ; int[] songTypes ; int mask ; public void solve(){ n = io.readInt(); t = io.readInt(); mask = (1 << n); f = new int[4][mask][(t + 1)]; for ( int i = 0;(i < 4);i++) {for ( int j = 0;(j < mask);j++) {for ( int k = 0;(k <= t);k++) {f[i][j][k] = -1; }}}songTimes = new int[(n + 1)]; songTypes = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {songTimes[i] = io.readInt(); songTypes[i] = io.readInt(); } int ans = 0; for ( int i = 0;(i < 4);i++) {for ( int j = 0;(j < mask);j++) {ans = modular.plus(ans,f(i,j,t)); }}io.cache.append(ans); } int f( int i, int j, int k){ if ( (j == 0)) {return (((k == 0) && (i == 0))?1:0);} if ( (k < 0)) {return 0;} if ( (f[i][j][k] == -1)) {f[i][j][k] = 0; for ( int x = 1;(x <= n);x++) {if ( ((songTypes[x] != i) || (bitOperator.bitAt(j,(x - 1)) == 0))) {continue;} for ( int y = 0;(y < 4);y++) {if ( (y == i)) {continue;} f[i][j][k] = modular.plus(f[i][j][k],f(y,bitOperator.setBit(j,(x - 1),false),(k - songTimes[x]))); }}} return f[i][j][k];} } public static class Modular{ int m ; public Modular( int m){ this.m = m; } public int valueOf( int x){ x %= m; if ( (x < 0)) {x += m; } return x;} public int valueOf( long x){ x %= m; if ( (x < 0)) {x += m; } return (int)x;} public int plus( int x, int y){ return valueOf((x + y));} @Override public String toString(){ return ("mod " + m);} } public static class BitOperator{ public int bitAt( int x, int i){ return ((x >> i) & 1);} public int bitAt( long x, int i){ return (int)((x >> i) & 1);} public int setBit( int x, int i, boolean v){ if ( v) {x |= (1 << i); } else {x &= (1 << i); }return x;} public long setBit( long x, int i, boolean v){ if ( v) {x |= (1L << i); } else {x &= (1L << i); }return x;} public long merge( long x, long y){ return (x | y);} public long intersect( long x, long y){ return (x & y);} } public static class Splay implements Cloneable{ public static final Splay NIL = new Splay(); {NIL.left = NIL; NIL.right = NIL; NIL.father = NIL; NIL.size = 0; NIL.key = Integer.MIN_VALUE; NIL.sum = 0; } Splay left = NIL; Splay right = NIL; Splay father = NIL; int size = 1; int key ; long sum ; public static void splay( Splay x){ if ( (x == NIL)) {return ;} Splay y ,z ; while(((y = x.father) != NIL)){if ( ((z = y.father) == NIL)) {y.pushDown(); x.pushDown(); if ( (x == y.left)) {zig(x); } else {zag(x); }} else {z.pushDown(); y.pushDown(); x.pushDown(); if ( (x == y.left)) {if ( (y == z.left)) {zig(y); zig(x); } else {zig(x); zag(x); }} else {if ( (y == z.left)) {zag(x); zig(x); } else {zag(y); zag(x); }}}}x.pushDown(); x.pushUp(); } public static void zig( Splay x){ Splay y = x.father;  Splay z = y.father;  Splay b = x.right; y.setLeft(b); x.setRight(y); z.changeChild(y,x); y.pushUp(); } public static void zag( Splay x){ Splay y = x.father;  Splay z = y.father;  Splay b = x.left; y.setRight(b); x.setLeft(y); z.changeChild(y,x); y.pushUp(); } public void setLeft( Splay x){ left = x; x.father = this; } public void setRight( Splay x){ right = x; x.father = this; } public void changeChild( Splay y, Splay x){ if ( (left == y)) {setLeft(x); } else {setRight(x); }} public void pushUp(){ if ( (this == NIL)) {return ;} size = ((left.size + right.size) + 1); sum = ((left.sum + right.sum) + key); } public void pushDown(){ } public static int toArray( Splay root, int[] data, int offset){ if ( (root == NIL)) {return offset;} offset = toArray(root.left,data,offset); data[offset++] = root.key; offset = toArray(root.right,data,offset); return offset;} public static void toString( Splay root, StringBuilder builder){ if ( (root == NIL)) {return ;} root.pushDown(); toString(root.left,builder); builder.append(root.key).append(','); toString(root.right,builder); } public Splay clone(){ try{return (Splay)super.clone(); }catch (CloneNotSupportedException e){ throw (new RuntimeException(e));} } public static Splay cloneTree( Splay splay){ if ( (splay == NIL)) {return NIL;} splay = splay.clone(); splay.left = cloneTree(splay.left); splay.right = cloneTree(splay.right); return splay;} public static Splay add( Splay root, Splay node){ if ( (root == NIL)) {return node;} Splay p = root; while((root != NIL)){p = root; root.pushDown(); if ( (root.key < node.key)) {root = root.right; } else {root = root.left; }}if ( (p.key < node.key)) {p.setRight(node); } else {p.setLeft(node); }p.pushUp(); splay(node); return node;} public static Splay selectMinAsRoot( Splay root){ if ( (root == NIL)) {return root;} root.pushDown(); while((root.left != NIL)){root = root.left; root.pushDown(); }splay(root); return root;} public static Splay selectMaxAsRoot( Splay root){ if ( (root == NIL)) {return root;} root.pushDown(); while((root.right != NIL)){root = root.right; root.pushDown(); }splay(root); return root;} public static Splay deleteRoot( Splay root){ root.pushDown(); Splay left = splitLeft(root);  Splay right = splitRight(root); return merge(left,right);} public static Splay splitLeft( Splay root){ root.pushDown(); Splay left = root.left; left.father = NIL; root.setLeft(NIL); root.pushUp(); return left;} public static Splay splitRight( Splay root){ root.pushDown(); Splay right = root.right; right.father = NIL; root.setRight(NIL); root.pushUp(); return right;} public static Splay merge( Splay a, Splay b){ if ( (a == NIL)) {return b;} if ( (b == NIL)) {return a;} a = selectMaxAsRoot(a); a.setRight(b); a.pushUp(); return a;} @Override public String toString(){ StringBuilder builder = new StringBuilder().append(key).append(":"); toString(cloneTree(this),builder); return builder.toString();} } public static class FastIO{ public final StringBuilder cache = new StringBuilder(); 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 << 13)]; 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 + " = ")); } } }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));  String line = stdin.readLine();  String[] prms = line.split(" ");  long a = Long.parseLong(prms[0]);  long b = Long.parseLong(prms[1]);  long cnt = 0; while(((a > 0) && (b > 0))){if ( (a >= b)) {cnt += (a / b); a = (a % b); } long c = a; a = b; b = c; }System.out.println(cnt); } }
6	public class Main{ static final boolean debug = false; static final String fileName = ""; static final boolean useFiles = false; public static void main( String[] args)throws FileNotFoundException { long start ; if ( debug) start = System.nanoTime();  InputStream inputStream ;  OutputStream outputStream ; if ( useFiles) {inputStream = new FileInputStream((fileName + ".in")); outputStream = new FileOutputStream((fileName + ".out")); } else {inputStream = System.in; outputStream = System.out; } InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(in,out); solver.solve(); if ( debug) out.println(((System.nanoTime() - start) / 1e+9)); out.close(); } } class Task{ int[][] dist ,pre ; int[] x ,y ,d ,prev ; String[] leafDescription ; String[] linerDescription ; String[][] allDescriptions ; int xs ,ys ,n ; int dist( int i, int j){ return (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j])));} int rec( int mask){ if ( (d[mask] != -1)) return d[mask]; int lowest = 0; for ( ;(((1 << lowest) & mask) == 0);lowest++) ; int newMask = (mask & (1 << lowest)); d[mask] = (rec(newMask) + dist[lowest][n]); prev[mask] = newMask; leafDescription[mask] = linerDescription[lowest]; for ( int bit = (lowest + 1);(bit < n);bit++) {if ( (((1 << bit) & mask) > 0)) {newMask = ((mask & (1 << bit)) & (1 << lowest)); int newValue = (rec(newMask) + pre[bit][lowest]); if ( (newValue < d[mask])) {d[mask] = newValue; prev[mask] = newMask; leafDescription[mask] = allDescriptions[lowest][bit]; } } }return d[mask];} public void solve(){ final int inf = (int)1e+9; 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; allDescriptions = new String[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {allDescriptions[i][j] = ((((i + 1) + " ") + (j + 1)) + " "); }}linerDescription = new String[n]; for ( int i = 0;(i < n);i++) {linerDescription[i] = ((i + 1) + " "); }dist = new int[(n + 1)][(n + 1)]; pre = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= n);j++) {dist[i][j] = (2 * dist(i,j)); pre[i][j] = ((dist(i,n) + dist(i,j)) + dist(j,n)); }}d = new int[(1 << n)]; Arrays.fill(d,-1); d[0] = 0; prev = new int[(1 << n)]; leafDescription = new String[(1 << n)]; int result = rec(((1 << n) - 1));  String answer = ""; for ( int curr = (d.length - 1);(prev[curr] != curr);curr = prev[curr]) {answer += ("0 " + leafDescription[curr]); }answer += "0"; out.println(result); out.println(answer); } private InputReader in ; private PrintWriter out ; Task( InputReader in, PrintWriter out){ this.in = in; this.out = out; } } 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());} }
1	public class B{ static private StreamTokenizer in ; static private PrintWriter out ; static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} static private 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(); } }
1	public class B{ void solve()throws IOException { int n = nextInt();  int a = nextInt();  int b = nextInt();  int[] p = new int[n]; for ( int i = 0;(i < n);i++) p[i] = nextInt(); TreeSet<Integer>[] s = new TreeSet[n]; for ( int i = 0;(i < n);i++) s[i] = new TreeSet<Integer>(); HashMap<Integer,Integer> m = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) m.put(p[i],i); for ( int i = 0;(i < n);i++) {if ( m.containsKey((a - p[i]))) {s[i].add((a - p[i])); s[m.get((a - p[i]))].add(p[i]); } if ( m.containsKey((b - p[i]))) {s[i].add((b - p[i])); s[m.get((b - p[i]))].add(p[i]); } } int last = -1;  LinkedList<Integer> q = new LinkedList<Integer>(); for ( int i = 0;(i < n);i++) {if ( (s[i].size() == 0)) {out.println("NO"); return ;} if ( (s[i].size() == 1)) {q.add(i); } } int[] ans = new int[n]; while((last != n)){while(!q.isEmpty()){ int cur = q.poll(); if ( (s[cur].size() == 0)) continue; int x = p[cur];  int y = s[cur].first(); if ( (x == (a - y))) {ans[cur] = 1; ans[m.get(y)] = 1; } else {ans[cur] = 2; ans[m.get(y)] = 2; }for ( Integer u :s[m.get(y)]) { int o = m.get(u); if ( (o != m.get(y))) {s[o].remove(y); if ( (s[o].size() == 1)) q.add(o); } }for ( Integer u :s[cur]) { int o = m.get(u); if ( (o != m.get(y))) {s[o].remove(y); if ( (s[o].size() == 1)) q.add(o); } }}last++; while((last != n)){if ( ((s[last].size() != 0) && (ans[last] == 0))) break; last++; }if ( (last != n)) {q.add(last); } }for ( int i = 0;(i < n);i++) if ( (ans[i] == 0)) {out.println("NO"); return ;} out.println("YES"); for ( int i = 0;(i < n);i++) out.print(((ans[i] - 1) + " ")); } public static void main( String[] args)throws IOException { new B().run(); } void run()throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); reader.close(); out.flush(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter out ; 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 run{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextInt();  long k = in.nextInt();  long ans = ((-3 + (long)Math.sqrt((9 + (8 * (n + k))))) / 2); System.out.println((n - ans)); } }
1	public class D909{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  char[] line = br.readLine().toCharArray();  int n = line.length;  int l = 0;  ArrayList<Node> groups = new ArrayList<>();  Node node = new Node(line[0],1); groups.add(node); for ( int i = 1;(i < n);i++) {if ( (line[i] == groups.get(l).letter)) {groups.get(l).count++; } else {node = new Node(line[i],1); groups.add(node); l++; }} int moves = 0;  ArrayList<Node> temp = new ArrayList<>(); while((groups.size() > 1)){moves++; l = groups.size(); groups.get(0).count--; groups.get((l - 1)).count--; for ( int i = 1;(i < (l - 1));i++) {groups.get(i).count -= 2; } int p ; for ( p = 0;(p < l);p++) {if ( (groups.get(p).count > 0)) {temp.add(groups.get(p)); break;} } int lTemp = temp.size(); for ( p++;(p < l);p++) {if ( (groups.get(p).count <= 0)) {continue;} if ( (groups.get(p).letter == temp.get((lTemp - 1)).letter)) {temp.get((lTemp - 1)).count += groups.get(p).count; } else {temp.add(groups.get(p)); lTemp++; }}groups.clear(); groups.addAll(temp); temp.clear(); }System.out.println(moves); } static private class Node{ char letter ; int count ; Node( char letter, int count){ this.letter = letter; this.count = count; } } }
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(); } }
3	public class oK{ void pre()throws Exception { } void solve( int TC)throws Exception { int n = ni();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ni(); }Arrays.sort(a); int b[] = new int[101];  int flag = 0;  int count = 0; for ( int i = 0;(i < n);i++) {flag = 0; if ( (b[a[i]] == 0)) {count++; } for ( int j = i;(j < n);j++) {if ( ((b[a[j]] == 0) && ((a[j] % a[i]) == 0))) {b[a[j]] = 1; } }}pn(count); } static boolean multipleTC = false,memory = false; FastReader in ; PrintWriter out ; void run()throws Exception { in = new FastReader(); out = new PrintWriter(System.out); int T = (multipleTC?ni():1); pre(); for ( int t = 1;(t <= T);t++) solve(t); out.flush(); out.close(); } public static void main( String[] args)throws Exception { if ( memory) new Thread(null,new Runnable(){public void run(){ try{new oK().run(); }catch (Exception e){ e.printStackTrace(); } } },"1",(1 << 28)).start(); else new oK().run(); } void pn( Object o){ out.println(o); } int ni()throws Exception { return Integer.parseInt(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()throws Exception { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new Exception(e.toString()));} }return st.nextToken();} String nextLine()throws Exception { String str = ""; try{str = br.readLine(); }catch (IOException e){ throw (new Exception(e.toString()));} return str;} } }
6	public class Main{ static int senator_attr[][] ; static int senators ; static double A ; public static void main( String[] args){ try{ Parserdoubt pd = new Parserdoubt(System.in);  PrintWriter pw = new PrintWriter(System.out); senators = pd.nextInt(); int candies = pd.nextInt(); senator_attr = new int[senators][2]; A = pd.nextInt(); for ( int i = 0;(i < senators);i++) {senator_attr[i][0] = pd.nextInt(); senator_attr[i][1] = pd.nextInt(); }max = -1; make(0,candies,new int[senators]); System.out.printf("%.10f",max); }catch (Exception e){ e.printStackTrace(); } } static double max ; static int maxer[] ; public static void get( int[] a){ maxer = new int[senators]; for ( int i = 0;(i < maxer.length);i++) maxer[i] = a[i]; } public static void make( int pos, int left, int[] arr){ if ( (pos == (senators - 1))) {arr[pos] = left; double f = calc(arr); if ( (f > max)) {max = f; get(arr); } return ;} if ( (left == 0)) { double f = calc(arr); if ( (f > max)) {max = f; get(arr); } return ;} for ( int i = 0;(i <= left);i++) {arr[pos] = i; make((pos + 1),(left - i),arr); arr[pos] = 0; }} public static double calc( int[] arr){ int tmp[][] = new int[senators][2]; for ( int i = 0;(i < senators);i++) {tmp[i][0] = senator_attr[i][0]; tmp[i][1] = Math.min((senator_attr[i][1] + (arr[i] * 10)),100); }return prob(tmp);} public static void print( int[] a){ for ( int i = 0;(i < a.length);i++) System.out.print((a[i] + " ")); System.out.println(); } public static double prob( int[][] arr){ double probability = 0.0; for ( int i = 0;(i < (1 << senators));i++) {if ( (Integer.bitCount(i) > (senators / 2))) { double add = 1.0;  int tmpi = i; for ( int p = 0;(p < senators);p++) {if ( ((tmpi % 2) == 1)) {add *= (arr[p][1] / 100.0); } else {add *= ((100 - arr[p][1]) / 100.0); }tmpi /= 2; }probability += add; } else { double add = 1.0;  double B = 0;  int tmpi = i; for ( int p = 0;(p < senators);p++) {if ( ((tmpi % 2) == 1)) {add *= (arr[p][1] / 100.0); } else {add *= ((100 - arr[p][1]) / 100.0); B += arr[p][0]; }tmpi /= 2; }add *= (A / (A + B)); probability += add; }}return probability;} } 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 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++];} }
3	public class codea{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = in.nextInt(); Arrays.sort(arr); int max = 0;  boolean check[] = new boolean[n];  int count = 0; for ( int i = 0;(i < n);i++) {if ( !check[i]) {count++; for ( int j = i;(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) check[j] = true; }} }System.out.println(count); } }
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); } }
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();} } }
5	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(""); private void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = nextInt();  int m[] = new int[n]; for ( int i = 0;(i < n);i++) m[i] = nextInt(); sort(m); m[(n - 1)] = ((m[(n - 1)] != 1)?1:2); sort(m); for ( int i = 0;(i < n);i++) {if ( (i != 0)) out.print(" "); out.print(m[i]); }out.println(); in.close(); 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());} }
1	public class Main implements Runnable{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private void eat( String line){ st = new StringTokenizer(line); } private String next()throws IOException { while(!st.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) return null; eat(line); }return st.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args){ new Thread(new Main()).start(); } public void go()throws IOException { int n = nextInt();  int[] v = new int[n],count = new int[2]; for ( int i = 0;(i < n);++i) {v[i] = nextInt(); ++count[(v[i] % 2)]; } int residue = ((count[0] == 1)?0:1); for ( int i = 0;(i < n);++i) if ( ((v[i] % 2) == residue)) out.println((i + 1)); } }
1	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());  String[] t = s.split(" ");  int n = Integer.parseInt(t[0]);  int k = Integer.parseInt(t[1]);  boolean[] prime = new boolean[(n + 1)]; for ( int i = 2;(i < Math.sqrt(n));i++) {for ( int j = (i + i);(j <= n);j = (j + i)) {prime[j] = true; }} int size = 0; for ( int i = 2;(i <= n);i++) {if ( !prime[i]) {size++; } } int[] pn = new int[size];  int index = 0; for ( int i = 2;(i <= n);i++) {if ( !prime[i]) {pn[index] = i; index++; } }for ( int i = 2;(i < size);i++) {for ( int j = 0;(j < i);j++) {if ( (pn[i] == ((pn[j] + pn[(j + 1)]) + 1))) {k--; } }}if ( (k <= 0)) {System.out.println("YES"); } else {System.out.println("NO"); }} }
5	public class A{ static BufferedReader in ; static PrintWriter out ; static StringTokenizer st ; static Random rnd ; void solve()throws IOException { int n = nextInt();  int[] arr = new int[n];  Integer[] arrCopy = new Integer[n]; for ( int i = 0;(i < n);i++) arr[i] = arrCopy[i] = nextInt(); Arrays.sort(arrCopy); int bad = 0; for ( int i = 0;(i < n);i++) if ( (arr[i] != arrCopy[i])) ++bad;  boolean fail = (bad > 2); out.println((!fail?"YES":"NO")); } 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());} }
5	public class A015{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),t = in.nextInt();  int[] centers = new int[n],sides = new int[n]; for ( int x = 0;(x < n);x++) {centers[x] = in.nextInt(); sides[x] = in.nextInt(); } int count = 0; for ( int x = -4000;(x <= 4000);x++) { boolean touch = false; for ( int i = 0;(i < n);i++) { int d = ((2 * centers[i]) - x); d = ((d > 0)?d:-d); int s = (t + sides[i]); if ( (s == d)) {touch = true; } else if ( (s > d)) {continue big;} }if ( touch) count++; }System.out.println(count); } }
1	public class Main{ PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next()throws IOException { if ( !tok.hasMoreTokens()) {tok = new StringTokenizer(in.readLine()); } return tok.nextToken();} int ni()throws IOException { return Integer.parseInt(next());} long mod = 1000000007; void solve()throws IOException { for ( int tc = ni();(tc > 0);tc--) { long n = ni();  long q = 1;  long p = 1;  boolean f = false; while(true){if ( (((p * 2) == n) || ((p * 4) == n))) {f = true; break;} q++; p = (q * q); if ( (p > n)) break; }if ( f) out.println("YES"); else out.println("NO"); }out.flush(); } int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} public static void main( String[] args)throws IOException { new Main().solve(); } }
0	public class aaaaaaaaaaaaaaaa{ public void run()throws Exception { Scanner file = new Scanner(System.in);  int a = file.nextInt(),b = file.nextInt(),c = file.nextInt(),n = file.nextInt(); a -= c; b -= c; if ( ((a < 0) || (b < 0))) System.out.println(-1); else { int x = ((a + b) + c); if ( (x >= n)) System.out.println(-1); else System.out.println((n - x)); }} public static void main( String[] args)throws Exception { new aaaaaaaaaaaaaaaa().run(); } }
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 xs[] = new int[n]; for ( int i = 0;(i < n);i++) xs[i] = in.nextInt(); double ys[] = new double[n]; ys[0] = r; for ( int i = 1;(i < n);i++) { double worst = r; for ( int j = 0;(j < i);j++) {if ( (xs[i] == xs[j])) {worst = Math.max(worst,((ys[j] + r) + r)); } else if ( (((xs[i] - xs[j]) * (xs[i] - xs[j])) <= ((4 * r) * r))) { double hypot = (r + r);  double adj = Math.abs((xs[i] - xs[j]));  double theta = Math.acos((adj / hypot)); worst = Math.max(((hypot * Math.sin(theta)) + ys[j]),worst); } }ys[i] = worst; }for ( int i = 0;(i < n);i++) out.printf("%.10f ",ys[i]); 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());} } }
4	public class Main{ public String[][] a ; public void run()throws Exception { Scanner in = new Scanner(new File("input.txt"));  PrintWriter pw = new PrintWriter(new File("output.txt"));  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int[] xx = new int[k];  int[] yy = new int[k]; for ( int i = 0;(i < k);i++) {xx[i] = in.nextInt(); yy[i] = in.nextInt(); } int x = 0,y = 0,r ; r = -1; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) { int rr = 1000000; for ( int q = 0;(q < k);q++) rr = Math.min(rr,(Math.abs(((xx[q] - 1) - i)) + Math.abs(((yy[q] - 1) - j)))); if ( (rr > r)) {r = rr; x = i; y = j; } }pw.print((((x + 1) + " ") + (y + 1))); pw.close(); } public static void main( String[] args)throws Exception { new Main().run(); } }
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 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);  atskb solver = new atskb(); solver.solve(1,in,out); out.close(); } static class atskb{ long s ; public void solve( int testNumber, InputReader in, PrintWriter out){ long n = in.nextLong(); s = in.nextLong(); long ans = binarysearch(0,((long)Math.pow(10,18) + (20 * 9))); if ( (ans > n)) {out.print(0); } else {out.print(((n - ans) + 1)); }} public long binarysearch( long l, long r){ if ( (l == r)) {if ( check(l)) return l; return -1;} if ( ((l - r) == -1)) {if ( check(l)) return l; if ( check(r)) {return r;} } long mid = (l + ((r - l) / 2)); if ( check(mid)) return binarysearch(l,mid); return binarysearch((mid + 1),r);} public boolean check( long m){ String str = (m + "");  long sum = 0; for ( int i = 0;(i < str.length());i++) {sum += (str.charAt(i) - '0'); }if ( ((sum + s) <= m)) return true; return false;} } 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 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 boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {if ( (Long.bitCount(choosed) < Long.bitCount(mds))) mds = choosed; return ;} int k = -1;  ArrayList<Integer> list = new ArrayList<Integer>(); for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) {list.clear(); list.add(i); k = i; } else if ( (Long.bitCount((g[i] & ~covered)) == Long.bitCount((g[k] & ~covered)))) list.add(i); }if ( (k == -1)) return ; k = list.get((int)(list.size() * random())); mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } 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 P111C().run(); } }
5	public class codef{ public static void main( String[] ar)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer nk = new StringTokenizer(br.readLine());  int n = Integer.parseInt(nk.nextToken());  int k = Integer.parseInt(nk.nextToken());  String st[] = br.readLine().split(" ");  int ans[] = new int[n];  int a[] = new int[n]; for ( int i = 0;(i < n);i++) ans[i] = Integer.parseInt(st[i]); for ( int i = 1;(i < n);i++) a[i] = (ans[i] - ans[(i - 1)]); a[0] = -1; Arrays.sort(a); int count = 0,sum = 0; for ( int i = 0;(i < n);i++) if ( (a[i] < 0)) count++; else sum = (sum + a[i]); k = (k - count); int i = (n - 1); while(((k > 0) && (i >= 0))){if ( (a[i] > -1)) {sum = (sum - a[i]); k--; } i--; }System.out.println(sum); } }
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 test1177b{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long k = sc.nextLong();  long k1 = 0,k2 = 0;  long p = 1;  String str = ""; for ( int i = 1;(i <= 12);i++) {if ( ((k >= k1) && (k <= (k1 + ((p * 9) * i))))) { long kk = ((k - k1) % i); k2 = ((p + ((k - k1) / i)) - 1); if ( (kk != 0)) k2++; str = ("" + k2); if ( (str.length() > i)) {k2--; str = ("" + k2); kk = 0; } if ( (kk > 0)) {System.out.println(str.charAt(((int)kk - 1))); } else {System.out.println(str.charAt((i - 1))); }break;} else {k1 += ((p * 9) * i); p = (p * 10); }}} }
1	public class Main implements Runnable{ public InputReader in ; public PrintWriter out ; public void solve()throws Exception { int N = in.nextInt();  int[] houses = new int[N];  boolean[] exist = new boolean[52]; for ( int i = 0;(i < N);i++) { char c = in.nextChar(); if ( (('a' <= c) && (c <= 'z'))) {houses[i] = (26 + (c - 'a')); } else {houses[i] = (c - 'A'); }exist[houses[i]] = true; } int[][] pokemons = new int[N][52]; pokemons[0][houses[0]] = 1; for ( int i = 1;(i < N);i++) {System.arraycopy(pokemons[(i - 1)],0,pokemons[i],0,pokemons[i].length); pokemons[i][houses[i]]++; } int uniques = 0; for ( boolean bool :exist) if ( bool) uniques++; if ( (uniques == 1)) {out.print(1); return ;} int last_variant = -1; for ( int i = 0;(i < (N - 1));i++) {if ( (pokemons[i][houses[i]] == pokemons[(N - 1)][houses[i]])) {last_variant = i; break;} } int minimum = N; for ( int i = 0;(i <= last_variant);i++) {if ( (houses[i] == houses[(i + 1)])) continue; int low = (i + 1);  int high = (N - 1); while((low < high)){ int mid = ((low + high) / 2);  boolean allPresent = true; for ( int j = 0;(j < 52);j++) {if ( (((j != houses[i]) && exist[j]) && (pokemons[mid][j] == pokemons[i][j]))) {allPresent = false; break;} }if ( allPresent) {high = mid; } else {low = (mid + 1); }}minimum = min(minimum,((low - i) + 1)); }out.print(minimum); } static int min( int a, int b){ return ((a < b)?a:b);} static long min( long a, long b){ return ((a < b)?a:b);} public static void main( String[] args){ new Thread(null,new Main(),"Main",(1 << 28)).start(); } static boolean OJ = (System.getProperty("ONLINE_JUDGE") != null); @SuppressWarnings({"Duplicates","unused"}) static class InputReader{ private InputStream stream ; private byte[] buf = new byte[2048]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader(){ this.stream = System.in; } public InputReader( InputStream stream){ this.stream = stream; } public InputReader( SpaceCharFilter filter){ this.stream = System.in; this.filter = filter; } public InputReader( InputStream stream, SpaceCharFilter filter){ this.stream = stream; this.filter = filter; } public int read(){ 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 char nextChar(){ int c = read(); while(isSpaceChar(c))c = read(); return (char)c;} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); boolean negative = false; if ( (c == '-')) {negative = true; 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 (negative?-res:res);} public final long nextLong(){ int c = read(); while(isSpaceChar(c)){c = read(); } boolean negative = false; if ( (c == '-')) {negative = true; c = read(); } long res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (negative?-res:res);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public boolean isEndChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return ((((c == '\n') || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
5	public class Solution{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  Comp c1 = getComp(scanner);  Comp c2 = getComp(scanner); c1.sortByPrice(); c2.sortByPrice(); int i = 0;  int j = 0; while(((i < c1.num) || (j < c2.num))){ Elem xi = ((i < c1.num)?c1.elems.get(i):null);  Elem yj = ((j < c2.num)?c2.elems.get(j):null); if ( ((xi != null) && (yj != null))) {if ( (xi.price >= yj.price)) {if ( !c2.resultSet.contains(xi)) {c1.resultSet.add(xi); } i++; } else {if ( !c1.resultSet.contains(yj)) {c2.resultSet.add(yj); } j++; }} else if ( (xi != null)) {if ( !c2.resultSet.contains(xi)) {c1.resultSet.add(xi); } i++; } else {if ( !c1.resultSet.contains(yj)) {c2.resultSet.add(yj); } j++; }} long result = (c1.getResultPrice() + c2.getResultPrice()); System.out.println(result); } static private Comp getComp( Scanner scanner){ Comp c = new Comp(); c.num = scanner.nextInt(); for ( int i = 0;(i < c.num);i++) {c.addElem(scanner.nextLong(),scanner.nextLong()); }return c;} } class Comp{ int num ; List<Elem> elems = new ArrayList<>(); Set<Elem> resultSet = new HashSet<>(); void addElem( long el, long pr){ Elem elem = new Elem(el,pr); elems.add(elem); } void sortByPrice(){ Collections.sort(elems); } long getResultPrice(){ long sumPrice = 0; for ( Elem elem :resultSet) {sumPrice += elem.price; }return sumPrice;} } class Elem implements Comparable<Elem>{ long elem ; long price ; public Elem( long el, long pr){ this.elem = el; this.price = pr; } }
3	public class D{ public static class BIT{ int[] dat ; public BIT( int n){ dat = new int[(n + 1)]; } public void add( int k, int a){ for ( int i = (k + 1);(i < dat.length);i += (i & -i)) {dat[i] += a; }} public int sum( int s, int t){ if ( (s > 0)) return (sum(0,t) - sum(0,s)); int ret = 0; for ( int i = t;(i > 0);i -= (i & -i)) {ret += dat[i]; }return ret;} } public static void main( String[] args){ try(Scanner sc=new Scanner(System.in)){final int N = sc.nextInt();  int[] array = new int[N]; for ( int i = 0;(i < N);i++) {array[i] = (sc.nextInt() - 1); } long inv = 0;  BIT bit = new BIT(N); for ( int i = 0;(i < N);i++) {inv += bit.sum(array[i],N); bit.add(array[i],1); } int mod2 = (int)(inv % 2); final int M = sc.nextInt(); for ( int i = 0;(i < M);i++) {final int l = (sc.nextInt() - 1); final int r = (sc.nextInt() - 1); final long size = ((r - l) + 1); if ( (size > 1)) {if ( ((((size * (size - 1)) / 2) % 2) == 1)) {mod2 = (1 - mod2); } } System.out.println(((mod2 == 0)?"even":"odd")); } }} public static class Scanner implements Closeable{ private BufferedReader br ; private StringTokenizer tok ; public Scanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } private void getLine(){ try{while(!hasNext()){tok = new StringTokenizer(br.readLine()); } }catch (IOException e){ } } private boolean hasNext(){ return ((tok != null) && tok.hasMoreTokens());} public String next(){ getLine(); return tok.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public void close(){ try{br.close(); }catch (IOException e){ } } } }
2	public class Solution{ public static void main( String[] args){ long b = 0;  long p = 1;  Scanner s = new Scanner(System.in);  long m = s.nextLong();  long x = 1; do {p = ((m + b) / x); b = ((10 * b) + 10); x++; }while(((p / (long)Math.pow(10,(x - 1))) != 0));x--; b = ((b / 10) - 1); b = ((x * p) - b); b = (m - b); b = ((x - b) - 1); p /= (long)Math.pow(10,b); p %= 10; System.out.println(p); } }
0	public class A630{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong(); System.out.println(25); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Kattio in = new Kattio(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, Kattio in, PrintWriter out){ int n = in.nextInt();  int r = in.nextInt();  double[] xs = new double[n];  double[] ys = new double[n];  TreeSet<TaskC.Pair> set = new TreeSet<>(); for ( int i = 0;(i < n);++i) {xs[i] = in.nextDouble(); ys[i] = (double)Integer.MIN_VALUE; if ( (i == 0)) {out.printf("%f",(double)r); ys[i] = (double)r; set.add(new TaskC.Pair(xs[i],ys[i])); } else {for ( TaskC.Pair p :set) { double maximum = p.x;  double diffX = ((xs[i] - maximum) * (xs[i] - maximum)); if ( (diffX <= ((r * r) * 4.0))) {ys[i] = Math.max(ys[i],(p.y + Math.sqrt((((r * r) * 4.0) - diffX)))); continue;} }if ( (ys[i] < 0)) ys[i] = (double)r; set.add(new TaskC.Pair(xs[i],ys[i])); out.printf(" %f",ys[i]); }}} } static class Kattio extends PrintWriter{ private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; public Kattio( InputStream i){ super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(i)); } public Kattio( InputStream i, OutputStream o){ super(new BufferedOutputStream(o)); r = new BufferedReader(new InputStreamReader(i)); } public int nextInt(){ return Integer.parseInt(nextToken());} public double nextDouble(){ return Double.parseDouble(nextToken());} private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} } }
6	public class TaskD implements Runnable{ private InputReader in ; private PrintWriter out ; private int n ; private int m ; private boolean[][] e ; private long[][] qp ; static private 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);} 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))){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();} } public static void main( String[] args){ new TaskD().run(); } public TaskD(){ in = new InputReader(System.in); out = new PrintWriter(System.out); } public void run(){ n = in.readInt(); m = in.readInt(); e = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (in.readInt() - 1);  int b = (in.readInt() - 1); e[a][b] = e[b][a] = true; } int msk = ((1 << n) - 1); qp = new long[(n - 1)][(1 << (n - 1))]; long ans = 0; for ( int i = (n - 1);(i >= 0);i--) {msk -= (1 << i); for ( int k = 0;(k < i);k++) Arrays.fill(qp[k],0,(1 << i),-1); for ( int j = 0;(j < i);j++) {if ( e[i][j]) {e[i][j] = e[j][i] = false; ans += go(j,(msk - (1 << j)),i); e[i][j] = e[j][i] = true; } }}out.println((ans / 2)); out.close(); } private long go( int v, int msk, int u){ if ( (qp[v][msk] != -1)) return qp[v][msk]; qp[v][msk] = 0; if ( e[v][u]) qp[v][msk] = 1; for ( int i = 0;(i < u);i++) {if ( (e[v][i] && (((msk >> i) & 1) != 0))) qp[v][msk] += go(i,(msk - (1 << i)),u); }return qp[v][msk];} }
4	public class Main{ public static void main( String[] args)throws IOException { PrintWriter pw = new PrintWriter(new FileWriter("output.txt"));  Scanner in = new Scanner(new File("input.txt"));  int n ,m ,k ; n = in.nextInt(); m = in.nextInt(); k = in.nextInt(); Vector<Integer> vec = new Vector<Integer>();  Vector<Integer> temp = new Vector<Integer>();  boolean[][] mas = new boolean[n][m];  long time = System.currentTimeMillis(); for ( int i = 0;(i < k);i++) {vec.add((in.nextInt() - 1)); vec.add((in.nextInt() - 1)); mas[vec.get((vec.size() - 2))][vec.get((vec.size() - 1))] = true; } int x ,y ; x = y = 0; while((vec.size() != 0)){for ( int i = 0;(i < vec.size());i += 2) {x = vec.get(i); y = vec.get((i + 1)); if ( ((x > 0) && !mas[(x - 1)][y])) {temp.add((x - 1)); temp.add(y); mas[(x - 1)][y] = true; } if ( ((x < (n - 1)) && !mas[(x + 1)][y])) {temp.add((x + 1)); temp.add(y); mas[(x + 1)][y] = true; } if ( ((y > 0) && !mas[x][(y - 1)])) {temp.add(x); temp.add((y - 1)); mas[x][(y - 1)] = true; } if ( ((y < (m - 1)) && !mas[x][(y + 1)])) {temp.add(x); temp.add((y + 1)); mas[x][(y + 1)] = true; } }vec = temp; temp = new Vector<Integer>(); }pw.println((((x + 1) + " ") + (y + 1))); System.out.println((System.currentTimeMillis() - time)); in.close(); pw.close(); } }
3	public class inversions{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int N = sc.nextInt();  int[] values = new int[N]; for ( int i = 0;(i < N);i++) {values[i] = sc.nextInt(); } int query = sc.nextInt();  int[][] tasks = new int[query][2]; for ( int i = 0;(i < query);i++) {tasks[i][0] = sc.nextInt(); tasks[i][1] = sc.nextInt(); } int startinversions = 0; for ( int i = 1;(i < values.length);i++) {for ( int j = (i - 1);(j >= 0);j--) {if ( (values[i] < values[j])) {startinversions++; } }} int value = (startinversions % 2); for ( int[] task :tasks) { int n = (task[1] - task[0]); if ( ((((n * (n + 1)) / 2) % 2) != 0)) {value = ((value + 1) % 2); } if ( (value == 1)) {System.out.println("odd"); } else {System.out.println("even"); }}} }
2	public class Solution{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long n = scanner.nextLong();  long s = scanner.nextLong();  long myLong = s;  long count = 0; while(true){if ( (myLong > n)) {break;} char[] num = ("" + myLong);  int sum = 0; for ( int j = 0;(j < num.length);j++) sum += (num[j] - '0'); if ( ((myLong - sum) >= s)) {break;} myLong++; }System.out.println(Math.max(((n - myLong) + 1),0)); scanner.close(); } }
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.nextInt(); if ( (n == 1)) {out.println(0); return ;} long max = (((k * (k - 1)) / 2) + 1); if ( (max < n)) {out.println("-1"); return ;} long low = 1,high = (k - 1);  long ans = (k - 1); while((low <= high)){ long mid = ((low + high) / 2);  long val = ((((mid * mid) - (mid * ((2 * k) - 1))) + (2 * n)) - 2); if ( (val > 0)) {low = (mid + 1); } else {ans = mid; high = (mid - 1); }}out.println(ans); } }
1	public class a implements Runnable{ private void solve()throws IOException { int n = nextInt();  int oddcnt = 0,evencnt = 0;  int odd = 0,even = 0; for ( int i = 0;(i < n);i++) { int a = nextInt(); if ( ((a % 2) == 0)) {even = (i + 1); evencnt++; } else {odd = (i + 1); oddcnt++; }}if ( (oddcnt == 1)) {System.out.println(odd); } else {System.out.println(even); }} public static void main( String[] args){ new Thread(new a()).start(); } BufferedReader br ; StringTokenizer st ; PrintWriter out ; boolean eof = false; 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(){ return Integer.parseInt(nextToken());} }
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 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); }}} }
4	public class cf35c{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int[] dx = {0,0,1,-1};  int[] dy = {1,-1,0,0};  int n = in.nextInt();  int m = in.nextInt();  int[][] seen = new int[n][m]; for ( int i = 0;(i < n);i++) Arrays.fill(seen[i],-1); Queue<Integer> q = new LinkedList<Integer>();  int k = in.nextInt(); for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); q.add(x); q.add(y); q.add(0); seen[x][y] = 0; }while(!q.isEmpty()){ int x = q.poll();  int y = q.poll();  int t = q.poll(); for ( int i = 0;(i < dx.length);i++) { int nx = (x + dx[i]);  int ny = (y + dy[i]); if ( ((((nx < 0) || (nx >= n)) || (ny < 0)) || (ny >= m))) continue; if ( (seen[nx][ny] != -1)) continue; seen[nx][ny] = (t + 1); q.add(nx); q.add(ny); q.add((t + 1)); }} int best = -1,x = 0,y = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (seen[i][j] > best)) {best = seen[i][j]; x = (i + 1); y = (j + 1); } out.println(((x + " ") + y)); out.close(); } }
1	public class A{ public static void main( String[] args)throws Exception { boolean submit = true;  Scanner sc = (submit?new Scanner(System.in):new Scanner(new File("A.in"))); while(sc.hasNext()){ int n = sc.nextInt(),k = sc.nextInt();  boolean p[] = sieveOfEratosthenes(1001);  ArrayList<Integer> nolds = new ArrayList<Integer>(); for ( int i = 0,prev = 0;(i < p.length);i++) {if ( p[i]) {nolds.add(((prev + i) + 1)); prev = i; } } int c = 0; for ( int i :nolds) if ( (((i >= 2) && (i <= n)) && p[i])) c++; System.out.println(((c >= k)?"YES":"NO")); }} static boolean[] sieveOfEratosthenes( int n){ boolean prime[] = new boolean[(n + 1)]; fill(prime,2,n,true); for ( int i = 2;(i <= n);i++) if ( prime[i]) for ( int j = (i * i);(j <= n);j += i) prime[j] = false; return prime;} }
2	public class Codechef{ static class FastScanner{ BufferedReader br ; StringTokenizer stok ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } String next()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return null;} stok = new StringTokenizer(s); }return stok.nextToken();} int ni()throws IOException { return Integer.parseInt(next());} long nl()throws IOException { return Long.parseLong(next());} double nd()throws IOException { return Double.parseDouble(next());} } static long mod = Long.MAX_VALUE; static PrintWriter out = new PrintWriter(System.out); static FastScanner in = new FastScanner(System.in); public static void main( String[] args)throws java.lang.Exception { int i ,j ;  long flag ,flag1 ,flag2 ,temp ,temp2 ,temp1 ,count ,counter ,l ;  HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();  ArrayList<Integer> arr = new ArrayList<Integer>();  HashSet<Integer> set = new HashSet<Integer>();  PriorityQueue<Integer> pq = new PriorityQueue<Integer>();  long k = in.nl(); temp = 9; l = 1; temp2 = 0; while(true){if ( (k <= (temp2 + (temp * l)))) {k -= temp2; break;} else {temp2 += (temp * l); temp *= 10; l++; }} long z = ((k - 1) / l);  long no = ((long)Math.pow(10,(l - 1)) + z);  int index = ((int)(((k % l) == 0)?l:(k % l)) - 1);  String p = Long.toString(no); out.println(p.charAt(index)); out.close(); } static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static int binarySearch( int[] a, int item, int low, int high){ if ( (high <= low)) return ((item > a[low])?(low + 1):low); int mid = ((low + high) / 2); if ( (item == a[mid])) return (mid + 1); if ( (item > a[mid])) return binarySearch(a,item,(mid + 1),high); return binarySearch(a,item,low,(mid - 1));} }
6	public class Solution{ static StringTokenizer st ; static BufferedReader reader ; public static void main( String[] args)throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); int xs = NextInt();  int ys = NextInt();  int n = NextInt();  int x[] = new int[n];  int y[] = new int[n];  int single[] = new int[n];  int pair[][] = new int[n][n]; for ( int i = 0;(i < n);++i) {x[i] = NextInt(); y[i] = NextInt(); }for ( int i = 0;(i < n);++i) single[i] = (2 * dist(xs,ys,x[i],y[i])); for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);++j) pair[i][j] = ((dist(xs,ys,x[i],y[i]) + dist(x[i],y[i],x[j],y[j])) + dist(x[j],y[j],xs,ys)); int dp[] = new int[(1 << n)];  int prev[] = new int[(1 << n)]; for ( int mask = 0;(mask < (1 << n));++mask) { int p = -1; for ( int i = 0;(i < n);++i) if ( (((mask >> i) & 1) != 0)) {p = i; break;} if ( (p == -1)) continue; dp[mask] = (dp[(mask ^ (1 << p))] + single[p]); prev[mask] = p; for ( int j = (p + 1);(j < n);++j) {if ( (((mask >> j) & 1) != 0)) { int res = (pair[p][j] + dp[((mask ^ (1 << p)) ^ (1 << j))]); if ( (res < dp[mask])) {dp[mask] = res; prev[mask] = (p + (100 * j)); } } }} int cur = ((1 << n) - 1); System.out.printf("%d\n0 ",dp[cur]); while((cur != 0)){if ( (prev[cur] < 100)) {System.out.printf("%d %d ",(prev[cur] + 1),0); cur ^= (1 << prev[cur]); } else { int i = (prev[cur] / 100);  int j = (prev[cur] % 100); System.out.printf("%d %d %d ",(i + 1),(j + 1),0); cur = ((cur ^ (1 << i)) ^ (1 << j)); }}} static int dist( int x0, int y0, int x1, int y1){ return (((x0 - x1) * (x0 - x1)) + ((y0 - y1) * (y0 - y1)));} static int NextInt()throws NumberFormatException,IOException { return Integer.parseInt(NextToken());} static String NextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(reader.readLine()); }return st.nextToken();} }
6	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);  TaskE2 solver = new TaskE2(); solver.solve(1,in,out); out.close(); } static class TaskE2{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int numTests = in.nextInt(); for ( int test = 0;(test < numTests);test++) { int n = in.nextInt();  int 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(); }}if ( (m > n)) { int[] maxInColumn = new int[m]; for ( int j = 0;(j < m);j++) {for ( int i = 0;(i < n);i++) {maxInColumn[j] = Math.max(maxInColumn[j],a[i][j]); }} Integer[] cols = new Integer[m]; for ( int i = 0;(i < m);i++) {cols[i] = i; }Arrays.sort(cols,(u,v)->(maxInColumn[u] - maxInColumn[v])); int[][] na = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {na[i][j] = a[i][cols[j]]; }}m = n; a = na; } int[] buf = new int[n];  int[][] sums = new int[m][(1 << n)];  int[] sumsCur = new int[(1 << n)]; for ( int j = 0;(j < m);j++) {for ( int shift = 0;(shift < n);shift++) {for ( int i = 0;(i < n);i++) {buf[i] = a[((i + shift) % n)][j]; }for ( int mask = 1;(mask < (1 << n));mask++) { int k = Integer.numberOfTrailingZeros(mask); sumsCur[mask] = (sumsCur[(mask ^ (1 << k))] + buf[k]); sums[j][mask] = Math.max(sums[j][mask],sumsCur[mask]); }}} int[] d = new int[(1 << n)]; for ( int j = 0;(j < m);j++) {for ( int mask = ((1 << n) - 1);(mask >= 0);mask--) {for ( int submask = mask;(submask > 0);submask = ((submask - 1) & mask)) {d[mask] = Math.max(d[mask],(d[(mask ^ submask)] + sums[j][submask])); }}} int ans = 0; for ( int x :d) {ans = Math.max(ans,x); }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());} } }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new PrintStream(System.out));  StringTokenizer st = new StringTokenizer(f.readLine());  int n = Integer.parseInt(st.nextToken());  int m = Integer.parseInt(st.nextToken());  long[] arrB = new long[n];  long[] arrG = new long[m]; st = new StringTokenizer(f.readLine()); for ( int i = 0;(i < n);i++) {arrB[i] = Long.parseLong(st.nextToken()); }st = new StringTokenizer(f.readLine()); for ( int j = 0;(j < m);j++) {arrG[j] = Long.parseLong(st.nextToken()); }Arrays.sort(arrB); Arrays.sort(arrG); long ans = 0; for ( int i = 0;(i < n);i++) {ans += (arrB[i] * (long)m); }for ( int i = 1;(i < m);i++) {ans += (arrG[i] - arrB[(n - 1)]); }if ( (arrB[(n - 1)] != arrG[0])) {if ( (n == 1)) {ans = -1; } else {ans += (arrG[0] - arrB[(n - 2)]); }} if ( (arrB[(n - 1)] > arrG[0])) {ans = -1; } System.out.println(ans); f.close(); out.close(); } }
0	public class Main{ public static void main( String[] args)throws java.lang.Exception { Scanner s = new Scanner(System.in);  long n = s.nextLong(); System.out.println(25); } }
6	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{ int n ; int[] bitCount ; long neededSum ; long[] sums ; Map<Long,Integer> where ; public void solve( int testNumber, FastScanner in, PrintWriter out){ n = in.nextInt(); int[][] a = new int[n][]; neededSum = 0; sums = new long[n]; for ( int i = 0;(i < n);i++) { int k = in.nextInt(); a[i] = new int[k]; for ( int j = 0;(j < k);j++) {a[i][j] = in.nextInt(); neededSum += a[i][j]; sums[i] += a[i][j]; }}if ( ((neededSum % n) != 0)) {out.println("No"); return ;} neededSum /= n; where = new HashMap<>(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < a[i].length);j++) {where.put((long)a[i][j],i); }}bitCount = new int[(1 << n)]; for ( int i = 0;(i < bitCount.length);i++) {bitCount[i] = Integer.bitCount(i); } Entry[][] cycleSol = new Entry[(1 << n)][];  List<Entry> sol = new ArrayList<>(); for ( int i = 0;(i < n);i++) {for ( int x :a[i]) {search(i,i,x,x,0,0,sol,cycleSol); }} boolean[] can = new boolean[(1 << n)];  int[] via = new int[(1 << n)]; can[0] = true; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int submask = mask;(submask > 0);submask = ((submask - 1) & mask)) {if ( ((cycleSol[submask] != null) && can[(mask ^ submask)])) {can[mask] = true; via[mask] = submask; } }}if ( !can[((1 << n) - 1)]) {out.println("No"); return ;} int[][] ans = new int[n][2]; for ( int mask = ((1 << n) - 1);(mask > 0);) { int sm = via[mask]; mask ^= sm; for ( Entry e :cycleSol[sm]) {ans[e.from][0] = e.what; ans[e.from][1] = (e.to + 1); }}out.println("Yes"); for ( int i = 0;(i < n);i++) {out.println(((ans[i][0] + " ") + ans[i][1])); }} private void search( int start, int cur, long fromStart, long fromCur, int hasIn, int hasOut, List<Entry> sol, Entry[][] cycleSol){ for ( int i = 0;(i < n);i++) {if ( ((hasIn & (1 << i)) > 0)) {continue;} if ( ((hasOut & (1 << cur)) > 0)) {continue;} long fromI = ((sums[i] + fromCur) - neededSum);  Integer w = where.get(fromI); if ( ((w == null) || (w != i))) {continue;} sol.add(new Entry(cur,i,(int)fromCur)); int nHasIn = (hasIn | (1 << i));  int nHasOut = (hasOut | (1 << cur)); if ( ((i == start) && (fromI == fromStart))) {cycleSol[nHasOut] = sol.toArray(new Entry[0]); } search(start,i,fromStart,fromI,nHasIn,nHasOut,sol,cycleSol); sol.remove((sol.size() - 1)); }} class Entry{ int from ; int to ; int what ; Entry( int from, int to, int what){ this.from = from; this.to = to; this.what = what; } } } 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{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
1	public class A{ static private StreamTokenizer in ; static private PrintWriter out ; static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws Exception { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); ArrayList<Integer> p = new ArrayList<Integer>();  ArrayList<Integer> o = new ArrayList<Integer>();  int n = nextInt(); for ( int i = 0;(i < n);i++) { int a = nextInt(); if ( ((a % 2) == 0)) p.add((i + 1)); else o.add((i + 1)); }if ( (p.size() < o.size())) out.println(p.get(0)); else out.println(o.get(0)); out.flush(); } }
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;} } }
3	public final class PythonIndentation{ public static void main( String[] args){ new PythonIndentation(System.in,System.out); } static class Solver implements Runnable{ static final int MOD = ((int)1e9 + 7); int n ; char[] arr ; long[][] dp ; BufferedReader in ; PrintWriter out ; void solve()throws IOException { n = Integer.parseInt(in.readLine()); arr = new char[n]; dp = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i < n);i++) arr[i] = in.readLine().charAt(0); for ( int i = 0;(i <= n);i++) Arrays.fill(dp[i],-1); dp[0][0] = 1; if ( (arr[0] == 's')) out.println(find(1,0)); else out.println(find(1,1)); } long find( int curr, int backIndents){ if ( (backIndents < 0)) return 0; if ( (curr == n)) return 1; if ( (dp[curr][backIndents] != -1)) return dp[curr][backIndents]; long ans ; if ( (arr[curr] == 's')) {if ( (arr[(curr - 1)] == 'f')) ans = find((curr + 1),backIndents); else ans = CMath.mod((find((curr + 1),backIndents) + find(curr,(backIndents - 1))),MOD); } else {ans = find((curr + 1),(backIndents + 1)); if ( (arr[(curr - 1)] != 'f')) ans = CMath.mod((ans + find(curr,(backIndents - 1))),MOD); }return dp[curr][backIndents] = ans;} public Solver( BufferedReader in, PrintWriter out){ this.in = in; this.out = out; } } private PythonIndentation( 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),"PythonIndentation",(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(); }} }
4	public class Watermelon{ static int[][] ans ; static int n ,m ; static boolean[][] vis ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new File("input.txt"));  PrintWriter pw = new PrintWriter("output.txt");  int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt();  Queue<Integer> pq = new ArrayDeque<>();  boolean[] vis = new boolean[(n * m)]; for ( int i = 0;(i < k);i++) { int r = (sc.nextInt() - 1),c = (sc.nextInt() - 1); pq.add(((m * r) + c)); vis[((m * r) + c)] = true; }sc.close(); int ans = 0; while((pq.size() != 0)){ int x = pq.remove(); ans = x; if ( ((n != 1) && ((x % n) == 0))) {if ( (((x + m) < (n * m)) && !vis[(x + m)])) {pq.add((x + m)); vis[(x + m)] = true; } if ( (((x - m) >= 0) && !vis[(x - m)])) {pq.add((x - m)); vis[(x - m)] = true; } if ( (((x + 1) < (n * m)) && !vis[(x + 1)])) {pq.add((x + 1)); vis[(x + 1)] = true; } } else if ( ((n != 1) && (((x + 1) % n) == 0))) {if ( (((x + m) < (n * m)) && !vis[(x + m)])) {pq.add((x + m)); vis[(x + m)] = true; } if ( (((x - m) >= 0) && !vis[(x - m)])) {pq.add((x - m)); vis[(x - m)] = true; } if ( (((x - 1) >= 0) && !vis[(x - 1)])) {pq.add((x - 1)); vis[(x - 1)] = true; } } else {if ( (((x + m) < (n * m)) && !vis[(x + m)])) {pq.add((x + m)); vis[(x + m)] = true; } if ( (((x - m) >= 0) && !vis[(x - m)])) {pq.add((x - m)); vis[(x - m)] = true; } if ( (((x - 1) >= 0) && !vis[(x - 1)])) {pq.add((x - 1)); vis[(x - 1)] = true; } if ( (((x + 1) < (n * m)) && !vis[(x + 1)])) {pq.add((x + 1)); vis[(x + 1)] = true; } }}pw.println(((((ans / m) + 1) + " ") + ((ans % m) + 1))); pw.close(); } }
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(); } }
6	public class Main{ static double EPS = 1e-10; static double PI = Math.acos(-1.0); static double p[][] = new double[25][25]; static double f[] = new double[(1 << 20)]; static int n ; public static void PR( String s){ System.out.print(s); } public static void PR( double s){ java.text.DecimalFormat d = new java.text.DecimalFormat("#.0000000"); System.out.print(d.format(s)); } public static void DP(){ int i ,j ,k ,cnt ; for ( i = 0;(i < (1 << n));i++) f[i] = 0; f[((1 << n) - 1)] = 1; for ( k = ((1 << n) - 1);(k >= 0);k--) {cnt = 0; for ( i = 0;(i < n);i++) if ( ((k & (1 << i)) != 0)) cnt++; for ( i = 0;(i < n);i++) if ( ((k & (1 << i)) != 0)) {for ( j = 0;(j < n);j++) if ( ((i != j) && ((k & (1 << j)) != 0))) {f[(k ^ (1 << j))] += ((f[k] * p[i][j]) / (((cnt - 1) * cnt) / 2)); } } }} public static void main( String[] args){ Scanner S = new Scanner(System.in); while(S.hasNext()){n = S.nextInt(); int i ,j ; for ( i = 0;(i < n);i++) for ( j = 0;(j < n);j++) p[i][j] = S.nextDouble(); DP(); for ( i = 0;(i < n);i++) {if ( (i != 0)) PR(" "); PR(f[(1 << i)]); }PR("\n"); }} }
0	public class Main{ long n ; long maxlcm ; void run(){ n = cin.nextInt(); if ( ((n == 1) || (n == 2))) maxlcm = n; else if ( (n >= 3)) {if ( ((n % 2) != 0)) {maxlcm = ((n * (n - 1)) * (n - 2)); } else if ( ((n % 3) != 0)) maxlcm = ((n * (n - 1)) * (n - 3)); else maxlcm = (((n - 1) * (n - 2)) * (n - 3)); } System.out.println(maxlcm); } public static void main( String[] args){ new Main().run(); } Scanner cin = new Scanner(new BufferedInputStream(System.in)); }
1	public class C{ InputStream is ; int __t__ = 1; int __f__ = 0; int __FILE_DEBUG_FLAG__ = __f__; String __DEBUG_FILE_NAME__ = "src/C4"; FastScanner in ; PrintWriter out ; int charToIndex( char c){ if ( Character.isLowerCase(c)) return (c - 'a'); else if ( Character.isUpperCase(c)) return ((c - 'A') + 26); return -1;} int CH_NUM = 52; public void solve(){ int n = in.nextInt();  String s = in.next();  boolean[] exist = new boolean[CH_NUM];  int typeNum = 0; for ( int i = 0;(i < n);i++) { int idx = charToIndex(s.charAt(i)); if ( !exist[idx]) {exist[idx] = true; typeNum++; } } int get = 0;  int tail = 0,head = 0;  int res = Integer.MAX_VALUE;  int[] cnt = new int[CH_NUM]; while(((tail < n) || (head < n))){if ( ((head == n) || (typeNum == get))) { int idx = charToIndex(s.charAt(tail++)); if ( (cnt[idx] == 1)) get--; cnt[idx]--; } else { int idx = charToIndex(s.charAt(head++)); if ( (cnt[idx] == 0)) get++; cnt[idx]++; }if ( (typeNum == get)) res = Math.min(res,(head - tail)); }System.out.println(res); } public void run(){ if ( (__FILE_DEBUG_FLAG__ == __t__)) {try{is = new FileInputStream(__DEBUG_FILE_NAME__); }catch (FileNotFoundException e){ e.printStackTrace(); } System.out.println("FILE_INPUT!"); } else {is = System.in; }in = new FastScanner(is); out = new PrintWriter(System.out); solve(); } public static void main( String[] args){ new C().run(); } 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));} int nextInt(){ return Integer.parseInt(next());} int[] nextIntArray( int n){ return nextIntArray(n,0);} int[] nextIntArray( int n, int margin){ int[] array = new int[(n + margin)]; for ( int i = 0;(i < n);i++) array[(i + margin)] = nextInt(); return array;} long nextLong(){ return Long.parseLong(next());} long[] nextLongArray( int n){ return nextLongArray(n,0);} long[] nextLongArray( int n, int margin){ long[] array = new long[(n + margin)]; for ( int i = 0;(i < n);i++) array[(i + margin)] = nextLong(); return array;} double nextDouble(){ return Double.parseDouble(next());} double[] nextDoubleArray( int n){ return nextDoubleArray(n,0);} double[] nextDoubleArray( int n, int margin){ double[] array = new double[(n + margin)]; for ( int i = 0;(i < n);i++) array[(i + margin)] = nextDouble(); return array;} 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();} } }
3	public class Main{ public static void main( String[] args)throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in),new PrintWriter(System.out)); new Main(io).solve(); io.close(); } ConsoleIO io ; Main( ConsoleIO io){ this.io = io; } List<List<Integer>> gr = new ArrayList<>(); long MOD = 1_000_000_007; public void solve(){ int n = io.ri(),r = io.ri();  double[] res = new double[n];  int[] xs = new int[n]; for ( int i = 0;(i < n);i++) { int x = io.ri(); xs[i] = x; double max = r; for ( int j = 0;(j < i);j++) { int dx = Math.abs((xs[j] - x));  int dx2 = (dx * dx); if ( (dx <= (2 * r))) {max = Math.max(max,(Math.sqrt((((4 * r) * r) - dx2)) + res[j])); } }res[i] = max; } StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < res.length);i++) {if ( (i > 0)) sb.append(' '); sb.append(res[i]); }io.writeLine(sb.toString()); } } class ConsoleIO{ BufferedReader br ; PrintWriter out ; public ConsoleIO( Reader reader, PrintWriter writer){ br = new BufferedReader(reader); out = writer; } public void flush(){ this.out.flush(); } public void close(){ this.out.close(); } public void writeLine( String s){ this.out.println(s); } public int read( char[] buf, int len){ try{return br.read(buf,0,len); }catch (Exception ex){ return -1;} } public String readLine(){ try{return br.readLine(); }catch (Exception ex){ return "";} } public int ri(){ try{ int r = 0;  boolean start = false;  boolean neg = false; while(true){ int c = br.read(); if ( ((c >= '0') && (c <= '9'))) {r = (((r * 10) + c) - '0'); start = true; } else if ( (!start && (c == '-'))) {start = true; neg = true; } else if ( (start || (c == -1))) return (neg?-r:r); } }catch (Exception ex){ return -1;} } }
6	public class B{ public static void main( String[] args){ new B(new FastScanner()); } int hash( int i, int[] cc){ int res = i; for ( int ii :cc) {res *= 8; res += ii; }return res;} int N ,K ,A ; int[] lvl ; int[] vs ; double calc( int i, int[] cc){ double res = 0;  int cnt = 0; for ( int m = 0;(m < (1 << N));m++) { double pt = 1.0;  boolean passed = true;  int nG = 0;  int lvlcnt = 0; for ( int j = 0;(j < N);j++) { int p = ((10 * cc[j]) + vs[j]);  int u = (m & (1 << j));  boolean votesGood = (u > 0); if ( votesGood) nG++; else lvlcnt += lvl[j]; if ( ((p == 0) && votesGood)) passed = false; if ( ((p == 100) && votesGood)) passed = false; if ( !passed) break; if ( votesGood) pt *= (p / 100.0); else pt *= ((100 - p) / 100.0); }if ( (passed == false)) continue; if ( ((2 * nG) <= N)) { double p1 = (A / (1.0 * (A + lvlcnt))); res += ((1 - p1) * pt); } }return (1.0 - res);} HashMap<Integer,Double> memo ; double go( int i, int[] cc){ if ( (i == -1)) return calc(i,cc); int hv = hash(i,cc);  Double rr = memo.get(hv); if ( (rr != null)) return rr; double res = go((i - 1),cc); for ( int j = 0;(j < N);j++) { int cv = (vs[j] + (cc[j] * 10)); if ( (cv == 100)) continue; cc[j]++; double rrr = go((i - 1),cc); cc[j]--; if ( (rrr > res)) res = rrr; }memo.put(hv,res); return res;} public B( FastScanner in){ N = in.nextInt(); K = in.nextInt(); A = in.nextInt(); memo = new HashMap<Integer,Double>(); lvl = new int[N]; vs = new int[N]; for ( int i = 0;(i < N);i++) {lvl[i] = in.nextInt(); vs[i] = in.nextInt(); } int[] cs = new int[8];  double res = go((K - 1),cs); System.out.printf("%.10f%n",res); } } class FastScanner{ 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;} } }
3	public class Main{ Scanner scanner = new Scanner(System.in); public static void main( String[] args){ new Main().solve(); } void solve(){ int n = scanner.nextInt(); scanner.nextLine(); String s1 = scanner.nextLine();  String s2 = scanner.nextLine();  int ans = 0;  boolean a[] = new boolean[30];  boolean b[] = new boolean[30]; for ( int i = 0;(i < n);i++) {if ( (s1.charAt(i) != s2.charAt(i))) {ans++; a[(s1.charAt(i) - 'a')] = true; b[(s2.charAt(i) - 'a')] = true; } }for ( int i = 0;(i < n);i++) {if ( (((s1.charAt(i) != s2.charAt(i)) && a[(s2.charAt(i) - 'a')]) && b[(s1.charAt(i) - 'a')])) {for ( int j = (i + 1);(j < n);j++) {if ( ((s1.charAt(i) == s2.charAt(j)) && (s1.charAt(j) == s2.charAt(i)))) {out.println((ans - 2)); out.println((((i + 1) + " ") + (j + 1))); return ;} }} }for ( int i = 0;(i < n);i++) {if ( ((s1.charAt(i) != s2.charAt(i)) && (a[(s2.charAt(i) - 'a')] || b[(s1.charAt(i) - 'a')]))) {for ( int j = (i + 1);(j < n);j++) {if ( ((s1.charAt(j) != s2.charAt(j)) && ((s1.charAt(i) == s2.charAt(j)) || (s1.charAt(j) == s2.charAt(i))))) {out.println((ans - 1)); out.println((((i + 1) + " ") + (j + 1))); return ;} }} }out.println(ans); out.println(((-1 + " ") + -1)); } }
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.readInt();  int r = in.readInt();  int[] x = IOUtils.readIntArray(in,n);  double[] y = new double[n]; for ( int idx = 0;(idx < x.length);idx++) { double yRes = r; for ( int prev = 0;(prev < idx);prev++) { int xDelta = Math.abs((x[idx] - x[prev])); if ( (xDelta <= (2 * r))) { double yDelta = calcDelta(xDelta,r); yRes = Math.max(yRes,(y[prev] + yDelta)); } }y[idx] = yRes; }out.printLine(y); } private double calcDelta( int xDelta, int r){ return Math.sqrt((((4 * r) * r) - (xDelta * xDelta)));} } 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( double[] array){ for ( int i = 0;(i < array.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(array[i]); }} public void printLine( double[] array){ print(array); 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 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); } } }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long l = sc.nextLong(),r = sc.nextLong(); if ( (((l % 2) == 0) && ((r - l) >= 2))) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else if ( (((l % 2) == 1) && ((r - l) >= 3))) {System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); } else {System.out.println(-1); }} }
6	public class B2{ String s = null; String[] ss = null; int[][] sn = null; int n = 0; double ans = 1; int A = 0; public void run()throws Exception { BufferedReader br = null;  File file = new File("input.txt"); if ( file.exists()) {br = new BufferedReader(new FileReader("input.txt")); } else {br = new BufferedReader(new InputStreamReader(System.in)); }s = br.readLine(); ss = s.split(" "); n = Integer.parseInt(ss[0]); int k = Integer.parseInt(ss[1]); A = Integer.parseInt(ss[2]); sn = new int[n][2]; for ( int i = 0;(i < n);i++) {s = br.readLine(); ss = s.split(" "); sn[i][0] = Integer.parseInt(ss[0]); sn[i][1] = Integer.parseInt(ss[1]); } int num = 0; for ( int i = 0;(i < n);i++) {num += ((100 - sn[i][1]) / 10); }if ( (k >= num)) {System.out.println("1.0"); return ;} check(0,k,sn); ans = (1 - ans); System.out.println(ans); } void check( int i, int k, int[][] sn){ if ( ((i == n) && (k == 0))) {check2(sn); return ;} else if ( ((i == n) && (k > 0))) {return ;} else if ( (k == 0)) {check((i + 1),k,sn); } else {for ( int j = 0;(j <= k);j++) {if ( ((sn[i][1] + (j * 10)) <= 100)) { int[][] nsn = copy(sn); nsn[i][1] += (j * 10); check((i + 1),(k - j),nsn); } }}} void check2( int[][] sn){ List<Integer> target = new ArrayList<Integer>();  int h = 0; for ( int i = 0;(i < sn.length);i++) {if ( (sn[i][1] != 100)) {target.add(i); } else {h++; }}if ( (h > (n / 2))) {System.out.println("1.0"); System.exit(0); } int makemax = (n - h);  int makemin = ((n + 1) / 2);  double ma = 0; for ( int i = makemax;(i >= makemin);i--) { Combination c = new Combination(makemax,i);  Iterator<int[]> ite = c.iterator(); while(ite.hasNext()){ int[] ret = ite.next();  Set<Integer> make = new HashSet<Integer>(); for ( int j = 0;(j < ret.length);j++) {if ( (ret[j] > 0)) {make.add(target.get(j)); } } double makeK = 1;  int B = 0; for ( int j = 0;(j < n);j++) { int perc = 0; if ( make.contains(j)) {perc = (100 - sn[j][1]); B += sn[j][0]; } else {perc = sn[j][1]; }makeK *= ((double)perc / 100); }ma += (makeK * (1 - ((double)A / (A + B)))); }}ans = Math.min(ans,ma); } int[][] copy( int[][] sn){ int[][] csn = new int[sn.length][2]; for ( int i = 0;(i < sn.length);i++) {csn[i][0] = sn[i][0]; csn[i][1] = sn[i][1]; }return csn;} public static void main( String[] args)throws Exception { B2 t = new B2(); t.run(); } public class Combination implements Iterable<int[]>{ private final int max ; private final int select ; public Combination( int max, int select){ if ( ((max < 1) || (62 < max))) {throw (new IllegalArgumentException());} this.max = max; this.select = select; } public Iterator<int[]> iterator(){ return new CombinationIterator(max,select);} private class CombinationIterator implements Iterator<int[]>{ private long value ; private final long max ; private final int size ; private int[] ret = null; public CombinationIterator( int max, int select){ this.value = ((1L << select) - 1L); this.size = max; this.max = (1L << max); this.ret = new int[size]; } public boolean hasNext(){ return (value < max);} public int[] next(){ long stock = value; value = next(value); for ( int i = 0;(i < size);i++) { long tmp = (stock >> i); tmp = (tmp & 1); ret[i] = (int)tmp; }return ret;} private long next( long source){ long param1 = smallestBitOf(source);  long param2 = (param1 + source);  long param3 = smallestBitOf(param2);  long param5 = ((param3 / param1) >>> 1); return ((param5 - 1) + param2);} private long smallestBitOf( long source){ long result = 1L; while(((source % 2) == 0)){source >>>= 1; result <<= 1; }return result;} } } }
1	public class BOOL{ static char[][] ch ; static int n ,m ; static private FastReader in = new FastReader(); public static void main( String[] args){ int n = in.nextInt();  int a[] = new int[1000002];  int dp[] = new int[1000002],ans = 0; for ( int i = 0;(i < n);i++) {a[in.nextInt()] = in.nextInt(); }dp[0] = ((a[0] == 0)?0:1); for ( int i = 1;(i < 1000002);i++) {if ( (a[i] == 0)) {dp[i] = dp[(i - 1)]; } else {if ( (a[i] >= i)) {dp[i] = 1; } else {dp[i] = (dp[((i - a[i]) - 1)] + 1); }}if ( (dp[i] >= ans)) ans = dp[i]; }System.out.println((n - ans)); } } 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());} }
4	public class Main{ public static void main( String[] args)throws Exception { Thread thread = new Thread(null,new TaskAdapter(),"",(1 << 29)); thread.start(); thread.join(); } static class TaskAdapter implements Runnable{ } static class CCompressionAndExpansion{ Node end = new Node(null,-1); FastOutput out ; public void solve( int testNumber, FastInput in, FastOutput out){ int n = in.ri();  List<Node> seq = new ArrayList<>(n);  Deque<Node> dq = new ArrayDeque<>(n); end = new Node(null,-1); dq.addLast(end); for ( int i = 0;(i < n);i++) { int x = in.ri(); while(true){ Node last = dq.peekLast(); if ( (last.nextChild != x)) {dq.removeLast(); continue;} last.nextChild++; dq.addLast(new Node(dq.peekLast(),x)); break;}seq.add(dq.peekLast()); }this.out = out; for ( Node node :seq) {print(node); out.println(); }} void print( Node root){ if ( (root.p != end)) {print(root.p); out.append('.'); } out.append(root.index); } } static class FastInput{ private final InputStream is ; private StringBuilder defaultStringBuf = new StringBuilder((1 << 13)); 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 String next(){ return readString();} public int ri(){ return readInt();} public int readInt(){ boolean rev = false; skipBlank(); if ( ((next == '+') || (next == '-'))) {rev = (next == '-'); next = read(); } int val = 0; while(((next >= '0') && (next <= '9'))){val = (((val * 10) - next) + '0'); next = read(); }return (rev?val:-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);} } static class Node{ Node p ; int index ; int nextChild = 1; public Node( Node p, int index){ this.p = p; this.index = index; } } static class FastOutput implements AutoCloseable,Closeable,Appendable{ static private final int THRESHOLD = (32 << 10); private final Writer os ; private StringBuilder cache = new StringBuilder((THRESHOLD * 2)); public FastOutput append( CharSequence csq){ cache.append(csq); return this;} public FastOutput append( CharSequence csq, int start, int end){ cache.append(csq,start,end); return this;} private void afterWrite(){ if ( (cache.length() < THRESHOLD)) {return ;} flush(); } public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput append( char c){ cache.append(c); afterWrite(); return this;} public FastOutput append( int c){ cache.append(c); afterWrite(); return this;} public FastOutput println(){ return append('\n');} 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();} } }
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());} } }
0	public class Hexadec implements Runnable{ static final String taskname = "filename"; public void solve()throws Exception { int n = Integer.parseInt(in.readLine()); out.write(((((n + " ") + 0) + " ") + 0)); } 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){ new Thread(new Hexadec()).start(); } }
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());} }
4	public class ques3{ public static void main( String[] args)throws Exception { new ques3().run(); } long mod = (1000000000 + 7); void solve()throws Exception { for ( int ii = ni();(ii > 0);ii--) { int n = ni();  Stack<Integer> st = new Stack<Integer>();  int x = ni(); st.add(1); out.println("1"); for ( int i = 2;(i <= n);i++) {x = ni(); if ( (x == 1)) {st.add(1); Stack<Integer> tep = (Stack<Integer>)st.clone(); display(tep); continue;} int top = st.peek(); if ( ((top + 1) == x)) {st.pop(); st.add(x); Stack<Integer> tep = (Stack<Integer>)st.clone(); display(tep); continue;} while(true){top = st.peek(); if ( ((top + 1) == x)) {st.pop(); st.add(x); Stack<Integer> tep = (Stack<Integer>)st.clone(); display(tep); break;} top = st.pop(); }}}} void display( Stack<Integer> st){ ArrayList<Integer> al = new ArrayList<>(); while((st.size() != 0)){ int tem = st.pop(); al.add(tem); }Collections.reverse(al); for ( int i = 0;(i < (al.size() - 1));i++) {out.print((al.get(i) + ".")); }out.println(al.get((al.size() - 1))); } private byte[] buf = new byte[1024]; private int index ; private InputStream in ; private int total ; private SpaceCharFilter filter ; PrintWriter out ; int min( int... ar){ int min = Integer.MAX_VALUE; for ( int i :ar) min = Math.min(min,i); return min;} long min( long... ar){ long min = Long.MAX_VALUE; for ( long i :ar) min = Math.min(min,i); return min;} int max( int... ar){ int max = Integer.MIN_VALUE; for ( int i :ar) max = Math.max(max,i); return max;} long max( long... ar){ long max = Long.MIN_VALUE; for ( long i :ar) max = Math.max(max,i); return max;} void reverse( int[] a){ for ( int i = 0;(i < (a.length >> 1));i++) { int tem = a[i]; a[i] = a[((a.length - 1) - i)]; a[((a.length - 1) - i)] = tem; }} void reverse( long[] a){ for ( int i = 0;(i < (a.length >> 1));i++) { long tem = a[i]; a[i] = a[((a.length - 1) - i)]; a[((a.length - 1) - i)] = tem; }} String reverse( String s){ StringBuilder sb = new StringBuilder(s); sb.reverse(); return sb.toString();} int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} void run()throws Exception { in = System.in; out = new PrintWriter(System.out); solve(); out.flush(); } private 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++];} private int ni()throws IOException { int c = scan(); while(isSpaceChar(c))c = scan(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = scan(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = scan(); }while(!isSpaceChar(c));return (res * sgn);} private String ns()throws IOException { int c = scan(); while(isSpaceChar(c))c = scan(); StringBuilder res = new StringBuilder(); do {if ( Character.isValidCodePoint(c)) res.appendCodePoint(c); c = scan(); }while(!isSpaceChar(c));return res.toString();} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; return false;} private boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhiteSpace(c);} private interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } }
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();  TreeSet<Integer> al = new TreeSet<Integer>();  TreeMap<Integer,Integer> mp = new TreeMap<Integer,Integer>();  int[] ans = new int[n]; Arrays.fill(ans,-1); TreeSet<Integer> used = new TreeSet<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;  TreeSet<Integer> u2 = new TreeSet<Integer>(); u2.add(pr); if ( (al.contains((a - pr)) && !u2.contains((a - pr)))) cc = (a - pr); else if ( (al.contains((b - pr)) && !u2.contains((a - pr)))) cc = (b - pr); if ( (cc != -1)) {u2.add(cc); boolean bGo = true; while(bGo){bGo = false; int nxt = -1; if ( (al.contains((a - cc)) && !u2.contains((a - cc)))) nxt = (a - cc); else if ( (al.contains((b - cc)) && !u2.contains((b - cc)))) nxt = (b - cc); if ( (nxt != -1)) {bGo = true; u2.add(nxt); cc = nxt; pr = cc; } }st = cc; } } int x = st; while((x != -1)){ int curr = x; used.add(curr); x = -1; int next1 = (a - curr); if ( al.contains(next1)) {if ( !used.contains(next1)) {x = next1; int ci = mp.get(curr);  int ni = mp.get(next1); if ( ((ans[ci] == -1) && (ans[ni] == -1))) {ans[ni] = 0; ans[ci] = 0; } } } int next2 = (b - curr); if ( al.contains(next2)) {if ( !used.contains(next2)) {x = next2; int ci = mp.get(curr);  int ni = mp.get(next2); if ( ((ans[ci] == -1) && (ans[ni] == -1))) {ans[ni] = 1; ans[ci] = 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] + " ")); }} }
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 ; boolean[] iq ; 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_]; 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)); } boolean dijkstra( int s, int t){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((dd[u] != dd[v])?(dd[u] - dd[v]):(u - v)))); pq.add(s); iq[s] = true; Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first; iq[u] = false; 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)))) {if ( iq[v]) {pq.remove(v); iq[v] = false; } pi[v] = p; dd[v] = d; bb[v] = h_; pq.add(v); iq[v] = true; } } }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(dijkstra(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))); } }
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(); } }
2	public class B{ public static void main( String[] args){ Scanner qwe = new Scanner(System.in);  int n = qwe.nextInt();  int x11 = bins(true,1,2,n,qwe,true);  int y11 = bins(true,1,2,n,qwe,false);  int x12 = bins(false,0,1,n,qwe,true);  int y12 = bins(false,0,1,n,qwe,false);  int x21 = bins(true,0,1,n,qwe,true);  int y21 = bins(true,0,1,n,qwe,false);  int x22 = bins(false,1,2,n,qwe,true);  int y22 = bins(false,1,2,n,qwe,false);  int[] xsl = {x11,x21};  int[] xsr = {x12,x22};  int[] ysl = {y11,y21};  int[] ysr = {y12,y22};  int[] ans = new int[8]; for ( int xpl = 0;(xpl < 2);xpl++) {for ( int xpr = 0;(xpr < 2);xpr++) for ( int ypl = 0;(ypl < 2);ypl++) {for ( int ypr = 0;(ypr < 2);ypr++) {if ( ((((xsl[xpl] <= xsr[xpr]) && (xsl[(1 - xpl)] <= xsr[(1 - xpr)])) && (ysl[ypl] <= ysr[ypr])) && (ysl[(1 - ypl)] <= ysr[(1 - ypr)]))) {System.out.printf("? %d %d %d %d",xsl[xpl],ysl[ypl],xsr[xpr],ysr[ypr]); System.out.println(); System.out.flush(); int response1 = qwe.nextInt(); System.out.printf("? %d %d %d %d",xsl[(1 - xpl)],ysl[(1 - ypl)],xsr[(1 - xpr)],ysr[(1 - ypr)]); System.out.println(); System.out.flush(); int response2 = qwe.nextInt(); if ( ((response1 == 1) && (response2 == 1))) {ans = new int[]{xsl[xpl],ysl[ypl],xsr[xpr],ysr[ypr],xsl[(1 - xpl)],ysl[(1 - ypl)],xsr[(1 - xpr)],ysr[(1 - ypr)]}; } } }}}System.out.printf("! %d %d %d %d %d %d %d %d",ans[0],ans[1],ans[2],ans[3],ans[4],ans[5],ans[6],ans[7]); System.out.println(); System.out.flush(); qwe.close(); } static int bins( boolean leftbound, int small, int big, int n, Scanner qwe, boolean isx){ int min = 0;  int max = n; if ( leftbound) {min++; max++; } int y1 = 1;  int y2 = n;  int x1 = 1;  int x2 = n; while(((min + 1) < max)){ int med = ((min + max) / 2); if ( isx) {if ( !leftbound) x2 = med; else x1 = med; } else {if ( !leftbound) y2 = med; else y1 = med; }System.out.printf("? %d %d %d %d",x1,y1,x2,y2); System.out.println(); System.out.flush(); int response = qwe.nextInt(); if ( leftbound) {if ( (response >= big)) min = med; else max = med; } else {if ( (response < big)) {min = med; } else {max = med; }}}if ( leftbound) max--; return max;} }
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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ double special( int[] loyalties, int[] levels, int playerlevelsum){ int poss = (1 << loyalties.length);  double res = 0; for ( int pos = 0;(pos < poss);pos++) { double occurs = 1;  int happy = 0;  int badlevelssum = 0; for ( int i = 0;(i < loyalties.length);i++) {if ( (((pos >> i) & 1) == 1)) {happy++; occurs *= ((double)loyalties[i] / 100); } else {badlevelssum += levels[i]; occurs *= ((double)(100 - loyalties[i]) / 100); }} double winprob = ((happy <= (levels.length / 2))?((double)playerlevelsum / (playerlevelsum + badlevelssum)):1); res += (occurs * winprob); }return res;} public void solve( int testNumber, InputReader in, OutputWriter out){ int senators = in.readInt();  int sweets = in.readInt();  int playerlevelsum = in.readInt();  int[] levels = new int[senators];  int[] loyalties = new int[senators]; IOUtils.readIntArrays(in,levels,loyalties); ArrayList<ArrayList<Integer>> possibilities = new ArrayList<>(Arrays.asList(new ArrayList<>())); for ( int senator = 0;(senator < senators);senator++) { ArrayList<ArrayList<Integer>> newpossibilities = new ArrayList<>(); for ( ArrayList<Integer> al :possibilities) { int sumsofar = 0; for ( int val :al) sumsofar += val; int minadd = ((senator == (senators - 1))?(sweets - sumsofar):0); for ( int moar = minadd;(moar <= (sweets - sumsofar));moar++) { ArrayList<Integer> copy = new ArrayList<>(al); copy.add(moar); newpossibilities.add(copy); }}possibilities = newpossibilities; } double res = 0; for ( ArrayList<Integer> al :possibilities) { int[] newloyalties = new int[senators]; for ( int i = 0;(i < senators);i++) newloyalties[i] = Math.min(100,(loyalties[i] + (10 * al.get(i)))); double special = special(newloyalties,levels,playerlevelsum);  double tot = special; res = Math.max(res,tot); }out.printLine(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 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 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(); } } }
6	public class TemnayaAssambleya implements Runnable{ public static void main( String[] args){ new Thread(new TemnayaAssambleya()).run(); } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer in ; PrintWriter out = new PrintWriter(System.out); public String nextToken()throws IOException { while(((in == null) || !in.hasMoreTokens())){in = new StringTokenizer(br.readLine()); }return in.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} int[] l ; int[] ln ; int[] pw ; int[] p ; int A ; double max = 0; public void gen( int n, int k){ if ( (n == 0)) {n = p.length; p[0] = k; for ( int i = 0;(i < n);i++) {ln[i] = (l[i] + (p[i] * 10)); if ( (ln[i] > 100)) ln[i] = 100; } double ans = 0; for ( int mask = 0;(mask < (1 << n));mask++) { int z = 0;  double pos = 1;  int power = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) > 0)) {z++; pos *= ((ln[i] * 1.) / 100); } else {pos *= (((100 - ln[i]) * 1.) / 100); power += pw[i]; }}if ( (z > (n / 2))) {ans += pos; } else {ans += ((pos * A) / (A + power)); }}max = Math.max(ans,max); return ;} for ( int i = 0;(i <= Math.min(k,(10 - (l[n] / 10))));i++) {p[n] = i; gen((n - 1),(k - i)); }} public void solve()throws IOException { int n = nextInt();  int k = nextInt(); A = nextInt(); p = new int[n]; pw = new int[n]; l = new int[n]; ln = new int[n]; for ( int i = 0;(i < n);i++) {pw[i] = nextInt(); l[i] = nextInt(); }gen((n - 1),k); out.println(max); } public void run(){ try{solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } }
4	public class B{ static PrintWriter out ; static InputReader in ; public static void main( String[] args){ out = new PrintWriter(System.out); in = new InputReader(); new B(); out.flush(); out.close(); } B(){ solve(); } void solve(){ int n = in.nextInt(),mod = in.nextInt();  long dp[][] = new long[(n + 1)][(n + 1)];  long ncr[][] = new long[810][410]; ncr[0][0] = 1; for ( int i = 1;(i < 810);i++) {for ( int j = 0;(j < 410);j++) {ncr[i][j] = ((ncr[(i - 1)][j] + ((j > 0)?ncr[(i - 1)][(j - 1)]:0)) % mod); }}for ( int i = 1;(i <= n);i++) dp[i][i] = 1; for ( int i = 1;(i < n);i++) {for ( int j = 1;((j + i) <= n);j++) { int end = (i + j); dp[j][end] = ((dp[(j + 1)][end] + dp[j][(end - 1)]) % mod); }} long value[] = new long[(n + 1)]; for ( int i = 1;(i <= n);i++) {value[i] = dp[1][i]; } long fdp[][] = new long[(n + 2)][(n + 2)]; fdp[0][0] = 1; long ans = 0; for ( int b = 1;(b <= ((n + 1) / 2));b++) {for ( int i = 1;(i <= n);i++) {for ( int k = Math.max(0,(b - 2));(k < i);k++) {fdp[(i + 1)][b] = ((fdp[(i + 1)][b] + ((((fdp[k][(b - 1)] * value[(i - k)]) % mod) * ncr[(((((k - b) + 2) + i) - k) - 1)][(i - k)]) % mod)) % mod); }}ans = ((ans + fdp[(n + 1)][b]) % mod); }out.print(ans); } public static class InputReader{ BufferedReader br ; StringTokenizer st ; InputReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public int nextInt(){ return Integer.parseInt(next());} public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ } }return st.nextToken();} } }
2	public class mad{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int cura = 0,curb = 0;  int ver ; System.out.println("? 0 0"); System.out.flush(); ver = sc.nextInt(); for ( int i = 29;(i >= 0);i--) {System.out.println(((("? " + (cura + (1 << i))) + " ") + curb)); System.out.flush(); int temp1 = sc.nextInt(); System.out.println(((("? " + cura) + " ") + (curb + (1 << i)))); System.out.flush(); int temp2 = sc.nextInt(); if ( (temp1 != temp2)) {if ( (temp2 == 1)) {cura += (1 << i); curb += (1 << i); } } else {if ( (ver == 1)) cura += (1 << i); if ( (ver == -1)) curb += (1 << i); ver = temp1; }}System.out.println(((("! " + cura) + " ") + curb)); } }
1	public class Main{ static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static long oo = 1000000000000L; public static void main( String[] args)throws IOException { int n = in.nextInt();  int q = in.nextInt();  ArrayDeque<Integer> dq = new ArrayDeque<>();  int max = -1; for ( int i = 0;(i < n);++i) { int x = in.nextInt(); dq.add(x); max = Math.max(max,x); } ArrayList<Pair> ans = new ArrayList<>(); while((dq.peekFirst() != max)){ int a = dq.pollFirst();  int b = dq.pollFirst(); ans.add(new Pair(a,b)); if ( (a > b)) {dq.addFirst(a); dq.addLast(b); } else {dq.addFirst(b); dq.addLast(a); }} ArrayList<Integer> a = new ArrayList<>(); dq.pollFirst(); for ( int x :dq) a.add(x); while((q-- > 0)){ long m = (in.nextLong() - 1); if ( (m < ans.size())) {System.out.println(((ans.get((int)m).first + " ") + ans.get((int)m).second)); } else { int idx = (int)((m - ans.size()) % a.size()); System.out.println(((max + " ") + a.get(idx))); }}out.close(); } static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} static long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} static class Pair implements Comparable<Pair>{ int first ,second ; public Pair( int first, int second){ super(); this.first = first; this.second = second; } } } 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 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 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));} }
2	public class Pipeline{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long k = sc.nextLong(); sc.close(); if ( ((((k * (k - 1)) / 2) + 1) < n)) {System.out.println(-1); } else { long l = -1,r = k; while(((r - l) > 1)){ long m = ((r + l) / 2); if ( (cantidadPosible(k,m) >= n)) {r = m; } else {l = m; }}System.out.println(r); }} static private long cantidadPosible( long k, long usadas){ return ((((k * (k - 1)) / 2) + 1) - (((k - usadas) * ((k - usadas) - 1)) / 2));} }
1	public class Solution{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  String s = sc.next();  StringBuilder ans = new StringBuilder();  int count = 0;  int open = 0; for ( int i = 0;(i < s.length());i++) {if ( (s.charAt(i) == '(')) {ans.append("("); count++; open++; } else {ans.append(")"); open--; }if ( (count == (k / 2))) {break;} }while((open > 0)){ans.append(")"); open--; }System.out.println(ans.toString()); } }
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))); } }
1	public class Code{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  HashMap<Double,Integer> h = new HashMap<>();  double[] temp = new double[n];  int m = 0; for ( int i = 0;(i < n);i++) { String l = br.readLine();  int[] x = new int[4];  int k = 0;  boolean t = false; for ( int j = 0;(j < l.length());j++) {if ( ((((l.charAt(j) == '(') || (l.charAt(j) == '+')) || (l.charAt(j) == ')')) || (l.charAt(j) == '/'))) x[k++] = j; } double a = Integer.parseInt(l.substring((x[0] + 1),x[1]));  double b = Integer.parseInt(l.substring((x[1] + 1),x[2]));  double c = Integer.parseInt(l.substring((x[3] + 1))); temp[m++] = ((a + b) / c); if ( h.containsKey(((a + b) / c))) h.put(((a + b) / c),(h.get(((a + b) / c)) + 1)); else h.put(((a + b) / c),1); }for ( int i = 0;(i < n);i++) {System.out.print((h.get(temp[i]) + " ")); }} }
1	public class Main{ public static StreamTokenizer in ; public static PrintStream out ; public static BufferedReader br ; public static String readLine()throws IOException { return br.readLine();} public static int genans( String ss){ int n = ss.length();  char[] s = ss.toCharArray();  int res = 0; while(true){ int firstT = -1; for ( int i = 0;(i < n);i++) if ( (s[i] == 'T')) {firstT = i; break;} int lastH = -1; for ( int i = (n - 1);(i >= 0);i--) if ( (s[i] == 'H')) {lastH = i; break;} if ( (firstT < lastH)) {res++; s[firstT] = 'H'; s[lastH] = 'T'; } else break;}return res;} public static void main( String[] args)throws IOException { in = new StreamTokenizer(new InputStreamReader(System.in)); br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintStream(System.out); readLine(); String s = readLine();  int n = s.length();  String kk = s;  int ans = (n * 100); for ( int tr = 0;(tr < (n + 2));tr++) { String kk2 = ""; for ( int i = 1;(i < n);i++) kk2 = (kk2 + kk.charAt(i)); kk2 = (kk2 + kk.charAt(0)); kk = kk2; int cur = genans(kk); if ( (cur < ans)) ans = cur; }out.println(ans); } }
4	public class D{ 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]; }} static int n ,m ,k ,uu[][] ,rr[][] ,dd[][] ,ll[][] ,dp[][][] ; public static void main( String[] args)throws IOException { Scan input = new Scan();  StringBuilder ans = new StringBuilder(""); n = input.scanInt(); m = input.scanInt(); k = input.scanInt(); dp = new int[n][m][k]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {for ( int kk = 0;(kk < k);kk++) {dp[i][j][kk] = -1; }}}uu = new int[n][m]; rr = new int[n][m]; dd = new int[n][m]; ll = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int tmp = input.scanInt(); rr[i][j] = tmp; ll[i][(j + 1)] = tmp; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { int tmp = input.scanInt(); dd[i][j] = tmp; uu[(i + 1)][j] = tmp; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( ((k % 2) != 0)) {ans.append((-1 + " ")); continue;} ans.append(((2 * solve(i,j,(k / 2))) + " ")); }ans.append("\n"); }System.out.println(ans); } public static int solve( int x, int y, int rem){ if ( (rem == 0)) {return 0;} if ( (dp[x][y][rem] != -1)) {return dp[x][y][rem];} int ans = (Integer.MAX_VALUE / 10); if ( (uu[x][y] != 0)) {ans = Math.min(ans,(uu[x][y] + solve((x - 1),y,(rem - 1)))); } if ( (rr[x][y] != 0)) {ans = Math.min(ans,(rr[x][y] + solve(x,(y + 1),(rem - 1)))); } if ( (dd[x][y] != 0)) {ans = Math.min(ans,(dd[x][y] + solve((x + 1),y,(rem - 1)))); } if ( (ll[x][y] != 0)) {ans = Math.min(ans,(ll[x][y] + solve(x,(y - 1),(rem - 1)))); } dp[x][y][rem] = ans; return ans;} }
5	public class R111_D2_A{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  int n = in.readInt();  int[] inp = new int[n]; for ( int i = 0;(i < inp.length);i++) {inp[i] = in.readInt(); }Arrays.sort(inp); int sum1 = 0;  int res = 0; for ( int i = (inp.length - 1);(i >= 0);i--) {sum1 += inp[i]; res++; int sum2 = 0; for ( int j = 0;(j < i);j++) {sum2 += inp[j]; }if ( (sum1 > sum2)) {break;} }System.out.println(res); } 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();} } }
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(); } }
4	public class Solution{ 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{ int[][] or ; int n ; int m ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); int k = in.nextInt();  ArrayList<Point> arr1 = new ArrayList<>();  ArrayList<Point> arr2 = new ArrayList<>(); for ( int i = 0;(i < k);i++) {arr1.add(new Point(in.nextInt(),in.nextInt())); }or = new int[(n + 1)][(m + 1)]; for ( int i = 0;(i < k);i++) {or[arr1.get(i).x][arr1.get(i).y] = -1; } Point lastValue = arr1.get(0); while(((arr1.size() > 0) || (arr2.size() > 0))){for ( Point p :arr1) {if ( valid(new Point((p.x - 1),p.y))) {arr2.add(new Point((p.x - 1),p.y)); } if ( valid(new Point((p.x + 1),p.y))) {arr2.add(new Point((p.x + 1),p.y)); } if ( valid(new Point(p.x,(p.y - 1)))) {arr2.add(new Point(p.x,(p.y - 1))); } if ( valid(new Point(p.x,(p.y + 1)))) {arr2.add(new Point(p.x,(p.y + 1))); } }arr1.clear(); if ( (arr2.size() > 0)) {lastValue = arr2.get(0); } for ( Point p :arr2) {if ( valid(new Point((p.x - 1),p.y))) {arr1.add(new Point((p.x - 1),p.y)); } if ( valid(new Point((p.x + 1),p.y))) {arr1.add(new Point((p.x + 1),p.y)); } if ( valid(new Point(p.x,(p.y - 1)))) {arr1.add(new Point(p.x,(p.y - 1))); } if ( valid(new Point(p.x,(p.y + 1)))) {arr1.add(new Point(p.x,(p.y + 1))); } }arr2.clear(); if ( (arr1.size() > 0)) {lastValue = arr1.get(0); } }out.println(((lastValue.x + " ") + lastValue.y)); } boolean valid( Point p){ if ( ((((p.x < 1) || (p.x > n)) || ((p.y < 1) || (p.y > m))) || (or[p.x][p.y] == -1))) {return false;} or[p.x][p.y] = -1; return true;} class Point{ int x ; int y ; public Point( int a, int b){ x = a; y = 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());} } }
2	public class TC{ static long N ; static int k ; static long WHOLESUM ; static long SUM( long k){ long res = ((k * (k + 1)) / 2); return (res - 1);} static long returnPipes( int mid){ long not = SUM((mid - 1));  long totpipes = (WHOLESUM - not);  int number = ((k - mid) + 1);  long res = ((totpipes - number) + 1); return res;} static long binarySearch( int lo, int hi){ int res = Integer.MAX_VALUE;  int val = 0; while((lo <= hi)){ int mid = ((lo + hi) / 2);  long cnt = returnPipes(mid); val = ((k - mid) + 1); ;if ( (cnt < N)) {hi = (mid - 1); continue;} else {res = Math.min(val,res); lo = (mid + 1); }}if ( (res == Integer.MAX_VALUE)) return -1; else return res;} public static void main( String[] args)throws IOException { Scanner s = new Scanner(System.in); N = s.nextLong(); k = s.nextInt(); WHOLESUM = SUM(k); if ( (N <= 1)) System.out.println(0); else System.out.println(binarySearch(2,k)); } }
6	public class BetaRound8_C implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok ; 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(null,new BetaRound8_C(),"",((256 * 1024) * 1024)).start(); } final int INF = ((1000 * 1000) * 1000); int x0 ,y0 ; int n ; int[] x ,y ; int t( int i, int j){ int dx = (x[i] - x[j]);  int dy = (y[i] - y[j]); return ((dx * dx) + (dy * dy));} int t0( int i){ int dx = (x[i] - x0);  int dy = (y[i] - y0); return ((dx * dx) + (dy * dy));} int[] dp ; int[] p ; void solve()throws IOException { x0 = readInt(); y0 = readInt(); n = readInt(); x = new int[n]; y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = readInt(); y[i] = readInt(); }dp = new int[(1 << n)]; p = new int[(1 << n)]; Arrays.fill(dp,INF); dp[((1 << n) - 1)] = 0; get(0); out.println(dp[0]); printPath(); } int get( int mask){ if ( (dp[mask] != INF)) {return dp[mask];} int res = INF; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & mask) == 0)) { int test = (get((mask ^ (1 << i))) + (2 * t0(i))); if ( (res > test)) {res = test; p[mask] = (mask ^ (1 << i)); } for ( int j = (i + 1);(j < n);j++) {if ( (((1 << j) & mask) == 0)) {test = (((get(((mask ^ (1 << i)) ^ (1 << j))) + t0(i)) + t(i,j)) + t0(j)); if ( (res > test)) {res = test; p[mask] = ((mask ^ (1 << i)) ^ (1 << j)); } } }break;} }return dp[mask] = res;} void printPath(){ ArrayList<Integer> ans = new ArrayList<Integer>(); ans.add(0); int mask = 0; while((mask != ((1 << n) - 1))){for ( int i = 0;(i < n);i++) {if ( (((mask ^ p[mask]) & (1 << i)) != 0)) {ans.add((i + 1)); } }mask = p[mask]; ans.add(0); }for ( int x :ans) {out.print((x + " ")); }} }
5	public class kMultRedo{ static int n ; static int k ; public static void main( String[] args){ Set<Integer> set = new HashSet<Integer>(1000000);  FastScanner s = new FastScanner(); n = s.nextInt(); k = s.nextInt(); int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); }Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( ((a[i] % k) != 0)) {set.add(a[i]); } else {if ( !set.contains((a[i] / k))) {set.add(a[i]); } }}System.out.println(set.size()); } public 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());} } }
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 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 RationalResistance{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  StringTokenizer st = new StringTokenizer(f.readLine());  long a = Long.parseLong(st.nextToken());  long b = Long.parseLong(st.nextToken());  long sum = 0; while(((a != 0) && (b != 0))){if ( (a > b)) { long val = (a / b); sum += val; a -= (val * b); } else { long val = (b / a); sum += val; b -= (val * a); }}out.println(sum); out.close(); System.exit(0); } }
6	public class l{ static long mod = (int)(1e9 + 7); static int n ; static StringBuilder sol ; static boolean is ; static int[][][] memo ; static int[] val ,gen ; static int dp( int last, int rem, int msk){ if ( (rem == 0)) return 1; if ( (memo[last][rem][msk] != -1)) return memo[last][rem][msk]; int ans = 0; for ( int i = 0;(i < n);i++) {if ( ((msk & (1 << i)) == 0)) {if ( ((gen[i] != last) && (val[i] <= rem))) {ans += dp(gen[i],(rem - val[i]),(msk | (1 << i))); ans %= mod; } } }return memo[last][rem][msk] = ans;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out); n = sc.nextInt(); int t = sc.nextInt(); gen = new int[n]; val = new int[n]; for ( int i = 0;(i < n);i++) {val[i] = sc.nextInt(); gen[i] = sc.nextInt(); }memo = new int[4][(t + 1)][(1 << n)]; for ( int[][] x :memo) for ( int[] a :x) Arrays.fill(a,-1); pw.println(dp(0,t,0)); pw.flush(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( FileReader r){ br = new BufferedReader(r); } 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();} } }
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))); } }
5	public class A{ BufferedReader br ; StringTokenizer st ; PrintWriter out ; void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } int[] b = a.clone(); Arrays.sort(b); int k = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) {k++; } }if ( (k <= 2)) {out.println("YES"); } else {out.println("NO"); }} void run(){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } public static void main( String[] args){ new A().run(); } public String nextToken()throws IOException { while(((st == null) || st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
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); } }
6	public class D{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int[][] a = new int[n][n]; for ( int i = 1;(i <= m);i++) { int v1 = sc.nextInt();  int v2 = sc.nextInt(); v1--; v2--; a[v1][v2] = a[v2][v1] = 1; } long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {dp[(1 << i)][i] = 1; }for ( int mask = 0;(mask < (1 << n));mask++) {if ( (Integer.bitCount(mask) > 1)) {for ( int i = 0;(i < n);i++) {if ( (i == Integer.numberOfTrailingZeros(mask))) continue; if ( ((mask & (1 << i)) != 0)) {for ( int j = 0;(j < n);j++) {if ( (((mask & (1 << j)) != 0) && (a[j][i] == 1))) {dp[mask][i] += dp[(mask ^ (1 << i))][j]; } }} }} } long ans = 0; for ( int mask = 0;(mask < (1 << n));mask++) {if ( (Integer.bitCount(mask) >= 3)) { int t = Integer.numberOfTrailingZeros(mask); for ( int i = 0;(i < n);i++) {if ( (a[t][i] == 1)) ans += dp[mask][i]; }} }ans /= 2; System.out.println(ans); } }
4	public class Main{ static FastReader in ; static PrintWriter out ; static Random rand = new Random(); static final int oo = ((int)1e9 + 10); static final long OO = ((long)1e18 + 10); static final int MOD = ((int)1e9 + 7); static void solve(){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); } Stack<Integer> st = new Stack<>(); for ( int i = 0;(i < n);i++) {if ( (a[i] != 1)) {while((!st.empty() && ((st.peek() + 1) != a[i])))st.pop(); st.pop(); } st.push(a[i]); for ( int j = 0;(j < st.size());j++) {out.print(st.get(j)); if ( (j < (st.size() - 1))) out.print('.'); }out.println(); }} public static void main( String[] args){ in = new FastReader(); out = new PrintWriter(System.out); int t = 1; t = in.nextInt(); while((t-- > 0)){solve(); }out.flush(); out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; FastReader(){ this(System.in); } FastReader( String file)throws FileNotFoundException{ this(new FileInputStream(file)); } FastReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } int nextInt(){ return Integer.parseInt(next());} String next(){ while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(nextLine()); }return st.nextToken();} String nextLine(){ String line ; try{line = br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} return line;} } }
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());} } }
6	public class Main{ static HashSet<Integer> adjList[] ; public static void main( String[] args)throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));  StringBuilder stringBuilder = new StringBuilder();  String temp[] = bufferedReader.readLine().split(" ");  int V = Integer.parseInt(temp[0]);  int E = Integer.parseInt(temp[1]); adjList = new HashSet[V]; for ( int i = 0;(i < V);i++) adjList[i] = new HashSet<>(); for ( int i = 0;(i < E);i++) {temp = bufferedReader.readLine().split(" "); int x = (Integer.parseInt(temp[0]) - 1);  int y = (Integer.parseInt(temp[1]) - 1); adjList[y].add(x); adjList[x].add(y); }stringBuilder.append((solve(V) + "\n")); System.out.println(stringBuilder); } static private long solve( int V){ long dp[][] = new long[(1 << V)][V];  long count = 0; for ( int i = 0;(i < V);i++) dp[(1 << i)][i] = 1; for ( int mask = 1;(mask < (1 << V));mask++) { int first = Integer.numberOfTrailingZeros(mask); for ( int i = 0;(i < V);i++) {if ( (((mask & (1 << i)) == 0) || (first == i))) continue; for ( int j = 0;(j < V);j++) if ( (adjList[i].contains(j) && ((mask & (1 << j)) != 0))) dp[mask][i] += dp[(mask ^ (1 << i))][j]; if ( (Integer.bitCount(mask) >= 3)) if ( adjList[first].contains(i)) count += dp[mask][i];  }}return (count / 2);} }
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 HashSet<Pair> graph[] ; static boolean oj = (System.getProperty("ONLINE_JUDGE") != null); static int n ,T ,input[] ,type[] ; static long dp[][] ; static long dfs( int mask, int t){ if ( (dp[mask][t] != -1)) {return dp[mask][t];} int s = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {s += input[i]; } }if ( (s > T)) {return 0;} if ( (s == T)) {dp[mask][t] = 1; return dp[mask][t];} long ans = 0; for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) == 0) && (type[i] != t))) {ans = ((ans + dfs((mask | (1 << i)),type[i])) % mod); } }dp[mask][t] = ans; return dp[mask][t];} public static void main( String[] args)throws Exception { String st[] = nl(); n = pi(st[0]); T = pi(st[1]); input = new int[n]; type = new int[n]; for ( int i = 0;(i < n);i++) {st = nl(); input[i] = pi(st[0]); type[i] = pi(st[1]); }dp = new long[(1 << n)][4]; for ( long[] arr :dp) Arrays.fill(arr,-1); long ans = dfs(0,0); out.println(ans); 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; } } }
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());} void solve()throws Exception { boolean[] r = new boolean[1010]; Arrays.fill(r,true); r[0] = r[1] = false; for ( int i = 2;(i < 1010);i++) {if ( r[i]) {for ( int j = (i + i);(j < 1010);j += i) {r[j] = false; }} } int[] pr = new int[1010];  int l = 0; for ( int i = 2;(i < 1010);i++) if ( r[i]) pr[l++] = i;  int n = nextInt();  int k = nextInt();  int ans = 0;  int j = 0; for ( int i = 2;(i <= n);i++) {if ( r[i]) {for ( ;(j < (l - 1));j++) {if ( (i == ((pr[j] + pr[(j + 1)]) + 1))) {ans++; break;} if ( (i < ((pr[j] + pr[(j + 1)]) + 1))) break; }} }if ( (ans >= k)) out.println("YES"); else out.println("NO"); } }
2	public class B{ 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 half = (n / 2); pw.println("? 1"); pw.flush(); int a = sc.nextInt(); pw.println(("? " + (1 + half))); pw.flush(); int b = sc.nextInt(); if ( ((a - b) == 0)) {pw.println("! 1"); } else if ( (((a - b) % 2) != 0)) {pw.println("! -1"); } else { boolean greater = (a > b);  int lo = 1;  int hi = half;  boolean ans = false; while((lo <= hi)){ int mid = ((lo + hi) / 2); pw.println(("? " + mid)); pw.flush(); a = sc.nextInt(); pw.println(("? " + (mid + half))); pw.flush(); b = sc.nextInt(); if ( (a == b)) {pw.println(("! " + mid)); ans = true; break;} if ( ((a > b) != greater)) {hi = (mid - 1); } else {lo = (mid + 1); greater = (a > b); }}if ( !ans) {pw.println("! -1"); } }pw.flush(); pw.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(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());} 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;  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){ long n = in.nextLong();  long s = in.nextLong();  long ans = 0;  long i = 0; for ( i = s;(i <= n);i++) { long t = (i - sum(i)); if ( (t >= s)) {if ( ((i % 10) == 9)) {break;} ans++; } }if ( (n >= s)) {out.println((((ans - i) + n) + 1)); } else {out.println(0); }} static long sum( long a){ long sum = 0; while((a != 0)){sum += (a % 10); a /= 10; }return sum;} } }
2	public class CF256B extends PrintWriter{ CF256B(){ super(System.out,true); } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF256B o = new CF256B(); o.main(); o.flush(); } long count( int n, int x, int y, int r){ long a = ((((2L * r) * r) + (2 * r)) + 1);  int w ; if ( ((w = (1 - (x - r))) > 0)) a -= ((long)w * w); if ( ((w = (1 - (y - r))) > 0)) a -= ((long)w * w); if ( ((w = ((x + r) - n)) > 0)) a -= ((long)w * w); if ( ((w = ((y + r) - n)) > 0)) a -= ((long)w * w); if ( ((w = (((r - 1) - (x - 1)) - (y - 1))) > 0)) a += (((long)w * (w + 1)) / 2); if ( ((w = (((r - 1) - (x - 1)) - (n - y))) > 0)) a += (((long)w * (w + 1)) / 2); if ( ((w = (((r - 1) - (n - x)) - (y - 1))) > 0)) a += (((long)w * (w + 1)) / 2); if ( ((w = (((r - 1) - (n - x)) - (n - y))) > 0)) a += (((long)w * (w + 1)) / 2); return a;} void main(){ int n = sc.nextInt();  int x = sc.nextInt();  int y = sc.nextInt();  int c = sc.nextInt();  int lower = -1,upper = c; while(((upper - lower) > 1)){ int r = ((lower + upper) / 2); if ( (count(n,x,y,r) >= c)) upper = r; else lower = r; }println(upper); } }
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());} } }
0	public class A{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt(); System.out.println(((n / 2) * 3)); } }
5	public class Main{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer = null; public static void main( String[] args)throws IOException { new Main().execute(); } int ni()throws IOException { return Integer.parseInt(ns());} long nl()throws IOException { return Long.parseLong(ns());} String ns()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(br.readLine()); return tokenizer.nextToken();} int totalCases ,testNum ; int n ,a ,b ; long arr[] ; void execute()throws IOException { totalCases = 1; for ( testNum = 1;(testNum <= totalCases);testNum++) {if ( !input()) break; solve(); }} void solve()throws IOException { Arrays.sort(arr); long x1 = arr[(b - 1)];  long x2 = arr[b]; System.out.println((x2 - x1)); } boolean input()throws IOException { n = ni(); a = ni(); b = ni(); arr = new long[n]; for ( int i = 0;(i < n);i++) {arr[i] = nl(); }return true;} }
4	public class P1517D{ static private int n ,m ,k ; static private int[][] hor ,ver ,a ,b ; static private long ans ; static private int[][] id ; static private Integer[][][] dp ; static private int idf ; static private String s ,t ; static private HashMap<Integer,ArrayList<Integer>> g ; static private final int MOD = ((int)1e9 + 7); public static void main( String[] args){ n = ini(); m = ini(); k = ini(); if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {print((-1 + " ")); }println(); }out.flush(); return ;} hor = new int[n][(m - 1)]; ver = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {hor[i][j] = ini(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ver[i][j] = ini(); }}dp = new Integer[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {print(((2 * solve(i,j,(k / 2))) + " ")); }println(); }out.flush(); out.close(); } static private int solve( int i, int j, int kLeft){ if ( ((((i < 0) || (i >= n)) || (j < 0)) || (j >= m))) {return (int)1e9;} else if ( (kLeft == 0)) {return 0;} if ( (dp[i][j][kLeft] != null)) {return dp[i][j][kLeft];} int ans = (int)1e9; final int[] dx = {-1,1,0,0}; final int[] dy = {0,0,-1,1}; for ( int type = 0;(type < 4);type++) { int ni = (i + dx[type]);  int nj = (j + dy[type]); if ( ((((ni < 0) || (ni >= n)) || (nj < 0)) || (nj >= m))) continue; int inhibit = 0; if ( (type == 0)) {inhibit = ver[ni][nj]; } else if ( (type == 1)) {inhibit = ver[i][j]; } else if ( (type == 2)) {inhibit = hor[ni][nj]; } else {inhibit = hor[i][j]; }ans = Math.min(ans,(inhibit + solve(ni,nj,(kLeft - 1)))); }return dp[i][j][kLeft] = ans;} static private void sort( int[] a){ int n = a.length;  Integer[] b = new Integer[n]; for ( int i = 0;(i < n);i++) {b[i] = a[i]; }Arrays.sort(b); for ( int i = 0;(i < n);i++) {a[i] = b[i]; }} static private void sort( long[] a){ int n = a.length;  Long[] b = new Long[n]; for ( int i = 0;(i < n);i++) {b[i] = a[i]; }Arrays.sort(b); for ( int i = 0;(i < n);i++) {a[i] = b[i]; }} static private int[] ina( int n){ int[] temp = new int[n]; for ( int i = 0;(i < n);i++) {temp[i] = in.nextInt(); }return temp;} static private int ini(){ return in.nextInt();} static private String ins(){ return in.readString();} static private void println( Object... o){ for ( Object x :o) {out.write((x + "")); }out.write("\n"); } static private void print( Object... o){ for ( Object x :o) {out.write((x + "")); }} static private class Edge implements Comparable<Edge>{ private int u ,v ; private long w ; public Edge( int a, int b, long c){ u = a; v = b; w = c; } public int compareTo( Edge edge){ return Long.compare(w,edge.w);} } static private int gcd( int a, int b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static private long modExp( long a, long b){ if ( (b == 0)) return 1; a %= MOD; long exp = modExp(a,(b / 2)); if ( ((b % 2) == 0)) {return ((exp * exp) % MOD);} else {return ((a * ((exp * exp) % MOD)) % MOD);}} static private int[] backTable( String p){ int m = p.length();  int j = 0;  int[] b = new int[m]; for ( int i = 1;(i < m);i++) {while(((j != 0) && (p.charAt(i) != p.charAt(j)))){j = b[(j - 1)]; }if ( (p.charAt(i) == p.charAt(j))) {b[i] = ++j; } }return b;} static private InputReader in = new InputReader(System.in); static private PrintWriter out = new PrintWriter(System.out); static private 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 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 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));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} } }
1	public class A{ private BufferedReader in ; private StringTokenizer st ; void solve()throws IOException { int n = nextInt();  int i = 0;  int[] nums = new int[n];  int numeven = 0;  int numodd = 0; while((n-- > 0)){nums[i] = nextInt(); if ( ((nums[i] % 2) == 0)) numeven++; else numodd++; i++; }for ( int j = 0;(j < nums.length);j++) {if ( ((numeven == 1) && ((nums[j] % 2) == 0))) {System.out.println((j + 1)); break;} if ( ((numodd == 1) && ((nums[j] % 2) != 0))) {System.out.println((j + 1)); break;} }} 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));} }
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());} } }
1	public class A{ public static void main( String[] args){ new A().run(); } private void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int ce = 0;  int co = 0;  int le = 0;  int lo = 0; for ( int i = 0;(i < n);i++) { int x = sc.nextInt(); if ( ((x % 2) == 0)) {ce++; le = (i + 1); } else {co++; lo = (i + 1); }}System.out.println(((ce == 1)?le:lo)); } }
0	public class A{ static private StringTokenizer tokenizer ; static private BufferedReader bf ; static private PrintWriter out ; static private int nextInt()throws IOException { return Integer.parseInt(nextToken());} static private String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(bf.readLine()); }return tokenizer.nextToken();} public static void main( String[] args)throws IOException { bf = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt(); if ( (n >= 0)) out.println(n); else {n = -n; int a = (n % 10);  int m = (n / 10);  int b = (m % 10); if ( (a >= b)) {if ( (m == 0)) out.println(0); else out.println(-m); } else {m = ((m - b) + a); if ( (m == 0)) out.println(0); else out.println(-m); }}out.close(); } }
5	public class A4{ public BufferedReader input ; public PrintWriter output ; public StringTokenizer stoken = new StringTokenizer(""); public static void main( String[] args)throws IOException { new A4(); } A4()throws IOException{ input = new BufferedReader(new InputStreamReader(System.in)); output = new PrintWriter(System.out); run(); input.close(); output.close(); } private void run()throws IOException { int n = Math.toIntExact(nextLong());  int m = Math.toIntExact(nextLong());  int[] coor = new int[(n + 1)];  int[] ss = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {coor[i] = Math.toIntExact(nextLong()); }coor[n] = 1000000000; Arrays.sort(coor); for ( int i = 0;(i < m);i++) { long x1 = nextLong();  long x2 = nextLong(); nextLong(); if ( ((x1 == 1) && (x2 >= coor[0]))) { int l = 0;  int r = (n + 1); while(((r - l) > 1)){ int mi = ((r + l) / 2); if ( (coor[mi] > x2)) {r = mi; } else {l = mi; }}ss[l]++; } } long[] ans = new long[(n + 1)]; ans[n] = (ss[n] + n); long min = ans[n]; for ( int i = (n - 1);(i > -1);i--) {ans[i] = ((ans[(i + 1)] - 1) + ss[i]); if ( (ans[i] < min)) {min = ans[i]; } }System.out.println(min); } private Long nextLong()throws NumberFormatException,IOException { return Long.parseLong(nextString());} private String nextString()throws IOException { while(!stoken.hasMoreTokens()){ String st = input.readLine(); stoken = new StringTokenizer(st); }return stoken.nextToken();} }
1	public class Main{ public static void main( String[] args){ Scanner scn = new Scanner(System.in);  int t = scn.nextInt(); while((t-- > 0)){ String str = scn.next();  Pattern p = Pattern.compile("R[0-9]+C[0-9]+");  Matcher m = p.matcher(str); if ( m.matches()) { String nums[] = str.split("[RC]");  String first = nums[1];  String second = nums[2];  String ans = "";  long num = Integer.parseInt(second); while((num > 0)){if ( ((num % 26) > 0)) {ans += (char)(((num % 26) + 'A') - 1); num /= 26; } else {ans += 'Z'; num /= 26; num--; }}for ( int i = (ans.length() - 1);(i >= 0);--i) {System.out.print(ans.charAt(i)); }System.out.println(first); } else { String first = str.split("[0-9]+")[0];  String second = str.split("[A-Z]+")[1]; System.out.print(("R" + second)); long num = 0,pow = 1; for ( int i = (first.length() - 1);(i >= 0);--i) {num += ((long)((first.charAt(i) - 'A') + 1) * pow); pow *= 26; }System.out.println(("C" + num)); }}} }
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(); } } }
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 D{ static Scanner sc ; static PrintWriter out ; public static void main( String[] args)throws Exception { sc = new Scanner(System.in); out = new PrintWriter(System.out); for ( int i = 0;(i < 1);i++) {solve(); }out.flush(); } static void solve(){ int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int[][] a = new int[n][(m - 1)];  int[][] b = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {a[i][j] = sc.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {b[i][j] = sc.nextInt(); }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (j > 0)) out.print(" "); out.print("-1"); }out.println(); }return ;} int[][] prev = new int[n][m]; k /= 2; for ( int l = 0;(l < k);l++) { int[][] next = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {next[i][j] = Integer.MAX_VALUE; if ( (i > 0)) {next[i][j] = Math.min(next[i][j],(prev[(i - 1)][j] + b[(i - 1)][j])); } if ( ((i + 1) < n)) {next[i][j] = Math.min(next[i][j],(prev[(i + 1)][j] + b[i][j])); } if ( (j > 0)) {next[i][j] = Math.min(next[i][j],(prev[i][(j - 1)] + a[i][(j - 1)])); } if ( ((j + 1) < m)) {next[i][j] = Math.min(next[i][j],(prev[i][(j + 1)] + a[i][j])); } }}prev = next; }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (j > 0)) out.print(" "); out.print((prev[i][j] * 2)); }out.println(); }} }
6	public class Main implements Runnable{ private int n ; private int nn ; private int[][] D ; private int[] dp ; private int[] prev ; private void solve()throws Throwable { int xs = nextInt(),ys = nextInt(); n = nextInt(); int[][] pts = new int[n][2]; for ( int i = 0;(i < n);i++) {pts[i][0] = nextInt(); pts[i][1] = nextInt(); }D = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i == j)) {D[i][i] = (2 * (sqr((pts[i][0] - xs)) + sqr((pts[i][1] - ys)))); } else {D[i][j] = (((((sqr((pts[i][0] - xs)) + sqr((pts[i][1] - ys))) + sqr((pts[i][0] - pts[j][0]))) + sqr((pts[i][1] - pts[j][1]))) + sqr((pts[j][0] - xs))) + sqr((pts[j][1] - ys))); }}}nn = (1 << n); dp = new int[nn]; prev = new int[nn]; Arrays.fill(dp,-1); Arrays.fill(prev,-1); dp[0] = 0; Dp((nn - 1)); pw.println(dp[(nn - 1)]); pw.print(0); for ( int p = (nn - 1);((p != -1) && (prev[p] != -1));p = prev[p]) { int vv = (p ^ prev[p]); for ( int j = 0;(j < n);j++) { int jj = (1 << j); if ( ((vv & jj) == 0)) continue; pw.print(' '); pw.print((j + 1)); }pw.print(" 0"); }pw.println(); } private int Dp( int i){ if ( (dp[i] != -1)) return dp[i]; int ans = 107374182,p = -1;  int j1 = 1,pos1 = 0; for ( ;((pos1 < n) && (j1 < nn));j1 *= 2,pos1++) {if ( ((i & j1) == 0)) continue; int a = (D[pos1][pos1] + Dp((i ^ j1))); if ( (a < ans)) {ans = a; p = (i ^ j1); } int j2 = (j1 * 2),pos2 = (pos1 + 1); for ( ;((pos2 < n) && (j2 < nn));j2 *= 2,pos2++) {if ( ((i & j2) == 0)) continue; a = (D[pos1][pos2] + Dp((i ^ (j1 | j2)))); if ( (a < ans)) {ans = a; p = (i ^ (j1 | j2)); } }break;}dp[i] = ans; prev[i] = p; return ans;} private int sqr( int i){ return (i * 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());} static Throwable sError ; public static void main( String[] args)throws Throwable { new Main().run(); if ( (sError instanceof OutOfMemoryError)) {throw (sError);} } public void run(){ try{initStreams(); solve(); }catch (Throwable e){ sError = e; } finally{if ( (pw != null)) pw.close();  }} }
3	public class C_Round_455_Div2{ static long[][] dp ; static long MOD = ((long)1e9 + 7); public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  char[] data = new char[n]; dp = new long[n][n]; for ( long[] a :dp) {Arrays.fill(a,-1); }for ( int i = 0;(i < n);i++) {data[i] = in.next().charAt(0); }out.println(cal(0,0,data)); out.close(); } static long cal( int index, int nested, char[] data){ if ( ((index + 1) == data.length)) {return 1;} if ( (dp[index][nested] != -1)) {return dp[index][nested];} long result = 0;  boolean isLoop = (data[index] == 'f'); if ( isLoop) {result = cal((index + 1),(nested + 1),data); } else {result = cal((index + 1),nested,data); if ( (nested > 0)) {result += cal(index,(nested - 1),data); result %= MOD; } }return dp[index][nested] = result;} }
3	public class Main{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  String s = br.readLine();  String ss[] = s.split(" ");  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = Integer.parseInt(ss[i]); Arrays.sort(arr); int coun = 0,coun2 = 0; for ( int i = arr[0],k = 0;(k < n);) {for ( int j = k;(j < n);j++) {if ( ((arr[j] % i) == 0)) {arr[j] = -1; coun2++; } }Arrays.sort(arr); k = coun2; coun++; if ( (coun2 < n)) i = arr[coun2]; else break;}System.out.println(coun); } }
5	public class R015A{ final double EPS = 1e-9; boolean isEqual( double x, double y){ return (Math.abs((x - y)) <= (EPS * Math.max(Math.abs(x),Math.abs(y))));} class Pair implements Comparable<Pair>{ double left ; double right ; Pair( double left, double right){ this.left = left; this.right = right; } } public R015A(){ } private void process(){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  int t = scanner.nextInt();  int[] x = new int[n];  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = scanner.nextInt(); a[i] = scanner.nextInt(); } List<Pair> pairs = new ArrayList<Pair>(); for ( int i = 0;(i < n);i++) { double left = (x[i] - (a[i] / 2.0));  double right = (x[i] + (a[i] / 2.0)); pairs.add(new Pair(left,right)); }Collections.sort(pairs); Set<Pair> newPairs = new HashSet<Pair>(); newPairs.add(new Pair((pairs.get(0).left - t),pairs.get(0).left)); for ( int i = 0;(i < (pairs.size() - 1));i++) {if ( ((pairs.get((i + 1)).left - pairs.get(i).right) >= t)) {newPairs.add(new Pair(pairs.get(i).right,(pairs.get(i).right + t))); newPairs.add(new Pair((pairs.get((i + 1)).left - t),pairs.get((i + 1)).left)); } }newPairs.add(new Pair(pairs.get((pairs.size() - 1)).right,(pairs.get((pairs.size() - 1)).right + t))); System.out.println(newPairs.size()); } public static void main( String[] args){ new R015A().process(); } }
6	public class Main{ private int n ; private int m ; private boolean[][] g ; private long[][] dp ; private int[] count ; private int[] first ; private void solve()throws IOException { n = nextInt(); m = nextInt(); 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; }count = new int[(1 << n)]; first = new int[(1 << n)]; dp = new long[(1 << n)][n]; for ( int mask = 0;(mask < (1 << n));mask++) {count[mask] = bitCount(mask); for ( int i = 0;(i < n);i++) {if ( (bit(i,mask) == 1)) {first[mask] = i; break;} }}for ( int mask = 0;(mask < (1 << n));mask++) {for ( int i = 0;(i < n);i++) {if ( ((count[mask] == 1) && (bit(i,mask) == 1))) {dp[mask][i] = 1; } else {for ( int j = 0;(j < n);j++) {if ( (((g[j][i] && (count[mask] > 1)) && (bit(i,mask) == 1)) && (first[mask] != i))) {dp[mask][i] += dp[(mask ^ (1 << i))][j]; } }}}} long ans = 0; for ( int i = 0;(i < n);i++) {for ( int mask = 0;(mask < (1 << n));mask++) {if ( (((count[mask] >= 3) && (first[mask] != i)) && g)) {ans += dp[mask][i]; } }}if ( ((ans % 2) != 0)) {throw (new RuntimeException("SHIT!!!"));} out.println((ans / 2)); } private final int bit( int i, int mask){ return (((mask & (1 << i)) != 0)?1:0);} private final int bitCount( int mask){ int ret = 0; while((mask != 0)){ret++; mask -= (mask & mask); }return ret;} private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private Main()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); eat(""); solve(); in.close(); out.close(); } private 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 Main(); } }
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(); } } }
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++];} }
6	public class ElongatedMatrix{ static private int n ; static private int[][] minCost ; static private int[][] minCostEndpoints ; static private HashMap<Integer,Integer> costs = new HashMap<>(); public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int[] params = Arrays.stream(br.readLine().split(" ")).mapToInt((x)->Integer.parseInt(x)).toArray(); n = params[0]; int m = params[1];  int[][] matrix = new int[n][m]; for ( int i = 0;(i < n);i++) {matrix[i] = Arrays.stream(br.readLine().split(" ")).mapToInt((x)->Integer.parseInt(x)).toArray(); }minCost = new int[n][n]; minCostEndpoints = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i > j)) {minCost[i][j] = Integer.MAX_VALUE; for ( int k = 0;(k < m);k++) { int diff = Math.abs((matrix[i][k] - matrix[j][k])); if ( (diff < minCost[i][j])) {minCost[i][j] = diff; } }minCost[j][i] = minCost[i][j]; } minCostEndpoints[i][j] = Integer.MAX_VALUE; for ( int k = 0;(k < (m - 1));k++) { int diff = Math.abs((matrix[i][(k + 1)] - matrix[j][k])); if ( (diff < minCostEndpoints[i][j])) {minCostEndpoints[i][j] = diff; } }}} int maxCost = ((n == 1)?minCostEndpoints[0][0]:0); for ( int i = 0;(i < n);i++) {costs.clear(); for ( int j = 0;(j < n);j++) {if ( (i != j)) { int bitmask = ((1 << i) | (1 << j));  int state = (bitmask + (j << 16)); costs.put(state,minCost[i][j]); } }for ( int j = 0;(j < n);j++) {if ( (i != j)) {if ( (minCostEndpoints[i][j] <= maxCost)) {continue;} else { int pathCost = Math.min(minCostEndpoints[i][j],findMaxCost(i,j,((1 << n) - 1))); maxCost = Math.max(maxCost,pathCost); }} }}System.out.println(maxCost); br.close(); } static private int findMaxCost( int st, int end, int set){ int state = (set + (end << 16)); if ( costs.containsKey(state)) {return costs.get(state);} int maxCost = 0; for ( int i = 0;(i < n);i++) {if ( (((i != st) && (i != end)) && ((set & (1 << i)) != 0))) { int setWithoutEnd = (set - (1 << end));  int pathCost = Math.min(findMaxCost(st,i,setWithoutEnd),minCost[i][end]); maxCost = Math.max(pathCost,maxCost); } }costs.put(state,maxCost); return maxCost;} }
3	public class Main{ static StringBuilder data = new StringBuilder(); static final FastReader in = new FastReader(); public static void main( String[] args){ int n = in.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }Arrays.sort(a); int answ = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != 0)) {for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {a[j] = 0; } }answ++; a[i] = 0; } }System.out.println(answ); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader( String path){ try{br = new BufferedReader(new InputStreamReader(new FileInputStream(path))); }catch (FileNotFoundException e){ e.printStackTrace(); } } 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 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();} } }
0	public class Main{ public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] spl = in.readLine().split(" ");  long l = Long.parseLong(spl[0]);  long r = Long.parseLong(spl[1]); if ( (((l + 2) <= r) && ((l % 2) == 0))) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else if ( (((l + 3) <= r) && (((l + 1) % 2) == 0))) {System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); } else System.out.println(-1); } }
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(); output.println(Math.max(((Long.highestOneBit((l ^ r)) * 2) - 1),0L)); } 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 ; }
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();} }
4	public class C{ static private PrintWriter out = new PrintWriter(System.out); public static void solve(){ In in = new In();  int tests = in.ni(); while((tests-- > 0)){ int n = in.ni();  int[] a = in.nia(n);  Stack<Integer> st = new Stack<>();  StringBuilder sb = new StringBuilder(); for ( int num :a) {if ( st.isEmpty()) {st.push(num); sb.append(num); } else {if ( (num == (st.peek() + 1))) {st.pop(); st.push(num); while(((sb.length() > 0) && (sb.charAt((sb.length() - 1)) != '.'))){sb.deleteCharAt((sb.length() - 1)); }sb.append(num); } else if ( (num == 1)) {st.push(num); sb.append("."); sb.append(num); } else {while((!st.isEmpty() && ((st.peek() + 1) != num))){st.pop(); while(((sb.length() > 0) && (sb.charAt((sb.length() - 1)) != '.'))){sb.deleteCharAt((sb.length() - 1)); }if ( (sb.length() > 0)) sb.deleteCharAt((sb.length() - 1)); }if ( (!st.isEmpty() && ((st.peek() + 1) == num))) {st.pop(); st.add(num); while(((sb.length() > 0) && (sb.charAt((sb.length() - 1)) != '.'))){sb.deleteCharAt((sb.length() - 1)); }sb.append(num); } }}out.println(sb); }}} public static void main( String[] args)throws IOException { solve(); out.flush(); } @SuppressWarnings("unused") static private class In{ static private final int BUFFER_SIZE = 1024; private byte[] buf ; private InputStream is ; private int buflen ; private int bufptr ; public In(){ is = System.in; buf = new byte[BUFFER_SIZE]; buflen = bufptr = 0; } public In( String input){ is = new ByteArrayInputStream(input.getBytes()); buf = new byte[BUFFER_SIZE]; buflen = bufptr = 0; } public int readByte(){ if ( (bufptr >= buflen)) {try{buflen = is.read(buf); }catch (IOException ioe){ throw (new InputMismatchException());} bufptr = 0; } if ( (buflen <= 0)) return -1; return buf[bufptr++];} public boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} public int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} public char nc(){ return (char)skip();} public double nd(){ return Double.parseDouble(ns());} public String ns(){ final StringBuilder sb = new StringBuilder();  int b = skip(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} public int ni(){ boolean minus = false;  int num = 0;  int b ; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(((b >= '0') && (b <= '9'))){num = ((num * 10) + (b - '0')); b = readByte(); }return (minus?-num:num);} public long nl(){ boolean minus = false;  long num = 0;  int b ; while((((b = readByte()) != -1) && (((b >= '0') && (b <= '9')) || (b == '-'))));if ( (b == '-')) {minus = true; b = readByte(); } while(((b >= '0') && (b <= '9'))){num = ((num * 10) + (b - '0')); b = readByte(); }return (minus?-num:num);} public int[] nia( int n){ final int[] arr = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = ni(); return arr;} } }
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(); } }
5	public class Prob015A{ public static void main( String[] Args){ Scanner scan = new Scanner(System.in);  int numHouses = scan.nextInt();  int side = (scan.nextInt() * 2);  ArrayList<Integer> sides = new ArrayList<Integer>(); for ( int x = 0;(x < numHouses);x++) { int c = (scan.nextInt() * 2);  int s = scan.nextInt();  int l = (c - s);  int r = (c + s);  int li = Collections.binarySearch(sides,l);  int ri = Collections.binarySearch(sides,r); if ( ((li >= 0) && (ri >= 0))) {sides.remove(li); sides.remove(li); } else if ( (li >= 0)) sides.set(li,r); else if ( (ri >= 0)) sides.set(ri,l); else {sides.add((-li - 1),r); sides.add((-li - 1),l); }} int possibilities = 2; for ( int x = 1;(x < (sides.size() - 1));x += 2) if ( ((sides.get((x + 1)) - sides.get(x)) > side)) possibilities += 2; else if ( ((sides.get((x + 1)) - sides.get(x)) == side)) possibilities += 1; System.out.println(possibilities); } }
1	public class A{ private Scanner in ; private PrintWriter out ; private String INPUT = ""; public void solve(){ int n = ni();  int[] u = new int[n];  int fe = -1,fo = -1;  int ne = -1,no = -1; for ( int i = 0;(i < n);i++) {u[i] = ni(); if ( ((u[i] % 2) == 0)) {if ( (fe == -1)) {fe = (i + 1); } else {ne = (i + 1); }} else {if ( (fo == -1)) {fo = (i + 1); } else {no = (i + 1); }}}if ( (ne > 0)) {out.println(fo); } else {out.println(fe); }} public void run()throws Exception { in = (INPUT.isEmpty()?new Scanner(System.in):new Scanner(INPUT)); out = new PrintWriter(System.out); solve(); out.flush(); } public static void main( String[] args)throws Exception { new A().run(); } private int ni(){ return Integer.parseInt(in.next());} }
2	public class A338{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextInt();  long m = in.nextInt();  long k = in.nextInt();  long x = (n - m);  long y = (n / k); if ( (x >= y)) System.out.println(m); else { long t = (y - x);  long ans = 0; ans += (k * (pow((t + 1)) - 2)); ans %= 1000000009; ans += (m - (t * k)); ans %= 1000000009; if ( (ans < 0)) ans += 1000000009; System.out.println(ans); }} public static long pow( long m){ if ( (m == 1)) return 2; long x = pow((m / 2)); x %= 1000000009; x *= x; if ( ((m % 2) != 0)) x *= 2; x %= 1000000009; return x;} }
0	public class Main{ private BufferedReader input ; private PrintWriter output ; private StringTokenizer stoken ; String fin = "input"; String fout = "output"; private void solve(){ long a = nextInt();  long res = ((a / 2) * 3); output.print(res); } Main()throws IOException{ input = new BufferedReader(new InputStreamReader(System.in)); output = new PrintWriter(System.out); solve(); input.close(); output.flush(); output.close(); } int nextInt(){ return Integer.parseInt(nextToken());} String nextToken(){ while(((stoken == null) || stoken.hasMoreTokens())){try{ String line = input.readLine(); stoken = new StringTokenizer(line); }catch (IOException e){ e.printStackTrace(); } }return stoken.nextToken();} public static void main( String[] args)throws IOException { new Main(); } }
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());} } }
1	public class A{ public static void main( String[] args){ Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  String[] number = new String[n]; sc.nextLine(); String l = sc.nextLine(); number = l.split(" "); int oe = 1; if ( ((((Integer.valueOf(number[0]) % 2) + (Integer.valueOf(number[1]) % 2)) + (Integer.valueOf(number[2]) % 2)) > 1)) {oe = 0; } for ( int i = 0;(i < n);i++) {if ( ((Integer.valueOf(number[i]) % 2) == oe)) {System.out.println((i + 1)); break;} }} }
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(); } static private 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;} }
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);  DExplorerSpace solver = new DExplorerSpace(); solver.solve(1,in,out); out.close(); } static class DExplorerSpace{ static final int oo = 1000000000; public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt(),m = in.nextInt(),k = in.nextInt();  int[][] right = new int[n][(m - 1)];  int[][] down = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) right[i] = in.readIntArray((m - 1)); for ( int i = 0;((i + 1) < n);i++) down[i] = in.readIntArray(m); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) out.print((-1 + " ")); out.println(); }return ;} int[][][] dp = new int[((k / 2) + 1)][n][m]; for ( int r = 1;((2 * r) <= k);r++) {for ( int i = 0;(i < n);i++) Arrays.fill(dp[r][i],oo); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < (m - 1));j++) { int cost = right[i][j]; dp[r][i][j] = Integer.min(dp[r][i][j],(dp[(r - 1)][i][(j + 1)] + cost)); dp[r][i][(j + 1)] = Integer.min(dp[r][i][(j + 1)],(dp[(r - 1)][i][j] + cost)); }for ( int i = 0;((i + 1) < n);i++) for ( int j = 0;(j < m);j++) { int cost = down[i][j]; dp[r][i][j] = Integer.min(dp[r][i][j],(dp[(r - 1)][(i + 1)][j] + cost)); dp[r][(i + 1)][j] = Integer.min(dp[r][(i + 1)][j],(dp[(r - 1)][i][j] + cost)); }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print(((2 * dp[(k / 2)][i][j]) + " ")); }out.println(); }} } 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){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }writer.print('\n'); } 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 int[] readIntArray( int size){ int[] array = new int[size]; for ( int i = 0;(i < size);i++) {array[i] = readInt(); }return array;} 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 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); } } }
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)));} }
4	public class tank{ static final FastScanner fs = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ int t = fs.nextInt(); while((t-- > 0)){run_case(); }out.close(); } static void run_case(){ int n = fs.nextInt(),prevLen = 1,one = 1;  int[] arr = fs.readArray(n);  int[] len = new int[1001];  StringBuilder[] prev = new StringBuilder[1001]; len[1] = 1; out.println(1); for ( int i = 0;(i < 1001);i++) {prev[i] = new StringBuilder(); }prev[1].append("1"); for ( int i = 1;(i < n);i++) {if ( (arr[i] == 1)) {prev[(prevLen + 1)] = new StringBuilder(prev[prevLen]); prev[(prevLen + 1)].append(".1"); out.println(prev[(prevLen + 1)]); prevLen++; len[prevLen] = 1; } else {for ( int j = 1000;(j > 0);j--) {if ( ((len[j] == (arr[i] - 1)) && (j <= prevLen))) { char[] tmp = prev[j].toString().toCharArray(); if ( fn(tmp)) {prev[j] = new StringBuilder(("" + (len[j] + 1))); } else {prev[j] = new StringBuilder(); int ub = fn2(tmp); for ( int k = 0;(k <= ub);k++) {prev[j].append(tmp[k]); }prev[j].append((len[j] + 1)); }out.println(prev[j]); len[j] = (len[j] + 1); prevLen = j; break;} if ( (j == 1)) {prev[j] = new StringBuilder(("" + (one + 1))); out.println(prev[j]); len[j] = (one + 1); prevLen = j; one++; } }}}} static boolean fn( char[] arr){ for ( char c :arr) {if ( (c == '.')) return false; }return true;} static int fn2( char[] arr){ int ret = 0; for ( int i = 0;(i < arr.length);i++) {if ( (arr[i] == '.')) ret = i; }return ret;} 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());} int[] readArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
0	public class CF{ public static void main( String[] args)throws IOException { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  int n = in.nextInt(); if ( (n >= 0)) {out.println(n); } else { int res = n; n = Math.abs(n); String s = String.valueOf(Math.abs(n)); if ( (s.length() == 1)) {res = 0; } else {res = Math.max(-Integer.parseInt(s.substring(0,(s.length() - 1))),res); res = Math.max(-Integer.parseInt((s.substring(0,(s.length() - 2)) + s.charAt((s.length() - 1)))),res); }out.println(res); }out.close(); } } 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 nextInt(){ return Integer.parseInt(next());} }
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 IOException,InterruptedException { int n = reader.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = reader.nextString().charAt(0); } long[][] d = new long[(n + 1)][(n + 1)]; d[0][0] = 1; long mod = 1_000_000_007; for ( int i = 1;(i < n);i++) {for ( int j = (n - 1);(j >= 0);j--) {if ( (a[(i - 1)] == 'f')) {d[i][(j + 1)] = d[(i - 1)][j]; } else {d[i][j] = ((d[(i - 1)][j] + d[i][(j + 1)]) % mod); }}} long ans = 0; for ( int i = 0;(i <= n);i++) {ans += d[(n - 1)][i]; }writer.print((ans % mod)); } 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(); } } }
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); } }
4	public class A{ static int[] dx = {-1,0,1,0}; static int[] dy = {0,1,0,-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(),k = sc.nextInt();  int[][] dist = new int[n][m]; for ( int[] a :dist) Arrays.fill(a,-1); Queue<Point> q = new LinkedList<>(); for ( int i = 0;(i < k);i++) { int x = (sc.nextInt() - 1),y = (sc.nextInt() - 1); dist[x][y] = 0; q.add(new Point(x,y)); } int ansX = -1,ansY = -1; while(!q.isEmpty()){ Point cur = q.remove(); ansX = cur.x; ansY = cur.y; for ( int i = 0;(i < 4);i++) { int x = (cur.x + dx[i]),y = (cur.y + dy[i]); if ( (((((x != -1) && (y != -1)) && (x != n)) && (y != m)) && (dist[x][y] == -1))) {q.add(new Point(x,y)); dist[x][y] = (dist[cur.x][cur.y] + 1); } }}out.println((((ansX + 1) + " ") + (ansY + 1))); out.flush(); out.close(); } 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();} } }
0	public class D5{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int a = input.nextInt(),v = input.nextInt();  int l = input.nextInt(),d = input.nextInt(),w = input.nextInt();  double lo = 0,hi = v; for ( int iter = 0;(iter < 1000);iter++) { double mid = ((lo + hi) / 2); if ( can(mid,a,d,w)) lo = mid; else hi = mid; } double t1 = (lo / a);  double gone = (((.5 * t1) * t1) * a); if ( (lo > w)) {gone += ((((((-a * .5) * (lo - w)) / a) * (lo - w)) / a) + ((lo * (lo - w)) / a)); t1 += ((lo - w) / a); } t1 += ((d - gone) / lo); double v0 = Math.min(lo,w);  double togo = (l - d);  double toAdd = ((-v0 + Math.sqrt(((v0 * v0) + (((4 * togo) * .5) * a)))) / a); if ( (((toAdd * a) + v0) > v)) { double tt = ((v - v0) / a); t1 += tt; togo -= ((((.5 * a) * tt) * tt) + (v0 * tt)); t1 += (togo / v); } else t1 += toAdd; System.out.println(t1); } static boolean can( double v, double a, double d, double max){ double t1 = (v / a);  double distGone = (((.5 * a) * t1) * t1); if ( (v > max)) {t1 = ((v - max) / a); distGone += ((((-.5 * a) * t1) * t1) + (v * t1)); } return (distGone <= d);} }
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(); } }
2	public class A{ static int[] UPPER = new int[64],LOWER = new int[64]; static long[][][] memo ; static long dp( int bit, int lims, int digs){ if ( (bit == -1)) return ((digs == 0)?1:0); if ( (memo[lims][bit][digs] != -1)) return memo[lims][bit][digs]; long ret = 0; for ( int d = 0,end = ((digs < 10)?(digs + 1):10);(d < end);++d) if ( ((((lims & 1) == 1) || (d >= LOWER[bit])) && (((lims & 2) == 2) || (d <= UPPER[bit])))) ret += dp((bit - 1),((lims | ((d > LOWER[bit])?1:0)) | ((d < UPPER[bit])?2:0)),(digs - d)); return memo[lims][bit][digs] = ret;} static void create( int[] x, long n){ for ( int i = 0;(i < 64);++i) {x[i] = (int)(n % 10); n /= 10; }} static void prepMemo( int sod){ memo = new long[4][64][(sod + 1)]; for ( long[][] x :memo) for ( long[] y :x) Arrays.fill(y,-1); } public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  long n = sc.nextLong(),s = sc.nextLong(); create(UPPER,n); long ans = 0; for ( int sod = 1;(sod <= 162);++sod) {create(LOWER,(s + sod)); prepMemo(sod); ans += dp(63,0,sod); }out.println(ans); 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 long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
5	public class D{ public static void main( String[] args)throws FileNotFoundException { Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] a = new int[n];  int[] p = new int[n]; for ( int i = 0;(i < a.length);i++) a[i] = p[i] = in.nextInt(); Arrays.sort(a); int sum = 0;  int t = 0; for ( int i = 0;(i < a.length);i++) t += a[i]; int cnt = 0; for ( int i = (a.length - 1);(i >= 0);i--) {cnt++; sum += a[i]; if ( ((t - sum) < sum)) break; }System.out.println(cnt); } }
3	public class C{ public static void main( String[] args){ MyScanner in = new MyScanner();  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int r = in.nextInt();  double[] y = new double[n];  int[] x = new int[n]; for ( int i = 0;(i < n);++i) {x[i] = in.nextInt(); double bestY = r; for ( int j = 0;(j < i);++j) {if ( (Math.abs((x[i] - x[j])) <= (2 * r))) { double ny = (y[j] + Math.sqrt((((4 * r) * r) - ((x[i] - x[j]) * (x[i] - x[j]))))); if ( (ny > bestY)) {bestY = ny; } } }y[i] = bestY; }for ( int i = 0;(i < n);++i) {out.println(y[i]); }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());} } }
5	public class A{ 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());  State[] s = new State[n]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); s[i] = new State(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())); }Arrays.sort(s); int num = 2; for ( int i = 1;(i < s.length);i++) { int dist = (s[i].x - s[(i - 1)].x); dist *= 2; int size = (s[i].d + s[(i - 1)].d); size += (2 * t); if ( (dist == size)) num++; else if ( (dist > size)) num += 2; }System.out.println(num); } static class State implements Comparable<State>{ public int x ,d ; public State( int a, int b){ x = a; d = b; } } }
4	public class Main{ public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static long MOD = (long)(1e9 + 7); static long MOD2 = (MOD * MOD); static FastReader sc = new FastReader(); static int pInf = Integer.MAX_VALUE; static int nInf = Integer.MIN_VALUE; static long ded = ((long)1e17 + 9); public static void main( String[] args)throws Exception { int test = 1; for ( int i = 1;(i <= test);i++) {solve(); }out.flush(); out.close(); } static int n ,m ; static int[][] hor ,ver ; static Long[][][] dp ; static void solve(){ n = sc.nextInt(); m = sc.nextInt(); int k = sc.nextInt(); dp = new Long[(n + 1)][(m + 1)][(k + 1)]; hor = new int[n][(m - 1)]; ver = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {hor[i][j] = sc.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ver[i][j] = sc.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 = (k / 2); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { long ans = cal(i,j,k); out.print(((2 * ans) + " ")); }out.println(); }} static long cal( int i, int j, int k){ if ( (k == 0)) return 0; if ( (dp[i][j][k] != null)) return dp[i][j][k]; long ans = ded; for ( int h = 0;(h < 4);h++) { int ni = (i + di[h]);  int nj = (j + dj[h]); if ( e(ni,nj)) { int cost = 0; if ( (ni == i)) {if ( (nj > j)) {cost = hor[i][j]; } else {cost = hor[i][nj]; }} if ( (nj == j)) {if ( (ni > i)) {cost = ver[i][j]; } else {cost = ver[ni][j]; }} ans = Math.min(ans,(cost)+cal(ni,nj,(k - 1))); } }return dp[i][j][k] = ans;} static int[] di = new int[]{0,-1,0,1}; static int[] dj = new int[]{-1,0,1,0}; static boolean e( int i, int j){ return ((((i >= 0) && (j >= 0)) && (i < n)) && (j < m));} public static long mul( long a, long b){ return (((a % MOD) * (b % MOD)) % MOD);} static final Random random = new Random(); static long countSetBits( long n){ if ( (n == 0)) return 0; return (1 + countSetBits((n & (n - 1))));} static long gcd( long A, long B){ if ( (B == 0)) return A; return gcd(B,(A % B));} static long fastExpo( long x, long n){ if ( (n == 0)) return 1; if ( ((n & 1) == 0)) return (fastExpo(((x * x) % MOD),(n / 2)) % MOD); return (((x % MOD) * fastExpo(((x * x) % MOD),((n - 1) / 2))) % MOD);} public static long modpow( long a, long b){ if ( (b == 0)) {return 1;} long x = modpow(a,(b / 2)); x = ((x * x) % MOD); if ( ((b % 2) == 1)) {return ((x * a) % MOD);} return x;} 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 GenerateLogin{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  String a = scan.next();  String b = scan.next();  char last = b.charAt(0);  String ans = ("" + a.charAt(0)); for ( int i = 1;(i < a.length());i++) {if ( (a.charAt(i) >= last)) break; ans += a.charAt(i); }ans += last; System.out.println(ans); } }
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;} }
0	public class origami{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  double n = input.nextInt();  double k = input.nextInt();  double red = 0;  double green = 0;  double blue = 0;  double ans = 0; red = ((2 * n) / k); green = ((5 * n) / k); blue = ((8 * n) / k); double red1 = Math.ceil(red);  double green1 = Math.ceil(green);  double blue1 = Math.ceil(blue); ans += red1; ans += green1; ans += blue1; Double answer = new Double(ans);  int finished = answer.intValue(); System.out.println(finished); } }
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) % MD) * dp[ma][mb][mc])) % MD); }}}System.out.println(ans); } }
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 Main implements Runnable{ private int n ; private int nn ; private int[][] D ; private int[] dp ; private int[] prev ; private void solve()throws Throwable { int xs = nextInt(),ys = nextInt(); n = nextInt(); int[][] pts = new int[n][2]; for ( int i = 0;(i < n);i++) {pts[i][0] = nextInt(); pts[i][1] = nextInt(); }D = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i == j)) {D[i][i] = (2 * (sqr((pts[i][0] - xs)) + sqr((pts[i][1] - ys)))); } else {D[i][j] = (((((sqr((pts[i][0] - xs)) + sqr((pts[i][1] - ys))) + sqr((pts[i][0] - pts[j][0]))) + sqr((pts[i][1] - pts[j][1]))) + sqr((pts[j][0] - xs))) + sqr((pts[j][1] - ys))); }}}nn = (1 << n); dp = new int[nn]; prev = new int[nn]; Arrays.fill(dp,-1); Arrays.fill(prev,-1); dp[0] = 0; Dp((nn - 1)); pw.println(dp[(nn - 1)]); pw.print(0); for ( int p = (nn - 1);((p != -1) && (prev[p] != -1));p = prev[p]) { int vv = (p ^ prev[p]); for ( int j = 0;(j < n);j++) { int jj = (1 << j); if ( ((vv & jj) == 0)) continue; pw.print(' '); pw.print((j + 1)); }pw.print(" 0"); }pw.println(); } private int Dp( int i){ if ( (dp[i] != -1)) return dp[i]; int ans = 107374182,p = -1;  int j1 = 1,pos1 = 0; for ( ;((pos1 < n) && (j1 < nn));j1 *= 2,pos1++) {if ( ((i & j1) == 0)) continue; int a = (D[pos1][pos1] + Dp((i ^ j1))); if ( (a < ans)) {ans = a; p = (i ^ j1); } int j2 = (j1 * 2),pos2 = (pos1 + 1); for ( ;((pos2 < n) && (j2 < nn));j2 *= 2,pos2++) {if ( ((i & j2) == 0)) continue; a = (D[pos1][pos2] + Dp((i ^ (j1 | j2)))); if ( (a < ans)) {ans = a; p = (i ^ (j1 | j2)); } }break;}dp[i] = ans; prev[i] = p; return ans;} private int sqr( int i){ return (i * i);} private void initstreams()throws Throwable { in = new BufferedReader(new InputStreamReader(System.in,"ISO-8859-1")); pw = new PrintWriter(System.out); } BufferedReader in ; PrintWriter pw ; StringTokenizer st ; 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 private 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); } }
0	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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt(); if ( ((n == 1) || (n == 2))) {out.println(n); return ;} if ( (n == 4)) {out.println(12); return ;} long nn = n; if ( ((n % 2) == 1)) { long ans = ((nn * (nn - 1)) * (nn - 2)); out.println(ans); } else if ( ((n % 3) == 0)) {nn--; long ans = ((nn * (nn - 1)) * (nn - 2)); out.println(ans); } else { long ans = ((nn * (nn - 1)) * (nn - 3)); out.println(ans); }} } 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);} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
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());} }
0	public class Main{ void solve(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int n1 = (n / 10);  int n2 = (((n / 100) * 10) + (n % 10));  int ans = n; ans = Math.max(ans,n1); ans = Math.max(ans,n2); System.out.println(ans); } public static void main( String[] args){ new Main().solve(); } }
5	public class Main{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt(),m = scanner.nextInt();  int[] vertical = new int[n]; for ( int i = 0;(i < n);i++) {vertical[i] = scanner.nextInt(); }Arrays.sort(vertical); ArrayList<Integer> horisontal = new ArrayList<>();  int amount = 0; for ( int i = 0;(i < m);i++) { int x1 = scanner.nextInt(),x2 = scanner.nextInt(),y = scanner.nextInt(); if ( (x1 == 1)) {amount++; horisontal.add(x2); } }Collections.sort(horisontal); if ( (amount == 0)) {System.out.println(0); return ;} int minVal = amount,horSize = horisontal.size(),verLen = vertical.length;  int h = 0,v = 0; for ( ;((v < verLen) && (h < horSize));) {while(((h < horSize) && (horisontal.get(h) < vertical[v]))){h++; amount--; }minVal = Math.min(minVal,(amount + v)); while((((h < horSize) && (v < verLen)) && (horisontal.get(h) >= vertical[v]))){minVal = Math.min(minVal,(amount + v)); v++; }}if ( (horisontal.get((horSize - 1)) < 1E9)) {minVal = Math.min(minVal,v); } System.out.println(minVal); } }
1	public class B{ public static String toB( String str){ String row ,col ;  int i = 0; while((((i < str.length()) && (str.charAt(i) <= 'Z')) && (str.charAt(i) >= 'A')))i++; col = str.substring(0,i); row = str.substring(i,str.length()); StringBuffer sb = new StringBuffer(col); col = sb.reverse().toString(); int accum = 0; for ( i = 0;(i < col.length());i++) { int val = getValue(col.charAt(i)); accum += (val * Math.pow(26,i)); }return ((("R" + row) + "C") + accum);} public static String toA( String str){ int i = str.indexOf('C');  String row ,col ,ans = ""; row = str.substring(1,i); col = str.substring((i + 1),str.length()); int colVal = Integer.parseInt(col),mod ; while((colVal > 0)){mod = (colVal % 26); if ( (mod == 0)) {ans += 'Z'; colVal--; } else {ans += getLetter(mod); }colVal /= 26; } StringBuffer sb = new StringBuffer(ans); ans = sb.reverse().toString(); return (ans + row);} public static int getValue( char c){ return ((c - 'A') + 1);} public static char getLetter( int n){ return (char)((n + 'A') - 1);} public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  int cases = in.nextInt(); for ( int i = 0;(i < cases);i++) { String str = in.next(); if ( ((((str.charAt(0) == 'R') && (str.charAt(1) >= '0')) && (str.charAt(1) <= '9')) && (str.indexOf('C') != -1))) {System.out.println(toA(str)); } else System.out.println(toB(str)); }} }
3	public class Main{ static final long MOD = 998244353; static boolean[] visited ; public static void main( String[] args)throws IOException { FastScanner sc = new FastScanner();  int N = sc.nextInt();  int[] nums = new int[N]; for ( int i = 0;(i < N);i++) {nums[i] = sc.nextInt(); }Arrays.sort(nums); boolean[] hit = new boolean[N];  int colors = 0;  int index = 0; while((index < N)){if ( (hit[index] == false)) {colors++; int div = nums[index]; for ( int i = index;(i < N);i++) {if ( ((nums[i] % div) == 0)) {hit[i] = true; } }} index++; }System.out.println(colors); } 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 CF125A{ private void work()throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int n = sc.nextInt(); System.out.printf("%d %d %d\n",0,0,n); System.out.close(); } public static void main( String[] args)throws IOException { new CF125A().work(); } }
3	public class Main{ public static void main( String[] args)throws NumberFormatException,IOException { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task();  int tc = in.nextInt(); for ( int i = 0;(i < tc);i++) solver.solve(i,in,out); out.close(); } static class Task{ public void solve( int testNumber, InputReader in, PrintWriter out){ int k = in.nextInt();  int[] s = getArray(in.nextToken());  int[] a = getArray(in.nextToken());  int[] b = getArray(in.nextToken());  int[] per = new int[k];  boolean[] used = new boolean[k]; Arrays.fill(per,-1); if ( !check(s,a,per.clone(),k,used)) {out.println("NO"); return ;} for ( int i = 0;(i < s.length);i++) {if ( (per[s[i]] != -1)) {continue;} for ( int j = 0;(j < k);j++) {if ( used[j]) {continue;} per[s[i]] = j; used[j] = true; if ( check(s,a,per.clone(),k,used)) {break;} per[s[i]] = -1; used[j] = false; }}for ( int i = 0;(i < s.length);i++) {if ( (per[s[i]] == -1)) {out.println("NO"); return ;} s[i] = per[s[i]]; }if ( (cmp(s,b) > 0)) {out.println("NO"); return ;} int last = 0; for ( int i = 0;(i < k);i++) {if ( (per[i] == -1)) {while(used[last])last++; per[i] = last; used[last] = true; } } char[] result = new char[k]; for ( int i = 0;(i < k);i++) {result[i] = (char)('a' + per[i]); }out.println("YES"); out.println(new String(result)); } private int cmp( int[] a, int[] b){ for ( int i = 0;(i < a.length);i++) {if ( (a[i] != b[i])) {return ((a[i] < b[i])?-1:1);} }return 0;} private boolean check( int[] s, int[] a, int[] per, int k, boolean[] used){ int res[] = new int[s.length];  int last = (k - 1); for ( int i = 0;(i < res.length);++i) {if ( (per[s[i]] == -1)) {while(((last >= 0) && used[last])){last--; }if ( (last < 0)) {return false;} per[s[i]] = last; last--; } res[i] = per[s[i]]; }return (cmp(a,res) <= 0);} private int[] getArray( String nextToken){ int result[] = new int[nextToken.length()]; for ( int i = 0;(i < nextToken.length());i++) {result[i] = (nextToken.charAt(i) - 'a'); }return result;} } static class InputReader{ BufferedReader in ; StringTokenizer tok ; public InputReader( InputStream stream){ in = new BufferedReader(new InputStreamReader(stream),32768); tok = null; } String nextToken(){ String line = ""; while(((tok == null) || !tok.hasMoreTokens())){try{if ( ((line = in.readLine()) != null)) tok = new StringTokenizer(line); else return null; }catch (IOException e){ e.printStackTrace(); return null;} }return tok.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} } }
5	public class test1{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int a[] = new int[n];  int b[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); b[i] = a[i]; }Arrays.sort(b); int count = 0; for ( int i = 0;(i < n);i++) if ( (a[i] != b[i])) count++; if ( (count <= 2)) System.out.println("YES"); else System.out.println("NO"); } }
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);  APaintTheNumbers solver = new APaintTheNumbers(); solver.solve(1,in,out); out.close(); } static class APaintTheNumbers{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.i();  int[] a = in.ia(n); RadixSort.radixSort(a); boolean[] flag = new boolean[n];  int count = 0; for ( int i = 0;(i < n);i++) {if ( !flag[i]) {++count; flag[i] = true; for ( int j = 0;(j < n);j++) {if ( (!flag[j] && ((a[j] % a[i]) == 0))) {flag[j] = true; } }} }out.printLine(count); } } 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); } } static class InputReader{ private InputStream is ; private byte[] inbuf = new byte[1024]; private int lenbuf = 0; private int ptrbuf = 0; public InputReader( InputStream is){ this.is = is; } 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++];} public int[] ia( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = i(); return a;} public 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(); }} } }
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 ( (memo1[idx][remCnt][remSum] != -1)) return memo1[idx][remCnt][remSum]; int ans = dp1((idx + 1),remCnt,remSum); if ( (((g[idx] == 0) && (t[idx] <= remSum)) && (remCnt > 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;} static private 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();} } }
4	public class PhoenixAndComputers{ 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 mod = Integer.parseInt(st.nextToken());  long[][] dp = new long[(n + 2)][(n + 1)];  long[] pow = new long[(n + 1)]; pow[0] = 1; for ( int i = 1;(i <= n);i++) {pow[i] = (pow[(i - 1)] * 2); pow[i] %= mod; } long[][] choose = new long[((n * 2) + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {choose[i][i] = 1; }for ( int i = 1;(i <= (n * 2));i++) {for ( int j = 0;(j <= n);j++) {choose[i][j] = choose[(i - 1)][j]; if ( (j > 0)) {choose[i][j] += choose[(i - 1)][(j - 1)]; } choose[i][j] %= mod; }}dp[0][0] = 1; 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)] += (((pow[(k - 1)] * choose[(j + k)][k]) % mod) * dp[i][j]); dp[((i + k) + 1)][(j + k)] %= mod; }}} long ans = 0; for ( int j = 0;(j <= n);j++) {ans += dp[(n + 1)][j]; ans %= mod; }System.out.println(ans); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ public void solve( int testNumber, FastScanner in, PrintWriter out){ final int[] dr = {-1,0,1,0}; final int[] dc = {0,-1,0,1};  int height = in.nextInt();  int width = in.nextInt();  int k = in.nextInt();  int[][][] cost = new int[4][height][width]; for ( int r = 0;(r < height);r++) {for ( int c = 0;((c + 1) < width);c++) { int x = in.nextInt(); cost[3][r][c] = x; cost[1][r][(c + 1)] = x; }}for ( int r = 0;((r + 1) < height);r++) {for ( int c = 0;(c < width);c++) { int x = in.nextInt(); cost[2][r][c] = x; cost[0][(r + 1)][c] = x; }} boolean odd = ((k % 2) != 0); k /= 2; int[][][] d = new int[(k + 1)][height][width]; for ( int len = 1;(len <= k);len++) {for ( int r = 0;(r < height);r++) {for ( int c = 0;(c < width);c++) {d[len][r][c] = Integer.MAX_VALUE; for ( int dir = 0;(dir < 4);dir++) { int nr = (r + dr[dir]);  int nc = (c + dc[dir]); if ( ((((nr < 0) || (nr >= height)) || (nc < 0)) || (nc >= width))) {continue;} d[len][r][c] = Math.min(d[len][r][c],(d[(len - 1)][nr][nc] + cost[dir][r][c])); }}}}for ( int r = 0;(r < height);r++) {for ( int c = 0;(c < width);c++) {if ( (c > 0)) {out.print(" "); } out.print((odd?-1:(2 * d[k][r][c]))); }out.println(); }} } 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());} } }
2	public class CodeForces1177B{ public static char custBinSearch( long lower, long upper, long lowIndex, int ten, long position){ long half = Math.round(((lower + upper) / 2.0));  long lowBound = (lowIndex + ((half - lower) * (ten + 1)));  long upBound = (lowBound + ten); if ( (position < lowBound)) {return custBinSearch(lower,(half - 1),lowIndex,ten,position);} else if ( (position > upBound)) {lowIndex += (((half + 1) - lower) * (ten + 1)); return custBinSearch((half + 1),upper,lowIndex,ten,position);} else {return Long.toString(half).charAt((int)(position - lowBound));}} public static void main( String[] args)throws IOException { BufferedReader inputs = new BufferedReader(new InputStreamReader(System.in));  long indexPosition = Long.parseLong(inputs.readLine()); inputs.close(); int tenFactor = 0;  long lowerBound = 1;  long upperBound = (long)Math.pow(10,12);  long lowerIndexBound = 1;  long redIndex = 0; redIndex += indexPosition; while((redIndex > 0)){redIndex -= (long)((9 * Math.pow(10,tenFactor)) * (tenFactor + 1)); if ( (redIndex <= 0)) {lowerBound = (long)Math.pow(10,tenFactor); upperBound = (long)(Math.pow(10,(tenFactor + 1)) - 1); break;} lowerIndexBound += (long)((9 * Math.pow(10,tenFactor)) * (tenFactor + 1)); tenFactor++; }System.out.println(custBinSearch(lowerBound,upperBound,lowerIndexBound,tenFactor,indexPosition)); } }
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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  int[] a = in.nextIntArray(n); Arrays.sort(a); int count = 0;  boolean[] used = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !used[i]) {count++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {used[j] = true; } }} }out.println(count); } } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } public FastScanner( String fileName){ try{br = new BufferedReader(new FileReader(fileName)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public int nextInt(){ return Integer.parseInt(next());} public String next(){ while(((st == null) || !st.hasMoreElements())){ String line = null; try{line = br.readLine(); }catch (IOException e){ } st = new StringTokenizer(line); }return st.nextToken();} public int[] nextIntArray( int n){ int[] ret = new int[n]; for ( int i = 0;(i < n);i++) {ret[i] = nextInt(); }return ret;} } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.nextInt();  int[] a = in.nextIntArray(n);  int ct = 0; for ( int i = 0;(i < n);++i) {for ( int j = (i + 1);(j < n);++j) {if ( (a[i] > a[j])) ++ct; }}ct &= 1; int Q = in.nextInt(); for ( int q = 0;(q < Q);++q) { int l = in.nextInt();  int r = in.nextInt();  int size = ((((r - l) + 1) * (r - l)) >> 1); ct ^= (size & 1); out.println((((ct % 2) == 0)?"even":"odd")); }} } 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);} public int[] nextIntArray( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = nextInt(); }return array;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
4	public class CF1515E extends PrintWriter{ CF1515E(){ super(System.out,true); } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF1515E o = new CF1515E(); o.main(); o.flush(); } void main(){ int n = sc.nextInt();  int md = sc.nextInt();  int k = ((n + 1) / 2);  int[][] dp = new int[(k + 1)][(n + 1)]; dp[0][0] = 1; for ( int h = 1;(h <= k);h++) for ( int l = h;(l <= ((n - h) + 1));l++) dp[h][l] = (int)((((dp[h][(l - 1)] * 2L) + dp[(h - 1)][(l - 1)]) * h) % md); int ans = 0; for ( int h = 1;(h <= k);h++) ans = ((ans + dp[h][((n - h) + 1)]) % md); println(ans); } }
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 f{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  Hashtable<Long,Boolean> d = new Hashtable<Long,Boolean>();  int n = in.nextInt(),k = in.nextInt(),size = 0,a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); Arrays.sort(a); for ( int i = 0;(i < n);i++) { long x = a[i]; if ( !d.containsKey(x)) {d.put((x * k),true); size++; } }System.out.println(size); } }
6	public class Hello{ 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 from = (scan.nextInt() - 1);  int to = (scan.nextInt() - 1); graph[from][to] = 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++) { boolean existI = ((mask & (1 << i)) > 0); if ( ((Integer.bitCount(mask) == 1) && existI)) {dp[mask][i] = 1; } else if ( (((Integer.bitCount(mask) > 1) && existI) && (first(mask) != i))) { long sum = 0; for ( int j = 0;(j < n);j++) {if ( graph[i][j]) sum += dp[(mask ^ (1 << i))][j]; }dp[mask][i] = sum; } }} long countCycles = 0; for ( int mask = 7;(mask < max);mask++) {for ( int i = 0;(i < n);i++) {if ( ((Integer.bitCount(mask) >= 3) && graph[first(mask)][i])) {countCycles += dp[mask][i]; } }}System.out.println((countCycles / 2)); } public static int first( int mask){ int i = 0; while(((mask & (1 << i++)) == 0));return (i - 1);} }
4	public class Abc{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt();  boolean vis[][] = new boolean[n][m];  LinkedList<Integer> q = new LinkedList<>(); for ( int i = 0;(i < k);i++) { int x = (sc.nextInt() - 1),y = (sc.nextInt() - 1); vis[x][y] = true; q.add(x); q.add(y); } int lastx = -1,lasty = -1;  int dirX[] = {1,-1,0,0},dirY[] = {0,0,1,-1}; while(!q.isEmpty()){ int x = q.removeFirst();  int y = q.removeFirst(); lastx = x; lasty = y; for ( int i = 0;(i < 4);i++) { int newx = (x + dirX[i]),newy = (y + dirY[i]); if ( (((((newx >= 0) && (newx < n)) && (newy >= 0)) && (newy < m)) && !vis[newx][newy])) {vis[newx][newy] = true; q.add(newx); q.add(newy); } }}out.println((((lastx + 1) + " ") + (lasty + 1))); out.close(); } }
4	public class x1515E{ static long MOD ; public static void main( String[] hi)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int N = Integer.parseInt(st.nextToken()); MOD = Long.parseLong(st.nextToken()); fac = new long[401]; invfac = new long[401]; fac[0] = invfac[0] = 1L; for ( int i = 1;(i <= 400);i++) {fac[i] = ((fac[(i - 1)] * i) % MOD); invfac[i] = power(fac[i],(MOD - 2),MOD); } long[] pow2 = new long[401]; for ( int i = 0;(i <= 400);i++) pow2[i] = power(2,i,MOD); long[][] dp = new long[(N + 1)][(N + 1)]; for ( int v = 1;(v <= N);v++) {dp[v][v] = pow2[(v - 1)]; for ( int k = 1;(k <= v);k++) for ( int block = 1;(block <= k);block++) {if ( (block == v)) continue; long temp = ((dp[((v - block) - 1)][(k - block)] * calc((k - block),block)) % MOD); temp = ((temp * pow2[(block - 1)]) % MOD); dp[v][k] += temp; if ( (dp[v][k] >= MOD)) dp[v][k] -= MOD; }} long res = 0L; for ( int v = 1;(v <= N);v++) {res += dp[N][v]; if ( (res >= MOD)) res -= MOD; }System.out.println(res); } static long[] fac ,invfac ; public static long calc( int a, int b){ long res = ((fac[(a + b)] * invfac[a]) % MOD); return ((res * invfac[b]) % MOD);} public static long power( long x, long y, long p){ long res = 1L; x = (x % p); while((y > 0)){if ( ((y & 1) == 1)) res = ((res * x) % p); y >>= 1; x = ((x * x) % p); }return res;} }
3	public class kosyaDetka{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int t = scan.nextInt();  ArrayList<Integer> arr = new ArrayList<>(); for ( int i = 0;(i < t);i++) {arr.add(scan.nextInt()); } int count = 0; while((arr.size() != 0)){ int min = Integer.MAX_VALUE; for ( int i = 0;(i < arr.size());i++) { int temp = arr.get(i); if ( (temp < min)) {min = temp; } }for ( int i = 0;(i < arr.size());i++) { int temp = arr.get(i); if ( ((temp % min) == 0)) {arr.remove(i); i--; } }count++; }System.out.println(count); } }
1	public class ProblemB{ Map<Integer,List<int[]>> dest ; private ProblemB()throws IOException{ BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));  String h = rd.readLine();  String[] q = h.split("\\s+");  int a = Integer.parseInt(q[1]);  int b = Integer.parseInt(q[2]); h = rd.readLine(); q = h.split(" "); int n = q.length;  int[] p = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = Integer.parseInt(q[i]); } Set<Integer> pset = new HashSet<>(); for ( int x :p) {pset.add(x); }if ( (a == b)) { boolean res = true; for ( int x :p) {if ( !pset.contains((a - x))) {res = false; break;} }out((res?"YES":"NO")); if ( res) { StringBuilder buf = new StringBuilder(); for ( int i = 0;(i < n);i++) {if ( (i > 0)) {buf.append(' '); } buf.append('0'); }out(buf); } } else {dest = new HashMap<>(); boolean res = true; for ( int x :p) { boolean aOk = pset.contains((a - x));  boolean bOk = pset.contains((b - x)); if ( (!aOk && !bOk)) {res = false; break;} else {if ( aOk) {addEdgeAndBack(x,(a - x),0); } if ( bOk) {addEdgeAndBack(x,(b - x),1); } }} Set<Integer> aSet = new HashSet<>(); if ( res) {for ( int x :p) { List<int[]> e = getEdges(x); if ( (e.size() == 1)) { int[] edge = e.get(0); if ( (edge[0] == x)) {if ( (edge[1] == 0)) {aSet.add(x); } } else { boolean odd = true;  int curA = edge[1];  int prev = x; while(true){ int cur = edge[0]; if ( ((curA == 0) && odd)) {aSet.add(prev); aSet.add(cur); } e = getEdges(cur); if ( (e.size() == 1)) {if ( (!odd && (e.get(0)[0] != cur))) {res = false; } break;} int other = ((e.get(0)[0] == prev)?1:0); edge = e.get(other); if ( (edge[1] == curA)) {res = false; break;} curA = (1 - curA); prev = cur; odd = !odd; }if ( !res) {break;} }} }} out((res?"YES":"NO")); if ( res) { StringBuilder buf = new StringBuilder(); for ( int i = 0;(i < n);i++) {if ( (i > 0)) {buf.append(' '); } buf.append((aSet.contains(p[i])?'0':'1')); }out(buf); } }} private void addEdgeAndBack( int from, int to, int u){ addEdge(from,to,u); addEdge(to,from,u); } private void addEdge( int from, int to, int u){ List<int[]> edges = getEdges(from); for ( int[] edge :edges) {if ( (edge[0] == to)) {return ;} }edges.add(new int[]{to,u}); } private List<int[]> getEdges( int from){ List<int[]> ds = dest.get(from); if ( (ds == null)) {ds = new ArrayList<>(); dest.put(from,ds); } return ds;} static private void out( Object x){ System.out.println(x); } public static void main( String[] args)throws IOException { new ProblemB(); } }
2	public class con169_D{ static private final boolean DEBUG = false; public static void main(final String[] args)throws Exception { final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); final String line = br.readLine(); final StringTokenizer tok = new StringTokenizer(line); final long L = Long.parseLong(tok.nextToken()); final long R = Long.parseLong(tok.nextToken()); System.out.println(solve(L,R)); } public static long solve(final long L,final long R){ if ( (L == R)) return (L ^ R); if ( DEBUG) System.out.printf("L=%d (%s), R=%d (%s)\n",L,Long.toBinaryString(L),R,Long.toBinaryString(R)); final int ld = length(L); final int ldm1 = (ld - 1); final int rd = length(R); if ( (ld < rd)) { long max = 1; while((length(max) < rd)){max <<= 1; } long min = 1; while((length(min) < (rd - 1))){min <<= 1; ++min; }if ( DEBUG) System.out.printf("min=%d (%s), max=%d (%s)\n",min,Long.toBinaryString(min),max,Long.toBinaryString(max)); return (min ^ max);} else {final char[] minStr = Long.toBinaryString(L).toCharArray(); final char[] maxStr = Long.toBinaryString(R).toCharArray(); final char[] res = new char[minStr.length]; Arrays.fill(res,'0'); { int i = 0; while((i < res.length)){if ( (minStr[i] == maxStr[i])) {res[i] = '0'; } else {break;}++i; }if ( DEBUG) System.out.println(("diff at pos: " + i)); if ( (minStr[i] == '0')) {res[i++] = '1'; for ( int j = i;(j < res.length);++j) {res[j] = '1'; }} else {throw (new IllegalArgumentException());}}return Long.parseLong(new String(res),2);}} static private int length( long l){ int res = 0; while((l > 0)){++res; l >>= 1; }return res;} }
5	public class A{ 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(); Arrays.sort(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"); }} 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(); } 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)); } }
3	public class Main{ static private final long mod = 1000000007; static private final int MAXN = 100001; static private long power( long x, long y, long m){ long temp ; if ( (y == 0)) return 1; temp = power(x,(y / 2),m); temp = ((temp * temp) % m); if ( ((y % 2) == 0)) return temp; else return (((x % m) * temp) % m);} static private long power( long x, long y){ return power(x,y,mod);} static private long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static int nextLog2( int a){ return ((a == 0)?0:(32 - Integer.numberOfLeadingZeros((a - 1))));} static private int[] getLogArr( int n){ int arr[] = new int[(n + 1)]; for ( int i = 1;(i < (n + 1));i++) {arr[i] = (int)((Math.log(i) / Math.log(2)) + 1e-10); }return arr;} static private int log[] = getLogArr(MAXN); static int find( Subset[] Subsets, int i){ if ( (Subsets[i].parent != i)) Subsets[i].parent = find(Subsets,Subsets[i].parent); return Subsets[i].parent;} public static void main( String[] args)throws Exception { try(FastReader in=new FastReader();FastWriter out=new FastWriter()){ int t ,i ,j ,n ,k ,l ,r ,m ,c ,p ,q ,ti ,tidx ;  long x ,y ,z ; {n = in.nextInt(); int a[] = new int[101]; for ( i = 0;(i < n);i++) {a[in.nextInt()]++; }m = 0; for ( i = 1;(i < 101);i++) {if ( (a[i] > 0)) {m++; for ( j = i;(j <= 100);j += i) {a[j] = 0; }} }out.println(m); }out.commit(); }} static class FastReader implements Closeable{ private BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private StringTokenizer st ; String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} double nextDouble(){ return Double.parseDouble(next());} int[] nextIntArr( int n){ int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextInt(); }return arr;} long[] nextLongArr( int n){ long[] arr = new long[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextLong(); }return arr;} @Override public void close()throws IOException { br.close(); } } static class FastWriter implements Closeable{ BufferedWriter bw ; StringBuilder sb = new StringBuilder(); List<String> list = new ArrayList<>(); Set<String> set = new HashSet<>(); FastWriter(){ bw = new BufferedWriter(new OutputStreamWriter(System.out)); } <T> void commit()throws IOException { bw.write(sb.toString()); bw.flush(); sb = new StringBuilder(); } <T> void print( T obj){ sb.append(obj.toString()); } void println()throws IOException { print("\n"); } <T> void println( T obj)throws IOException { print((obj.toString() + "\n")); } @Override public void close()throws IOException { bw.close(); } } }
4	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 ((a == 0)?b:gcd((b % a),a));} void work(){ int n = ni(); mod = nl(); long[] dp1 = new long[401];  long[][] dp2 = new long[(n + 1)][(n + 1)];  long[][] C = new long[401][401]; for ( int j = 0;(j <= 400);j++) {for ( int i = 0;(i <= j);i++) {if ( ((i == 0) || (j == i))) {C[i][j] = 1; } else {C[i][j] = ((C[(i - 1)][(j - 1)] + C[i][(j - 1)]) % mod); }}}for ( int i = 1;(i <= 400);i++) {for ( int j = 0;(j < i);j++) {dp1[i] = ((dp1[i] + C[j][(i - 1)]) % mod); }}for ( int i = 1;(i <= n);i++) {dp2[i][i] = dp1[i]; }for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j < i);j++) {for ( int k = 1;(k < j);k++) {dp2[i][j] = (dp2[i][j] + ((((dp2[((i - k) - 1)][(j - k)] * dp1[k]) % mod) * C[k][j]) % mod)); dp2[i][j] %= mod; }}} long ret = 0; for ( int j = 1;(j <= n);j++) {ret = ((ret + dp2[n][j]) % mod); }out.println(ret); } private int ni(){ return in.nextInt();} private long nl(){ return in.nextLong();} } class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.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());} public long nextLong(){ return Long.parseLong(next());} }
3	public final class paint_and_numers{ public static void main( String[] args){ 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(); Arrays.sort(a); int count = 0;  boolean[] c = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( (c[i] == false)) {c[i] = true; count++; for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {c[j] = true; } }} }System.out.println(count); } }
3	public class NewYearCurling908C{ public static void main( String[] args)throws IOException { FastScanner in = new FastScanner();  int n = in.nextInt();  double r = (double)in.nextInt();  double[] answers = new double[n];  double[] xCoords = new double[n]; for ( int i = 0;(i < n);i++) xCoords[i] = (double)in.nextInt(); answers[0] = r; for ( int i = 1;(i < n);i++) { double bound = r; for ( int j = 0;(j < i);j++) { double xDif = (xCoords[i] - xCoords[j]);  double y = answers[j];  double yNew = (y + Math.sqrt((((4 * r) * r) - (xDif * xDif)))); if ( (yNew > bound)) bound = yNew; }answers[i] = bound; }for ( int i = 0;(i < n);i++) System.out.print((answers[i] + " ")); System.out.println(); } public 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());} } }
6	public class E16{ static double[][] grid ; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine()); grid = new double[n][n]; for ( int i = 0;(i < n);i++) { StringTokenizer st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < n);j++) {grid[i][j] = Double.parseDouble(st.nextToken()); }} boolean[] seen = new boolean[(1 << n)];  double[] prob = new double[(1 << n)]; prob[((1 << n) - 1)] = 1; LinkedList<Integer> q = new LinkedList<Integer>(); q.add(((1 << n) - 1)); while(!q.isEmpty()){ int curr = q.removeFirst(); if ( (Integer.bitCount(curr) == 1)) continue; for ( int i = 0;(i < n);i++) {if ( ((curr & (1 << i)) == 0)) continue; for ( int j = (i + 1);(j < n);j++) {if ( ((curr & (1 << j)) == 0)) continue; prob[(curr - (1 << i))] += (prob[curr] * grid[j][i]); prob[(curr - (1 << j))] += (prob[curr] * grid[i][j]); if ( !seen[(curr - (1 << i))]) {q.addLast((curr - (1 << i))); seen[(curr - (1 << i))] = true; } if ( !seen[(curr - (1 << j))]) {q.addLast((curr - (1 << j))); seen[(curr - (1 << j))] = true; } }}prob[curr] = 0; } double sum = 0; for ( int i = 0;(i < n);i++) {sum += prob[(1 << i)]; }for ( int i = 0;(i < (n - 1));i++) {System.out.print(((prob[(1 << i)] / sum) + " ")); }System.out.println((prob[(1 << (n - 1))] / sum)); } }
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); } }
5	public class A{ public A(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  Integer mas[] = new Integer[n];  int b = 0; for ( int i = 0;(i < n);i++) {mas[i] = sc.nextInt(); b += mas[i]; }Arrays.sort(mas,new Comparator<Integer>(){}); int N = 0;  int g = 0; for ( int i = 0;(i < n);i++) {g += mas[i]; if ( (g > (int)(b / 2))) {System.out.println((i + 1)); return ;} }System.out.println(n); } public static void main( String[] args){ new A(); } }
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(); } } class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); if ( (n > m)) { int t = m; m = n; n = t; } f = new int[n][m]; res = Integer.MAX_VALUE; cur = 0; step = 1; numFree = (n * m); rec(0,0); out.println(((n * m) - res)); } private void rec( int x, int y){ if ( (numFree == 0)) {res = Math.min(res,cur); return ;} if ( (x >= n)) return ; if ( (y >= m)) {rec((x + 1),0); return ;} if ( (f[x][y] != 0)) {rec(x,(y + 1)); return ;} put(x,y); rec(x,(y + 1)); remove(x,y); if ( isValid((x + 1),y)) {put((x + 1),y); rec(x,(y + 1)); remove((x + 1),y); } if ( isValid(x,(y + 1))) {put(x,(y + 1)); rec(x,(y + 1)); remove(x,(y + 1)); } } private void put( int x, int y){ for ( int i = 0;(i < 5);++i) { int nx = (x + dx[i]);  int ny = (y + dy[i]); if ( isValid(nx,ny)) {if ( (f[nx][ny] == 0)) {--numFree; f[nx][ny] = step; } } }++step; ++cur; } private void remove( int x, int y){ --step; for ( int i = 0;(i < 5);++i) { int nx = (x + dx[i]);  int ny = (y + dy[i]); if ( isValid(nx,ny)) {if ( (f[nx][ny] == step)) {++numFree; f[nx][ny] = 0; } } }--cur; } private boolean isValid( int x, int y){ return ((((x >= 0) && (y >= 0)) && (x < n)) && (y < m));} int n ,m ; int[] dx = new int[]{-1,0,1,0,0}; int[] dy = new int[]{0,1,0,-1,0}; int step ; int numFree ; int cur ; int res ; int[][] f ; } 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());} }
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(); } }
0	public class ProblemD_05{ 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();} double readDouble()throws IOException { return Double.parseDouble(readString());} public static void main( String[] args){ new ProblemD_05().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 { double a = readDouble();  double v = readDouble();  double l = readDouble();  double d = readDouble();  double w = readDouble();  double t = 0;  double td = ((d > ((v * v) / (2 * a)))?((v / a) + ((d - ((v * v) / (2 * a))) / v)):sqrt(((2 * d) / a))); if ( (w >= min((a * td),v))) {t += td; w = min((a * td),v); } else { double v0 = sqrt((((w * w) / 2) + (a * d))); if ( ((v0 * v0) <= (v * v))) {t += (((2 * v0) - w) / a); } else {t += (((2 * v) - w) / a); double s2 = (d - ((((2 * v) * v) - (w * w)) / (2 * a))); t += (s2 / v); }} double t1 = ((sqrt(((w * w) + ((2 * a) * (l - d)))) - w) / a); if ( (t1 > ((v - w) / a))) t1 = ((v - w) / a); t += t1; double s1 = ((w * t1) + (((a * t1) * t1) / 2));  double t2 = (((l - d) - s1) / v); t += t2; out.printf(Locale.US,"%.12f",t); } 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);} } }
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; } } }
3	public class A{ void solve(){ int n = ni(); s = new char[(n + 1)]; s[0] = '.'; for ( int i = 1;(i <= n);i++) s[i] = ns().charAt(0); dp = new long[5001][5001]; dp[1][0] = 1; long sum[] = new long[(n + 2)]; sum[0] = 1; for ( int i = 2;(i <= n);i++) {for ( int j = 0;(j <= n);j++) {if ( (s[(i - 1)] == 'f')) {if ( ((j - 1) >= 0)) dp[i][j] = dp[(i - 1)][(j - 1)]; else dp[i][j] = 0; } else {dp[i][j] = sum[j]; }}for ( int j = n;(j >= 0);j--) {sum[j] = ((sum[(j + 1)] + dp[i][j]) % M); }} long ans = 0; for ( int i = 0;(i <= n);i++) {ans += dp[n][i]; if ( (ans >= M)) ans %= M; }pw.println(ans); } char s[] ; long dp[][] ; long go( int x, int cnt, int n){ if ( (x > n)) return 1; long cc = 0; if ( (dp[x][cnt] != -1)) return dp[x][cnt]; if ( (s[x] == 'f')) {cc = ((cc + go((x + 1),(cnt + 1),n)) % M); } else {for ( int j = cnt;(j >= 0);j--) cc = ((cc + go((x + 1),j,n)) % M); if ( (x == n)) cc = (((cc - cnt) + M) % M); }cc %= M; dp[x][cnt] = cc; return cc;} long M = ((long)1e9 + 7); InputStream is ; PrintWriter pw ; String INPUT = ""; void run()throws Exception { is = (INPUT.isEmpty()?System.in:new ByteArrayInputStream(INPUT.getBytes())); pw = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); pw.flush(); if ( !INPUT.isEmpty()) 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 = 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 void tr( Object... o){ if ( (INPUT.length() > 0)) System.out.println(Arrays.deepToString(o)); } }
1	public class stub implements Runnable{ public static void main( String[] args){ new stub().run(); } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer st ; public String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(br.readLine()); }return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} private void solve()throws IOException { int[] cnt = new int[(int)1e6];  int n = nextInt();  int k = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } int cur = 0;  int left = 0;  int i = left; while(((i < n) && (cur != k))){if ( (cnt[a[i]] == 0)) {cur++; } cnt[a[i]]++; i++; }i--; if ( (cur != k)) {out.println("-1 -1"); return ;} int right = i; while((cnt[a[left]] > 1)){cnt[a[left]]--; left++; }out.println((((left + 1) + " ") + (right + 1))); } public void run(){ try{solve(); out.close(); br.close(); }catch (IOException e){ e.printStackTrace(); } } }
1	public class RoundOneProblemB{ public static void main( String[] args){ int n = 1;  BufferedReader input = new BufferedReader(new InputStreamReader(System.in),50); try{n = Integer.valueOf(input.readLine()); if ( ((1 <= n) && (n <= Math.pow(10,5)))) {formatError(); } Pattern typeOne = Pattern.compile("^([A-Z]+)([0-9]+)$");  Pattern typeTwo = Pattern.compile("^R([0-9]+)C([0-9]+)$"); for ( int i = 0;(i < n);i++) { String line = input.readLine();  Matcher matchOne = typeOne.matcher(line); if ( matchOne.find()) {System.out.println(convertOneToTwo(matchOne.group(2),matchOne.group(1))); } else { Matcher matchTwo = typeTwo.matcher(line); if ( matchTwo.find()) {System.out.println(convertTwoToOne(matchTwo.group(1),matchTwo.group(2))); } }} }catch (Exception e){ formatError(); } } static private String convertTwoToOne( String row, String col){ StringBuilder result = new StringBuilder();  long c = Long.parseLong(col); while((c > 0)){result.append((char)(((c - 1) % 26) + 'A')); c = ((c - 1) / 26); }result.reverse(); result.append(Long.parseLong(row)); return result.toString();} static private String convertOneToTwo( String row, String col){ StringBuilder result = new StringBuilder();  int l = col.length(); col = col.toUpperCase(); long base = 1;  long c = 0; for ( int i = (l - 1);(i >= 0);i--) {c = (c + (((col.charAt(i) - 'A') + 1) * base)); base = (base * 26); }result.append("R").append(Long.parseLong(row)).append("C").append(c); return result.toString();} static private void formatError(){ System.out.println("Unexpected input"); System.exit(1); } }
2	public class Edu23{ public static int sum( String s){ int tot = 0; for ( int i = 0;(i < s.length());i++) {tot += (s.charAt(i) - '0'); }return tot;} public static BigInteger comb( int n, int k){ if ( (k == 0)) return new BigInteger("1"); else return comb(n,(k - 1)).multiply(new BigInteger((((n - k) + 1) + ""))).divide(new BigInteger((k + "")));} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long s = sc.nextLong();  long i ; for ( i = s;((i - sum((i + ""))) < s);i++) if ( ((i % 10) == 0)) i += 9; System.out.println(Math.max(0,((n - i) + 1))); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String f)throws FileNotFoundException{ br = new BufferedReader(new FileReader(f)); } 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 long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} public int[] nextIntArray( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} public int[] shuffle( int[] a, int n){ int[] b = new int[n]; for ( int i = 0;(i < n);i++) b[i] = a[i]; Random r = new Random(); for ( int i = 0;(i < n);i++) { int j = (i + r.nextInt((n - i)));  int t = b[i]; b[i] = b[j]; b[j] = t; }return b;} public long[] nextLongArray( int n)throws IOException { long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nextLong(); return a;} } }
4	public class Main{ static private final String NO = "NO"; static private final String YES = "YES"; InputStream is ; PrintWriter out ; String INPUT = ""; static private long MOD = 1000000007; static private 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(); }} static private void tr( Object... o){ System.out.println(Arrays.deepToString(o)); } }
4	public class CF_1523_C{ void pre()throws Exception { } void solve( int TC)throws Exception { int N = ni();  int[] A = new int[N]; for ( int i = 0;(i < N);i++) A[i] = ni(); int[] stack = new int[(2 * N)];  int sz = 0; for ( int i = 0;(i < N);i++) {if ( (A[i] == 1)) stack[sz++] = 1; else {while(((sz > 0) && ((stack[(sz - 1)] + 1) != A[i])))sz--; hold((sz != 0)); stack[(sz - 1)]++; hold((stack[(sz - 1)] == A[i])); }hold((sz != 0)); StringBuilder st = new StringBuilder(); for ( int s = 0;(s < sz);s++) {st.append(stack[s]); if ( ((s + 1) < sz)) st.append("."); }pn(st.toString()); }} void hold( boolean b)throws Exception { if ( !b) throw (new Exception("Hold right there, Sparky!")); } void exit( boolean b){ if ( !b) System.exit(0); } final long IINF = (long)1e17; final int INF = ((int)1e9 + 2); DecimalFormat df = new DecimalFormat("0.00000000000"); double PI = 3.141592653589793238462643383279502884197169399,eps = 1e-8; static boolean multipleTC = true,memory = true,fileIO = false; FastReader in ; PrintWriter out ; void run()throws Exception { long ct = System.currentTimeMillis(); if ( fileIO) {in = new FastReader(""); out = new PrintWriter(""); } else {in = new FastReader(); out = new PrintWriter(System.out); } int T = (multipleTC?ni():1); pre(); for ( int t = 1;(t <= T);t++) solve(t); out.flush(); out.close(); System.err.println((System.currentTimeMillis() - ct)); } public static void main( String[] args)throws Exception { if ( memory) new Thread(null,new Runnable(){public void run(){ try{new CF_1523_C().run(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } },"1",(1 << 28)).start(); else new CF_1523_C().run(); } int find( int[] set, int u){ return set[u] = ((set[u] == u)?u:find(set,set[u]));} 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 bit( long n){ return ((n == 0)?0:(1 + bit((n & (n - 1)))));} void pn( Object... o){ for ( int i = 0;(i < o.length);i++) out.print((o[i] + (((i + 1) < o.length)?" ":"\n"))); } int ni()throws Exception { return Integer.parseInt(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()throws Exception { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new Exception(e.toString()));} }return st.nextToken();} String nextLine()throws Exception { String str ; try{str = br.readLine(); }catch (IOException e){ throw (new Exception(e.toString()));} return str;} } }
3	public class Dasha{ static Scanner sc = new Scanner(System.in); static PrintWriter pw = new PrintWriter(System.out),pw2 = new PrintWriter(System.out); public static void main( String[] args)throws IOException { int n = sc.nextInt();  int[] arr = new int[101]; for ( int i = 0;(i < n);i++) arr[sc.nextInt()]++; boolean[] vis = new boolean[101];  int c = 0; for ( int i = 1;(i <= 100);i++) {if ( (!vis[i] && (arr[i] > 0))) {c++; for ( int j = (i + i);(j <= 100);j += i) vis[j] = true; } }pw.println(c); pw.flush(); } public static long pow( long a, long pow){ return ((pow == 0)?1:(((pow % 2) == 0)?pow((a * a),(pow >> 1)):(a * pow((a * a),(pow >> 1)))));} public static int gcd( int n1, int n2){ return ((n2 == 0)?n1:gcd(n2,(n1 % n2)));} public static long factorial( long a){ return (((a == 0) || (a == 1))?1:(a * factorial((a - 1))));} public static void sort( int[] arr){ shuffle(arr); Arrays.sort(arr); } public static void shuffle( int[] arr){ Random rnd = new Random(); for ( int i = (arr.length - 1);(i > 0);i--) { int index = rnd.nextInt((i + 1));  int temp = arr[index]; arr[index] = arr[i]; arr[i] = temp; }} static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( FileReader r){ br = new BufferedReader(r); } 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();} } }
5	public class Solution implements Runnable{ public void solve()throws Exception { int n = nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }Arrays.sort(a); if ( (n == 1)) {if ( (a[0] == 1)) {out.print(2); } else {out.print(1); }} else {out.print(1); for ( int i = 1;(i < n);i++) {if ( ((i == (n - 1)) && (a[i] == 1))) {out.print((" " + 2)); } else {out.print((" " + a[(i - 1)])); }}}} BufferedReader in ; PrintWriter out ; StringTokenizer st ; long stime = 0; private String next()throws Exception { while(((st == null) || !st.hasMoreElements()))st = new StringTokenizer(in.readLine()); return st.nextToken();} private int nextInt()throws Exception { return Integer.parseInt(next());} public static void main( String[] args)throws Exception { new Thread(null,new Solution(),"",(1 << 25)).start(); } }
5	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(""); void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int N = nextInt();  int T = nextInt();  Pair[] p = new Pair[N]; for ( int i = 0;(i < N);i++) p[i] = new Pair(nextInt(),nextInt()); sort(p); int ans = 2; for ( int i = 1;(i < N);i++) { int dif = (((2 * p[i].x) - p[i].a) - ((2 * p[(i - 1)].x) + p[(i - 1)].a)); if ( (dif == (2 * T))) ans++; else if ( (dif > (2 * T))) ans += 2; }out.println(ans); out.close(); } class Pair implements Comparable<Pair>{ int x ,a ; public Pair( int xx, int aa){ x = xx; a = aa; } } String nextToken()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
0	public class solution{ static long gcd( long a, long b){ if ( (b == 0)) return a; else return gcd(b,(a % b));} public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long m1 = 0,m2 = 0; if ( (n < 3)) m1 = n; else {if ( ((n & 1) == 1)) { long lcm = ((n * (n - 1)) / gcd(n,(n - 1))); m1 = ((lcm * (n - 2)) / gcd(lcm,(n - 2))); } else { long lcm = (((n - 1) * (n - 2)) / gcd((n - 1),(n - 2))); m1 = ((lcm * (n - 3)) / gcd(lcm,(n - 3))); lcm = ((n * (n - 1)) / gcd(n,(n - 1))); m2 = ((lcm * (n - 3)) / gcd(lcm,(n - 3))); m1 = Math.max(m1,m2); }}System.out.println(m1); } }
3	public class Main{ private FastScanner in ; private PrintWriter out ; private void solve()throws IOException { solveC(); } int n ,m ,cl ; char a[][] ; int[] b ; int fromi ,fromj ,toi ,toj ; private boolean bfs( long[] str){ int[][] steps = {{(((int)str[0] / 10) - 1),(((int)str[0] % 10) - 1)},{(((int)str[1] / 10) - 1),(((int)str[1] % 10) - 1)},{(((int)str[2] / 10) - 1),(((int)str[2] % 10) - 1)},{(((int)str[3] / 10) - 1),(((int)str[3] % 10) - 1)}}; for ( int i = 0,ci = fromi,cj = fromj;(i < cl);i++) {ci += steps[b[i]][0]; cj += steps[b[i]][1]; if ( (((((ci >= n) || (ci < 0)) || (cj >= m)) || (cj < 0)) || (a[ci][cj] == '#'))) return false; if ( (a[ci][cj] == 'E')) return true; }return false;} private void solveC()throws IOException { int n = in.nextInt();  int r = in.nextInt();  int[] x = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = in.nextInt(); } double[] y = new double[n]; for ( int i = 0;(i < n);i++) {y[i] = r; for ( int j = 0;(j < i);j++) {if ( (abs((x[i] - x[j])) <= (2 * r))) {y[i] = max(y[i],(y[j] + sqrt((((4.0 * r) * r) - ((x[i] - x[j]) * (x[i] - x[j])))))); } }}for ( double ty :y) out.print((ty + " ")); out.println(); } 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());} String nextLine()throws IOException { return br.readLine();} } 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(); } }
4	public class TestClass{ public static class FastWriter{ static private 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;} static private 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;} static private 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 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 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();} } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { return (int)readLong();} public final long readLong()throws IOException { int c = read(); while(isSpaceChar(c)){c = read(); if ( (c == -1)) throw (new IOException()); } boolean negative = false; if ( (c == '-')) {negative = true; c = read(); } long res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (negative?-res:res);} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } static long pow( long a, long b, long MOD){ long x = 1,y = a; while((b > 0)){if ( ((b % 2) == 1)) {x = (x * y); if ( (x > MOD)) x %= MOD; } y = (y * y); if ( (y > MOD)) y %= MOD; b /= 2; }return x;} static long[] f = new long[200001]; static long InverseEuler( long n, long MOD){ return pow(n,(MOD - 2),MOD);} static int[] h = {0,0,-1,1}; static int[] v = {1,-1,0,0}; public static class Pair{ public int a ; public int b ; public Pair( int a, int b){ this.a = a; this.b = b; } } static int counter = 0; static int[] rIn ; static int[] rOut ; static int[] lIn ; static int[] lOut ; static private int[] flatten ; static private int[] lFlatten ; static long answer = 0; static int VISITED = 1; static int VISITING = 2; static int[] DIRX = new int[]{0,0,1,-1}; static int[] DIRY = new int[]{1,-1,0,0}; public static void main( String[] args)throws Exception { InputReader in = new InputReader(System.in);  FastWriter out = new FastWriter(System.out);  int t = in.readInt(); while((t-- > 0)){ int n = in.readInt();  Stack<Integer> s = new Stack<>(); System.out.println("1"); int i1 = in.readInt(); assert (i1 == 1); s.add(1); for ( int i = 1;(i < n);++i) { int next = in.readInt(); if ( (next == 1)) {} else {while(((s.peek() + 1) != next)){s.pop(); }s.pop(); }s.add(next); StringBuilder ans = new StringBuilder(); for ( int c :s) {ans.append(c).append("."); }out.println(ans.substring(0,(ans.length() - 1))); out.flush(); }}} static private void solvedd( int[] arr, int left, int right, int[] ans, int depth){ if ( (left > right)) return ; int maxInd = left; for ( int i = left;(i <= right);++i) {if ( (arr[i] > arr[maxInd])) {maxInd = i; } }ans[maxInd] = depth; solvedd(arr,left,(maxInd - 1),ans,(depth + 1)); solvedd(arr,(maxInd + 1),right,ans,(depth + 1)); } static private void solved( List<List<Integer>> g, int node, int[][] dp, int last, int[] a){ int donttake = 0;  int take = 0; for ( int i = 0;(i < g.get(node).size());++i) { int ntb = g.get(node).get(i); if ( (ntb != last)) {solved(g,ntb,dp,node,a); donttake += Math.max(dp[ntb][0],dp[ntb][1]); take += dp[ntb][1]; } }dp[node][0] = (a[node] + take); dp[node][1] = donttake; } static private boolean solve( int n, List<Integer> nums, int cur, int pos, Boolean[][] dp){ if ( (cur > n)) return false; if ( (cur == n)) return true; if ( (pos >= nums.size())) return false; if ( (dp[cur][pos] != null)) {return dp[cur][pos];} boolean without = solve(n,nums,cur,(pos + 1),dp);  boolean with = false;  int ogcur = cur; for ( int i = 1;(i < 12);++i) {with |= solve(n,nums,(cur + nums.get(pos)),(pos + 1),dp); cur += nums.get(pos); }return dp[ogcur][pos] = (with | without);} static private int dfs( HashMap<Pair,TreeSet<Pair>> grid, int x, int y, int ti, HashSet<Pair> vis, int r, int startX, int startY){ int taken = ((ti - Math.abs((startX - x))) - Math.abs((startY - y))); if ( (taken < 0)) return 0; if ( ((((x < 0) || (y < 0)) || (x > r)) || (y > r))) return 0; if ( vis.contains(new Pair(x,y))) return 0; int max = 0; if ( grid.containsKey(new Pair(x,y))) { TreeSet<Pair> times = grid.get(new Pair(x,y)); for ( Pair t :times) {if ( (t.a <= taken)) {max = Math.max(t.b,max); } else break;}} vis.add(new Pair(x,y)); max = Math.max(dfs(grid,(x + 1),y,ti,vis,r,startX,startY),max); max = Math.max(dfs(grid,x,(y + 1),ti,vis,r,startX,startY),max); max = Math.max(dfs(grid,(x - 1),y,ti,vis,r,startX,startY),max); max = Math.max(dfs(grid,x,(y - 1),ti,vis,r,startX,startY),max); return max;} static private int solver( int[] nums, int pos, int[] dp){ if ( (pos >= nums.length)) return 0; if ( (dp[pos] != Integer.MAX_VALUE)) return dp[pos]; int min = (solver(nums,(pos + 2),dp) + nums[pos]); min = Math.min((solver(nums,(pos + 3),dp) + nums[pos]),min); if ( ((pos + 1) < nums.length)) min = Math.min(min,((nums[pos] + nums[(pos + 1)]) + solver(nums,(pos + 3),dp))); if ( ((pos + 1) < nums.length)) min = Math.min(min,((nums[pos] + nums[(pos + 1)]) + solver(nums,(pos + 4),dp))); return dp[pos] = min;} static private void dfsR( List<List<Integer>> g, int node, int[] v){ rIn[node] = counter; flatten[counter++] = v[node]; for ( int i = 0;(i < g.get(node).size());++i) {dfsR(g,g.get(node).get(i),v); }rOut[node] = counter; flatten[counter++] = (v[node] * -1); } static private void dfsL( List<List<Integer>> g, int node, int[] v){ lIn[node] = counter; lFlatten[counter++] = v[node]; for ( int i = 0;(i < g.get(node).size());++i) {dfsL(g,g.get(node).get(i),v); }lOut[node] = counter; lFlatten[counter++] = (v[node] * -1); TreeMap<String,Integer> map = new TreeMap<>(); } static private void preprocess( int pos, int[][] pre, List<List<Integer>> tree, int[] traverse, int depth, int last, int[] tin, int[] tout){ tin[pos] = counter++; traverse[depth] = pos; for ( int i = 0;((depth - (1 << i)) >= 0);++i) {pre[pos][i] = traverse[(depth - (1 << i))]; }for ( int i = 0;(i < tree.get(pos).size());++i) {if ( (tree.get(pos).get(i) != last)) preprocess(tree.get(pos).get(i),pre,tree,traverse,(depth + 1),pos,tin,tout); }tout[pos] = counter++; } static boolean submit = true; }
6	public class SpidersSolver{ public static final boolean DEBUG = false; public static void main( String[] args){ if ( DEBUG) {try{System.setIn(new FileInputStream("input.txt")); }catch (IOException e){ } } Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),m = sc.nextInt(); if ( (n < m)) { int tmp = n; n = m; m = tmp; } int pow = 1; for ( int i = 0;(i < m);i++) pow *= 2; int[] count = new int[pow]; for ( int cur = 0;(cur < pow);cur++) { int x = cur; while((x > 0)){count[cur] += (x % 2); x /= 2; }count[cur] = (m - count[cur]); } int[][] C = new int[pow][pow]; for ( int cur = 0;(cur < pow);cur++) {C[0][cur] = 0; for ( int last = 1;(last < pow);last++) C[last][cur] = Integer.MIN_VALUE; }for ( int i = 0;(i < n);i++) { int[][] newC = new int[pow][pow]; for ( int cur = 0;(cur < pow);cur++) for ( int next = 0;(next < pow);next++) { int mask = (((cur | (cur << 1)) | (cur >> 1)) | next); mask %= pow; int max = 0; for ( int last = 0;(last < pow);last++) if ( (((last | mask) == (pow - 1)) && (max < (count[cur] + C[last][cur])))) max = (count[cur] + C[last][cur]); newC[cur][next] = max; }C = newC; } int result = 0; for ( int cur = 0;(cur < pow);cur++) result = Math.max(result,C[cur][0]); System.out.println(result); } }
1	public class Noldbach{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  boolean[] sieve = new boolean[1001]; sieve[2] = false; ArrayList<Integer> primes = new ArrayList<Integer>(); for ( int x = 2;(x < 1001);x++) if ( !sieve[x]) {primes.add(x); for ( int y = x;(y < 1001);y += x) sieve[y] = true; } int sum = 0; for ( int x = 2;(x <= n);x++) {if ( primes.contains(x)) { int need = (x - 1); for ( int y = 0;(y < (primes.size() - 1));y++) {if ( ((primes.get(y) + primes.get((y + 1))) == need)) {sum++; break;} }} if ( (sum == k)) break; }if ( (sum == k)) System.out.println("YES"); else System.out.println("NO"); } }
3	public class A{ public static void main( String[] args)throws Exception { FastScanner sc = new FastScanner(System.in);  FastPrinter out = new FastPrinter(System.out); new A().run(sc,out); out.close(); } public void run( FastScanner sc, FastPrinter out)throws Exception { int N = sc.nextInt();  int[] arr = sc.nextIntArray(N); Arrays.sort(arr); boolean[] done = new boolean[N];  int ans = 0; for ( int i = 0;(i < N);i++) {if ( done[i]) continue; ans++; for ( int j = i;(j < N);j++) {if ( ((arr[j] % arr[i]) == 0)) {done[j] = true; } }}out.println(ans); } static class FastScanner{ private final int BUFFER_SIZE = (1 << 10); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public FastScanner(){ this(System.in); } public FastScanner( InputStream stream){ din = new DataInputStream(stream); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public FastScanner( String fileName)throws IOException{ Path p = Paths.get(fileName); buffer = Files.readAllBytes(p); bytesRead = buffer.length; } int[] nextIntArray( int N)throws IOException { int[] arr = new int[N]; for ( int i = 0;(i < N);i++) {arr[i] = nextInt(); }return arr;} boolean isEndline( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} 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 { if ( (din == null)) {bufferPointer = 0; bytesRead = -1; } else {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++];} private int readOutSpaces()throws IOException { while(true){if ( (bufferPointer == bytesRead)) fillBuffer();  int c = buffer[bufferPointer++]; if ( !isSpaceChar(c)) {return c;} }} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } static class FastPrinter{ static final char ENDL = '\n'; StringBuilder buf ; PrintWriter pw ; public FastPrinter( OutputStream stream){ buf = new StringBuilder(); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))); } public FastPrinter( String fileName)throws Exception{ buf = new StringBuilder(); pw = new PrintWriter(new BufferedWriter(new FileWriter(fileName))); } public FastPrinter( StringBuilder buf){ this.buf = buf; } public void print( int a){ buf.append(a); } public void print( long a){ buf.append(a); } public void print( char a){ buf.append(a); } public void print( char[] a){ buf.append(a); } public void print( double a){ buf.append(a); } public void print( String a){ buf.append(a); } public void print( Object a){ buf.append(a.toString()); } public void println(){ buf.append(ENDL); } public void println( int a){ buf.append(a); buf.append(ENDL); } public void println( long a){ buf.append(a); buf.append(ENDL); } public void println( char a){ buf.append(a); buf.append(ENDL); } public void println( char[] a){ buf.append(a); buf.append(ENDL); } public void println( double a){ buf.append(a); buf.append(ENDL); } public void println( String a){ buf.append(a); buf.append(ENDL); } public void println( Object a){ buf.append(a.toString()); buf.append(ENDL); } public void close(){ pw.print(buf); pw.close(); } public void flush(){ pw.print(buf); pw.flush(); buf.setLength(0); } } }
3	public class Problem1{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); }Arrays.sort(a); int k = a.length; for ( int i = (a.length - 1);(i >= 0);i--) { int A = a[i]; for ( int j = 0;(j < i);j++) {if ( ((A % a[j]) == 0)) {k--; break;} }}System.out.println(k); sc.close(); } }
0	public class Main{ public static void main( String[] args)throws Exception { Scanner sc = null;  PrintWriter pr = null; pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); sc = new Scanner(new BufferedReader(new InputStreamReader(System.in))); long n = sc.nextInt(); if ( (n > 0)) pr.println(n); else { long n1 = (n / 10);  long n2 = (((n / 100) * 10) + (n % 10)); if ( (n1 < n2)) pr.println(n2); else pr.println(n1); }pr.close(); sc.close(); } }
5	public class House{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  ArrayList<HS> list = new ArrayList<HS>(); for ( int i = 0;(i < n);i++) {list.add(new HS(sc.nextInt(),sc.nextInt())); }Collections.sort(list); int count = 0; if ( (n >= 1)) count = 2; for ( int i = 0;(i < (list.size() - 1));i++) { double d = Math.abs((list.get((i + 1)).x - list.get(i).x)); d -= (((1.0 * list.get(i).a) / 2.0) + ((1.0 * list.get((i + 1)).a) / 2.0)); if ( ((d >= t) && ((d - t) <= 0.00000001))) {count++; } else if ( (d > t)) {count += 2; } }System.out.println(count); } } class HS implements Comparable<HS>{ public int x ; public int a ; public HS( int x, int a){ this.x = x; this.a = a; } }
4	public class FireAgain{ static int n ,m ,k ; static int inf = (int)1e9; static class Pair{ int x ,y ; Pair( int a, int b){ x = a; y = b; } } static int[] dx = {1,-1,0,0},dy = {0,0,1,-1}; static boolean valid( int x, int y){ return ((((x >= 0) && (x < n)) && (y >= 0)) && (y < m));} static int[][] bfs( int[] xs, int[] ys){ int[][] dist = new int[n][m]; for ( int i = 0;(i < n);i++) Arrays.fill(dist[i],inf); Queue<Pair> q = new LinkedList<>(); for ( int i = 0;(i < k);i++) {dist[xs[i]][ys[i]] = 0; q.add(new Pair(xs[i],ys[i])); }while(!q.isEmpty()){ Pair p = q.remove(); for ( int d = 0;(d < 4);d++) { int nx = (p.x + dx[d]),ny = (p.y + dy[d]); if ( (valid(nx,ny) && (dist[nx][ny] == inf))) {dist[nx][ny] = (dist[p.x][p.y] + 1); q.add(new Pair(nx,ny)); } }}return dist;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(); n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); int[] xs = new int[k],ys = new int[k]; for ( int i = 0;(i < k);i++) {xs[i] = (sc.nextInt() - 1); ys[i] = (sc.nextInt() - 1); } int[][] dist = bfs(xs,ys);  int x = 0,y = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (dist[i][j] > dist[x][y])) {x = i; y = j; } x++; y++; PrintWriter out = new PrintWriter("output.txt"); out.println(((x + " ") + y)); out.flush(); out.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner()throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt")); } 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());} } }
4	public class D{ static private void run()throws IOException { int n = in.nextInt();  int m = in.nextInt();  int p = in.nextInt();  int[] dx = {1,-1,0,0};  int[] dy = {0,0,1,-1};  int[][][] map = new int[n][m][4];  ArrayList<Edge> edges = new ArrayList<>(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int len = in.nextInt(); edges.add(new Edge(new Point[]{new Point(i,j),new Point(i,(j + 1))},len)); map[i][j][2] = map[i][(j + 1)][3] = len; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { int len = in.nextInt(); edges.add(new Edge(new Point[]{new Point(i,j),new Point((i + 1),j)},len)); map[i][j][0] = map[(i + 1)][j][1] = len; }}if ( ((p % 2) != 0)) { int[] ans = new int[m]; for ( int i = 0;(i < m);i++) {ans[i] = -1; }for ( int i = 0;(i < n);i++) {print_array(ans); }return ;} edges.sort(Comparator.comparingInt((o)->o.len)); int[][][] dp = new int[2][n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int min = Integer.MAX_VALUE; for ( int k = 0;(k < 4);k++) {if ( (map[i][j][k] == 0)) continue; min = Math.min(min,map[i][j][k]); }dp[1][i][j] = (min * 2); }}for ( int k = 2;(k <= (p / 2));k++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[(k & 1)][i][j] = Integer.MAX_VALUE; for ( int d = 0;(d < 4);d++) { int nx = (i + dx[d]);  int ny = (j + dy[d]); if ( ((((nx < 0) || (nx >= n)) || (ny < 0)) || (ny >= m))) continue; dp[(k & 1)][i][j] = Math.min((dp[((k - 1) & 1)][nx][ny] + (map[i][j][d] * 2)),dp[(k & 1)][i][j]); }}}}for ( int i = 0;(i < n);i++) {print_array(dp[((p / 2) & 1)][i]); }} static class Edge{ Point[] points ; int len ; public Edge( Point[] points, int len){ this.points = points; this.len = len; } } static class Point{ final int x ,y ; public Point( int x, int y){ this.x = x; this.y = y; } } public static void main( String[] args)throws IOException { in = new Reader(); out = new PrintWriter(new OutputStreamWriter(System.out)); run(); out.flush(); in.close(); out.close(); } static final long mod = 1000000007; static private Reader in ; static private PrintWriter out ; static private void print_array( int[] array){ for ( int now :array) {out.print(now); out.print(' '); }out.println(); } static private void print_array( long[] array){ for ( long now :array) {out.print(now); out.print(' '); }out.println(); } static class Reader{ static private final int BUFFER_SIZE = (1 << 16); private final DataInputStream din ; private final byte[] buffer ; private int bufferPointer ,bytesRead ; Reader(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } static private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} public int skip()throws IOException { int b ; while((((b = read()) != -1) && isSpaceChar(b))){;}return b;} public int nextInt()throws IOException { int ret = 0;  byte c = read(); while((c <= ' ')){c = read(); }final 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 { din.close(); } } }
1	public class Main{ static private StringTokenizer st ; static private BufferedReader br ; public static long MOD = 1000000007; public static long tenFive = 100000; public static int INF = 100000; public static void print( Object x){ System.out.println((x + "")); } public static String join( Collection<?> x, String space){ if ( (x.size() == 0)) return ""; StringBuilder sb = new StringBuilder();  boolean first = true; for ( Object elt :x) {if ( first) first = false; else sb.append(space); sb.append(elt); }return sb.toString();} public static String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = br.readLine(); st = new StringTokenizer(line.trim()); }return st.nextToken();} public static int nextInt()throws IOException { return Integer.parseInt(nextToken());} public static List<Integer> nextInts( int N)throws IOException { List<Integer> ret = new ArrayList<Integer>(); for ( int i = 0;(i < N);i++) {ret.add(nextInt()); }return ret;} public static void solve( int a, int b, List<Integer> orig){ boolean swap = false; if ( (a > b)) {swap = true; int tmp = a; a = b; b = tmp; } List<Integer> nums = new ArrayList<Integer>(orig); Collections.sort(nums); Collections.reverse(nums); Set<Integer> all = new HashSet<Integer>(nums);  Set<Integer> done = new HashSet<Integer>();  Set<Integer> inB = new HashSet<Integer>(); for ( int x :nums) {if ( done.contains(x)) continue; if ( (all.contains((a - x)) && !done.contains((a - x)))) {done.add(x); done.add((a - x)); } else if ( (all.contains((b - x)) && !done.contains((b - x)))) {done.add(x); done.add((b - x)); inB.add(x); inB.add((b - x)); } else {print("NO"); return ;}}print("YES"); List<Integer> out = new ArrayList<Integer>(); for ( int x :orig) {if ( (inB.contains(x) ^ swap)) out.add(1); else out.add(0); }print(join(out," ")); } public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); int n = nextInt();  int a = nextInt();  int b = nextInt();  List<Integer> nums = nextInts(n); solve(a,b,nums); } }
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; }}} }
4	public class N718{ static PrintWriter out ; static Scanner sc ; static ArrayList<int[]> q ,w ,x ; static ArrayList<Integer> adj[] ; static HashSet<Integer> primesH ; static boolean prime[] ; static HashSet<Long> tmp ; static int[][][] dist ; static boolean[] v ; static int[] a ,b ,c ,d ; static Boolean[][] dp ; static char[][] mp ; static int A ,B ,n ,m ,h ,ans ,sum ; static long oo = ((long)1e9 + 7); public static void main( String[] args)throws IOException { sc = new Scanner(System.in); out = new PrintWriter(System.out); D(); out.close(); } static private Boolean dp( int i, int j){ if ( (j > (sum / 2))) return false; if ( (i == x.size())) {return ((sum / 2) == j);} if ( (dp[i][j] != null)) return dp[i][j]; return dp[i][j] = (dp((i + 1),(j + x.get(i)[0])) || dp((i + 1),j));} static void D()throws IOException { int t = 1; while((t-- > 0)){ int n = ni(),m = ni(),k = ni();  int[][] ans = new int[n][m]; dist = new int[n][m][4]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j > m);j++) Arrays.fill(dist[i][j],Integer.MAX_VALUE); int x ; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {dist[i][j][2] = x = ni(); dist[i][(j + 1)][3] = x; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {dist[i][j][1] = x = ni(); dist[(i + 1)][j][0] = x; }} int[][] nans = new int[n][m]; if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) Arrays.fill(ans[i],-1); } else {for ( int ii = 0;(ii < (k / 2));ii++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {nans[i][j] = Integer.MAX_VALUE; if ( (i > 0)) nans[i][j] = Math.min(nans[i][j],(ans[(i - 1)][j] + dist[(i - 1)][j][1])); if ( (i < (n - 1))) nans[i][j] = Math.min(nans[i][j],(ans[(i + 1)][j] + dist[(i + 1)][j][0])); if ( (j > 0)) nans[i][j] = Math.min(nans[i][j],(ans[i][(j - 1)] + dist[i][(j - 1)][2])); if ( (j < (m - 1))) nans[i][j] = Math.min(nans[i][j],(ans[i][(j + 1)] + dist[i][(j + 1)][3])); }} int[][] tmp = ans; ans = nans; nans = tmp; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (ans[i][j] != -1)) ans[i][j] *= 2; out.print((ans[i][j] + " ")); }ol(""); }}} static private boolean valid( int nx, int ny){ return ((((nx >= 0) && (nx < dist.length)) && (ny >= 0)) && (ny < dist[0].length));} static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} static int ni()throws IOException { return sc.nextInt();} static long nl()throws IOException { return sc.nextLong();} static int[] nai( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); return a;} static int[][] nmi( int n, int m)throws IOException { int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[i][j] = sc.nextInt(); }}return a;} static void ol( String x){ out.println(x); } static void ol( int x){ out.println(x); } 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 double nextDouble()throws IOException { return Double.parseDouble(next());} public long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
5	public class A{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int t = scan.nextInt();  List<Double> coords = new ArrayList<Double>(); while((n-- > 0)){ double x = scan.nextDouble();  double a = (scan.nextDouble() / 2); coords.add((x - a)); coords.add((x + a)); }Collections.sort(coords); int count = 2;  ChoiceFormat f = new ChoiceFormat("-1#0|0#1|0<2"); for ( int i = 1;(i < (coords.size() - 2));i += 2) {count += new Integer(f.format(((coords.get((i + 1)) - coords.get(i)) - t))); }System.out.println(count); } }
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); } }
3	public class TaskC{ public static void main( String[] args){ new TaskC().run(); } void solve(){ int n = in.nextInt();  String s[] = new String[n]; for ( int i = 0;(i < n);i++) s[i] = in.next(); if ( (s[(n - 1)].compareTo("f") == 0)) {out.println(0); return ;} int dp[] = new int[(n + 2)];  int mod = (((1000 * 1000) * 1000) + 7); dp[0] = 1; for ( int i = (n - 1);(i >= 0);i--) {if ( (s[i].compareTo("s") == 0)) { int ss = 0; for ( int j = 0;(j <= n);j++) {ss += dp[j]; if ( (ss >= mod)) ss -= mod; dp[j] = ss; }} else {for ( int j = 0;(j < n);j++) {dp[j] = dp[(j + 1)]; }dp[n] = 0; }}out.println(dp[0]); } FastScanner in ; PrintWriter out ; void run(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); int tests = 1; while((tests > 0)){solve(); tests--; }out.close(); } class FastScanner{ StringTokenizer st ; BufferedReader bf ; public FastScanner( InputStream is){ bf = new BufferedReader(new InputStreamReader(is)); } public FastScanner( File f){ try{bf = new BufferedReader(new FileReader(f)); }catch (IOException ex){ ex.printStackTrace(); } } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(bf.readLine()); }catch (Exception ex){ ex.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
0	public class a{ public static long mod = ((long)Math.pow(10,9) + 7); public static long gcd( long a, long b){ if ( (b == 0)) return a; else return gcd(b,(a % b));} public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringBuilder qq = new StringBuilder();  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  String y[] = in.readLine().split(" ");  long n = Long.parseLong(y[0]);  long m = Long.parseLong(y[1]); if ( ((m - n) < 2)) {System.out.println(-1); } else if ( ((m - n) == 2)) {if ( (gcd(n,m) != 1)) System.out.println(((((n + " ") + (n + 1)) + " ") + (n + 2))); else System.out.println(-1); } else {if ( ((n % 2) == 0)) System.out.println(((((n + " ") + (n + 1)) + " ") + (n + 2))); else System.out.println((((((n + 1) + " ") + (n + 2)) + " ") + (n + 3))); }out.close(); } }
5	public class A{ String line ; StringTokenizer inputParser ; BufferedReader is ; FileInputStream fstream ; DataInputStream in ; String FInput = ""; void openInput( String file){ if ( (file == null)) is = new BufferedReader(new InputStreamReader(System.in)); else {try{fstream = new FileInputStream(file); in = new DataInputStream(fstream); is = new BufferedReader(new InputStreamReader(in)); }catch (Exception e){ System.err.println(e); } }} void readNextLine(){ try{line = is.readLine(); inputParser = new StringTokenizer(line," "); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } catch (NullPointerException e){ line = null; } } int NextInt(){ String n = inputParser.nextToken();  int val = Integer.parseInt(n); return val;} void closeInput(){ try{is.close(); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } public static void main( String[] argv){ String filePath = null; if ( (argv.length > 0)) filePath = argv[0]; new A(filePath); } public A( String inputFile){ openInput(inputFile); readNextLine(); int n = NextInt();  int ret = 0;  int[] p = new int[n]; readNextLine(); int sum = 0; for ( int i = 0;(i < n);i++) { int a = NextInt(); p[i] = a; sum += a; }Arrays.sort(p); int my = 0; for ( int i = (n - 1);(i >= 0);i--) {my += p[i]; ret++; if ( ((my * 2) > sum)) break; }System.out.println(ret); closeInput(); } }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}candidate = new int[n]; mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; int[] candidate ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {if ( (Long.bitCount(choosed) < Long.bitCount(mds))) mds = choosed; return ;} long s = covered; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); s |= ((1L << i) | g[i]); }if ( (s != ((1L << n) - 1))) return ; int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) k = i; }if ( (k == -1)) return ; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } 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 P111C().run(); } }
1	public class TreasureHunt{ public static String Solve(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); sc.nextLine(); String kuro = sc.nextLine(),shiro = sc.nextLine(),katie = sc.nextLine(); sc.close(); String[] output = {"Kuro","Shiro","Katie","Draw"}; if ( (n >= kuro.length())) return output[3]; int[] maxArr = new int[3];  int[][] freq = new int[3][58]; for ( int i = 0;(i < kuro.length());i++) {maxArr[0] = ((++freq[0][(kuro.charAt(i) - 65)] > maxArr[0])?freq[0][(kuro.charAt(i) - 65)]:maxArr[0]); maxArr[1] = ((++freq[1][(shiro.charAt(i) - 65)] > maxArr[1])?freq[1][(shiro.charAt(i) - 65)]:maxArr[1]); maxArr[2] = ((++freq[2][(katie.charAt(i) - 65)] > maxArr[2])?freq[2][(katie.charAt(i) - 65)]:maxArr[2]); } int winner = 0,max = 0; for ( int i = 0;(i < 3);i++) {if ( ((kuro.length() - maxArr[i]) >= n)) maxArr[i] += n; else maxArr[i] = ((n == 1)?(kuro.length() - 1):kuro.length()); if ( (max < maxArr[i])) {winner = i; max = maxArr[i]; } else if ( (max == maxArr[i])) winner = 3; }return output[winner];} public static void main( String[] args){ System.out.println(Solve()); } }
1	public class Main implements Runnable{ StreamTokenizer ST ; PrintWriter out ; BufferedReader br ; int inf = 1000000000; public static void main( String[] args)throws IOException { new Thread(new Main()).start(); } String code( int x){ x--; StringBuilder sb = new StringBuilder(); while((x > 0)){ int c = (x % 26); if ( (x < 10)) sb.append((char)(c + '0')); else sb.append((char)(('A' + c) - 10)); x /= 26; }if ( (sb.length() == 0)) sb.append("0"); return sb.toString();} StringBuilder sb = new StringBuilder(); public void solve()throws IOException { int tt = Integer.parseInt(br.readLine());  HashMap<String,Integer> map = new HashMap<String,Integer>(); for ( int i = 1;(i <= 10);i++) map.put(code(i),i); while((tt-- > 0)){ String s = br.readLine(); if ( s.matches("^[A-Z]+[0-9]+$")) { int t = 0; while(Character.isLetter(s.charAt(t)))t++; int r = Integer.parseInt(s.substring(t)); s = s.substring(0,t); int res = 0; for ( int c :s.toCharArray()) {res *= 26; res += ((c - 'A') + 1); }out.println(((("R" + r) + "C") + res)); } else { int t = s.indexOf('C');  int c = Integer.parseInt(s.substring(1,t));  int r = Integer.parseInt(s.substring((t + 1))); sb.setLength(0); while((r > 0)){r--; int ch = (r % 26); sb.append((char)('A' + ch)); r /= 26; }sb = sb.reverse(); out.println(((sb + "") + c)); }}} }
0	public class A{ BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter out ; public void solve()throws IOException { long A = nextLong();  long B = nextLong();  long ans = 0; while((A > 0)){if ( (A >= B)) {ans += (A / B); A %= B; if ( (A == 0)) break; } else { long tmp = A; A = B; B = tmp; }}out.println(ans); } public static void main( String[] args){ new A().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); } } long nextLong()throws IOException { return Long.parseLong(nextToken());} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
3	public class Main{ static private void solve(){ int n = ni();  double r = ni();  double[][] p = new double[n][2];  double EPS = 0.0000000000001; for ( int i = 0;(i < n);i++) { double x = ni();  double y = r; for ( int j = 0;(j < i);j++) { double dx = Math.abs((p[j][0] - x)); if ( (dx <= ((r * 2) + EPS))) { double dy = Math.sqrt((((4.0 * r) * r) - (dx * dx))); y = Math.max(y,(p[j][1] + dy)); } }out.printf("%.12f ",y); p[i][0] = x; p[i][1] = y; }out.println(); } public static void main( String[] args){ new Thread(null,new Runnable(){},"",64000000).start(); } static private java.io.InputStream is = System.in; static private java.io.PrintWriter out = new java.io.PrintWriter(System.out); static private java.util.StringTokenizer tokenizer = null; static private java.io.BufferedReader reader ; public static String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new java.util.StringTokenizer(reader.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} static private long nl(){ return Long.parseLong(next());} static private int ni(){ return Integer.parseInt(next());} static private void tr( Object... o){ if ( (is != System.in)) System.out.println(java.util.Arrays.deepToString(o)); } }
1	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] nums = new int[n];  int kisu = 0;  int gusu = 0; for ( int i = 0;(i < n);i++) {nums[i] = sc.nextInt(); if ( ((nums[i] % 2) == 0)) gusu++; if ( ((nums[i] % 2) == 1)) kisu++; } int ans = -1; if ( (gusu == 1)) {for ( int i = 0;(i < n);i++) {if ( ((nums[i] % 2) == 0)) {ans = (i + 1); break;} }} else {for ( int i = 0;(i < n);i++) {if ( ((nums[i] % 2) == 1)) {ans = (i + 1); break;} }}System.out.println(ans); } }
0	public class bhaa{ InputStream is ; PrintWriter o ; void solve(){ int n = ni();  int k = ni();  int rr = (2 * n);  int gr = (5 * n);  int br = (8 * n); o.println((long)((Math.ceil(((rr * 1.0) / k)) + Math.ceil(((gr * 1.0) / k))) + Math.ceil(((br * 1.0) / k)))); } public static void main( String[] args){ new bhaa().run(); } void run(){ is = System.in; o = new PrintWriter(System.out); solve(); o.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);} long nl(){ long n = 0L;  int b = readByte();  boolean minus = false; while(((b != -1) && (((b >= '0') && (b <= '9')) || (b == '-')))){b = readByte(); }if ( (b == '-')) {minus = true; b = readByte(); } while(((b >= '0') && (b <= '9'))){n = ((n * 10) + (b - '0')); b = readByte(); }return (minus?-n:n);} 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));} }
5	public class ProblemA{ public static class Team{ int solved ; int penalty ; Team( int s, int p){ solved = s; penalty = p; } } public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  String[] data = s.readLine().split(" ");  int n = Integer.valueOf(data[0]);  int k = Integer.valueOf(data[1]);  Team[] t = new Team[n]; for ( int i = 0;(i < n);i++) { String[] line = s.readLine().split(" "); t[i] = new Team(Integer.valueOf(line[0]),Integer.valueOf(line[1])); }Arrays.sort(t,new Comparator<Team>(){}); int idx = (k - 1);  int ksol = t[idx].solved;  int kpen = t[idx].penalty;  int count = 0; for ( int i = 0;(i < n);i++) {if ( ((t[i].solved == ksol) && (t[i].penalty == kpen))) {count++; } }System.out.println(count); } }
6	public class DarkAssembly extends Thread{ public DarkAssembly(){ this.input = new BufferedReader(new InputStreamReader(System.in)); this.output = new PrintWriter(System.out); this.setPriority(Thread.MAX_PRIORITY); } class Senator{ int loyalty ; int level ; public Senator( int level, int loyalty){ this.level = level; this.loyalty = loyalty; } } static private double doIt( Senator[] senators, int A){ double probability = .0; for ( int mask = 0;(mask < (1 << senators.length));++mask) { int sum = A;  double current = 1.0; for ( int i = 0;(i < senators.length);++i) {if ( ((mask & (1 << i)) != 0)) {current *= (.01 * senators[i].loyalty); } else {current *= (.01 * (100 - senators[i].loyalty)); sum += senators[i].level; }}if ( (getOnes(mask) > (senators.length / 2))) {probability += current; } else {probability += ((current * (double)A) / sum); }}return probability;} static private double go( Senator[] senators, int candies, int A, int current){ if ( (current == senators.length)) {return doIt(senators,A);} else { double result = go(senators,candies,A,(current + 1)); if ( ((candies > 0) && (senators[current].loyalty < 100))) {senators[current].loyalty += 10; result = Math.max(result,go(senators,(candies - 1),A,current)); senators[current].loyalty -= 10; } return result;}} static int getOnes( int mask){ int result = 0; while((mask != 0)){mask &= (mask - 1); ++result; }return result;} public static void main( String[] args){ new DarkAssembly().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 BufferedReader input ; private PrintWriter output ; private StringTokenizer tokens = null; }
6	public class Main{ static int t ,m ,mod = 998244353,maxn = 1000000,q ,n ,k ; static int INF = (int)1e8; void solve( PrintWriter out, Reader in)throws IOException { n = in.nextInt(); m = in.nextInt(); String str = in.next();  int[][] pre = new int[(1 << m)][m];  int child = 0,head ,child2 = 0; for ( int i = 0;(i < n);i++) {if ( (i != 0)) child = (1 << (str.charAt((i - 1)) - 'a')); if ( (i != (n - 1))) child2 = (1 << (str.charAt((i + 1)) - 'a')); head = (str.charAt(i) - 'a'); if ( (i != 0)) pre[child][head]++; if ( (i != (n - 1))) pre[child2][head]++; } int rmv = 0; for ( int i = 0;(i < m);i++) {head = i; for ( int j = 1;(j < (1 << m));j++) {if ( (pre[j][i] != 0)) continue; rmv = (j - (j & -j)); pre[j][head] = (pre[rmv][head] + pre[(j ^ rmv)][head]); }} int[] dp = new int[(1 << m)]; for ( int i = 1;(i < (1 << m));i++) dp[i] = INF; int bit = 0,full = ((1 << m) - 1),cnt = 0; for ( int j = 1;(j < (1 << m));j++) {for ( int i = 0;(i < m);i++) {if ( (((1 << i) & j) != 0)) {bit = (1 << i); cnt = cnt(j); dp[j] = Math.min(dp[j],((dp[(j ^ bit)] + (pre[(j ^ bit)][i] * cnt)) - (pre[(j ^ full)][i] * cnt))); } }}out.println(dp[full]); } static int cnt( int x){ int res = 0; while((x > 0)){res += (x & 1); x >>= 1; }return res;} 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));} } public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out);  Reader in = new Reader();  Main solver = new Main(); solver.solve(out,in); out.flush(); out.close(); } }
4	public class OnTheBenchAlt{ public static void main( String[] args){ setupCombo(301); FastScanner sc = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int N = sc.nextInt();  long[] a = new long[N];  HashMap<Long,Integer> clusters = new HashMap<>(); for ( int i = 0;(i < N);i++) {a[i] = removeSquares(sc.nextLong()); clusters.merge(a[i],1,Integer::sum); } int G = clusters.size();  int[] groups = new int[(G + 1)];  int ptr = 1; for ( int amt :clusters.values()) {groups[ptr++] = amt; } long[][] dp = new long[(G + 1)][(N + 1)]; dp[0][0] = 1; int total = 0; for ( int prefix = 1;(prefix <= G);prefix++) { int amt = groups[prefix]; for ( int prevBad = 0;(prevBad <= max(0,(total - 1)));prevBad++) {for ( int fixed = 0;(fixed <= min(prevBad,amt));fixed++) {for ( int slots = max(1,fixed);(slots <= min(amt,(total + 1)));slots++) { int introduced = (amt - slots);  long ways = mult(choose[prevBad][fixed],choose[((total + 1) - prevBad)][(slots - fixed)],choose[(amt - 1)][(slots - 1)],fact[amt],dp[(prefix - 1)][prevBad]);  int currBad = ((prevBad + introduced) - fixed); dp[prefix][currBad] = ((dp[prefix][currBad] + ways) % mod); }}}total += amt; }out.println(dp[G][0]); out.close(); } static long mod = ((long)1e9 + 7); static long[][] choose ; static long[] fact ; static long removeSquares( long x){ long curr = x; for ( long v = 2;(((v * v) <= x) && (curr > 1));v++) { int cnt = 0; while(((curr % v) == 0)){curr /= v; cnt ^= 1; }if ( (cnt == 1)) curr *= v; }return curr;} static long mult( long... multiplicands){ long ans = 1; for ( long v :multiplicands) {ans = ((ans * v) % mod); }return ans;} static void setupCombo( int MAX){ choose = new long[(MAX + 1)][(MAX + 1)]; fact = new long[(MAX + 1)]; choose[0][0] = 1; fact[0] = 1; for ( int i = 1;(i <= MAX);i++) {fact[i] = (((long)i * fact[(i - 1)]) % mod); choose[i][0] = 1; for ( int j = 1;(j < i);j++) {choose[i][j] = ((choose[(i - 1)][(j - 1)] + choose[(i - 1)][j]) % mod); }choose[i][i] = 1; }} 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);} public double nextDouble(){ double cur = nextLong(); return ((c != '.')?cur:(cur + (nextLong() / cnt)));} } }
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);  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();  char[] poks = in.next().toCharArray();  boolean[] was = new boolean[52]; for ( int i = 0;(i < n);i++) {if ( Character.isLowerCase(poks[i])) {was[(poks[i] - 'a')] = true; } else {was[((poks[i] - 'A') + 26)] = true; }} int count = 0; for ( int i = 0;(i < 52);i++) {count += (was[i]?1:0); } int[] vis = new int[52];  int pre = 0;  int chr = 0;  int ans = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int pos = (poks[i] - 'a'); if ( Character.isUpperCase(poks[i])) {pos = ((poks[i] - 'A') + 26); } if ( (vis[pos] == 0)) {chr++; } vis[pos]++; while((chr == count)){ans = Math.min(ans,((i - pre) + 1)); pos = (poks[pre] - 'a'); if ( Character.isUpperCase(poks[pre])) {pos = ((poks[pre] - 'A') + 26); } vis[pos]--; if ( (vis[pos] == 0)) chr--; pre++; }}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; 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 bender{ static long[] dx = new long[]{0,1,0,-1}; static long[] dy = new long[]{-1,0,1,0}; static long n ,x ,y ,c ; public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer dxdync = new StringTokenizer(in.readLine()); n = Long.parseLong(dxdync.nextToken()); x = Long.parseLong(dxdync.nextToken()); y = Long.parseLong(dxdync.nextToken()); c = Long.parseLong(dxdync.nextToken()); long a = 0;  long b = c; while((a < b)){ long m = ((a + b) / 2);  long[] dxn = new long[4];  long[] dyn = new long[4]; for ( int d = 0;(d < 4);d++) {dxn[d] = (x + (dx[d] * m)); dyn[d] = (y + (dy[d] * m)); } long ret = (((m + 1) * (m + 1)) + (m * m)); ret -= h((1 - dyn[0])); ret -= h((dyn[2] - n)); ret -= h((dxn[1] - n)); ret -= h((1 - dxn[3])); ret += q(((1 - dyn[0]) - ((n - x) + 1))); ret += q(((1 - dyn[0]) - x)); ret += q(((dyn[2] - n) - ((n - x) + 1))); ret += q(((dyn[2] - n) - x)); if ( (ret < c)) a = (m + 1); else b = m; }System.out.println(a); } public static long h( long x){ if ( (x <= 0)) return 0; return ((2 * q(x)) - x);} static private long q( long x){ if ( (x <= 0)) return 0; return ((x * (x + 1)) / 2);} }
1	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));  int n = Integer.parseInt(bf.readLine());  StringTokenizer st = new StringTokenizer(bf.readLine());  Integer[] a = new Integer[n]; for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(st.nextToken()); Arrays.sort(a); int[] b = new int[n]; for ( int i = 0;(i < n);i++) b[i] = a[i].intValue(); boolean diff = false;  boolean diff2 = false;  Set<Integer> vals = new HashSet<Integer>(); vals.add(b[0]); int valval = 0; for ( int i = 1;(i < n);i++) {vals.add(b[i]); if ( (b[i] == b[(i - 1)])) {if ( !diff) {diff = true; valval = b[i]; } else diff2 = true; } } long sum = 0; for ( int i :b) sum += i; sum -= (((1L * n) * (n - 1)) / 2); if ( (diff && !diff2)) {if ( (!vals.contains((valval - 1)) && (valval > 0))) {if ( ((sum % 2) == 0)) out.println("cslnb"); else out.println("sjfnb"); } else out.println("cslnb"); } else if ( diff2) out.println("cslnb"); else if ( ((sum % 2) == 0)) out.println("cslnb"); else out.println("sjfnb"); out.close(); System.exit(0); } }
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 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)); } }
0	public class ex5{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  String S[] = new String[3];  int m = 0,s = 0,p = 0;  int temp = 0; for ( int i = 0;(i < S.length);i++) {S[i] = scan.next(); if ( (S[i].indexOf('m') != -1)) m++; if ( (S[i].indexOf('s') != -1)) s++; if ( (S[i].indexOf('p') != -1)) p++; } int n1 = Integer.parseInt(S[0].substring(0,1));  int n2 = Integer.parseInt(S[1].substring(0,1));  int n3 = Integer.parseInt(S[2].substring(0,1));  int d3 = Math.abs((n1 - n2));  int d4 = Math.abs((n1 - n3));  int d5 = Math.abs((n2 - n3)); if ( (((m == 3) || (s == 3)) || (p == 3))) {if ( (((((d3 == 1) & (d5 == 1)) & (d4 == 2)) || (((d3 == 1) & (d4 == 1)) & (d5 == 2))) || (((d5 == 1) & (d4 == 1)) & (d3 == 2)))) System.out.println(0); else if ( ((d3 == 0) & (d4 == 0))) System.out.println(0); else if ( ((d3 < d5) & (d3 < d4))) {if ( (((d3 == 1) || (d3 == 2)) || (d3 == 0))) System.out.println(1); else System.out.println(2); } else if ( ((d5 < d4) & (d5 < d3))) {if ( (((d5 == 1) || (d5 == 2)) || (d5 == 0))) System.out.println(1); else System.out.println(2); } else if ( ((d4 < d5) & (d4 < d3))) {if ( (((d4 == 1) || (d4 == 2)) || (d4 == 0))) System.out.println(1); else System.out.println(2); } else if ( (((((((d3 == 2) & (d5 == 2)) || ((d4 == 2) & (d5 == 2))) || ((d3 == 2) & (d4 == 2))) || ((d3 == 1) & (d5 == 1))) || ((d4 == 1) & (d5 == 1))) || ((d3 == 2) & (d4 == 1)))) System.out.println(1); else System.out.println(2); } if ( (((m == 2) || (s == 2)) || (p == 2))) { char c1 = S[0].charAt(1);  char c2 = S[1].charAt(1);  char c3 = S[2].charAt(1); if ( (c1 == c2)) {if ( (n1 == n2)) System.out.println(1); else if ( ((d3 == 1) || (d3 == 2))) System.out.println(1); else System.out.println(2); } if ( (c1 == c3)) {if ( (n1 == n3)) System.out.println(1); else if ( ((d4 == 1) || (d4 == 2))) System.out.println(1); else System.out.println(2); } if ( (c2 == c3)) {if ( (n2 == n3)) System.out.println(1); else if ( ((d5 == 1) || (d5 == 2))) System.out.println(1); else System.out.println(2); } } if ( (((m == 1) & (s == 1)) & (p == 1))) System.out.println(2); } }
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 l ,r ,sum = 0;  int[] a = new int[(n + 5)]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( (a[i] > a[j])) sum++;  int q = in.nextInt(); while((q-- > 0)){l = in.nextInt(); r = in.nextInt(); sum += (((r - l) + 1) / 2); if ( ((sum % 2) == 1)) out.println("odd"); else out.println("even"); }} } 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 A{ public static void main( String[] args){ FastScanner scn = new FastScanner();  int n = scn.nextInt();  int s = scn.nextInt(); if ( (s <= n)) {System.out.println(1); } else if ( (s > n)) {if ( ((s % n) == 0)) {System.out.println((s / n)); } else {System.out.println(((s / n) + 1)); }} } public 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());} } }
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{ final int INF = 1000000000; final int MAXN = 100100; Scanner input = new Scanner(System.in); BufferedReader inp = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws IOException { new Main().run(); } double a ,v ; double l ,d ,w ; void run()throws IOException { a = input.nextDouble(); v = input.nextDouble(); l = input.nextDouble(); d = input.nextDouble(); w = input.nextDouble(); if ( (v <= w)) {out.println(timeTravel(l,0)); } else { double tw = (w / a);  double dw = dist(tw,0); if ( (dw >= d)) {out.println(timeTravel(l,0)); } else { double tSym = timeTravel(((d - dw) / 2),w); out.println(((tw + (2 * tSym)) + timeTravel((l - d),w))); }}out.close(); } double dist( double time, double speed){ return ((speed * time) + (((a * time) * time) / 2));} double timeTravel( double distance, double speed){ double delta = ((speed * speed) + ((2 * a) * distance));  double tAll = ((Math.sqrt(delta) - speed) / a);  double tMax = ((v - speed) / a); if ( (tMax >= tAll)) {return tAll;} else {return (tMax + ((distance - dist(tMax,speed)) / v));}} }
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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ private double[][][] dp ; private int n ; private int k ; private int[] loyalty ; private int[] level ; double[] P ; private int a ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); k = in.nextInt(); a = in.nextInt(); level = new int[n]; loyalty = new int[n]; for ( int i = 0;(i < n);++i) {level[i] = in.nextInt(); loyalty[i] = in.nextInt(); }P = new double[(1 << n)]; for ( int mask = 0;(mask < (1 << n));++mask) {if ( ((Integer.bitCount(mask) * 2) > n)) {P[mask] = 1.; } else { double sumB = 0; for ( int i = 0;(i < n);++i) {if ( !BitUtils.checkBit(mask,i)) {sumB += level[i]; } }P[mask] = ((double)a / (sumB + a)); }}dp = new double[(1 << n)][(n + 1)][(k + 1)]; ArrayUtils.fill(dp,-1); newLoyalty = new int[n]; brute(0,k); out.println(best); } int[] newLoyalty ; double best = 0; void brute( int id, int leftCandies){ if ( (id == n)) { double cur = calcCur(); if ( (best < cur)) {best = cur; } return ;} for ( int candies = 0;(candies <= leftCandies);++candies) {newLoyalty[id] = (loyalty[id] + (candies * 10)); if ( (newLoyalty[id] > 100)) {break;} brute((id + 1),(leftCandies - candies)); }} private double calcCur(){ double sum = 0; for ( int mask = 0;(mask < (1 << n));++mask) { double p = (getP(mask) * P[mask]); sum += p; }return sum;} private double getP( int mask){ double p = 1; for ( int i = 0;(i < n);++i) {if ( BitUtils.checkBit(mask,i)) {p *= ((newLoyalty[i] * 1.) / 100.); } else {p *= ((100. - newLoyalty[i]) / 100.); }}return p;} } 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());} }
6	public class Main{ public static void main( String[] args)throws Exception { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));  PrintWriter pw = new PrintWriter(System.out); in.nextToken(); int n = (int)in.nval;  double[][] a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {in.nextToken(); a[i][j] = in.nval; }} double[] dp = new double[(1 << n)]; dp[((1 << n) - 1)] = 1.0; for ( int mask = ((1 << n) - 2);(mask > 0);mask--) { int count = Integer.bitCount(mask);  double pPair = (2.0 / ((double)count * (count + 1)));  double ans = 0.0; for ( int j = 0;(j < n);j++) { int jj = (1 << j); if ( ((jj & mask) != 0)) continue; double p = dp[(mask | jj)];  double s = 0; for ( int k = 0;(k < n);k++) { int kk = (1 << k); if ( ((kk & mask) == 0)) continue; s += a[k][j]; }ans += ((s * pPair) * p); }dp[mask] = ans; }for ( int i = 0;(i < n);i++) {pw.print(dp[(1 << i)]); pw.print(' '); }pw.close(); } }
6	public class A{ static MyScanner sc ; static PrintWriter pw ; public static void main( String[] args)throws Throwable { sc = new MyScanner(); pw = new PrintWriter(System.out); n = sc.nextInt(); int m = sc.nextInt();  int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) a[i][j] = sc.nextInt(); val = new int[n][n]; for ( int i = 0;(i < n);i++) Arrays.fill(val[i],Integer.MAX_VALUE); for ( int i = 0;(i < n);i++) for ( int j = i;(j < n);j++) {for ( int k = 0;(k < m);k++) val[i][j] = val[j][i] = Math.min(val[i][j],Math.abs((a[i][k] - a[j][k]))); }val2 = new int[n][n]; for ( int i = 0;(i < n);i++) Arrays.fill(val2[i],Integer.MAX_VALUE); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < (m - 1));k++) val2[i][j] = Math.min(val2[i][j],Math.abs((a[i][k] - a[j][(k + 1)]))); }mem = new Long[n][n][(1 << n)]; long ans = 0; for ( int i = 0;(i < n);i++) {ans = Math.max(ans,dp(i,i,(1 << i))); }if ( (n == 1)) pw.println(val2[0][0]); else pw.println(ans); pw.flush(); pw.close(); } static int n ; static int[][] val ,val2 ; static Long[][][] mem ; static long dp( int st, int lst, int msk){ int bits = Integer.bitCount(msk); if ( (mem[st][lst][msk] != null)) return mem[st][lst][msk]; long ans = 0; for ( int i = 0;(i < n);i++) if ( ((msk & (1 << i)) == 0)) { int newMsk = (msk | (1 << i)); if ( (bits < (n - 1))) ans = Math.max(ans,Math.min(val[lst][i],dp(st,i,newMsk))); else ans = Math.max(ans,Math.min(val[lst][i],val2[i][st])); } return mem[st][lst][msk] = ans;} 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());} } }
5	public class A{ static InputStreamReader in = new InputStreamReader(System.in); static BufferedReader bf = new BufferedReader(in); static StreamTokenizer st = new StreamTokenizer(bf); static Scanner sc = new Scanner(System.in); static class Sort implements Comparable<Sort>{ int x ,a ; } public static void main( String[] args)throws IOException { int n = nextInt();  double t = nextInt();  Sort[] p = new Sort[n]; for ( int i = 0;(i < n);i++) {p[i] = new Sort(); p[i].x = nextInt(); p[i].a = nextInt(); } int ans = 2; Arrays.sort(p); for ( int i = 1;(i < p.length);i++) { double k = (((p[i].x - (p[i].a / 2.0)) - p[(i - 1)].x) - (p[(i - 1)].a / 2.0)); if ( (t == k)) ans++; else if ( (k > t)) ans += 2; }System.out.println(ans); } static private int nextInt()throws IOException { st.nextToken(); return (int)st.nval;} }
3	public class TaskA{ public static void main( String[] args){ FastReader in = new FastReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }Arrays.sort(a); int ans = 1; for ( int i = 1;(i < n);i++) { boolean bb = false; for ( int j = (i - 1);(j >= 0);j--) {if ( ((a[i] % a[j]) == 0)) {bb = true; break;} }if ( !bb) ans++; }out.println(ans); out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; FastReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } Integer nextInt(){ return Integer.parseInt(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;} } }
2	public class l{ static int mod = (int)(1e9 + 7); static StringBuilder sol ; static ArrayList<pair>[] adj ; static int n ; 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 lo = 0;  int hi = n;  int ans = 0; while((lo <= hi)){ int mid = ((lo + hi) >> 1);  long rem = (n - mid); rem *= (rem + 1); rem /= 2; rem -= mid; if ( (rem == k)) {ans = mid; break;} else if ( (rem > k)) {lo = (mid + 1); } else hi = (mid - 1); }pw.println(ans); pw.flush(); } static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( FileReader r){ br = new BufferedReader(r); } 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();} } }
4	public class Problem{ public static Pair solve( Forest f, List<Pair> queue){ Pair current = null,next = null;  int index = 0; while((queue.size() > 0)){current = queue.remove(0); index = f.desk[current.x][current.y]; if ( (current.x > 0)) {next = new Pair((current.x - 1),current.y); if ( (f.desk[next.x][next.y] == 0)) {f.desk[next.x][next.y] = (index + 1); queue.add(next); } } if ( (current.x < (f.N - 1))) {next = new Pair((current.x + 1),current.y); if ( (f.desk[next.x][next.y] == 0)) {f.desk[next.x][next.y] = (index + 1); queue.add(next); } } if ( (current.y > 0)) {next = new Pair(current.x,(current.y - 1)); if ( (f.desk[next.x][next.y] == 0)) {f.desk[next.x][next.y] = (index + 1); queue.add(next); } } if ( (current.y < (f.M - 1))) {next = new Pair(current.x,(current.y + 1)); if ( (f.desk[next.x][next.y] == 0)) {f.desk[next.x][next.y] = (index + 1); queue.add(next); } } }return f.findMax();} public static void main( String[] args){ String buffer = null;  StringTokenizer st = null;  Forest f = null;  List<Pair> pairs = new LinkedList<Pair>();  Integer N ,M ,K ,x ,y ; try{ BufferedReader in = new BufferedReader(new FileReader("input.txt"));  FileWriter out = new FileWriter("output.txt"); buffer = in.readLine(); st = new StringTokenizer(buffer); N = new Integer(st.nextToken()); M = new Integer(st.nextToken()); f = new Forest(N,M); buffer = in.readLine(); st = new StringTokenizer(buffer); K = new Integer(st.nextToken()); buffer = in.readLine(); st = new StringTokenizer(buffer); for ( int i = 0;(i < K);i++) {x = new Integer(st.nextToken()); y = new Integer(st.nextToken()); f.desk[(x - 1)][(y - 1)] = 1; pairs.add(new Pair((x - 1),(y - 1))); } Pair res = solve(f,pairs); out.write(res.toString()); out.flush(); }catch (Exception e){ } } } class Pair{ public Pair( int i, int j){ x = i; y = j; } public String toString(){ return (((x + 1) + " ") + (y + 1));} public int x ; public int y ; } class Forest{ public Forest( int n, int m){ N = n; M = m; desk = new int[N][M]; } public Pair findMax(){ Pair max = new Pair(0,0); for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {if ( (desk[i][j] > desk[max.x][max.y])) {max.x = i; max.y = j; } }}return max;} public int N ; public int M ; public int[][] desk ; }
6	public class e{ int n ; double f[] ; double a[][] ; public void run(){ Locale.setDefault(Locale.US); Scanner in = new Scanner(System.in); n = in.nextInt(); a = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) a[i][j] = in.nextDouble(); f = new double[(1 << n)]; for ( int i = 0;(i < (1 << n));i++) f[i] = -1; f[((1 << n) - 1)] = 1.0; for ( int i = 0;(i < n);i++) System.out.print((doIt((1 << i)) + " ")); } private double doIt( int mask){ if ( (f[mask] >= 0)) return f[mask]; f[mask] = 0; double k = getBits(mask); k *= ((k - 1) / 2.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)) f[mask] += ((doIt((mask | (1 << j))) * a[i][j]) / k);  return f[mask];} private int getBits( int x){ int cnt = 0; while((x > 0)){x &= (x - 1); cnt++; }return (cnt + 1);} public static void main( String[] args){ new e().run(); } }
2	public class B2{ Scanner in ; PrintWriter out ; String INPUT = ""; int qc = 0; int n ; int[] table ; int val( int x){ if ( (table[x] != Integer.MIN_VALUE)) return table[x]; if ( (qc > 60)) throw (new RuntimeException()); out.println(("? " + (x + 1))); out.flush(); table[x] = ni(); if ( (table[x] == table[((x + (table.length / 2)) % table.length)])) {if ( (x >= (n / 2))) x -= (n / 2); out.println(("! " + (x + 1))); out.flush(); throw (new IllegalStateException());} return table[x];} void solve(){ n = ni(); if ( ((n % 4) != 0)) {out.println("! -1"); out.flush(); return ;} table = new int[n]; Arrays.fill(table,Integer.MIN_VALUE); Random gen = new Random(1); try{outer:while(true){ int pu = gen.nextInt(n);  int pd = ((pu + (n / 2)) % n);  int pl = (((pu + gen.nextInt(((n / 2) - 1))) + 1) % n);  int pr = ((pl + (n / 2)) % n);  int vu = val(pu),vd = val(pd);  int vl = val(pl),vr = val(pr); if ( cross(vu,vl,vd,vr)) {} else if ( cross(vu,vr,vd,vl)) { int npu = pr,npl = pu;  int npd = pl,npr = pd; pu = npu; pl = npl; pd = npd; pr = npr; vu = val(pu); vl = val(pl); vd = val(pd); vr = val(pr); } else {continue outer;}while(true){ int pul = h(pu,pl,n);  int vul = val(pul);  int pdr = h(pd,pr,n);  int vdr = val(pdr); if ( cross(vul,vu,vdr,vd)) {pl = pul; vl = vul; pr = pdr; vr = vdr; } else {pu = pul; vu = vul; pd = pdr; vd = vdr; }}} }catch (IllegalStateException e){ } } int h( int a, int b, int n){ if ( (a > b)) {b += n; } int u = ((a + b) / 2); if ( (u >= n)) u -= n; return u;} boolean cross( int a, int b, int c, int d){ return (Integer.signum((c - a)) != Integer.signum((d - b)));} 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 B2().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)); } }
0	public class HelloWorld{ InputReader input ; PrintWriter output ; BufferedReader inp ; void run(){ output = new PrintWriter(new OutputStreamWriter(System.out)); input = new InputReader(System.in); inp = new BufferedReader(new InputStreamReader(System.in)); solve(); output.flush(); } public static void main( String[] args){ new HelloWorld().run(); } long stps ; long gcd( long a, long b){ if ( ((b == 0) || (a == 0))) {return 0;} return ((a / b) + gcd(b,(a % b)));} void solve(){ long a = input.readLong();  long b = input.readLong(); stps = gcd(a,b); output.println(stps); } 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 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();} public Long readLong(){ return Long.parseLong(readString());} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
5	public class A{ final int MOD = ((int)1e9 + 7); final double eps = 1e-12; final int INF = (int)1e9; public A(){ int N = sc.nextInt();  int K = sc.nextInt();  Long[] A = sc.nextLongs(); sort(A); TreeSet<Long> S = new TreeSet<Long>(); for ( long a :A) {if ( (((a % K) == 0) && S.contains((a / K)))) continue; S.add(a); } int res = S.size(); 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 A(); exit(); } static void start(){ t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t ; static long millis(){ return System.currentTimeMillis();} }
6	public class Main implements Runnable{ private void solution()throws IOException { int n = in.nextInt();  int m = in.nextInt();  boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = in.nextInt();  int y = in.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]; } }}out.println((res / 2)); } private class Scanner{ BufferedReader reader ; 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)); }
4	public class Solution{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter("output.txt");  String[] raw = in.readLine().split(" ");  int n = Integer.parseInt(raw[0]);  int m = Integer.parseInt(raw[1]);  int k = Integer.parseInt(in.readLine()); raw = in.readLine().split(" "); boolean[][] map = new boolean[n][m];  LinkedList<Point> queue = new LinkedList<>(); for ( int i = 0;(i < k);i++) { Point fireStarter = new Point((Integer.parseInt(raw[(i * 2)]) - 1),(Integer.parseInt(raw[((i * 2) + 1)]) - 1)); queue.addLast(fireStarter); } int treesLeft = (n * m); while(true){ Point firepoint = queue.removeFirst(); if ( map[firepoint.x][firepoint.y]) continue; treesLeft--; map[firepoint.x][firepoint.y] = true; if ( (treesLeft == 0)) {out.printf("%d %d",(firepoint.x + 1),(firepoint.y + 1)); out.flush(); return ;} if ( ((firepoint.x > 0) && !map[(firepoint.x - 1)][firepoint.y])) queue.add(new Point((firepoint.x - 1),firepoint.y)); if ( ((firepoint.y > 0) && !map[firepoint.x][(firepoint.y - 1)])) queue.add(new Point(firepoint.x,(firepoint.y - 1))); if ( ((firepoint.x < (n - 1)) && !map[(firepoint.x + 1)][firepoint.y])) queue.add(new Point((firepoint.x + 1),firepoint.y)); if ( ((firepoint.y < (m - 1)) && !map[firepoint.x][(firepoint.y + 1)])) queue.add(new Point(firepoint.x,(firepoint.y + 1))); }} static private class Point{ public int x ; public int y ; public Point( int x, int y){ this.x = x; this.y = y; } } }
3	public class Colours{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String line = br.readLine();  int n = Integer.parseInt(line); line = br.readLine(); String[] values = line.split(" ");  int[] arr = new int[n];  TreeSet<Integer> set = new TreeSet<>(); for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(values[i]); set.add(arr[i]); } int count = 0;  TreeSet<Integer> copy = new TreeSet<>(); copy.addAll(set); int prev = copy.size(); for ( Integer i :set) {if ( (copy.size() == 0)) {break;} Iterator<Integer> iterator = copy.iterator(); while(iterator.hasNext()){ Integer e = iterator.next(); if ( ((e % i) == 0)) {iterator.remove(); } }if ( (copy.size() != prev)) {count++; prev = copy.size(); } }System.out.println(count); } }
5	public class A{ public A()throws IOException{ int N = sc.nextInt();  int[] A = new int[N]; for ( int n = 0;(n < N);++n) A[n] = sc.nextInt(); solve(N,A); } public void solve( int N, int[] A){ Arrays.sort(A); int S1 = 0; for ( int n = 0;(n < N);++n) S1 += A[n]; int S2 = 0; for ( int n = (N - 1);(n >= 0);--n) {S2 += A[n]; if ( (S2 > (S1 - S2))) exit((N - n)); }} static MyScanner sc ; static long t ; static void print( Object o){ System.out.println(o); } static void exit( Object o){ print(o); System.exit(0); } static void run()throws IOException { sc = new MyScanner(); new A(); } public static void main( String[] args)throws IOException { run(); } static long millis(){ return System.currentTimeMillis();} static class MyScanner{ String next()throws IOException { newLine(); return line[index++];} int nextInt()throws IOException { return Integer.parseInt(next());} private final BufferedReader r ; MyScanner()throws IOException{ this(new BufferedReader(new InputStreamReader(System.in))); } MyScanner( BufferedReader r)throws IOException{ this.r = r; newLine(); } private String[] line ; private int index ; private void newLine()throws IOException { if ( ((line == null) || (index == line.length))) {line = r.readLine().split(" "); index = 0; } } } }
2	public class B{ static long sum( long from, long to){ final long d = (to - from); return (((d * (d + 1)) / 2) + ((d + 1) * from));} static long howMany( long n, long k){ if ( (n == 1)) {return 0;} if ( (n > (((k * (k - 1)) / 2) + 1))) {return -1;} long hi = (k - 1);  long lo = 1; while((lo < hi)){final long mi = (((lo + hi) + 1) >> 1); final long sum = sum(mi,(k - 1)); if ( (((n - 1) - sum) < mi)) {lo = mi; } else {hi = (mi - 1); }} long res = (k - lo); final long sum = sum(lo,(k - 1)); if ( (((n - 1) - sum) > 0)) {res++; } return res;} public static void main( String[] args){ try(Scanner s=new Scanner(System.in)){final long n = s.nextLong(); final long k = s.nextLong(); System.out.println(howMany(n,k)); }} }
4	public class FireAgain{ Point[] coordinate ; Queue<Point> q = new LinkedList<>(); boolean[][] vis ; PrintStream out ; int x ,y ; void bfs( Point s){ while(!q.isEmpty()){s = q.poll(); Point p = new Point(); p.x = (s.x - 1); p.y = s.y; if ( ((((p.x >= 1) && (p.x <= x)) && (p.y >= 1)) && (p.y <= y))) {if ( !vis[p.x][p.y]) {vis[p.x][p.y] = true; q.add(p); } } p = new Point(); p.x = (s.x + 1); p.y = s.y; if ( ((((p.x >= 1) && (p.x <= x)) && (p.y >= 1)) && (p.y <= y))) {if ( !vis[p.x][p.y]) {vis[p.x][p.y] = true; q.add(p); } } p = new Point(); p.x = s.x; p.y = (s.y - 1); if ( ((((p.x >= 1) && (p.x <= x)) && (p.y >= 1)) && (p.y <= y))) {if ( !vis[p.x][p.y]) {vis[p.x][p.y] = true; q.add(p); } } p = new Point(); p.x = s.x; p.y = (s.y + 1); if ( ((((p.x >= 1) && (p.x <= x)) && (p.y >= 1)) && (p.y <= y))) {if ( !vis[p.x][p.y]) {vis[p.x][p.y] = true; q.add(p); } } if ( (q.size() == 0)) out.print(((s.x + " ") + s.y)); }} public static void main( String[] args)throws FileNotFoundException { FireAgain F = new FireAgain();  Scanner in = new Scanner(new FileReader("input.txt")); F.out = new PrintStream(new File("output.txt")); F.x = in.nextInt(); F.y = in.nextInt(); int l = 0; F.vis = new boolean[(F.x + 1)][(F.y + 1)]; int k = in.nextInt(); for ( int i = 0;(i < k);i++) { Point P = new Point(in.nextInt(),in.nextInt()); F.vis[P.x][P.y] = true; F.q.add(P); }F.bfs(F.q.peek()); } }
6	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());  int n = Integer.parseInt(st.nextToken());  int m = Integer.parseInt(st.nextToken());  char[] arr = br.readLine().toCharArray();  int[][] count = new int[m][m]; for ( int i = 0;(i < (n - 1));i++) {count[(arr[i] - 'a')][(arr[(i + 1)] - 'a')]++; count[(arr[(i + 1)] - 'a')][(arr[i] - 'a')]++; } int[] memo = new int[(1 << m)]; Arrays.fill(memo,(int)1e9); memo[0] = 0; for ( int msk = 0;(msk < (1 << m));msk++) {for ( int c = 0;(c < m);c++) {if ( ((msk & (1 << c)) != 0)) continue; int temp = 0; for ( int i = 0;(i < m);i++) {if ( (i == c)) continue; if ( ((msk & (1 << i)) != 0)) {temp += count[c][i]; } else temp -= count[c][i]; }memo[(msk | (1 << c))] = Math.min(memo[(msk | (1 << c))],((temp * Integer.bitCount(msk)) + memo[msk])); }}System.out.println(memo[((1 << m) - 1)]); } }
2	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong();  long disc = (long)Math.sqrt((9 - (4 * ((-2 * n) - (2 * k)))));  long x = ((-3 + disc) / 2); System.out.println((n - x)); } }
3	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); }Arrays.sort(a); Set<Integer> div = new HashSet<>();  boolean[] d = new boolean[n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( d[j]) {continue;} if ( ((a[j] % a[i]) == 0)) {d[j] = true; div.add(a[i]); } }}System.out.println(div.size()); } }
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); }} }
0	public class A{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  long n = s.nextLong(); if ( (n >= 0)) System.out.println(n); else { String str = ("" + n); if ( (str.length() == 1)) System.out.println(("-" + str)); else { long one = Long.parseLong(str.substring(0,(str.length() - 1)));  long two = Long.parseLong((str.substring(0,(str.length() - 2)) + str.substring((str.length() - 1)))); if ( (one > two)) System.out.println((((two != 0)?"-":"") + two)); else System.out.println((((one != 0)?"-":"") + one)); }}} }
4	public class Main{ static int[] di = {-1,0,1,0}; static int[] dj = {0,1,0,-1}; public static void main( String[] args)throws IOException { Scanner sc = new Scanner("input.txt");  PrintWriter out = new PrintWriter("output.txt");  Queue<Pair> q = new LinkedList<Pair>();  int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt();  boolean[][] vis = new boolean[n][m]; while((k-- > 0))q.add(new Pair((sc.nextInt() - 1),(sc.nextInt() - 1))); int ansX = 1,ansY = 1; while(!q.isEmpty()){ Pair cur = q.poll(); if ( vis[cur.i][cur.j]) continue; ansX = cur.i; ansY = cur.j; vis[cur.i][cur.j] = true; for ( int i = 0;(i < di.length);i++) { int ni = (cur.i + di[i]),nj = (cur.j + dj[i]); if ( (((((ni >= 0) && (ni < n)) && (nj >= 0)) && (nj < m)) && !vis[ni][nj])) q.add(new Pair(ni,nj)); }}out.append(((++ansX + " ") + ++ansY)); out.flush(); } static class Pair{ int i ,j ; public Pair( int a, int b){ i = a; j = b; } } 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();} } }
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)); } }
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))); }} }
5	public class Main{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer = null; public static void main( String[] args)throws IOException { new Main().execute(); } int ni()throws IOException { return Integer.parseInt(ns());} String ns()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(br.readLine()); return tokenizer.nextToken();} int totalCases ,testNum ; int sum ; int n ; int arr[] ; void execute()throws IOException { totalCases = 1; for ( testNum = 1;(testNum <= totalCases);testNum++) {if ( !input()) break; solve(); }} void solve()throws IOException { Arrays.sort(arr); int count = 0;  int ans = 0; for ( int i = (n - 1);(i >= 0);i--) {count += arr[i]; if ( (count > (sum - count))) {ans = (n - i); break;} }System.out.println(ans); } boolean input()throws IOException { n = ni(); sum = 0; arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = ni(); sum = (sum + arr[i]); }return true;} }
3	public class Main{ public static void main( String[] args){ long MOD = 1000000007;  Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  long[][] dp = new long[n][5010];  char[] program = new char[n]; for ( int i = 0;(i < n);i++) {program[i] = sc.next().charAt(0); }dp[0][0] = 1; long[] acc = new long[5010]; acc[0] = 1; for ( int i = 1;(i < n);i++) {for ( int j = 0;(j < 5010);j++) {if ( (program[(i - 1)] == 'f')) {if ( ((j - 1) >= 0)) {dp[i][j] = dp[(i - 1)][(j - 1)]; } } else {dp[i][j] = acc[j]; }}acc[5009] = dp[i][5009]; for ( int j = 5008;(j >= 0);j--) {acc[j] = ((acc[(j + 1)] + dp[i][j]) % MOD); }}System.out.println(acc[0]); } }
0	public class A{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; void solve()throws IOException { String s = nextToken();  int res = Integer.parseInt(s);  String s1 = s.substring(0,(s.length() - 1)); res = Math.max(res,Integer.parseInt(s1)); String s2 = (s.substring(0,(s.length() - 2)) + s.charAt((s.length() - 1))); res = Math.max(res,Integer.parseInt(s2)); out.println(res); } A()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 A(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} }
0	public class A{ public static void main( String[] ar)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String s1[] = br.readLine().split(" ");  int n = Integer.parseInt(s1[0]);  int S = Integer.parseInt(s1[1]); if ( ((S % n) == 0)) System.out.println((S / n)); else System.out.println(((S / n) + 1)); } }
4	public class Main{ public static void main( String[] Args)throws Exception { Scanner sc = new Scanner(new FileReader("input.txt"));  int n ,m ,k ;  Integer lx ,ly ;  boolean d[][] ; n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); d = new boolean[(n + 1)][(m + 1)]; for ( int i = 0;(i <= n);++i) for ( int j = 0;(j <= m);++j) d[i][j] = false; Queue<pair> q = new LinkedList<pair>(); lx = ly = -1; for ( int i = 0;(i < k);++i) { int x ,y ; x = sc.nextInt(); y = sc.nextInt(); q.add(new pair(x,y)); lx = x; ly = y; d[x][y] = true; } int dx[] = {0,0,1,-1};  int dy[] = {-1,1,0,0}; while(!q.isEmpty()){ pair tp = q.remove();  int x = tp.x;  int y = tp.y; for ( int i = 0;(i < 4);++i) { int nx = (x + dx[i]);  int ny = (y + dy[i]); if ( (((((nx < 1) || (nx > n)) || (ny < 1)) || (ny > m)) || d[nx][ny])) continue; d[nx][ny] = true; q.add(new pair(nx,ny)); lx = nx; ly = ny; }} FileWriter fw = new FileWriter("output.txt"); fw.write(lx.toString()); fw.write(" "); fw.write(ly.toString()); ;fw.flush(); } } class pair{ public int x ,y ; public pair( int _x, int _y){ x = _x; y = _y; } }
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); } }
2	public class B{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextInt(),k = sc.nextInt();  long start = 1,end = n; while((start <= end)){ long mid = ((start + end) >> 1); if ( ((calc(mid) - (n - mid)) == k)) {System.out.println((n - mid)); return ;} else if ( ((calc(mid) - (n - mid)) > k)) {end = (mid - 1); } else {start = (mid + 1); }}} public static long calc( long n){ return (((n * n) + n) / 2);} }
2	public class CF1195B{ static private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); static private BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out)); static private StringTokenizer st ; public static void main( String[] args)throws Exception { st = new StringTokenizer(reader.readLine()); long n = Long.parseLong(st.nextToken());  long k = Long.parseLong(st.nextToken());  long put = ((-3 + (long)Math.sqrt((((long)9 + (8 * k)) + (8 * n)))) / 2);  long eat = (n - put); writer.write(Long.toString(eat)); writer.newLine(); writer.flush(); } }
2	public class Main{ class IOManager{ BufferedReader reader ; PrintWriter writer ; StringTokenizer tokenizer ; IOManager(){ reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(new BufferedOutputStream(System.out)); } IOManager( String file)throws FileNotFoundException{ reader = new BufferedReader(new FileReader(file)); writer = new PrintWriter(new BufferedOutputStream(System.out)); } String next()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){ String line = reader.readLine(); if ( (line == null)) throw (new IOException("No lines left.")); tokenizer = new StringTokenizer(line); }return tokenizer.nextToken();} public Long nextLong()throws IOException { return Long.parseLong(next());} public void writeLine( Object obj){ writer.println(obj.toString()); } public void close(){ writer.close(); } } IOManager ioManager ; Main(){ ioManager = new IOManager(); } Main( String file)throws FileNotFoundException{ ioManager = new IOManager(file); } long n ,s ; int m ,a[] ,sum[] ; long pow[] ; long f[][] ; void doi( long n){ m = 0; while((n > 0)){a[m++] = (int)(n % 10L); n /= 10L; }} int getsum( long n){ int res = 0; while((n > 0)){res += (int)(n % 10L); n /= 10L; }return res;} void solve()throws IOException { n = ioManager.nextLong(); s = ioManager.nextLong(); a = new int[100]; pow = new long[100]; pow[0] = 1; for ( int i = 1;(i < 100);++i) {pow[i] = (pow[(i - 1)] * 10L); }doi(n); sum = new int[(m + 1)]; sum[m] = 0; for ( int i = (m - 1);(i >= 0);--i) sum[i] = (sum[(i + 1)] + a[i]); long first = -1; for ( long i = (s + 1);(i <= n);++i) {if ( ((i - getsum(i)) >= s)) {first = i; break;} }if ( (first == -1)) {ioManager.writeLine(0); return ;} ioManager.writeLine(((n - first) + 1)); } void close(){ ioManager.close(); } public static void main( String[] args)throws IOException { Main solver ; if ( !"true".equals(System.getProperty("ONLINE_JUDGE"))) {solver = new Main("input.txt"); } else {solver = new Main(); }solver.solve(); solver.close(); } }
3	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] a = new int[n];  boolean[] used = new boolean[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); }Arrays.sort(a); int ans = 0; for ( int i = 0;(i < used.length);i++) {if ( !used[i]) {ans++; for ( int j = i;(j < used.length);j++) {if ( ((a[j] % a[i]) == 0)) {used[j] = true; } }} }System.out.print(ans); } }
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(); } }
4	public class D{ static private ArrayDeque<Integer>[][] edge ; static private long[][] dp[] ,w1 ,w2 ; static private int N ,M ,K ; static private void answer(){ StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) sb.append(dp[i][j][K]).append(" "); sb.append("\n"); }System.out.println(sb); } static private long solve( int i, int j, int pos){ if ( (pos == 0)) return 0; if ( (dp[i][j][pos] != -1)) return dp[i][j][pos]; long a = (Long.MAX_VALUE / 100); if ( ((i - 1) >= 0)) a = Math.min(a,(solve((i - 1),j,(pos - 1)) + w2[(i - 1)][j])); if ( (i < (N - 1))) a = Math.min(a,(solve((i + 1),j,(pos - 1)) + w2[i][j])); if ( ((j - 1) >= 0)) a = Math.min(a,(solve(i,(j - 1),(pos - 1)) + w1[i][(j - 1)])); if ( (j < (M - 1))) a = Math.min(a,(solve(i,(j + 1),(pos - 1)) + w1[i][j])); return dp[i][j][pos] = a;} public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int i ;  String[] s = br.readLine().trim().split(" "); N = Integer.parseInt(s[0]); M = Integer.parseInt(s[1]); K = Integer.parseInt(s[2]); edge = new ArrayDeque[N][M]; for ( i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) edge[i][j] = new ArrayDeque<>(); }w1 = new long[N][(M - 1)]; w2 = new long[(N - 1)][M]; dp = new long[N][M][((K / 2) + 1)]; for ( i = 0;(i < N);i++) {s = br.readLine().trim().split(" "); for ( int j = 0;(j < (M - 1));j++) w1[i][j] = (Integer.parseInt(s[j]) * 2L); }for ( i = 0;(i < (N - 1));i++) {s = br.readLine().trim().split(" "); for ( int j = 0;(j < M);j++) w2[i][j] = (Integer.parseInt(s[j]) * 2L); }for ( i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) Arrays.fill(dp[i][j],-1); }if ( ((K % 2) == 1)) {K /= 2; answer(); System.exit(0); } K /= 2; for ( i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) solve(i,j,K); }answer(); } }
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)); }} }
6	public class Main{ int n ,A ; int[] bs ,ls ; void run(){ n = nextInt(); int k = nextInt(); A = nextInt(); bs = new int[n]; ls = new int[n]; for ( int i = 0;(i < n);i++) {bs[i] = nextInt(); ls[i] = nextInt(); }dfs(k,0); System.out.println(res); } double res = 0; private void dfs( int k, int i){ if ( (i == n)) { double val = 0; for ( int j = 0;(j < (1 << n));j++) { double p = 1;  int B = 0; for ( int l = 0;(l < n);l++) p *= ((((j >> l) & 1) == 1)?(ls[l] / 100.0):((100 - ls[l]) / 100.0)); for ( int l = 0;(l < n);l++) if ( (((j >> l) & 1) == 0)) B += bs[l]; if ( (Integer.bitCount(j) > (n / 2))) {val += p; } else {val += ((p * A) / (A + B)); }}res = max(res,val); return ;} for ( int j = 0;(j < (k + 1));j++) {ls[i] += (j * 10); if ( (ls[i] <= 100)) {dfs((k - j),(i + 1)); } ls[i] -= (j * 10); }} 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 Main().run(); } }
6	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);  E2RotateColumnsHardVersion solver = new E2RotateColumnsHardVersion();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class E2RotateColumnsHardVersion{ public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  E2RotateColumnsHardVersion.Column[] columns = new E2RotateColumnsHardVersion.Column[m]; for ( int i = 0;(i < columns.length);++i) columns[i] = new E2RotateColumnsHardVersion.Column(new int[n]); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {columns[j].vals[i] = in.nextInt(); }}for ( E2RotateColumnsHardVersion.Column column :columns) column.initMax(); Arrays.sort(columns,new Comparator<E2RotateColumnsHardVersion.Column>(){}); if ( (columns.length > n)) columns = Arrays.copyOf(columns,n); out.println(solveOne(columns)); } private int solveOne( E2RotateColumnsHardVersion.Column[] columns){ int n = columns[0].vals.length;  int[] best = new int[(1 << n)];  int[] next = new int[(1 << n)];  int[] temp = new int[(1 << n)]; for ( E2RotateColumnsHardVersion.Column nowColumn :columns) {System.arraycopy(best,0,next,0,best.length); for ( int rot = 0;(rot < n);++rot) {System.arraycopy(best,0,temp,0,next.length); for ( int i = 0,pos = rot;(i < n);++i,++pos) {if ( (pos >= n)) pos = 0;  int val = nowColumn.vals[pos]; for ( int j = 0;(j < temp.length);++j) {if ( ((j & (1 << i)) == 0)) {temp[(j | (1 << i))] = Math.max(temp[(j | (1 << i))],(temp[j] + val)); } }}for ( int j = 0;(j < temp.length);++j) {next[j] = Math.max(next[j],temp[j]); }} int[] aa = best; best = next; next = aa; }return best[(best.length - 1)];} } 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 String next(){ return nextString();} 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);} public String nextString(){ int c = pread(); while(isSpaceChar(c))c = pread(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = pread(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
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();} } }
1	public class TwoSets{ static ArrayList<Integer> g[] ; static boolean visited[] ; static int ans[] ,p[] ,orig[] ; static int n ,a ,b ; @SuppressWarnings public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter w = new PrintWriter(System.out);  StringTokenizer st1 = new StringTokenizer(br.readLine()); n = ip(st1.nextToken()); a = ip(st1.nextToken()); b = ip(st1.nextToken()); g = new ArrayList[n]; visited = new boolean[n]; ans = new int[n]; p = new int[n]; orig = new int[n]; StringTokenizer st2 = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {p[i] = ip(st2.nextToken()); orig[i] = p[i]; g[i] = new ArrayList<Integer>(); }Arrays.sort(p); boolean impossible = false; for ( int i = 0;(i < n);i++) { int i1 = Arrays.binarySearch(p,(a - p[i]));  int i2 = Arrays.binarySearch(p,(b - p[i])); if ( ((i1 < 0) || (i1 >= n))) i1 = -1; if ( ((i2 < 0) || (i2 >= n))) i2 = -1; if ( ((i1 == -1) && (i2 != -1))) g[i].add(i2); else if ( ((i1 != -1) && (i2 == -1))) g[i].add(i1); else if ( ((i1 != -1) && (i2 != -1))) {g[i].add(i1); g[i].add(i2); } else {impossible = true; break;}}if ( impossible) {System.out.println("NO"); return ;} LinkedList<Integer> q = new LinkedList(); for ( int i = 0;(i < n);i++) {if ( (visited[i] == false)) { ArrayList<Integer> curq = new ArrayList<Integer>(); curq.add(i); q.add(i); visited[i] = true; while(!q.isEmpty()){ int curr = q.remove();  int s = g[curr].size(); for ( int j = 0;(j < s);j++) {if ( !visited[g[curr].get(j)]) {visited[g[curr].get(j)] = true; curq.add(g[curr].get(j)); q.add(g[curr].get(j)); } }} boolean found = true;  int s = curq.size();  int temp[] = new int[s]; for ( int j = 0;(j < s);j++) temp[j] = p[curq.get(j)]; Arrays.sort(temp); int anss = -1; for ( int j = 0;(j < s);j++) { int i3 = Arrays.binarySearch(temp,(a - temp[j])); if ( ((i3 < 0) || (i3 >= n))) {found = false; break;} }if ( !found) {found = true; for ( int j = 0;(j < s);j++) { int i3 = Arrays.binarySearch(temp,(b - temp[j])); if ( ((i3 < 0) || (i3 >= n))) {found = false; break;} }if ( found) anss = 1; else {impossible = true; break;}} else anss = 0; for ( int j = 0;(j < s);j++) ans[curq.get(j)] = anss; } }if ( !impossible) {w.println("YES"); for ( int i = 0;(i < n);i++) { int i1 = Arrays.binarySearch(p,orig[i]); if ( (ans[i1] == -1)) ans[i1] = 1; w.print((ans[i1] + " ")); }w.println(); } else w.println("NO"); w.close(); } public static int ip( String s){ return Integer.parseInt(s);} }
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());} } }
1	public class Main{ public void solve(){ int n = ni();  int a = ni();  int b = ni();  long ans = 0;  HashMap<Long,Long> m = new HashMap<>();  HashMap<String,Long> s = new HashMap<>(); for ( int i = 0;(i < n);i++) {ni(); long vx = ni();  long vy = ni();  long v = (((long)a * vx) - vy);  String k = ((vx + "|") + vy);  long cs = s.getOrDefault(k,0L);  long c = m.getOrDefault(v,0L); ans += (c - cs); m.put(v,(c + 1)); s.put(k,(cs + 1)); }write(((ans * 2) + "\n")); } public static void main( String[] args){ Main m = new Main(); m.solve(); try{m.out.close(); }catch (IOException e){ } } BufferedReader in ; BufferedWriter out ; StringTokenizer tokenizer ; public Main(){ in = new BufferedReader(new InputStreamReader(System.in)); out = new BufferedWriter(new OutputStreamWriter(System.out)); } public String n(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(in.readLine()); }catch (IOException e){ } } return tokenizer.nextToken();} public int ni(){ return Integer.parseInt(n());} public void write( String s){ try{out.write(s); }catch (IOException e){ } } }
1	public class theyareeverywhere{ public static void main( String[] args)throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  PrintWriter w = new PrintWriter(System.out);  int n = Integer.parseInt(r.readLine());  char[] pokemans = r.readLine().toCharArray();  int[] counts = new int[52];  boolean[] exists = new boolean[52]; for ( int i = 0;(i < pokemans.length);i++) {exists[index(pokemans[i])] = true; } int left = 0,right = 0; counts[index(pokemans[0])] = 1; int answer = 1000000000; while(((left < n) && (right < n))){if ( !valid(counts,exists)) {right++; if ( (right < n)) counts[index(pokemans[right])]++; } else {answer = Math.min(answer,((right - left) + 1)); left++; if ( ((left - 1) >= 0)) counts[index(pokemans[(left - 1)])]--; }}w.println(answer); w.flush(); } public static boolean valid( int[] counts, boolean[] exists){ for ( int i = 0;(i < counts.length);i++) {if ( (exists[i] && (counts[i] == 0))) return false; }return true;} public static int index( char c){ if ( ((c >= 'a') && (c <= 'z'))) {return (c - 'a');} else {return ((c - 'A') + 26);}} }
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(); } }
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);  APaintTheNumbers solver = new APaintTheNumbers(); solver.solve(1,in,out); out.close(); } static class APaintTheNumbers{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int arr[] = in.nextIntArray(n); Arrays.sort(arr); int ans = 0; for ( int i = 0;(i < n);i++) {if ( (arr[i] == -1)) continue; else {ans++; for ( int j = (i + 1);(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) arr[j] = -1; }arr[i] = -1; }}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));} public int[] nextIntArray( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);++i) array[i] = nextInt(); return array;} 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 Main{ PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); private void solution()throws IOException { int sx = in.nextInt();  int sy = 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(); y[i] = in.nextInt(); } int[] dp = new int[(1 << n)];  int[] prev = new int[(1 << n)]; Arrays.fill(dp,(Integer.MAX_VALUE / 2)); dp[0] = 0; prev[0] = -1; for ( int mask = 0;(mask < (1 << n));++mask) {if ( (dp[mask] != (Integer.MAX_VALUE / 2))) {for ( int next = 0;(next < n);++next) {if ( (((mask >> next) & 1) == 0)) { int nmask = (mask | (1 << next));  int val = (dp[mask] + (2 * getDist(sx,sy,x[next],y[next]))); if ( (dp[nmask] > val)) {dp[nmask] = val; prev[nmask] = mask; } for ( int next2 = (next + 1);(next2 < n);++next2) {if ( (((nmask >> next2) & 1) == 0)) { int nnmask = (nmask | (1 << next2));  int nval = (((dp[mask] + getDist(sx,sy,x[next],y[next])) + getDist(x[next],y[next],x[next2],y[next2])) + getDist(x[next2],y[next2],sx,sy)); if ( (dp[nnmask] > nval)) {dp[nnmask] = nval; prev[nnmask] = mask; } } }break;} }} } List<Integer> res = new ArrayList<Integer>(); res.add(0); int mask = ((1 << n) - 1); while((mask > 0)){for ( int i = 0;(i < n);++i) {if ( ((((prev[mask] >> i) & 1) == 0) && (((mask >> i) & 1) == 1))) {res.add((i + 1)); } }res.add(0); mask = prev[mask]; }Collections.reverse(res); out.println(dp[((1 << n) - 1)]); for ( int i = 0;(i < res.size());++i) {if ( (i != 0)) {out.print(" "); } out.print(res.get(i)); }out.println(); out.flush(); } private int getDist( int x1, int y1, int x2, int y2){ return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));} 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 tmp = reader.readLine(); if ( (tmp == null)) return false; tokenizer = new StringTokenizer(tmp); }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().solution(); } }
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();} }
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(); } }
3	public class Main{ public static void main( String[] args){ Main main = new Main(); main.solveC(); } private void solveC(){ Scanner sc = new Scanner(System.in);  int N = sc.nextInt();  double R = (0.0 + sc.nextInt());  double[] x = new double[N];  double[] y = new double[N]; for ( int i = 0;(i < N);i++) {x[i] = (0.0 + sc.nextInt()); double max_y = R; for ( int j = 0;(j < i);j++) { double dy = (((4 * R) * R) - ((x[i] - x[j]) * (x[i] - x[j]))); if ( (dy >= 0)) { double tmp_y = (y[j] + Math.sqrt(dy)); if ( (max_y < tmp_y)) {max_y = tmp_y; } } }y[i] = max_y; } StringJoiner sj = new StringJoiner(" "); for ( int i = 0;(i < N);i++) {sj.add(String.valueOf(y[i])); }System.out.println(sj.toString()); } interface Graph{ void link( int from, int to, long cost); Optional<Long> getCost( int from, int to); int getVertexNum(); } interface FlowResolver{ ; } }
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(); } static class TaskB{ int stage ; int n ; OutputWriter out ; InputReader in ; void query( int end){ switch(stage){ case 0:out.printLine('?',1,1,end,n); break; case 1:out.printLine('?',1,1,n,end); break; case 2:out.printLine('?',((n + 1) - end),1,n,n); break; case 3:out.printLine('?',1,((n + 1) - end),n,n); break; } out.flush(); } public void solve( int testNumber, InputReader in, OutputWriter out){ this.out = out = new OutputWriter(System.out); this.in = in = new InputReader(System.in); n = in.readInt(); int[] endx = new int[2];  int[] endy = new int[2];  int[] stx = new int[2];  int[] sty = new int[2]; find(endx); stage++; find(endy); stage++; find(stx); for ( int i = 0;(i < 2);i++) {stx[i] = ((n + 1) - stx[i]); }stage++; find(sty); for ( int i = 0;(i < 2);i++) {sty[i] = ((n + 1) - sty[i]); }for ( int i = 0;(i < 8);i++) {if ( ((stx[(i & 1)] > endx[((i >> 2) & 1)]) || (sty[((i >> 1) & 1)] > endy[0]))) {continue;} if ( ((stx[(1 - (i & 1))] > endx[(1 - ((i >> 2) & 1))]) || (sty[(1 - ((i >> 1) & 1))] > endy[1]))) {continue;} out.printLine('?',stx[(i & 1)],sty[((i >> 1) & 1)],endx[((i >> 2) & 1)],endy[0]); out.flush(); if ( (in.readInt() == 0)) {continue;} out.printLine('?',stx[(1 - (i & 1))],sty[(1 - ((i >> 1) & 1))],endx[(1 - ((i >> 2) & 1))],endy[1]); out.flush(); if ( (in.readInt() != 0)) {out.printLine("!",stx[(i & 1)],sty[((i >> 1) & 1)],endx[((i >> 2) & 1)],endy[0],stx[(1 - (i & 1))],sty[(1 - ((i >> 1) & 1))],endx[(1 - ((i >> 2) & 1))],endy[1]); out.flush(); return ;} }} private void find( int[] endx){ int left = 1;  int right = n; while((left < right)){ int middle = ((left + right) >> 1); query(middle); if ( (in.readInt() == 2)) {right = middle; } else {left = (middle + 1); }}endx[0] = left; left = 0; right--; while((left < right)){ int middle = (((left + right) + 1) >> 1); query(middle); if ( (in.readInt() == 0)) {left = middle; } else {right = (middle - 1); }}endx[1] = (left + 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 printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } public void flush(){ writer.flush(); } } 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); } } }
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 SFly{ public static void main( String[] args)throws IOException { BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));  int planet = Integer.parseInt(lector.readLine());  int ini = Integer.parseInt(lector.readLine());  double peso = ini;  int[] desp = new int[planet];  int[] ater = new int[planet];  String[] temp = lector.readLine().split(" "); for ( int i = 0;(i < planet);i++) {desp[i] = Integer.parseInt(temp[i]); if ( (desp[i] == 1)) {System.out.println(-1); lector.close(); return ;} }temp = lector.readLine().split(" "); for ( int i = 0;(i < planet);i++) {ater[i] = Integer.parseInt(temp[i]); if ( (ater[i] == 1)) {System.out.println(-1); lector.close(); return ;} }temp = null; int i = (planet - 1); peso = ((peso * ater[0]) / (ater[0] - 1)); while((i > 0)){peso = ((peso * desp[i]) / (desp[i] - 1)); peso = ((peso * ater[i]) / (ater[i] - 1)); i--; }peso = ((peso * desp[0]) / (desp[0] - 1)); peso = (peso - ini); System.out.println(peso); lector.close(); } }
2	public class Main{ static private final int Max = (int)(1e5 + 10); static private long n ,s ; public static void main( String[] args){ InitData(); GetAns(); } static private void InitData(){ Scanner cin = new Scanner(System.in); n = cin.nextLong(); s = cin.nextLong(); } static private 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); }} static private long sum( long ans){ long sum = 0; while((ans > 0)){sum += (ans % 10); ans /= 10; }return sum;} }
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 A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  team[] t = new team[n]; for ( int i = 0;(i < n);i++) t[i] = new team(in.nextInt(),in.nextInt()); Arrays.sort(t); int cnt = 0;  team tm = t[(t.length - k)]; for ( int i = (t.length - 1);(i >= 0);i--) if ( tm.equal(t[i])) cnt++; System.out.println(cnt); } static class team implements Comparable<team>{ int p ,t ; public team( int pp, int tt){ p = pp; t = tt; } public boolean equal( team a){ return ((a.p == p) && (a.t == t));} } }
5	public class C{ Scanner sc ; BufferedReader in ; PrintStream out ; StringTokenizer tok ; public C()throws NumberFormatException,IOException{ in = new BufferedReader(new InputStreamReader(System.in)); out = System.out; run(); } void run()throws NumberFormatException,IOException { int[] array ;  int n = nextInt(); array = new int[n]; int max = 0;  int pos = 0; for ( int i = 0;(i < n);i++) { int l = nextInt(); if ( (l > max)) {pos = i; max = l; } array[i] = l; }if ( (max == 1)) array[pos] = 2; else array[pos] = 1; Arrays.sort(array); out.print(array[0]); for ( int i = 1;(i < n);i++) out.print((" " + array[i])); out.println(); } public static void main( String[] args)throws NumberFormatException,IOException { new C(); } String nextToken()throws IOException { if ( ((tok == null) || !tok.hasMoreTokens())) tok = new StringTokenizer(in.readLine()); return tok.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} }
0	public class A{ FastScanner in ; PrintWriter out ; void solve(){ long a = in.nextLong(),b = in.nextLong();  long ans = 0; while(true){ long div = (a / b); ans += div; a -= (div * b); if ( (a == 0)) {break;} long tmp = a; a = b; b = tmp; }out.println(ans); } void run(){ in = new FastScanner(); out = new PrintWriter(System.out); solve(); out.close(); } 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();} long nextLong(){ return Long.parseLong(nextToken());} } public static void main( String[] args){ new A().run(); } }
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 Solution implements Runnable{ 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());} void solve()throws Exception { int n = nextInt();  Integer[] a = new Integer[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } Integer[] b = a.clone(); Arrays.sort(b); int d = 0; for ( int i = 0;(i < n);i++) {if ( !a[i].equals(b[i])) d++; }out.println(((d > 2)?"NO":"YES")); } public void run(){ try{Locale.setDefault(Locale.UK); 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(); } }
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)));} }
5	public class Main{ static int n ; static long TotalTime ; static Problem[] problems ; static StringBuilder sb ; public static void main( String[] args){ FastScanner sc = new FastScanner(); sb = new StringBuilder(); n = sc.nextInt(); TotalTime = sc.nextLong(); problems = new Problem[n]; for ( int i = 0;(i < n);i++) {problems[i] = new Problem(sc.nextInt(),sc.nextLong(),i); }Arrays.sort(problems); long num = -1;  long high = n;  long low = 0;  int iter = 0; while(((high - low) > 1)){num = ((high + low) / 2); if ( test(num,false)) {low = num; } else {high = num; }}if ( test(high,false)) num = high; else num = low; test(num,true); System.out.print(sb); } public static boolean test( long num, boolean print){ int count = 0;  long sum = 0L; if ( print) sb.append((((num + "\n") + num) + "\n")); for ( int i = 0;((i < n) && (count < num));i++) {if ( (problems[i].a >= num)) {count++; sum += problems[i].t; if ( print) sb.append(((problems[i].index + 1) + " ")); } }return ((count == num) && (sum <= TotalTime));} public static class Problem implements Comparable<Problem>{ int a ; long t ; int index ; public Problem( int a, long t, int index){ this.a = a; this.t = t; this.index = index; } } 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());} long nextLong(){ return Long.parseLong(next());} } }
2	public class Main{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long n = scanner.nextLong();  long s = scanner.nextLong();  long l = 0,r = (n + 1); while(((r - l) > 1)){ long mid = ((l + r) / 2);  long k = mid,sum = 0; while((k != 0)){sum += (k % 10); k /= 10; }if ( ((mid - sum) >= s)) r = mid; else l = mid; }System.out.print(((n - r) + 1)); } }
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{ static private final int bufferMaxLength = 1024; private InputStream in ; private byte[] buffer ; private int currentBufferSize ; private int currentBufferTop ; static private 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(); } }
1	public class Polycarp{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int rem[] = new int[3]; Arrays.fill(rem,-1); rem[0] = 0; char ch[] = s.next().toCharArray();  int n = ch.length;  long dp[] = new long[n];  int sum = 0; for ( int i = 0;(i < ch.length);i++) {sum = (sum + (ch[i] - 48)); if ( (rem[(sum % 3)] != -1)) if ( (i > 0)) {dp[i] = Math.max(dp[(i - 1)],(dp[rem[(sum % 3)]] + 1)); } else dp[i] = 1; else if ( (i > 0)) dp[i] = dp[(i - 1)]; rem[(sum % 3)] = i; sum = (sum % 3); }System.out.println(dp[(n - 1)]); } }
2	public class D276{ Scanner sc = new Scanner(in); public void run(){ long l = sc.nextLong(),r = sc.nextLong();  long tes = (l ^ r);  int d = 0; while((tes != 0)){tes /= 2; d++; }ln(((1L << d) - 1)); } public static void main( String[] _){ new D276().run(); } public static void ln( Object o){ out.println(o); } public static void ln(){ out.println(); } }
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(){ final int n = i(); final 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++; } }}final int q = i(); for ( int i = 0;(i < q);i++) {final int l = i(),r = i(); final 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); }
0	public class RationalResistance{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(f.readLine());  long a = Long.parseLong(st.nextToken());  long b = Long.parseLong(st.nextToken()); System.out.println(f(a,b)); } public static long f( long a, long b){ if ( ((a == 1) || (b == 1))) return ((a + b) - 1); if ( (a > b)) return (f((a % b),b) + (a / b)); else return (f(a,(b % a)) + (b / a));} }
5	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 class result implements Comparable{ public int t = 0; public int p = 0; public result( int p, int t){ this.t = t; this.p = p; } } public void solve()throws NumberFormatException,IOException { int n = nextInt();  int k = nextInt();  result[] table = new result[n]; for ( int i = 0;(i < n);i++) { int p = nextInt();  int t = nextInt(); table[i] = new result(p,t); }Arrays.sort(table); int result = 1; k--; for ( int i = (k - 1);(((i >= 0) && (table[i].p == table[k].p)) && (table[i].t == table[k].t));i--) {result++; }for ( int i = (k + 1);(((i < n) && (table[i].p == table[k].p)) && (table[i].t == table[k].t));i++) {result++; }out.println(result); } public void close(){ out.flush(); out.close(); } }
4	public class Main{ static int MOD = 1000000007; void solve()throws IOException { int T = ri(); for ( int Ti = 0;(Ti < T);Ti++) { int n = ri();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ri(); Deque<int[]> stack = new ArrayDeque<>(); stack.addLast(new int[]{1}); pw.println("1"); for ( int i = 1;(i < n);i++) {if ( (a[i] == 1)) { int[] prev = stack.peekLast();  int[] curr = new int[(prev.length + 1)]; System.arraycopy(prev,0,curr,0,prev.length); curr[(curr.length - 1)] = 1; printArr(curr); stack.addLast(curr); continue;} while(!stack.isEmpty()){ int[] prev = stack.removeLast(); if ( (a[i] == (prev[(prev.length - 1)] + 1))) {prev[(prev.length - 1)]++; printArr(prev); stack.addLast(prev); break;} else {continue;}}}}} void printArr( int[] a){ pw.print(a[0]); for ( int j = 1;(j < a.length);j++) pw.print(("." + a[j])); pw.println(); } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); public static void main( String[] args)throws IOException { Main m = new Main(); m.solve(); m.close(); } void close()throws IOException { pw.flush(); pw.close(); br.close(); } int ri()throws IOException { return Integer.parseInt(br.readLine().trim());} int[] ril( int n)throws IOException { int[] nums = new int[n];  int c = 0; for ( int i = 0;(i < n);i++) { int sign = 1; c = br.read(); int x = 0; if ( (c == '-')) {sign = -1; c = br.read(); } while(((c >= '0') && (c <= '9'))){x = (((x * 10) + c) - '0'); c = br.read(); }nums[i] = (x * sign); }while(((c != '\n') && (c != -1)))c = br.read(); return nums;} long[] rll( int n)throws IOException { long[] nums = new long[n];  int c = 0; for ( int i = 0;(i < n);i++) { int sign = 1; c = br.read(); long x = 0; if ( (c == '-')) {sign = -1; c = br.read(); } while(((c >= '0') && (c <= '9'))){x = (((x * 10) + c) - '0'); c = br.read(); }nums[i] = (x * sign); }while(((c != '\n') && (c != -1)))c = br.read(); return nums;} void sort( int[] A){ Random r = new Random(); for ( int i = (A.length - 1);(i > 0);i--) { int j = r.nextInt((i + 1));  int temp = A[i]; A[i] = A[j]; A[j] = temp; }Arrays.sort(A); } }
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); } }
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;} }
1	public class Main{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; void solve()throws IOException { int n = ni();  int k = ni();  boolean[] t = new boolean[(n + 1)]; for ( int i = 2;(i <= n);i++) {t[i] = false; } int p = 2; while(true){ int pointer = 2; while(((pointer * p) <= n)){t[(pointer * p)] = true; pointer++; } boolean flag = false; for ( int i = (p + 1);(i <= n);i++) {if ( !t[i]) {p = i; flag = true; break;} }if ( !flag) break; } List<Integer> lst = new ArrayList<Integer>();  int countN = 0; for ( int i = 1;(i <= n);i++) {if ( !t[i]) {lst.add(i); countN++; } } int count = 0;  String resulPO = "NO"; for ( int i = 2;(i < countN);i++) { boolean result = false; for ( int j = 0;(j < i);j++) {if ( (((lst.get(j) + lst.get((j + 1))) + 1) == lst.get(i))) {result = true; break;} }if ( result) count++; }if ( (count >= k)) resulPO = "YES"; else resulPO = "NO"; out.print(resulPO); } public Main()throws IOException{ Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } String ns()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int ni()throws IOException { return Integer.valueOf(ns());} public static void main( String[] args)throws IOException { new Main(); } }
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));} } }
3	public class C{ public static void main( String[] args){ FastScanner scan = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int n = scan.nextInt(),r = scan.nextInt();  int[] x = scan.nextIntArray(n);  double[] y = new double[n]; for ( int i = 0;(i < n);i++) { double best = 0; for ( int j = 0;(j < i);j++) {if ( (Math.abs((dist(x[i],y[j],x[j],y[j]) - (2 * r))) <= 1e-7)) {best = Math.max(best,y[j]); continue;} double lo = ((y[j] - r) - r),hi = ((y[j] + r) + r); for ( int bs = 0;(bs < 200);bs++) { double mid = ((lo + hi) / 2.0); if ( ((dist(x[i],mid,x[j],y[j]) - (2 * r)) <= 1e-7)) lo = mid; else hi = mid; }if ( ((dist(x[i],lo,x[j],y[j]) - (2 * r)) <= 1e-7)) best = Math.max(best,lo); }if ( (best == 0)) y[i] = r; else y[i] = best; }for ( int i = 0;(i < n);i++) out.printf("%.6f ",y[i]); out.close(); } static double dist( double x, double y, double xx, double yy){ return Math.sqrt((((x - xx) * (x - xx)) + ((y - yy) * (y - yy))));} static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ try{br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } public String next(){ if ( st.hasMoreTokens()) return st.nextToken(); try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } 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[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
2	public class Main{ public static Character solve( long a, long b, long c){ long min = a;  long max ;  long xth = 0;  long index ; for ( index = (String.valueOf(a).length() - 1);;index++) { long numOfDigits = 0; max = ((long)Math.pow(10,(index + 1)) - 1); long count = (((max - min) / b) + 1); numOfDigits += (count * (index + 1)); if ( ((c - numOfDigits) <= 0)) {break;} c -= numOfDigits; min = (min + (count * b)); }if ( ((c % (index + 1)) == 0)) {xth = (c / (index + 1)); } else {xth = ((c / (index + 1)) + 1); } long lastNum = (min + (b * (xth - 1)));  int pos = (int)(c % (index + 1)); if ( (pos == 0)) {return String.valueOf(lastNum).charAt((int)index);} else {return String.valueOf(lastNum).charAt((pos - 1));}} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long tc ; tc = sc.nextLong(); System.out.println(solve(1,1,tc)); } }
1	public class B{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int i ,N ;  int T = Integer.parseInt(br.readLine().trim());  StringBuilder sb = new StringBuilder(); while((T-- > 0)){N = Integer.parseInt(br.readLine().trim()); boolean flag = false;  int sqrt = (int)Math.sqrt((N / 2)); if ( (((sqrt * sqrt) == (N / 2)) && ((N % 2) == 0))) flag = true; sqrt = (int)Math.sqrt((N / 4)); if ( (((sqrt * sqrt) == (N / 4)) && ((N % 4) == 0))) flag = true; sb.append((flag?"YES\n":"NO\n")); }System.out.println(sb); } }
5	public class C{ 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 C().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();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = readInt(); } boolean c = true; for ( int i = 0;(i < n);i++) {if ( (a[i] != 1)) {c = false; break;} }if ( c) {for ( int i = 0;(i < (n - 1));i++) {out.print((a[i] + " ")); }out.println(2); return ;} Utils.mergeSort(a); out.print((1 + " ")); for ( int i = 1;(i < n);i++) {out.print((a[(i - 1)] + " ")); }} static long gcd( long a, long b){ if ( (min(a,b) == 0)) return max(a,b); return gcd((max(a,b) % min(a,b)),min(a,b));} }
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());} } static private 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 Main{ public static void main( String[] args)throws IOException { PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); br = new BufferedReader(new InputStreamReader(System.in)); int n = nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextInt(); }Arrays.sort(arr); int c = 0; for ( int i = 0;(i < n);i++) {if ( (arr[i] != 0)) { int a = arr[i]; c++; for ( int j = i;(j < n);j++) {if ( ((arr[j] % a) == 0)) {arr[j] = 0; } }} }pw.println(c); pw.close(); } public static BufferedReader br ; public static StringTokenizer st ; public static String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return st.nextToken();} public static Integer nextInt(){ return Integer.parseInt(next());} static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} 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); if ( ((y % 2) == 0)) return p; else return ((x * p) % m);} 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);} }
0	public class Main{ public static void main( String[] args){ Scanner read = new Scanner(System.in);  int n = read.nextInt(); System.out.println(((n * 3) / 2)); } }
0	public class A{ public static void main( String[] args){ FastScanner sc = new FastScanner();  int n = sc.nextInt();  String nStr = Integer.toString(n);  String nStr1 = nStr.substring(0,(nStr.length() - 1));  String nStr2 = (nStr.substring(0,(nStr.length() - 2)) + nStr.charAt((nStr.length() - 1)));  int result = Math.max(n,Integer.parseInt(nStr1)); result = Math.max(result,Integer.parseInt(nStr2)); System.out.println(result); } public 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());} } }
5	public class test{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int m = s.nextInt();  int arr[] = new int[n];  int max = Integer.MIN_VALUE;  long sum = 0; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); sum = (sum + arr[i]); max = Math.max(max,arr[i]); }Arrays.sort(arr); int i = 0;  int count = 0;  int d = 0; for ( i = 0;(i < n);i++) {if ( (arr[i] > d)) {count++; d++; } else if ( ((arr[i] == d) && (arr[i] > 0))) {count++; } }if ( ((max - d) > 0)) {count = ((count + max) - d); } System.out.println((sum - count)); } }
5	public class CoveredPointsCount{ 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());  long[] myArray = new long[(2 * n)]; for ( int i = 0;(i < n);i++) { StringTokenizer st1 = new StringTokenizer(br.readLine()); myArray[(2 * i)] = (Long.parseLong(st1.nextToken()) * 2); myArray[((2 * i) + 1)] = ((Long.parseLong(st1.nextToken()) * 2) + 1); }Arrays.sort(myArray); long[] ans = new long[(n + 1)];  int cnt = 0; for ( int i = 0;(i < ((2 * n) - 1));i++) {if ( ((myArray[i] % 2) == 0)) cnt++; else cnt--; ans[cnt] += (((myArray[(i + 1)] + 1) / 2) - ((myArray[i] + 1) / 2)); } StringBuilder answer = new StringBuilder(); for ( int i = 1;(i < (n + 1));i++) {answer.append(ans[i]); answer.append(" "); }System.out.println(answer); } }
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); } }
6	public class E{ static void solve()throws Exception { int tests = scanInt(); for ( int test = 0;(test < tests);test++) { int n = scanInt(),m = scanInt(),a[][] = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[i][j] = scanInt(); }} int bestCols[] = new int[min(m,n)]; for ( int i = 0;(i < bestCols.length);i++) {bestCols[i] = i; }if ( (m > n)) { int bestColMax[] = new int[n]; for ( int i = 0;(i < n);i++) { int cmax = 0; for ( int j = 0;(j < n);j++) {cmax = max(cmax,a[j][i]); }bestColMax[i] = cmax; }for ( int i = n;(i < m);i++) { int cmax = 0; for ( int j = 0;(j < n);j++) {cmax = max(cmax,a[j][i]); } int minBC = 0,minBCM = Integer.MAX_VALUE; for ( int j = 0;(j < n);j++) {if ( (bestColMax[j] < minBCM)) {minBC = j; minBCM = bestColMax[j]; } }if ( (cmax > minBCM)) {bestCols[minBC] = i; bestColMax[minBC] = cmax; } }} int dyn[] = new int[(1 << n)],dynNext[] = new int[(1 << n)],sums[] = new int[(1 << n)],csums[] = new int[(1 << n)]; for ( int i :bestCols) {fill(dynNext,0); fill(sums,0); for ( int j = 0;(j < n);j++) {for ( int k = 1,bit = 0;(k < (1 << n));k++) {if ( (k == (1 << (bit + 1)))) {++bit; } sums[k] = max(sums[k],csums[k] = (csums[(k ^ (1 << bit))] + a[((bit + j) % n)][i])); }}for ( int mask1 = 0;(mask1 < (1 << n));mask1++) { int cdyn = dynNext[mask1]; for ( int mask2 = mask1;;mask2 = ((mask2 - 1) & mask1)) {cdyn = max(cdyn,(dyn[mask2] + sums[(mask1 ^ mask2)])); if ( (mask2 == 0)) {break;} }dynNext[mask1] = cdyn; } int t[] = dyn; dyn = dynNext; dynNext = t; }out.println(dyn[((1 << n) - 1)]); }} 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); } } }
1	public class Solution{ public static void main( String[] args){ new Thread(new Runnable(){}).start(); } Solution(){ String data = "2\nR1C18\nR1";  PrintWriter pw = new PrintWriter(System.out);  BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); try{ int n = Integer.parseInt(in.readLine());  int[] res = new int[2]; for ( int i = 0;(i < n);i++) { String s = in.readLine(); if ( isSecondType(s,res)) {pw.println(toFirstType(res)); } else {pw.println(toSecondType(s)); }} }catch (IOException e){ } finally{pw.flush(); pw.close(); }} private String toSecondType( String s){ int i = 0; for ( ;(i < s.length());i++) {if ( ((s.charAt(i) < 'A') || (s.charAt(i) > 'Z'))) break; } String first = s.substring(0,i);  String second = s.substring(i,s.length());  StringBuilder sb = new StringBuilder(); sb.append("R"); sb.append(second); sb.append("C"); sb.append(stringToNum(first)); return sb.toString();} private int stringToNum( String first){ int k = 0;  int res = 0;  int p = 1; for ( int i = (first.length() - 1);(i >= 0);i--) { int v = ((first.charAt(i) - 'A') + k); k = 1; res += (p * v); p *= 26; }return (res + 1);} private String toFirstType( int[] res){ StringBuilder sb = new StringBuilder(); sb.append(numToString(res[1])); sb.append(res[0]); return sb.toString();} private String numToString( int num){ StringBuilder sb = new StringBuilder(); while((num > 0)){num--; char c = (char)((num % 26) + 'A'); sb.append(c); num /= 26; }return sb.reverse().toString();} private boolean isSecondType( String s, int[] res){ try{return doIsSecondType(s,res); }catch (Exception e){ return false;} } private boolean doIsSecondType( String s, int[] res){ StringTokenizer st = new StringTokenizer(s,"RC",true);  String token = st.nextToken(); if ( !token.equals("R")) return false; token = st.nextToken(); if ( !isDigit(token)) return false; res[0] = Integer.parseInt(token); token = st.nextToken(); if ( !token.equals("C")) return false; token = st.nextToken(); if ( !isDigit(token)) return false; res[1] = Integer.parseInt(token); return true;} private boolean isDigit( String token){ for ( int i = 0;(i < token.length());i++) {if ( ((token.charAt(i) < '0') || (token.charAt(i) > '9'))) return false; }return true;} }
1	public class A{ public static int palin( String str){ int flag = 0;  int l = str.length(); for ( int i = 0;(i < (l / 2));i++) {if ( (str.charAt(i) != str.charAt(((l - i) - 1)))) {flag = 1; break;} }if ( (flag == 1)) return 0; else return 1;} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  String str = sc.next();  HashSet<Character> hs = new HashSet<>(); for ( int i = 0;(i < str.length());i++) {hs.add(str.charAt(i)); }if ( (hs.size() == 1)) System.out.println(0); else if ( (palin(str) == 0)) System.out.println(str.length()); else System.out.println((str.length() - 1)); } }
2	@SuppressWarnings("unchecked") public class Solution 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 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); } } static int num = (int)1e6; public static int random( int min, int max){ return (min + (int)((max - min) * Math.random()));} public static long pow( long n, int pow){ long res = 1; while((pow != 0)){if ( ((pow & 1) == 1)) {res *= n; } n *= n; pow = (pow >> 1); }return res;} public static int bsearch( int n, long k){ int l = 1;  int r = n; while((r > l)){ int mid = (((l + r) + 1) >> 1); if ( (((pow(2,(mid + 1)) - mid) - 2) <= k)) {l = mid; } else {r = (mid - 1); }}if ( ((((pow(2,(l + 1)) - l) - 2) == 0) && (((pow(2,(l + 1)) - l) - 2) == k))) {return 0;} else if ( (((pow(2,(l + 1)) - l) - 2) <= k)) {return l;} return 0;} public static boolean valid( int n, long k, int steps){ long total_max = ((pow(4,n) - 1) / 3);  long cant_be = (((pow(4,(n - steps)) - 1) / 3) * (pow(2,(steps + 1)) - 1));  long available = (total_max - cant_be); if ( (available >= k)) {return true;} return false;} public static void main( String[] args)throws Exception { new Thread(null,new Solution(),"Main",(1 << 26)).start(); } }
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 IOException,InterruptedException { int n = reader.nextInt();  int[] a = reader.nextIntArray(n);  boolean b = false; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) {b = !b; } }} int m = reader.nextInt(); for ( int i = 0;(i < m);i++) { int l = reader.nextInt();  int r = reader.nextInt();  int d = ((r - l) + 1); if ( ((((d * (d - 1)) / 2) % 2) == 1)) {b = !b; } writer.println((b?"odd":"even")); }} 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 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(); } }
3	public class InVoker{ public static void main( String[] args){ Scanner inp = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = inp.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = inp.nextInt(); Arrays.sort(a); int gg = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] == 0)) continue; gg++; for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {a[j] = 0; } }}out.println(gg); out.close(); inp.close(); } }
1	public class C01Easy{ public static void main( String[] args){ try(BufferedReader r=new BufferedReader(new InputStreamReader(System.in))){final String[] line = r.readLine().split(" "); final int N = Integer.parseInt(line[0]),P = Integer.parseInt(line[1]); final String[] numS = r.readLine().split(" "); if ( (numS.length != N)) throw (new IllegalArgumentException()); final int[] n = new int[N];  int sum1 = 0,sum2 = 0; for ( int i = 0;(i < N);i++) {n[i] = (Integer.parseInt(numS[i]) % P); sum2 += n[i]; if ( (sum2 >= P)) sum2 -= P; } int max = sum2; for ( int i = 0;(i < N);i++) {sum1 += n[i]; if ( (sum1 >= P)) sum1 -= P; sum2 -= n[i]; if ( (sum2 < 0)) sum2 += P; final int s = (sum1 + sum2); if ( (s > max)) max = s; }System.out.println(max); }catch (IOException e){ e.printStackTrace(); } } }
5	public class Main{ static private IO io ; public static void main( String[] args)throws IOException { new Main().run(); } private void run()throws IOException { io = new IO((System.getProperty("ONLINE_JUDGE") != null)); solve(); io.flush(); } private void solve()throws IOException { int n = io.nI(),a = io.nI(),b = io.nI(),h[] = new int[n],i ; for ( i = 0;(i < n);i++) h[i] = io.nI(); Arrays.sort(h); io.wln((h[b] - h[(b - 1)])); } @SuppressWarnings("unused") private class IO{ StreamTokenizer in ; PrintWriter out ; BufferedReader br ; Reader reader ; Writer writer ; public IO( boolean oj)throws IOException{ Locale.setDefault(Locale.US); reader = (oj?new InputStreamReader(System.in):new FileReader("input.txt")); writer = (oj?new OutputStreamWriter(System.out):new FileWriter("output.txt")); br = new BufferedReader(reader); in = new StreamTokenizer(br); out = new PrintWriter(writer); } public void wln(){ out.println(); } public void wln( int arg){ out.println(arg); } public void wln( long arg){ out.println(arg); } public void wln( double arg){ out.println(arg); } public void wln( String arg){ out.println(arg); } public void wln( boolean arg){ out.println(arg); } public void wln( char arg){ out.println(arg); } public void wln( float arg){ out.println(arg); } public void wln( Object arg){ out.println(arg); } public void flush(){ out.flush(); } public int nI()throws IOException { in.nextToken(); return (int)in.nval;} } }
2	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(); } static class TaskB{ FastReader in ; PrintWriter out ; int n ; public void solve( int testNumber, FastReader in, PrintWriter out){ this.in = in; this.out = out; n = in.nextInt(); if ( ((n % 4) != 0)) {out.println("! -1"); return ;} int low = 0;  int high = (n >> 1); if ( (BValue(low) == 0)) {out.println(("! " + (low + 1))); return ;} boolean value = (BValue(low) > 0); while(((high - low) > 1)){ int mid = ((high + low) >> 1);  int BVal = BValue(mid); if ( (BVal == 0)) {out.println(("! " + (mid + 1))); return ;} if ( value) {if ( (BVal < 0)) {high = mid; } else {low = mid; }} else {if ( (BVal > 0)) {high = mid; } else {low = mid; }}}out.println("! -1"); } public int BValue( int index){ out.println(("? " + (index + 1))); out.flush(); int f = in.nextInt(); out.println(("? " + ((index + 1) + (n >> 1)))); out.flush(); int s = in.nextInt(); return (f - s);} } 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));} } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ public void solve( int testNumber, InputReader in, OutputWriter out){ int N = in.nextInt(),i ,a[] = new int[N];  int rev[] = new int[N]; for ( i = 0;(i < N);i++) {a[i] = in.nextInt(); rev[((N - i) - 1)] = a[i]; } long[][] inverse = inversions(a,N);  long[][] revInverse = inversions(rev,N);  int q = in.nextInt();  long inversions = (inverse[0][(N - 1)] % 2); while((q-- > 0)){ int left = (in.nextInt() - 1),right = (in.nextInt() - 1);  int length = ((right - left) + 1); length = ((length * (length - 1)) / 2); if ( ((length % 2) == 1)) {inversions = (1 - inversions); } if ( ((inversions % 2) == 0)) {out.printLine("even"); } else {out.printLine("odd"); }}} public long[][] inversions( int[] a, int N){ int x[][] = new int[N][N];  int i ,j ; for ( i = 0;(i < N);i++) {for ( j = (i + 1);(j < N);j++) {if ( (a[i] > a[j])) {x[i][j] = 1; } }} int colSum[][] = new int[N][N]; for ( i = 0;(i < N);i++) {colSum[0][i] = x[0][i]; for ( j = 1;(j < N);j++) {colSum[j][i] = (colSum[(j - 1)][i] + x[j][i]); }} long inverse[][] = new long[N][N]; for ( int length = 2;(length <= N);length++) {j = (length - 1); i = 0; while((j < N)){inverse[i][j] = (inverse[i][(j - 1)] + colSum[((i + length) - 1)][j]); if ( (i > 0)) {inverse[i][j] -= colSum[(i - 1)][j]; } i++; j++; }}return inverse;} } 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());} } 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(); } } }
6	@SuppressWarnings("unused") public class Solution{ static long inf = ((long)1e18 + 100); static final long mod = ((long)1e9 + 7); @SuppressWarnings public static void main( String[] args)throws IOException { FastScanner fs = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int tt = 1; outer:while((tt-- > 0)){ int n = fs.nextInt(),T = fs.nextInt();  int[] t = new int[n],g = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = fs.nextInt(); g[i] = fs.nextInt(); } long[][] dp = new long[(1 << n)][4]; dp[0][0] = 1; long ans = 0; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int pre = 0;(pre <= 3);pre++) {for ( int i = 0;(i < n);i++) if ( (((mask & (1 << i)) == 0) && (g[i] != pre))) dp[(mask ^ (1 << i))][g[i]] = add(dp[(mask ^ (1 << i))][g[i]],dp[mask][pre]);  int sum = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) sum += t[i]; }if ( (sum == T)) ans = add(ans,dp[mask][pre]); }}out.println(ans); }out.close(); } static long add( long a, long b){ a += b; if ( (a > mod)) return (a - mod); return a;} static final Random random = new Random(); 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();} public 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);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class TaskB{ public void solve( int testNumber, InputReader in, PrintWriter out){ long x = in.readLong(); if ( ((x % 2) == 1)) {out.println("NO"); return ;} if ( ((x % 2) == 0)) { long p = (x / 2);  long square = (long)Math.sqrt(p); if ( (((square * 1L) * square) == p)) {out.println("YES"); return ;} } if ( ((x % 4) == 0)) { long p = (x / 4);  long square = (long)Math.sqrt(p); if ( (((square * 1L) * square) == p)) {out.println("YES"); return ;} } out.println("NO"); } } 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 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 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 interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
1	public class HamstersTigers{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; int solve( String a, int k){ int n = a.length(),ret = 0;  int temp[] = new int[n]; for ( int i = 0;(i < n);i++) temp[(((n + i) - k) % n)] = ((a.charAt(i) == 'T')?1:0); int left = 0,right = (n - 1); while((left < right)){while((temp[left] == 0))left++; while((temp[right] == 1))right--; if ( (left < right)) { int t = temp[left]; temp[left] = temp[right]; temp[right] = t; ret++; } }return ret;} void solve()throws IOException { int n = nextInt();  String a = next();  int ans = Integer.MAX_VALUE; for ( int fix = 0;(fix < n);fix++) {ans = Math.min(ans,solve(a,fix)); }out.println(ans); } HamstersTigers()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 HamstersTigers(); } }
4	public class E{ static long mod ; static long[][] dp ; static int n ; static long[] nWaysToPlaceGroupOfSize ; public static void main( String[] args){ FastScanner fs = new FastScanner(); n = fs.nextInt(); mod = fs.nextInt(); precomp(); dp = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i < dp.length);i++) Arrays.fill(dp[i],-1); long ans = 0; for ( int nXsLeft = 2;(nXsLeft <= n);nXsLeft++) { long curAns = go(0,nXsLeft); ans = add(ans,curAns); }System.out.println(ans); } static long go( int position, int nXsLeft){ if ( (position == n)) {return 0;} if ( (position == (n + 1))) {if ( (nXsLeft == 0)) return 1; return 0;} if ( (dp[position][nXsLeft] != -1)) {return dp[position][nXsLeft];} long ways = 0; for ( int nPlace = 1;(nPlace <= Math.min(nXsLeft,(n - position)));nPlace++) { long futureWays = go(((position + nPlace) + 1),(nXsLeft - nPlace));  long waysToPlaceMe = nCk(nXsLeft,nPlace); if ( (nPlace > 1)) waysToPlaceMe = mul(waysToPlaceMe,nWaysToPlaceGroupOfSize[nPlace]); ways = add(ways,mul(waysToPlaceMe,futureWays)); }return dp[position][nXsLeft] = ways;} static long nCk( int n, int k){ if ( (k > n)) throw (null); return mul(facts[n],mul(factInvs[k],factInvs[(n - k)]));} static long add( long a, long b){ return ((a + b) % mod);} static long mul( long a, long b){ return ((a * b) % mod);} static long fastPow( long base, long e){ if ( (e == 0)) return 1; long half = fastPow(base,(e / 2)); if ( ((e % 2) == 0)) return mul(half,half); return mul(half,mul(half,base));} static long[] facts = new long[1_000_00]; static long[] factInvs = new long[1_000_00]; static void precomp(){ facts[0] = 1; for ( int i = 1;(i < facts.length);i++) facts[i] = mul(facts[(i - 1)],i); for ( int i = 0;(i < factInvs.length);i++) factInvs[i] = fastPow(facts[i],(mod - 2)); nWaysToPlaceGroupOfSize = new long[500]; for ( int finalSize = 1;(finalSize < nWaysToPlaceGroupOfSize.length);finalSize++) {for ( int firstPos = 0;(firstPos < finalSize);firstPos++) { int l = firstPos,r = ((finalSize - 1) - firstPos); nWaysToPlaceGroupOfSize[finalSize] = add(nWaysToPlaceGroupOfSize[finalSize],nCk((l + r),l)); }}System.err.println("Done with precomp."); } 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());} } }
0	public class CF{ long getAns( long a, long b){ if ( (a == b)) return 1; if ( (a < b)) {return getAns(b,a);} long cnt = ((a - 1) / b); return (cnt + getAns(b,(a - (b * cnt))));} void solve(){ long a = in.nextLong();  long b = in.nextLong(); out.println(getAns(a,b)); } FastScaner in ; PrintWriter out ; void run(){ in = new FastScaner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } public static void main( String[] args){ new CF().run(); } class FastScaner{ BufferedReader br ; StringTokenizer st ; FastScaner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } FastScaner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } String next(){ while(((st == null) || !st.hasMoreElements())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} long nextLong(){ return Long.parseLong(next());} } }
5	public class Split{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  int a[] = new int[n];  int d[] = new int[(n - 1)]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); if ( (i > 0)) d[(i - 1)] = (a[(i - 1)] - a[i]); }Arrays.sort(d); int t = 0; for ( int i = 0;(i < (k - 1));i++) t += d[i]; System.out.println(((a[(n - 1)] - a[0]) + t)); } }
6	public class Main{ static final int MOD = ((int)1e9 + 7); static int n ; static int[] t ; static int[] g ; static int[][] memo ; static int dp( int mask, int rem, int last){ if ( (rem == 0)) return 1; if ( (memo[last][mask] != -1)) return memo[last][mask]; int ans = 0; for ( int i = 0;(i < n);i++) {if ( ((((mask & (1 << i)) == 0) && (rem >= t[i])) && (g[i] != last))) ans += dp((mask | (1 << i)),(rem - t[i]),g[i]); if ( (ans >= MOD)) ans -= MOD; }return memo[last][mask] = ans;} 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); n = in.nextInt(); int T = in.nextInt(); t = new int[n]; g = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = in.nextInt(); g[i] = (in.nextInt() - 1); }memo = new int[4][(1 << n)]; for ( int[] x :memo) {Arrays.fill(x,-1); }out.println(dp(0,T,3)); out.close(); } 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());} } }
6	public class CF1209E2{ public static void main( String[] args)throws Exception { boolean local = (System.getSecurityManager() == null);  boolean async = false;  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; public Task( FastIO io, Debug debug){ this.io = io; this.debug = debug; } @Override public void run(){ int t = io.readInt(); while((t-- > 0))solve(); } int[][] prefix = new int[12][(1 << 12)]; int[][] profits = new int[12][(1 << 12)]; Col[] cols = new Col[2000]; {for ( int i = 0;(i < 2000);i++) {cols[i] = new Col(12); }}public void solve(){ int n = io.readInt();  int m = io.readInt(); for ( int i = 0;(i < m);i++) {cols[i].max = 0; cols[i].n = n; }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {cols[j].data[i] = io.readInt(); cols[j].max = Math.max(cols[j].max,cols[j].data[i]); }}Arrays.sort(cols,0,m,(a,b)->(a.max - b.max)); Col[] cols = Arrays.copyOf(this.cols,Math.min(m,n));  int mask = ((1 << n) - 1);  SubsetGenerator sg = new SubsetGenerator();  SubsetGenerator2 sg2 = new SubsetGenerator2();  BitOperator bo = new BitOperator(); for ( int i = 0;(i < cols.length);i++) {Arrays.fill(profits[i],0); for ( int j = 0;(j < n);j++) {cols[i].rotate(); for ( int k = 0;(k < n);k++) {sg2.values[k] = cols[i].data[k]; }sg2.setSet(mask); while(sg2.hasNext()){profits[i][sg2.next] = Math.max(profits[i][sg2.next],sg2.val); sg2.next(); }}}prefix[0] = profits[0]; for ( int i = 1;(i < cols.length);i++) {for ( int j = 0;(j <= mask);j++) {sg.setSet(j); prefix[i][j] = prefix[(i - 1)][j]; while(sg.hasNext()){ int next = sg.next(); prefix[i][j] = Math.max(prefix[i][j],(profits[i][next] + prefix[(i - 1)][(j ^ next)])); }}}io.cache.append(prefix[(cols.length - 1)][mask]).append('\n'); } } public static class BitOperator{ public long intersect( long x, long y){ return (x & y);} } public static class SubsetGenerator2{ private int[] meanings = new int[33]; private int[] values = new int[33]; private int[] bits = new int[33]; private int remain ; private int next ; private int val ; public void setSet( int set){ int bitCount = 0; while((set != 0)){meanings[bitCount] = (set & -set); bits[bitCount] = 0; set -= meanings[bitCount]; bitCount++; }remain = (1 << bitCount); next = 0; val = 0; } public boolean hasNext(){ return (remain > 0);} private void consume(){ remain = (remain - 1); int i ; for ( i = 0;(bits[i] == 1);i++) {bits[i] = 0; next -= meanings[i]; val -= values[i]; }bits[i] = 1; next += meanings[i]; val += values[i]; } public int next(){ int returned = next; consume(); return returned;} } public static class SubsetGenerator{ private int[] meanings = new int[33]; private int[] bits = new int[33]; private int remain ; private int next ; public void setSet( int set){ int bitCount = 0; while((set != 0)){meanings[bitCount] = (set & -set); bits[bitCount] = 0; set -= meanings[bitCount]; bitCount++; }remain = (1 << bitCount); next = 0; } public boolean hasNext(){ return (remain > 0);} private void consume(){ remain = (remain - 1); int i ; for ( i = 0;(bits[i] == 1);i++) {bits[i] = 0; next -= meanings[i]; }bits[i] = 1; next += meanings[i]; } public int next(){ int returned = next; consume(); return returned;} } public static class Col{ int[] data ; int max ; int n ; public void rotate(){ int end = data[(n - 1)]; System.arraycopy(data,0,data,1,(n - 1)); data[0] = end; } public Col( int n){ data = new int[n]; } } public static class FastIO{ public final StringBuilder cache = new StringBuilder((1 << 13)); private final InputStream is ; private final OutputStream os ; private final Charset charset ; private StringBuilder defaultStringBuf = new StringBuilder((1 << 13)); private byte[] buf = new byte[(1 << 13)]; 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()throws IOException { os.write(cache.toString().getBytes(charset)); os.flush(); cache.setLength(0); } } 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 + " = ")); } } }
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);  TaskE solver = new TaskE(); solver.solve(1,in,out); out.close(); } } class TaskE{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  double[][] probability = in.next2DDoubleArray(n,n);  double[] dp = new double[(1 << n)]; dp[(dp.length - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask >= 0);mask--) { int count = Integer.bitCount(mask); if ( (count <= 1)) continue; double multi = (1. / calc(count)); for ( int i = 0;(i < n);i++) {if ( NumberUtils.checkBit(mask,i)) {for ( int j = (i + 1);(j < n);j++) {if ( NumberUtils.checkBit(mask,j)) {dp[(mask - (1 << j))] += ((multi * probability[i][j]) * dp[mask]); dp[(mask - (1 << i))] += ((multi * probability[j][i]) * dp[mask]); } }} }} double[] answer = new double[n]; for ( int i = 0;(i < n);i++) {answer[i] = dp[(1 << i)]; }out.printLine(ArrayUtils.asList(answer).toArray()); } static private int calc( int x){ return ((x * (x - 1)) / 2);} } 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 & 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 double nextDouble(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } double res = 0; while((!isSpaceChar(c) && (c != '.'))){if ( ((c == 'e') || (c == 'E'))) return (res * Math.pow(10,nextInt())); if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }if ( (c == '.')) {c = read(); double m = 1; while(!isSpaceChar(c)){if ( ((c == 'e') || (c == 'E'))) return (res * Math.pow(10,nextInt())); if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); m /= 10; res += ((c - '0') * m); c = read(); }} return (res * sgn);} public double[] nextDoubleArray( int count){ double[] result = new double[count]; for ( int i = 0;(i < count);i++) {result[i] = nextDouble(); }return result;} public double[][] next2DDoubleArray( int n, int m){ double[][] result = new double[n][]; for ( int i = 0;(i < n);i++) {result[i] = nextDoubleArray(m); }return result;} } class OutputWriter{ 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 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(); } }
3	public class Main{ static int inf = ((int)1e9 + 7); public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); int n = nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); int ans = 0;  boolean b[] = new boolean[n]; Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( !b[i]) {for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) b[j] = true; }ans++; } }pw.println(ans); pw.close(); } static BufferedReader br ; static StringTokenizer st = new StringTokenizer(""); static PrintWriter pw ; static String next()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(br.readLine()); return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(next());} }
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)); } }
5	public class round111A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] coins = new int[n]; for ( int i = 0;(i < n);++i) coins[i] = sc.nextInt(); Arrays.sort(coins); int ans = (int)1e9; for ( int i = 1;(i <= n);++i) { int sum1 = 0;  int c = 0;  int j = (n - 1); for ( j = (n - 1);((j >= 0) && (c < i));--j,++c) {sum1 += coins[j]; } int sum2 = 0; for ( int k = 0;(k <= j);++k) sum2 += coins[k]; if ( (sum1 > sum2)) {System.out.println(i); return ;} }} }
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(); } }
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 solve( int mask){ if ( (mask == ((1 << m) - 1))) return 0; if ( (dp[mask] != -1)) return dp[mask]; int res = oo;  int addOn = 0; for ( int nxt = 0;(nxt < m);nxt++) {if ( (((1 << nxt) & mask) > 0)) continue; addOn += cost[nxt][mask]; }for ( int nxt = 0;(nxt < m);nxt++) {if ( (((1 << nxt) & mask) > 0)) continue; int ret = (addOn + solve((mask | (1 << nxt)))); res = Math.min(res,ret); }return dp[mask] = res;} 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 as{ 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 Exception { Reader sc = new Reader();  StringBuilder finalAnswer = new StringBuilder();  int t = sc.nextInt(); while((t-- > 0)){ int count = 0;  int n = sc.nextInt(); if ( ((n == 2) || (n == 4))) {finalAnswer.append("YES").append('\n'); count++; } if ( (((n % 2) == 0) && (count == 0))) {n /= 2; if ( (((int)Math.sqrt(n) * (int)Math.sqrt(n)) == n)) {finalAnswer.append("YES").append('\n'); count++; } else {n *= 2; }} if ( (((n % 4) == 0) && (count == 0))) {n /= 4; if ( (((int)Math.sqrt(n) * (int)Math.sqrt(n)) == n)) {finalAnswer.append("YES").append('\n'); count++; } } if ( (count == 0)) {finalAnswer.append("NO").append('\n'); } }System.out.println(finalAnswer); } public static long gcd( long a, long b){ while((b > 0)){ long temp = b; b = (a % b); a = temp; }return a;} }
6	public class Code implements Runnable{ public static void main( String[] args)throws IOException { new Thread(new Code()).start(); } private void solve()throws IOException { int n = nextInt(),m = nextInt(); if ( (n > m)) {n ^= m; m ^= n; n ^= m; } int[][][] dp = new int[41][64][64]; for ( int i = 0;(i < 41);++i) for ( int j = 0;(j < 64);++j) for ( int k = 0;(k < 64);++k) dp[i][j][k] = (Integer.MAX_VALUE / 2); for ( int i = 0;(i < 64);++i) dp[0][0][i] = countBit(i); for ( int i = 1;(i <= m);++i) {for ( int cur = 0;(cur < 64);++cur) {for ( int next = 0;(next < 64);++next) {for ( int prev = 0;(prev < 64);++prev) {if ( !isBad(prev,cur,next,n)) {dp[i][cur][next] = min(dp[i][cur][next],(dp[(i - 1)][prev][cur] + countBit(next))); } }}}} int ans = Integer.MAX_VALUE; for ( int i = 0;(i < 64);++i) ans = min(ans,dp[m][i][0]); writer.println(((n * m) - ans)); } private boolean isBit( int bits, int pos){ return ((pos < 0)?false:((bits & (1 << pos)) != 0));} private boolean isBad( int prev, int cur, int next, int count){ for ( int i = 0;(i < count);++i) if ( ((((isBit(cur,(i - 1)) || isBit(cur,i)) || isBit(cur,(i + 1))) || isBit(prev,i)) || isBit(next,i))) return true; return false;} private int countBit( int bits){ int ans = 0; for ( int i = 0;(i < 6);++i) ans += (((bits & (1 << i)) > 0)?1:0); return ans;} 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 Codeforces{ static private boolean greater( long mid, long s){ int sum = 0;  long num = mid; while((num != 0)){sum += (num % 10); num /= 10; }return ((mid - sum) >= s);} public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long n ,s ;  String arr[] = br.readLine().split(" "); n = Long.parseLong(arr[0]); s = Long.parseLong(arr[1]); long l = 1;  long h = n; while((l < h)){ long mid = ((l + h) / 2); if ( greater(mid,s)) {h = mid; } else {l = (mid + 1); }}System.out.println((greater(h,s)?((n - h) + 1):0)); } }
5	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){ Map<Integer,Integer> map = new HashMap(); map.put(0,1); int n = nextInt();  int m = nextInt();  int index = -1;  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); if ( (a[i] == m)) index = i; } int sum = 0; for ( int i = 0;(i < index);i++) {if ( (a[i] < m)) sum--; else sum++; if ( map.containsKey(sum)) {map.put(sum,(map.get(sum) + 1)); } else {map.put(sum,1); }} long ans = 0; for ( int i = index;(i < n);i++) {if ( (a[i] < m)) sum--; else if ( (a[i] > m)) sum++; if ( map.containsKey(sum)) ans += map.get(sum); if ( map.containsKey((sum - 1))) ans += map.get((sum - 1)); }out.print(ans); out.flush(); } }
5	public class p15a{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int t = in.nextInt(); if ( (n == 1)) {System.out.println(2); return ;} house[] all = new house[n]; for ( int i = 0;(i < all.length);i++) {all[i] = new house(in.nextInt(),in.nextInt()); }Arrays.sort(all); int count = 0; for ( int i = 0;(i < all.length);i++) { double left = (all[i].center - ((all[i].side * 1.0) / 2));  double right = (all[i].center + ((all[i].side * 1.0) / 2)); if ( (i == 0)) {count++; double left2 = (all[(i + 1)].center - ((all[(i + 1)].side * 1.0) / 2)); if ( ((right + t) < left2)) {count++; } continue;} if ( (i == (all.length - 1))) {count++; double right2 = (all[(i - 1)].center + ((all[(i - 1)].side * 1.0) / 2)); if ( ((left - t) >= right2)) {count++; } continue;} double left2 = (all[(i + 1)].center - ((all[(i + 1)].side * 1.0) / 2));  double right2 = (all[(i - 1)].center + ((all[(i - 1)].side * 1.0) / 2)); if ( ((right + t) < left2)) {count++; } if ( ((left - t) >= right2)) count++; }System.out.println(count); } } class house implements Comparable<house>{ int center ; int side ; public house( int a, int b){ center = a; side = b; } }
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());} }
3	public class A1{ public static BufferedReader br ; public static StringTokenizer st ; public static String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return st.nextToken();} public static Integer nextInt(){ return Integer.parseInt(next());} 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);} static long finextDoubleMMI_fermat( long n, int M){ return fast_pow(n,(M - 2),M);} static void merge( int[] arr, int l, int m, int r){ int n1 = ((m - l) + 1);  int n2 = (r - m);  int L[] = new int[n1];  int R[] = new int[n2]; for ( int i = 0;(i < n1);++i) L[i] = arr[(l + i)]; for ( int j = 0;(j < n2);++j) R[j] = arr[((m + 1) + j)]; int i = 0,j = 0;  int k = l; while(((i < n1) && (j < n2))){if ( (L[i] <= R[j])) {arr[k] = L[i]; i++; } else {arr[k] = R[j]; j++; }k++; }while((i < n1)){arr[k] = L[i]; i++; k++; }while((j < n2)){arr[k] = R[j]; j++; k++; }} static void sort( int[] arr, int l, int r){ if ( (l < r)) { int m = ((l + r) / 2); sort(arr,l,m); sort(arr,(m + 1),r); merge(arr,l,m,r); } } static void sort( int[] arr){ int l = 0;  int r = (arr.length - 1); if ( (l < r)) { int m = ((l + r) / 2); sort(arr,l,m); sort(arr,(m + 1),r); merge(arr,l,m,r); } } static long gcd( long a, long b){ if ( ((a % b) == 0)) return b; if ( ((b % a) == 0)) return a; if ( (a > b)) return gcd((a % b),b); return gcd(a,(b % a));} static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); public static void main( String[] args)throws IOException { int i ,j ; br = new BufferedReader(new InputStreamReader(System.in)); int n = nextInt();  int a[] = new int[n]; for ( i = 0;(i < n);i++) a[i] = nextInt(); Arrays.sort(a); int l = 0; for ( i = 0;(i < n);i++) {if ( (a[i] != -1)) { int p = a[i]; for ( j = i;(j < n);j++) {if ( ((a[j] % p) == 0)) a[j] = -1; }l++; } }pw.println(l); pw.close(); } }
6	public class G{ static private int M = 1000000007,MM = 998244353; static private int N = 15,n ,T ; static private int[] time ,gi ; static private int[][][] dp ; public static void process()throws IOException { n = sc.nextInt(); T = sc.nextInt(); time = new int[(n + 1)]; gi = new int[(n + 1)]; for ( int i = 0;(i < n);i++) { int a = sc.nextInt(),b = sc.nextInt(); time[i] = a; gi[i] = (b - 1); }dp = new int[(1 << n)][(T + 1)][3]; for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < (T + 1));j++) {for ( int k = 0;(k < 3);k++) dp[i][j][k] = -1; }} int ans = 0; for ( int i = 0;(i < n);i++) {if ( (time[i] <= T)) {ans = ((ans + solve((1 << i),time[i],gi[i])) % M); } }println(ans); } static private int solve( int mask, int tim, int code){ if ( (tim == T)) return 1; if ( (dp[mask][tim][code] != -1)) return dp[mask][tim][code]; int ans = 0; for ( int i = 0;(i < n);i++) {if ( (((mask >> i) & 1) > 0)) continue; if ( (code == gi[i])) continue; if ( ((tim + time[i]) > T)) continue; ans = ((ans + solve((mask | (1 << i)),(time[i] + tim),gi[i])) % M); }return dp[mask][tim][code] = (ans % M);} static FastScanner sc ; static PrintWriter out ; public static void main( String[] args)throws IOException { boolean oj = true; if ( oj) {sc = new FastScanner(); out = new PrintWriter(System.out); } else {sc = new FastScanner(100); out = new PrintWriter("output.txt"); } int t = 1; while((t-- > 0)){process(); }out.flush(); out.close(); } static void println( Object o){ out.println(o); } static void println(){ out.println(); } static void print( Object o){ out.print(o); } static int max( int x, int y){ return Math.max(x,y);} static int min( int x, int y){ return Math.min(x,y);} static int abs( int x){ return Math.abs(x);} static long abs( long x){ return Math.abs(x);} static long max( long x, long y){ return Math.max(x,y);} static long min( long x, long y){ return Math.min(x,y);} public static int gcd( int a, int b){ BigInteger b1 = BigInteger.valueOf(a);  BigInteger b2 = BigInteger.valueOf(b);  BigInteger gcd = b1.gcd(b2); return gcd.intValue();} public static long gcd( long a, long b){ BigInteger b1 = BigInteger.valueOf(a);  BigInteger b2 = BigInteger.valueOf(b);  BigInteger gcd = b1.gcd(b2); return gcd.longValue();} static class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner()throws FileNotFoundException{ br = new BufferedReader(new InputStreamReader(System.in)); } FastScanner( int a)throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt")); } String next()throws IOException { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} long nextLong()throws IOException { return Long.parseLong(next());} } }
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(); } }
1	public class Test{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int x = (int)Math.sqrt(n);  int a[] = new int[(n + 5)]; for ( int i = 1,o = n,j ;(i <= n);i += x) for ( j = (int)Math.min(((i + x) - 1),n);(j >= i);a[j--] = o--) ;for ( int i = 1;(i <= n);i++) System.out.print((a[i] + " ")); System.out.println(); } }
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); } }
1	public class A{ static private int[] prime = 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}; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt(); for ( int i = 0;(i < (prime.length - 1));i++) {if ( ((((prime[i] + prime[(i + 1)]) + 1) > n) || (k == 0))) break; if ( isPrime(((prime[i] + prime[(i + 1)]) + 1))) k--; }if ( (k == 0)) outnl("YES"); else outnl("NO"); } public static boolean isPrime( int x){ int i = 0; while((i < prime.length))if ( (prime[i++] == x)) return true; return false;} static private void outnl( String out){ System.out.println(out); } }
5	public class Main{ public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int k = (scan.nextInt() - 1);  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) { int p = scan.nextInt();  int t = scan.nextInt(); arr[i] = ((-p * 10000) + t); }Arrays.sort(arr); int count = 0; for ( int i = 0;(i < n);i++) {if ( (arr[i] == arr[k])) {count++; } }System.out.println(count); } }
2	public class A{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(in.readLine()); }catch (Exception e){ } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} int n ,x ,y ,c ; long cnt( int m){ long ret = 0; for ( int i = max(1,(y - m));(i <= min(n,(y + m)));i++) { int x1 = max(1,(x - (m - abs((i - y)))));  int x2 = min(n,(x + (m - abs((i - y))))); ret += ((x2 - x1) + 1); }return ret;} public void run(){ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); n = nextInt(); x = nextInt(); y = nextInt(); c = nextInt(); int l = 0,r = 1000000;  int ans = 0; while((l <= r)){ int m = ((l + r) / 2); if ( (cnt(m) >= c)) {ans = m; r = (m - 1); } else l = (m + 1); }out.println(ans); out.close(); } int sign( long x){ if ( (x < 0)) return -1; if ( (x > 0)) return 1; return 0;} public static void main( String[] args)throws Exception { new A().run(); } }
5	public class TaskA{ BufferedReader br ; PrintWriter out ; StringTokenizer stok ; String nextToken()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return "-1";} stok = new StringTokenizer(s); }return stok.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }Arrays.sort(a); a[(n - 1)] = ((a[(n - 1)] == 1)?2:1); Arrays.sort(a); for ( int i = 0;(i < n);i++) {out.print(a[i]); out.print(' '); }} void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); br.close(); out.close(); } public static void main( String[] args)throws IOException { new TaskA().run(); } }
3	public class D{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = na(n);  int[] ft = new int[(n + 3)];  int x = 0; for ( int i = (n - 1);(i >= 0);i--) {x ^= sumFenwick(ft,a[i]); addFenwick(ft,a[i],1); }x &= 1; for ( int Q = ni();(Q > 0);Q--) { int l = ni(),r = ni();  long u = ((((r - l) + 1) * (r - l)) / 2); x ^= (u & 1); if ( (x == 0)) {out.println("even"); } else {out.println("odd"); }}} public static int sumFenwick( int[] ft, int i){ int sum = 0; for ( i++;(i > 0);i -= (i & -i)) sum += ft[i]; return sum;} public static void addFenwick( int[] ft, int i, int v){ if ( ((v == 0) || (i < 0))) return ; int n = ft.length; for ( i++;(i < n);i += (i & -i)) ft[i] += v; } public static int findGFenwick( int[] ft, int v){ int i = 0;  int n = ft.length; for ( int b = Integer.highestOneBit(n);((b != 0) && (i < n));b >>= 1) {if ( ((i + b) < n)) { int t = (i + b); if ( (v >= ft[t])) {i = t; v -= ft[t]; } } }return ((v != 0)?(i + 1):(i - 1));} 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 D().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 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{ final int MOD = (int)(1e9 + 7); long[][] C ; long[] fact ; public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt(); precalc(n); int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); a[i] = removeSquares(a[i]); } int[] g = getGroupSizes(a);  long ans = solve(g); for ( int x :g) {ans = ((ans * fact[x]) % MOD); }out.println(ans); } private long solve( int[] a){ long[] d = new long[1]; d[0] = 1; int totalPositions = 1; for ( int x :a) { long[] nd = new long[((d.length + x) + 1)]; for ( int s = 0;(s < d.length);s++) {if ( (d[s] == 0)) {continue;} for ( int m = 1;(m <= x);m++) {for ( int p = 0;((p <= s) && (p <= m));p++) { long cur = d[s]; cur = ((cur * C[s][p]) % MOD); cur = ((cur * C[(totalPositions - s)][(m - p)]) % MOD); cur = ((cur * f(x,m)) % MOD); int ns = (((s + x) - m) - p); nd[ns] += cur; if ( (nd[ns] >= MOD)) {nd[ns] -= MOD; } }}}totalPositions += x; d = nd; }return d[0];} private long f( int n, int k){ if ( (n < k)) {return 0;} n -= k; return C[((n + k) - 1)][(k - 1)];} private void precalc( int n){ fact = new long[(n + 1)]; fact[0] = 1; for ( int i = 1;(i < fact.length);i++) {fact[i] = ((i * fact[(i - 1)]) % MOD); }C = new long[1000][1000]; 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 - 1)] + C[(i - 1)][j]); if ( (C[i][j] >= MOD)) {C[i][j] -= MOD; } }}} private int[] getGroupSizes( int[] a){ Arrays.sort(a); List<Integer> res = new ArrayList<>(); for ( int i = 0;(i < a.length);) { int j = i; while(((j < a.length) && (a[i] == a[j]))){++j; }res.add((j - i)); i = j; } int[] r = new int[res.size()]; for ( int i = 0;(i < r.length);i++) {r[i] = res.get(i); }return r;} private int removeSquares( int n){ int res = 1; for ( int d = 2;((d * d) <= n);d++) {if ( ((n % d) == 0)) { int cur = 0; while(((n % d) == 0)){n /= d; ++cur; }if ( ((cur % 2) == 1)) {res *= d; } } }if ( (n > 1)) {res *= n; } return res;} } 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());} } }
5	public class Main{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; void solve()throws IOException { int n = ni();  int t = ni();  int[] center = new int[n];  int[] width = new int[n]; for ( int i = 0;(i < n);i++) {center[i] = ni(); width[i] = ni(); }for ( int i = 0;(i < n);i++) {for ( int j = i;(j < n);j++) {if ( (center[i] > center[j])) { int cent = center[i];  int wid = width[i]; center[i] = center[j]; width[i] = width[j]; center[j] = cent; width[j] = wid; } }} int count = 2; for ( int i = 0;(i < (n - 1));i++) { double ideal = ((((double)width[i] / 2) + ((double)width[(i + 1)] / 2)) + t);  double real = (center[(i + 1)] - center[i]); if ( (ideal == real)) count++; else {if ( (ideal < real)) count = (count + 2); }}out.println(count); } public Main()throws IOException{ Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } String ns()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int ni()throws IOException { return Integer.valueOf(ns());} public static void main( String[] args)throws IOException { new Main(); } }
0	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));  int n = Integer.parseInt(in.readLine()); if ( (n == 0)) {System.out.println("0 0 0"); return ;} int p2 = 0;  int p1 = 1; while(true){ int now = (p2 + p1); if ( (n == now)) {System.out.println(((("0 " + p1) + " ") + p2)); return ;} else {p2 = p1; p1 = now; }}} }
5	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(" ");  int n = Integer.parseInt(str.substring(0,blank));  int m = Integer.parseInt(str.substring((blank + 1)));  long[] num = new long[n];  int j = 0;  int s = 0;  int k = 0; str = br.readLine(); int length = str.length(); while((j < length)){while((j < length)){if ( (str.charAt(j) == ' ')) {break;} else {j++; }}num[k] = Long.parseLong(str.substring(s,j)); k++; j++; s = j; }Arrays.sort(num); int count = 0; if ( (m == 1)) {count = 1; for ( int i = 1;(i < n);i++) {if ( (num[i] != num[(i - 1)])) {count++; } }} else { TreeSet<Long> take = new TreeSet<Long>();  TreeSet<Long> notTake = new TreeSet<Long>(); for ( int i = 0;(i < n);i++) { long temp = num[i]; if ( !notTake.contains(temp)) {take.add(temp); temp *= (long)m; notTake.add(temp); } }count = take.size(); }bos.write(new Integer(count).toString().getBytes()); bos.write(eolb); bos.flush(); }catch (IOException ioe){ ioe.printStackTrace(); } } }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); System.out.println(((3 * n) / 2)); } }
2	public class Main{ long sum( long n){ return ((n * (n + 1)) / 2);} public void solve()throws Exception { Scanner in = new Scanner(System.in);  long n = (in.nextLong() - 1);  long k = (in.nextLong() - 1);  long lo = 0,hi = k,mi ; while((lo < hi)){mi = ((lo + hi) / 2); if ( ((sum(k) - sum(((k - mi) - 1))) <= n)) lo = (mi + 1); else hi = mi; } long ans = lo; n -= (sum(k) - sum((k - ans))); k -= ans; if ( (n > k)) println("-1"); else if ( (n == 0)) println(ans); else println((ans + 1)); } public static void main( String[] args)throws Exception { new Main().solve(); } public static void print( Object o){ System.out.print(o); } public static void println( Object o){ System.out.println(o); } public static void println(){ System.out.println(); } }
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));} PandaScanner in = new PandaScanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  C solver = new C(); solver.solve(1,in,out); out.close(); } } class C{ final int dx[] = {-1,0,1,0}; final int dy[] = {0,-1,0,1}; final int SHIFT = 15; final int COLUMN_MASK = ((1 << SHIFT) - 1); public void solve( int testNumber, PandaScanner in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  boolean burning[][] = new boolean[n][m];  int k = in.nextInt();  ArrayDeque<Integer> q = new ArrayDeque<>(); for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); burning[x][y] = true; q.add(((x << SHIFT) + y)); } int last = 0; while(!q.isEmpty()){last = q.poll(); int x = (last >> SHIFT);  int y = (last & COLUMN_MASK); for ( int d = 0;(d < 4);d++) { int nx = (x + dx[d]);  int ny = (y + dy[d]); if ( (((((nx >= 0) && (nx < n)) && (ny >= 0)) && (ny < m)) && !burning[nx][ny])) {burning[nx][ny] = true; q.add(((nx << SHIFT) + ny)); } }}out.printf("%d %d\n",((last >> SHIFT) + 1),((last & COLUMN_MASK) + 1)); } } class PandaScanner{ public BufferedReader br ; public StringTokenizer st ; public InputStream in ; public PandaScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(this.in = in)); } public String nextLine(){ try{return br.readLine(); }catch (Exception e){ return null;} } public String next(){ if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(nextLine().trim()); return next();} return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
4	public class E2_SquareFreeDivision2{ static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ int T = sc.nextInt();  int MAX = (int)1e7;  int[] canonical = new int[(MAX + 1)]; canonical[1] = 1; for ( int factor = 2;(factor <= MAX);factor++) {if ( (canonical[factor] == 0)) {for ( int mult = factor;(mult <= MAX);mult += factor) { int prev = canonical[(mult / factor)]; if ( ((prev % factor) == 0)) {canonical[mult] = (prev / factor); } else {canonical[mult] = (prev * factor); }}} } int[] freq = new int[(MAX + 1)]; while((T-- > 0)){ int N = sc.nextInt();  int K = sc.nextInt();  int[] a = new int[(N + 1)]; for ( int i = 1;(i <= N);i++) {a[i] = canonical[sc.nextInt()]; } int[][] transition = new int[(K + 1)][(N + 1)]; for ( int k = 0;(k <= K);k++) { int l = (N + 1);  int duplicates = 0; for ( int r = N;(r >= 1);r--) {while(((l - 1) >= 1)){ int nextDuplicates = duplicates; if ( (freq[a[(l - 1)]] >= 1)) {nextDuplicates++; } if ( (nextDuplicates <= k)) {duplicates = nextDuplicates; freq[a[(l - 1)]]++; l--; } else {break;}}transition[k][r] = l; if ( (--freq[a[r]] >= 1)) {duplicates--; } }} int[][] dp = new int[(K + 1)][(N + 1)];  int oo = (int)1e9; for ( int[] row :dp) {Arrays.fill(row,oo); }for ( int k = 0;(k <= K);k++) {dp[k][0] = 0; }for ( int r = 1;(r <= N);r++) {for ( int k = 0;(k <= K);k++) {for ( int delta = 0;(delta <= k);delta++) {dp[k][r] = min(dp[k][r],(dp[(k - delta)][(transition[delta][r] - 1)] + 1)); }}}out.println(dp[K][N]); }out.close(); } 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); } } 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++];} int nextInt(){ return (int)nextLong();} 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);} } }
0	public class cf{ static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ try{br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } public String next(){ if ( st.hasMoreTokens()) return st.nextToken(); try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt(); pw.println(((n / 2) + 1)); pw.close(); } }
6	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);  F solver = new F(); solver.solve(1,in,out); out.close(); } static class F{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.ni(),m = in.ni();  int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) {a[i] = in.na(m); }if ( (n == 1)) { int ans = Integer.MAX_VALUE; for ( int i = 1;(i < m);i++) {ans = Math.min(ans,Math.abs((a[0][i] - a[0][(i - 1)]))); }out.println(ans); return ;} int[][] mk = new int[n][n];  int[][] mk1 = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) { int minK = Integer.MAX_VALUE;  int minK1 = Integer.MAX_VALUE;  int minK2 = Integer.MAX_VALUE; for ( int l = 0;(l < m);l++) {minK = Math.min(minK,Math.abs((a[i][l] - a[j][l]))); if ( (l > 0)) {minK1 = Math.min(minK1,Math.abs((a[i][l] - a[j][(l - 1)]))); minK2 = Math.min(minK2,Math.abs((a[i][(l - 1)] - a[j][l]))); } }mk[i][j] = mk[j][i] = minK; mk1[i][j] = minK1; mk1[j][i] = minK2; }} int ans = 0; for ( int first = 0;(first < n);first++) { int[][] dp = new int[(1 << n)][n]; for ( int mask = 1;(mask < ((1 << n) - 1));mask++) { int bc = Integer.bitCount(mask); if ( ((mask & (1 << first)) != 0)) {if ( (bc == 1)) {dp[mask][first] = Integer.MAX_VALUE; } for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {for ( int j = 0;(j < n);j++) {if ( ((mask & (1 << j)) == 0)) {dp[(mask | (1 << j))][j] = Math.max(dp[(mask | (1 << j))][j],Math.min(dp[mask][i],mk[i][j])); } }} }} }for ( int i = 0;(i < n);i++) {if ( (i != first)) {ans = Math.max(ans,Math.min(dp[((1 << n) - 1)][i],mk1[first][i])); } }}out.println(ans); } } static class FastScanner{ private BufferedReader in ; private StringTokenizer st ; public FastScanner( InputStream stream){ in = new BufferedReader(new InputStreamReader(stream)); } public String ns(){ while(((st == null) || !st.hasMoreTokens())){try{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int ni(){ return Integer.parseInt(ns());} public int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} } }
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();} } }
0	public class Solution{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(); out.print(((n / 2) + n)); out.close(); in.close(); } }
0	public class A{ public static void main( String[] args)throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  String s = r.readLine();  int n = Integer.parseInt(s); System.out.println(((n * 3) / 2)); } }
1	public class ErrorCorrectSystem{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  String a = scan.next();  String b = scan.next();  int[][] mismatch = new int[26][26]; for ( int i = 0;(i < 26);i++) Arrays.fill(mismatch[i],-1); int[][] pair = new int[2][26]; for ( int i = 0;(i < 2);i++) Arrays.fill(pair[i],-1); int hd = 0; for ( int i = 0;(i < n);i++) {if ( (a.charAt(i) != b.charAt(i))) {hd++; mismatch[(a.charAt(i) - 'a')][(b.charAt(i) - 'a')] = i; pair[0][(a.charAt(i) - 'a')] = i; pair[1][(b.charAt(i) - 'a')] = i; } }for ( int i = 0;(i < 26);i++) {for ( int j = (i + 1);(j < 26);j++) {if ( ((mismatch[i][j] > -1) && (mismatch[j][i] > -1))) {System.out.println((hd - 2)); System.out.println((((mismatch[i][j] + 1) + " ") + (mismatch[j][i] + 1))); return ;} }}for ( int i = 0;(i < n);i++) {if ( (a.charAt(i) != b.charAt(i))) {if ( (pair[0][(b.charAt(i) - 'a')] > -1)) {System.out.println((hd - 1)); System.out.println((((i + 1) + " ") + (pair[0][(b.charAt(i) - 'a')] + 1))); return ;} } }System.out.println(hd); System.out.println("-1 -1"); } }
6	public class CF1238E{ public static void main( String[] args)throws Exception { boolean local = (System.getSecurityManager() == null);  boolean async = false;  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; double dInf = 1e50; public Task( FastIO io, Debug debug){ this.io = io; this.debug = debug; } @Override public void run(){ solve(); } int[][] fee ; int m ; long[] dp ; int mask ; int[][] maskFee ; public void solve(){ int n = io.readInt(); m = io.readInt(); char[] s = new char[n]; io.readString(s,0); for ( int i = 0;(i < n);i++) {s[i] -= 'a'; }fee = new int[m][m]; for ( int i = 1;(i < n);i++) {fee[s[i]][s[(i - 1)]]++; fee[s[(i - 1)]][s[i]]++; }mask = ((1 << m) - 1); maskFee = new int[m][(mask + 1)]; SubsetGenerator sg = new SubsetGenerator(); for ( int i = 0;(i < m);i++) {for ( int j = 0;(j < m);j++) {sg.meanings[j] = fee[i][j]; }for ( int j = 0;(j <= mask);j++) {maskFee[i][j] = sg.next(); }}dp = new long[(mask + 1)]; Arrays.fill(dp,-1); dp[0] = 0; io.cache.append(dp(mask)); } BitOperator bo = new BitOperator(); public long dp( int s){ if ( (dp[s] == -1)) { long extra = 0;  int remainSet = (mask - s); for ( int j = 0;(j < m);j++) {if ( (bo.bitAt(s,j) == 0)) {continue;} extra += maskFee[j][remainSet]; }dp[s] = lInf; for ( int j = 0;(j < m);j++) {if ( (bo.bitAt(s,j) == 0)) {continue;} int ss = bo.setBit(s,j,false); dp[s] = Math.min(dp[s],(extra + dp(ss))); }} return dp[s];} } public static class BitOperator{ public int bitAt( int x, int i){ return ((x >> i) & 1);} public int bitAt( long x, int i){ return (int)((x >> i) & 1);} public int setBit( int x, int i, boolean v){ if ( v) {x |= (1 << i); } else {x &= (1 << i); }return x;} public long setBit( long x, int i, boolean v){ if ( v) {x |= (1L << i); } else {x &= (1L << i); }return x;} public long intersect( long x, long y){ return (x & y);} } public static class SubsetGenerator{ private int[] meanings = new int[33]; private int[] bits = new int[33]; private int remain ; private int next ; private void consume(){ remain = (remain - 1); int i ; for ( i = 0;(bits[i] == 1);i++) {bits[i] = 0; next -= meanings[i]; }bits[i] = 1; next += meanings[i]; } public int next(){ int returned = next; consume(); return returned;} } public static class FastIO{ public final StringBuilder cache = new StringBuilder((1 << 13)); private final InputStream is ; private final OutputStream os ; private final Charset charset ; private StringBuilder defaultStringBuf = new StringBuilder((1 << 13)); private byte[] buf = new byte[(1 << 13)]; 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()throws IOException { os.write(cache.toString().getBytes(charset)); os.flush(); cache.setLength(0); } } 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 CFDiv1{ FastScanner in ; PrintWriter out ; boolean canBe( int from, long curVal, long l, long r){ if ( (curVal > r)) return false; for ( int i = 0;(i <= from);i++) curVal += (1L << i); if ( (curVal >= l)) return true; return false;} long solve2( long l, long r){ long min = 0;  long max = 0; for ( int i = 62;(i >= 0);i--) { boolean max0 = canBe((i - 1),max,l,r);  boolean max1 = canBe((i - 1),(max | (1L << i)),l,r);  boolean min0 = canBe((i - 1),min,l,r);  boolean min1 = canBe((i - 1),(min | (1L << i)),l,r); if ( ((max0 && min1) && (max > min))) {min = (min | (1L << i)); } else {if ( (max1 && min0)) {max |= (1L << i); } else {if ( (max1 && min1)) {max |= (1L << i); min |= (1L << i); } else {}}}}return (min ^ max);} void solve(){ out.println(solve2(in.nextLong(),in.nextLong())); } void runIO(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } class FastScanner{ BufferedReader br ; 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)); } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} long nextLong(){ return Long.parseLong(next());} } public static void main( String[] args){ new CFDiv1().runIO(); } }
0	public class SolutionB{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int a[] = new int[1501]; for ( int i = 0;(i < 3);i++) {a[sc.nextInt()]++; }if ( ((((a[1] > 0) || (a[2] > 1)) || (a[3] > 2)) || ((a[4] == 2) && (a[2] == 1)))) {System.out.println("YES"); } else {System.out.println("NO"); }} }
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(); } static private long nextLong()throws NumberFormatException,IOException { return Long.parseLong(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
6	public class CF11D{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  boolean[][] map = new boolean[n][n];  long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < m);i++) { int a = (sc.nextInt() - 1);  int b = (sc.nextInt() - 1); map[a][b] = map[b][a] = true; dp[((1 << a) + (1 << b))][Math.max(a,b)] = 1; } long ans = 0; for ( int mask = 1;(mask < (1 << n));mask++) { int lowbit = 0; for ( ;((mask & (1 << lowbit)) == 0);lowbit++) ;for ( int i = (lowbit + 1);(i < n);i++) {if ( ((mask & (1 << i)) == 0)) {continue;} for ( int j = (lowbit + 1);(j < n);j++) {if ( (((mask & (1 << j)) == 0) || (j == i))) {continue;} if ( map[i][j]) {dp[mask][i] += dp[(mask ^ (1 << i))][j]; } }if ( map[lowbit][i]) {ans += dp[mask][i]; } }}System.out.println(((ans - m) / 2)); sc.close(); } }
5	public class A{ static class Sort implements Comparable<Sort>{ int x ,a ; } public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  Sort[] a = new Sort[n]; for ( int i = 0;(i < n);i++) {a[i] = new Sort(); a[i].x = sc.nextInt(); a[i].a = sc.nextInt(); }Arrays.sort(a); int ans = 2; for ( int i = 1;(i < n);i++) { double d = (((a[i].x - (a[i].a / 2.0)) - a[(i - 1)].x) - (a[(i - 1)].a / 2.0)); if ( (d == t)) ans++; else if ( (d > t)) ans += 2; }System.out.println(ans); } }
1	public class pr1073B{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int n = Integer.parseInt(br.readLine());  int[] a = new int[n];  int[] b = new int[n];  StringTokenizer st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(st.nextToken()); }st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {b[i] = Integer.parseInt(st.nextToken()); }solve(n,a,b,out); out.flush(); out.close(); } static private void solve( int n, int[] a, int[] b, PrintWriter out){ boolean[] book = new boolean[(n + 1)];  boolean f ;  int j1 = 0,j2 = 0; for ( int i = 0;(i < n);i++) {f = false; int num = b[i]; if ( !book[num]) {f = true; j1 = j2; for ( ;(j2 < n);j2++) {book[a[j2]] = true; if ( (a[j2] == num)) {j2++; break;} }} out.print((f?((j2 - j1) + " "):(0 + " "))); }} }
6	public class ProblemC_008 implements Runnable{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; OutputWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new ProblemC_008(),"",(128 * (1L << 20))).start(); } void init()throws FileNotFoundException { Locale.setDefault(Locale.US); if ( 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"); }} long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } String delim = " "; String readString()throws IOException { while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken(delim);} String readLine()throws IOException { return in.readLine();} final char NOT_A_SYMBOL = '\0'; int readInt()throws IOException { return Integer.parseInt(readString());} long readLong()throws IOException { return Long.parseLong(readString());} double readDouble()throws IOException { return Double.parseDouble(readString());} Point readPoint()throws IOException { return new Point(readInt(),readInt());} class OutputWriter extends PrintWriter{ final int DEFAULT_PRECISION = 12; int precision ; String format ,formatWithSpace ; {precision = DEFAULT_PRECISION; format = createFormat(precision); formatWithSpace = (format + " "); }public OutputWriter( OutputStream out){ super(out); } public OutputWriter( String fileName)throws FileNotFoundException{ super(fileName); } private String createFormat( int precision){ return (("%." + precision) + "f");} @Override public void print( double d){ printf(format,d); } public void printWithSpace( double d){ printf(formatWithSpace,d); } public 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); } public void printlnAll( double... d){ printAll(d); println(); } } int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; void solve()throws IOException { Point bag = readPoint();  int n = readInt();  Point[] points = new Point[n]; for ( int i = 0;(i < n);++i) {points[i] = readPoint(); } int[] dist = new int[n]; for ( int i = 0;(i < n);++i) { int dx = (points[i].x - bag.x);  int dy = (points[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 = (points[i].x - points[j].x);  int dy = (points[i].y - points[j].y); d[i][j] = ((dx * dx) + (dy * dy)); d[i][j] += (dist[i] + dist[j]); }} int[] singleMasks = new int[n]; for ( int i = 0;(i < n);++i) {singleMasks[i] = (1 << i); } int[][] doubleMasks = new int[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {doubleMasks[i][j] = (singleMasks[i] | singleMasks[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"); } private boolean checkBit( int mask, int bitNumber){ return ((mask & (1 << bitNumber)) != 0);} }
3	public class Codeshefcode{ public static void main( String[] args)throws IOException { new Thread(null,new Runnable(){},"Solver",(1l << 27)).start(); } } class Solver{ Reader ip = new Reader(System.in); PrintWriter op = new PrintWriter(System.out); public void Solve()throws IOException { int n = ip.i();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ip.i(); int num = 0; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( (a[i] > a[j])) num++; num %= 2; int m = ip.i(); while((m-- != 0)){ int l = ip.i();  int r = ip.i();  int d = ((r - l) + 1);  int mod = (d % 4);  int bit ; if ( (mod <= 1)) bit = 0; else bit = 1; num += bit; num %= 2; pln(((num == 1)?"odd":"even")); }} void Finish(){ op.flush(); op.close(); } void pln( Object o){ op.println(o); } } class Reader{ BufferedReader reader ; StringTokenizer tokenizer ; Reader( InputStream input){ reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); } String s()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} int i()throws IOException { return Integer.parseInt(s());} }
4	public class Main{ public static void main( String[] args)throws IOException { Scanner scn = new Scanner(new File("input.txt"));  BufferedWriter out = new BufferedWriter(new FileWriter("output.txt"));  int r = scn.nextInt();  int c = scn.nextInt();  int[][] a = new int[r][c]; for ( int[] i :a) Arrays.fill(i,(1 << 30)); int k = scn.nextInt();  Queue<State> q = new LinkedList<State>(); for ( int l = 0;(l < k);l++) { int i = (scn.nextInt() - 1);  int j = (scn.nextInt() - 1); a[i][j] = 0; q.add(new State(i,j,0)); }while(!q.isEmpty()){ State st = q.poll(); a[st.i][st.j] = st.c; for ( int d = 0;(d < 4);d++) { int ii = (st.i + di[d]);  int jj = (st.j + dj[d]); if ( ((((ii < 0) || (ii >= r)) || (jj < 0)) || (jj >= c))) continue; if ( (a[ii][jj] != (1 << 30))) continue; a[ii][jj] = (st.c + 1); q.add(new State(ii,jj,(st.c + 1))); }} int max = 0; for ( int i = 0;(i < r);i++) for ( int j = 0;(j < c);j++) max = Math.max(max,a[i][j]); for ( int i = 0;(i < r);i++) for ( int j = 0;(j < c);j++) if ( (a[i][j] == max)) {out.write((((i + 1) + " ") + (j + 1))); out.newLine(); out.close(); return ;} } static int[] di = {0,0,-1,1}; static int[] dj = {1,-1,0,0}; } class State{ int i ,j ,c ; public State( int ii, int ji, int ci){ i = ii; j = ji; c = ci; } }
4	public class TaskC extends Thread{ public TaskC(){ try{this.input = new BufferedReader(new FileReader("input.txt")); this.output = new PrintWriter("output.txt"); this.setPriority(Thread.MAX_PRIORITY); }catch (Throwable e){ System.exit(666); } } private void solve()throws Throwable { int n = nextInt();  int m = nextInt();  int k = nextInt();  Queue<Integer> qX = new ArrayDeque<Integer>();  Queue<Integer> qY = new ArrayDeque<Integer>();  boolean[][] was = new boolean[n][m]; for ( int i = 0;(i < k);++i) { int x = (nextInt() - 1),y = (nextInt() - 1); qX.add(x); qY.add(y); was[x][y] = true; } int lastX = -1,lastY = -1; while(!qX.isEmpty()){lastX = qX.poll(); lastY = qY.poll(); for ( int i = 0;(i < dx.length);++i) { int nextX = (lastX + dx[i]),nextY = (lastY + dy[i]); if ( (((((nextX < n) && (nextY < m)) && (nextX >= 0)) && (nextY >= 0)) && !was[nextX][nextY])) {qX.add(nextX); qY.add(nextY); was[nextX][nextY] = true; } }}++lastX; ++lastY; output.println(((lastX + " ") + lastY)); } public static void main( String[] args){ new TaskC().start(); } private int nextInt()throws IOException { return Integer.parseInt(nextToken());} private String nextToken()throws IOException { while(((tokens == null) || !tokens.hasMoreTokens())){tokens = new StringTokenizer(input.readLine()); }return tokens.nextToken();} static final int PRIME = 3119; static final int[] dx = {1,-1,0,0},dy = {0,0,-1,1}; private BufferedReader input ; private PrintWriter output ; private StringTokenizer tokens = null; }
6	public class Main{ 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 Hexadecimaltheorem{ public static void main( String[] args){ BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));  int x ;  ArrayList<Integer> arr = new ArrayList<Integer>(); arr.add(0); arr.add(1); try{while(((x = Integer.parseInt(buf.readLine())) != -1)){if ( (x == 1)) {System.out.println(((((arr.get(0) + " ") + arr.get(0)) + " ") + arr.get(1))); } else if ( (x == 0)) {System.out.println(((((arr.get(0) + " ") + arr.get(0)) + " ") + arr.get(0))); } else { int i = 1; while((x > arr.get((arr.size() - 1)))){arr.add((arr.get(i) + arr.get((i - 1)))); i++; }System.out.println(((((arr.get(0) + " ") + arr.get((i - 2))) + " ") + arr.get((i - 1)))); }} }catch (NumberFormatException e){ e.printStackTrace(); } catch (IOException e){ e.printStackTrace(); } } }
2	public class Main{ public static long howMany( long n, long x, long y, long s){ long res = 0;  int cnt = 0;  long[] px = new long[9];  long[] py = new long[9]; if ( ((x - s) < 1)) {px[cnt] = 1; py[cnt++] = (((((y - x) + s) + 1) <= n)?(((y - x) + s) + 1):n); px[cnt] = 1; py[cnt++] = (((((x + y) - s) - 1) > 0)?(((x + y) - s) - 1):1); res += 6; } else {px[cnt] = (x - s); py[cnt++] = y; res += 2; }if ( ((y - s) < 1)) {py[cnt] = 1; px[cnt++] = (((((x + y) - s) - 1) > 0)?(((x + y) - s) - 1):1); py[cnt] = 1; px[cnt++] = ((((x - (y - s)) + 1) <= n)?(((x - y) + s) + 1):n); res += 6; } else {px[cnt] = x; py[cnt++] = (y - s); res += 2; }if ( ((x + s) > n)) {px[cnt] = n; py[cnt++] = ((((y - (x + s)) + n) > 0)?((y - (x + s)) + n):1); px[cnt] = n; py[cnt++] = (((((x + s) + y) - n) <= n)?(((x + s) + y) - n):n); res += 6; } else {px[cnt] = (x + s); py[cnt++] = y; res += 2; }if ( ((y + s) > n)) {py[cnt] = n; px[cnt++] = (((((x + y) + s) - n) <= n)?(((x + y) + s) - n):n); py[cnt] = n; px[cnt++] = (((n - ((y + s) - x)) > 0)?(n - ((y + s) - x)):1); res += 6; } else {px[cnt] = x; py[cnt++] = (y + s); res += 2; }px[cnt] = px[0]; py[cnt] = py[0]; long ret = 0;  long sum = 0; for ( int i = 0;(i < cnt);i++) {ret += ((px[i] * py[(i + 1)]) - (py[i] * px[(i + 1)])); sum += (Math.max(Math.abs((px[i] - px[(i + 1)])),Math.abs((py[i] - py[(i + 1)]))) + 1); }return ((((4 * ret) + (4 * sum)) - res) / 8);} public static void main( String[] args)throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer str = new StringTokenizer(r.readLine());  int n = Integer.parseInt(str.nextToken());  int x = Integer.parseInt(str.nextToken());  int y = Integer.parseInt(str.nextToken());  long c = Long.parseLong(str.nextToken()); if ( (c == 1)) {System.out.println(0); return ;} long high = 1; while((howMany(n,x,y,high) < c)){high <<= 1; } long low = (high >> 1); while(((high - low) > 1)){ long med = ((high + low) / 2); if ( (howMany(n,x,y,med) < c)) {low = med; } else {high = med; }}System.out.println(high); } }
0	public class problemB185{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringBuffer sb = new StringBuffer();  int n = Integer.parseInt(br.readLine()); if ( (n < 0)) { int temp = -n;  int temp2 = (temp / 10);  int x = (temp % 10);  int y = (temp2 % 10); if ( (x > y)) {temp = (temp / 10); } else {temp = (((temp / 10) - y) + x); }n = -temp; } System.out.println(n); } }
4	public class C{ static class Node{ StringBuilder sb = new StringBuilder(); Stack<Integer> stk = new Stack<>(); } public static void main( String[] args)throws IOException { Soumit sc = new Soumit();  int t = sc.nextInt();  StringBuilder sb = new StringBuilder(); while((t-- > 0)){ int n = sc.nextInt();  int[] arr = sc.nextIntArray(n);  Stack<Node> mainstk = new Stack<>();  Node pnode = new Node(); pnode.stk.push(1); pnode.sb.append("1"); mainstk.push(pnode); sb.append(pnode.sb).append("\n"); for ( int i = 1;(i < n);i++) { int val = arr[i]; if ( (val == 1)) { Node node = new Node(); node.stk.push(1); node.sb.append(mainstk.peek().sb).append(".1"); mainstk.push(node); sb.append(node.sb).append("\n"); } else {while(true){ Node node = mainstk.pop(); if ( (node.stk.peek() == (val - 1))) {node.stk.push(val); if ( mainstk.isEmpty()) {node.sb = new StringBuilder(); node.sb.append(val); sb.append(val).append("\n"); } else { Node peeknode = mainstk.peek(); node.sb = new StringBuilder(); node.sb.append(peeknode.sb).append(".").append(val); sb.append(peeknode.sb).append(".").append(val).append("\n"); }mainstk.push(node); break;} }}}}System.out.println(sb); sc.close(); } static class Soumit{ private final int BUFFER_SIZE = (1 << 18); private final DataInputStream din ; private final byte[] buffer ; private PrintWriter pw ; private int bufferPointer ,bytesRead ; StringTokenizer st ; public Soumit(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Soumit( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public void println( String a){ pw.println(a); } public void print( String a){ pw.print(a); } public String readLine()throws IOException { byte[] buf = new byte[3000064];  int cnt = 0,c ; while(((c = read()) != -1)){if ( (c == '\n')) break; buf[cnt++] = (byte)c; }return new String(buf,0,cnt);} public void sort( int[] arr){ ArrayList<Integer> arlist = new ArrayList<>(); for ( int i :arr) arlist.add(i); Collections.sort(arlist); for ( int i = 0;(i < arr.length);i++) arr[i] = arlist.get(i); } public void sort( long[] arr){ ArrayList<Long> arlist = new ArrayList<>(); for ( long i :arr) arlist.add(i); Collections.sort(arlist); for ( int i = 0;(i < arr.length);i++) arr[i] = arlist.get(i); } public int[] nextIntArray( int n)throws IOException { int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextInt(); }return arr;} 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)) din.close(); if ( (pw != null)) pw.close(); } } }
2	public class Main{ static int d[][] ; static int N ; static boolean used[] ; static point dats[] ; public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  long k = scan.nextLong(); if ( (n == 1)) {System.out.print("0"); return ;} if ( (n <= k)) {System.out.print("1"); return ;} long d = (9 - (4 * (((2 * n) - (k * k)) + k))); if ( (d < 0)) {System.out.print("-1"); return ;} double a = ((3 + Math.sqrt(d)) / 2); if ( (a >= 1)) System.out.println(Math.max(2,((k - (long)a) + 1))); else System.out.println(-1); } }
3	public class C908{ public static class mPoint implements Comparable<mPoint>{ public double a ,b ; public mPoint( int a, double b){ this.a = a; this.b = b; } } public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),r = in.nextInt();  int[] ar = new int[n];  ArrayList<mPoint> disks = new ArrayList<>();  double[] ans = new double[n]; for ( int i = 0;(i < n);i++) {ar[i] = in.nextInt(); double max = -1; for ( int j = 0;(j < disks.size());j++) {if ( inRange(ar[i],disks.get(j).a,r)) { double h = (((4 * r) * r) - ((ar[i] - disks.get(j).a) * (ar[i] - disks.get(j).a))); max = Math.max(max,(Math.sqrt(h) + disks.get(j).b)); } } mPoint p = null; if ( (max == -1)) {p = new mPoint(ar[i],r); } else {p = new mPoint(ar[i],max); }disks.add(p); ans[i] = p.b; }for ( int i = 0;(i < (ans.length - 1));i++) {System.out.print((ans[i] + " ")); }System.out.println(ans[(ans.length - 1)]); } public static boolean inRange( int a, double b, int r){ if ( (Math.abs((b - a)) <= (2 * r))) return true; return false;} }
6	public class D{ static int n ,KA ,A ; static int[] b ; static int[] l ; static double ans = 0; public static void main( String[] args)throws IOException { Scanner in = new Scanner(System.in); n = in.nextInt(); KA = in.nextInt(); A = in.nextInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < l.length);i++) {b[i] = in.nextInt(); l[i] = in.nextInt(); }dp = new double[(n + 2)][(n + 2)][((n * 9999) + 2)]; go(0,KA); System.out.printf("%.6f\n",ans); } public static void go( int at, int k){ if ( (at == n)) {ans = Math.max(ans,solve(0,0,0)); return ;} for ( int i = 0;(i <= k);i++) {if ( ((l[at] + (i * 10)) <= 100)) {l[at] += (i * 10); go((at + 1),(k - i)); l[at] -= (i * 10); } }} static double dp[][][] ; public static double solve( int at, int ok, int B){ if ( (at == n)) {if ( (ok > (n / 2))) {return 1;} else {return ((A * 1.0) / ((A * 1.0) + B));}} double ret = (((l / 100.0) * solve((at + 1),(ok + 1),B)) + ((1.0 - (l / 100.0)) * solve((at + 1),ok,(B + b[at])))); return ret;} }
5	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  int[] a = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); sum += a[i]; }for ( int i = 0;(i < n);i++) a[i] *= -1; Arrays.sort(a); for ( int i = 0;(i < n);i++) a[i] *= -1; int ans = 0;  int sum1 = 0; for ( int i = 0;(i < n);i++) {sum1 += a[i]; sum -= a[i]; ans++; if ( (sum1 > sum)) break; }pw.print(ans); pw.close(); } }
3	public class d{ 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 perm[] = new int[n]; for ( int i = 0;(i < n);i++) {perm[i] = in.nextInt(); } int q = in.nextInt();  int inv[] = new int[n]; inv[0] = 0; for ( int i = 1;(i < n);i++) {inv[i] = inv[(i - 1)]; for ( int j = (i - 1);(j >= 0);j--) {if ( (perm[i] < perm[j])) inv[i]++; }} boolean parity = ((inv[(n - 1)] % 2) == 0); for ( int i = 0;(i < q);i++) { int l = (in.nextInt() - 1);  int r = (in.nextInt() - 1); if ( (l == r)) {System.out.println((parity?"even":"odd")); continue;} int s = ((r - l) + 1); s = ((s * (s - 1)) / 2); if ( ((s % 2) != 0)) {parity = !parity; } System.out.println((parity?"even":"odd")); }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());} } }
2	public class B{ public void solve()throws IOException { long n = nextInt(),k = nextInt();  long c = (2 * (n + k));  long l = -1,r = 200000; while(((r - l) > 1)){ long m = (l + ((r - l) / 2)); if ( (((m * m) + (3 * m)) >= c)) {r = m; } else {l = m; }}out.print((n - r)); } public void run(){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); System.exit(1); } } BufferedReader br ; StringTokenizer in ; PrintWriter out ; public String nextToken()throws IOException { while(((in == null) || !in.hasMoreTokens())){in = new StringTokenizer(br.readLine()); }return in.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} public static void main( String[] args)throws IOException { Locale.setDefault(Locale.US); new B().run(); } }
0	public class ProbA{ int account ; void start( Scanner sc, PrintStream out){ int ans = 0; account = sc.nextInt(); int account1 = (account / 10);  int account2 = (((account - (account % 100)) / 10) + (account % 10)); out.println(Math.max(account1,Math.max(account,account2))); } public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintStream out = System.out; new ProbA().start(sc,out); } }
5	public class P166A{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  Point[] P = new Point[n]; for ( int i = 0;(i < n);i++) P[i] = new Point(in.nextInt(),in.nextInt()); Arrays.sort(P,new Comparator<Point>(){}); int cnt = 0;  Point ans = P[(k - 1)]; for ( int i = 0;(i < n);i++) {if ( ((P[i].x == ans.x) && (P[i].y == ans.y))) cnt++; }System.out.println(cnt); } }
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 D{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long a = in.nextLong();  long b = in.nextLong();  String sa = Long.toBinaryString(a);  String sb = Long.toBinaryString(b);  long ans = 0; if ( ((sb.length() - sa.length()) > 0)) {for ( int i = 0;(i < sb.length());i++) {ans += (1l << i); }System.out.println(ans); } else { int num = -1; for ( int i = 62;(i >= 0);i--) {if ( (((b & (1l << i)) != 0) && ((a & (1l << i)) != 0))) {num = i; break;} }ans = 0; if ( (num != -1)) for ( int i = 0;(i <= num);i++) {ans += (1l << i); } System.out.println(ans); }} }
3	public class Main{ static int N ; static int[][] dp ; static int M = (int)(1e9 + 7); static ArrayList<Integer> l ; static int f( int idx, int b){ if ( (idx == l.size())) return 1; if ( (dp[idx][b] != -1)) return dp[idx][b]; long ret = f((idx + 1),(b + l.get(idx))); if ( (b > 0)) ret += f(idx,(b - 1)); return dp[idx][b] = (int)(ret % M);} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(); N = sc.nextInt(); int[] val = new int[N]; for ( int i = 0;(i < N);++i) if ( (sc.next().charAt(0) == 's')) val[i] = 0; else val[i] = 1; l = new ArrayList<Integer>(); l.add(val[0]); for ( int i = 1;(i < N);++i) if ( ((val[i] == val[(i - 1)]) && (val[i] == 1))) { int prev = l.get((l.size() - 1)); l.set((l.size() - 1),++prev); } else if ( (val[(i - 1)] == 0)) {l.add(val[i]); } dp = new int[(l.size() + 1)][(N + 1)]; for ( int i = 0;(i <= l.size());++i) Arrays.fill(dp[i],-1); System.out.println(f(0,0)); } 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());} } }
2	public class B{ final String filename = new String("B").toLowerCase(); int n ; int r ,c ; void solve()throws Exception { n = nextInt(); r = (nextInt() - 1); c = (nextInt() - 1); long count = nextLong();  long left = -1,right = (n * 2L); while((left < (right - 1))){ long mid = ((left + right) / 2); if ( (getSq(n,r,c,mid) >= count)) {right = mid; } else {left = mid; }}out.println(right); } long getSq( int n, int x, int y, long size){ long cur = (((size + 1) * (size + 1)) + (size * size)); cur -= get(((x + size) - (n - 1))); cur -= get(((y + size) - (n - 1))); cur -= get((x - size)); cur -= get((y - size)); cur += getCorner((((x + 1) + (y + 1)) - (size + 1))); cur += getCorner((((x + 1) + (n - y)) - (size + 1))); cur += getCorner((((n - x) + (y + 1)) - (size + 1))); cur += getCorner((((n - x) + (n - y)) - (size + 1))); return cur;} private long getCorner( long min){ if ( (min >= 0)) {return 0;} min = -min; return ((min * (min + 1)) / 2);} long get( long a){ if ( (a <= 0)) {return 0;} return (a * a);} void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } BufferedReader in ; StringTokenizer st ; PrintWriter out ; 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 nextLong()throws Exception { return Long.parseLong(nextToken());} public static void main( String[] args){ new B().run(); } }
2	public class global{ public static void main( String[] s){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  String st = String.valueOf(n); if ( (st.length() == 1)) {System.out.println(n); } else { long val = 1;  long prev = 9;  long total = 9;  long late = 9; for ( int i = 2;(i <= 12);i++) {val *= 10; total += (i * (val * 9)); if ( (n <= total)) { long diff = (n - late);  long div = (diff / i);  long mod = (diff % i); if ( (mod == 0)) {prev += div; System.out.println((prev % 10)); break;} else {prev += (div + 1); String fg = String.valueOf(prev); System.out.println(fg.charAt(((int)mod - 1))); break;}} prev += (9 * val); late = total; }}} }
2	public class D{ public static void main( String[] args)throws IOException { new D().solve(); } void solve()throws IOException { Scanner sc = new Scanner(System.in);  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] sp ;  long L = sc.nextLong();  long R = sc.nextLong(); if ( (L == R)) {System.out.println(0); } else {System.out.println(((Long.highestOneBit((R ^ L)) * 2) - 1)); }} }
3	public class P911d{ static private void solve(){ int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } int cnt = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) {cnt++; } }}cnt %= 2; int m = nextInt(); for ( int i = 0;(i < m);i++) { int l = nextInt();  int r = nextInt();  int size = ((r - l) + 1);  int sum = ((size * (size - 1)) / 2); sum %= 2; cnt += sum; cnt %= 2; out.println(((cnt == 0)?"even":"odd")); }} static private void run(){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } static private StringTokenizer st ; static private BufferedReader br ; static private PrintWriter out ; static private String next(){ while(((st == null) || !st.hasMoreElements())){ String s ; try{s = br.readLine(); }catch (IOException e){ return null;} st = new StringTokenizer(s); }return st.nextToken();} static private int nextInt(){ return Integer.parseInt(next());} public static void main( String[] args){ run(); } }
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 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(); } }
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 PriorityQueue<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(); } }
1	public class B_14{ @SuppressWarnings public static void main( String[] args){ Scanner input = new Scanner(System.in);  int t = input.nextInt(); for ( int test = 0;(test < t);test++) { int n = input.nextInt(); if ( ((n % 2) == 0)) {if ( (Math.sqrt((n / 2)) == (int)Math.sqrt((n / 2)))) {System.out.println("YES"); } else if ( (((n % 4) == 0) && (Math.sqrt((n / 4)) == (int)Math.sqrt((n / 4))))) {System.out.println("YES"); } else {System.out.println("NO"); }} else {System.out.println("NO"); }}} }
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 C113A{ static BufferedReader br ; public static void main( String[] args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); int nm[] = toIntArray();  int n = nm[0];  int k = nm[1];  Pai p[] = new Pai[n]; for ( int i = 0;(i < n);i++) {nm = toIntArray(); p[i] = new Pai(nm[0],nm[1]); }Arrays.sort(p); int count = 0; for ( int i = 0;(i < n);i++) {if ( ((p[(k - 1)].first == p[i].first) && (p[(k - 1)].second == p[i].second))) {count++; } }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;} } class Pai implements Comparable<Pai>{ int first ; int second ; public Pai( int f, int s){ first = f; second = s; } }
1	public class ProblemC{ public static void main( String[] args){ ProblemC problem = new ProblemC(); problem.solve(); } private void solve(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  String s = sc.next();  int ret = n;  int toth = 0;  int tott = 0; for ( int j = 0;(j < n);j++) {if ( (s.charAt(j) == 'H')) {toth++; } else {tott++; }}for ( int j = 0;(j < n);j++) { int cnth = 0; for ( int k = 0;(k < toth);k++) { int pos = ((j + k) % n); if ( (s.charAt(pos) == 'H')) {cnth++; } } int makeh = (toth - cnth); ret = Math.min(ret,makeh); }System.out.println(ret); } }
1	public class IQ{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  ArrayList<Integer> e = new ArrayList<Integer>();  ArrayList<Integer> o = new ArrayList<Integer>();  int size = sc.nextInt(); for ( int w = 0;(w < size);w++) { int x = sc.nextInt(); if ( ((x % 2) == 0)) e.add((w + 1)); else o.add((w + 1)); }if ( (e.size() == 1)) System.out.println(e.get(0)); else System.out.println(o.get(0)); } }
0	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 n = Integer.parseInt(str);  int ans = 0; if ( (n >= 0)) {ans = n; } else {if ( (str.length() == 2)) {if ( (str.charAt(0) != '-')) { int a = Integer.parseInt(str.substring(0,1));  int b = Integer.parseInt(str.substring(1,2)); ans = Math.max(a,b); } else {ans = Integer.parseInt(str.substring(1,2)); }} else { String s1 = str.substring(0,(str.length() - 2)).concat(str.substring((str.length() - 2),(str.length() - 1)));  String s2 = str.substring(0,(str.length() - 2)).concat(str.substring((str.length() - 1),str.length()));  int a = Integer.parseInt(s1);  int b = Integer.parseInt(s2); ans = Math.max(a,b); }}bos.write(new Integer(ans).toString().getBytes()); bos.write(eolb); bos.flush(); }catch (IOException ioe){ ioe.printStackTrace(); } } }
1	public class alex{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int sum = 1; for ( int i = 1;(i <= n);i++) {sum = (sum + (4 * (i - 1))); }System.out.println(sum); } }
1	public class A{ public static void main( String[] args){ new A().run(); } private void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt(); sc.close(); boolean[] isp = new boolean[(n + 1)]; Arrays.fill(isp,true); isp[1] = false; int[] primes = new int[n];  int pc = 0; for ( int i = 2;(i <= n);i++) {if ( isp[i]) {primes[pc++] = i; for ( int j = (i * i);(j <= n);j += i) {isp[j] = false; }} } int res = 0; for ( int i = 0;(i < pc);i++) {for ( int j = 1;(j < i);j++) if ( (primes[i] == ((primes[j] + primes[(j - 1)]) + 1))) res++; }System.out.println(((res >= k)?"YES":"NO")); } }
3	public class Main{ static LinkedList<Integer> adj[] ; static ArrayList<Integer> adj1[] ; static int[] color ,visited1 ; static boolean b[] ,visited[] ,possible ; static int level[] ; static Map<Integer,HashSet<Integer>> s ; static int totalnodes ,colored ; static int count[] ; static long sum[] ; static int nodes ; static double ans = 0; static long[] as = new long[10001]; static long c1 = 0,c2 = 0; static int[] a ,d ,k ; static int max = 100000000; static long MOD = ((long)1e9 + 7),sm = 0,m = Long.MIN_VALUE; static boolean[] prime = new boolean[1000005]; static int[] levl ; static int[] eat ; static int price[] ; static int size[] ,res[] ,par[] ; static int result = 0; public static void main( String[] args)throws IOException { in = new InputReader(System.in); w = new PrintWriter(System.out); int n = ni();  int[] a = na(n);  int ans = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[j] < a[i])) ans++; }} int m = ni(); ans = (ans % 2); while((m-- > 0)){ int l = ni(),r = ni();  int range = ((r - l) + 1); range = ((range * (range - 1)) / 2); range = (range % 2); ans = ((ans + range) % 2); if ( (ans == 1)) w.println("odd"); else w.println("even"); }w.close(); } public static long nCrModpDP( long n, long r, long p){ long[] C = new long[((int)r + 1)]; C[0] = 1; for ( long i = 1;(i <= n);i++) {for ( int j = (int)Math.min(i,r);(j > 0);j--) C[j] = ((C[j] + C[(j - 1)]) % p); }return C[(int)r];} public static long nCrModpLucas( long n, long r, long p){ if ( (r == 0)) return 1; long ni = (n % p),ri = (r % p); return ((nCrModpLucas((n / p),(r / p),p) * nCrModpDP(ni,ri,p)) % p);} public static int ni(){ return in.nextInt();} public static int[] na( int n){ a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} public static void dfs( int i){ visited[i] = true; for ( int j :adj[i]) {if ( !visited[j]) {dfs(j); nodes++; } }} static long gcd( long a, long b){ while((b > 0)){ long temp = b; b = (a % b); a = temp; }return a;} static InputReader in ; static PrintWriter w ; 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 String nextLine(){ int c = snext(); while(isSpaceChar(c))c = snext(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = snext(); }while(!isEndOfLine(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));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
0	public class Round_146_A{ public static void main( String[] args){ new Round_146_A().go(); } void go(){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  long result = solve(n);  PrintStream out = System.out; out.println(result); } static long solve( int n){ if ( (n == 1)) return 1; if ( (n == 2)) return 2; if ( ((n % 2) == 0)) {if ( ((n % 3) == 0)) return (((long)(n - 1) * (n - 2)) * (n - 3)); else return (((long)n * (n - 1)) * (n - 3));} else return (((long)n * (n - 1)) * (n - 2));} }
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); } }
0	public class D{ public static void main( String[] args)throws IOException { new D().solve(); } static final double EPS = 1e-10; Parser parser ; enum Result{UNDER,OVER}private void solve()throws IOException { this.parser = new Parser(new BufferedReader(new InputStreamReader(System.in))); double a = parser.nextInt();  double vmax = parser.nextInt();  double l = parser.nextInt();  double d = parser.nextInt();  double w = parser.nextInt();  double low = 0;  double high = 20000; while((Math.abs((high - low)) > 1e-10)){ double accelerateTime = ((low + high) / 2);  Result res = check(accelerateTime,a,vmax,d,w).result; if ( (res == Result.UNDER)) {low = accelerateTime; } else {high = accelerateTime; }} IP ip = check(high,a,vmax,d,w);  TV tv = tv(ip.v,(l - d),a,vmax);  PrintWriter pw = new PrintWriter(System.out); pw.printf("%.5f\n",(ip.time + tv.time)); pw.close(); } private IP check( double accelerateTime, double a, double vmax, double d, double w){ DV dv = dv(0,a,accelerateTime,vmax); if ( (dv.d > d)) {return new IP(accelerateTime,dv.v,Result.OVER);} Double slowTime = time2MakeDist(-a,dv.v,(d - dv.d)); if ( (slowTime == null)) {return new IP(0,0,Result.UNDER);} double vDown = (dv.v - (a * slowTime)); if ( (vDown < w)) {return new IP(0,0,Result.UNDER);} else {return new IP((accelerateTime + slowTime),vDown,Result.OVER);}} static class IP{ final double time ; final double v ; final Result result ; IP( double time, double v, Result result){ this.time = time; this.v = v; this.result = result; } } static class DV{ final double d ; final double v ; DV( double d, double v){ this.d = d; this.v = v; } } static class TV{ final double time ; final double v ; TV( double time, double v){ this.time = time; this.v = v; } } static Double time2MakeDist( double a, double v0, double dist){ return quadric((a / 2),v0,-dist);} static TV tv( double v0, double d, double a, double vmax){ double acTime = ((vmax - v0) / a);  double unboundedTime = time2MakeDist(a,v0,d); if ( (unboundedTime > acTime)) { double ad = dist(v0,a,acTime); return new TV((acTime + ((d - ad) / vmax)),vmax);} else {return new TV(unboundedTime,(v0 + (a * unboundedTime)));}} static DV dv( double v0, double a, double time, double vmax){ double time2maxV = ((vmax - v0) / a); if ( (time2maxV < time)) {return new DV((dist(v0,a,time2maxV) + dist(vmax,0,(time - time2maxV))),vmax);} else {return new DV(dist(v0,a,time),(v0 + (a * time)));}} static double dist( double v0, double a, double time){ return ((v0 * time) + (((a * time) * time) / 2));} static Double quadric(final double a,final double b,final double c){ double d = ((b * b) - ((4 * a) * c)); if ( (d < -EPS)) {return null;} d = Math.abs(d); double x1 = ((-b + Math.sqrt(d)) / (2 * a));  double x2 = ((-b - Math.sqrt(d)) / (2 * a));  double r = Integer.MAX_VALUE; if ( (x1 > -EPS)) {r = x1; } if ( (x2 > -EPS)) {r = Math.min(r,x2); } if ( (r == Integer.MAX_VALUE)) {throw (new RuntimeException("BOTVA"));} return r;} static class Parser{ final BufferedReader br ; StringTokenizer st = new StringTokenizer(""); public Parser( BufferedReader bufferedReader){ this.br = bufferedReader; } String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(br.readLine()); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} } }
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))); } }
2	public class A{ long mod = (long)(1e+9 + 9); long pow( long a, long b){ long mul = a;  long res = 1; while((b > 0)){if ( ((b % 2) == 1)) {res = ((res * mul) % mod); } mul = ((mul * mul) % mod); b /= 2; }return res;} void solve()throws IOException { long n = nextLong();  long m = nextLong();  long k = nextLong();  long l = -1;  long r = (m / k); while((l < (r - 1))){ long mid = ((l + r) / 2);  long leftOk = (m - (mid * k));  long leftPos = (n - (mid * k));  long cgroups = ((leftOk + (k - 2)) / (k - 1));  long positions = ((leftOk + cgroups) - 1); if ( (positions <= leftPos)) {r = mid; } else {l = mid; }} long res = pow(2,(r + 1)); res = (((res - 2) + mod) % mod); res = ((res * k) % mod); res = (((res + m) - (r * k)) % mod); out.println(res); } 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 A().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer st ; String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String temp = in.readLine(); if ( (temp == null)) {return null;} st = new StringTokenizer(temp); }return st.nextToken();} long nextLong()throws IOException { 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);  E solver = new E(); solver.solve(1,in,out); out.close(); } static class E{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.ni(),K = in.ni();  long mod = 998244353;  long[][] dp = new long[(n + 1)][(n + 1)]; for ( int lim = 1;(lim <= n);lim++) { long sum = 1; dp[0][lim] = 1; for ( int i = 1;(i <= n);i++) {dp[i][lim] = ((dp[i][lim] + sum) % mod); sum = ((sum + dp[i][lim]) % mod); if ( (i >= lim)) sum = (((sum - dp[(i - lim)][lim]) + mod) % mod); }} long ans = 0; for ( int k = 1;(k < Math.min(K,(n + 1)));k++) { long h = (dp[n][k] - dp[n][(k - 1)]);  int lim = (K / k); if ( ((K % k) == 0)) lim--; if ( (lim > n)) lim = n; ans += ((dp[n][lim] * h) % mod); }out.println(((2 * ans) % mod)); } } static class FastScanner{ private BufferedReader in ; private StringTokenizer st ; public FastScanner( InputStream stream){ in = new BufferedReader(new InputStreamReader(stream)); } public String ns(){ while(((st == null) || !st.hasMoreTokens())){try{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int ni(){ return Integer.parseInt(ns());} } }
2	public class B{ static long sumN( long n){ return ((n * (n + 1)) / 2);} static int binSearchPuts( int n, int k){ int L = 1;  int U = n;  int M = ((L + U) / 2); while((L <= U)){ long left = (sumN(M) - (n - M)); if ( (left < k)) {L = (M + 1); } else if ( (left > k)) {U = M; } else {break;}M = ((L + U) / 2); }return M;} public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt();  int k = input.nextInt();  long ate = (n - binSearchPuts(n,k)); System.out.println(ate); } }
5	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);  CGlassCarving solver = new CGlassCarving(); solver.solve(1,in,out); out.close(); } static class CGlassCarving{ public void solve( int testNumber, FastReader s, PrintWriter out){ TreeMap<Long,Integer> mapH = new TreeMap<>();  TreeMap<Long,Integer> mapV = new TreeMap<>();  TreeMap<Long,Integer> hDiff = new TreeMap<>();  TreeMap<Long,Integer> vDiff = new TreeMap<>();  long width = s.nextInt();  long height = s.nextInt(); mapH.put(0L,1); mapV.put(0L,1); mapV.put(width,1); mapH.put(height,1); vDiff.put(width,1); hDiff.put(height,1); long maxV = height;  long maxH = width;  int n = s.nextInt(); for ( int i = 0;(i < n);i++) { char ch = s.nextCharacter();  long cut = s.nextInt(); if ( (ch == 'H')) { Long next = mapH.higherKey(cut);  Long prev = mapH.lowerKey(cut);  Long diff = (next - prev);  int freq = hDiff.get(diff); if ( (freq == 1)) {hDiff.remove(diff); } else {hDiff.put(diff,(freq - 1)); }hDiff.put((next - cut),(hDiff.getOrDefault((next - cut),0) + 1)); hDiff.put((cut - prev),(hDiff.getOrDefault((cut - prev),0) + 1)); mapH.put(cut,(mapH.getOrDefault(cut,0) + 1)); } else { Long next = mapV.higherKey(cut);  Long prev = mapV.lowerKey(cut);  Long diff = (next - prev);  int freq = vDiff.get(diff); if ( (freq == 1)) {vDiff.remove(diff); } else {vDiff.put(diff,(freq - 1)); }vDiff.put((next - cut),(vDiff.getOrDefault((next - cut),0) + 1)); vDiff.put((cut - prev),(vDiff.getOrDefault((cut - prev),0) + 1)); mapV.put(cut,(mapV.getOrDefault(cut,0) + 1)); }out.println((hDiff.lastKey() * vDiff.lastKey())); }} } static class FastReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private FastReader.SpaceCharFilter filter ; public FastReader( 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 char nextCharacter(){ int c = read(); while(isSpaceChar(c)){c = read(); }return (char)c;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
6	public class Main{ public void go(){ int n = sc.nextInt(),k = sc.nextInt(),A = sc.nextInt();  ArrayList<ArrayList<Integer>> waysGiveCandies = doit1(n,k,new ArrayList<Integer>());  int[] lvl = new int[n],loyal = new int[n]; for ( int i = 0;(i < n);++i) {lvl[i] = sc.nextInt(); loyal[i] = sc.nextInt(); } double ret = 0; for ( ArrayList<Integer> distribution :waysGiveCandies) { double[] Loyal = new double[n]; for ( int i = 0;(i < n);++i) Loyal[i] = (min((loyal[i] + (10 * distribution.get(i))),100) / 100.0); double pWin = 0; for ( int i = 0;(i < (1 << n));++i) { double pVoteOccurs = 1; for ( int j = 0;(j < n);++j) if ( ((i & (1 << j)) != 0)) pVoteOccurs *= Loyal[j]; else pVoteOccurs *= (1 - Loyal[j]); int B = 0; for ( int j = 0;(j < n);++j) if ( ((i & (1 << j)) == 0)) B += lvl[j];  double pWinFight = ((double)A / (A + B)); if ( ((bit_count(i) * 2) > n)) pWinFight = 1; pWin += (pVoteOccurs * pWinFight); }ret = max(ret,pWin); }System.out.printf("%.9f\n",ret); } ArrayList<ArrayList<Integer>> doit1( int n, int k, ArrayList<Integer> soFar){ ArrayList<ArrayList<Integer>> ret = new ArrayList<ArrayList<Integer>>(); if ( (n == 1)) {soFar.add(k); ret.add(soFar); return ret;} for ( int i = 0;(i < (k + 1));++i) { ArrayList<Integer> tmp = new ArrayList<Integer>(soFar); tmp.add(i); ret.addAll(doit1((n - 1),(k - i),tmp)); }return ret;} public static final int INF = (((1000 * 1000) * 1000) + 7); public static final double EPS = 1e-9; public static final double PI = (2 * acos(0.0)); public int bit_count( long x){ return ((x == 0)?0:(1 + bit_count((x & (x - 1)))));} static myScanner sc ; static PrintWriter pw ; static long startTime ; public static void main( String[] args)throws Exception { sc = new Main().new myScanner(new BufferedReader(new InputStreamReader(System.in))); pw = new PrintWriter(System.out); startTime = System.nanoTime(); new Main().go(); pw.flush(); System.exit(0); } }
6	public class B{ static int n ; static double A ; static int[] L ; static int[] B ; static double max = 0; public static void rec( int index, int k){ if ( (k < 0)) return ; if ( (index == n)) { double prob = 0; for ( int i = 0;(i < (1 << n));i++) { double b = 0;  double temp = 1.0; for ( int j = 0;(j < n);j++) {if ( (L[j] > 100)) return ; if ( ((i & (1 << j)) == 0)) {b += B[j]; temp *= ((100 - L[j]) / 100.0); } else temp *= (L[j] / 100.0); }if ( ((Integer.bitCount(i) * 2) <= n)) temp *= (A / (A + b)); prob += temp; }max = Math.max(max,prob); return ;} L[index] += 10; rec(index,(k - 1)); L[index] -= 10; rec((index + 1),k); } public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextInt(); int k = in.nextInt(); A = in.nextDouble(); B = new int[n]; L = new int[n]; for ( int i = 0;(i < n);i++) {B[i] = in.nextInt(); L[i] = in.nextInt(); }rec(0,k); System.out.println(max); } }
4	public class Main{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ boolean env = (System.getProperty("ONLINE_JUDGE") != null); if ( !env) {try{br = new BufferedReader(new FileReader("src\\input.txt")); }catch (FileNotFoundException e){ e.printStackTrace(); } } 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());} long nextLong(){ return Long.parseLong(next());} } static long MOD = ((long)1e9 + 7); static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static long memo[] ; static long C[][] ; static long exp( long a, long x){ if ( (x == 0)) return 1; if ( ((x % 2) == 0)) return (exp(((a * a) % MOD),(x / 2)) % MOD); return (((a % MOD) * (exp(((a * a) % MOD),(x / 2)) % MOD)) % MOD);} static void fill( int n){ C = new long[(n + 1)][(n + 1)]; for ( int i = 1;(i <= n);i++) C[i][0] = C[i][i] = 1; for ( int i = 2;(i <= n);i++) {for ( int j = 1;(j <= n);j++) {C[i][j] = ((C[(i - 1)][j] + C[(i - 1)][(j - 1)]) % MOD); }}} public static void main( String[] args)throws java.lang.Exception { int test = 1; while((test-- > 0)){ int n = sc.nextInt(); MOD = sc.nextLong(); memo = new long[(n + 1)]; fill(n); long dp[][] = new long[(n + 5)][(n + 5)]; for ( int i = 1;(i <= n);i++) dp[i][i] = exp(2,(i - 1)); for ( int i = 2;(i <= n);i++) {for ( int j = 1;(j < i);j++) {for ( int k = 1;(k <= j);k++) { long val = ((dp[((i - k) - 1)][(j - k)] * C[j][k]) % MOD); if ( (memo[(k - 1)] == 0)) memo[(k - 1)] = exp(2,(k - 1)); val = ((val * memo[(k - 1)]) % MOD); dp[i][j] = ((dp[i][j] + val) % MOD); }}} long ans = 0; for ( int i = 0;(i <= n);i++) ans = ((ans + dp[n][i]) % MOD); out.println(ans); }out.flush(); out.close(); } }
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; } } static private boolean inside( int a, int b, int n, int m){ return ((((a >= 0) && (a < n)) && (b >= 0)) && (b < m));} }
2	public class Main{ public static void main( String[] args)throws Exception { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task task = new Task(); task.solve(in,out); out.close(); } static class Rectangle{ int x1 ,y1 ; int x2 ,y2 ; } static class Task{ public void solve( InputReader in, PrintWriter out){ int n = in.nextInt();  int l = 1;  int r = n;  int ans = 0; while((r >= l)){ int mid = ((r + l) / 2); if ( (ask(in,out,1,1,mid,n) == 0)) {l = (mid + 1); } else {ans = mid; r = (mid - 1); }}if ( ((ans < n) && (ask(in,out,(ans + 1),1,n,n) == 1))) { Rectangle r1 = find(in,out,1,1,ans,n,n);  Rectangle r2 = find(in,out,(ans + 1),1,n,n,n); System.out.printf("! %d %d %d %d %d %d %d %d\n",r1.x1,r1.y1,r1.x2,r1.y2,r2.x1,r2.y1,r2.x2,r2.y2); } else {l = 1; r = n; ans = 0; while((r >= l)){ int mid = ((r + l) / 2); if ( (ask(in,out,1,1,n,mid) == 0)) {l = (mid + 1); } else {ans = mid; r = (mid - 1); }} Rectangle r1 = find(in,out,1,1,n,ans,n);  Rectangle r2 = find(in,out,1,(ans + 1),n,n,n); System.out.printf("! %d %d %d %d %d %d %d %d\n",r1.x1,r1.y1,r1.x2,r1.y2,r2.x1,r2.y1,r2.x2,r2.y2); }} public Rectangle find( InputReader in, PrintWriter out, int x1, int y1, int x2, int y2, int n){ Rectangle rec = new Rectangle();  int ansx1 = x1;  int ansx2 = x2;  int ansy1 = y1;  int ansy2 = y2;  int l = x1;  int r = x2; while((r >= l)){ int mid = ((r + l) / 2); if ( (ask(in,out,x1,y1,mid,y2) == 1)) {ansx2 = mid; r = (mid - 1); } else {l = (mid + 1); }}r = x2; l = x1; while((r >= l)){ int mid = ((r + l) / 2); if ( (ask(in,out,mid,y1,x2,y2) == 1)) {ansx1 = mid; l = (mid + 1); } else {r = (mid - 1); }}l = y1; r = y2; while((r >= l)){ int mid = ((r + l) / 2); if ( (ask(in,out,x1,y1,x2,mid) == 1)) {ansy2 = mid; r = (mid - 1); } else {l = (mid + 1); }}r = y2; l = y1; while((r >= l)){ int mid = ((r + l) / 2); if ( (ask(in,out,x1,mid,x2,y2) == 1)) {ansy1 = mid; l = (mid + 1); } else {r = (mid - 1); }}rec.x1 = ansx1; rec.x2 = ansx2; rec.y1 = ansy1; rec.y2 = ansy2; return rec;} public int ask( InputReader in, PrintWriter out, int x1, int y1, int x2, int y2){ System.out.printf("? %d %d %d %d\n",x1,y1,x2,y2); System.out.flush(); return in.nextInt();} } 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 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;} }
1	public class C{ static String s ; static long val[] ; static int N ,size ; static int index( char c){ if ( (c <= 'Z')) {return (c - 'A');} else {return ((c - 'a') + (('Z' - 'A') + 1));}} static int l( int i){ return ((i << 1) + 1);} static int r( int i){ return ((i << 1) + 2);} static void setup( int l, int r, int i){ if ( (l == r)) {val[i] = (1L << index(s.charAt(l))); } else { int mid = ((l + r) / 2); setup(l,mid,l(i)); setup((mid + 1),r,r(i)); val[i] = (val[l(i)] | val[r(i)]); }} static long query( int min, int max, int l, int r, int i){ if ( ((min <= l) && (r <= max))) {return val[i];} if ( ((max < l) || (r < min))) return 0; int mid = ((l + r) / 2); return (query(min,max,l,mid,l(i)) | query(min,max,(mid + 1),r,r(i)));} static long query( int min, int max){ return query(min,max,0,(N - 1),0);} static int binarySearch( int start, long toFind){ int max = (N - 1);  int min = start; if ( (query(start,max) != toFind)) return (1 << 29); if ( (query(start,start) == toFind)) {return 1;} int ret = ((max - min) + 1); while(((min + 1) < max)){ int mid = ((min + max) / 2); if ( (query(start,mid) == toFind)) {max = mid; } else {min = mid; }}return ((max - start) + 1);} public static void main( String[] args){ Scanner sc = new Scanner(System.in); N = sc.nextInt(); s = sc.next(); int size = 1; while((size <= N))size *= 2; val = new long[(size * 2)]; setup(0,(N - 1),0); long toFind = query(0,(N - 1),0,(N - 1),0);  long ans = (1L << 29); for ( int i = 0;(i < N);i++) ans = Math.min(ans,binarySearch(i,toFind)); System.out.println(ans); } }
2	public class P{ public static void main( String[] args)throws NumberFormatException,IOException { Scanner sc = new Scanner();  PrintWriter out = new PrintWriter(System.out);  int N = sc.nextInt(),x = sc.nextInt(),y = sc.nextInt();  long C = sc.nextLong();  int lo = 0,hi = (int)1e6;  int answer = -1; while((lo <= hi)){ int L = (lo + ((hi - lo) / 2));  long area = 0; for ( int steps = 0;(steps <= L);++steps) {if ( ((y + steps) > N)) break; long up = Math.min(x,((1 + L) - steps)),down = Math.min((N - x),(L - steps)); area += (up + down); }for ( int steps = 1;(steps <= L);++steps) {if ( ((y - steps) < 1)) break; long up = Math.min(x,((1 + L) - steps)),down = Math.min((N - x),(L - steps)); area += (up + down); }if ( (area >= C)) {answer = L; hi = (L - 1); } else lo = (L + 1); }out.println(answer); out.flush(); out.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } Scanner( String file)throws FileNotFoundException{ br = new BufferedReader(new FileReader(file)); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} long nextLong()throws NumberFormatException,IOException { return Long.parseLong(next());} } }
5	public class P15A{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt(),t = scan.nextInt();  TreeMap<Integer,Integer> hm = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) hm.put(scan.nextInt(),scan.nextInt()); int _x = 0,_a = 0,res = 2;  boolean started = false; for ( Integer key :hm.keySet()) {if ( !started) {_x = key; _a = hm.get(_x); started = true; continue;} if ( (((key - _x) - (((Integer)hm.get(key) + _a) / 2.0)) > t)) res += 2; else if ( (((key - _x) - (((Integer)hm.get(key) + _a) / 2.0)) == t)) res++; _x = key; _a = hm.get(_x); }System.out.println(res); } }
4	public class Main{ static class Point{ int x ; int y ; Point( int a, int b){ x = a; y = b; } } 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[][] board = new boolean[n][m];  int count = sc.nextInt();  Point[] burningTrees = new Point[count]; for ( int i = 0;(i < count);i++) {burningTrees[i] = new Point((sc.nextInt() - 1),(sc.nextInt() - 1)); } Point last = findLastPoint(board,burningTrees); bw.append(((((last.x + 1) + " ") + (last.y + 1)) + "\n")); bw.flush(); bw.close(); sc.close(); } public static Point findLastPoint( boolean[][] board, Point[] burningTree){ Queue<Point> queue = new LinkedList<Point>(); for ( int i = 0;(i < burningTree.length);i++) {queue.add(burningTree[i]); board[burningTree[i].x][burningTree[i].y] = true; } Point lastPoint = new Point(-1,-1); while(!queue.isEmpty()){ Point p = queue.poll(); lastPoint = p; ArrayList<Point> neighbours = getNeighbours(p,board); for ( int i = 0;(i < neighbours.size());i++) {queue.add(neighbours.get(i)); board[neighbours.get(i).x][neighbours.get(i).y] = true; }}return lastPoint;} public static ArrayList<Point> getNeighbours( Point p, boolean[][] board){ ArrayList<Point> neighbours = new ArrayList<>(); for ( int i = -1;(i <= 1);i++) {for ( int j = -1;(j <= 1);j++) {if ( (Math.abs(i) != Math.abs(j))) { int x = (p.x + i);  int y = (p.y + j); if ( ((((x >= 0) && (x < board.length)) && (y >= 0)) && (y < board[0].length))) {if ( (board[x][y] == false)) {neighbours.add(new Point(x,y)); } } } }}return neighbours;} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  LightScanner in = new LightScanner(inputStream);  LightWriter out = new LightWriter(outputStream);  APaintTheNumbers solver = new APaintTheNumbers(); solver.solve(1,in,out); out.close(); } static class APaintTheNumbers{ public void solve( int testNumber, LightScanner in, LightWriter out){ int n = in.ints();  int[] a = in.ints(n); IntroSort.sort(a); boolean[] done = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( done[i]) continue; int d = a[i]; ans++; for ( int j = 0;(j < n);j++) {if ( ((a[j] % d) == 0)) {done[j] = true; } }}out.ans(ans).ln(); } } static class LightScanner{ private BufferedReader reader = null; private StringTokenizer tokenizer = null; public LightScanner( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); } public String string(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new UncheckedIOException(e));} } return tokenizer.nextToken();} public int ints(){ return Integer.parseInt(string());} public int[] ints( int length){ return IntStream.range(0,length).map((x)->ints()).toArray();} } static class LightWriter implements AutoCloseable{ private final Writer out ; private boolean autoflush = false; private boolean breaked = true; public LightWriter( Writer out){ this.out = out; } public LightWriter( OutputStream out){ this(new BufferedWriter(new OutputStreamWriter(out,Charset.defaultCharset()))); } public LightWriter print( char c){ try{out.write(c); breaked = false; }catch (IOException ex){ throw (new UncheckedIOException(ex));} return this;} public LightWriter print( String s){ try{out.write(s,0,s.length()); breaked = false; }catch (IOException ex){ throw (new UncheckedIOException(ex));} return this;} public LightWriter ans( String s){ if ( !breaked) {print(' '); } return print(s);} public LightWriter ans( int i){ return ans(Integer.toString(i));} public LightWriter ln(){ print(System.lineSeparator()); breaked = true; if ( autoflush) {try{out.flush(); }catch (IOException ex){ throw (new UncheckedIOException(ex));} } return this;} public void close(){ try{out.close(); }catch (IOException ex){ throw (new UncheckedIOException(ex));} } } }
3	public class Contest{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Contest().run(); } 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 void run(){ try{ long t1 = System.currentTimeMillis(); init(); solve(); out.close(); long t2 = System.currentTimeMillis(); System.err.println(("Time(ms) = " + (t2 - t1))); }catch (Exception e){ e.printStackTrace(System.err); System.exit(-1); } } public void solve()throws IOException { int num_a = readInt();  int[] array = new int[num_a]; for ( int i = 0;(i < num_a);i++) {array[i] = readInt(); } int result = 0; Arrays.sort(array); for ( int i = 0;(i < array.length);i++) {if ( (array[i] == -1)) {continue;} for ( int j = 0;(j < array.length);j++) {if ( (((array[j] != -1) && ((array[j] % array[i]) == 0)) && (j != i))) {array[j] = -1; } }result++; }System.out.println(result); } }
2	public class cf_contest_1177_problem_B{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  long k = s.nextLong(); if ( (k <= 9)) System.out.println(k); else { int c = 1; while((k > (c * (Math.pow(10,c) - Math.pow(10,(c - 1)))))){k -= (c * (Math.pow(10,c) - Math.pow(10,(c - 1)))); c++; } long mo = (k % c); k = (k / c); if ( (mo == 0)) {mo = c; k--; } mo--; long j = (long)(Math.pow(10,(c - 1)) + k);  String j1 = ("" + j); System.out.println(j1.charAt((int)mo)); }} }
0	public class Rules{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int a = in.nextInt();  double maxSpeed = in.nextInt();  double len = in.nextInt();  double delayDist = in.nextInt();  double delaySpeed = in.nextInt();  double timeToDelaySpeed = (delaySpeed / a);  double timeToDelay = travelS(a,0.0,maxSpeed,delayDist); if ( (timeToDelay < timeToDelaySpeed)) {timeToDelay = travelS(a,0.0,maxSpeed,len); double timeToMax = (maxSpeed / a); if ( (timeToDelay < timeToMax)) {System.out.printf("%.9f\n",timeToDelay); return ;} double[] parts = travelA(a,0.0,maxSpeed);  double remainingDist = (len - parts[1]);  double time = (parts[0] + (remainingDist / maxSpeed)); System.out.printf("%.9f\n",time); return ;} if ( (delaySpeed > maxSpeed)) { double time = travelS(a,0.0,maxSpeed,len); System.out.printf("%.9f\n",time); return ;} double lowV = delaySpeed;  double highV = maxSpeed;  int loopCount = 1000;  double[] initial = null;  double[] secondary = null; while((loopCount-- > 0)){ double guessV = ((lowV + highV) / 2.0); initial = travelA(a,0.0,guessV); secondary = travelA(a,guessV,Math.min(delaySpeed,maxSpeed)); if ( ((initial[1] + secondary[1]) < delayDist)) {lowV = guessV; } else {highV = guessV; }} double totalTime = 0.0;  double finalSpeed = 0.0; initial = travelA(a,0.0,lowV); secondary = travelA(a,lowV,delaySpeed); totalTime = (initial[0] + secondary[0]); double totalDist = (initial[1] + secondary[1]); totalTime += ((delayDist - totalDist) / maxSpeed); totalTime += travelS(a,delaySpeed,maxSpeed,(len - delayDist)); System.out.printf("%.9f\n",totalTime); } public static double[] travelA( int a, double startSpeed, double endSpeed){ if ( (startSpeed > endSpeed)) a = -a;  double time = ((endSpeed - startSpeed) / a);  double dist = ((((0.5 * a) * time) * time) + (startSpeed * time)); return new double[]{time,dist};} public static double travelS( int a, double startSpeed, double maxSpeed, double dist){ double timeToMax = ((maxSpeed - startSpeed) / a);  double targetTime = ((-startSpeed + Math.sqrt(((startSpeed * startSpeed) + ((2 * a) * dist)))) / a); if ( (targetTime < timeToMax)) return targetTime; double partialDist = ((((0.5 * timeToMax) * timeToMax) * a) + (startSpeed * timeToMax));  double remainingDist = (dist - partialDist); targetTime = (remainingDist / maxSpeed); return (targetTime + timeToMax);} }
0	public class D0005{ public static void main( String[] args)throws Exception { new D0005(); } D0005()throws Exception{ PandaScanner sc = null;  PrintWriter out = null; try{sc = new PandaScanner(System.in); out = new PrintWriter(System.out); }catch (Exception ignored){ } a = sc.nextInt(); max = sc.nextInt(); double length = sc.nextInt();  double dist = sc.nextInt();  double limit = sc.nextInt(); if ( (max <= limit)) {out.println(travelTime(length,0)); } else { double tLimit = (limit / a);  double dLimit = distance(0,tLimit); if ( (dLimit >= dist)) {out.println(travelTime(length,0)); } else { double res = ((tLimit + (2 * travelTime((0.5 * (dist - dLimit)),limit))) + travelTime((length - dist),limit)); out.println(res); }}out.close(); System.exit(0); } double a ,max ; double distance( double v, double t){ return ((v * t) + (((0.5 * a) * t) * t));} double travelTime( double d, double v){ double tAll = ((-v + Math.sqrt(((v * v) + ((2 * a) * d)))) / a);  double tMax = ((max - v) / a); if ( (tAll <= tMax)) {return tAll;} else {return (tMax + ((d - distance(v,tMax)) / max));}} public class PandaScanner{ BufferedReader br ; StringTokenizer st ; InputStream in ; PandaScanner( InputStream in)throws Exception{ br = new BufferedReader(new InputStreamReader(this.in = in)); } public String next()throws Exception { if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(br.readLine().trim()); return next();} return st.nextToken();} public int nextInt()throws Exception { return Integer.parseInt(next());} } }
4	public class Main{ public static void main( String[] args)throws Exception { FastIO in = new FastIO(args);  int t = in.ni(); while((t-- > 0)){ int n = in.ni();  LinkedList<Integer> l = new LinkedList<>();  ArrayList<LinkedList<Integer>> al = new ArrayList<>(); for ( int i = 0;(i < n);i++) { int p = in.ni(); if ( (p == 1)) {l.addFirst(1); } else {while(true){if ( (l.peekFirst() == (p - 1))) {l.addFirst((l.removeFirst() + 1)); break;} else {l.removeFirst(); }}}al.add(new LinkedList<>(l)); }for ( LinkedList<Integer> ll :al) {while((ll.size() > 1)){System.out.print((ll.removeLast() + ".")); }System.out.println(ll.remove()); }System.out.println(); }in.bw.flush(); } static class Data implements Comparable<Data>{ int a ,b ; public Data( int a, int b){ this.a = a; this.b = b; } public static void sort( int[] a){ Data d[] = new Data[a.length]; for ( int i = 0;(i < a.length);i++) {d[i] = new Data(a[i],0); }Arrays.sort(d); for ( int i = 0;(i < a.length);i++) {a[i] = d[i].a; }} } static class FastIO{ private final BufferedReader br ; private final BufferedWriter bw ; private String s[] ; private int index ; public FastIO( String[] args)throws IOException{ if ( (args.length > 1)) {br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(args[0])))); bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(args[1])))); } else {br = new BufferedReader(new InputStreamReader(System.in)); bw = new BufferedWriter(new OutputStreamWriter(System.out,"UTF-8")); }s = br.readLine().split(" "); index = 0; } public int ni()throws IOException { return Integer.parseInt(nextToken());} public double nd()throws IOException { return Double.parseDouble(nextToken());} public long nl()throws IOException { return Long.parseLong(nextToken());} public void print( String s)throws IOException { bw.write(s); } public void println( String s)throws IOException { bw.write(s); bw.newLine(); } public void print( int s)throws IOException { bw.write((s + "")); } public void println( int s)throws IOException { bw.write((s + "")); bw.newLine(); } public void print( long s)throws IOException { bw.write((s + "")); } public void println( long s)throws IOException { bw.write((s + "")); bw.newLine(); } public void print( double s)throws IOException { bw.write((s + "")); } public void println( double s)throws IOException { bw.write((s + "")); bw.newLine(); } private String nextToken()throws IndexOutOfBoundsException,IOException { if ( (index == s.length)) {s = br.readLine().split(" "); index = 0; } return s[index++];} private void validate( int n, int start, int end){ if ( ((start < 0) || (end >= n))) {throw (new IllegalArgumentException());} } } }
1	public class C{ Scanner in ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  char[] x = in.next().toCharArray();  int t = 0; for ( int i = 0;(i < n);i++) {if ( (x[i] == 'T')) {t++; } } int min = 9999; for ( int i = 0;(i < n);i++) { int y = 0; for ( int j = i;(j < (i + t));j++) {if ( (x[(j % n)] == 'T')) {y++; } }min = Math.min(min,(t - y)); }out.println(min); } void run()throws Exception { in = (INPUT.isEmpty()?new Scanner(System.in):new Scanner(INPUT)); out = 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());} }
5	public class AAA{ public static void main( String[] args){ 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 max = a[0];  int ind = 0; for ( int k = 1;(k < n);k++) {if ( (a[k] > max)) {max = a[k]; ind = k; } }if ( (max != 1)) {a[ind] = 1; Arrays.sort(a); for ( int i = 0;(i < (a.length - 1));i++) System.out.print((a[i] + " ")); System.out.println(a[(a.length - 1)]); } else {a[0] = 2; Arrays.sort(a); for ( int i = 0;(i < (a.length - 1));i++) System.out.print((a[i] + " ")); System.out.println(a[(a.length - 1)]); }} }
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(); } }
0	public class n5D{ public static void main( String[] args){ double a = 0,v = 0,l = 0,d = 0,w = 0; try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] str = br.readLine().split(" "); a = Double.parseDouble(str[0]); v = Double.parseDouble(str[1]); str = br.readLine().split(" "); l = Double.parseDouble(str[0]); d = Double.parseDouble(str[1]); w = Double.parseDouble(str[2]); }catch (Exception e){ System.out.println(e); } double t1 ,t2 ,t3 ,t4 ,t5 ,t ,D = 0; if ( (w > v)) w = v; t2 = (((d / v) - (v / a)) + ((((w * w) / 2) / a) / v)); if ( (t2 >= 0)) {t1 = (v / a); t3 = (t1 - (w / a)); } else {if ( (Math.sqrt(((2 * d) / a)) > (w / a))) {t1 = Math.sqrt(((((2 * a) * d) + (w * w)) / ((a * a) * 2))); t3 = (t1 - (w / a)); } else {t1 = Math.sqrt(((2 * d) / a)); t3 = 0; }t2 = 0; }t5 = ((((l - d) - (((v * v) / 2) / a)) + (((a * (t1 - t3)) * (t1 - t3)) / 2)) / v); if ( (t5 >= 0)) t4 = ((v / a) - (t1 - t3)); else {t5 = 0; t4 = ((-t1 + t3) + Math.sqrt((((t1 - t3) * (t1 - t3)) + ((2 * (l - d)) / a)))); }t = ((((t1 + t2) + t3) + t4) + t5); System.out.println(t); } }
3	public class Paint_The_Numbers{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  ArrayList<Integer> paint = new ArrayList<Integer>();  int num = scan.nextInt(); for ( int i = 0;(i < num);i++) paint.add(scan.nextInt()); Collections.sort(paint); int counter = 0; while((paint.size() != 0)){num = paint.remove(0); for ( int i = 0;(i < paint.size());i++) {if ( ((paint.get(i) % num) == 0)) {paint.remove(i--); } }counter++; }System.out.println(counter); } }
5	public class CFJava{ static private void println( Integer n){ System.out.println(n); } static private void println( String s){ System.out.println(s); } static private void print( Integer n){ System.out.print(n); } static private void print( String s){ System.out.print(s); } public static void main( String[] args)throws IOException { MyScanner scanner = new MyScanner();  int n = scanner.nextInt();  int k = scanner.nextInt();  Integer[] a = scanner.getIntArray(n); Arrays.sort(a); TreeSet<Integer> res = new TreeSet<Integer>(); for ( Integer i :a) {if ( (!res.contains((i / k)) || ((i % k) != 0))) res.add(i); }println(res.size()); } } class MyScanner{ private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private String[] buffer ; private int pos = 0; public Integer nextInt()throws IOException { if ( (buffer == null)) {buffer = in.readLine().split(" "); pos = 0; } if ( (buffer.length <= pos)) {buffer = in.readLine().split(" "); pos = 0; } pos++; return Integer.parseInt(buffer[(pos - 1)]);} public Integer[] getIntArray( Integer n)throws IOException { Integer[] result = new Integer[n]; for ( int i = 0;(i < n);i++) result[i] = nextInt(); return result;} }
3	public class Main{ static class Reader{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ,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 s(){ 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 i(){ 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));} public int[] arr( int n){ int[] ret = new int[n]; for ( int i = 0;(i < n);i++) {ret[i] = i(); }return ret;} } public static void main( String[] args)throws IOException { Reader sc = new Reader();  PrintWriter out = new PrintWriter(System.out);  int n = sc.i();  int arr[] = sc.arr(n);  int count = 0; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( (arr[j] < arr[i])) count++; count %= 2; int q = sc.i(); while((q-- > 0)){ int a = sc.i();  int b = sc.i();  long len = (((long)((b - a) + 1) * (b - a)) / 2); if ( ((len % 2) == 1)) count ^= 1; if ( (count == 0)) out.println("even"); else out.println("odd"); }out.flush(); } }
6	public class E implements Runnable{ public static void main( String[] args){ new Thread(null,new E(),"_cf",(1 << 28)).start(); } HashMap<Integer,Integer> valToNode ,nodeToVal ,whichBox ; int N ,ptsTo[] ,cycleMask[] ,dfsStack[] ,tempList[] ; ArrayDeque<Integer> stack = new ArrayDeque<>(); void dfs( int node){ dfsStack[node] = 1; stack.addLast(node); int goTo = ptsTo[node]; if ( (goTo == -1)) {while(!stack.isEmpty()){cycleMask[stack.pollLast()] = -1; }} else {if ( (dfsStack[goTo] == 1)) { int ptr = 0,mask = 0,conflict = 0; while(!stack.isEmpty()){ int now = stack.pollLast(),val = nodeToVal.get(now),box = whichBox.get(val); tempList[ptr++] = now; if ( ((mask & (1 << box)) > 0)) conflict = 1; mask |= (1 << box); if ( (now == goTo)) break; }while(!stack.isEmpty()){cycleMask[stack.pollLast()] = -1; }for ( int i = 0;(i < ptr);i++) { int now = tempList[i]; if ( (conflict > 0)) cycleMask[now] = -1; else cycleMask[now] = mask; }} else if ( (dfsStack[goTo] == 2)) {while(!stack.isEmpty()){cycleMask[stack.pollLast()] = -1; }} else {dfs(goTo); }}dfsStack[node] = 2; } 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);} } }
5	public class a{ static long mod = 1000000007; static boolean[][] blacks ; public static void main( String[] args)throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(new PrintStream(System.out));  int n = input.nextInt(),t = input.nextInt();  int res = 2;  Cottage[] data = new Cottage[n];  int[] xs = new int[n],as = new int[n]; for ( int i = 0;(i < n);i++) {data[i] = new Cottage(input.nextInt(),input.nextInt()); }Arrays.sort(data); for ( int i = 0;(i < n);i++) {xs[i] = data[i].x; as[i] = data[i].a; }for ( int i = 0;(i < (n - 1));i++) {if ( ((2 * (xs[(i + 1)] - xs[i])) == (((2 * t) + as[i]) + as[(i + 1)]))) res++; else if ( ((2 * (xs[(i + 1)] - xs[i])) > (((2 * t) + as[i]) + as[(i + 1)]))) res += 2; }out.println(res); out.close(); } static class Cottage implements Comparable<Cottage>{ int x ,a ; public Cottage( int xx, int aa){ x = xx; a = aa; } } static long pow( long a, long p){ if ( (p == 0)) return 1; if ( ((p & 1) == 0)) { long sqrt = pow(a,(p / 2)); return ((sqrt * sqrt) % mod);} else return ((a * pow(a,(p - 1))) % mod);} }
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))); } }
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(); } }
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(); } }
2	public class P1177A{ public static void main( String[] args)throws FileNotFoundException { Scanner in = new Scanner(System.in); System.out.println(solve(in.nextLong())); } static private 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)));} }
4	public class C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long mod = 1000000007l;  int cases = sc.nextInt(); while((cases > 0)){cases--; Stack<Integer> stack = new Stack<>();  int n = sc.nextInt(); for ( int j = 0;(j < n);j++) { int x = sc.nextInt(); if ( (x == 1)) {stack.add(1); } else { int p = stack.pop(); if ( (p == (x - 1))) {stack.add(x); } else {while((p != (x - 1))){p = stack.pop(); }stack.add(x); }} StringBuilder f = new StringBuilder();  Stack<Integer> temp = new Stack<>(); while((stack.isEmpty() == false)){temp.add(stack.pop()); }while((temp.isEmpty() == false)){ int z = temp.pop(); f.append((z + ".")); stack.add(z); }System.out.println(f.substring(0,(f.length() - 1))); }}} }
6	public class C{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; final int INF = (Integer.MAX_VALUE / 2); void solve()throws IOException { int n = nextInt();  int m = nextInt(); if ( (n > m)) { int tmp = n; n = m; m = tmp; } if ( (n == 1)) {out.print((m - ((m + 2) / 3))); return ;} int[][] dp = new int[((n * m) + 1)][(1 << (2 * n))]; for ( int i = 0;(i < dp.length);i++) Arrays.fill(dp[i],INF); dp[0][0] = 0; for ( int i = 0;(i < (dp.length - 1));i++) { int maxNewMask = ((1 << Math.min((2 * n),((n * m) - i))) - 1); for ( int mask = 0;(mask < dp[i].length);mask++) if ( (dp[i][mask] != INF)) {if ( ((mask & 1) == 1)) dp[(i + 1)][(mask >> 1)] = Math.min(dp[(i + 1)][(mask >> 1)],dp[i][mask]);  int newMask = (mask >> 1); if ( ((i % n) != (n - 1))) newMask |= 1; newMask |= (1 << (n - 1)); newMask &= maxNewMask; dp[(i + 1)][newMask] = Math.min(dp[(i + 1)][newMask],(dp[i][mask] + 1)); if ( ((i % n) != (n - 1))) {newMask = (mask >> 1); newMask |= 1; if ( ((i % n) != (n - 2))) newMask |= 2; newMask |= (1 << n); newMask &= maxNewMask; dp[(i + 1)][newMask] = Math.min(dp[(i + 1)][newMask],(dp[i][mask] + 1)); } if ( ((i + n) < (n * m))) {newMask = (mask >> 1); newMask |= (1 << (n - 1)); if ( ((i % n) != 0)) newMask |= (1 << (n - 2)); if ( ((i % n) != (n - 1))) newMask |= (1 << n); newMask |= (1 << ((2 * n) - 1)); newMask &= maxNewMask; dp[(i + 1)][newMask] = Math.min(dp[(i + 1)][newMask],(dp[i][mask] + 1)); } } }out.print(((n * m) - dp[(n * m)][0])); } void inp()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 C().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());} }
2	public class B2{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong();  long upn = k;  long tmp = upn; if ( (n == 1)) {System.out.println(0); return ;} if ( (n <= k)) {System.out.println(1); return ;} if ( !bS(n,k,upn)) {System.out.println(-1); return ;} boolean flag = false; while(bS(n,k,upn)){tmp = upn; flag = true; upn = ((5 * upn) / 6); if ( (tmp == upn)) break; } long ans = tmp; if ( !flag) upn = 0; for ( int i = (int)tmp;(i >= upn);i--) {if ( bS(n,k,i)) {ans = i; } else break;}System.out.println(ans); } static boolean bS( long key, long k, long n){ long pipe = ((n * (((k - n) + k) + 1)) / 2); pipe = ((pipe - n) + 1); if ( (pipe >= key)) {return true;} else return false;} }
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); } }
4	public class Global14{ static PrintWriter out ; static Scanner sc ; static ArrayList<int[]> q ,w ,x ; static ArrayList<Integer> adj[] ; static HashSet<Integer> primesH ; static boolean prime[] ; static HashSet<Long> tmp ; static int[][][] dist ; static boolean[] v ; static int[] a ,b ,c ,d ; static Boolean[][] dp ; static char[][] mp ; static int A ,B ,n ,m ,h ,ans ,sum ; static long oo = ((long)1e9 + 7); public static void main( String[] args)throws IOException { sc = new Scanner(System.in); out = new PrintWriter(System.out); E(); out.close(); } static private Boolean dp( int i, int j){ if ( (j > (sum / 2))) return false; if ( (i == x.size())) {return ((sum / 2) == j);} if ( (dp[i][j] != null)) return dp[i][j]; return dp[i][j] = (dp((i + 1),(j + x.get(i)[0])) || dp((i + 1),j));} static private boolean valid( int nx, int ny){ return ((((nx >= 0) && (nx < dist.length)) && (ny >= 0)) && (ny < dist[0].length));} static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} static void E()throws IOException { int t = 1; while((t-- > 0)){ int n = ni();  long oo = nl();  long fc[] = new long[(n + 1)]; fc[0] = fc[1] = 1l; long[] pow2 = new long[(n + 1)]; pow2[0] = 1l; for ( int i = 1;(i < pow2.length);i++) {pow2[i] = ((pow2[(i - 1)] * 2l) % oo); }for ( int i = 2;(i < fc.length);i++) {fc[i] = (((fc[(i - 1)] * 1l) * i) % oo); } long ncr[][] = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= i);j++) {ncr[i][j] = (((i == 0) || (j == 0))?1l:((ncr[(i - 1)][(j - 1)] + ncr[(i - 1)][j]) % oo)); }} long ans = 0;  long dp[][] = new long[(n + 2)][(n + 2)]; dp[0][0] = 1l; 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] * pow2[(k - 1)]) % oo) * ncr[(j + k)][k]) % oo); dp[((i + k) + 1)][(j + k)] %= oo; }}}for ( int i = 0;(i <= n);i++) {ans = ((ans + dp[(n + 1)][i]) % oo); }ol(("" + ans)); }} static int ni()throws IOException { return sc.nextInt();} static long nl()throws IOException { return sc.nextLong();} static int[] nai( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); return a;} static void ol( String x){ out.println(x); } static void ol( int x){ out.println(x); } static void disp2( int[] a){ for ( int i = (a.length - 1);(i >= 0);i--) {out.print((a[i] + " ")); }out.println(); } 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 double nextDouble()throws IOException { return Double.parseDouble(next());} public long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
1	public class Main{ public static void main( String[] args)throws IOException { final long mod = (long)(1e9 + 7);  Reader s = new Reader();  PrintWriter pt = new PrintWriter(System.out);  int T = s.nextInt(); while((T-- > 0)){ long n = s.nextInt();  long sq1 = (n / 2);  long sq2 = (n / 4); if ( ((isPerfectSquare(sq1) && ((sq1 * 2) == n)) || (isPerfectSquare(sq2) && ((sq2 * 4) == n)))) pt.println("YES"); else pt.println("NO"); }pt.close(); } static int gcd( int a, int b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static void reverse( int[] arr, int start, int end){ int temp ; while((start < end)){temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; }} static void reverse( long[] arr, int start, int end){ long temp ; while((start < end)){temp = arr[start]; arr[start] = arr[end]; arr[end] = temp; start++; end--; }} 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(); }} static int max( int x, int y){ return ((x > y)?x:y);} static long power( long x, long y, long p){ long res = 1; x = (x % p); while((y > 0)){if ( ((y % 2) == 1)) res = ((res * x) % p); y = (y >> 1); x = ((x * x) % p); }return res;} static long modInverse( long n, long p){ return power(n,(p - 2),p);} static String reverse( String str){ return new StringBuffer(str).reverse().toString();} static long fastpow( long x, long y, long m){ if ( (y == 0)) return 1; long p = (fastpow(x,(y / 2),m) % m); p = ((p * p) % m); if ( ((y % 2) == 0)) return p; else return ((x * p) % m);} static boolean isPerfectSquare( long l){ return (Math.pow((long)Math.sqrt(l),2) == l);} static void merge( long[] arr, int l, int m, int r){ int n1 = ((m - l) + 1);  int n2 = (r - m);  long L[] = new long[n1];  long R[] = new long[n2]; for ( int i = 0;(i < n1);++i) L[i] = arr[(l + i)]; for ( int j = 0;(j < n2);++j) R[j] = arr[((m + 1) + j)]; int i = 0,j = 0;  int k = l; while(((i < n1) && (j < n2))){if ( (L[i] <= R[j])) {arr[k] = L[i]; i++; } else {arr[k] = R[j]; j++; }k++; }while((i < n1)){arr[k] = L[i]; i++; k++; }while((j < n2)){arr[k] = R[j]; j++; k++; }} static void sort( int[] arr, int l, int r){ if ( (l < r)) { int m = ((l + r) / 2); sort(arr,l,m); sort(arr,(m + 1),r); merge(arr,l,m,r); } } static void merge( int[] arr, int l, int m, int r){ int n1 = ((m - l) + 1);  int n2 = (r - m);  int L[] = new int[n1];  int R[] = new int[n2]; for ( int i = 0;(i < n1);++i) L[i] = arr[(l + i)]; for ( int j = 0;(j < n2);++j) R[j] = arr[((m + 1) + j)]; int i = 0,j = 0;  int k = l; while(((i < n1) && (j < n2))){if ( (L[i] <= R[j])) {arr[k] = L[i]; i++; } else {arr[k] = R[j]; j++; }k++; }while((i < n1)){arr[k] = L[i]; i++; k++; }while((j < n2)){arr[k] = R[j]; j++; k++; }} static void sort( long[] arr, int l, int r){ if ( (l < r)) { int m = ((l + r) / 2); sort(arr,l,m); sort(arr,(m + 1),r); merge(arr,l,m,r); } } 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(); } } }
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);  TaskE2 solver = new TaskE2(); solver.solve(1,in,out); out.close(); } static class TaskE2{ int[][] grid ; int[][] val ; int[][] dp ; int rows ; int two( int bit){ return (1 << bit);} boolean contain( int mask, int bit){ return ((mask & two(bit)) > 0);} int rec( int col, int mask){ if ( (col == grid[0].length)) return 0; if ( (dp[col][mask] != -1)) return dp[col][mask]; int res = rec((col + 1),mask); for ( int newMask = mask;(newMask > 0);newMask = (mask & (newMask - 1))) {res = Math.max(res,(rec((col + 1),(mask ^ newMask)) + val[col][newMask])); }dp[col][mask] = res; return res;} public void solve( int testNumber, InputReader in, PrintWriter out){ int T = in.nextInt(); for ( int t = 0;(t < T);t++) { int n = in.nextInt();  int m = in.nextInt(); rows = n; int[][] input = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {input[i][j] = in.nextInt(); }} ArrayList<Col> cols = new ArrayList<>(); for ( int col = 0;(col < m);col++) { int maxVal = 0; for ( int row = 0;(row < n);row++) {maxVal = Math.max(maxVal,input[row][col]); }cols.add(new Col(maxVal,col)); }Collections.sort(cols); m = Math.min(n,m); grid = new int[n][m]; for ( int i = 0;(i < m);i++) { int c = cols.get(i).colID; for ( int row = 0;(row < n);row++) {grid[row][i] = input[row][c]; }}val = new int[m][two(n)]; for ( int c = 0;(c < m);c++) {for ( int mask = 0;(mask < two(n));mask++) {val[c][mask] = 0; for ( int offset = 0;(offset < n);offset++) { int sum = 0; for ( int bit = 0;(bit < n);bit++) {if ( (contain(mask,bit) == true)) sum += grid[((bit + offset) % n)][c]; }val[c][mask] = Math.max(val[c][mask],sum); }}}dp = new int[m][two(n)]; for ( int[] aux :dp) Arrays.fill(aux,-1); int ans = rec(0,(two(n) - 1)); out.println(ans); }} class Col implements Comparable<Col>{ int maxVal ; int colID ; Col( int _maxVal, int _colID){ this.maxVal = _maxVal; this.colID = _colID; } } } 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);} } }
1	public class A{ public static long Mod = (long)(1e9 + 7); public static long[][] dp ; public static void main( String[] args)throws FileNotFoundException { PrintWriter out = new PrintWriter(System.out);  Scanner in = new Scanner();  int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] data = new int[n];  int[] u = new int[n];  int[] s = new int[n];  HashMap<Integer,Integer> map = new HashMap(); for ( int i = 0;(i < n);i++) {u[i] = i; data[i] = in.nextInt(); map.put(data[i],i); } boolean ok = true;  boolean[] check = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( map.containsKey((a - data[i]))) {u[find(i,u)] = u[find(map.get((a - data[i])),u)]; s[i] |= 1; } if ( map.containsKey((b - data[i]))) {u[find(i,u)] = u[find(map.get((b - data[i])),u)]; s[i] |= 2; } } int[] g = new int[n]; Arrays.fill(g,3); for ( int i = 0;(i < n);i++) {if ( (s[i] == 0)) {ok = false; break;} g[find(i,u)] &= s[i]; if ( (g[find(i,u)] == 0)) {ok = false; break;} }if ( ok) {out.println("YES"); for ( int i = 0;(i < n);i++) {if ( ((g[find(i,u)] & 1) == 0)) {out.print((1 + " ")); } else {out.print((0 + " ")); }}} else {out.println("NO"); }out.close(); } static int find( int index, int[] u){ if ( (index != u[index])) {return u[index] = find(u[index],u);} return index;} public static long pow( int a, int b, long mod){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long v = pow(a,(b / 2),mod); if ( ((b % 2) == 0)) {return ((v * v) % mod);} else {return ((((v * v) % mod) * a) % mod);}} public static int[][] powSquareMatrix( int[][] A, long p){ int[][] unit = new int[A.length][A.length]; for ( int i = 0;(i < unit.length);i++) {unit[i][i] = 1; }if ( (p == 0)) {return unit;} int[][] val = powSquareMatrix(A,(p / 2)); if ( ((p % 2) == 0)) {return mulMatrix(val,val);} else {return mulMatrix(A,mulMatrix(val,val));}} public static int[][] mulMatrix( int[][] A, int[][] B){ int[][] result = new int[A.length][B[0].length]; for ( int i = 0;(i < result.length);i++) {for ( int j = 0;(j < result[0].length);j++) { long temp = 0; for ( int k = 0;(k < A[0].length);k++) {temp += (((long)A[i][k] * B[k][j]) % Mod); temp %= Mod; }temp %= Mod; result[i][j] = (int)temp; }}return result;} static long gcd( long a, long b){ if ( (b == 0)) {return a;} else {return gcd(b,(a % b));}} static long pow( long a, int 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) % Mod) * a) % Mod);}} static double cross( Point a, Point b, Point c){ Point ab = new Point((b.x - a.x),(b.y - a.y));  Point ac = new Point((c.x - a.x),(c.y - a.y)); return cross(ab,ac);} static double cross( Point a, Point b){ return ((a.x * b.y) - (a.y * b.x));} static long dot( Point a, Point b, Point c){ Point ab = new Point((b.x - a.x),(b.y - a.y));  Point ac = new Point((c.x - a.x),(c.y - a.y)); return dot(ab,ac);} static long dot( Point a, Point b){ long total = (a.x * b.x); total += (a.y * b.y); return total;} static double dist( Point a, Point b){ long total = (((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y))); return Math.sqrt(total);} static long norm( Point a){ long result = (a.x * a.x); result += (a.y * a.y); return result;} static double dist( Point a, Point b, Point x, boolean isSegment){ double dist = (cross(a,b,x) / dist(a,b)); if ( isSegment) { Point ab = new Point((b.x - a.x),(b.y - a.y));  long dot1 = dot(a,b,x);  long norm = norm(ab);  double u = ((double)dot1 / norm); if ( (u < 0)) {return dist(a,x);} if ( (u > 1)) {return dist(b,x);} } return Math.abs(dist);} static class Point{ int x ,y ; public Point( int x, int y){ this.x = x; this.y = y; } } static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner()throws FileNotFoundException{ 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());} } }
3	public class C{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] line = in.readLine().split(" ");  int n = Integer.parseInt(line[0]);  int r = Integer.parseInt(line[1]); line = in.readLine().split(" "); double[] x = new double[n];  double[] y = new double[n]; for ( int i = 0;(i < n);i++) {y[i] = r; x[i] = Integer.parseInt(line[i]); }for ( int i = 1;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) > (r * 2))) {continue;} double low = y[j];  double high = (y[j] + ((double)r * 2.0)); for ( int k = 0;((k < 85) && (low < high));k++) { double mid = ((low + high) / 2.0); if ( (Point2D.distance(x[j],y[j],x[i],mid) < ((double)r * 2.0))) {low = mid; } else {high = mid; }}y[i] = Math.max(y[i],low); }}System.out.printf("%.15f",y[0]); for ( int i = 1;(i < n);i++) {System.out.printf(" %.15f",y[i]); }System.out.print("\n"); } }
6	public class Main{ static Scanner in = new Scanner(System.in); static Coor[] p ; static Coor ori ; static int n ; static int dp[] ; static Coor pre[] ; public static void main( String[] args){ ori = new Coor(in.nextInt(),in.nextInt()); n = in.nextInt(); p = new Coor[n]; dp = new int[(1 << n)]; pre = new Coor[(1 << n)]; for ( int i = 0;(i < n);i++) {p[i] = new Coor(in.nextInt(),in.nextInt()); }Arrays.fill(dp,-1); dp[0] = 0; System.out.println(getdp(((1 << n) - 1))); System.out.printf("%d",0); trace(((1 << n) - 1)); System.out.println(); } static void trace( int mask){ if ( (mask == 0)) return ; if ( (pre[mask].y == -1)) {System.out.printf(" %d %d",(pre[mask].x + 1),0); trace((mask - (1 << pre[mask].x))); } else {System.out.printf(" %d %d %d",(pre[mask].x + 1),(pre[mask].y + 1),0); trace(((mask - (1 << pre[mask].x)) - (1 << pre[mask].y))); }} static int getdp( int mask){ if ( (dp[mask] != -1)) return dp[mask]; int fr = 0; for ( int i = 0;(i < n);i++) if ( ((mask & (1 << i)) != 0)) {fr = i; break;} dp[mask] = (getdp((mask - (1 << fr))) + (2 * p[fr].dist(ori))); pre[mask] = new Coor(fr,-1); for ( int i = (fr + 1);(i < n);i++) { int to = i; if ( ((mask & (1 << i)) != 0)) { int tmp = (((getdp(((mask - (1 << fr)) - (1 << i))) + p[fr].dist(ori)) + p[to].dist(ori)) + p[fr].dist(p[to])); if ( (tmp < dp[mask])) {dp[mask] = tmp; pre[mask].y = i; } } }return dp[mask];} } class Coor{ int x ,y ; Coor( int _x, int _y){ x = _x; y = _y; } int dist( Coor o){ return (((x - o.x) * (x - o.x)) + ((y - o.y) * (y - o.y)));} }
2	public class Practice{ static long MOD = ((long)Math.pow(10,9) + 7); public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } static InputReader in ; static PrintWriter w ; static void solve(){ in = new InputReader(System.in); w = new PrintWriter(System.out); long n = in.nextLong();  long s = in.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)) {w.println(0); } else w.println(((n - ans) + 1)); } static boolean check( long n, long s){ long temp = n;  long sum = 0; while((temp > 0)){sum += (temp % 10); temp = (temp / 10); }if ( ((n - sum) >= s)) {return true;} return false;} static int adj[][] ; static int V ; static long gcd( long a, long b){ if ( (a == 0)) {return b;} return gcd((b % a),a);} static int Arr[] ; static long size[] ; static int root( int i){ while((Arr[i] != i)){Arr[i] = Arr[Arr[i]]; i = Arr[i]; }return i;} static int maxlevel = 0; static int minPrime[] ; static long[] extendedEuclid( long A, long B){ if ( (B == 0)) { long d = A;  long x = 1;  long y = 0; return new long[]{x,y,d};} else { long arr[] = extendedEuclid(B,(A % B));  long temp = arr[0]; arr[0] = arr[1]; arr[1] = (temp - ((A / B) * arr[1])); return arr;}} static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ,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 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);} 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); } } }
4	public class Main{ 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());} int[] nextArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} long[] nextArray( long n){ long[] a = new long[(int)n]; for ( int i = 0;(i < n);i++) a[i] = nextLong(); return a;} long nextLong(){ return Long.parseLong(next());} } static class FastWriter extends PrintWriter{ FastWriter(){ super(System.out); } void println( int[] array){ for ( int i = 0;(i < array.length);i++) {print((array[i] + " ")); }println(); } void println( long[] array){ for ( int i = 0;(i < array.length);i++) {print((array[i] + " ")); }println(); } } static int MOD = 998244353; public static void main( String[] args){ FastScanner in = new FastScanner();  FastWriter out = new FastWriter();  Scanner sc = new Scanner(System.in);  int t = in.nextInt(); while((t-- > 0)){ int n = in.nextInt();  int[] ar = in.nextArray(n);  int[] level = new int[1005];  int j = 1; level[1] = 1; out.println(1); for ( int i = 1;(i < n);i++) {if ( (ar[i] == 1)) {j++; level[j] = 1; } else {while((j >= 1)){if ( ((level[j] + 1) != ar[i])) {j--; } else {break;}}level[j]++; }for ( int k = 1;(k <= j);k++) {if ( (k == j)) {out.print(level[k]); } else {out.print((level[k] + ".")); }}out.println(); }}out.close(); } static boolean subset( int[] ar, int n, int sum){ if ( (sum == 0)) {return true;} if ( ((n < 0) || (sum < 0))) {return false;} return (subset(ar,(n - 1),sum) || subset(ar,(n - 1),(sum - ar[n])));} 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));} }
2	public class q5{ public static void main( String[] args)throws IOException { Reader.init(System.in); PrintWriter out = new PrintWriter(System.out);  long n = Reader.nextInt();  long k = Reader.nextLong();  long v = (((8 * n) + (8 * k)) + 4);  long v2 = (long)Math.sqrt(v);  long v3 = ((2 * n) + 2);  long v5 = ((v3 - v2) / 2); out.println(v5); out.flush(); } }
6	public class Order8C implements Runnable{ private Scanner in = new Scanner(System.in); private PrintWriter out = new PrintWriter(System.out); int mintime ; String path ; int xs ; int ys ; int n ; int[] obx ; int[] oby ; public static void main( String[] args){ new Thread(new Order8C()).start(); } private void read(){ xs = in.nextInt(); ys = in.nextInt(); n = in.nextInt(); obx = new int[n]; oby = new int[n]; for ( int i = 0;(i < n);i++) {obx[i] = in.nextInt(); oby[i] = in.nextInt(); }} private void solve(){ int[] ds = new int[n];  int[][] d = new int[n][n];  int[] best = new int[(1 << n)];  int[] last = new int[(1 << n)]; for ( int i = 0;(i < n);i++) {ds[i] = (((obx[i] - xs) * (obx[i] - xs)) + ((oby[i] - ys) * (oby[i] - ys))); for ( int j = (i + 1);(j < n);j++) {d[i][j] = (((obx[i] - obx[j]) * (obx[i] - obx[j])) + ((oby[i] - oby[j]) * (oby[i] - oby[j]))); d[j][i] = (((obx[i] - obx[j]) * (obx[i] - obx[j])) + ((oby[i] - oby[j]) * (oby[i] - oby[j]))); }}for ( int i = 0;(i < (1 << n));i++) {best[i] = 100000000; }best[0] = 0; for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( (((1 << j) & i) != 0)) {if ( ((best[(i - (1 << j))] + (2 * ds[j])) < best[i])) {best[i] = (best[(i - (1 << j))] + (2 * ds[j])); last[i] = (i - (1 << j)); } for ( int k = (j + 1);(k < n);k++) {if ( (((1 << k) & i) != 0)) {if ( ((((best[((i - (1 << j)) - (1 << k))] + ds[j]) + ds[k]) + d[j][k]) < best[i])) {best[i] = (((best[((i - (1 << j)) - (1 << k))] + ds[j]) + ds[k]) + d[j][k]); last[i] = ((i - (1 << j)) - (1 << k)); } } }break;} }} int i = ((1 << n) - 1); mintime = best[i]; path = ""; while((i > 0)){path = (path + "0 "); int dif = (i - last[i]); for ( int j = 0;(j < n);j++) {if ( (((1 << j) & dif) != 0)) {path = ((path + (j + 1)) + " "); } }i = last[i]; }path = (path + "0"); } private void write(){ out.println(mintime); out.println(path); } }
6	public class Main{ public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } void solve(){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ScanReader in = new ScanReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  FElongatedMatrix solver = new FElongatedMatrix(); solver.solve(1,in,out); out.close(); } static class FElongatedMatrix{ int[][] G ; int[][] G1 ; public int findIt( int[] map, int n, int start){ int[][] mask = new int[(1 << n)][n]; for ( int i = 0;(i < n);i++) mask[(1 << i)][i] = G[start][map[i]]; for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < n);k++) {if ( (((k != j) && ((i & (1 << k)) == 0)) && ((i & (1 << j)) != 0))) {mask[(i | (1 << k))][k] = Math.max(mask[(i | (1 << k))][k],Math.min(mask[i][j],G[map[j]][map[k]])); } }}} int ans = 0; for ( int i = 0;(i < n);i++) ans = Math.max(ans,Math.min(mask[((1 << n) - 1)][i],G1[start][map[i]])); return ans;} public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int m = in.scanInt(); G = new int[n][n]; G1 = new int[n][n]; int[][] ar = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {ar[i][j] = in.scanInt(); }}if ( (n == 1)) { int ans = Integer.MAX_VALUE; for ( int i = 0;(i < (m - 1));i++) ans = Math.min(ans,Math.abs((ar[0][i] - ar[0][(i + 1)]))); out.println(ans); return ;} 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 = Math.min(min,Math.abs((ar[i][k] - ar[j][k]))); G[i][j] = G[j][i] = min; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i == j)) continue; int min = Integer.MAX_VALUE; for ( int k = 1;(k < m);k++) min = Math.min(min,Math.abs((ar[i][k] - ar[j][(k - 1)]))); G1[i][j] = min; }} int[] map ;  int ans = 0; for ( int i = 0;(i < n);i++) {map = new int[(n - 1)]; int tl = 0; for ( int temp = 0;(temp < n);temp++) {if ( (temp == i)) continue; map[tl++] = temp; }ans = Math.max(ans,findIt(map,(n - 1),i)); }out.println(ans); } } 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
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);  BSportMafia solver = new BSportMafia(); solver.solve(1,in,out); out.close(); } static class BSportMafia{ private InputReader in ; private OutputWriter out ; public void solve( int testNumber, InputReader in, OutputWriter out){ this.in = in; this.out = out; long n = in.nextInt();  long k = in.nextInt(); for ( long i = 1;((((i * (i + 1)) / 2) + i) <= (n + k));i++) {if ( ((((i * (i + 1)) / 2) + i) == (n + k))) {out.println((n - i)); return ;} }} } static class InputReader extends InputStream{ 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 - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} static private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } static class OutputWriter{ private final PrintWriter out ; public OutputWriter( OutputStream outputStream){ out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.out = new PrintWriter(writer); } public void close(){ out.close(); } public void println( long i){ out.println(i); } } }
3	public class C{ static long mod = 1000000007; static int n ; static long w[][] ; static void MainMethod()throws Exception { n = reader.nextInt(); w = new long[(n + 2)][(n + 2)]; for ( int i = 0;(i <= (n + 1));i++) Arrays.fill(w[i],0); w[1][0] = 1; String prev ,next ; prev = reader.next(); long s[] = new long[(n + 2)]; for ( int i = 2;(i <= n);i++) {next = reader.next(); if ( prev.equals("f")) for ( int lv = 0;(lv <= n);lv++) w[i][(lv + 1)] = w[(i - 1)][lv]; else for ( int lv = n;(lv >= 0);lv--) {w[i][lv] = ((w[(i - 1)][lv] + w[i][(lv + 1)]) % mod); }prev = next; } long res = 0; for ( int i = 0;(i <= n);i++) res = ((res + w[n][i]) % mod); printer.print(res); } public static void main( String[] args)throws Exception { MainMethod(); printer.close(); } static PrintWriter printer = new PrintWriter(new OutputStreamWriter(System.out)); }
3	public class ProblemC{ static long MOD = 1_000_000_007; public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt();  boolean[] isFor = new boolean[n]; for ( int a = 0;(a < n);a++) {isFor[a] = (input.next().charAt(0) == 'f'); } long[][] array = new long[(n + 1)][(n + 1)]; array[0][0] = 1; boolean isPreviousFor = false; for ( int idx = 0;(idx < n);idx++) { long heightCache = 0; for ( int height = (n - 1);(height >= 0);height--) {if ( isPreviousFor) {array[(idx + 1)][(height + 1)] += array[idx][height]; array[(idx + 1)][(height + 1)] %= MOD; } else {heightCache += array[idx][height]; heightCache %= MOD; array[(idx + 1)][height] += heightCache; array[(idx + 1)][height] %= MOD; }}isPreviousFor = isFor[idx]; } long sum = 0; for ( int height = 0;(height <= n);height++) {sum += array[n][height]; }System.out.println((sum % MOD)); } }
5	public class A{ class Team implements Comparable<Team>{ int p ,t ; public Team( int p, int t){ this.p = p; this.t = t; } public int compareTo( Team other){ if ( (this.p != other.p)) return (other.p - this.p); return (this.t - other.t);} } public void solve()throws IOException { int n = nextInt();  int K = (nextInt() - 1);  Team[] team = new Team[n]; for ( int i = 0;(i < n);i++) team[i] = new Team(nextInt(),nextInt()); Arrays.sort(team); int ans = -1;  int pre = 0; for ( int i = 1;(i < n);i++) if ( (team[i].compareTo(team[(i - 1)]) != 0)) {if ( ((K >= pre) && (K < i))) {ans = (i - pre); break;} pre = i; } if ( (ans == -1)) ans = (n - pre); writer.println(ans); } public static void main( String[] args)throws FileNotFoundException { new A().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{ long tbegin = System.currentTimeMillis(); reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); solve(); 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 Main{ InputStream is ; PrintWriter out ; String INPUT = ""; long MOD = 1_000_000_007; int inf = Integer.MAX_VALUE; void solve(){ int n = ni();  int r = ni();  int[] x = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = ni(); } double[] y = new double[n]; Arrays.fill(y,-1); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) { double res = (((4 * r) * r) - ((x[i] - x[j]) * (x[i] - x[j]))); if ( (res < 0)) continue; else { double tmp = (Math.sqrt(res) + y[j]); if ( (tmp > y[i])) {y[i] = tmp; } }}if ( (y[i] == -1)) y[i] = r; }for ( int i = 0;(i < n);i++) {out.print((y[i] + " ")); }} 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]; 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) && (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(); }} static private void tr( Object... o){ System.out.println(Arrays.deepToString(o)); } }
5	public class C{ public static final long MAX = 1000000000L; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer tok1 = new StringTokenizer(br.readLine()); final int n = Integer.parseInt(tok1.nextToken()); final long k = Integer.parseInt(tok1.nextToken());  StringTokenizer tok2 = new StringTokenizer(br.readLine());  int[] array = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = Integer.parseInt(tok2.nextToken()); } int size = n; Arrays.sort(array); boolean[] skip = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( skip[i]) {size--; continue;} long input = array[i]; input *= k; if ( (input > MAX)) {continue;} final int pos = Arrays.binarySearch(array,(int)input); if ( ((pos >= 0) && !skip[pos])) {skip[pos] = true; } }System.out.println(size); } }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] in = br.readLine().split(" ");  int n = Integer.parseInt(in[0]),m = Integer.parseInt(in[1]),k = Integer.parseInt(in[2]);  StringTokenizer st = new StringTokenizer(br.readLine());  int[] caps = new int[n]; for ( int i = 0;(i < caps.length);i++) {caps[i] = Integer.parseInt(st.nextToken()); }Arrays.sort(caps); int curSockets = k,neededLines = 0;  int i = (n - 1); while(((curSockets < m) && (i >= 0))){curSockets += (caps[i] - 1); neededLines++; i--; }if ( (curSockets >= m)) System.out.println(neededLines); else System.out.println(-1); } }
4	public class E2_SquareFreeDivision2{ static FastScanner sc = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ int MAX = (int)1e7;  int[] spf = new int[(MAX + 1)]; for ( int i = 2;(i <= MAX);i++) {if ( (spf[i] == 0)) {spf[i] = i; for ( int j = (i + i);(j <= MAX);j += i) {if ( (spf[j] == 0)) {spf[j] = i; } }} } int[] freq = new int[(MAX + 1)];  int T = sc.nextInt(); while((T-- > 0)){ int N = sc.nextInt();  int K = sc.nextInt();  int[] a = new int[(N + 1)]; for ( int i = 1;(i <= N);i++) {a[i] = sc.nextInt(); int canonical = 1; while((a[i] > 1)){ int factor = spf[a[i]];  int parity = 0; while(((a[i] % factor) == 0)){a[i] /= factor; parity ^= 1; }if ( (parity == 1)) {canonical *= factor; } }a[i] = canonical; } int[][] transition = new int[(K + 1)][(N + 1)]; for ( int k = 0;(k <= K);k++) { int l = (N + 1);  int duplicates = 0; for ( int r = N;(r >= 1);r--) {while(((l - 1) >= 1)){ int nextDuplicates = duplicates; if ( (freq[a[(l - 1)]] >= 1)) {nextDuplicates++; } if ( (nextDuplicates <= k)) {duplicates = nextDuplicates; freq[a[(l - 1)]]++; l--; } else {break;}}transition[k][r] = l; if ( (--freq[a[r]] >= 1)) {duplicates--; } }} int[][] dp = new int[(K + 1)][(N + 1)];  int oo = (int)1e9; for ( int[] row :dp) {Arrays.fill(row,oo); }for ( int k = 0;(k <= K);k++) {dp[k][0] = 0; }for ( int r = 1;(r <= N);r++) {for ( int k = 0;(k <= K);k++) {for ( int delta = 0;(delta <= k);delta++) {dp[k][r] = min(dp[k][r],(dp[(k - delta)][(transition[delta][r] - 1)] + 1)); }}}out.println(dp[K][N]); }out.close(); } 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); } } 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++];} int nextInt(){ return (int)nextLong();} 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);} } }
3	public class D{ static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ boolean even = true;  int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); for ( int j = 0;(j < i);j++) {if ( (a[j] > a[i])) {even = !even; } }} int m = in.nextInt(); for ( int i = 0;(i < m);i++) {if ( (((((1 - in.nextInt()) + in.nextInt()) / 2) % 2) == 1)) {even = !even; } if ( even) out.println("even"); else out.println("odd"); }finish(); } public static void finish(){ out.close(); in.close(); System.exit(0); } static class InputReader implements Iterator<String>,Closeable{ private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; public InputReader( InputStream i){ r = new BufferedReader(new InputStreamReader(i)); } public int nextInt(){ return Integer.parseInt(nextToken());} public void close(){ try{r.close(); }catch (IOException e){ } } private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} } }
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);  A solver = new A(); solver.solve(1,in,out); out.close(); } } class A{ public void solve( int testNumber, InputReader in, PrintWriter out){ int number = in.nextInt(); if ( ((number & 1) == 0)) {out.println(((4 + " ") + (number - 4))); } else {out.println(((9 + " ") + (number - 9))); }} } class InputReader{ private final BufferedReader bufferedReader ; private StringTokenizer stringTokenizer ; public InputReader( InputStream in){ bufferedReader = new BufferedReader(new InputStreamReader(in)); stringTokenizer = null; } public String nextLine(){ try{return bufferedReader.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} } public String nextBlock(){ while(((stringTokenizer == null) || !stringTokenizer.hasMoreTokens())){stringTokenizer = new StringTokenizer(nextLine()); }return stringTokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(nextBlock());} }
6	public class EMatrix{ 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.flush(); out.close(); } static class TaskE{ final int max = (int)1E9; int n ,m ; int a[][] ; int gm[] ; boolean visit[][] ; int dp[][] ; boolean check( int d){ if ( (n == 1)) {for ( int i = 0;(i < (m - 1));i++) {if ( (Math.abs((a[0][i] - a[0][(i + 1)])) < d)) return false; }return true;} int nm[] = new int[n],pm[] = new int[n]; for ( int i = 0;(i < n);i++) { boolean r ; for ( int j = 0;(j < n);j++) {if ( (j == i)) continue; r = true; for ( int k = 0;(k < m);k++) {if ( (Math.abs((a[i][k] - a[j][k])) < d)) {r = false; break;} }if ( r) {nm[i] |= (1 << j); } r = true; for ( int k = 0;(k < (m - 1));k++) {if ( (Math.abs((a[i][(k + 1)] - a[j][k])) < d)) {r = false; break;} }if ( r) {pm[i] |= (1 << j); } }}for ( int i = 0;(i < n);i++) {gm = new int[n]; gm[i] = nm[i]; for ( int j = 0;(j < n);j++) {if ( (j == i)) continue; if ( ((nm[j] & (1 << i)) != 0)) {gm[j] = (nm[j] ^ (1 << i)); } else {gm[j] = nm[j]; }}for ( int j = 0;(j < n);j++) {if ( (j == i)) continue; if ( (((pm[i] >> j) % 2) == 1)) {gm[j] |= (1 << i); } }visit = new boolean[n][(1 << n)]; dp = new int[n][(1 << n)]; if ( (dfs(i,i,(1 << i)) == n)) {return true;} }return false;} int dfs( int u, int r, int mask){ if ( ((u == r) && (mask == ((1 << n) - 1)))) return 0; if ( visit[u][mask]) return dp[u][mask]; visit[u][mask] = true; int val = 0; for ( int i = 0;(i < n);i++) {if ( ((((gm[u] >> i) % 2) == 1) && (((i == r) && (mask == ((1 << n) - 1))) || (((mask >> i) % 2) != 1)))) {val = Math.max(val,(1 + dfs(i,r,(mask | (1 << i))))); } }return dp[u][mask] = val;} public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); a = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[i][j] = in.nextInt(); }} int l = 0,r = max,ans = 0; while((l <= r)){ int m = ((l + r) >> 1); if ( check(m)) {ans = m; l = (m + 1); } else {r = (m - 1); }}out.println(ans); } } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); st = null; } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} public int nextInt(){ return Integer.parseInt(next());} } }
6	public class Main{ public class BasicInputOutput{ private StringTokenizer strtoken ; private BufferedReader bufferReader ; private BufferedWriter bufferWriter ; private String delim = " \t\n\r\f"; BasicInputOutput(){ delim = " \t\n\r\f"; initialize(); } BasicInputOutput( String s){ delim = s; initialize(); } private void initialize(){ bufferReader = new BufferedReader(new InputStreamReader(System.in)); bufferWriter = new BufferedWriter(new PrintWriter(System.out)); strtoken = null; } private void checkStringTokenizer()throws IOException { if ( ((strtoken == null) || (strtoken.hasMoreTokens() == false))) strtoken = new StringTokenizer(bufferReader.readLine(),delim); } public int getNextInt()throws IOException { checkStringTokenizer(); return Integer.parseInt(strtoken.nextToken());} public double getNextDouble()throws IOException { checkStringTokenizer(); return Double.parseDouble(strtoken.nextToken());} public void write( String var)throws IOException { bufferWriter.write(var); } public <T> void write( char sep, T... var)throws IOException { if ( (var.length == 0)) return ; bufferWriter.write(var[0].toString()); for ( int i = 1;(i < var.length);i++) bufferWriter.write((sep + var[i].toString())); } public void flush()throws IOException { bufferWriter.flush(); } } public static void main( String[] args){ try{new Main().run(); }catch (Exception ex){ ex.printStackTrace(); } } private BasicInputOutput iohandler ; private int n ; private double[][] mat ; private double[][] sum ; private double[] dp ; private int tolive ; private void run()throws Exception { initialize(); solve(); } private void initialize()throws Exception { iohandler = new BasicInputOutput(); n = iohandler.getNextInt(); mat = new double[n][n]; sum = new double[((1 << n) + 10)][n]; dp = new double[(1 << n)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) {mat[i][j] = iohandler.getNextDouble(); }} private int bitCount( int mask){ int ret = 0; while((mask > 0)){ret++; mask &= (mask - 1); }return ret;} private void solve()throws Exception { double[] ans = new double[n];  int ub = (1 << n); for ( int i = 1;(i < ub);i++) {for ( int j = 0;(j < n);j++) {sum[i][j] = 0; for ( int k = 0;(k < n);k++) if ( ((i & (1 << k)) != 0)) sum[i][j] += mat[k][j];  int cntbit = bitCount(i); if ( (cntbit > 1)) sum[i][j] /= (((double)cntbit * (cntbit - 1.)) / 2.); }}for ( int i = 0;(i < n);i++) {for ( int mask = 1;(mask < ub);mask++) {dp[mask] = 0; if ( ((mask & (1 << i)) == 0)) continue; if ( (bitCount(mask) == 1)) {dp[mask] = 1.; } else for ( int k = 0;(k < n);k++) {if ( ((mask & (1 << k)) == 0)) continue; if ( (i == k)) continue; dp[mask] += (sum[mask][k] * dp[(mask - (1 << k))]); }}ans[i] = dp[(ub - 1)]; }iohandler.write((ans[0] + "")); for ( int i = 1;(i < n);i++) iohandler.write((" " + ans[i])); iohandler.write("\n"); iohandler.flush(); } }
1	public class C{ public static void main( String[] args){ Kattio sc = new Kattio(System.in);  int n = sc.getInt();  String s = sc.getWord();  int[] found = new int[('z' + 1)];  int amount = 0; for ( int i = 0;(i < s.length());i++) { char c = s.charAt(i); if ( (found[c] == 0)) amount++; found[c]++; } int contains[] = new int[('z' + 1)];  int min = n;  int start = 0;  int end = 0;  int in = 0; while(true){if ( (in < amount)) {if ( (end == n)) break; char c = s.charAt(end); if ( (contains[c] == 0)) in++; contains[c]++; end++; } else {if ( (min > (end - start))) min = (end - start);  char c = s.charAt(start); if ( (contains[c] == 1)) in--; contains[c]--; start++; }}System.out.println(min); } } class Kattio extends PrintWriter{ public Kattio( InputStream i){ super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(i)); } public Kattio( InputStream i, OutputStream o){ super(new BufferedOutputStream(o)); r = new BufferedReader(new InputStreamReader(i)); } public boolean hasMoreTokens(){ return (peekToken() != null);} public int getInt(){ return Integer.parseInt(nextToken());} public String getWord(){ return nextToken();} private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} }
1	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(); } static private void solve()throws Exception { int n = nextInt();  int co = 0,ce = 0;  int[] v = new int[n]; for ( int i = 0;(i < n);i++) {v[i] = nextInt(); }for ( int i = 0;(i < n);i++) {if ( ((v[i] % 2) == 0)) {co++; } else {ce++; }}if ( (co == 1)) {for ( int i = 0;(i < n);i++) {if ( ((v[i] % 2) == 0)) {out.println((i + 1)); return ;} }} else {for ( int i = 0;(i < n);i++) {if ( ((v[i] % 2) != 0)) {out.println((i + 1)); return ;} }}} static private BufferedReader in ; static private PrintWriter out ; static private 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());} }
1	public class C43{ static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter out = new PrintWriter(System.out); static int nextInt()throws IOException { in.nextToken(); return Integer.valueOf(in.sval);} static String nextString()throws IOException { in.nextToken(); return in.sval;} {in.ordinaryChars('0','9'); in.wordChars('0','9'); in.ordinaryChars('.','.'); in.wordChars('.','.'); in.ordinaryChars('-','-'); in.wordChars('-','-'); }public static void main( String[] args)throws IOException { int n = nextInt();  char[] s = nextString().toCharArray();  int h = 0; for ( int i = 0;(i < n);i++) if ( (s[i] == 'H')) h++;  int ans = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int p = i,t = 0; for ( int j = 0;(j < h);j++,p = ((p + 1) % n)) if ( (s[p] == 'T')) t++; ans = Math.min(ans,t); }out.println(ans); out.flush(); } }
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(); } }
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(); } 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]))); 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)))); } int[] best = new int[(1 << n)];  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); for ( int j = (i + 1);(j < n);++j) if ( ((set & (1 << j)) != 0)) { int cur = (best[((set ^ (1 << i)) ^ (1 << j))] + pair[i][j]); if ( (cur < best[set])) {best[set] = cur; prev[set] = ((1 << i) | (1 << j)); } } }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();} }
5	public class Beta97B{ static Scanner in ; static StreamTokenizer st ; static int n ; static int[] a ; static int max = 1; public static void main( String[] args)throws IOException { st = new StreamTokenizer(new InputStreamReader(System.in)); n = nextInt(); a = new int[n]; int ind = 0; for ( int i = 0;(i < n);++i) {a[i] = nextInt(); if ( (a[i] > max)) {max = a[i]; ind = i; } }if ( (max == 1)) {a[0] = 2; } else {a[ind] = 1; }Arrays.sort(a); for ( int i = 0;(i < n);++i) System.out.print((a[i] + " ")); } static private int nextInt()throws IOException { st.nextToken(); return (int)st.nval;} }
0	public class dwl{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  String[] lr = sc.nextLine().split(" ");  long l = Long.valueOf(lr[0]);  long r = Long.valueOf(lr[1]); if ( ((((r - l) <= 1) || ((l == 1) && ((r - l) == 2))) || (((l % 2) != 0) && ((r - l) < 3)))) System.out.println(-1); else {if ( (l == 1)) System.out.println(((((2 + " ") + 3) + " ") + 4)); else {if ( ((l % 2) == 0)) { String res = ""; res += (l + " "); res += ((l + 1) + " "); res += ((l + 2) + " "); res = res.trim(); System.out.println(res); } else { String res = ""; res += ((l + 1) + " "); res += ((l + 2) + " "); res += ((l + 3) + " "); res = res.trim(); System.out.println(res); }}}} }
6	public class Template{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; public static void main( String[] args)throws IOException { new Template().run(); } void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); st = null; out = new PrintWriter(System.out); solve(); br.close(); out.close(); } double dm[] ; double a[][] ; boolean fil[] ; int p[] ; int n ; void solve()throws IOException { n = nextInt(); a = new double[n][n]; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);++j) {a[i][j] = nextDouble(); }dm = new double[(1 << n)]; dm[((1 << n) - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask >= 1);--mask) { int c = Integer.bitCount(mask); if ( (c == 1)) continue; double p = ((2.0 / (double)(c - 1)) / (double)c); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {if ( (((i != j) && ((mask & (1 << i)) > 0)) && ((mask & (1 << j)) > 0))) {dm[(mask ^ (1 << j))] += ((a[i][j] * dm[mask]) * p); } }}}for ( int i = 0;(i < n);++i) {out.print((dm[(1 << i)] + " ")); }} int nextInt()throws IOException { return Integer.parseInt(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(br.readLine()); }return st.nextToken();} }
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(); } }
4	public class Fire_Again{ static int N ; static int M ; static int K ; private class Pos{ public int r ; public int c ; int last ; public Pos( int r, int c, int last){ this.r = r; this.c = c; this.last = last; } } static ArrayList<Pos> pos = new ArrayList<>(); static boolean[][] used ; static int[] rows = {-1,1,0,0}; static int[] cols = {0,0,-1,1}; int LAST = 0; int lastRow = 1; int lastCol = 1; public static void main( String[] args)throws IOException { Fire_Again fire_again = new Fire_Again();  BufferedReader bufferedReader = new BufferedReader(new FileReader("input.txt"));  String[] nm = bufferedReader.readLine().split(" "); N = (Integer.parseInt(nm[0]) + 1); M = (Integer.parseInt(nm[1]) + 1); K = Integer.parseInt(bufferedReader.readLine()); used = new boolean[N][M]; String[] rc = bufferedReader.readLine().split(" "); for ( int k = 0;(k < rc.length);k += 2) { int r = Integer.parseInt(rc[k]);  int c = Integer.parseInt(rc[(k + 1)]); pos.add(new Pos(r,c,0)); }fire_again.bfs(); PrintStream ps = new PrintStream("output.txt"); ps.printf("%d %d\n",fire_again.lastRow,fire_again.lastCol); ps.flush(); ps.close(); } Queue<Pos> queue = new LinkedList<>(); private void bfs(){ queue.addAll(pos); for ( Pos p :pos) {used[p.r][p.c] = true; }while(!queue.isEmpty()){ Pos p = queue.poll(); if ( (p.last > LAST)) {LAST = p.last; lastRow = p.r; lastCol = p.c; } for ( int i = 0;(i < rows.length);i++) { int currR = p.r;  int currC = p.c; if ( ((((((currR + rows[i]) >= 1) && ((currR + rows[i]) < N)) && ((currC + cols[i]) >= 1)) && ((currC + cols[i]) < M)) && !used[(currR + rows[i])][(currC + cols[i])])) {queue.add(new Pos((currR + rows[i]),(currC + cols[i]),(p.last + 1))); used[(currR + rows[i])][(currC + cols[i])] = true; } }}} }
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); solve(in,out); out.close(); } static String reverse( String s){ return new StringBuilder(s).reverse().toString();} static void sort( int[] ar){ int n = ar.length;  ArrayList<Integer> a = new ArrayList<>(); for ( int i = 0;(i < n);i++) a.add(ar[i]); Collections.sort(a); for ( int i = 0;(i < n);i++) ar[i] = a.get(i); } static long ncr( long n, long r, long mod){ if ( (r == 0)) return 1; long val = ncr((n - 1),(r - 1),mod); val = ((n * val) % mod); val = ((val * modInverse(r,mod)) % mod); return val;} static int findMax( int[] a, int n, int[] vis, int i, int d){ if ( (i >= n)) return 0; if ( (vis[i] == 1)) return findMax(a,n,vis,(i + 1),d); int max = 0; for ( int j = (i + 1);(j < n);j++) {if ( ((Math.abs((a[i] - a[j])) > d) || (vis[j] == 1))) continue; vis[j] = 1; max = Math.max(max,(1 + findMax(a,n,vis,(i + 1),d))); vis[j] = 0; }return max;} public static void solve( InputReader sc, PrintWriter pw){ int i ,j = 0;  int t = sc.nextInt(); u:while((t-- > 0)){ int n = sc.nextInt();  int a[] = new int[n];  ArrayList<Integer> ar = new ArrayList<>(); ar.add(0); for ( i = 0;(i < 1000);i++) {ar.add(0); } int m = 1; for ( i = 0;(i < n);i++) {a[i] = sc.nextInt(); if ( (a[i] == 1)) {ar.set(m,1); m++; } else {while(((m > 0) && (ar.get((m - 1)) != (a[i] - 1)))){m--; }ar.set((m - 1),a[i]); }pw.print(ar.get(1)); for ( j = 2;(j < m);j++) {pw.print(("." + ar.get(j))); }pw.println(); }}} static void assignAnc( ArrayList<Integer>[] ar, int[] sz, int[] pa, int curr, int par){ sz[curr] = 1; pa[curr] = par; for ( int v :ar[curr]) {if ( (par == v)) continue; assignAnc(ar,sz,pa,v,curr); sz[curr] += sz[v]; }} static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static long fast_pow( long base, long n, long M){ if ( (n == 0)) return 1; if ( (n == 1)) return (base % M); long halfn = fast_pow(base,(n / 2),M); if ( ((n % 2) == 0)) return ((halfn * halfn) % M); else return ((((halfn * halfn) % M) * base) % M);} static long modInverse( long n, long M){ return fast_pow(n,(M - 2),M);} static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),9992768); 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 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());} } }
1	public class Array{ void run(){ try{ BufferedReader bfd = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer tk = new StringTokenizer(bfd.readLine());  int n = Integer.parseInt(tk.nextToken());  int k = Integer.parseInt(tk.nextToken()),i ;  int arr[] = new int[n]; tk = new StringTokenizer(bfd.readLine()); for ( i = 0;(i < n);++i) arr[i] = Integer.parseInt(tk.nextToken()); int dist = 0,l = 0,r = 0;  HashSet<Integer> hs = new HashSet<Integer>(); for ( i = 0;(i < n);++i) {if ( !hs.contains(arr[i])) {hs.add(arr[i]); dist++; } if ( (dist == k)) break; r++; } int freq[] = new int[100010]; if ( (hs.size() < k)) System.out.println("-1 -1"); else {while((((l < (arr.length - 1)) && (l < r)) && (arr[l] == arr[(l + 1)])))++l; while((((r >= 1) && (r > l)) && (arr[r] == arr[(r - 1)])))--r; for ( i = l;(i <= r);++i) freq[arr[i]]++; while((freq[arr[l]] > 1)){freq[arr[l]]--; l++; }while((freq[arr[r]] > 1)){freq[arr[r]]--; r--; }System.out.println((((l + 1) + " ") + (r + 1))); } }catch (Exception e){ } } public static void main( String[] args){ new Array().run(); } }
2	public class B{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long n = input.nextLong();  long k = input.nextLong(); System.out.println(solve(n,k)); input.close(); } public static long solve( long n, long k){ long dis = (n - k); if ( (n == 1)) return 0; if ( (((((k - 2) * ((k - 2) + 1)) / 2) + 1) <= dis)) return -1; if ( (k >= n)) return 1; long ans = 2;  long now = (((((k - 2) * ((k - 2) + 1)) / 2) + 1) + k);  long dist = Math.abs((now - n));  long delta = (1 + (8 * dist));  double ret = ((1 + Math.sqrt(delta)) / 2); now = (((((k - 2) * ((k - 2) + 1)) / 2) + 1) + k); dist = Math.abs((now - k)); delta = (1 + (8 * dist)); double nret = ((1 + Math.sqrt(delta)) / 2);  double back = (nret - ret); ans = (long)back; return (ans + 2);} }
2	public class MrBenderAndSquare{ static long n ,x ,y ,c ; public static void main( String[] args)throws IOException { Kattio io = new Kattio(System.in); n = io.getLong(); x = io.getLong(); y = io.getLong(); c = io.getLong(); long lo = 0;  long hi = c; while((lo < hi)){ long mid = (lo + ((hi - lo) / 2)); if ( (f(mid) >= c)) {hi = mid; } else {lo = (mid + 1); }}io.println(lo); io.close(); } static long f( long t){ long res = 0;  long left = Math.max(0,(t - (x - 1))); res -= (left * left); long right = Math.max(0,(t - (n - x))); res -= (right * right); long up = Math.max(0,(t - (y - 1))); res -= (up * up); long down = Math.max(0,(t - (n - y))); res -= (down * down); res += (1 + ((2 * t) * (t + 1))); long upLeft = Math.max(0,((t - (x + y)) + 1));  long upRight = Math.max(0,((t - (((n - x) + 1) + y)) + 1));  long downLeft = Math.max(0,((t - (((x + n) - y) + 1)) + 1));  long downRight = Math.max(0,((t - (((((n - x) + 1) + n) - y) + 1)) + 1)); res += ((upLeft * (upLeft + 1)) / 2); res += ((upRight * (upRight + 1)) / 2); res += ((downLeft * (downLeft + 1)) / 2); res += ((downRight * (downRight + 1)) / 2); return res;} static class Kattio extends PrintWriter{ public Kattio( InputStream i){ super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(i)); } public Kattio( InputStream i, OutputStream o){ super(new BufferedOutputStream(o)); r = new BufferedReader(new InputStreamReader(i)); } public boolean hasMoreTokens(){ return (peekToken() != null);} public long getLong(){ return Long.parseLong(nextToken());} private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} } }
2	public class Main{ static long initTime ; static final Random rnd = new Random(7777L); static boolean writeLog = false; public static void main( String[] args)throws IOException { initTime = System.currentTimeMillis(); try{writeLog = "true".equals(System.getProperty("LOCAL_RUN_7777")); }catch (SecurityException e){ } 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){ } long prevTime = System.currentTimeMillis(); new Main().run(); log((("Total time: " + (System.currentTimeMillis() - prevTime)) + " ms")); log(("Memory status: " + memoryStatus())); }catch (IOException e){ e.printStackTrace(); } } },"1",(1L << 24)).start(); } void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); in.close(); } void solve()throws IOException { long leftBorder = nextLong();  long rightBorder = nextLong();  long[][][][][] dp = new long[64][2][2][2][2]; for ( long[][][][] a :dp) for ( long[][][] b :a) for ( long[][] c :b) for ( long[] d :c) fill(d,-1L); dp[63][0][0][0][0] = 0L; for ( int lastBit = 63;(lastBit > 0);lastBit--) { int curBit = (lastBit - 1);  int leftBit = (int)((leftBorder >> curBit) & 1L);  int rightBit = (int)((rightBorder >> curBit) & 1L); for ( int agl = 0;(agl < 2);agl++) {for ( int alr = 0;(alr < 2);alr++) {for ( int bgl = 0;(bgl < 2);bgl++) {for ( int blr = 0;(blr < 2);blr++) { long prvXor = dp[lastBit][agl][alr][bgl][blr]; if ( (prvXor < 0L)) continue; for ( int ab = 0;(ab < 2);ab++) { int nagl = left(agl,leftBit,ab);  int nalr = right(alr,rightBit,ab); if ( ((nagl < 0) || (nalr < 0))) continue; for ( int bb = 0;(bb < 2);bb++) { int nbgl = left(bgl,leftBit,bb);  int nblr = right(blr,rightBit,bb); if ( ((nbgl < 0) || (nblr < 0))) continue; long setBit = (ab ^ bb); dp[curBit][nagl][nalr][nbgl][nblr] = max(dp[curBit][nagl][nalr][nbgl][nblr],(prvXor | (setBit << curBit))); }}}}}}} long answer = -1L; for ( int agl = 0;(agl < 2);agl++) {for ( int alr = 0;(alr < 2);alr++) {for ( int bgl = 0;(bgl < 2);bgl++) {for ( int blr = 0;(blr < 2);blr++) {answer = max(answer,dp[0][agl][alr][bgl][blr]); }}}}out.println(answer); } int left( int gl, int leftBit, int b){ if ( (gl == 0)) {if ( (b < leftBit)) return -1; if ( (b == leftBit)) return 0; if ( (b > leftBit)) return 1; } return 1;} int right( int lr, int rightBit, int b){ if ( (lr == 0)) {if ( (b < rightBit)) return 1; if ( (b == rightBit)) return 0; if ( (b > rightBit)) return -1; } return 1;} BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); String nextToken()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} static String memoryStatus(){ return (((((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20) + "/") + (Runtime.getRuntime().totalMemory() >> 20)) + " MB");} static long prevTimeStamp = Long.MIN_VALUE; static long elapsedTime(){ return (System.currentTimeMillis() - prevTimeStamp);} static void log( String format, Object... args){ if ( writeLog) System.err.println(String.format(Locale.US,format,args)); } }
3	public class Main{ static int bit[] ; static int array[] ; public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine()); bit = new int[1505]; array = new int[(n + 1)]; StringTokenizer st = new StringTokenizer(br.readLine()); for ( int i = 1;(i <= n);i++) array[i] = Integer.parseInt(st.nextToken()); long ans = 0; for ( int i = n;(i >= 1);i--) {ans += read(array[i]); update(array[i]); } long val = ((ans & 1) + 1000_000);  int m = Integer.parseInt(br.readLine());  StringBuilder sb = new StringBuilder(); for ( int i = 1;(i <= m);i++) {st = new StringTokenizer(br.readLine()); int l = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken());  long temp = ((r - l) + 1); temp = ((temp * (temp - 1)) / 2); if ( ((temp & 1) == 1)) --val; if ( ((val & 1) == 1)) sb.append("odd"); else sb.append("even"); sb.append('\n'); }System.out.print(sb); } static int update( int idx){ int sum = 0; while((idx < 1501)){bit[idx] += 1; idx += (idx & idx); }return sum;} static int read( int idx){ int sum = 0; while((idx > 0)){sum += bit[idx]; idx -= (idx & idx); }return sum;} }
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)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); } }
0	public class Codechef{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long m = in.nextLong();  long k = in.nextLong();  long l = in.nextLong();  long j = ((k + l) / m); if ( (((k + l) % m) != 0)) j++; if ( (((k + l) > n) || ((j * m) > n))) {System.out.println(-1); } else {System.out.println(j); }} }
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();} }
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))); } }
1	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  String str = in.next();  int cnt = 0; for ( int i = 0;(i < str.length());++i) {if ( (str.charAt(i) == '1')) {++cnt; } } int i = 0; for ( ;(i < str.length());++i) {if ( (str.charAt(i) == '0')) {System.out.print("0"); } else if ( (str.charAt(i) == '2')) {while((cnt-- > 0)){System.out.print("1"); }System.out.print("2"); } }while((cnt-- > 0)){System.out.print("1"); }in.close(); } }
1	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 ; void solve()throws IOException { ArrayList<Integer> p = new ArrayList<Integer>();  StringTokenizer st = tokens();  int n = nextInt(st),k = nextInt(st); for ( int i = 2;(i <= n);i++) if ( prime(i)) p.add(i);  int count = 0; for ( int x = 2;(x <= n);x++) {if ( !prime(x)) continue; for ( int i = 0;((i + 1) < p.size());i++) { int p1 = p.get(i);  int p2 = p.get((i + 1));  int P = ((p1 + p2) + 1); if ( (P == x)) {count++; break;} if ( (P > x)) break; }}System.out.println(((count >= k)?"YES":"NO")); } boolean prime( int n){ for ( int i = 2;((i * i) <= n);i++) if ( ((n % i) == 0)) return false; return true;} 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());} }
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();  boolean[] a = new boolean[218]; for ( int i = 0;(i < n);++i) {a[in.nextInt()] = true; } int res = 0; for ( int i = 1;(i < a.length);++i) {if ( a[i]) {++res; for ( int j = i;(j < a.length);j += i) {a[j] = false; }} }out.printLine(res); } } 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;} } }
4	public class FireAgain{ public static void main( String[] args){ File in = new File("input.txt");  File out = new File("output.txt");  Scanner sc ;  PrintWriter pw ; try{sc = new Scanner(in); pw = new PrintWriter(out); }catch (Exception e){ sc = new Scanner(System.in); pw = null; } int max_x = sc.nextInt();  int max_y = sc.nextInt();  int start_num = sc.nextInt();  HashSet<int[]> start = new HashSet<int[]>(); for ( int i = 0;(i < start_num);i++) { int[] cell = new int[2]; cell[0] = sc.nextInt(); cell[1] = sc.nextInt(); start.add(cell); } int[] result = new int[]{1,1};  int resultLen = 0; for ( int i = 1;(i <= max_x);i++) {for ( int j = 1;(j <= max_y);j++) { int[] sh = new int[]{1,1};  int shLen = Integer.MAX_VALUE; for ( int[] fired :start) { int len = (Math.abs((i - fired[0])) + Math.abs((j - fired[1]))); if ( (len < shLen)) {sh[0] = i; sh[1] = j; shLen = len; } }if ( (shLen > resultLen)) {result[0] = sh[0]; result[1] = sh[1]; resultLen = shLen; } }}pw.print(((result[0] + " ") + result[1])); pw.close(); return ;} }
0	public class RespectTheRules{ static private final double E = 1E-10; public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  double a = scanner.nextDouble();  double maxV = scanner.nextDouble();  double l = scanner.nextDouble();  double d = scanner.nextDouble();  double w = scanner.nextDouble();  double r = (l - d); w = Math.min(w,maxV); List<WayPoint> wayPoints = new ArrayList<WayPoint>(256);  double t = 0; wayPoints.add(new WayPoint(0)); double dW = dTo(w,0,a); if ( leq(dW,d)) {wayPoints.add(new WayPoint(w)); { double v = v(w,a,((d - dW) / 2)); v = Math.min(v,maxV); wayPoints.add(new WayPoint(v)); wayPoints.add(new WayPoint(w)); double dW_V = dTo(v,w,a);  double vDistance = ((d - dW) - (2 * dW_V)); if ( !eq(vDistance)) {t += (vDistance / maxV); } }{ double dW_MaxV = dTo(maxV,w,a); dW_MaxV = Math.min(dW_MaxV,r); double v = v(w,a,dW_MaxV); wayPoints.add(new WayPoint(v)); double dMaxV = (r - dW_MaxV); if ( !eq(dMaxV)) {t += (dMaxV / maxV); } }} else { double dMaxV = dTo(maxV,0,a); dMaxV = Math.min(dMaxV,l); double v = v(0,a,dMaxV); wayPoints.add(new WayPoint(v)); double dv = (l - dMaxV); if ( !eq(dMaxV)) {t += (dv / maxV); } }for ( int i = 1;(i < wayPoints.size());++i) { double v0 = wayPoints.get((i - 1)).v;  double v = wayPoints.get(i).v; t += Math.abs(tTo(v,v0,a)); }System.out.println(t); } static double tTo( double v, double v0, double a){ return ((v - v0) / a);} static double dTo( double v, double v0, double a){ return (((v * v) - (v0 * v0)) / (2 * a));} static double v( double v0, double a, double d){ return Math.sqrt((((2 * d) * a) + (v0 * v0)));} static boolean eq( double value){ return (Math.abs(value) <= E);} static boolean l( double v){ return (v < -E);} static boolean leq( double v){ return (l(v) || eq(v));} static boolean leq( double one, double another){ return leq((one - another));} static class WayPoint{ double v ; WayPoint( double v){ this.v = v; } } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Parser in = new Parser(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ int mod = 1000000009; public void solve( int testNumber, Parser in, OutputWriter out){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int o = m; m -= (n - (n / k)); if ( (m < 0)) m = 0;  long temp = (n / k);  long ans ; if ( (m == 0)) ans = 0; else {ans = (((MathUtils.modpow(2,(m + 1),mod) + mod) - 2) % mod); ans = ((ans * k) % mod); }out.println(((ans + (o - (m * k))) % mod)); } } class Parser{ private BufferedReader din ; private StringTokenizer tokenizer ; public Parser( InputStream in){ din = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(din.readLine()); }catch (Exception e){ throw (new UnknownError());} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } class OutputWriter extends PrintWriter{ public OutputWriter( Writer out){ super(out); } public OutputWriter( OutputStream out){ super(out); } }
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))); } }
4	public class Main{ public static Scanner scan = new Scanner(System.in); int n ,m ; int[][] x ; int[][] y ; int k ,k2 ; int[][] sol0 ; int[][] sol1 ; public Main( int[][] x, int[][] y, int k){ this.x = x; this.y = y; this.k = k; this.n = x.length; this.m = x[0].length; } void go(){ if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {System.out.print((-1 + " ")); }System.out.println(); }return ;} k2 = (k / 2); sol0 = new int[n][m]; sol1 = new int[n][m]; for ( int d = 0;(d < k2);++d) { var zzz = sol1; sol1 = sol0; sol0 = zzz; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < m);++j) {update(i,j); }}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {System.out.print(((sol1[i][j] * 2) + " ")); }System.out.println(); }} void update( int i, int j){ int ret = Integer.MAX_VALUE; if ( (i > 0)) ret = Math.min(ret,(sol0[(i - 1)][j] + y[(i - 1)][j])); if ( (j > 0)) ret = Math.min(ret,(sol0[i][(j - 1)] + x[i][(j - 1)])); if ( (i < (n - 1))) ret = Math.min(ret,(sol0[(i + 1)][j] + y[i][j])); if ( (j < (m - 1))) ret = Math.min(ret,(sol0[i][(j + 1)] + x[i][j])); sol1[i][j] = ret; } public static void main( String[] args){ int n = scan.nextInt();  int m = scan.nextInt();  int k = scan.nextInt();  int x[][] = new int[n][m];  int y[][] = new int[n][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < (m - 1));++j) {x[i][j] = scan.nextInt(); }}for ( int i = 0;(i < (n - 1));++i) {for ( int j = 0;(j < m);++j) {y[i][j] = scan.nextInt(); }} Main mm = new Main(x,y,k); mm.go(); } }
5	public class CottageVillage{ static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st ; static String LINE()throws Exception { return stdin.readLine();} static String TOKEN()throws Exception { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(LINE()); return st.nextToken();} static int INT()throws Exception { return Integer.parseInt(TOKEN());} static DecimalFormat DF = new DecimalFormat("0.000",new DecimalFormatSymbols(Locale.ENGLISH)); public static final double EPSILON = 1E-9; public static void main( String[] args)throws Exception { int N = INT(),T = INT();  House[] list = new House[N]; for ( int i = 0;(i < N);i++) {list[i] = new House(INT(),INT()); }Arrays.sort(list); int cnt = 2; for ( int i = 1;(i < N);i++) { int room = (list[i].center - list[(i - 1)].center); if ( ((2 * T) < (((2 * room) - list[i].side) - list[(i - 1)].side))) cnt += 2; else if ( ((2 * T) == (((2 * room) - list[i].side) - list[(i - 1)].side))) cnt++; }System.out.println(cnt); } static private class House implements Comparable<House>{ int center ,side ; House( int c, int s){ this.center = c; this.side = s; } } }
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());} }
2	public class Quiz{ static int MOD = ((int)1e9 + 9); public static void main( String[] args){ Scanner reader = new Scanner(System.in);  long n = reader.nextInt();  long m = reader.nextInt();  long k = reader.nextInt();  long r = (((n + k) - 1) / k);  long longDrops = (n % k); if ( (longDrops == 0)) { long d = (m - (r * (k - 1))); if ( (d <= 0)) {System.out.println(m); return ;} long sum = (((fastExpo(2,(d + 1)) - 2) * k) + (m - (d * k))); System.out.println(((sum + MOD) % MOD)); } else { long d = ((m - (longDrops * r)) - ((r - 1) * ((k - longDrops) - 1))); if ( (d <= 0)) {System.out.println(m); return ;} long sum = (((fastExpo(2,(d + 1)) - 2) * k) + (m - (d * k))); System.out.println(((sum + MOD) % MOD)); }} public static long fastExpo( long b, long p){ if ( (p == 0)) return 1; if ( ((p % 2) == 1)) return ((b * fastExpo(b,(p - 1))) % MOD); long x = fastExpo(b,(p / 2)); return ((x * x) % MOD);} }
2	public class Main{ long k ; private void solve()throws IOException { long n = nl(); k = nl(); if ( (n == 1)) {prln(0); return ;} if ( (n <= k)) {prln(1); return ;} long l = 1,r = (k - 1);  long mid = (((l + r) + 1) / 2);  long old = -1; while((old != mid)){old = mid; if ( (take(mid) >= n)) r = mid; if ( (take(mid) < n)) l = mid; mid = (((l + r) + 1) / 2); }if ( ((mid >= k) || (mid <= 0))) {prln(-1); return ;} if ( (take(mid) == n)) {prln(mid); return ;} if ( (mid == (k - 1))) prln(-1); else if ( (take(mid) < n)) prln((mid + 1)); else prln(mid); } long take( long t){ return (((k * t) - ((t * (t - 1)) / 2)) - (t - 1));} public static void main( String[] args){ new Main().run(); } public void run(){ try{if ( isFileIO) {pw = new PrintWriter(new File("output.out")); br = new BufferedReader(new FileReader("input.in")); } else {pw = new PrintWriter(System.out); br = new BufferedReader(new InputStreamReader(System.in)); }solve(); pw.close(); br.close(); }catch (IOException e){ System.err.println("IO Error"); } } private void prln( Object o){ pw.println(o); } private void prln(){ pw.println(); } long nl()throws IOException { return Long.parseLong(nextToken());} private String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(br.readLine()); }return tokenizer.nextToken();} private BufferedReader br ; private StringTokenizer tokenizer ; private PrintWriter pw ; private final boolean isFileIO = false; }
2	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++) { long k = Long();  Solution sol = new Solution(out); sol.solution(k); }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{ PrintWriter out ; public Solution( PrintWriter out){ this.out = out; } long f[] = new long[15]; public void solution( long k){ f[0] = 9; for ( int i = 1;(i < f.length);i++) {f[i] = (10 * f[(i - 1)]); }for ( int i = 1;(i < f.length);i++) {f[i] *= (i + 1); } long l = 1,r = 1000000000000l;  long res = -1;  long count = 0; while((l <= r)){ long mid = (l + ((r - l) / 2));  long cnt = get(mid); if ( (cnt >= k)) {res = mid; count = cnt; r = (mid - 1); } else {l = (mid + 1); }} int extra = (int)(count - k);  String s = (res + ""); out.println(s.charAt(((s.length() - 1) - extra))); } public long get( long n){ long res = 0;  long base = 0;  int i = 0; while(true){if ( (n <= ((base * 10) + 9))) {res = (res + ((i + 1) * (n - base))); break;} res += f; i++; base = ((base * 10) + 9); }return res;} }
5	public class ProblemOne{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int problemCount = scanner.nextInt();  int petrCount = scanner.nextInt();  int vasCount = scanner.nextInt();  int[] problems = new int[problemCount]; for ( int i = 0;(i < problemCount);i++) {problems[i] = scanner.nextInt(); }Arrays.sort(problems); System.out.println((-problems[(vasCount - 1)] + problems[vasCount])); } }
0	public class ProblemA{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); sc.next(); System.out.println(25); sc.close(); } }
0	@SuppressWarnings("unused") public class A{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  long n = in.nextLong(); System.out.println(("0 0 " + n)); } }
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); static private 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));} } }
2	public class Main{ public static void main( String[] args)throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  long n = Long.parseLong(st.nextToken()),s = Long.parseLong(st.nextToken());  long m = s; while((((m - f(m)) < s) && (m <= n)))m++; System.out.println(Math.max(((n - m) + 1),0)); } public static int f( long n){ int sum = 0; for ( long i = 0,j = 1L;(i < ((int)Math.log10(n) + 1));i++,j *= 10) {sum += ((n / j) % 10); }return sum;} }
5	public class A{ String line ; StringTokenizer inputParser ; BufferedReader is ; FileInputStream fstream ; DataInputStream in ; String FInput = ""; void openInput( String file){ if ( (file == null)) is = new BufferedReader(new InputStreamReader(System.in)); else {try{fstream = new FileInputStream(file); in = new DataInputStream(fstream); is = new BufferedReader(new InputStreamReader(in)); }catch (Exception e){ System.err.println(e); } }} void readNextLine(){ try{line = is.readLine(); inputParser = new StringTokenizer(line," "); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } catch (NullPointerException e){ line = null; } } int NextInt(){ String n = inputParser.nextToken();  int val = Integer.parseInt(n); return val;} void closeInput(){ try{is.close(); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } public static void main( String[] argv){ String filePath = null; if ( (argv.length > 0)) filePath = argv[0]; new A(filePath); } public A( String inputFile){ openInput(inputFile); readNextLine(); int n = NextInt();  int a = NextInt();  int b = NextInt();  int ret = 0; readNextLine(); int[] p = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = NextInt(); }Arrays.sort(p); int id = 0,cnt = 0; while(((id < n) && (cnt < b))){cnt++; id++; }if ( (id < n)) {ret = (p[id] - p[(id - 1)]); } System.out.print(ret); closeInput(); } }
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); long[] mx = new long[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] = (((1000000000L - u) << 32) | i); }Arrays.sort(mx); int[] dp = new int[(1 << n)]; for ( int i = 0;((i < n) && (i < m));i++) { int c = (int)mx[i];  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)); } }
2	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long x = 1;  long ar = 0; for ( long i = 1;;i++) {ar += ((9 * i) * x); if ( (ar >= n)) { long d = (n - (ar - ((9 * i) * x)));  long ans = (x + (d / i));  long p = (d % i); if ( (p == 0)) {p = i; ans--; } p = (i - p); p++; long fns = 0; while((p != 0)){fns = (ans % 10); ans /= 10; p--; }System.out.println(fns); break;} x *= 10; }} }
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)); } }
0	public class Main{ static private PrintWriter out ; static private FastReader in ; static private class FastReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastReader( InputStream inputStream){ reader = new BufferedReader(new InputStreamReader(inputStream),(1 << 16)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException ex){ throw (new RuntimeException(ex));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] args)throws FileNotFoundException,InterruptedException { in = new FastReader(System.in); out = new PrintWriter(System.out); int n = in.nextInt();  int a = (((n & 1) == 0)?(a = 6):9);  int b = (n - a); out.println(((a + " ") + b)); out.flush(); } }
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))); }} }
5	public class Main{ static int[] a ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt(); a = sc.nextIntArray(n); long inversions = divide(0,(n - 1)); if ( (n == 5)) out.println("Petr"); else {if ( ((n % 2) == 0)) out.println((((inversions % 2) == 0)?"Petr":"Um_nik")); else out.println((((inversions % 2) != 0)?"Petr":"Um_nik")); }out.flush(); out.close(); } static long divide( int b, int e){ if ( (b == e)) return 0; long cnt = 0;  int mid = ((b + e) >> 1); cnt += divide(b,mid); cnt += divide((mid + 1),e); cnt += merge(b,mid,e); return cnt;} static long merge( int b, int mid, int e){ long cnt = 0;  int len = ((e - b) + 1);  int[] tmp = new int[len];  int i = b,j = (mid + 1); for ( int k = 0;(k < len);k++) {if ( ((i == (mid + 1)) || ((j != (e + 1)) && (a[i] > a[j])))) {tmp[k] = a[j++]; cnt += ((mid + 1) - i); } else tmp[k] = a[i++]; }for ( int k = 0;(k < len);k++) a[(b + k)] = tmp[k]; return cnt;} 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 int nextInt()throws IOException { return Integer.parseInt(next());} public double nextDouble()throws IOException { return Double.parseDouble(next());} public Long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} public int[] nextIntArray( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
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;} }
6	public class E74{ 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();  String s = sc.next();  long time = System.currentTimeMillis();  int[][] a = new int[m][m];  int[][] pre = new int[m][(1 << m)]; for ( int i = 0;(i < (n - 1));i++) {if ( (s.charAt(i) == s.charAt((i + 1)))) continue; a[(s.charAt(i) - 'a')][(s.charAt((i + 1)) - 'a')]++; a[(s.charAt((i + 1)) - 'a')][(s.charAt(i) - 'a')]++; }for ( int i = 0;(i < m);i++) { int b = 0;  int stor = 2; for ( int j = 1;(j < (1 << m));j++) {if ( (j == stor)) {b++; stor = (1 << (b + 1)); } pre[i][j] = (pre[i][(j ^ (1 << b))] + a[i][b]); }} long[] dp = new long[(1 << m)]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; for ( int mask = 1;(mask < (1 << m));mask++) {for ( int i = 0;(i < m);i++) {if ( (((mask >> i) & 1) == 0)) continue; long prev = dp[(mask ^ (1 << i))];  long contribution = ((pre[i][mask] - pre[i][(((1 << m) - 1) ^ mask)]) * Integer.bitCount(mask)); dp[mask] = Math.min(dp[mask],(prev + contribution)); }}out.println(dp[((1 << m) - 1)]); 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());} } }
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))); } }
3	public class Main{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int[] nums = new int[n]; for ( int i = 0;(i < n);i++) {nums[i] = scan.nextInt(); }Arrays.sort(nums); boolean[] div = new boolean[n];  int count = 0; for ( int i = 0;(i < n);i++) {if ( !div[i]) {count++; div[i] = true; for ( int j = (i + 1);(j < n);j++) {if ( ((nums[j] % nums[i]) == 0)) {div[j] = true; } }} }System.out.println(count); } }
4	public class MainF{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new FileReader(new File("input.txt")));  BufferedWriter bw = new BufferedWriter(new FileWriter(new File("output.txt")));  String S = br.readLine();  String[] J = S.split(" ");  int N = Integer.parseInt(J[0]);  int M = Integer.parseInt(J[1]);  int K = Integer.parseInt(br.readLine());  int[] x = new int[K];  int[] y = new int[K]; S = br.readLine(); J = S.split(" "); for ( int i = 0;(i < (2 * K));i = (i + 2)) {x[(i / 2)] = Integer.parseInt(J[i]); y[(i / 2)] = Integer.parseInt(J[(i + 1)]); } int ans = -1;  int ansX = -1;  int ansY = -1; for ( int i = 1;(i <= N);i++) {for ( int j = 1;(j <= M);j++) { int W = (M + N); for ( int k = 0;(k < K);k++) {W = Math.min(W,(Math.abs((i - x[k])) + Math.abs((j - y[k])))); }if ( (W < ans)) continue; ans = W; ansX = i; ansY = j; }}bw.write(((Integer.toString(ansX) + " ") + Integer.toString(ansY))); br.close(); bw.close(); } }
4	public class CF1187G extends PrintWriter{ CF1187G(){ super(System.out,true); } 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 ,kk ; int[] uu ,vv ,uv ,cost ,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_]; kk = new int[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)); } boolean dijkstra( int s, int t){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((kk[u] != kk[v])?(kk[u] - kk[v]):(u - v)))); pq.add(s); Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first;  int k = (kk[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) && (kk[v] > k)))) {if ( (pi[v] != INF)) pq.remove(v); pi[v] = p; kk[v] = k; pq.add(v); } } }return (pi[t] != INF);} int dfs( int u, int t, int c){ if ( ((u == t) || (c == 0))) return c; int k = (kk[u] + 1);  ArrayList<Integer> adj = aa_[u]; for ( int h_ :adj) { int h = (h_ >> 1);  int v = (u ^ uv[h]); if ( (kk[v] != k)) continue; int p = (pi[u] + (((h_ & 1) == 0)?cost_[h]:-cost_[h])),f ; if ( ((pi[v] == p) && ((f = dfs(v,t,Math.min(c,cc[h_]))) != 0))) {cc[h_] -= f; cc[(h_ ^ 1)] += f; return f;} }kk[u] = INF; return 0;} int edmonds_karp( int s, int t){ cost_ = Arrays.copyOf(cost,m_); while(dijkstra(s,t)){while((dfs(s,t,INF) > 0));for ( int h = 0;(h < m_);h++) { int u = uu[h],v = vv[h]; if ( ((pi[u] != INF) && (pi[v] != INF))) cost_[h] += (pi[u] - pi[v]); }} 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))); } }
6	public class ProblemE{ static final int INF = 1000000; public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int n = Integer.valueOf(s.readLine());  double[][] prob = new double[n][n];  double[] dp = new double[(1 << n)]; for ( int i = 0;(i < n);i++) { String[] line = s.readLine().split(" "); for ( int j = 0;(j < n);j++) {prob[i][j] = Double.valueOf(line[j]); }}dp[((1 << n) - 1)] = 1.0d; for ( int p = ((1 << n) - 1);(p >= 1);p--) {if ( (dp[p] > 0.0d)) { int left = Integer.bitCount(p); if ( (left == 1)) {continue;} double baseProb = (1.0d / ((left * (left - 1)) / 2)); for ( int i = 0;(i < n);i++) {if ( ((p & (1 << i)) == 0)) {continue;} for ( int j = (i + 1);(j < n);j++) {if ( ((p & (1 << j)) == 0)) {continue;} dp[(p - (1 << i))] += ((dp[p] * baseProb) * prob[j][i]); dp[(p - (1 << j))] += ((dp[p] * baseProb) * prob[i][j]); }}} } StringBuffer b = new StringBuffer(); for ( int i = 0;(i < n);i++) {b.append(" ").append(dp[(1 << i)]); }out.println(b.substring(1)); out.flush(); } }
3	public class CE35D{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(sc.readLine());  String[] t = sc.readLine().split(" ");  int[] list = new int[n]; for ( int x = 0;(x < n);x++) {list[x] = Integer.parseInt(t[x]); } boolean even = true;  int[] indList = new int[(n + 1)]; for ( int x = 0;(x < n);x++) {indList[list[x]] = x; }for ( int x = 1;(x <= n);x++) { int theIndex = indList[x];  int other = list[(x - 1)]; if ( (theIndex != (x - 1))) {even = !even; list[(x - 1)] = x; list[theIndex] = other; indList[x] = (x - 1); indList[other] = theIndex; } } int numQ = Integer.parseInt(sc.readLine()); for ( int x = 0;(x < numQ);x++) { String[] dir = sc.readLine().split(" ");  int l = Integer.parseInt(dir[0]);  int r = Integer.parseInt(dir[1]);  int diff = ((r - l) + 1); if ( ((diff % 4) > 1)) {even = !even; } if ( even) {System.out.println("even"); } else {System.out.println("odd"); }}} }
6	public class Main{ public static void main( String[] args)throws Exception { Reader.init(System.in); PrintWriter out = new PrintWriter(System.out);  Main mm = new Main();  int n = Reader.nextInt();  int m = Reader.nextInt();  String s = Reader.next();  int[][] count = new int[m][m]; for ( int i = 1;(i < n);i++) {count[(s.charAt(i) - 'a')][(s.charAt((i - 1)) - 'a')]++; count[(s.charAt((i - 1)) - 'a')][(s.charAt(i) - 'a')]++; } int[] dp = new int[(1 << m)]; Arrays.fill(dp,(Integer.MAX_VALUE / 10)); for ( int i = 0;(i < m);i++) {dp[(1 << i)] = 0; }for ( int i = 0;(i < (1 << m));i++) { int extra = 0; for ( int j = 0;(j < m);j++) {if ( ((i & (1 << j)) > 0)) {for ( int k = 0;(k < m);k++) {if ( ((j != k) && ((i & (1 << k)) == 0))) {extra += count[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] + extra)); } }}out.println(dp[((1 << m) - 1)]); out.close(); } }
3	public class Hack{ 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(); Arrays.sort(arr); Set<Integer> set = new TreeSet<Integer>(); for ( int i = 0;(i < n);i++) { boolean flag = false; for ( Integer x :set) {if ( ((arr[i] % x) == 0)) {flag = true; break;} }if ( !flag) set.add(arr[i]); }System.out.println(set.size()); } }
3	public class C{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt();  int[] dp1 = new int[(n + 1)];  int[] dp2 = new int[(n + 1)]; dp1[1] = 1; int mod = (int)(1e9 + 7);  char[] instruction = new char[(n + 1)]; instruction[0] = 's'; int[] sum = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {instruction[i] = next().charAt(0); for ( int j = 1;(j <= i);j++) {sum[j] = (sum[(j - 1)] + dp1[j]); if ( (sum[j] >= mod)) sum[j] -= mod; }for ( int j = 1;(j <= i);j++) {if ( (instruction[(i - 1)] == 'f')) dp2[j] = dp1[(j - 1)]; else {dp2[j] = (sum[i] - sum[(j - 1)]); if ( (dp2[j] < 0)) dp2[j] += mod; }}for ( int j = 1;(j <= i);j++) {dp1[j] = dp2[j]; }} int ans = 0; for ( int i = 1;(i <= n);i++) {ans += dp1[i]; if ( (ans >= mod)) ans -= mod; }System.out.println(ans); pw.close(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
4	public class Main{ public static void main( String[] args)throws IOException { Main m = new Main(); m.run(); m.out.close(); } void run()throws IOException { int n = nextInt();  int m = nextInt();  int k = nextInt();  long[][] r = new long[n][(m - 1)];  long[][] d = new long[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {r[i][j] = nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {d[i][j] = nextInt(); }}if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((-1 + " ")); }out.println(); }return ;} long[][][] dp = new long[n][m][(k + 1)]; for ( int kk = 2;(kk <= k);kk += 2) for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { long ans = (long)1e18; if ( ((i + 1) < n)) {ans = Math.min(ans,(dp[(i + 1)][j][(kk - 2)] + (d[i][j] * 2))); } if ( ((i - 1) > -1)) ans = Math.min(ans,(dp[(i - 1)][j][(kk - 2)] + (d[(i - 1)][j] * 2))); if ( ((j + 1) < m)) ans = Math.min(ans,(dp[i][(j + 1)][(kk - 2)] + (r[i][j] * 2))); if ( ((j - 1) > -1)) ans = Math.min(ans,(dp[i][(j - 1)][(kk - 2)] + (r[i][(j - 1)] * 2))); dp[i][j][kk] = ans; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((dp[i][j][k] + " ")); }out.println(); }} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer in = new StringTokenizer(""); String nextToken()throws IOException { while(!in.hasMoreTokens()){in = new StringTokenizer(br.readLine()); }return in.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
6	public final class CF_599_D1_C{ static boolean verb = true; static void log( Object X){ if ( verb) System.err.println(X); } static void log( Object[] X){ if ( verb) {for ( Object U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X){ if ( verb) {for ( int U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X, int L){ if ( verb) {for ( int i = 0;(i < L);i++) System.err.print((X[i] + " ")); System.err.println(""); } } static void log( long[] X){ if ( verb) {for ( long U :X) System.err.print((U + " ")); System.err.println(""); } } static void output( Object o){ outputWln((("" + o) + "\n")); } static void outputWln( Object o){ try{out.write(("" + o)); }catch (Exception e){ } } static long mod = 1000000007; static BufferedWriter out ; static InputReader reader ; static void explore( ArrayList<Integer>[] components, ArrayList<Integer> bob, int[][] move, ArrayList<int[]>[] howto, int[][] list){ for ( int x :bob) {if ( (components[x].size() == 1)) { int tm[] = howto[x].get(0);  int L = howto[x].size(); howto[x].add(tm); for ( int i = 0;(i < L);i++) { int[] cur = howto[x].get(i);  int[] nx = howto[x].get((i + 1));  int a = cur[0];  int a2 = nx[0];  int b2 = nx[1]; move[a2][0] = list[a2][b2]; move[a2][1] = a; }} else {explore(components,components[x],move,howto,list); }}} static void process()throws Exception { out = new BufferedWriter(new OutputStreamWriter(System.out)); reader = new InputReader(System.in); int k = reader.readInt();  int[][] list = new int[k][];  long[] sum = new long[k];  int[] L = new int[k];  HashMap<Integer,int[]> target = new HashMap<Integer,int[]>();  long tot = 0; for ( int i = 0;(i < k);i++) {L[i] = reader.readInt(); list[i] = new int[L[i]]; for ( int j = 0;(j < L[i]);j++) {list[i][j] = reader.readInt(); sum[i] += list[i][j]; target.put(list[i][j],new int[]{i,j}); }tot += sum[i]; } int MX = (1 << k);  int AX = 1000000001;  ArrayList<int[]>[] howto = new ArrayList[MX]; log("ok with the data"); if ( ((tot % k) != 0)) {output("No"); } else {tot /= k; for ( int i = 0;(i < k);i++) {if ( (sum[i] == tot)) { int mask = (1 << i);  ArrayList<int[]> cand = new ArrayList<int[]>(); cand.add(new int[]{i,0}); howto[mask] = cand; } else for ( int j = 0;(j < L[i]);j++) { int u = i;  int v = j;  boolean ok = true;  int src_u = u;  int src_v = v;  int mask = 0;  boolean goon = true;  ArrayList<int[]> cand = new ArrayList<int[]>(); while(goon){cand.add(new int[]{u,v}); ok = false; goon = false; long need = (tot - ((long)sum[u] - (long)list[u][v])); if ( (Math.abs(need) <= AX)) { int nd = (int)need;  int[] tm = target.get(nd); if ( (tm != null)) { int nxu = tm[0];  int nxv = tm[1]; if ( ((mask & (1 << nxu)) == 0)) {mask |= (1 << nxu); if ( (nxu == src_u)) {if ( (nxv == src_v)) ok = true; } else {u = nxu; v = nxv; ok = true; goon = true; }} } } }if ( ok) {if ( (howto[mask] == null)) {howto[mask] = cand; } } }}log("step 1 done"); ArrayList[] components = new ArrayList[MX]; for ( int m = 0;(m < MX);m++) {if ( (howto[m] != null)) {components[m] = new ArrayList<Integer>(); components[m].add(m); } } int[] msk = new int[MX];  int w = 0; for ( int a = 0;(a < MX);a++) {if ( (howto[a] != null)) { ArrayList<Integer> add = new ArrayList<Integer>();  int ww = w; for ( int i = 0;(i < ww);i++) { int b = msk[i]; if ( ((b & a) == 0)) { int c = (b | a); if ( (components[c] == null)) {components[c] = new ArrayList<Integer>(); components[c].add(a); components[c].add(b); msk[w++] = c; } } }msk[w++] = a; } }if ( (components[(MX - 1)] != null)) {output("Yes"); int[][] move = new int[k][2]; explore(components,components[(MX - 1)],move,howto,list); for ( int i = 0;(i < k);i++) {output(((move[i][0] + " ") + (move[i][1] + 1))); }} else {output("No"); }}try{out.close(); }catch (Exception e){ } } public static void main( String[] args)throws Exception { process(); } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
1	public class B{ public static void main( String[] args){ Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int nc = sc.nextInt(); while((nc-- > 0)){ String s = sc.next();  StringTokenizer st = new StringTokenizer(s,"0123456789"); if ( (st.countTokens() > 1)) { int k = s.indexOf('C');  int r = Integer.parseInt(s.substring(1,k));  int c = Integer.parseInt(s.substring((k + 1)));  int len = 1;  int p = 26; while((c > p)){c -= p; len++; p *= 26; } String col = Integer.toString(--c,26).toUpperCase(); while((col.length() < len))col = ("0" + col); StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < col.length());i++) {if ( (col.charAt(i) < 'A')) {sb.append((char)((col.charAt(i) - '0') + 'A')); } else {sb.append((char)(col.charAt(i) + 10)); }}System.out.printf("%s%d\n",sb.toString(),r); } else { int k = 0; while((s.charAt(k) > '9'))k++; char[] col = s.substring(0,k).toCharArray();  int r = Integer.parseInt(s.substring(k));  int c = 1;  int p = 26;  int cnt = 1; while((cnt++ < col.length)){c += p; p *= 26; } StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < col.length);i++) {if ( (s.charAt(i) < 'K')) {sb.append((char)(('0' + col[i]) - 'A')); } else {sb.append((char)(col[i] - 10)); }}c += Integer.parseInt(sb.toString(),26); System.out.printf("R%dC%d\n",r,c); }}System.out.close(); } }
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());} }
2	public class Main{ public static void main( String[] args)throws Exception { InputReader in = new InputReader(System.in);  int n = in.readInt();  int m = in.readInt();  int k = in.readInt();  long wrong = (n - m);  long c = ((wrong * (k)+k) - 1);  long xk = (n - c); if ( (xk <= 0)) System.out.println(((n - wrong) % 1000000009)); else { long x = (long)Math.ceil((xk / (k * 1.0)));  long power = Long.parseLong((BigInteger.valueOf(2) + "")); power += 1000000009; power %= 1000000009; long first = ((power * k) % 1000000009); first += ((n - (x * k)) - wrong); System.out.println((first % 1000000009)); }} 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 A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int t = (in.nextInt() * 2);  Point[] A = new Point[n]; for ( int i = 0;(i < n);i++) { int center = (in.nextInt() * 2);  int side = in.nextInt(); A[i] = new Point((center - side),(center + side)); }Arrays.sort(A,new Comparator<Point>(){}); int ans = 2; for ( int i = 1;(i < n);i++) {if ( ((A[i].x - A[(i - 1)].y) > t)) ans += 2; else if ( ((A[i].x - A[(i - 1)].y) == t)) ans++; }System.out.println(ans); } }
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(); } }
3	public class Solution{ private long[] sums ; private void solve(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int[] arr = new int[n]; this.sums = new long[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); sums[i] = (arr[i] + ((i == 0)?0:sums[(i - 1)])); } long ans = 0; for ( int i = 1;((i <= n) && (i <= m));i++) {ans = Math.max(ans,(sum(0,(i - 1)) - k)); } long[] dp = new long[n]; for ( int i = 0;(i < n);i++) {if ( ((i + 1) >= m)) { long cur = (sum(((i - m) + 1),i) - k); if ( ((i - m) >= 0)) {cur += dp[(i - m)]; } dp[i] = Math.max(dp[i],cur); } for ( int j = 0;((j <= m) && ((i + j) < n));j++) {ans = Math.max(ans,((dp[i] + sum((i + 1),(i + j))) - (k * ((j > 0)?1:0)))); }}System.out.println(ans); } private long sum( int l, int r){ if ( (l <= 0)) {return sums[r];} else {return (sums[r] - sums[(l - 1)]);}} public static void main( String[] args){ new Solution().solve(); } }
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);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt();  int k = in.nextInt();  char[] c = in.next().toCharArray();  NavigableSet<Integer> ones = new TreeSet<>();  NavigableSet<Integer> zeros = new TreeSet<>(); for ( int i = 0;(i < n);i++) {if ( (c[i] == '0')) zeros.add(i); else ones.add(i); }if ( (((ones.isEmpty() || zeros.isEmpty()) || (((ones.last() - ones.first()) + 1) <= k)) || (((zeros.last() - zeros.first()) + 1) <= k))) {out.println("tokitsukaze"); return ;} if ( (check(ones,n,k) && check(zeros,n,k))) {out.println("quailty"); return ;} out.println("once again"); } private boolean check( NavigableSet<Integer> ones, int n, int k){ for ( int i = 0;((i + k) <= n);i++) { int left = ones.first();  int right = ones.last(); if ( (left >= i)) {left = ones.higher(((i + k) - 1)); } if ( (right < (i + k))) {right = ones.lower(i); } if ( (((right - left) + 1) > k)) {return false;} }return true;} } static class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } } static 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());} } public String next(){ StringBuilder sb = new StringBuilder();  int c = read(); while(isWhiteSpace(c)){c = read(); }if ( (c < 0)) {return null;} while(((c >= 0) && !isWhiteSpace(c))){sb.appendCodePoint(c); c = read(); }return sb.toString();} 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);} } }
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();} }
2	public class C_Edu_Round_23{ public static long MOD = 1000000007; static long[][][][] dp ; public static void main( String[] args)throws FileNotFoundException { PrintWriter out = new PrintWriter(System.out);  Scanner in = new Scanner();  long n = in.nextLong();  long s = in.nextLong(); if ( (s == 0)) {out.println(n); } else { String N = ("" + n); dp = new long[N.length()][163][2][2]; long re = 0; for ( int i = 1;((i < 163) && (i <= n));i++) { long tmp = (s + i); if ( (tmp <= n)) { String S = ("" + tmp); while((S.length() < N.length())){S = ('0' + S); }for ( long[][][] a :dp) {for ( long[][] b :a) {for ( long[] c :b) {Arrays.fill(c,-1); }}}re += cal(0,i,0,0,N,S); } }out.println(re); }out.close(); } public static long cal( int index, int left, int lessThanN, int largerThanS, String n, String s){ if ( (index == n.length())) {if ( (left == 0)) {return 1;} return 0;} if ( (dp[index][left][lessThanN][largerThanS] != -1)) {return dp[index][left][lessThanN][largerThanS];} int x = (n.charAt(index) - '0');  int y = (s.charAt(index) - '0');  long re = 0; for ( int i = 0;((i < 10) && (i <= left));i++) {if ( ((i <= x) || (lessThanN == 1))) {if ( ((i >= y) || (largerThanS == 1))) {re += cal((index + 1),(left - i),((i < x)?1:lessThanN),((i > y)?1:largerThanS),n,s); } } }return dp[index][left][lessThanN][largerThanS] = re;} 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, long MOD){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long val = pow(a,(b / 2),MOD); 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(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 long nextLong(){ return Long.parseLong(next());} } }
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());} } }
3	public class Solution{ public static void main( String[] args)throws Exception { int n = nextInt();  int r = nextInt();  int x[] = new int[n];  double y[] = new double[n]; for ( int i = 0;(i < n);i++) x[i] = nextInt(); for ( int i = 0;(i < n);i++) {y[i] = r; for ( int j = 0;(j < i);j++) { int d = (sq((2 * r)) - sq((x[i] - x[j]))); if ( (d >= 0)) { double y1 = (Math.sqrt(d) + y[j]); y[i] = Math.max(y1,y[i]); } }}for ( int i = 0;(i < n);i++) System.out.printf("%.12g ",y[i]); } static int sq( int a){ return (a * a);} static int nextInt()throws IOException { InputStream in = System.in;  int ans = 0;  boolean flag = true;  byte b = 0; while((((b > 47) && (b < 58)) || flag)){if ( ((b >= 48) && (b < 58))) {ans = ((ans * 10) + (b - 48)); flag = false; } b = (byte)in.read(); }return ans;} static boolean isWhiteSpace( byte b){ char ch = (char)b; return (((ch == '\0') || (ch == ' ')) || (ch == '\n'));} }
1	public class HamstersAndTigers{ Scanner in ; PrintWriter out ; HamstersAndTigers(){ in = new Scanner(System.in); out = new PrintWriter(System.out); } HamstersAndTigers( String i, String o)throws FileNotFoundException{ in = new Scanner(new File(i)); out = new PrintWriter(new File(o)); } public void finalize(){ out.flush(); in.close(); out.close(); } void solve(){ int i = 0,h = 0,n = in.nextInt();  String buf = "";  char[] ht = in.next().toCharArray(); for ( i = 0;(i < n);++i) if ( (ht[i] == 'H')) ++h; for ( i = 0;(i < h);++i) buf += 'H'; for ( i = 0;(i < (n - h));++i) buf += 'T'; int diff = (1 << 28); for ( i = 0;(i < n);++i) { int tmp = 0; for ( int j = 0;(j < n);++j) if ( (buf.charAt(j) != ht[((i + j) % n)])) ++tmp; diff = Math.min(tmp,diff); }out.println((diff / 2)); } public static void main( String[] args)throws FileNotFoundException { HamstersAndTigers t = new HamstersAndTigers(); t.solve(); t.finalize(); } }
0	public class Main{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int x = scan.nextInt(); solve(x); } public static void solve( int x){ int z = 0; System.out.print((z + " ")); System.out.print((z + " ")); System.out.print(x); } }
2	public class D{ static long max ; public static long[] getOneRange( long min, long max, int bit){ long st = ((min & (((1l << 63) - 1) & ((1l << (bit + 1)) - 1))) | (1l << bit));  long end = (st | ((1l << (bit + 1)) - 1));  long interSt = Math.max(st,min);  long interEnd = Math.min(end,max); if ( (interSt > interEnd)) return null; return new long[]{interSt,interEnd};} public static long[] getZeroRange( long min, long max, int bit){ long st = (min & (((1l << 63) - 1) & ((1l << (bit + 1)) - 1)));  long end = (st | ((1l << bit) - 1));  long interSt = Math.max(st,min);  long interEnd = Math.min(end,max); if ( (interSt > interEnd)) return null; return new long[]{interSt,interEnd};} public static void solve( int bitPosition, long min1, long max1, long min2, long max2, long curNum){ if ( (bitPosition == -1)) {max = Math.max(max,curNum); return ;} long[] firZeroRange = getZeroRange(min1,max1,bitPosition);  long[] secZeroRange = getZeroRange(min2,max2,bitPosition);  long[] firOneRange = getOneRange(min1,max1,bitPosition);  long[] secOneRange = getOneRange(min2,max2,bitPosition); if ( (((firOneRange != null) && (secZeroRange != null)) || ((firZeroRange != null) && (secOneRange != null)))) { long newNum = (curNum | (1l << bitPosition)); if ( ((((firOneRange != null) && (secZeroRange != null)) && (((firOneRange[1] - firOneRange[0]) + 1) == (1l << bitPosition))) && (((secZeroRange[1] - secZeroRange[0]) + 1) == (1l << bitPosition)))) {solve((bitPosition - 1),firOneRange[0],firOneRange[1],secZeroRange[0],secZeroRange[1],newNum); return ;} if ( ((((firZeroRange != null) && (secOneRange != null)) && (((firZeroRange[1] - firZeroRange[0]) + 1) == (1l << bitPosition))) && (((secOneRange[1] - secOneRange[0]) + 1) == (1l << bitPosition)))) {solve((bitPosition - 1),firZeroRange[0],firZeroRange[1],secOneRange[0],secOneRange[1],newNum); return ;} if ( ((firOneRange != null) && (secZeroRange != null))) {solve((bitPosition - 1),firOneRange[0],firOneRange[1],secZeroRange[0],secZeroRange[1],newNum); } if ( ((firZeroRange != null) && (secOneRange != null))) {solve((bitPosition - 1),firZeroRange[0],firZeroRange[1],secOneRange[0],secOneRange[1],newNum); } } else {solve((bitPosition - 1),min1,max1,min2,max2,curNum); }} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long l = sc.nextLong();  long r = sc.nextLong(); max = 0; solve(62,l,r,l,r,0); System.out.println(max); } }
6	public class C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int xs = sc.nextInt();  int ys = sc.nextInt();  int n = sc.nextInt();  int[] x = new int[n],y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = sc.nextInt(); y[i] = sc.nextInt(); } int[] single = new int[n];  int[][] pair = new int[n][n]; for ( int i = 0;(i < n);i++) {single[i] = (2 * (((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys)))); }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[i] - x[j]) * (x[i] - x[j]))) + ((y[i] - y[j]) * (y[i] - y[j]))); }} int[] best = new int[(1 << n)],prev = new int[(1 << n)]; for ( int mask = 1;(mask < (1 << n));mask++) { int i = 0; while(((mask & (1 << i)) == 0))i++; best[mask] = (best[(mask ^ (1 << i))] + single[i]); prev[mask] = (i + 1); for ( int j = (i + 1);(j < n);j++) {if ( ((mask & (1 << j)) != 0)) { int temp = (best[((mask ^ (1 << i)) ^ (1 << j))] + pair[i][j]); if ( (temp < best[mask])) {best[mask] = temp; prev[mask] = (((i + 1) * 100) + (j + 1)); } } }}System.out.println(best[((1 << n) - 1)]); System.out.print("0 "); int cur = ((1 << n) - 1); while((cur > 0)){ int a = (prev[cur] % 100);  int b = (prev[cur] / 100); if ( (a > 0)) {System.out.print((a + " ")); cur ^= (1 << (a - 1)); } if ( (b > 0)) {System.out.print((b + " ")); cur ^= (1 << (b - 1)); } System.out.print((0 + " ")); }} }
1	public class Main{ public static void main( String[] args){ ConsoleIO io = new ConsoleIO(); new Main(io).solve(); io.close(); } ConsoleIO io ; Main( ConsoleIO io){ this.io = io; } ArrayList<ArrayList<Integer>> gr ; boolean[] visit ; long MOD = 1_000_000_007; int N ,M ,K ; double[][] map ; public void solve(){ String s = io.readLine(); N = Integer.parseInt(s); char[] a = io.readLine().toCharArray();  int[] look = new int[256]; Arrays.fill(look,10000); int k = 0; for ( int i = 0;(i < a.length);i++) {if ( (look[a[i]] == 10000)) {look[a[i]] = k; k++; } } int res = N;  long need = ((1L << k) - 1);  long mask = 0;  int head = 0;  int tail = 0;  int[] c = new int[k]; while((head < a.length)){while(((head < a.length) && (mask != need))){ int v = look[a[head]]; if ( (c[v] == 0)) mask |= (1L << v); c[v]++; head++; }while(((tail < head) && (mask == need))){res = Math.min(res,(head - tail)); int v = look[a[tail]]; c[v]--; if ( (c[v] == 0)) mask ^= (1L << v); tail++; }}io.writeLine((res + "")); } long gcd( long a, long b){ if ( (a < b)) return gcd(b,a); if ( (b == 0)) return a; return gcd(b,(a % b));} } class ConsoleIO{ BufferedReader br ; PrintWriter out ; public ConsoleIO(){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } public void flush(){ this.out.flush(); } public void close(){ this.out.close(); } public void writeLine( String s){ this.out.println(s); } public int read( char[] buf, int len){ try{return br.read(buf,0,len); }catch (Exception ex){ return -1;} } public String readLine(){ try{return br.readLine(); }catch (Exception ex){ return "";} } }
3	public class C{ public static void main( String[] args){ FastScanner sc = new FastScanner();  int n = sc.nextInt();  long r = sc.nextInt();  double d = (2 * r);  long[] xs = sc.readLongArray(n);  P[] points = new P[n];  StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < n);i++) {if ( (i > 0)) sb.append(' ');  double y = r; for ( int j = 0;(j < i);j++) { long diff = Math.abs((xs[i] - points[j].x)); if ( (diff <= (2 * r))) { double dy = Math.sqrt(((d * d) - (diff * diff)));  double testY = (points[j].y + dy); y = Math.max(y,testY); } }sb.append(y); points[i] = new P(xs[i],y); }System.out.println(sb); } static class P{ final long x ; final double y ; public P( long x, double y){ this.x = x; this.y = y; } } 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());} long nextLong(){ return Long.parseLong(next());} long[] readLongArray( int n){ long[] a = new long[n]; for ( int idx = 0;(idx < n);idx++) {a[idx] = nextLong(); }return a;} } }
5	public class Main{ BufferedReader reader ; FastScanner sc ; void solve()throws Exception { int n = sc.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); }Arrays.sort(arr); if ( (arr[(n - 1)] == 1)) arr[(n - 1)] = 2; else arr[(n - 1)] = 1; Arrays.sort(arr); for ( int i = 0;(i < n);i++) {System.out.print((arr[i] + " ")); }System.out.println(); } public static void main( String[] args)throws Exception { new Main().solve(); } Main()throws Exception{ if ( (System.getProperty("ONLINE_JUDGE") == null)) {} reader = new BufferedReader(new InputStreamReader(System.in)); sc = new FastScanner(reader); } } class FastScanner{ BufferedReader reader ; StringTokenizer strTok ; public FastScanner( BufferedReader reader){ this.reader = reader; } public String nextToken()throws IOException { if ( ((strTok == null) || !strTok.hasMoreTokens())) {strTok = new StringTokenizer(reader.readLine()); } return strTok.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
6	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())){ String r = in.readLine(); if ( (r == null)) return null; st = new StringTokenizer(r); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} int n ; int[] b ,l ; double ans ; int[] sw ; int a ; void sol(){ for ( int i = 0;(i < n);i++) l[i] += (sw[i] * 10); double yes = 0; for ( int q = 0;(q < (1 << n));q++) { double p = 1;  int bb = 0;  int cnt = 0; for ( int i = 0;(i < n);i++) {if ( ((q & (1 << i)) == 0)) {p *= (1.0 - ((double)l[i] / 100)); bb += b[i]; } else {p *= ((1.0 * (double)l[i]) / 100); cnt++; }}if ( (cnt > (n / 2))) {yes += p; } else {yes += ((p * (double)a) / (double)(a + bb)); }}if ( (ans < yes)) ans = yes; for ( int i = 0;(i < n);i++) l[i] -= (sw[i] * 10); } void rek( int i, int k){ if ( (i == n)) sol(); else {for ( int q = 0;((q <= k) && ((l[i] + (q * 10)) <= 100));q++) {sw[i] = q; rek((i + 1),(k - q)); }}} void solve()throws Exception { n = nextInt(); int k = nextInt(); a = nextInt(); b = new int[n]; l = new int[n]; sw = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = nextInt(); l[i] = nextInt(); }rek(0,k); out.printf("%.10f",ans); } }
1	public class Main implements Runnable{ final String filename = ""; public void solve()throws Exception { int n = iread(),k = iread();  boolean[] f = new boolean[10000];  int prev = -1; for ( int i = 2;(i <= n);i++) {for ( int j = 2;((j * j) <= i);j++) if ( ((i % j) == 0)) continue cycle; if ( (prev != -1)) f[((i + prev) + 1)] = true; if ( f[i]) k--; prev = i; }if ( (k <= 0)) out.write("YES\n"); else out.write("NO\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(new Main()).start(); } }
1	public class Main{ Scanner in ; PrintWriter out ; StreamTokenizer ST ; BufferedReader br ; void solve()throws IOException { br.readLine(); char[] s = br.readLine().toCharArray();  int n = s.length;  int h = 0; for ( int i = 0;(i < n);++i) if ( (s[i] == 'H')) ++h;  int res = 1000000; for ( int i = 0;(i < n);++i) { int t = 0; for ( int j = 0;(j < h);++j) {if ( (s[((i + j) % n)] == 'T')) ++t; }res = Math.min(res,t); }out.println(res); } public void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); ST = new StreamTokenizer(br); in = new Scanner(br); out = new PrintWriter(System.out); solve(); in.close(); out.close(); br.close(); } public static void main( String[] args)throws Exception { new Main().run(); } }
6	public class Main{ static double max = 0.0; public static void main( String[] args){ Scanner r = new Scanner(System.in);  int n = r.nextInt();  int k = r.nextInt();  int A = r.nextInt();  Person[] p = new Person[n]; for ( int i = 0;(i < n);i++) { int l = r.nextInt();  int prob = r.nextInt(); p[i] = new Person(l,prob); } int[] add = new int[n];  double res = dfs(0,k,p,add,n,A); System.out.println(res); } static private double dfs( int ptr, int k, Person[] p, int[] add, int n, int A){ if ( (k < 0)) return 0; double res1 = 0; for ( int m = 0;(m < (1 << n));m++) { double win = 1;  int cnt = 0; for ( int i = 0;(i < n);i++) {if ( ((m & (1 << i)) == 0)) {win *= (((100 - (p[i].p + add[i])) * 1.0) / 100); } else {win *= (((add[i] + p[i].p) * 1.0) / 100); cnt++; }}if ( (cnt > (n / 2))) {res1 += win; } else { int B = 0; for ( int i = 0;(i < n);i++) {if ( ((m & (1 << i)) == 0)) {B += p[i].l; } }win *= ((A * 1.0) / (A + B)); res1 += win; }} double res2 = 0,res3 = 0; if ( ((add[ptr] + p[ptr].p) < 100)) {add[ptr] += 10; res2 = dfs(ptr,(k - 1),p,add,n,A); add[ptr] -= 10; } if ( ((ptr + 1) < n)) {res3 = dfs((ptr + 1),k,p,add,n,A); } return Math.max(res1,Math.max(res2,res3));} } class Person{ int l ,p ; public Person( int li, int pi){ l = li; p = pi; } }
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();} } }
2	public class Main{ static int mod = ((int)1e9 + 7); public static void main( String[] args)throws FileNotFoundException { FasterScanner s = new FasterScanner();  int test = 1; testloop:while((test-- > 0)){ int n = s.nextInt();  int left = 1;  int right = n;  int x[][] = new int[2][2];  int y[][] = new int[2][2]; while((left < right)){ int mid = ((left + right) / 2); query(1,mid,1,n); int ans = s.nextInt(); if ( (ans < 2)) {left = (mid + 1); } else {right = mid; }}x[0][0] = left; left = 1; right = n; while((left < right)){ int mid = ((left + right) / 2); query(1,mid,1,n); int ans = s.nextInt(); if ( (ans < 1)) {left = (mid + 1); } else {right = mid; }}x[0][1] = left; left = 1; right = n; while((left < right)){ int mid = (((left + right) + 1) / 2); query(mid,n,1,n); int ans = s.nextInt(); if ( (ans < 2)) {right = (mid - 1); } else {left = mid; }}x[1][0] = left; left = 1; right = n; while((left < right)){ int mid = (((left + right) + 1) / 2); query(mid,n,1,n); int ans = s.nextInt(); if ( (ans < 1)) {right = (mid - 1); } else {left = mid; }}x[1][1] = left; left = 1; right = n; while((left < right)){ int mid = ((left + right) / 2); query(1,n,1,mid); int ans = s.nextInt(); if ( (ans < 2)) {left = (mid + 1); } else {right = mid; }}y[0][0] = left; left = 1; right = n; while((left < right)){ int mid = ((left + right) / 2); query(1,n,1,mid); int ans = s.nextInt(); if ( (ans < 1)) {left = (mid + 1); } else {right = mid; }}y[0][1] = left; left = 1; right = n; while((left < right)){ int mid = (((left + right) + 1) / 2); query(1,n,mid,n); int ans = s.nextInt(); if ( (ans < 2)) {right = (mid - 1); } else {left = mid; }}y[1][0] = left; left = 1; right = n; while((left < right)){ int mid = (((left + right) + 1) / 2); query(1,n,mid,n); int ans = s.nextInt(); if ( (ans < 1)) {right = (mid - 1); } else {left = mid; }}y[1][1] = left; int x11 = 0,x12 = 0,y11 = 0,y12 = 0;  int x21 = 0,x22 = 0,y21 = 0,y22 = 0; for ( int x1 = 0;(x1 < 2);x1++) {x11 = x[1][x1]; x21 = x[1][(1 - x1)]; for ( int x2 = 0;(x2 < 2);x2++) {x12 = x[0][x2]; x22 = x[0][(1 - x2)]; if ( (x11 > x12)) continue; if ( (x21 > x22)) continue; for ( int y1 = 0;(y1 < 2);y1++) {y11 = y[1][y1]; y21 = y[1][(1 - y1)]; for ( int y2 = 0;(y2 < 2);y2++) {y12 = y[0][y2]; y22 = y[0][(1 - y2)]; if ( (y11 > y12)) continue; if ( (y21 > y22)) continue; query(x11,x12,y11,y12); int ans1 = s.nextInt(); query(x21,x22,y21,y22); int ans2 = s.nextInt(); if ( ((ans1 == 1) && (ans2 == 1))) {System.out.println(((((((((((((((("! " + x11) + " ") + y11) + " ") + x12) + " ") + y12) + " ") + x21) + " ") + y21) + " ") + x22) + " ") + y22)); System.out.flush(); break;} }}}}}} public static void query( int x1, int x2, int y1, int y2){ System.out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); System.out.flush(); } public static int max( int[] t, int a, int b){ int res = 0; for ( a += (t.length / 2),b += (t.length / 2);(a <= b);a = ((a + 1) >> 1),b = ((b - 1) >> 1)) {if ( ((a & 1) != 0)) res = Math.max(res,t[a]); if ( ((b & 1) == 0)) res = Math.max(res,t[b]); }return res;} static class FasterScanner{ 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));} } }
5	public class C{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(in.readLine());  String[] S = in.readLine().split(" ");  int[] A = new int[n];  boolean allOnes = true; for ( int i = 0;(i < n);i++) {A[i] = Integer.parseInt(S[i]); allOnes &= (A[i] == 1); }Arrays.sort(A); if ( (A[(A.length - 1)] > 1)) A[(A.length - 1)] = 1; else A[(A.length - 1)] = 2; Arrays.sort(A); for ( int i = 0;(i < A.length);i++) System.out.print((A[i] + " ")); System.out.println(); } }
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); }} }
5	public class A{ public static void main( String[] args){ HomeWorks hw = new HomeWorks(); hw.sol(); hw.print(); } } class HomeWorks{ HomeWorks(){ Scanner scr = new Scanner(System.in); n = scr.nextInt(); a = scr.nextInt(); b = scr.nextInt(); h = new int[n]; for ( int i = 0;(i < n);i++) {h[i] = scr.nextInt(); }scr.close(); } void sol(){ Arrays.sort(h); int Vasya = h[(b - 1)];  int Petya = h[b]; ans = (Petya - Vasya); if ( (ans < 0)) {ans = 0; } } void print(){ PrintWriter pw = new PrintWriter(System.out); pw.println(ans); pw.flush(); pw.close(); } int ans ; int[] h ; int n ; int a ; int 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);  TaskG solver = new TaskG(); solver.solve(1,in,out); out.close(); } static class TaskG{ static final long MODULO = ((long)1e9 + 7); static final long BIG = (Long.MAX_VALUE - (Long.MAX_VALUE % MODULO)); static final int[] ONE = new int[]{1}; int k ; int n ; long[] globalRes ; int[] p2 ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); k = in.nextInt(); globalRes = new long[(k + 1)]; p2 = new int[(n + 1)]; p2[0] = 1; for ( int i = 1;(i <= n);++i) p2[i] = (int)((2 * p2[(i - 1)]) % MODULO); Vertex[] vs = new Vertex[n]; for ( int i = 0;(i < n);++i) vs[i] = new Vertex(); for ( int i = 0;(i < (n - 1));++i) { Vertex a = vs[(in.nextInt() - 1)];  Vertex b = vs[(in.nextInt() - 1)]; a.adj.add(b); b.adj.add(a); }vs[0].dfs(null); long[][] ways = new long[(k + 1)][(k + 1)]; ways[0][0] = 1; for ( int i = 1;(i <= k);++i) {for ( int j = 1;(j <= k);++j) {ways[i][j] = ((j * (ways[(i - 1)][j] + ways[(i - 1)][(j - 1)])) % MODULO); }} long sum = 0; for ( int i = 1;(i <= k);++i) { long s = globalRes[i]; s %= MODULO; sum = ((sum + (s * ways[k][i])) % MODULO); }out.println(sum); } class Vertex{ int[] res ; int subtreeSize ; List<Vertex> adj = new ArrayList<>(); public void dfs( Vertex parent){ subtreeSize = 1; int[] prod = ONE; for ( Vertex child :adj) if ( (child != parent)) {child.dfs(this); subtreeSize += child.subtreeSize; } int mult = 2; for ( Vertex child :adj) if ( (child != parent)) { int[] c = child.res; prod = mul(prod,c); subFrom(globalRes,c,1); } addTo(globalRes,prod,mult); res = insertEdge(prod); } private int[] insertEdge( int[] a){ int len = (a.length + 1); if ( (len > k)) len = (k + 1);  int[] b = new int[len]; b[0] = (a[0] * 2); if ( (b[0] >= MODULO)) b[0] -= MODULO; for ( int i = 1;(i < len);++i) { long s = a[(i - 1)]; if ( (i < a.length)) s += a[i]; if ( (s >= MODULO)) s -= MODULO; s = (s * 2); if ( (s >= MODULO)) s -= MODULO; b[i] = (int)s; }b[1] -= 1; if ( (b[1] < 0)) b[1] += MODULO; return b;} private void addTo( long[] a, int[] b, int mult){ for ( int i = 0;(i < b.length);++i) { long s = (a[i] + (b[i] * (long)mult)); if ( (s < 0)) s -= BIG; a[i] = s; }} private void subFrom( long[] a, int[] b, int mult){ for ( int i = 0;(i < b.length);++i) { long s = (a[i] + ((MODULO - b[i]) * (long)mult)); if ( (s < 0)) s -= BIG; a[i] = s; }} private int[] mul( int[] a, int[] b){ int len = ((a.length + b.length) - 1); if ( (len > k)) len = (k + 1);  int[] c = new int[len]; for ( int i = 0;(i < len);++i) { long s = 0;  int left = Math.max(0,(i - (b.length - 1)));  int right = Math.min((a.length - 1),i); for ( int ia = left;(ia <= right);++ia) { int ib = (i - ia); s += (a[ia] * (long)b[ib]); if ( (s < 0)) s -= BIG; }c[i] = (int)(s % MODULO); }return c;} } } 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 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{ StreamTokenizer in ; PrintWriter out ; BufferedReader re ; Scanner sc ; public void solve( int testNumber, InputStreamReader in, PrintWriter out){ this.in = new StreamTokenizer(new BufferedReader(in)); this.re = new BufferedReader(in); this.sc = new Scanner(in); this.out = out; try{this.solve(); }catch (IOException e){ e.printStackTrace(); } out.flush(); } void solve()throws IOException { long a = sc.nextLong(),b = sc.nextLong();  long ans = 0,t ; while((Math.min(a,b) != 1)){if ( (a > b)) {ans += (a / b); a %= b; } else {t = b; b = a; a = t; long g = gcd(a,b); a /= g; b /= g; }}ans += Math.max(a,b); out.println(ans); } public static long gcd( long a, long b){ long c = 0; if ( (a < 0)) a = -a; if ( (b < 0)) b = -b; while((b > 0)){c = (a % b); a = b; b = c; }return a;} }
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{ static int N ; static int[] U ,V ; static int[] A ; public static void main( String[] args){ FastScanner sc = new FastScanner(System.in); N = sc.nextInt(); U = new int[(N - 1)]; V = new int[(N - 1)]; for ( int i = 0;(i < (N - 1));i++) {U[i] = (sc.nextInt() - 1); V[i] = (sc.nextInt() - 1); }A = sc.nextIntArray(N,-1); System.out.println((solve()?"Yes":"No")); } static boolean solve(){ if ( (A[0] != 0)) return false; int[][] G = adjB(N,U,V);  Map<Integer,Integer> parents = new HashMap<>(); for ( Node node :orderFromRoot(N,G,0)) {parents.put(node.a,node.parent); } ArrayDeque<Integer> q = new ArrayDeque<>(); for ( int next :G[0]) {q.add(0); } int idx = 1; while(!q.isEmpty()){ int p = q.poll();  int a = A[idx++]; if ( (parents.get(a) != p)) {return false;} for ( int next :G[a]) {if ( (next == p)) continue; q.add(a); }}return true;} static int[][] adjB( int n, int[] from, int[] to){ int[][] adj = new int[n][];  int[] cnt = new int[n]; for ( int f :from) {cnt[f]++; }for ( int t :to) {cnt[t]++; }for ( int i = 0;(i < n);i++) {adj[i] = new int[cnt[i]]; }for ( int i = 0;(i < from.length);i++) {adj[from[i]][--cnt[from[i]]] = to[i]; adj[to[i]][--cnt[to[i]]] = from[i]; }return adj;} static Node[] orderFromRoot( int N, int[][] G, int root){ ArrayDeque<Node> q = new ArrayDeque<>();  Node[] ret = new Node[N];  int idx = 0; q.add(new Node(-1,root)); while(!q.isEmpty()){ Node n = q.poll(); ret[idx++] = n; for ( int next :G[n.a]) {if ( (next == n.parent)) continue; q.add(new Node(n.a,next)); }}return ret;} static class Node{ int parent ,a ; public Node( int parent, int a){ this.parent = parent; this.a = a; } } @SuppressWarnings("unused") static class FastScanner{ private BufferedReader reader ; private StringTokenizer tokenizer ; FastScanner( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } String next(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} } return tokenizer.nextToken();} long nextLong(){ return Long.parseLong(next());} int nextInt(){ return Integer.parseInt(next());} int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} int[] nextIntArray( int n, int delta){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = (nextInt() + delta); return a;} } static int max( int... as){ int max = Integer.MIN_VALUE; for ( int a :as) max = Math.max(a,max); return max;} static int min( int... as){ int min = Integer.MAX_VALUE; for ( int a :as) min = Math.min(a,min); return min;} }
0	public class Main{ public static void main( String[] args){ InputStream intputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(intputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(in,out); out.close(); } static class TaskA{ public void solve( InputReader in, PrintWriter out){ out.println(25); } } 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();} } }
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());} } }
2	public class prob1177b{ 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)]); } }
5	public class A{ public void run()throws IOException { final int n = IOFast.nextInt();  int[] xs = new int[n]; for ( int i = 0;(i < n);i++) {xs[i] = IOFast.nextInt(); } int[] ys = xs.clone();  Random random = new Random(); for ( int i = 0;(i < n);i++) {final int j = random.nextInt((i + 1)); final int t = ys[j]; ys[j] = ys[i]; ys[i] = t; }Arrays.sort(ys); int diff = 0; for ( int i = 0;(i < ys.length);i++) {if ( (xs[i] != ys[i])) {diff++; } }IOFast.out.println(((diff > 2)?"NO":"YES")); } public static void main( String[] args)throws IOException { new A().run(); IOFast.out.flush(); } }
3	public class Solution{ static private int[] dx = {-1,-1,-1,0,0,1,1,1}; static private int[] dy = {-1,0,1,-1,1,-1,0,1}; public static void main( String[] args){ Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int r = in.nextInt();  int c = in.nextInt();  boolean[][] m = new boolean[(r + 1)][(c + 1)];  boolean[][] inp = new boolean[(r + 1)][(c + 1)]; for ( int i = 0;(i < r);i++) { String s = in.next(); for ( int j = 0;(j < s.length());j++) {if ( (s.charAt(j) == '#')) {m[i][j] = true; inp[i][j] = true; } }}for ( int i = 0;(i < r);i++) {for ( int j = 0;(j < c);j++) {if ( canPress(i,j,r,c,inp)) {for ( int k = 0;(k < 8);k++) { int xi = (i + dx[k]);  int yi = (j + dy[k]); m[xi][yi] = false; }} }} boolean isLeftAny = false; for ( int i = 0;((i < r) && !isLeftAny);i++) {for ( int j = 0;((j < c) && !isLeftAny);j++) {if ( m[i][j]) {isLeftAny = true; break;} }}if ( isLeftAny) {System.out.println("NO"); } else {System.out.println("YES"); }} static private boolean canPress( int x, int y, int r, int c, boolean[][] inp){ for ( int i = 0;(i < 8);i++) { int xi = (x + dx[i]);  int yi = (y + dy[i]); if ( ((xi < 0) || (yi < 0))) {return false;} if ( ((xi >= r) || (yi >= c))) {return false;} if ( !inp[xi][yi]) {return false;} }return true;} }
3	public class icpc{ public static void main( String[] args)throws IOException { Reader in = new Reader();  int n = in.nextInt();  boolean[] A = new boolean[n];  int count = 0;  int[] B = new int[n]; for ( int i = 0;(i < n);i++) B[i] = in.nextInt(); Arrays.sort(B); for ( int i = 0;(i < n);i++) {if ( !A[i]) { int gcd = B[i]; for ( int j = 0;(j < n);j++) {if ( !A[j]) {gcd = gcd(B[j],gcd); if ( (gcd == B[i])) {A[j] = true; } else {gcd = B[i]; }} }count++; A[i] = true; } }System.out.println(count); } public static int gcd( int a, int b){ if ( (b == 0)) return a; return gcd(b,(a % b));} } class Name{ long d ; long x ; long y ; public Name( long d, long x, long y){ this.d = d; this.x = x; this.y = y; } } 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(); } }
6	public class Main{ static int hx ,hy ; static int[] X ,Y ; static int N ; static int[] DP ; static int pw( int a){ return (a * a);} 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 = ((((((recur(((U | (1 << a)) | (1 << i))) + 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 ( (ans3 < ans2)) {ans2 = ans3; 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)); }}System.out.println(ans); for ( int i = 0;(i < aa.size());++i) {System.out.print((aa.get(i) + " ")); }} static private 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,((((((recur(((U | (1 << a)) | (1 << i))) + 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)))); } }DP[U] = ans; return ans;} }
1	public class SonyaExhibition{ static BufferedReader br ; static StringTokenizer tokenizer ; public static void main( String[] args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); int n = nextInt();  int[] arr = {0,1}; for ( int i = 0;(i < n);i++) {System.out.print(arr[(i % 2)]); }System.out.println(); } public static String next()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){ String line = br.readLine(); if ( (line == null)) throw (new IOException()); tokenizer = new StringTokenizer(line); }return tokenizer.nextToken();} public static int nextInt()throws IOException { return Integer.parseInt(next());} }
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[] input = new int[n];  int total = 0; for ( int i = 0;(i < n);++i) {input[i] = in.nextInt(); total += input[i]; }Arrays.sort(input); int res = 0;  int now = 0; for ( int i = (n - 1);(i >= 0);--i) {now += input[i]; int left = (total - now); ++res; if ( (now > left)) {break;} }out.println(res); return ;} }
6	public class x1209E{ public static void main( String[] hi)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int T = Integer.parseInt(st.nextToken());  StringBuilder sb = new StringBuilder(); while((T-- > 0)){st = new StringTokenizer(infile.readLine()); int N = Integer.parseInt(st.nextToken());  int M = Integer.parseInt(st.nextToken());  int[][] grid = new int[N][M]; for ( int r = 0;(r < N);r++) grid[r] = readArr(M,infile,st); ArrayList<Integer> ls = new ArrayList<Integer>(); for ( int i = 0;(i < M);i++) ls.add(i); Collections.sort(ls,(x,y)->{ int m1 = grid[0][x];  int m2 = grid[0][y]; for ( int r = 1;(r < N);r++) {m1 = max(m1,grid[r][x]); m2 = max(m2,grid[r][y]); }return (m2 - m1);}); int[][] newgrid = new int[N][M]; for ( int r = 0;(r < N);r++) for ( int c = 0;(c < M);c++) newgrid[r][c] = grid[r][ls.get(c)]; M = min(M,N); int[][] sums = new int[M][(1 << N)]; for ( int i = 1;(i < M);i++) for ( int mask = 0;(mask < (1 << N));mask++) {for ( int head = 0;(head < N);head++) { int temp = 0; for ( int b = 0;(b < N);b++) { int nb = (b + head); if ( (nb >= N)) nb -= N; if ( ((mask & (1 << nb)) > 0)) temp += newgrid[b][i]; }sums[i][mask] = max(sums[i][mask],temp); }} int[][] dp = new int[M][(1 << N)]; for ( int mask = 0;(mask < (1 << N));mask++) for ( int b = 0;(b < N);b++) if ( ((mask & (1 << b)) > 0)) dp[0][mask] += newgrid[b][0]; for ( int i = 1;(i < M);i++) for ( int mask = 0;(mask < (1 << N));mask++) for ( int pmask = mask;(pmask >= 0);pmask = ((pmask - 1) & mask)) {dp[i][mask] = max(dp[i][mask],(dp[(i - 1)][pmask] + sums[i][(mask - pmask)])); if ( (pmask == 0)) break; }sb.append((dp[(M - 1)][((1 << N) - 1)] + "\n")); }System.out.print(sb); } public static int[] readArr( int N, BufferedReader infile, StringTokenizer st)throws Exception { int[] arr = new int[N]; st = new StringTokenizer(infile.readLine()); for ( int i = 0;(i < N);i++) arr[i] = Integer.parseInt(st.nextToken()); return arr;} }
1	public class TaxiDriversAndLyft2{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long n = scanner.nextLong();  long m = scanner.nextLong();  long[] people = new long[(int)(n + m)];  int[] taxiDrivers = new int[(int)(n + m)]; for ( int i = 0;(i < (n + m));i++) {people[i] = scanner.nextLong(); }for ( int i = 0;(i < (n + m));i++) {taxiDrivers[i] = scanner.nextInt(); } int lastTaxiDriverIndex = -1;  long[] riderCountArray = new long[(int)m];  long[] a1 = new long[(int)n];  long[] b1 = new long[(int)m];  int j = 0,k = 0; for ( int i = 0;(i < (n + m));i++) {if ( (taxiDrivers[i] == 0)) {a1[j] = people[i]; j++; } else {b1[k] = people[i]; k++; }} int l = 0,q = 0; for ( int i = 0;(i < j);i++) {while((((l < (m - 1)) && (m > 1)) && (Math.abs((a1[i] - b1[l])) > Math.abs((a1[i] - b1[(l + 1)]))))){l++; }riderCountArray[l]++; }for ( int i = 0;(i < m);i++) {System.out.print((riderCountArray[i] + " ")); }} }
5	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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.nextInt();  TaskD.Pair[] p = new TaskD.Pair[n]; for ( int i = 0;(i < n);++i) {p[i] = new TaskD.Pair(in.nextLong(),in.nextLong()); }Arrays.sort(p); int last = 0;  int ans = 1; for ( int i = 1;(i < n);++i) {if ( ((p[i].x - p[i].w) >= (p[last].x + p[last].w))) {last = i; ++ans; } }out.println(ans); } } 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);} public long nextLong(){ int c = pread(); while(isSpaceChar(c))c = pread(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = pread(); } long res = 0; do {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));} } }
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.readInt();  int[] a = in.readIntArray(n);  int[][] sol = new int[n][n]; for ( int i = 0;(i < n);i++) {sol[0][i] = a[i]; }for ( int i = 1;(i < n);i++) {for ( int j = 0;(j < (n - i));j++) {sol[i][j] = (sol[(i - 1)][j] ^ sol[(i - 1)][(j + 1)]); }}for ( int i = 1;(i < n);i++) {for ( int j = 0;(j < (n - i));j++) {sol[i][j] = Math.max(sol[i][j],Math.max(sol[(i - 1)][j],sol[(i - 1)][(j + 1)])); }} int q = in.readInt(); for ( int i = 0;(i < q);i++) { int l = (in.readInt() - 1);  int r = (in.readInt() - 1); out.println(sol[(r - l)][l]); }} } static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read(){ try{if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) return -1; } }catch (IOException e){ throw (new RuntimeException(e));} return buf[curChar++];} public int readInt(){ return (int)readLong();} public long readLong(){ int c = read(); while(isSpaceChar(c)){c = read(); if ( (c == -1)) throw (new RuntimeException()); } boolean negative = false; if ( (c == '-')) {negative = true; 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 (negative?res:res);} public int[] readIntArray( int size){ int[] arr = new int[size]; for ( int i = 0;(i < size);i++) arr[i] = readInt(); return arr;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
2	public class Main{ static ArrayList<BigInteger> bs = new ArrayList<>(); static void getBs( int n, BigInteger k){ BigInteger four = BigInteger.valueOf(4);  BigInteger tmp4 = BigInteger.valueOf(1);  BigInteger sum = BigInteger.ZERO; for ( int i = 1;(i <= n);i++) {sum = sum.add(tmp4); bs.add(sum); if ( (sum.compareTo(k) >= 0)) break; tmp4 = tmp4.multiply(four); }} static int ss( int n, BigInteger k){ bs = new ArrayList<>(); BigInteger two = BigInteger.valueOf(2);  BigInteger s1 ;  BigInteger ts = BigInteger.ZERO; getBs((n - 1),k); int idx = (bs.size() - 1);  BigInteger tx = BigInteger.valueOf(-1);  int ans = -1; for ( int i = 1;(i <= n);i++) {two = two.shiftLeft(1); s1 = two.add(BigInteger.valueOf((-i - 2))); if ( (idx >= 0)) {tx = tx.add(BigInteger.ONE).multiply(BigInteger.valueOf(2)).add(BigInteger.ONE); ts = ts.add(tx.multiply(bs.get(idx--))); } if ( (k.compareTo(s1) >= 0)) {if ( (k.subtract(s1).compareTo(ts) <= 0)) {ans = (n - i); break;} } }return ans;} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int T = sc.nextInt(); while((T-- > 0)){ int n = sc.nextInt();  BigInteger k = sc.nextBigInteger();  int ans = ss(n,k); if ( (ans == -1)) {System.out.println("NO"); } else {System.out.println(("YES " + ans)); }}} }
1	public class B implements Runnable{ public static void main( String[] args){ new Thread(new B()).start(); } StringTokenizer st ; PrintWriter out ; BufferedReader br ; boolean eof = false,in_out = false,std = false; 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(){ return Integer.parseInt(nextToken());} void solve(){ int n = nextInt(); for ( int i = 0;(i < n);i++) {solve2(); }} void solve2(){ String s = nextToken();  boolean wasNum = false,isFirst = false; for ( int i = 0;(i < s.length());i++) {if ( ((s.charAt(i) >= '0') && (s.charAt(i) <= '9'))) {wasNum = true; } else if ( wasNum) {isFirst = true; break;} }if ( isFirst) { StringTokenizer e = new StringTokenizer(s,"RC");  int y = Integer.parseInt(e.nextToken());  int x = (Integer.parseInt(e.nextToken()) - 1); go1(x,y); } else {go2(s); }} void go1( int x, int y){ long cur = 26;  int len = 1; while((x >= cur)){x -= cur; cur *= 26; len++; } StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < len);i++) {sb.append((char)('A' + (x % 26))); x /= 26; }out.println((sb.reverse().toString() + y)); } void go2( String s){ int id = -1; for ( int i = 0;(i < s.length());i++) {if ( ((s.charAt(i) <= '9') && (s.charAt(i) >= '0'))) {id = i; break;} } String s1 = s.substring(0,id);  String s2 = s.substring(id);  int x = 0;  int cur = 26; for ( int i = 1;(i < s1.length());i++) {x += cur; cur *= 26; } int d = 0; for ( int i = 0;(i < s1.length());i++) {d *= 26; d += (s1.charAt(i) - 'A'); }x += d; out.println(((("R" + s2) + "C") + (x + 1))); } }
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{ static private 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 Main{ void pre()throws Exception { } void solve( int TC)throws Exception { long K = nl(); K--; int sz = 1;  long pw = 1; while((K >= pw)){ long npw = (pw * 10);  long dig = (sz * (npw - pw)); if ( (K >= dig)) {K -= dig; sz++; pw *= 10; } else break;} long num = (pw + (K / sz));  int dig = ((sz - (int)(K % sz)) - 1); while((dig-- > 0))num /= 10; pn((num % 10)); } void exit( boolean b){ if ( !b) System.exit(0); } final long IINF = (long)2e18; final int INF = ((int)1e9 + 2); DecimalFormat df = new DecimalFormat("0.00000000000"); double PI = 3.141592653589793238462643383279502884197169399,eps = 1e-8; static boolean multipleTC = false,memory = true,fileIO = false; FastReader in ; PrintWriter out ; void run()throws Exception { long ct = System.currentTimeMillis(); if ( fileIO) {in = new FastReader(""); out = new PrintWriter(""); } else {in = new FastReader(); out = new PrintWriter(System.out); } int T = (multipleTC?ni():1); pre(); for ( int t = 1;(t <= T);t++) solve(t); out.flush(); out.close(); System.err.println((System.currentTimeMillis() - ct)); } 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(); } int find( int[] set, int u){ return set[u] = ((set[u] == u)?u:find(set,set[u]));} 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 bit( long n){ return ((n == 0)?0:(1 + bit((n & (n - 1)))));} void pn( Object o){ out.println(o); } int ni()throws Exception { return Integer.parseInt(in.next());} long nl()throws Exception { 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()throws Exception { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new Exception(e.toString()));} }return st.nextToken();} String nextLine()throws Exception { String str ; try{str = br.readLine(); }catch (IOException e){ throw (new Exception(e.toString()));} return str;} } }
6	public class codeforces{ public static long cnt = 0; public static void f( int g1, int g2, int g3, int last){ if ( (((g1 == 0) && (g2 == 0)) && (g3 == 0))) cnt++; if ( ((g1 > 0) && (last != 1))) f((g1 - 1),g2,g3,1); if ( ((g2 > 0) && (last != 2))) f(g1,(g2 - 1),g3,2); if ( ((g3 > 0) && (last != 3))) f(g1,g2,(g3 - 1),3); } public static void main( String[] args)throws IOException { BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(scan.readLine());  int n = Integer.parseInt(st.nextToken());  int t = Integer.parseInt(st.nextToken());  int T[] = new int[n];  int G[] = new int[n]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(scan.readLine()); T[i] = Integer.parseInt(st.nextToken()); G[i] = Integer.parseInt(st.nextToken()); } long ans = 0; for ( int mask = 1;(mask < (1 << n));mask++) { int sum = 0;  int g1 = 0;  int g2 = 0;  int g3 = 0; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & mask) > 0)) {sum += T[i]; if ( (G[i] == 1)) g1++; if ( (G[i] == 2)) g2++; if ( (G[i] == 3)) g3++; } }cnt = 0; if ( (sum == t)) f(g1,g2,g3,-1); for ( long i = 1;(i <= g1);i++) cnt *= i; for ( long i = 1;(i <= g2);i++) cnt *= i; for ( long i = 1;(i <= g3);i++) cnt *= i; ans += cnt; }System.out.println((ans % 1000000007)); } }
5	public class Solution{ public static void main( String[] args)throws IOException { Scanner in = new Scanner(System.in);  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 res = 0,p = (n - 1); while(((k < m) && (p >= 0))){++res; k += (a[p] - 1); --p; }if ( (k >= m)) System.out.println(res); else System.out.println("-1"); } }
1	public class Main{ public static void main( String[] args){ Scanner cin = new Scanner(System.in);  int n ; n = cin.nextInt(); String s = cin.next();  int ans = n;  int cntH = 0,cntT = 0; for ( int i = 0;(i < n);i++) {if ( (s.charAt(i) == 'H')) cntH++; }cntT = (n - cntH); for ( int i = 0;((i + cntH) < n);i++) { int tmp = 0; for ( int j = i;(j < (i + cntH));j++) if ( (s.charAt(j) == 'T')) tmp++; if ( (ans > tmp)) ans = tmp; }for ( int i = 0;((i + cntT) < n);i++) { int tmp = 0; for ( int j = i;(j < (i + cntT));j++) if ( (s.charAt(j) == 'H')) tmp++; if ( (ans > tmp)) ans = tmp; }System.out.println(ans); } }
3	public class Main{ static Scanner console ; public static void main( String[] args){ console = new Scanner(System.in); int n = console.nextInt();  List<Integer> arr = new ArrayList<>(); for ( int i = 0;(i < n);i++) arr.add(console.nextInt()); Collections.sort(arr); List<Integer> groups = new ArrayList<>(); for ( int i = 0;(i < (arr.size() - 1));i++) { int j = (i + 1); groups.add(arr.get(i)); while((j < arr.size())){if ( ((arr.get(j) % arr.get(i)) == 0)) {arr.remove(j); } else {j++; }}}System.out.println(arr.size()); } }
6	public class Solution{ public static long mod = 1000000007; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int t = Integer.parseInt(st.nextToken());  int[] d = new int[n];  int[] g = new int[n]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); d[i] = Integer.parseInt(st.nextToken()); g[i] = (Integer.parseInt(st.nextToken()) - 1); } long[][] dp = new long[(1 << n)][3]; for ( int i = 0;(i < n);i++) {dp[(1 << i)][g[i]] = 1; } long res = 0; for ( int i = 1;(i < (1 << n));i++) { int k = i;  int sum = 0; for ( int j = (n - 1);(j >= 0);j--) {if ( (k >= (1 << j))) {k -= (1 << j); sum += d[j]; } else {for ( int r = 0;(r < 3);r++) if ( (r != g[j])) dp[(i + (1 << j))][g[j]] += dp[i][r]; dp[(i + (1 << j))][g[j]] %= mod; }}if ( (sum == t)) {res += ((dp[i][0] + dp[i][1]) + dp[i][2]); res %= mod; } }out.println(res); out.flush(); } }
1	public class ProblemA{ public static void main( String[] args)throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  PrintWriter writer = new PrintWriter(System.out);  int n = Integer.parseInt(reader.readLine());  String[] split = reader.readLine().split("\\s+");  int value ;  int[] count = new int[2];  int[] pos = new int[2]; for ( int i = 0;(i < split.length);i++) {value = Integer.parseInt(split[i]); count[(value % 2)]++; pos[(value % 2)] = (i + 1); }writer.println(((count[0] == 1)?pos[0]:pos[1])); writer.flush(); writer.close(); } }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}candidate = new int[n]; xs = new Xorshift(); mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; int[] candidate ; Xorshift xs ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {if ( (Long.bitCount(choosed) < Long.bitCount(mds))) mds = choosed; return ;} { long s = covered; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); s |= ((1L << i) | g[i]); }if ( (s != ((1L << n) - 1))) {return ;} } int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) k = i; }if ( (k == -1)) return ; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } class Xorshift{ int x ,y ,z ,w ; public Xorshift(){ x = 123456789; y = 362436069; z = 521288629; w = 88675123; } public Xorshift( int seed){ x = _(seed,0); y = _(x,1); z = _(y,2); w = _(z,3); } int _( int s, int i){ return (((1812433253 * (s ^ (s >>> 30))) + i) + 1);} public int nextInt(){ int t = (x ^ (x << 11)); x = y; y = z; z = w; return w = (((w ^ (w >>> 19)) ^ t) ^ (t >>> 8));} public int nextInt( int n){ return (int)(n * nextDouble());} public double nextDouble(){ int a = (nextInt() >>> 5),b = (nextInt() >>> 6); return (((a * 67108864.0) + b) * (1.0 / (1L << 53)));} } 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 P111C().run(); } }
2	public class Main{ public static void main( String[] args){ Scanner cin = new Scanner(System.in);  long z = ((cin.nextLong() - 1) << 1),n = cin.nextInt(),l = -1,r = (1 + n),m ; while((l < (m = ((l + r) >> 1))))if ( (z > (((m + n) - 1) * (n - m)))) r = m; else l = m; if ( (0 < l)) l = (n - l); System.out.print(l); } }
5	public class test{ public static void main( String[] args){ new test().run(); } PrintWriter out = null; void run(){ Scanner in = new Scanner(System.in); out = new PrintWriter(System.out); int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] h = new int[n]; for ( int i = 0;(i < n);i++) h[i] = in.nextInt(); Arrays.sort(h); if ( (h[b] == h[(b - 1)])) out.println(0); else out.println((h[b] - h[(b - 1)])); 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);  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;} } }
4	public class FireAgain{ static int n ; static int m ; public static void main( String[] args)throws IOException { BufferedReader r = new BufferedReader(new FileReader("input.txt"));  String s = r.readLine();  String[] sp = s.split(" "); n = new Integer(sp[0]); m = new Integer(sp[1]); boolean[][] v = new boolean[n][m]; r.readLine(); s = r.readLine(); sp = s.split(" "); Queue<Integer> q = new LinkedList<Integer>(); for ( int i = 0;(i < sp.length);i += 2) {v[(new Integer(sp[i]) - 1)][(new Integer(sp[(i + 1)]) - 1)] = true; q.add((new Integer(sp[i]) - 1)); q.add((new Integer(sp[(i + 1)]) - 1)); } int[] dx = {1,-1,0,0};  int[] dy = {0,0,1,-1};  int lx = -1;  int ly = -1; while(!q.isEmpty()){ int x = q.remove();  int y = q.remove(); lx = x; ly = y; for ( int i = 0;(i < dy.length);i++) { int nx = (x + dx[i]);  int ny = (y + dy[i]); if ( (valid(nx,ny) && !v[nx][ny])) {v[nx][ny] = true; q.add(nx); q.add(ny); } }}lx++; ly++; BufferedWriter wr = new BufferedWriter(new FileWriter("output.txt")); wr.write(((("" + lx) + " ") + ly)); wr.newLine(); wr.close(); } static private boolean valid( int nx, int ny){ return ((((nx >= 0) && (nx < n)) && (ny >= 0)) && (ny < m));} }
3	public class _909C{ int mod = ((int)1e9 + 7); public void solve()throws FileNotFoundException { InputStream inputStream = System.in;  InputHelper in = new InputHelper(inputStream);  int n = in.readInteger();  char[] a = new char[n]; for ( int i = 0;(i < n);i++) {a[i] = in.read().charAt(0); } int[][][] dp = new int[2][(n + 1)][2]; dp[0][0][0] = dp[0][0][1] = 1; for ( int i = 1;(i < n);i++) {for ( int j = n;(j >= 0);j--) {if ( (a[(i - 1)] == 's')) {dp[1][j][0] = dp[1][j][1] = dp[0][j][1]; } else {if ( (j > 0)) dp[1][j][0] = dp[1][j][1] = dp[0][(j - 1)][0]; }}for ( int j = 0;(j <= n);j++) {dp[0][j][0] = dp[1][j][0]; dp[0][j][1] = dp[1][j][1]; dp[1][j][0] = 0; dp[1][j][1] = 0; }for ( int j = (n - 1);(j >= 0);j--) {dp[0][j][1] += dp[0][(j + 1)][1]; dp[0][j][1] %= mod; }}System.out.println(dp[0][0][1]); } public static void main( String[] args)throws FileNotFoundException { new _909C().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());} } }
4	public class FireAgain implements Runnable{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer tok ; private void solve()throws IOException { int n = nextInt(),m = nextInt();  int[][] sources = readIntMatrix(nextInt(),2);  int max = -1,maxI = 0,maxJ = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int min = Integer.MAX_VALUE; for ( int[] source :sources) { int dist = (abs((source[0] - i)) + abs((source[1] - j))); if ( (dist < min)) {min = dist; } }if ( (min > max)) {max = min; maxI = i; maxJ = j; } }}out.print((((maxI + 1) + " ") + (maxJ + 1))); } public static void main( String[] args){ new FireAgain().run(); } @Override public void run(){ try{in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); tok = null; solve(); in.close(); out.close(); }catch (IOException e){ System.exit(0); } } private String nextToken()throws IOException { while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(nextToken());} private int[][] readIntMatrix( int n, int m)throws IOException { int[][] mx = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {mx[i][j] = (nextInt() - 1); }}return mx;} }
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]; 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; for ( int j = 0;(j < m);j++) {if ( ((i & (1 << j)) > 0)) {for ( int k = 0;(k < m);k++) {if ( ((i & (1 << k)) == 0)) {v += cnt[j][k]; } }} }for ( int j = 0;(j < m);j++) {if ( ((i & (1 << j)) > 0)) {dp[i] = Math.min(dp[i],(dp[(i - (1 << j))] + 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());} }
5	public class CodeforcesRound159{ public static void main( String[] args){ Scanner kde = new Scanner(System.in);  int n = kde.nextInt();  int m = kde.nextInt();  int k = kde.nextInt();  ArrayList<Integer> count = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {count.add(kde.nextInt()); }Collections.sort(count); Collections.reverse(count); if ( (m <= k)) {System.out.println("0"); return ;} m = ((m - k) + 1); int res = 0; for ( int i = 0;(i < n);i++) {if ( (i != 0)) {res += (count.get(i) - 1); } else {res += count.get(i); }if ( (res >= m)) {System.out.println((i + 1)); return ;} }System.out.println("-1"); } }
2	public class CodeForces{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  int ans = 0;  long x = n; x = ((x * (x + 1)) / 2); while((x != k)){x -= n; n--; ans++; k++; }System.out.println(ans); } }
3	public class CF{ private FastScanner in ; private PrintWriter out ; final int mod = ((int)1e9 + 7); private long f( String s, int digit){ final int n = s.length();  int[][] dp = new int[2][(n + 1)]; dp[0][0] = 1; int[][] ndp = new int[2][(n + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < 2);j++) {Arrays.fill(ndp[j],0); }for ( int less = 0;(less < 2);less++) {for ( int cntBigger = 0;(cntBigger <= n);cntBigger++) { int cur = dp[less][cntBigger]; if ( (cur == 0)) {continue;} int max = ((less == 1)?9:(s.charAt(i) - '0')); for ( int next = 0;(next <= max);next++) { int nextLess = (((less == 1) || (next < max))?1:0);  int nextCntBigger = (cntBigger + ((next >= digit)?1:0)); ndp[nextLess][nextCntBigger] += cur; while((ndp[nextLess][nextCntBigger] >= mod)){ndp[nextLess][nextCntBigger] -= mod; }}}} int[][] tmp = dp; dp = ndp; ndp = tmp; } long result = 0; for ( int less = 0;(less < 2);less++) { long sum = 0; for ( int cntBigger = 1;(cntBigger <= n);cntBigger++) {sum = (((sum * 10) + 1) % mod); result = ((result + (sum * dp[less][cntBigger])) % mod); }}return (result % mod);} private void solve(){ final String number = in.next();  long result = 0; for ( int digit = 1;(digit < 10);digit++) { long cur = f(number,digit); result += cur; }out.println((result % mod)); } private void runIO(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } private 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())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} } public static void main( String[] args){ new CF().runIO(); } }
1	public class TheyAreEverywhere{ static StringTokenizer st ; static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in),325678); static int[] id = new int[100000]; public static void main( String[] args)throws IOException { int n = in();  String s = next();  int total = 0;  int[] seq = new int[n];  boolean[] c = new boolean[100000]; for ( int i = 0;(i < n);i++) {seq[i] = s.charAt(i); if ( !c[seq[i]]) {total++; c[seq[i]] = true; } }Arrays.fill(id,-1); int best = Integer.MAX_VALUE;  TreeSet<Integer> q = new TreeSet<Integer>(new Comparator<Integer>(){}); for ( int i = 0;(i < n);i++) {q.remove(seq[i]); id[seq[i]] = i; q.add(seq[i]); if ( (q.size() == total)) {best = Math.min(best,((i - id[q.first()]) + 1)); } }System.out.println(best); } public static int in()throws IOException { return Integer.parseInt(next());} public static String next()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) st = new StringTokenizer(bf.readLine()); return st.nextToken();} }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong(); System.out.println(25); } }
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(); } } class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ int N = in.nextInt();  int M = in.nextInt();  int K = in.nextInt();  int[][] dist = new int[(N + 1)][(M + 1)]; for ( int[] ini :dist) Arrays.fill(ini,(1 << 30)); int best = 0;  ArrayList<Integer> result = new ArrayList<Integer>();  Queue<Integer> q = new LinkedList<Integer>(); for ( int k = 0;(k < K);++k) { int x = in.nextInt();  int y = in.nextInt(); dist[x][y] = 0; q.offer(x); q.offer(y); } int[] dx = new int[]{1,-1,0,0};  int[] dy = new int[]{0,0,1,-1}; while(!q.isEmpty()){ int a = q.poll();  int b = q.poll(); for ( int r = 0;(r < 4);++r) { int x = (a + dx[r]);  int y = (b + dy[r]); if ( (((((x >= 1) && (x <= N)) && (y >= 1)) && (y <= M)) && (dist[x][y] > (dist[a][b] + 1)))) {dist[x][y] = (dist[a][b] + 1); q.offer(x); q.offer(y); } }}for ( int i = 1;(i <= N);++i) for ( int j = 1;(j <= M);++j) best = Math.max(best,dist[i][j]); for ( int a = 1;(a <= N);++a) for ( int b = 1;(b <= M);++b) if ( (dist[a][b] == best)) {result.add(a); result.add(b); } if ( (result.size() > 0)) {out.print(((result.get(0) + " ") + result.get(1))); } out.println(); } } 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 nextInt(){ return Integer.parseInt(next());} }
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 memo[mask][u] = sum;}} static private void solveTopDown( FastScanner s1, PrintWriter out){ int V = s1.nextInt();  int E = s1.nextInt(); graph = new int[V]; memo = new long[(1 << V)][V]; for ( long[] l :memo) Arrays.fill(l,-1); 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++) memo[(1 << i)][i] = 1; 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 += hamiltonianPath(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); solveTopDown(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(); } } } }
2	public class P1177A{ public static void main( String[] args)throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  long n = Long.parseLong(r.readLine()); if ( (n < 10)) {System.out.print(n); return ;} int len = 1;  long edge = 10;  long prev = 0;  long prepow = 0; while(((edge - 1) < n)){prepow = (long)Math.pow(10,len); long pow = (prepow * 10); prev = edge; edge = (edge + ((pow - prepow) * (len + 1))); len += 1; } long b = (n - prev);  long c = (b / len);  int rem = (int)(b % len);  String s = (Long.toString((prepow + c)).charAt(rem) + ""); System.out.print(s); } }
2	public class Main implements Runnable{ int n ; boolean inBound( int x, int y){ return ((((x >= 1) && (y >= 1)) && (x <= n)) && (y <= n));} void solve()throws Exception { n = sc.nextInt(); int y = sc.nextInt();  int x = sc.nextInt();  int c = sc.nextInt();  int yu = y;  int yd = y;  int xl = x;  int xr = x;  int current = 1;  int time = 0; while((current < c)){time++; yu--; yd++; xl--; xr++; { int cur = (time - 1); if ( (yu < 1)) {cur -= yu; } if ( (xl < 1)) {cur -= xl; } if ( (cur > 0)) {current += cur; } }{ int cur = (time - 1); if ( (yu < 1)) {cur -= yu; } if ( (xr > n)) {cur -= ((xr - n) - 1); } if ( (cur > 0)) {current += cur; } }{ int cur = (time - 1); if ( (yd > n)) {cur -= ((yd - n) - 1); } if ( (xl < 1)) {cur -= xl; } if ( (cur > 0)) {current += cur; } }{ int cur = (time - 1); if ( (yd > n)) {cur -= ((yd - n) - 1); } if ( (xr > n)) {cur -= ((xr - n) - 1); } if ( (cur > 0)) {current += cur; } }if ( inBound(x,yd)) current++; if ( inBound(x,yu)) current++; if ( inBound(xl,y)) current++; if ( inBound(xr,y)) current++; }out.println(time); } BufferedReader in ; PrintWriter out ; FastScanner sc ; static Throwable uncaught ; public static void main( String[] args)throws Throwable { Thread t = new Thread(null,new Main(),"",(1 << 26)); 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());} }
4	public class e_g14{ public static void main( String[] args)throws Exception { FastScanner in = new FastScanner(System.in);  OutputStream outputStream = System.out;  PrintWriter out = new PrintWriter(outputStream);  int T = 1;  Solver A = new Solver(in,out); for ( int aa = 0;(aa < T);aa++) {A.answer((aa + 1)); }out.close(); } static class Solver{ FastScanner in ; PrintWriter out ; int n ; long m ; long[] fact ,pow ,choose[] ,dp[] ; public Solver( FastScanner in, PrintWriter out){ this.in = in; this.out = out; } public void answer( int aa)throws Exception { n = in.nextInt(); m = in.nextLong(); fact = new long[(n + 5)]; choose = new long[(n + 5)][(n + 5)]; dp = new long[(n + 2)][(n + 2)]; pow = new long[(n + 2)]; init(); 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] * choose[(j + k)][k]) % m) * pow[(k - 1)]); dp[((i + k) + 1)][(j + k)] %= m; }}} long ans = 0; for ( int i = 0;(i <= n);i++) {ans += dp[(n + 1)][i]; ans %= m; }out.println(ans); } public void init(){ fact[0] = 1; for ( int i = 1;(i <= (n + 4));i++) {fact[i] = ((i * fact[(i - 1)]) % m); }pow[0] = 1; for ( int i = 1;(i <= (n + 1));i++) {pow[i] = ((2 * pow[(i - 1)]) % m); }for ( int i = 0;(i <= (n + 4));i++) {for ( int j = 0;(j <= i);j++) {choose[i][j] = choose(i,j); }}} private long choose( int a, int b){ long res = ((fact[a] * inv(((fact[b] * fact[(a - b)]) % m))) % m); return res;} private long power( long x, long y){ long res = 1; while((y > 0)){if ( ((y % 2) == 1)) res = ((res * x) % m); x = ((x * x) % m); y /= 2; }return (res % m);} private long inv( long a){ return power(a,(m - 2));} } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); st = new StringTokenizer(""); } public FastScanner( String fileName)throws Exception{ br = new BufferedReader(new FileReader(new File(fileName))); st = new StringTokenizer(""); } public String next()throws Exception { while(!st.hasMoreTokens()){st = new StringTokenizer(br.readLine()); }return st.nextToken();} public int nextInt()throws Exception { return Integer.parseInt(next());} public long nextLong()throws Exception { return Long.parseLong(next());} } }
1	public class Round1TaskB implements Runnable{ static PrintWriter pw = null; static BufferedReader br = null; StringTokenizer st = null; public static void main( String[] args)throws IOException { pw = new PrintWriter(new OutputStreamWriter(System.out)); br = new BufferedReader(new InputStreamReader(System.in)); new Thread(new Round1TaskB()).start(); } void nline(){ try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ } } int ni(){ while(((st == null) || !st.hasMoreTokens()))nline(); return Integer.valueOf(st.nextToken());} String nwrd(){ while(((st == null) || !st.hasMoreTokens()))nline(); return st.nextToken();} boolean isDigit( char c){ if ( ((c <= '9') && (c >= '0'))) return true; return false;} void rec( int t, int length){ if ( (length == 0)) {return ;} rec((t / 26),(length - 1)); pw.print((char)('A' + (t % 26))); } void RC( int i, int j){ int num = 0; for ( int t = i;(t < j);t++) {num = (((num * 10) + format[t]) - '0'); } int len = 0,base = 1,total = 0; while(true){base *= 26; total += base; len++; if ( (num <= total)) break; }num -= (total / 26); rec(num,len); } void BC( int i, int j){ int total = 0,base = 1,rest = 0; for ( int k = i;(k < j);k++) {total += base; base *= 26; rest = (((rest * 26) + format[k]) - 'A'); }pw.print((total + rest)); } char format[] ; public void solve(){ format = nwrd().toCharArray(); int L = format.length; for ( int i = 0;(i < (L - 1));i++) {if ( (isDigit(format[i]) && (format[(i + 1)] == 'C'))) {RC((i + 2),L); for ( int j = 1;(j <= i);j++) {pw.print(format[j]); }pw.println(); return ;} }for ( int i = 0;(i < L);i++) {if ( isDigit(format[i])) {pw.print('R'); for ( int j = i;(j < L);j++) {pw.print(format[j]); }pw.print('C'); BC(0,i); pw.println(); return ;} }} }
3	public class C{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int r = sc.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = sc.nextInt(); double[] ans = new double[n]; for ( int i = 0;(i < n);i++) { double max = 0; for ( int j = 0;(j < i);j++) { int difx = Math.abs((arr[i] - arr[j])); if ( (difx <= (2 * r))) {max = Math.max(max,(ans[j] + Math.sqrt((((4 * r) * r) - (difx * difx))))); } }ans[i] = max; } PrintWriter pw = new PrintWriter(System.out); for ( int i = 0;(i < n);i++) pw.print(((ans[i] + r) + " ")); pw.flush(); } 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();} } }
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(); } }
1	public class IQTest{ public static void main( String[] args){ try{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String str = in.readLine();  int n = Integer.parseInt(str);  int odd = -1,even = -1,odds = 0,evens = 0; str = in.readLine(); String[] numbers = str.split(" ");  int index = 1; for ( String number :numbers) { int i = Integer.parseInt(number); if ( ((i % 2) == 0)) {++evens; if ( (even == -1)) even = index; } else {++odds; if ( (odd == -1)) odd = index; }++index; }System.out.println(((evens > odds)?odd:even)); }catch (Exception e){ e.printStackTrace(); } } }
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; for ( int i = 0;(i < N);i++) { boolean[][] mat = makeAdjMat(N,edgeFrom,edgeTo); best = Math.min(best,count(mat,M,i)); }System.out.println(best); } public static int count( boolean[][] mat, int M, int center){ int N = mat.length;  int centerCount = (mat?1:0); for ( int i = 0;(i < N);i++) {if ( (i != center)) {if ( mat[i][center]) {centerCount++; } if ( mat[center][i]) {centerCount++; } } mat[i][center] = false; mat[center][i] = false; } int other = (M - centerCount);  int matches = bipartiteMatching(mat); return ((((((((2 * N) - 1) - centerCount) + 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 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();} } }
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());} } }
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(); } }
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();} static private boolean isSpaceChar(final int c){ return (((((c == 32) || (c == 10)) || (c == 13)) || (c == 9)) || (c == -1));} } }
1	public class SpreadSheet{ public void run(){ try{ Scanner s = new Scanner(System.in);  int tests = s.nextInt(); for ( int i = 0;(i < tests);i++) { String line = s.next();  String regex = "R[\\d]+C[\\d]+";  Pattern pattern = Pattern.compile(regex);  Matcher matcher = pattern.matcher(line); if ( matcher.matches()) { int r = Integer.parseInt(line.substring(1,line.indexOf("C")));  int c = Integer.parseInt(line.substring((line.indexOf("C") + 1))); System.out.println(toFormula(r,c)); } else { int index = -1; for ( int j = 0;(j < line.length());j++) {if ( ((line.charAt(j) >= '0') && (line.charAt(j) <= '9'))) {index = j; break;} } String c = line.substring(0,index);  int r = Integer.parseInt(line.substring(index)); System.out.println(fromFormula(c,r)); }} }catch (Exception e){ e.printStackTrace(); } } private String toFormula( int r, int c){ StringBuffer buff = new StringBuffer();  char ch ; while((c != 0)){ int m = (c % 26); if ( (m == 0)) {ch = 'Z'; c = ((c / 26) - 1); } else {ch = (char)((m + 'A') - 1); c /= 26; }buff.append(ch); }return (buff.reverse().toString() + r);} private String fromFormula( String c, int r){ int ret = 0;  int power = 1; for ( int i = (c.length() - 1);(i >= 0);i--) {ret += (((c.charAt(i) - 'A') + 1) * power); power *= 26; }return ((("R" + r) + "C") + ret);} public static void main( String[] args){ new SpreadSheet().run(); } }
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());} } }
6	public class G1_PlaylistForPolycarp{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader inp = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Solver solver = new Solver(); solver.solve(inp,out); out.close(); } static private class Solver{ private void solve( InputReader inp, PrintWriter out){ int n = inp.nextInt(),t = inp.nextInt();  int[][] tracks = new int[n][2];  long MOD = 1000000007; for ( int i = 0;(i < n);i++) {tracks[i][0] = inp.nextInt(); tracks[i][1] = (inp.nextInt() - 1); } long[][] dp = new long[(2 << n)][4]; dp[0][3] = 1; int curr = 1; while((curr <= n)){ int mask = 0; for ( int i = 0;(i < curr);i++) mask |= (1 << i); while((mask < (2 << n))){for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {for ( int j = 0;(j < 4);j++) {if ( (j == tracks[i][1])) continue; dp[mask][tracks[i][1]] += dp[(mask - (1 << i))][j]; }} }mask = nextNumberXBits(mask); }curr++; } long res = 0; for ( int i = 0;(i < (2 << n));i++) { int time = 0; for ( int j = 0;(j < n);j++) {if ( ((i & (1 << j)) != 0)) time += tracks[j][0]; }if ( (time == t)) {for ( int j = 0;(j < 4);j++) {res += dp[i][j]; }res %= MOD; } }out.print(res); } static private int nextNumberXBits( int mask){ int c = (mask & -mask);  int r = (mask + c); return ((((r ^ mask) >> 2) / c) | r);} } static class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } 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 Main implements Runnable{ public void _main()throws IOException { int n = nextInt();  int k = nextInt();  boolean[] p = new boolean[(n + 1)]; Arrays.fill(p,true); List<Integer> primes = new ArrayList<Integer>(); for ( int i = 2;(i <= n);i++) if ( p[i]) {primes.add(i); for ( int j = (i + i);(j <= n);j += i) p[j] = false; } boolean[] ok = new boolean[(n + 1)]; for ( int i = 0;(i < (primes.size() - 1));i++) { int x = primes.get(i);  int y = primes.get((i + 1)); if ( (((x + y) + 1) <= n)) ok[((x + y) + 1)] = true; }for ( int i = 2;(i <= n);i++) if ( (p[i] && ok[i])) {--k; } out.println(((k <= 0)?"YES":"NO")); } 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 D{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int inv = 0;  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); for ( int j = 0;(j < n);j++) for ( int i = (j + 1);(i < n);i++) if ( (a[j] > a[i])) inv = (1 - inv);  int m = sc.nextInt();  StringBuilder sb = new StringBuilder(); while((m-- > 0)){ int l = sc.nextInt();  int r = sc.nextInt();  int s = ((r - l) + 1); if ( ((((s * (s - 1)) / 2) % 2) == 1)) inv = (1 - inv); if ( (inv == 1)) sb.append("odd\n"); else sb.append("even\n"); }System.out.print(sb); } 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();} } }
1	public class A{ static double eps = (double)1e-15; static long mod = ((int)1e9 + 7); public static void main( String[] args){ InputReader in = new InputReader(System.in);  OutputStream outputStream = System.out;  PrintWriter out = new PrintWriter(outputStream);  int n = in.nextInt();  int l = 0,r = 0;  String s = in.nextLine();  HashSet<Character> size = new HashSet<>(); for ( int i = 0;(i < n);i++) { char p = s.charAt(i); size.add(p); } int chk = size.size();  HashMap<Character,Integer> hm = new HashMap<>();  int ans = Integer.MAX_VALUE; while((l < n)){if ( ((hm.size() < chk) && (r < n))) { char p = s.charAt(r); if ( hm.containsKey(p)) {hm.put(p,(hm.get(p) + 1)); } else {hm.put(p,1); }r++; } else { char p = s.charAt(l); if ( (hm.get(p) == 1)) {hm.remove(p); } else {hm.put(p,(hm.get(p) - 1)); }l++; }if ( (hm.size() == chk)) {ans = Math.min(ans,(r - l)); } }out.println(ans); 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 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();} public int nextInt(){ return Integer.parseInt(next());} } }
1	public class A{ public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  List<Integer> list = new ArrayList<Integer>(),list2 ; for ( ;(n-- > 0);) {list.add(scan.nextInt()); }list2 = new ArrayList<Integer>(list); Collections.sort(list2,new Comparator<Integer>(){}); System.out.println((list.indexOf(list2.get((((list2.get(1) % 2) > 0)?0:(list2.size() - 1)))) + 1)); } }
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 ;} }} }
1	public class helloWorld{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  int[] ar = new int[200];  String str = in.next(); for ( int i = 0;(i < str.length());i++) ar[str.charAt(i)]++; int ans = 100000; for ( int i = 'A';(i < ('A' + m));i++) ans = Math.min(ans,ar[i]); ans *= m; System.out.println(ans); in.close(); } }
0	public class ProblemB{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int a = s.nextInt();  int f1 = (a / 10);  int b = a;  int last = (a % 10); b /= 10; b /= 10; b *= 10; b += last; System.out.println(Math.max(a,Math.max(f1,b))); } }
2	public class CodeforcesRound176B{ public static void main( String[] args){ Scanner kde = new Scanner(System.in);  Long n = kde.nextLong();  Long k = kde.nextLong(); if ( ((((k - 1) * (k - 2)) + (2 * k)) < (n * (long)2))) {System.out.println(-1); return ;} Long a ,b ; if ( (n == 1)) {System.out.println(0); return ;} if ( (k >= n)) {System.out.println(1); return ;} else {a = (long)2; b = (k - 1); } boolean flag = false; while(true){if ( (a >= b)) {break;} long c = ((a + b) / 2); if ( (((2 * ((k - c) + 1)) + (((((k - 1) + k) - c) + 1) * (c - 1))) < (n * 2))) {a = (c + 1); } else {b = c; }flag = true; }if ( (flag == true)) {System.out.println(a); } else {System.out.println(a); }} }
1	public class Main{ static FastReader in ; static PrintWriter out ; static Random rand = new Random(); static final int oo = ((int)1e9 + 10); static final long OO = ((long)1e18 + 10); static final int MOD = ((int)1e9 + 7); static boolean isSq( int x){ int sq = (int)Math.sqrt(x); return ((sq * sq) == x);} static void solve(){ int n = in.nextInt(); if ( ((((n % 2) == 0) && isSq((n / 2))) || (((n % 4) == 0) && isSq((n / 4))))) out.println("YES"); else out.println("NO"); } public static void main( String[] args){ in = new FastReader(); out = new PrintWriter(System.out); int t = 1; t = in.nextInt(); while((t-- > 0)){solve(); }out.flush(); out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; FastReader(){ this(System.in); } FastReader( String file)throws FileNotFoundException{ this(new FileInputStream(file)); } FastReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } int nextInt(){ return Integer.parseInt(next());} String next(){ while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(nextLine()); }return st.nextToken();} String nextLine(){ String line ; try{line = br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} return line;} } }
2	public class D{ 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 k = Integer.parseInt(st.nextToken()); for ( int i = 0;(i < 100000);i++) { long mult = (((1L * i) * (i + 1)) / 2);  long b = ((1L * mult) - k); if ( ((i + b) == (n * 1L))) {out.println(b); out.close(); System.exit(0); } }out.close(); System.exit(0); } }
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); } }
5	public class a implements Comparable<a>{ int x ,y ,id ; public a( int x1, int y1, int id1){ this.x = x1; this.y = y1; this.id = id1; } static int n ; static int arr[] ; public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); arr = new int[n]; int sum = 0; for ( int i = 0;(i < n);i++) {arr[i] = in.nextInt(); sum += arr[i]; }Arrays.sort(arr); int sum2 = 0;  int ans = 0; for ( int i = (n - 1);(i >= 0);i--) {sum2 += arr[i]; if ( (sum2 > (sum - sum2))) {ans = (n - i); break;} }System.out.println(ans); } }
4	public class Main{ static private BufferedReader br ; static private StringTokenizer st ; static private 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; } } static private void exitImmediately(){ pw.close(); System.exit(0); } static private int readInt()throws IOException { return Integer.parseInt(nextToken());} static private String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){if ( !br.ready()) {exitImmediately(); } st = new StringTokenizer(br.readLine().trim()); }return st.nextToken();} }
5	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  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); pw.print((h[b] - h[(b - 1)])); pw.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 C455{ static int N ; static final int mod = 1_000_000_007; static int[][] memo ; static int[] list ; public static void main( String[] args){ FS scan = new FS(System.in); N = scan.nextInt(); list = new int[N]; for ( int i = 0;(i < N);i++) {list[i] = (scan.next().equals("s")?0:1); }if ( (list[(N - 1)] == 1)) {System.out.println(0); return ;} memo = new int[(N + 1)][(N + 2)]; Arrays.fill(memo[N],1); int[] sum = new int[(N + 2)]; for ( int i = (N - 1);(i >= 0);i--) {sum[0] = memo[(i + 1)][0]; for ( int j = 1;(j < sum.length);j++) {sum[j] = (sum[(j - 1)] + memo[(i + 1)][j]); sum[j] %= mod; }for ( int j = 0;(j <= N);j++) {if ( ((list[i] == 1) && ((i == 0) || (list[(i - 1)] == 1)))) memo[i][j] = memo[(i + 1)][(j + 1)]; else if ( ((i == 0) || (list[(i - 1)] == 1))) memo[i][j] = memo[(i + 1)][j]; else if ( (list[i] == 1)) {memo[i][j] = ((sum[(j + 1)] - sum[0]) + mod); memo[i][j] %= mod; } else if ( (list[i] == 0)) {memo[i][j] = sum[j]; } }}System.out.println(memo[0][0]); } static private class FS{ BufferedReader br ; StringTokenizer st ; public FS( 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());} } }
6	public class LookingForOrder{ static int[][] pos ; static int[] dp ; static int[] nextstate ; static int[][] dist ; static int r ; static int v ; static void print( int mask){ if ( (mask < v)) { int c = 0;  int x = (mask ^ nextstate[mask]); for ( int i = 0;(i < (dist.length - 1));i++) {if ( ((x & (1 << i)) > 0)) {System.out.print(((i + 1) + " ")); c++; } }System.out.print("0 "); print(nextstate[mask]); } } static int distace( int x1, int x2, int y1, int y2){ return (((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));} static int solve( int mask){ if ( (mask == v)) {nextstate[mask] = r; return 0;} if ( (nextstate[mask] != 0)) {return dp[mask];} dp[mask] = (int)1e9; for ( int i = 1;(i < pos.length);i++) { int u = (1 << (i - 1));  int z = (mask | u); if ( ((mask & u) == 0)) { int x = ((2 * dist[i][0]) + solve(z)); if ( (dp[mask] > x)) {dp[mask] = x; nextstate[mask] = z; } for ( int j = 1;(j < pos.length);j++) { int m = (1 << (j - 1));  int y = (z | m); if ( ((z & m) == 0)) {x = (((dist[i][0] + solve(y)) + dist[i][j]) + dist[j][0]); if ( (dp[mask] > x)) {dp[mask] = x; nextstate[mask] = y; } } }break;} }return dp[mask];} public static void main( String[] args){ InputReader0 in = new InputReader0(System.in);  int x = in.nextInt(),y = in.nextInt();  int n = in.nextInt(); r = (1 << n); v = (r - 1); dp = new int[r]; nextstate = new int[r]; pos = new int[(n + 1)][2]; pos[0][0] = x; pos[0][1] = y; for ( int i = 1;(i < pos.length);i++) {pos[i][0] = in.nextInt(); pos[i][1] = in.nextInt(); }dist = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i < dist.length);i++) {for ( int j = (i + 1);(j < dist.length);j++) {dist[i][j] = dist[j][i] = distace(pos[i][0],pos[j][0],pos[i][1],pos[j][1]); }}System.out.println(solve(0)); System.out.print("0 "); print(0); } } class InputReader0{ BufferedReader reader ; StringTokenizer tokenizer ; public InputReader0( 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());} }
2	public class x1080D{ public static void main( String[] hi)throws Exception { long[] dp = new long[32]; for ( int i = 1;(i <= 31);i++) dp[i] = (1 + (4 * dp[(i - 1)])); BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int T = Integer.parseInt(st.nextToken());  StringBuilder sb = new StringBuilder(); matcha:while((T-- > 0)){st = new StringTokenizer(infile.readLine()); int N = Integer.parseInt(st.nextToken());  long K = Long.parseLong(st.nextToken()); if ( ((N >= 32) || (K == 1))) sb.append((("YES " + (N - 1)) + "\n")); else if ( (dp[N] == K)) sb.append("YES 0\n"); else if ( (dp[N] < K)) sb.append("NO\n"); else { long total = 3L;  long length = 2; for ( int res = (N - 1);(res >= 0);res--) { long min = (1 + (3 * dp[((N - 1) - res)]));  long max = (min + dp[(N - 1)]);  long cansplit = ((total - (2 * length)) + 1); max += (dp[res] * cansplit); if ( ((min <= K) && (K <= max))) {sb.append((("YES " + res) + "\n")); continue matcha;} length <<= 1; total *= 4; }sb.append("NO\n"); }}System.out.print(sb); } }
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; }
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(); } }
2	public class Main{ static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ long n = in.nextLong();  long s = in.nextLong(); if ( (diff(n) < s)) {System.out.println(0); out.close(); return ;} long lo = 1;  long hi = n; while((lo < hi)){ long mid = (lo + ((hi - lo) / 2)); if ( (diff(mid) >= s)) hi = mid; else lo = (mid + 1); }System.out.println(((n - lo) + 1)); out.close(); } static long diff( long n){ char[] ca = (n + "");  int sum = 0; for ( char c :ca) sum += (c - '0'); return (n - sum);} } 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 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 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));} }
2	public class A{ void solve(){ long k = readLong();  long x = 9;  long y = 1; while((k > (x * y))){k -= (x * y); x *= 10; y++; } long w = ((k / y) + (((k % y) == 0)?0:1));  long e = ((((k % y) - (1 % y)) + y) % y);  long num = (((x / 9) + w) - 1);  String s = Long.toString(num); out.print((s.charAt((int)e) - '0')); } public static void main( String[] args){ new A().run(); } void run(){ init(); solve(); out.close(); } BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init(){ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } String readLine(){ try{return in.readLine(); }catch (Exception ex){ throw (new RuntimeException(ex));} } String readString(){ while(!tok.hasMoreTokens()){ String nextLine = readLine(); if ( (nextLine == null)) return null; tok = new StringTokenizer(nextLine); }return tok.nextToken();} long readLong(){ return Long.parseLong(readString());} }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  String[] splitted = reader.readLine().split(" ");  int n = Integer.parseInt(splitted[0]);  int m = Integer.parseInt(splitted[1]);  int k = Integer.parseInt(splitted[2]);  PriorityQueue<Integer> queue = new PriorityQueue<Integer>(1000,Collections.reverseOrder()); splitted = reader.readLine().split(" "); for ( int ii = 0;(ii < splitted.length);ii++) {queue.add(Integer.parseInt(splitted[ii])); } int counter = 0;  int spot = k; while(((spot < m) && !queue.isEmpty())){spot = ((spot + queue.poll()) - 1); counter++; }if ( (spot < m)) {System.out.println("-1"); } else {System.out.println(counter); }} }
6	public class A{ static MyScanner sc ; static PrintWriter pw ; public static void main( String[] args)throws Throwable { sc = new MyScanner(); pw = new PrintWriter(System.out); n = sc.nextInt(); int m = sc.nextInt();  int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) a[i][j] = sc.nextInt(); val = new int[n][n]; for ( int i = 0;(i < n);i++) Arrays.fill(val[i],Integer.MAX_VALUE); for ( int i = 0;(i < n);i++) for ( int j = i;(j < n);j++) {for ( int k = 0;(k < m);k++) val[i][j] = val[j][i] = Math.min(val[i][j],Math.abs((a[i][k] - a[j][k]))); }val2 = new int[n][n]; for ( int i = 0;(i < n);i++) Arrays.fill(val2[i],Integer.MAX_VALUE); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < (m - 1));k++) val2[i][j] = Math.min(val2[i][j],Math.abs((a[i][k] - a[j][(k + 1)]))); }mem = new Integer[n][n][(1 << n)]; int ans = 0; for ( int i = 0;(i < n);i++) {ans = Math.max(ans,dp(i,i,(1 << i))); }if ( (n == 1)) pw.println(val2[0][0]); else pw.println(ans); pw.flush(); pw.close(); } static int n ; static int[][] val ,val2 ; static Integer[][][] mem ; static int dp( int st, int lst, int msk){ int bits = Integer.bitCount(msk); if ( (mem[st][lst][msk] != null)) return mem[st][lst][msk]; int ans = 0; for ( int i = 0;(i < n);i++) if ( ((msk & (1 << i)) == 0)) { int newMsk = (msk | (1 << i)); if ( (bits < (n - 1))) ans = Math.max(ans,Math.min(val[lst][i],dp(st,i,newMsk))); else ans = Math.max(ans,Math.min(val[lst][i],val2[i][st])); } return mem[st][lst][msk] = ans;} 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());} } }
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)); } }
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());} } }
2	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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ int n ; int sepX ; int sepY ; int x1 ; int y1 ; int x2 ; int y2 ; FastScanner in ; PrintWriter out ; public void solve( int testNumber, FastScanner in, PrintWriter out){ this.in = in; this.out = out; n = in.nextInt(); int x11 ,x12 ,y11 ,y12 ;  int x21 ,x22 ,y21 ,y22 ; findSeparatingX(); findSeparatingY(); if ( (sepX >= 0)) {locate(0,0,sepX,n); x11 = x1; y11 = y1; x12 = x2; y12 = y2; locate(sepX,0,n,n); x21 = x1; y21 = y1; x22 = x2; y22 = y2; } else {locate(0,0,n,sepY); x11 = x1; y11 = y1; x12 = x2; y12 = y2; locate(0,sepY,n,n); x21 = x1; y21 = y1; x22 = x2; y22 = y2; }++x11; ++x21; ++y11; ++y21; out.println(((((((((((((((("! " + x11) + " ") + y11) + " ") + x12) + " ") + y12) + " ") + +x21) + " ") + y21) + " ") + x22) + " ") + y22)); out.flush(); } void locate( int x1, int y1, int x2, int y2){ for ( int step = 15;(step >= 0);step--) { int h = (1 << step); if ( (query((x1 + h),y1,x2,y2) > 0)) {x1 += h; } if ( (query(x1,y1,(x2 - h),y2) > 0)) {x2 -= h; } if ( (query(x1,(y1 + h),x2,y2) > 0)) {y1 += h; } if ( (query(x1,y1,x2,(y2 - h)) > 0)) {y2 -= h; } }this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } private void findSeparatingX(){ int l = 0;  int r = n; while(((r - l) > 1)){ int m = ((l + r) / 2); if ( (query(0,0,m,n) == 0)) {l = m; } else {r = m; }}sepX = -1; if ( ((query(0,0,r,n) == 1) && (query(r,0,n,n) == 1))) {sepX = r; } } private void findSeparatingY(){ int l = 0;  int r = n; while(((r - l) > 1)){ int m = ((l + r) / 2); if ( (query(0,0,n,m) == 0)) {l = m; } else {r = m; }}sepY = -1; if ( ((query(0,0,n,r) == 1) && (query(0,r,n,n) == 1))) {sepY = r; } } int query( int x1, int y1, int x2, int y2){ if ( ((x1 >= x2) || (y1 >= y2))) {return 0;} ++x1; ++y1; out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); out.flush(); return in.nextInt();} } 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{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }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){ Scanner s = new Scanner(System.in); while(s.hasNext()){ int n = s.nextInt();  int[] a = new int[n];  int odd = 0;  int even = 0;  int po = -1;  int ev = -1; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); if ( ((a[i] % 2) == 0)) {even++; ev = (i + 1); } else {odd++; po = (i + 1); }}if ( (odd == 1)) {System.out.println(po); } else {System.out.println(ev); }}} }
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());} }
4	public class Main{ static final long MOD = 1000000007L; static final int INF = 1000000005; static final int NINF = -1000000005; static FastScanner sc ; static PrintWriter pw ; static final int[][] dirs = {{-1,0},{1,0},{0,-1},{0,1}}; public static void main( String[] args){ sc = new FastScanner(); pw = new PrintWriter(System.out); int Q = sc.ni(); for ( int q = 0;(q < Q);q++) { int N = sc.ni();  int[] nums = sc.intArray(N,0); pw.println(1); ArrayDeque<Integer> ad = new ArrayDeque<Integer>(); ad.push(1); for ( int i = 1;(i < N);i++) {if ( (nums[i] == 1)) {ad.push(1); } else {while(!ad.isEmpty()){ int d = ad.pop(); if ( (d == (nums[i] - 1))) {ad.push(nums[i]); break;} }}printAD(ad); }}pw.close(); } public static void printAD( ArrayDeque<Integer> v){ Object[] arr = v.toArray(); for ( int i = (arr.length - 1);(i >= 0);i--) {pw.print(arr[i]); if ( (i > 0)) pw.print("."); }pw.println(); } public static void sort( int[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( long[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( int[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<int[]>(){}); } public static void sort( long[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<long[]>(){}); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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 mod){ int[] ret = new int[N]; for ( int i = 0;(i < N);i++) ret[i] = (ni() + mod); return ret;} long nl(){ return Long.parseLong(next());} } }
4	public class Etruco2{ static String[] vals = {"%S3L{PYzV1%SGI'>$/4Gam=^#ODu|`Q!Bys%Mw|?fA*0ti{r69RB1N`{B>YC;.:XEmm3t-i^N","#Y73mVxQ&J`inFO4.v<j?yg{4~O=p=t$'#UHQizDnbsn,+JyuS~@WKw0p*Gy%V:#sa5,L|9RX{","f0J*n]5ZaRg:d-;{f!Y47]i_'u'cTz*=K$b#=}w[U]3*f+$|4ePs'K?]p8~0loSL$h_+T^{+ik","@r),FzP0XP>vU2<s9GIJ;0K0e)b_Hwyaw2}n0-%|lUlV(kWB<nx7@M[30yXxR(n:5@CEc[~,B^o","0<2C[Fz1*3iganAet-6RW8/X&nnSUf`Tu5-$~<5}F~$e_n5j9jD^Kk)_Xh=)WG@{4:XC;V4a|X]*","(_gw]4[ktYOZ},E?GXG5h{UF<Fx1O$0YNdA0+5)7#j%f)=Ui|3p^tt:SV(N^mbR9.+!s4fy<.?WQ.","%-i=_PJtuHA63yU,f)Gh@#Z*;FIWjaXwKS*bq=EOMA9yc>OD+}xg{z`X.~atEmXp9Z~*u]I3_7IxDZ","#N,-ehU0na1kWpn=P9ZK{TRs/&@KgxaK4h+V/ea!9Y3QYy9ZL}n&pn>G+'I+]ekWM$(g'8ym$Mj+,?V","coyL[=Xb>wzL0z?{kW5GQjeWPCy6YU<B/?paWq?^7__LMh<{ZJ+8!o7I.=<2b)j-)f!Cwk7!Ojrs[Zs","A+If^46|x9Wfiv3OlqZAUE[u(p2nLL/x$!LmSrR4Do9+4oYG:0P-!#>g9'|axl=i;q`E:ja?MDOB<Gyk","1$8eKLgE'nM]8^vi,NCMzBN{a<@{.}Yibo/OLo*`;G%v}'Lh~oGudWag6ECf{cpc<%]2ciRk*]k|/>y?V",")>A7nmMgLYs=3#7`G%X{Kr~U%||frj>qN)}H^GawXTT}/=bFAGD+u1?YNT_2Ht~w[m8?LLh=YBS!6(nYD:","%W;~8W^>]K2kwP_JIVOGo.l5<Z0zR51sXzT'sS)-@WFA6I1Q*{$SR0UT1x}[!]|^JT.N>;yA`kfH`f>E.`6","#iCwqRtf[6J>97)oD,nb>z+}nIJ=?2h40Mhp=)E'Bm|<?v1e<H68>yG'sA0#eN>Ft4N<Qt}eXeLHI|A7BmOV","sYg3/'{oSnr!c#bd??s'UM==k<CN-|!,}c8Vb[&?tR}]?N38+U-w=$yYb_3?k*RDR1=.q]xSz2Lz(&53-xGF","J<2wR!6o@K;#ftMP&,Gl;<VmX#2TNi]l_ZP]1Y$,bqcrIl_2KlqcXh46&fB&5{h/+[~5lLK8C*Ypm$UxRW4-N","6:X}!AJ[uGdSD@Bbe7#$g]u{ByvOp[nkDIG*Ln1@d:`OnhYjr#c]4qa4>hatq4l_EoFb}6FtSOQfu3j$>o$98J",",:=#^-<(+n*e[l7/{uM<_x)#7GNxXsA*v@5~9+*;=l%XX[65ms-a3rQE({l3Y#L'>1[lHW*9/;8w^x96dK8d|H*","'7C8`Ku%e]3X@+oX0(O/)~Up%;eaEA_q0kVkr>BtTCV{$~:ff]['Oy4lW[F&#5Epcri#A$q7qk3x(I[)Iu`+qjc2","$a|sCP(`q)r!w>3jHD7~;@Y%U_BTgu%!<]/Qs}siNKUHJ`^mEFMI!6<o.la&tEkP%V^q#RZb2S4,izBiS_l.Yh2y{","#ESSy)K!I_r#D'5qJ)s]SnZ8c:~PE4*;#A$[AeE9A8,{2._6YY;=~iOJ=33d8Hw)5vXp%g=WqVl+yy,VmtM,2ao4=N","e<)oJ1mnPoS!A$'Y}`AZVCZUQ0Ky)'^jQZB{eVCW~xb4f_*_Lo$>.Cj_X+%~h2UsWSQbRj4XoL'#yW?IGXbd[!3U|6","D`L&4'8NHO(dVv{+<uYwH5t#c?4YOB.5@z%:p>`HG#]pe,!!F.~|CZ$Qh]<J%_ON:6GMr|5b<w~)?1]6H%QT:hfMYAN","48eMirgOAMc0``u#]nz{aP5u:cM>>5B%J|+w}8}(y_Uv_VFq]rCYB1wpD[{U}={#=S+SJQmQ@~1zY~idvR]4rKz#L3L{","+`-#D+O:7z=[7GBB)R=eQ:5OZa'bc_[D+NFe=P3cdM3QKJVv*?x;RlNZixw?{qd#@8D>CoZzsJEqnGL!Xd3RoZ,qBv!4k","'/q7_eOF].wH,o}YDkMDO^#+TvDqr*Q4.~%*h6DH=0TCpE*m3T++kJK(JQlIwA~+r/c{N0,QD;1DDX(<OZivC3Y>J5Uyfo","$i+*e>tWyzs,GKQ>IP/+re2YX[.uY[jzUE$$o3KmUIDxlxy}ZdhF(wBOTip8DjA,cwHU&:qHwKta#[,SJ#oYa$BjEd<Fe]*","#O*r,8u<Bz3Vs&Jdq1d2AIxB3}skyib'GPee/r0tw^7AaxMJUncL$:O-C?#`!j:sw!s3rlz:mtk$|rN{Ma`!jezRkTgI>n9.","mH`mtJAcH6.~?en.+&TlY/[Wye#N<]Ei$ErRJJpnprYU1]lK{)rXjST-bu[KYUZw'1f<lYS({<1+Sz,T3~sB/);u$eO=PMmZ","J^-Oc/l}!vGny~6jX-@G>;ot_||1)VA<AH4Sx'fRx?%:^tq-#+,99k0LY~S4u^>Wn>(ai?;7'C|f=5-*X%G<R6i7r}gr#nq/V","8@>trXHR!F2,jQ<C4lqC5wlS)}t8@+,Ha]YnP1ACVvyJrDz[t6T9?n69yZk#&+p6;&kLk#Bwb:cA-|TKzXq0Tk{J3gTt*!(rRs",".AGXO=~svf*-P1ad/!n]Jc^EPtwzaC!6kKUUz*0TTW%qkFX`bO=/pH.QU!A|C,r-03O/_/@l*bKJZqO3HW7M*i;?h8;Fg`cS0Lk","(r9y<CJ.RO,zE$/)g%8/Lrp?VQ4+-wr4D?5IpIWtzbNqQG3UL!/L,#N:h7RJYVAXK,6LT2ZSx,J5mEDS5Es&}Y3aSMh`hLeO0/[V","%p%8Rcx~SIuxqTE=n?~W?J-$36syElGT#mdT~oi7bRh,X5Y;'iSv]VQ#R^os:M~B:daTv/#{|,.3mo/.xKESf^3FtfI#95yn9{;}:","$0XUj],Dq.GU.t].u7/,H2CQ_`#=tV?sV'q%#/Nx9E)Qgalh]t(Dx}f0FNT(VW;V2pK7!P?Ov]j1kz])U-l%SjP<Q}C?}eW6t:c?t6","#6CSvs;f%`_m<op_8dmjpm3wze?_~SUiAOHD@CEXM,vU}i+|V7zk{uw_uyynMDL>0b[9)}Wk-bC.J<SyR+?(zHXd9c{Bx]bA/uDrK|V","byn4b~4K[/q[ZNRj){-dXsS~xlky#0,DdUaO<t5JD;33h1B+<17-{#m)LY:8$(y3!HwqUuygn-[x(k%Hmis9T|E;b{P5iXxw}u&MD[F","FX|Q06PFPwj.#(LJ=`zx[*J2H?3~7vR:nL9)%!n|)x#KbXFkh{G'zb|#}0F.fZO}aV)7OGtt!^9}KBe[$N)d2@ZnYZnNx@s%W[DQr79N","7(&-S]Jg#y1n-{jgr%y57TT`Fsppqgs|2Pk7Enqw^[4N%~:{vlU1[z%,!_-RPASA8~$rq$jMG6,V[(+wGiX(A|2AT)M8Tx%X>}3,+kQyJ",".3rtg&n9N_e.5[77e*ftW;C1O;U%Qf,}8>.0q~hd!{IHpG~(.O9NdCq`VeKx@H$9(&zgo[{KSq5J-@/$Tq<7eV;6(WMbEkOq[!`nPBB/(*",")+(4Xy##P^T-5H~m|Xp'{=+G_`7;s9u.SvcNw_xaI'&R)m;`$(8PX8xZ>*@2>xfJR<g]PeA8fk.,H+WoxSrJ$dMqs2nc)4x(T3jeQ<[^~c2","&0<|E2l(VeGZt+;mpfAe/w(fyb#U,)i>{Q`s11FEBLydh,'Jz<a,_Lhd7pFC2(Xz(.b5-Yz}::NV/`Mm$;iZR4=}!ph:3+awm>mf&'%6KkX{","$K$o}U#q@7(@BTdC.?bOK'KbtD4!bv49z}W=SX/2|G}.g1zn9-1wwY!CV<h2i!ve2ifU;Y}30mtC)Ks~JrllIN_L0q$lEiv3<^HS<d/U*RBvN","#K3b}I$Zz}:>?3e>H4B|fEdd7Qf+_&*J<!HxkBjF=1W-YO*sxeKKt'<Sq}|C>:?O(AFgaID%'M![`@F&S0Wh]o_{/Rm4{Iz9w=6+'FZ8+By0x6","r:W%R2Z}E)rayr$Gb]UCZFBVy-V7|mEr/3cur6A*;A~Lw2WYGd;@10.H>*.i;J=]6.(=~%JoHc1TBa2!6#[q&TdsqepNhlz#`{iO_</yT,QJ%N","QIe,.{^Zi@pR~m4z`j#7)UUIKL&j|2656o<u+o)Iun/cgnSDn(Er*CU'Ix'oMqVLf#Q3px=i^Xe5IX>p.(RylcT?u2b<@dxI7CalOz%bt;ZO$@{",">S=~&b_O'HOj#A_%6}b!f&:J%)M>5+u1SDSR32En077OL`F#VRFoVroWa59I002YC@?]1LY(jhoD4S*R;}<*,Sw2mT*7'f6B?'^c*e)#c-)arm]k","39yr+-}9xZ[IL`G-,~bcWQ$e<$~*!dZE#tMe[OZ-dpH$GXdT,qJ:NvaAi5+<VP3PGos<bgu7s>;%-k4a,=w0,6.WL08y1x)1F;]ITwV5UtL^m&_no",",O[]LZ531#KNR1W/Dp*p#xX:mf$]Dx{jXE=GW#C7$!mlZO80(W-nJBnpDzuq`'bh'ci>$23`M=wagB024KJB/zC$6GeoiF'_oeyMEh+eI0&8TjgT]*","(H?He]J)!SWDW1'$5mj#LMOQ`>A(<!JWh/sqBVqh5`3Sn=~Q2Xd60ga6X8rmbsFN6$8;*KT$wtn?BI/GgH`Y;G-C<b(y{`/'g5W_R8%N7g$U2'{}>~.","%yke'YZk3,v$aBhJ2v;^uu$ttS1Mop#,iA^_9]WHWvy7^Y,3_7^Qm{y~axM&s!e(Go'VS.4Bk9v[B:cFQ)O75HC5qY|:pH5lgyoRD.MTg3AcVQ~@A}8Z","$J-~[Tc.xDAf+=IC91X/q9f881;?NR;9mE/RDn*%Ik,y9??^&bxA)xr/F,Va_'6eNq4i`kUsKl!|B=I#$}Mhk86(3HU&0dt{GTVR[&Ud|y:'jK&p']h|V","#Q3OW&>Jm<pdtfR;qu!:ux&*t+u[Y%1Pt>!PSbJku'7'li(^>eL_l.Ykf$SSv:q-j95w@3v[iec>;CDP=eL]#~R9<pnl+=46=$c,aB|NCp,3z]V8Z2MtJs","ytm.~`FCg@m(=F@@U{J0VYStErIP?I-H-a6s$.$#K{3B:tEBJzy|FEaCF&`2HrZ(Y&37=(^}eE+_AQn:/*$%:+ML,g',1k~^dfBSUBskMeZ~x2(Q6>Pq}k","XQseb,o}gb]X/'2P%Q$%@Km16RjWt#91?0][T%}q==jMrJGCPP6y?{!OJ:AQ_2dfnHE*Ys+8aS(+D`s&'@A*)E<hlY>v{N@GM!U$jyRr%Q';X^;@gJ#2&xV","DELtxBvP@0IqcRU%L-`xQ4no:.|f,NTu1xr`wDGEIVm-q@,G8|1Wst3v)9Dxdc77a1mM6&PgJKY9B~rMVkIoWIG'N>Mrl9YNg)o3)P}mUt^)8-cb$xI_;oX:","7lAu)]H&x-r)=mE]6P2B&Ifm(9F9!zNjJd&TN,b}mE;BPwb/*Im&&^pdI%@,U&8ZA24^Us]WYEc[dS[<87^^~/+Nm;?jMe|TU[mP#N,_D}h%-CQxL86/HF-+6","/t_'OVLqoVtJlGd%mSg;o^7S(~wf9+>I'INo<[BqyTn]v<PaeLj~eQ~}~X32b7ZTcAMzHu)6jtT2H?@M95(C1:?aNhYMKC(kvP=Z^~+6P@|viR#utIW/iI!3KV","*u-akgNqo>b6tkqN5DJSt9NoLl<?DE>+T4N-|<(&kFCv$Q%-fo9dC*4U!gnv<w,Xc4bXAhBV|Jm,Z]J0pMlXBy=*nbA_Pjbr#O;$%dfzGRd}KeJQo/RZNogHMpF","'eP7fDQH-H#!j|h>)IoEF6-WZC]lIVJ/@|?/s9&sqd)p^~ugx~zDDH`&P7ch~iZ-jKp5aGQo-v1@I0ugW3LsiA%U:CP`UP@jc>*E30?~zglP0lXb@p(<c$ePRwEN","%cQ]O`I?Z^[TbsO6:jNKN`y7o[~KhRv~iu=cY;NVxR*ZQxNrIpfSqw7K{#{{4dOtIsKF-':@tqyVW[{x9t4U}[e1-0XXTABM^.J,{Tc{(wr3Uj@+O7`rznkDp>s]J","$G?d*@BxvQ>{2NdbzHeR[LIa-7Q`Puj(Ht)5f+GP7]1AoL[>IIW(>*_Z2`H2Pq:pj2JQ^t|tr|;d5:JS/cG37|x(tV~iHgDQN-3-tyAc{hf#kdsD=lbd`v{64$E2e*","#VUQemGH]0leFuV^:<V`hp?J7x?aenY:C^^R:27~{+4jYd+A4{txe>S*/pWVcA~Kjo<HDh=.Mqo`PR,/t1yx&5px3636chFvn1$PAdbtca1B=7:64O5`)Y9`q)hc1c2","#$t@73::fTYCj%S]lKo/sIlI=zunsA#8Y5]YEEo6-Bq_u>F-NdUoPs-L'uH@/u++l[,a&e`PX|1u<TjyASURuXJFL'wxzLw<BTzE>*_JmA@$LcB,j:g<d3y`0R*r'!8{","aWSp_j@Tzm%?v;)3UoRbqZr;p?D:^wBRjKN@S;`AB|b,1B;(HORok;Tc1W!0qAF%Uq3f@,!+zaG*?GaT*'k@QN3K|S.N$s?<Uw-J+ukf~H#FgGFU`RNx`ZWq(,9=kQQN","KMrVDEkM16AuyoI;P*ZJBrv;!,rR/iDn7LxrWtsMh|I.#'x1]/]02wG2I^X3$WOMk0A?DkDk7Ta$FXEt]!hm&UK-RLlB$xpxW][P7=wuoM(e^M]ZerZ<Ey}eoNjw9pdt6","=[3C~w/f.74V:6:vze7B-.zl4Mw#~{HFD?;@hicn$B@AU'>e|01JEdcS^bZS,M}DH[=Fc9G5&r7czx%499'f&s9uf4X*%Ei1`=&gz`MEBv6TchYh=G:{7^+(K3V-`*r:fN","4NI+1'KkL4u,#{IDd(8p+|$@Q>sGQ;'T[>:skE#M4G7B^kOGP&~L5W)`DhVup.E!M46H{gMN+]THBE/1&.j>)x_a[0S:Cov+^]u&Sz/44.dqrhwnJlxxpLge!w{3%Ha!%4{",".I9PeehvXspF[F$??y]9*V0Da/~9kfR-%sg_NA#]Xxk~gJ(2JFVOd(F:H)G,LTuD]nY7weQX%'`M]sn{Q1abJ,J_KV{w?/.!I6SBb3I==k(pzLJ(0o$Ih35I)JJh(jdwLS(k","*F=.dZ6XliY}&(4]/>7en<4)&}1)Yk2%tdSgZOi7M`g|D-eWdts32qTEnwEciT[1[mixh814UhZVbCc/eyiMlf<P:`hMxf~`wP><%l*pFpj3A,Uz{}zR]9/pWZq_'|{+lsPvo","'c0|-O$kHD9._=4.EXU3rQN?)jM!C$%])y?0&TQLnGChYe1n(txC1vYA2L'z2Fx(#p2ONeuWeUR]N?uoLNKG_kk7DA:<v9Y#4[|a]h?eXDk1#TTWnDq+EI8WfPdGsF+woh+(]*","%tHm:f~UE8a({i;ikm_%*IZyoVGIlQl6)E'S|E7,mO|Sy|g~&sXWSc3^atX-c_@2,g?h9w%Xax21gl4m}3k?ZXn;JVDh'H6A~D[Oc}S0wcI9X[xxR!IVyA/+CX;rwO/Q<F2m(f.","$_r)|9(3McJ-d$423`!PiVacGmd-|wL|2TRIOvq&4>j$6PM!{pWp530Vk/pj9K#-J+MUCyGf%s|*:`fL)XzifrJ6A!Lur(>mBOhH_yW0A0WW'gC|iX;s]hv9u[{hfLp]9S|PoJaZ","#oR;uMX=U1vgn%6nTONc7HP;wsY5|sj'm>zI|ff>V&U@ZW(S)S^%~51fbNUoSCQCMm73(MwEA{>5&,!L[:i%HT6Yjoac;Dx%K<=2{K`)xm/0:9:p9$]FeZ,M2^0bE|B'>3JX5hplV","#:R)W$kuhEe3d_wB{!Y9%-/nZF$yNyk]o71|Uk1(2`Qfm8>g6Y7Wfzz0)-G8Vh%tqC$#mvyeE]-kr/W]ugLvm-y&HUtC^&71L+JG!!Z>U,}5qllO4?9`qnvKB+JHaCS!16I}8k5bBs","sy38-RZ3/aMN`V6#v#QS]a5vnCRk%SMYn)8W!]gau]4egu3aCsW2T0c`J;`o<|v<<VC8`@!SIi,x'4lTcdbh?$-=-2EBPl2hcU>{+:m{Z%mFZbNyC'ePuR(@lE2DLSXeSTeSaa^QPk","ZMhWciybNhr1kRtD|1_b<8Ax6tqq84EVb)wS%t-W^~psSX.G,jCrYO7wj~DwYFZAqLeR(53?h+g`INo7Gm$lCWz,209vpKRHUK:i/FY_aOWDl.gt3|wCSl5XWO0Fvh1o#?TvCp`4_7V","IWy*`0ug(-b!Hu}e4v-W+y358)Kvnq#M_E)o3P=w{,-ta^8NI7sALy>QPAq>r!<3xS#it4'Zi(.eo_~UqS)z=}FKPQ9{d.~P^K*~K`fb<FlZo_<F8Vs<iA.&q=e_I,lq&DP_1iSco94:","=s@WG606c{xgI~7*0!PO~*Opu4^+m>eGcD_^'/tf_Jr%QCIH>WOKnaw`pXz&xMbI(=+b,nt+qJr*+-TjK`Z,sURM]TL>d|[H[#(G`zF,:okg}c^(&aI0N%Z.`Sg!OI(X'kgH&K4MhLR?6","5dc/|C@JoStGxr~,2i;p@;M.cezli},k%lPJ^o_A)^e}+p*e{(3k^*[[ZrGU]JU^Ag?ReXF_@$=6rUGrP#qR[q0^,Gp5$9IqT&n29ic`r?==r@^whM:ipsm2%[=s`A)^+K/Z4i0Z[Kj!xV","0!RU141:2FQ7b-=QkN5lDbJJQq|S.[?N*0)h6S(/MqbBopgx,%e[!,YDzlC&{HLU',BFiP:8*!Q~qb8T!Gm[]Lt}f}Mru&:w5-16h#kvG.s|N.H)'&hYW)Zr%ZSypdd;.?S[ewN7CUJ|7'F","+~Oy!c<ye{%@^P`HAFbH?yd.U_QPeZ-Un=#L>wU_PlYHx4I-O4aTY.z%cbL~#g3Wfxkx2.,J(d({fC&|~>Gqdnk+G{XFMIQY1Z1XAZ,qASVDt9j/zS7L~6F/jkb_QL<}3oQEI|!1s3,+]9QN",")1'xJf[WHGn}?ovZ(M[s;tx[3Gk$rRWA4bx+Yw]Xr>?n9.mssuU^/bwCos?]N?v9,@xow'95f>y9=t!V,S(G<3Gnq7BYHJ);&[R33!;lE+cPcR%jurr*LJi]m4av[qqKQjA|}#g,|MyfNA?@J","'0MeY|zpcPO]+C}p[ScFIWpJ}'laL>}CR9LuWPtFfm;<bxFzP-K`h&HVtJ5M1wJgox/ehMdTdhv^gye}4A4_}vr6W7V?N&/C}duZI'Xz`HnaK=b.SfNWd'k/nYwtX-4`p(*BNE4`_K@)bbz*D*","%f)ZWb4.HR#3AQ!}3/aNEJweg0ZI~D$6B}q1S6pL7RMc[?wc}Ks:=%PCcQVVlwXTW4/,6@DP?uX-y`DM0]F|)#Npx$HY2@@A@b~_ExX,8HiX=@,Ykg9aU`K~R>hg,+[}h>O(6r!!l2<HdY:Y=c2","$d0Q?B+wWpn8pVU}Un4f[-JzQN?zhJtzI^V[%X#7>EIJ4C6#nb:.:Go2=j+UH[$r=~|Mq#x8c%Sz;Fg&E$`FwHdbnSUp1:IjEIGv[v1Mw+lg<aIzH@atHjwT=qI39mm*+!djVLZR?9{i9t7D@nu{","#|f?>D1?`|Df:<~jRYwxGXRF|~}O=^(.6)(Ge'@U,83J^xFhoN&6(.O3710XFRLB_o7`g7!7?#UYi>Tl292a9-R:U&jIJ[cI%.F7'D;Q)|XV/]J~X&!vZ$}%T[_pPCBXu;'*BmD&t0:DB_Fd@!a-N","#K-M@%$Z`Cb@'K>+z~C&~+]I;Y<~,DV)#k#pvMluvyl1Uq#E|(zgPb$_NaB8*.z^,uf~6goZrJdB9ZT5SvTG~SL#MJ^BV:Ua;(mf=!5/N4]-T:|O5-eqUKP5@([-QHtM/_M(_,+}jzwE,d8<xvc6p6","#'y8SS*f5SdrItW5ZAgEzM|htCuqTLG`5S?LGyJfQ0Ez6^dkIm?<AN.13h%{}::'N731(S=2q/TOC2C?1U#g!IFIvE|F'<Q'FnvH2FTcmoBZZLlWWQG~y>/>S{:@;Rbp>b9ejm8?1-{DoJL8@Yt-+IN","kC$'rcIg|P!GdR(kY2w_W*A*K9F[M]vO3&t=}I%mf08|r|@{<5]fy2xRwQJVe+*b}L0:AWdvVtR?Vi}AifSK%7b<,|n_sQXFAu_A6b:/.''?D@V#BkMM,@N&;ODqLq1XP?I}'J{T[r`D3'pezl7^6({","Wb?|O-W}`m2#~)URv`a&j4~npK{Beqg]+!g*`pL!XCV_IDa&IxAoB&LQt;]#>wwen?HS)%rSJbR'GJ!&Hvp;G-b8,n'izx__|1a+pU@+k`~/rzMI'SoURS[:`_ezt!mm)$]]34F4!!KkfdMIC]/F=1Pk","J!CDyVG#XcOnkE;-c<RE'[%&,M!m${C='`!Y$R1Q[hA%D/34uyM<X#QRV3W=<]p_+y9N`(<EH:*hQnj58gQ|R31b`^,w]?a_Gq=q'_wmDx2EuNX1UhQX`}OG+JP~+$pmqM+G1MN{rq}6T=_1Qe3q$AN~o","?xq)>v8vOf@l`9oGm*)uWG05rKQyNqQji/a`1acf4AL?hJ*q?]v97!~5?^.XsI0m:oD770_IUuMe/{iXVLl#S#X_H+:<PB@&Qx(B,-{)>QY*9xY{Is2hS)!lcjsc.l?$l?/h78KuW}8'H!8|b`r#5wT<]*","8O6O6|`gzc7![)&miUYasq@:fY,}e+MC#o~~.[gf0aU5P/Wq`(m6L-Kz|N5D(:dinev11:TF'c5FHAS!m!QKwo4$i`4%u]bj`6>^$jw*v%#2*QBKI$bk*W?|^_m*enz|wsoOi%j>?&PB(Tk.!UP@^bL:*M.","2|<^@&/r.y`4N%ph?-'xXSf`-k>fnliC80KQO44BS~<xS^5s(8a$U2`c@o23mR(948HI6_Y:CrpIy4-{o)5Ux}V~rmNjvEf~ymKd`@t!{j$-*z&n[yIjQO]qD$U0'lZ2W3%sLMMrT-KLlk+&yE7_F~;|nr,Z",".qxph,NAEG,gz7x#,gR8y}^?vd{'1pzmJ]^nC@vss,h!e'de6B3t4vY)^42jSD}ey.N|Gb,Y-f]jEfyCOE)Q/m.Y22WOp;H~YQ|<JfZ),%MT56&jdAI#72K?+9=.Yn|x/U0YtPoOfY=tcA5fYkfkMgY_#G+[V","+j|Fu,mnMb[[_I7{AP%`L!@GB->vOZFa{3PT{+&nZ;{Gd`CqZr?hW1%ZR3WqcpBQ2ayi}RE+>:&pLP5:rp]Qt+eZN[)tNwG.tAIztFPvVz]K~$@UB.o,6[iXpmKX2#)[+}0>:=H.al{0h1nA&|3w,4z#[PH;:s",")MQ6zmK`vZeC{H2Istj')PMbKVYeF<eM.o),T6DO<!&Rk=vGIuPYCTMY>czUhIjh?C;tiQugSI6|r's}rGh{H/(Y'a!a%9lU.n_:}Vf6ro}[;X0XOXrsl__lP1?lMroE|xEG0I:~UmEK+Q?vqsvKro7FpQdE.$k","'fC;a;Ted#3(|RP[*S{K^RtLZeavB#xHv<|{RQpa|/%b|_tY?>Q;UtC4,4hO,u9gZ+@sd83Odl[=em=7-^H%*HCE<eat.]&wmMbV{)y@-9<%[Xm-8Z=Hy2|2<x57P,/;o8hZZH;m4pmO$M!1M~4?.xfK]DP#'zSV","&H16w,mmofX[4yXDF.}Na@CH@^jFf,K}>M#OV>+R%0dS1M|`Q<yqyun1|8?Sr#xBau(!bR)MKQ,P>>xKRCI/Bxl2H4P#y0gD+}R:r+UeI$|[s6lHJ5>;oA~_=IX*#/U_t5tC?}%vd&R#g_fOENC_d{8:B?%AX^Sm:","%H*Hw<Ia]{(CEN=TN%QfM?0^,L2@,wOG*82YV=;@_iZ?p]DnnO_l>fa*}/3^h?G.XH+d'Q<z4@6{x`Y={B=H?e-OthzW$!&UZI{2Un[sW'Iz*X^Eg`F=3YU%T9SIc8D-jiCOnjd]49t6)CI{/*i;W[@`:s(}ydvSS6","$^s.%XfK,2Us*n]WU'k9Y>9Ti?20]8RxV2EX'=SXH:,X@;e|.Sb;.7R7wCrll+HHJ|O>jw:!P5[i?v'w~{:MycsG{*[}8JgOsqC%SL0t[HM}i41=Jf}')SGy@tfqofVg:6&Q|w,#b&/H'/.gM3>HqO:Aqi&$W|U1wGV","$(,3<E-seNZ&V1R_W=Spc4Br?Rg4?~dFw$an{FvyZMra{{gqA9+.X|vAGE<<L##Eo!CMQ~!e?e,,h3=K?<wT)|e+z:%2.k@VLav8M|,N@)/ROo']/KQ1P:X|H%Po<NFFj-+%U729dyXh,-~=2~fTYI3|AB~u_PcH-];F","#Zl-GtX['ct@ch9KkiOLP]77.6VNelm_SNNJdW.dFGXRP%<TwO#K98r$NfUG*#-L({8o%>XZF}J|D?E0DEL@v83NC.L!wex96!O|5QQ_*e7RG=j-Sj'o>2*{HV<)GOwH487evAZNk=r-T1y.=m,&Vi.(knw@I$;T,58^N","#:wmn8J6`[w<COAVr/!`3[G5V}yy;>2<UfHofYl%Uhh;t&1M<H$Y7q(hJNy68M=yQESKE)T19)Z;oRk9WWNe4{]G1J<_oCXnTy`%GEly&XLiN[K`H<r^Z:9s>Bei|x({E(Aoo5T{_BYg%2Edli_86seC(U~'B+>1]FYq$J","#!8/U;c]1nFCeP9%:a!g0~F%q3lXy#KH[k@uUwmEAGJt,wmWt8L{MMQ7Sr6'S!+L<z=tFrp^:'(^49)2fXPqLWd#<tHob8o^:|o9i]HcFT^;,8tDi#ES>'='m~au8*d?Dsmn>#WSWrgYm<5~x:g=(!gS%3/{L<~EgF!1s$*","l'7.(t`M4Y7Tk7XzHdB&z`(SJ>m?-f(bJ3{6uUJbV4+;qxH#UAT^aB|4zph0r(2z52!]Vrcx*h3!Z_<rw@bUdg6]B?6M;XK2-I4#_H$8s0Gjo@2GGER/F7/o9]Y?]rb@50|~5UVv_o(y9GjTwNs]nvw4wFBw0,{Gz7N|Ec2","]*=2VfKD12h27;a()?>O9fOx5@[2,TyP$:Xbhxtx]9}xp,-;&yi/Fo|0eMDY-50VUl)QoLe9=N0ed/1!<Q>Qoa5yto%M@Z,HIoStM+YJw;?vva-.}tFowDB#Wr/t14u4'nx%h6b1]XMVEMJEamjX;v=/<Km3>$S~N[5h)9T{","PD(W!DH&6nUOB'l@y{vk3w^|[rZt.RGB+rS=m~CrP[XY#LewEHqr{I.3km60z=fFEG31N:tlvhC(A4gEa;.*grU~zK6AuPX31.+0r*;[a[19~H/h~PN8Gt1hlA=iy$7fJ.N`bKWSCL{v&BJ#f8?t`zjg<V(wRRU>cbfWcVofN","G0^NuhwXa4w~)jZ[j*{E%YMCaa<&H.}X945dS|w^g;'GQc<-.a(E&5g/:ZEWy?abIifub!S|`!&]&AZs'ePT?t$6ZZCB`UI@|moZ75`Sg:_nG}k6A`&9<<^[>os<kF;0F4qe2!PA^}fqmcypQwv2)hC`D,*rEqHAm)uL_I;bl6","?u2[Z<@uQ{/!E3#STHVkA'RhMEn,'e@y}aWko'B&:3Mu?UVS-@V;Ink)`@yu]:~My@|Xiz7rP@fa.GW~DlD=gKzDxOH{6fATk-UFfFe=>_8Cqi:zL{MP#[HM'6ob$BW-(@;x[H`}jv@lWTdXKMdyZ}mK=|=U+*ePW0`AR0Kuy-N",":.{n;Au!==aW_~~/31:%|ap'pU+C9#>Hlf;h;HKs)1CYZnJ5ly_+@AM%,@N`|Eihs-c~{A~6|1,M1cU>*Ej`k:&.VOu;t)&e~~#MjS5,jIA;nB4^V*|T_F_z[-,A5}jP/_/i~Gc;*(fL8p%0U-A},qRIs*YKv>qa!y19MO~^(Vy{","5VN9jpHpDfSUTBca)i8|h}_bRyht0S'H!{CRO9.Sq[efz^ORXP8zS}x8~;];v@eD^HGNAle,7ZI`T1NU4Mg~{W(W-&M[<h|Q*[l1:/3!'g*aYkfa[REbi`==?-PzhwO:%'sXir$}=O}~Cs-vr5YyZ%qZCPzPPnFZ8h^fO~)wB|dyk","1x3Vt~rj21Twzr|,,=oz8EPC)V[~)lB|>thqaR,X?GC(h`u)I7K/BWtaGwt_!_vcA%!zerw[UCYgMvE,KBX<%m8unQG2aTCbOqNk[v%}%`]IH]@0n=4^G#}`jdM3|Y2+n|TLx=~d/y0fqc&n,OZS^]3Z,]%Q#hQoYNX|b)e~?PhY)o","/!t6rJh<$~fBmH<nWA'=$:;%E'e`;}v/jOSQ^b4YA*GEiGrK{~4fync%3;JCq+oDTJhIi|)u$TC>3!qC6a=d`ccOA,!aEI6XA~_W0%S4,2/KseIf>8eclVHN&a91=uADU2|N[-*E-xv+P@9xHT7&'w$DxgfW?nOJ,2NFOCcY@7s24]*",",`HDkC$U.~U'arpO^7jRs]noo(UES(0LwSUbf@#+JSp0sfGq{*b@i`n}Rc|9>Bu>_NU>#_DG)%QYR^a`od5Ur|x8lyt&]Wc}f{b5}c7:nQdLrV.Dqy|XUCZlrgL-g6uyCW8pg2DC[0qxk0B'!tA)s[y_?}xR`VGm$0pPcPn}g[Q>oD5.","*jji4DRB!hfp?ZuKi9k'ac`.p6,[NI[W#/?|N!'[kkltdB+{[9p^&~s7_[4^)[[|S.)s+Aou|O;yO&xEZD^)'U#A2F}V?iqsuurhiF.N!)7K!t@^-LGY_n2cxwvAT>q>>3go&'seAX~WI2)qxnX8n|}*:*Xb|)&mR<;RbxYd<}*fg47TZ",")9CRIedE3+m?Od0R1]irO:W=/#h7)Lh=~{KW0X0f^g9XrRAdlZ$z?Fc;x7j8Sd-2|g55F$;cXNhs/mw<s,TQDSeWsm33#3(R{,Ob8`2~@{k]$1Jwe-yT'`c&x3y(O-OmpGPhh^LrZS6j`?yx4~7T]vdtnje8zi{@=jd05}`Z>IkH'5kSKV","(#HoN7l>L4n=^ANA(IaRW.G[)a~Ba;X,w{e8v8clkID!fYH+5{|xDSS$uC6syF88!9+a9ih_egHrdO@.;1*{d8^F:zB-99jpxCc@:X8GEVd*'&05V`~33r%m+bT'lN`G[k|`QHd|TZtk4GW^DBSQ7e}K0muStmgPPmt`.n}-|KkY03@5^2s","'!^B^p',7STXpZVf!2wPNs!z53Tk_-^^pl8bur(,DSd-'NfF0GGO+'=a2*d#8-^Ja>&jO:J+tBeaIU&^5e^11z{f~{ytN6ul%t.p-3yu$VYB-tfY(/oPp9aH1j/L26}w{'{scAx]z8@zK7[E8yMBe(HyyAg!;ccXrY-_N'@a!(&L(Dnb/cTk","&2pjLw&NC{giV*juxwZWN_}/[*!%Ti?4@;z]A[]Dpj9h%~qj1_jYBnxTzo*(yHv`SJ^O]gr5jV{)(e2zqQZ%:t-CG+(Yh5K,%+!AAf:ME/x#fovahf5<|:Fw<oGcpve8n:[p[sThf_RUs&f:y}s&3wq/gD./o>3xtwx!+ir<@IB.*~}m6WypV","%Pd*8Gq8{;atxi@9$8q?&?f#T]yuZ@^,6'54subP_v/fw,i.Z0|wzZ0C>Kyi`Sc@w4kUsL^CAlKy-Jza<4?pk+XHykmfao.1jaLrNOiidfXW`_8'_xjQkzN1_rC`uJ/>xaq=>wTY7'HY4~2Z=_Cjmj$4EIKc4H:#w8[*CKrh]7C=.S`R;8jcH:","$zY+<nWAv5i;5blo,oAh0F/w[:=L@%K1XC1Op3Li<aDJFGJQWPb8Pd35kPWnJjUL<|hoHVruU)5ikGU6/s*|o1<E4Co{yhRn*>[C1+$fD0@A:1Xw^.m}j3NJ+3vw;Z.`WIKy!ZUBTS>k(y5qJnaw0X.)d*=oAk{B{qJw.+10!m$m&4Al=A1f0h6","$OHucOmzWj'k|Jum@9Mg64h49fO.<8K2<m;z`P';F50%ZrwSiHx2t1fS[/Vx'G~#]6GA%x`QVa6/'%boOHc2U+4kXCnB38j]ff&7PfpLTCa*EDDM[*)ry;]$,o~vrZz=bw}CYJE-~|}^ubb6O{~]k9dB5?uW^F&MIYW@lgQRYK*zVy(Ur}2n4vtV","$,PB8I?Ky'%q[q^yot]_Sjm8Wem9n=BQ&e2OXz#}<O)5gpTR7fucCdbZ[yh6a&xJkk~&=V;4!Ug,>sKDH|YQ((c@x=U6i@i<'U3B6.HtIftpsNF:xp<luo!!'9k94a}G=fV?[h$lWDCO,o$A_eWM=;n#/Xz?=4K<2:[4n0miA1kDTcF;`JNr~tbOF","#lOxX(0q*A!6x.j;!R'WxF3pC=Vx}q(RXzrm,&EyEr1C[a|l,QZKf|+OUBof`Viu]gl8VQn<AoNKCcc.k8N#rEuv.2_}on<_%s1=Co/<c>3t];!V{']M/*&jJRzd,?ZiD[x%.`[5>`SDpjK<WI?N}Mk)wf2=03N5q4'uc]xqVz/n~:L~GG#CjO=tjN","#S@AU=fe$SHn]yzn6gqIfj('27i23vxet%fC4Fy/8('5p.1'RED9mctIV'Tm]2H0BA'wCtJza8k>&&JC67wZtn$O`4HNixlu9xHK.(z:4u'8bq>f@NUXG-fktAC,m[8^t1E=@58C5%_n}I#S2-C0:]*!fx^]k$=xGXaEyh7puIJVR*34^DXH(ArqLeJ","#?-RrehybIle8R52XUN-S51F3S*IX;?(cBUR25Uv(_}JP{?OI:P~2L5>LNU-Lb8lqf~mpkvv/s[m7_L?ov5Xb.(7IMSaBF]Pm~Wy)+0k90csQ{URTd:%zd}wkT3W87xMd;zJNHBFHH4!^28nJW0l^t^57H5^o%0|{x63}4rm%'<6!=@)(kWl7oNm3Qa*","#.2hWTPyqLPcf!YQV^I.ok9GxDNS#ENgo(8{r198n0M(gLp8wZ<-4F4[$mmI;vfrbKM?5pK8S]}6jV!a;ZQAEKo*SI;IOQ]M#-{.;=[Wsn?Df^,RUEX#IC6Q>[~UZono|L'B}Ux^meu(F6#oSkphejQU+q57hm(z}<s@oW$+VU5QBl6Rzu{zpc$B?HIc2","|xQ<OktmmS8Ky.b)v<(=>^0Wm['.76wt>X`B?9)fuW0)JoDfwQzn(MAedlPn}ec'Ce:7a>3(6)6b+)SoL4&)trtualfml=v$6Q5lVbzlhb0k_f=oqfzI:7n5Qg|y58?mJ$.$r+{^1#+cDWS.xAd]Vi@>+##Bsm8n`3OZhV9wiRT(lpHgT9iqZ5#m,(=4{","pv*~5&:|m~ss@H+X|H0h~{XZ'oe}VR1'N#q3fECr1p%l5&j7c(WgI8<TPL>0Y.X*P6(V{e4e-[;x,a/9).'tNQ]c;kbZyQ%kYH;(3CaS(rS4XT~/e$[x/~#mgDoxv55I@s?CEs`*^_^ZbY/G3zD.3SW]a_c?g,j}6~]5?9kg_K#~J7>L<z}i&|}v'Ns~AN","fe`c<@@ER5E?wAhfkO3jAKY+$anJ4X4iu{h![)lqYWaK98]!ZrQ3w$5Z'e3$5O~c!S5sMta/lpI4&8G4.@DpF?inWC1dDbZn`=Bz$M!;|8G):_X:q,/`<THEO5oVfJAum6}lHQQH$Qy!BUHe~vSP7<C>x@ggqh~Sk5+BxKu5ASf(rr%ls8ZqR;J:MjpD,h6","^)fTj5!q<yp).wIma11RS7,=?v1-]iV8-fvs0m+eBTCC8*h@;I-YEXC{o#gHkz@CEz2u6W~r^f9'Rm8*.+2OQZzpIUjO94@m<aJY`|~ynb$Pg.R/j+3,DnahKN!3FX1:v4lJp_X'<lp0a+G{Sc=Dz$)BWqF|W2vEJ)NJpTmvi[+pa;+)aF9rM*g)PO-WminN","UevaP{tsZ_IsFO.O,DrTETjhFk[Wm@#Y!IL:5t/CJ+eq+HwWl-OYn1Yp8zF$cJbFVw(rVM6A6xm]~:#rxW;mW+z:!>bGh%#/#>ZFPr`6eKpF8l%*tBz&wG@|yVt-6LFUUS4JuE,o@9&hYOGjJ:+<&o>nW);'0BvR/iWa{'%a/8vU/=}t$%p2KBHBS_KjSy+m{","OJ{`D$g@95?7dOu1+UxJKIgk:kRZ!I1jiWpANY{$[9.BWkzDVt<yHs?dT~p^m%U@]30Q$-K=&?+OcjxOA(?:`_C.LUElc$Xr75ZGBVUiG/)1nQW}?5cWds>+D'3E~zHE|.a&M#$F:/4Gwh3-y}IE]r@A@)%/:^=NpD^*H2|J@TL~@G)gbvDQKDv2lI!xa|,2Dk","J($ts4G+1>s:%rtmu!H*(UG%HoXPAR0)(c(_mDXZW?c|1:i*0Vq!gS2c[8heGEh?-KbP[k:A=7Y<M:IG/-5F=[Z/s/;:tVgk?,$|mjYbv1fF/t[di::Kp%3}l%eC}F!RGzy/1BOwfTA#}?5$`|StC$^Jc{b(z~~ALPw/[~]WMXi+>F=3=,MXmBvf](f}cLPHp1o","EJ}~.I!*LesVOH,}'d^+y`qqHU0B2?<MERaZ_{E=yP&9ZTn/lL'dpd%qR]gmH}&(Rmv#i7QjV'1PgKnddXjj%sb$e3d5a&llD]q.Tq-p%dOn@F&6+Mw/Z1zfjcs:}vW|&]9H'4A<qs;)62i77F$5O-)AB&<SXi]:Zo>[U#CyBl|gN?D|eR~VD2ZvGsOlJ.W((m]*","ALzX&|aT.Dmt`:~9xe7&fBf0vx+D:ZKNp9l9s3B%96fh.IXnH~R'an0yT?8{cVUG>0XF[*O=;nr[N(,tpq3^H(Aq*!h6.5%%cySP?;?bY4nfEyJ+,=rd8?9Hj[Xde.|Q:;_VoTV<;ep'T5kX4z(,.Mq19>c@y4VB+`|$}TF3,}ythw$VqVpMZ%N1^o*H=BMmE}vz.",">$rw|!m?2><`[:&M2C~i(d+iZMYy<dI7Gv=qzvvp*'G:=TOy3Up]|&o;(sc,se!5o>^kT~a!HFGqZVOGonQ7G+)lIYGe9!ys=Y!X|GJ@([iWe'e.QQKs+V`:^Ip=W1.^~Wg?y3IR6YNWV:qU`a3naI-I9#LK*}Z&Et;$?H1fgIcYSl:pwa{8uo.[0$pL3n@<qanU}Z",";'3^il_9O)ZDc7b@u'P(0|&4WuNdD--=?b[GdoBj'qqswyT^oYv.`UmEkrBAEM0/[5q>6+,a0._sDs^;XCo/_JkgCae>]9E^kL4=#?6u}QLcBU/{s$VYuVK'jbCF&+JEO(a9.f!./=Ph5a2votzQj8|(KMg#bSQZdU*@eYem{leJ?kN8|$&xqTYg_vrZJ'::'Sk./;V","8MZ?;{+LTa;B,{[N^tb=&K&xKbuz(>oY:Y<BZTIC]q@STh_a:_>V>x}bA~vEb4S4zw5+NYd@e@*e&Y^?NDbUGqb&4VYj!kLq!z,f[kb+h+a2WC#>Y1kRt0`!i|3A'Pvo:Q]O@(QYZ}/6no[T+rV'rx[(}cZholzWm|Ykw<&i,u>!DK=rKAa!}9c-C9OLb{ag4sPTfl*s","66pK~$<x#nX}}G2ov/*D3nSu{O&'w[ZFY5x*{9$;'v/}Xxe|{#?hzRC;%-Gly58=@)%v@p#d&&gyd520|(?>-P3zl%HZol(aQGhI}>_qSWGlV(@'ZvweZd<TjH)ovAS;NBc?[P<YJXB1JFxJW!YbG:Xf)nO#I4|<i_8)e,#>z_riy,T#AW=j3)GUI*5!pT9;Gj{o<E7(k","4:J?]u@Lll<=)L~k(&DLSSq+oVUGVl@]Upgd%0l@&Qy0w]2&*OrS,w*~B6O_F?PW.byYh'vU,&1bQMv^*Q}P7byDt-!F@Y%RTkj$4vv1+UZNui~~>nlyjPzdgbpr&}/kK/RTx7PMBbl6)~(,JhS}gu$&./z7d[0aa*!Z,J88am1FfYk[17~6l;6Se5y+#.k!}.Qgu)X]/V","2T_]&ocY++_6VV{$.GzkrjbY1+F&}bWvhUAEYmSKj}}3{nvy8J&U7QAFeFgOONyG/id2%p^Oc[WLC9XteY~by)UK@X]1{=TdWoDxAUvDE(}T3-[(jEt:o`e^OkdZb3z20;$%4t;l1Zs87l+DOV+|IFMZ$+7|DqL(<s-POEg^]nSL`G)Re1t?(*#f6GlYf`)O^;mnG2@:f$:","1&AaeWkkM6l0VZnBT7qOB)A$@*:T>KfPz6#*Kk[pOe7SU19>JLD0um!fmCwL'US+5[Ss=oW/BfNi;BTku??4Im]ip9n}~g2D(Dtg@=_.AMA-:|Y{&g}ZfdXe(5;`H//*Ns~ca3SUeOhz])%cbr]D-;qt19pyJYNTH6=vl[QX3*msbQNp!,gV=F:^m8KOz,jut_d#ViZHxE|6","/enI@^+TreiDlM6uffShI7yAj.F?Ow+P',EXBy$^OF#Gom|V;~AkwQ0zKG!cTI%jP~#luZiKbLLQ|sG;?67y-@S;Ty9/;v'b+p4zu,P1LP[E%u4efl*I%iZMt#}U;S6$@(1=>h*imkBG2qdJ:pO+y(Q~.g|~+?FFe:`gVa~]NaFyC!eHkV3onN;L{Q#1ySeHB8pA@AWK?r~CV",".Un-RzOkdbH$-en3szwY~^Af?hTU)]iSk.4%F*@[*ldxO'/W6%nhDF2SPX^>[U`fn{y4MEMYOz:$PB6u';8T'*<L`*'c`,;!uJ`kb90#?|$hYmUJw#UdGgnfJ%!)H}mw76#*.)i,'scblCSMS:7b=uz={5)~Cr!N&T}L/.pMt!.Ji_+hIw4]iu{dqrhg@DV5/Ul]>#X=.]9FdF","-SG;#)fjZ`(Enb}`}W*H/VxeQa7Rj~jTV^PP;O&Fw^'CBHG[JXYeYHZ+2l7;G/G0ct/klpDKpq|CcK5jd>f,y:g4TyAmIPJFh{x5+HT]1tKy*|vph2kMRx}ltKn'|@Xew!>/sE+k.a@e(hDOfe<%j],euH(/`inABzDnZF!dAJEmln.F_WJ'l-92?-|zgC,f<S0lgcxb^9E{2vN",",[yX){E~e9S4jvQT/~Aakj=uo/4@*gD3,V*D8ofysX1>Ae-xXq,}:rbT{,HTIo'ZMA&i_DpHO%Q&Q7>>xZQ*dTP2_`oXz0(cO$aM0d{jeNH.?(5F-sg7$9KRkFr)NgGC<3M`Jm(Xs&8]K^+9g^;jSj-Nx&dK|li!A73VXF;'6yLj_Mb8Gk-za{wT0MW0>&^BwqJ;qmQ)P?H)n1HJ","+o#r6Pnw$cD996'^:%b$n&j,0M?G|GHN#y9(1k[niN.7ZpfH|<wMH*eU.N9R0(T95(7WaL#SfK^0n_c&k7#/X?+YFj|iv#^p61D[~(:`Q7kFu$?VIL7$knd(Hl`-qjyd{9`b?d(m$*Z.1z(e_v:UE%@qI#nj^R7%F[Vb6&h'=bPn%8TCgA;kuuIV&)~u'n7sC~KIG_XP,zOl3.%@*","+,JO<qcGu5bN/#%H`j}_DKpe09'ECkP)/s@fqz4!]J#AX]&R8f=|/TKnL2#=XM[1YrBFU^E94/536qmN?ZE.[Dk4OVT,l.++@m+I5tT$nZpWbGo}$o8`0/*{>awt)US<.8{Junv/Ds8z:iZ|^q}S:CA[5,$<CjRW[y|cN9<oU]#&vG|hxvc;s:;FD_M2KWH,TkW'MZLn4?7Gb6TIc2","*N1[!]mY?Jj#d`:'`9${KbD!(Pt7~jyE4/AT3y@eHG-:%kGs:Mj0J(k^Ua)YlmWR2B>vcUR)EL_ro]^uYOLVcGWe+4dp8ew(l'G6~5%5!D$5KPf,+k)/Y<%>#g-v=|*_x=^E}g{Us.'Ru5Rv7VYpB_K_j@[75!Mh+x,e`kO;PHk|X)e{//t6}<:CV{>`)Mu1fM_hj.$>5j|_Z#c)yq{",")w?e1OFY04O8C,8ulv*]M0'`67yRZ|AOqt!+o<2g6l-RZn6[Bm]%7{&%KH.>Y5&w0n*Kp*zJbY<]-xwLjA>nI7,TDj]Mp?Qt'wUz~0W*Qd_/SF'PMPdPa4WS2aL&MKrt2e$3NxEz{>V#ZwL5Zkg4b--jP0=o+ZIg8E/~B9~Fjv;8YIr!xWVN^9']ZH}FxlTAr|,0O!pw-7OeMMm:?/zN",")H.Y(S1~@HuNS/&&*qk1w{1V;{IsIcRDYDrx`BO0Fu?3C-!xR^uNLzpl~2UafSvwtQ7sy%RveJkiL*MMeJ6^mlGaShVj6J!_nt%<MURec4bvC^IuQA^v8Dl7Wr]t[bw?D8Nl{z:#Y#J|EuO-?MK'y/@w6S)MD9b@x$z3[o]?zvmv+=35RG%=?Mona((Ta%_Wc/QEx&>0wUIC->&T*hOd6","({zdo_T@^?&st*6ZCH4F(nJ~oWkmJ/]-1$AMJ{W;y_xDV:GWu<M1Fss~3n=I<ng8gWsZzn:N3>ah*Z*(KSX67WiMz.(_4hg_f^^%3#9U.@'oFJ<4mk+2HHc&3TM|e'5NEd2=3U>-O{~EAV;RJ%ICi$~kQY8<PW|m$|IPl6vW0*H@~la5udc%'s^/t|0s[}^-q8o3UD'/qlVbnc4]!nLYQN","(V4iSgme]A-r)`jW>0kIH_fM7&$}JM-_Kn/mM]Ov)k-Fq*e&ts=]j1Pb$lPO`sO-al2xp*8c*7o7#lEMS_cOUE_X=PL`/jsfLIwAn$wRfY5-n:fl,k:PR8hCrKw7BGgUc3J2plF6!dD[Duy][J0l8MSc^6q#[J##A8lQw9V5=U1#{+^+_UdoC5hM5;)o4{J>l%@wEa=;|e]aeWV<Ddttma{","(5FP#L;TnJb)@wYlgh`V&UJ1pfDaVF?zL;Xo*ZfP@S$JSH_=.MWZYEKa-/!|PX`)C<3&}(7~HYu'mch`SaQCx?J(IEO)!<+,kK]8&ev/Y<^{97:aWI3|[y'>)nS4ir$WP](2de{wC>a$_n#mf}tj-'851_),l*ON:j.<{DqqL3acKw*P7!<@63)ek%=)%Jk8O(sd_7NV%-R0osNX,JY=>Tmk","'u+diyQHDXQ$$dXf1h6%bbi}zKe1G|'1>lg5DU1{Sd1e-.a']0Fo0G0`+MS7BmEF&1ro?C|EM#)nI%v2<]r+8Wl_!OP2iPzXmhR;K6&P(n(9h$q|dWWY:{8'`B5wD?/?AP^nQo-`sg]-3*~;sK(;)x!lY4*5J$<HtCZ%Z`j6RE<A(wr5NAt4S(dJl@yh}B9k&GwA6LMJ/u{HfioiYFDVN^59o","'Y{H>k77_<{*x>yk^IdL{APT8y#~[r`5~Jg1+o3p^$93<'L=iDf1J5n@e8?EzNR;>7D-P*?WL=i^=,,y$Ad0nHhB!]l#Od!''l{!./F,;KZ(G-Q[KUlPN>0Q-YQNU#.fm)M!S=f.qwL@XbV7e+[H6nTB{o+kq!LO'q2@j'n%X63:'AoY||~!2F4k%n(t'U8w]ivI@v,uAVAD@$H`{(9b6o@,]*","'B^+L2*tNL3]Nhz?9dWv#IWwdUYujTZ6|@%rY}|6}k#iCD&PWuQI6v]J+2(mKP5zFAz9:4H@GRW%N>a=_lxM'$K;b[q8Pj9HDgQ`Y1KH0g;%K2`yUc+22jKDVDz]|}K-urG=IXP}2qQ5p-R+}AIX:|S8i7rA79D^{/v,|n!qTs|TNdY+0G1$KmZDCB:Vm%NtV(&;eJHF9bJiLignN-[0@]M5db.","'-s0fO*o_?61-|:h;mfv:Em>%008;X5kh)xjpmK]@`p`qh_iPb%DcQSWDWZLlQ$=6[JM(Z.t+U%7mGVztM`Q7zCW0GRq`eQ0MP$5!m7thKT0;!=@RRTXq2~!'p%vEQCb!Mi}4QM`cCp;Wa]_1c_l!6H0l54z<*(:5'v0?+)0Se<8~@hW-3KUaer@0cgb&!Mye{:2:6|5@j(LwDM/cuK.vMITUqHZ","&xGB9=4|u&BO]B7&R~^y.n#./!R%Xx.Z8yzDO]Uif%k%bBd|JJ8ML'b_&L4jekaLZrkA%lFtdty4,FZ2`V-Ub$KeJo6,.N$!4SW<K*}9E>>jWqq./@)Eqw^TWt<ic@mhQm9X/Kc*+yi!evriT{c0*A8P3'i6N$3C>2[j!S.#zJZi;1emv*jXh^T[yjyCK3;+Yb|0|4re'-HpZdsJ|)C{I'KTv^x+V","&h%DhhZhb6@Ev#_3evf|V^yG.M_^y<3~5[JBD*sGnX:u9>qb}#L8-59V-Y]H*62;#TB_Xpul4.hu!cyNOjwyL`[L^A3)>K9V|3a~n)_GjQl;^h|tp)')R/;yr'rva/J/~-a>)kHUAW]:tqJ+u{qUKE#3d<A*aVWtuB2`KzK@ewYYlleW7JTd;eqmB8?,GDfrhV%|o]W$8a4`I>j$xjV5m(Jm2j,f!s","&XWQd:?07/|#n2R_%sb9uEk)x^#GPt/M#%s-u1liz!<PXsXW0uuF~Pef2tc^nyN8Vg:/bu=N%&wsEH:_+q1j8oTd5aBeDtU}?wa)/fp[jLO7HB0Iex&ht;#*7$@z'4b3i'UnE5@kksu|ac}.n{ZuT~On,Y#t3bO@v.{teuiGgCDOVkBW*d;0(S/5}5~:tzR*BbHQLfD)YF9ITfc8t+GtMb(XiJWQdXk","&Kt>R1iyl{Pe-xo>`%s8+*AuM]3_-S1^LlW}{PDMB#<#+q<E3t(sJ7+#g-).:;|Y)':lcB{C5lT%CvP^vm#rHj~8IlBe8A@,_D]pv`4Hf`rDr@@3h|@/~$*/&,PPaqVOb)=uLG>Q~Y0'#<e#OVID}ioWl#bEPy6e/MXb;toMQ@dhz'wi9)Xyq>JW#Ob]z=>cXNzFDw;5)aCo`oWJH)18!j[B(?M|w#KV","&@m<3d~P~N_)x?M~JJ|F<gOgG[_R7l&`$MmdJ1_Zs5sGV@.+]iZFZml-UrV(lgLyTI5X1Ea6b!^)Y$L@>?kL*obXI1/UCRXbbGb6/|AeCbFYs>.&5DE[+jkdf6VAI6o#t[X:}{$x+O{@b.&-]j&Qb%kfYbd/>e'-x^l/2V_Ub.8Uqunjed`TWcMyvzSB<%oAFw9E3~)jQCG5K}3H4O+nM'U8=olN80[]:","&77g_!J'DZOxTsR<MpgQ>c!C[DeWJQ7)~&j}ZUTl8^kAg-z~+[fIiM-#E_Doa$1blY2|avWsXD@dg&nwT')C'w]E_MH5o6VrA)@5t|FaYT/]^!FbFif;#<@w]1'w`7/0ePPy`-TqLQT!sa_F/!,d{xL(A(ZX.nItXk/mCpEe0UY8.2<76p1N0@ic#g.?P[rCe>)5_c1FnYc.>H&xV3z:_Qpv1]Wz>5P736","&/(WDe4PS<6CY3wE;L@TG30Dz^28T?|K%fzH%u%+Cvhew`k70^]4bUUwLf37JL.jo5^q];5?/JkYX!]B3e4)5-R`p|*Zjh59k`:`Zvkt$5@zpd=(OV(E=HRK~&R(M}(M:JC*~gP9'|mq#D:_sawO0)uBk(_FmzEV']l?EKF(lqF}*'fU&QV9cdI2'+~Ql!U:`v@LCJ2bIg_d{.;|nQ>;&o1zuxb&,h110pV","&(7*iQA{mRD@plNg/h$W{t?LBW$3FNAt&'-V1F~@2J<Y*WKEc0VE-JKdos<Y<,%B=.9_5p~hY6Mj4fG~N5NvkIZ6rMzWnUxmrclLBN&gdE`X.RmiHeuvE|IaFZ7iEeIaSu*r5WWMi#D$D@'[3U){`<A{zqXeA!PD~[on5'TRI^'D0ba|=%{t3Oc]PCBvaHQhqBdB)?W]D>wud9m}#M=!ntYT]>7t=LPp6hxF","&!]tzv5c.`qp)4+]t4=0ut2?p<X,vU@8R~TX&9#L$Dvw(et!Mxvt_45*Dc1>}ZtDLBst8t|8-EOZt(oeicymv=U.YB}JOb/,sMy-m(z=nRw+mC#cr=])HS<{5z{ewB[FhoAfKB{IH8V@+-=nqTBEx=xUfqS;L4TKnKdg9TsrR2u&LU=$Njq>ZoP_'T!5QL$*h^C>K8t{Bf#wxTo.&24DJ$3sK0I:pZ()-6.%N","%{8giEEItyyGh{>Jz7g#CZ&I>/nR{27=qWpD-=w_H:Qfv>$'x=z`Ga4-9zQzM[[)b/pFv%nl7Y@iVzrq<O?#%mTyYp-OW:AYudAM**9W]tN0qj%zw=,l&h$UaA~'Z5{k55C6q-a0cOT5M!l{;ON3&9,v(9lt`@T$iqa`T@gyjofT[=.t~'0aCGI(2isA:)^EU@u^tB1iI$Mr2GsVPXw.-+TV(3Am_[:e/07{,J","%x!SSO+~//5`Q4|@j72YAhOb,eU/cj@$MP9?,TjF(;={.lKHq]1^#rvyH5QcuGFd+'Z5>+f6},iR3&`gBe?_1iikXz;:VB|$a1Av]a2vViLo~&Q_I;.n~0^<MY2'v#sKqxb8#kk{joFlMixtp^}s&ae*DgRf,?'VRYfc|#5:gXuZFA4qp6/:Fg8W~)6`.YWmqkelY,X?J4U{Y&.$=A>-y'v.;~_%}DNe#WJ-H}*","%ut0`n5]=4(YL9xQIxIts8`F-2NC)$6s>pi<:ea}uKv:Z'&WDU@:'i*^!1.C*etp8x4:H'1Ukw-|jwwk(z@$&p$c4snB<N9gj5cP,3(f1.LfN&.e%c{g,CL8<3y_hx/ggVRFzo`l$?OavoBL[ilpq8%=AYw#i$@L1v@/s|u<wG>9W13E*&i-Ua&a*u}U>(4]K>,XbcMGR^6nM_c,5ece>AVx`.'A+1+}b*f6|Ec2","%tqMbjP,)e(VFo~:jq?7)lauN9~?RucQ/VXA0lAPG%fjua)y6hq>,o0E%YcRdUfPwV@N,Cu#j9CbEQ]5jV}?+(P~oCOeE+js`t)Ltu43h,J~+Be[r3,{PjQ=bhzk<JUpNAWI+(L^Y)4@OSUd(hgpqXpHbb@qVLTWE<76`kFA!;?I'HpT>2M-f|y;uJ{a<M@8Z*fff}Vbi5X#d3Kq+H~mBt?uv`mx`?2Q8rLDtw4P{","%tv;h1+|!@_Je-oSg89Dw@1@(&T9(}k{Y#}u5VIq^e.E!'lxwP9_NH7NyVS#`co}Vp{{F<:LhXN7Y|j&APt7xi_J%{PYb;<,{B6%M9}lC=hW[o)zT40MmZlR^}!ekBy*iuL+B#,51-';v3YAaz`S/v*UDtB<nir)C#}GIG2g<i}E4x&!cx,&,BMAa{uh`h2MQc;(S]:{]N}e5zmfxngL4YJ0?D=K|gZ50{U|y.;>UN","%v%;KXf~<;aM<6CI,N#:Ypv5h4DdU5uX.yQW+K$[}^LyjB~7_gNgyNS{M-%@&<!@I!eQJ<<2r!C&=|t[44f)IxiS7+=)QS]XOm#P7cy1|`{]`1-Y3e#l2m0L;8KN.$V]'T&XN%DYEPG_=E/3=s*ZA'Q2e%`.KUaeNH?Y=ML;hG&1,h?)zFO]_B'ouAz;_(<GsmipHNwF)@'WORd<&baV^d(=rU5X??^ndw^}7)&5o`6","%x9'{X)y#eZ6*Nm)7$;^%f!~VF]w-3T1+|A`u_oL4M9?eB-qEMLu[IgLnXqPw,]k3%<S`>03nP<.4x-VxN0jZ@mlcX'WI^?BX!MPHtn-PYX&bZmlAIeCS}EsyUZBItOfmBZp&UC6?;_g)571xUkhVl=<RMXC](8B/m(3F81Y}&[D8d$_J:?(Os7ZRHu7m-k-89UJVn'8~6BJ*1s[uy{zY7{a[!7=El3FHK58ly]OLJ5N","%{V/DZIv*!rN5JB$p=z1>_uL!jC_CTz_skqo(6o#yHa0${3uU_5_c_bK.7{/PI*~h;WQ|!%#WcS++vn@y1<;,3f5[#zOYM2-A2n80XQl[>e&7yPCvV;L~YV,L30D'AIaVq&Qc'*:}(-%.FPbi.C6:,aihL9xlGng8yLu#eC^x_sj{5`F*N4]3[X!td(fpakTOwtzvu/otDIHIO0,+yn;5YnP8Q2&O2$N@mkE7:bqyWbT{","&#!y>t~PAqR.V%|i~`K=C`P;mtyU#PR!%n1Oli~bOm!)r*hAnb;bRgK%<dK'*&Ikf_etTiJ.Yk,,6AfNm_1_VYGmKP!K=D|%%bOan0S9sTm~4<'jcWo>>g^^VX/&KUzVt&S?S_'nkk{$XraA:IEORO5lOPAcE*)K~<<|DJ:E~6fdk>J-!>Z5sFw1}%/_tRZg/.Xzr:Z+R,XTfXBOb8yhex@rPct$)kWn+TkR#(y~d@2p8k","&(Zmm.72gip[0d;F(1gqQybOtV=ke4qb7qaMX1p#}WQ]`>y9[t*PPHw`eNOVOI7Haatl)A=D+khBJ>)@s.kyCtaWrrM8#801>!e(;2$.a(w(!$6$C>*H`iYYEr*!gQ,gXI4DJ8LpK}Ui8EjWl9kL%3dr#UZ8c<>-OZpxZ6C]Kh}~nv_Uy_z'Au(kC8v}8q_tA0bL@W@/m&p(u#;eGw>R14K7ZdlLP_HZ*Q.H6%Z''2.edAo","&/J.Nt;:aH/>idWpCdRYg2wCIBkaUcRTQnF/g=.{Y9GK23l3Eo9pu!:1^)Jx>2z?a5fDS|>Mn|R@*F-ZL,^3tRe2=@0t_D4;XHhzwC_I9$,D~&~)ikBgc[fxH>lHQ9^]al!XT%h&klWmyn+v=zrt)Ky6W,xrc)dTbG!/`Mz%(bG_klTcSE}?XiMx96c[8){-jb%i<CfyG,xkvc6X*j6prsy7cT1W<<P@IDO]xy=q>E`C$,]*","&7R@4`hqsgPzRn5o=?!)eD'HaSl&/Og$X&W3<aoO6YhzAib?{}pC)'%hJeSmODCG7@`i?z&`|=#_QyLy.A5%#KP5$s3Cf0pY>MfYp3^AH{R}h]-X)P.I+kv4Zit7l/E4>dD(c7m+:lx6]cc,IWXz<85V8M/L%=].{ob9`jD]=RG=+<.Mro,t%33iif.FGt|:,6-]YHCBY.f>DWmd8;u0%+!'ti`)>oyIj%UJn]}C6.1wK}jI.","&@zz+v,sQig,mt`fm(,1!B=M'r5&_J6RvjElE4!+XZsF|-qK(E0|si*lS;~r0iN8rY[w7CZO}B+;Cke7Z$il.f2{I,MDC#R}BuM,z`h5!&D*v`{}S5OK$8F^NqwXI4sCOYjIjW=)E3<AEXVJpno&wc1RcQfoR_X4K7|S([(~h<:b=TyKHT~vuB0P^dGNpz-;oSDF.R*0Vp>8Ws'OH%]0^-pUVp'NpA)/Gfx-;R/Ko'bY){=*qZ","&KmjIGZ}T`V7=r'0bi}T]>`>$]%Egsbu[Z6VW7hkWYL/>mX!5x-sR+0HDkWp^L/K`:>-aJJ[=^%$<BZ7:wT+%q85dgb>&v@muDy4TZa7Mw^[H!];dZR=)dj6k$@D#43dpTOjR2LT|'=4WBqQ<4(*s@C7u=Q|?7VaWO3`E*fp!22k-%}.AW)aBPi?wlLgdiN.}Qv8>p!V]zw~=T{y`m,P0^iH2,!Re[u/iN/{cfLJN]*1n8~UsxV","&X3z%oAU7C/(l+}kOFxyw<;,UVAlqDmb%YrwLZliJN?_T.NcGx?Zz>d}OCR+h-KNs[Eo(LTUxQpH|EzVy#t$fSRACzX}OLDMg9<RmN]X%uhvJ`H|`:_A6B+ts9~5~j`.Ja%L|W694xWJ9529FLN(@BK*hu4:L-0x^[[xzgOgxZ(:[B@[Ix0z@u>?wXu#9#g!f~%&u8G~A^34{b*xI4g^H'v[LIHZVJ0WvEg^0?!#AtL%@niuNJws","&g6(*iJ8SU1zWu=^eBWM3]LnnE_{L;-[/]ZhsTTn1]pCEP`k,P25T6W6]X;zSB}j);xo[pLN)MR~R^1;XqUr_??:Lf#:yFneG[w:*@38fx$CJ`jR>bXP9x*Xu:Nz84_j][&'<msmLBzap+U4@<_Dyq3N~EK.I9pTe)9[v:6]laEr@K$t_xk0!`Q&=0/:3p?O9z6ZNg'Gmyw]qC!,atvI;GwQU#hjI!LAOgh'0<TKjk;bZh<h$~0,k","&w#ExlgoO#qZ6lAsSt:7yv^8`Dx'F+l*!(m4+|TQ:3ez^j1f+l8,]{nUFFC[;DOc/Y>Thu9*6!E?rDJ+&4ez?FC9oBs71Q6s6piMuEt+y5QJPE?gQ?D&~PaJ[,Y+N=Sj_8?+o0g@*cxp`/%7Dxw5oPEYkMGcw}6a9)k5:7cbBAbahP+u^k5A=auzg#>u0^#B`WciaGQaR:LqUN8y@]+T'b5J|4ZAYW%ud_W7a+ZmWG`0CZA*gvD*hV","'+g!]HA8.`yy,}<.C4SAm?vgFDY5FOomR6S~SaYiu(mSMAk0c=SrD&b&>E9k=v^d=}Z-Y0z6W]af8F9pCM>{XdtXi#1@?n;~*.@B!zShx+/WsV[IQ'4b<Ib/>>$jJs+^EPej/U]eM!xRX~+}af1oKY3n1<dEliNH%Z=,)jzI~636FM5dS[e@&7L=uu)onr;z|A,zn*|+4tjn2tubaM(h{ZzNvY~(S%:&0CgN^xZ#K<:q;q,F!D-OF8:","'?V'UGGP|}`ZxXn=MOkdzNC&k/}je0e9*(y}_n:~j_;=FKfnt6u4h}QXnmZaM&QZ,gr4Zc/PDLJDbali#.Knq+}rf/)gA}$+psUEqrl`{jqksv*1H0V$fLSRW-]LGRn*hkUbamc5FS9l(ns!'eG8_D+NX}jz?}yW?Ixy#=?=pZ^1Ts]*Gf*Fg7&k:p~+U;Xaso^n?`>t^aj[EZ]9x`;Y<(U&3zvk.}HPLK]So:ouQHg6v5|JrO}dKaG6","'Uc#?%n>|8i't.1^>RSl,1>(n;YL7p+V|agbq]<3Lzz/>Nlif5ULaPS/zsfH@)@+{N/h+q@+mOBW9'J)<)iOyS+u`!mPW?hNkschD7EraAZYb!T6ab|P4hP~mQBlzl_ufaG^8#Y{$Hu=a1?`(zfa6Pl:O;A:;)duA`r*a(Vu,z3Z.w|A;tIP18>YrYeCxJbB*Id^NrRE&J14aZ@Fpk7FH(-{3STL=#K(,)wv-MY;E2@^Rk{^,_ymI*H?V","'oBzev'qdA])6$DzD~H]@XE/oCQ!)n*?knyKAzGs|LUg$)6L/>ctZ,YPPE_d5$S-8w2dzUZ)<~Js%w%+S[SRuFjkPXh(uO`BkzE)}+uFTKl6z5+4}/r(KaFmMU*IAoY&oH>A~(w9yn|4poCi0y,LKewKX~ZpX4]5r*o+NTUwiVBwWeb+uuBdM(kh%Lq#(#Y8.j`|.xCY{@Lv[{G<|2x&eqz~j_d`TE|1g~@7gAWd6'TFO][}C~~pG6lj/F","(-myEJBheWd$M:Qea89c^S@KCJu-cBC)s1'<^-a2L3,2-GKrbO$.zDhVldQt(9K.YVCMux{-2W.CO*Z-(`]l:3(xmpmBcY#+y'Bxqwtg#bh4Jev*xCV4a0gIL#(<K`3]-.?E:eDCwD8mL2#+!&^bddW0)vEFgS::YT|<z1,y*cu!Sm/K&-afW=N?./t`ew@:uR~L?D+<,_EeNrNA(>1<02KFEKb]5p&<2kT'dsZHJ:U+N:{1EY`kQ{2-f1N","(LCHV$f<zGDO-wbl4E0M`_mJP_lh;8>yg#KdAosur!XxkPx(lA,';eXc#EjK,_unyz'|7=$?%@o{R8l{<gL*i](dB/3gK+3?W'X|j`{j,0jZviwjs9-<NC!{hXgqL*NHZ(6k+Q6V&v7:s7~}P{Yr'qK:~>M9@;L--a|_rhB=}kk=B6;7LRm&*:a$T>[6k8|AvhsF-Xd*[+7b($1FG;tD=g`nVrQ1h;GysC4<E17+>^2^[#'Hs+1YQB)*qomJ","(oAdE+GLv>6~=l_*8JYlzkp/w$,a`i'8B^m5DGFHs]<e6l{Ek<j-soK>.ulcml,I*ad?:2,H&nn@']+Fs8-RsO:'0%8la`w'W){an/[t5smfrRY']J%7E6+]f.[ijXOq;!_'E{GckyEP:/x'oWtIDd|cM6%rL{6T^q`dvH:H.B,#J~e$aDkT^Enyrv7!rAO07_9,_f%mb,kfU{/X-5rt`)r1q/`az|[7Zl-Sy2(g_t!Oddv4.@dtw<_E(=a]*",")8/U6{fR)$.p*i7Jpoig::%Lgbjhc%ItuuumWH{Rgpq0,]'FJH)GxuB:kxv2AeJ[1<%t=ef|`L}r35#[Tk-Z-%D}Bf/ihkH}?uE{zG`UDH-Qh`,AW+ktq`:iz2bCLWrv,ua*|7?Bv!BPv=w[mC^lfU};RTY+EW45@O]1wLD3[jw/!,bnv~.()%9O5>K?0^quTs:{^yD{hF1qr98sgs;I.qST5w]BK>f(d7t3Q%DX~CB.P<E6E3{/Jf!S,x==c2",")c5ji)&<7G8&W07Q7ywkLV6ddadrpgD|kk?:-N3j&=f@2C%_X:Nh0U~3Tx0LC;=3-t&QRKKwIN2CB4;}HapMEN,eoB:-;AyWBY<f8+&=Imz&'G0H)=R)z^c`9VL;[tn7THS%I=hl%J;-Az^8.23qgx)h{*hA2G,-Gr1z:X%V%SRtcSG!=:y~wipa9Sa9LL,Py^U_Am(>-rRow/Wf%rDB=vRe*%TJS&0tT>L&-[f&?..1G%995'Q?$ayhv34A(0{","*5'%u}Aquvq9uA$XT&'3yO?hMF#+vClkz6+mYSK~.<gKdBNfpE/H/>+Mo#&Kiuj~lX':Hm~:^t]jc.2Lk8q(1,uR,gelMoKxkMkx6xLe:J8;W<[.8M06<E[,h*kT5>8@45%{tx5@~I#JMt:H`Am^)|B4xTpXfY<gx2x2OP%g6ct73#<h|DFbIr=f1mruWtZF=?8xq}aP[+()c-EH#7H.WN%%6RYHpJ9-2n'X=(_0o#;sbfsvt*}CZd4cj)ze/M1N","*j8fYqG8>]b'!FpVzsCwfxV&Xx|y)0x$Z_W`=vdj|}!n]-A&B3)FkXp=Olvdr|,w!(':$*E?1J#w&hlssJG[=Hj.h[?wbD*o/]a?;|)VI7Co){'?OVqcR%M/;?j=UVa%y=2^i4~?^LmGv7pT#{GB,a^rr{&5LF/'}b/d&`c3SAn0sfF]%H6v<)rzUAgOHu=TRqp)3Q%txW3-|J4{U@z#hzL]?QC81S?=GN7Iw5`jGgs9N<J&K,QEZ^+z}r5gLS-[6","+GL#RG:_9-*4VHCz+3-v@d|4}]Q(2C|^;{3EhQV*P9`VgI+=wF5lzC%tTtAI;:nr{{N8Fa;Vy?.>5dI'}!$>t&[6>!jZ2`oI06za6='@0[($>!+t53mXfmIi2w}l]gA-(X']HlpH8wz-CCL|c}wu`qd/E8h+ZL`%;-.l]gLg2tzG1EsFm$4rW'U{b3ZZwR:*?adn`tOvcu{31hF9W%Ioh?Y+M'[tc|]zp%A!r@A9Izx<k2jE-u6oj%8YlwJhneH:vN",",,K%#wHw(_3!=0/]*@_w4#ZZM:#Uc/B5.MB%ph}6W(tl]4D|[<jQ&<[_8pf|?S/Tn&=sQ#1xS@2A^bt:IIvdo*pRACAj)Y2(&@OQQ6*CFI,yc}]gwOT__iU{qY(IA{p<<KdRNxubHz>pI6/5c%PuVQ7;q9fldg+!`*D,qR{mPFRK+qyE{f,l739/zxocNS_x'ZTT0[sRv)K>n4.jONe}tO4u|'z+(Qd3g]Q?a+4IK?]%bQ'yrTV?Bc2iv:>unD9`gH{",",v*ASLj[c=7,Eg[R+L2M9fke#p3uXw[p>$X9j}ugwtRG>p_/_6ej|[V7lMj+GUfzca1F6t_,^P#i:P:Kdq]yMHWiE?$$G4&F9nG65{+.efvZ_I$dH4_}hn@{|0Vfs^ZmjNG0BpL/!hgDn]mGk'Um]H.9j?1&['3)uaN|cO!Vk[o6)FC]b/QLWTn:[uh`th6Ou{SS~$Qnp`#!9@Y6,MsT@2J*.j1YUl'}'7@d_pX64R*had%Z/;7'pqJ!EN}iNC@{A%ak","-kFXt|5NetdlWQ!fj*)(BM>TKQdbDM]5#!v>2(C1'jUtXGb`[WF}n2D%KFW&WR2z!*<qtKcXTvOA6@bk41B0dBk[S(`G9i-]OvF9*_cM{1s$g^xUE(1tAYi<(qi8^{.GB[-^Vz1{7K9OKDhWPvn.!eEWv^18u/D!;<dfbUu;J$rS%~-L=+e0LlCcg,bs;T0t{fsyh0.gzX(&,dF4LW6&.'FHr*tI~-1xTr,xfJ|/Ye0mu+$2g4y}z,AIpG=:8f]vC|AIo",".jRPe)Ixz3EFION-8<10CQch}[N*i^ySd#J%kqc|E@`eeS/6pv6|DBPsCgGkK[nhs~j*-M6<}_*^e'276|^Njk0kz:^}(^a|#>T}R/W6H-7MTij%Y.|:ak0f.60.=[#CAD|P64=s,EqD@Qo6;v-5U=AzEZ42z5xv~4-oP8rubB~Yj'd0`$`Ex`t%h&E/Qyl`k3v-n9y,'nanhBImM_,'&ot8M!Njr#E2Wx|YOm;cgTk)]b,He^1#~138yduJ(UY}%e8m]*","/tn25c-piMHQGKWi*N0_3[IS~gmOWriMZmoi5jIJJbEtorn!P(A|6-TW^?1t?Kn>h:-V})$E+,KAZuKfvjb7oC'R#V:Hb^+~^/#$>pNjsI.@ez*DIs{6=7Nl-nW&-Jn}<f3agKRHjW9v?&c$D.@n(}M)lrZ%8fb[Vj>|eF&uL@P,psv1/lTROF/$qZ69:0kxn7T(Xh@Ws(D'-q,Ifq>.#`0h6~NZX]6;$-ulg9N!<<Y4f.1Z|B!f.Srsep&+J}24[2Ek+1.","1.mo;$(!s'[%;&&<-t2?J%I3n`QizhNX8}+A2xe#hScJ<C-bq(X'+>A3lt>%{AV@p7{WNHdbwSf<LOiPGbohO%GUdmZ_'[TNr4wLFzpw|5c8aH]Oqjq/1wz4x6(wr-7yXWsKZAT@ijZdK<`HWd>(q+Jm:YH9EaH~TQH5}_I2w|QH%EgKUEPZ4vDs$?;9&a0'DxqdGn5=`d`0[wdrFjr/Z[]OQCn~q<#dZbhlul!|w-E8G&oBY<6fIh;0{|y.@G@O0qqFt=<Z","2T>'F|mIV/wuwiD%w`V;mBjqFRQY)$wY`]UPanj#%Q~1$<i$KZv#y,i}Ixg3M?HnrBA2Mi%H&p@MQFS0juO}R|)IGz8!t'6ugd97FonE7dS.e`Bz7[#D)@+G(OW4]2J!ZG[/H*Jy_R|M[`w[7=~Blk_GH4gdj<!W#iAyQ3rJB[$1+9B:>r!}S;8i>`alHDFk.5hfSKu0{_fE(Wdif^wCnLHX5[GbS<EqKEq7C(EbBqH)G`;a37;5V^5G7^={n==4;d+O`*!hV","4.C_<}34U0YZH_VxuULz|X_HvpkdRsWZunf8'X+o[_QWB!o~e<^Iv]-k`voq$@dR2@0UE@tACr0lll$.Q6,*N4TsH~/W-g@D!M#'_FEj)D&l[/Y&lIglsR)9Nguhed_W3UH.ogHA-9g.r<JG[M9v[9[OX/qJMoWXYgVw)m$RaW|b,/0Ds#3$B|'<vc&lX:2@WW#.>O|EhF4]B;5c0kL&zlG)70zRi.63uaD-urd$|v^qc(GCI6v7y(?9,TSZoZ7L8H~(b-{yos","5xG/e&BMWR~Wx$Z;{Z:;UFO[lJb$oB-#1b~!Oz_sg:I/8ccc(#d1i<?]FJHC9_!O^6>+OUpa%]#tq.MemuYBY3+r=Asg5bMfs1>z<JkATw!jJ)NF-hR0#Rq?Og}7M=)cw~0,`F$Y5Yjca|^VsjB1iG<.]}meEn5+Q+Pi%0'Qg6r*>V?%d51@26I$*g9G-;P.PCzn@JX`|yPOL9MH_ysB2Qh^A@<{LkeoM4#77DhAm[8:P1=^:h:w1/,-z_B-$+D=e~/RhUO7T]k","7{64bEI7YSYXC'5O>.5j.mha3?mp@Ov(+TLg8gy7un.uINhD{qy9h&,9KYOr_HdOaBb7;Hxd?LP<n0h15;|}ax1{Eh0u3R?VlJ;8lFV-r&h3%kb0<hp*Ck`$eF1%Xr|GeF5L~N`**MTQ:<9$eVtvMkr65mH=MD!E<]`c8,E$Rn'OQ6b']#3i:msPo(6:$'c|V$'FoSR)oRe2Cx28gI,tj^3u<Bs15FXyE@V4i/7NgXeTC.}r@3TP>#n5:h3-Ov!Gb.xhbf6Mks'V","::)$OcnfBSmn@7IU`'1S1-O_}5I.[aimA~U#bp$aPkLT;)_A|[]aCP]=2<O2E%>+2T;Oc59@AlqJW=*Ci:U!+*>Ec1#63#ab}gm_<3e<v!:Jsw:b00gV1S'/juk8+^E`mAUzo>pB>L-WG>:AM%@-_(3|K0S;4oELKfJu#R_n*wG'Z3}wT`p/Fe-:J&'5C_viFg}VHGu2SRF{'SOT+LPJ/6/8t@gstm|wd-_Uw8;&%0}~8o,mXzw*uc$$<es8NN6AjdAHZIB{r?$q:","<sk#T>!Lc(Le<:Zr3UX9DGr_2NgsDA*jTPl%,?vr]o(GaKf*$wt8'fPWNZ~](-9ncVirxqMmdi%<a}WP[uK}.xD.33Br0=Mj~zL3f8}j`ze4YOd7_k^e7eO_,Ud_)C4)wAopNr/S+>5{^9./T]![<5]78a>%Sln>6}c+y$jr-2`w'0,)[0+B[@?$VU7c-#!;w]vk5!QiJUNq3)c*t?NUw-qx)BY3*adv.2L|C'q!Jr8vF$m5}WC9%-4HE^v6e12?[U_5S0[YaRjf[6","?qkr{PTow/L,sEA^vB+V3:a3t_:mpOt#cuHI#M3@Xx8~b0)A(fHZ/A%z}Ez?w(=eYp$J$dMy{I!ku&M@M2.v7pM=Lq-(L3s9Oe?frFXE=kRu*|/@TV,TiGk!`H|uhSZRB&GMh!;LuCk$el13F`8{]{El2TGk=9.=wWRbcNGK72D*<g([=k&CmzD=R;]2M8{&P|e#G,QT'br{+|xb8vB;+o[&9xVA/;sX9}FoAym4D3@0Q3_t1J*u(.z2<=$xAzdore6IZKc9A%3^hlV","C9?Mqu0}qGQW~y.d#FdZhCocB.I^5~G`5v`F|8@d.O[wzKy>N*)'q_%-Pm|f_k%bp*/ItL8=8z|gN><hWWl&hgaYUp:#qI+P([}>T1<Noiw>X|rB6x92dK(4S_p%msE/L&oygwV2e.fYo[?WiE}goNu`{OuP80IE7!1r^iF?4=S(Kq=8??pjsGHj3=f=N}vaLh`;~5ll;y3B,Ae`q%E]S$V`V2R>yk6Pp]b'd!juqA@1Ut8m0e_&Kh?fibHL^,59VKm`{R^h-%.N}JCF","G.N|9^}I;^ww7GkTa=EsSD7x@1@gE!h=K{8Jw'$I5O,z?]C0&dGv}HJ]NA!)XYH|vb`hz'1Sd`n&yk@TU{YJsE,/)ltz6ad+-lEP[V`}snyV{a(FT>`M,X^+0o$Y0UxwM1`r%PkrlrjZb3>W>[lNqIDqokzSaN<=D/;<qW7?@9PZ+?McX{!{WJi6CkNgx.lQ!/&ZNFc~/FT1a?W_')mi0;Aad8BfDzXMuZyOr.<{P{29?uzNd9HDPl+j-4[h)fnk&yRU9(?J46Q25e}=N","KWOC(Q}p68l~},uN_Z,:9X$D,<^'IH?gCGQ<I$RU,pi]~w/`0AS>J+gGprGN,i;b=_p)of(ho6JYeNPX!,s'p0*wZ}'w]rRGYH!G?S,uE;Uj8|9'dv0'YJTW^0SO4WAkPt6LJ^nJ+6fP$}o8=9Or>@e;snzndN3C*%#?u%Hm]'J$KEX0|`TUe}*z|ifD(Q,p8E~YW*6F!G-z!0Dc&z2#h`qSD]&;p@Eu{wr)goY30hwVq&3Ba?l(#h&>7U<6Mv8:^iK-`p@FVb*sMpGlPJ","Pam?dqbl#gMC2O0PRE)jwm!cA<rt(5<_5C+qcU{?B)kuH|2~4?zz{C~h_0FGsO'w9Gf_@C+~;98PqM_5!e_V&]&:;sNR<'K>nf1%E^K{[^vB}Ci@|I+.Xlk^XzcBt5t|@Xhu'I!f9(9CZy$9B(gj`%]92~HUzg-^$1g-~AEJ(hx]UCCi>xC;D1p2;^isxQ]0u'a*&yW.Iyc2D}{H4(N;C|59^AB%:^8p6%>95-*o,tAn.XZ.XaWi,Ekw;Qkh{<tTqq0=>#q+;8z4lomkm<*","VTIn9(r?$7Xx)1;w]2Jb?Slq:dcYABtAriKzhi*Y<EeU$d,W90ll?UC&x%F#O}<APi%7zTX}~W_w@D=2.8(G}e<|5LwDBqUv6Wz^]iP)JAi5I-!P9+,X810i.J%E)x:P%qBuNp(2B6J'A8u5?S#C+_}N>toa}ZjHW~i&a4Bsp@`b*4X=rkF?YC!r-WownGVl.Kd=4lx7=C1MwOa,.yYl<j'Y]EoV*2v#H0cuU`Z#;_LB_{%;<WX%<{EO[QI3{NL8b/dqMAEphBPdT{$N.1c2","^>3@osGB*<Q1%xC[$AZQazOp@SZS&mh!vvaY%?dmK}]]43CG~<|]4QyRDZ|31myYfNpG.^9HhG4b*n1I~@Vd..-3a=NFr)]$QVfwsCpo!hb+.;tf9gu&b#Vn!$}swDZt@h&Ln1$/d&K_Y{;tKTLWU=v~h1Q5C%v,I_R(tpB'yZIpZ<4gbP;^&+=]w@M-RQ/V5G6'&KHM0x0=Lw:`aNS4z6:cT!t5(]O:l2{mZo89YCupkhyr8rY/w6(*~csA0dCto()kmu*AC?p0W&aj:.Sm{","f,(mTM@22om}$P=dD^rB=|x8)T,_#?IME~?~0C*/&G=%e]2aH5;OTlvL~f$=]h;6V&+<_'W(O`LWn/%wX7B;'|GU]iO3V9(nIp2FE[Ni3d`1{8a<0C6eA;k.XWGTn,!3qc%O6fPUI!A}lI;(6j-/3f[(IDT98mM?x-|H6n'RBR0j_yaTw@Mkuiz:'7:||5ECcA0k2|Y~bozU%6Y9?<RBw%'gbcem)]'?1~.BBs4ilD2+TmuX*~OU&^x5R::.-bb{IVx{(>x32W@U~!zte1?[jN","o.cIxaY%Rknl|fLYe4WPx'-hAh*V/xu+)mgJtN.c2<U5FamI2>9GR_H9-.<8gso^VPZu?dPKiZh?H42}_@D^byW,d4pOG=>=Aq070N:<PSQ0Lkm;a;/d0hA/j|_6a<Wc[gck&rrG/|3_KB:y><D`MaXh:`b5xCn+9YDHDfRb6i7?zkOnzt`~}Mh8iNS)XN:b_d9)#m(iI2e68*wfP.'{wMR;sVso;9|qU2Z8'UCq[aZC0}$#n8kwI+!=r_'ILVk{)+%P[[9)a06NC`D`7P$ODW6","yYmu)SNT]3WoS2z&m5gBK5[BTU@?BU/4m'yyHpN&SOOlQjDf7T!0og);75[QD9jYaBC%Lp_U|dXTel*sx#j4d`x/{1+1hXLc&<jd^1dDGOL~wJc]|H)McQ566D7FfdNwQTN@O2ivT%OE-D~@q</zrOKW(.Yo=}o+.5Ht%muHo:#j'R7y#5v}`1yc3b)`IrD)jZrGYLMMu4P/[z;As{iSo$srxm(RH]_U~3mK46xw>++m_s*JTWr|K%(7,1)JaYoC5>XFrDCgW_8$!xd+M7$Fy+YN","#(ixw}il[2!tw^QFME&fy19P?|Fl:`ro>CfGn>8fL|j%onSR[z=b2P*W|Sp.^L5AO5r^QwX.IjSCGw/a<_M+wOIb+cOn^5C;wS}ufT%w1@W#k|?O_d;s';6bX[y;6-RUOX?DUHz5i^/)w(j;/qAf]O)uwUChhn0My}G;s{Ky&|$?B$o%i(P-@ICzlL]X)1xPniOG.imT0UK)3_]elWQR^G=tbVrK+Mzt7a:#SvXZm>fm>S%+ltYg}agv;zc/16=(v%&ew)qQD9gf0rGN<w$@4cl|<{","#6y-R`Z(6vm#BS|MQc^96=^J#0dQaS9MT>M}%g`{SLgh7Xkv>m(oz?UPFHL-$yl(%@<q]I;p~xm?Db2{Ea@hE1wOg#03(JgtjP(n6Ed]Oq4x_K8ys?69wY6Z0juzB%U?=OI<&HE)`U]RRib/f#0hd!sdH=d(%-bg=tMz9qIMvk@@@Eij18M#C&~ogwX)Q}P.#HeCfCR;&o8dIIf,_]=;1y/S?oYwo6`EO{358!`&#.ld=%=]a4Z<0TdleIs?x|AIz*LX/nS~5n|%<%@NK~RoZN!E0,k","#GLyddH[O!u?{)K0R67YGycsb&dXoVMf)l7^]Vy(k@0`7;#{17?@N2:ZeaQ;&!}[*YgqJ$h/7=o`_|ct,O9+JMq*`^G0*M-lH;N?kceK6bF.'.RQj|p'sb/u?d<T83{!~C44*T8j_bQ<aKs~YF)@X$?X!e3qd[}j:@@{ZM~&_Di<A_ybp#6%'eG!k,vEJ!l1V<Q!6--5>)r|=6-o+CV6q,*:Mk@c@fg.Xu|**<):9YCfvsDd`%dB#C={vp}M#x_g1MGRLBg!P_#yY`hs)6BybDC=b+Qo","#ZlWB>5Hxz3!BuK6CbLJxf{5z0XA~'21su#yiJ&6rrVwd==.?;r,dC+{HT9Ga%FtHP4~A~$jgz0ujgdF^O-&^b$RJ3k[S!B2N<w6<k?|+?KWK(T~EiRjw[4K`_T'+YGl#OCMszY2&(9>DYN8$'-8O$(=q_TY;`cq3z)Zd^p!1yW4k7c#AO+P{+EK}669dV8V7'wL{hR@?=e}Pw^TR=>+#/a}t=S.I,@TYeTzf~DiTW,xFAp:SR]Q[KT*A&W6I<*?Ez^J>s7Y)NTd;7HXl(!57(d?q*4]*","#rL;XYqXANI&J)!%'1rL':YdJ09]9{]2p5%s^*/hWOe[SKG<3H$/K3$x;1^=5x?9xOy#G^paY~by5iN^[2:X./H~5Ko)0-D2W:}GGf1rN/ro#e4iqLh81-vfl9}vy!60w&[n&cm%7Bt=XD0tN]br$]~v!'vK)G[Oe-8bX4L5Ux@03V&,XB8SyxJ:iTXUus,3ZZmszvD%1[ktcJ57W>$YTB]a9r8l[hJrLNLlWe]uvyqKK`[/*C)'bD?HO+|a14boXmyQ;w(?7KQTq}]'RXjf6D/W;J)av.","$0)&DevbA.2iU_Hf<T.@S8$fB5F{7E=~9@W2YV7`(wwq?dn9CSgb]'h0fxC01@Qd$ciZE|{p}jhi9(-74Oj5LxmKH&*cqJ0rtx_i$hxT~Bk?Ko;}8|*TD'PeaW8m~x1>Z[*A<TT9$nv[bGs-iye}wkgeKFCiv>^{:Y1d,G3DAJ^br,gP-F?Dm5EYX>F0u>~%=u,sI&&_OfT5L^pD&T0};eby'RF*SrZJ9*(:R0zeHmU%G2`I47#tMQa5=&0a/i}80d7s9Km]ayB$W'~qHmeaqfV,?e74KeZ","$OGjtpKA`vz*8DE`?zqFcOQIPE%MjL/f#3g~Atw4{^;[^y<bW:%yx+,Xg^9~GNob]y5T#DMPPKX>TlH24Vr%feA{&#V5#5G7#v^6W.sbk7TA7GZ:Y}`Bx%b+dnC!gpP<uUv5>5:]<?bw=>SY&J#F^Aj|3bPh@+(bjRkmGfDP8x;,hN~1wxzewb[([FE-x#jc!VXt8heFHo$P|B=]:6kjni0L7&m1dPx+i4%(#06M=pb/WA&Erw,'h!e@J[Xq8|r*Tk9u[Bx%4nvw&M0q<EhgeJ`p@.rhJ>WV","$uDqXvMZcIaE.=MjGG+Fe`uC;Qawx;(</$Z~c+'.Mn-Squvz0^8lS=I8/.@%)F/a#'#I{;4$gk~S$#h'|Q8]zti,ODR%4#^qDW1ol20Yi*c!M3WI5X9p*hG73g~!g{~_]T9eig6iKXv49*'ybz$`8?~A`WH=MQc+F-{0o($j%*Ws{g$*(0x;=jk,]FF?uo0?7Qu*tfQ%guA~KzNW*BWdS`'S`:Lq9w3Y5#N'(00]rPc&#*#Ihob9-aj.On4owf1*dh[1_IvKWVZ|mEkSI'N'@'ivwHv,}c6gs","%D*?W@yqSA$efWzmSw>gn1Fj=(#LS7GS*Y%ort`HjX8!QMCIPC7s-yI$v(X^U?<3SahO0/Mr.,&&@FK,zJ:k%$Ej4MNhX%eV%!/CeyO=n6Jnku;p!~4^XO6Dy#kRwC,f2PBdE)dbB4[67]^J(UTmQWzB$s9znKZ'dPHK,FR2C)'33'VR)ni'v`0meR:@-I|{1:}6JseLy5)+xVGU3!>#(~OJ#Ms3<QDyA=PR=b%Ltb;G_pBL8(&OH7f>Kbr|j5SQ}[?miKiNc(NU3c-xxAuJD8_y=r4jv4av0k","%xtr[Ak{Qc)N3@AO=sBXYXxu/eL}C#MJ4HMBRdm[QTo<q.O8UX6.}&y4G_~IUw>+|@+^IINa$xAm):8~0m:sZlcdXj4kRECju5%A,6m1+i]*?_0Q28FQ7GhjW?qr$$_=23*xNaxA{JaefIP}<EFhmK5}9!dyVlSPYL(_>r;/d:kTT87C175XHOB2v9ieziK+T}9a_|*yqxl_ri$)T-$hL[<iG8r1+GTrET~E??'Q}9AP'.5T|VQX?am@@*/*/=/;6G~M{6Em7,)^O~`N1j[a.Wa>v[1#XZv!ACV","&YG`yc12FXq;/!(2Ni0S2g7]3rTi@j:'f'{~CMA?s1Bzm!-QJRil]12O#[6DU9FB;R0^';z2<.-zY6z0_FG-/k~+k8LXTH1BoZxa]H=g~k{)I!v[m$tx_bDl!x}%CQW%d}T0?dG)qPE/}pnZ'emI5PBAI);C,8J/v9%L,^VhhpO9z`<tmGcA~6@RtJp79'QD}0{kn4uA/A6/;Vt>2t4f<|Tl[vHZi6DmWxs#[uVC2#R+$XQucI2@'Tt+:<R+#oJyZX)2gE!1qz&Fd;,k*k~U;*~a]SNF{iO(`SL:","'F]Mh)|R$YjxV2gS(qW0A7M;+mE$|+nJ>3&Hw!GoWklM/R3?be#-WS*]ain06nx8K$_oGWf0%hyRBI&ISHsQprL1o*5%gl&d%#M2#p.<}XsYweR4QN?13O7g:z9Fk<2Th-8rh-`}OP)`UtEEN:/{$_mv:V2tde{ef-{eC^ptSx[.D%(F0BgR2V6rb*yy#dcl]o$y4C=6Xr{qU~y?42y`6?M4Q[$6p'&3s&W[71`7Skr$z*^(px'%U2i!1I9[c'MH[uOk;&V3*`o|{~R;ek$!.M+{B[{o{$Z>dNFp6","(A~%DO5`36dR#yi-pKMuwylgz$qE_^Oa[Jl|u?Y$w9;7JmtE?/-_`[?DF4+N^*to.;ibmM&mzPv4qMaY=2J>gv9Rm6Fz7-D-g)aKRU%+m,obrltb,8ggJKPXF{z|Jkc9~d[jib$t%r/Qrbe(ZE];.qxRInvZUZHXMTa)JVMkD*6XgH<;[/i2De$FM<HYC@xT%V)~O^#3Mst,38sr/vSP-5q6<FlzNWv5H1Pby*o,ZIyW`d'`MxD^|Wn@S;)~/a},xb)Q&awBp$4U})I$_ZjC-)1f80M$NNXFOTp3;V",")NILV}J<,fm{|b^8;YRO;gR<ss!5jqrsn#@UM0]$-'nyfW)k~'<4=b~E*Z`OJqSosCq%(m|OTP86],9D7.NSM/<p!1].5a5:*<FTHBMjDw5F/P(6rJ/Bs(4YC/aE&UQg5,Yd50ppq(k}|u3oc@H292+$;5Oz:s*R5K-x3.NVf7Wp3@x&|s4aetR1CV`fD$p7@GA8t.DofQ&gE$2nEhoSRBOZ3Yb(6T>h9)a<{eXzwp|G+o&#@@Cn9}~zaM37cem#VHfm~9=d-=ETx/tD8WwPK^bpHawLj4qxMEGihWF","*pVkZo/M#.*/)2[#L]Nxs4?x?+g~lg>t(,QCorU*5?X.xx;H4&>!^*0L(jH;=G8j68fJlO(8[j~aX6+<3.n}7VqL@fKJzUk2$DQC&^nt8nnd!9G!!r?%o{!AEv;khKZA|cAU`7D]cJZ&YU*+FfNQ(``Pl9@yzL~V3oruo+^OW%^/<@k1r4<Eh`HjF-bOCTa0x(O0!b`-sG=wDh>0h?:{(R-v&I*R.)>k@bh9E>rE&,h$@9UYGp?)ODDjKO}7c^fIS`4|Y$Y,,^BLe8,S;pYSVyr=Og@99BUlwCS)'tIN",",MrIu=y|@T@4m8@D8NOc8u(Dp/-6!wv*[h+0;c8^Z~mhI&z@|kMz5|*BYZ>'R)e/`K9~V!^Yd1B3i|Y1W@zk4t,g2%(l%saq/[MVm6W<0e5gA]9`yM-DMV8ltN9>I*EPA!D74d<8m4HV8_zW:Ja1&0j5.F0^m3xpGOe$j%CzdqP7OJp8dvQXk)gHk844)%39j]Ot*(`~,dHM/vaKncl}Hpjb.OE97K>~LZ#bRctV.&vTph3C`!#^&dL<CD3,W~;di.{to4GK&6(y5[Qjel1c,^]z@(u4h&9rbl|l7]q4J",".Jh9Ass+DhP1QglLwRGGb-v<;~$Qu|rTdkAPzK:irmPo<*@OFn{0FrKgfy9AKT0rn~>1wQJhQcs[gWq4|5mpf#;Y!!H5W#c:4j(6b4&+,#@S'bJ']3~@K:X*t]8@%Pd`X,Bhtfz18Fh=D-p6l.ztytR^IDMaF+CV;H@`Bv()F28P%*#E`A.kt@vIRxjShM~mQPg%nnoqntwMG*%u~tTV`+w%>|~E531wu;|NU0dOl#ca02dS;&GQSqA7g!}svMShs2II[R1({&xh6&jTHj*k`i?umv#:G1G!)VeBPZely*","0m{0=9xG{1;gcav>r,nGX!EpCAE&['`r}kS.KsX4^k)8/?fFsc1S#j3+47@nU%VZWvI'nuQiA0Tg>d>1)thz9KzX+4St1Y%~iO,k@)4BV.'?Yow4%N0CJOET7}.67=u0)f.!fQn1xX]v<GMK`R.kkpF()X!'9Ewc0<LV)hZ[~kOL+~L,:##`I#DDaDe}S_V}h`~?B=nvp=p!:#,DOrb~bz;3kNp[VoK@(R3D2em%;Lh]v!fBcMAE:GHgsO/YVx+$u9_(d5FJ_..|{{nmUddgc:wN^hV&},%soS)q)UZ)~c2","3aiJwY#i8!s~LY^iANizu>l/(ywHss!5,$-SHqvf=qplq/<=jLNo#}n|K#Et=|1%)<FKTe^kF4{n:`,A||W}~o!]A3T,&I@22[S_<03'yBvn<+O,=?23AK`N3]vcQ-60oaXrGn|>d^mPKQ_}wX*j+URop.2MSN'Y!#z.<k_QM|%'4dyphF8;E,^=[x339'+p|fO%829M,y_F2,^0z#|As3mvPa(5?/v9S<h&D53BVJ:teEu1u>'OYDLARTe+{vVPmYfL384tJEu~w`5</G+i`T]fw:%c+:=ymU-7jSiq*[L{","70HKkgU6by5:4,f0$nNy8E$r23AnV6/<]}dn,VzcSGf?|?ONMnvBQ,!~[;D^EQgGYAF1v&H*#I<6beWy>wv4GGKQPN7cha2hQGJ@'hQy>r7-CgRzW[-6$L~:Fz;I$@U@@B9F:3{8]ca+kMS<ft[|:4aC|RZ$[-n{VGAgt2U[!0F#ITV]2gC)yd8+Cze]'fpC[5Es`#7TBQ-;DjFpk/wGR.g,(KkRbJs.O~t`|Y2vYSV'B92rV%)*EM/Jqc:TMLf#|5}xGEIxt^[i1m#_5C3:8]ARRB*RO<f^,#1p>U1G/3kEN",";DYEl74o.`>HRyei'%@nN**1v>TF4sy4C&!*_dExh)InVEA/X#IwkA^I;2LV-H7uG+zMGBL:evALtpXUFjr]ERH^s4r2E.L#u;0Wy}fU1w5!d3CSQlW_:w$D@7Qnw*+&'-8)O]*686W:^VWT=6+e1swK?WBT6>Ri6(t,'K3CF1v7j'*2l;I>iO]3xsz9I$6h'7mLAt;'Lx%k<]vwrHe^>K[e{X/[D|&/hJv<@9U)_su0X/@LCa<!E%%l$y+-/zQe}96HY;FO6}EIW2.'R^QZ;BjmGg$qL+:cNYq1`,NL7@sWS6","@Q'tc*;Qjz_B3Km=ytWn*?~&uU(b6sqVTxG5vfUj(v{yk_KAgEyA2^Fz,vq@)GoP|4$*PIkWCco:)*%w-dwc6;>6Jl~EnX4W8^#RP{BhY^S%.{nB1XXEH>luf|-EKBr0<MEk8a7e1]Z9kwDj<*2en#B[]*xytPY}-0T{)R6k7WJZ7BC[~Ua%{A1p3l(T~/Y!GU%gK;dALctQWdWfM[x*7/,J0bCQU%E4d<u.n`aTkfV{BX.yt,?H/K=.N-&^!MbqI7|s8Rgtl&avC#=RM7R4o+xg61b{]eQL>3#t9]^cQ~5[y=N","FjEO)NcQ':odiWn%!tv>9GQu.#'R_a^~M<g-jr'!Nh:x?RK:,5VUjxR%Nuwyom%@`@GdK0b&tK-3Tc02EwhY^.xL^E/1L%R$J$t_5HQ!%O5IL2c>is;s>g2Q[j*EBE%Y4JOQ}gu5#Uus:2_ucV)b'VMzEfb@m6yMh';sdnmw|(`OCoX0,P.6q}H+Cu(Pr83+]}P57KkQkr_@u}$MeVx1/,|mI/fR{JxwoW&;t;>%H]Z{NLN1_1PG*PCYh(R$h;h5((7G<O)y6bY16}rGCKXc>=Q;Ew'};N#Y4K,K)ovVD1eK]D0{","NI|+b5qq)8+i%{`}w9)gVe;b:vFpFvC!R{:YWF2}%AO^HZYyu?H#DUs<Phi&6}gXAii4ScA!f6F0@8o^i#LwjXppE.8>PH_uuGlOZ/AmMd}1`5?%gyMu/7v^@+p}}H-k.pQ3&aYhWK(mCRc.wT3DUSY4o5U:xn4%%t]qIx=m<DCdq=T>fhnlmvOsuBR^7Pek(N_}q?P;8psZ0YOP_tQ45U;8xY5DshCB>h^O0U@.fj=A8e.!?PYxfrrHNSzuz%(}OfYX^#-_6hgoE9ZlUUSK^I`'NG&cO<)HQ[V_sG!<,ze42x2Tk","Wn;hhdbNk$Q1_F>,uspUK]Jgj4?+3#*=@MALQe>}9}Akzyy3{-LsA_u>3<+@`o3za(m1&`R1F}3G}G1]Mm::}B$ic^a786vkFqnIx(BALaBtsbnV3~H?T8*3wx-&7vL/p})'Z!JFkD%1f/C45k+!#fDN+J]wBgsZ3)ZXd%u:+Gl?[qAscDM@*Z_02_,5vQ&lqd4++kTUG_w$=yJp6b$I!C+}FY6W,nC-g=F3m9iJ+%4vE^(MBb74pVH>^v|q~DNh75$+dpjj$6=dn0`fP&'JEdvX!?MG;8?G@DklL?YAF66y};1~Yo","dAJE`{`}K1?XHQu(<M![{<JT{2|Y:^XnB%-S8siWn8l=2=i(+;y#tsQ;i{1aivYa_sF4S.TGIW-z<:ejuq/Y/CIS5^ab$#U#-WaJY~*4kns`(')qly5k7_Lq8)|yh?wo6tdaNeP~Eh:,3Vzh.ZEzC'5ZP7iOF7].?[sSGGJ?)dxe8#va|_oO7Z.WU)<|0Su^E+BR~A-@v-]bO9Q5Zu}uzp0pf=u<8;,*G)X^^QrMU`}JicO3zjmoD{}C_bW1`B,8Tg@c3rB,0<AyWC$vGp<c71LL~[=Y4^8EGU>KwN_BJ9daQPT]<]*","rR7L:j%d+=T'h4Gd|@!50[T-'}&}bR9~tAv@#n.5ii[VPklF3X3`zciq8s,OPo^47RKoy6p[hx+3}sZ8wX]X55oyco<FdY}tQ't.F856QpPDHT_9A7w^9p;V)G@gY{WRs,2*aLRiy,:4la<aj$`BRWoO;4b<pq)ZRmB.MEgg*LU:u,:M*&q:j!pv05s{F>S|PWhv%!d}(}JPv);=f~~VfphYi`jx9pl}L)Vv{Rk!:KY1!dL0^K:T&YxO?$+NEV)uF#$WF-o`j~5dE7SD>84|J_SLE3f%gl?~_ab`<F2e*Ul:.a/uCR^.","#'#bcttIXwNOCYvebn%,eEh<;z)Jfh|*?An34=Sgh,4MW+.RVR1EZsmn)%r(YVm{F|tJSm@R=)LGyU:rv/o+Zu.b$,1y0.[Q~gegZ8,!F<0u4;1Qvj2%a'+|ekW6:2VmTYdLmf-*9]0hJu[>Zw3e0lRo!VaS|xc7+sf;_-iu?T_3F|Md<vdz&{XT<Vqx,L<4Xz,SD7I53T)%Pgr@cnMi')M?z375R0zY1:bC(x[&1f(r=?_S&K[MXh'n/0X,^!Kwl-`*g_qB$S,.&xU9w<-&d=Yxt0%l@8Q!=AA/z:._TFZ,hkz05a,V0Z","#<^D^4{x^T^C5@-PX,Yu.j&li0CV!j~GTv!e}qYS1>o1M^zEb61WMz+R_W=fkfKM`1w1%EEO?1XrFjkTMy=7[n5*.[U^4fC@^9(gJ4r]u[`RJpEt4ASsffb4aj@widV[?QmK#bRqq%`]0Yxmk`*PiH%-iP1i[0S(L7X?by=+.2=eG)t/V=Q%J[@f;.R_P_6gInvI6E3;[+?3,t.(hRj>qv?Ug|x/;7X@$T]ieJ#)0u0P#gx05$RK1hg7-$UY>,qHxGP(PG&tiS9U4H;J0#2M9BYM/$MaJ??t)*<R{ym)LpxpcKv|Y^?okGV","#WJWtI6}Wq-(/mr'|F{`&n=T5h*>a6WTZs!G7#aA886&e=X:kY/KhZ27xL{mru1}AXJU.C8aouNq(w%agHvf7pAuc0u]8R}u|AMgb=aj>VF!uUcoC{.gen&gRSZe5Xceh}8yK%bkk1wD)AV7#LWwdFJ9YE=n6G{*<*gSI(7oAO7L+[H`@|70VnQY4`BJghU#[PSR_`k3L^IY!x{Q@xvw1j$o@DrUTGNb-b&H#6o7NgTo<OM[C6M*52~+M956c;Z5JQP7Rn4FBOld9C*$?0993q_H+)Dn3<dF>4u_OeawY8UahPqWfdz;m<_s","#ydhx<~teMT^HfbhdZ1Z/-'&m;,z}g^f4F:[TVJ<(Q+1#ZNo/AAJ$.1joxfnBnU`^FQgcOs($}Bx{Ag}TqZ|Efc4.!@+_ai#1VDxx(XvJ~MrG#|gCJ>.C?P>N])'ErM6VXQM3tq*6MS?W<E~wf)dG~.{~!08bh)|#H2.5<z+x/tb7zY,})>(OyA0_QW)G%%Xs?qZ<3!)jHbP]r>]Cgji0$AL(<Ppd%d[WkNHnK$b.m=B#}=/!PH0%!4J?2DslW`+r4D07f:NP3KZLhs7Du>}'2IX6'1&XN,vu@+45NcceaJUi'qf=vJVlj5ak","$F-HX0{O|O-.kWtew81jMy}n!gTaOyt~+(QY8ozkejbIL}xwuNn@ba$ATywmHdowcyme4+TS]#NdP.HkrKI$0R%Ng1cQA9Vx+3Zx)u#Ebz4deV]6AoL}'XOtGIY|2G&Kc/78?nx>-.+<HOKF3IX.9H_Fl[eX^}$64fsV:nVJO@Zz4aW(RTv'xr=S`J*ty$#:v`kVjzhX5iTV$_Su:gAqT'@UD3ST6$qk+{dvO=qKZZszBxT[@rT}G~>]q7J~i'l('HR/l9IJ'|`}xC-rT}Ew@=G8xc}j38|ub~uB(CC:r/JgRRAYrv/,f!oP`V","$zj+$BCM2*jrT1QABrlNnsWcw0(:X0q{FcuZC,)nE?HoZ(F0oeglKpE]d>L*pr940_)XZ]NVJm|fy&;dwliS9gyrn'{sP~rb'W],Cj]avBk;m]b'5n:hzb)qc_-Eb-oXBxN7om`q)&cwzHWI;hBARGY*$ZBd{`/HK)mnp!%T{Q->}%5P:31#D.Y'`_yPBQ_Q~Vh4WsU:'1lJ>_1j'jYJYtcu;v;XvVV`F3@/W#V0>7f^{i}is060!=XKcHBw@Pa$?H$~Mk0`o`/pwqNI_S2|kfKZFQ'+j}@e`muR]BY@|F|$`h.o[EP&sK,Xw(:","%_@s,]8CF?@+HToQ#1<VF+vwodQ7))kiSYr=h_qRk/tjw^KWg`$'S~)*~>p@^{D8mM3mF^>&$m49&=Y>X;oo1JLSBBIh-.j*)[[no9T+`bB'A_*%o8DLo`I*($-}TP[8^[gsz:finLeKqa*~.W.WQM:>V8Su5)GC|K8zYf-16{C8Gntunf(o4fmO]'0NKm0;%7[psxeOjWUb[4F.[%N,%OPqOO7Jn3%P<ZbP80)$2ce5(X{cj?2D(?u@rn=`S.,4M#<QNp$ow9cnSMr4WeU+@.UrjLW`S-/M~=k'm'S9<<oWquZ/]x$>Bt.fUa'6","&S68xnqL?jt=nJHgis&*ZgPca&w;XG]}|rH3zR$KtnF&sgG[-dMo2,0)m}PMF`FyX'Cqij<p].>jzz13>c;8}U-(f$w1Y~mO90D3@C8pS(lVZ-PA%6!!:Piwp#Y}2B{F^I>q;h0KXWe:H][9w{tbS8)@YZ[ki:K-QT4,UpvFT;$nO+DIa7_,ZM1k]*%>zr#uZaXaa1p^%D^29G=O(35^RsquX]|{N&`|~4B3l`7$F@/b,Tr*KGA2#tk/*2>pZDUPu}|6~Bqgh@%;F7L}q,p(sgoZUtr.._Iy60os!vB6ptfGNBpoDDut}STrX_chV","']jMB)IG2`RJzjN+$NI8*7iv6/7_1#;Q/9el)br5T.[L+)R{Gk'[,)G7R*hgKgsOOhZrdX'tMRUFqOfP#cM_!-bykP'*Ex;quu,{Taa&$Q[LfC22Kw4XxG*HVe>Llt=J!urpJGh&M1w$14ZX+mVYL@KKiFkF?TFi#m2n:O{K*Ai7[<y}/nT.c%Yv$ZbZre'Dr{.`M[b]HRtI.@B^k]f4$;x{md%`<%};gk4^!7!zxyJ@m`D1gPhDWxL=3ji#qAu2ByJ?K^Um+D=7(,P)Pc,:cr@Gxo,c7AjV0fjh5r?C3xyc,~z%iy>?3up/ar0elF",")$VR<ms!>RSTSH({sVrL)NYtc)j22yPkLZFnEcbZoi`66rE7L@>U19Mq@^fpPM*(gMh!%r$]DJwup.hT32JOP@C|0U#~n|eY:W|%vi4qc'O&N1]~<4>3)h'P-/=_%xZu7O{}&5ufpsW|n1HQ([%}&$#ha',`SOr?KG%fbmqW907>u;rx1zNgeJ;H4bykK8`=)o9jOQkD>&;k{xwc]9N$Ye.J4]s},W$>x77u0iHO#1F@GR|nB3hb3nyuCTW>|g~SPoA{}}~]U2~CCBpH036T4~p@2H$dH~}psxi{CrDTrt)W4zMPQ9^as>I6z>j2JUN","*jfa7K){O/#?SLj[J~pmY;!j8fD0nT;zRvNRuMH(/j`RH%vNq'Ummtuv/x*DRV7|vd%nmM8b-XQgg?Gr2j[r?[17#v]5l$NvkCgObi.NU%XpB]e!F,9j23+hcxbxd^Ck`Z;(P(,KHQPHsD&EZ`wu[sJ[[l!#}Q#~JFI#Pk=-`t,]4-XJe.}:N^M51]j#`cQ-Cs,W'U/F*T1(IaGGgQ`/Vghcw)+(.942(l~zuDRh77K>/Au;Zl}Z{}Ov]>Ki!X)}{);;UL0&!Wn/pdc|:bH._y4N&r]>XJmJcyFP*E$^`^2zw'MHxY~;jm~K?v1%;}uJ",",~Io6vl2IE6IH$kby-Vdt{<`_EPm]NJ*O;bRJI7@iJ7q8gkMv'dNoZ;_aeYl}|1XWfb*+1^Yw)H]E%s:is-)BLq:K1t>a!orjZyEs5P.=XsmGct8axD.t?kDtAh!=g2*N-P@QoBYdu:B1w|;?kEvTNqx2&VU_Y3x**[I+Xkef4x%t3%SV]0>-Krtuv}&AR5*-fIt9RIXAA&?%9EIG{wu6<{6t=4lu&qK^q%m-&<:n,&GaaYNa-n4DD.,5`Kh$LezK'wt>`'6}?A*DSB?82Ni)>>}[O@3ml7Z`O0O'3w`cbI#EirlQ5A8H)&IeJCd^7`X*","/lKkVWzvSP/wNNLi(xHY@aFVHXq~X:$=uYP!>vdYy%=-a7FjV&(WW/}{_Rzu/$_qh*m5sR9MW!ghoUy-/=+Qd1zR`S=/f&PCVO?GGH]f$'fz2Wk[tEt79JduH&l%#ll8iFxE{=.S*~Jt;sa?eMYPl2'Wu_5>X@hi8~5{mW<2F&}-S/+w5d@ZC>/0G0|15n)Fl~CAi3>KbgXLy+A;N5<two1jtd8/Kk/NjtskL:~ts7ZmKYzopbX[R3)EctA1PVx,>)F!YBv#W)nfl$,+^Ip<is2l'88y>s.['uD}6yriZ-Kv02qT@sRJ!8!)K,$6/Yijc2","3C!Q^8llMl?e1E^^3y2,g|x~K#X-yP?'w&6n-OZy{=)v;jnYJI1jQ2BXT|)hXAg<~P4,z%<ep(38]6n;J?!))Y*Rn>QP/M~,#%4u(|/et.8?*mHRZF>G)&AmjFtqcq&Mxm:?Kr*bS+g%QsWzaGu$@S~0Sp<,j)&Y|N[}QTO`h/<LeMd51ztXnzhr.X[c1:+e(uT@UTl@Q%!iihiZOZ4vXG-|XYFbD!``i_nB9?+xmZ~wO$A[=gkE>7-2>LPg(E6*5vfm5W#hY?;E7SYXg%cKx8KVmfUNBz]MJ<}bi;I]*A|'=Z?:9y6qUIqHxWfZ9Bq~?,{","7tfhFhN+In9@4y;uJX.Vz.^Y|HDc>_q1[n)N3v%FY(,Q66SPEOE'eN|8I%7{/%IaIVTX$Oe*IJ=i5}t01MK<7P_&VJ#!^~.h[QzE:X7.-ZMI([[*B7LUwNk=c$FLC|{Azoik.g;:nIv![_;#``chZNlWcVR:>y[)]N.p$[1%=X'WPd}aD~l:$N)Q1qz%;'dfKz-Z^-Ca0}6J9x/per{@X/lf/WCi_f,$w587~5u#Fg|8CVz;urpg0~Sp{!DPOppRLAj~~J+4:le?oVyif~fK]hm/oywcNih>7sO2q7@YEy,[[O2'sB]JdMT&:F9|+gJp/y~N","=`*2pE~jAfzi:;'$9!8`/c|=v8Y`+p2k.Ic[T#D<zEcXyUVIq;%A;P?R^vi~x~=@)|;Wc`|^g@B#F67,+-|L[8MrUv#'k[w4^q'SF%%.'|e<8exT7}~#/$e)64<F3f>ol8Bb4((gt{4zGX$rx;w[|oCM+VgzPbr5;31s(07,}e6z>`*2iqtjRnQjIvTjTr}74zZ$Jtcg1hX~7Nn`*]SV:*V_'b'PNpS{f<iXQ$:ky]rj[L`y>a$B+oq+h$Y%$Fq{<4JUzd:=ktj]]Dg/v>Z;jwL5-SN.rD><`v8Nu}0Q>a@H=@.IGd,gjQGqAxrzyA|+uLgO6","E&(aY$GfJIc;YVnE'4Yx1sTq[q$oJ[Z9P?X:I:,HWDQNR^&JBhRe6O~@Glt]?f`G[yG]{2qWTQy,lcAQ+,Dw:cdS_&c?X`DolV!!GDQ;QxY[mt}yqy+b/{4F;c0$@aiN*#x<fMsfq&uo'!b]eKt^.~vhT9(1EFeSWW-PtCL5.=.DxV/@|Rds7bQafBvVjqDX4~2'Enj#pl$J-WNF8;P-WSl_(_I,zf`Tm'yhThTy*v7;eg:mfU$=-RK/<m]ZD!=-o]FXk|b1qB)KO&;lMt0zi~gO^TZ~'$B2`j%97sWBVPjR@l>Ng~|`^W!59#vzxibkG[+i~N","NOYA]|Zy%[E9w*'SQD[e9bd[R8dKhs'YlZQ,boXf^lnx(>$[]SW`f9i9Mt>N?QqI8m4byK0NHF<j/K*AUc;uXBX$~{9C;L)<hjg#{.haglq{'mX*J[_T>Dts5x8TRU!Kr2kpsy<meuZJ<Y]YIbU7&baz)l*bPw!G9TYO5hoN(>MO~/6UCpF?S,&VZCG$]R#Vj7TTfUMga<@aXC[<G<gp;?+4TZi`:eD1VJ_ixO,~fW1W0+{A$Ta~(C?tcLS-<H^_b-iZ.1QP@0g#H;BAUX4aI@%eWRgKYmXeL09X)&Rjj}%.=%HYWz$#5~8a:OGd(]zXxD|mz${","Z[W;%Mkpe%k,g39A;OP<:V1ax}G?lf*5A0=G!gRXEE'0xBL#/+$i#`t:$2%Pn7p9s+z>>(TT}t(s+*<BBE@ZA>g:@)C812ZwHdr}(ZAb+7/HVI0E#bDK540?k<cUKEj/07puI&mY@XhY:p7|2)jNG1>adFmtRD_&45m(ogqz#42}4iW5=g!9:AgSLTdG$P0;3rSAFZD%s[N_*ZgU=m|calSAJ$wRm-opooIU-%]S,Cj@Jl04@oQn83fn'YtEIm)(-Ap#oMZ6{?Z#:t$YbUz{wcqyCMuMCO^cTR`C-R:}:'WdNp-RA1r~'ax#VMzM1Q=Qgj#.W,}k","k6|k`H$MH32,G?mD+3X4kl_qi|a-+o3:&Xs.:,h#_^w1WjhF`ylHS1x-ZJY.}@['v7~Q#VJWm6Y-G~TLe&fcxP3NIgn*BU7{4TbOz#[Sj'cVy5p/K*N@H?-K%@r/9sF6bR`BZcOF=yX?a#d(UH}Kw*x!Ds-sDk6~A?rEwWiCSF#EBrKwE]B!VCeHS[<LJv*p+Z<]%N`G-!!&-1E[Zx.':/43=0k8ms<?cg?'2j+30+ytbKVC|-Hz3.5,4A]4rbvkVwCrxYh2M}:+Cx4rE)M{AXX}`=kHZr8'zdiIy<mt9uhFIeQ/X'jy?]`)dV{FXz!bkP3vpg#bo","#!A7RqIK|K%Ji3sYP[kUMnn1I<'jh},;8<sW(Oxvbs|5QA>+hKp$52:AOH/tqA}@[rLcEH<1qP[R}3-kHS*.ALL0n)!^L<$nuPuD2?m#5n2wYZfjyYPR$@'gePjn#3SD`^{Ywjmb.IRaf6o}*U~nT0$t+e,T:yS0i]qG0OBz(k(dW]U7`IwofxFUvv,9SU9](VL>x|QCc>jWM^?le3C,.YOb]t}AFuFCntN3g}/7v%1wb?~Cdnr3!F'|%v?A|+h%i;I+f7Fz~EH#$Y#ykMTKfnsGk$%`d-/]++jURI*e<))dyckGC}SuEyF]4wjqtZ&N>Nd$3hO|(]*","#<?J53IY~r2]](I`bq|1pA3rS<Nd@H@c(:M-k]>{xe^Mo[uIgh?4BDd_>7G?$u^aqLTBvr~YVn.JXc>>uO]OyAbk;_*KzSfsg7KQ:_8r6uOvOy#bW.16,&[wN|>s9r'sry%20S6D8yj#Mt!8#Y40?K;<rW.N,AMgxt-j(eB^{=@_z9[o8l&|5rq/Hm|iB(r52~lAA[RAeaq9x)]d^vP1^l}p%#p7Ohf)Vy{#>!Jjqr]Cm>+?3bnO+BEESMj';S)>DyTz{JdR!zc[$oLQ([MrH0[i:!<n@s(^#$#g,(@d>OPQ7`7@riNWzvSPs0uaA<ws_4z|QTU4+]E.","#^zp}Y3dmNyNFYdW}N#O'impD9tcs[w,NvSkyDh*OOjDlx3XUF`5JHeJlP/u%i<I*4,XlN0$7QR-M*5kDrZphsk*GLQm_Y<a.Q*NzqR+?A-WEq_'z`55s@wiN%%kXC*l+rfK}K;v[]Rat>;4uzN'>3xqJ.Cv}P4e$%8CTqvyLLdF4}K)498fmgp/NAmvfiZSaKvh'j#8x&IU#K[^hQ7a`,++yDQr7XKPl9?^ksbs>nKI0O|_]mLuA`I{G7e7^%fKPRw,|fUtfun[,Npy$ET&@FQgtt,ZvAZ9ulk*ALI~LU;Dva7E;H|/Zy;).-{vFoWX%v*0V,=zoO]XZ","$-XZIbQk5EX%|'=^06g-UWQQ,UrX(%21VJ2uZM7p*CV~c*I-mN<&'{7-$:^$xzq4,mE</IY-)H9SqF}GnVo<BhW8J81?Ld9Ztx~T_5nb7TuR6lT=S@TZ[VAa#D..hRD{HP,>Hr?wi`MTyx$>D|h?Jh2_xy,p7)c/~o:h.Gr)@(Y$1X?QGa1_-i-*#HRCk5v.T)oKa?uN-Q<$UXQu`Cmhh9[=+'P|3(a2*V;9l;9JB.{,![IPR4HP^[tBOO7$oqiO)d2%XTFIX5}RxZDOaOj3qOB~1iklMo_:#)?]ENgYwb(9g'W,d!y<*8y{XWshGQsLQJg$R&hhn^OJ7V","$g@e{!IdK@kp}qbO6V(i!)ry:O]p~*^dI8[#2]kuwDX8fhf?w6U9n1FH:P(NO/$po<PAuvQ-r|=kkYmSn4FS^<?lc:iZ-N[9.H*bj6X{G'xo>S6Tdn,`H4n!.7W6E3%EohZEI2Spv.25LF74-.Iq/W(]'G)pe&~,Z-b'@rh%J@1%jgj'S$i#p.c!(0!/(qhH(Z|B,QMH8oEb7R9![B~ZT7FOyw4]-RBXhS/I-G]uv(qvo(4q}|nme#}lg{u(ZsLi2vm$Lz-Ie5_:lFcKehJpPJE,0!y^-SU8mrsdz&ej(H^81W*Q7ngFT>`sh03D-T%|NXlM43c|e_.I.Vs","%T:di!5|Uw.6QR[h,i>_D^:<5)e9PM_}5sPW>;INAI]-YY1f(QhgBS_!H-`KIfHC29G}bt*!)x,>{%$-$a[btyf8!YRzQ?ud6mRAJ(=yXs=c#9c411vOp(=z$J~'7mcF^[mR*ri9w~P4?xfk&+dhO>asDcb'Y%<>;%O34v*l4Jo75aAP=d)*J0_LOZOpwIPsc}6'%)PnN(-9XR@/,zMkIT-,m;.J8z~D$%tMOXjIhQhEkXa.mRJacYEG&u:r7Z+Mj[|Ov-#_bTb,!VrCtL6nJid.dR/4)jV|]1jE6!QDXH03|ts.6(x2|(@%(R}yin)i_yOHI]5G)_]>yN4k","&Xn$=~2(Ld<BhF'FQ//G#m$z'y!&^3@W14O-CNYoMA|hjaIl%y^.,LJ=cZ,Q.qsUl?D?{|w#pZ:|z+4ybgD_w9o3+|]>?RX1(7&TaJ1}Yc#SzC_T+a|?JIgt4I]K,wz!&}!]oN29FwV/Q5cB^_!/)Yr+%duKZr@,lNv%yzRSApr5&_D]xUX+y3hO5UvUue=}D<u9PH:MD,|xilIHiCrT@^we:rzr~jrYyc`CC<$],KQ~|Z|H:c@t`b/x?0>i22O+_5W*olB!e[1{egP3%$Si5oB-/0D1lXhe5m:L+uXF:o;@$8MfG7UP=[c{8TB>N:wtXTqb*['vrM(<7+C|V","'|0p]1w;Ulg{*[aHODXhz3pP*(h*F'p@nwvO/j]<1'7)>cXK%1-amh<Ulc=kg3eg,p`g]T[~w8Uh#by{yGJ.d1P+>?0'0Ty7MpQTTy*oVk0}M71P93-hfLzz&uRZ22b{F7&BK*C|qag]tUaiEE4mPr5&5A}Nzc_p9SKSFvXGwxV>&rwSj1G3wL)v:&=mHkaFyyO0n&fMRUwSMMl(U^92ngs8/b%fpj!padysC?/w{W7Wt^Ki&q{(&r:TE((Mt0t#BPa%@V<8n*0'JN$v[(YGMF2X3WlC{+K9Y+)_mH,p-#Gz^5^JYN^x`<01lt9x@50?{e?hI))K*mlul*/0a:",")iq}8qDHN>vwf)K(,P@!Js,5^kt**9k|IBPd^)5;}lk&}'?JD=OU1S%+9a!f*S0}jWg0ol+f%^BYl*t#+5^iK'oK:Abh9HXNt3tf`HK<EaA$2C>k4fgQphn]RO6WQ5^gReq=BVYmVAo>4jPL`.Yc](0rp&Kr#RT0CAPBF^59B7Z%&i{t|#'}&Y>.1qDYoNXLyPCHWwT'RuEe2TR*C&70-{}=`}KGo'y_c%g[2dLD]{8(c38A2Dfe|3=2ZU3T&njF0iy']Va{itp5)QPF|?pT=xii`KCH/byzw^5#BDv(jPR)~``7y1Y1FNDzo5C%{CT.TVMTdi|`d(~dr2Q#U;6",",.[pR2,1ELu;PQDOMsIk5]HT*/J/TOePoDBLpx$Ck_`~dU1$+h9tL2,Jow%cpnP.J*$!'},~M_3-H,2OT5qO}|kuyMEW&$1oX~SD5Ah/l(T[*N51F=Z4+?^R~}Y`M*{,fhu]XF:1ZN;2Kd&@(kfRtkNctc^.{e6zin&V|+20BU5-D-=f<z1J^O=[kx0CXVtv!W4^#3~QLrz@$qay2-teJ0Y0uLg]=+cP}AJAJ/S-sv&P@|@I2&43cDME^D2@r~SedB<vbCT$D-*%OTq-^<BfMMpV^60L[.Pbpcq[d(1wiJB{_u1+/RvojM]4_@=8#ZZut~$qHi?2_?PfGbEG,>7V","/9K>Ec@rcr:B-Sm5n1Az~*q[-*qgG`I1>si8BQvvCWQ8m%uR!QF~V<^K^'(:nH*@JAn^e0L[f6_Jz#2^n{,:>Us3m)yoq1^|tw}FwJl+xl>ZW{tK4GQ?YDQ&h5ea_PJ2Dof+wUu5Eqy[biJx<no.Ccs`%v.FZ)IRT$Bc.?k0V3V6'N2LWx.373MzR,gM+*!QoJat;9zxhb&k;PCcL2uWTeDx/B.yOk/jk]WhjQ5SH=`<aZ?MI8`?1_;nq;w=trV$LIY+t^)+g0g8wSywcURnAzp%v7.B$FAWk)BThW?F2#RkeFemBSaD<)}B@I7@md6+6_:b;64JysKK:X!tl0B#F","3D#pRZ:<>Fu'e!*Z`-nVw^Aukh[q{b;#>RtG|I7Y'gvIK_F`+}XQZ7$H5]Va$^Z#EMFxsljfj~i)@!~xXbHAEubsD>1|1Forb60Y7JLT8VeUr%})?HF9h`~J@B7h#UW+>nO[eep;l9!pFr(f}HV{>J{VPsCU9Yfe&UmqvtAVY9G9czio`H:w#~![#V~do]JsVjTUhB3`wyRRmV~('T<#Da`xQ)<{*BTw]%[cWWjD/-Ka?~m{<<I]Qf4P'Hbr1bm[;3jX`KVvbE'Z|^4S,J(*aV&.:;Zn/M*9u_$?hvX$)bvY(2[S34J-eh&`>y@wd}*kHn*Qr6.[7nL}Af=y7O,^bN","8mhZV4J-XR1/{ftDN4Lf3+K^RT(3(`].gu>*#/0Na2]t:y|+h`GQkxzC~:W6R!QLU<;]sL3zcoW1UJCTohnl4%7MfGB{?'dQL/+lp]ik$_DMGB[jIm}w4Oi1;m-Y}yQ&CXA~)_wi5z]=ah$,*|Txv]~!4H!w_&E-ot>CP35@Q,3(|[qvmH`;Ik>;*./hCdXNwQv%,hLefb$;p/yTV3^^<8y]jqkI)}<:x89C*bMVtZ5x-D,^nlm`KcS3B/0U;<8!~vC<9]]2_FPgGVA4_17.IrfTF:Y<6$xi*.`|9iY]/LD<Y93|@0WNTy7'<^zf2JS~1&;]WVHo(y$2smPH1qw)5XJ","@$O1/kxR&oD8CG+78WST0DRU6BQ<+-#KL>6@ZV(_zIKNb0p+r^xbvDe+^w^7SG2gG+cKRx$zGChJ%;Z!*6J5$(Ra#=1$k2UgM.@C*M1Md+W:pt_XFA(s:S<_hrmK]J*gmn#<@hSLNzgRR!:aYb{Ww/uC+$%/<KCVVcWns,IV)w8har|%MJPX^=n|O-f|Y0j_TPqgJsEb|6A0vW^C)/DWDTe|}w(sO_@'Lw:uq9z}=jiR))*O:o>gOK-&cA4bP^F[DE%Vb]^)sp'm,2p22+ZCO!:[$Yvfm8W$c+z^sB'N8V+/lfg0zX{d;Ib3nmj{Hyzy/UF$BnupwH^s[,_<S|B;KG8*","IZ/d/</NOmb$x;tc%HR|tpLqxU=N6?~.^QnLvw7J1>xZ|[W<@_!@:9`/r;3wX*&`TI08tZ7~@o/F;1aBwY2<<9fqifXM@%I_B|{>0L,%=rj^J#[>U,c:=7>o6`?hFw5p*M#|FuP{IdA,:oc=PzodU/z~w}B+J;wy(C87zk?ddV3@vq.wSV*X+cV*Qnfys5O8,FL+Ugi&;Ay'8I(#6heftIO'dj:4|kVnZEn6eB78La~?VW=LRdq[=kxESa?_iO:wp9<aBL5AQ~:wSs'#a$9{pp@oq3D<=-P~YxdV=^{|@4`]Ct5AheXrkJN0f&x(0$.7|Cz__K$(p^{X^l@RL)hx?kQc2","VCi;F4*}!9i#Q!z2tZh4n+Q'B3EY3@USxf0JGXJhSm4]B=Kb-r+k:'BUy`Hahl=GP'U`L**~A)iNqvvcl*rcwHL~l3Nv#S+_Z#XLA)l/a!6KYunvcAGO.^`Fut.Yx`2E$s5g?C)v$JVvr/GFC`mpOmx#3!}57zp1I6AJ[1%WOogI)P~13_n)<UKdXcnoFn'Rd8&=j4=I5a3nvoN9LoVI3vE:UyLcP(hWWJ+sk/MiLL1Zbt]:V=P1<deL}A.fM}alkcg)t!o%qJylt7+0-&I?zq1TMXu0{,EzK5)j'Y,<hsa'vt=#a>*e6^/6Liq}6+@%'#K&sGowCWu66#Z,^ws)S?ZZi{","hE?Mdq,e!+FZ^FOEnx54'3Ok;<!(u%QH~QV^q!5t4>{{]wd#.gYc|9ZQ0(JF6Kwi_tQl5sn^)xd@XNv#Ds!j'X$2Cj4>gOXiMq=-i;]Tq3+$UR_i$,D;x%53qN-`ZUU~MK0i3dV6UMLW7q{Rav~5fc9ZE[wJh:v7$.HMpcMd<@G){O2;5DZ}<*k]h~@;*@::&>M1*&xGm..W3v5P[R_k#jiY]6rZKx4.LiK,A{2qx.1)=|1}>=uCc;iw}S_RVDjQA!?[se5uRbhS%OD!}Y2vN2XJT8_P']#$lM]dq.)(#`/HlByb79k=ZL^-vH2}u*i~|egVZ2ipL4YE1xIn9)q=qO{X+YN","#!.-0p(g8}z|kNr'x.pP}OQb9r:oVoAwY$(te'mG#0cl}O/;KRg^Ei$4TR+v:RxIfEnB<$*.iac8]_aKxI+['kMtb3#BK+4OrV]lrZb*3cdop@7e=}+9d#B)s5dLx#_>Er~t$8_D.~8cY+36;eA0;q9/g=ZxrqrqjwWHsmImu_mV3(|*11Z6iYi_Yg&E$r$?^ep1#Gt+$RgIq3U;z^i{6lX.oNHs%0bik~'?tJ%[[{[-jESg=:;k=9Gm4bpQ$z=fQ8YF:'ZKP*.xMK`G1$8+3~`5tv#kNE$VPuFNdJ->t701Y!!$6#I}3t^P^,j&8(24c{:5WRtW+D9!DjX+WM,l,rgx.%rK6","#@Y[_pgp>8hl!_8&I^Hr1c61`oYZyfltUCE!,W|OtCk(xIB+UPXiFx`y!~bPiIK^aLH3qs]/=Bzd#|R([_?A&o4sw4/q%B,:1LN!A;bf^TT>ZBefH6:-onGa{M,;sXEkQ+POR1({9H.7LRLBL|(wad6ioG^B/oY.,ZIilztb+RL7@y4K!uKTr>y>F36'b<pPcJ_7]8D=AeLbD<%1|a!+Z`c?i3zI[LV?Or_o$kW*(OB~*_U?}[;L*Z.r5eY_WFAJc[JuJ1?;cAB:qUQb.g-=-i{*V+hOP-Y@JF%ZYw<kg~Y=+#3$z@#[_~wn0ya}lK:k_q{5mA'3tNW6fj97_ngEUn8pUr|YbN","#jQ*,]7ea17g{W5f&9W6conksw7+I_u~Yr8~yDyJ9jA32Pf(6.6fx]E;@Q56(Fbf:F8rk+h6eV-.8{Xf^krkQWQGaq>ho'+3Q$ArW63v?6Nt%`+o_vz)'iy=4ZE~MogN(yT'zG2x?BJU?^wwJx,2tbadr|w@B^Fukj/?5DL-5XbToa`D0{nfw!_dcfI'6G<6WZ9Km?+RW4VgsVT]{p.:#m}!~j(KVjQbz!<D-5VDs2/+K#`o;Lwn%U!%hNe?q+rnze.D)U+e/u>u,:^-m/~?~@&YG+>0)bc-x(sLiCohQr?F7sWQ$aozJO;AZL5U=Y#W&R.tXx<lr>Z)P_~<$m*T77dV,C&~bu{","$DSmthwzpd;|Y!0N@EwR|<'Gk|:s-kG9K<@p;d^px7&9TXm<N<Jt`Vata=2hbOm=T1?){6xp8[DXvfW^_l+cAb(rt>2-nYrGwjuXy07.+iY?%eC-5x~[aMd0{]VAXl4Bt(y;ntAzr4o6R<xxTIL.,jR9NocyO%xsMR6a>$VI)Nul:cf%<BGZQ0/#Ut}nWyr;QVZ'&@]L5=Y|t!cJXHBCX0`_w&u$`5Iii6.g3%}fWWAp@4R&EVN&ksXYM]s3#P'~g2|AH/F-W.=DzIK1q0Xm$wO6S<>[Z59PNPzB6<cSBpt),4t>kqZk`(7._xvQFQp)ryD&vPW$U^,CDFk4n|;E):Us$s<Gy|Hk","%2e[;,B|/Eu/ZE4lNtcjC.R6.fe@z5%2PN<,:D:K)O5vAa,YxM#q{S}A:<DOs/uLs8DB&D^Sx>vxNSM-l.fH,S[lS):qrPY3lb!,g`l'A~Syu|(|0?pjXEY[wZXIOM$;zs??,~g]v0gR~Do3]>6d.4{c($[<Qv^Wiv![/,xru^c=lBuvpq:lbN:0(Or4[|i=pxfT&V:-N<YbgC)M4d*gNI3,!.:IIaA.E=WOUqxwXC,kboWnpgZLN_e9!&g-IP6K)Es3w]Z`V@Y,;>:j>?/d1huGG(aI|?Jc.o6Y#/<tl0zy>_+aJoxiU8%qIPkwPSTmjWt.ngDEk4U8GjT1~Z5hmHX8>wHskb1jo"}; static String chars = "!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~"; static int N = 400; static long mod ; public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  long b = chars.length();  int n = sc.nextInt(); mod = sc.nextLong(); if ( (n > 110)) { char[] s = vals[(n - 111)].toCharArray();  long res = 0; for ( char c :s) {res *= b; res += chars.indexOf(c); res %= mod; }System.out.println(res); } else {c = new long[(N + 1)][(N + 1)]; c[0][0] = 1; for ( int i = 0;(i < n);i++) {c[i][0] = 1; for ( int j = 1;(j <= i);j++) {c[i][j] = ((c[(i - 1)][j] + c[(i - 1)][(j - 1)]) % mod); }}dpcl = new long[(N + 1)][(N + 1)]; dpop = new long[(N + 1)][(N + 1)]; for ( int i = 0;(i <= N);i++) {for ( int j = 0;(j <= N);j++) {dpcl[i][j] = -1; dpop[i][j] = -1; }} long res = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= (n - 1));j++) {for ( int a = 0;(a <= j);a++) { long leftv = dpop(i,a);  long rightv = dpop(((n - i) - 1),(j - a));  long curr = ((leftv * rightv) % mod);  long fac = c[j][a];  long v = ((curr * fac) % mod); res = ((res + v) % mod); }}}System.out.println(res); }} static long[][] c ,dpcl ,dpop ; static long dpcl( int n, int k){ if ( (dpcl[n][k] >= 0)) return dpcl[n][k]; if ( ((n == 0) || (n == 1))) {if ( (k == 0)) {return dpcl[n][k] = 1;} else {return dpcl[n][k] = 0;}} if ( (k == 0)) {return dpcl[n][k] = 0;} long res = 0; for ( int i = 0;(i < n);i++) {for ( int a = 0;(a <= (k - 1));a++) { long leftv = dpcl(i,a);  long rightv = dpcl(((n - i) - 1),((k - 1) - a));  long curr = ((leftv * rightv) % mod);  long fac = c[(k - 1)][a];  long v = ((curr * fac) % mod); res = ((res + v) % mod); }}return dpcl[n][k] = res;} static long dpop( int n, int k){ if ( (dpop[n][k] >= 0)) return dpop[n][k]; if ( (n == 0)) {if ( (k == 0)) {return dpop[n][k] = 1;} else {return dpop[n][k] = 0;}} if ( (k == 0)) {return dpop[n][k] = 0;} long res = 0; for ( int i = 0;(i < n);i++) {for ( int a = 0;(a <= (k - 1));a++) { long leftv = dpcl(i,a);  long rightv = dpop(((n - i) - 1),((k - 1) - a));  long curr = ((leftv * rightv) % mod);  long fac = c[(k - 1)][a];  long v = ((curr * fac) % mod); res = ((res + v) % mod); }}return dpop[n][k] = res;} }
6	public class CF8C{ FastScanner in ; PrintWriter out ; int[] x ,y ; int[] av ; int[][] d = new int[25][25]; int dist( int v, int u){ if ( (u == v)) return 0; return ((d[v][u] == 0)?(d[v][u] = d[u][v] = (((x[v] - x[u]) * (x[v] - x[u])) + ((y[v] - y[u]) * (y[v] - y[u])))):d[v][u]);} void add( int x){ av[++av[0]] = x; } int size(){ return av[0];} int get( int i){ return av[(i + 1)];} int N = 24; int[] dp = new int[(1 << N)]; int[] dpFrom = new int[(1 << N)]; void solve(){ int x1 = in.nextInt();  int y1 = in.nextInt();  int n = in.nextInt(); x = new int[(n + 1)]; y = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {x[i] = in.nextInt(); y[i] = in.nextInt(); }x[0] = x1; y[0] = y1; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; av = new int[(n + 1)]; for ( int i = 0;(i <= n);i++) for ( int j = 0;(j <= n);j++) dist(i,j); for ( int st = 0;(st < (1 << n));st++) {if ( (dp[st] == Integer.MAX_VALUE)) continue; av[0] = 0; for ( int i = 0;(i < n);i++) if ( ((st & (1 << i)) == 0)) add(i); if ( (av[0] == 0)) continue; for ( int i = 0;(i < 1);i++) for ( int j = (i + 1);(j < av[0]);j++) { int val = (((dp[st] + d[(get(i) + 1)][0]) + d[(get(j) + 1)][0]) + d[(get(i) + 1)][(get(j) + 1)]); if ( (dp[((st | (1 << get(i))) | (1 << get(j)))] > val)) {dp[((st | (1 << get(i))) | (1 << get(j)))] = val; dpFrom[((st | (1 << get(i))) | (1 << get(j)))] = st; } }for ( int i = 0;(i < 1);i++) { int val = (dp[st] + (d[(get(i) + 1)][0] * 2)); if ( (dp[(st | (1 << get(i)))] > val)) {dp[(st | (1 << get(i)))] = val; dpFrom[(st | (1 << get(i)))] = st; } }}out.println(dp[((1 << n) - 1)]); int nowSt = ((1 << n) - 1);  ArrayList<Integer> ans = new ArrayList<Integer>(); ans.add(0); while((nowSt != 0)){ int newSt = dpFrom[nowSt]; for ( int i = 0;(i < n);i++) if ( (((1 << i) & nowSt) == (1 << i))) if ( (((1 << i) & newSt) == 0)) ans.add((i + 1));  ans.add(0); nowSt = newSt; }for ( int i = (ans.size() - 1);(i >= 0);i--) out.print((ans.get(i) + " ")); } void runIO(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } class FastScanner{ BufferedReader br ; 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)); } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] args){ new CF8C().runIO(); } }
2	public class Main{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong(),k = scan.nextLong(); if ( (n > ((((k - 2) * (k - 1)) / 2) + k))) {System.out.println("-1"); } else if ( (n == 1)) {System.out.println("0"); } else if ( ((n <= k) && (n > 1))) {System.out.println("1"); } else {n -= k; long start = (k - 2);  long x ;  long left = 1,right = (k - 2); while((left <= right)){x = ((left + right) / 2); if ( (n > cumSum(x,start))) {left = (x + 1); } else if ( (n < cumSum((x - 1),start))) {right = (x - 1); } else {System.out.println((1 + x)); break;}}}} public static long cumSum( long x, long start){ return ((x * (((2 * start) + 1) - x)) / 2);} }
0	public class p343A{ static long n = 0; static void resistance( long a, long b){ n += (a / b); a %= b; if ( (a != 0)) resistance(b,a); } public static void main( String[] args){ Scanner in = new Scanner(System.in);  long a = in.nextLong();  long b = in.nextLong(); resistance(a,b); System.out.println(n); } }
0	public class A{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long n = input.nextLong(); 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());} }
4	public class Main{ static FastReader sc = new FastReader(); static long dp[][][] ; static int mod = 1000000007; public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out);  int ttt = 1; outer:while((ttt-- > 0)){ int n = i();  int m = i();  int k = i();  int A[][] = input(n,(m - 1));  int B[][] = input((n - 1),m); dp = new long[(n + 1)][(m + 1)][(k + 1)]; for ( int ii = 0;(ii < n);ii++) {for ( int jj = 0;(jj < m);jj++) {Arrays.fill(dp[ii][jj],-1); }}if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print("-1 "); }System.out.println(); }} else {go(A,B,0,0,(k / 2),n,m); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print(((dp[i][j][(k / 2)] * 2) + " ")); }System.out.println(); }}}out.close(); } static long go( int[][] A, int[][] B, int i, int j, int k, int l, int p){ if ( (k == 0)) return 0; if ( ((i >= l) || (j >= p))) return Integer.MAX_VALUE; if ( (dp[i][j][k] != -1)) return dp[i][j][k]; long op1 = Long.MAX_VALUE; if ( ((i + 1) < l)) op1 = Math.min(op1,(go(A,B,(i + 1),j,(k - 1),l,p) + B[i][j])); if ( ((i - 1) >= 0)) op1 = Math.min(op1,(go(A,B,(i - 1),j,(k - 1),l,p) + B[(i - 1)][j])); if ( ((j + 1) < p)) op1 = Math.min(op1,(go(A,B,i,(j + 1),(k - 1),l,p) + A[i][j])); if ( ((j - 1) >= 0)) op1 = Math.min(op1,(go(A,B,i,(j - 1),(k - 1),l,p) + A[i][(j - 1)])); go(A,B,(i + 1),j,k,l,p); go(A,B,i,(j + 1),k,l,p); return dp[i][j][k] = op1;} static int[] input( int n){ int A[] = new int[n]; for ( int i = 0;(i < n);i++) {A[i] = sc.nextInt(); }return A;} static void reverse( long[] A){ int n = A.length;  long B[] = new long[n]; for ( int i = 0;(i < n);i++) {B[i] = A[((n - i) - 1)]; }for ( int i = 0;(i < n);i++) A[i] = B[i]; } static void reverse( int[] A){ int n = A.length;  int B[] = new int[n]; for ( int i = 0;(i < n);i++) {B[i] = A[((n - i) - 1)]; }for ( int i = 0;(i < n);i++) A[i] = B[i]; } static void input( int[] A, int[] B){ for ( int i = 0;(i < A.length);i++) {A[i] = sc.nextInt(); B[i] = sc.nextInt(); }} static int[][] input( int n, int m){ int A[][] = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {A[i][j] = i(); }}return A;} static int max( int[] A){ int max = Integer.MIN_VALUE; for ( int i = 0;(i < A.length);i++) {max = Math.max(max,A[i]); }return max;} static int min( int[] A){ int min = Integer.MAX_VALUE; for ( int i = 0;(i < A.length);i++) {min = Math.min(min,A[i]); }return min;} static long max( long[] A){ long max = Long.MIN_VALUE; for ( int i = 0;(i < A.length);i++) {max = Math.max(max,A[i]); }return max;} static long min( long[] A){ long min = Long.MAX_VALUE; for ( int i = 0;(i < A.length);i++) {min = Math.min(min,A[i]); }return min;} static void print( int[] A){ for ( int i :A) {System.out.print((i + " ")); }System.out.println(); } static void print( long[] A){ for ( long i :A) {System.out.print((i + " ")); }System.out.println(); } static String reverse( String s){ StringBuffer p = new StringBuffer(s); p.reverse(); return p.toString();} static int i(){ return sc.nextInt();} static String s(){ return sc.next();} static void sort( int[] A){ int n = A.length;  Random rnd = new Random(); for ( int i = 0;(i < n);++i) { int tmp = A[i];  int randomPos = (i + rnd.nextInt((n - i))); A[i] = A[randomPos]; A[randomPos] = tmp; }Arrays.sort(A); } static void sort( long[] A){ int n = A.length;  Random rnd = new Random(); for ( int i = 0;(i < n);++i) { long tmp = A[i];  int randomPos = (i + rnd.nextInt((n - i))); A[i] = A[randomPos]; A[randomPos] = tmp; }Arrays.sort(A); } static String sort( String s){ Character ch[] = new Character[s.length()]; for ( int i = 0;(i < s.length());i++) {ch[i] = s.charAt(i); }Arrays.sort(ch); StringBuffer st = new StringBuffer(""); for ( int i = 0;(i < s.length());i++) {st.append(ch[i]); }return st.toString();} static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} 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());} long nextLong(){ return Long.parseLong(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.nextInt();  int a[] = in.nextIntArray(n);  int i ,j ,k ;  int b[] = a.clone(); ArrayUtils.randomShuffle(a); Arrays.sort(a); int c[] = new int[n]; k = 0; for ( i = 0;(i < n);++i) if ( (a[i] != b[i])) c[k++] = i;  String res = "NO"; if ( (k == 0)) {res = "YES"; } else if ( (k == 1)) {} else if ( (k == 2)) {i = c[0]; j = c[1]; if ( ((a[i] == b[j]) && (a[j] == b[i]))) res = "YES"; } out.writeln(res); } } 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 (Exception e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public int[] nextIntArray( int size){ int array[] = new int[size]; for ( int i = 0;(i < size);++i) array[i] = nextInt(); return array;} } class OutputWriter{ private PrintWriter out ; public OutputWriter( Writer out){ this.out = new PrintWriter(out); } public OutputWriter( OutputStream out){ this.out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out))); } public void close(){ out.flush(); out.close(); } public void writeln( Object... o){ for ( Object x :o) out.print(x); out.println(); } }
1	public class Main{ int work( int x){ if ( ((x % 2) == 0)) return (x + 1); else return (x - 1);} static int N = 200050; class Edge{ int from ,to ,nex ; Edge( int from, int to, int nex){ this.from = from; this.to = to; this.nex = nex; } } Edge[] edge = new Edge[(N * 10)]; int[] head = new int[N]; int edgenum ; int n ; int[] p = new int[N],ans = new int[N]; int a ,b ,max ; Map<Integer,Integer> map = new HashMap(); boolean match( int x, int y, int col){ int P = map.get(x); if ( (map.containsKey((y - x)) == false)) return false; int Q = map.get((y - x)); if ( ((ans[Q] == -1) || ((x * 2) == y))) {ans[Q] = ans[P] = col; } else {if ( match((((a + b) - (2 * y)) + x),y,col)) ans[Q] = ans[P] = col; else return false;}return true;} boolean solve(){ if ( ((max >= a) && (max >= b))) return false; for ( int i = 1;(i <= n);i++) if ( (ans[i] == -1)) {if ( ((match(p[i],a,0) == false) && (match(p[i],b,1) == false))) return false; } return true;} void init(){ n = cin.nextInt(); a = cin.nextInt(); b = cin.nextInt(); max = 0; for ( int i = 1;(i <= n);i++) {ans[i] = -1; p[i] = cin.nextInt(); map.put(p[i],i); if ( (p[i] > max)) max = p[i]; }} public void work(){ init(); if ( solve()) {out.println("YES"); for ( int i = 1;(i <= n);i++) out.print((ans[i] + " ")); out.println(); } else out.println("NO"); } Main(){ cin = new Scanner(System.in); out = new PrintWriter(System.out); } public static void main( String[] args){ Main e = new Main(); e.work(); out.close(); } public Scanner cin ; public static PrintWriter out ; }
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(); } }
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)); } static private 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());} } }
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(); } }
3	public class Main{ static BufferedReader in ; static PrintStream out ; static StringTokenizer tok ; @SuppressWarnings public static void main( String[] args)throws NumberFormatException,IOException,Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = System.out; long mod = ((long)1e9 + 7);  int n = nextInt();  long[][] dp = new long[(n + 1)][(n + 1)];  Character[] line = new Character[(n + 1)]; line[0] = 'a'; for ( int i = 1;(i <= n);i++) {line[i] = nextToken().charAt(0); if ( (line[(i - 1)] == 'f')) {for ( int j = 0;(j < i);j++) {dp[i][(j + 1)] = dp[(i - 1)][j]; }} else if ( (line[(i - 1)] == 's')) { long temp = 0; for ( int j = i;(j >= 0);j--) {temp = ((temp + dp[(i - 1)][j]) % mod); dp[i][j] = temp; }} else dp[i][0] = 1; } long total = 0; for ( int j = 0;(j <= n);j++) total = ((total + dp[n][j]) % mod); out.println(total); } static String nextToken()throws IOException { String line = ""; while(((tok == null) || !tok.hasMoreTokens())){if ( ((line = in.readLine()) != null)) tok = new StringTokenizer(line); else return null;}return tok.nextToken();} static int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} }
4	public class Main{ public static final DecimalFormat DF_3 = new DecimalFormat("0.000"); static private final long MOD = 1000000007; static private long[] allInvs( int n, long mod){ long[] inv = new long[(n + 1)]; inv[1] = 1; for ( int i = 2;(i <= n);++i) {inv[i] = subMod(mod,(((mod / i) * inv[(int)(mod % i)]) % mod),mod); }return inv;} static private long subMod( long x, long y, long mod){ long res = (x - y); if ( (res < 0)) {return (res + mod);} return res;} static private long fastPow( long x, long y, long mod){ if ( (x == 1)) {return 1;} if ( (y == 0)) {return 1;} long p = (fastPow(x,(y / 2),mod) % mod); p = ((p * p) % mod); if ( ((y % 2) == 1)) {p = ((p * x) % mod); } return p;} public static void main( String[] args)throws FileNotFoundException { InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int n = in.nextInt();  long mod = in.nextLong();  long[] invs = allInvs((n + 3),mod);  long[] facts = new long[(n + 2)]; facts[0] = 1; long[] invFacts = new long[(n + 2)]; invFacts[0] = 1; for ( int i = 1;(i < (n + 2));i++) {facts[i] = ((facts[(i - 1)] * i) % mod); invFacts[i] = ((invFacts[(i - 1)] * invs[i]) % mod); } long[] pow2 = new long[(n + 3)]; pow2[0] = 1; for ( int i = 1;(i < (n + 3));i++) {pow2[i] = ((pow2[(i - 1)] * 2) % mod); } long[][] dp = new long[(n + 2)][(n + 2)]; for ( int i = 2;(i <= (n + 1));i++) {dp[i][1] = ((invFacts[(i - 1)] * pow2[(i - 2)]) % mod); for ( int k = 2;(k <= n);k++) {for ( int j = (i - 2);(j >= 1);j--) {dp[i][k] = ((dp[i][k] + ((((dp[j][(k - 1)] * pow2[((i - j) - 2)]) % mod) * invFacts[((i - j) - 1)]) % mod)) % mod); }}} long ans = 0; for ( int k = 1;(k <= n);k++) {ans = ((ans + ((dp[(n + 1)][k] * facts[((n - k) + 1)]) % mod)) % mod); }out.println(ans); out.close(); } static private 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());} private List<Integer>[] readGraph( int n, int m){ List<Integer>[] result = new ArrayList[n]; for ( int i = 0;(i < n);i++) {result[i] = new ArrayList<>(); }for ( int i = 0;(i < m);i++) { int u = (nextInt() - 1);  int v = (nextInt() - 1); result[u].add(v); result[v].add(u); }return result;} } }
4	public class Main{ static FastScanner sc = new FastScanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static StringBuilder sb = new StringBuilder(); static long mod = ((long)1e9 + 7); public static void main( String[] args)throws Exception { solve(); pw.flush(); } static ArrayList<ArrayList<ArrayList<int[]>>> kruscal = new ArrayList<>(); static long ans = Integer.MAX_VALUE; static int[][][] map ; public static void solve(){ int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt(); for ( int i = 0;(i < n);i++) {kruscal.add(new ArrayList<>()); for ( int j = 0;(j < m);j++) {kruscal.get(i).add(new ArrayList<>()); }}map = new int[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int now = sc.nextInt(); kruscal.get(i).get(j).add(new int[]{now,i,(j + 1)}); kruscal.get(i).get((j + 1)).add(new int[]{now,i,j}); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { int now = sc.nextInt(); kruscal.get(i).get(j).add(new int[]{now,(i + 1),j}); kruscal.get((i + 1)).get(j).add(new int[]{now,i,j}); }}if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {sb.append(-1).append(" "); }pw.println(sb.toString().trim()); sb.setLength(0); }return ;} for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {Arrays.fill(map[i][j],(Integer.MAX_VALUE / 2)); map[i][j][(k / 2)] = 0; }}for ( int kk = (k / 2);(kk > 0);kk--) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {for ( int[] next :kruscal.get(i).get(j)) { int d = next[0],i2 = next[1],j2 = next[2]; map[i2][j2][(kk - 1)] = Math.min(map[i2][j2][(kk - 1)],(map[i][j][kk] + d)); }}}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {sb.append((map[i][j][0] * 2)).append(" "); }pw.println(sb.toString().trim()); sb.setLength(0); }} static void dfs( Stack<Integer> st, int y, int x, int cnt, long total){ if ( (st.size() == cnt)) {ans = Math.min(total,ans); } for ( int[] next :kruscal.get(y).get(x)) { int d = next[0],i = next[1],j = next[2]; if ( (((Math.abs((i - y)) + Math.abs((j - x))) - st.size()) < 0)) {continue;} Stack<Integer> stk = (Stack<Integer>)st.clone(); stk.push(d); dfs(stk,i,j,cnt,(total + d)); } int rem = (cnt - st.size());  long tmp = 0;  int c = 0; while((st.size() > 0)){tmp += st.pop(); c++; if ( ((rem % c) == 0)) {ans = Math.min(ans,(total + (tmp * (rem / c)))); } }} } class FastScanner{ private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public FastScanner( FileReader in){ reader = new BufferedReader(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());} }
2	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String S[] = br.readLine().split(" ");  int N = Integer.parseInt(S[0]);  int x = Integer.parseInt(S[1]);  int y = Integer.parseInt(S[2]);  int c = Integer.parseInt(S[3]);  int lo = 0;  int hi = 1000000000; while(((hi - lo) >= 10)){ int steps = ((hi + lo) / 2);  long total = (((f(x,y,steps) + f(((N - x) + 1),y,steps)) + f(((N - x) + 1),((N - y) + 1),steps)) + f(x,((N - y) + 1),steps)); total -= 3; total -= Math.min(steps,(x - 1)); total -= Math.min(steps,(y - 1)); total -= Math.min(steps,(N - x)); total -= Math.min(steps,(N - y)); if ( (total >= c)) hi = (steps + 1); else lo = (steps - 1); }for ( int steps = lo;(steps <= hi);steps++) { long total = (((f(x,y,steps) + f(((N - x) + 1),y,steps)) + f(((N - x) + 1),((N - y) + 1),steps)) + f(x,((N - y) + 1),steps)); total -= 3; total -= Math.min(steps,(x - 1)); total -= Math.min(steps,(y - 1)); total -= Math.min(steps,(N - x)); total -= Math.min(steps,(N - y)); if ( (total >= c)) {System.out.println(steps); return ;} }} public static long f( long a, long b, long steps){ steps++; long A = Math.min(a,b);  long B = Math.max(a,b);  long ans = 0; if ( (steps >= (A + B))) {ans = (A * B); } else if ( (steps <= A)) {ans = ((steps * (steps + 1)) / 2); } else if ( ((steps > A) && (steps <= B))) {ans = (((A * (A + 1)) / 2) + ((steps - A) * A)); } else if ( (steps > B)) {ans = (((((A * (A + 1)) / 2) + ((B - A) * A)) + ((steps - B) * A)) - (((steps - B) * ((steps - B) + 1)) / 2)); } return ans;} }
5	public class TaskA{ public static void main( String[] args)throws Exception { Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt(); scanner.nextLine(); int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = scanner.nextInt(); }Arrays.sort(a); int sum = 0; for ( int i = 0;(i < n);i++) {sum += a[i]; } int take = 0,num = 0; for ( int i = (n - 1);(i > -1);i--) {num++; take += a[i]; sum -= a[i]; if ( (take > sum)) {break;} }System.out.println(num); } }
0	public class Pizza{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long num = (sc.nextLong() + 1); sc.close(); System.out.println(((((num % 2) == 0) || (num == 1))?(num / 2):num)); } }
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(); } }
3	public class Main{ public static void main( String[] args)throws Exception { BufferedReader jk = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  StringTokenizer ana = new StringTokenizer(jk.readLine());  int n = Integer.parseInt(ana.nextToken());  int t[] = new int[101];  ArrayList<Integer> v = new ArrayList<>(); ana = new StringTokenizer(jk.readLine()); for ( int i = 0;(i < n);i++) { int y = Integer.parseInt(ana.nextToken()); t[y] = 1; v.add(y); }Collections.sort(v); int c = 0; for ( int ele :v) {if ( (t[ele] == 1)) {for ( int i = ele;(i <= 100);i += ele) {t[i] = 2; }c++; } }out.println(c); out.flush(); } }
3	public class D2{ 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 - 1));i++) {array[i] = sc.nextInt(); } int m = sc.nextInt();  int result = count(array); for ( int i = 1;(i <= m);i++) { int a = sc.nextInt();  int b = sc.nextInt(); result += (((b - a) * ((b - a) + 1)) / 2); result = (result % 2); if ( ((result % 2) == 1)) System.out.println("odd"); else System.out.println("even"); }} public static int count( int[] arr){ int[] array = arr.clone(); return sort(array,0,(array.length - 1));} public static int sort( int[] arr, int i, int j){ if ( (i >= j)) return 0; int mid = ((i + j) / 2);  int a = sort(arr,i,mid);  int b = sort(arr,(mid + 1),j);  int addition = 0;  int r1 = (mid + 1);  int[] tmp = new int[arr.length];  int tIndex = i;  int cIndex = i; while(((i <= mid) && (r1 <= j))){if ( (arr[i] <= arr[r1])) tmp[tIndex++] = arr[i++]; else {tmp[tIndex++] = arr[r1++]; addition += ((mid + 1) - i); }}while((i <= mid)){tmp[tIndex++] = arr[i++]; }while((r1 <= j)){tmp[tIndex++] = arr[r1++]; }while((cIndex <= j)){arr[cIndex] = tmp[cIndex]; cIndex++; }return ((a + b) + addition);} }
2	public class D2{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ long L = nl(),R = nl(); out.println(Math.max(0,((Long.highestOneBit((L ^ R)) * 2) - 1))); } 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 D2().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 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{ 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 ; }
0	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long num = input.nextLong(); if ( (num == 0)) {System.out.println(num); } else if ( ((num == 1) || (num == 2))) {System.out.println(num); } else if ( ((((num % 2) == 0) && (num > 2)) && ((num % 3) != 0))) {System.out.println(((num * (num - 1)) * (num - 3))); } else if ( (((num % 2) == 0) && ((num % 3) == 0))) {System.out.println((((num - 1) * (num - 2)) * (num - 3))); } else {System.out.println(((num * (num - 1)) * (num - 2))); }} }
6	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 Thread(null,new Runnable(){public void run(){ try{new Main().run(); }catch (Throwable e){ e.printStackTrace(); exit(999); } } },"1",(1 << 23)).start(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); int n ,m ; int dp[][][] ; int MV = (Integer.MAX_VALUE >> 1); int ans = MV; private void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); n = nextInt(); m = nextInt(); if ( (n < m)) { int d = n; n = m; m = d; } int M = (1 << m); dp = new int[n][M][M]; for ( int[][] a :dp) for ( int[] b :a) fill(b,MV); dp[0][0][0] = 0; for ( int i = 0;(i < n);i++) for ( int m1 = 0;(m1 < M);m1++) for ( int m2 = 0;(m2 < M);m2++) {if ( (dp[i][m1][m2] == MV)) continue; for ( int nm1 = 0;(nm1 < M);nm1++) for ( int nm2 = 0;(nm2 < M);nm2++) { int res1 = ((((m1 | nm1) | (nm1 << 1)) | (nm1 >> 1)) | nm2); res1 &= (M - 1); if ( (res1 != (M - 1))) continue; int res2 = ((((m2 | nm1) | (nm2 << 1)) | (nm2 >> 1)) | nm2); res2 &= (M - 1); int next1 = (res2 & (M - 1));  int next2 = (nm2 & (M - 1));  int over = (Integer.bitCount(nm1) + Integer.bitCount(nm2)); if ( (i < (n - 1))) dp[(i + 1)][next1][next2] = min(dp[(i + 1)][next1][next2],(dp[i][m1][m2] + over)); else if ( ((res1 & (M - 1)) == (M - 1))) {ans = min((dp[i][m1][m2] + over),ans); } }}out.println(((n * m) - ans)); in.close(); 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());} }
4	public class Main{ static final long MOD = 1000000007L; static final int INF = 1000000005; static final int NINF = -1000000005; static FastScanner sc ; static PrintWriter pw ; static final int[][] dirs = {{-1,0},{1,0},{0,-1},{0,1}}; static final int MO = 1200; public static void main( String[] args){ sc = new FastScanner(); pw = new PrintWriter(System.out); int N = sc.ni();  int M = sc.ni();  int K = sc.ni();  int[][] LR = new int[N][(M - 1)]; for ( int i = 0;(i < N);i++) {LR[i] = sc.intArray((M - 1),0); } int[][] UD = new int[(N - 1)][M]; for ( int i = 0;(i < (N - 1));i++) {UD[i] = sc.intArray(M,0); }if ( ((K % 2) == 0)) { int T = (K / 2);  int[][] dist = new int[N][M]; for ( int step = 1;(step <= T);step++) { int[][] newDist = new int[N][M]; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {newDist[i][j] = INF; if ( (i > 0)) {newDist[i][j] = Math.min(newDist[i][j],(UD[(i - 1)][j] + dist[(i - 1)][j])); } if ( (i < (N - 1))) {newDist[i][j] = Math.min(newDist[i][j],(UD[i][j] + dist[(i + 1)][j])); } if ( (j > 0)) {newDist[i][j] = Math.min(newDist[i][j],(LR[i][(j - 1)] + dist[i][(j - 1)])); } if ( (j < (M - 1))) {newDist[i][j] = Math.min(newDist[i][j],(LR[i][j] + dist[i][(j + 1)])); } }}dist = newDist; }for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {pw.print(((2 * dist[i][j]) + " ")); }pw.println(); }} else {for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {pw.print("-1 "); }pw.println(); }}pw.close(); } public static void sort( int[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( long[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( int[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<int[]>(){}); } public static void sort( long[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<long[]>(){}); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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 mod){ int[] ret = new int[N]; for ( int i = 0;(i < N);i++) ret[i] = (ni() + mod); return ret;} long nl(){ return Long.parseLong(next());} } }
3	public class ROUGH{ 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());} } public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static long mod = (long)(1e9 + 7); static int N = (int)1e5; public static void main( String[] args){ FastReader sc = new FastReader();  int n = sc.nextInt();  int[] a = new int[n];  TreeSet<Integer> set = new TreeSet<Integer>(); for ( int i = 0;(i < n);++i) {a[i] = sc.nextInt(); set.add(a[i]); } long ans = 0; while((set.size() > 0)){++ans; int min = set.first();  TreeSet<Integer> temp = new TreeSet<>(); for ( int x :set) {if ( ((x % min) != 0)) temp.add(x); }set = temp; }out.print(ans); out.close(); } }
3	public class Solution{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  char[] seq = new char[n]; for ( int i = 0;(i < n);i++) {seq[i] = s.next().charAt(0); } long mod = ((long)Math.pow(10,9) + 7);  long[][] arr = new long[n][n]; arr[0][0] = 1; for ( int i = 1;(i < n);i++) {if ( (seq[(i - 1)] == 'f')) {for ( int j = 1;(j < n);j++) {arr[i][j] = arr[(i - 1)][(j - 1)]; }} else { long sum = 0; for ( int j = (n - 1);(j >= 0);j--) {sum = ((sum + arr[(i - 1)][j]) % mod); arr[i][j] = sum; }}} long ans = 0; for ( int i = 0;(i < n);i++) {ans = ((ans + arr[(n - 1)][i]) % mod); }System.out.println(ans); } }
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 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;} }
1	public class Homyak implements Runnable{ private void solve()throws IOException { int n = nextInt();  String seq = nextToken();  int nh = 0;  int nt = 0; for ( int i = 0;(i < n);++i) if ( (seq.charAt(i) == 'H')) ++nh; else ++nt; int res = n; for ( int delta = 0;(delta < n);++delta) { int changed = 0;  int at = delta; for ( int i = 0;(i < nh);++i) {if ( (seq.charAt(at) != 'H')) ++changed; ++at; if ( (at >= n)) at = 0; }for ( int i = 0;(i < nt);++i) {if ( (seq.charAt(at) != 'T')) ++changed; ++at; if ( (at >= n)) at = 0; }res = Math.min(res,(changed / 2)); }writer.println(res); } public static void main( String[] args){ new Homyak().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();} }
6	public class Driver{ static private int[][] distances ,parents ; static private int[] distance ,parent ; static private String[][] longNames ; static private String[] shortNames ,answers ; static private int N ; public static void main( String[] args)throws IOException { BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));  String[] pieces = scanner.readLine().split("\\s+");  Point origin = new Point(Integer.parseInt(pieces[0]),Integer.parseInt(pieces[1])); N = Integer.parseInt(scanner.readLine()); Point[] points = new Point[(N + 1)]; distances = new int[(N + 1)][(N + 1)]; parents = new int[(N + 1)][(N + 1)]; longNames = new String[N][N]; shortNames = new String[N]; for ( int i = 0;(i < N);++i) {pieces = scanner.readLine().split("\\s+"); points[i] = new Point(Integer.parseInt(pieces[0]),Integer.parseInt(pieces[1])); }points[N] = origin; for ( int i = 0;(i <= N);++i) {if ( (i < N)) {shortNames[i] = ((i + 1) + " "); } for ( int j = 0;(j <= N);++j) {if ( ((i < N) && (j < N))) {longNames[i][j] = ((((i + 1) + " ") + (j + 1)) + " "); } distances[i][j] = (2 * points[i].distance(points[j])); parents[i][j] = ((points[i].distance(points[N]) + points[i].distance(points[j])) + points[j].distance(points[N])); }}distance = new int[(1 << N)]; parent = new int[(1 << N)]; answers = new String[(1 << N)]; Arrays.fill(distance,-1); distance[0] = 0; int result = rec(((1 << N) - 1));  StringBuilder answer = new StringBuilder(); for ( int i = (distance.length - 1);(parent[i] != i);i = parent[i]) {answer.append("0 "); answer.append(answers[i]); }answer.append("0"); System.out.println(result); System.out.println(answer.toString()); } static private int rec( int mask){ if ( (distance[mask] != -1)) {return distance[mask];} int min = 0; while((((1 << min) & mask) == 0)){min++; } int newMask = (mask & (1 << min)); distance[mask] = (rec(newMask) + distances[min][N]); parent[mask] = newMask; answers[mask] = shortNames[min]; for ( int i = (min + 1);(i < N);i++) {if ( (((1 << i) & mask) > 0)) {newMask = ((mask & (1 << i)) & (1 << min)); int temp = (rec(newMask) + parents[i][min]); if ( (temp < distance[mask])) {distance[mask] = temp; parent[mask] = newMask; answers[mask] = longNames[min][i]; } } }return distance[mask];} static private class Point{ int x ,y ; public Point( int x, int y){ this.x = x; this.y = y; } public int distance( Point p){ return (int)(Math.pow((this.x - p.x),2) + Math.pow((this.y - p.y),2));} } }
6	public class B{ int n ,k ,a ; int[] b ,l ; double best ; double calc( int i, int r, int c, double p){ if ( (i == n)) {if ( (c <= (n / 2))) {p *= ((1.0 * a) / (a + r)); } return p;} else {return (calc((i + 1),r,(c + 1),((p * l[i]) / 10.0)) + calc((i + 1),(r + b[i]),c,((p * (10 - l[i])) / 10.0)));}} void go( int i, int k){ if ( (i == n)) { double p = calc(0,0,0,1.0); if ( (p > best)) best = p; } else {for ( int c = 0;((c <= k) && ((l[i] + c) <= 10));++c) {l[i] += c; go((i + 1),(k - c)); l[i] -= c; }}} void solve()throws IOException { in("__std"); out("__std"); n = readInt(); k = readInt(); a = readInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < n);++i) {b[i] = readInt(); l[i] = (readInt() / 10); }go(0,k); println("%.10f",best); exit(); } void in( String name)throws IOException { if ( name.equals("__std")) {in = new BufferedReader(new InputStreamReader(System.in)); } else {in = new BufferedReader(new FileReader(name)); }} void out( String name)throws IOException { if ( name.equals("__std")) {out = new PrintWriter(System.out); } else {out = new PrintWriter(name); }} void exit(){ out.close(); System.exit(0); } int readInt()throws IOException { return Integer.parseInt(readToken());} String readLine()throws IOException { st = null; return in.readLine();} String readToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} void print( String format, Object... args){ out.println(new Formatter().format(format,args)); } void println( String format, Object... args){ out.println(new Formatter().format(format,args)); } void print( Object value){ out.print(value); } void println( Object value){ out.println(value); } void println(){ out.println(); } StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args)throws IOException { new B().solve(); } }
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(); } }
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)));} }
3	public class PaintTheNumber{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  ArrayList<Integer> l = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {l.add(sc.nextInt()); } boolean c = false; for ( int i = 0;(i < l.size());i++) {if ( (l.get(i) == -1)) continue; for ( int j = 0;(j < l.size());j++) {if ( ((i == j) || (l.get(j) == -1))) continue; else {if ( ((l.get(j) % l.get(i)) == 0)) {l.set(j,-1); } }}} int nbr = 0; for ( int i = 0;(i < l.size());i++) if ( (l.get(i) != -1)) nbr++; System.out.println(nbr); } }
0	public class TaskA extends Thread{ public TaskA( 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 n = nextLong(); output.println(("0 0 " + n)); } public static void main( String... args){ new TaskA(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 ; }
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"); }} }
0	public class rgb{ public static void main( String[] args)throws IOException { System.out.print(25); return ;} }
0	public class A{ public static void main( String[] args)throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String ln = in.readLine().trim(); System.out.println(max(parseInt(ln),max(parseInt(ln.substring(0,(ln.length() - 1))),parseInt((ln.substring(0,(ln.length() - 2)) + ln.substring((ln.length() - 1))))))); } }
0	public class CF630_A{ public static void main( String[] args){ try(Scanner s=new Scanner(System.in)){ long n = s.nextLong(); System.out.println("25"); }} }
5	public class Solver{ StringTokenizer st ; BufferedReader in ; PrintWriter out ; public long result = 0; public int k = 0; 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();  int a = nextInt();  int b = nextInt();  int[] ar = new int[n]; for ( int i = 0;(i < n);i++) {ar[i] = nextInt(); }Arrays.sort(ar); out.println((ar[b] - ar[(b - 1)])); } public void close(){ out.flush(); out.close(); } }
5	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();  int[] ar = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {ar[i] = nextInt(); sum += ar[i]; }Arrays.sort(ar); int me = 0;  int k = 0; while((me <= sum)){k++; int coin = ar[(ar.length - k)]; me += coin; sum -= coin; }out.println(k); } public void close(){ out.flush(); out.close(); } }
5	public class a{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  int[][] xa = new int[n][2]; for ( int i = 0;(i < n);++i) {xa[i][0] = sc.nextInt(); xa[i][1] = sc.nextInt(); }Arrays.sort(xa,new Comparator<int[]>(){}); int ans = 2; for ( int i = 0;(i < (n - 1));i++) { int s = (((xa[(i + 1)][0] * 2) - xa[(i + 1)][1]) - ((xa[i][0] * 2) + xa[i][1])); if ( (s > (t * 2))) {ans += 2; } else if ( (s == (t * 2))) {ans++; } }System.out.println((ans + "")); } }
3	public class C{ static final long MOD = 1_000_000_007; public static void main( String[] args)throws Exception { FastScanner sc = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int N = sc.nextInt();  long[][] dp = new long[N][N]; dp[0][0] = 1L; for ( int i = 0;(i < (N - 1));i++) { char oper = sc.next().charAt(0); if ( (oper == 'f')) {dp[(i + 1)][0] = 0L; for ( int j = 1;(j < N);j++) {dp[(i + 1)][j] = dp[i][(j - 1)]; }} else {dp[(i + 1)][(N - 1)] = dp[i][(N - 1)]; for ( int j = (N - 2);(j >= 0);j--) {dp[(i + 1)][j] = ((dp[(i + 1)][(j + 1)] + dp[i][j]) % MOD); }}} long res = 0; for ( int i = 0;(i < N);i++) {res += dp[(N - 1)][i]; res %= MOD; }out.println(res); out.flush(); } static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
2	public class D{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; String toStr( long a){ String s = Long.toBinaryString(a); while((s.length() < 64))s = ("0" + s); return s;} void solve()throws IOException { long a = nextLong();  long b = nextLong();  String sa = toStr(a);  String sb = toStr(b);  int i = 0; while(((i < 64) && (sa.charAt(i) == sb.charAt(i))))i++; int left = (64 - i); out.println(((1L << left) - 1)); } D()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 D(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} long nextLong()throws IOException { return Long.parseLong(nextToken());} }
5	public class A implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; public static final String filename = "a"; class I implements Comparable<I>{ int x ; int a ; I( int x, int a){ this.x = x; this.a = a; } } public void solve()throws IOException { int n = nextInt();  int t = nextInt();  I[] a = new I[n]; for ( int i = 0;(i < n);i++) {a[i] = new I(nextInt(),nextInt()); } int res = 2; Arrays.sort(a); for ( int i = 1;(i < n);i++) {if ( (((a[i].x - a[(i - 1)].x) - ((1.0 * (a[i].a + a[(i - 1)].a)) / 2)) >= t)) res++; if ( (((a[i].x - a[(i - 1)].x) - ((1.0 * (a[i].a + a[(i - 1)].a)) / 2)) > t)) res++; }out.println(res); } public static void main( String[] args){ new Thread(new A()).start(); } public String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
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(); } }
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(); } }
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)); } }
0	public class Problem1{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( (n < 0)) { int first = (n / 10);  int second = (((n / 100) * 10) + (n % 10)); if ( (first > second)) System.out.println(first); else System.out.println(second); } else {System.out.println(n); }} }
0	public class A{ public static void main( String[] args){ try(Scanner sc=new Scanner(System.in)){System.out.println(25); }} public static class Scanner implements Closeable{ private BufferedReader br ; private StringTokenizer tok ; public Scanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } private void getLine(){ try{while(!hasNext()){tok = new StringTokenizer(br.readLine()); } }catch (IOException e){ } } private boolean hasNext(){ return ((tok != null) && tok.hasMoreTokens());} public String next(){ getLine(); return tok.nextToken();} public void close(){ try{br.close(); }catch (IOException e){ } } } }
2	public class Main{ public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  long k = scan.nextLong();  long total = (((k * (k - 1)) / 2) + 1); if ( (total < n)) {System.out.println(-1); return ;} long left = (total - n);  long low = 1;  long high = (k - 1); while((low < high)){ long mid = ((low + high) / 2);  long temp = ((mid * (mid + 1)) / 2); if ( (temp < left)) {low = (mid + 1); } else {high = mid; }} long temp = ((low * (low + 1)) / 2); if ( (temp == left)) {System.out.println(((k - 1) - low)); } else {System.out.println((k - low)); }} }
2	public class TaskD{ boolean eof ; BufferedReader br ; StringTokenizer st ; PrintWriter out ; public static void main( String[] args)throws IOException { new TaskD().run(); } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return "-1";} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} public long nextLong(){ return Long.parseLong(nextToken());} void run()throws IOException { InputStream input = System.in;  PrintStream output = System.out; try{ File f = new File("a.in"); if ( (f.exists() && f.canRead())) {input = new FileInputStream(f); output = new PrintStream("a.out"); } }catch (Throwable e){ } br = new BufferedReader(new InputStreamReader(input)); out = new PrintWriter(output); solve(); br.close(); out.close(); } void solve(){ int t = nextInt();  long n ,k ;  int m = 34;  long[] res = new long[m]; res[1] = 0; res[2] = 1; for ( int i = 3;(i < m);i++) {res[i] = (res[(i - 1)] * 4L); } long[] l = new long[m];  long[] r = new long[m]; l[0] = 0; l[1] = 1; r[0] = 0; r[1] = 1; for ( int i = 2;(i < m);i++) {l[i] = ((l[(i - 1)] * 2) + 1); r[i] = (r[(i - 1)] * 4); } long[] mi = new long[m];  long[] ma = new long[m]; for ( int i = 1;(i < m);i++) {mi[i] = (mi[(i - 1)] + l[i]); ma[i] = (ma[(i - 1)] + r[i]); }for ( int i = 0;(i < t);i++) {n = nextLong(); k = nextLong(); if ( (n >= 32)) {out.println(("YES " + (n - 1))); } else {if ( (k > ma[(int)n])) {out.println("NO"); } else {for ( int j = 0;(j <= n);j++) {if ( ((mi[((int)n - j)] <= k) && ((ma[(int)n] - (l[(((int)n - j) + 1)] * ma[j])) >= k))) {out.println(("YES " + j)); break;} if ( (j == (n - 1))) {out.println("NO"); } }}}}} }
6	public class Main{ public static void main( String[] args)throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = nextInt();  double[][] a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {a[i][j] = nextDouble(); }} double[] dp = new double[(1 << n)]; dp[((1 << n) - 1)] = 1.0; for ( int mask = ((1 << n) - 2);(mask > 0);mask--) { int count = Integer.bitCount(mask);  double pPair = (2.0 / (count * (count + 1)));  double ans = 0.0; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & mask) == 0)) { double p = dp[((1 << i) | mask)];  double s = 0.0; for ( int j = 0;(j < n);j++) {if ( (((1 << j) & mask) != 0)) s += a[j][i]; }ans += ((pPair * p) * s); } }dp[mask] = ans; }for ( int i = 0;(i < n);i++) {out.print(dp[(1 << i)]); out.print(' '); }in.close(); out.close(); } static StringTokenizer st ; static BufferedReader in ; static PrintWriter out ; static int nextInt()throws IOException { return Integer.parseInt(nextString());} static double nextDouble()throws IOException { return Double.parseDouble(nextString());} static String nextString()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
2	public class B{ public static void main( String[] args){ FastScanner sc = new FastScanner();  long n = sc.nextLong();  int k = sc.nextInt(); if ( (n == 1)) {System.out.println(0); return ;} n = (n - 1); int count = 0;  long nextK = (k - 1); while(true){if ( ((nextK < 1) || ((nextK <= 1) && (n > 1)))) {System.out.println(-1); return ;} nextK = Math.min(n,nextK); if ( (n == nextK)) {System.out.println((count + 1)); return ;} long bSum = ((nextK * (nextK + 1)) / 2);  long a = nextK;  long decrement = 1; while((((bSum - (((a - 1) * a) / 2)) <= n) && (a >= 1))){a -= decrement; decrement *= 2; }a += (decrement / 2); count += ((nextK - a) + 1); long nDecr = (bSum - ((a * (a - 1)) / 2)); n -= nDecr; nextK = (a - 1); if ( (n == 0)) {System.out.println(count); return ;} }} public 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());} long nextLong(){ return Long.parseLong(nextToken());} } }
6	public class Main{ public static void main( String[] args)throws IOException { FastScanner scanner = new FastScanner();  int n = scanner.nextInt();  int m = scanner.nextInt();  boolean graph[][] = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = scanner.nextInt();  int b = scanner.nextInt(); graph[(a - 1)][(b - 1)] = true; graph[(b - 1)][(a - 1)] = true; }if ( (n <= 2)) {System.out.println(0); return ;} long dp[][] = new long[(1 << n)][n]; for ( int i = 0;(i < (1 << n));i++) {Arrays.fill(dp[i],-1); }for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {f(i,j,dp,graph,n); }} long sum = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (1 << n));j++) {if ( ((Integer.bitCount(j) >= 3) && graph[Integer.numberOfTrailingZeros(j)][i])) {sum += dp[j][i]; } }}System.out.println((sum / 2)); } static private long f( int mask, int i, long[][] dp, boolean[][] graph, int n){ if ( (dp[mask][i] != -1)) return dp[mask][i]; if ( ((Integer.bitCount(mask) == 1) && ((mask & (1 << i)) != 0))) {dp[mask][i] = 1; } else if ( (((Integer.bitCount(mask) > 1) && ((mask & (1 << i)) != 0)) && (i != Integer.numberOfTrailingZeros(mask)))) {dp[mask][i] = 0; for ( int j = 0;(j < n);j++) {if ( graph[i][j]) dp[mask][i] = (dp[mask][i] + f((mask ^ (1 << i)),j,dp,graph,n)); }} else {dp[mask][i] = 0; }return dp[mask][i];} static class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner(){ 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 CF1238E extends PrintWriter{ CF1238E(){ super(System.out,true); } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF1238E o = new CF1238E(); o.main(); o.flush(); } static final int INF = 0x3f3f3f3f; void main(){ int n = sc.nextInt();  int m = sc.nextInt();  byte[] cc = sc.next().getBytes();  int[] kk = new int[(1 << m)]; for ( int i = 1;(i < n);i++) { int a = (cc[(i - 1)] - 'a');  int b = (cc[i] - 'a'); kk[((1 << a) | (1 << b))]++; }for ( int h = 0;(h < m);h++) for ( int b = 0;(b < (1 << m));b++) if ( ((b & (1 << h)) == 0)) kk[(b | (1 << h))] += kk[b];  int[] dp = new int[(1 << m)];  int m_ = ((1 << m) - 1); for ( int b = 1;(b < (1 << m));b++) { int k = (((n - 1) - kk[b]) - kk[(m_ ^ b)]);  int x = INF; for ( int h = 0;(h < m);h++) if ( ((b & (1 << h)) != 0)) { int b_ = (b ^ (1 << h)); x = Math.min(x,dp[b_]); } dp[b] = ((x == INF)?INF:(x + k)); }println(dp[m_]); } }
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 Village{ private class House implements Comparable<House>{ Double Coordinate ; Double Sidelength ; private House( double coordinate, double sidelength){ Coordinate = coordinate; Sidelength = sidelength; } public int compareTo( House o){ return Coordinate.compareTo(o.Coordinate);} } private void solve(){ Scanner in = new Scanner(System.in); in.next(); double requireside = in.nextDouble();  ArrayList<House> coordinate = new ArrayList<House>(); while(in.hasNext()){ double coo = in.nextDouble();  double side = in.nextDouble(); coordinate.add(new House(coo,side)); }Collections.sort(coordinate); ArrayList<Double> edges = new ArrayList<Double>();  int count = 2; for ( int i = 0;(i < coordinate.size());i++) {edges.add((coordinate.get(i).Coordinate - ((double)coordinate.get(i).Sidelength / (double)2))); edges.add((coordinate.get(i).Coordinate + ((double)coordinate.get(i).Sidelength / (double)2))); } ArrayList<Double> difference = new ArrayList<Double>(); for ( int i = 1;(i < (edges.size() - 1));i++) {difference.add(Math.abs((edges.get(i) - edges.get((i + 1))))); }for ( int i = 0;(i < difference.size());i += 2) {if ( (difference.get(i) == requireside)) count++; else if ( (difference.get(i) > requireside)) count += 2; }System.out.println(count); } public static void main( String[] args){ Village v = new Village(); v.solve(); } }
0	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt(); System.out.println(((n * 6) / 4)); } }
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; }}} }
1	public class _1036_B_DiagonalWalkingV2{ public static void main( String[] args)throws IOException { int Q = readInt(); while((Q-- > 0)){ long n = readLong(),m = readLong(),k = readLong(); if ( (Math.max(n,m) > k)) println(-1); else { long ans = k; if ( ((n % 2) != (k % 2))) ans--; if ( ((m % 2) != (k % 2))) ans--; println(ans); }}exit(); } static private final int BUFFER_SIZE = (1 << 16); static private DataInputStream din = new DataInputStream(System.in); static private byte[] buffer = new byte[BUFFER_SIZE]; static private int bufferPointer = 0,bytesRead = 0; static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); public static String read()throws IOException { byte[] ret = new byte[1024];  int idx = 0;  byte c = Read(); while((c <= ' ')){c = Read(); }do {ret[idx++] = c; c = Read(); }while(((((c != -1) && (c != ' ')) && (c != '\n')) && (c != '\r')));return new String(ret,0,idx);} public static int readInt()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 static long readLong()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;} static private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } static private byte Read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} static void print( Object o){ pr.print(o); } static void println( Object o){ pr.println(o); } static void flush(){ pr.flush(); } static void println(){ pr.println(); } static void exit()throws IOException { din.close(); pr.close(); System.exit(0); } }
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 ( (remCnt == 0)) return ((remSum == 0)?1:0); if ( ((remSum == 0) || (idx == n))) return 0; if ( (memo1[idx][remCnt][remSum] != -1)) return memo1[idx][remCnt][remSum]; int ans = dp1((idx + 1),remCnt,remSum); if ( ((g[idx] == 0) && (t[idx] <= remSum))) {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;} static private 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();} } }
3	public class A{ public static int mod = 1000000007; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  char s[] = new char[n]; for ( int i = 0;(i < n);i++) s[i] = sc.next().charAt(0); int dp[][] = new int[5001][5001];  int sum[][] = new int[5001][5001]; dp[0][0] = 1; sum[0][0] = 1; for ( int i = 1;(i < n);i++) {for ( int j = (n - 1);(j >= 0);j--) {if ( ((s[(i - 1)] == 'f') && (j > 0))) {dp[i][j] = (dp[(i - 1)][(j - 1)] % mod); } else if ( (s[(i - 1)] == 's')) {dp[i][j] = (sum[(i - 1)][j] % mod); } sum[i][j] = ((sum[i][(j + 1)] + dp[i][j]) % mod); }}System.out.println(sum[(n - 1)][0]); } }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long l = in.nextLong();  long r = in.nextLong(); in.close(); if ( ((r - l) < 2)) {System.out.println(-1); return ;} if ( (((r - l) > 2) || ((l % 2) == 0))) { long s = (l + (l % 2)); System.out.println(((((s + " ") + (s + 1)) + " ") + (s + 2))); } else {if ( ((l % 2) == 1)) {System.out.println(-1); } else { long s = l; System.out.println(((((s + " ") + (s + 1)) + " ") + (s + 2))); }}} static long gcd( long a, long b){ if ( (a == 0)) {return b;} if ( (b == 0)) {return a;} if ( (a > b)) {return gcd((a % b),b);} return gcd((b % a),a);} }
5	public class A{ public static void main( String[] ar)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String s1[] = br.readLine().split(" ");  int n = Integer.parseInt(s1[0]);  long x = Long.parseLong(s1[1]);  long y = Long.parseLong(s1[2]);  long S = 0;  long mod = 1000000007;  B a[] = new B[n];  TreeMap<Long,Long> tm = new TreeMap<Long,Long>();  long ans[] = new long[n]; for ( int i = 0;(i < n);i++) { String s2[] = br.readLine().split(" ");  long l = Long.parseLong(s2[0]);  long r = Long.parseLong(s2[1]);  B b1 = new B(l,r); a[i] = b1; }Arrays.sort(a,new The_Comp()); for ( int i = 0;(i < n);i++) { long l = a[i].x;  long r = a[i].y; if ( (tm.floorKey((l - 1)) != null)) { long u = tm.floorKey((l - 1));  long v = l; if ( (((v - u) * y) < x)) {ans[i] = (((r - u) * y) % mod); if ( (tm.get(u) > 1)) tm.put(u,(tm.get(u) - 1)); else tm.remove(u); } else {ans[i] = ((x + ((r - l) * y)) % mod); }} else ans[i] = ((x + ((r - l) * y)) % mod); S = ((S + ans[i]) % mod); if ( tm.containsKey(r)) tm.put(r,(1 + tm.get(r))); else tm.put(r,(long)1); }System.out.println(S); } } class The_Comp implements Comparator<B>{ } class B{ long x = (long)1; long y = (long)1; public B( long l1, long l2){ x = l1; y = l2; } }
2	public class Solution{ public static void main( String[] args){ Solution solution = new Solution(); solution.solve(); } private void solve(){ Scanner in = new Scanner(System.in);  int t = in.nextInt(); while((t-- > 0)){ long n = in.nextLong();  long k = in.nextLong(); System.out.println(solve(n,k)); }} private String solve( long n, long k){ if ( (n > 31)) return ("YES " + (n - 1)); if ( (k > f(n))) return "NO"; long square = 1;  long splitDone = 0;  long size = n;  long splitLeft = 0; while((((splitDone + square) <= k) && (size > 0))){splitDone += square; --size; splitLeft += (((square * 2) - 1) * f(size)); square = ((square * 2) + 1); }if ( (k > (splitDone + splitLeft))) return "NO"; else return ("YES " + size);} private long f( long x){ return (((1L << (2 * x)) - 1) / 3);} }
3	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = in.nextInt(); }Arrays.sort(arr); int cnt = 0;  int pos = 0; while(true){while(((pos < n) && (arr[pos] == -1)))pos++; if ( (pos == n)) break; int min = arr[pos]; arr[pos] = -1; cnt++; for ( int i = (pos + 1);(i < n);i++) {if ( ((arr[i] % min) == 0)) {arr[i] = -1; } }}System.out.println(cnt); } }
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[] ; 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 ;} }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;} } 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); } }
4	public class Main{ public static void pri( ArrayList<Integer> list){ int len = list.size(); for ( int i = 0;(i < (len - 1));++i) System.out.print((list.get(i) + ".")); System.out.println(list.get((len - 1))); } public static void main( String[] args)throws java.io.IOException { Scanner sc = new Scanner(System.in);  int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);++i) {arr[i] = sc.nextInt(); } ArrayList<Integer> cur = new ArrayList<>(); cur.add(1); System.out.println(1); for ( int i = 1;(i < n);++i) {if ( (arr[i] == 1)) {cur.add(1); pri(cur); continue;} int len = cur.size(); while((cur.get((len - 1)) != (arr[i] - 1))){cur.remove((len - 1)); len--; }cur.set((len - 1),arr[i]); pri(cur); continue;}}} }
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();} } }
4	public class CF387D{ static class A{ ArrayList<Integer> list = new ArrayList<>(); int u ,v ,d ; } static int INF = Integer.MAX_VALUE; static boolean bfs( A[] aa, int n){ LinkedList<Integer> queue = new LinkedList<>(); for ( int u = 1;(u <= n);u++) if ( (aa[u].v > 0)) aa[u].d = INF; else {aa[u].d = 0; queue.addLast(u); }aa[0].d = INF; while(!queue.isEmpty()){ int u = queue.removeFirst(); if ( ((aa[u].d + 1) == aa[0].d)) break; for ( int v :aa[u].list) { int w = aa[v].u; if ( (aa[w].d == INF)) {aa[w].d = (aa[u].d + 1); queue.addLast(w); } }}return (aa[0].d != INF);} 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); } }
1	public class A implements Runnable{ String file = "input"; void init()throws IOException { input = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new BufferedOutputStream(System.out)); } void solve()throws IOException { int odd = 0,even = 0;  int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); if ( ((a[i] % 2) == 0)) even++; else odd++; }if ( (even >= 2)) {for ( int i = 0;(i < n);i++) if ( ((a[i] % 2) == 1)) {System.out.println((i + 1)); return ;} } else {for ( int i = 0;(i < n);i++) if ( ((a[i] % 2) == 0)) {System.out.println((i + 1)); return ;} }} String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(input.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} BufferedReader input ; PrintWriter out ; StringTokenizer st ; int test ; public static void main( String[] args)throws IOException { new Thread(null,new A(),"",(1 << 20)).start(); } }
5	public class ProblemA{ static ArrayList<Point2> houses = new ArrayList<Point2>(); public static void main( String[] args){ ProblemA a = new ProblemA();  Scanner in = new Scanner(System.in); while(in.hasNextInt()){ int n = in.nextInt();  double t = in.nextDouble(); for ( int k = 0;(k < n);k++) {houses.add(new Point2(in.nextDouble(),in.nextDouble())); }Collections.sort(houses); int ans = 2; for ( int k = 0;(k < (n - 1));k++) { Point2 cur = houses.get(k);  Point2 next = houses.get((k + 1));  double dist = ((next.x - (next.y / 2)) - (cur.x + (cur.y / 2))); if ( (dist == t)) ans++; if ( (dist > t)) ans += 2; }System.out.println(ans); }} }
6	public class BetaRound81_B implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new BetaRound81_B(),"",(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());} int n ,k ,A ; int[] b ,l ,c ; void solve()throws IOException { n = readInt(); k = readInt(); A = readInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = readInt(); l[i] = readInt(); }c = new int[n]; rec(0,0); out.printf("%.12f\n",ans); } double ans = 0; void rec( int sum, int i){ if ( (i > n)) return ; if ( (sum > k)) return ; if ( (i == n)) {ans = max(ans,p()); return ;} if ( ((l[i] + (c[i] * 10)) <= 100)) { int can = min((k - sum),((100 - (l[i] + (c[i] * 10))) / 10)); for ( int set = can;(set >= 0);set--) {c[i] += set; rec((sum + set),(i + 1)); c[i] -= set; }} } double p(){ int n = c.length;  int need = ((n / 2) + 1);  int[] L = new int[n]; for ( int i = 0;(i < n);i++) {L[i] = (l[i] + (c[i] * 10)); if ( (L[i] > 100)) {throw (new RuntimeException());} } double p = 0; for ( int mask = 0;(mask < (1 << n));mask++) { double q = 1; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & mask) != 0)) {q *= (L[i] / 100.0); } else {q *= (1 - (L[i] / 100.0)); }}if ( (q == 0)) continue; if ( (Integer.bitCount(mask) >= need)) {p += q; } else { int B = 0; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & mask) == 0)) {B += b[i]; } } double q2 = ((double)A / (A + B)); p += (q * q2); }}return p;} }
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(); } @SuppressWarnings("Duplicates") static class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ int MAX = 6000;  int MOD = 1000000007;  int n = in.nextInt();  int[][] dp = new int[n][MAX]; dp[0][0] = 1; char next ;  int current ; for ( int i = 0;(i < n);i++) {next = in.next().charAt(0); if ( (i == (n - 1))) continue; current = 0; for ( int j = (MAX - 1);(j >= 0);j--) {if ( (dp[i][j] != 0)) {if ( (next == 'f')) {if ( (j < (MAX - 1))) dp[(i + 1)][(j + 1)] = ((dp[(i + 1)][(j + 1)] + dp[i][j]) % MOD); } else {current = ((current + dp[i][j]) % MOD); }} if ( (next == 's')) dp[(i + 1)][j] = current; }} int res = 0; for ( int i = 0;(i < MAX);i++) {res = ((res + dp[(n - 1)][i]) % MOD); }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 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;} } }
6	public class Main{ static private StreamTokenizer in ; static private PrintWriter out ; {in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); }static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws Exception { int n = nextInt(),k = nextInt(),A = nextInt(),r = ((n + k) - 1);  int[][] s = new int[n][]; for ( int i = 0;(i < n);i++) {s[i] = new int[]{nextInt(),nextInt()}; } double max = 0;  int[] prb = new int[n]; for ( int u = (1 << r);(u >= 0);u--) { int ones = 0; for ( int i = 0;(i < r);i++) {if ( ((u & (1 << i)) != 0)) {ones++; } }if ( (ones != (n - 1))) {continue;} ones = 0; int p = 0; for ( int i = 0;(i < r);i++) {if ( ((u & (1 << i)) == 0)) {ones++; } else {prb[p] = (ones * 10); p++; ones = 0; }}prb[p] = (ones * 10); p++; ones = 0; double sum = 0; for ( int i = 0;(i < n);i++) {if ( (prb[i] > (100 - s[i][1]))) prb[i] = (100 - s[i][1]); s[i][1] = (prb[i] + s[i][1]); }for ( int i = ((1 << n) - 1);(i >= 0);i--) { double prob = 1;  int lvl = 0;  int kill = 0; for ( int j = 0;(j < n);j++) {if ( ((i & (1 << j)) != 0)) {prob *= (s[j][1] / 100.0); kill--; } else {lvl += s[j][0]; prob *= (1 - (s[j][1] / 100.0)); kill++; }}if ( (kill >= 0)) {sum += (prob * ((double)A / (A + lvl))); } else {sum += prob; }}for ( int i = 0;(i < n);i++) {s[i][1] = (-prb[i] + s[i][1]); }max = Math.max(max,sum); }out.println(max); out.flush(); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader sc = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(1,sc,out); out.close(); } static class Task{ public void solve( int testNumber, InputReader sc, PrintWriter out){ int n = sc.nextInt();  int[] a = new int[n];  boolean[] jud = new boolean[101]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); int ans = 0; for ( int i = 0;(i < n);i++) {if ( jud[a[i]]) continue; ans++; for ( int j = a[i];(j <= 100);j += a[i]) jud[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 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);} } }
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));} }
5	public class Main{ public static void main( String[] args)throws Exception { File _ = new File("chores.in");  BufferedReader br = (_.exists()?new BufferedReader(new FileReader(_)):new BufferedReader(new InputStreamReader(System.in)));  StringTokenizer st ;  String str ; st = new StringTokenizer(br.readLine()); int n ,a ,b ; n = Integer.parseInt(st.nextToken()); a = Integer.parseInt(st.nextToken()); b = Integer.parseInt(st.nextToken()); ArrayList<Integer> chores = new ArrayList<Integer>();  int k ; st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {k = Integer.parseInt(st.nextToken()); chores.add(k); }Collections.sort(chores); System.out.println((chores.get(b) - chores.get((b - 1)))); } }
6	public class Main implements Runnable{ private void solution()throws IOException { int n = in.nextInt();  int m = in.nextInt();  boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = in.nextInt();  int y = in.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; } }}final long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);++i) {for ( int mask = 0;(mask < (1 << (n - i)));++mask) {for ( int j = 0;(j < (n - i));++j) {dp[mask][j] = 0; }}dp[0][0] = 1; for ( int mask = 0;(mask < (1 << (n - i)));++mask) {for ( int j = 0;(j < (n - i));++j) {if ( (dp[mask][j] != 0)) {for ( int k = 0;(k < (n - i));++k) {if ( ((((mask >> k) & 1) == 0) && adj[(j + i)][(k + i)])) {dp[(mask | (1 << k))][k] += dp[mask][j]; } }} }if ( (((mask >> 0) & 1) != 0)) {res += dp[mask][0]; } }}out.println((res / 2)); } private class Scanner{ BufferedReader reader ; 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)); }
3	public final class PythonIndentation{ public static void main( String[] args){ new PythonIndentation(System.in,System.out); } static class Solver implements Runnable{ static final int MOD = ((int)1e9 + 7); int n ; char[] arr ; long[][] dp ; BufferedReader in ; PrintWriter out ; void solve()throws IOException { n = Integer.parseInt(in.readLine()); arr = new char[n]; dp = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i < n);i++) arr[i] = in.readLine().charAt(0); for ( int i = 0;(i <= n);i++) Arrays.fill(dp[i],-1); dp[0][0] = 1; if ( (arr[0] == 's')) out.println(find(1,0)); else out.println(find(1,1)); } long find( int curr, int backIndents){ if ( (backIndents < 0)) return 0; if ( (curr == n)) return dp[curr][backIndents] = 1; if ( (dp[curr][backIndents] != -1)) return dp[curr][backIndents]; long ans ; if ( (arr[curr] == 's')) {if ( (arr[(curr - 1)] == 'f')) ans = find((curr + 1),backIndents); else ans = CMath.mod((find((curr + 1),backIndents) + find(curr,(backIndents - 1))),MOD); } else {ans = find((curr + 1),(backIndents + 1)); if ( (arr[(curr - 1)] != 'f')) {ans = CMath.mod((ans + find(curr,(backIndents - 1))),MOD); } }return dp[curr][backIndents] = ans;} public Solver( BufferedReader in, PrintWriter out){ this.in = in; this.out = out; } } private PythonIndentation( 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),"PythonIndentation",(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(); }} }
6	public class c8{ static int n ; static int[] ds ; static int[][] g ; public static void main( String[] args){ Scanner input = new Scanner(System.in);  int x = input.nextInt(),y = input.nextInt();  int n = input.nextInt();  int[] xs = new int[n],ys = new int[n]; for ( int i = 0;(i < n);i++) {xs[i] = input.nextInt(); ys[i] = input.nextInt(); }ds = new int[n]; g = new int[n][n]; for ( int i = 0;(i < n);i++) {ds[i] = (((x - xs[i]) * (x - xs[i])) + ((y - ys[i]) * (y - ys[i]))); for ( int j = 0;(j < n);j++) {g[i][j] = (((xs[i] - xs[j]) * (xs[i] - xs[j])) + ((ys[i] - ys[j]) * (ys[i] - ys[j]))); }} int[] dp = new int[(1 << n)]; Arrays.fill(dp,987654321); dp[0] = 0; for ( int i = 0;(i < (1 << n));i++) {if ( (dp[i] == 987654321)) continue; for ( int a = 0;(a < n);a++) {if ( ((i & (1 << a)) > 0)) continue; dp[(i | (1 << a))] = Math.min(dp[(i | (1 << a))],(dp[i] + (2 * ds[a]))); for ( int b = (a + 1);(b < n);b++) {if ( ((i & (1 << b)) > 0)) continue; dp[((i | (1 << a)) | (1 << b))] = Math.min(dp[((i | (1 << a)) | (1 << b))],(((dp[i] + ds[a]) + ds[b]) + g[a][b])); }break;}} Stack<Integer> stk = new Stack<Integer>(); stk.add(0); int i = ((1 << n) - 1); trace:while((i > 0)){for ( int a = 0;(a < n);a++) {if ( ((i & (1 << a)) == 0)) continue; if ( (dp[i] == (dp[(i - (1 << a))] + (2 * ds[a])))) {stk.add((a + 1)); stk.add(0); i -= (1 << a); continue trace;} for ( int b = (a + 1);(b < n);b++) {if ( ((i & (1 << b)) == 0)) continue; if ( (dp[i] == (((dp[((i - (1 << a)) - (1 << b))] + ds[a]) + ds[b]) + g[a][b]))) {stk.add((a + 1)); stk.add((b + 1)); stk.add(0); i -= ((1 << a) + (1 << b)); continue trace;} }}}System.out.println(dp[((1 << n) - 1)]); while(!stk.isEmpty())System.out.print((stk.pop() + " ")); } }
3	public class C{ static private final int MOD = ((int)1e9 + 7); public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[][] DP = new int[n][(n + 1)]; DP[0][0] = 1; for ( int i = 0;(i < (n - 1));i++) {if ( (in.next().charAt(0) == 'f')) {for ( int j = 1;(j < n);j++) DP[(i + 1)][j] = DP[i][(j - 1)]; } else {for ( int j = (n - 1);(j >= 0);j--) DP[(i + 1)][j] = ((DP[i][j] + DP[(i + 1)][(j + 1)]) % MOD); }} int answer = 0; for ( int i = 0;(i < n);i++) answer = ((answer + DP[(n - 1)][i]) % MOD); System.out.println(answer); } }
2	public class P_1177B{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long k = scan.nextLong();  long k2 = (k - 10);  int cont = 1,pos ;  String out ; if ( (k <= 9)) System.out.println(k); else {cont++; while((k2 >= (cont * (long)(Math.pow(10,cont) - Math.pow(10,(cont - 1)))))){k2 -= (cont * (long)(Math.pow(10,cont) - Math.pow(10,(cont - 1)))); cont++; }pos = (int)(k2 % cont); k2 /= cont; k2 += (long)Math.pow(10,(cont - 1)); out = String.valueOf(k2); System.out.println(out.charAt(pos)); }} }
0	public class A{ public static void main( String[] args){ System.out.println(25); } }
4	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new FileReader(new File("input.txt")));  PrintWriter pw = new PrintWriter(new File("output.txt"));  StringTokenizer st ; st = new StringTokenizer(in.readLine()); int n = Integer.parseInt(st.nextToken()),m = Integer.parseInt(st.nextToken()),k = Integer.parseInt(in.readLine());  int[][] A = new int[n][m]; st = new StringTokenizer(in.readLine()); for ( int i = 0;(i < k);i++) { int x1 = (Integer.parseInt(st.nextToken()) - 1),y1 = (Integer.parseInt(st.nextToken()) - 1); A[x1][y1] = -10000000; for ( int j = 0;(j < n);j++) {for ( int g = 0;(g < m);g++) {if ( ((A[j][g] == 0) || (A[j][g] > (Math.abs((y1 - g)) + Math.abs((x1 - j)))))) {A[j][g] = (Math.abs((y1 - g)) + Math.abs((x1 - j))); } }}} int f = 0,h = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (A[i][j] != -10000000)) {f = i; h = j; } }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( ((A[i][j] > A[f][h]) && (A[i][j] != -10000000))) {f = i; h = j; } }}pw.println((((f + 1) + " ") + (h + 1))); pw.close(); } }
4	public class FireAgain{ public static void main( String[] args)throws IOException { FileInputStream in = null;  FileOutputStream out = null; try{in = new FileInputStream("input.txt"); out = new FileOutputStream("output.txt"); Scanner sc = new Scanner(in);  int h = sc.nextInt();  int w = sc.nextInt();  int k = sc.nextInt();  int[] xk = new int[k];  int[] yk = new int[k]; for ( int i = 0;(i < k);i++) { int y = (sc.nextInt() - 1);  int x = (sc.nextInt() - 1); xk[i] = x; yk[i] = y; } int best = -1;  int bestx = -1;  int besty = -1; for ( int x = 0;(x < w);x++) {for ( int y = 0;(y < h);y++) { int cur = 99999; for ( int f = 0;(f < k);f++) {cur = Math.min(cur,(Math.abs((xk[f] - x)) + Math.abs((yk[f] - y)))); }if ( (cur > best)) {best = cur; bestx = x; besty = y; } }} String s = (((besty + 1) + " ") + (bestx + 1)); out.write(s.getBytes()); }finally{if ( (in != null)) {in.close(); } if ( (out != null)) {out.close(); } }} }
1	public class ProblemaNoldbaha implements Runnable{ public static void main( String[] args)throws IOException { new Thread(new ProblemaNoldbaha()).start(); } BufferedReader br ; StringTokenizer in ; PrintWriter out ; public String nextToken()throws IOException { while(((in == null) || !in.hasMoreTokens())){in = new StringTokenizer(br.readLine()); }return in.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} public void solve()throws IOException { int n = nextInt();  int k = nextInt();  int[] prime = new int[1000];  int l = 0; for ( int i = 2;(i <= n);i++) { boolean f = false; for ( int j = 2;(j < i);j++) {if ( ((i % j) == 0)) {f = true; break;} }if ( !f) {prime[l] = i; l++; } } int count = 0; for ( int i = 2;(i < l);i++) { boolean f = false; for ( int j = 0;(j < (l - 1));j++) {if ( (((prime[j] + prime[(j + 1)]) + 1) == prime[i])) {f = true; break;} }if ( f) count++; }if ( (count >= k)) {out.println("YES"); } else {out.println("NO"); }} }
1	public class NickAndArray{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int array[] = new int[n];  int max = Integer.MAX_VALUE;  int index = 0; for ( int i = 0;(i < n);i++) { int k = sc.nextInt(); array[i] = k; if ( (array[i] >= 0)) {array[i] = (-array[i] - 1); } if ( (array[i] < max)) {max = array[i]; index = i; } }if ( ((n % 2) != 0)) {array[index] = (-array[index] - 1); } for ( int i = 0;(i < n);i++) {System.out.print((array[i] + " ")); }} }
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){ if ( (idx == n)) return ((((remSum == 0) && (remCnt1 == 0)) && (remCnt2 == 0))?1:0); if ( (((remSum < 0) || (remCnt1 < 0)) || (remCnt2 < 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 ( (g[idx] == 1)) ans += dp2((idx + 1),(remCnt1 - 1),remCnt2,(remSum - t[idx])); else if ( (g[idx] == 2)) ans += dp2((idx + 1),remCnt1,(remCnt2 - 1),(remSum - t[idx])); if ( (ans >= MOD)) ans -= MOD; return memo2[idx][remCnt1][remCnt2][remSum] = ans;} static private int dp3( int cnt0, int cnt1, int cnt2, int last){ if ( (((cnt0 < 0) || (cnt1 < 0)) || (cnt2 < 0))) return 0; if ( (((cnt0 + cnt1) + cnt2) == 0)) return 1; if ( (memo3[last][cnt0][cnt1][cnt2] != -1)) return memo3[last][cnt0][cnt1][cnt2]; long ans = 0; if ( (last != 0)) ans += dp3((cnt0 - 1),cnt1,cnt2,0); if ( (last != 1)) ans += dp3(cnt0,(cnt1 - 1),cnt2,1); if ( (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();} } }
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());} }
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))); } }
0	public class Soal3{ public static void main( String[] args)throws IOException { BufferedReader baca = new BufferedReader(new InputStreamReader(System.in));  String[] masukan = baca.readLine().split(" ");  BigInteger a = new BigInteger(masukan[0]);  BigInteger b = new BigInteger(masukan[1]);  BigInteger i = new BigInteger("0"); while((a.compareTo(new BigInteger("1")) != 0)){if ( (a.compareTo(b) == 1)) {i = i.add(a.divide(b)); if ( (a.mod(b) == new BigInteger("0"))) {a = new BigInteger("1"); b = new BigInteger("0"); } else {a = a.mod(b); }} else { BigInteger temp = a; a = b; b = temp; }}if ( (a.compareTo(new BigInteger("1")) == 0)) {i = i.add(b); } System.out.println(i.toString()); } }
1	public class E17{ static StreamTokenizer in ; static PrintWriter out ; static int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); int n = nextInt(),k = nextInt();  int MAX = n,nprimes = 0;  int[] primes = new int[MAX];  boolean[] isPrime = new boolean[(MAX + 1)]; Arrays.fill(isPrime,true); isPrime[0] = false; isPrime[1] = false; for ( int i = 2;(i <= MAX);i++) if ( isPrime[i]) {primes[nprimes++] = i; for ( int j = (i + i);(j <= MAX);j += i) isPrime[j] = false; } primes[nprimes] = Integer.MAX_VALUE; HashSet<Integer> h = new HashSet<Integer>(); for ( int i = 1;(i < nprimes);i++) { int x = ((primes[(i - 1)] + primes[i]) + 1); if ( (x > n)) break; if ( isPrime[x]) h.add(x); }out.println(((h.size() >= k)?"YES":"NO")); out.flush(); } }
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{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int r = in.nextInt();  int[] xs = new int[n]; for ( int i = 0;(i < n);i++) xs[i] = in.nextInt(); double[] ys = new double[n]; for ( int i = 0;(i < n);i++) { int x = xs[i];  double y = r; for ( int j = 0;(j < i);j++) {y = Math.max(y,calc(xs[j],ys[j],x,r)); }ys[i] = y; }for ( int i = 0;(i < n);i++) {out.printf("%.10f ",ys[i]); }out.println(); } private double calc( int x, double y, int x1, int r){ int dx = Math.abs((x - x1)); if ( (dx > (2 * r))) return 0; double dy = Math.sqrt((((4 * r) * r) - (dx * dx))); return (y + dy);} } static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in),32768); } public String nextLine(){ try{return br.readLine(); }catch (IOException e){ return null;} } public boolean hasNext(){ while(((st == null) || !st.hasMoreTokens())){ String s = nextLine(); if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} public String next(){ hasNext(); return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
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); } static private 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; } }
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);  TaskG2 solver = new TaskG2(); solver.solve(1,in,out); out.close(); } static class TaskG2{ static final int MOD = (1000000000 + 7); static final int MAXN = 51; int getWays( int i, int j, int k, int l, int[][][][] ways, boolean[][][][] cached){ if ( (((i + j) + k) == 0)) return ((l == -1)?1:0); if ( (l < 0)) return 0; if ( cached[i][j][k][l]) return ways[i][j][k][l]; int s = ((i + j) + k);  long value = 0; if ( ((l == 0) && (i != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays((i - 1),j,k,x,ways,cached); } } if ( ((l == 1) && (j != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays(i,(j - 1),k,x,ways,cached); } } if ( ((l == 2) && (k != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays(i,j,(k - 1),x,ways,cached); } } ways[i][j][k][l] = (int)(value % MOD); cached[i][j][k][l] = true; return ways[i][j][k][l];} int totalWays( int i, int j, int k, int[][][][] ways, boolean[][][][] cached, int[] factorial){ long ret = 0; for ( int l = 0;(l < 3);l++) ret += getWays(i,j,k,l,ways,cached); ret *= factorial[i]; ret %= MOD; ret *= factorial[j]; ret %= MOD; ret *= factorial[k]; ret %= MOD; return (int)ret;} int add( int type, int value, int[] sizes, int sum, int[][][][] dp){ sizes[type]++; if ( (type == 0)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 1;(i <= sizes[0]);i++) for ( int j = 0;(j <= sizes[1]);j++) for ( int k = 0;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[(i - 1)][j][k][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} if ( (type == 1)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 0;(i <= sizes[0]);i++) for ( int j = 1;(j <= sizes[1]);j++) for ( int k = 0;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[i][(j - 1)][k][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} if ( (type == 2)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 0;(i <= sizes[0]);i++) for ( int j = 0;(j <= sizes[1]);j++) for ( int k = 1;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[i][j][(k - 1)][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} return (sum + value);} public void solve( int testNumber, InputReader in, OutputWriter out){ int[][][][] ways = new int[MAXN][MAXN][MAXN][3];  boolean[][][][] cached = new boolean[MAXN][MAXN][MAXN][3];  int n = in.nextInt(),T = in.nextInt();  ArrayList<Integer>[] ar = new ArrayList[3]; for ( int i = 0;(i < 3);i++) ar[i] = new ArrayList<Integer>(); int total_sum = 0; for ( int i = 0;(i < n);i++) { int t = in.nextInt(),g = in.nextInt(); ar[(g - 1)].add(t); total_sum += t; }if ( (T > total_sum)) {out.println(0); return ;} int min_index = 0,mn = 100000000; for ( int i = 0;(i < 3);i++) {if ( (ar[i].size() < mn)) {mn = ar[i].size(); min_index = i; } } int[][][][] dp = new int[(ar[((1 + min_index) % 3)].size() + 1)][(ar[((2 + min_index) % 3)].size() + 1)][1][(total_sum + 1)];  int[][][][] dp2 = new int[1][1][(mn + 1)][(total_sum + 1)]; dp[0][0][0][0] = dp2[0][0][0][0] = 1; int[] sizes = {0,0,0};  int sum = 0;  int[] order = {((min_index + 1) % 3),((min_index + 2) % 3)};  int type = 0; for ( int i :order) {for ( int v :ar[i]) sum = add(type,v,sizes,sum,dp); type++; }sum = 0; sizes[0] = sizes[1] = sizes[2] = 0; for ( int i :ar[min_index]) sum = add(2,i,sizes,sum,dp2); int[] factorial = new int[MAXN]; factorial[0] = 1; for ( int i = 1;(i < MAXN);i++) factorial[i] = (int)(((factorial[(i - 1)] * 1L) * i) % MOD); long answer = 0; for ( int i = 0;(i < dp.length);i++) for ( int j = 0;(j < dp[0].length);j++) for ( int k = 0;(k <= mn);k++) for ( int s = 0;(s <= T);s++) { long x = (((dp[i][j][0][s] * 1L) * totalWays(i,j,k,ways,cached,factorial)) % MOD); x *= dp2[0][0][k][(T - s)]; x %= MOD; answer += x; }out.println((answer % MOD)); } } 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); } } 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 println( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }writer.print('\n'); } public void close(){ writer.close(); } } }
6	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());} }
2	public class Main{ static long s ; static boolean check( long n){ int sum = 0;  long storen = n; while((n > 0)){ int k = (int)(n % 10); n /= 10; sum += k; }return ((storen - (long)sum) >= s);} public static void main( String[] args){ PrintWriter pw = new PrintWriter(System.out);  InputReader ip = new InputReader(System.in);  long n ; n = ip.nextLong(); s = ip.nextLong(); if ( (s > n)) {pw.println("0"); } else { long l = 0,r = n;  boolean possible = false;  long mid = 0;  int it = 100; while((it-- > 0)){mid = ((l + r) / 2); if ( check(mid)) {r = mid; possible = true; } else {l = (mid + 1); }}if ( possible) {pw.println(((n - l) + 1)); } else {pw.println("0"); }}pw.close(); } 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); } } }
0	public class Counterexample483A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long l = sc.nextLong();  long r = sc.nextLong(); if ( ((l == r) || ((l + 1) == r))) {System.out.println(-1); return ;} if ( (((l + 2) == r) && ((l % 2) == 1))) {System.out.println(-1); return ;} if ( ((l % 2) == 0)) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); return ;} System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); } }
2	public class main implements Runnable{ static ArrayList<Integer> adj[] ; static int co = 0,f = 0; static void add( int i, int j){ adj[i].add(j); adj[j].add(i); } public static void main( String[] args){ new Thread(null,new main(),"Check2",(1 << 26)).start(); } static long mod = (long)(1e9 + 7); public boolean ch( long a, long s){ long p = 0;  long val = a; while((val > 0)){p = (p + (val % 10)); val = (val / 10); }if ( ((a - p) >= s)) return true; return false;} public boolean rec( int a, int b, int x, int y, int c, int d, int co){ if ( ((a > x) | (b > y))) return false; if ( (((a < -100000) || (b < -100000)) || (co > 100000))) return false; if ( ((a == x) && (b == y))) return true; return (((rec((a + c),(b + d),x,y,c,d,(co + 1)) || rec((a + c),(b - d),x,y,c,d,(co + 1))) || rec((a - c),(b + d),x,y,c,d,(co + 1))) || rec((a - c),(b - d),x,y,c,d,(co + 1)));} static int gcd( int a, int b){ if ( (b == 0)) return a; return gcd(b,(a % b));} static void dfs( int i, int[] v, int val, int[] b){ if ( (v[i] == 1)) return ; v[i] = 1; b[i] = val; Iterator<Integer> it = adj[i].iterator(); while(it.hasNext()){ int q = it.next(); dfs(q,v,val,b); }} static void rec( String s, int a, int b, int n){ if ( (b == n)) {System.out.println(s); return ;} String p = s; if ( (a > b)) {s = (p + ")"); rec(s,a,(b + 1),n); } if ( (a < n)) {s = (p + "("); rec(s,(a + 1),b,n); } } 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 String next(){ return readString();} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ int found = 0; int queryCount = 0; int[] result = new int[8]; public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int left = 1;  int right = (n + 1); while(((left + 1) < right)){ int middle = ((left + right) / 2);  int res = query(middle,1,n,n); if ( (res == 2)) left = middle; else if ( (res == 1)) {findSingle(middle,1,n,n); found++; break;} else {right = middle; }} int top = 1;  int bottom = (n + 1); while(((top + 1) < bottom)){ int middle = ((top + bottom) / 2);  int res = query(1,middle,n,n); if ( (res == 2)) top = middle; else if ( (res == 1)) {if ( ((found == 0) || containsRect(1,middle,n,n,result[0],result[1],result[2],result[3]))) {findSingle(1,middle,n,n); found++; } break;} else {bottom = middle; }}if ( (found < 2)) {left = 0; right = n; while(((left + 1) < right)){ int middle = ((left + right) / 2);  int res = query(1,1,middle,n); if ( (res == 2)) right = middle; else if ( (res == 1)) {if ( ((found == 0) || containsRect(1,1,middle,n,result[0],result[1],result[2],result[3]))) {findSingle(1,1,middle,n); found++; } break;} else {left = middle; }}} if ( (found < 2)) {top = 0; bottom = n; while(((top + 1) < bottom)){ int middle = ((top + bottom) / 2);  int res = query(1,1,n,middle); if ( (res == 2)) bottom = middle; else if ( (res == 1)) {if ( ((found == 0) || containsRect(1,1,n,middle,result[0],result[1],result[2],result[3]))) {findSingle(1,1,n,middle); found++; } break;} else {top = middle; }}} System.out.print("! "); for ( int i = 0;(i < 8);i++) System.out.print((result[i] + " ")); } public boolean containsRect( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){ if ( ((((x1 <= x3) && (y1 <= y3)) && (x2 >= x4)) && (y2 >= y4))) return true; return false;} public void findSingle( int x1, int y1, int x2, int y2){ x1 = findTopX(x1,y1,x2,y2); y1 = findTopY(x1,y1,x2,y2); x2 = findBottomX(x1,y1,x2,y2); y2 = findBottomY(x1,y1,x2,y2); result[(0 + (4 * found))] = x1; result[(1 + (4 * found))] = y1; result[(2 + (4 * found))] = x2; result[(3 + (4 * found))] = y2; } public int findTopX( int x1, int y1, int x2, int y2){ int left = x1;  int right = x2; while(((left + 1) < right)){ int mid = ((left + right) / 2); if ( (query(mid,y1,x2,y2) == 1)) {left = mid; } else {right = mid; }}while((query(right,y1,x2,y2) == 0))right--; return right;} public int findTopY( int x1, int y1, int x2, int y2){ int left = y1;  int right = y2; while(((left + 1) < right)){ int mid = ((left + right) / 2); if ( (query(x1,mid,x2,y2) == 1)) {left = mid; } else {right = mid; }}while((query(x1,right,x2,y2) == 0))right--; return right;} public int findBottomX( int x1, int y1, int x2, int y2){ int left = x1;  int right = x2; while(((left + 1) < right)){ int mid = ((left + right) / 2); if ( (query(x1,y1,mid,y2) == 1)) {right = mid; } else {left = mid; }}while((query(x1,y1,left,y2) == 0))left++; return left;} public int findBottomY( int x1, int y1, int x2, int y2){ int left = y1;  int right = y2; while(((left + 1) < right)){ int mid = ((left + right) / 2); if ( (query(x1,y1,x2,mid) == 1)) {right = mid; } else {left = mid; }}while((query(x1,y1,x2,left) == 0))left++; return left;} public int query( int x1, int y1, int x2, int y2){ queryCount++; System.out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); System.out.flush(); Scanner sc = new Scanner(System.in); return sc.nextInt();} } static class InputReader{ static private BufferedReader in ; static private StringTokenizer tok ; public InputReader( InputStream in){ this.in = new BufferedReader(new InputStreamReader(in)); } public int nextInt(){ return Integer.parseInt(next());} public String next(){ try{while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); } }catch (IOException ex){ System.err.println(("An IOException was caught :" + ex.getMessage())); } return tok.nextToken();} } }
0	public class A{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  String s = bf.readLine(); out.println(25); out.flush(); out.close(); } }
3	public class Main{ public static void main( String[] args){ Main main = new Main(); main.solveC(); } private void solveC(){ Scanner sc = new Scanner(System.in); final long MOD_NUM = 1000000007L;  int N = sc.nextInt();  long[] level = new long[(N + 2)]; level[0] = 1; sc.nextLine(); String pre = "s"; for ( int i = 0;(i < N);i++) { String line = sc.nextLine();  long[] next_level = new long[(N + 2)]; if ( pre.equals("f")) {for ( int j = 1;(j < (N + 1));j++) {next_level[j] = level[(j - 1)]; }} if ( pre.equals("s")) {for ( int j = N;(j >= 0);j--) {next_level[j] = ((next_level[(j + 1)] + level[j]) % MOD_NUM); }} pre = line; level = next_level; } long answer = 0L; for ( int i = 0;(i < (N + 1));i++) {answer = ((answer + level[i]) % MOD_NUM); }System.out.println(answer); } interface Graph{ void link( int from, int to, long cost); Optional<Long> getCost( int from, int to); int getVertexNum(); } interface FlowResolver{ ; } }
0	public class Main{ final int INF = (Integer.MAX_VALUE / 2); private void doit(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( (n == 0)) {System.out.println("0 0 0"); } else if ( (n == 1)) {System.out.println("0 0 1"); } else { ArrayList<Integer> fibList = new ArrayList<Integer>();  int pre = 0;  int next = 1; fibList.add(pre); fibList.add(next); while((next != n)){ int temp = next; next += pre; fibList.add(next); pre = temp; } int len = fibList.size();  int a = fibList.get((len - 4));  int b = fibList.get((len - 3));  int c = fibList.get((len - 3)); System.out.println(((((a + " ") + b) + " ") + c)); }} public static void main( String[] args){ Main obj = new Main(); obj.doit(); } }
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; int h = (int)Math.sqrt((n + 0.5)); if ( ((h * h) == n)) {out.println("YES"); return ;} if ( ((n % 2) == 1)) {out.println("NO"); return ;} n /= 2; h = (int)Math.sqrt((n + 0.5)); if ( ((h * h) == n)) {out.println("YES"); } 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 println( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }writer.print('\n'); } 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 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 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();} 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); } } }
5	public class A{ static BufferedReader in ; static PrintWriter out ; static StringTokenizer st ; static Random rnd ; void solve()throws IOException { int n = nextInt();  int[] arr = new int[n];  Integer[] arrCopy = new Integer[n]; for ( int i = 0;(i < n);i++) arr[i] = arrCopy[i] = nextInt(); Arrays.sort(arrCopy); int bad = 0; for ( int i = 0;(i < n);i++) if ( (arr[i] != arrCopy[i])) ++bad;  boolean fail = (bad > 2); out.println((!fail?"YES":"NO")); } 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());} }
6	public class LookingForOrder{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] parsedString = parsedString = in.readLine().split(" ");  int xStart = parseInt(parsedString[0]);  int yStart = parseInt(parsedString[1]);  int objectNum = parseInt(in.readLine());  int[] xLocs = new int[(objectNum + 1)];  int[] yLocs = new int[(objectNum + 1)];  int[] bitMasks = new int[(1 << objectNum)]; Arrays.fill(bitMasks,MAX_VALUE); int[] previous = new int[(1 << objectNum)]; xLocs[objectNum] = xStart; yLocs[objectNum] = yStart; for ( int i = 0;(i < objectNum);i++) {parsedString = in.readLine().split(" "); xLocs[i] = parseInt(parsedString[0]); yLocs[i] = parseInt(parsedString[1]); } int[][] times = new int[(objectNum + 1)][(objectNum + 1)]; for ( int i = 0;(i <= objectNum);i++) {for ( int j = 0;(j <= objectNum);j++) {times[i][j] = times[j][i] = (((xLocs[i] - xLocs[j]) * (xLocs[i] - xLocs[j])) + ((yLocs[i] - yLocs[j]) * (yLocs[i] - yLocs[j]))); }}bitMasks[0] = 0; for ( int i = 0;(i < (1 << objectNum));i++) {if ( (bitMasks[i] != MAX_VALUE)) {for ( int j = 0;(j < objectNum);j++) {if ( (((1 << j) & i) == 0)) { int curState = ((1 << j) | i);  int curTime = (bitMasks[i] + (2 * times[objectNum][j])); if ( (curTime < bitMasks[curState])) {bitMasks[curState] = curTime; previous[curState] = i; } for ( int k = 0;(k < objectNum);k++) {if ( (((1 << k) & curState) == 0)) { int kState = ((1 << k) | curState);  int kTime = (((bitMasks[i] + times[objectNum][j]) + times[j][k]) + times[k][objectNum]); if ( (kTime < bitMasks[kState])) {bitMasks[kState] = kTime; previous[kState] = i; } } }break;} }} } int finalState = ((1 << objectNum) - 1);  StringBuilder sb = new StringBuilder(); sb.append(bitMasks[finalState]).append('\n'); Deque<Integer> outputQ = new ArrayDeque<>(); outputQ.add(0); int curState = finalState; while((curState > 0)){ int difference = (curState ^ previous[curState]);  int firstItem = -1;  int secondItem = -1; for ( int i = 0;(i < objectNum);i++) {if ( (((1 << i) & difference) > 0)) {secondItem = firstItem; firstItem = i; } }if ( (secondItem != -1)) {outputQ.add((firstItem + 1)); outputQ.add((secondItem + 1)); outputQ.add(0); } else {outputQ.add((firstItem + 1)); outputQ.add(0); }curState = previous[curState]; }sb.append(outputQ.removeLast()); while(!outputQ.isEmpty()){sb.append(' ').append(outputQ.removeLast()); }System.out.print(sb); } }
3	public class Main{ public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out);  Reader in = new Reader();  Main solver = new Main(); solver.solve(out,in); out.flush(); out.close(); } static int INF = (int)1e9; static int maxn = ((int)2e5 + 5); static int mod = 998244353; static int n ,m ,k ,t ,q ,d ,cnt = 2; void solve( PrintWriter out, Reader in)throws IOException { n = in.nextInt(); Integer[] arr = new Integer[n]; for ( int i = 0;(i < n);i++) arr[i] = in.nextInt(); boolean[] vis = new boolean[n]; Arrays.sort(arr); int cnt = 0; for ( int i = 0;(i < n);i++) {if ( vis[i]) continue; cnt++; vis[i] = true; for ( int j = (i + 1);(j < n);j++) {if ( !vis[j]) {if ( ((arr[j] % arr[i]) == 0)) {vis[j] = true; } } }}out.println(cnt); } 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));} } }
2	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] in = br.readLine().split(" ");  long n = Long.parseLong(in[0]),s = Long.parseLong(in[1]);  Solver solver = new Solver(n,s); System.out.println(solver.solve()); } } class Solver{ private long n ,s ; Solver( long n, long s){ this.n = n; this.s = s; } public long solve(){ long low = 1,high = n; for ( int i = 0;(i < 72);++i) { long x = (low + ((high - low) / 2)); if ( check(x)) high = (x - 1); else low = (x + 1); }return (n - high);} private boolean check( long x){ long tmp = x;  int sum = 0; while((tmp > 0)){sum += (tmp % 10); tmp /= 10; }return ((x - sum) >= s);} }
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 ,kk ,bb ; int[] uu ,vv ,uv ,cost ,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_]; kk = new int[n_]; bb = new int[n_]; uu = new int[m_]; vv = new int[m_]; uv = new int[m_]; cost = 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)); } void dijkstra( int s){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((kk[u] != kk[v])?(kk[u] - kk[v]):(u - v)))); pq.add(s); Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first;  int k = (kk[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) && (kk[v] > k)))) {if ( (pi[v] < INF)) pq.remove(v); pi[v] = p; kk[v] = k; bb[v] = h_; pq.add(v); } } }} 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){ System.arraycopy(cost,0,cost_,0,m_); while(true){dijkstra(s); if ( (pi[t] == INF)) break; push1(s,t); for ( int h = 0;(h < m_);h++) { int u = uu[h],v = vv[h]; if ( ((pi[u] != INF) && (pi[v] != INF))) cost_[h] += (pi[u] - pi[v]); }} 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))); } }
2	public class Main{ public static void main( String[] args){ long n ,k ;  Scanner s = new Scanner(System.in); n = s.nextInt(); k = s.nextInt(); System.out.println((int)(n - ((-3 + Math.sqrt((9 + (8 * (n + k))))) / 2))); } }
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));} FastScanner in = new FastScanner(inputStream);  FastPrinter out = new FastPrinter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ static private final int[] dx = {-1,0,+1,0}; static private final int[] dy = {0,+1,0,-1}; static private final int WHITE = 123456789; public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt();  int m = in.nextInt();  int[][] map = new int[n][m]; for ( int i = 0;(i < n);i++) {Arrays.fill(map[i],WHITE); } int k = in.nextInt();  int qh = 0;  int qt = 0;  int[] q = new int[(int)7e6]; for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); map[x][y] = 0; q[qh++] = ((x * m) + y); } int d = 0;  int X = (q[0] / m);  int Y = (q[0] % m); while((qt < qh)){ int pos = q[qt++];  int x = (pos / m);  int y = (pos % m); for ( int i = 0;(i < 4);i++) { int xx = (x + dx[i]);  int yy = (y + dy[i]); if ( ((isValid(xx,n) && isValid(yy,m)) && (map[xx][yy] == WHITE))) {map[xx][yy] = (map[x][y] + 1); q[qh++] = ((xx * m) + yy); if ( (d < map[xx][yy])) {d = map[xx][yy]; X = xx; Y = yy; } } }}out.println((((X + 1) + " ") + (Y + 1))); } private boolean isValid( int x, int X){ return ((x >= 0) && (x < X));} } static class FastScanner{ public BufferedReader br ; public StringTokenizer st ; public FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } public FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public String next(){ while(((st == null) || !st.hasMoreElements())){ 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(next());} } static class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } } }
3	public class Main911D{ public static void main( String[] args){ run(System.in,System.out); } public static void run( InputStream in, PrintStream out){ try(Scanner sc=new Scanner(in)){ int n = sc.nextInt();  int[] t = new int[n];  int inv = 0; for ( int i = 0;(i < n);i++) {t[i] = sc.nextInt(); for ( int j = 0;(j < i);j++) {if ( (t[j] > t[i])) inv++; }}inv = (inv % 2); int m = sc.nextInt(); for ( int i = 0;(i < m);i++) { int a = sc.nextInt();  int b = sc.nextInt();  int s = ((b - a) + 1); inv = ((inv + ((s * (s - 1)) / 2)) % 2); out.println(((inv == 0)?"even":"odd")); } }} }
4	public class p1523C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int t = sc.nextInt(); for ( int i = 0;(i < t);i++) { int n = sc.nextInt();  ArrayList<Stack<Integer>> ar = new ArrayList<Stack<Integer>>(); for ( int j = 0;(j < (n + 1));j++) {ar.add(new Stack<Integer>()); } HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();  StringBuilder cur = new StringBuilder();  int l = 0; for ( int j = 0;(j < n);j++) { int a = sc.nextInt(); if ( (a == 1)) {if ( (cur.length() == 0)) cur.append("1"); else cur.append(".1"); l++; ar.get(1).add(l); hm.put(l,1); } else { int newl = ar.get((a - 1)).pop(); for ( int k = (newl + 1);(k <= l);k++) {ar.get(hm.get(k)).pop(); hm.remove(k); cur.delete((cur.lastIndexOf(".") + 1),cur.length()); cur.delete((cur.length() - 1),cur.length()); }cur.delete((cur.lastIndexOf(".") + 1),cur.length()); cur.append(a); ar.get(a).add(newl); hm.put(newl,a); l = newl; }System.out.println(cur); }}} }
1	public class A{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); String[] ss = br.readLine().split(" ");  int n = ss.length;  int[] a = new int[n]; for ( int i = 0;(i < n);++i) a[i] = Integer.parseInt(ss[i]); for ( int i = 0;(i < n);++i) { boolean ok = true; for ( int j = 0;(j < n);++j) if ( ((j != i) && ((a[j] % 2) == (a[i] % 2)))) ok = false; if ( ok) System.out.println((i + 1)); }} }
1	public class ProblemA{ public void solve(){ boolean oj = true; try{ Reader reader = (oj?new InputStreamReader(System.in):new FileReader("A.in"));  Writer writer = (oj?new OutputStreamWriter(System.out):new FileWriter("A.out"));  BufferedReader br = new BufferedReader(reader);  StreamTokenizer st = new StreamTokenizer(reader);  PrintWriter out = new PrintWriter(writer);  int n = Integer.valueOf(br.readLine());  String s = br.readLine();  MyTokenizer tok = new MyTokenizer(s);  int[] a = new int[2];  int[] ind = new int[2];  int[] c = new int[2]; for ( int i = 0;(i < n);i++) { int p = (int)tok.getNum(); c[(p % 2)]++; a[(p % 2)] = p; ind[(p % 2)] = i; } int b = ind[0]; if ( (c[0] > c[1])) b = ind[1]; out.printf("%d",(b + 1)); br.close(); out.close(); reader.close(); writer.close(); }catch (Exception ex){ ex.printStackTrace(); } } public static void main( String[] args){ ProblemA f = new ProblemA(); f.solve(); } private class MyTokenizer{ private String s ; private int cur ; public MyTokenizer( String s){ this.s = s; cur = 0; } public void skip(){ while(((cur < s.length()) && ((s.charAt(cur) == ' ') || (s.charAt(cur) == '\n')))){cur++; }} public double getNum(){ skip(); String snum = ""; while(((cur < s.length()) && ((((s.charAt(cur) >= '0') && (s.charAt(cur) <= '9')) || (s.charAt(cur) == '.')) || (s.charAt(cur) == '-')))){snum += s.charAt(cur); cur++; }return Double.valueOf(snum);} } }
2	public class Main{ static final int MAX_N = 1000010; static final int INF = 0x3f3f3f3f; static final int mod = 1000000007; public static void main( String[] args)throws IOException { initReader(System.in); solve(); pw.flush(); } public static void solve()throws IOException { while(hasNext()){ long n = (nextLong() - 1);  long k = 1,x = 9; while(((n - (k * x)) >= 0)){n -= (k * x); k += 1; x *= 10; }if ( (n == 0)) pw.println(1); else { long num = ((x / 9) + (n / k));  String s = String.valueOf(num); pw.println(s.charAt((int)(n % k))); }}} static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter pw ; public static void initReader( InputStream input)throws IOException { reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); } public static boolean hasNext(){ try{while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); } }catch (Exception e){ return false;} return true;} public static String next()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} public static long nextLong()throws IOException { return Long.parseLong(next());} }
2	public class Main{ static final long Mod = 1000000009; static long n ,m ,k ,t ,l ,u ,ans ; static Scanner cin = new Scanner(System.in); static long multi_mod( long base, long cur){ long res = 1; while((cur > 0)){if ( ((cur % 2) == 1)) res = ((res * base) % Mod); cur >>= 1; base = ((base * base) % Mod); }return res;} public static void main( String[] args){ n = cin.nextLong(); m = cin.nextLong(); k = cin.nextLong(); l = (((k - 1) * (n / k)) + (n % k)); if ( (m <= l)) {System.out.println(m); } else {t = (n / k); u = (m - l); ans = (((0 + ((t - u) * (k - 1))) + (n % k)) % Mod); ans = ((ans + ((k * (((multi_mod(2,(u + 1)) - 2) + Mod) % Mod)) % Mod)) % Mod); System.out.println(ans); }} }
6	public class Main{ BufferedReader in ; StringTokenizer str = null; PrintWriter out ; private String next()throws Exception { if ( ((str == null) || !str.hasMoreElements())) str = new StringTokenizer(in.readLine()); return str.nextToken();} private int nextInt()throws Exception { return Integer.parseInt(next());} int[] x ,y ; int n ; int[] dp ,prev ; public void run()throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int xs = nextInt();  int ys = nextInt(); n = nextInt(); x = new int[n]; y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = nextInt(); y[i] = nextInt(); } int one[] = new int[n]; for ( int i = 0;(i < n);i++) {one[i] = dist(xs,ys,x[i],y[i]); } int two[][] = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {two[i][j] = two[j][i] = ((dist(xs,ys,x[i],y[i]) + dist(x[i],y[i],x[j],y[j])) + dist(xs,ys,x[j],y[j])); }}dp = new int[(1 << n)]; Arrays.fill(dp,(Integer.MAX_VALUE / 2)); dp[0] = 0; prev = new int[(1 << n)]; Arrays.fill(prev,-1); for ( int mask = 1;(mask < (1 << n));mask++) { int i = 0; while(((mask & (1 << i)) == 0))i++; dp[mask] = (dp[(mask ^ (1 << i))] + (2 * one[i])); prev[mask] = (i + 1); for ( int j = (i + 1);(j < n);j++) {if ( ((mask & (1 << j)) > 0)) {if ( (dp[mask] > (dp[((mask ^ (1 << i)) ^ (1 << j))] + two[i][j]))) {dp[mask] = (dp[((mask ^ (1 << i)) ^ (1 << j))] + two[i][j]); prev[mask] = ((100 * (i + 1)) + (j + 1)); } } }}out.println(dp[((1 << n) - 1)]); out.print((0 + " ")); int cur = ((1 << n) - 1);  int i = 0,j = 0; while((cur > 0)){i = (prev[cur] / 100); j = (prev[cur] % 100); if ( (i > 0)) {cur ^= (1 << (i - 1)); out.print((i + " ")); } if ( (j > 0)) {cur ^= (1 << (j - 1)); out.print((j + " ")); } out.print((0 + " ")); }out.close(); } private int dist( int x1, int y1, int x2, int y2){ return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));} public static void main( String[] args)throws Exception { new Main().run(); } }
5	public class Main{ static Scanner in = new Scanner(System.in); public static void main( String[] args){ int n = in.nextInt();  int t = in.nextInt();  List<Integer> v = new ArrayList<Integer>(n); for ( int i = 0;(i < n);i++) { int a = in.nextInt();  int b = in.nextInt(); v.add(((2 * a) - b)); v.add(((2 * a) + b)); }Collections.sort(v); int ans = 2; for ( int i = 2;(i < v.size());i += 2) {if ( ((v.get(i) - v.get((i - 1))) > (2 * t))) ans += 2; if ( ((v.get(i) - v.get((i - 1))) == (2 * t))) ans++; }System.out.println(ans); } }
6	public class Template{ public static void main( String[] args)throws IOException { final Scanner in = new Scanner(System.in); final PrintStream out = System.out;  int n = in.nextInt(),m = in.nextInt();  boolean[][] g = new boolean[n][n]; for ( int i = 0;(i < m);++i) { int a = in.nextInt(),b = in.nextInt(); --a; --b; g[a][b] = g[b][a] = true; }final int mx = (1 << n);  long[][] dp = new long[mx][n];  long res = 0; for ( int mask = 0;(mask < mx);++mask) for ( int i = 0;(i < n);++i) {if ( (mask == (1 << i))) {dp[mask][i] = 1; } else if ( (((mask & (1 << i)) != 0) && ((mask & ((1 << i) - 1)) != 0))) { long r = 0;  int next = (mask ^ (1 << i)); for ( int j = 0;(j < n);++j) if ( g[i][j]) {r += dp[next][j]; } dp[mask][i] = r; } else {dp[mask][i] = 0; }if ( (((mask & (mask - 1)) != 0) && g[i][lowestBit(mask)])) {res += dp[mask][i]; } }System.out.println(((res - m) / 2)); } static private int lowestBit( int mask){ for ( int i = 0;;++i) {if ( ((mask & (1 << i)) > 0)) {return i;} }} }
3	public class CFA{ static private final String INPUT = ("8\n" + "7 6 5 4 3 2 2 3\n"); static private final int MOD = 1_000_000_007; private PrintWriter out ; private FastScanner sc ; public static void main( String[] args){ new CFA().run(); } public void run(){ sc = new FastScanner((oj?System.in:new ByteArrayInputStream(INPUT.getBytes()))); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(((System.currentTimeMillis() - s) + "ms")); } static class Color{ int nr ; boolean used ; public Color( int nr){ this.nr = nr; } } private void solve(){ int n = sc.nextInt();  Color[] a = new Color[n]; for ( int i = 0;(i < n);i++) {a[i] = new Color(sc.nextInt()); }Arrays.sort(a,Comparator.comparingInt((c)->c.nr)); int ans = 0; for ( int i = 0;(i < n);i++) {if ( a[i].used) continue; ans++; for ( int j = (i + 1);(j < n);j++) {if ( ((a[j].nr % a[i].nr) == 0)) {a[j].used = true; } }}out.println(ans); } int[] sort( int[] a){ final int SHIFT = 16,MASK = ((1 << SHIFT) - 1),SIZE = ((1 << SHIFT) + 1);  int n = a.length,ta[] = new int[n],ai[] = new int[SIZE]; for ( int i = 0;(i < n);ai[((a[i] & MASK) + 1)]++,i++) ;for ( int i = 1;(i < SIZE);ai[i] += ai[(i - 1)],i++) ;for ( int i = 0;(i < n);ta[ai[(a[i] & MASK)]++] = a[i],i++) ; int[] t = a; a = ta; ta = t; ai = new int[SIZE]; for ( int i = 0;(i < n);ai[((a[i] >> SHIFT) + 1)]++,i++) ;for ( int i = 1;(i < SIZE);ai[i] += ai[(i - 1)],i++) ;for ( int i = 0;(i < n);ta[ai[(a[i] >> SHIFT)]++] = a[i],i++) ;return ta;} static private int gcd( int a, int b){ BigInteger b1 = BigInteger.valueOf(a);  BigInteger b2 = BigInteger.valueOf(b);  BigInteger gcd = b1.gcd(b2); return gcd.intValue();} static private long gcd( long a, long b){ BigInteger b1 = BigInteger.valueOf(a);  BigInteger b2 = BigInteger.valueOf(b);  BigInteger gcd = b1.gcd(b2); return gcd.longValue();} @SuppressWarnings("unused") static class FastScanner{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; 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 long nextLong(){ return Long.parseLong(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();} } 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 long[][] memo ; static boolean[][] adjMat ; static int N ,endNode ; static ArrayList<Integer>[] bits ; static long dp( int idx, int msk){ if ( (memo[idx][msk] != -1)) return memo[idx][msk]; long ret = (adjMat[idx][endNode]?1:0); for ( int i = 0,sz = bits[msk].size();(i < sz);++i) { int j = bits[msk].get(i); if ( (j > endNode)) break; if ( adjMat[idx][j]) ret += dp(j,(msk | (1 << j))); }return memo[idx][msk] = ret;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out); N = sc.nextInt(); adjMat = new boolean[N][N]; bits = new ArrayList[(1 << N)]; for ( int i = 0;(i < (1 << N));++i) {bits[i] = new ArrayList<>(1); for ( int j = 0;(j < N);++j) if ( ((i & (1 << j)) == 0)) bits[i].add(j); } int M = sc.nextInt(); while((M-- > 0)){ int u = (sc.nextInt() - 1),v = (sc.nextInt() - 1); adjMat[u][v] = adjMat[v][u] = true; } long ans = 0; for ( int i = N;(i > 1);--i) {memo = new long[i][(1 << i)]; for ( long[] x :memo) Arrays.fill(x,-1); ans += dp(endNode = (i - 1),(1 << endNode)); }for ( int i = 0;(i < N);++i) for ( int j = (i + 1);(j < N);++j) if ( adjMat[i][j]) --ans; out.println((ans >> 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 int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
2	public class C{ static private final String REGEX = " "; static private final Boolean DEBUG = false; static private final String FILE_NAME = "input.txt"; public static void main( String[] args)throws IOException { if ( DEBUG) {generate(); } Solver solver = new Solver(); solver.readData(); solver.solveAndPrint(); } static private void generate()throws IOException { } static private class Solver{ long n ,s ; void readData()throws IOException { InputStream in = (DEBUG?new FileInputStream(FILE_NAME):System.in);  Scanner scanner = new Scanner(in); n = scanner.nextLong(); s = scanner.nextLong(); scanner.close(); } void solveAndPrint(){ long cur = (s + 1);  long sum = getSum(cur);  long res = 0; while((cur <= n)){if ( ((cur - sum) >= s)) {System.out.println(((n - cur) + 1)); return ;} cur++; if ( ((cur % 10) != 0)) {sum++; } else {sum = getSum(cur); }}System.out.println(0); } long getSum( long cur){ long res = 0; while((cur > 0)){res += (cur % 10); cur /= 10; }return res;} @SuppressWarnings int[] splitInteger( String string, int n){ final String[] split = string.split(REGEX,n);  int[] result = new int[split.length]; for ( int i = 0;(i < n);++i) {result[i] = Integer.parseInt(split[i]); }return result;} public int[] splitInteger( String string){ return splitInteger(string,0);} @SuppressWarnings long[] splitLong( String string, int n){ final String[] split = string.split(REGEX,n);  long[] result = new long[split.length]; for ( int i = 0;(i < n);++i) {result[i] = Long.parseLong(split[i]); }return result;} public long[] splitLong( String string){ return splitLong(string,0);} @SuppressWarnings double[] splitDouble( String string, int n){ final String[] split = string.split(REGEX,n);  double[] result = new double[split.length]; for ( int i = 0;(i < n);++i) {result[i] = Double.parseDouble(split[i]); }return result;} public double[] splitDouble( String string){ return splitDouble(string,0);} @SuppressWarnings String[] splitString( String string, int n){ return string.split(REGEX,n);} public String[] splitString( String string){ return splitString(string,0);} public int max( int a, int b){ return Math.max(a,b);} public long max( long a, long b){ return Math.max(a,b);} public int min( int a, int b){ return Math.min(a,b);} public long min( long a, long b){ return Math.min(a,b);} public double max( double a, double b){ return Math.max(a,b);} public double min( double a, double b){ return Math.min(a,b);} static private final int MOD = 1000000009; } }
3	public class G{ static final int MOD = 1000000007; static int add( int a, int b){ int res = (a + b); return ((res >= MOD)?(res - MOD):res);} static int mul( int a, int b){ int res = (int)(((long)a * b) % MOD); return ((res < 0)?(res + MOD):res);} static int pow( int a, int e){ if ( (e == 0)) {return 1;} int r = a; for ( int i = (30 - Integer.numberOfLeadingZeros(e));(i >= 0);i--) {r = mul(r,r); if ( ((e & (1 << i)) != 0)) {r = mul(r,a); } }return r;} static int inv( int a){ return pow(a,(MOD - 2));} static void solve()throws Exception { String x = scanString();  int n = x.length();  int pows[][] = new int[10][n]; for ( int i = 0;(i < 10);i++) {pows[i][0] = 1; for ( int j = 1;(j < n);j++) {pows[i][j] = mul(pows[i][(j - 1)],i); }} int ru[] = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {ru[i] = add(1,mul(10,ru[(i - 1)])); } int facts[] = new int[n]; facts[0] = 1; for ( int i = 1;(i < n);i++) {facts[i] = mul(facts[(i - 1)],i); } int factsInv[] = new int[n]; factsInv[(n - 1)] = inv(facts[(n - 1)]); for ( int i = (n - 1);(i > 0);i--) {factsInv[(i - 1)] = mul(factsInv[i],i); } int ans = 0;  int off[] = new int[10]; for ( int i = 0;(i < n);i++) { int cd = (x.charAt(i) - '0');  int l = ((n - i) - 1); for ( int d = 1;(d < 10);d++) {for ( int p = 0;(p <= l);p++) { int mul = ((d < cd)?add(mul(d,ru[(p + off[d])]),mul((cd - d),ru[((p + off[d]) + 1)])):mul(cd,ru[(p + off[d])])); ans = add(ans,mul(mul,mul(mul(pows[d][(l - p)],pows[(10 - d)][p]),mul(facts[l],mul(factsInv[p],factsInv[(l - p)]))))); }}for ( int d = 0;(d <= cd);d++) {++off[d]; }}for ( int d = 1;(d < 10);d++) {ans = add(ans,ru[off[d]]); }out.print(ans); } 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 paintTheNumbers{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = scanner.nextInt(); }System.out.print(paint(arr)); } public static int paint( int[] arr){ Arrays.sort(arr); HashSet<Integer> set = new HashSet<>();  int num = arr[0]; set.add(num); for ( int i = 1;(i < arr.length);i++) {if ( !divBySet(set,arr[i])) {set.add(arr[i]); } }return set.size();} public static boolean divBySet( HashSet<Integer> set, int a){ for ( int s :set) {if ( ((a % s) == 0)) {return true;} }return false;} }
1	public class Main{ static String S ; public static void main( String[] args){ FastScanner sc = new FastScanner(System.in); S = sc.next(); System.out.println(solve()); } static int solve(){ int ans = -1;  int time = 1;  int n = S.length(); for ( int i = 1;(i < (n * 2));i++) {if ( (S.charAt(((i - 1) % n)) != S.charAt((i % n)))) {time++; } else {ans = Math.max(time,ans); time = 1; }}ans = Math.max(time,ans); if ( (ans == (n * 2))) {return n;} else {return ans;}} @SuppressWarnings("unused") static class FastScanner{ private BufferedReader reader ; private StringTokenizer tokenizer ; FastScanner( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } String next(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} } return tokenizer.nextToken();} long nextLong(){ return Long.parseLong(next());} int nextInt(){ return Integer.parseInt(next());} } static int max( int... as){ int max = Integer.MIN_VALUE; for ( int a :as) max = Math.max(a,max); return max;} static int min( int... as){ int min = Integer.MAX_VALUE; for ( int a :as) min = Math.min(a,min); return min;} }
3	public class Main{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new PrintStream(System.out));  int n = Integer.parseInt(f.readLine());  StringTokenizer st = new StringTokenizer(f.readLine());  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(st.nextToken()); }Arrays.sort(arr); int ans = 0;  boolean[] used = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !used[i]) {ans++; for ( int j = (i + 1);(j < n);j++) {if ( (!used[j] && ((arr[j] % arr[i]) == 0))) {used[j] = true; } }used[i] = true; } }System.out.print(ans); f.close(); out.close(); } }
5	public class ProblemA{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int t = s.nextInt();  TreeMap<Integer,Integer> map = new TreeMap<Integer,Integer>(); while(s.hasNextInt()){ int i = s.nextInt();  int j = s.nextInt(); map.put(i,j); } int count = 0;  double left = -100000;  double right ;  int size ; for ( Integer i :map.keySet()) {size = map.get(i); right = ((double)i - ((double)size / 2.0)); if ( ((right - left) > t)) {count += 2; } if ( ((right - left) == t)) {count++; } left = ((double)i + ((double)size / 2.0)); }System.out.println(count); } }
6	public class r568p8{ static private InputReader sc ; static private PrintWriter pw ; static private 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(); } static private 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); }} static private 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;} static private 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); } }
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 Thread(){public void run(){ try{new Main().run(); }catch (IOException e){ } } }.start(); } 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();} }
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());} } }
6	public class C{ public static void main( String[] args){ new C().run(); } private void run(){ Scanner sc = new Scanner(System.in);  int sx = sc.nextInt();  int sy = sc.nextInt();  int n = sc.nextInt();  int[] x = new int[n];  int[] y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = sc.nextInt(); y[i] = sc.nextInt(); }sc.close(); int[] w = new int[(n * n)];  int[] pMask = new int[(n * n)]; for ( int i = 0;(i < n);i++) {for ( int j = i;(j < n);j++) { int ind = ((i * n) + j); if ( (i == j)) {w[ind] = (2 * dist(sx,sy,x[i],y[i])); pMask[ind] = (1 << i); } else {w[ind] = ((dist(sx,sy,x[i],y[i]) + dist(x[i],y[i],x[j],y[j])) + dist(x[j],y[j],sx,sy)); pMask[ind] = ((1 << i) | (1 << j)); }}} int max = (1 << n);  int[] p = new int[max];  int[] dist = new int[max]; Arrays.fill(dist,(Integer.MAX_VALUE / 2)); dist[0] = 0; int[] available = new int[(n * n)]; for ( int mask = 0;(mask < max);mask++) { int ac = 0; for ( int i = 0;(i < n);i++) {if ( (((mask >> i) & 1) == 0)) {available[ac++] = i; } } int s = 0; for ( int j = s;(j < ac);j++) { int a = available[s];  int b = available[j];  int ind = ((a * n) + b);  int nextMask = (mask | pMask[ind]);  int newD = (dist[mask] + w[ind]); if ( (newD < dist[nextMask])) {dist[nextMask] = newD; p[nextMask] = ind; } }}System.out.println(dist[(max - 1)]); ArrayList<Integer> steps = new ArrayList<Integer>();  int mask = (max - 1); while((mask > 0)){ int msk = p[mask]; steps.add(msk); int a = (msk / n);  int b = (msk % n); if ( (a == b)) {mask ^= (1 << a); } else {mask ^= (1 << a); mask ^= (1 << b); }}System.out.print(0); for ( int i = (steps.size() - 1);(i >= 0);i--) { int msk = steps.get(i);  int a = (msk / n);  int b = (msk % n); if ( (a == b)) {System.out.printf(" %d 0",(a + 1)); } else {System.out.printf(" %d %d 0",(a + 1),(b + 1)); }}System.out.println(); } private int dist( int x1, int y1, int x2, int y2){ return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));} }
1	public class Main{ static class Reader{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ,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 s(){ 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 i(){ 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));} } public static void main( String[] args){ Reader sc = new Reader();  PrintWriter out = new PrintWriter(System.out);  int n = sc.i();  String s1 = sc.s();  String s2 = sc.s();  int pos1 = -1;  int pos2 = -1;  int arr[][][] = new int[100][100][2]; for ( int i = 0;(i < n);i++) {if ( (s1.charAt(i) != s2.charAt(i))) {if ( (arr[(s2.charAt(i) - 97)][(s1.charAt(i) - 97)][0] == 1)) {pos2 = i; pos1 = arr[(s2.charAt(i) - 97)][(s1.charAt(i) - 97)][1]; break;} arr[(s1.charAt(i) - 97)][(s2.charAt(i) - 97)][0] = 1; arr[(s1.charAt(i) - 97)][(s2.charAt(i) - 97)][1] = i; } } int ham = 0; for ( int i = 0;(i < n);i++) {if ( (s1.charAt(i) != s2.charAt(i))) ham++; }if ( ((pos1 != -1) && (pos2 != -1))) {System.out.println((ham - 2)); System.out.println((((pos1 + 1) + " ") + (pos2 + 1))); System.exit(0); } int arr1[][] = new int[100][2];  int arr2[][] = new int[100][2]; for ( int i = 0;(i < n);i++) {if ( (s1.charAt(i) != s2.charAt(i))) {if ( (arr1[(s1.charAt(i) - 97)][0] == 1)) {pos2 = i; pos1 = arr1[(s1.charAt(i) - 97)][1]; break;} if ( (arr2[(s2.charAt(i) - 97)][0] == 1)) {pos2 = i; pos1 = arr2[(s2.charAt(i) - 97)][1]; break;} arr1[(s2.charAt(i) - 97)][0] = 1; arr1[(s2.charAt(i) - 97)][1] = i; arr2[(s1.charAt(i) - 97)][0] = 1; arr2[(s1.charAt(i) - 97)][1] = i; } }if ( ((pos1 != -1) && (pos2 != -1))) {System.out.println((ham - 1)); System.out.println((((pos1 + 1) + " ") + (pos2 + 1))); System.exit(0); } System.out.println(ham); System.out.println(((pos1 + " ") + pos2)); } }
2	public class Main{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt(),k = sc.nextInt();  long rhs = (2l * (n + k)); for ( int x = 1;;x++) { long lhs = (((1l * x) * x) + (3l * x)); if ( (rhs == lhs)) {out.println((n - x)); break;} }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 int nextInt()throws IOException { return Integer.parseInt(next());} public double nextDouble()throws IOException { return Double.parseDouble(next());} public Long nextLong()throws IOException { return Long.parseLong(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;  QuickScanner in = new QuickScanner(inputStream);  QuickWriter out = new QuickWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ static boolean LOCAL = false; static int TEST_CASE = 10000; QuickScanner in ; QuickWriter out ; int n ; Server server ; public void solve( int testNumber, QuickScanner in, QuickWriter out){ this.in = in; this.out = out; n = (LOCAL?(1 << 16):in.nextInt()); server = new Server(); for ( int remCases = (LOCAL?TEST_CASE:1);(remCases > 0);--remCases) {server.init(n); Rect[] rects = split(0); if ( (rects == null)) {rects = split(1); } rects[0] = shrink(rects[0]); rects[1] = shrink(rects[1]); server.answer(rects[0],rects[1]); }} Rect[] split( int dim){ int lower = 1,upper = (n - 1),res = 0;  Rect fullRect = new Rect(1,1,n,n); while((lower <= upper)){ int medium = ((lower + upper) >> 1); if ( (server.ask(fullRect.update(1,dim,medium)) == 0)) {res = medium; lower = (medium + 1); } else {upper = (medium - 1); }} Rect[] rects = new Rect[]{fullRect.update(1,dim,(res + 1)),fullRect.update(0,dim,(res + 2))}; return (((server.ask(rects[0]) == 1) && (server.ask(rects[1]) == 1))?rects:null);} Rect shrink( Rect rect){ rect = shrink(rect,0); rect = shrink(rect,1); return rect;} Rect shrink( Rect rect, int dim){ int lower ,upper ,res ; lower = (rect.getValue(0,dim) + 1); upper = rect.getValue(1,dim); res = (lower - 1); while((lower <= upper)){ int medium = ((lower + upper) >> 1); if ( (server.ask(rect.update(0,dim,medium)) == 1)) {res = medium; lower = (medium + 1); } else {upper = (medium - 1); }}rect = rect.update(0,dim,res); lower = rect.getValue(0,dim); upper = (rect.getValue(1,dim) - 1); res = (upper + 1); while((lower <= upper)){ int medium = ((lower + upper) >> 1); if ( (server.ask(rect.update(1,dim,medium)) == 1)) {res = medium; upper = (medium - 1); } else {lower = (medium + 1); }}return rect.update(1,dim,res);} class Server{ Rect rect1 ; Rect rect2 ; Server(){ rect1 = new Rect(); rect2 = new Rect(); } void init( int n){ if ( LOCAL) {do {rect1.initRandom(n); rect2.initRandom(n); }while(!rect1.valid(rect2));} } int ask( Rect rect){ out.print("? "); rect.print(); out.println(); out.flush(); if ( LOCAL) {return ((rect1.in(rect)?1:0) + (rect2.in(rect)?1:0));} else {return in.nextInt();}} void answer( Rect rect1, Rect rect2){ out.print("! "); rect1.print(); out.print(' '); rect2.print(); out.println(); out.flush(); if ( LOCAL) {if ( ((rect1.equals(this.rect1) && rect2.equals(this.rect2)) || (rect2.equals(this.rect1) && rect1.equals(this.rect2)))) {System.out.println("AC!"); } else {System.out.println("WA!"); throw (new IllegalArgumentException());}} } } class Rect{ final Random random = new Random(); int x1 ; int y1 ; int x2 ; int y2 ; Rect(){ } Rect( int x1, int y1, int x2, int y2){ this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } void initRandom( int n){ x1 = random.nextInt(n); x2 = ((random.nextInt((n - x1)) + x1) + 1); ++x1; y1 = random.nextInt(n); y2 = ((random.nextInt((n - y1)) + y1) + 1); ++y1; } int getValue( int idx1, int idx2){ switch(((idx1 << 1) | idx2)){ case 0:return x1; case 1:return y1; case 2:return x2; case 3:return y2; } throw (new IllegalArgumentException());} Rect update( int idx1, int idx2, int value){ switch(((idx1 << 1) | idx2)){ case 0:return new Rect(value,y1,x2,y2); case 1:return new Rect(x1,value,x2,y2); case 2:return new Rect(x1,y1,value,y2); case 3:return new Rect(x1,y1,x2,value); } return null;} boolean valid( Rect o){ if ( (x2 < o.x1)) return true; if ( (y2 < o.y1)) return true; if ( (o.x2 < x1)) return true; if ( (o.y2 < y1)) return true; return false;} boolean in( Rect o){ return ((((o.x1 <= x1) && (x2 <= o.x2)) && (o.y1 <= y1)) && (y2 <= o.y2));} boolean equals( Rect o){ return ((((x1 == o.x1) && (y1 == o.y1)) && (x2 == o.x2)) && (y2 == o.y2));} void print(){ out.printf("%d %d %d %d",x1,y1,x2,y2); } } } static class QuickScanner{ static private final int BUFFER_SIZE = 1024; private InputStream stream ; private byte[] buffer ; private int currentPostion ; private int numberOfChars ; public QuickScanner( InputStream stream){ this.stream = stream; this.buffer = new byte[BUFFER_SIZE]; this.currentPostion = 0; this.numberOfChars = 0; } public int nextInt(){ int c = nextNonSpaceChar();  boolean positive = true; if ( (c == '-')) {positive = false; c = nextChar(); } int res = 0; do {if ( ((c < '0') || ('9' < c))) throw (new RuntimeException()); res = (((res * 10) + c) - '0'); c = nextChar(); }while(!isSpaceChar(c));return (positive?res:-res);} public int nextNonSpaceChar(){ int res = nextChar(); for ( ;(isSpaceChar(res) || (res < 0));res = nextChar()) ;return res;} public int nextChar(){ if ( (numberOfChars == -1)) {throw (new RuntimeException());} if ( (currentPostion >= numberOfChars)) {currentPostion = 0; try{numberOfChars = stream.read(buffer); }catch (Exception e){ throw (new RuntimeException(e));} if ( (numberOfChars <= 0)) {return -1;} } return buffer[currentPostion++];} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c < 0));} } static class QuickWriter{ private final PrintWriter writer ; public QuickWriter( OutputStream outputStream){ this.writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public QuickWriter( 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.print('\n'); } public void printf( String format, Object... objects){ writer.printf(format,objects); } public void close(){ writer.close(); } public void flush(){ writer.flush(); } } }
6	public class C{ public static double Epsilon = 1e-6; public static long x ,y ,d ; public static long MOD = 1000000007; public static int[][][] dp ; public static int min ,max ,need ; public static void main( String[] args){ Scanner in = new Scanner();  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int m = in.nextInt(); min = Math.min(n,m); max = ((m + n) - min); dp = new int[max][(1 << min)][(1 << min)]; for ( int[][] temp :dp) {for ( int[] val :temp) {Arrays.fill(val,-1); }}need = ((1 << min) - 1); out.println(cal(0,0,0)); out.close(); } public static int cal( int index, int last, int lastHold){ if ( (index == max)) {return 0;} if ( (dp[index][lastHold][last] != -1)) {return dp[index][lastHold][last];} int result = 0; for ( int i = 0;(i < (1 << min));i++) {if ( (((i | last) == need) || (index == 0))) {if ( (((index + 1) == max) && (match(i,lastHold) != need))) {continue;} int temp = (cal((index + 1),match(i,lastHold),i) + (min - Integer.bitCount(i))); result = ((result < temp)?temp:result); } }dp[index][lastHold][last] = result; return result;} public static int match( int mask, int last){ int result = last; for ( int i = 0;(i < min);i++) {if ( (((1 << i) & mask) != 0)) { int a = (i - 1);  int b = (i + 1); result |= (1 << i); if ( (a >= 0)) {result |= (1 << a); } if ( (b < min)) {result |= (1 << b); } } }return result;} public static long pow( long a, long b){ if ( (b == 0)) {return 1;} long val = pow(a,(b / 2)); if ( ((b % 2) == 0)) {return ((val * val) % MOD);} else {return ((a * ((val * val) % MOD)) % MOD);}} public static void extendEuclid( long a, long b){ if ( (b == 0)) {x = 1; y = 0; d = a; return ;} extendEuclid(b,(a % b)); long x1 = y;  long y1 = (x - ((a / b) * y)); x = x1; y = y1; } public static long gcd( long a, long b){ if ( (b == 0)) {return a;} return gcd(b,(a % b));} static class Line{ double a ,b ,c ; Line( double x1, double y1, double x2, double y2){ if ( ((Math.abs((x1 - x2)) < Epsilon) && (Math.abs((y1 - y2)) < Epsilon))) {throw (new RuntimeException("Two point are the same"));} a = (y1 - y2); b = (x2 - x1); c = ((-a * x1) - (b * y1)); } Line( Point x, Point y){ this(x.x,x.y,y.x,y.y); } public Point intersect( Line l){ double d = ((a * l.b) - (b * l.a)); if ( (d == 0)) {throw (new RuntimeException("Two lines are parallel"));} return new Point((((l.c * b) - (c * l.b)) / d),(((l.a * c) - (l.c * a)) / d));} } static Point intersect( Point a, Point b, Point c){ double D = cross(a,b); if ( (D != 0)) {return new Point((cross(c,b) / D),(cross(a,c) / D));} return null;} static Point minus( Point a, Point b){ return new Point((a.x - b.x),(a.y - b.y));} static Point add( Point a, Point b){ return new Point((a.x + b.x),(a.y + b.y));} static double cross( Point a, Point b){ return ((a.x * b.y) - (a.y * b.x));} static class Point{ double x ,y ; Point( double x, double y){ this.x = x; this.y = y; } } 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());} } }
3	public class maestro{ public static long inversions( long[] arr){ long x = 0;  int n = arr.length; for ( int i = (n - 2);(i >= 0);i--) {for ( int j = (i + 1);(j < n);j++) {if ( (arr[i] > arr[j])) {x++; } }}return x;} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  long[] arr = new long[n]; for ( int i = 0;(i < n);i++) arr[i] = sc.nextLong(); long m = sc.nextLong();  long x = (inversions(arr) % 2); for ( int i = 0;(i < m);i++) { int l = (sc.nextInt() - 1);  int r = (sc.nextInt() - 1); if ( ((((r - l) + 1) % 4) > 1)) x = ((x + 1) % 2); if ( (x == 1)) System.out.println("odd"); else System.out.println("even"); }} }
4	public class C{ public static void main( String[] args){ FastScanner fs = new FastScanner();  int T = fs.nextInt();  PrintWriter out = new PrintWriter(System.out); for ( int tt = 0;(tt < T);tt++) { int n = fs.nextInt();  int[] a = fs.readArray(n);  int[] stack = new int[n];  int size = 0; for ( int i :a) {if ( (i == 1)) {stack[size++] = i; } else {while((stack[(size - 1)] != (i - 1))){size--; }size--; stack[size++] = i; }for ( int j = 0;(j < size);j++) {out.print(stack[j]); if ( (j != (size - 1))) out.print('.'); }out.println(); }}out.close(); } 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());} int[] readArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
5	public class A{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni(),k = ni();  int[][] d = new int[n][2]; for ( int i = 0;(i < n);i++) {d[i][0] = ni(); d[i][1] = ni(); }Arrays.sort(d,new Comparator<int[]>(){}); int b ; for ( b = (k - 1);(((b >= 0) && (d[(k - 1)][0] == d[b][0])) && (d[(k - 1)][1] == d[b][1]));b--) ;b++; int a ; for ( a = (k - 1);(((a < n) && (d[(k - 1)][0] == d[a][0])) && (d[(k - 1)][1] == d[a][1]));a++) ;a--; out.println(((a - b) + 1)); } 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(); } 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)); } }
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 ,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_]; 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)); } boolean dijkstra( int s, int t){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((dd[u] != dd[v])?(dd[u] - dd[v]):(u - v)))); pq.add(s); Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first;  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)))) {if ( (pi[v] != INF)) pq.remove(v); pi[v] = p; dd[v] = d; bb[v] = h_; pq.add(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){ cost_ = Arrays.copyOf(cost,m_); while(dijkstra(s,t)){push1(s,t); for ( int h = 0;(h < m_);h++) { int u = uu[h],v = vv[h]; if ( ((pi[u] != INF) && (pi[v] != INF))) cost_[h] += (pi[u] - pi[v]); }} 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 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());} } }
2	public class B{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni(),x = ni(),y = ni();  long c = nl();  int l = (x - 1),r = (n - x);  int u = (y - 1),d = (n - y);  long low = -1,high = ((2 * n) + 3); while(((high - low) > 1)){ long t = ((high + low) / 2);  long num = ((((((((diag(t,l,u) + diag(t,r,u)) + diag(t,l,d)) + diag(t,r,d)) + hor(t,l)) + hor(t,r)) + hor(t,u)) + hor(t,d)) + 1); if ( (num >= c)) {high = t; } else {low = t; }}out.println(high); } long hor( long t, int n){ return Math.min(t,n);} long diag( long t, long r, long u){ if ( (t > (((2 + r) + u) - 2))) {return (r * u);} long ret = ((t * (t - 1)) / 2); if ( (t > r)) ret -= (((t - r) * ((t - r) - 1)) / 2); if ( (t > u)) ret -= (((t - u) * ((t - u) - 1)) / 2); 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 B().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 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 codeforces{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] data = new int[n]; for ( int i = 0;(i < n);i++) data[i] = sc.nextInt(); Arrays.sort(data); if ( (data[(n - 1)] != 1)) data[(n - 1)] = 1; else data[(n - 1)] = 2; Arrays.sort(data); for ( int i = 0;(i < n);i++) {System.out.print(data[i]); if ( (i != (n - 1))) System.out.print(" "); }return ;} }
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(); } }
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 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); }} }
3	public final class EcRound35DApplication{ public static void main( String[] args){ Input input = new Input(); input = SystemInput(); List<String> resultList = run(input); for ( String result :resultList) {System.out.println(result); }} static private Input SystemInput(){ Input input = new Input();  Scanner sc = new Scanner(System.in);  List<Integer> inputList = new ArrayList<Integer>(); while(sc.hasNextInt()){inputList.add(sc.nextInt()); }input.setInput(inputList); sc.close(); return input;} static private List<String> run( Input input){ List<String> result = new ArrayList<String>();  List<Integer> permutation = input.getPermutationList();  Integer count ; count = inversion(permutation); for ( Integer i = 0;(i < input.getQueryNum());i++) {count = (count + change(input.getQuery(i))); result.add(evenOdd(count)); }return result;} static private Integer inversion( List<Integer> permutation){ String result = new String();  Integer inversionCount = 0; for ( Integer i = 0;(i < permutation.size());i++) {for ( Integer j = (i + 1);(j < permutation.size());j++) {if ( (permutation.get(i) > permutation.get(j))) {inversionCount++; } }}return inversionCount;} static private Integer change( Query query){ Integer result ; result = ((query.getLength() * (query.getLength() - 1)) / 2); return result;} static private String evenOdd( Integer i){ if ( ((i % 2) == 0)) {return "even";} else {return "odd";}} static private class Query{ private Integer l ; private Integer r ; public void setQuery( Integer l, Integer r){ this.l = l; this.r = r; } public Integer getL(){ return l;} public Integer getR(){ return r;} public Integer getLength(){ return ((r - l) + 1);} } static private class Input{ private Integer length ; private List<Integer> permutationList = new ArrayList<Integer>(); private Integer queryNum ; private List<Query> queryList = new ArrayList<Query>(); public void setInput( List<Integer> inputList){ this.length = inputList.get(0); setPermutationList(inputList.subList(1,(length + 1))); this.queryNum = inputList.get((length + 1)); for ( Integer j = (length + 2);(j < (inputList.size() - 1));j = (j + 2)) {addQueryList(inputList.get(j),inputList.get((j + 1))); }} public Integer getLength(){ return length;} public List<Integer> getPermutationList(){ return permutationList;} public void setPermutationList( List<Integer> permutationList){ this.permutationList = permutationList; } public Integer getQueryNum(){ return queryNum;} public Query getQuery( Integer i){ return queryList.get(i);} public Integer getQueryL( Integer i){ return queryList.get(i).getL();} public Integer getQueryR( Integer i){ return queryList.get(i).getR();} public void addQueryList( Query newQuery){ this.queryList.add(newQuery); } public void addQueryList( Integer l, Integer r){ Query newQuery = new Query(); newQuery.setQuery(l,r); addQueryList(newQuery); } } }
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();} }
6	public class C{ public static void main( String[] args){ FastScanner fs = new FastScanner();  int nBoxes = fs.nextInt();  long[] sums = new long[nBoxes];  HashMap<Long,Integer> boxOf = new HashMap<>();  int[][] boxes = new int[nBoxes][];  long total = 0; for ( int i = 0;(i < nBoxes);i++) { int size = fs.nextInt(); boxes[i] = new int[size]; for ( int j = 0;(j < size);j++) {boxes[i][j] = fs.nextInt(); boxOf.put((long)boxes[i][j],i); sums[i] += boxes[i][j]; }total += sums[i]; }if ( ((total % nBoxes) != 0)) {System.out.println("No"); return ;} long target = (total / nBoxes);  int[][] masks = new int[nBoxes][];  ArrayList<Integer>[][] maskLoops = new ArrayList[nBoxes][]; for ( int i = 0;(i < nBoxes);i++) {masks[i] = new int[boxes[i].length]; maskLoops[i] = new ArrayList[boxes[i].length]; for ( int j = 0;(j < maskLoops[i].length);j++) maskLoops[i][j] = new ArrayList<>(); for ( int j = 0;(j < boxes[i].length);j++) { long startVal = boxes[i][j],lookingFor = (target - (sums[i] - startVal)); maskLoops[i][j].add((int)lookingFor); int mask = (1 << i); while((lookingFor != startVal)){if ( !boxOf.containsKey(lookingFor)) continue inner; int nextBox = boxOf.get(lookingFor); if ( ((mask & (1 << nextBox)) != 0)) continue inner; mask |= (1 << nextBox); lookingFor = (target - (sums[nextBox] - lookingFor)); maskLoops[i][j].add((int)lookingFor); }masks[i][j] = mask; }} boolean[] possible = new boolean[(1 << nBoxes)];  int[] maskFrom = new int[(1 << nBoxes)];  int[] indexToUse = new int[(1 << nBoxes)]; possible[0] = true; for ( int mask = 1;(mask < (1 << nBoxes));mask++) { int lowestBit = Integer.numberOfTrailingZeros(Integer.lowestOneBit(mask)); for ( int i = 0;(i < masks[lowestBit].length);i++) { int m = masks[lowestBit][i]; if ( (((mask & m) == m) && possible[(mask ^ m)])) {possible[mask] = true; maskFrom[mask] = (mask ^ m); indexToUse[mask] = i; break;} }}if ( !possible[((1 << nBoxes) - 1)]) {System.out.println("No"); return ;} System.out.println("Yes"); ArrayList<ArrayList<Integer>> loops = new ArrayList<>();  int mask = ((1 << nBoxes) - 1); while((mask != 0)){ int lowestBit = Integer.numberOfTrailingZeros(Integer.lowestOneBit(mask)); loops.add(maskLoops[lowestBit][indexToUse[mask]]); mask = maskFrom[mask]; } int[] takeFrom = new int[nBoxes];  int[] boxGiveTo = new int[nBoxes]; for ( ArrayList<Integer> loop :loops) {for ( int i = 0;(i < loop.size());i++) { int cur = loop.get(i),next = loop.get(((i + 1) % loop.size()));  int curBox = boxOf.get((long)cur),nextBox = boxOf.get((long)next); takeFrom[nextBox] = next; boxGiveTo[nextBox] = curBox; }}for ( int i = 0;(i < nBoxes);i++) {System.out.println(((takeFrom[i] + " ") + (boxGiveTo[i] + 1))); }} 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();} public int nextInt(){ return Integer.parseInt(next());} } }
6	public class Main implements Runnable{ private void solution()throws IOException { int n = in.nextInt();  int m = in.nextInt();  boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = in.nextInt();  int y = in.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; } }} long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);++i) {for ( int mask = 0;(mask < (1 << (n - i)));++mask) {for ( int j = 0;(j < (n - i));++j) {dp[mask][j] = 0; }}dp[0][0] = 1; for ( int mask = 0;(mask < (1 << (n - i)));++mask) {for ( int j = 0;(j < (n - i));++j) {if ( (dp[mask][j] != 0)) {for ( int k = 0;(k < (n - i));++k) {if ( ((((mask >> k) & 1) == 0) && adj[(j + i)][(k + i)])) {dp[(mask | (1 << k))][k] += dp[mask][j]; } }} }if ( (((mask >> 0) & 1) != 0)) {res += dp[mask][0]; } }}out.println((res / 2)); } private class Scanner{ BufferedReader reader ; 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)); }
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 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(); } }
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(); } }
2	public class Main{ public static void main( String[] argv){ new Main(); } boolean test = false; final int MOD = 998244353; public Main(){ FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in))); final int N = 50;  long[] f = new long[N];  int maxN = 50; f[0] = 0; for ( int i = 1;(i < N);i++) {if ( ((Long.MAX_VALUE / 4) <= f[(i - 1)])) {maxN = (i - 1); break;} f[i] = ((f[(i - 1)] * 4) + 1); } long[] a = new long[N];  long[] b = new long[N];  int nt = in.nextInt(); for ( int ii = 1;(ii <= nt);ii++) { int n = in.nextInt();  long k = in.nextLong(); if ( (k == 0)) {System.out.println(("YES " + n)); continue;} if ( (((n - 1) > maxN) || (k <= (1 + f[(n - 1)])))) {System.out.println(("YES " + (n - 1))); continue;} if ( ((n - 1) == maxN)) {System.out.println(("YES " + (n - 2))); continue;} if ( (k > f[n])) {System.out.println("NO"); continue;} if ( (n == 2)) {if ( (k == 3)) System.out.println("NO"); else System.out.println("YES 0"); continue;} a[1] = 1; b[1] = f[(n - 1)]; int ret = 0; for ( int i = 2;(i <= n);i++) {a[i] = ((a[(i - 1)] + (1L << i)) - 1); b[i] = (b[(i - 1)] + (((2 * (1L << i)) - 3) * f[(n - i)])); if ( ((a[i] + b[i]) >= k)) {ret = (n - i); break;} }System.out.println(("YES " + ret)); }} private long abs( long v){ return ((v > 0)?v:-v);} private int abs( int v){ return ((v > 0)?v:-v);} private void swap( char[] a, int i, int j){ char t = a[i]; a[i] = a[j]; a[j] = t; } private int gcd( int x, int y){ if ( (y == 0)) return x; return gcd(y,(x % y));} 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());} long nextLong(){ return Long.parseLong(next());} } }
1	public class Main{ private MyScanner scan = new MyScanner(); private PrintWriter out = new PrintWriter(System.out); private final double PI = Math.PI; private final int INF = (int)1e9; private final double EPS = 1e-6; private final int SIZEN = (int)1e7; private final int MOD = (int)(1e9 + 7); private final long MODH = 10000000007L,BASE = 10007; private final int[] DX = {0,1,0,-1},DY = {-1,0,1,0}; int n ; int[] sum ; int[][] a ; public int getId( char c){ return (((c >= 'a') && (c <= 'z'))?(c - 'a'):((c - 'A') + 26));} public boolean isOk( int len){ for ( int i = 0;((i + len) <= n);++i) { boolean flag = true; for ( int j = 0;(j < 52);++j) {if ( (((a[(i + len)][j] - a[i][j]) == 0) && (sum[j] != 0))) {flag = false; break;} }if ( flag) {return true;} }return false;} public void foo(){ n = scan.nextInt(); char[] s = scan.next().toCharArray(); a = new int[(n + 1)][52]; sum = new int[52]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < 52);++j) a[(i + 1)][j] = a[i][j]; ++a[(i + 1)][getId(s[i])]; ++sum[getId(s[i])]; } int left = 1,right = n,ans = n; while((left <= right)){ int mid = ((left + right) >> 1); if ( isOk(mid)) {ans = mid; right = (mid - 1); } else {left = (mid + 1); }}out.println(ans); } public static void main( String[] args){ Main m = new Main(); m.foo(); m.out.close(); } public long gcd( long a, long b){ return ((0 == b)?a:gcd(b,(a % b)));} class MyScanner{ private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; BufferedInputStream bis = new BufferedInputStream(System.in); public int read(){ if ( (-1 == numChars)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = bis.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 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();} private boolean isSpaceChar( int c){ return (((((' ' == c) || ('\n' == c)) || ('\r' == c)) || ('\t' == c)) || (-1 == c));} } }
0	public class D5 implements Runnable{ final double eps = 1e-9; private void Solution()throws IOException { double a = nextDouble(),v = nextDouble();  double l = nextDouble(),d = nextDouble(),w = nextDouble();  double t = 0; if ( ((w + eps) > v)) { double s = ((v * v) / (2 * a)); if ( ((s + eps) > l)) t = Math.sqrt(((2 * l) / a)); else { double ta = (v / a);  double sa = (((a * ta) * ta) / 2); t = (ta + ((l - sa) / v)); }} else { double sv = ((v * v) / (2 * a));  double sw = ((w * w) / (2 * a)); if ( ((sw + eps) > d)) {if ( ((sv + eps) > l)) t = Math.sqrt(((2 * l) / a)); else { double ta = (v / a);  double sa = (((a * ta) * ta) / 2); t = (ta + ((l - sa) / v)); }} else { double sd = (((w * w) - (v * v)) / (-2 * a)); if ( ((sv + sd) < (eps + d))) t = (((v / a) + (((d - sv) - sd) / v)) + ((v - w) / a)); else { double f = Math.sqrt(((d * a) + ((w * w) / 2))); t = ((f / a) + ((f - w) / a)); }if ( ((sd + eps) > (l - d))) { double lv = Math.sqrt(((((l - d) * 2) * a) + (w * w))); t += ((lv - w) / a); } else {t += (((v - w) / a) + (((l - d) - sd) / v)); }}}out.printf("%.12f",t); } public static void main( String[] args){ new D5().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer tokenizer ; public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); Solution(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(0); } } void print( Object... obj){ for ( int i = 0;(i < obj.length);i++) {if ( (i != 0)) out.print(" "); out.print(obj[i]); }} double nextDouble()throws NumberFormatException,IOException { return Double.parseDouble(next());} String nextLine()throws IOException { return in.readLine();} String next()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(nextLine()); return tokenizer.nextToken();} }
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 Fish{ public static void main( String[] args){ Scanner in = new Scanner(System.in); in.useLocale(Locale.US); int n = in.nextInt();  double[] dp = new double[(1 << n)]; Arrays.fill(dp,0); dp[((1 << n) - 1)] = 1; double[][] prob = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {prob[i][j] = in.nextDouble(); }}for ( int t = ((1 << n) - 1);(t >= 0);t--) { int k = Integer.bitCount(t); for ( int i = 0;(i < n);i++) {if ( ((t & (1 << i)) > 0)) {for ( int j = 0;(j < n);j++) {if ( ((t & (1 << j)) > 0)) {if ( (i != j)) {dp[(t - (1 << j))] += ((dp[t] * prob[i][j]) / ((k * (k - 1)) / 2)); } } }} }}for ( int i = 0;(i < n);i++) {System.out.print((dp[(1 << i)] + " ")); }} }
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;} static private 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); } } static private 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; } } static private 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(); } } static private class RuntimeIOException extends RuntimeException{ static private final long serialVersionUID = -6463830523020118289L; RuntimeIOException( Throwable cause){ super(cause); } } static private final int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; static private final int[][] steps8 = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{1,-1},{-1,1}}; static private boolean checkCell( int row, int rowsCount, int column, int columnsCount){ return (checkIndex(row,rowsCount) && checkIndex(column,columnsCount));} static private boolean checkIndex( int index, int lim){ return ((0 <= index) && (index < lim));} static private long gcd( long a, long b){ return ((a == 0)?b:gcd((b % a),a));} static private 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;} }
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)]; {for ( int a = 1;(a <= A);a++) cc[a] = a; for ( int a = 2;(a <= (A / a));a++) { int s = (a * a); for ( int b = s;(b <= A);b += s) while(((cc[b] % s) == 0))cc[b] /= s; }} 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 Solution implements Runnable{ 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());} int fu( int[] a, int l){ for ( int i = l;(i < (a.length - 1));i++) {if ( (a[i] > a[(i + 1)])) return i; }return a.length;} void swap( int[] a, int q, int w){ int t = a[q]; a[q] = a[w]; a[w] = t; } void solve()throws Exception { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); int q = fu(a,0); if ( (q == n)) out.println("YES"); else { int w = fu(a,(q + 1)); if ( (w < n)) { boolean ans = false; swap(a,q,w); ans |= (fu(a,0) == n); swap(a,q,w); if ( (q < (n - 1))) {swap(a,(q + 1),w); ans |= (fu(a,0) == n); swap(a,(q + 1),w); } if ( (w < (n - 1))) {swap(a,q,(w + 1)); ans |= (fu(a,0) == n); swap(a,q,(w + 1)); } if ( ((q < (n - 1)) && (w < (n - 1)))) {swap(a,(q + 1),(w + 1)); ans |= (fu(a,0) == n); swap(a,(q + 1),(w + 1)); } if ( ans) out.println("YES"); else out.println("NO"); } else { int j = (q + 1); while(((j < n) && (a[j] == a[(q + 1)])))j++; j--; swap(a,q,j); if ( (fu(a,0) == n)) out.println("YES"); else {swap(a,q,j); q++; j = (q - 1); while(((j >= 0) && (a[j] == a[(q - 1)])))j--; j++; swap(a,q,j); if ( (fu(a,0) == n)) out.println("YES"); else out.println("NO"); }}}} public void run(){ try{Locale.setDefault(Locale.UK); 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(); } }
2	public class icpc{ public static void main( String[] args)throws IOException { Reader in = new Reader();  long n = in.nextLong();  long k = in.nextLong();  long val = ((2 * n) + (2 * k));  long D = (9 + (4 * val));  long sqrtD = (long)Math.sqrt((double)D);  double r1 = ((-3 + sqrtD) / 2);  long r1DAsh = (long)r1; System.out.println((n - r1DAsh)); } } class Name{ long d ; long x ; long y ; public Name( long d, long x, long y){ this.d = d; this.x = x; this.y = y; } } 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 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;} 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(); } }
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());} } }
2	public class _v14{ public static void main( String[] args){ PrintWriter out = new PrintWriter(System.out);  Reader in = new Reader();  long k = in.nextLong(); if ( (k < 10)) {System.out.println(k); return ;} long sum = 0;  long cur = 9;  long prev = 0;  int count = 1; while((k > cur)){k = (k - cur); sum = (sum + (cur / count)); prev = cur; cur = ((9 * (count + 1)) * (long)Math.pow(10,count)); count++; } long num = (k / count); sum = (sum + num); if ( ((k % count) == 0)) {System.out.println((sum % 10)); } else {sum++; k = (k % count); String str = String.valueOf(sum); System.out.println(str.charAt(((int)k - 1))); }out.flush(); out.close(); } 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 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){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} } }
5	public class R113A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),k = in.nextInt();  int[] ind = new int[n];  int[] p = new int[n];  int[] t = new int[n]; for ( int i = 0;(i < n);i++) {ind[i] = i; p[i] = in.nextInt(); t[i] = in.nextInt(); }for ( int i = 0;(i < (n - 1));i++) for ( int j = (i + 1);(j < n);j++) {if ( ((p[i] < p[j]) || ((p[i] == p[j]) && (t[i] > t[j])))) { int tmp = p[i]; p[i] = p[j]; p[j] = tmp; tmp = t[i]; t[i] = t[j]; t[j] = tmp; } } int i = (k - 1); while((((i > 0) && (p[i] == p[(i - 1)])) && (t[i] == t[(i - 1)])))i--; int j = 0; while((((i < (n - 1)) && (p[i] == p[(i + 1)])) && (t[i] == t[(i + 1)]))){i++; j++; }System.out.println((j + 1)); } }
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 class Main implements Runnable{ public void _main()throws IOException { long a = nextLong();  long b = nextLong();  long res = 0; while((b > 0)){res += (a / b); long t = (a % b); a = b; b = t; }out.println(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(); } }
5	public class A{ String line ; StringTokenizer inputParser ; BufferedReader is ; FileInputStream fstream ; DataInputStream in ; String FInput = ""; void openInput( String file){ if ( (file == null)) is = new BufferedReader(new InputStreamReader(System.in)); else {try{fstream = new FileInputStream(file); in = new DataInputStream(fstream); is = new BufferedReader(new InputStreamReader(in)); }catch (Exception e){ System.err.println(e); } }} void readNextLine(){ try{line = is.readLine(); inputParser = new StringTokenizer(line," "); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } catch (NullPointerException e){ line = null; } } int NextInt(){ String n = inputParser.nextToken();  int val = Integer.parseInt(n); return val;} void closeInput(){ try{is.close(); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } public static void main( String[] argv){ String filePath = null; if ( (argv.length > 0)) filePath = argv[0]; new A(filePath); } public A( String inputFile){ openInput(inputFile); readNextLine(); int n = NextInt();  int k = (NextInt() - 1);  int ret = 0;  Team[] t = new Team[n]; for ( int i = 0;(i < n);i++) {readNextLine(); t[i] = new Team(NextInt(),NextInt()); }Arrays.sort(t); int ti = t[k].t,p = t[k].p; for ( int i = 0;(i < n);i++) if ( ((t[i].t == ti) && (t[i].p == p))) ret++; System.out.print(ret); closeInput(); } private class Team implements Comparable<Team>{ int p ,t ; Team( int p, int t){ this.p = p; this.t = t; } } }
3	public class C{ static int N ; static char[] a ; static int[][] memo ; static int[] ind ; static final int MOD = ((int)1e9 + 7); 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 char[N]; for ( int i = 0;(i < N);i++) a[i] = sc.nextChar(); if ( (N == 1)) {out.println(1); out.flush(); return ;} memo = new int[N][(N + 5)]; for ( int[] a :memo) Arrays.fill(a,-1); out.println(dp(0,1)); out.flush(); out.close(); } static int dp( int i, int ind){ if ( (i == (N - 1))) return ((a[(i - 1)] == 'f')?1:ind); if ( (i == 0)) return dp((i + 1),((a[i] == 's')?1:2)); if ( (memo[i][ind] != -1)) return memo[i][ind]; int ans = 0; if ( (a[(i - 1)] == 'f')) ans = dp((i + 1),((a[i] == 's')?ind:(ind + 1))); else {if ( (ind > 1)) ans = ((ans + dp(i,(ind - 1))) % MOD); ans = ((ans + dp((i + 1),((a[i] == 's')?ind:(ind + 1)))) % MOD); }return memo[i][ind] = ans;} static class Scanner{ StringTokenizer st ; BufferedReader br ; Scanner( InputStream system){ br = new BufferedReader(new InputStreamReader(system)); } Scanner( String file)throws FileNotFoundException{ br = new BufferedReader(new FileReader(file)); } 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());} char nextChar()throws IOException { return next().charAt(0);} boolean ready()throws IOException { return br.ready();} } }
3	public class D{ public static void main( String[] args){ 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 ans = 0; for ( int i = 0;(i < n);++i) {for ( int j = (i + 1);(j < n);++j) {if ( (a[i] > a[j])) ans++; }} 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 x = ((size * size) - size); x = (x >> 1); ans = (ans ^ x); if ( ((ans % 2) == 0)) System.out.println("even"); else System.out.println("odd"); }} }
2	public class D{ InputStream is ; PrintWriter out ; String INPUT = ""; long I = 4000000000000000007L; void solve(){ for ( int T = ni();(T > 0);T--) { long n = nl(),K = nl();  long inf = 0;  long sup = 0; for ( int d = 1;(d <= n);d++) {inf += (pow(2,d) - 1); if ( (inf >= I)) inf = I; sup += ((pow(2,d) - 1) + mul((pow(2,(d + 1)) - 3),((pow(4,(n - d)) - 1) / 3))); if ( (sup >= I)) sup = I; if ( ((inf <= K) && (K <= sup))) {out.println(("YES " + (n - d))); continue outer;} }out.println("NO"); }} long mul( long a, long b){ if ( (((double)a * b) > I)) return I; return (a * b);} long pow( int b, long d){ long v = 1; for ( int i = 1;(i <= d);i++) {if ( (((double)v * b) > I)) return I; v = (v * b); }return v;} 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 D().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 Main{ static double eps = 1e-8; public static void main( String[] args){ Scanner r = new Scanner(System.in);  int n = r.nextInt();  int t = r.nextInt();  House[] a = new House[n]; for ( int i = 0;(i < n);i++) { double c = r.nextInt();  double l = r.nextInt(); a[i] = new House((c - (l / 2)),l); }Arrays.sort(a); int res = 0; for ( int i = 0;(i < (n - 1));i++) { double dist = (a[(i + 1)].s - (a[i].s + a[i].l)); if ( (Math.abs((dist - t)) < eps)) res++; else if ( (dist > t)) res += 2; }System.out.println((res + 2)); } } class House implements Comparable<House>{ double s ,l ; public House( double si, double li){ s = si; l = li; } }
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());} } }
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 ;} 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)); }} }
6	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(""); void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int N = nextInt();  double[][] a = new double[N][N]; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < N);j++) a[i][j] = nextDouble(); int NN = (1 << N);  double[] dp = new double[NN]; dp[(NN - 1)] = 1.0; for ( int mask = (NN - 1);(mask > 0);mask--) { int b = Integer.bitCount(mask); if ( (b <= 1)) continue; double k = (2.0 / (b * (b - 1))); for ( int i = 0;(i < N);i++) {if ( ((mask & (1 << i)) == 0)) continue; for ( int j = (i + 1);(j < N);j++) {if ( ((mask & (1 << j)) == 0)) continue; double p = a[i][j]; dp[(mask & (1 << j))] += ((k * p) * dp[mask]); dp[(mask & (1 << i))] += ((k * (1.0 - p)) * dp[mask]); }}}out.printf(Locale.US,"%.8f",dp[1]); for ( int i = 1,ind = 2;(i < N);ind <<= 1,i++) out.printf(Locale.US," %.8f",dp[ind]); out.println(); 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());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} }
1	public class C701{ static FastReader in = null; static PrintWriter out = null; public static void solve(){ int n = in.nint();  String pk = in.next();  boolean[] occ = new boolean[52]; for ( int i = 0;(i < n);i++) { char c = pk.charAt(i);  int val = (Character.isUpperCase(c)?(int)(c - 'A'):(int)((c - 'a') + 26)); occ[val] = true; } int[][] next = new int[n][52]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < 52);j++) next[i][j] = -1; for ( int i = (n - 1);(i >= 0);i--) { char c = pk.charAt(i);  int val = (Character.isUpperCase(c)?(int)(c - 'A'):(int)((c - 'a') + 26)); next[i][val] = i; if ( (i < (n - 1))) for ( int j = 0;(j < 52);j++) {if ( (j != val)) {next[i][j] = next[(i + 1)][j]; } } } int min = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int maxd = 0;  boolean endearly = false; for ( int j = 0;(j < 52);j++) {if ( (occ[j] && (next[i][j] == -1))) {endearly = true; break;} else if ( occ[j]) {maxd = Math.max(maxd,((next[i][j] - i) + 1)); } }if ( endearly) break; min = Math.min(min,maxd); }out.println(min); } public static void main( String[] args){ in = new FastReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); out.close(); } static class FastReader{ BufferedReader read ; StringTokenizer tokenizer ; public FastReader( InputStream in){ read = new BufferedReader(new InputStreamReader(in)); } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(read.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nint(){ return Integer.parseInt(next());} public long nlong(){ return Long.parseLong(next());} } }
2	public class B{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(1,in,out); out.close(); } static class Task{ int n = 0; int query( int p, InputReader in){ p %= n; if ( (p <= 0)) p += n; System.out.println(("? " + p)); System.out.flush(); int x = in.nextInt(); return x;} public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); if ( ((n % 4) != 0)) {out.println("! -1"); return ;} int p = query(0,in);  int q = query((n / 2),in);  int l = 0;  int r = (n / 2); if ( (p == q)) {out.println(("! " + (n / 2))); return ;} while(((l + 1) < r)){ int mid = ((l + r) / 2);  int u = query(mid,in);  int v = query((mid + (n / 2)),in); if ( (u == v)) {out.println(("! " + (mid + (n / 2)))); return ;} if ( ((p < q) == (u < v))) {l = mid; } else {r = mid; }}} } 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());} } }
2	public class Cses{ public static void main( String[] args){ FastReader sc = new FastReader();  long n = sc.nextLong(); if ( (n < 10)) {System.out.println(n); return ;} else { long sum = 0;  long cur = 9;  long prev = 0;  int count = 1; while((n > cur)){n -= cur; sum += (cur / count); prev = cur; cur = ((9 * (count + 1)) * (long)Math.pow(10,count)); count++; }sum = (sum + (n / count)); if ( ((n % count) == 0)) {System.out.println((sum % 10)); } else {sum++; n = (n % count); String s = String.valueOf(sum); System.out.println(s.charAt(((int)n - 1))); }}} public static int pow( int a, int b){ int res = 1; while((b > 0)){if ( ((b & 1) != 0)) {res = (res * a); } a = (a * a); b = (b >> 1); }return res;} public static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} 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());} } }
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 Contest176B{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  int k = sc.nextInt(); if ( ((((((long)k * (long)(k + 1)) / 2) - 1) - (k - 2)) < n)) {System.out.println(-1); return ;} if ( (n == 1)) {System.out.println(0); return ;} if ( (n <= k)) {System.out.println(1); return ;} int ans = rek(2,k,n,k); System.out.println(ans); } static private int rek( int s, int e, long n, int k){ if ( (s == e)) {return ((k - s) + 1);} if ( ((s + 1) == e)) {if ( (sum(e,k) >= n)) return ((k - e) + 1); return ((k - s) + 1);} int m = ((s + e) / 2);  long ans = sum(m,k); if ( (ans == n)) return ((k - m) + 1); if ( (ans < n)) return rek(s,(m - 1),n,k); else return rek(m,e,n,k);} static private long sum( int a, int b){ long sum1 = (((long)a * (long)(a - 1)) / 2);  long sum2 = (((long)b * (long)(b + 1)) / 2);  int numelement = ((b - a) + 1); return ((sum2 - sum1) - (numelement - 1));} }
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());} }
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());} } }
1	public class CF_1029E_Tree_with_Small_Distances{ static ArrayList<Integer> adj[] ; static int dist[] ; static boolean visitParent[] ; static int ans = 0; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); adj = new ArrayList[(n + 1)]; dist = new int[(n + 1)]; visitParent = new boolean[(n + 1)]; for ( int i = 0;(i <= n);i++) adj[i] = new ArrayList<Integer>(); int max = 0; for ( int i = 1;(i < n);i++) { int u = sc.nextInt(),v = sc.nextInt(); adj[u].add(v); adj[v].add(u); }dist[1] = 0; dfs(1,1); System.out.println(ans); } static private void dfs( int i, int j){ boolean f = false; for ( int k = 0;(k < adj[i].size());k++) { int x = adj[i].get(k); if ( (x != j)) {dist[x] = (dist[i] + 1); dfs(x,i); if ( visitParent[x]) f = true; } }if ( ((((dist[i] > 2) && !visitParent[j]) && !f) && !visitParent[i])) {visitParent[j] = true; ans++; for ( int v = 0;(v < adj[i].size());v++) {}} } 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();} } }
1	public class CodeForces{ static boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); void runCase( int caseNum)throws IOException { int n = nextInt();  int k = nextInt();  int[] nums = new int[n];  int distinct = 0;  int L = -1,R = -1;  int minLen = Integer.MAX_VALUE;  int maxNum = 0; for ( int i = 0;(i < n);++i) {nums[i] = nextInt(); maxNum = Math.max(maxNum,nums[i]); } int[] count = new int[(maxNum + 1)];  int j = 0; for ( int i = 0;(i < n);++i) {++count[nums[i]]; if ( (count[nums[i]] == 1)) {++distinct; if ( (distinct >= k)) {for ( ;(j <= i);++j) {--count[nums[j]]; if ( (count[nums[j]] <= 0)) {--distinct; if ( (distinct < k)) {if ( ((i - j) < minLen)) {minLen = (i - j); L = (j + 1); R = (i + 1); } break;} } }} } }out.print(((L + " ") + R)); } public static void main( String[] args)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"); }new CodeForces().runIt(); out.flush(); out.close(); return ;} static BufferedReader in ; private StringTokenizer st ; static PrintWriter out ; String next()throws IOException { while(!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(next());} void runIt()throws IOException { st = new StringTokenizer(""); runCase(0); out.flush(); } }
3	public class p3{ 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)); st = new StringTokenizer(br.readLine()); int N = Integer.parseInt(st.nextToken());  int R = Integer.parseInt(st.nextToken());  double[] x = new double[N]; st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < N);i++) {x[i] = Double.parseDouble(st.nextToken()); } double[] y = new double[N]; for ( int i = 0;(i < N);i++) { double maxy = R; for ( int j = (i - 1);(j >= 0);j--) {if ( (Math.abs((x[j] - x[i])) <= (2 * R))) {maxy = Math.max((y[j] + inc((x[j] - x[i]),R)),maxy); } }y[i] = maxy; }for ( int i = 0;(i < (y.length - 1));i++) {System.out.print((y[i] + " ")); }System.out.println(y[(y.length - 1)]); } public static double inc( double x, double R){ return Math.sqrt((((4 * R) * R) - (x * x)));} }
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(); } static class TaskB{ public void solve( int testNumber, Scanner in, PrintWriter out){ long n = in.nextLong();  long st = 1,en = n,ans = 0,len = 0; while((st <= en)){ long mid = ((st + en) / 2);  long have = 0;  int curLen = Long.toString(mid).length();  long bef = 0; for ( int i = 1;(i < curLen);i++) { long cur = 0; for ( int j = 1;(j <= i);j++) {cur *= 10; cur += 9; }have += (i * (cur - bef)); bef = cur; }have += (curLen * (mid - bef)); if ( (have < n)) {ans = mid; len = have; st = (mid + 1); } else en = (mid - 1); } String s = Long.toString((ans + 1)); for ( int i = 0;(i < s.length());i++) {if ( (((len + i) + 1) == n)) {out.print(s.charAt(i)); return ;} }} } }
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); } }
3	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(); } }
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());} } }
1	public class Main{ public static void main( String[] args){ new Main().run(); } Scanner sc = new Scanner(System.in); void run(){ int n = sc.nextInt();  char[] cs = sc.next().toCharArray();  int h = 0; for ( int i = 0;(i < n);i++) if ( (cs[i] == 'H')) h++;  int res = n; for ( int i = 0;(i < n);i++) { int val = 0; for ( int j = 0;(j < h);j++) if ( (cs[((i + j) % n)] == 'T')) val++; res = min(res,val); }System.out.println(res); } }
2	public class ProblemB{ InputReader in ; PrintWriter out ; void solve(){ int n = in.nextInt();  int x = in.nextInt();  int y = in.nextInt();  int c = in.nextInt();  int cur = 1; for ( int k = 1;(k <= c);k++) {if ( (cur >= c)) {out.println((k - 1)); return ;} int iLess = (n - x);  int iMore = ((y + k) - n); if ( (iLess > k)) iLess = k; if ( (iMore < 0)) iMore = 0;  int add = ((iLess - iMore) + 1); if ( (add < 0)) add = 0; cur += add; iLess = (n - x); iMore = ((1 + k) - y); if ( (iLess > k)) iLess = k; if ( (iMore < 0)) iMore = 0; add = ((iLess - iMore) + 1); if ( (add < 0)) add = 0; cur += add; iLess = (x - 1); iMore = ((1 + k) - y); if ( (iLess > k)) iLess = k; if ( (iMore < 0)) iMore = 0; add = ((iLess - iMore) + 1); if ( (add < 0)) add = 0; cur += add; iLess = (x - 1); iMore = ((y + k) - n); if ( (iLess > k)) iLess = k; if ( (iMore < 0)) iMore = 0; add = ((iLess - iMore) + 1); if ( (add < 0)) add = 0; cur += add; if ( ((x + k) <= n)) cur--; if ( ((y - k) >= 1)) cur--; if ( ((x - k) >= 1)) cur--; if ( ((y + k) <= n)) cur--; }} ProblemB(){ 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 ProblemB(); } } 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());} }
3	public class Main{ static final int mod = 1_000_000_007; public static void main( String[] args)throws Exception { STDIN scan = new STDIN();  PrintWriter pw = new PrintWriter(System.out);  int n = scan.nextInt();  boolean even = true;  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = scan.nextInt(); for ( int j = 0;(j < i);j++) if ( (a[i] < a[j])) even = !even; } int q = scan.nextInt(); while((q-- > 0)){ int l = scan.nextInt(),r = scan.nextInt();  int len = ((r - l) + 1);  int permutations = ((len * (len - 1)) / 2); if ( ((permutations % 2) != 0)) even = !even; pw.println((even?"even":"odd")); }pw.flush(); } static class STDIN{ BufferedReader br ; StringTokenizer st ; public STDIN(){ br = new BufferedReader(new InputStreamReader(System.in)); st = null; } int nextInt()throws Exception { return Integer.parseInt(next());} String next()throws Exception { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} } }
2	public class B{ public static void main( String[] args)throws NumberFormatException,IOException { Scanner sc = new Scanner(System.in);  long n = sc.nextLong(),k = sc.nextLong(); if ( (n == 1)) {System.out.println(0); return ;} if ( (n <= k)) {System.out.println(1); return ;} long seg = ((((k + 1) * k) / 2) - 1); seg += (2 - k); if ( (seg < n)) {System.out.println(-1); return ;} long s = 1,f = k;  long mid = ((s + f) / 2); while(((s + 1) < f)){ long seg_m = ((((mid + k) - 1) * (k - mid)) / 2); if ( (seg_m >= (n - 1))) {s = mid; } else f = mid; mid = ((s + f) / 2); }System.out.println((k - s)); } }
0	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(); out.println((n + " 0 0")); in.close(); out.close(); } }
0	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());  StringTokenizer tok = new StringTokenizer(br.readLine());  int ax = Integer.parseInt(tok.nextToken());  int ay = Integer.parseInt(tok.nextToken()); tok = new StringTokenizer(br.readLine()); int bx = Integer.parseInt(tok.nextToken());  int by = Integer.parseInt(tok.nextToken()); tok = new StringTokenizer(br.readLine()); int cx = Integer.parseInt(tok.nextToken());  int cy = Integer.parseInt(tok.nextToken());  boolean ans = (((((((bx < ax) && (cx < ax)) && (by < ay)) && (cy < ay)) || ((((bx < ax) && (cx < ax)) && (by > ay)) && (cy > ay))) || ((((bx > ax) && (cx > ax)) && (by < ay)) && (cy < ay))) || ((((bx > ax) && (cx > ax)) && (by > ay)) && (cy > ay))); System.out.print((ans?"YES":"NO")); } }
1	public class B1{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int testCount = in.nextInt(); for ( int test = 0;(test < testCount);test++) { String src = in.next(); if ( src.matches("^R\\d+C\\d+$")) { Pattern p = Pattern.compile("\\d+");  Matcher m = p.matcher(src); m.find(); int r = Integer.parseInt(m.group(0)); m.find(); int c = Integer.parseInt(m.group(0)); System.out.println((toBase26(c) + r)); } else { Pattern p = Pattern.compile("[A-Z]+");  Matcher m = p.matcher(src); m.find(); String c = m.group(0); p = Pattern.compile("\\d+"); m = p.matcher(src); m.find(); int r = Integer.parseInt(m.group(0)); System.out.println(((("R" + r) + "C") + toBase10(c))); }}} static private String toBase26( int n){ String res = ""; do {n -= 1; res = ((char)('A' + (n % 26)) + res); n /= 26; }while((n > 0));return res;} static private int toBase10( String x){ int n = 0;  char[] digits = x.toCharArray(); for ( int i = 0;(i < digits.length);i++) {n *= 26; n += ((digits[i] - 'A') + 1); }return n;} }
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());} } }
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(); } }
1	public class TaskB implements Runnable{ boolean prime[] = new boolean[((int)1e6 + 10)]; InputReader c ; PrintWriter w ; 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 TaskB(),"TaskB",(1 << 26)).start(); } }
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());} } }
6	public class CF11D{ 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());  boolean[][] ee = new boolean[n][n]; while((m-- > 0)){st = new StringTokenizer(br.readLine()); int i = (Integer.parseInt(st.nextToken()) - 1);  int j = (Integer.parseInt(st.nextToken()) - 1); ee[i][j] = ee[j][i] = true; } long cnt = 0; for ( int i = 2;(i < n);i++) { long[][] dp = new long[(1 << i)][i]; for ( int j = 0;(j < i);j++) dp[0][j] = (ee[i][j]?1:0); for ( int b = 1;(b < (1 << i));b++) for ( int j = 0;(j < i);j++) {if ( ((b & (1 << j)) > 0)) continue; for ( int k = 0;(k < i);k++) {if ( ((b & (1 << k)) == 0)) continue; if ( ee[k][j]) dp[b][j] += dp[(b ^ (1 << k))][k]; }if ( ((dp[b][j] > 0) && ee[j][i])) cnt += dp[b][j]; }}System.out.println((cnt / 2)); } }
1	public class b{ public static void main( String[] args)throws Exception { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  StringTokenizer st = new StringTokenizer(f.readLine());  int T = Integer.parseInt(st.nextToken()); for ( int t = 0;(t < T);t++) {st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken());  int sqrt = (int)Math.sqrt(n);  int sqrt2 = (int)Math.sqrt((n / 2)); if ( (((sqrt * sqrt) == n) && ((sqrt % 2) == 0))) {out.println("YES"); } else if ( (((2 * sqrt2) * sqrt2) == n)) {out.println("YES"); } else {out.println("NO"); }}out.close(); } }
5	public class ProblemA_15{ 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 ProblemA_15().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();  int t = readInt();  Point[] a = new Point[n]; for ( int i = 0;(i < n);i++) {a[i] = new Point(readInt(),readInt()); } int count = 2; Arrays.sort(a,new Comparator<Point>(){}); for ( int i = 1;(i < n);i++) { double li = (a[(i - 1)].x + ((double)a[(i - 1)].y / 2));  double ri = (a[i].x - ((double)a[i].y / 2)); if ( ((ri - li) > t)) {count += 2; } if ( ((ri - li) == t)) {count++; } }out.print(count); } }
5	public class solve{ Scanner in ; PrintWriter out ; public void solve()throws IOException { int n = in.nextInt();  long k = in.nextLong();  int[] a = new int[n];  Set<Long> b = new TreeSet<Long>(); for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }Arrays.sort(a); int ans = 0; for ( int i = (n - 1);(i >= 0);i--) {if ( !b.contains(((long)k * a[i]))) {ans++; b.add((long)a[i]); } }out.print(ans); } public void run(){ try{in = new Scanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } public static void main( String[] arg){ new solve().run(); } }
3	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);  APaintTheNumbers solver = new APaintTheNumbers(); solver.solve(1,in,out); out.close(); } static class APaintTheNumbers{ public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int arr[] = new int[n]; in.scanInt(arr); CodeX.sort(arr); int ans = 0;  boolean vissited[] = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !vissited[i]) {ans++; for ( int j = 0;(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) {vissited[j] = true; } }} }out.println(ans); } } 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);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} public void scanInt( int[] A){ for ( int i = 0;(i < A.length);i++) A[i] = scanInt(); } } }
3	public class C{ static int MOD = 1_000_000_007; public static void main( String[] args){ MyScanner in = new MyScanner();  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  char prev = ' ';  int[][] dp = new int[(n + 1)][(n + 2)]; dp[0][0] = 1; for ( int i = 0;(i < n);++i) { char ch = in.next().charAt(0); if ( (prev == 's')) { int sum = 0; for ( int j = n;(j >= 0);--j) {sum = ((sum + dp[(i - 1)][j]) % MOD); dp[i][j] = sum; }} else if ( (prev == 'f')) {for ( int j = 0;(j < n);++j) {dp[i][(j + 1)] = dp[(i - 1)][j]; }} prev = ch; } int result = 0; for ( int i = 0;(i <= n);++i) {result = ((result + dp[(n - 1)][i]) % MOD); }out.println(result); 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());} } }
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(); } }
1	public class Main{ static StringTokenizer st ; static PrintWriter out = new PrintWriter(System.out,true); static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static int nextInt()throws Exception { if ( ((st == null) || !st.hasMoreTokens())) st = new StringTokenizer(in.readLine()); return Integer.parseInt(st.nextToken());} public static void main( String[] args)throws Exception { HashSet<Integer> set = new HashSet<>();  int n = nextInt();  int k = nextInt();  int[] m = new int[n];  int[] d = new int[n]; for ( int i = 0;(i < n);i++) m[i] = nextInt(); int l = -1;  int r = -1; for ( int i = 0;(i < n);i++) {set.add(m[i]); d[i] = set.size(); if ( (d[i] == k)) {r = i; break;} }if ( (r == -1)) {out.println("-1 -1"); return ;} for ( int i = r;(i >= 0);i--) {set.remove(m[i]); if ( (set.size() == 0)) {l = i; break;} }out.println((((l + 1) + " ") + (r + 1))); } }
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;} }
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 ; }
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;}} static private 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(); } } } }
3	public class A{ public static void main( String[] args){ MyScanner sc = new MyScanner();  int n = sc.nextInt();  Integer[] a = new Integer[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); boolean[] b = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) if ( !b[i]) {ans++; for ( int j = (i + 1);(j < n);j++) if ( ((a[j] % a[i]) == 0)) b[j] = true; } out.println(ans); out.close(); } 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());} } }
4	public class E{ public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main( String[] args)throws IOException { readInput(); out.close(); } static long[][] dp ; static int n ; static long m ; static long pow( long b, long e){ if ( (e == 0)) return 1; long r = pow(b,(e / 2)); r = ((r * r) % m); if ( ((e & 1) == 1)) return ((r * b) % m); return r;} static long modinv( long a){ return pow(a,(m - 2));} static long solve( int len, int num){ if ( ((len == -1) && (num == -1))) return 1; if ( ((num < 0) || (len <= 0))) return 0; if ( (dp[len][num] == -1)) {dp[len][num] = 0; for ( int i = 0;(i < len);i++) {if ( (i == 1)) continue; long sol = ((pow[((len - i) - 1)] * solve((i - 1),(num - 1))) % m); sol = ((sol * faci[(len - i)]) % m); dp[len][num] += sol; dp[len][num] %= m; }} return dp[len][num];} static long[] fac ,faci ,pow ; public static void readInput()throws IOException { StringTokenizer st = new StringTokenizer(br.readLine()); n = Integer.parseInt(st.nextToken()); m = Long.parseLong(st.nextToken()); fac = new long[500]; pow = new long[500]; faci = new long[fac.length]; fac[0] = pow[0] = 1; faci[0] = modinv(fac[0]); for ( int i = 1;(i < fac.length);i++) {fac[i] = ((fac[(i - 1)] * i) % m); faci[i] = modinv(fac[i]); pow[i] = ((pow[(i - 1)] * 2) % m); }dp = new long[(n + 1)][(n + 1)]; for ( long[] a :dp) Arrays.fill(a,-1); long ans = 0; for ( int i = 0;(i <= ((n / 2) + 1));i++) { long sol = (solve(n,i) * fac[(n - i)]); sol %= m; ans += sol; }out.println((ans % m)); } }
0	public class Solution{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] str = br.readLine().split(" ");  long n = Long.parseLong(str[0]); if ( (n < 3)) 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(((n * (n - 1)) * (n - 3))); else System.out.println((((n - 1) * (n - 2)) * (n - 3))); }} }
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 D{ static LinkedList<Integer>[] E ; static int[] M ; static boolean[] visited ; static int n ; static int center ; public static boolean match( int x){ if ( visited[x]) return false; visited[x] = true; for ( int y :E[x]) if ( ((y != center) && ((M[y] == -1) || match(M[y])))) {M[y] = x; return true;} return false;} public static int maxMatch(){ int res = 0; Arrays.fill(M,-1); for ( int i = 0;(i < n);i++) {Arrays.fill(visited,false); if ( ((i != center) && match(i))) res++; }return res;} public static void main( String[] args){ InputReader in = new InputReader(System.in); n = in.readInt(); int m = in.readInt(); E = new LinkedList[n]; M = new int[n]; boolean[][] C = new boolean[n][n]; visited = new boolean[n]; for ( int i = 0;(i < n);i++) E[i] = new LinkedList<Integer>(); for ( int i = 0;(i < m);i++) { int x = (in.readInt() - 1);  int y = (in.readInt() - 1); C[x][y] = true; E[x].add(y); } int min = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int res = 0;  int all = 0; for ( int j = 0;(j < n);j++) if ( (j != i)) {all += E[j].size(); if ( !C[i][j]) res++; if ( !C[j][i]) res++; else all--; } if ( !C[i][i]) res++; center = i; int match = maxMatch(); res += ((all - match) + ((n - match) - 1)); min = Math.min(min,res); }System.out.println(min); } } 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 Solution{ static private int[] a ; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),m = sc.nextInt(); a = new int[101]; for ( int i = 0;(i < m);i++) { int type = sc.nextInt(); a[type] = (a[type] + 1); } int lo = 1,hi = 100,max = 0; while((lo <= hi)){ int mid = (lo + ((hi - lo) / 2)); if ( check(n,mid)) {max = mid; lo = (mid + 1); } else {hi = (mid - 1); }}System.out.println(max); } public static boolean check( int n, int target){ int result = 0; for ( int i = 0;(i < a.length);i++) {result = (result + (a[i] / target)); }if ( (result >= n)) {return true;} return false;} }
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)); } }
3	public class C{ 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.nextInt();  int r = in.nextInt();  int x[] = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = in.nextInt(); } double ans[] = new double[n]; ans[0] = r; int index = 1; for ( int i = 1;(i < n);i++) { double maxY = r; for ( int j = 0;(j < index);j++) { int xDist = Math.abs((x[i] - x[j])); if ( (xDist <= (r * 2))) { double cur = (Math.sqrt((((r * 2) * (r * 2)) - (xDist * xDist))) + ans[j]); maxY = Math.max(maxY,cur); } }ans[i] = maxY; index++; }for ( int i = 0;(i < n);i++) {out.print((ans[i] + " ")); }} } 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 CF1515E extends PrintWriter{ CF1515E(){ super(System.out,true); } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF1515E o = new CF1515E(); o.main(); o.flush(); } int[] ff ,gg ; int md ; long ch( int n, int k){ return (((((long)ff[n] * gg[k]) % md) * gg[(n - k)]) % md);} long inv( int a){ return ((a == 1)?1:((inv((a - (md % a))) * ((md / a) + 1)) % md));} void main(){ int n = sc.nextInt(); md = sc.nextInt(); int[] p2 = new int[n]; for ( int p = 1,i = 0;(i < n);i++) {p2[i] = p; p = ((p * 2) % md); }ff = new int[(n + 1)]; gg = new int[(n + 1)]; long f = 1; for ( int i = 0;(i <= n);i++) {gg[i] = (int)inv(ff[i] = (int)f); f = ((f * (i + 1)) % md); } int[][] dp = new int[(n + 1)][(n + 1)]; dp[1][1] = 1; dp[2][2] = 2; for ( int u = 3;(u <= n);u++) for ( int v = 1;(v <= u);v++) { long x = ((v == u)?p2[(u - 1)]:0); for ( int k = 1;((k < v) && (k <= (u - 2)));k++) x += ((((dp[((u - k) - 1)][(v - k)] * ch(v,k)) % md) * p2[(k - 1)]) % md); dp[u][v] = (int)(x % md); } int ans = 0; for ( int v = 1;(v <= n);v++) ans = ((ans + dp[n][v]) % md); println(ans); } }
6	public class Problem_8C{ static private int dis( int x1, int y1, int x2, int y2){ return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int ox = sc.nextInt();  int oy = sc.nextInt();  int n = sc.nextInt();  int[] ix = new int[n];  int[] iy = new int[n];  int[] single = new int[n];  int[][] pair = new int[n][n]; for ( int i = 0;(i < n);i++) {ix[i] = sc.nextInt(); iy[i] = sc.nextInt(); single[i] = (dis(ox,oy,ix[i],iy[i]) * 2); for ( int j = 0;(j < i);j++) {pair[i][j] = pair[j][i] = (dis(ix[i],iy[i],ix[j],iy[j]) + ((single[i] + single[j]) / 2)); }} int[] min = new int[(1 << n)];  int[] pre = 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;} }min[set] = (min[(set ^ (1 << i))] + single[i]); pre[set] = (set ^ (1 << i)); for ( int j = 0;(j < n);j++) {if ( ((set & (1 << j)) == 0)) {continue;} if ( (min[set] > (min[((set ^ (1 << i)) ^ (1 << j))] + pair[i][j]))) {min[set] = (min[((set ^ (1 << i)) ^ (1 << j))] + pair[i][j]); pre[set] = ((set ^ (1 << i)) ^ (1 << j)); } }}System.out.println(min[((1 << n) - 1)]); for ( int set = ((1 << n) - 1);(set != 0);set = pre[set]) {System.out.print("0 "); for ( int i = 0;(i < n);i++) {if ( (((set ^ pre[set]) & (1 << i)) != 0)) {System.out.print(((i + 1) + " ")); } }}System.out.println("0"); sc.close(); } }
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));} } }
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;} } }
3	public class A{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }Arrays.sort(a); int vis[] = new int[n]; Arrays.fill(vis,-1); int c = 0; for ( int i = 0;(i < n);i++) {if ( (vis[i] != -1)) continue; c++; for ( int j = i;(j < n);j++) {if ( ((vis[j] == -1) && ((a[j] % a[i]) == 0))) {vis[j] = c; } }}pw.println(c); pw.close(); } }
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(); } }
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;} }
4	public class C{ static private BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static private BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static void main( String[] args)throws IOException { int t = Integer.parseInt(br.readLine()); while((t-- > 0)){ int n = Integer.parseInt(br.readLine());  int prev = 1;  ArrayList<Integer> nums = new ArrayList<>(); nums.add(1); String till = "1"; for ( int i = 0;(i < n);i++) { int ln = Integer.parseInt(br.readLine()); if ( (i == 0)) {bw.write("1\n"); continue;} if ( (ln == 1)) {nums.add(1); } else if ( (ln == (prev + 1))) {nums.set((nums.size() - 1),ln); } else { int idx = -1; for ( int j = (nums.size() - 1);(j >= 0);j--) {if ( (nums.get(j) == (ln - 1))) {idx = j; break;} } ArrayList<Integer> temp = new ArrayList<>(); for ( int j = 0;(j < idx);j++) {temp.add(nums.get(j)); }temp.add(ln); nums.clear(); nums = temp; }for ( int j = 0;(j < (nums.size() - 1));j++) {bw.write((nums.get(j) + ".")); }bw.write((nums.get((nums.size() - 1)) + "\n")); prev = ln; }}bw.flush(); } }
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);  TaskF solver = new TaskF(); solver.solve(1,in,out); out.close(); } static class TaskF{ public void solve( int testNumber, Scanner in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  int[][] graph = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) graph[i][j] = in.nextInt(); } int[][] mn1 = new int[n][n];  int[][] mn2 = new int[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) { int min_val = Integer.MAX_VALUE; for ( int k = 0;(k < m);k++) min_val = Math.min(min_val,Math.abs((graph[i][k] - graph[j][k]))); mn1[i][j] = min_val; min_val = Integer.MAX_VALUE; for ( int k = 0;(k < (m - 1));k++) {min_val = Math.min(min_val,Math.abs((graph[i][k] - graph[j][(k + 1)]))); }mn2[i][j] = min_val; } int[][] dp = new int[(1 << (n + 2))][n];  int ans = 0; for ( int i = 0;(i < n);i++) {for ( int[] temp :dp) Arrays.fill(temp,-1); for ( int j = 0;(j < n);j++) {dp[(1 << j)][j] = ((j == i)?Integer.MAX_VALUE:0); }for ( int j = 0;(j < n);j++) {ans = Math.max(ans,Math.min(mn2[j][i],calc(((1 << n) - 1),j,dp,mn1,n))); }}out.println(ans); } public int calc( int mask, int v, int[][] dp, int[][] mn1, int n){ if ( (dp[mask][v] != -1)) return dp[mask][v]; dp[mask][v] = 0; for ( int u = 0;(u < n);u++) {if ( ((u != v) && (((mask >> u) & 1) == 1))) dp[mask][v] = Math.max(dp[mask][v],Math.min(mn1[u][v],calc((mask ^ (1 << v)),u,dp,mn1,n))); }return dp[mask][v];} } }
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); new TaskC().solve(in,out); out.close(); } } class TaskC{ static final long mod = 1000000009; public void solve( InputReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int l = 0,r = (m / k); while((l < r)){ int mid = ((l + r) >>> 1); if ( good(n,m,k,mid)) {r = mid; } else {l = (mid + 1); }} Mat u = new Mat(); u.set(k,1,0,0); Mat v = new Mat(); v.set(2,0,k,1); u = u.mul(v.powMat(l)); out.println(((((u.e[0][0] - k) + (m - (l * k))) + mod) % mod)); } private boolean good( int n, int m, int k, int mid){ n -= (mid * k); m -= (mid * k); int ans = (((n / k) * (k - 1)) + (n % k)); if ( (ans >= m)) return true; return false;} static private class Mat{ long[][] e = new long[2][2]; Mat mul( Mat u){ Mat s = new Mat(); s.set(0,0,0,0); for ( int i = 0;(i < 2);i++) {for ( int j = 0;(j < 2);j++) {for ( int k = 0;(k < 2);k++) {s.e[i][j] = ((s.e[i][j] + (e[i][k] * u.e[k][j])) % mod); }}}return s;} Mat powMat( int k){ Mat u = this;  Mat s = new Mat(); s.set(1,0,0,1); while((k != 0)){if ( ((k % 2) == 1)) {s = s.mul(u); } u = u.mul(u); k /= 2; }return s;} void set( long i, long j, long k, long l){ e[0][0] = i; e[0][1] = j; e[1][0] = k; e[1][1] = l; } } } 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 Main{ static PrintWriter out ; static InputReader ir ; static void solve(){ int n = ir.nextInt();  int t = ir.nextInt();  int[][] a = new int[n][]; for ( int i = 0;(i < n);i++) a[i] = ir.nextIntArray(2); long[] f = fact(15);  long res = 0; for ( int i = 0;(i < (1 << n));i++) { int[] ct = new int[4];  int tot = 0; for ( int j = 0;(j < n);j++) {if ( (((1 << j) & i) != 0)) {tot += a[j][0]; ct[a[j][1]]++; } }if ( (tot != t)) continue; long[][][][] dp = new long[(ct[1] + 1)][(ct[2] + 1)][(ct[3] + 1)][4]; dp[0][0][0][0] = 1; for ( int j = 0;(j < ((ct[1] + ct[2]) + ct[3]));j++) {for ( int k = 0;(k <= ct[1]);k++) {for ( int l = 0;(l <= ct[2]);l++) {if ( (((k + l) > j) || (((j - k) - l) > ct[3]))) continue; for ( int m = 0;(m <= 3);m++) {for ( int o = 0;(o <= 3);o++) {if ( (m == o)) continue; if ( ((o == 1) && (k == ct[1]))) continue; if ( ((o == 2) && (l == ct[2]))) continue; if ( ((o == 3) && (((j - k) - l) == ct[3]))) continue; if ( (o == 1)) {dp[(k + 1)][l][((j - k) - l)][1] = add(dp[(k + 1)][l][((j - k) - l)][1],dp[k][l][((j - k) - l)][m]); } if ( (o == 2)) {dp[k][(l + 1)][((j - k) - l)][2] = add(dp[k][(l + 1)][((j - k) - l)][2],dp[k][l][((j - k) - l)][m]); } if ( (o == 3)) {dp[k][l][(((j - k) - l) + 1)][3] = add(dp[k][l][(((j - k) - l) + 1)][3],dp[k][l][((j - k) - l)][m]); } }}}}}for ( int m = 0;(m <= 3);m++) res = add(res,mul(mul(f[ct[1]],f[ct[2]]),mul(f[ct[3]],dp[ct[1]][ct[2]][ct[3]][m]))); }out.println(res); } static long mod = ((long)1e9 + 7); static long add( long a, long b){ return ((a + b) % mod);} static long mul( long a, long b){ return ((a * b) % mod);} static long div( long a, long b){ return ((a * mod_inverse(b)) % mod);} static private long[] fact( int n){ long[] ret = new long[(n + 1)]; ret[0] = (1 % mod); for ( int i = 1;(i <= n);i++) {ret[i] = mul(ret[(i - 1)],i); }return ret;} public static long mod_inverse( long a){ long[] ret = extgcd(a,mod); return add(mod,(ret[0] % mod));} public static long[] extgcd( long a, long b){ long[] ret = new long[3]; ret[2] = _extgcd(a,b,ret); return ret;} static private long _extgcd( long a, long b, long[] x){ long g = a; x[0] = 1; x[1] = 0; if ( (b != 0)) {g = _extgcd(b,(a % b),x); long temp = x[0]; x[0] = x[1]; x[1] = temp; x[1] -= ((a / b) * x[0]); } return g;} public static void main( String[] args){ ir = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static class InputReader{ private InputStream in ; private byte[] buffer = new byte[1024]; private int curbuf ; private int lenbuf ; public InputReader( InputStream in){ this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte(){ if ( (curbuf >= lenbuf)) {curbuf = 0; try{lenbuf = in.read(buffer); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return false; } return true;} private int readByte(){ if ( hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private void skip(){ while((hasNextByte() && isSpaceChar(buffer[curbuf])))curbuf++; } public boolean hasNext(){ skip(); return hasNextByte();} public String next(){ if ( !hasNext()) throw (new NoSuchElementException()); StringBuilder sb = new StringBuilder();  int b = readByte(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} public int nextInt(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public long nextLong(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
1	public class Main{ static final long MOD = 1000000007L; public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int k = scan.nextInt();  int res = -1;  int[] arr = new int[n]; for ( int i = 0;(i < arr.length);i++) {arr[i] = scan.nextInt(); } BitSet bits = new BitSet();  int count = 0;  int end = -1; for ( int i = 0;(i < arr.length);i++) {if ( !bits.get(arr[i])) {bits.set(arr[i]); count++; if ( (count == k)) {end = i; break;} } }if ( (end == -1)) {System.out.print("-1 -1"); return ;} bits = new BitSet(); count = 0; int start = end; while((start >= 0)){if ( !bits.get(arr[start])) {bits.set(arr[start]); count++; if ( (count == k)) {break;} } start--; }System.out.println((((start + 1) + " ") + (end + 1))); } }
3	public class Main{ static private int REM = 1000000007; static private int dig ; static private int[][][] dp = new int[701][701][2]; public static void main( String[] args){ Scanner in = new Scanner(System.in);  String X = in.next();  int N = X.length();  int[] P = new int[701]; P[0] = 1; for ( int i = 1;(i < P.length);++i) {P[i] = (int)(((long)P[(i - 1)] * 10) % REM); } int ans = 0; for ( int d = 1;(d <= 9);++d) {dig = d; for ( int[][] array2 :dp) {for ( int[] array1 :array2) {Arrays.fill(array1,-1); }}for ( int c = 1;(c <= N);++c) {for ( int k = 0;(k < c);++k) {ans = (int)((ans + ((long)f(0,c,false,X) * P[k])) % REM); }}}System.out.println(ans); } static private int f( int ps, int needed, boolean less,final String X){ if ( (needed < 0)) {return 0;} if ( (dp[ps][needed][(less?0:1)] != -1)) {return dp[ps][needed][(less?0:1)];} if ( (ps == X.length())) {if ( (needed == 0)) {return 1;} return 0;} int dg = (X.charAt(ps) - '0');  int ans = 0; for ( int d = 0;(d <= 9);++d) {if ( (!less && (d > dg))) {continue;} boolean nless = (less || (d < dg)); ans = (int)((ans + (long)f((ps + 1),(needed - ((d >= dig)?1:0)),nless,X)) % REM); }dp[ps][needed][(less?0:1)] = ans; return ans;} }
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; } HashMap<Long,Integer> map = new HashMap<Long,Integer>();  long[] ar = new long[numCnt]; for ( int i = 0;(i < numCnt);i++) {ar[i] = nextLong(); map.put(((ar[i] * 10007) + (ar[i] / 13)),i); }for ( int i = 0;(i < ar.length);i++) { long req = (ar[i] * k);  Integer idx = map.get(((req * 10007) + (req / 13))); if ( (idx != null)) {union(i,idx); } } 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); }} }
0	public class A{ public static void main( String[] args){ OutputStream outputStream = System.out;  PrintWriter out = new PrintWriter(outputStream);  Application solver = new Application(); solver.solve(System.in,out); out.close(); } } class Application{ int max( int a, int b){ return ((a > b)?a:b);} public void solve( InputStream in, PrintWriter out){ Scanner scanner = new Scanner(in);  int n = scanner.nextInt();  int n1 = (n / 10);  int n2 = (((n / 100) * 10) + (n % 10));  int m = max(max(n1,n2),n); out.println(m); } }
4	public class E3{ InputStream is ; FastWriter out ; String INPUT = ""; void solve(){ for ( int T = ni();(T > 0);T--) go(); } int[] lpf = enumLowestPrimeFactors(10000000); void go(){ int n = ni(),K = ni();  int[] a = na(n); for ( int i = 0;(i < n);i++) {a[i] = factorFast(a[i],lpf); }a = shrink(a); int[][] dp = new int[(K + 1)][(n + 1)]; for ( int i = 0;(i <= K);i++) {Arrays.fill(dp[i],999999999); }for ( int i = 0;(i <= K);i++) dp[i][0] = 0; int[] prev = makePrev(a,(n + 1));  int[] imos = new int[(n + 5)];  int[] pp = new int[(K + 1)];  int[] vs = new int[(K + 1)]; for ( int i = 0;(i < n);i++) { int p = prev[i]; imos[(p + 1)]--; for ( int j = 0;(j <= K);j++) {vs[j]++; if ( (pp[j] >= (p + 1))) {vs[j]--; } while((vs[j] > j)){pp[j]++; vs[j] += imos[pp[j]]; }for ( int k = 0;((k + j) <= K);k++) {dp[(k + j)][(i + 1)] = Math.min(dp[(k + j)][(i + 1)],(dp[k][pp[j]] + 1)); }}}out.println(dp[K][n]); } public static int[] shrink( int[] a){ int n = a.length;  long[] b = new long[n]; for ( int i = 0;(i < n);i++) b[i] = (((long)a[i] << 32) | i); Arrays.sort(b); int[] ret = new int[n];  int p = 0; for ( int i = 0;(i < n);i++) {if ( ((i > 0) && (((b[i] ^ b[(i - 1)]) >> 32) != 0))) p++; ret[(int)b[i]] = p; }return ret;} public static int[] makePrev( int[] a, int sup){ int n = a.length;  int[] mnext = new int[sup]; Arrays.fill(mnext,-1); int[] next = new int[n]; for ( int i = 0;(i < n);i++) {next[i] = mnext[a[i]]; mnext[a[i]] = i; }return next;} public static int factorFast( int n, int[] lpf){ int ret = 1;  int e = 0;  int last = -1; while((lpf[n] > 0)){ int p = lpf[n]; if ( (last != p)) {if ( ((last > 0) && ((e % 2) == 1))) {ret = (ret * last); } last = p; e = 1; } else {e++; }n /= p; }if ( ((last > 0) && ((e % 2) == 1))) {ret *= last; } return ret;} public static int[] enumLowestPrimeFactors( int n){ int tot = 0;  int[] lpf = new int[(n + 1)];  int u = (n + 32);  double lu = Math.log(u);  int[] primes = new int[(int)((u / lu) + (((u / lu) / lu) * 1.5))]; for ( int i = 2;(i <= n);i++) lpf[i] = i; for ( int p = 2;(p <= n);p++) {if ( (lpf[p] == p)) primes[tot++] = p;  int tmp ; for ( int i = 0;(((i < tot) && (primes[i] <= lpf[p])) && ((tmp = (primes[i] * p)) <= n));i++) {lpf[tmp] = primes[i]; }}return lpf;} 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 E3().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{ static private 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;} static private 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;} static private 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)); } }
3	public class D{ private void solve(){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = nextInt(),m = nextInt(),u = 1,d = n; while((u < d)){for ( int i = 1;(i <= m);i++) {out.println(((u + " ") + i)); out.println(((d + " ") + ((m - i) + 1))); }u++; d--; }if ( (u == d)) { int l = 1,r = m; while((l < r)){out.println(((u + " ") + l++)); out.println(((d + " ") + r--)); }if ( (l == r)) out.println(((u + " ") + l)); } out.close(); } public static void main( String[] args){ new D().solve(); } private BufferedReader br ; private StringTokenizer st ; private PrintWriter out ; private String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return st.nextToken();} private int nextInt(){ return Integer.parseInt(next());} }
4	public class Main1{ static class pair{ int x ; int y ; public pair( int k, int p){ x = k; y = p; } } public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter("output.txt");  Queue<pair> q = new LinkedList<>();  int n = sc.nextInt();  int m = sc.nextInt();  int t = sc.nextInt();  int mark[][] = new int[(n + 2)][(m + 2)]; while((t-- > 0)){ int a = sc.nextInt();  int b = sc.nextInt(); mark[a][b] = 1; q.add(new pair(a,b)); } int ansx = 1;  int ansy = 1; while((q.size() != 0)){ pair p = q.remove(); if ( (mark[Math.max(1,(p.x - 1))][p.y] == 0)) {q.add(new pair(Math.max(1,(p.x - 1)),p.y)); mark[Math.max(1,(p.x - 1))][p.y] = 1; ansx = Math.max(1,(p.x - 1)); ansy = p.y; } if ( (mark[Math.min(n,(p.x + 1))][p.y] == 0)) {q.add(new pair(Math.min(n,(p.x + 1)),p.y)); mark[Math.min(n,(p.x + 1))][p.y] = 1; ansx = Math.min(n,(p.x + 1)); ansy = p.y; } if ( (mark[p.x][Math.max(1,(p.y - 1))] == 0)) {q.add(new pair(p.x,Math.max(1,(p.y - 1)))); mark[p.x][Math.max(1,(p.y - 1))] = 1; ansx = p.x; ansy = Math.max(1,(p.y - 1)); } if ( (mark[p.x][Math.min(m,(p.y + 1))] == 0)) {q.add(new pair(p.x,Math.min(m,(p.y + 1)))); mark[p.x][Math.min(m,(p.y + 1))] = 1; ansx = p.x; ansy = Math.min(m,(p.y + 1)); } }out.println(((ansx + " ") + ansy)); out.flush(); } }
3	public class c implements Runnable{ int N ; int[] arr ; public static void main( String[] args){ new Thread(null,new c(),"",(1 << 27)).start(); } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line = null; int line_ptr = 0; void read(){ try{line = br.readLine().split(" "); }catch (IOException ioe){ System.err.println("bad input"); line = null; } } void ensure(){ while(((line == null) || (line.length <= line_ptr))){read(); line_ptr = 0; }} int nextInt(){ ensure(); return Integer.parseInt(line[line_ptr++]);} String nextString(){ ensure(); return line[line_ptr++];} }
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){ int N = in.nextInt(); if ( ((N % 2) == 0)) {out.println(("4 " + (N - 4))); } else {out.println(("9 " + (N - 9))); }} }
0	public class A{ long gcd( long a, long b){ if ( (b == 0)) {return a;} else {return gcd(b,(a % b));}} long solve( long a, long b){ if ( ((a == 0) || (b == 0))) {return 0;} long t = gcd(a,b); a /= t; b /= t; if ( (a > b)) {return (solve((a % b),b) + (a / b));} else {return (solve(a,(b % a)) + (b / a));}} void solve()throws IOException { long a = nextLong();  long b = nextLong(); out.println(solve(a,b)); } void run()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 A().run(); } BufferedReader br ; PrintWriter out ; StringTokenizer str ; String next()throws IOException { while(((str == null) || !str.hasMoreTokens())){str = new StringTokenizer(br.readLine()); }return str.nextToken();} long nextLong()throws IOException { return Long.parseLong(next());} }
0	public class D5{ 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)));  double a = nextInt();  double v = nextInt();  double L = nextInt();  double d = nextInt();  double w = nextInt();  double ans = 0; if ( (w >= v)) ans = go(0,a,L,v); else {ans = go(Math.min(w,Math.sqrt(((2 * a) * d))),a,(L - d),v); if ( (((2 * a) * d) < (w * w))) ans += Math.sqrt(((2 * d) / a)); else {if ( ((d - ((v * v) / (2 * a))) >= (((v * v) - (w * w)) / (2 * a)))) ans += (((v / a) + ((v - w) / a)) + (((d - ((v * v) / (2 * a))) - (((v * v) - (w * w)) / (2 * a))) / v)); else { double x = Math.sqrt((((w * w) + ((2 * a) * d)) / 2)); ans += ((x / a) + ((x - w) / a)); }}}System.out.println(ans); pw.close(); } static private double go( double v0, double a, double s, double vmax){ double t = ((vmax - v0) / a); if ( (((v0 * t) + (((a * t) * t) / 2)) < s)) return (t + (((s - (v0 * t)) - (((a * t) * t) / 2)) / vmax)); else { double D = ((v0 * v0) + ((2 * a) * s)); return ((-v0 + Math.sqrt(D)) / a);}} static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
6	public class D11{ static StreamTokenizer in ; static PrintWriter out ; static int nextInt()throws IOException { in.nextToken(); return (int)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(); m = nextInt(); g = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (nextInt() - 1),b = (nextInt() - 1); g[a][b] = g[b][a] = true; } long ans = 0; for ( int i = (n - 1);(i >= 0);i--) { long cur = solve(i); ans += cur; }out.println((ans / 2)); out.flush(); } static int n ,m ; static boolean[][] g ; static long solve( int v){ long[][] memo = new long[v][(1 << v)]; for ( int i = 0;(i < v);i++) if ( g[v][i]) memo[i][(1 << i)] = 1; for ( int mask = 1;(mask < (1 << v));mask++) for ( int i = 0;(i < v);i++) if ( ((mask & (1 << i)) != 0)) for ( int j = 0;(j < v);j++) if ( (g[i][j] && ((mask & (1 << j)) == 0))) memo[j][(mask | (1 << j))] += memo[i][mask];  long res = 0; for ( int mask = 1;(mask < (1 << v));mask++) for ( int i = 0;(i < v);i++) if ( ((Integer.bitCount(mask) > 1) && g[v][i])) res += memo[i][mask]; return res;} }
1	public class Trains1_2 implements Runnable{ private BufferedReader br = null; private PrintWriter pw = null; private StringTokenizer stk = new StringTokenizer(""); public static void main( String[] args){ new Thread(new Trains1_2()).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());} boolean isNumber( char c){ if ( ((c <= '9') && (c >= '0'))) return true; return false;} String to10( String s){ long ans = 0; for ( int i = (s.length() - 1);(i >= 0);i--) {ans += (((s.charAt(i) - 'A') + 1) * Math.pow(26,((s.length() - i) - 1))); }return String.valueOf(ans);} String to26( String s){ String ans = "";  int a = Integer.valueOf(s); while((a > 26)){a--; int k = (a % 26); ans = (ans + (char)((int)'A' + k)); a /= 26; }ans += (char)((a + 'A') - 1); String ans1 = ""; for ( int i = (ans.length() - 1);(i >= 0);i--) ans1 += ans.charAt(i); return ans1;} String rev( String s){ String ans = "";  int format = 0;  int git = 0;  String token1 = "";  String token2 = "";  String token3 = "",token4 = ""; for ( int i = 0;(i < s.length());i++) {if ( !isNumber(s.charAt(i))) token1 += s.charAt(i); else break;git++; }for ( int i = git;(i < s.length());i++) {if ( isNumber(s.charAt(i))) token2 += s.charAt(i); else break;git++; }if ( (s.length() == git)) format = 1; else {format = 2; for ( int i = git;(i < s.length());i++) {if ( !isNumber(s.charAt(i))) token3 += s.charAt(i); else break;git++; }for ( int i = git;(i < s.length());i++) if ( isNumber(s.charAt(i))) token4 += s.charAt(i); else break;}if ( (format == 1)) {ans += "R"; ans += token2; ans += "C"; ans += to10(token1); } else {ans += to26(token4); ans += token2; }return ans;} private void solver(){ int n = ni(); for ( int i = 0;(i < n);i++) System.out.println(rev(nstr())); } void exit(){ System.exit(0); } }
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 D{ static long n ; static long x ; static long y ; static long c ; static long f( long t){ long s = 0; if ( (t == 0)) s = 1; else {s = ((((4 + (4 * t)) / 2) * t) + 1); }if ( ((x + t) > n)) { long c = ((x + t) - n); s -= (c * c); } if ( ((x - t) <= 0)) { long c = ((t - x) + 1); s -= (c * c); } if ( ((y + t) > n)) { long c = ((y + t) - n); s -= (c * c); } if ( ((y - t) <= 0)) { long c = ((t - y) + 1); s -= (c * c); } if ( (t > ((x + y) - 1))) { long m = (((t - x) - y) + 1); s += ((m * (m + 1)) / 2); } if ( (t > ((x + n) - y))) { long m = (((t - x) - n) + y); s += ((m * (m + 1)) / 2); } if ( (t > ((n - x) + y))) { long m = (((t - n) - y) + x); s += ((m * (m + 1)) / 2); } if ( (t > ((((n - x) + n) - y) + 1))) { long m = ((((t - (2 * n)) + x) + y) - 1); s += ((m * (m + 1)) / 2); } return s;} public static void main( String[] args){ Scanner in = new Scanner(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out); n = in.nextLong(); x = in.nextLong(); y = in.nextLong(); c = in.nextLong(); long l = 0;  long r = (2 * n); while((l < r)){ long m = ((l + r) / 2);  long ff = f(m); if ( (ff < c)) {l = (m + 1); } else {r = m; }}out.println(l); 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);  PrintWriter out = new PrintWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ long l = in.readLong(),r = in.readLong();  int pow = 62;  long mask = (1L << pow); while((((r | l) & mask) == 0)){pow--; mask = (1L << pow); }while(true){if ( ((((r ^ l) & mask) == mask) || (pow < 0))) {break;} mask >>= 1; l = (l & (1L << pow)); r = (r & (1L << pow)); pow--; }pow++; out.print(((1L << pow) - 1)); } } 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 = 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));} }
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 m = in.nextInt();  int k = in.nextInt();  int[] fs = IOUtils.readIntArray(in,n); Arrays.sort(fs); int ptr = (fs.length - 1);  int res = 0; while(((ptr >= 0) && (k < m))){k += (fs[ptr--] - 1); res++; }if ( (k < m)) out.println(-1); else out.println(res); } }
5	public class A{ 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 r = 0,an = 0; Arrays.sort(a); int t = 0; for ( int z :a) t += z; for ( int i = (a.length - 1);(i >= 0);i--) {r += a[i]; an++; if ( (r > (t - r))) break; }System.out.println(an); } }
1	public class Pr468B{ public static void main( String[] args)throws IOException { new Pr468B().run(); } 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());} void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out,true); solve(); out.flush(); } int[] which ; boolean[] was ; int[] pa ; int[] pb ; void dfs( int i, boolean fa){ was[i] = true; if ( fa) {if ( (pa[i] == -1)) {out.println("NO"); out.flush(); System.exit(0); } which[i] = 0; which[pa[i]] = 0; if ( ((pb[pa[i]] != -1) && !was[pb[pa[i]]])) {dfs(pb[pa[i]],fa); } } else {if ( (pb[i] == -1)) {out.println("NO"); out.flush(); System.exit(0); } which[i] = 1; which[pb[i]] = 1; if ( ((pa[pb[i]] != -1) && !was[pa[pb[i]]])) {dfs(pa[pb[i]],fa); } }} void solve()throws IOException { int n = nextInt();  int a = nextInt();  int b = nextInt();  int[] p = new int[n];  HashMap<Integer,Integer> allNums = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {p[i] = nextInt(); if ( (p[i] >= Math.max(a,b))) {out.println("NO"); return ;} allNums.put(p[i],i); }pa = new int[n]; pb = new int[n]; Arrays.fill(pa,-1); Arrays.fill(pb,-1); which = new int[n]; Arrays.fill(which,-1); for ( int i = 0;(i < n);i++) {if ( ((pa[i] == -1) && allNums.containsKey((a - p[i])))) {pa[i] = allNums.get((a - p[i])); pa[pa[i]] = i; } if ( ((pb[i] == -1) && allNums.containsKey((b - p[i])))) {pb[i] = allNums.get((b - p[i])); pb[pb[i]] = i; } if ( ((pa[i] == -1) && (pb[i] == -1))) {out.println("NO"); return ;} }was = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( (!was[i] && (pa[i] == -1))) {dfs(i,false); } else if ( (!was[i] && (pb[i] == -1))) {dfs(i,true); } }for ( int i = 0;(i < n);i++) {if ( !was[i]) {dfs(i,true); } }out.println("YES"); for ( int i = 0;(i < n);i++) {out.print((which[i] + " ")); }} }
2	public class A{ FastScanner in ; PrintWriter out ; final long mod = ((long)1e9 + 9); public void solve()throws IOException { long n = in.nextInt();  long m = in.nextInt();  long k = in.nextInt();  long l = (n / k);  long c = (n - m);  long mul2 = Math.max(0,(l - c)); if ( (mul2 == 0)) {out.println(m); return ;} long ans = power(2,(mul2 + 1),mod); ans = (((ans + mod) - 2) % mod); ans = ((ans * k) % mod); long z = (mul2 * k);  long r = (m - z); ans = ((ans + r) % mod); out.print(ans); } public long power( long x, long pow, long mod){ if ( (pow == 0)) {return 1;} if ( ((pow % 2) == 0)) {return power(((x * x) % mod),(pow / 2),mod);} else {return ((power(x,(pow - 1),mod) * x) % mod);}} public void run(){ try{in = new FastScanner(System.in); out = new PrintWriter(System.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(); } } public FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } 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 A().run(); } }
3	public class Practice{ 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();  String[] arr1 = new String[n];  String[] arr2 = new String[n]; for ( int i = 0;(i < n);i++) {arr1[i] = in.next(); }for ( int i = 0;(i < n);i++) {arr2[i] = in.next(); } int ans = 0;  boolean arr[] = new boolean[n];  boolean found = false; for ( int i = 0;(i < arr1.length);i++) {for ( int j = 0;(j < arr1.length);j++) {found = false; if ( (arr1[i].equals(arr2[j]) && !arr[j])) {found = true; arr[j] = true; break;} }if ( !found) {ans++; } }out.println(ans); } } public long GCD( long a, long b){ if ( (b == 0)) {return a;} return 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());} } }
0	public class A{ public static final boolean DEBUG = false; Scanner sc ; public void pln( Object o){ System.out.println(o); } public void run(){ sc = new Scanner(System.in); long a = sc.nextLong();  long b = sc.nextLong();  long nr = 0; if ( (a < b)) { long aux = a; a = b; b = aux; } while(((a != 0) && (b != 0))){nr += (a / b); long c = (a % b); a = b; b = c; }pln(nr); return ;} public static void main( String[] args){ A t = new A(); t.run(); } }
6	public class ASimpleTask{ static private void solve( FastScanner s1, PrintWriter out){ int V = s1.nextInt();  int E = s1.nextInt();  int 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); solve(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(); } } } }
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)); } static private 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); }} } static private 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++]); }}} static private 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); } }
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(); out.println(go(a,b)); } private long go( long a, long b){ if ( (b == 0)) return 0; return ((a / b) + go(b,(a % b)));} } class InputReader{ BufferedReader reader ; 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 (Exception e){ throw (new UnknownError());} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
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); } }
2	public class C{ static private BufferedReader in ; static private StringTokenizer st ; static private 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());} }
0	public class Task343A{ public static void main( String... args)throws NumberFormatException,IOException { Solution.main(System.in,System.out); } static class Scanner{ private final BufferedReader br ; private String[] cache ; private int cacheIndex ; Scanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); cache = new String[0]; cacheIndex = 0; } long nextLong()throws IOException { if ( (cacheIndex >= cache.length)) {cache = br.readLine().split(" "); cacheIndex = 0; } return Long.parseLong(cache[cacheIndex++]);} void close()throws IOException { br.close(); } } static class Solution{ static private long r( long a, long b){ if ( ((a == 0) || (b == 0))) {return 0;} if ( (a > b)) {return ((a / b) + r(b,(a % b)));} return ((b / a) + r(a,(b % a)));} public static void main( InputStream is, OutputStream os)throws NumberFormatException,IOException { PrintWriter pw = new PrintWriter(os);  Scanner sc = new Scanner(is);  long a = sc.nextLong();  long b = sc.nextLong(); pw.println(r(a,b)); pw.flush(); sc.close(); } } }
0	public class A{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int prev2 = 0;  int prev1 = 1;  int prev = 1;  int curr = 2; if ( (n == 0)) {System.out.println("0 0 0"); return ;} else if ( (n == 1)) {System.out.println("0 0 1"); return ;} while(true){if ( (curr == n)) break; prev2 = prev1; prev1 = prev; int temp = (prev + curr); prev = curr; curr = temp; }System.out.println(((((prev2 + " ") + prev1) + " ") + prev1)); } }
1	public class IQTest{ public static void main( String[] args)throws Exception { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));  String line ; line = stdin.readLine(); int n = Integer.parseInt(line); line = stdin.readLine(); List even = new ArrayList();  List odd = new ArrayList();  String[] kk = line.split(" "); for ( int i = 0;(i < n);i++) {if ( ((Integer.parseInt(kk[i]) % 2) == 0)) even.add(i); else odd.add(i); }if ( (even.size() == 1)) System.out.println(((Integer)even.get(0) + 1)); else System.out.println(((Integer)odd.get(0) + 1)); } }
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){ int balance = in.nextInt(); if ( (balance >= 0)) {out.println(balance); return ;} balance = -balance; int a = (balance / 100);  int b = Math.min((balance % 10),((balance / 10) % 10)); balance = ((a * 10) + b); out.println(balance); } }
2	public class Main{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  long k = scan.nextLong();  long D = (9 + (4 * ((2 * k) + (2 * n))));  long y = ((-3 + (long)Math.sqrt(D)) / 2); System.out.println((n - y)); } }
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.nextInt();  long x = in.nextInt();  long y = in.nextInt();  long c = in.nextInt(); if ( (c == 1)) {out.println(0); return ;} long left = 1,right = (2 * n),middle ,res = -1;  long val = getNumberOfCells(x,y,n,2); while((left <= right)){middle = ((left + right) / 2); long numberOfCells = getNumberOfCells(x,y,n,middle); if ( (numberOfCells < c)) {left = (middle + 1); } else {res = middle; right = (middle - 1); }}out.println(res); } private long getNumberOfCells( long x, long y, long n, long middle){ long res = 0; res += calc(x,y,(middle + 1)); res += calc(((n - x) + 1),y,(middle + 1)); res += calc(x,((n - y) + 1),(middle + 1)); res += calc(((n - x) + 1),((n - y) + 1),(middle + 1)); res -= calcX(x,n,middle); res -= calcX(y,n,middle); --res; return res;} private long calcX( long x, long n, long size){ long left = (x - size);  long right = (x + size); left = Math.max(left,1); right = Math.min(right,n); if ( (left <= right)) {return ((right - left) + 1);} return 0;} private long calc( long x, long y, long size){ if ( (size <= Math.min(x,y))) {return (((1 + size) * size) / 2);} if ( (size >= ((x + y) - 1))) {return (x * y);} if ( (size > Math.max(x,y))) {return ((x * y) - calc(x,y,(((x + y) - 1) - size)));} long min = Math.min(x,y);  long res = (((1 + min) * min) / 2);  long rest = (size - min); res += (rest * min); 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(); }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());} }
3	public class Main{ static private 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(); } static private 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(); } } } static private 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(); } } } }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st ; st = new StringTokenizer(in.readLine()); int n = Integer.parseInt(st.nextToken()),a = Integer.parseInt(st.nextToken()),b = Integer.parseInt(st.nextToken()); st = new StringTokenizer(in.readLine()); ArrayList<Integer> A = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {A.add(Integer.parseInt(st.nextToken())); }Collections.sort(A); System.out.println((A.get(b) - A.get((b - 1)))); } }
1	public class Main{ public static void process()throws IOException { long n = nl(); if ( ((n % 2) == 0)) { long a1 = (long)Math.sqrt(n);  long a2 = (long)Math.sqrt((n / 2)); if ( (((a1 * a1) == n) || (((a2 * a2) * 2) == n))) {pn("YES"); return ;} } pn("NO"); } static AnotherReader sc ; static PrintWriter out ; public static void main( String[] args)throws IOException { boolean oj = (System.getProperty("ONLINE_JUDGE") != null); if ( oj) {sc = new AnotherReader(); out = new PrintWriter(System.out); } else {sc = new AnotherReader(100); out = new PrintWriter("output.txt"); } int t = 1; t = ni(); while((t-- > 0)){process(); }out.flush(); out.close(); } static void pn( Object o){ out.println(o); } static int ni()throws IOException { return sc.nextInt();} static long nl()throws IOException { return sc.nextLong();} static long gcd( long a, long b)throws IOException { return ((b == 0)?a:gcd(b,(a % b)));} static int gcd( int a, int b)throws IOException { return ((b == 0)?a:gcd(b,(a % b)));} static int bit( long n)throws IOException { return ((n == 0)?0:(1 + bit((n & (n - 1)))));} static class AnotherReader{ BufferedReader br ; StringTokenizer st ; AnotherReader()throws FileNotFoundException{ br = new BufferedReader(new InputStreamReader(System.in)); } AnotherReader( int a)throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt")); } String next()throws IOException { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }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());} String nextLine()throws IOException { String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} } }
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 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());} } }
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)); } }
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 Main{ static private BufferedReader reader ; static private BufferedWriter out ; static private StringTokenizer tokenizer ; static private void init( InputStream input, OutputStream output){ reader = new BufferedReader(new InputStreamReader(input)); out = new BufferedWriter(new OutputStreamWriter(output)); tokenizer = new StringTokenizer(""); } static private String nextLine()throws IOException { return reader.readLine();} static private String next()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(nextLine()); }return tokenizer.nextToken();} static private int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { init(System.in,System.out); int n = nextInt(); if ( (n > 0)) {out.write((n + "\n")); } else { String s = (n + "");  String s2 = s.substring(0,(s.length() - 1));  String s3 = (s.substring(0,(s.length() - 2)) + s.charAt((s.length() - 1)));  int a = Integer.parseInt(s2);  int b = Integer.parseInt(s3);  int ans = Math.max(a,b); out.write((ans + "\n")); }out.flush(); } }
4	public class E{ FastScanner in ; PrintWriter out ; private int M ; public static void main( String[] args){ new E().solve(); } private void solve(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); solveCase(); out.close(); } long[][] comb = new long[512][512]; private void solveCase(){ int n = in.nextInt(); this.M = in.nextInt(); calcComb(n,M); for ( int i = 0;(i < 512);i++) {for ( int j = 0;(j < 512);j++) {memoDivide[i][j] = -1; memoDP[i][j] = -1; dpG[i] = -1; }} long res = g(n); for ( int i = 1;(i <= (n - 1));i++) {res = ((res + dp(n,i)) % M); }out.println(res); } long[] dpG = new long[512]; private long g( int n){ if ( (n < 2)) return 1; if ( (n == 2)) return 2; if ( (dpG[n] != -1)) return dpG[n]; long res = 0; for ( int divide = 0;(divide < n);divide++) {res = ((res + divider(divide,((n - divide) - 1))) % M); }return dpG[n] = res;} long[][] memoDivide = new long[512][512]; private long divider( int a, int b){ if ( ((a == 0) || (b == 0))) return 1; if ( (memoDivide[a][b] != -1)) return memoDivide[a][b]; return memoDivide[a][b] = ((divider((a - 1),b) + divider(a,(b - 1))) % M);} long[][] memoDP = new long[512][512]; private long dp( int n, int i){ if ( ((n > 0) && (i == 0))) return 0; if ( ((n == 0) && (i > 0))) return 0; if ( (i > n)) return 0; if ( ((n == 0) && (i == 0))) return 1; if ( (i == n)) return g(n); if ( (i <= 1)) return 0; if ( (memoDP[n][i] != -1)) return memoDP[n][i]; long res = 0; for ( int failure = 1;((failure < (n - 1)) && ((i - failure) >= 1));failure++) {res += (((g(failure) * comb[i][failure]) % M) * dp(((n - failure) - 1),(i - failure))); res %= M; }return memoDP[n][i] = res;} private void calcComb( int n, int m){ for ( int i = 0;(i < 512);i++) {comb[0][i] = 0; }for ( int i = 0;(i < 512);i++) {comb[i][0] = 1; }for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= n);j++) {comb[i][j] = ((comb[(i - 1)][j] + comb[(i - 1)][(j - 1)]) % m); }}} static class FastScanner{ BufferedReader br ; 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)); } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} int nextInt(){ return Integer.parseInt(next());} } }
3	public class newProgram5{ public static void main( String[] args)throws IOException { FastIO in = new FastIO();  int n = in.ni();  int a[] = in.gia(n);  int freq[] = new int[(100 + 1)]; for ( int i = 0;(i < n);i++) {freq[a[i]]++; } int k = 0; for ( int i = 1;(i <= 100);i++) {if ( (freq[i] > 0)) {for ( int j = i;(j <= 100);j += i) {freq[j] = 0; }k++; } }System.out.println(k); in.bw.flush(); } static class FastIO{ private final BufferedReader br ; private final BufferedWriter bw ; private String s[] ; private int index ; private final StringBuilder sb ; public FastIO()throws IOException{ br = new BufferedReader(new InputStreamReader(System.in)); bw = new BufferedWriter(new OutputStreamWriter(System.out,"UTF-8")); s = br.readLine().split(" "); sb = new StringBuilder(); index = 0; } public int ni()throws IOException { return Integer.parseInt(nextToken());} public double nd()throws IOException { return Double.parseDouble(nextToken());} public long nl()throws IOException { return Long.parseLong(nextToken());} public int[] gia( int n)throws IOException { int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ni(); }return a;} public int[] gia( int n, int start, int end)throws IOException { validate(n,start,end); int a[] = new int[n]; for ( int i = start;(i < end);i++) {a[i] = ni(); }return a;} public void println( String s)throws IOException { bw.write(s); bw.newLine(); } public void println( int s)throws IOException { bw.write((s + "")); bw.newLine(); } public void println( long s)throws IOException { bw.write((s + "")); bw.newLine(); } public void println( double s)throws IOException { bw.write((s + "")); bw.newLine(); } private String nextToken()throws IndexOutOfBoundsException,IOException { if ( (index == s.length)) {s = br.readLine().split(" "); index = 0; } return s[index++];} private void validate( int n, int start, int end){ if ( ((start < 0) || (end >= n))) {throw (new IllegalArgumentException());} } } static class Data implements Comparable<Data>{ int a ,b ; public Data( int a, int b){ this.a = a; this.b = b; } public static void sort( int[] a){ Data d[] = new Data[a.length]; for ( int i = 0;(i < a.length);i++) {d[i] = new Data(a[i],0); }Arrays.sort(d); for ( int i = 0;(i < a.length);i++) {a[i] = d[i].a; }} } }
0	public class TwoSquares{ int INF = 1000; void solve(){ int[][] s1 = new int[4][2]; for ( int i = 0;(i < 4);i++) {s1[i][0] = in.nextInt(); s1[i][1] = in.nextInt(); } int[][] s2 = new int[4][2]; for ( int i = 0;(i < 4);i++) {s2[i][0] = in.nextInt(); s2[i][1] = in.nextInt(); }if ( ok(s1,s2)) {out.println("Yes"); return ;} rotate(s1); rotate(s2); if ( ok(s2,s1)) {out.println("Yes"); return ;} out.println("No"); } void rotate( int[][] s){ for ( int i = 0;(i < 4);i++) { int x = s[i][0],y = s[i][1]; s[i][0] = (x - y); s[i][1] = (x + y); }} boolean ok( int[][] s1, int[][] s2){ int xmin = INF,xmax = -INF,ymin = INF,ymax = -INF; for ( int i = 0;(i < 4);i++) {xmin = Math.min(xmin,s1[i][0]); xmax = Math.max(xmax,s1[i][0]); ymin = Math.min(ymin,s1[i][1]); ymax = Math.max(ymax,s1[i][1]); }for ( int i = 0;(i < 4);i++) {if ( ((((s2[i][0] >= xmin) && (s2[i][0] <= xmax)) && (s2[i][1] >= ymin)) && (s2[i][1] <= ymax))) return true; } int[] mid2 = new int[]{(s2[0][0] + s2[2][0]),(s2[0][1] + s2[2][1])}; return ((((mid2[0] >= (xmin * 2)) && (mid2[0] <= (xmax * 2))) && (mid2[1] >= (ymin * 2))) && (mid2[1] <= (ymax * 2)));} public static void main( String[] args){ in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); new TwoSquares().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());} } }
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(); } }
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);  BTheHat solver = new BTheHat(); solver.solve(1,in,out); out.close(); } static class BTheHat{ InputReader in ; OutputWriter out ; int n ; int ask( int student){ student %= n; out.println(("? " + (student + 1))); out.flush(); return in.nextInt();} public void solve( int testNumber, InputReader in, OutputWriter out){ this.in = in; this.out = out; n = in.nextInt(); int a = ask(0),b = ask((n / 2)); if ( (((a + b) % 2) != 0)) {out.println("! -1"); out.flush(); return ;} if ( (a == b)) {out.println("! 1"); out.flush(); return ;} int lo = 0,hi = (n / 2); while((lo < hi)){ int mid = ((lo + hi) / 2);  int f1 = ask(mid),f2 = ask((mid + (n / 2))); if ( (f1 == f2)) {out.println(("! " + (mid + 1))); return ;} if ( ((a > b) == (f1 > f2))) {lo = (mid + 1); } else {hi = (mid - 1); }}out.println(("! " + (lo + 1))); out.flush(); } } static 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 ( (this.numChars == -1)) {throw (new InputMismatchException());} else {if ( (this.curChar >= this.numChars)) {this.curChar = 0; try{this.numChars = this.stream.read(this.buf); }catch (IOException var2){ throw (new InputMismatchException());} if ( (this.numChars <= 0)) {return -1;} } return this.buf[this.curChar++];}} public 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 static boolean isSpaceChar( int c){ return (((((c == 32) || (c == 10)) || (c == 13)) || (c == 9)) || (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(); } } }
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();  Map<Integer,Integer> horizontalEdgeWeights = new HashMap<Integer,Integer>(); for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < (cols - 1));c++) { int hash = getHash(r,c); horizontalEdgeWeights.put(hash,FR.nextInt()); }} Map<Integer,Integer> verticalEdgeWeights = new HashMap<Integer,Integer>(); for ( int r = 0;(r < (rows - 1));r++) {for ( int c = 0;(c < cols);c++) { int hash = getHash(r,c); verticalEdgeWeights.put(hash,FR.nextInt()); }} List<List<Integer>> result = getResult(rows,cols,moves,horizontalEdgeWeights,verticalEdgeWeights); for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) { int value = ((result != null)?result.get(r).get(c):-1); solution.append((value + " ")); }solution.append("\n"); }PW.print(solution.toString()); PW.close(); } static List<List<Integer>> getResult( int rows, int cols, int moves, Map<Integer,Integer> horizontalEdgeWeights, Map<Integer,Integer> verticalEdgeWeights){ if ( ((moves & 1) == 1)) {return null;} int mid = (moves >> 1);  List<List<List<Integer>>> minForDistance = new ArrayList<List<List<Integer>>>(rows); for ( int r = 0;(r < rows);r++) {minForDistance.add(new ArrayList<List<Integer>>(cols)); for ( int c = 0;(c < cols);c++) {minForDistance.get(r).add(new ArrayList<Integer>(Collections.nCopies((mid + 1),Integer.MAX_VALUE))); minForDistance.get(r).get(c).set(0,0); }}for ( int m = 1;(m <= mid);m++) {for ( int r = 0;(r < rows);r++) {for ( int c = 0;(c < cols);c++) { int minBoredom = minForDistance.get(r).get(c).get(m);  int hash = getHash(r,c); if ( (r > 0)) {if ( (minForDistance.get((r - 1)).get(c).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get((r - 1)).get(c).get((m - 1)) + verticalEdgeWeights.get(getHash((r - 1),c))); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( (c > 0)) {if ( (minForDistance.get(r).get((c - 1)).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get(r).get((c - 1)).get((m - 1)) + horizontalEdgeWeights.get(getHash(r,(c - 1)))); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( ((r + 1) < rows)) {if ( (minForDistance.get((r + 1)).get(c).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get((r + 1)).get(c).get((m - 1)) + verticalEdgeWeights.get(hash)); minBoredom = Math.min(minBoredom,candidateBoredom); } } if ( ((c + 1) < cols)) {if ( (minForDistance.get(r).get((c + 1)).get((m - 1)) < Integer.MAX_VALUE)) { int candidateBoredom = (minForDistance.get(r).get((c + 1)).get((m - 1)) + horizontalEdgeWeights.get(hash)); minBoredom = Math.min(minBoredom,candidateBoredom); } } minForDistance.get(r).get(c).set(m,minBoredom); }}} List<List<Integer>> result = new ArrayList<List<Integer>>(rows); for ( int r = 0;(r < rows);r++) {result.add(new ArrayList<Integer>(cols)); for ( int c = 0;(c < cols);c++) {result.get(r).add((minForDistance.get(r).get(c).get(mid) << 1)); }}return result;} static int getHash( int row, int col){ return ((row * 1000) + col);} 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());} } }
4	public class D2{ InputStream is ; FastWriter out ; String INPUT = ""; void solve(){ int n = ni(),m = ni(),K = ni();  int[][] a = new int[((2 * n) + 1)][((2 * m) + 1)]; for ( int i = 0;(i < n);i++) { int[] u = na((m - 1)); for ( int j = 0;(j < (m - 1));j++) {a[(2 * i)][((2 * j) + 1)] = u[j]; }}for ( int i = 0;(i < (n - 1));i++) { int[] u = na(m); for ( int j = 0;(j < m);j++) {a[((2 * i) + 1)][(2 * j)] = u[j]; }}if ( ((K % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((-1 + " ")); }out.println(); }return ;} int[][][] dp = new int[((K / 2) + 1)][n][m];  int[] dr = {1,0,-1,0};  int[] dc = {0,1,0,-1}; for ( int i = 1;(i <= (K / 2));i++) {for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < m);k++) {dp[i][j][k] = Integer.MAX_VALUE; for ( int l = 0;(l < 4);l++) { int jj = (j + dr[l]),kk = (k + dc[l]); if ( ((((jj >= 0) && (jj < n)) && (kk >= 0)) && (kk < m))) {dp[i][j][k] = Math.min(dp[i][j][k],(dp[(i - 1)][jj][kk] + a[(j + jj)][(k + kk)])); } }}}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print(((dp[(K / 2)][i][j] * 2) + " ")); }out.println(); }} 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 D2().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{ static private 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;} static private 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;} static private 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)); } }
1	public class B{ int mod = 1000_000_007; public static void main( String[] args)throws Exception { PrintWriter out = new PrintWriter(System.out);  FastScanner fs = new FastScanner();  int t = fs.nextInt(); while((t-- > 0)){ double n = fs.nextInt(); if ( (isp((n / 2)) || isp((n / 4)))) {System.out.println("YES"); } else System.out.println("NO"); }} static boolean isp( double n){ if ( (n == 0)) return false; double a = Math.ceil(Math.sqrt(n));  double b = Math.floor(Math.sqrt(n)); return (a == b);} 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());} } }
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);  TaskE2 solver = new TaskE2();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class TaskE2{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  TaskE2.Column[] columns = new TaskE2.Column[m]; for ( int i = 0;(i < m);++i) columns[i] = new TaskE2.Column(new int[n]); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {columns[j].vals[i] = in.nextInt(); }}for ( int i = 0;(i < m);++i) columns[i].initMax(); Arrays.sort(columns,new Comparator<TaskE2.Column>(){}); if ( (columns.length > n)) {columns = Arrays.copyOf(columns,n); } out.println(solveOne(columns)); } private int solveOne( TaskE2.Column[] columns){ int n = columns[0].vals.length;  int[] best = new int[(1 << n)];  int[] next = new int[(1 << n)];  int[] tmp = new int[(1 << n)]; for ( TaskE2.Column c :columns) {System.arraycopy(best,0,next,0,best.length); for ( int rot = 0;(rot < n);++rot) {System.arraycopy(best,0,tmp,0,best.length); for ( int i = 0,pos = rot;(i < n);++i,++pos) {if ( (pos >= n)) pos = 0;  int val = c.vals[pos]; for ( int j = 0;(j < tmp.length);++j) if ( ((j & (1 << i)) == 0)) {tmp[(j ^ (1 << i))] = Math.max(tmp[(j ^ (1 << i))],(tmp[j] + val)); } }for ( int j = 0;(j < tmp.length);++j) {next[j] = Math.max(next[j],tmp[j]); }} int[] aa = best; best = next; next = aa; }return best[(best.length - 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 A{ public static void main( String[] args){ InputScanner scanner = new InputScanner(); try{ long l = scanner.nextLong();  long r = scanner.nextLong(); if ( ((r - l) < 2)) {System.out.println("-1"); return ;} if ( ((l % 2) == 0)) { long a = l;  long b = (l + 1);  long c = (l + 2); System.out.println(((((a + " ") + b) + " ") + c)); } else if ( ((r % 2) == 0)) { long a = r;  long b = (r - 1);  long c = (r - 2); System.out.println(((((c + " ") + b) + " ") + a)); } else {l++; if ( ((r - l) < 2)) {System.out.println("-1"); return ;} long a = l;  long b = (l + 1);  long c = (l + 2); System.out.println(((((a + " ") + b) + " ") + c)); } }catch (IOException e){ } } static class InputScanner{ BufferedReader br ; StringTokenizer st ; public InputScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) { String line = br.readLine(); st = new StringTokenizer(line); } return st.nextToken();} public long nextLong()throws IOException { String next = next(); next.length(); return Long.parseLong(next);} } }
4	public class P{ static int N ,M ,K ; static int dx[] = {0,0,1,-1,1,1,-1,-1}; static int dy[] = {1,-1,0,0,1,-1,1,-1}; static Pair[] b ; static boolean isValid( int x, int y){ return ((((x >= 0) && (y >= 0)) && (x < N)) && (y < M));} static class Pair{ int x ,y ; Pair( int i, int j){ x = i; y = j; } } static Pair bfs(){ Queue<Pair> q = new LinkedList<Pair>();  int[][] dist = new int[N][M]; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) dist[i][j] = -1; for ( int i = 0;(i < K);i++) {dist[b[i].x][b[i].y] = 0; q.add(b[i]); }while(!q.isEmpty()){ Pair cur = q.remove(); for ( int d = 0;(d < 4);d++) { int X = (cur.x + dx[d]);  int Y = (cur.y + dy[d]); if ( (isValid(X,Y) && (dist[X][Y] == -1))) {dist[X][Y] = (dist[cur.x][cur.y] + 1); Pair P = new Pair(X,Y); q.add(P); } }} int max = -1;  Pair MX = null; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) {if ( (dist[i][j] > max)) {max = dist[i][j]; MX = new Pair((i + 1),(j + 1)); } }return MX;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner("input.txt");  PrintWriter out = new PrintWriter("output.txt"); N = sc.nextInt(); M = sc.nextInt(); K = sc.nextInt(); b = new Pair[K]; for ( int i = 0;(i < K);i++) b[i] = new Pair((sc.nextInt() - 1),(sc.nextInt() - 1)); Pair last = bfs(); out.println(((last.x)+" " + last.y)); out.flush(); out.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( String f)throws FileNotFoundException{ br = new BufferedReader(new FileReader(f)); } 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 long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} public int[] nextIntArray( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} public long[] nextLongArray( int n)throws IOException { long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nextLong(); return a;} } }
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 C{ public static void main( String[] args){ try(Scanner sc=new Scanner(System.in)){final int N = sc.nextInt();  String[] ins = new String[N]; for ( int i = 0;(i < N);i++) {ins[i] = sc.next(); }final long MOD = 1000000007;  long[] DP = new long[N];  long[] nextDP = new long[N]; DP[0] = 1; for ( int i = 1;(i < N);i++) {Arrays.fill(nextDP,0); if ( "f".equals(ins[(i - 1)])) {for ( int j = 0;(j < (N - 1));j++) {nextDP[(j + 1)] += DP[j]; nextDP[(j + 1)] %= MOD; }} else {for ( int j = (N - 1);(j >= 0);j--) {nextDP[j] += DP[j]; nextDP[j] %= MOD; if ( (j < (N - 1))) {nextDP[j] += nextDP[(j + 1)]; nextDP[j] %= MOD; } }}{ long[] tmp = DP; DP = nextDP; nextDP = tmp; }} long answer = 0; for ( int i = 0;(i < N);i++) {answer += DP[i]; answer %= MOD; }System.out.println(answer); }} public static class Scanner implements Closeable{ private BufferedReader br ; private StringTokenizer tok ; public Scanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } private void getLine(){ try{while(!hasNext()){tok = new StringTokenizer(br.readLine()); } }catch (IOException e){ } } private boolean hasNext(){ return ((tok != null) && tok.hasMoreTokens());} public String next(){ getLine(); return tok.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public void close(){ try{br.close(); }catch (IOException e){ } } } }
3	public class Main{ public static void main( String[] args)throws IOException { Reader.init(System.in); int n = Reader.nextInt();  int[] arr = new int[n];  int initial = 0; for ( int i = 0;(i < n);i++) arr[i] = Reader.nextInt(); for ( int i = 0;(i < arr.length);i++) {for ( int j = (i + 1);(j < arr.length);j++) if ( (arr[i] > arr[j])) initial++; } int m = Reader.nextInt();  boolean parity = ((initial % 2) == 0); for ( int i = 0;(i < m);i++) { int l = Reader.nextInt();  int r = Reader.nextInt();  int elems = ((r - l) + 1);  boolean change = (((elems / 2) % 2) == 0); parity = (parity == change); System.out.println((parity?"even":"odd")); }} }
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)); } }
2	public class Codeforces{ public StreamTokenizer st ; public PrintWriter pw ; public static final int modulo = 1000000009; void init( String in, String out){ if ( in.isEmpty()) st = new StreamTokenizer(System.in); else {try{st = new StreamTokenizer(new BufferedReader(new FileReader(in))); }catch (FileNotFoundException e){ } }if ( out.isEmpty()) pw = new PrintWriter(System.out); else {try{pw = new PrintWriter(new FileWriter(out)); }catch (IOException e){ } }} private void close(){ pw.close(); } private long nL(){ try{st.nextToken(); }catch (IOException e){ } return (long)st.nval;} public static void qSort( int[] A, int low, int high){ int i = low;  int j = high;  int x = A[((low + high) / 2)]; do {while((A[i] < x))++i; while((A[j] > x))--j; if ( (i <= j)) { int temp = A[i]; A[i] = A[j]; A[j] = temp; i++; j--; } }while((i < j));if ( (low < j)) qSort(A,low,j); if ( (i < high)) qSort(A,i,high); } public static void main( String[] aslkdjlkgja)throws IOException { Codeforces z = new Codeforces(); z.init("",""); long l = z.nL();  long r = z.nL(); if ( (l == r)) {System.out.println(0); z.close(); return ;} List<Boolean> R = new ArrayList<Boolean>();  List<Boolean> L = new ArrayList<Boolean>();  long temp = r; while((temp != 0)){if ( ((temp % 2) == 1)) R.add(true); else R.add(false); temp /= 2; }Collections.reverse(R); temp = l; while((temp != 0)){if ( ((temp % 2) == 1)) L.add(true); else L.add(false); temp /= 2; } int n = (R.size() - L.size()); while((n != 0)){L.add(false); --n; }Collections.reverse(L); List<Boolean> res = new ArrayList<Boolean>();  int it = 0; while((R.get(0) == L.get(0))){res.add(false); R.remove(0); L.remove(0); }for ( int i = 0;(i < R.size());++i) res.add(true); long out = 0; it = 0; long add = 1; Collections.reverse(res); while((it < res.size())){if ( res.get(it)) out += add; add *= 2; ++it; }System.out.println(out); } }
4	public class Main{ int n ,m ; int d[][] ; Queue<int[]> q = new LinkedList<int[]>(); int cur[] ; public void run()throws Exception { Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt")); n = in.nextInt(); m = in.nextInt(); int k = in.nextInt(); d = new int[n][m]; for ( int i = 0;(i < n);i++) Arrays.fill(d[i],(Integer.MAX_VALUE / 2)); for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); d[x][y] = 0; q.add(new int[]{x,y}); }while((q.size() > 0)){cur = q.poll(); int x = cur[0];  int y = cur[1]; add(x,(y + 1)); add((x + 1),y); add((x - 1),y); add(x,(y - 1)); } int max = 0;  int x = 0;  int y = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (max < d[i][j])) {max = d[i][j]; x = i; y = j; } out.println((((x + 1) + " ") + (y + 1))); out.close(); } private void add( int x, int y){ if ( ((x < 0) || (y < 0))) return ; if ( ((x >= n) || (y >= m))) return ; if ( (d[x][y] > (d[cur[0]][cur[1]] + 1))) {d[x][y] = (d[cur[0]][cur[1]] + 1); q.add(new int[]{x,y}); } } public static void main( String[] args)throws Exception { new Main().run(); } }
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));} static private 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{ } static private 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));} } }
6	public class Main{ BufferedReader in = null; PrintWriter out = null; int dist( int x1, int y1, int x2, int y2){ int dx = Math.abs((x1 - x2));  int dy = Math.abs((y1 - y2)); return ((dx * dx) + (dy * dy));} boolean testBit( int use, int p){ return (((use >> p) & 1) == 1);} int rec( int use, int[][] a, int[] dp, int[] next){ if ( (dp[use] != -1)) {return dp[use];} if ( (use == 0)) {return dp[use] = 0;} int n = a.length;  int ix = -1; for ( int i = 0;(i < n);++i) {if ( testBit(use,i)) {if ( (ix == -1)) {ix = i; break;} } } int r = (rec((use ^ (1 << ix)),a,dp,next) + a[ix][ix]); next[use] = (use ^ (1 << ix)); for ( int i = (ix + 1);(i < n);++i) {if ( !testBit(use,i)) {continue;} int t = rec(((use ^ (1 << ix)) ^ (1 << i)),a,dp,next); t += a[ix][i]; if ( (t < r)) {r = t; next[use] = ((use ^ (1 << ix)) ^ (1 << i)); } }return dp[use] = r;} void print( int use1, int use2, int n){ for ( int i = 0;(i < n);++i) {if ( (testBit(use1,i) ^ testBit(use2,i))) { int x = (i + 1); out.print((x + " ")); } }} void solve()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); StringTokenizer st ; st = new StringTokenizer(in.readLine()); int sx = Integer.valueOf(st.nextToken());  int sy = Integer.valueOf(st.nextToken()); st = new StringTokenizer(in.readLine()); int n = Integer.valueOf(st.nextToken());  int x[] = new int[n];  int y[] = new int[n]; for ( int i = 0;(i < n);++i) {st = new StringTokenizer(in.readLine()); x[i] = Integer.valueOf(st.nextToken()); y[i] = Integer.valueOf(st.nextToken()); } int a[][] = new int[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {a[i][j] = ((dist(x[i],y[i],sx,sy) + dist(x[j],y[j],sx,sy)) + dist(x[i],y[i],x[j],y[j])); }} int dp[] = new int[(1 << n)]; Arrays.fill(dp,-1); int next[] = new int[(1 << n)];  int ans = rec(((1 << n) - 1),a,dp,next); out.println(ans); int use = ((1 << n) - 1); while(true){ int nuse = next[use]; out.print("0 "); print(use,nuse,n); if ( (nuse == 0)) break; use = nuse; }out.println("0"); in.close(); out.close(); } public static void main( String[] args)throws IOException { new Main().solve(); } }
6	public class TaskE{ static int[][] transpose( int[][] a, int n, int m){ int[][] t = new int[m][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {t[j][i] = a[i][j]; }}return t;} public static void main( String[] args){ FastReader in = new FastReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int t = in.nextInt(); while((t-- > 0)){ int n = in.nextInt();  int m = in.nextInt();  int[][] a = new int[(n + 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[i][j] = in.nextInt(); a[n][j] = Math.max(a[n][j],a[i][j]); }}a = transpose(a,n,m); Arrays.sort(a,new Comparator<int[]>(){}); a = transpose(a,m,n); int[] dp = new int[(1 << n)]; for ( int i = 0;(i < Math.min(n,m));i++) { int[] best = new int[(1 << n)]; for ( int j = 1;(j < (1 << n));j++) {for ( int k = 0;(k < n);k++) { int sum = 0; for ( int l = 0;(l < n);l++) {if ( ((j & (1 << l)) != 0)) sum += a[((l + k) % n)][i]; }best[j] = Math.max(best[j],sum); }} int[] dp1 = dp.clone(); for ( int j = 0;(j < (1 << n));j++) {for ( int k = j;(k > 0);k = ((k - 1) & j)) {dp[j] = Math.max(dp[j],(dp1[(k ^ j)] + best[k])); }}}out.println(dp[((1 << n) - 1)]); }out.close(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; FastReader( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } Integer nextInt(){ return Integer.parseInt(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;} } }
0	public class Main{ StreamTokenizer in ; int n ,k ; public void run(){ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); read(); print(solve()); } void read(){ n = nextInt(); } int solve(){ int result = n; if ( (result < 0)) { int res1 = (n / 10);  int mod = (n % 10);  int res2 = (((res1 / 10) * 10) + mod); if ( (res1 > res2)) result = res1; else result = res2; } return result;} void print( int result){ System.out.println(result); } public static void main( String[] Args){ new Main().run(); } public int nextInt(){ try{in.nextToken(); }catch (Exception e){ } return (int)in.nval;} }
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)); } static private 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;} }
5	public class C implements Runnable{ private void Solution()throws IOException { int n = nextInt(),max = 0,maxi = 0;  ArrayList<Integer> mas = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) { int num = nextInt(); if ( (num > max)) {max = num; maxi = i; } mas.add(num); }mas.remove(maxi); mas.add(((max == 1)?2:1)); Collections.shuffle(mas); Collections.sort(mas); for ( int i = 0;(i < n);i++) System.out.print((mas.get(i) + " ")); } public static void main( String[] args){ new C().run(); } BufferedReader in ; StringTokenizer tokenizer ; public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; Solution(); in.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(in.readLine()); return tokenizer.nextToken();} }
0	public class j{ public static void main( String[] aa)throws IOException { BufferedReader b = new BufferedReader(new InputStreamReader(System.in));  int i = 0,m = 0,p = 0,n = 0,k = 0,j = 0;  String s ,r ; s = b.readLine(); r = s; n = Integer.parseInt(s); s = s.substring(0,(s.length() - 2)); s += r.charAt((r.length() - 1)); r = r.substring(0,(r.length() - 1)); m = Integer.parseInt(s); p = Integer.parseInt(r); System.out.print((long)Math.max(Math.max(m,n),p)); } }
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 + " ")); }} }
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 C{ static private boolean marked[][] ; public static void main( String[] args)throws Exception { File file = new File("input.txt");  Scanner s = new Scanner(file);  int n = s.nextInt();  int m = s.nextInt(); marked = new boolean[(n + 1)][(m + 1)]; int k = s.nextInt();  Queue<Point> queue = new LinkedList<Point>(); for ( int i = 0;(i < k);++i) { int tempX = s.nextInt();  int tempY = s.nextInt(); marked[tempX][tempY] = true; queue.add(new Point(tempX,tempY)); } Point c = null; while(!queue.isEmpty()){c = queue.poll(); if ( ((c.x > 1) && !marked[(c.x - 1)][c.y])) {marked[(c.x - 1)][c.y] = true; queue.add(new Point((c.x - 1),c.y)); } if ( ((c.y > 1) && !marked[c.x][(c.y - 1)])) {marked[c.x][(c.y - 1)] = true; queue.add(new Point(c.x,(c.y - 1))); } if ( ((c.x < n) && !marked[(c.x + 1)][c.y])) {marked[(c.x + 1)][c.y] = true; queue.add(new Point((c.x + 1),c.y)); } if ( ((c.y < m) && !marked[c.x][(c.y + 1)])) {marked[c.x][(c.y + 1)] = true; queue.add(new Point(c.x,(c.y + 1))); } } PrintWriter out = new PrintWriter(new File("output.txt")); out.println(((c.x + " ") + c.y)); out.close(); } static class Point{ int x ; int y ; public Point( int x, int y){ this.x = x; this.y = y; } } }
2	public class LittleGirlAndMaximumXOR{ private InputStream input ; private PrintStream output ; private Scanner inputSc ; static final boolean ONE = true; static final boolean ZERO = false; char dp[][][] ; public LittleGirlAndMaximumXOR( InputStream input, PrintStream output){ this.input = input; this.output = output; init(); } private void init(){ inputSc = new Scanner(input); } public void solve(){ solveTestCase(1); } void fill( char[] a, long value){ String str = Long.toBinaryString(value);  char array[] = str.toCharArray();  int len = array.length;  int index = 63; while((len > 0)){a[index] = array[(len - 1)]; len--; index--; }} void init( char[] a){ for ( int i = 0;(i < 64);i++) {a[i] = '0'; }} private void solveTestCase( int testN){ long l = inputSc.nextLong();  long r = inputSc.nextLong();  char lBit[] = new char[64];  char rBit[] = new char[64]; init(lBit); init(rBit); fill(lBit,l); fill(rBit,r); int i = 0;  char ansBit[] = new char[64];  char a[] = new char[64];  char b[] = new char[64]; init(a); init(b); init(ansBit); for ( ;(i < 64);i++) {if ( ((lBit[i] == '0') && (rBit[i] == '0'))) {} else if ( ((lBit[i] == '1') && (rBit[i] == '0'))) {throw (new RuntimeException("Wrong Input"));} else if ( ((lBit[i] == '0') && (rBit[i] == '1'))) {a[i] = '0'; b[i] = '1'; break;} else {a[i] = '1'; b[i] = '1'; }} boolean aLessB = true;  boolean aBig = false;  boolean bSmall = false; for ( ;(i < 64);i++) {if ( ((lBit[i] == '0') && (rBit[i] == '0'))) {a[i] = '1'; b[i] = '0'; aBig = true; } else if ( ((lBit[i] == '1') && (rBit[i] == '0'))) {a[i] = '1'; b[i] = '0'; } else if ( ((lBit[i] == '0') && (rBit[i] == '1'))) {a[i] = '0'; b[i] = '1'; } else {a[i] = '1'; b[i] = '0'; bSmall = true; }}for ( i = 0;(i < 64);i++) {if ( ((a[i] == '0') && (b[i] == '0'))) {ansBit[i] = '0'; } else if ( ((a[i] == '1') && (b[i] == '0'))) {ansBit[i] = '1'; } else if ( ((a[i] == '0') && (b[i] == '1'))) {ansBit[i] = '1'; } else {ansBit[i] = '0'; }} String ansStr = new String(ansBit);  long ansValue = Long.parseLong(ansStr,2); output.println(ansValue); } public static void main( String[] args){ LittleGirlAndMaximumXOR lgamx = new LittleGirlAndMaximumXOR(System.in,System.out); lgamx.solve(); } }
3	public class A{ InputStream is ; PrintWriter out ; String INPUT = ""; public void solve(){ int n = ni();  int ans = 0;  int[] arr = na(n); for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (arr[i] > arr[j])) {ans ^= 1; } }} int m = ni(); while((m-- > 0)){ int a = ni(),b = ni();  int diff = (Math.abs((a - b)) + 1); ans = (ans ^ ((((diff - 1) * diff) / 2) % 2)); out.println(((ans == 0)?"even":"odd")); }} void print( int n, long[][] memo){ for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {out.print((memo[i][j] + " ")); }out.println(); }} void run(){ is = new DataInputStream(System.in); out = new PrintWriter(System.out); int t = 1; while((t-- > 0))solve(); out.flush(); } 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 = 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(); }} static int i( long x){ return (int)Math.round(x);} }
6	public class E{ public static double[] dp ; public static double[][] data ; public static int n ; public static void main( String[] args){ Scanner in = new Scanner();  PrintWriter out = new PrintWriter(System.out); n = in.nextInt(); data = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {data[i][j] = in.nextDouble(); }}dp = new double[(1 << n)]; Arrays.fill(dp,-1); for ( int i = 0;(i < n);i++) { int a = (1 << i); out.print((cal(a) + " ")); }out.close(); } public static double cal( 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 += (data[i][j] * cal((mask | b))); } }} } int nC2 = (((c + 1) * c) / 2); dp[mask] = (result / nC2); return dp[mask];} 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());} public double nextDouble(){ return Double.parseDouble(next());} } }
5	public class A{ void run()throws IOException { int n = ni();  int m = ni();  int k = ni();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = (ni() - 1); Arrays.sort(a); int ans = 0; if ( (m > k)) {m -= (k - 1); for ( int i = (n - 1);(i >= 0);i--) {ans++; m -= a[i]; if ( (m < 2)) break; }if ( (m > 1)) ans = -1; } pw.print(ans); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int ni()throws IOException { return Integer.parseInt(next());} PrintWriter pw ; BufferedReader br ; StringTokenizer st ; public static void main( String[] args)throws IOException { long timeout = System.currentTimeMillis();  boolean CF = (System.getProperty("ONLINE_JUDGE") != null);  PrintWriter _pw = new PrintWriter(System.out);  BufferedReader _br = new BufferedReader((CF?new InputStreamReader(System.in):new FileReader(new File("in.txt")))); new A(_br,_pw).run(); if ( !CF) {_pw.println(); _pw.println((System.currentTimeMillis() - timeout)); } _br.close(); _pw.close(); } public A( BufferedReader _br, PrintWriter _pw){ br = _br; pw = _pw; } }
3	public class Main{ static private void solve(){ int n = ni();  String[] lines = new String[n]; for ( int i = 0;(i < n);i++) {lines[i] = next(); } int mod = (1000000000 + 7);  long[][] dp = new long[2][(n + 1)]; dp[0][0] = 1; for ( int i = 0;(i < n);i++) { int from = (i % 2);  int to = ((i + 1) % 2);  boolean flg = ((i == 0) || lines[(i - 1)].equals("s")); if ( flg) { long v = Arrays.stream(dp[from]).sum(); for ( int j = 0;(j <= n);j++) {dp[to][j] += v; dp[to][j] %= mod; v -= dp[from][j]; }} else {for ( int j = 0;(j < n);j++) {dp[to][(j + 1)] += dp[from][j]; dp[to][(j + 1)] %= mod; }}Arrays.fill(dp[from],0); } long ret = (Arrays.stream(dp[(n % 2)]).sum() % mod); System.out.println(ret); } public static void main( String[] args){ new Thread(null,new Runnable(){},"",64000000).start(); } static private java.io.InputStream is = System.in; static private java.io.PrintWriter out = new java.io.PrintWriter(System.out); static private java.util.StringTokenizer tokenizer = null; static private java.io.BufferedReader reader ; public static String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new java.util.StringTokenizer(reader.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} static private long nl(){ return Long.parseLong(next());} static private int ni(){ return Integer.parseInt(next());} static private void tr( Object... o){ if ( (is != System.in)) System.out.println(java.util.Arrays.deepToString(o)); } }
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();} }
5	public class div168C{ public static void main( String[] args)throws Exception { div168C a = new div168C();  Parserdoubt pd = new Parserdoubt(System.in);  StringBuffer sb = new StringBuffer();  ArrayList<Integer> arr = new ArrayList<Integer>();  int max = 0;  int n = pd.nextInt();  int k = pd.nextInt(); for ( int i = 0;(i < n);i++) {arr.add(pd.nextInt()); max = Math.max(max,arr.get(i)); }Collections.sort(arr); int count = 0;  int[] mat = new int[(n + 1)]; for ( int i = (n - 1);(i >= 0);i--) {if ( (mat[i] != 1)) { int x = arr.get(i); if ( ((x % k) == 0)) { int ans = Collections.binarySearch(arr,(x / k)); if ( ((ans >= 0) && (arr.get(ans) == (x / k)))) {count++; mat[ans] = 1; } else {count++; }} else {count++; }} }if ( (n == 1)) count = 1; System.out.println(count); } }
1	public class Answer17A{ public static void main( String[] args){ try{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  String[] tmp = reader.readLine().split(" ");  int n = Integer.parseInt(tmp[0]);  int k = Integer.parseInt(tmp[1]);  boolean[] m = getPrime(n);  ArrayList<Integer> prime = new ArrayList<Integer>(); for ( int i = 0;(i < m.length);i++) {if ( m[i]) prime.add(i); } int sum = 0; for ( int i = 2;(i <= n);i++) {if ( m[i]) {for ( int j = 0;(j < (prime.size() - 1));j++) {if ( (i == ((prime.get(j) + prime.get((j + 1))) + 1))) {sum++; break;} }} }if ( (sum >= k)) {System.out.println("YES"); } else {System.out.println("NO"); } }catch (IOException e){ e.printStackTrace(); } } public static boolean[] getPrime( int N){ boolean[] memo = new boolean[(N + 1)]; Arrays.fill(memo,true); memo[0] = false; memo[1] = false; for ( int i = 2;((i * i) <= N);i++) {if ( memo[i]) {for ( int j = (i * i);(j <= N);j += i) {memo[j] = false; }} }return memo;} }
6	public class CF8C{ static int n ; static int[] mem ; static HashMap<Integer,String> map ; static int INF = (int)1e9; static StringBuilder sb ; public static void main( String[] args)throws IOException { MyScanner sc = new MyScanner(System.in);  String s = sc.nextLine(); n = sc.nextInt(); mem = new int[(1 << n)]; Arrays.fill(mem,-1); map = new HashMap<>(); map.put(0,s); for ( int i = 1;(i <= n);i++) {map.put(i,sc.nextLine()); } int val = dp(0);  PrintWriter pw = new PrintWriter(System.out); pw.println(val); sb = new StringBuilder(); sb.append("0 "); build(0); pw.println(sb); pw.flush(); } static private int dp( int msk){ if ( (msk == ((1 << n) - 1))) return 0; if ( (mem[msk] != -1)) return mem[msk]; boolean foundFirst = false;  int val = (int)1e9;  int mark = -1; for ( int i = 1;(i <= n);i++) {if ( ((msk & (1 << (i - 1))) == 0)) {if ( !foundFirst) {foundFirst = true; mark = i; val = ((dist(0,mark) * 2) + dp((msk | (1 << (mark - 1))))); } else {val = Math.min(val,(((dist(0,mark) + dist(mark,i)) + dist(i,0)) + dp(((msk | (1 << (mark - 1))) | (1 << (i - 1)))))); }} }return mem[msk] = val;} static private int dist( int node, int i){ String from = map.get(i);  String to = map.get(node);  String[] fromco = from.split(" ");  String[] toco = to.split(" ");  int xs = Integer.parseInt(fromco[0]);  int ys = Integer.parseInt(fromco[1]);  int xf = Integer.parseInt(toco[0]);  int yf = Integer.parseInt(toco[1]); return (((xs - xf) * (xs - xf)) + ((ys - yf) * (ys - yf)));} static private void build( int msk){ if ( (msk == ((1 << n) - 1))) return ; boolean foundFirst = false;  int ans = dp(msk);  int mark = -1;  int val = (int)1e9; for ( int i = 1;(i <= n);i++) {if ( ((msk & (1 << (i - 1))) == 0)) {if ( !foundFirst) {foundFirst = true; mark = i; val = ((dist(0,mark) * 2) + dp((msk | (1 << (mark - 1))))); if ( (val == ans)) {sb.append((mark + " 0 ")); build((msk | (1 << (mark - 1)))); return ;} } else {val = (((dist(0,mark) + dist(mark,i)) + dist(i,0)) + dp(((msk | (1 << (mark - 1))) | (1 << (i - 1))))); if ( (val == ans)) {sb.append((((mark + " ") + i) + " 0 ")); build(((msk | (1 << (mark - 1))) | (1 << (i - 1)))); return ;} }} }} static class MyScanner{ StringTokenizer st ; BufferedReader br ; public MyScanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public MyScanner( 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());} public String nextLine()throws IOException { return br.readLine();} public boolean ready()throws IOException { return br.ready();} } }
1	public class q1{ int m = ((int)1e9 + 7); public int mul( int a, int b){ a = (a % m); b = (b % m); return ((a * b) % m);} public static long gcd( long a, long b){ if ( (b == 0)) return a; else return gcd(b,(a % b));} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  HashMap<Integer,Integer> h = new HashMap();  int[] a = new int[n];  int x = sc.nextInt(); for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); if ( (h.get(a[i]) == null)) {h.put(a[i],1); } else {System.out.print(0); System.exit(0); }}for ( int i = 0;(i < n);i++) { int num = (a[i] & x); if ( (num == a[i])) continue; if ( (h.get(num) == null)) continue; else {System.out.print(1); System.exit(0); }}for ( int i = 0;(i < n);i++) { int num = (a[i] & x); if ( (num == a[i])) continue; if ( (h.get(num) == null)) h.put(num,1); else {System.out.print(2); System.exit(0); }}System.out.print(-1); } }
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); } }
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 B{ public static PrintWriter out ; public static BufferedReader bf ; public static int n ; public static int[] a ; public static void main( String[] args)throws Exception { bf = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); n = Integer.parseInt(bf.readLine()); a = new int[n]; Arrays.fill(a,Integer.MAX_VALUE); if ( (((n / 2) % 2) != 0)) {out.println(("! " + 1)); out.flush(); out.close(); System.exit(0); } ask(0); ask(opp(0)); int low = 0;  int high = opp(0); while(true){ int test = ((low + high) / 2); ask(test); ask(opp(test)); int l_1 = a[low];  int l_2 = a[test];  int r_1 = a[opp(low)];  int r_2 = a[opp(test)]; if ( (((1L * (l_1 - r_1)) * (l_2 - r_2)) < 0L)) {high = test; } else low = test; }} public static int ask( int i)throws Exception { out.println(("? " + (i + 1))); out.flush(); int k = Integer.parseInt(bf.readLine()); a[i] = k; if ( (a[i] == a[opp(i)])) {out.println(("! " + (i + 1))); out.flush(); out.close(); System.exit(0); } return k;} public static int opp( int k){ return ((k + (n / 2)) % n);} }
4	public class Solve{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int size = ((int)1e7 + 1);  int[] pr = new int[size]; for ( int i = 0;(i < size);i++) {pr[i] = i; }for ( int i = 2;((i * i) < size);i++) { int val = (i * i); for ( int j = val;(j <= size);j += val) {pr[j] = (j / val); }} int t = sc.nextInt();  int[] dp = new int[size]; Arrays.fill(dp,-1); while((t-- > 0)){ int n = sc.nextInt();  int k = sc.nextInt();  int[] ar = new int[n]; for ( int i = 0;(i < n);i++) { int a = sc.nextInt(); ar[i] = pr[a]; } int[] ans = new int[(k + 1)];  int[] ind = new int[(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int h = k;(h >= 0);h--) {if ( (dp[ar[i]] >= ind[h])) {ans[h]++; ind[h] = i; } if ( ((h > 0) && ((ans[(h - 1)] < ans[h]) || ((ans[(h - 1)] == ans[h]) && (ind[(h - 1)] > ind[h]))))) {ans[h] = ans[(h - 1)]; ind[h] = ind[(h - 1)]; } }dp[ar[i]] = i; }out.println((ans[k] + 1)); for ( int i = 0;(i < n);i++) dp[ar[i]] = -1; }out.close(); } }
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)))); }} }
1	public class Main{ StreamTokenizer in ; PrintWriter out ; public static void main( String[] args)throws IOException { new Main().run(); } public void run()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } public int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} boolean pr( int i){ if ( (i < 4)) return true; for ( int j = 2;(j < (Math.sqrt(i) + 1));j++) if ( ((i % j) == 0)) return false; return true;} public void solve()throws IOException { int n = nextInt(),k = nextInt();  int prost[] = new int[1000];  boolean now[] = new boolean[10000];  int a = 0; for ( int i = 2;(i != 1000);i++) if ( pr(i)) prost[a++] = i; for ( int i = 0;(i != (a - 1));i++) {if ( pr(((prost[i] + prost[(i + 1)]) + 1))) now[((prost[i] + prost[(i + 1)]) + 1)] = true; } int answ = 0; for ( int i = 0;(i != (n + 1));i++) if ( now[i]) answ++; if ( (answ >= k)) out.print("YES"); else out.print("NO"); } }
6	public class G_PlaylistForPolycarp{ static final int mod = 1000000007; static int dp[][] ; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));  String[] dat = br.readLine().split(" ");  int n = Integer.parseInt(dat[0]);  int T = Integer.parseInt(dat[1]);  int[] st = new int[n];  byte[] sg = new byte[n]; dp = new int[(1 << (n + 1))][4]; for ( int j = 0;(j < (1 << (n + 1)));j++) {for ( int k = 0;(k < 4);k++) {dp[j][k] = -1; }}for ( int i = 0;(i < n);i++) {dat = br.readLine().split(" "); st[i] = Integer.parseInt(dat[0]); sg[i] = Byte.parseByte(dat[1]); } short visited = 0;  int count = recur(0,visited,st,sg,T,0); bw.write((count + "\n")); bw.close(); } static private int recur( int time, short visited, int[] st, byte[] sg, int T, int last){ int count = 0; if ( (dp[visited][last] != -1)) {return dp[visited][last];} for ( int i = 0;(i < st.length);i++) {if ( (((visited & (1 << i)) == 0) && (sg[i] != last))) {if ( ((time + st[i]) == T)) {count += 1; } else if ( ((time + st[i]) < T)) { short visitedc = (short)(visited | (1 << i)); count += recur((time + st[i]),visitedc,st,sg,T,sg[i]); if ( (count > mod)) {count = (count % mod); } } } }return dp[visited][last] = (count % mod);} }
0	public class BB{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a = sc.nextLong();  long b = sc.nextLong(); if ( ((b - a) > (long)2)) {if ( ((a % (long)2) == 0)) {System.out.print(((((a + " ") + (a + 1)) + " ") + (a + 2))); return ;} else {System.out.print((((((a + 1) + " ") + (a + 2)) + " ") + (a + 3))); return ;}} else {if ( ((b - a) <= (long)1)) {System.out.println(-1); return ;} if ( ((b - a) == (long)2)) {if ( ((a % (long)2) == 0)) {System.out.print(((((a + " ") + (a + 1)) + " ") + (a + 2))); return ;} else {System.out.print(-1); return ;}} }} }
4	public class Div1_429C{ static final long MOD = 1_000_000_007; static long[] fact = new long[305]; static long[] iFact = new long[305]; static final long I304 = 904487323; public static void main( String[] args)throws IOException { fact[0] = 1; for ( int i = 1;(i < 305);i++) {fact[i] = ((fact[(i - 1)] * i) % MOD); }iFact[304] = I304; for ( int i = 303;(i >= 0);i--) {iFact[i] = ((iFact[(i + 1)] * (i + 1)) % MOD); } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int len = Integer.parseInt(reader.readLine());  long[] groups = new long[(len + 1)];  int[] gSizes = new int[(len + 1)];  int nG = 0;  StringTokenizer inputData = new StringTokenizer(reader.readLine()); for ( int i = 0;(i < len);i++) { long nxt = Integer.parseInt(inputData.nextToken()); for ( int j = 1;(j <= nG);j++) {if ( isSquare((nxt * groups[j]))) {gSizes[j]++; continue iLoop;} }groups[++nG] = nxt; gSizes[nG] = 1; } long[][] dp = new long[(nG + 1)][len]; dp[0][0] = 1; int fTotal = 0; for ( int fG = 0;(fG < nG);fG++) {for ( int fB = 0;(fB < len);fB++) {if ( (dp[fG][fB] == 0)) {continue;} int nGSize = gSizes[(fG + 1)]; for ( int nS = 1;(nS <= Math.min(nGSize,(fTotal + 1)));nS++) {for ( int nBR = 0;(nBR <= Math.min(fB,nS));nBR++) { long nW = ((((((((dp[fG][fB] * fact[nGSize]) % MOD) * comb((nGSize - 1),(nS - 1))) % MOD) * comb(fB,nBR)) % MOD) * comb(((fTotal + 1) - fB),(nS - nBR))) % MOD); dp[(fG + 1)][(((fB - nBR) + nGSize) - nS)] = ((dp[(fG + 1)][(((fB - nBR) + nGSize) - nS)] + nW) % MOD); }}}fTotal += gSizes[(fG + 1)]; }printer.println(dp[nG][0]); printer.close(); } static long comb( int a, int b){ if ( (b > a)) {return 0;} return ((((fact[a] * iFact[(a - b)]) % MOD) * iFact[b]) % MOD);} static boolean isSquare( long inp){ long sqrt = (long)Math.sqrt(inp); return (inp == (sqrt * sqrt));} }
5	public class A15{ final double eps = 10e-9; class Pair implements Comparable<Pair>{ int x ; int length ; Pair( int x, int length){ this.x = x; this.length = length; } } private void Solution()throws IOException { int n = nextInt(),t = nextInt(),ans = 2;  Pair[] pairs = new Pair[n]; for ( int i = 0;(i < n);i++) { int x = nextInt(),length = nextInt(); pairs[i] = new Pair(x,length); }Arrays.sort(pairs); for ( int i = 0;(i < (n - 1));i++) { double place = (((pairs[(i + 1)].x - pairs[i].x) - ((double)pairs[(i + 1)].length / 2)) - ((double)pairs[i].length / 2)); if ( (place > t)) ans += 2; else if ( ((int)(place + eps) == t)) ans++; }System.out.println(ans); } public static void main( String[] args){ new A15().run(); } BufferedReader in ; StringTokenizer tokenizer ; public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; Solution(); in.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(in.readLine()); return tokenizer.nextToken();} }
0	public class Ideone{ static long ans = 0; public static void Stepgcd( long a, long b){ if ( (b != 0)) {ans += (a / b); Stepgcd(b,(a % b)); } } public static void main( String[] args)throws java.lang.Exception { Scanner in = new Scanner(System.in);  long a = in.nextLong(),b = in.nextLong(); Stepgcd(a,b); System.out.println(ans); } }
0	public class Solution{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; void solve()throws IOException { double a = nextDouble();  double v = nextDouble();  double l = nextDouble();  double d = nextDouble();  double w = nextDouble(); if ( (w > v)) {w = v; } double ans1 = 0.;  double v1 ; { double l_ = 0.,r_ = 1e+9; for ( int it = 0;(it < 100);++it) { double mid = ((l_ + r_) / 2.);  double V = (a * mid);  double t1 = (((V + w) / 2.) / a);  double t2 = (mid - t1); t1 = Math.min(t1,(v / a)); t2 = Math.min(t2,((v - w) / a)); if ( (V < w)) {t1 = mid; t2 = 0.; } double dist = (((((t1 * t1) * a) / 2.) + (t2 * (w + ((t2 * a) / 2.)))) + (v * ((mid - t1) - t2))); if ( (dist < d)) {l_ = mid; } else {r_ = mid; }}ans1 = ((l_ + r_) / 2.); v1 = Math.min((ans1 * a),w); } double ans2 = 0.; { double tSp = ((v - v1) / a);  double l_ = 0.,r_ = 1e+9; for ( int it = 0;(it < 100);++it) { double mid = ((l_ + r_) / 2.);  double dist = (Math.min(tSp,mid) * (v1 + ((Math.min(tSp,mid) * a) / 2.))); dist += ((mid - Math.min(tSp,mid)) * v); if ( (dist < (l - d))) {l_ = mid; } else {r_ = mid; }}ans2 = ((l_ + r_) / 2.); }out.println((ans1 + ans2)); } 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();} double nextDouble()throws IOException { return Double.parseDouble(next());} public static void main( String[] args)throws IOException { new Solution(); } }
6	public final class CF_599_D1_C{ static boolean verb = true; static void log( Object X){ if ( verb) System.err.println(X); } static void log( Object[] X){ if ( verb) {for ( Object U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X){ if ( verb) {for ( int U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X, int L){ if ( verb) {for ( int i = 0;(i < L);i++) System.err.print((X[i] + " ")); System.err.println(""); } } static void log( long[] X){ if ( verb) {for ( long U :X) System.err.print((U + " ")); System.err.println(""); } } static void output( Object o){ outputWln((("" + o) + "\n")); } static void outputWln( Object o){ try{out.write(("" + o)); }catch (Exception e){ } } static long mod = 1000000007; static BufferedWriter out ; static InputReader reader ; static void explore( ArrayList<Integer>[] components, ArrayList<Integer> bob, int[][] move, ArrayList<int[]>[] howto, int[][] list){ for ( int x :bob) {if ( (components[x].size() == 1)) { int tm[] = howto[x].get(0);  int L = howto[x].size(); howto[x].add(tm); for ( int i = 0;(i < L);i++) { int[] cur = howto[x].get(i);  int[] nx = howto[x].get((i + 1));  int a = cur[0];  int a2 = nx[0];  int b2 = nx[1]; move[a2][0] = list[a2][b2]; move[a2][1] = a; }} else {explore(components,components[x],move,howto,list); }}} static void process()throws Exception { out = new BufferedWriter(new OutputStreamWriter(System.out)); reader = new InputReader(System.in); int k = reader.readInt();  int[][] list = new int[k][];  long[] sum = new long[k];  int[] L = new int[k];  HashMap<Integer,int[]> target = new HashMap<Integer,int[]>();  long tot = 0; for ( int i = 0;(i < k);i++) {L[i] = reader.readInt(); list[i] = new int[L[i]]; for ( int j = 0;(j < L[i]);j++) {list[i][j] = reader.readInt(); sum[i] += list[i][j]; target.put(list[i][j],new int[]{i,j}); }tot += sum[i]; } int MX = (1 << k);  int AX = 1000000001;  ArrayList<int[]>[] howto = new ArrayList[MX]; log("ok with the data"); if ( ((tot % k) != 0)) {output("No"); } else {tot /= k; for ( int i = 0;(i < k);i++) {if ( (sum[i] == tot)) { int mask = (1 << i);  ArrayList<int[]> cand = new ArrayList<int[]>(); cand.add(new int[]{i,0}); howto[mask] = cand; } else for ( int j = 0;(j < L[i]);j++) { int u = i;  int v = j;  boolean ok = true;  int src_u = u;  int src_v = v;  int mask = 0;  boolean goon = true;  ArrayList<int[]> cand = new ArrayList<int[]>(); while(goon){cand.add(new int[]{u,v}); ok = false; goon = false; long need = (tot - ((long)sum[u] - (long)list[u][v])); if ( (Math.abs(need) <= AX)) { int nd = (int)need;  int[] tm = target.get(nd); if ( (tm != null)) { int nxu = tm[0];  int nxv = tm[1]; if ( ((mask & (1 << nxu)) == 0)) {mask |= (1 << nxu); if ( (nxu == src_u)) {if ( (nxv == src_v)) ok = true; } else {u = nxu; v = nxv; ok = true; goon = true; }} } } }if ( ok) {if ( (howto[mask] == null)) {howto[mask] = cand; } } }}log("step 1 done"); ArrayList[] components = new ArrayList[MX]; for ( int m = 0;(m < MX);m++) {if ( (howto[m] != null)) {components[m] = new ArrayList<Integer>(); components[m].add(m); } } int[] msk = new int[MX];  int w = 0; for ( int a = 0;(a < MX);a++) {if ( (howto[a] != null)) { ArrayList<Integer> add = new ArrayList<Integer>();  int ww = w; for ( int i = 0;(i < ww);i++) { int b = msk[i]; if ( ((b & a) == 0)) { int c = (b | a); log((("creating c:" + c) + " ")); if ( (components[c] == null)) {components[c] = new ArrayList<Integer>(); components[c].add(a); components[c].add(b); msk[w++] = c; } } }msk[w++] = a; } }if ( (components[(MX - 1)] != null)) {output("Yes"); int[][] move = new int[k][2]; explore(components,components[(MX - 1)],move,howto,list); for ( int i = 0;(i < k);i++) {output(((move[i][0] + " ") + (move[i][1] + 1))); }} else {output("No"); }}try{out.close(); }catch (Exception e){ } } public static void main( String[] args)throws Exception { process(); } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
5	public class CottageVillage{ public static void main( String[] args){ Scanner scan = new Scanner(System.in); while(scan.hasNext()){ int counter = 0;  int numbCottages = scan.nextInt();  int t = scan.nextInt();  House[] cottages = new House[numbCottages]; for ( int i = 0;(i < numbCottages);i++) { int centre = scan.nextInt();  int length = scan.nextInt();  double beginning = (centre - ((double)length / 2));  double end = (centre + ((double)length / 2)); cottages[i] = new House(beginning,end); }Arrays.sort(cottages); for ( int i = 0;(i < (numbCottages - 1));i++) {if ( ((cottages[i].end + t) <= cottages[(i + 1)].beginning)) {counter++; } if ( ((cottages[(i + 1)].beginning - t) >= cottages[i].end)) {counter++; } if ( (Math.abs(((cottages[i].end + t) - cottages[(i + 1)].beginning)) < 1e-8)) {counter--; } }System.out.println((counter + 2)); }} static class House implements Comparable<House>{ double beginning ; double end ; House( double _beginning, double _end){ beginning = _beginning; end = _end; } @Override public int compareTo( House house){ return Double.valueOf(beginning).compareTo(house.beginning);} } }
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{ class Team implements Comparable<Team>{ int solved = 0; int penalty = 0; Team( int solved, int penalty){ this.solved = solved; this.penalty = penalty; } public boolean equals( Object obj){ if ( (obj instanceof Team)) { Team o = (Team)obj; return ((this.solved == o.solved) && (this.penalty == o.penalty));} return false;} } public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int k = in.nextInt();  Team[] teams = new Team[n]; for ( int i = 0;(i < n);i++) teams[i] = new Team(in.nextInt(),in.nextInt()); Arrays.sort(teams); int[] top = new int[n];  int[] map = new int[n];  int cur = -1; for ( int i = 0;(i < n);i++) {if ( ((i == 0) || !teams[i].equals(teams[(i - 1)]))) cur = i; top[cur]++; map[i] = cur; }out.println(top[map[(k - 1)]]); } } 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());} } 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++) {writer.print(objects[i]); }} public void println( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } }
5	public class Flatville{ public static void main( String[] args){ class SquareHouse implements Comparable<SquareHouse>{ public SquareHouse( double posLeft, double sideLen){ _posLeft = posLeft; _sideLen = sideLen; } public double posLeft(){ return _posLeft;} public double posRight(){ return (_posLeft + _sideLen);} private double _posLeft ; private double _sideLen ; } Scanner scanner = new Scanner(System.in); final int nHouses = scanner.nextInt(); final double sideLen = scanner.nextDouble();  ArrayList<SquareHouse> houses = new ArrayList<SquareHouse>(); for ( int iHouse = 0;(iHouse < nHouses);++iHouse) { double pos = scanner.nextDouble();  double size = scanner.nextDouble();  double posLeft = (pos - (size / 2.0)); houses.add(new SquareHouse(posLeft,size)); }Collections.sort(houses); int nPositions = 2; for ( int iHouse = 0;(iHouse < (nHouses - 1));++iHouse) { double space = (houses.get((iHouse + 1)).posLeft() - houses.get(iHouse).posRight()); if ( (sideLen < space)) nPositions += 2; else if ( (sideLen == space)) nPositions++; }out.println(nPositions); } }
3	public class C{ public C(){ int N = sc.nextInt();  int R = sc.nextInt();  int[] X = sc.nextInts();  double[] res = new double[N]; for ( int i :rep(N)) {res[i] = R; for ( int j :rep(i)) { int D = abs((X[i] - X[j])); if ( (D <= (2 * R))) { double H = sqrt((((4.0 * R) * R) - ((1.0 * D) * D))); res[i] = max(res[i],(res[j] + H)); } }}exit(res); } static private int[] rep( int N){ return rep(0,N);} static private int[] rep( int S, int T){ if ( (T <= S)) return new int[0]; int[] res = new int[(T - S)]; for ( int i = S;(i < T);++i) res[(i - S)] = i; return res;} static private final IOUtils.MyScanner sc = new IOUtils.MyScanner(); static private void exit( Object o, Object... A){ IOUtils.print(o,A); IOUtils.exit(); } public static void main( String[] args){ new C(); IOUtils.exit(); } }
0	public class A{ static Scanner scanner = new Scanner(System.in); static int s ; public static void main( String[] args){ s = scanner.nextInt(); if ( (s >= 0)) {System.out.println(s); } else {if ( (s >= -10)) {System.out.println(0); } else { int ss = -s;  int a ,b ; a = (ss % 10); b = ((ss % 100) / 10); if ( (a > b)) {ss = (ss / 10); } else {ss = (((ss / 100) * 10) + a); }if ( (ss == 0)) {System.out.println(0); } else {System.out.println(("-" + ss)); }}}} }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(new BufferedInputStream(System.in));  PrintStream out = System.out;  int n = in.nextInt(); if ( (n >= 0)) out.println(n); else out.println(Math.max((n / 10),(((n / 100) * 10) + (n % 10)))); out.close(); in.close(); } }
3	public class CODEFORCES{ static InputReader in ; static PrintWriter out ; static void solve(){ int n = in.ni();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = in.ni(); int cnt = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) if ( (arr[j] > arr[i])) cnt++; }cnt %= 2; int m = in.ni(); while((m-- > 0)){ int l = in.ni(),r = in.ni();  int fin = ((r - l) + 1); fin *= (fin - 1); fin >>= 1; if ( ((fin & 1) == 1)) cnt++; cnt %= 2; if ( ((cnt & 1) == 1)) out.println("odd"); else out.println("even"); }} @SuppressWarnings static void soln(){ in = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } static class InputReader<SpaceCharFilter>{ 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 ni(){ 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 nl(){ 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); } } }
4	public class Solution35C{ 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 FileReader("input.txt")); out = new PrintWriter("output.txt"); } 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 Solution35C().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();  int m = readInt();  int k = readInt();  Point[] focuses = new Point[k]; for ( int i = 0;(i < k);i++) { int a = (readInt() - 1);  int b = (readInt() - 1); focuses[i] = new Point(a,b); } int maxI = 0,maxJ = 0;  int max = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) { int curMin = 1000000; for ( int r = 0;(r < k);r++) if ( ((abs((focuses[r].x - i)) + abs((focuses[r].y - j))) < curMin)) {curMin = (abs((focuses[r].x - i)) + abs((focuses[r].y - j))); if ( (curMin < max)) break; } if ( (curMin > max)) {max = curMin; maxI = i; maxJ = j; } }maxI++; maxJ++; out.println(((maxI + " ") + maxJ)); } static long gcd( long a, long b){ while((a != b)){if ( (a < b)) a -= b; else b -= a; }return a;} }
0	public class main1{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a = (n / 2);  int b = (n - a); if ( ((n % 2) == 0)) {if ( ((a % 2) == 1)) {a++; b--; } System.out.println(((a + " ") + b)); } else {if ( ((a % 2) == 1)) { int x = a; a = b; b = x; } if ( ((b % 3) == 0)) {} else if ( ((b % 3) == 1)) {a -= 2; b += 2; } else {a += 2; b -= 2; }System.out.println(((a + " ") + b)); }} }
4	public class D{ public static void main( String[] args){ FastScanner fs = new FastScanner();  int h = fs.nextInt(),w = fs.nextInt(),k = fs.nextInt();  PrintWriter out = new PrintWriter(System.out); if ( ((k % 2) == 1)) {for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {if ( (x != 0)) out.print(" "); out.print(-1); }out.println(); }out.close(); return ;} k /= 2; int[][] rightCost = new int[(w - 1)][h];  int[][] downCost = new int[w][(h - 1)]; for ( int y = 0;(y < h);y++) for ( int x = 0;(x < (w - 1));x++) rightCost[x][y] = fs.nextInt(); for ( int y = 0;(y < (h - 1));y++) for ( int x = 0;(x < w);x++) downCost[x][y] = fs.nextInt(); long[][] dp = new long[w][h];  long[][] dpNext = new long[w][h]; for ( int i = 0;(i < k);i++) {for ( int x = 0;(x < w);x++) {for ( int y = 0;(y < h);y++) { long ans = (long)1e18; if ( (x != 0)) ans = Math.min(ans,(dp[(x - 1)][y] + rightCost[(x - 1)][y])); if ( (y != 0)) ans = Math.min(ans,(dp[x][(y - 1)] + downCost[x][(y - 1)])); if ( (x != (w - 1))) ans = Math.min(ans,(dp[(x + 1)][y] + rightCost[x][y])); if ( (y != (h - 1))) ans = Math.min(ans,(dp[x][(y + 1)] + downCost[x][y])); dpNext[x][y] = ans; }}dp = dpNext; dpNext = new long[w][h]; }for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {if ( (x != 0)) out.print(" "); out.print((2 * dp[x][y])); }out.println(); }out.close(); } 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());} } }
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()); System.out.println("25"); } }
5	public class Solution{ static class Team implements Comparable<Team>{ int pr ; int time ; int id ; public Team( int P, int T, int I){ pr = P; time = T; id = I; } } public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  StringTokenizer st = new StringTokenizer(in.readLine());  int n = Integer.parseInt(st.nextToken());  int k = Integer.parseInt(st.nextToken());  Team[] a = new Team[n];  int[] c = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(in.readLine()); int p = Integer.parseInt(st.nextToken());  int t = Integer.parseInt(st.nextToken()); a[i] = new Team(p,t,i); }Arrays.sort(a); int prev = 1; c[1]++; for ( int i = 1;(i < n);i++) {if ( ((a[i].pr == a[(i - 1)].pr) && (a[i].time == a[(i - 1)].time))) for ( int j = (i + 1);(j >= prev);j--) c[j] = ((i + 2) - prev); else {prev = (i + 1); c[prev] = 1; }}out.println(c[k]); out.close(); } }
6	public class Fishes{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  double[][] p = new double[n][n];  double[] dp = new double[(1 << 18)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {p[i][j] = Double.parseDouble(s.next()); }} int last = (1 << n); dp[(last - 1)] = 1.0; for ( int i = (last - 2);(i > 0);i--) { int res = 0; for ( int j = 0;(j < n);j++) {if ( (((1 << j) & i) > 0)) res++; }res++; res = ((res * (res - 1)) / 2); for ( int j = 0;(j < n);j++) {if ( (((1 << j) & i) == 0)) {for ( int z = 0;(z < n);z++) {if ( (((1 << z) & i) > 0)) {dp[i] += (((dp[(i | (1 << j))] * 1.0) / res) * p[z][j]); } }} }}for ( int i = 0;(i < n);i++) {System.out.print((dp[(1 << i)] + " ")); }} }
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(); } }
0	public class KingEscape{ public static void main( String[] args){ Reader read = new Reader();  int n = read.nextInt();  int a1 = read.nextInt();  int a2 = read.nextInt();  int b1 = read.nextInt();  int b2 = read.nextInt();  int c1 = read.nextInt();  int c2 = read.nextInt(); if ( ((((b1 > a1) && (b2 > a2)) && (c1 > a1)) && (c2 > a2))) System.out.print("YES"); else if ( ((((b1 > a1) && (b2 < a2)) && (c1 > a1)) && (c2 < a2))) System.out.print("YES"); else if ( ((((b1 < a1) && (b2 > a2)) && (c1 < a1)) && (c2 > a2))) System.out.print("YES"); else if ( ((((b1 < a1) && (b2 < a2)) && (c1 < a1)) && (c2 < a2))) System.out.print("YES"); else System.out.print("NO"); } static private class Reader{ private final BufferedReader reader ; private final String separator ; private String ln ; private String[] tokens ; private int ptr ; Reader( String separator, InputStream input){ this.reader = new BufferedReader(new InputStreamReader(input)); this.separator = separator; this.ptr = -1; } Reader( String separator){ this(separator,System.in); } Reader(){ this(" "); } String nextStr(){ if ( Objects.isNull(ln)) {try{ln = reader.readLine(); }catch (IOException e){ System.out.println(e.getMessage()); } if ( Objects.nonNull(ln)) {tokens = ln.split(separator); ptr = 0; } else {throw (new NoSuchElementException("no next element"));}} else if ( (ptr == tokens.length)) {ln = null; tokens = null; ptr = -1; return nextStr();} return tokens[ptr++];} int nextInt(){ return Integer.parseInt(nextStr());} } }
0	public class Main{ public static void main( String[] args){ try{ Parserdoubt pd = new Parserdoubt(System.in);  int n = pd.nextInt();  PrintWriter pw = new PrintWriter(System.out); pw.println(((n * 3) / 2)); pw.flush(); }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 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++];} }
5	public class A{ public static double EPS = .001; public class House implements Comparable<House>{ int x ; int a ; public House( int mx, int ma){ x = mx; a = ma; } public double right(){ return ((double)x + ((double)a / 2.0));} public double left(){ return ((double)x - ((double)a / 2.0));} } public static void main( String[] args){ new A().solve(); } public void solve(){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int t = in.nextInt();  ArrayList<House> houses = new ArrayList<House>(); for ( int i = 0;(i < n);i++) { int x = in.nextInt();  int a = in.nextInt(); houses.add(new House(x,a)); }Collections.sort(houses); int total = 2; for ( int i = 0;(i < (houses.size() - 1));i++) { House me = houses.get(i);  House next = houses.get((i + 1));  double meright = me.right();  double nextleft = next.left();  double diff = (nextleft - meright); if ( ((diff - EPS) > (double)t)) {total += 2; } else if ( ((diff + EPS) > (double)t)) {total += 1; } }System.out.println(total); } }
2	public class d_169{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long x = sc.nextLong();  long y = sc.nextLong();  String s = Long.toBinaryString(x);  String p = Long.toBinaryString(y);  int id = (p.length() - s.length()); for ( int i = 1;(i <= id);i++) {s = ("0" + s); }if ( (x == y)) {System.out.println(0); return ;} for ( int i = 0;(i < p.length());i++) {if ( (s.charAt(i) != p.charAt(i))) {System.out.println(((long)Math.pow(2,(s.length() - i)) - 1)); return ;} }} }
3	public class D_Edu_Round_35{ public static long MOD = 1000000007; public static void main( String[] args)throws FileNotFoundException { PrintWriter out = new PrintWriter(System.out);  Scanner in = new Scanner();  int n = in.nextInt();  int[] data = new int[n]; for ( int i = 0;(i < n);i++) {data[i] = in.nextInt(); } FT tree = new FT((n + 1));  int result = 0; for ( int i = (n - 1);(i >= 0);i--) {tree.update(data[i],1); result += tree.get((data[i] - 1)); result %= 2; } int q = in.nextInt();  int[] tmp = new int[n]; for ( int i = 0;(i < q);i++) { int l = (in.nextInt() - 1);  int r = (in.nextInt() - 1);  int total = ((r - l) + 1); total = ((total * (total - 1)) / 2); total %= 2; result += total; result %= 2; if ( ((result % 2) == 0)) {out.println("even"); } else {out.println("odd"); }}out.close(); } public static class FT{ int[] data ; FT( int n){ data = new int[n]; } public void update( int index, int value){ while((index < data.length)){data[index] += value; data[index] %= 2; index += (index & index); }} public int get( int index){ int result = 0; while((index > 0)){result += data[index]; result %= 2; index -= (index & index); }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, long MOD){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long val = pow(a,(b / 2),MOD); 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(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());} } }
6	public class _8C{ static int[] x = new int[30],y = new int[30]; static int[][] dist = new int[30][30]; static int n ; static final int M = 1000; static int[] bitPos = new int[M]; {Arrays.fill(bitPos,-1); for ( int i = 0;(i < 24);i++) bitPos[((1 << i) % M)] = i; }static int sqr( int i){ return (i * i);} public static void main( String[] args)throws Exception { Reader.init(System.in); BufferedWriter cout = new BufferedWriter(new OutputStreamWriter(System.out)); x[0] = Reader.nextInt(); y[0] = Reader.nextInt(); n = Reader.nextInt(); for ( int i = 1;(i <= n);i++) {x[i] = Reader.nextInt(); y[i] = Reader.nextInt(); }for ( int i = 0;(i <= n);i++) for ( int j = 0;(j <= n);j++) dist[i][j] = (sqr((x[i] - x[j])) + sqr((y[i] - y[j]))); int[] f = new int[(1 << n)];  int[] r = new int[(1 << n)]; for ( int mask = 1;(mask < (1 << n));mask++) { int lowbit = (mask & -mask);  int lowbitPos = bitPos[(lowbit % M)]; f[mask] = ((dist[(lowbitPos + 1)][0] * 2) + f[(mask ^ lowbit)]); r[mask] = lowbit; for ( int i = (mask ^ lowbit);(i > 0);i = (i ^ (i & -i))) { int otherBit = (i & -i);  int otherBitPos = bitPos[(otherBit % M)];  int tmp = (((dist[0][(lowbitPos + 1)] + dist[(lowbitPos + 1)][(otherBitPos + 1)]) + dist[(otherBitPos + 1)][0]) + f[((mask ^ otherBit) ^ lowbit)]); if ( (tmp < f[mask])) {f[mask] = tmp; r[mask] = (lowbit | otherBit); } }}System.out.println(f[((1 << n) - 1)]); int mask = ((1 << n) - 1); while((mask > 0)){if ( ((r[mask] ^ (r[mask] & -r[mask])) == 0)) {System.out.print((("0 " + (bitPos[(r[mask] % M)] + 1)) + " ")); } else { int bit1 = (r[mask] & -r[mask]);  int bit2 = (r[mask] ^ bit1); System.out.print((((("0 " + (bitPos[(bit1 % M)] + 1)) + " ") + (bitPos[(bit2 % M)] + 1)) + " ")); }mask ^= r[mask]; }System.out.println("0"); cout.close(); } }
1	public class Round1B{ public static void main( String[] args)throws Exception { new Round1B().run(); } private void run()throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int tc = Integer.parseInt(br.readLine().trim()); while((tc > 0)){ String s = br.readLine().trim(); if ( s.matches("R[0-9]+C[0-9]+")) { Pattern p = Pattern.compile("R([0-9]+)C([0-9]+)");  Matcher m = p.matcher(s); if ( m.matches()) { int rows = Integer.parseInt(m.group(1));  int cols = Integer.parseInt(m.group(2));  String col = ""; while((cols > 0)){ int mod = ((cols - 1) % 26); col = ((char)('A' + mod) + col); cols = ((cols - 1) / 26); }System.out.println((col + rows)); } else {throw (new Exception());}} else { Pattern p = Pattern.compile("([A-Z]+)([0-9]+)");  Matcher m = p.matcher(s); if ( m.matches()) { int rows = Integer.parseInt(m.group(2));  int cols = 0;  int mul = 1; for ( int i = (m.group(1).length() - 1);(i >= 0);i--) {cols += (mul * ((m.group(1).charAt(i) - 'A') + 1)); mul *= 26; }System.out.printf("R%dC%d\n",rows,cols); } else {throw (new Exception());}}tc--; }br.close(); } }
5	public class Solution{ public static void main( String[] args){ Solution solution = new Solution(); System.out.println(solution.solve()); } private int solve(){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  int[] a = new int[m]; for ( int i = 0;(i < m);++i) a[i] = in.nextInt(); if ( (n > m)) return 0; Map<Integer,Integer> map = new HashMap<>(); for ( int k :a) map.put(k,(map.getOrDefault(k,0) + 1)); List<Integer> keySet = new ArrayList<>(map.keySet());  int end = (m / n); keySet.sort((u,v)->-Integer.compare(u,v)); do { int count = 0; for ( int k :keySet) {count += (map.get(k) / end); if ( (count >= n)) return end; }}while((--end > 0));return 0;} }
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(); } }
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{ static private int[] dx = {1,-1,0,0}; static private int[] dy = {0,0,-1,1}; public static void main( String[] args)throws Exception { Thread t = new Thread(null,null,"~",Runtime.getRuntime().maxMemory()){}; t.start(); t.join(); } public static void solve()throws Exception { Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = in.nextInt();  int m = in.nextInt();  int[][] time = new int[n][m]; for ( int i = 0;(i < n);++i) {Arrays.fill(time[i],Integer.MAX_VALUE); } int qq = in.nextInt();  int[] xs = new int[qq];  int[] ys = new int[qq]; for ( int i = 0;(i < qq);++i) {xs[i] = (in.nextInt() - 1); ys[i] = (in.nextInt() - 1); }for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {for ( int k = 0;(k < qq);++k) { int dist = (Math.abs((i - xs[k])) + Math.abs((j - ys[k]))); time[i][j] = Math.min(time[i][j],dist); }}} int max = -1;  int x = -1;  int y = -1; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) if ( (max < time[i][j])) {max = time[i][j]; x = (i + 1); y = (j + 1); } }out.println(((x + " ") + y)); out.flush(); out.close(); } }
4	public class cf1517d{ public static void main( String[] args)throws IOException { int n = rni(),m = ni(),k = ni(),ans[][] = new int[n][m];  WGraph g = wgraph((n * m)); for ( int i = 0;(i < n);++i) {r(); for ( int j = 0;(j < (m - 1));++j) {g.c(((i * m) + j),(((i * m) + j) + 1),ni()); }}for ( int i = 0;(i < (n - 1));++i) {r(); for ( int j = 0;(j < m);++j) {g.c(((i * m) + j),(((i + 1) * m) + j),ni()); }}if ( ((k % 2) == 1)) {for ( int[] row :ans) {fill(row,-1); prln(row); }close(); return ;} k >>= 1; for ( int l = 0;(l < k);++l) { int nans[][] = new int[n][m]; for ( int[] row :nans) {fill(row,IBIG); }for ( int i = 0;(i < (n * m));++i) {for ( int[] ed :g.get(i)) { int j = ed[0],d = ed[1]; if ( ((ans[(i / m)][(i % m)] + d) < nans[(j / m)][(j % m)])) {nans[(j / m)][(j % m)] = (ans[(i / m)][(i % m)] + d); } }}ans = nans; }for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {ans[i][j] *= 2; }}for ( int[] row :ans) {prln(row); }close(); } static WGraph wgraph( int n){ WGraph g = new WGraph(); for ( int i = 0;(i < n);++i) {g.add(new ArrayList<>()); }return g;} static WGraph wgraph( int n, int m)throws IOException { WGraph g = wgraph(n); for ( int i = 0;(i < m);++i) {g.c((rni() - 1),(ni() - 1),ni()); }return g;} static class WGraph extends ArrayList<List<int[]>>{ void cto( int u, int v, int w){ get(u).add(new int[]{v,w}); } void c( int u, int v, int w){ cto(u,v,w); cto(v,u,w); } } 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 gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} static long gcd( long a, long b){ return ((b == 0)?a:gcd(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(); } }
1	public class Main{ static PrintWriter out ; static BufferedReader in ; public static void main( String[] args)throws Exception { out = new PrintWriter(System.out); in = new BufferedReader(new InputStreamReader(System.in)); int n = new Integer(in.readLine()); for ( int i = 0;(i < n);i++) { String s = in.readLine();  int x = 0; while((((s.charAt(x) - 'A') >= 0) && ((s.charAt(x) - 'Z') <= 0)))x++; int y = (s.length() - 1); while((((s.charAt(y) - '0') >= 0) && ((s.charAt(y) - '9') <= 0)))y--; if ( (x > y)) { int k = 1;  int a = 1; for ( int j = 1;(j < x);j++) {k *= 26; a += k; }for ( int j = 0;(j < x);j++) {a += (k * (s.charAt(j) - 'A')); k /= 26; } int b = Integer.parseInt(s.substring(x)); out.println(((("R" + b) + "C") + a)); } else {while((((s.charAt(x) - '0') >= 0) && ((s.charAt(x) - '9') <= 0)))x++; int b = Integer.parseInt(s.substring(1,x));  int a = Integer.parseInt(s.substring((x + 1)));  int num = 0;  int k = 1; while((a >= k)){a -= k; k *= 26; }k /= 26; while((k > 0)){out.print((char)('A' + (a / k))); a %= k; k /= 26; }out.println(b); }}out.close(); } }
0	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 n1 = (n / 10);  int s = (n % 10);  int n2 = (((n / 100) * 10) + s); System.out.println(Math.max(n,Math.max(n1,n2))); pw.close(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
0	public class Main{ public static void main( String[] args){ Scanner cin = new Scanner(System.in);  int n = cin.nextInt();  long res = 2;  long[] a = new long[4]; a[0] = 0; a[1] = 1; a[2] = 1; a[3] = 2; if ( (n == 1)) {System.out.println("0 0 1"); return ;} if ( (n == 2)) {System.out.println("0 1 1"); return ;} if ( (n == 0)) {System.out.println("0 0 0"); return ;} if ( (n == 3)) {System.out.println("1 1 1"); return ;} do {a[3] = res; res = (a[2] + a[3]); if ( (res == n)) {System.out.println(((((a[0] + " ") + a[1]) + " ") + a[3])); return ;} a[0] = a[1]; a[1] = a[2]; a[2] = a[3]; }while(true);} }
6	public class B{ static Senator[] data ; public static void main( String[] args){ Scanner in = new Scanner(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int k = in.nextInt();  int A = in.nextInt(); data = new Senator[n]; for ( int i = 0;(i < n);i++) {data[i] = new Senator(in.nextInt(),in.nextInt()); }out.println(cal(0,new int[n],A,k)); out.close(); } public static double cal( int index, int[] num, int A, int left){ if ( (index == (data.length - 1))) { int dif = ((100 - data[index].loyal) / 10); dif = ((left >= dif)?dif:left); num[index] = dif; double result = 0; for ( int k = 0;(k < (1 << num.length));k++) { double val = 1;  double total = 0; for ( int i = 0;(i < num.length);i++) {if ( (((1 << i) & k) != 0)) {val *= ((double)(data[i].loyal + (10 * num[i])) / 100); } else {val *= ((double)(100 - (data[i].loyal + (10 * num[i]))) / 100); total += data[i].level; }}if ( (countBit(k) > (num.length / 2))) {result += val; } else {result += (val * ((double)A / (A + total))); }}return result;} else { double result = 0; for ( int i = 0;(i <= left);i++) {if ( (((i * 10) + data[index].loyal) <= 100)) {num[index] = i; result = Math.max(result,cal((index + 1),num,A,(left - i))); } else {break;}}return result;}} public static int countBit( int val){ int result = 0; while((val > 0)){result += (val % 2); val >>= 1; }return result;} public static class Senator{ int level ,loyal ; public Senator( int level, int loyal){ this.level = level; this.loyal = loyal; } } public double pow( double a, int b){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} double val = pow(a,(b / 2)); if ( ((b % 2) == 0)) {return (val * val);} else {return ((val * val) * a);}} public static long gcd( long a, long b){ if ( (b == 0)) {return a;} return gcd(b,(a % b));} }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputUtil in = new InputUtil(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ HashMap<Integer,Integer> left = new HashMap<Integer,Integer>(); public void solve( int testNumber, InputUtil in, PrintWriter out){ int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] res = new int[n];  int[] arr = in.nextIntArray(n);  IntDeque[] adj = IntDeque.IntDeques(n);  boolean[] self = new boolean[n];  boolean[] assigned = new boolean[n]; for ( int i = 0;(i < n);i++) {left.put(arr[i],i); }for ( int i = 0;(i < n);i++) { int x = arr[i];  boolean canA = left.containsKey((a - x));  boolean canB = left.containsKey((b - x)); if ( (!canA && !canB)) {out.println("NO"); return ;} if ( left.containsKey((a - x))) {self[i] |= (x == (a - x)); if ( (x != (a - x))) {adj[i].add(left.get((a - x))); } } if ( left.containsKey((b - x))) {self[i] |= (x == (b - x)); if ( (x != (b - x))) {adj[i].add(left.get((b - x))); } } }if ( (a == b)) {out.println("YES"); out.println(IntArrayUtil.toString(res)); return ;} for ( int iter = 0;(iter < 2);iter++) {for ( int i = 0;(i < n);i++) {if ( ((!self[i] && !assigned[i]) && ((iter == 1) || (adj[i].size() == 1)))) { int u = i; DFS:while(true){assigned[u] = true; if ( (self[u] && (arr[u] == (b - arr[u])))) {res[u] = 1; break;} for ( int v :adj[u]) {if ( !assigned[v]) {assigned[v] = true; if ( (arr[u] == (b - arr[v]))) {res[u] = res[v] = 1; } for ( int newU :adj[v]) {if ( !assigned[newU]) {u = newU; continue DFS;} }break;} }out.println("NO"); return ;}} else if ( ((((iter == 1) && !assigned[i]) && (adj[i].size() == 0)) && (arr[i] == (b - arr[i])))) {res[i] = 1; } }}out.println("YES"); out.println(IntArrayUtil.toString(res)); } } class InputUtil{ JoltyScanner in ; public InputUtil( InputStream istream){ in = new JoltyScanner(istream); } public String next(){ return in.next();} public int nextInt(){ return Integer.parseInt(next());} public int[] nextIntArray( int size){ int[] arr = new int[size]; for ( int i = 0;(i < size);i++) {arr[i] = in.nextInt(); }return arr;} } class IntDeque implements Iterable<Integer>{ private int capacity ; private int size = 0; private int front = 0; private int back = 0; private int[] deque ; public IntDeque(){ this(16); } public IntDeque( int capacity){ this.capacity = capacity; deque = new int[capacity]; } public static IntDeque[] IntDeques( int length){ IntDeque[] arr = new IntDeque[length]; for ( int i = 0;(i < length);i++) {arr[i] = new IntDeque(); }return arr;} public IntDeque( T intList){ this(16); addAll(intList); } public IntDeque( int[] intArr){ this(16); for ( int i :intArr) {addLast(i); }} public void add( int x){ addLast(x); } public <T> void addAll( T intList){ for ( int i :intList) {addLast(i); }} public void addLast( int x){ ensureCapacity(); size++; deque[back++] = x; if ( (back == capacity)) {back = 0; } } public void ensureCapacity(){ if ( (size < capacity)) {return ;} int[] newDeque = new int[(capacity << 1)]; for ( int i = 0,j = front;(i < size);i++,j++) {if ( (j == capacity)) {j = 0; } newDeque[i] = deque[j]; }deque = newDeque; capacity <<= 1; front = 0; back = size; } public int size(){ return size;} public String toString(){ if ( (size == 0)) {return "";} StringBuilder res = new StringBuilder(); for ( int i :this) {res.append(i); res.append(" "); }res.setLength((res.length() - 1)); return res.toString();} } class JoltyScanner{ public static final int BUFFER_SIZE = (1 << 16); public static final char NULL_CHAR = (char)-1; StringBuilder str = new StringBuilder(); byte[] buffer = new byte[BUFFER_SIZE]; boolean EOF_FLAG = false; int bufferIdx = 0,size = 0; char c = NULL_CHAR; BufferedInputStream in ; public JoltyScanner( InputStream in){ this.in = new BufferedInputStream(in,BUFFER_SIZE); } public int nextInt(){ long x = nextLong(); if ( ((x > Integer.MAX_VALUE) || (x < Integer.MIN_VALUE))) {throw (new ArithmeticException("Scanned value overflows integer"));} return (int)x;} public long nextLong(){ boolean negative = false; if ( (c == NULL_CHAR)) {c = nextChar(); } for ( ;(!EOF_FLAG && ((c < '0') || (c > '9')));c = nextChar()) {if ( (c == '-')) {negative = true; } }checkEOF(); long res = 0; for ( ;((c >= '0') && (c <= '9'));c = nextChar()) {res = ((((res << 3) + (res << 1)) + c) - '0'); }return (negative?-res:res);} public String next(){ checkEOF(); if ( (c == NULL_CHAR)) {c = nextChar(); } while(Character.isWhitespace(c)){c = nextChar(); checkEOF(); }str.setLength(0); for ( ;(!EOF_FLAG && !Character.isWhitespace(c));c = nextChar()) {str.append(c); }return str.toString();} public char nextChar(){ if ( EOF_FLAG) {return NULL_CHAR;} while((bufferIdx == size)){try{size = in.read(buffer); if ( (size == -1)) {throw (new Exception());} }catch (Exception e){ EOF_FLAG = true; return NULL_CHAR;} if ( (size == -1)) {size = BUFFER_SIZE; } bufferIdx = 0; }return (char)buffer[bufferIdx++];} public void checkEOF(){ if ( EOF_FLAG) {throw (new EndOfFileException());} } public class EndOfFileException extends RuntimeException{ } }
2	public class B{ public static void main( String[] args){ Pipes pipes = new Pipes(); pipes.solve(); pipes.print(); } } class Pipes{ Pipes(){ Scanner scr = new Scanner(System.in); n = scr.nextLong(); k = scr.nextLong(); } long bs( long nb, long nk){ long left = 2;  long ls = (((((nk - left) + 1) * (nk + left)) / 2) - (nk - left));  long right = nk;  long rs = nk; if ( (nb > ls)) {return -1;} long mid = left; while((rs < ls)){mid = ((left + right) / 2); long ms = (((((nk - mid) + 1) * (nk + mid)) / 2) - (nk - mid)); if ( (nb > ms)) {right = mid; rs = ms; } else if ( (nb < ms)) {left = (mid + 1); ls = (((((nk - left) + 1) * (nk + left)) / 2) - (nk - left)); } else {left = mid; break;}}return left;} void solve(){ long nn = n;  long kk = k; ans = 0; long ps = 1;  long add ; if ( (n == 1)) {ans = 0; return ;} nn = (n - (ps - 1)); while((nn > kk)){add = bs(nn,kk); if ( (add == -1)) {ans = -1; return ;} else {ans = (ans + ((kk - add) + 1)); } long addn = (((((kk - add) + 1) * (kk + add)) / 2) - (kk - add)); ps = ((ps - 1) + addn); if ( (ps == n)) return ; nn = (nn - (ps - 1)); kk = (add - 1); }if ( (nn > 0)) {ans++; } } void print(){ System.out.println(ans); } long ans ; long n ; long k ; }
5	public class main{ 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();  int a = next();  int b = next();  int k = 0;  int i ;  int[] ar = new int[n]; for ( i = 0;(i < n);i++) ar[i] = next(); Arrays.sort(ar); k = (ar[(n - a)] - ar[(b - 1)]); if ( (k < 0)) out.print(0); else out.print(k); out.close(); } }
5	public class A{ void solve()throws Exception { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); Arrays.sort(a); int[] res = new int[n]; for ( int i = 0;(i < n);i++) {if ( (i == 0)) res[i] = 1; else res[i] = a[(i - 1)]; }if ( (a[(n - 1)] == 1)) res[(n - 1)] = 2; for ( int i = 0;(i < n);i++) {if ( (i == (n - 1))) writer.println(res[i]); else writer.print((res[i] + " ")); }} BufferedReader reader ; PrintWriter writer ; StringTokenizer stk ; void run()throws Exception { reader = new BufferedReader(new InputStreamReader(System.in)); stk = null; writer = new PrintWriter(new PrintWriter(System.out)); solve(); reader.close(); writer.close(); } int nextInt()throws Exception { return Integer.parseInt(nextToken());} String nextLine()throws Exception { return reader.readLine();} String nextToken()throws Exception { if ( ((stk == null) || !stk.hasMoreTokens())) {stk = new StringTokenizer(nextLine()); return nextToken();} return stk.nextToken();} public static void main( String[] args)throws Exception { new A().run(); } }
6	public class Template{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; public static void main( String[] args)throws IOException { new Template().run(); } void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); st = null; out = new PrintWriter(System.out); solve(); br.close(); out.close(); } double dm[] ; double a[][] ; boolean fil[] ; int p[] ; int n ; void solve()throws IOException { n = nextInt(); a = new double[n][n]; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);++j) {a[i][j] = nextDouble(); }dm = new double[(1 << n)]; fil = new boolean[(1 << n)]; for ( int i = 0;(i < n);++i) {out.print((brute((1 << i)) + " ")); }} private double brute( int mask){ if ( (Integer.bitCount(mask) == n)) return 1; if ( fil[mask]) return dm[mask]; int c = Integer.bitCount(mask);  double res = 0;  double p = ((2.0 / (double)(c + 1)) / (double)c); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {if ( (((mask & (1 << i)) == 0) && ((mask & (1 << j)) > 0))) {res += (a[j][i] * brute((mask ^ (1 << i)))); } }}res *= p; dm[mask] = res; fil[mask] = true; return dm[mask];} int nextInt()throws IOException { return Integer.parseInt(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(br.readLine()); }return st.nextToken();} }
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"); } }
5	public class A113{ public static void main( String[] args){ new A113().run(); } public void run(){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  Team[] teams = new Team[n]; for ( int i = 0;(i < teams.length);i++) {teams[i] = new Team(in.nextInt(),in.nextInt()); }Arrays.sort(teams); int counter = 1;  int index = (k - 2); while((((index >= 0) && (teams[index].p == teams[(k - 1)].p)) && (teams[index].t == teams[(k - 1)].t))){index--; counter++; }index = k; while((((index < n) && (teams[index].p == teams[(k - 1)].p)) && (teams[index].t == teams[(k - 1)].t))){index++; counter++; }System.out.println(counter); } private class Team implements Comparable<Team>{ int p ; int t ; public Team( int pp, int tt){ p = pp; t = tt; } } }
2	public class Main{ public static void main( String[] args)throws java.lang.Exception { FastReader sc = new FastReader();  long n = sc.L();  long k = sc.L();  long x = (8 * (n + k)); x += 9; x = ((long)Math.sqrt(x) - 3); x /= 2; System.out.println((n - x)); } static long power( long x, long y, long p){ long res = 1; x = (x % p); while((y > 0)){if ( ((y & 1) == 1)) res = ((res * x) % p); y = (y >> 1); x = ((x * x) % p); }return res;} 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 L(){ return Long.parseLong(next());} } static int gcd( int a, int b){ if ( ((a % b) == 0)) return b; return gcd(b,(a % b));} static float power( float x, int y){ float temp ; if ( (y == 0)) return 1; temp = power(x,(y / 2)); if ( ((y % 2) == 0)) return (temp * temp); else {if ( (y > 0)) return ((x * temp) * temp); else return ((temp * temp) / x);}} }
0	public class Task1{ public static void main( String[] args){ int n = new Scanner(System.in).nextInt(); System.out.println(((n * 3) / 2)); } }
6	public class E{ public static void main( String[] args){ 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(); }} double[] dp = new double[(1 << n)]; dp[((1 << n) - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask > 0);mask--) { int t = Integer.bitCount(mask); if ( (t == 1)) continue; double p0 = (1.0 / ((t * (t - 1)) / 2)); for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) {for ( int j = 0;(j < n);j++) {if ( ((j != i) && ((mask & (1 << j)) != 0))) dp[(mask ^ (1 << i))] += ((dp[mask] * p[j][i]) * p0); }} }}for ( int i = 0;(i < n);i++) {System.out.print((dp[(1 << i)] + " ")); }} }
2	public class ProblemB{ 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(" ");  long n = Long.valueOf(line[0]);  long y = Long.valueOf(line[1]);  long x = Long.valueOf(line[2]);  long c = Long.valueOf(line[3]);  long min = 0;  long max = ((n * 2L) + 20); for ( int cnt = 0;(cnt < 300);cnt++) { long med = ((min + max) / 2L);  long ct = isok(med,n,x,y,c); if ( (ct >= c)) {max = med; } else {min = (med + 1); }} long lst = max; for ( long d = -2;(d <= 2);d++) {if ( (((max + d) >= 0) && (isok((max + d),n,x,y,c) >= c))) {lst = Math.min(lst,(max + d)); } }out.println(lst); out.flush(); } static private long isok( long time, long n, long x, long y, long c){ long total = (((time * 2) * (time + 1)) + 1);  long top = (y - time); if ( (top <= 0)) { long dy = (Math.abs(top) + 1); total -= (dy * dy); long over = (dy - x); if ( (over >= 1)) {total += (((1L + over) * over) / 2); } over = (dy - ((n + 1) - x)); if ( (over >= 1)) {total += (((1L + over) * over) / 2); } } long bottom = (y + time); if ( (bottom > n)) { long dy = Math.abs((bottom - n)); total -= (dy * dy); long over = (dy - x); if ( (over >= 1)) {total += (((1L + over) * over) / 2); } over = (dy - ((n + 1) - x)); if ( (over >= 1)) {total += (((1L + over) * over) / 2); } } long left = (x - time); if ( (left <= 0)) { long dy = (Math.abs(left) + 1); total -= (dy * dy); } long right = (x + time); if ( (right > n)) { long dy = Math.abs((right - n)); total -= (dy * dy); } return total;} }
3	public class FUck{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int k = scan.nextInt();  String t = scan.next();  int mx = 0; for ( int i = 1;(i < n);i++) { int gd = 1; for ( int j = 0;(j < i);j++) {if ( (t.charAt(j) != t.charAt(((n - i) + j)))) {gd = 0; } }if ( (gd == 1)) {mx = i; } }System.out.print(t); for ( int i = 2;(i <= k);i++) {for ( int j = mx;(j < n);j++) {System.out.print(t.charAt(j)); }}} }
1	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int[] a = new int[1010]; while(in.hasNext()){ int n = in.nextInt();  String s = in.next();  int sum = 0; for ( int i = 0;(i < n);++i) {if ( (s.charAt(i) == 'H')) {a[i] = 1; ++sum; } else a[i] = 0; } int min = 10010; for ( int i = 0;(i < (n - sum));++i) { int count = 0; for ( int j = (i + sum);(j < n);++j) {if ( (a[j] == 1)) ++count; }for ( int j = 0;(j < i);++j) {if ( (a[j] == 1)) ++count; }if ( (count < min)) min = count; }sum = (n - sum); for ( int i = 0;(i < (n - sum));++i) { int count = 0; for ( int j = (i + sum);(j < n);++j) {if ( (a[j] == 0)) ++count; }for ( int j = 0;(j < i);++j) {if ( (a[j] == 0)) ++count; }if ( (count < min)) min = count; }System.out.println(min); }} }
2	public class Main{ public static void main( String[] args){ Scanner scn = new Scanner(System.in);  long a ,b ; a = scn.nextLong(); b = scn.nextLong(); long diff = (b - a),tot = 0;  int ind = 0; while(true){ long res = (long)Math.pow(2.0,ind); if ( (res > b)) break; if ( (((a >> ind) != (b >> ind)) || (diff >= res))) tot += res; ind++; }System.out.println(tot); } }
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();  int K = in.nextInt();  long pipes = 1; if ( (N == 1)) {out.println(0); return ;} long left = 0,right = (K - 1),find = -1; while((left <= right)){ long mid = ((left + right) / 2); if ( ((((mid * mid) + ((1 - (2 * K)) * mid)) + (2 * (N - 1))) <= 0)) {find = mid; right = (mid - 1); } else left = (mid + 1); }out.println(find); } }
2	public class A{ static private Scanner in ; final int M = 1000000009; public void run(){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int z = (n - m); if ( (z >= (n / k))) {System.out.println(m); return ;} int f = (n - (k * z));  int ans = BigInteger.ONE.shiftLeft(((f / k) + 1)).remainder(BigInteger.valueOf(M)).intValue(); System.out.println((((((ans + M) - 2L) * k) + ((f % k) + ((k - 1) * z))) % M)); } public static void main( String[] args){ Locale.setDefault(Locale.US); in = new Scanner(System.in); new A().run(); in.close(); } }
2	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)){ long k = input.nextLong();  long v = 9;  long s = 0;  int x = 1; while(true){if ( ((s + (v * x)) > k)) {break;} s += (v * x); v *= 10; x++; }if ( (s == k)) {out.println(9); } else { long d = (k - s);  long u = (d / x);  long rem = (d % x);  long nu = (long)Math.pow(10,(x - 1)); nu += u; if ( (rem == 0)) {nu--; out.println((nu % 10)); } else { String str = String.valueOf(nu); out.println(str.charAt((int)(rem - 1))); }}}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();} long nextLong(){ return Long.parseLong(next());} } }
0	public class A{ private void processInput()throws IOException { Scanner in = new Scanner(System.in);  int n = in.nextInt();  long res = go(n); System.out.printf(Locale.ENGLISH,"%d\n",res); in.close(); } private long go( long n){ long res = ((3 * n) / 2); return res;} public static void main( String[] args)throws Exception { A a = new A(); a.processInput(); } }
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 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);} }
1	public class test{ public static void main( String[] args)throws Exception,IOException { Reader sc = new Reader(System.in);  int n = sc.nextInt(),m = sc.nextInt(),a[] = new int[n];  int b[] = new int[(100000 + 1)],r = (n + 1); for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); int s = 0,t = -1,sum = 0;  int as = 0,at = 0; for ( ;;) {while(((t < (n - 1)) && (sum < m))){t++; if ( (b[a[t]] < 1)) {sum++; } b[a[t]]++; }db(s,t,sum); if ( (sum < m)) break; as = s; at = t; r = min(r,((t - s) + 1)); if ( (b[a[s]] == 1)) {sum--; } b[a[s]]--; s++; }if ( (n < r)) System.out.println("-1 -1"); else System.out.println((((as + 1) + " ") + (at + 1))); } static void db( Object... os){ System.err.println(Arrays.deepToString(os)); } } 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());} }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Reader in = new Reader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  BDigitsSequenceHardEdition solver = new BDigitsSequenceHardEdition(); solver.solve(1,in,out); out.close(); } static class BDigitsSequenceHardEdition{ public void solve( int testNumber, Reader in, PrintWriter out){ long k = in.nextLong();  long start = 1;  long nDigit = 1; while(true){ long curr = ((start * 9) * nDigit); if ( (curr >= k)) break; start *= 10; nDigit += 1; k -= curr; }if ( ((k % nDigit) == 0)) {start += ((k / nDigit) - 1); out.println((start % 10)); } else { long n = (start + (k / nDigit));  int off = (int)(k % nDigit); out.println(Long.toString(n).charAt((off - 1))); }} } static class Reader{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ; private int bytesRead ; public Reader( InputStream in){ din = new DataInputStream(in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader( String file_name){ try{din = new DataInputStream(new FileInputStream(file_name)); }catch (IOException e){ throw (new RuntimeException(e));} buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } 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(){ try{bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) {buffer[0] = -1; } }catch (IOException e){ throw (new RuntimeException(e));} } private byte read(){ if ( (bufferPointer == bytesRead)) {fillBuffer(); } return buffer[bufferPointer++];} } }
3	public class mainD{ public static PrintWriter out = new PrintWriter(System.out); public static FastScanner enter = new FastScanner(System.in); public static long[] arr ; public static void main( String[] args)throws IOException { int n = enter.nextInt();  int m = enter.nextInt();  long k = enter.nextLong(); arr = new long[(n + 1)]; for ( int i = 1;(i < (n + 1));i++) {arr[i] = enter.nextLong(); } long[] summ = new long[(n + 1)]; for ( int i = 1;(i < (n + 1));i++) {summ[i] += (arr[i] + summ[(i - 1)]); } long[] best = new long[(n + 1)]; for ( int i = 1;(i < (n + 1));i++) {best[i] = Math.max(0,(((i - m) >= 0)?(((best[(i - m)] + summ[i]) - summ[(i - m)]) - k):0)); } long ans = best[1]; for ( int i = 1;(i < (n + 1));i++) {ans = Math.max(ans,best[i]); for ( int j = 1;(j < m);j++) {ans = Math.max(ans,(((i - j) >= 0)?(((best[(i - j)] - k) + summ[i]) - summ[(i - j)]):0)); }}System.out.println(ans); } static class FastScanner{ BufferedReader br ; StringTokenizer stok ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } String next()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return null;} stok = new StringTokenizer(s); }return stok.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} long nextLong()throws IOException { return Long.parseLong(next());} } }
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());} } }
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); } } }
6	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNextInt()){ int n = sc.nextInt();  long m = sc.nextInt();  boolean edge[][] = new boolean[n][n];  long dp[][] = new long[(1 << n)][n]; for ( long i = 1;(i <= m);++i) { int u = sc.nextInt();  int v = sc.nextInt(); --u; --v; edge[u][v] = edge[v][u] = true; }for ( int i = 0;(i < n);++i) {dp[(1 << i)][i] = 1; } long res = 0; for ( int i = 1;(i < (1 << n));++i) { int first = cal(i); for ( int j = first;(j < n);++j) {if ( (dp[i][j] == 0)) {continue;} for ( int k = first;(k < n);++k) {if ( ((j == k) || !edge[j][k])) {continue;} if ( ((k == first) && judge(i))) {res += dp[i][j]; } if ( ((i & (1 << k)) == 0)) {dp[(i | (1 << k))][k] += dp[i][j]; } }}}System.out.println((res / 2)); }} public static int cal( int x){ int ord = 0; while(true){if ( ((x & (1 << ord)) != 0)) {break;} ++ord; }return ord;} public static boolean judge( int x){ int cnt = 0; while((x >= 1)){if ( ((x & 1) == 1)) {++cnt; } x >>= 1; }return (cnt >= 3);} }
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);  ABirthday solver = new ABirthday(); solver.solve(1,in,out); out.close(); } static class ABirthday{ public void solve( int testNumber, InputReader in, OutputWriter out){ long N = in.readLong(),M = in.readLong(),K = in.readLong(),L = in.readLong();  long ans = ((((L + K) - 1) / M) + 1); if ( (((ans * M) > N) || (((ans * M) - K) < L))) out.printLine(-1); else out.printLine(ans); } } 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( long i){ writer.println(i); } public void printLine( 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 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); } } }
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")); }} static private 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); } static private 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;} } }
1	public class Solution1 implements Runnable{ static final long MAX = 1000000007L; 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 String next(){ return readString();} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new Solution1(),"Solution1",(1 << 26)).start(); } long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} int root( int a){ while((arr[a] != a)){arr[a] = arr[arr[a]]; a = arr[a]; }return a;} int[] arr ; final int level = 20; }
0	public class test{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  String num = input.nextLine(); System.out.println("25"); } }
3	public class A{ static int countColors( List<Integer> colors){ Collections.sort(colors); int k = 0; while(!colors.isEmpty()){ Integer c = colors.get(0); colors.remove(0); k++; List<Integer> toRemove = new ArrayList<>(); for ( int i = 0;(i < colors.size());i++) {if ( ((colors.get(i) % c) == 0)) toRemove.add(i); }Collections.reverse(toRemove); for ( Integer integer :toRemove) {colors.remove(integer.intValue()); }}return k;} public static void main( String[] args){ try(Scanner scanner=new Scanner(System.in)){ int n = scanner.nextInt(); scanner.nextLine(); List<Integer> integers = Arrays.stream(scanner.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList()); System.out.println(countColors(integers)); }} }
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);} }
1	public class TaskA implements Runnable{ private InputReader in ; private PrintWriter out ; public static void main( String[] args){ new Thread(new TaskA()).start(); } public TaskA(){ in = new InputReader(System.in); out = new PrintWriter(System.out); } static private 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);} 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))){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();} } }
4	public class Main{ public static void main( String[] args)throws FileNotFoundException { Scanner read = new Scanner(new FileInputStream(new File("input.txt")));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = read.nextInt(),m = read.nextInt(),k = read.nextInt(),tree[][] = new int[n][m],a[] = new int[k],b[] = new int[k],x = 0,y = 0,max = -1,d = 0; for ( int i = 0;(i < k);i++) {a[i] = (read.nextInt() - 1); b[i] = (read.nextInt() - 1); tree[a[i]][b[i]] = 0; }for ( int i = 0;(i < n);i++) {Arrays.fill(tree[i],Integer.MAX_VALUE); }for ( int o = 0;(o < k);o++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {d = (Math.abs((a[o] - i)) + Math.abs((b[o] - j))); if ( (d < tree[i][j])) tree[i][j] = d; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (tree[i][j] > max)) {max = tree[i][j]; x = i; y = j; } }}out.println((((x + 1) + " ") + (y + 1))); out.close(); } }
3	public class a1{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int a[] = new int[n];  HashMap<Integer,ArrayList<Integer>> h = new HashMap<>();  boolean visited[] = new boolean[n]; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); }Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( h.containsKey(a[i])) { ArrayList<Integer> temp = h.get(a[i]); temp.add(i); h.put(a[i],temp); } else { ArrayList<Integer> k = new ArrayList<>(); k.add(i); h.put(a[i],k); }} int ctr = 0; for ( int i = 0;(i < n);i++) {if ( !visited[i]) {ctr++; for ( int j = a[i];(j <= 100);j += a[i]) {if ( h.containsKey(j)) { ArrayList<Integer> m = h.get(j); for ( int k = 0;(k < m.size());k++) {visited[m.get(k)] = true; }h.remove(j); } }} }System.out.println(ctr); } }
3	public class C{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n ,r ; n = scan.nextInt(); r = scan.nextInt(); int[] locs = new int[n]; for ( int i = 0;(i < n);i++) {locs[i] = scan.nextInt(); } double[] yPos = new double[n]; Arrays.fill(yPos,10e100); yPos[0] = r; for ( int i = 1;(i < n);i++) { double pos = r; for ( int j = 0;(j < i);j++) { int xDist = Math.abs((locs[i] - locs[j])); if ( (xDist <= (2 * r))) { double y = (((2.0 * r) * (2.0 * r)) - (xDist * xDist)); if ( (Math.abs((y - 0.0)) < 0.0000000001)) {y = 0; } else {y = Math.sqrt(y); }y += yPos[j]; pos = Math.max(pos,y); } else {continue;}}yPos[i] = pos; } String[] ans = new String[n]; for ( int i = 0;(i < n);i++) {ans[i] = ("" + yPos[i]); }System.out.println(String.join(" ",ans)); } }
1	public class B{ static BufferedReader in ; static StringTokenizer st ; static String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  int n = nextInt();  int k = nextInt();  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = nextInt(); } Set<Integer> set_1 = new HashSet<Integer>(); for ( int i = 1;(i <= n);i++) {set_1.add(a[i]); if ( (set_1.size() == k)) { Set<Integer> set_2 = new HashSet<Integer>(); for ( int j = i;(j >= 1);j--) {set_2.add(a[j]); if ( (set_2.size() == k)) {out.print(((j + " ") + i)); out.close(); return ;} }} }out.print("-1 -1"); out.close(); } }
1	public class D999{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int req = (n / m);  int arr[] = new int[(n + 1)];  int size[] = new int[m];  List<Integer> list[] = new ArrayList[m]; for ( int i = 0;(i < m);i++) {list[i] = new ArrayList<>(); }for ( int i = 1;(i <= n);i++) {arr[i] = sc.nextInt(); size[(arr[i] % m)]++; list[(arr[i] % m)].add(i); } long tot = 0;  int x = 0,y = 0;  List<Integer> idx = new ArrayList<>(); for ( int i = 0;(i < (2 * m));i++) {if ( (size[(i % m)] > req)) {for ( int j = 0;(j < (size[(i % m)] - req));j++) {idx.add(list[(i % m)].get(j)); y++; }size[(i % m)] = req; } else if ( (size[(i % m)] < req)) {while(((x != y) && (size[(i % m)] < req))){ int num = arr[idx.get(x)];  int gg = (i - (num % m)); tot += gg; arr[idx.get(x)] += gg; x++; size[(i % m)]++; }} }System.out.println(tot); for ( int i = 1;(i <= n);i++) {System.out.print((arr[i] + " ")); }} }
1	public class Main{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  StringBuilder sb = new StringBuilder();  long[] a = new long[(n / 2)]; for ( int i = 0;(i < (n / 2));i++) {a[i] = s.nextLong(); } int j = 0;  long[] a2 = new long[(n / 2)];  long[] a1 = new long[(n / 2)]; a1[j] = (a[(a.length - 1)] / 2); a2[j] = (a[(a.length - 1)] - (a[(a.length - 1)] / 2)); for ( int i = (((n - 1) / 2) - 1);(i >= 0);i--) { long n1 = a1[j]; if ( ((a[i] - n1) < a2[j])) {a2[(j + 1)] = a2[j++]; a1[j] = (a[i] - a2[j]); } else {a1[++j] = n1; a2[j] = (a[i] - n1); }} int k = 0; for ( int i = ((n - 1) / 2);(i >= 0);i--) sb.append((a1[i] + " ")); for ( int i = 0;(i < (n / 2));i++) sb.append((a2[i] + " ")); System.out.println(sb.toString()); } }
1	public class Practice{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); sc.nextLine(); String s = sc.nextLine();  char c[] = s.toCharArray();  ArrayList a = new ArrayList(); for ( int i = 0;(i < c.length);i++) {a.add(c[i]); } int x = Collections.frequency(a,'0');  int y = Collections.frequency(a,'1'); if ( ((y == 0) || (y == 1))) {System.out.println(s); } else {if ( (y >= 2)) { String s1 = "1"; for ( int i = 0;(i < x);i++) {s1 = (s1 + "0"); }System.out.println(s1); } }} }
5	public class AA{ static class Pair implements Comparable<Pair>{ public int x ,y ; public Pair( int x, int y){ this.x = x; this.y = y; } } public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int t = (in.nextInt() * 2);  List<Pair> l = new ArrayList<Pair>(); for ( int i = 0;(i < n);i++) { int c = (in.nextInt() * 2);  int a = in.nextInt(); l.add(new Pair((c - a),(c + a))); }Collections.sort(l); int ret = 2; for ( int i = 1;(i < n);i++) {if ( ((l.get(i).x - l.get((i - 1)).y) > t)) ret += 2; else if ( ((l.get(i).x - l.get((i - 1)).y) == t)) ret += 1; }System.out.println(ret); } }
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(); } } }
6	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int V = in.nextInt();  int E = in.nextInt();  boolean[][] G = new boolean[V][V]; for ( int i = 0;(i < E);i++) { int u = (in.nextInt() - 1);  int v = (in.nextInt() - 1); G[u][v] = true; G[v][u] = true; } int pset = (1 << V);  long[][] dp = new long[pset][V];  long cycles = 0; for ( int set = 1;(set < pset);set++) { int bit = Integer.bitCount(set);  int src = first(set); if ( (bit == 1)) {dp[set][src] = 1; } else if ( (bit > 1)) {for ( int i = 0;(i < V);i++) {if ( (i == src)) continue; if ( ((set & (1 << i)) != 0)) { int S_1 = (set ^ (1 << i)); for ( int v = 0;(v < V);v++) {if ( (G[v][i] == true)) {dp[set][i] += dp[S_1][v]; } }} if ( ((bit >= 3) && G[src][i])) {cycles += dp[set][i]; } }} }System.out.println((cycles / 2)); } public static int first( int n){ int cnt = 0; while(((n & 1) != 1)){cnt++; n >>= 1; }return cnt;} }
3	public class Codeshefcode{ public static void main( String[] args)throws IOException { Solver Machine = new Solver(); Machine.Solve(); Machine.Finish(); } } class Solver{ Reader ip = new Reader(System.in); PrintWriter op = new PrintWriter(System.out); long dp[][] ; public void Solve()throws IOException { int n = ip.i();  int arr[] = new int[n]; dp = new long[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) dp[i][j] = -1; for ( int i = 0;(i < n);i++) { String s = ip.s(); if ( (s.compareTo("s") == 0)) arr[i] = 0; else if ( (s.compareTo("f") == 0)) arr[i] = 1; else throw (new IOException());}for ( int j = 0;(j < n);j++) dp[(n - 1)][j] = 1; for ( int i = (n - 2);(i >= 0);i--) { long cuml[] = new long[n]; for ( int j = 0;(j < n);j++) cuml[j] = ((dp[(i + 1)][j] + ((j == 0)?0:cuml[(j - 1)])) % Mod.mod); for ( int j = 0;(j < n);j++) dp[i][j] = ((arr[i] == 0)?cuml[j]:((j == (n - 1))?-1:dp[(i + 1)][(j + 1)])); }pln(dp[0][0]); } void Finish(){ op.flush(); op.close(); } void pln( Object o){ op.println(o); } } class Reader{ BufferedReader reader ; StringTokenizer tokenizer ; Reader( InputStream input){ reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); } String s()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} int i()throws IOException { return Integer.parseInt(s());} }
2	public class ReallyBigNums{ static private long[] factorArray( long s){ int d = 0;  long n = s;  long f = 1; while((n > 0)){n = (n / 10); d++; f = (f * 10); } long[] fact = new long[(d + 1)]; n = s; for ( int i = d;(i >= 0);i--) {if ( (f == 1)) fact[i] = n; else {fact[i] = (n / (f - 1)); n = (n % (f - 1)); f = (f / 10); }} int carry = 0; for ( int i = 0;(i <= d);i++) {fact[i] = (fact[i] + carry); if ( ((fact[i] > 9) || ((i == 0) && (fact[i] > 0)))) {fact[i] = 0; carry = 1; for ( int j = (i - 1);(j >= 0);j--) {fact[j] = 0; }} else {carry = 0; }}return fact;} static private long bigNumCount( long n, long s){ if ( (s >= n)) return 0; if ( (s == 0)) return n; long[] fact = factorArray(s);  long startNum = 0;  int len = fact.length;  long tenPow = 1; for ( int i = 0;(i < len);i++) {startNum = (startNum + (tenPow * fact[i])); tenPow = (tenPow * 10); }return Math.max(0,((n - startNum) + 1));} static private 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 r = new FastReader();  long n = r.nextLong();  long s = r.nextLong(); System.out.println(bigNumCount(n,s)); } }
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);  TaskG2 solver = new TaskG2(); solver.solve(1,in,out); out.close(); } static class TaskG2{ static final int MOD = (1000000000 + 7); static final int MAXN = 51; int getWays( int i, int j, int k, int l, int[][][][] ways, boolean[][][][] cached){ if ( (((i + j) + k) == 0)) return ((l == -1)?1:0); if ( (l < 0)) return 0; if ( cached[i][j][k][l]) return ways[i][j][k][l]; int s = ((i + j) + k);  long value = 0; if ( ((l == 0) && (i != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays((i - 1),j,k,x,ways,cached); } } if ( ((l == 1) && (j != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays(i,(j - 1),k,x,ways,cached); } } if ( ((l == 2) && (k != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays(i,j,(k - 1),x,ways,cached); } } ways[i][j][k][l] = (int)(value % MOD); cached[i][j][k][l] = true; return ways[i][j][k][l];} int totalWays( int i, int j, int k, int[][][][] ways, boolean[][][][] cached, int[] factorial){ long ret = 0; for ( int l = 0;(l < 3);l++) ret += getWays(i,j,k,l,ways,cached); ret *= factorial[i]; ret %= MOD; ret *= factorial[j]; ret %= MOD; ret *= factorial[k]; ret %= MOD; return (int)ret;} int add( int type, int value, int[] sizes, int sum, int[][][][] dp){ sizes[type]++; if ( (type == 0)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 1;(i <= sizes[0]);i++) for ( int j = 0;(j <= sizes[1]);j++) for ( int k = 0;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[(i - 1)][j][k][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} if ( (type == 1)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 0;(i <= sizes[0]);i++) for ( int j = 1;(j <= sizes[1]);j++) for ( int k = 0;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[i][(j - 1)][k][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} if ( (type == 2)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 0;(i <= sizes[0]);i++) for ( int j = 0;(j <= sizes[1]);j++) for ( int k = 1;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[i][j][(k - 1)][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} return (sum + value);} public void solve( int testNumber, InputReader in, OutputWriter out){ int[][][][] ways = new int[MAXN][MAXN][MAXN][3];  boolean[][][][] cached = new boolean[MAXN][MAXN][MAXN][3];  int n = in.nextInt(),T = in.nextInt();  ArrayList<Integer>[] ar = new ArrayList[3]; for ( int i = 0;(i < 3);i++) ar[i] = new ArrayList<Integer>(); int total_sum = 0; for ( int i = 0;(i < n);i++) { int t = in.nextInt(),g = in.nextInt(); ar[(g - 1)].add(t); total_sum += t; }if ( (T > total_sum)) {out.println(0); return ;} int min_index = 0,mn = 100000000; for ( int i = 0;(i < 3);i++) {if ( (ar[i].size() < mn)) {mn = ar[i].size(); min_index = i; } } int[][][][] dp = new int[(ar[((1 + min_index) % 3)].size() + 1)][(ar[((2 + min_index) % 3)].size() + 1)][(mn + 1)][(total_sum + 1)]; dp[0][0][0][0] = 1; int[] sizes = {0,0,0};  int sum = 0;  int[] order = {((min_index + 1) % 3),((min_index + 2) % 3),min_index};  int type = 0; for ( int i :order) {for ( int v :ar[i]) sum = add(type,v,sizes,sum,dp); type++; } int[] factorial = new int[MAXN]; factorial[0] = 1; for ( int i = 1;(i < MAXN);i++) factorial[i] = (int)(((factorial[(i - 1)] * 1L) * i) % MOD); long answer = 0; for ( int i = 0;(i < dp.length);i++) for ( int j = 0;(j < dp[0].length);j++) for ( int k = 0;(k < dp[0][0].length);k++) {answer += ((dp[i][j][k][T] * 1L) * totalWays(i,j,k,ways,cached,factorial)); answer %= MOD; }out.println(answer); } } 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); } } 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 println( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }writer.print('\n'); } public void close(){ writer.close(); } } }
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); } 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 = Integer.bitCount(mask);  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 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; }
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)); } }
4	public class mC{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  StringBuilder st = new StringBuilder();  int t = 1; for ( int test = 0;(test < t);test++) { int n = sc.nextInt();  int MOD = sc.nextInt();  long[] factorial = new long[1000];  long[] powerOfTwo = new long[1000]; factorial[0] = 1; powerOfTwo[0] = 1; for ( int i = 1;(i < 1000);i++) {factorial[i] = (i * factorial[(i - 1)]); factorial[i] %= MOD; powerOfTwo[i] = (2 * powerOfTwo[(i - 1)]); if ( (powerOfTwo[i] >= MOD)) {powerOfTwo[i] -= MOD; } } long[] oneOverFactorial = new long[500]; oneOverFactorial[0] = 1; oneOverFactorial[1] = 1; for ( int i = 2;(i < 450);i++) {oneOverFactorial[i] = fastPow(factorial[i],(MOD - 2),MOD); } long dp[][] = new long[(n + 3)][(n + 3)]; dp[1][1] = 1; for ( int i = 2;(i <= n);i++) {dp[i][i] = powerOfTwo[(i - 1)]; for ( int j = 1;(j < (i - 1));j++) {for ( int k = 1;(k <= j);k++) { long add = (dp[j][k] * factorial[(k + ((i - j) - 1))]); add %= MOD; add *= oneOverFactorial[k]; add %= MOD; add *= oneOverFactorial[((i - j) - 1)]; add %= MOD; add *= powerOfTwo[((i - j) - 2)]; add %= MOD; dp[i][(k + ((i - j) - 1))] += add; dp[i][(k + ((i - j) - 1))] %= MOD; }}} long ans = 0; for ( int i = 1;(i <= n);i++) {ans += dp[n][i]; }ans %= MOD; System.out.println(ans); }} public static int findNthInArray( int[] arr, int val, int start, int o){ if ( (o == 0)) {return (start - 1);} else if ( (arr[start] == val)) {return findNthInArray(arr,val,(start + 1),(o - 1));} else {return findNthInArray(arr,val,(start + 1),o);}} public static ArrayList<Integer> dfs( int at, ArrayList<Integer> went, ArrayList<ArrayList<Integer>> connect){ for ( int i = 0;(i < connect.get(at).size());i++) {if ( !went.contains(connect.get(at).get(i))) {went.add(connect.get(at).get(i)); went = dfs(connect.get(at).get(i),went,connect); } }return went;} public static int[] bfs( int at, int[] went, ArrayList<ArrayList<Integer>> queue, int numNodes, ArrayList<ArrayList<Integer>> connect){ if ( (went[at] == 0)) {went[at] = queue.get(numNodes).get(1); for ( int i = 0;(i < connect.get(at).size());i++) {if ( (went[connect.get(at).get(i)] == 0)) { ArrayList<Integer> temp = new ArrayList<>(); temp.add(connect.get(at).get(i)); temp.add((queue.get(numNodes).get(1) + 1)); queue.add(temp); } }} if ( (queue.size() == (numNodes + 1))) {return went;} else {return bfs(queue.get((numNodes + 1)).get(0),went,queue,(numNodes + 1),connect);}} public static long fastPow( long base, long exp, long mod){ if ( (exp == 0)) {return 1;} else {if ( ((exp % 2) == 1)) { long z = fastPow(base,((exp - 1) / 2),mod); return ((((z * base) % mod) * z) % mod);} else { long z = fastPow(base,(exp / 2),mod); return ((z * z) % mod);}}} public static int fastPow( int base, long exp){ if ( (exp == 0)) {return 1;} else {if ( ((exp % 2) == 1)) { int z = fastPow(base,((exp - 1) / 2)); return ((z * base) * z);} else { int z = fastPow(base,(exp / 2)); return (z * z);}}} public static int firstLarger( long val, ArrayList<Long> ok, int left, int right){ if ( (ok.get(right) <= val)) {return -1;} if ( (left == right)) {return left;} else if ( ((left + 1) == right)) {if ( (val < ok.get(left))) {return left;} else {return right;}} else { int mid = ((left + right) / 2); if ( (ok.get(mid) > val)) {return firstLarger(val,ok,left,mid);} else {return firstLarger(val,ok,(mid + 1),right);}}} public static int binSearchArr( long val, ArrayList<Integer> ok, long[] arr, int left, int right){ if ( (arr[ok.get(right)] <= val)) {return -1;} if ( (left == right)) {return left;} else if ( ((left + 1) == right)) {if ( (val < arr[ok.get(left)])) {return left;} else {return right;}} else { int mid = ((left + right) / 2); if ( (arr[ok.get(mid)] > val)) {return binSearchArr(val,ok,arr,left,mid);} else {return binSearchArr(val,ok,arr,(mid + 1),right);}}} public static long gcd( long a, long b){ if ( (b > a)) {return gcd(b,a);} if ( (b == 0)) {return a;} if ( ((a % b) == 0)) {return b;} else {return gcd(b,(a % b));}} }
1	public class Main{ void run()throws IOException { int n = in.nextInt();  char[] c = in.next().toCharArray();  int[][] t = new int[n][n];  int[][] h = new int[n][n];  int allt = 0,allh = 0; for ( int i = 0;(i < n);i++) {if ( (c[i] == 'T')) {allt++; } else {allh++; }}for ( int i = 0;(i < n);i++) {if ( (c[i] == 'T')) {t[i][i] = 1; h[i][i] = 0; } else {t[i][i] = 0; h[i][i] = 1; }for ( int j = (i + 1);(j < n);j++) {if ( (c[j] == 'T')) {t[i][j] = (t[i][(j - 1)] + 1); h[i][j] = h[i][(j - 1)]; } else {h[i][j] = (h[i][(j - 1)] + 1); t[i][j] = t[i][(j - 1)]; }}}for ( int i = 1;(i < n);i++) {t[i][(i - 1)] = allt; h[i][(i - 1)] = allh; for ( int j = 0;(j < (i - 1));j++) {t[i][j] = (allt - t[(j + 1)][(i - 1)]); h[i][j] = (allh - h[(j + 1)][(i - 1)]); }} int r = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (h[i][j] == t[((j + 1) % n)][(((i - 1) + n) % n)])) {r = min(r,h[i][j]); } if ( (t[i][j] == h[((j + 1) % n)][(((i - 1) + n) % n)])) {r = min(r,t[i][j]); } }}out.println(r); } static PrintWriter out ; static Scanner in ; public static void main( String[] args)throws IOException { Locale.setDefault(Locale.US); in = new Scanner(System.in); out = new PrintWriter(System.out); new Main().run(); out.close(); } }
6	public class C{ static Point hand ; static int n ; static Point[] data ; static int[] next ; static int[] dp ; static int[][] pre ; public static void main( String[] args){ Scanner in = new Scanner();  PrintWriter out = new PrintWriter(System.out); hand = new Point(in.nextInt(),in.nextInt()); n = in.nextInt(); data = new Point[n]; for ( int i = 0;(i < n);i++) {data[i] = new Point(in.nextInt(),in.nextInt()); }pre = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {pre[i][j] = distance(data[i],data[j]); }}next = new int[(1 << n)]; dp = new int[(1 << n)]; Arrays.fill(dp,-1); out.println(cal(0)); int start = 0; do { int m = next[start];  int val = (m - start); out.print((0 + " ")); for ( int i = 0;(i < n);i++) {if ( (((1 << i) & val) != 0)) {out.print(((i + 1) + " ")); } }start = m; }while((start != ((1 << n) - 1)));out.println(0); out.close(); } public static int cal( int mask){ if ( (((1 << n) - 1) == mask)) {return 0;} if ( (dp[mask] != -1)) {return dp[mask];} int result = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & mask) == 0)) { int dist = distance(hand,data[i]); for ( int j = (i + 1);(j < n);j++) {if ( (((1 << j) & mask) == 0)) { int temp = (((dist + distance(hand,data[j])) + pre[i][j]) + cal(((mask | (1 << i)) | (1 << j)))); if ( (temp < result)) {result = temp; next[mask] = ((mask | (1 << i)) | (1 << j)); } } } int temp = ((2 * dist) + cal((mask | (1 << i)))); if ( (temp < result)) {result = temp; next[mask] = (mask | (1 << i)); } break;} }dp[mask] = result; return result;} static int distance( Point a, Point b){ int total = (((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y))); return total;} static class Point{ int x ,y ; public Point( int x, int y){ this.x = x; this.y = y; } } 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());} } }
3	public class A{ public void realMain()throws Exception { BufferedReader fin = new BufferedReader(new InputStreamReader(System.in),1000000);  String in = fin.readLine();  String[] ar = in.split(" ");  int n = Integer.parseInt(ar[0]);  int[] a = new int[n]; for ( int i = 0;(i < n);i++) { int ret = 0;  boolean dig = false; for ( int ch = 0;((ch = fin.read()) != -1);) {if ( ((ch >= '0') && (ch <= '9'))) {dig = true; ret = (((ret * 10) + ch) - '0'); } else if ( dig) break; }a[i] = ret; } int ret = 0; Arrays.sort(a); boolean[] colored = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !colored[i]) {ret++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {colored[j] = true; } }} }System.out.println(ret); } public static void main( String[] args)throws Exception { A a = new A(); a.realMain(); } }
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); }} }
5	public class A{ int n ,m ,k ; int[] a ; void run()throws IOException { Scanner sc = new Scanner(new InputStreamReader(System.in)); n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); if ( (m <= k)) {System.out.println(0); return ;} int cnt = k;  int ind = (a.length - 1);  int ret = 0; while(((cnt < m) && (ind >= 0))){cnt += (a[ind] - 1); --ind; ret++; }if ( (cnt >= m)) System.out.println(ret); else System.out.println(-1); } public static void main( String[] args)throws IOException { new A().run(); } }
4	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int t = sc.nextInt(); for ( int tc = 0;(tc < t);++tc) { int n = sc.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < a.length);++i) {a[i] = sc.nextInt(); }System.out.println(solve(a)); }sc.close(); } static String solve( int[] a){ List<String> result = new ArrayList<>();  Stack<Integer> stack = new Stack<>(); for ( int ai :a) {if ( (ai != 1)) {while(((stack.peek() + 1) != ai)){stack.pop(); }stack.pop(); } stack.push(ai); result.add(stack.stream().map(String::valueOf).collect(Collectors.joining("."))); }return String.join("\n",result);} }
5	public class A{ public static void main( String[] args){ A problem = new A(); problem.solve(); } private void solve(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int p = sc.nextInt();  int v = sc.nextInt();  long a[] = new long[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextLong(); } long aux ; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a > a)) {aux = a[j]; a[j] = a[i]; a[i] = aux; } }}System.out.println((a[v] - a[(v - 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 Main{ static final int primeCount = 452; static final int[] prime = new int[primeCount]; static void build_prime(){ boolean[] notPrime = new boolean[3200]; for ( int i = 2;(i < 3200);i++) {if ( notPrime[i]) continue; for ( int j = (i * i);(j < 3200);j += i) {notPrime[j] = true; }} int count = 0; for ( int i = 2;(i < 3200);i++) {if ( notPrime[i]) continue; prime[count++] = i; }} static private void run( Reader in, PrintWriter out)throws IOException { int n = in.nextInt();  int m = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = getReal(in.nextInt()); } int[] pre = new int[n]; for ( int i = 0;(i < n);i++) pre[i] = -1; TreeMap<Integer,Integer> exist = new TreeMap<>(); for ( int i = 0;(i < n);i++) { Integer result = exist.get(a[i]); if ( (result != null)) {pre[i] = result; } exist.put(a[i],i); } int[][] left = new int[(m + 1)][n]; for ( int i = 0;(i <= m);i++) { int start = 0;  PriorityQueue<Integer> inSame = new PriorityQueue<>(); for ( int j = 0;(j < n);j++) {if ( (pre[j] >= start)) {inSame.add(pre[j]); if ( (inSame.size() > i)) {start = (inSame.poll() + 1); } } left[i][j] = start; }} int[][] dp = new int[n][(m + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= m);j++) {if ( (j == 0)) dp[i][0] = Integer.MAX_VALUE; else dp[i][j] = dp[i][(j - 1)]; for ( int k = 0;(k <= j);k++) {if ( (left[k][i] == 0)) {dp[i][j] = 1; } else {dp[i][j] = Math.min(dp[i][j],(dp[(left[k][i] - 1)][(j - k)] + 1)); }}}}out.println(dp[(n - 1)][m]); } static int getReal( int x){ int result = 1; for ( int i = 0;(i < primeCount);i++) {if ( ((x % prime[i]) == 0)) { int count = 0; while(((x % prime[i]) == 0)){count++; x /= prime[i]; }if ( ((count % 2) == 1)) {result *= prime[i]; } } }result *= x; return result;} public static void main( String[] args)throws IOException { Reader in = new Reader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); build_prime(); int t = in.nextInt(); for ( int i = 0;(i < t);i++) {run(in,out); }out.flush(); in.close(); out.close(); } static class Reader{ BufferedReader reader ; StringTokenizer st ; Reader( InputStreamReader stream){ reader = new BufferedReader(stream,32768); st = null; } void close()throws IOException { reader.close(); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
2	public class Template{ public static void main( String[] args)throws IOException { st = new StringTokenizer(rd.readLine()); n = Long.parseLong(st.nextToken()); m = Long.parseLong(st.nextToken()); k = Long.parseLong(st.nextToken()); long s = (n - m); s = Math.min(s,(m / (k - 1))); s = Math.min(s,(n / k)); long score = 0; score = ((s * (k - 1)) % P); long n1 = (n - (k * s)),m1 = (m - ((k - 1) * s)); sc = 0; if ( (m1 == n1)) {score = ((score + full(m1)) % P); System.out.println(score); return ;} score = ((score + m1) % P); System.out.println(score); } static long full( long N){ long x = (N / k),r = (N - (x * k));  long powTwo = ((powMod(2,(x + 1)) - 2) + (2 * P)); powTwo %= P; powTwo = ((powTwo * k) % P); powTwo = ((powTwo + r) % P); return powTwo;} static long sc = 0; static void rec( long N, long M){ if ( (N == M)) {sc = ((sc + full(N)) % P); return ;} if ( ((N >= k) && (M >= (k - 1)))) {sc = ((sc + (k - 1)) % P); rec((N - k),(M - (k - 1))); return ;} sc = ((sc + M) % P); } static long powMod( long a, long p){ if ( (p == 0)) return 1L; long h = powMod(a,(p >> 1)); h = ((h * h) % P); return (((p % 2) == 0)?h:((a * h) % P));} static long n ,m ,k ; static long P = 1000000009; static StringTokenizer st ; static BufferedReader rd = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pw = new PrintWriter(System.out); }
2	public class B{ static PrintWriter out = new PrintWriter(System.out); static FS in ; static int N ; static final boolean debug = false; static int inp[] = new int[]{1,2,3,2,1,0}; public static void main( String[] args){ in = new FS(); if ( !debug) N = in.nextInt(); else N = inp.length; int x = solve(0,((N / 2) - 1),(N / 2),(N - 1)); out.println(("! " + (x + 1))); out.flush(); out.close(); } static int solve( int l1, int r1, int l2, int r2){ int sz = ((r1 - l1) + 1); if ( (sz <= 0)) return -2; int a1 = query(l1);  int a2 = query(l2); if ( (a1 == a2)) return l1; if ( (sz == 1)) return -2; int b1 = query((l1 + (sz / 2)));  int b2 = query((l2 + (sz / 2))); if ( (b1 == b2)) return (l1 + (sz / 2)); if ( (sz == 2)) return -2; int d1 = (a2 - a1);  int d2 = (b2 - b1); if ( (((d1 < 0) && (d2 > 0)) || ((d1 > 0) && (d2 < 0)))) {return solve((l1 + 1),((l1 + (sz / 2)) - 1),(l2 + 1),((l2 + (sz / 2)) - 1));} else {return solve(((l1 + (sz / 2)) + 1),r1,((l2 + (sz / 2)) + 1),r2);}} static int query( int a){ out.println(("? " + (a + 1))); out.flush(); if ( debug) return inp[a]; else return in.nextInt();} 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());} } }
0	public class C994{ static double area( double x1, double y1, double x2, double y2, double x3, double y3){ return Math.abs(((((x1 * (y2 - y3)) + (x2 * (y3 - y1))) + (x3 * (y1 - y2))) / 2.0));} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  PrintWriter pw = new PrintWriter(System.out);  int x11 = sc.nextInt();  int y11 = sc.nextInt();  int x12 = sc.nextInt();  int y12 = sc.nextInt();  int x13 = sc.nextInt();  int y13 = sc.nextInt();  int x14 = sc.nextInt();  int y14 = sc.nextInt();  double x1c = ((((x11 + x12) + x13) + x14) / 4.0);  double y1c = ((((y11 + y12) + y13) + y14) / 4.0);  int x21 = sc.nextInt();  int y21 = sc.nextInt();  int x22 = sc.nextInt();  int y22 = sc.nextInt();  int x23 = sc.nextInt();  int y23 = sc.nextInt();  int x24 = sc.nextInt();  int y24 = sc.nextInt();  double x2c = ((((x21 + x22) + x23) + x24) / 4.0);  double y2c = ((((y21 + y22) + y23) + y24) / 4.0);  double a1 = (area(x11,y11,x12,y12,x13,y13) + area(x11,y11,x13,y13,x14,y14));  double a2 = (area(x21,y21,x22,y22,x23,y23) + area(x21,y21,x23,y23,x24,y24)); if ( (a1 == (((area(x11,y11,x12,y12,x21,y21) + area(x11,y11,x21,y21,x14,y14)) + area(x21,y21,x12,y12,x13,y13)) + area(x21,y21,x14,y14,x13,y13)))) {pw.println("YES"); pw.close(); return ;} if ( (a1 == (((area(x11,y11,x12,y12,x22,y22) + area(x11,y11,x22,y22,x14,y14)) + area(x22,y22,x12,y12,x13,y13)) + area(x22,y22,x14,y14,x13,y13)))) {pw.println("YES"); pw.close(); return ;} if ( (a1 == (((area(x11,y11,x12,y12,x23,y23) + area(x11,y11,x23,y23,x14,y14)) + area(x23,y23,x12,y12,x13,y13)) + area(x23,y23,x14,y14,x13,y13)))) {pw.println("YES"); pw.close(); return ;} if ( (a1 == (((area(x11,y11,x12,y12,x24,y24) + area(x11,y11,x24,y24,x14,y14)) + area(x24,y24,x12,y12,x13,y13)) + area(x24,y24,x14,y14,x13,y13)))) {pw.println("YES"); pw.close(); return ;} if ( (a1 == (((area(x11,y11,x12,y12,x2c,y2c) + area(x11,y11,x2c,y2c,x14,y14)) + area(x2c,y2c,x12,y12,x13,y13)) + area(x2c,y2c,x14,y14,x13,y13)))) {pw.println("YES"); pw.close(); return ;} if ( (a2 == (((area(x21,y21,x22,y22,x11,y11) + area(x21,y21,x11,y11,x24,y24)) + area(x11,y11,x22,y22,x23,y23)) + area(x11,y11,x24,y24,x23,y23)))) {pw.println("YES"); pw.close(); return ;} if ( (a2 == (((area(x21,y21,x22,y22,x12,y12) + area(x21,y21,x12,y12,x24,y24)) + area(x12,y12,x22,y22,x23,y23)) + area(x12,y12,x24,y24,x23,y23)))) {pw.println("YES"); pw.close(); return ;} if ( (a2 == (((area(x21,y21,x22,y22,x13,y13) + area(x21,y21,x13,y13,x24,y24)) + area(x13,y13,x22,y22,x23,y23)) + area(x13,y13,x24,y24,x23,y23)))) {pw.println("YES"); pw.close(); return ;} if ( (a2 == (((area(x21,y21,x22,y22,x14,y14) + area(x21,y21,x14,y14,x24,y24)) + area(x14,y14,x22,y22,x23,y23)) + area(x14,y14,x24,y24,x23,y23)))) {pw.println("YES"); pw.close(); return ;} if ( (a2 == (((area(x21,y21,x22,y22,x1c,y1c) + area(x21,y21,x14,y14,x2c,y2c)) + area(x1c,y1c,x22,y22,x23,y23)) + area(x1c,y1c,x24,y24,x23,y23)))) {pw.println("YES"); pw.close(); return ;} pw.println("NO"); pw.close(); } }
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(); } }
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(); } static private 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;} }
3	public class c{ public static void main( String[] args)throws Exception { new c(new Reader()); } public c( Reader rr)throws IOException{ int n = rr.ni();  double r = rr.nd();  HashMap<Integer,Double> disk = new HashMap<Integer,Double>(); for ( int i = 0;(i < n);i++) { int next = rr.ni(); if ( disk.isEmpty()) {disk.put(next,r); System.out.print((r + " ")); } else { double high = r; for ( Map.Entry<Integer,Double> it :disk.entrySet()) {if ( ((2 * r) < (next - it.getKey()))) continue; double tempHigh = (pyth(Math.abs((next - it.getKey())),(r * 2)) + it.getValue()); if ( (tempHigh > high)) {high = tempHigh; } }disk.put(next,high); System.out.print((high + " ")); }}} public double pyth( double a, double c){ return Math.sqrt((Math.pow(c,2) - Math.pow(a,2)));} static class Reader{ private DataInputStream din ; private byte[] buffer = new byte[1024]; private int bufP ,bytR ; public Reader()throws IOException{ din = new DataInputStream(System.in); bufP = bytR = 0; } public Reader( String file)throws IOException{ din = new DataInputStream(new FileInputStream(file)); bufP = bytR = 0; } private int ni()throws IOException { int num = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); do {num = (((num * 10) + c) - '0'); }while((((c = read()) >= '0') && (c <= '9')));if ( neg) return -num; return num;} private double nd()throws IOException { return Double.parseDouble(ns());} private String ns()throws IOException { int c = next();  StringBuilder sb = new StringBuilder(); while(!isChar(c)){sb.appendCodePoint(c); c = read(); }return sb.toString();} private char[] ns( int n)throws IOException { char[] buf = new char[n];  int c = next(),r = 0; while(((r < n) && !isChar(c))){buf[r++] = (char)c; c = next(); }return ((n == r)?buf:Arrays.copyOf(buf,r));} private boolean isChar( int c)throws IOException { return ((c >= 33) && (c <= 126));} private int next()throws IOException { int c ; while((((c = read()) != -1) && isChar(c)));return c;} private byte read()throws IOException { if ( (bufP == bytR)) {bytR = din.read(buffer,bufP = 0,1024); if ( (bytR == -1)) buffer[0] = -1; } return buffer[bufP++];} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } }
2	@SuppressWarnings("Duplicates") public class C817{ private FastScanner in ; private PrintWriter out ; private long calcSum( long x){ int ans = 0; while((x > 0)){ans += (x % 10); x /= 10; }return ans;} private long calcDiff( long x){ return (x - calcSum(x));} private long binSearch( long n, long s){ long l = 0;  long r = (n + 1); while(((r - l) > 1)){ long m = ((r + l) >> 1); if ( (calcDiff(m) >= s)) {r = m; } else {l = m; }}return l;} private void solve()throws IOException { long n = in.nextLong();  long s = in.nextLong();  long ans = binSearch(n,s); out.println((n - ans)); } private void run(){ try{in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream f){ br = new BufferedReader(new InputStreamReader(f)); } FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } String next(){ while(((st == null) || !st.hasMoreTokens())){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[] arg){ new C817().run(); } }
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 A{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  String l[] = bf.readLine().split(" "); System.out.println(25); } }
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 ,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_]; 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 * 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();  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; 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 C{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = na(n); for ( int i = 0;(i < n);i++) { int v = a[i]; for ( int j = 2;((j * j) <= v);j++) {while(((v % (j * j)) == 0)){v /= (j * j); }}a[i] = v; }Arrays.sort(a); int[] f = new int[n];  int p = 0; for ( int i = 0;(i < n);i++) {if ( ((i > 0) && (a[i] != a[(i - 1)]))) {p++; } f[p]++; }f = Arrays.copyOf(f,(p + 1)); int mod = 1000000007;  int[][] fif = enumFIF(1000,mod);  long[] res = countSameNeighborsSequence(f,fif,mod);  long ans = res[0]; for ( int v :f) {ans = ((ans * fif[0][v]) % mod); }out.println(ans); } public static int[][] enumFIF( int n, int mod){ int[] f = new int[(n + 1)];  int[] invf = new int[(n + 1)]; f[0] = 1; for ( int i = 1;(i <= n);i++) {f[i] = (int)(((long)f[(i - 1)] * i) % mod); } long a = f[n];  long b = mod;  long p = 1,q = 0; while((b > 0)){ long c = (a / b);  long d ; d = a; a = b; b = (d % b); d = p; p = q; q = (d - (c * q)); }invf[n] = (int)((p < 0)?(p + mod):p); for ( int i = (n - 1);(i >= 0);i--) {invf[i] = (int)(((long)invf[(i + 1)] * (i + 1)) % mod); }return new int[][]{f,invf};} public static long[] countSameNeighborsSequence( int[] a, int[][] fif, int mod){ int all = 0; for ( int v :a) all += v; int len = 0;  long[] dp = new long[(all + 1)]; dp[0] = 1; for ( int v :a) { long[][] pre = new long[(all + 1)][(v + 1)]; for ( int j = 0;(j <= all);j++) pre[j][0] = dp[j]; for ( int j = 0;(j < v);j++) {for ( int k = 0;(k <= all);k++) {for ( int L = j;(L >= 0);L--) {if ( (pre[k][L] == 0)) continue; int ca = (2 * (j - L));  int ab = (((((len + j) + 1) - k) - ca) - L); if ( (ab < 0)) continue; if ( ((k - 1) >= 0)) {pre[(k - 1)][L] += (pre[k][L] * k); pre[(k - 1)][L] %= mod; } if ( ((L + 1) <= v)) {pre[k][(L + 1)] += (pre[k][L] * (ca + L)); pre[k][(L + 1)] %= mod; } pre[k][L] = ((pre[k][L] * ab) % mod); }}}Arrays.fill(dp,0); for ( int k = 0;(k <= all);k++) {for ( int L = 0;((L <= v) && ((k + L) <= all));L++) {dp[(k + L)] += pre[k][L]; }}for ( int k = 0;(k <= all);k++) {dp[k] %= mod; }len += v; } long fifs = 1; for ( int v :a) fifs = ((fifs * fif[1][v]) % mod); for ( int k = 0;(k <= all);k++) dp[k] = ((dp[k] * fifs) % mod); return dp;} 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[] 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)); } }
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(); } }
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(); }} }
5	public class l{ static long mod = (int)(1e9 + 7); static int n ; static StringBuilder sol ; static boolean is ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int m = sc.nextInt();  int n = sc.nextInt();  int q = sc.nextInt();  TreeSet<Integer> length = new TreeSet<>(); length.add(0); length.add(n); TreeSet<Integer> width = new TreeSet<>(); width.add(0); width.add(m); TreeMap<Integer,Integer> len = new TreeMap<>(); len.put(n,1); TreeMap<Integer,Integer> wid = new TreeMap<>(); wid.put(m,1); while((q-- > 0)){ String t = sc.next(); if ( t.equals("H")) { int x = sc.nextInt();  int k1 = length.ceiling(x);  int k2 = length.floor(x); if ( (x != k1)) { int s = (k1 - k2);  int con = len.get(s); if ( (con == 1)) len.remove(s); else len.put(s,(con - 1)); len.put((k1 - x),(len.getOrDefault((k1 - x),0) + 1)); len.put((x - k2),(len.getOrDefault((x - k2),0) + 1)); length.add(x); } } else { int x = sc.nextInt();  int k1 = width.ceiling(x);  int k2 = width.floor(x); if ( (x != k1)) { int s = (k1 - k2);  int con = wid.get(s); if ( (con == 1)) wid.remove(s); else wid.put(s,(con - 1)); wid.put((k1 - x),(wid.getOrDefault((k1 - x),0) + 1)); wid.put((x - k2),(wid.getOrDefault((x - k2),0) + 1)); width.add(x); } }pw.println(((1l * len.lastKey()) * wid.lastKey())); }pw.flush(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( FileReader r){ br = new BufferedReader(r); } 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 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)); }} }
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.readInt();  boolean[] isF = new boolean[n]; for ( int i = 0;(i < n);i++) {isF[i] = (in.readCharacter() == 'f'); } long[][] mem = new long[(n + 1)][(n + 1)]; mem[n][0] = 1; for ( int idx = (n - 1);(idx >= 0);idx--) {for ( int indentLevel = 0;(indentLevel < n);indentLevel++) {mem[(idx + 1)][(indentLevel + 1)] += mem[(idx + 1)][indentLevel]; long res = (isF[idx]?(mem[(idx + 1)][(indentLevel + 1)] - mem[(idx + 1)][indentLevel]):mem[(idx + 1)][indentLevel]); mem[idx][indentLevel] = (res % MiscUtils.MOD7); }}out.printLine(mem[0][0]); } } 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 char readCharacter(){ int c = read(); while(isSpaceChar(c)){c = read(); }return (char)c;} 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( long i){ writer.println(i); } } }
2	public class Main{ static StreamTokenizer st = new StreamTokenizer(new BufferedInputStream(System.in)); static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter pr = new PrintWriter(new BufferedOutputStream(System.out)); static Scanner sc = new Scanner(System.in); public static void main( String[] args)throws NumberFormatException,IOException { int a = sc.nextInt();  int b = sc.nextInt();  int i = 0;  int cont = 0; while((cont < b)){i++; cont += i; }if ( (((i + cont) - b) == a)) {System.out.println((cont - b)); } else {while((((i + cont) - b) != a)){i++; cont += i; }System.out.println((cont - b)); }} static private int nextInt(){ try{st.nextToken(); }catch (IOException e){ e.printStackTrace(); } return (int)st.nval;} }
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));  StringTokenizer st = new StringTokenizer(f.readLine());  BigInteger l = new BigInteger(st.nextToken());  BigInteger r = new BigInteger(st.nextToken()); if ( ((r.subtract(l).intValue() < 2) || ((r.subtract(l).intValue() == 2) && (r.mod(new BigInteger("2")).intValue() == 1)))) out.println(-1); else out.println(((((l.add(l.mod(new BigInteger("2"))).toString() + " ") + l.add(l.mod(new BigInteger("2"))).add(new BigInteger("1")).toString()) + " ") + l.add(l.mod(new BigInteger("2"))).add(new BigInteger("2")).toString())); out.close(); System.exit(0); } }
4	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 M ; boolean[][] used ; Queue<Integer> queue ; int[] dx = {-1,0,1,0}; int[] dy = {0,-1,0,1}; int ans = -1; void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter("output.txt"); N = nextInt(); M = nextInt(); used = new boolean[N][M]; queue = new ArrayDeque<Integer>((N * M)); for ( int K = nextInt();(K-- > 0);) addState((nextInt() - 1),(nextInt() - 1)); while(!queue.isEmpty()){ int cv = queue.poll();  int cx = (cv / M);  int cy = (cv % M); for ( int d = 0;(d < dx.length);d++) { int nx = (cx + dx[d]);  int ny = (cy + dy[d]); if ( (((((0 <= nx) && (nx < N)) && (0 <= ny)) && (ny < M)) && !used[nx][ny])) addState(nx,ny); }}out.println((((1 + (ans / M)) + " ") + (1 + (ans % M)))); out.close(); } void addState( int x, int y){ used[x][y] = true; queue.add(ans = code(x,y)); } int code( int x, int y){ return ((x * M) + y);} 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 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 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());} }
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)); }} }
3	public class Main{ long MOD = 1000000007; InputReader in ; BufferedReader br ; PrintWriter out ; public static void main( String[] args)throws java.lang.Exception { Main solver = new Main(); solver.in = new InputReader(System.in); solver.br = new BufferedReader(new InputStreamReader(System.in)); solver.out = new PrintWriter(System.out); solver.solve(); solver.out.flush(); solver.out.close(); } public void solve(){ int tc = 1; for ( int cas = 1;(cas <= tc);cas++) { int N = in.readInt();  int[] A = new int[N]; in.readInt(A); int res = 0; for ( int i = 0;(i < N);i++) {for ( int j = (i + 1);(j < N);j++) {if ( (A[i] > A[j])) res++; }}res = (res % 2); int Q = in.readInt(); while((Q-- > 0)){ int l = in.readInt();  int r = in.readInt();  int add = (((r - l) + 1) / 2); res = (res + add); res %= 2; out.println((((res % 2) == 0)?"even":"odd")); }}} } 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 void readInt( int[] A){ for ( int i = 0;(i < A.length);i++) A[i] = readInt(); } 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 void readLong( long[] A){ for ( int i = 0;(i < A.length);i++) A[i] = readLong(); } 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); } }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ReaderFastIO in = new ReaderFastIO(inputStream);  PrintWriter out = new PrintWriter(outputStream);  DConcatenatedMultiples solver = new DConcatenatedMultiples(); solver.solve(1,in,out); out.close(); } static class DConcatenatedMultiples{ public void solve( int testNumber, ReaderFastIO in, PrintWriter out){ Map<Integer,Integer>[] mapMods = new HashMap[11];  int n = in.nextInt();  int k = in.nextInt();  int[] a = in.readArrayInt(n); for ( int i = 0;(i < 11);i++) {mapMods[i] = new HashMap<>(); }for ( int i = 0;(i < n);i++) { int pot = getPot(a[i]); mapMods[pot].put((a[i] % k),(mapMods[pot].getOrDefault((a[i] % k),0) + 1)); } long ct = 0; for ( int i = 0;(i < n);i++) { int ownPot = getPot(a[i]);  long suffix = (a[i] * 10L); for ( int j = 1;(j <= 10);j++) { int mod = (int)(suffix % k);  int comMod = ((k - mod) % k);  int qt = mapMods[j].getOrDefault(comMod,0); if ( ((j == ownPot) && ((a[i] % k) == comMod))) {qt--; } ct += qt; suffix = ((suffix * 10L) % k); }}out.println(ct); } public int getPot( int x){ int ct = 0; while((x != 0)){x /= 10; ct++; }return ct;} } static class ReaderFastIO{ BufferedReader br ; StringTokenizer st ; public ReaderFastIO(){ br = new BufferedReader(new InputStreamReader(System.in)); } public ReaderFastIO( InputStream input){ br = new BufferedReader(new InputStreamReader(input)); } 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 int[] readArrayInt( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = nextInt(); }return array;} } }
2	public class taskB{ StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args)throws NumberFormatException,IOException { taskB solver = new taskB(); solver.open(); long time = System.currentTimeMillis(); solver.solve(); if ( !"true".equals(System.getProperty("ONLINE_JUDGE"))) {System.out.println(("Spent time: " + (System.currentTimeMillis() - time))); System.out.println(("Memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()))); } 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());} long n ,x ,y ,c ; long sq( long n){ if ( (n <= 0)) return 0; return (n * n);} long lrsp( long len, long max){ long cnt = Math.min(len,max);  long arpr = (((1 + cnt) * cnt) / 2); if ( (len > max)) arpr += ((len - max) * max); return arpr;} long onn( long len){ long up ,down ,left ,right ;  long toup = (x - 1),todown = (n - x),toleft = (y - 1),toright = (n - y); left = Math.min(toleft,len); right = Math.min(toright,len); down = up = sq(len); up -= sq((len - toup)); down -= sq((len - todown)); len--; if ( (toright < len)) {up -= lrsp((len - toright),toup); down -= lrsp((len - toright),todown); } if ( (toleft < len)) {up -= lrsp((len - toleft),toup); down -= lrsp((len - toleft),todown); } return ((((1 + up) + down) + left) + right);} public void solve()throws NumberFormatException,IOException { n = nextInt(); x = nextInt(); y = nextInt(); c = nextInt(); long down = 0,up = ((2 * n) + 13); while(((up - down) > 2)){ long tmp = ((up + down) / 2); if ( (onn(tmp) >= c)) up = tmp; else down = tmp; }if ( (onn(down) >= c)) out.println(down); else if ( (onn((down + 1)) >= c)) out.println((down + 1)); else if ( (onn((down + 2)) >= c)) out.println((down + 2)); else out.println((down + 3)); } public void close(){ out.flush(); out.close(); } }
5	public final class Main implements Runnable{ static private 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); ; ; ; ; ; ; }
1	public class C{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(in.readLine());  char[] ps = in.readLine().toCharArray();  HashMap<Character,TreeSet<Integer>> locs = new HashMap<Character,TreeSet<Integer>>();  HashSet<Character> poks = new HashSet<Character>();  int lastNew = n; for ( int i = 0;(i < n);i++) {if ( !poks.contains(ps[i])) {poks.add(ps[i]); locs.put(ps[i],new TreeSet<Integer>()); lastNew = i; } locs.get(ps[i]).add(i); } int max = lastNew;  int minRange = (max + 1); for ( int min = 0;(min < n);min++) { char pAtMin = ps[min];  Integer nextInd = locs.get(pAtMin).higher(min); if ( (nextInd == null)) break; max = Math.max(max,nextInd); minRange = Math.min(minRange,(max - min)); }System.out.println(minRange); } }
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{ static private 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;} } }
5	public class _AAAA implements Runnable{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; OutputWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new _AAAA(),"",(128 * (1L << 20))).start(); } void init()throws FileNotFoundException { Locale.setDefault(Locale.US); if ( 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"); }} long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } String delim = " "; String readString()throws IOException { while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken(delim);} String readLine()throws IOException { return in.readLine();} final char NOT_A_SYMBOL = '\0'; int readInt()throws IOException { return Integer.parseInt(readString());} long readLong()throws IOException { return Long.parseLong(readString());} double readDouble()throws IOException { return Double.parseDouble(readString());} Point readPoint()throws IOException { return new Point(readInt(),readInt());} class OutputWriter extends PrintWriter{ final int DEFAULT_PRECISION = 12; int precision ; String format ,formatWithSpace ; {precision = DEFAULT_PRECISION; format = createFormat(precision); formatWithSpace = (format + " "); }public OutputWriter( OutputStream out){ super(out); } public OutputWriter( String fileName)throws FileNotFoundException{ super(fileName); } private String createFormat( int precision){ return (("%." + precision) + "f");} @Override public void print( double d){ printf(format,d); } public void printWithSpace( double d){ printf(formatWithSpace,d); } public 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); } public void printlnAll( double... d){ printAll(d); println(); } } int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; void solve()throws IOException { int n = readInt();  int k = readInt();  Map<Long,Integer> map = new TreeMap<Long,Integer>(); for ( int i = 0;(i < n);++i) {map.put(readLong(),i); } int ans = 0;  boolean[] used = new boolean[n]; for ( Map.Entry<Long,Integer> e :map.entrySet()) {if ( used[e.getValue()]) continue; long value = (e.getKey() * k);  Integer index = map.get(value); if ( (index != null)) {used[index] = true; } ++ans; }out.println(ans); } }
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());} }
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){ int n = in.nextInt(); if ( ((n % 2) == 0)) {out.println(("4 " + (n - 4))); } else {out.println(("9 " + (n - 9))); }} } class InputReader{ public BufferedReader reader ; private int tokenCount ,nextTokenIndex ; private String[] tokens ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenCount = nextTokenIndex = 0; } public String next(){ String nextLine ; if ( (nextTokenIndex == tokenCount)) {try{nextLine = reader.readLine(); nextTokenIndex = 0; tokens = nextLine.split("\\s"); tokenCount = tokens.length; }catch (IOException e){ throw (new RuntimeException(e));} } return tokens[nextTokenIndex++];} public int nextInt(){ return Integer.parseInt(next());} }
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(); } }
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)); } }
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)); } }
0	public class Main{ public static void main( String[] args){ InputReader in = new InputReader();  PrintWriter out = new PrintWriter(System.out); while(in.hasNext()){ long n = in.nextLong(); out.println("25"); }out.close(); } } class InputReader{ BufferedReader buf ; StringTokenizer tok ; InputReader(){ buf = new BufferedReader(new InputStreamReader(System.in)); } boolean hasNext(){ while(((tok == null) || !tok.hasMoreElements())){try{tok = new StringTokenizer(buf.readLine()); }catch (Exception e){ return false;} }return true;} String next(){ if ( hasNext()) return tok.nextToken(); return null;} long nextLong(){ return Long.parseLong(next());} }
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));} } }
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());} }
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; }} }
2	public class DD{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long k = Long.parseLong(br.readLine());  long ans = (9 * (int)Math.pow(10,0));  int c = 0;  long start = 0; while((k > ans)){c++; start = ans; ans += ((9 * (long)Math.pow(10,c)) * (c + 1)); } long ms = (((k - start) - 1) % (c + 1));  long a = ((long)Math.pow(10,c) + (((k - start) - 1) / (c + 1))); System.out.println((a + "")); } }
3	public class CFA{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; final long MOD = (((1000L * 1000L) * 1000L) + 7); int[] dx = {0,-1,0,1}; int[] dy = {1,0,-1,0}; void solve()throws IOException { int n = nextInt();  int[] arr = nextIntArr(n);  int cnt = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (arr[i] > arr[j])) {cnt++; } }} int m = nextInt();  boolean[] vis = new boolean[n]; for ( int i = 0;(i < m);i++) { int l = (nextInt() - 1);  int r = (nextInt() - 1);  int len = ((r - l) + 1); if ( ((((len * (len - 1)) / 2) % 2) != 0)) {cnt++; } if ( ((cnt % 2) != 0)) {outln("odd"); } else {outln("even"); }}} 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 int[] nextIntArr( int n)throws IOException { int[] res = new int[n]; for ( int i = 0;(i < n);i++) res[i] = nextInt(); return res;} 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 int nextInt()throws IOException { return Integer.parseInt(nextToken());} public long nextLong()throws IOException { return Long.parseLong(nextToken());} }
1	public class C{ public static void main( String[] arg)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.valueOf(in.readLine());  char[] s = in.readLine().toCharArray();  int i = 0,j = 0;  int[] ct = new int[256];  Set<Character> all = new HashSet<>(); for ( char c :s) {all.add(c); } int total = 0,res = Integer.MAX_VALUE; while((j < s.length)){while(((total < all.size()) && (j < s.length))){if ( (ct[s[j]] == 0)) {total++; } ct[s[j]]++; j++; }res = Math.min(res,(j - i)); while(((total == all.size()) && (i < s.length))){ct[s[i]]--; if ( (ct[s[i]] == 0)) {total--; } i++; if ( (total == all.size())) {res = Math.min(res,(j - i)); } }}System.out.println(res); } }
3	public class C{ int n ; char[] a ; long[][] memo ; long mod = ((long)1e9 + 7); boolean lastFor( int i){ if ( (i == 0)) return false; return (a[(i - 1)] == 'f');} long dp( int ind, int curIndent){ if ( (ind == n)) return 1; if ( (curIndent < 0)) return 0; if ( (memo[ind][curIndent] != -1)) return memo[ind][curIndent]; long ans = 0; if ( ((a[ind] == 'f') && lastFor(ind))) {ans += dp((ind + 1),(curIndent + 1)); } else if ( ((a[ind] == 'f') && !lastFor(ind))) {ans += dp(ind,(curIndent - 1)); ans += dp((ind + 1),(curIndent + 1)); } else if ( ((a[ind] == 's') && lastFor(ind))) {ans += dp((ind + 1),curIndent); } else if ( ((a[ind] == 's') && !lastFor(ind))) {ans += dp((ind + 1),curIndent); ans += dp(ind,(curIndent - 1)); } return memo[ind][curIndent] = (ans % mod);} public void solve( Scanner in, PrintWriter out){ n = in.nextInt(); a = new char[n]; int forCount = 0;  int[] fc = new int[(n + 1)]; for ( int i = 0;(i < n);++i) {a[i] = in.next().charAt(0); if ( (a[i] == 'f')) ++forCount; fc[i] = forCount; }fc[n] = fc[(n - 1)]; memo = new long[n][(forCount + 1)]; for ( long[] aa :memo) {Arrays.fill(aa,-1); }for ( int i = n;(i >= 0);--i) {for ( int indent = (fc[i] - 1);(indent >= 0);--indent) {dp(i,indent); }}out.println((dp(0,0) % mod)); } public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out); new C().solve(in,out); in.close(); out.close(); } }
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 Thread(){public void run(){ try{new Main().run(); }catch (IOException e){ e.printStackTrace(); } } }.start(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); private void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); boolean[] pr = new boolean[1001]; for ( int i = 2;(i <= 1000);i++) if ( !pr[i]) { int l = (2 * i); while((l <= 1000)){pr[l] = true; l += i; }} Set<Integer> set = new HashSet<Integer>(); for ( int i = 2;(i < 1000);i++) {for ( int j = (i + 1);(j <= 1000);j++) {if ( !pr[j]) {set.add(((j + i) + 1)); i = (j - 1); break;} }} int n = nextInt();  int k = nextInt();  int res = 0; for ( int i = 2;(i <= n);i++) {if ( (set.contains(i) && !pr[i])) res++; }if ( (res >= k)) out.println("YES"); else out.println("NO"); in.close(); 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());} }
6	public class G{ static int n ,t ; static int[] a ; static int[] g ; static long[][][] dp ; static final long MOD = 1000000007; public static void main( String[] args){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); t = sc.nextInt(); a = new int[n]; g = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); g[i] = sc.nextInt(); }dp = new long[4][(1 << ((n - 1) + 1))][(t + 1)]; for ( int i = 0;(i < 4);i++) for ( int j = 0;(j < (1 << ((n - 1) + 1)));j++) for ( int k = 0;(k <= t);k++) dp[i][j][k] = -1; System.out.println(dp(0,0,t)); } static private long dp( int genre, int mask, int time){ if ( (time < 0)) return 0; if ( (dp[genre][mask][time] != -1)) return dp[genre][mask][time]; if ( (time == 0)) return 1; dp[genre][mask][time] = 0; for ( int i = 0;(i < n);i++) {if ( ((g[i] != genre) && (((1 << i) & mask) == 0))) dp[genre][mask][time] = ((dp[genre][mask][time] + dp(g[i],(mask | (1 << i)),(time - a[i]))) % MOD); }return dp[genre][mask][time];} }
0	public class Bank{ public static void main( String[] args){ Scanner reader = new Scanner(System.in);  int in = reader.nextInt();  int sign = (int)Math.signum(in);  String str = (Math.abs(in) + ""); if ( (str.length() == 1)) {if ( (in < 0)) System.out.println(0); else System.out.println(in); return ;} int max = in; max = Math.max(max,(sign * Integer.parseInt(str.substring(0,(str.length() - 1))))); max = Math.max(max,(sign * Integer.parseInt((str.substring(0,(str.length() - 2)) + str.charAt((str.length() - 1)))))); System.out.println(max); } }
1	public class Main{ static final double eps = 1e-10; public static void main( String[] args)throws FileNotFoundException { new Main().solve(); } public void solve()throws FileNotFoundException { Scanner cin = new Scanner(System.in);  int n ; n = cin.nextInt(); String s ; s = cin.next(); int ans = Integer.MAX_VALUE;  int h = 0,t = 0; for ( int i = 0;(i < s.length());i++) {if ( (s.charAt(i) == 'H')) h++; else if ( (s.charAt(i) == 'T')) t++; }ans = Math.min(ans,fun(s,'H',h)); ans = Math.min(ans,fun(s,'T',t)); System.out.println(ans); } public int fun( String s, char c, int num){ int ans = Integer.MAX_VALUE;  int ret = num; for ( int i = 0;(i < num);i++) {if ( (s.charAt(i) == c)) {ret--; } }ans = ret; for ( int i = 0;((i + num) < s.length());i++) {if ( (s.charAt(i) != c)) ret--; if ( (s.charAt((i + num)) != c)) {ret++; } ans = Math.min(ans,ret); }return ans;} }
1	public class ProblemC{ public static void main( String[] args)throws IOException { init(); new ProblemC().run(); out.flush(); out.close(); } static void init()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); in.ordinaryChars(0,65535); in.wordChars(0,65535); in.whitespaceChars(' ',' '); in.whitespaceChars('\n','\n'); in.whitespaceChars('\r','\r'); } static final long INFL = 200000000000000000L; static final int INF = 2000000000; static final boolean DEBUG = true; static StreamTokenizer in ; static PrintWriter out ; static void print( String s){ print(s,0); } static void print( String s, int debug){ if ( ((debug == 0) || DEBUG)) {out.print(s); } } static void println( String s){ println(s,0); } static void println( String s, int debug){ if ( ((debug == 0) || DEBUG)) {out.println(s); } } static void sort( int[] a){ Random rnd = new Random(); for ( int i = (a.length - 1);(i > 0);i--) { int index = rnd.nextInt(i); a[i] ^= a[index]; a[index] ^= a[i]; a[i] ^= a[index]; }Arrays.sort(a); } static char[] inChars ; static int inCharsInd ; static String next()throws IOException { in.nextToken(); return in.sval;} static int nextInt()throws IOException { return Integer.valueOf(next());} private void run()throws IOException { solve(); } int K ,L ,M ,N ,P ; private void solve()throws IOException { int[] countChars = new int[('z' + 1)];  boolean[] gotIt = new boolean[('z' + 1)];  int N = nextInt();  int fullCount = 0;  char[] chars = next().toCharArray(); for ( int i = 0;(i < N);i++) {if ( (countChars[chars[i]] == 0)) fullCount++; countChars[chars[i]]++; }countChars = new int[('z' + 1)]; int answer = N;  int start = 0,finish = 0; countChars[chars[start]]++; fullCount--; while(((finish + 1) < N)){finish++; if ( (countChars[chars[finish]] == 0)) {fullCount--; } countChars[chars[finish]]++; while((countChars[chars[start]] > 1)){countChars[chars[start]]--; start++; }while((fullCount == 0)){answer = Math.min(answer,((finish - start) + 1)); countChars[chars[start]]--; if ( (countChars[chars[start]] == 0)) fullCount++; start++; }}out.println(answer); } }
3	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);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, MyInput in, PrintWriter out){ int n = in.nextInt();  int r = in.nextInt();  int[] x = in.nextIntArray(n);  double[] py = new double[n]; for ( int i = 0;(i < n);i++) { double y = r; for ( int j = 0;(j < i);j++) { int dx = Math.abs((x[i] - x[j])); if ( (dx > (2 * r))) continue; y = Math.max(y,(Math.sqrt((((4 * r) * r) - (dx * dx))) + py[j])); }py[i] = y; }for ( int i = 0;(i < n);i++) {out.printf("%.10f%s",py[i],((i == (n - 1))?"\n":" ")); }} } static class MyInput{ private final BufferedReader in ; static private int pos ; static private int readLen ; static private final char[] buffer = new char[(1024 * 8)]; static private char[] str = new char[((500 * 8) * 2)]; static private boolean[] isDigit = new boolean[256]; static private boolean[] isSpace = new boolean[256]; static private 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 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;} public int[] nextIntArray(final int n){ final int[] res = new int[n]; for ( int i = 0;(i < n);i++) {res[i] = nextInt(); }return res;} } }
2	public class Main{ static private StringTokenizer st ; static private BufferedReader br ; public static long MOD = 1000000007; public static void print( Object x){ System.out.println((x + "")); } public static String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = br.readLine(); st = new StringTokenizer(line.trim()); }return st.nextToken();} public static int nextInt()throws IOException { return Integer.parseInt(nextToken());} public static long nextLong()throws IOException { return Long.parseLong(nextToken());} public static long[] search( long[] none, long[] some)throws IOException { long[] med = new long[4]; for ( int i = 0;(i < 4);i++) {if ( (Math.abs((none[i] - some[i])) == 1)) {return some;} med[i] = ((none[i] + some[i]) / 2); } int ans = query(med); if ( (ans > 0)) return search(none,med); else return search(med,some);} public static int query( long[] query)throws IOException { print(("? " + arr(query))); System.out.flush(); int ans = nextInt(); if ( contains(query)) ans -= 1; return ans;} public static boolean contains( long[] search){ if ( (rect1 == null)) return false; if ( (search[0] > rect1[0])) return false; if ( (search[1] > rect1[1])) return false; if ( (search[2] < rect1[2])) return false; if ( (search[3] < rect1[3])) return false; return true;} public static String arr( long[] x){ return ((((((x[0] + " ") + x[1]) + " ") + x[2]) + " ") + x[3]);} public static long[] find()throws IOException { long[] d0 = {1,1,1,1};  long[] some = {1,1,n,n}; if ( (query(d0) > 0)) {return d0;} long[] none = {1,1,n,1}; if ( (query(none) > 0)) some = none; else some = search(none,some); none = new long[]{1,1,1,some[3]}; if ( (query(none) > 0)) some = none; else some = search(none,some); none = new long[]{1,some[3],some[2],some[3]}; if ( (query(none) > 0)) some = none; else some = search(none,some); none = new long[]{some[2],some[1],some[2],some[3]}; if ( (query(none) > 0)) some = none; else some = search(none,some); return some;} public static long[] rect1 = null; public static long[] rect2 = null; public static long n ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); n = nextLong(); rect1 = find(); rect2 = find(); print(((("! " + arr(rect1)) + " ") + arr(rect2))); System.out.flush(); } }
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(); } }
1	public class Main{ void run()throws IOException { int n = nint();  char[] s = token().toCharArray();  int h = 0; for ( int i = 0;(i < n);i++) {if ( (s[i] == 'H')) h++; } int r = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int t = 0; for ( int j = i;(j < (i + h));j++) {if ( (s[(j % n)] == 'T')) t++; }r = min(r,t); }out.println(r); } public static void main( String[] args)throws IOException { Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); st = new StringTokenizer(" "); new Main().run(); out.close(); } static BufferedReader in ; static PrintWriter out ; static StringTokenizer st ; String token()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int nint()throws IOException { return Integer.parseInt(token());} }
2	public class B{ final int MOD = ((int)1e9 + 7); final double eps = 1e-12; final int INF = (int)1e9; public B(){ long N = sc.nextInt();  long X = (sc.nextInt() - 1);  long Y = (sc.nextInt() - 1);  long C = sc.nextInt();  long[] A1 = new long[]{X,Y};  long[] A2 = new long[]{X,Y};  long[] B1 = new long[]{X,Y};  long[] B2 = new long[]{X,Y};  long[] C1 = new long[]{X,Y};  long[] C2 = new long[]{X,Y};  long[] D1 = new long[]{X,Y};  long[] D2 = new long[]{X,Y};  long cnt = 1,T = 0; while((cnt < C)){if ( (A1[0] > 0)) --A1[0]; else --A1[1]; if ( (A2[0] > 0)) --A2[0]; else ++A2[1]; if ( (B1[1] > 0)) --B1[1]; else --B1[0]; if ( (B2[1] > 0)) --B2[1]; else ++B2[0]; if ( (C1[0] < (N - 1))) ++C1[0]; else --C1[1]; if ( (C2[0] < (N - 1))) ++C2[0]; else ++C2[1]; if ( (D1[1] < (N - 1))) ++D1[1]; else --D1[0]; if ( (D2[1] < (N - 1))) ++D2[1]; else ++D2[0]; long[] Z = {(B1[0] - A1[0]),(C1[0] - B2[0]),(C2[0] - D2[0]),(D1[0] - A2[0])}; for ( long z :Z) if ( (z >= 0)) cnt += (z + 1); if ( Arrays.equals(A1,A2)) --cnt; if ( Arrays.equals(B1,B2)) --cnt; if ( Arrays.equals(C1,C2)) --cnt; if ( Arrays.equals(D1,D2)) --cnt; ++T; }exit(T); } static MyScanner sc ; static class MyScanner{ public String next(){ newLine(); return line[index++];} public int nextInt(){ return Integer.parseInt(next());} public String[] nextStrings(){ line = null; return readLine().split(" ");} 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){ pw.println(build(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( Object... a){ StringBuilder b = new StringBuilder(); for ( Object o :a) append(b,o); return b.toString().trim();} static void append( StringBuilder b, Object o){ if ( o.getClass().isArray()) { int L = Array.getLength(o); for ( int i = 0;(i < L);++i) append(b,Array.get(o,i)); } else if ( (o instanceof Iterable<?>)) {for ( Object p :(Iterable<?>)o) append(b,p); } else b.append(" ").append(o); } public static void main( String[] args){ sc = new MyScanner(); new B(); exit(); } static void start(){ t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t ; static long millis(){ return System.currentTimeMillis();} }
0	public class Main{ static final double EPS = 1E-6; double a ,v ,l ,d ,w ,u ; public void run(){ a = cin.nextDouble(); v = cin.nextDouble(); l = cin.nextDouble(); d = cin.nextDouble(); w = cin.nextDouble(); w = Math.min(w,v); double s1 = ((v * v) / (2 * a));  double s2 = ((w * w) / (2 * a));  double s3 = (s1 - s2);  double cost = 0; if ( (d < s2)) {cost += Math.sqrt(((2 * d) / a)); w = (cost * a); } else if ( (d < (s1 + s3))) {u = (Math.sqrt(((d / a) + ((w * w) / ((2 * a) * a)))) * a); cost = ((u / a) + ((u - w) / a)); } else {cost += (v / a); cost += ((v - w) / a); cost += (((d - s3) - s1) / v); }d = (l - d); s3 = (((v * v) - (w * w)) / (2 * a)); if ( (d < s3)) {cost += ((-w + Math.sqrt(((w * w) + ((2 * a) * d)))) / a); } else {cost += ((v - w) / a); cost += ((d - s3) / v); }out.println(cost); } public static void main( String[] args)throws IOException { Main sloved = new Main(); sloved.run(); sloved.out.close(); } Scanner cin = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); }
6	public class CF_11D{ long[][] ways ; boolean[][] connect ; int n ,m ,lowestIndex ,mask ; static private int HEAD_POINT_INDEX = 0; public void solve()throws Exception { int a ,b ;  long total = 0; n = nextInt(); m = nextInt(); connect = new boolean[n][n]; ways = new long[(1 << n)][n]; for ( int i = 0;(i < m);i++) {a = nextInt(); b = nextInt(); connect[(a - 1)][(b - 1)] = true; connect[(b - 1)][(a - 1)] = true; }for ( int i = 0;(i < n);i++) {ways[(1 << i)][i] = 1; }for ( mask = 1;(mask < (1 << n));mask++) { int tmp = mask,cnt = 0; while((tmp > 0)){tmp = (tmp & (tmp - 1)); cnt++; }lowestIndex = -1; for ( int endPointIndex = 0;(endPointIndex < n);endPointIndex++) {if ( ((mask & (1 << endPointIndex)) != 0)) {if ( (lowestIndex < 0)) {lowestIndex = endPointIndex; } else if ( (lowestIndex != endPointIndex)) {for ( int i = lowestIndex;(i < n);i++) if ( connect[i][endPointIndex]) {ways[mask][endPointIndex] += ways[(mask & (1 << endPointIndex))][i]; } if ( (connect[endPointIndex][lowestIndex] && (cnt > 2))) {total += ways[mask][endPointIndex]; } } } }}writer.println((total / 2)); } public static void main( String[] args){ new CF_11D().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();} }
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());} }
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)));} }
3	public class B{ static StringBuilder sb ; static int N ; static int[] A ; static boolean[] B ; public static void main( String[] args){ FastScanner sc = new FastScanner(); sb = new StringBuilder(); N = sc.nextInt(); A = new int[N]; for ( int i = 0;(i < N);i++) {A[i] = sc.nextInt(); }Arrays.sort(A); B = new boolean[N]; int count = 0; for ( int i = 0;(i < A.length);i++) {if ( B[i]) {continue;} else {count++; B[i] = true; }for ( int j = (i + 1);(j < A.length);j++) {if ( ((A[j] % A[i]) == 0)) {B[j] = true; } }}sb.append(count); System.out.println(sb); } 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());} long nextLong(){ return Long.parseLong(next());} } }
5	public class A{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); class Pointd implements Comparable<Pointd>{ int x ,in ; public Pointd( int x, int in){ super(); this.x = x; this.in = in; } } void solve()throws IOException { int n = readInt();  Pointd[] a = new Pointd[n]; for ( int i = 0;(i < n);i++) {a[i] = new Pointd(readInt(),i); }Arrays.sort(a); int count = 0; for ( int i = 0;(i < n);i++) {if ( (a[i].x != a[a[i].in].x)) count++; }if ( ((count == 0) || (count == 2))) out.println("YES"); else out.println("NO"); } 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());} long readLong()throws IOException { return Long.parseLong(readString());} public static void main( String[] args){ new A().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); } } }
5	public class CodeforcesA implements Runnable{ public static final String taskname = "A"; BufferedReader in ; PrintWriter out ; StringTokenizer tok ; public static void main( String[] args){ new Thread(new CodeforcesA()).start(); } static class Square implements Comparable<Square>{ int x ,a ; public Square( int x, int a){ this.x = x; this.a = a; } int distance( Square a, int t){ double dist = (((a.x - x) - (this.a / 2.0)) - (a.a / 2.0)); if ( (dist > t)) return 2; else if ( (abs((dist - t)) < 1e-9)) return 1; return 0;} } void solve()throws IOException { int n = nextInt(),t = nextInt();  Square[] x = new Square[n]; for ( int i = 0;(i < n);++i) {x[i] = new Square(nextInt(),nextInt()); }Arrays.sort(x); long res = 2; for ( int i = 0;(i < (n - 1));++i) {res += x[i].distance(x[(i + 1)],t); }out.println(res); } 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();} }
1	public class C{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int len = s.nextInt(); s.nextLine(); String l = s.nextLine();  char[] ca = l.toCharArray();  int h = 0; for ( char c :ca) h += A(c); int cur = h;  int i ; for ( i = 0;(i < h);i++) cur -= A(ca[i]); int best = cur; while((i != (h + len))){cur -= A(ca[(i % len)]); cur += A(ca[((i - h) % len)]); best = ((best > cur)?cur:best); i++; }System.out.println(best); } public static int A( char x){ return ((x == 'H')?1:0);} }
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 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 E1180D{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));  int n = sc.nextInt();  int m = sc.nextInt(); for ( int i = 1;(i <= (m / 2));i++) { int i2 = ((m - i) + 1); for ( int j = 1;(j <= n);j++) { int j2 = ((n - j) + 1); pw.println(((j + " ") + i)); pw.println(((j2 + " ") + i2)); }}if ( ((m % 2) == 1)) { int i2 = ((m / 2) + 1); for ( int j = 1;(j <= (n / 2));j++) { int j2 = ((n - j) + 1); pw.println(((j + " ") + i2)); pw.println(((j2 + " ") + i2)); }if ( ((n % 2) == 1)) { int j = ((n / 2) + 1); pw.println(((j + " ") + i2)); } } pw.flush(); pw.close(); } }
5	public class Flatwile{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  int[] c = new int[n];  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {c[i] = sc.nextInt(); a[i] = sc.nextInt(); }sort(c,a); int res = 1;  double prev = Integer.MIN_VALUE; for ( int i = 0;(i < c.length);i++) {if ( (((c[i] - (a[i] / 2d)) - prev) >= t)) {res++; } if ( ((i != (c.length - 1)) && (((c[(i + 1)] - (a[(i + 1)] / 2d)) - (c[i] + (a[i] / 2d))) > t))) {res++; } prev = (c[i] + (a[i] / 2d)); }System.out.println(res); } static private void sort( int[] a, int[] b){ for ( int i = 0;(i < a.length);i++) {for ( int j = (i + 1);(j < a.length);j++) {if ( (a[i] > a[j])) {swap(a,i,j); swap(b,i,j); } }}} static private void swap( int[] a, int i, int j){ int t = a[i]; a[i] = a[j]; a[j] = t; } }
3	public class C{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int mod = 1000000007;  long[] dp = new long[5005]; dp[0] = 1; for ( int i = 0;(i < n);i++) { char c = nc(); if ( (c == 's')) {if ( (i < (n - 1))) {for ( int j = 5003;(j >= 0);j--) {dp[j] += dp[(j + 1)]; if ( (dp[j] >= mod)) dp[j] -= mod; }} } else {for ( int j = 5003;(j >= 0);j--) {dp[(j + 1)] = dp[j]; }dp[0] = 0; }} long ans = 0; for ( int i = 0;(i < 5005);i++) ans += dp[i]; 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 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 char nc(){ return (char)skip();} 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 D{ public static int dir[][] = {{-1,0},{1,0},{0,-1},{0,1}}; public static void main( String[] args){ FastScanner sc = new FastScanner();  FastOutput out = new FastOutput(System.out);  int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int ans[][][] = new int[n][m][11];  int arr[][] = new int[(n * m)][4]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int x = sc.nextInt(); arr[((i * m) + j)][3] = x; arr[(((i * m) + j) + 1)][2] = x; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { int x = sc.nextInt(); arr[((i * m) + j)][1] = x; arr[(((i + 1) * m) + j)][0] = x; }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) { StringBuilder sb = new StringBuilder(""); for ( int j = 0;(j < m);j++) {ans[i][j][10] = -1; sb.append((ans[i][j][10] + " ")); }out.println(sb.toString()); }} else {for ( int ceng = 1;(ceng <= (k / 2));ceng++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {ans[i][j][ceng] = (Integer.MAX_VALUE / 3); for ( int dr = 0;(dr < 4);dr++) { int nx = (i + dir[dr][0]);  int ny = (j + dir[dr][1]); if ( ((((nx < n) && (ny < m)) && (nx >= 0)) && (ny >= 0))) {ans[i][j][ceng] = Math.min(ans[i][j][ceng],(ans[nx][ny][(ceng - 1)] + arr[((i * m) + j)][dr])); } }}}}for ( int i = 0;(i < n);i++) { StringBuilder sb = new StringBuilder(""); for ( int j = 0;(j < m);j++) {sb.append(((ans[i][j][(k / 2)] * 2) + " ")); }out.println(sb.toString()); }}out.close(); } 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());} } static class FastOutput implements AutoCloseable,Closeable,Appendable{ static private final int THRESHOLD = (1 << 13); private final Writer os ; private StringBuilder cache = new StringBuilder((THRESHOLD * 2)); public FastOutput append( CharSequence csq){ cache.append(csq); return this;} public FastOutput append( CharSequence csq, int start, int end){ cache.append(csq,start,end); return this;} private void afterWrite(){ if ( (cache.length() < THRESHOLD)) {return ;} flush(); } public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput append( char c){ cache.append(c); afterWrite(); return this;} public FastOutput append( int c){ cache.append(c); afterWrite(); return this;} public FastOutput append( String c){ cache.append(c); afterWrite(); return this;} public FastOutput println( String c){ return append(c).println();} public FastOutput println(){ return append(System.lineSeparator());} 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();} } }
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{ int mod = 1000000007; public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.readInt();  int[][] dp = new int[(n + 1)][5002];  char[] a = new char[n]; for ( int i = 0;(i < n);i++) a[i] = in.readCharacter(); for ( int i = 0;(i < dp[n].length);i++) dp[n][i] = 1; for ( int i = (n - 1);(i >= 0);i--) {for ( int j = 0;(j < n);j++) {if ( (a[i] == 's')) {if ( (j > 0)) dp[i][j] = dp[i][(j - 1)]; dp[i][j] = (int)((dp[i][j] + (long)dp[(i + 1)][j]) % mod); } else {if ( (j > 0)) dp[i][j] = dp[i][(j - 1)]; dp[i][j] = (int)((((dp[i][j] + (long)dp[(i + 1)][(j + 1)]) - (long)dp[(i + 1)][j]) + mod) % mod); }}}out.println(dp[0][0]); } } 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 char readCharacter(){ int c = read(); while(isSpaceChar(c))c = read(); return (char)c;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
2	public class Main{ static private Reader in ; static private PrintWriter out ; public static void main( String[] args)throws IOException { in = new Reader(); out = new PrintWriter(System.out); long n = in.nextLong();  long s = in.nextLong();  long low = 0,mid = 0,high = n; while((low <= high)){mid = ((low + high) / 2); if ( func(mid,s)) {high = (mid - 1); } else {low = (mid + 1); }}out.println(((n - low) + 1)); out.close(); } static private boolean func( long num, long s){ long sum = 0,temp = num; while((temp > 0)){sum += (temp % 10); temp /= 10; }return ((num - sum) >= s);} 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 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;} 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(); } } }
5	public class Teams{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; Random rnd ; class Pair implements Comparable<Pair>{ int a ,b ; public Pair( int a, int b){ this.a = a; this.b = b; } public int compareTo( Pair p){ if ( (a != p.a)) {return (a - p.a);} return (b - p.b);} } void solve()throws IOException { int n = nextInt(),k = nextInt();  Pair[] ps = new Pair[n]; for ( int i = 0;(i < n);i++) ps[i] = new Pair(nextInt(),nextInt()); Arrays.sort(ps); int curPlace = 1,res = 0;  int[] places = new int[n]; for ( int i = 0;(i < n);i++) {if ( (((i - 1) >= 0) && (ps[i].compareTo(ps[(i - 1)]) != 0))) ++curPlace; places[i] = curPlace; }for ( int i = 0;(i < n);i++) {if ( (places[i] == places[(k - 1)])) ++res; }out.println(res); } public static void main( String[] args){ new Teams().run(); } public void run(){ try{final String className = this.getClass().getName().toLowerCase(); try{in = new BufferedReader(new FileReader((className + ".in"))); out = new PrintWriter(new FileWriter((className + ".out"))); }catch (FileNotFoundException e){ 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());} }
0	public class Main{ public static void main( String[] args){ System.out.println("25"); } }
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());} }
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(); } static class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ out.printLine(25); } } static class InputReader{ private InputStream stream ; public InputReader( InputStream stream){ this.stream = stream; } } 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); } } }
6	public class G1{ static int n ,T ,duration[] ,type[] ; static long dp[][][] ,mod = ((long)1e9 + 7); public static void main( String[] args)throws Exception { new Thread(null,new Runnable(){},"Main",(1 << 28)).start(); } public static void solveIt()throws Exception { Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out); n = in.nextInt(); T = in.nextInt(); dp = new long[4][(T + 1)][(1 << n)]; duration = new int[n]; type = new int[n]; for ( int i = 0;(i < n);i++) {duration[i] = in.nextInt(); type[i] = (in.nextInt() - 1); }for ( long[][] a :dp) for ( long[] b :a) Arrays.fill(b,-1); pw.println(solve(3,T,0)); pw.close(); } static long solve( int lastType, int rem, int mask){ if ( (rem == 0)) return 1; if ( (rem < 0)) return 0; if ( (dp[lastType][rem][mask] != -1)) return dp[lastType][rem][mask]; long res = 0; for ( int i = 0;(i < n);i++) {if ( ((!check(mask,i) && (lastType != type[i])) && ((rem - duration[i]) >= 0))) {res += solve(type[i],(rem - duration[i]),set(mask,i)); if ( (res >= mod)) res -= mod; } }return dp[lastType][rem][mask] = res;} static boolean check( int N, int pos){ return ((N & (1 << pos)) != 0);} static int set( int N, int pos){ return N = (N | (1 << pos));} }
2	public class B{ public static void main( String[] args)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int N = Integer.parseInt(st.nextToken());  int K = Integer.parseInt(st.nextToken());  long x = (long)N;  long low = 0L;  long high = N; while((low != high)){x = (((low + high) + 1) / 2); long add = ((x * (x + 1)) / 2);  long y = (N - x); if ( ((add - y) > K)) high = x; else if ( ((add - y) == K)) {System.out.println(y); break;} else low = x; }} }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader c = new BufferedReader(new InputStreamReader(System.in));  String S[] = c.readLine().split(" ");  int N = Integer.parseInt(S[0]);  int K = Integer.parseInt(S[1]);  int A[] = parseArray(c.readLine(),N); shuffle(A); Arrays.sort(A); TreeMap<Long,Long> T = new TreeMap<Long,Long>();  int ans = 0; for ( int i = 0;(i < N);i++) T.put((long)A[i],1L); if ( (K == 1)) {System.out.println(N); return ;} else {for ( int i = 0;(i < N);i++) {if ( (((A[i] % K) == 0) && T.containsKey(((long)A[i] / K)))) continue; int chainSize = 0;  long init = A[i]; while(T.containsKey(init)){chainSize++; init = (init * K); }ans += ((chainSize + 1) / 2); }}System.out.println(ans); } public static int[] shuffle( int[] A){ int N = A.length; for ( int i = 1;(i < N);i++) { int j = ((int)(Math.random() * 100000) % (i + 1));  int temp = A[i]; A[i] = A[j]; A[j] = temp; }return A;} public static int[] parseArray( String s, int N){ int A[] = new int[N];  StringTokenizer st = new StringTokenizer(s); for ( int i = 0;(i < N);i++) A[i] = Integer.parseInt(st.nextToken()); return A;} }
3	public class BuildIn{ public static void main( String[] args)throws IOException { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream); solve(in,out); out.close(); } public static void solve( InputReader in, PrintWriter out)throws IOException { int n = in.nextInt();  int[] list = new int[n]; for ( int i = 0;(i < n);i++) {list[i] = in.nextInt(); } int count = 0; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (list[j] < list[i])) {count++; } }} boolean sta = true; if ( ((count % 2) == 1)) sta = false;  int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int a = in.nextInt();  int b = in.nextInt(); if ( (((b - a) % 4) == 2)) sta = !sta; if ( (((b - a) % 4) == 1)) sta = !sta; if ( sta) out.println("even"); else out.println("odd"); }} 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 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;} }
6	public class E{ static int n ; static int m ; static int[][][] DP ; static int[] dx = {0,0,1,-1}; static int[] dy = {1,-1,0,0}; static int inf = 1000000; public static int get( int x, int current, int last){ if ( (x == n)) {if ( (last == 0)) return 0; else return -inf;} if ( (DP[x][current][last] != -1)) return DP[x][current][last]; int max = 0; for ( int mask = 0;(mask < (1 << m));mask++) { int tempLast = last;  int tempCurrent = current;  int tempNext = ((1 << m) - 1); for ( int i = 0;(i < m);i++) if ( ((mask & (1 << i)) != 0)) {if ( (i > 0)) tempCurrent &= (1 << (i - 1)); if ( (i < (m - 1))) tempCurrent &= (1 << (i + 1)); tempNext &= (1 << i); tempLast &= (1 << i); } if ( (tempLast != 0)) continue; max = Math.max(max,((m - Integer.bitCount(mask)) + get((x + 1),tempNext,(tempCurrent & ~mask)))); }return DP[x][current][last] = max;} public static void main( String[] args){ Scanner in = new Scanner(System.in);  int x = in.nextInt();  int y = in.nextInt(); n = Math.max(x,y); m = Math.min(x,y); DP = new int[n][(1 << m)][(1 << m)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < (1 << m));j++) Arrays.fill(DP[i][j],-1); System.out.println(get(0,((1 << m) - 1),0)); } }
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));} }
6	public class p105b{ static int[] b ,l ; static int n ; static int A ; static boolean[] masks ; static double max ; public static double work( int index, int k, int mask){ if ( (index == n)) {if ( ((Integer.bitCount(mask) * 2) <= n)) { int sum = 0; for ( int i = 0;(i < n);i++) {if ( (((1 << i) & mask) == 0)) {sum += b[i]; } }return ((A * 1.0) / ((A * 1.0) + sum));} return 1;} double max = 0;  int to = Math.min(k,((100 - l[index]) / 10)); for ( int i = to;(i >= 0);i--) { double loy = (l[index] + (i * 10));  double b = (((100.0 - loy) / 100.0) * work((index + 1),(k - i),mask));  double a = ((loy / 100.0) * work((index + 1),(k - i),(mask | (1 << index)))); max = Math.max(max,(a + b)); }return max;} public static void rec( int index, int k){ if ( (k == -1)) return ; if ( (index == n)) { double tot = 0; for ( int i = 0;(i < (1 << n));i++) { double temp = 1.0;  int bb = 0; for ( int j = 0;(j < n);j++) {if ( (l[j] > 100)) return ; if ( (((1 << j) & i) != 0)) {temp *= ((l[j] * 1.0) / 100.0); } else {bb += b[j]; temp *= ((100.0 - l[j]) / 100.0); }}if ( ((Integer.bitCount(i) * 2) <= n)) {temp *= ((A * 1.0) / ((A * 1.0) + bb)); } tot += temp; }max = Math.max(max,tot); return ;} l[index] += 10; rec(index,(k - 1)); l[index] -= 10; rec((index + 1),k); } public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextInt(); int k = in.nextInt(); A = in.nextInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = in.nextInt(); l[i] = in.nextInt(); }masks = new boolean[(1 << n)]; max = 0; rec(0,k); System.out.println(max); } }
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)); } }
1	class Parser{ private final int BUFFER_SIZE = (1 << 16); private java.io.DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Parser( java.io.InputStream in){ din = new java.io.DataInputStream(in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws Exception { byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read();  int ret = 0; do {ret = (((ret * 10) + c) - '0'); c = read(); }while((c > ' '));bufferPointer--; if ( neg) return -ret; return ret;} public String next()throws Exception { StringBuilder ret = new StringBuilder();  byte c = read(); while((c <= ' '))c = read(); do {ret.append((char)c); c = read(); }while((c > ' '));bufferPointer--; return ret.toString();} public int next( char[] ret)throws Exception { byte c = read(); while((c <= ' '))c = read(); int bRead = 0; do {ret[bRead++] = (char)c; c = read(); }while((c > ' '));bufferPointer--; return bRead;} private void fillBuffer()throws Exception { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); } private byte read()throws Exception { if ( (bufferPointer == bytesRead)) fillBuffer(); if ( (bytesRead == -1)) return -1; return buffer[bufferPointer++];} } class Printer{ private final int BUFFER_SIZE = (1 << 16); private java.io.DataOutputStream dout ; private byte[] buffer ; private int bufferPointer ; Printer( java.io.OutputStream out)throws Exception{ dout = new java.io.DataOutputStream(out); buffer = new byte[BUFFER_SIZE]; bufferPointer = 0; } public void println()throws Exception { write((byte)'\n'); } public void println( int n)throws Exception { print(n); println(); } public void print( int n)throws Exception { if ( (n >= 0)) print(n,true); else {write((byte)'-'); print(-n,true); }} private void print( int n, boolean first)throws Exception { if ( (n == 0)) {if ( first) write((byte)(n + '0')); } else {print((n / 10),false); write((byte)((n % 10) + '0')); }} public void println( long n)throws Exception { print(n); println(); } public void print( long n)throws Exception { if ( (n >= 0)) print(n,true); else {write((byte)'-'); print(-n,true); }} private void print( long n, boolean first)throws Exception { if ( (n == 0)) {if ( first) write((byte)(n + '0')); } else {print((n / 10),false); write((byte)((n % 10) + '0')); }} public void println( double d)throws Exception { print(d); println(); } public void print( double d)throws Exception { print("double printing is not yet implemented!"); } public void println( char c)throws Exception { print(c); println(); } public void print( char c)throws Exception { write((byte)c); } public void println( String s)throws Exception { print(s); println(); } public void print( String s)throws Exception { int len = s.length(); for ( int i = 0;(i < len);i++) print(s.charAt(i)); } public void close()throws Exception { flushBuffer(); } private void flushBuffer()throws Exception { dout.write(buffer,0,bufferPointer); bufferPointer = 0; } private void write( byte b)throws Exception { buffer[bufferPointer++] = b; if ( (bufferPointer == BUFFER_SIZE)) flushBuffer(); } } public class Main{ public static void main( String[] args)throws Exception { new Main(); } final int oo = (int)1e9; InputStream stream = System.in; Parser in = new Parser(stream); Printer out = new Printer(System.out); Printer err = new Printer(System.err); long start_time = System.nanoTime(); int Sn ; char[] S = new char[1000]; char[] B = new char[1000]; Main()throws Exception{ for ( int T = in.nextInt();(T-- > 0);) {Sn = in.next(S); if ( matchRxCy()) toLet(); else toNum(); } long end_time = System.nanoTime(); err.println((("Time: " + ((end_time - start_time) / 1e9)) + "(s).")); if ( (stream instanceof FileInputStream)) {err.println("~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!!!!!!!!!!!!!!!!!!!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~"); err.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~CHANGE INPUT STREAM~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); err.println("~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!!!!!!!!!!!!!!!!!!!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~"); } out.close(); err.close(); } boolean matchRxCy(){ boolean ok = ((S[0] == 'R') && ((S[1] >= '0') && (S[1] <= '9'))); if ( !ok) return false; int i ; for ( i = 2;((i < Sn) && (S[i] != 'C'));++i) ;return (i < Sn);} void toLet()throws Exception { int r = 0;  int i = 1; while((S[i] != 'C'))r = (((r * 10) + S[i++]) - '0'); int c = 0; ++i; while((i < Sn))c = (((c * 10) + S[i++]) - '0'); int bi = 0; while((c > 0)){B[bi++] = (char)(((c - 1) % 26) + 'A'); c = ((c - 1) / 26); }for ( int j = (bi - 1);(j >= 0);--j) out.print(B[j]); i = 1; while((S[i] != 'C'))out.print(S[i++]); out.println(); } void toNum()throws Exception { int c = 0;  int i = 0;  int v = 1; while(Character.isLetter(S[i++]))v *= 26; v /= 26; i = 0; while(Character.isLetter(S[i])){c += (v * ((S[i++] - 'A') + 1)); v /= 26; } int r = 0; while((i < Sn))r = (((r * 10) + S[i++]) - '0'); out.print('R'); out.print(r); out.print('C'); out.print(c); out.println(); } }
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(); } static class TaskB{ int n ; int startrow ; int startcol ; long want ; boolean check( long time){ long max = ((((long)2 * time) * (time + 1)) + 1);  long highest = (startrow - time); if ( (highest < 0)) {max -= (Math.abs(highest) * Math.abs(highest)); } long lowest = (startrow + time); if ( (lowest >= n)) {max -= (Math.abs(((lowest - n) + 1)) * Math.abs(((lowest - n) + 1))); } long leftmost = (startcol - time); if ( (leftmost < 0)) {max -= (Math.abs(leftmost) * Math.abs(leftmost)); } long rightmost = (startcol + time); if ( (rightmost >= n)) {max -= (Math.abs(((rightmost - n) + 1)) * Math.abs(((rightmost - n) + 1))); } long upperright = ((time - (startrow + 1)) - (n - startcol)); if ( (upperright >= 0)) {max += (((upperright + 1) * (upperright + 2)) / 2); } long lowerright = ((time - (n - startrow)) - (n - startcol)); if ( (lowerright >= 0)) {max += (((lowerright + 1) * (lowerright + 2)) / 2); } long upperleft = ((time - (startrow + 1)) - (startcol + 1)); if ( (upperleft >= 0)) {max += (((upperleft + 1) * (upperleft + 2)) / 2); } long lowerleft = ((time - (n - startrow)) - (startcol + 1)); if ( (lowerleft >= 0)) {max += (((lowerleft + 1) * (lowerleft + 2)) / 2); } return (max >= want);} public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.readInt(); startrow = (in.readInt() - 1); startcol = (in.readInt() - 1); want = in.readLong(); long low = 0,high = (2 * n); while((low < high)){ long mid = ((low + high) / 2); if ( check(mid)) high = mid; else low = (mid + 1); }out.printLine(low); } } 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 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 close(){ writer.close(); } public void printLine( long i){ writer.println(i); } } }
2	public class D{ public Object solve(){ long N = sc.nextLong(),K = (sc.nextLong() - 1); if ( (N >= 32)) return print("YES",(N - 1)); long A = (1L << (N - 1)),C = 4,T = (((A * A) - 1) / 3); while(((A > 1) && (K > T))){A /= 2; K -= (C - 1); C *= 2; T += (((C - 3) * ((A * A) - 1)) / 3); }if ( ((K >= 0) && (K <= T))) return print("YES",Long.numberOfTrailingZeros(A)); else return print("NO");} static private final boolean ONE_TEST_CASE = false; static private void init(){ } static private IOUtils.MyScanner sc = new IOUtils.MyScanner(); static private Object print( Object o, Object... A){ IOUtils.print(o,A); return null;} public static void main( String[] args){ init(); int N = (ONE_TEST_CASE?1:sc.nextInt()); IOUtils.run(N); } }
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;} }
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);  APaintTheNumbers solver = new APaintTheNumbers(); solver.solve(1,in,out); out.close(); } static class APaintTheNumbers{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] a = in.readIntArray(n); Arrays.sort(a); int answer = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] == 0)) continue; answer++; for ( int j = 0;(j < n);j++) {if ( (j == i)) continue; if ( ((a[j] % a[i]) == 0)) {a[j] = 0; } }a[i] = 0; }out.println(answer); } } 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 int[] readIntArray( int n){ int[] x = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = nextInt(); }return x;} } }
4	public class Main{ void run(){ Locale.setDefault(Locale.US); boolean oj = (System.getProperty("ONLINE_JUDGE") != null); try{if ( oj) {sc = new FastScanner(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); } else {sc = new FastScanner(new FileReader("in.txt")); out = new PrintWriter(new FileWriter("out.txt")); } }catch (Exception e){ System.exit(-1); } long tB = System.currentTimeMillis(); solve(); if ( !oj) System.err.println(("Time: " + ((System.currentTimeMillis() - tB) / 1e3))); out.flush(); } class FastScanner{ BufferedReader br ; StringTokenizer st = new StringTokenizer(""); FastScanner( InputStreamReader a){ br = new BufferedReader(a); } FastScanner( FileReader a){ br = new BufferedReader(a); } String next(){ while(!st.hasMoreTokens())try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ return null;} return st.nextToken();} String readLine(){ try{return br.readLine(); }catch (Exception e){ return null;} } int nextInt(){ return Integer.parseInt(next());} } FastScanner sc ; PrintWriter out ; public static void main( String[] args){ new Main().run(); } void exit( int val){ out.flush(); System.exit(val); } int n ,m ; boolean[][] grid ; ArrayList<Integer>[] gr ; int c ; int[] mt ; boolean[] u ; boolean try_kuhn( int v){ if ( u[v]) return false; u[v] = true; for ( int to :gr[v]) {if ( (to == c)) continue; if ( ((mt[to] == -1) || try_kuhn(mt[to]))) {mt[to] = v; return true;} }return false;} void solve(){ n = sc.nextInt(); m = sc.nextInt(); grid = new boolean[(n + 1)][(n + 1)]; gr = new ArrayList[(n + 1)]; for ( int v = 1;(v <= n);++v) gr[v] = new ArrayList<Integer>(); for ( int it = 0;(it < m);++it) { int a = sc.nextInt();  int b = sc.nextInt(); grid[a][b] = true; gr[a].add(b); } int ans = Integer.MAX_VALUE; for ( c = 1;(c <= n);++c) { int curAns = 0; for ( int v = 1;(v <= n);++v) if ( (v != c)) {if ( !grid[c][v]) ++curAns; if ( !grid[v][c]) ++curAns; } if ( !grid[c][c]) ++curAns; mt = new int[(n + 1)]; fill(mt,-1); for ( int i = 1;(i <= n);++i) if ( (i != c)) {u = new boolean[(n + 1)]; try_kuhn(i); } int szMt = 0; for ( int i = 1;(i <= n);++i) if ( (mt[i] != -1)) ++szMt; curAns += ((n - 1) - szMt); for ( int a = 1;(a <= n);++a) {for ( int b :gr[a]) {if ( ((a == c) || (b == c))) continue; if ( (a != mt[b])) ++curAns; }}ans = min(ans,curAns); }out.println(ans); } }
6	public class Main{ static long mod = 1000000007; static int INF = 1000000000; public static void main( String[] args){ FastScanner scanner = new FastScanner();  int n = scanner.nextInt();  int m = scanner.nextInt();  String s = scanner.next();  int[][] cnt = new int[20][20]; for ( int i = 0;(i < (n - 1));i++) {cnt[(s.charAt(i) - 'a')][(s.charAt((i + 1)) - 'a')]++; cnt[(s.charAt((i + 1)) - 'a')][(s.charAt(i) - 'a')]++; } int[] dp = new int[(1 << m)]; for ( int i = 0;(i < (1 << m));i++) {dp[i] = INF; }dp[0] = 0; for ( int i = 0;(i < (1 << m));i++) { int cost = 0; for ( int j = 0;(j < m);j++) {if ( (((i >> j) & 1) == 0)) {for ( int k = 0;(k < m);k++) {if ( (((~i >> k) & 1) == 0)) {cost += cnt[j][k]; } }} }for ( int j = 0;(j < m);j++) {dp[(i | (1 << j))] = Math.min(dp[(i | (1 << j))],(dp[i] + cost)); }}System.out.println(dp[((1 << m) - 1)]); } static private 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;} static private 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 nextLong(){ 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))) {return (minus?-n:n);} else {throw (new NumberFormatException());}b = readByte(); }} public int nextInt(){ long nl = nextLong(); if ( ((nl < Integer.MIN_VALUE) || (nl > Integer.MAX_VALUE))) throw (new NumberFormatException()); return (int)nl;} } }
5	public class A{ public static void main( String[] args){ try{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] s = in.readLine().split(" ");  int n = Integer.parseInt(s[0]);  int t = (Integer.parseInt(s[1]) * 2);  int[] walls = new int[(n * 2)]; for ( int i = 0;(i < n);i++) {s = in.readLine().split(" "); int x = (Integer.parseInt(s[0]) * 2);  int a = Integer.parseInt(s[1]); walls[(i * 2)] = (x - a); walls[((i * 2) + 1)] = (x + a); }Arrays.sort(walls); int count = 2; for ( int i = 1;(i < ((n * 2) - 2));i += 2) { int space = (walls[(i + 1)] - walls[i]); if ( (space == t)) count += 1; else if ( (space > t)) count += 2; }System.out.println(count); }catch (NumberFormatException e){ throw (new RuntimeException(e));} catch (IOException e){ throw (new RuntimeException(e));} } }
5	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){ 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); if ( (k >= m)) {out.println(0); return ;} for ( int i = 1;(i <= n);i++) { int sockets = (k - 1); for ( int j = 0;(j < i);j++) sockets += a[((n - j) - 1)]; sockets -= (i - 1); if ( (sockets >= m)) {out.println(i); return ;} }out.println(-1); } } class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public int nextInt(){ return Integer.parseInt(next());} 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 q4{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int query = in.nextInt(); while((query-- > 0)){ int n = in.nextInt();  int k = in.nextInt();  char[] arr = new char[n];  String code = in.next(); for ( int i = 0;(i < n);i++) {arr[i] = code.charAt(i); } int r = 0;  int g = 0;  int b = 0; for ( int i = 0;(i < k);i++) {if ( ((i % 3) == 0)) {if ( (arr[i] == 'R')) {g++; b++; } else if ( (arr[i] == 'G')) {r++; b++; } else {r++; g++; }} else if ( ((i % 3) == 1)) {if ( (arr[i] == 'G')) {g++; b++; } else if ( (arr[i] == 'B')) {r++; b++; } else {r++; g++; }} else {if ( (arr[i] == 'B')) {g++; b++; } else if ( (arr[i] == 'R')) {r++; b++; } else {r++; g++; }}} int rMin = r;  int gMin = g;  int bMin = b; for ( int j = k;(j < n);j++) {if ( (((((j % 3) == 0) && (arr[j] != 'R')) || (((j % 3) == 1) && (arr[j] != 'G'))) || (((j % 3) == 2) && (arr[j] != 'B')))) {r++; } if ( ((((((j - k) % 3) == 0) && (arr[(j - k)] != 'R')) || ((((j - k) % 3) == 1) && (arr[(j - k)] != 'G'))) || ((((j - k) % 3) == 2) && (arr[(j - k)] != 'B')))) {r--; } rMin = Math.min(r,rMin); if ( (((((j % 3) == 0) && (arr[j] != 'G')) || (((j % 3) == 1) && (arr[j] != 'B'))) || (((j % 3) == 2) && (arr[j] != 'R')))) {g++; } if ( ((((((j - k) % 3) == 0) && (arr[(j - k)] != 'G')) || ((((j - k) % 3) == 1) && (arr[(j - k)] != 'B'))) || ((((j - k) % 3) == 2) && (arr[(j - k)] != 'R')))) {g--; } gMin = Math.min(gMin,g); if ( (((((j % 3) == 0) && (arr[j] != 'B')) || (((j % 3) == 1) && (arr[j] != 'R'))) || (((j % 3) == 2) && (arr[j] != 'G')))) {b++; } if ( ((((((j - k) % 3) == 0) && (arr[(j - k)] != 'B')) || ((((j - k) % 3) == 1) && (arr[(j - k)] != 'R'))) || ((((j - k) % 3) == 2) && (arr[(j - k)] != 'G')))) {b--; } bMin = Math.min(bMin,b); }System.out.println(Math.min(Math.min(rMin,gMin),bMin)); }} }
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++];} }
2	public class Main{ static class Reader{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ,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 s(){ 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 i(){ 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));} } public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out);  Reader sc = new Reader();  int n = sc.i(); System.out.println(("? " + 1)); int a = sc.i(); System.out.println(("? " + (1 + (n / 2)))); int b = sc.i(); if ( (a == b)) {System.out.println(("! " + 1)); System.exit(0); } int inv = 0; if ( (a > b)) inv = 1;  int low = 2;  int high = (n / 2);  int q = 0; while((low <= high)){if ( (q == 60)) break; int mid = ((low + high) / 2); System.out.println(("? " + mid)); a = sc.i(); System.out.println(("? " + (mid + (n / 2)))); b = sc.i(); if ( (a == b)) {System.out.println(("! " + mid)); System.exit(0); } else if ( (a < b)) {if ( (inv == 0)) low = (mid + 1); else high = (mid - 1); } else {if ( (inv == 0)) high = (mid - 1); else low = (mid + 1); }q++; }System.out.println("! -1"); out.flush(); } }
6	public class SimpleCycle{ int first( int x){ return (x - (x & (x - 1)));} void run(){ int N = nextInt(),M = nextInt();  int[] graph = new int[N]; for ( int i = 0;(i < M);i++) { int a = (nextInt() - 1),b = (nextInt() - 1); graph[a] |= (1 << b); graph[b] |= (1 << a); } int[] bitcount = new int[(1 << N)]; for ( int i = 0;(i < (1 << N));i++) {bitcount[i] = bitcount[(i >> 1)]; if ( ((i % 2) == 1)) bitcount[i]++; } long[][] dp = new long[(1 << N)][N]; for ( long[] f :dp) Arrays.fill(f,0); long ans = 0; for ( int mask = 1;(mask < (1 << N));mask++) {for ( int i = 0;(i < N);i++) if ( ((mask & (1 << i)) > 0)) {if ( (bitcount[mask] == 1)) dp[mask][i] = 1; else {if ( (first(mask) != (1 << i))) {for ( int j = 0;(j < N);j++) if ( (((graph[i] & (1 << j)) > 0) && ((mask & (1 << j)) > 0))) {dp[mask][i] += dp[(mask - (1 << i))][j]; } } }if ( ((bitcount[mask] >= 3) && ((graph[i] & first(mask)) > 0))) ans += dp[mask][i]; } }System.out.println((ans / 2)); } 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 SimpleCycle().run(); } }
6	public class Main{ static class Task{ int NN = 1000006; int MOD = 998244353; int INF = 2000000000; long INFINITY = 1000000000000000000L; long[][] a ; long[][] w ,w1 ; long[][] dp ; int countBit( int num){ int ret = 0; while((num > 0)){if ( ((num & 1) != 0)) ++ret; num >>= 1; }return ret;} long rec( int at, int mask, int n, int start){ long ans = -INFINITY; if ( (dp[at][mask] != -1)) return dp[at][mask]; if ( (countBit(mask) == n)) {return dp[at][mask] = w1[start][at];} for ( int i = 0;(i < n);++i) {if ( (((mask >> i) & 1) == 0)) {ans = Math.max(ans,Math.min(w[at][i],rec(i,(mask | (1 << i)),n,start))); } }return dp[at][mask] = ans;} public void solve( InputReader in, PrintWriter out){ int n = in.nextInt(),m = in.nextInt(); dp = new long[n][(1 << n)]; a = new long[n][m]; w = new long[n][n]; w1 = new long[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {a[i][j] = in.nextLong(); }}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {w[i][j] = INFINITY; if ( (i == j)) continue; for ( int k = 0;(k < m);++k) {w[i][j] = Math.min(w[i][j],Math.abs((a[j][k] - a[i][k]))); }}}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {w1[i][j] = INFINITY; for ( int k = 1;(k < m);++k) {w1[i][j] = Math.min(w1[i][j],Math.abs((a[i][k] - a[j][(k - 1)]))); }}} long ans = 0; for ( int start = 0;(start < n);++start) {for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < (1 << n));++j) dp[i][j] = -1; }ans = Math.max(ans,rec(start,(1 << start),n,start)); }out.println(ans); } } 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());} } }
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); } }
6	public class E{ static int g[][] ; static int n ,m ; static char[] s ; static int dp[] ,inf = (int)2e9; 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]++; } }dp = new int[(1 << m)]; Arrays.fill(dp,-1); pw.println(solve(0,0)); pw.close(); } 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 = 0; for ( int j = 0;(j < m);j++) {if ( check(mask,j)) res += (g[i][j] * pos); else res -= (g[i][j] * pos); }res += 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));} }
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 k = nextInt();  Integer[] a = new Integer[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = nextInt(); }if ( (k == 1)) {System.out.println(n); return ;} Arrays.sort(a,1,(n + 1)); Set<Integer> set = new HashSet<Integer>();  int ans = 0;  int INF = (int)1e9; for ( int i = 1;(i <= n);i++) {if ( set.contains(a[i])) continue; int t = a[i];  int s = 1; while((((long)t * k) <= INF)){t *= k; if ( (Arrays.binarySearch(a,1,(n + 1),t) >= 0)) {set.add(t); s++; } else break;}if ( ((s % 2) == 0)) ans += (s / 2); else ans += ((s / 2) + 1); }System.out.println(ans); pw.close(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
0	public class Main implements Runnable{ 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); } PrintWriter pw ; BufferedReader in ; StringTokenizer st ; void initStreams()throws FileNotFoundException,UnsupportedEncodingException { pw = new PrintWriter(System.out); if ( (System.getProperty("ONLINE_JUDGE") == null)) {System.setIn(new FileInputStream("1")); } in = new BufferedReader(new InputStreamReader(System.in,"ISO-8859-9")); } String nextString()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} double nextDouble()throws NumberFormatException,IOException { return Double.parseDouble(nextString());} private void out( double t){ pw.println(t); } }
0	public class Main{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  BigInteger l = new BigInteger(scanner.next());  BigInteger r = new BigInteger(scanner.next()); if ( (r.subtract(l).intValue() < 2)) {System.out.println(-1); return ;} BigInteger a = l.abs(),b ,c ;  BigInteger toothless = r.subtract(BigInteger.valueOf(1)); while((a.compareTo(toothless) == -1)){b = l.add(BigInteger.valueOf(1)); while((b.compareTo(r) == -1)){c = l.add(BigInteger.valueOf(2)); while(((c.compareTo(r) == -1) || (c.compareTo(r) == 0))){if ( (((gcd(a,b) == 1) && (gcd(b,c) == 1)) && (gcd(a,c) != 1))) {System.out.println(((((a + " ") + b) + " ") + c)); return ;} c = c.add(BigInteger.valueOf(1)); }b = b.add(BigInteger.valueOf(1)); }a = a.add(BigInteger.valueOf(1)); }System.out.println(-1); } static private int gcd( BigInteger a, BigInteger b){ return a.gcd(b).intValue();} }
2	public class C{ String line ; StringTokenizer inputParser ; BufferedReader is ; FileInputStream fstream ; DataInputStream in ; String FInput = ""; void openInput( String file){ if ( (file == null)) is = new BufferedReader(new InputStreamReader(System.in)); else {try{fstream = new FileInputStream(file); in = new DataInputStream(fstream); is = new BufferedReader(new InputStreamReader(in)); }catch (Exception e){ System.err.println(e); } }} void readNextLine(){ try{line = is.readLine(); inputParser = new StringTokenizer(line," "); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } int NextInt(){ String n = inputParser.nextToken();  int val = Integer.parseInt(n); return val;} void closeInput(){ try{is.close(); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } public static void main( String[] argv){ String filePath = null; if ( (argv.length > 0)) filePath = argv[0]; new C(filePath); } final int MOD = 1000000009; public C( String inputFile){ openInput(inputFile); StringBuilder sb = new StringBuilder(); readNextLine(); int N = NextInt(),M = NextInt(),K = NextInt(); if ( ((N / K) <= (N - M))) {sb.append(M); } else { int x = ((N / K) - (N - M));  long ret = (pow(2,x) - 1); ret *= K; ret %= MOD; ret *= 2; ret %= MOD; ret += (M - (x * K)); ret %= MOD; sb.append((ret + "\n")); }System.out.println(sb); closeInput(); } long pow( long b, long exponent){ long ret = 1; while((exponent > 0)){if ( ((exponent % 2) == 1)) ret = ((ret * b) % MOD); exponent = (exponent >> 1); b = ((b * b) % MOD); }return ret;} }
5	public class SolA{ static private InputReader in ; static private PrintWriter out ; public static void main( String[] args)throws IOException { in = new InputReader(System.in); out = new PrintWriter(System.out); run(); out.close(); } public static void run(){ int n = in.readInt();  int a = in.readInt();  int b = in.readInt();  int[] h = new int[n]; for ( int i = 0;(i < n);i++) {h[i] = -in.readInt(); }Arrays.sort(h); int base = -h[(a - 1)];  int base1 = -h[a]; out.print((base1 - base)); } } 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 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();} public static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} }
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(); }} }
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());} }
3	public class q1{ static int MOD = 1000000007; 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 { Scanner sc = new Scanner(System.in);  int T = 1; while((T-- > 0)){ int N = sc.nextInt();  int a[] = new int[N];  int count = 0;  int ans = 0;  boolean flag = false; for ( int i = 0;(i < N);++i) {a[i] = sc.nextInt(); }Arrays.sort(a); for ( int i = 0;(i < N);++i) {if ( (a[i] == -1)) continue; for ( int j = (i + 1);(j < N);++j) {if ( (((a[j] % a[i]) == 0) && (a[j] != -1))) {a[j] = -1; ;} }}for ( int i = 0;(i < N);++i) {if ( (a[i] != -1)) count++; }System.out.println(count); }} }
2	public class DigitalSequence{ public static void print( String s){ System.out.println(s); } public static void main( String[] args){ long k = new Scanner(System.in).nextLong();  long i = 1,t = 0,c = 9,digits = 0,l = 0,k2 = k; while((t < k)){l = t; t += (i * c); i++; c *= 10; digits++; }k = (k - l); long lastNumber = ((long)Math.pow(10,(digits - 1)) - 1);  long p = (k / digits),q = (k % digits);  long finalNumber = (lastNumber + p); if ( (q != 0)) {finalNumber++; } k = (k - (digits * p)); if ( (k <= 0)) k += digits;  String ans = ("" + finalNumber);  int index = (int)(k - 1); print(("" + ans.charAt(index))); } }
4	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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt();  int m = in.nextInt();  int[] from = new int[m];  int[] to = new int[m]; for ( int i = 0;(i < m);i++) {from[i] = (in.nextInt() - 1); to[i] = (in.nextInt() - 1); } int ans = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { KuhnMatchingGraph g = new KuhnMatchingGraph(n,n);  int count = 0; for ( int j = 0;(j < m);j++) {if ( ((from[j] != i) && (to[j] != i))) {g.addEdge(from[j],to[j]); ++count; } } int cur = (((n - 1) + count) - (2 * g.getMaximalMatching()));  boolean[] a = new boolean[n];  boolean[] b = new boolean[n]; for ( int j = 0;(j < m);j++) {if ( (from[j] == i)) {a[to[j]] = true; } if ( (to[j] == i)) {b[from[j]] = true; } }for ( int j = 0;(j < n);j++) {if ( (j == i)) {if ( !a[j]) ++cur; } else {if ( !a[j]) ++cur; if ( !b[j]) ++cur; }}ans = Math.min(ans,cur); }out.println(ans); } } 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);} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } } class KuhnMatchingGraph{ int n ; int m ; List<Integer>[] edges ; int[] p1 ; int[] p2 ; int[] was ; int VER ; public KuhnMatchingGraph( int n, int m){ this.n = n; this.m = m; edges = new ArrayList[n]; for ( int i = 0;(i < n);i++) {edges[i] = new ArrayList<Integer>(2); }} public void addEdge( int from, int to){ edges[from].add(to); } public int getMaximalMatching(){ p1 = new int[n]; p2 = new int[m]; was = new int[n]; VER = 0; Arrays.fill(p1,-1); Arrays.fill(p2,-1); int answer = 0; for ( int i = 0;(i < n);i++) {for ( int j :edges[i]) {if ( (p2[j] < 0)) {p2[j] = i; p1[i] = j; answer++; break;} }}for ( int i = 0;(i < n);i++) {if ( (p1[i] >= 0)) {continue;} VER++; if ( dfs(i)) {answer++; } }return answer;} boolean dfs( int v){ if ( (was[v] == VER)) {return false;} was[v] = VER; for ( int i = 0;(i < edges[v].size());i++) { int e = edges[v].get(i); if ( ((p2[e] < 0) || dfs(p2[e]))) {p2[e] = v; p1[v] = e; return true;} }return false;} }
5	public class A{ final int MOD = ((int)1e9 + 7); final double eps = 1e-12; final int INF = (int)1e9; public A(){ int N = sc.nextInt();  int K = sc.nextInt();  Long[] A = sc.nextLongs(); sort(A); Set<Long> S = new HashSet<Long>(); for ( long a :A) {if ( (((a % K) == 0) && S.contains(H((a / K))))) continue; S.add(H(a)); } int res = S.size(); exit(res); } long P = probablePrime(60,new Random()).longValue(); long Q = probablePrime(60,new Random()).longValue(); long H( long x){ return ((P * x) + Q);} 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 A(); exit(); } static void start(){ t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t ; static long millis(){ return System.currentTimeMillis();} }
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();} }
6	public class C{ static boolean[][] matrix ; static long[][] dp ; static int n ; static int m ; public static void main( String[] args){ Scanner s = new Scanner(System.in); n = s.nextInt(); m = s.nextInt(); matrix = new boolean[n][n]; for ( int i = 0;(i < m);++i) { int v1 = (s.nextInt() - 1);  int v2 = (s.nextInt() - 1); matrix[v1][v2] = true; matrix[v2][v1] = true; }dp = new long[n][(1 << (n + 1))]; for ( int i = 0;(i < n);++i) Arrays.fill(dp[i],-1); long res = 0; for ( int i = 0;(i < n);++i) res += calc(i,i,(1 << i),1); System.out.println((res / 2)); } public static long calc( int h, int c, int m, int len){ if ( (dp[c][m] != -1)) return dp[c][m]; long ret = 0; if ( ((len > 2) && matrix[c][h])) ret = 1; for ( int i = (h + 1);(i < n);++i) if ( (((m & (1 << i)) == 0) && matrix[c][i])) ret += calc(h,i,(m | (1 << i)),(len + 1)); return dp[c][m] = ret;} }
6	public class Main{ public static double p[] ; static double s[] ; static double m[] ; static int n ; public static double a[][] ; public static int index = 0; public static boolean vis[] ; public static HashMap<Integer,Integer> permMap ; public static void main( String[] g){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); m = new double[((1 << n) + 1)]; vis = new boolean[((1 << n) + 1)]; a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {a[i][j] = sc.nextDouble(); }}s = new double[(1 << n)]; int perm = 0; m[0] = 1; p(); int c = ((1 << n) - 1); for ( int i = 0;(i < n);i++) {perm = (c - (1 << i)); System.out.printf("%.6f ",m[perm]); }{}} public static void p(){ for ( int k = 0;(k < (1 << n));k++) { int perm = k; for ( int j = 0;(j < n);j++) {if ( bitTest(perm,j)) {continue;} int newPerm = (perm | (1 << j)); for ( int i = 0;(i < n);i++) {if ( ((i == j) || bitTest(newPerm,i))) {continue;} int L = (n - countO(perm)); if ( (L < 2)) {continue;} double pm = (2.0 / (L * (L - 1))); m[newPerm] += ((m[perm] * a[i][j]) * pm); }}}} static private int countO( int marked){ int count = 0; for ( int i = 0;(i < n);i++) { int test = (1 << i); if ( ((test & marked) == test)) count++; }return count;} static private boolean bitTest( int perm, int i){ int test = (1 << i); if ( ((test & perm) == test)) return true; return false;} }
2	public class C{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); long n = nextLong();  long s = nextLong();  long ans = 0; if ( ((s + 200) <= n)) ans += ((n - (s + 200)) + 1); for ( long i = s;(i < (s + 200));i++) {if ( ((i <= n) && ((i - sumDigits(i)) >= s))) {ans++; } }System.out.println(ans); pw.close(); } static private long sumDigits( long n){ long sum = 0; while((n > 0)){sum += (n % 10); n /= 10; }return sum;} static private long nextLong()throws IOException { return Long.parseLong(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
2	public class Temppp{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long k = sc.nextLong();  long ans = (long)((java.lang.Math.sqrt((9 + (8 * (n + k)))) - 3) / 2); System.out.println((n - ans)); } }
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());} } }
5	public class A{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int t = scan.nextInt();  List<List<Double>> coords = new ArrayList<List<Double>>(); while((n-- > 0)){ double x = scan.nextDouble();  double a = (scan.nextDouble() / 2); coords.add(Arrays.asList((x - a),(x + a))); }Collections.sort(coords,new Comparator<List<Double>>(){}); int count = 2;  ChoiceFormat f = new ChoiceFormat("-1#0|0#1|0<2"); for ( int i = 0;(i < (coords.size() - 1));i++) { double l = ((coords.get((i + 1)).get(0) - coords.get(i).get(1)) - t); count += new Integer(f.format(l)); }System.out.println(count); } }
4	public class Main implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws FileNotFoundException { 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 mergeSort( int[] a){ mergeSort(a,0,(a.length - 1)); } static private 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); }} } static private 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++]); }}} static private 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 static void main( String[] args){ new Main().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); } } int mini = Integer.MAX_VALUE; int maxi = Integer.MIN_VALUE; int ans = 0; int ans2 = 0; int sum = 0; void solve()throws IOException { int n = readInt();  int m = readInt();  int maxi = 0;  int[][] a = new int[n][m];  int k = readInt();  ArrayDeque<Point> dq = new ArrayDeque<Point>();  Point p = new Point(); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) {a[i][j] = Integer.MAX_VALUE; }for ( int i = 0;(i < k);i++) { int x = (readInt() - 1);  int y = (readInt() - 1); p.x = x; p.y = y; dq.add(new Point(x,y)); a[x][y] = 0; }while(!dq.isEmpty()){ Point v = dq.pollFirst();  Point u = new Point(); if ( ((v.x - 1) != -1)) {if ( (a[(v.x - 1)][v.y] > (a[v.x][v.y] + 1))) {a[(v.x - 1)][v.y] = (a[v.x][v.y] + 1); maxi = max(maxi,a[(v.x - 1)][v.y]); u.x = (v.x - 1); u.y = v.y; dq.add(new Point(u.x,u.y)); } } if ( ((v.y - 1) != -1)) {if ( (a[v.x][(v.y - 1)] > (a[v.x][v.y] + 1))) {a[v.x][(v.y - 1)] = (a[v.x][v.y] + 1); maxi = max(maxi,a[v.x][(v.y - 1)]); u.y = (v.y - 1); u.x = v.x; dq.add(new Point(u.x,u.y)); } } if ( ((v.x + 1) != n)) {if ( (a[(v.x + 1)][v.y] > (a[v.x][v.y] + 1))) {a[(v.x + 1)][v.y] = (a[v.x][v.y] + 1); maxi = max(maxi,a[(v.x + 1)][v.y]); u.x = (v.x + 1); u.y = v.y; dq.add(new Point(u.x,u.y)); } } if ( ((v.y + 1) != m)) {if ( (a[v.x][(v.y + 1)] > (a[v.x][v.y] + 1))) {a[v.x][(v.y + 1)] = (a[v.x][v.y] + 1); maxi = max(maxi,a[v.x][(v.y + 1)]); u.y = (v.y + 1); u.x = v.x; dq.add(new Point(u.x,u.y)); } } }for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) {if ( (maxi == a[i][j])) {out.print((((i + 1) + " ") + (j + 1))); return ;} }} char c[] ; void per( int left, int right){ if ( (left == right)) {for ( int i = 0;(i <= right);i++) {out.print(c[i]); }out.println(); } else {for ( int i = left;(i <= right);i++) { char k = c[left]; c[left] = c[i]; c[i] = k; per((left + 1),right); k = c[left]; c[left] = c[i]; c[i] = k; }}} }
0	public class FunctionHeight{ public static void main( String[] args){ MyScanner sc = new MyScanner();  long n = sc.nl();  long k = sc.nl();  long ans = (((n + k) - 1) / n); System.out.println(ans); } static private 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();} long nl(){ return Long.parseLong(next());} } }
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))); } }
5	public class village{ static int[] X ,A ; public void solve(){ Scanner in = new Scanner(System.in);  int N = in.nextInt(),T = in.nextInt(); X = new int[N]; A = new int[N]; for ( int i = 0;(i < N);i++) {X[i] = in.nextInt(); A[i] = in.nextInt(); }if ( (N == 1)) {System.out.println("2"); return ;} List<Integer> x = new ArrayList<Integer>(); for ( int i = 0;(i < N);i++) {x.add(i); }Collections.sort(x,new Comp()); int places = 0; for ( int i = 0;(i < (N - 1));i++) { double space = (((X[x.get((i + 1))] - X[x.get(i)]) - (A[x.get((i + 1))] / 2.0)) - (A[x.get(i)] / 2.0)); if ( (space < T)) {continue;} if ( ((space - T) < 1e-9)) {places++; } else if ( (space > T)) {places += 2; } }System.out.println((places + 2)); } public class Comp implements Comparator<Integer>{ } public static void main( String[] args){ new village().solve(); } }
6	public class Main{ static int[][] memo ; static int n ,m ,in[][] ; static int dp( int col, int maxRowMask){ if ( ((col >= Math.min(n,m)) || (maxRowMask == ((1 << n) - 1)))) return 0; if ( (memo[col][maxRowMask] != -1)) return memo[col][maxRowMask]; int ans = 0;  int availableBits = (maxRowMask ^ ((1 << n) - 1)); for ( int colMask = availableBits;(colMask != 0);colMask = ((colMask - 1) & availableBits)) {ans = Math.max(ans,(maxMask[col][colMask] + dp((col + 1),(maxRowMask | colMask)))); }return memo[col][maxRowMask] = ans;} static int[][] sumOfMask ; static int[][] maxMask ; public static void main( String[] args)throws Exception { pw = new PrintWriter(System.out); sc = new MScanner(System.in); int tc = sc.nextInt(); while((tc-- > 0)){n = sc.nextInt(); m = sc.nextInt(); int[] maxInCol = new int[m]; in = new int[m][(n + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {in[j][i] = sc.nextInt(); maxInCol[j] = Math.max(maxInCol[j],in[j][i]); in[j][n] = j; }}Arrays.sort(in,(x,y)->(maxInCol[y[n]] - maxInCol[x[n]])); memo = new int[n][(1 << n)]; sumOfMask = new int[n][(1 << n)]; maxMask = new int[n][(1 << n)]; for ( int i = 0;(i < n);i++) {for ( int msk = 0;(msk < memo[i].length);msk++) {memo[i][msk] = -1; if ( (i >= m)) continue; for ( int bit = 0;(bit < n);bit++) {if ( (((msk >> bit) & 1) != 0)) {sumOfMask[i][msk] += in[i][bit]; } }}}for ( int col = 0;(col < n);col++) {for ( int msk = 0;(msk < (1 << n));msk++) { int curMask = msk; for ( int cyclicShift = 0;(cyclicShift < n);cyclicShift++) {maxMask[col][msk] = Math.max(maxMask[col][msk],sumOfMask[col][curMask]); int lastBit = (curMask & 1); curMask >>= 1; curMask |= (lastBit << (n - 1)); }}}pw.println(dp(0,0)); }pw.flush(); } static PrintWriter pw ; static MScanner sc ; 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 long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } static void shuffle( int[] in){ for ( int i = 0;(i < in.length);i++) { int idx = (int)(Math.random() * in.length);  int tmp = in[i]; in[i] = in[idx]; in[idx] = tmp; }} static void shuffle( long[] in){ for ( int i = 0;(i < in.length);i++) { int idx = (int)(Math.random() * in.length);  long tmp = in[i]; in[i] = in[idx]; in[idx] = tmp; }} }
2	public class C{ static long s ; public static void main( String[] args)throws IOException { Reader.init(System.in); long n = Reader.nextLong(); s = Reader.nextLong(); long lo = 1,hi = n,mid ; while((lo < hi)){mid = ((lo + hi) / 2); if ( (diff(mid) >= s)) hi = mid; else lo = (mid + 1); }if ( (diff(lo) >= s)) System.out.println(((n - lo) + 1)); else System.out.println(0); } static long diff( long n){ String s = String.valueOf(n);  int sum = 0; for ( int i = 0;(i < s.length());i++) {sum += Integer.parseInt(s.valueOf(s.charAt(i))); }return (n - sum);} }
5	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){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  Integer[] cap = new Integer[n]; for ( int i = 0;(i < n);i++) {cap[i] = in.nextInt(); }Arrays.sort(cap,Collections.reverseOrder()); int count = 0; while(((k < m) && (count < cap.length))){k += (cap[count] - 1); ++count; }if ( (k >= m)) {out.println(count); } else {out.println(-1); }} } class InputReader{ StringTokenizer st ; BufferedReader in ; public InputReader( InputStream ins){ in = new BufferedReader(new InputStreamReader(ins)); } 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());} }
6	public class Main implements Runnable{ boolean multiple = false; long MOD ; @SuppressWarnings void solve()throws Exception { int k = sc.nextInt();  long tar = 0;  long[][] arr = new long[k][];  long[] sum = new long[k];  HashMap<Long,Pair<Integer,Integer>> map = new HashMap<>(); for ( int i = 0;(i < k);i++) { int ni = sc.nextInt(); arr[i] = new long[ni]; for ( int j = 0;(j < ni);j++) {sum[i] += arr[i][j] = sc.nextInt(); map.put(arr[i][j],new Pair<>(i,j)); }tar += sum[i]; }if ( ((tar % k) != 0)) {System.out.println("No"); return ;} tar /= k; works = new HashMap<>(); for ( int i = 0;(i < k);i++) {for ( int j = 0;(j < arr[i].length);j++) { long val = arr[i][j];  long want = ((tar - sum[i]) + val); if ( !map.containsKey(want)) continue; int key = (1 << i);  int next = map.get(want).getKey();  HashSet<Integer> seen = new HashSet<>(); seen.add(i); while(true){if ( seen.contains(next)) {if ( ((next == i) && (want == arr[i][j]))) works.put(key,(((long)i << 32) + (long)j)); break;} val = arr[next][map.get(want).getValue()]; want = ((tar - sum[next]) + val); if ( !map.containsKey(want)) continue outer; key |= (1 << next); seen.add(next); next = map.get(want).getKey(); }}}dp = new long[(1 << k)]; done = new boolean[(1 << k)]; yes = new boolean[(1 << k)]; yes[0] = done[0] = true; long ans = r(((1 << k) - 1));  long[] val = new long[k];  int[] pos = new int[k]; if ( !yes[((1 << k) - 1)]) System.out.println("No"); else {System.out.println("Yes"); while(((ans >> 32) != 0)){ long p = works.get((int)(ans >> 32));  int i = (int)(p >> 32),j = (int)(p & ((1L << 32) - 1));  long VAL = arr[i][j];  long want = ((tar - sum[i]) + VAL);  int key = (1 << i);  int next = map.get(want).getKey();  int prev = i; while(true){if ( (next == i)) {val[map.get(want).getKey()] = want; pos[map.get(want).getKey()] = (prev + 1); if ( (want == arr[i][j])) works.put(key,(((long)i << 32) + (long)j)); break;} val[map.get(want).getKey()] = want; pos[map.get(want).getKey()] = (prev + 1); VAL = arr[next][map.get(want).getValue()]; want = ((tar - sum[next]) + VAL); key |= (1 << next); prev = next; next = map.get(want).getKey(); }ans = dp[(int)(ans & ((1L << 32) - 1))]; }for ( int i = 0;(i < k);i++) System.out.println(((val[i] + " ") + pos[i])); }} HashMap<Integer,Long> works ; long[] dp ; boolean[] done ,yes ; long r( int mask){ if ( done[mask]) return dp[mask]; done[mask] = true; for ( int s = mask;(s != 0);s = ((s - 1) & mask)) if ( works.keySet().contains(s)) { int tempMask = mask; for ( int i = 0;(i < 16);i++) if ( ((s & (1 << i)) != 0)) tempMask ^= (1 << i); r(tempMask); if ( yes[tempMask]) {yes[mask] = true; return dp[mask] = (((long)s << 32) + tempMask);} } return 0;} StringBuilder ANS = new StringBuilder(); public static void main( String[] args)throws Throwable { Thread thread = new Thread(null,new Main(),"",(1 << 26)); thread.start(); thread.join(); if ( (Main.uncaught != null)) {throw (Main.uncaught);} } static Throwable uncaught ; BufferedReader in ; FastScanner sc ; PrintWriter out ; } 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 int nextInt()throws Exception { return Integer.parseInt(nextToken());} }
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 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(); } static private long numDigit( long ans){ long sum = 0; while((ans > 0)){sum++; ans /= 10; }return sum;} static private 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);} static private 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--; }} static private 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;} static private void reverse( long[] arr, int l, int m){ while((l < m)){ long temp = arr[l]; arr[l] = arr[m]; arr[m] = temp; l++; m--; }} static private 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 ; static private 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]; static private 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;} }
3	public class C{ static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ int n = in.nextInt();  int[] sol = new int[n]; sol[0] = 1; int mod = 1000000007;  int maxind = 0;  boolean f = true; for ( int i = 0;(i < n);i++) {if ( !f) {for ( int j = 1;(j <= maxind);j++) {sol[j] += sol[(j - 1)]; sol[j] %= mod; }} if ( in.next().equals("f")) {maxind++; f = true; } else {f = false; }} int ans = 0; for ( int i = 0;(i <= maxind);i++) {ans += sol[i]; ans %= mod; }out.println(ans); finish(); } public static void finish(){ out.close(); in.close(); System.exit(0); } static class InputReader implements Iterator<String>,Closeable{ private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; public InputReader( InputStream i){ r = new BufferedReader(new InputStreamReader(i)); } public int nextInt(){ return Integer.parseInt(nextToken());} public String next(){ return nextToken();} public void close(){ try{r.close(); }catch (IOException e){ } } private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} } }
6	public class E1{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  ArrayList<Integer>[] reps = new ArrayList[13];  int[][] index = new int[13][];  int[][] eqcl = new int[13][];  ArrayList<Integer>[][] nexts = new ArrayList[13][]; for ( int n = 1;(n <= 12);n++) {eqcl[n] = new int[(1 << n)]; reps[n] = new ArrayList<Integer>(); index[n] = new int[(1 << n)]; int ind = 0; for ( int mask = 0;(mask < (1 << n));mask++) { boolean add = true; for ( int k = 0;(k < n);k++) {if ( (rot(mask,k,n) < mask)) add = false; }if ( add) {reps[n].add(mask); index[n][mask] = ind; ind++; } }nexts[n] = new ArrayList[reps[n].size()]; for ( int i = 0;(i < reps[n].size());i++) { int mask = reps[n].get(i); for ( int k = 0;(k < n);k++) {eqcl[n][rot(mask,k,n)] = i; }nexts[n][i] = new ArrayList<>(); for ( int y = 0;(y < (1 << n));y++) {if ( ((mask & y) == 0)) {nexts[n][i].add(y); } }}} int T = Integer.parseInt(br.readLine());  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); for ( int test = 0;(test < T);test++) { StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int m = Integer.parseInt(st.nextToken());  int[][] arrt = new int[m][n]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < m);j++) {arrt[j][i] = Integer.parseInt(st.nextToken()); }} Column[] cols = new Column[m]; for ( int j = 0;(j < m);j++) {cols[j] = new Column(arrt[j]); }Arrays.sort(cols,Collections.reverseOrder()); m = Integer.min(n,m); int[][] arr = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {arr[i][j] = cols[j].arr[i]; }} int[][] max = new int[m][reps[n].size()]; for ( int c = 0;(c < m);c++) {for ( int mask = 0;(mask < (1 << n));mask++) { int curr = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) > 0)) curr += arr[i][c]; } int cl = eqcl[n][mask]; max[c][cl] = Integer.max(max[c][cl],curr); }} int[][] dp = new int[(m + 1)][reps[n].size()]; for ( int c = 0;(c < m);c++) {for ( int i = 0;(i < reps[n].size());i++) { int mask = reps[n].get(i); for ( int next :nexts[n][i]) { int cl = eqcl[n][next];  int dl = eqcl[n][(mask | next)]; if ( ((dp[c][i] + max[c][cl]) > dp[(c + 1)][dl])) {dp[(c + 1)][dl] = (dp[c][i] + max[c][cl]); } }}}bw.write((dp[m][(reps[n].size() - 1)] + "\n")); }bw.flush(); } static int rot( int x, int k, int n){ int a = (x << k);  int b = (x >> (n - k)); return ((a + b) & ((1 << n) - 1));} static class Column implements Comparable<Column>{ int[] arr ; int max ; public Column( int[] arr){ this.arr = arr; max = 0; for ( int k :arr) {max = Integer.max(max,k); }} } }
2	public class B{ public static final boolean DEBUG = false; Scanner sc ; public void pln( Object o){ System.out.println(o); } long getNumber( int x, int y, int n, int m){ int n1 = Math.max(0,((x + m) - n));  int n2 = Math.max(0,((y + m) - n));  int n3 = Math.max(0,(1 - (x - m)));  int n4 = Math.max(0,(1 - (y - m)));  int n12 = Math.max(0,(((n1 + n2) - m) - 1));  int n23 = Math.max(0,(((n2 + n3) - m) - 1));  int n34 = Math.max(0,(((n3 + n4) - m) - 1));  int n41 = Math.max(0,(((n4 + n1) - m) - 1));  int m1 = (m + 1);  long nr = ((1 + (((long)m1 * m1) * 2)) - (m1 * 2)); nr -= (((((long)n1 * n1) + ((long)n2 * n2)) + ((long)n3 * n3)) + ((long)n4 * n4)); nr += ((((((long)n12 * (n12 + 1)) / 2) + (((long)n23 * (n23 + 1)) / 2)) + (((long)n34 * (n34 + 1)) / 2)) + (((long)n41 * (n41 + 1)) / 2)); return nr;} public void run(){ sc = new Scanner(System.in); int n = sc.nextInt();  int x = sc.nextInt();  int y = sc.nextInt();  int c = sc.nextInt(); if ( (c <= 1)) {pln(0); return ;} int ll = 0;  int rr = ((2 * n) + 20); while(true){ int m = ((ll + rr) / 2); if ( (getNumber(x,y,n,m) >= c)) {rr = m; } else {ll = m; }if ( ((rr - ll) < 3)) {for ( int m2 = ll;(m2 <= rr);m2++) {if ( (getNumber(x,y,n,m2) >= c)) {pln(m2); return ;} }} }} public static void main( String[] args){ B t = new B(); t.run(); } }
1	public class Main2{ static List<List<Integer>> getLayers( int[] numbers, int a, int b){ boolean[] used = new boolean[numbers.length];  HashSet<Integer> hs = new HashSet<Integer>(); for ( int i = 0;(i < numbers.length);i++) {hs.add(numbers[i]); } HashMap<Integer,Integer> numberToIndex = new HashMap<Integer,Integer>(); for ( int i = 0;(i < numbers.length);i++) {numberToIndex.put(numbers[i],i); } List<List<Integer>> ans = new ArrayList<List<Integer>>(); for ( int i = 0;(i < numbers.length);i++) {if ( !used[i]) { List<Integer> ansRow = new ArrayList<Integer>();  LinkedList<Integer> current = new LinkedList<Integer>(); current.add(numbers[i]); while(!current.isEmpty()){ int c = current.removeFirst(); used[numberToIndex.get(c)] = true; boolean found = false; if ( hs.contains((a - c))) {found = true; if ( ((a - c) != c)) current.add((a - c)); } if ( hs.contains((b - c))) {found = true; if ( ((b - c) != c)) current.add((b - c)); } if ( (found || (ansRow.size() > 0))) ansRow.add(c); hs.remove(c); }ans.add(ansRow); } }return ans;} 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[] numbers = new int[n]; for ( int i = 0;(i < numbers.length);i++) {numbers[i] = sc.nextInt(); } HashSet<Integer> hs = new HashSet<Integer>(); for ( int i = 0;(i < numbers.length);i++) {hs.add(numbers[i]); } int[] belongs = new int[n]; for ( int i = 0;(i < belongs.length);i++) {belongs[i] = -1; } HashMap<Integer,Integer> numberToIndex = new HashMap<Integer,Integer>(); for ( int i = 0;(i < numbers.length);i++) {numberToIndex.put(numbers[i],i); } boolean possible = true;  List<List<Integer>> layers = getLayers(numbers,a,b); for ( List<Integer> layer :layers) {if ( (layer.size() == 0)) {System.out.println("NO"); return ;} int starting = -1; for ( int j = 0;(j < layer.size());j++) { int cur = layer.get(j);  int nei = 0; if ( hs.contains((a - cur))) {nei++; } if ( hs.contains((b - cur))) {nei++; } if ( ((nei == 1) || ((a == b) && (nei == 2)))) {starting = j; } }if ( (starting == -1)) throw (new Error()); int c = layer.get(starting);  HashSet<Integer> layerset = new HashSet<Integer>(layer); while(true){if ( (layerset.contains(c) && layerset.contains((a - c)))) {belongs[numberToIndex.get(c)] = 0; belongs[numberToIndex.get((a - c))] = 0; layerset.remove(c); layerset.remove((a - c)); c = (b - (a - c)); } else if ( (layerset.contains(c) && layerset.contains((b - c)))) {belongs[numberToIndex.get(c)] = 1; belongs[numberToIndex.get((b - c))] = 1; layerset.remove(c); layerset.remove((b - c)); c = (a - (b - c)); } else {break;}}}printResult(belongs); } static void printResult( int[] belongs){ boolean ok = true; for ( int i = 0;(i < belongs.length);i++) {if ( (belongs[i] < 0)) ok = false; }if ( ok) {System.out.println("YES"); StringBuffer sb = new StringBuffer(); for ( int i = 0;(i < belongs.length);i++) {sb.append(belongs[i]); if ( (i != (belongs.length - 1))) sb.append(" "); }System.out.println(sb.toString()); } else {System.out.println("NO"); }} }
3	public class D911{ public static long total = 0; public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  ArrayList<Integer> temp = new ArrayList<>();  int[] ar = new int[n];  int[] memo = new int[n]; for ( int i = 0;(i < n);i++) { int t = in.nextInt();  int index = ((-1 * Collections.binarySearch(temp,t)) - 1); temp.add(index,t); ar[i] = t; memo[i] = (i - index); total += memo[i]; } int m = in.nextInt(); for ( int i = 0;(i < m);i++) {total += (((-1 * (((in.nextInt() - 1) - in.nextInt()) + 1)) + 1) / 2); System.out.println((((total % 2) == 0)?"even":"odd")); }} public static void query( int[] ar, int[] memo, int a, int b){ if ( (a >= b)) {return ;} if ( (ar[a] < ar[b])) {memo[a]++; total++; } else {memo[b]--; total--; } int t = ar[a]; ar[b] = ar[a]; ar[b] = t; t = memo[a]; memo[b] = memo[a]; memo[b] = t; query(ar,memo,(a + 1),(b - 1)); } }
0	public class A{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); BigInteger a = new BigInteger(next()); System.out.println(BigInteger.valueOf(5).modPow(a,BigInteger.valueOf(100))); pw.close(); } static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
6	public class B{ static int[] loyality ; static int[] level ; static int mid ; static int a ,n ; static double sol ; public static void getMax( int idx, int rem){ if ( (idx == loyality.length)) { double pos = 0; for ( int i = 0;(i < (1 << n));i++) pos += solve(i); sol = Math.max(sol,pos); return ;} int cur = loyality[idx];  int r = 0; while((((r + cur) <= 10) && (r <= rem))){loyality[idx] = (cur + r); getMax((idx + 1),(rem - r)); r++; }loyality[idx] = cur; } public static double solve( int mask){ int c = 0;  int sum = 0;  double b = 1; for ( int i = 0;(i < n);i++) {if ( (((1 << i) | mask) == mask)) {c++; b *= (loyality[i] / 10.0); } else {sum += level[i]; b *= (1 - (loyality[i] / 10.0)); }}if ( (c >= mid)) return b; return ((b * (a * 1.0)) / (a + sum));} public static void main( String[] args){ Scanner sc = new Scanner(System.in); n = sc.nextInt(); int k = sc.nextInt(); a = sc.nextInt(); level = new int[n]; loyality = new int[n]; for ( int i = 0;(i < n);i++) {level[i] = sc.nextInt(); loyality[i] = (sc.nextInt() / 10); }mid = ((n / 2) + 1); sol = 0; getMax(0,k); System.out.println(sol); } }
3	public class A{ public void run()throws Exception { FastScanner sc = new FastScanner();  int n = sc.nextInt();  int[] arr = new int[n];  int[] color = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); }Arrays.sort(arr); int counter = 1; for ( int i = 0;(i < n);i++) {if ( (color[i] != 0)) continue; for ( int j = i;(j < n);j++) {if ( (color[j] != 0)) continue; else if ( ((arr[j] % arr[i]) == 0)) color[j] = counter; }counter++; } int max = 0; for ( int i = 0;(i < n);i++) {max = Math.max(max,color[i]); }System.out.println(max); } static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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)throws Exception { new A().run(); } }
6	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);  E2RotateColumnsHardVersion solver = new E2RotateColumnsHardVersion();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class E2RotateColumnsHardVersion{ public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  E2RotateColumnsHardVersion.Column[] columns = new E2RotateColumnsHardVersion.Column[m]; for ( int i = 0;(i < columns.length);++i) columns[i] = new E2RotateColumnsHardVersion.Column(new int[n]); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {columns[j].v[i] = in.nextInt(); if ( (i == (n - 1))) columns[j].initMax(); }}Arrays.sort(columns,(o1,o2)->(o2.max - o1.max)); if ( (columns.length > n)) columns = Arrays.copyOf(columns,n);  long[] dp = new long[(1 << n)]; for ( E2RotateColumnsHardVersion.Column c :columns) { long[] ndp = new long[(1 << n)]; System.arraycopy(dp,0,ndp,0,dp.length); for ( int rot = 0;(rot < n);++rot) { long[] temp = new long[(1 << n)]; System.arraycopy(dp,0,temp,0,dp.length); for ( int i = 0,pos = rot;(i < n);++i,++pos) {if ( (pos >= n)) pos = 0;  int val = c.v[pos]; for ( int j = 0;(j < temp.length);++j) {if ( ((j & (1 << i)) == 0)) temp[(j | (1 << i))] = Math.max(temp[(j | (1 << i))],(temp[j] + val)); }}for ( int i = 0;(i < ndp.length);++i) ndp[i] = Math.max(ndp[i],temp[i]); }dp = ndp; }out.println(dp[(dp.length - 1)]); } } 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 String next(){ return nextString();} 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);} public String nextString(){ int c = pread(); while(isSpaceChar(c))c = pread(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = pread(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  long n = in.nextLong(); out.println(((((0 + " ") + 0) + " ") + n)); in.close(); out.close(); } }
1	public class First{ StreamTokenizer in ; PrintWriter out ; int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} String nextString()throws IOException { in.nextToken(); return in.sval;} void run()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); solve(); out.flush(); } void solve()throws IOException { int n = nextInt(),k = nextInt(),sum = 0,count = 0;  String str = nextString();  char[] arr = str.toCharArray();  boolean[] bool = new boolean[26]; for ( char ch :arr) {bool[((int)ch - 97)] = true; }for ( int i = 0;(i < 26);i++) {if ( bool[i]) {sum += (i + 1); count++; i += 1; } if ( (count == k)) break; }if ( (count == k)) out.println(sum); else out.println(-1); } public static void main( String[] args)throws IOException { new First().run(); } }
0	public class A{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt(); s.close(); if ( ((n % 2) == 0)) System.out.print(("4 " + (n - 4))); else System.out.print(("9 " + (n - 9))); } }
2	public class B2{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  String line = reader.readLine();  StringTokenizer tokenizer = new StringTokenizer(line);  long n = Long.parseLong(tokenizer.nextToken());  long k = Long.parseLong(tokenizer.nextToken()); if ( (n == 1)) {System.out.println("0"); return ;} if ( (n <= k)) {System.out.println("1"); return ;} long first = 0;  long end = k;  long mid ; while((first < end)){mid = (first + ((end - first) / 2)); if ( is_exist(n,k,(mid - 1))) {end = mid; } else {first = (mid + 1); }}if ( is_exist(n,k,(end - 1))) {System.out.println(end); return ;} System.out.println("-1"); return ;} static boolean is_exist( long n, long k, long x){ long res = (n - (((((k - 1) + k) - x) * (((k - 1) - (k - x)) + 1)) / 2)); if ( (res <= (k - x))) {return true;} return false;} }
1	public class Cf2207C{ static private InputReader in = new InputReader(System.in); static private OutputWriter out = new OutputWriter(System.out); static private void solve()throws Exception { int n = in.readInt();  String s = in.readString();  int[] count = new int[200];  boolean[] flag = new boolean[200]; for ( int i = 0;(i < n);++i) {flag[s.charAt(i)] = true; } int ref = 0; for ( int i = 0;(i < 200);++i) {if ( flag[i]) {ref++; } } int total = 0;  int min = Integer.MAX_VALUE;  int j = 0; for ( int i = 0;(i < n);++i) {if ( ((j == n) && (total < ref))) {break;} if ( (total == ref)) {min = Math.min(min,(j - i)); count[s.charAt(i)]--; if ( (count[s.charAt(i)] == 0)) {total--; } continue;} for ( ;(j < n);++j) {count[s.charAt(j)]++; if ( (count[s.charAt(j)] == 1)) {total++; } if ( (total == ref)) {min = Math.min(min,((j - i) + 1)); j++; break;} }count[s.charAt(i)]--; if ( (count[s.charAt(i)] == 0)) {total--; } }out.println(min); } public static void main( String[] args)throws Exception { solve(); out.close(); } static private class InputReader{ private InputStream stream ; private byte[] buffer ; private int currentIndex ; private int bytesRead ; public InputReader( InputStream stream){ this.stream = stream; buffer = new byte[16384]; } public InputReader( InputStream stream, int bufferSize){ this.stream = stream; buffer = new byte[bufferSize]; } private int read()throws IOException { if ( (currentIndex >= bytesRead)) {currentIndex = 0; bytesRead = stream.read(buffer); if ( (bytesRead <= 0)) {return -1;} } return buffer[currentIndex++];} public String readString()throws IOException { int c = read(); while(!isPrintable(c)){c = read(); } StringBuilder result = new StringBuilder(); do {result.appendCodePoint(c); c = read(); }while(isPrintable(c));return result.toString();} public int readInt()throws Exception { int c = read();  int sign = 1; while(!isPrintable(c)){c = read(); }if ( (c == '-')) {sign = -1; c = read(); } int result = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} result *= 10; result += (c - '0'); c = read(); }while(isPrintable(c));return (sign * result);} private boolean isPrintable( int c){ return ((c > 32) && (c < 127));} } static private class OutputWriter{ private 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 E{ public static void main( String[] args){ FastScanner scanner = new FastScanner();  PrintWriter out = new PrintWriter(System.out,false);  int n = scanner.nextInt();  int m = scanner.nextInt();  char[] str = scanner.next().toCharArray();  int maxMask = (1 << m);  long[] dp = new long[maxMask];  int[][] dists = new int[m][m]; for ( int i = 1;(i < n);i++) { int c1 = (str[i] - 'a');  int c2 = (str[(i - 1)] - 'a'); dists[c1][c2]++; dists[c2][c1]++; } int[] pre = new int[maxMask]; for ( int mask = 0;(mask < maxMask);mask++) {for ( int i = 0;(i < m);i++) {if ( (((1 << i) & mask) == 0)) continue; for ( int j = 0;(j < m);j++) {if ( (((1 << j) & mask) > 0)) continue; pre[mask] += dists[i][j]; }}}Arrays.fill(dp,(Long.MAX_VALUE / 4)); dp[0] = 0; for ( int mask = 0;(mask < maxMask);mask++) {if ( (dp[mask] == (Long.MAX_VALUE / 4))) continue; for ( int i = 0;(i < m);i++) {if ( (((1 << i) & mask) > 0)) continue; int nmask = (mask | (1 << i)); dp[nmask] = Math.min(dp[nmask],(dp[mask] + pre[nmask])); }}out.println(dp[(maxMask - 1)]); 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());} } }
2	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{ int MOD = 1000000009; public void solve( int testNumber, InputStreamReader inSt, PrintWriter out){ InputReader in = new InputReader(inSt);  long n = in.nextInt();  long m = in.nextInt();  long k = in.nextInt();  long t = find(n,m,k);  long twoPow = binPow(2,(int)t); twoPow--; long result = ((2 * ((k * twoPow) % MOD)) % MOD); result += (m - (t * k)); result = (result % MOD); out.println(result); } int binPow( int a, int n){ if ( (n == 0)) {return 1;} if ( ((n % 2) == 1)) {return (int)((binPow(a,(n - 1)) * (a + 0l)) % MOD);} else { int b = (binPow(a,(n / 2)) % MOD); return (int)(((b + 0l) * b) % MOD);}} long find( long n, long m, long k){ long l = 0;  long r = (m / k); while((l < r)){ long mid = ((l + r) / 2);  long m1 = (m - (mid * k));  long n1 = (n - (mid * k)); if ( isPossible(n1,m1,k)) {r = mid; } else {l = (mid + 1); }}return l;} boolean isPossible( long n, long m, long k){ long r = (m / (k - 1));  long q = (m - ((k - 1) * r)); if ( (q == 0)) {return ((((r * (k - 1)) + r) - 1) <= n);} return ((((r * (k - 1)) + q) + r) <= n);} class InputReader{ public BufferedReader reader ; private String[] currentArray ; int curPointer ; public InputReader( InputStreamReader inputStreamReader){ reader = new BufferedReader(inputStreamReader); } public int nextInt(){ if ( ((currentArray == null) || (curPointer >= currentArray.length))) {try{currentArray = reader.readLine().split(" "); }catch (IOException e){ throw (new RuntimeException(e));} curPointer = 0; } return Integer.parseInt(currentArray[curPointer++]);} } }
1	public class BDiv1{ static int n ; static int a ; static int b ; static HashMap<Integer,Integer> graphA = new HashMap<>(); static HashMap<Integer,Integer> graphB = new HashMap<>(); static int[] array ; static int[] original ; static boolean x = true; public static void main( String[] args)throws Exception { BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(buf.readLine()); n = parseInt(st.nextToken()); a = parseInt(st.nextToken()); b = parseInt(st.nextToken()); st = new StringTokenizer(buf.readLine()); array = new int[n]; original = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = parseInt(st.nextToken()); original[i] = array[i]; }Arrays.sort(array); for ( int i = 0;(i < n);i++) { int k = Arrays.binarySearch(array,(a - array[i])); if ( (k >= 0)) {graphA.put(array[i],array[k]); graphA.put(array[k],array[i]); } }for ( int i = 0;(i < n);i++) { int k = Arrays.binarySearch(array,(b - array[i])); if ( (k >= 0)) {graphB.put(array[i],array[k]); graphB.put(array[k],array[i]); } }for ( int i = 0;(i < n);i++) { Integer j = graphA.get(array[i]); if ( (j != null)) {if ( (graphB.containsKey(array[i]) && graphB.containsKey(j))) {graphA.remove(array[i]); graphA.remove(j); } else if ( (graphB.containsKey(array[i]) && !graphB.containsKey(j))) {graphB.remove(graphB.get(array[i])); graphB.remove(array[i]); } else if ( (!graphB.containsKey(array[i]) && graphB.containsKey(j))) {graphB.remove(graphB.get(j)); graphB.remove(j); } } } int[] res = new int[n]; for ( int i = 0;(i < n);i++) {if ( graphA.containsKey(original[i])) res[i] = 0; else if ( graphB.containsKey(original[i])) res[i] = 1; else {System.out.println("NO"); return ;}}System.out.println("YES"); for ( int k :res) System.out.print((k + " ")); } }
4	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new FileReader("input.txt"));  StringBuilder out = new StringBuilder();  StringTokenizer tk ;  PrintWriter pw = new PrintWriter("output.txt","UTF-8");  int[] dx = {-1,1,0,0},dy = {0,0,-1,1}; tk = new StringTokenizer(in.readLine()); int n = parseInt(tk.nextToken()),m = parseInt(tk.nextToken());  int k = parseInt(in.readLine());  int[][] dist = new int[n][m]; for ( int i = 0;(i < n);i++) Arrays.fill(dist[i],-1); int ans = -1,atx = -1,aty = -1;  Queue<point> q = new LinkedList<point>(); tk = new StringTokenizer(in.readLine()); while((k-- > 0)){ int x = (parseInt(tk.nextToken()) - 1),y = (parseInt(tk.nextToken()) - 1); dist[x][y] = 0; q.add(new point(x,y)); }while(!q.isEmpty()){ point p = q.remove(); if ( (dist[p.x][p.y] > ans)) {ans = dist[p.x][p.y]; atx = (p.x + 1); aty = (p.y + 1); } for ( int i = 0;(i < 4);i++) { int nx = (p.x + dx[i]);  int ny = (p.y + dy[i]); if ( (((((nx >= 0) && (nx < n)) && (ny >= 0)) && (ny < m)) && (dist[nx][ny] == -1))) {dist[nx][ny] = (dist[p.x][p.y] + 1); q.add(new point(nx,ny)); } }}pw.println(((atx + " ") + aty)); pw.close(); } } class point{ int x ,y ; public point( int x, int y){ this.x = x; this.y = y; } }
6	public class Solution{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; int[] x ; int[] y ; int n ; int X ,Y ; int[] d ; int[][] dist ; int sqr( int a){ return (a * a);} int dist( int X, int Y, int i){ return (sqr((X - x[i])) + sqr((Y - y[i])));} int[] dp ; byte[][] pred ; int rec( int mask){ if ( (dp[mask] == -1)) { int res = (1 << 29);  boolean ok = false; for ( int i = 0;(i < n);++i) if ( ((mask & (1 << i)) > 0)) {ok = true; int mm = (mask & (1 << i)); for ( int j = i;(j < n);j++) if ( ((mask & (1 << j)) > 0)) { int nmask = (mm & (1 << j));  int a = (((rec(nmask) + d[i]) + d[j]) + dist[i][j]); if ( (a < res)) {res = a; pred[0][mask] = (byte)i; pred[1][mask] = (byte)j; } } break;} if ( !ok) res = 0; dp[mask] = res; } return dp[mask];} void solve()throws IOException { X = ni(); Y = ni(); n = ni(); x = new int[n]; y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = ni(); y[i] = ni(); }d = new int[n]; dist = new int[n][n]; for ( int i = 0;(i < n);++i) d[i] = dist(X,Y,i); for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);j++) {dist[i][j] = dist(x[i],y[i],j); }pred = new byte[2][(1 << n)]; dp = new int[(1 << n)]; Arrays.fill(dp,-1); out.println(rec(((1 << n) - 1))); int a = ((1 << n) - 1); while((a > 0)){if ( (pred[0][a] != pred[1][a])) out.print((((((0 + " ") + (pred[0][a] + 1)) + " ") + (pred[1][a] + 1)) + " ")); else out.print((((0 + " ") + (pred[0][a] + 1)) + " ")); int na = (a & (1 << pred[0][a])); na &= (1 << pred[1][a]); a = na; }out.println(0); } public Solution()throws IOException{ Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } String ns()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int ni()throws IOException { return Integer.valueOf(ns());} public static void main( String[] args)throws IOException { new Solution(); } }
3	public class C{ public static void main( String[] args){ FastScanner scan = new FastScanner();  PrintWriter out = new PrintWriter(System.out); n = scan.nextInt(); mod = ((int)1e9 + 7); in = new char[n]; for ( int i = 0;(i < n);i++) in[i] = scan.next().charAt(0); dp = new Long[n][n]; out.println(go(0,0)); out.close(); } static long go( int at, int i){ if ( (at == (n - 1))) return 1; if ( (dp[at][i] != null)) return dp[at][i]; long res = 0; if ( (in[at] == 's')) {res += go((at + 1),i); res %= mod; if ( (i > 0)) {res += go(at,(i - 1)); res %= mod; } } else {res += go((at + 1),(i + 1)); res %= mod; }return dp[at][i] = res;} static Long[][] dp ; static int n ,mod ; static char[] in ; static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ try{br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } public String next(){ if ( st.hasMoreTokens()) return st.nextToken(); try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public long nextLong(){ return Long.parseLong(next());} public double nextDouble(){ return Double.parseDouble(next());} } }
3	public class utkarsh{ BufferedReader br ; void solve(){ br = new BufferedReader(new InputStreamReader(System.in)); int i ,j ,n ,mod = (int)(1e9 + 7); n = ni(); char c[] = new char[n]; for ( i = 0;(i < n);i++) c[i] = ns().charAt(0); long dp[][] = new long[n][n]; dp[0][0] = 1; for ( i = 1;(i < n);i++) {if ( (c[(i - 1)] == 'f')) {for ( j = 0;(j < i);j++) {dp[i][(j + 1)] = dp[(i - 1)][j]; }} else {for ( j = (i - 1);(j >= 0);j--) {dp[i][j] = (dp[(i - 1)][j] + dp[i][(j + 1)]); dp[i][j] %= mod; }}} long ans = 0; for ( long x :dp[(n - 1)]) {ans += x; ans %= mod; }System.out.println(ans); } int ni(){ return Integer.parseInt(ns());} String ip[] ; int len ,sz ; String ns(){ if ( (len >= sz)) {try{ip = br.readLine().split(" "); len = 0; sz = ip.length; }catch (IOException e){ throw (new InputMismatchException());} if ( (sz <= 0)) return "-1"; } return ip[len++];} public static void main( String[] args){ new utkarsh().solve(); } }
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); } } }
5	public class VkR2A{ static BufferedReader br ; public static void main( String[] args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); int nm[] = toIntArray();  int n = nm[0];  int a = nm[1];  int b = nm[2]; nm = toIntArray(); Arrays.sort(nm); int k = nm[(b - 1)];  int res = (nm[b] - k); System.out.println(res); } 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;} }
5	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  double[] left = new double[n];  double[] right = new double[n]; for ( int i = 0;(i < n);i++) { int x = sc.nextInt();  int a = sc.nextInt();  double l = (x - ((double)a / 2));  double r = (x + ((double)a / 2)); left[i] = l; right[i] = r; } int answer = 2; quickSort(left,right,0,(n - 1)); for ( int i = 0;(i < (n - 1));i++) {if ( ((left[(i + 1)] - right[i]) == t)) {answer++; } if ( ((left[(i + 1)] - right[i]) > t)) {answer += 2; } }System.out.println(answer); } int partition( double[] arr, int left, int right){ int i = left,j = right;  double tmp ;  double pivot = arr[((left + right) / 2)]; while((i <= j)){while((arr[i] < pivot))i++; while((arr[j] > pivot))j--; if ( (i <= j)) {tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; i++; j--; } };return i;} void quickSort( double[] arr, int left, int right){ int index = partition(arr,left,right); if ( (left < (index - 1))) quickSort(arr,left,(index - 1)); if ( (index < right)) quickSort(arr,index,right); } static int partition( double[] arr, double[] arr2, int left, int right){ int i = left,j = right;  double tmp ;  double tmp2 ;  double pivot = arr[((left + right) / 2)]; while((i <= j)){while((arr[i] < pivot))i++; while((arr[j] > pivot))j--; if ( (i <= j)) {tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; tmp2 = arr2[i]; arr2[i] = arr2[j]; arr2[j] = tmp2; i++; j--; } };return i;} static void quickSort( double[] arr, double[] arr2, int left, int right){ int index = partition(arr,arr2,left,right); if ( (left < (index - 1))) quickSort(arr,arr2,left,(index - 1)); if ( (index < right)) quickSort(arr,arr2,index,right); } }
1	public class Solution{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  HashSet<Integer> set = new HashSet<>(); for ( int i = 0;(i < n);i++) { int a = sc.nextInt(); if ( (a != 0)) {set.add(a); } }System.out.println(set.size()); } }
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.removeFirst();  int[] studying1 = {(studying[0] - 1),studying[1]};  int[] studying2 = {studying[0],(studying[1] - 1)};  int[] studying3 = {studying[0],(studying[1] + 1)};  int[] studying4 = {(studying[0] + 1),studying[1]}; if ( ((studying1[0] >= 1) && !burning[studying1[0]][studying1[1]])) {LitTrees.add(studying1); burning[studying1[0]][studying1[1]] = true; } if ( ((studying2[1] >= 1) && !burning[studying2[0]][studying2[1]])) {LitTrees.add(studying2); burning[studying2[0]][studying2[1]] = true; } if ( ((studying3[1] < (M + 1)) && !burning[studying3[0]][studying3[1]])) {LitTrees.add(studying3); burning[studying3[0]][studying3[1]] = true; } if ( ((studying4[0] < (N + 1)) && !burning[studying4[0]][studying4[1]])) {LitTrees.add(studying4); burning[studying4[0]][studying4[1]] = true; } lastTree = studying; }} }
3	public class InversionCounting{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); int[] a = Arrays.stream(br.readLine().split(" ")).mapToInt((x)->Integer.parseInt(x)).toArray();  boolean evenInv = true; for ( int i = 0;(i < a.length);i++) {for ( int j = 0;(j < (a.length - 1));j++) {if ( (a[j] > a[(j + 1)])) { int temp = a[j]; a[j] = a[(j + 1)]; a[(j + 1)] = temp; evenInv = !evenInv; } }} int q = Integer.parseInt(br.readLine()); for ( int i = 0;(i < q);i++) { int[] sw = Arrays.stream(br.readLine().split(" ")).mapToInt((x)->Integer.parseInt(x)).toArray();  int len = (sw[1] - sw[0]); if ( (((len * (len + 1)) % 4) != 0)) {evenInv = !evenInv; } if ( evenInv) {System.out.println("even"); } else {System.out.println("odd"); }}} }
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);  TaskE1 solver = new TaskE1();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) {solver.solve(i,in,out); }out.close(); } static class TaskE1{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int m = in.nextInt();  int[][] d = new int[2][(1 << n)];  int[] buf = new int[(1 << n)];  int[][] a = new int[m][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {a[j][i] = in.nextInt(); }} ArrayList<Integer> inds = new ArrayList<>(); for ( int i = 0;(i < m);++i) {inds.add(i); } int[][] finalA = a; Collections.sort(inds,new Comparator<Integer>(){public int compare( Integer i1, Integer i2){ int val1 = 0,val2 = 0; for ( int i = 0;(i < n);++i) {if ( (finalA[i1][i] > val1)) {val1 = finalA[i1][i]; } }for ( int i = 0;(i < n);++i) {if ( (finalA[i2][i] > val2)) {val2 = finalA[i2][i]; } }return -Integer.compare(val1,val2);} }); int newM = Math.min(m,(n + 1));  int[][] na = new int[newM][]; for ( int i = 0;(i < newM);++i) { int ind = inds.get(i); na[i] = a[ind]; }m = newM; a = na; for ( int i = 0;(i < m);++i) { int[] prev = d[(i % 2)],nx = d[((i + 1) % 2)]; for ( int shift = 0;(shift < n);++shift) { int[] b = new int[n]; for ( int j = 0;(j < n);++j) {b[j] = a[i][((j + shift) % n)]; }System.arraycopy(prev,0,buf,0,prev.length); for ( int j = 0;(j < n);++j) { int inc = b[j]; for ( int mask = 0;(mask < (1 << n));++mask) {if ( (((mask >> j) % 2) == 0)) { int val = (buf[mask] + inc);  int nm = (mask ^ (1 << j)); if ( (val > buf[nm])) {buf[nm] = val; } } }}for ( int mask = 0;(mask < (1 << n));++mask) {if ( (nx[mask] < buf[mask])) {nx[mask] = buf[mask]; } }}}out.printLine(d[(m % 2)][((1 << n) - 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 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 String nextToken(){ int c = readSkipSpace();  StringBuilder sb = new StringBuilder(); while(!isSpace(c)){sb.append((char)c); c = read(); }return sb.toString();} public String next(){ return nextToken();} 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;} } }
5	public class Main{ public static void main( String[] args){ Scanner kb = new Scanner(System.in);  int n = kb.nextInt();  int a[] = new int[n];  int b[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = kb.nextInt(); b[i] = a[i]; }Arrays.sort(a); int count = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) count++; }if ( (count <= 2)) System.out.println("YES"); else System.out.println("NO"); } }
1	public class TwoSets{ static int n ,a ,b ; static HashSet<Integer> arr = new HashSet<Integer>(); static HashSet<Integer> visited = new HashSet<Integer>(); static HashMap<Integer,Integer> result = new HashMap<Integer,Integer>(); static void dfs( int x, int parent, int len){ stack.push(x); visited.add(x); int children = 0; if ( ((a - x) > 0)) {if ( (((a - x) != parent) && arr.contains((a - x)))) {dfs((a - x),x,(len + 1)); children++; } } if ( ((b - x) > 0)) {if ( (((b - x) != parent) && arr.contains((b - x)))) {dfs((b - x),x,(len + 1)); children++; } } if ( (children == 0)) {if ( ((len % 2) == 1)) {System.out.println("NO"); System.exit(0); } else {while(!stack.isEmpty()){ int first = stack.pop();  int second = stack.pop(); if ( (first == (a - second))) {result.put(first,0); result.put(second,0); } else {result.put(first,1); result.put(second,1); }}}} } static Stack<Integer> stack = new Stack<Integer>(); public static void main( String[] args){ InputReader r = new InputReader(System.in); n = r.nextInt(); a = r.nextInt(); b = r.nextInt(); int[] list = new int[n]; for ( int i = 0;(i < n);i++) {list[i] = r.nextInt(); arr.add(list[i]); }for ( int x :arr) {if ( !visited.contains(x)) {if ( (arr.contains((a - x)) && arr.contains((b - x)))) continue; if ( (arr.contains((a - x)) || arr.contains((b - x)))) {dfs(x,-1,1); } else {System.out.println("NO"); System.exit(0); }} } PrintWriter out = new PrintWriter(System.out); out.println("YES"); for ( int i = 0;(i < list.length);i++) {if ( (result.get(list[i]) == null)) out.println(0); else out.println(result.get(list[i])); }out.close(); } 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());} } }
3	public class Main{ static PrintWriter out ; static InputReader ir ; static void solve(){ int n = ir.nextInt();  int[] a = ir.nextIntArray(n);  int m = ir.nextInt();  long ret = (mergeSort(a,0,n) % 2);  int p ,q ; for ( int i = 0;(i < m);i++) {p = (ir.nextInt() - 1); q = (ir.nextInt() - 1); if ( ((((q - p) % 4) == 1) || (((q - p) % 4) == 2))) ret ^= 1; f(ret); }} public static void f( long a){ if ( (a == 0)) {out.println("even"); } else out.println("odd"); } public static long mergeSort( int[] a, int left, int right){ long cnt = 0; if ( ((left + 1) < right)) { int mid = ((left + right) / 2); cnt += mergeSort(a,left,mid); cnt += mergeSort(a,mid,right); cnt += merge(a,left,mid,right); } return cnt;} public static long merge( int[] a, int left, int mid, int right){ long cnt = 0;  int n1 = (mid - left);  int n2 = (right - mid);  int[] l = new int[(n1 + 1)];  int[] r = new int[(n2 + 1)]; for ( int i = 0;(i < n1);i++) {l[i] = a[(left + i)]; }for ( int i = 0;(i < n2);i++) {r[i] = a[(mid + i)]; }l[n1] = Integer.MAX_VALUE; r[n2] = Integer.MAX_VALUE; for ( int i = 0,j = 0,k = left;(k < right);k++) {if ( (l[i] <= r[j])) {a[k] = l[i]; i++; } else {a[k] = r[j]; j++; cnt += (n1 - i); }}return cnt;} public static void main( String[] args)throws Exception { ir = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static class InputReader{ private InputStream in ; private byte[] buffer = new byte[1024]; private int curbuf ; private int lenbuf ; public InputReader( InputStream in){ this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte(){ if ( (curbuf >= lenbuf)) {curbuf = 0; try{lenbuf = in.read(buffer); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return false; } return true;} private int readByte(){ if ( hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private void skip(){ while((hasNextByte() && isSpaceChar(buffer[curbuf])))curbuf++; } public boolean hasNext(){ skip(); return hasNextByte();} public String next(){ if ( !hasNext()) throw (new NoSuchElementException()); StringBuilder sb = new StringBuilder();  int b = readByte(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} public int nextInt(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public long nextLong(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
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){ long n = in.nextLong();  long x = in.nextLong();  long y = in.nextLong();  long c = in.nextLong();  long tl ,tr ,tt = -1,t ; tl = 0; tr = (long)4e9; while((tl < tr)){t = ((tl + tr) >> 1); long cc = f(n,t,x,y); if ( (cc >= c)) {tt = t; tr = t; } else tl = (t + 1); }out.writeln(tt); } public static long f( long n, long t, long x, long y){ long res = (((((t * t) + t) / 2) * 4) + 1);  long s ; if ( ((x - t) < 1)) {s = ((t - x) + 1); res -= (s * s); } if ( ((y - t) < 1)) {s = ((t - y) + 1); res -= (s * s); } if ( ((x + t) > n)) {s = ((x + t) - n); res -= (s * s); } if ( ((y + t) > n)) {s = ((y + t) - n); res -= (s * s); } s = ((t - (Math.abs((x - 1)) + Math.abs((y - 1)))) - 1); if ( (s > 0)) res += (((s * s) + s) / 2); s = ((t - (Math.abs((x - 1)) + Math.abs((n - y)))) - 1); if ( (s > 0)) res += (((s * s) + s) / 2); s = ((t - (Math.abs((n - x)) + Math.abs((n - y)))) - 1); if ( (s > 0)) res += (((s * s) + s) / 2); s = ((t - (Math.abs((n - x)) + Math.abs((y - 1)))) - 1); if ( (s > 0)) res += (((s * s) + s) / 2); return res;} } 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());} } class OutputWriter{ private PrintWriter out ; public OutputWriter( Writer out){ this.out = new PrintWriter(out); } public OutputWriter( OutputStream out){ this.out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out))); } public void write( Object... o){ for ( Object x :o) out.print(x); } public void writeln( Object... o){ write(o); out.println(); } public void close(){ out.close(); } }
4	public class E2{ InputStream is ; FastWriter out ; String INPUT = ""; public static int[][] enumFIF( int n, int mod){ int[] f = new int[(n + 1)];  int[] invf = new int[(n + 1)]; f[0] = 1; for ( int i = 1;(i <= n);i++) {f[i] = (int)(((long)f[(i - 1)] * i) % mod); } long a = f[n];  long b = mod;  long p = 1,q = 0; while((b > 0)){ long c = (a / b);  long d ; d = a; a = b; b = (d % b); d = p; p = q; q = (d - (c * q)); }invf[n] = (int)((p < 0)?(p + mod):p); for ( int i = (n - 1);(i >= 0);i--) {invf[i] = (int)(((long)invf[(i + 1)] * (i + 1)) % mod); }return new int[][]{f,invf};} public static long[] enumPows( int a, int n, int mod){ a %= mod; long[] pows = new long[(n + 1)]; pows[0] = 1; for ( int i = 1;(i <= n);i++) pows[i] = ((pows[(i - 1)] * a) % mod); return pows;} void solve(){ int N = ni(); final int mod = ni();  long[] p2 = enumPows(2,1000,mod);  int[][] fif = enumFIF(1000,mod);  long[][] dp = new long[(N + 2)][(N + 1)]; dp[0][0] = 1; for ( int i = 0;(i <= (N + 1));i++) {for ( int j = 0;(j <= N);j++) {for ( int k = 1;((((i + k) + 1) <= (N + 1)) && ((j + k) <= N));k++) {dp[((i + k) + 1)][(j + k)] += (((dp[i][j] * fif[1][k]) % mod) * p2[(k - 1)]); dp[((i + k) + 1)][(j + k)] %= mod; }}} long ans = 0; for ( int i = 1;(i <= N);i++) {ans += (dp[(N + 1)][i] * fif[0][i]); ans %= mod; }out.println(ans); } 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 E2().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{ static private 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;} static private 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;} static private 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)); } }
0	public class ProblemA{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  int num1 ,num2 ; if ( ((n % 2) == 0)) {num1 = (n / 2); if ( ((num1 % 2) == 0)) {num2 = num1; } else {num1--; num2 = (num1 + 2); }} else {num1 = 9; num2 = (n - num1); }System.out.println(((num1 + " ") + num2)); } }
6	public class Main{ static HashSet<Integer> adjList[] ; public static void main( String[] args)throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));  StringBuilder stringBuilder = new StringBuilder();  String temp[] = bufferedReader.readLine().split(" ");  int V = Integer.parseInt(temp[0]);  int E = Integer.parseInt(temp[1]); adjList = new HashSet[V]; for ( int i = 0;(i < V);i++) adjList[i] = new HashSet<>(); for ( int i = 0;(i < E);i++) {temp = bufferedReader.readLine().split(" "); int x = (Integer.parseInt(temp[0]) - 1);  int y = (Integer.parseInt(temp[1]) - 1); adjList[y].add(x); adjList[x].add(y); }stringBuilder.append((solve(V) + "\n")); System.out.println(stringBuilder); } static private long solve( int V){ long dp[][] = new long[(1 << V)][V]; for ( int i = 0;(i < V);i++) dp[(1 << i)][i] = 1; for ( int mask = 1;(mask < (1 << V));mask++) { int first = Integer.numberOfTrailingZeros(mask); for ( int i = 0;(i < V);i++) {if ( (((mask & (1 << i)) == 0) || (first == i))) continue; for ( int j = 0;(j < V);j++) if ( (adjList[i].contains(j) && ((mask & (1 << j)) != 0))) dp[mask][i] += dp[(mask ^ (1 << i))][j]; }} long count = 0; for ( int mask = 1;(mask < (1 << V));mask++) { int first = Integer.numberOfTrailingZeros(mask); if ( (Integer.bitCount(mask) >= 3)) for ( int i = 0;(i < V);i++) {if ( adjList[first].contains(i)) count += dp[mask][i]; } }return (count / 2);} }
4	public class Main{ public static void main( String[] args)throws IOException,URISyntaxException { Reader.init(new FileInputStream("input.txt")); StringBuilder s = new StringBuilder();  boolean[][] vis = new boolean[Reader.nextInt()][Reader.nextInt()];  int k = Reader.nextInt(),r ,c ;  Queue<Point> q = new LinkedList<Point>(); while((k-- > 0)){r = (Reader.nextInt() - 1); c = (Reader.nextInt() - 1); vis[r][c] = true; q.add(new Point(r,c)); } Point end = null;  int[] x = {0,0,1,-1},y = {1,-1,0,0};  int a ,b ,i ; while(!q.isEmpty()){end = q.poll(); for ( i = 0;(i < 4);i++) {a = (end.x + x[i]); b = (end.y + y[i]); if ( (((((a >= 0) && (b >= 0)) && (a < vis.length)) && (b < vis[a].length)) && !vis[a][b])) {vis[a][b] = true; q.add(new Point(a,b)); } }}s.append((end.x + 1)).append(' ').append((end.y + 1)); PrintWriter p = new PrintWriter("output.txt"); p.println(s); p.close(); } }
5	public class CF_Chores{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int a = s.nextInt();  int b = s.nextInt();  long ar[] = new long[n]; for ( int i = 0;(i < n);i++) {ar[i] = s.nextLong(); }Arrays.sort(ar); long ret = 0; if ( (ar[b] == ar[(b - 1)])) System.out.println("0"); else {ret = (ar[b] - ar[(b - 1)]); System.out.println(ret); }} }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ ArrayList<Integer>[] g ; int n ,m ; boolean[][] have ; int[] x ; int[] y ; boolean[] used ; int stop ; public void solve( int testNumber, FastScanner in, PrintWriter out){ n = in.nextInt(); g = new ArrayList[n]; for ( int i = 0;(i < n);i++) g[i] = new ArrayList<>(); have = new boolean[n][n]; m = in.nextInt(); for ( int i = 0;(i < m);i++) { int a = in.nextInt();  int b = in.nextInt(); --a; --b; g[a].add(b); have[a][b] = true; } int res = Integer.MAX_VALUE; for ( int center = 0;(center < n);center++) res = Math.min(res,solve(center)); out.print(res); } int solve( int v){ stop = v; int withV = 0;  int add = 0; for ( int i = 0;(i < n);i++) if ( (i != v)) if ( have[v][i]) withV++; else add++; for ( int i = 0;(i < n);i++) if ( (i != v)) if ( have[i][v]) withV++; else add++; if ( have[v][v]) withV++; else add++; x = new int[n]; y = new int[n]; used = new boolean[n]; Arrays.fill(x,-1); Arrays.fill(y,-1); int matched = 0; for ( int i = 0;(i < n);i++) if ( ((i != v) && (x[i] == -1))) {Arrays.fill(used,false); if ( dfs(i)) matched++; } add += ((n - 1) - matched); add += ((m - withV) - matched); return add;} boolean dfs( int v){ if ( used[v]) return false; used[v] = true; for ( int to :g[v]) if ( ((to != stop) && (y[to] == -1))) {x[v] = to; y[to] = v; return true;} for ( int to :g[v]) if ( ((to != stop) && dfs(y[to]))) {x[v] = to; y[to] = v; return true;} return false;} } class FastScanner{ BufferedReader reader ; StringTokenizer tokenizer ; public FastScanner( InputStream inputStream){ reader = new BufferedReader(new InputStreamReader(inputStream)); } public String nextToken(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){ String line ; try{line = reader.readLine(); }catch (IOException e){ return null;} tokenizer = new StringTokenizer(line); }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ int n ; public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.nextInt(); int base = calc(in,out,0); if ( (base == 0)) {out.printLine("! 1"); out.flush(); return ;} if ( ((Math.abs(base) % 2) != 0)) {out.printLine("! -1"); out.flush(); return ;} int down = 0,up = (n / 2);  int sdown = ((base < 0)?-1:1);  int sup = ((up < 0)?-1:1); while(((up - down) > 1)){ int t = ((up + down) / 2);  int cur = calc(in,out,t); if ( (cur == 0)) {out.printLine(("! " + (t + 1))); out.flush(); return ;} int scur = ((cur < 0)?-1:1); if ( (scur == sdown)) {down = t; } else {up = t; }}throw (new RuntimeException());} private int calc( InputReader in, OutputWriter out, int val){ out.printLine(("? " + (val + 1))); out.flush(); int res1 = in.nextInt(); out.printLine(("? " + (((val + (n / 2)) % n) + 1))); out.flush(); int res2 = in.nextInt(); return (res1 - res2);} } 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(); } public void flush(){ writer.flush(); } } 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;} } }
1	public class codeforces{ public static void main( String[] args){ PrintWriter out = new PrintWriter(System.out);  Scanner s = new Scanner(System.in);  int t = s.nextInt(); for ( int tt = 0;(tt < t);tt++) { long n = s.nextInt();  long x = (long)Math.sqrt((n / 2));  long y = (long)Math.sqrt((n / 4)); if ( ((((x * x) * 2) == n) || (((y * y) * 4) == n))) {out.println("YES"); } else {out.println("NO"); }}out.close(); s.close(); } 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); } }
0	public class Main{ public static long GCF( long a, long b){ if ( (b == 0)) return a; else return GCF(b,(a % b));} public static long LCM( long a, long b){ return ((a * b) / GCF(a,b));} public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt(); if ( (n < 3)) System.out.println(n); else { long t1 = LCM(n,(n - 1));  long t2 = LCM((n - 2),(n - 3));  long l1 = LCM(t1,(n - 2));  long l2 = LCM(t1,(n - 3));  long l3 = LCM(n,t2);  long l4 = LCM((n - 1),t2); System.out.println(Math.max(l1,Math.max(l2,Math.max(l3,l4)))); }} }
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());} } }
5	public class cf166a{ static private boolean[][] matrix ; static private int n ; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  int[] p = new int[n];  int[] t = new int[n];  int[] score = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = sc.nextInt(); t[i] = sc.nextInt(); score[i] = ((p[i] * 100) + (50 - t[i])); } boolean[] called = new boolean[n];  int x = 0;  boolean check = false; while(true){ int max = 0;  int y = 0; for ( int i = 0;(i < n);i++) {if ( ((called[i] == false) && (score[i] > max))) {max = score[i]; } }for ( int i = 0;(i < n);i++) {if ( (max == score[i])) {called[i] = true; x++; y++; if ( (x == k)) {check = true; } } }if ( check) {System.out.println(y); break;} }} }
6	public class B implements Runnable{ String file = "input"; boolean TEST = false; double EPS = 1e-8; void solve()throws IOException { int n = nextInt(),k = nextInt(),A = nextInt();  int[] level = new int[n];  int[] loyal = new int[n]; for ( int i = 0;(i < n);i++) {level[i] = nextInt(); loyal[i] = nextInt(); } double res = 0; for ( int mask = 0;(mask < (1 << ((n + k) - 1)));mask++) {if ( (Integer.bitCount(mask) != k)) continue; int[] L = new int[n];  int x = mask; for ( int i = 0;(i < n);i++) {L[i] = loyal[i]; while(((x % 2) == 1)){L[i] += 10; x /= 2; }L[i] = min(L[i],100); x /= 2; } double tmp = 0; for ( int w = 0;(w < (1 << n));w++) { double p = 1.;  double B = 0; for ( int i = 0;(i < n);i++) if ( (((w >> i) & 1) != 0)) p *= (L[i] / 100.); else {p *= ((100 - L[i]) / 100.); B += level[i]; }if ( ((Integer.bitCount(w) * 2) > n)) tmp += p; else tmp += (p * (A / (A + B))); }res = max(res,tmp); }out.printf("%.8f\n",res); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(input.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} BufferedReader input ; PrintWriter out ; StringTokenizer st ; int test ; void init()throws IOException { if ( TEST) input = new BufferedReader(new FileReader((file + ".in"))); else input = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new BufferedOutputStream(System.out)); } public static void main( String[] args)throws IOException { new Thread(null,new B(),"",(1 << 20)).start(); } }
5	public class test{ public static void main( String[] args){ Scanner kb = new Scanner(System.in);  int n = kb.nextInt();  int a = kb.nextInt();  int b = kb.nextInt();  int array[] = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = kb.nextInt(); }Arrays.sort(array); int k = 0;  int t1 = 0;  int t2 = 0; for ( int i = 0;(i < b);i++) {t1 = array[i]; if ( (i < (n - 1))) {t2 = array[(i + 1)]; k = (t2 - t1); } else k = 0; }System.out.println(k); } }
0	public class Main{ static void solve()throws IOException { String str = br.readLine();  StringBuffer sb1 = new StringBuffer(str);  StringBuffer sb2 = new StringBuffer(str);  StringBuffer sb3 = new StringBuffer(str); sb1.deleteCharAt((sb1.length() - 1)); sb2.deleteCharAt((sb2.length() - 2)); int n1 = Integer.parseInt(sb1.toString());  int n2 = Integer.parseInt(sb2.toString());  int n3 = Integer.parseInt(sb3.toString()); out.println(Math.max(n1,Math.max(n2,n3))); } static BufferedReader br ; static StringTokenizer st ; static PrintWriter out ; public static void main( String[] args)throws IOException { InputStream input = System.in; br = new BufferedReader(new InputStreamReader(input)); out = new PrintWriter(System.out); solve(); out.close(); } 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();} }
6	public class A{ static int n ,m ,start ; static boolean[][] adj ; static long[][] mem ; public static void main( String[] args)throws Throwable { Scanner sc = new Scanner(System.in); n = sc.nextInt(); m = sc.nextInt(); adj = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int u = (sc.nextInt() - 1);  int v = (sc.nextInt() - 1); adj[u][v] = true; adj[v][u] = true; }mem = new long[(n + 1)][(1 << n)]; for ( int i = 0;(i <= n);i++) Arrays.fill(mem[i],-1); long ans = 0; for ( int i = 0;(i < n);i++) {start = i; ans += dp(i,(1 << i)); }System.out.println((ans / 2)); } public static long dp( int i, int msk){ if ( (mem[i][msk] != -1)) return mem[i][msk]; long ans = 0; if ( (adj[i][start] && (Integer.bitCount(msk) > 2))) ans++; for ( int j = (start + 1);(j < n);j++) {if ( (adj[i][j] && ((msk & (1 << j)) == 0))) {ans += dp(j,(msk | (1 << j))); } }return mem[i][msk] = ans;} 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;  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)); }} }
4	public class Main{ static private StreamTokenizer in ; static private PrintWriter out ; static private BufferedReader inB ; static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} {try{inB = new BufferedReader(new InputStreamReader(new FileInputStream("input.txt"))); out = new PrintWriter(new FileOutputStream("output.txt")); }catch (Exception e){ } in = new StreamTokenizer(inB); }static private int[][] mind ; static private boolean[][] used ; static private int n ,m ; public static void main( String[] args)throws Exception { n = nextInt(); m = nextInt(); int k = nextInt();  int[][] mas = new int[k][2]; for ( int i = 0;(i < k);i++) {mas[i][0] = (nextInt() - 1); mas[i][1] = (nextInt() - 1); }mind = new int[n][m]; used = new boolean[n][m]; for ( int i = 0;(i < n);i++) {Arrays.fill(mind[i],Integer.MAX_VALUE); } ArrayDeque<int[]> ad = new ArrayDeque<int[]>(); for ( int i = 0;(i < k);i++) {ad.add(new int[]{mas[i][0],mas[i][1],0}); }while(!ad.isEmpty()){ int[] cur = ad.remove(); if ( used[cur[0]][cur[1]]) continue; int x = cur[0];  int y = cur[1];  int d = cur[2]; mind[x][y] = ++d; used[x][y] = true; if ( (isValid((x + 1),y) && !used[(x + 1)][y])) ad.add(new int[]{(x + 1),y,d}); if ( (isValid(x,(y + 1)) && !used[x][(y + 1)])) ad.add(new int[]{x,(y + 1),d}); if ( (isValid(x,(y - 1)) && !used[x][(y - 1)])) ad.add(new int[]{x,(y - 1),d}); if ( (isValid((x - 1),y) && !used[(x - 1)][y])) ad.add(new int[]{(x - 1),y,d}); } int max = Integer.MIN_VALUE;  int maxx = 0,maxy = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (mind[i][j] > max)) {max = mind[i][j]; maxx = (i + 1); maxy = (j + 1); } }}out.println(((maxx + " ") + maxy)); out.flush(); } static private boolean isValid( int x, int y){ return ((((x >= 0) && (x < n)) && (y >= 0)) && (y < m));} static private void println( Object o)throws Exception { System.out.println(o); } static private void exit( Object o)throws Exception { println(o); exit(); } static private void exit(){ System.exit(0); } }
5	public class A{ public static void main( String[] ar)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String s1[] = br.readLine().split(" ");  int n = Integer.parseInt(s1[0]);  int m = Integer.parseInt(s1[1]);  int a[] = new int[n];  String s2[] = br.readLine().split(" ");  long S = 0; for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(s2[i]); S += (long)a[i]; }Arrays.sort(a); m = a[(n - 1)]; int last = 1;  int t = 1; for ( int i = 1;(i < (n - 1));i++) {if ( (a[i] == last)) t++; else {t++; last = (last + 1); }}if ( (last < m)) {t += (m - last); } else t++; System.out.println((S - t)); } }
5	public class Solution{ static private StringTokenizer st ; static private java.io.BufferedReader reader ; static private java.io.BufferedWriter writer ; static private int nextInt(){ return Integer.parseInt(st.nextToken());} static private void initTokenizer()throws Exception { st = new StringTokenizer(reader.readLine()); } public static void main( String[] args)throws Exception { reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in),(1 << 20)); writer = new java.io.BufferedWriter(new java.io.OutputStreamWriter(System.out)); initTokenizer(); int n = nextInt();  int m = nextInt();  int k = nextInt(); initTokenizer(); int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }Arrays.sort(a); int total = k;  int cnt = 0; while(((total < m) && (cnt < a.length))){total += (a[((a.length - 1) - cnt)] - 1); cnt++; }if ( (total >= m)) System.out.println(cnt); else System.out.println(-1); } }
0	public class A{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); long x = nextLong();  long y = nextLong();  long ans = 0; while(((x > 0) && (y > 0))){if ( (x > y)) {ans += (x / y); x %= y; } else {ans += (y / x); y %= x; }}System.out.println(ans); } static private long nextLong()throws IOException { return Long.parseLong(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
5	public class Main implements Runnable{ PrintWriter out ; BufferedReader in ; StringTokenizer st ; void solve()throws Exception { int n = nextInt();  int[] a = new int[n];  int sum = 0; for ( int i = 0;(i < n);++i) {a[i] = nextInt(); sum += a[i]; }Arrays.sort(a); int ans = 0,csum = 0; for ( int i = (n - 1);((csum <= (sum - csum)) && (i >= 0));i--) {csum += a[i]; ans++; }out.println(ans); } public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); } } public static void main( String[] args)throws Exception { new Main().run(); } int nextInt(){ return Integer.parseInt(nextToken());} String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{ String line = in.readLine(); st = new StringTokenizer(line); }catch (Exception e){ return null;} }return st.nextToken();} }
3	public class LogicalExpression{ int N = 256; void solve(){ Expression[] E = new Expression[N]; for ( int i = 0;(i < N);i++) E[i] = new Expression(); E[Integer.parseInt("00001111",2)].update_f("x"); E[Integer.parseInt("00110011",2)].update_f("y"); E[Integer.parseInt("01010101",2)].update_f("z"); for ( int l = 2;(l < 40);l++) {for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < N);j++) {if ( (((E[i].e != null) && (E[j].t != null)) && (((E[i].e.length() + E[j].t.length()) + 1) == l))) {E[(i | j)].update_e(((E[i].e + '|') + E[j].t)); } if ( (((E[i].t != null) && (E[j].f != null)) && (((E[i].t.length() + E[j].f.length()) + 1) == l))) {E[(i & j)].update_t(((E[i].t + '&') + E[j].f)); } }if ( (E[i].f != null)) E[(i ^ (N - 1))].update_f(('!' + E[i].f)); }} String[] res = new String[N]; for ( int i = 0;(i < N);i++) res[i] = E[i].calc_best(); int n = in.nextInt(); for ( int i = 0;(i < n);i++) { int x = Integer.parseInt(in.nextToken(),2); out.println(res[x]); }} static class Expression{ String e ,t ,f ; Expression(){ } public Expression( String e, String t, String f){ this.e = e; this.t = t; this.f = f; } String calc_best(){ String best = e; if ( (compare(best,t) > 0)) best = t; if ( (compare(best,f) > 0)) best = f; return best;} void update_e( String ne){ if ( ((e == null) || (compare(e,ne) > 0))) {e = ne; update_f((('(' + e) + ')')); } } void update_t( String nt){ if ( ((t == null) || (compare(t,nt) > 0))) {t = nt; update_e(t); } } void update_f( String nf){ if ( ((f == null) || (compare(f,nf) > 0))) {f = nf; update_t(f); } } int compare( String a, String b){ if ( (a.length() != b.length())) return Integer.compare(a.length(),b.length()); return a.compareTo(b);} } public static void main( String[] args){ in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); new LogicalExpression().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 nA{ Scanner in ; PrintWriter out ; void solve(){ 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 nowsum = 0;  int kol = 0; for ( int i = (n - 1);(i >= 0);i--) {if ( (nowsum <= (sum / 2))) {nowsum += a[i]; kol++; } else {break;}}out.println(kol); } void run(){ in = new Scanner(System.in); out = new PrintWriter(System.out); try{solve(); }finally{out.close(); }} public static void main( String[] args){ new nA().run(); } }
0	public class C{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer tokenizer = new StringTokenizer(br.readLine());  BigInteger left = new BigInteger(tokenizer.nextToken());  BigInteger right = new BigInteger(tokenizer.nextToken());  BigInteger val = right.subtract(left).add(new BigInteger(("" + 1))); if ( (val.intValue() < 3)) {System.out.println(-1); return ;} BigInteger a ,b ,c ;  BigInteger i = left; while((i.intValue() <= right.intValue())){ BigInteger temp1 = i;  BigInteger temp2 = i.add(new BigInteger(("" + 1)));  BigInteger j = temp2.add(new BigInteger(("" + 1))); while((j.intValue() <= right.intValue())){ BigInteger b1 = temp2;  BigInteger b2 = j;  BigInteger b3 = temp1;  BigInteger gcd = b1.gcd(b2); if ( (gcd.intValue() == 1)) { BigInteger gcd2 = b2.gcd(b3); if ( (gcd2.intValue() != 1)) {a = b3; b = b1; c = b2; System.out.print((((((a + " ") + b) + " ") + c) + " ")); System.out.println(); return ;} } j = j.add(new BigInteger(("" + 1))); }i = i.add(new BigInteger(("" + 1))); }System.out.println(-1); } }
5	public class Solution implements Runnable{ void solve()throws Exception { int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); }Arrays.sort(a); if ( (k >= m)) {out.println(0); return ;} int sum = k; for ( int j = (n - 1);(j >= 0);j--) {sum--; sum += a[j]; if ( (sum >= m)) {out.println((n - j)); return ;} }out.println(-1); } BufferedReader in ; PrintWriter out ; FastScanner sc ; static Throwable uncaught ; public static void main( String[] args)throws Throwable { Thread t = new Thread(null,new Solution(),"",(1 << 26)); 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());} }
5	public class Main{ private FastScanner scanner = new FastScanner(); public static void main( String[] args){ new Main().solve(); } private List<Integer>[] gr = new ArrayList[(1000_000 + 5)]; private int dp[][] = new int[21][(1000_000 + 5)]; private boolean used[] = new boolean[(1000_000 + 5)]; void init( int v, int p){ Stack<Integer> st = new Stack<>(); st.push(v); st.push(p); while(!st.isEmpty()){p = st.pop(); v = st.pop(); used[v] = true; dp[0][v] = p; for ( int i = 1;(i <= 20);i++) {if ( (dp[(i - 1)][v] != -1)) {dp[i][v] = dp[(i - 1)][dp[(i - 1)][v]]; } }for ( int next :gr[v]) {if ( !used[next]) {st.push(next); st.push(v); } }}} private void solve(){ int n = scanner.nextInt(),k = scanner.nextInt();  boolean[] ans = new boolean[(1000_000 + 5)]; for ( int i = 0;(i < n);i++) {gr[i] = new ArrayList<>(); }for ( int i = 0;(i < (n - 1));i++) { int u = (scanner.nextInt() - 1),v = (scanner.nextInt() - 1); gr[u].add(v); gr[v].add(u); }k = ((n - k) - 1); ans[(n - 1)] = true; init((n - 1),(n - 1)); int t ,d ,next ; for ( int i = (n - 2);(i >= 0);i--) {t = i; d = 1; if ( ans[i]) {continue;} for ( int j = 20;(j >= 0);j--) {next = dp[j][t]; if ( ((next != -1) && !ans[next])) {t = next; d += (1 << j); } }if ( (d <= k)) {k -= d; t = i; while(!ans[t]){ans[t] = true; t = dp[0][t]; }} if ( (k == 0)) {break;} } StringBuilder sb = new StringBuilder(""); for ( int i = 0;(i < n);i++) {if ( !ans[i]) {sb.append((i + 1)).append(" "); } }System.out.println(sb.toString()); } class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
2	public class Main{ public static void main( String[] args)throws IOException { Scanner s = new Scanner(System.in);  long k = s.nextLong();  long dp[] = new long[13];  long x = 9;  int i = 1;  long ansx = 0;  int ansi = 0; for ( ;(i < 13);i++) {dp[i] = (dp[(i - 1)] + (x * i)); x *= 10; if ( (k <= dp[i])) {ansx = x; ansi = i; break;} if ( (dp[i] > 1000000000000l)) break; }if ( (ansi < 2)) {System.out.println(k); return ;} k -= dp[(ansi - 1)]; long st = (long)Math.pow(10,(ansi - 1));  long div = (k / ansi); if ( ((k % ansi) == 0)) div--; k -= (div * ansi); System.out.println(findKthDigit((st + div),k)); } static private Long findKthDigit( long xx, long k){ int z = (int)k;  ArrayList<Long> arr = new ArrayList(); while((xx > 0)){arr.add((xx % 10)); xx /= 10; }return arr.get((arr.size() - z));} }
2	public class D{ 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)));  long L = nextLong();  long R = nextLong(); if ( (L == R)) {System.out.println(0); return ;} String s1 = Long.toBinaryString(L),s2 = Long.toBinaryString(R); while((s1.length() != s2.length()))s1 = ("0" + s1); for ( int i = 0;(i < s1.length());i++) {if ( (s1.charAt(i) != s2.charAt(i))) { int pow = (s1.length() - i); System.out.println(((long)Math.pow(2,pow) - 1)); return ;} }pw.close(); } static private long nextLong()throws IOException { return Long.parseLong(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
6	public class Handbag{ public static class Item{ int x ; int y ; Item( int x, int y){ this.x = x; this.y = y; } public int dist( Item i){ int dx = (x - i.x);  int dy = (y - i.y); return ((dx * dx) + (dy * dy));} } public static int solve( int bitNum){ if ( (bitNum == ((1 << N) - 1))) return 0; if ( (bits[bitNum] != -1)) return bits[bitNum]; int ans = Integer.MAX_VALUE;  int j = 0; for ( int i = 1;(i < N);i++) {if ( ((bitNum & (1 << i)) == 0)) {if ( (j == 0)) {ans = ((2 * items[0].dist(items[i])) + solve((bitNum | (1 << i)))); j = i; } else { int dist1 = items[0].dist(items[i]);  int dist2 = items[i].dist(items[j]);  int dist3 = items[j].dist(items[0]); ans = Math.min(ans,(((dist1 + dist2) + dist3) + solve(((bitNum | (1 << i)) | (1 << j))))); }} }return bits[bitNum] = ans;} static void printOptPath( int bitNum){ if ( (bitNum == ((1 << N) - 1))) return ; int j = 0; for ( int i = 1;(i < N);i++) if ( ((bitNum & (1 << i)) == 0)) {if ( (j == 0)) {j = i; if ( (bits[bitNum] == ((2 * items[0].dist(items[i])) + solve((bitNum | (1 << i)))))) {pw.print(((" " + i) + " 0")); printOptPath((bitNum | (1 << i))); return ;} } else if ( (bits[bitNum] == (((items[0].dist(items[i]) + items[i].dist(items[j])) + items[j].dist(items[0])) + solve(((bitNum | (1 << i)) | (1 << j)))))) {pw.print(((((" " + j) + " ") + i) + " 0")); printOptPath(((bitNum | (1 << i)) | (1 << j))); return ;} } } static private int N = 0; static private Item[] items ; static private int[] bits ; static private PrintWriter pw = new PrintWriter(System.out); public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] input = br.readLine().split(" ");  Item handbag = new Item(Integer.parseInt(input[0]),Integer.parseInt(input[1])); N = (Integer.parseInt(br.readLine()) + 1); items = new Item[N]; for ( int n = 1;(n < N);n++) {input = br.readLine().split(" "); items[n] = new Item(Integer.parseInt(input[0]),Integer.parseInt(input[1])); }items[0] = handbag; bits = new int[(1 << N)]; Arrays.fill(bits,-1); int ans = solve((1 << 0)); pw.println(ans); pw.print("0"); printOptPath((1 << 0)); pw.close(); } }
4	public class CFTemplate{ static final long MOD = 1000000007L; static final int INF = 1100000000; static final int NINF = -100000; static FastScanner sc ; static PrintWriter pw ; static final int[][] dirs = {{-1,0},{1,0},{0,-1},{0,1}}; public static void main( String[] args){ sc = new FastScanner(); pw = new PrintWriter(System.out); ArrayList<Integer> primes = new ArrayList<Integer>(); for ( int i = 2;(i <= 3200);i++) { boolean p = true; for ( int j = 2;((j * j) <= i);j++) {if ( ((i % j) == 0)) {p = false; break;} }if ( p) primes.add(i); } int Q = sc.ni(); for ( int q = 0;(q < Q);q++) { int N = sc.ni();  int K = sc.ni();  int[] nums = new int[(N + 1)]; for ( int i = 1;(i <= N);i++) nums[i] = sc.ni(); for ( int i = 1;(i <= N);i++) {for ( int p :primes) { int c = 0; while(((nums[i] % p) == 0)){nums[i] /= p; c++; }if ( ((c % 2) == 1)) nums[i] *= p; }} TreeSet<Integer> ts = new TreeSet<Integer>();  HashMap<Integer,Integer> last = new HashMap<Integer,Integer>();  int[][] dp = new int[(N + 1)][(K + 1)]; for ( int i = 1;(i <= N);i++) {if ( last.containsKey(nums[i])) {ts.add(last.get(nums[i])); } last.put(nums[i],i); int[] inds = new int[(K + 1)];  int ind = 0; for ( int x :ts.descendingSet()) {inds[ind] = x; if ( (ind == K)) break; ind++; }for ( int j = 0;(j <= K);j++) {dp[i][j] = INF; if ( (j > 0)) dp[i][j] = dp[i][(j - 1)]; for ( int k = 0;(k <= j);k++) {dp[i][j] = Math.min(dp[i][j],(dp[inds[k]][(j - k)] + 1)); }}}pw.println(dp[N][K]); }pw.close(); } public static void sort( int[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( long[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( int[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<int[]>(){}); } public static void sort( long[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<long[]>(){}); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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());} long nl(){ return Long.parseLong(next());} } }
6	public class CF1102F{ 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[][] aa = new int[n][m]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < m);j++) aa[i][j] = Integer.parseInt(st.nextToken()); } int[][] dd = new int[n][n]; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) { int d = Integer.MAX_VALUE; for ( int h = 0;(h < m);h++) d = Math.min(d,Math.abs((aa[i][h] - aa[j][h]))); dd[i][j] = dd[j][i] = d; } int[][] dd_ = new int[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) { int d = Integer.MAX_VALUE; for ( int h = 0;(h < (m - 1));h++) d = Math.min(d,Math.abs((aa[i][h] - aa[j][(h + 1)]))); dd_[i][j] = d; }if ( (n == 1)) {System.out.println(dd_[0][0]); return ;} int[] ii = new int[(1 << n)]; for ( int i = 0;(i < n);i++) ii[(1 << i)] = i; int[][][] dp = new int[(1 << n)][n][n]; for ( int b = 0;(b < (1 << n));b++) for ( int u = b;(u > 0);u &= (u - 1)) { int i = ii[(u & -u)]; for ( int v = (b ^ (1 << i));(v > 0);v &= (v - 1)) { int j = ii[(v & -v)]; if ( (b == ((1 << i) ^ (1 << j)))) dp[b][i][j] = dd[i][j]; else { int x = 0; for ( int w = ((b ^ (1 << i)) ^ (1 << j));(w > 0);w &= (w - 1)) { int k = ii[(w & -w)]; x = Math.max(x,Math.min(dp[(b ^ (1 << j))][i][k],dd[k][j])); }dp[b][i][j] = x; }}} int b = ((1 << n) - 1);  int x = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) if ( (i != j)) x = Math.max(x,Math.min(dp[b][i][j],dd_[i][j])); System.out.println(x); } }
0	public class Main{ public static boolean isPrime( long num){ int divisor = 2;  boolean bandera = true; while((bandera && (divisor < num))){if ( ((num % divisor) == 0)) {bandera = false; break;} else {divisor++; }}return bandera;} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  int uno = 4;  int dos = (n - 4); while((isPrime(dos) || isPrime(uno))){dos--; uno++; }System.out.println(((uno + " ") + dos)); } }
1	public class javatemp{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int ans = 1000; in.readLine(); String s = in.readLine();  int H = 0; for ( int i = 0;(i < s.length());i++) if ( (s.charAt(i) == 'H')) H++; for ( int i = 0;(i < s.length());i++) { int count = 0; for ( int j = 0;(j < H);j++) if ( (s.charAt(((i + j) % s.length())) == 'T')) count++; ans = Math.min(ans,count); }System.out.println(ans); } }
2	public class digits{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long k = Long.parseLong(br.readLine());  long temp = (9 * (int)Math.pow(10,0));  int count = 0;  long initial = 0; while((k > temp)){count++; initial = temp; temp += ((9 * (long)Math.pow(10,count)) * (count + 1)); } long index = (((k - initial) - 1) % (count + 1));  long num = ((long)Math.pow(10,count) + (((k - initial) - 1) / (count + 1))); System.out.println((num + "")); } }
2	public class A{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long N ,K ,tmp ,ans = 0;  String s[] = br.readLine().trim().split(" "); N = Long.parseLong(s[0]); K = Long.parseLong(s[1]); long l = 1,r = N,mid ; while((l <= r)){mid = ((l + r) / 2); tmp = ((mid * (mid + 1)) / 2); tmp -= N; tmp += mid; if ( (tmp == K)) {ans = (N - mid); break;} else if ( (tmp > K)) r = (mid - 1); else l = (mid + 1); }System.out.println(ans); } }
4	public class C{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int t = sc.nextInt(); for ( int z = 0;(z < t);++z) { int n = sc.nextInt();  ArrayList<Integer> al = new ArrayList<>(); for ( int i = 0;(i < n);++i) { int x = sc.nextInt(); if ( (x == 1)) {al.add(x); } else {while((al.get((al.size() - 1)) != (x - 1))){al.remove((al.size() - 1)); }al.remove((al.size() - 1)); al.add(x); } StringBuilder pr = new StringBuilder();  String d = ""; for ( int xx :al) {pr.append((d + xx)); d = "."; }System.out.println(pr); }}} }
0	public class Solve4{ public static void main( String[] args)throws IOException { FastReader sc = new FastReader();  int x = sc.nextInt();  int y = sc.nextInt();  int z = sc.nextInt();  int t1 = sc.nextInt();  int t2 = sc.nextInt();  int t3 = sc.nextInt(); if ( ((Math.abs((x - y)) * t1) < (((Math.abs((x - z)) + Math.abs((x - y))) * t2) + (3 * t3)))) System.out.println("NO"); else System.out.println("YES"); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(br.readLine()); } return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
2	public class B{ static long n ,k ; public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out); n = in.nextLong(); k = in.nextLong(); long ans = (n - TernarySearch(0,n)); pw.println(ans); pw.close(); } static long cal( long m){ long x = ((m * (m + 1)) / 2);  long y = (x - (n - m)); return abs((k - y));} static long TernarySearch( long l, long r){ long m1 ,m2 ; while(((r - l) > 5)){m1 = (((2 * l) + r) / 3); m2 = ((l + (2 * r)) / 3); if ( (cal(m1) > cal(m2))) l = m1; else r = m2; } long min = cal(l),i = l; for ( ;(l <= r);l++) { long t = cal(l); if ( (t < min)) {min = t; i = l; } }return i;} }
3	public class Solver{ public static void main( String[] args){ FastReader in = new FastReader();  PrintWriter out = new PrintWriter(System.out);  TaskC solver = new TaskC(in,out); solver.solve(); out.close(); } static class TaskC{ FastReader in ; PrintWriter out ; public TaskC( FastReader in, PrintWriter out){ this.in = in; this.out = out; } public void solve(){ solveA(); } public void solveA(){ int n = in.nextInt();  int[] inputColors = in.nextIntArray(n);  int colors = 0; Arrays.sort(inputColors); for ( int i = 0;(i < inputColors.length);i++) {if ( (inputColors[i] == -1)) {continue;} int colorCode = inputColors[i];  boolean colorFound = false; for ( int j = i;(j < inputColors.length);j++) {if ( ((inputColors[j] != -1) && ((inputColors[j] % colorCode) == 0))) {if ( !colorFound) {colorFound = true; colors++; } inputColors[j] = -1; } }}out.println(colors); } } static private long gcd( long a, long b){ if ( (a == 0)) {return b;} return gcd((b % a),a);} 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());} int[] nextIntArray( int n){ int[] array = new int[n]; for ( int i = 0;(i < n);i++) {array[i] = nextInt(); }return array;} } }
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 Main{ public static void main( String[] args){ Scanner in = new Scanner(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  Vector<Integer> mas = new Vector<Integer>();  Vector<Integer> mas2 = new Vector<Integer>();  int index = -1;  boolean res = false; for ( int i = 0;(i < n);i++) {mas.add(in.nextInt()); if ( ((i != 0) && (mas.get(i) < mas.get((i - 1))))) {index = (i - 1); break;} }if ( (index == -1)) res = true; else { int min = mas.get((index + 1));  int minIndex = (index + 1); for ( int i = (index + 2);(i < n);i++) {mas.add(in.nextInt()); if ( (mas.get(i) <= min)) {min = mas.get(i); minIndex = i; } }mas2.addAll(mas); mas.set(minIndex,mas.get(index)); mas.set(index,min); int o = mas.hashCode(); Collections.sort(mas); int nw = mas.hashCode(); res = (nw == o); }if ( !res) {mas = mas2; for ( int i = (n - 1);(i >= 0);i--) {if ( ((i != (n - 1)) && (mas.get(i) > mas.get((i + 1))))) {index = (i + 1); break;} }if ( (index == -1)) res = true; else { int max = mas.get((index - 1));  int maxIndex = (index - 1); for ( int i = (index - 1);(i >= 0);i--) {if ( (mas.get(i) >= max)) {max = mas.get(i); maxIndex = i; } }mas.set(maxIndex,mas.get(index)); mas.set(index,max); int o = mas.hashCode(); Collections.sort(mas); int nw = mas.hashCode(); res = (res || (nw == o)); }} if ( res) out.println("YES"); else out.println("NO"); out.close(); } }
5	public class Main{ static int sum = 0; public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = ni(sc),x[] = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) x[i] = ni(sc); sort(x); if ( (x[n] == 1)) {x[n] = 2; for ( int i = 1;(i <= n);i++) System.out.print((x[i] + " ")); } else {x[0] = 1; for ( int i = 0;(i < n);i++) System.out.print((x[i] + " ")); }}} static int ni( Scanner in){ return in.nextInt();} }
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{ long MOD = ((long)1e9 + 7); long[][] dp ; int[] a ; public void solve( int testNumber, InputReader in, OutputWriter out){ int N = in.nextInt(); a = new int[N]; dp = new long[N][N]; int i ; for ( i = 0;(i < N);i++) { char c = in.nextChar(); if ( (c == 'f')) {a[i] = 1; } }out.printLine(iterative()); } public long iterative(){ int i ,j ,N = a.length,lastLevel = 0; dp[0][0] = 1; for ( i = 1;(i < N);i++) {if ( (a[(i - 1)] == 1)) {lastLevel++; for ( j = 1;(j <= lastLevel);j++) {dp[i][j] = dp[(i - 1)][(j - 1)]; }} else {dp[i][(N - 1)] = dp[(i - 1)][(N - 1)]; for ( j = (N - 2);(j >= 0);j--) {dp[i][j] = ((dp[i][(j + 1)] + dp[(i - 1)][j]) % MOD); }}} long ans = 0; for ( i = 0;(i < N);i++) {ans += dp[(N - 1)][i]; }return (ans % MOD);} } 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 char nextChar(){ return next().charAt(0);} } 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(); } } }
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.readInt();  boolean[] isF = new boolean[n]; for ( int i = 0;(i < n);i++) {isF[i] = (in.readCharacter() == 'f'); } int[][] mem = new int[(n + 1)][(n + 1)]; mem[n][0] = 1; for ( int idx = (n - 1);(idx >= 0);idx--) {for ( int indentLevel = 0;(indentLevel < n);indentLevel++) {mem[(idx + 1)][(indentLevel + 1)] += mem[(idx + 1)][indentLevel]; mem[(idx + 1)][(indentLevel + 1)] %= MiscUtils.MOD7; int res = (isF[idx]?(mem[(idx + 1)][(indentLevel + 1)] - mem[(idx + 1)][indentLevel]):mem[(idx + 1)][indentLevel]); mem[idx][indentLevel] = ((res + MiscUtils.MOD7) % MiscUtils.MOD7); }}out.printLine(mem[0][0]); } } 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 char readCharacter(){ int c = read(); while(isSpaceChar(c)){c = read(); }return (char)c;} 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); } } }
6	public class ProblemC{ public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int[] pt = readPoint(s);  int n = Integer.valueOf(s.readLine());  int[][] xp = new int[(n + 1)][]; for ( int i = 1;(i <= n);i++) {xp[i] = readPoint(s); }xp[0] = pt; int[][] dist = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= n);j++) { int dx = Math.abs((xp[i][0] - xp[j][0]));  int dy = Math.abs((xp[i][1] - xp[j][1])); dist[i][j] = ((dx * dx) + (dy * dy)); }} int[][] dist2 = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= n);j++) {dist2[i][j] = ((dist[0][i] + dist[i][j]) + dist[j][0]); }} int[] dp = new int[(1 << n)];  int[][] dp_prev = new int[2][(1 << n)]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; for ( int i = 0;(i < (1 << n));i++) {if ( (dp[i] == Integer.MAX_VALUE)) {continue;} int base = dp[i]; for ( int y = 0;(y < n);y++) {if ( ((i & (1 << y)) >= 1)) {break;} for ( int z = (y + 1);(z < n);z++) {if ( ((i & (1 << z)) >= 1)) {continue;} int ti = ((i | (1 << y)) | (1 << z));  int d = dist2[(y + 1)][(z + 1)]; if ( (dp[ti] > (base + d))) {dp[ti] = (base + d); dp_prev[0][ti] = (z + 1); dp_prev[1][ti] = (y + 1); } }}} int bestOnes = 0; for ( int i = 0;(i < (1 << n));i++) {if ( (dp[i] == Integer.MAX_VALUE)) {continue;} int sub = (((1 << n) - 1) - i);  int add = 0; for ( int j = 0;(j < n);j++) {if ( ((sub & (1 << j)) >= 1)) {add += (dist[0][(j + 1)] * 2); } }if ( ((dp[i] + add) < dp[((1 << n) - 1)])) {dp[((1 << n) - 1)] = (dp[i] + add); bestOnes = sub; } } StringBuffer b = new StringBuffer(); b.append(" 0"); for ( int i = 0;(i < n);i++) {if ( ((bestOnes & (1 << i)) >= 1)) {b.append(" ").append((i + 1)).append(" ").append(0); } }out.println(dp[((1 << n) - 1)]); int nptn = (((1 << n) - 1) - bestOnes); while((nptn >= 1)){ int i1 = dp_prev[0][nptn];  int i2 = dp_prev[1][nptn]; if ( (i1 >= 1)) {nptn -= (1 << (i1 - 1)); b.append(" ").append(i1); } if ( (i2 >= 1)) {nptn -= (1 << (i2 - 1)); b.append(" ").append(i2); } b.append(" ").append(0); }out.println(b.substring(1)); out.flush(); } static private int[] readPoint( BufferedReader s)throws IOException { int[] ret = new int[2];  String[] data = s.readLine().split(" "); ret[0] = Integer.valueOf(data[0]); ret[1] = Integer.valueOf(data[1]); return ret;} }
1	public class Main{ public static void main( String[] args){ Scanner stdin = new Scanner(System.in); test(stdin); stdin.close(); } public static void test( Scanner stdin){ int n = stdin.nextInt();  int min = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int a = stdin.nextInt(); if ( ((int)((1.0 * a) / Math.max(i,((n - i) - 1))) < min)) {min = (int)((1.0 * a) / Math.max(i,((n - i) - 1))); } }System.out.println(min); } }
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 == 1)) { double[] ret = new double[N]; for ( int i = 0;(i < N);++i) if ( ((alive & (1 << i)) != 0)) {ret[i] = 1; break;} return memo[alive] = ret;} if ( (memo[alive] != null)) return memo[alive]; double[] ret = new double[N]; for ( int j = 0;(j < N);++j) if ( ((alive & (1 << j)) != 0)) { double[] nxt = dp((alive & (1 << j))); for ( int i = 0;(i < N);++i) ret[i] += (die[j][alive] * nxt[i]); } 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(); double[] ret = dp(((1 << N) - 1)); for ( int i = 0;(i < (N - 1));++i) out.printf("%.8f ",ret[i]); out.printf("%.8f\n",ret[(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();} } }
1	public class Main{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  String s ;  int i ,j ; for ( i = 0;(i < n);i++) {s = sc.next(); j = 0; boolean ok ; while(((s.charAt(j) >= 'A') && (s.charAt(j) <= 'Z')))j++; while((((j < s.length()) && (s.charAt(j) >= '0')) && (s.charAt(j) <= '9')))j++; if ( (j == s.length())) ok = true; else ok = false; String s1 = "",s2 = ""; if ( ok) {j = 0; while(((s.charAt(j) >= 'A') && (s.charAt(j) <= 'Z'))){s1 += s.charAt(j); j++; }while((j < s.length())){s2 += s.charAt(j); j++; } int v = 0,p = 1; for ( j = (s1.length() - 1);(j >= 0);j--) {v += (p * ((s1.charAt(j) - 'A') + 1)); p *= 26; }System.out.println(((("R" + s2) + "C") + v)); } else {j = 1; while(((s.charAt(j) >= '0') && (s.charAt(j) <= '9'))){s1 += s.charAt(j); j++; }j++; while((j < s.length())){s2 += s.charAt(j); j++; } Integer a = new Integer(s2);  String s3 = "";  int d ; while((a > 0)){d = (a % 26); a /= 26; if ( (d == 0)) {d = 26; a--; } s3 = (Character.toUpperCase(Character.forDigit((9 + d),36)) + s3); }System.out.println((s3 + s1)); }}} }
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;} }
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 Pipeline{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong(); if ( (n == 1)) {System.out.println(0); return ;} if ( (k >= n)) {System.out.println(1); return ;} long total = ((((k + 2) * (k - 1)) / 2) - (k - 2)); if ( (total < n)) {System.out.println(-1); return ;} int i = 2,j = (int)k; while((i < j)){ int m = (((i + j) + 1) / 2); total = ((((k + m) * ((k - m) + 1)) / 2) - (k - m)); if ( (total < n)) j = (m - 1); else i = m; }System.out.println(((k - i) + 1)); } }
6	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(),k = Int();  int A[][] = new int[n][2]; for ( int i = 0;(i < n);i++) {A[i][0] = Int(); A[i][1] = Int(); } Solution sol = new Solution(out); sol.solution(A,k); }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; } long dp[][] ; int mod = 1000000007; int time ; public void solution( int[][] A, int t){ this.time = t; dp = new long[4][(1 << (A.length + 2))]; for ( int i = 0;(i < dp.length);i++) {Arrays.fill(dp[i],-1); } long a = dfs(A,0,((1 << A.length) - 1)); out.println(a); } public long dfs( int[][] A, int pre, int state){ int use = cal(A,state); if ( ((time - use) == 0)) {return 1;} if ( ((time < use) || (state == 0))) {return 0;} if ( (dp[pre][state] != -1)) return dp[pre][state]; long res = 0; for ( int i = 0;(i < A.length);i++) {if ( (((state & (1 << i)) != 0) && (A[i][1] != pre))) {res += dfs(A,A[i][1],(state ^ (1 << i))); res %= mod; } }dp[pre][state] = res; return res;} public int cal( int[][] A, int state){ int t = 0; for ( int i = 0;(i < A.length);i++) {if ( ((state & (1 << i)) == 0)) {t += A[i][0]; } }return t;} }
5	public class CottageVillage{ public Scanner in = new Scanner(System.in); public PrintStream out = System.out; public int n ,t ; public Pair[] v ; public void main(){ n = in.nextInt(); t = in.nextInt(); int i ; v = new Pair[n]; for ( i = 0;(i < n);++i) v[i] = new Pair((in.nextInt() * 2),in.nextInt()); Arrays.sort(v); int res = 2; for ( i = 0;((i + 1) < n);++i) {if ( (((v[i].x + v[i].y) + (2 * t)) == (v[(i + 1)].x - v[(i + 1)].y))) ++res; else if ( (((v[i].x + v[i].y) + (2 * t)) < (v[(i + 1)].x - v[(i + 1)].y))) res += 2; }out.println(res); } private class Pair implements Comparable<Pair>{ public int x ,y ; public Pair( int xx, int yy){ x = xx; y = yy; } } public static void main( String[] args){ new CottageVillage().main(); } }
1	public class TaskB{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int k = s.nextInt();  int[] nums = new int[(100000 + 10)];  int first = -1,last = -1;  Set<Integer> dif = new TreeSet<Integer>(); s.nextLine(); for ( int i = 0;(i < n);i++) {nums[i] = s.nextInt(); dif.add(nums[i]); if ( (dif.size() == k)) {last = i; break;} }dif.clear(); for ( int i = last;(i >= 0);i--) {dif.add(nums[i]); if ( (dif.size() == k)) {first = i; break;} }if ( (last == -1)) System.out.print("-1 -1"); else System.out.print(((Integer.toString((first + 1)) + " ") + Integer.toString((last + 1)))); } }
5	public class A{ final int MOD = ((int)1e9 + 7); final double eps = 1e-12; final int INF = (int)1e9; public A(){ int N = sc.nextInt();  int M = sc.nextInt();  int K = sc.nextInt();  Integer[] S = sc.nextInts(); sort(S,reverseOrder()); int cnt = K,res ; for ( res = 0;((res < N) && (cnt < M));++res) cnt += (S[res] - 1); exit(((cnt < M)?-1:res)); } static MyScanner sc ; static class MyScanner{ public String next(){ newLine(); return line[index++];} public int nextInt(){ return Integer.parseInt(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;} 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){ pw.println(build(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( Object... a){ StringBuilder b = new StringBuilder(); for ( Object o :a) append(b,o); return b.toString().trim();} static void append( StringBuilder b, Object o){ if ( o.getClass().isArray()) { int L = Array.getLength(o); for ( int i = 0;(i < L);++i) append(b,Array.get(o,i)); } else if ( (o instanceof Iterable<?>)) {for ( Object p :(Iterable<?>)o) append(b,p); } else b.append(" ").append(o); } public static void main( String[] args){ sc = new MyScanner(); new A(); exit(); } static void start(){ t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t ; static long millis(){ return System.currentTimeMillis();} }
2	public class Main{ static int n ,k ; public static void main( String[] args)throws IOException { FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out); n = sc.nextInt(); k = sc.nextInt(); long l = 0;  long r = (n + 1); while(((l + 1) != r)){ long m = ((r + l) / 2); if ( check(m)) l = m; else r = m; }pw.print((((l * (l + 1L)) / 2L) - k)); pw.close(); } public static boolean check( long m){ return ((((m * (m + 1)) / 2) - (n - m)) <= k);} } class FastScanner{ static BufferedReader br ; static StringTokenizer st = new StringTokenizer(""); public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } public String next()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(br.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} }
1	public class TestClass11{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  OutputWriter out = new OutputWriter(System.out);  int n = in.readInt();  String s = in.readString();  int low[] = new int[26];  int upper[] = new int[26];  boolean islow[] = new boolean[26];  boolean isupper[] = new boolean[26]; Arrays.fill(low,Integer.MAX_VALUE); Arrays.fill(upper,Integer.MAX_VALUE); int ans[] = new int[n];  int finalsans = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int c = s.charAt(i); if ( ((c >= 'a') && (c <= 'z'))) {islow[(c - 'a')] = true; } else {isupper[(c - 'A')] = true; }}for ( int i = (n - 1);(i >= 0);i--) { int c = s.charAt(i); if ( ((c >= 'a') && (c <= 'z'))) {low[(c - 'a')] = i; } else {upper[(c - 'A')] = i; }for ( int j = 0;(j < 26);j++) {if ( (islow[j] == true)) {ans[i] = Math.max(ans[i],low[j]); } }for ( int j = 0;(j < 26);j++) {if ( (isupper[j] == true)) {ans[i] = Math.max(ans[i],upper[j]); } }finalsans = Math.min(((ans[i] - i) + 1),finalsans); }System.out.println(finalsans); } } 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); } } 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(); } }
0	public class Lcm{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long n = Long.parseLong(br.readLine()); if ( (n <= 2)) System.out.println(n); else {if ( ((n % 6) == 0)) {System.out.println((((n - 1) * (n - 2)) * (n - 3))); } else if ( ((n % 2) == 0)) {System.out.println(((n * (n - 1)) * (n - 3))); } else {System.out.println(((n * (n - 1)) * (n - 2))); }}} }
0	public class RENAMETHISBITCH{ public static void main( String[] args){ try(Scanner sc=new Scanner(System.in)){ int n = sc.nextInt();  BigInteger m = sc.nextBigInteger(); System.out.println(m.mod(BigInteger.valueOf(2).pow(n))); }catch (Exception e){ e.printStackTrace(); } } }
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'));} }
1	public class P3{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  String s = ""; while((s.length() == 0)){s = sc.nextLine(); } char[] pokemons = s.toCharArray();  Set<Character> pokemonTypes = new HashSet<>(); for ( int i = 0;(i < n);i++) {pokemonTypes.add(pokemons[i]); } int types = pokemonTypes.size();  int l = 0;  int r = 0;  int min = n;  Map<Character,Integer> currentPokemons = new HashMap<>(); while((r < n)){while(((currentPokemons.size() < types) && (r < n))){ char pokemon = pokemons[r++]; currentPokemons.merge(pokemon,1,(a,b)->(a + b)); }min = Math.min((r - l),min); while((currentPokemons.size() == types)){ char pokemon = pokemons[l++]; if ( (currentPokemons.get(pokemon) == 1)) {currentPokemons.remove(pokemon); } else {min = Math.min((r - l),min); currentPokemons.put(pokemon,(currentPokemons.get(pokemon) - 1)); }}}min = Math.min(min,((r - l) + 1)); min = Math.max(min,types); System.out.println(min); } }
3	public class a{ public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out);  int n = nextInt();  int v[] = new int[n];  int fv[] = new int[101]; for ( int i = 0;(i < n);i++) {v[i] = nextInt(); }Arrays.sort(v); for ( int i = 0;(i < n);i++) {for ( int j = i;(j < n);j++) {if ( ((v[j] % v[i]) == 0)) {v[j] = v[i]; fv[v[j]]++; } }} int ans = 0; for ( int i = 0;(i < 101);i++) {if ( (fv[i] != 0)) {ans++; } }out.println(ans); out.close(); } static BufferedReader br ; static StringTokenizer st = new StringTokenizer(""); static String next()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(br.readLine()); }return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(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 ; }
5	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int produzeni = in.nextInt();  int devices = in.nextInt();  int stekovi = in.nextInt();  int[] filter = new int[produzeni]; for ( int i = 0;(i < produzeni);i++) {filter[i] = in.nextInt(); }Arrays.sort(filter); int filt_no = (filter.length - 1); if ( (devices <= stekovi)) {System.out.println("0"); return ;} int used = 0; while((devices > stekovi)){try{stekovi += (filter[filt_no--] - 1); }catch (Exception e){ System.out.println("-1"); return ;} }System.out.println(((filter.length - filt_no) - 1)); } }
5	public class Main{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[][] point = new int[n][]; for ( int i = 0;(i < n);i++) point[i] = new int[]{sc.nextInt(),sc.nextInt()}; Arrays.sort(point,(a,b)->((a[0] - a[1]) - (b[0] - b[1]))); TreeMap<Integer,Integer> tm = new TreeMap<>();  int ans = 0; for ( int i = (n - 1);(i >= 0);i--) { int x = point[i][0],w = point[i][1];  Map.Entry<Integer,Integer> cur = tm.ceilingEntry((x + w));  int curRes ; if ( (cur == null)) curRes = 1; else curRes = (cur.getValue() + 1); ans = Math.max(ans,curRes); Map.Entry<Integer,Integer> upper = tm.ceilingEntry((x - w)); if ( ((upper == null) || (upper.getValue() < curRes))) tm.put((x - w),curRes); }System.out.println(ans); } }
1	public class two{ public static void main( String[] args)throws IOException,FileNotFoundException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  HashSet<Integer> good = new HashSet<>();  int i = 1; for ( ;(i <= (int)1e9);) {i <<= 1; good.add(i); }for ( i = 3;(((i * i) * 2) <= (int)1e9);i++) {good.add(((i * i) * 2)); } int beg = 4; for ( i = 3;((beg + (i * 4)) <= (int)1e9);i += 2) {good.add((beg + (i * 4))); beg += (i * 4); } int t = Integer.parseInt(in.readLine()); while((t-- > 0)){ int n = Integer.parseInt(in.readLine()); if ( good.contains(n)) {System.out.println("YES"); } else {System.out.println("NO"); }}} }
6	public class CF1238E{ static long[][] Q ; static int N ; static int M ; static long[] mem ; static long[] sums ; public static void main( String[] args)throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for ( String ln ;((ln = in.readLine()) != null);) { StringTokenizer st = new StringTokenizer(ln); N = parseInt(st.nextToken()); M = parseInt(st.nextToken()); char[] S = in.readLine().toCharArray(); Q = new long[M][M]; mem = new long[(1 << M)]; Arrays.fill(mem,-1); for ( int i = 1;(i < N);i++) Q[(S[(i - 1)] - 'a')][(S[i] - 'a')] = Q[(S[i] - 'a')][(S[(i - 1)] - 'a')] = (Q[(S[(i - 1)] - 'a')][(S[i] - 'a')] + 1); calculateSums(); for ( int i = ((1 << M) - 1);(i >= 0);i--) f(i); System.out.println(f(0)); }} static void calculateSums(){ sums = new long[(1 << M)]; Arrays.fill(sums,-1); for ( int u = 0;(u < (1 << M));u++) {if ( (sums[u] == -1)) {sums[u] = 0; for ( int j = 0;(j < M);j++) for ( int k = (j + 1);(k < M);k++) if ( ((((u & (1 << j)) == 0) && ((u & (1 << k)) != 0)) || (((u & (1 << j)) != 0) && ((u & (1 << k)) == 0)))) sums[u] += Q[j][k];  int neg = (u & ((1 << M) - 1)); sums[neg] = sums[u]; } }} static long f( int u){ if ( (bitCount(u) == M)) return 0; if ( (mem[u] >= 0)) return mem[u]; long min = 10000000000L; for ( int i = 0;(i < M);i++) if ( ((u & (1 << i)) == 0)) {u = (u | (1 << i)); min = Math.min((f(u) + sums[u]),min); u = (u ^ (1 << i)); } return mem[u] = min;} }
1	public class Round364_div2_C{ public static void main( String[] args)throws IOException { FastReader in = new FastReader(System.in);  PrintWriter out = new PrintWriter(System.out); solve(in,out); out.flush(); } public static void solve( FastReader in, PrintWriter out){ int n = in.readInt();  String s = in.readString();  int totalCnt = (int)s.chars().distinct().count();  Map<Character,Integer> curCnts = new HashMap<>();  int solution = s.length();  int i = 0; for ( int j = 0;(j < s.length());j++) { char sj = s.charAt(j); curCnts.put(sj,(curCnts.getOrDefault(sj,0) + 1)); while((curCnts.getOrDefault(s.charAt(i),0) > 1)){ char si = s.charAt(i);  int siCnt = curCnts.get(si); if ( (siCnt > 1)) {curCnts.put(si,(siCnt - 1)); } else {curCnts.remove(si); }i++; }if ( (curCnts.size() == totalCnt)) {solution = Math.min(solution,((j - i) + 1)); } }out.println(solution); } static class FastReader{ private final InputStream stream ; private int current ; private int size ; private byte[] buffer = new byte[(1024 * 8)]; public FastReader( InputStream stream){ this.stream = stream; current = 0; size = 0; } public int readInt(){ int sign = 1;  int abs = 0;  int c = readNonEmpty(); if ( (c == '-')) {sign = -1; c = readAny(); } do {if ( ((c < '0') || (c > '9'))) {throw (new IllegalStateException());} abs = ((10 * abs) + (c - '0')); c = readAny(); }while(!isEmpty(c));return (sign * abs);} public String readString(){ StringBuffer sb = new StringBuffer();  int c ; do {c = readAny(); }while(isEmpty(c));do {sb.append((char)c); c = readAny(); }while(!isEmpty(c));return sb.toString();} private int readAny(){ try{if ( (current >= size)) {current = 0; size = stream.read(buffer); if ( (size < 0)) {return -1;} } }catch (IOException e){ throw (new RuntimeException("Failed to readAny next byte",e));} return buffer[current++];} private int readNonEmpty(){ int result ; do {result = readAny(); }while(isEmpty(result));return result;} static private boolean isEmpty( int c){ return (((((c == ' ') || (c == '\t')) || (c == '\n')) || (c == '\r')) || (c == -1));} } }
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"); } }
0	public class cf343a{ static FastIO in = new FastIO(),out = in; public static void main( String[] args){ out.println(go(in.nextLong(),in.nextLong())); out.close(); } static long go( long a, long b){ return ((b == 0)?0:(go(b,(a % b)) + (a / b)));} static class FastIO extends PrintWriter{ BufferedReader br ; StringTokenizer st ; public FastIO(){ this(System.in,System.out); } public FastIO( InputStream in, OutputStream out){ super(new BufferedWriter(new OutputStreamWriter(out))); br = new BufferedReader(new InputStreamReader(in)); scanLine(); } public void scanLine(){ try{st = new StringTokenizer(br.readLine().trim()); }catch (Exception e){ throw (new RuntimeException(e.getMessage()));} } public int numTokens(){ if ( !st.hasMoreTokens()) {scanLine(); return numTokens();} return st.countTokens();} public String next(){ if ( !st.hasMoreTokens()) {scanLine(); return next();} return st.nextToken();} public long nextLong(){ return Long.parseLong(next());} } }
6	public class Main{ public static void main( String[] args){ new Main().run(); } void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),m = sc.nextInt();  boolean[][] bs = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int s = (sc.nextInt() - 1),t = (sc.nextInt() - 1); bs[s][t] = bs[t][s] = true; } long res = 0; for ( int i = 0;(i < n);i++) {res += calc(bs,((n - 1) - i)); }System.out.println((res / 2)); } long calc( boolean[][] bs, int n){ long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {if ( bs[i][n]) dp[(1 << i)][i]++; }for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) if ( (((i >> j) & 1) == 1)) for ( int k = 0;(k < n);k++) if ( ((((i >> k) & 1) == 0) && bs[j][k])) {dp[(i | (1 << k))][k] += dp[i][j]; } } long res = 0; for ( int i = 0;(i < (1 << n));i++) for ( int j = 0;(j < n);j++) if ( ((Integer.bitCount(i) >= 2) && bs[j][n])) res += dp[i][j]; return res;} }
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(""); }} }
5	public class A2{ 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(),k = (next() - 1);  int x[] = new int[n]; for ( int i = 0;(i < n);i++) x[i] = (((100 - next()) * 100) + next()); Arrays.sort(x); int res = 0,t = x[k]; for ( int i = 0;(i < n);i++) if ( (t == x[i])) res++; out.println(res); out.println(); out.close(); } }
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 = 405; 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); static int[][] dp = new int[N][N]; static int[] p2 = new int[N]; static int[] fac = new int[N]; static int[] ifac = new int[N]; static int M ; public static int mul( int a, int b){ return (int)(((1l * a) * b) % M);} public static int poww( int a, int b){ int r = 1; while((b > 0)){if ( ((b % 2) == 1)) r = mul(r,a); a = mul(a,a); b >>= 1; }return r;} public static int inv( int x){ return poww(x,(M - 2));} public static int add( int a, int b){ a += b; if ( (a >= M)) a -= M; return a;} public static int bino( int n, int k){ return mul(fac[n],mul(ifac[(n - k)],ifac[k]));} public static void main( String[] args)throws IOException { int n = r.nextInt(); M = r.nextInt(); fac[0] = 1; ifac[0] = 1; p2[0] = 1; for ( int i = 1;(i <= n);++i) {fac[i] = mul(fac[(i - 1)],i); ifac[i] = inv(fac[i]); p2[i] = mul(p2[(i - 1)],2); } int ans = 0; dp[0][0] = 1; for ( int i = 0;(i <= n);++i) {for ( int k = 0;(k <= i);++k) {for ( int j = 1;(j <= ((n - i) + 1));++j) {dp[((i + j) + 1)][(k + j)] = add(dp[((i + j) + 1)][(k + j)],mul(dp[i][k],mul(p2[(j - 1)],bino((j + k),j)))); }}}for ( int i = 0;(i <= (n + 1));++i) {ans = add(ans,dp[(n + 1)][i]); }pw.print(ans); 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);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ static final int modular = (int)(1e9 + 7); public void solve( int testNum, InputReader in, PrintWriter out){ int n = in.nextInt();  int ans = 0;  String[] g = new String[n];  int[][] dp = new int[2][n]; for ( int i = 0;(i < n);i++) {g[i] = in.next(); }if ( (n == 1)) {out.println(1); return ;} dp[0][0] = 1; for ( int i = 1;(i < n);i++) {if ( g[(i - 1)].equals("f")) {dp[1][0] = 0; for ( int j = 1;(j < n);j++) {dp[1][j] = dp[0][(j - 1)]; }} else {dp[1][(n - 1)] = dp[0][(n - 1)]; for ( int j = (n - 2);(j >= 0);j--) {dp[1][j] = (dp[1][(j + 1)] + dp[0][j]); dp[1][j] = (dp[1][j] % modular); }}for ( int j = 0;(j < n);j++) {dp[0][j] = dp[1][j]; }if ( (i == (n - 1))) {for ( int j = 0;(j < n);j++) {ans = (ans + dp[1][j]); ans = (ans % modular); }} }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 Solution implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; int[] x ; int[] y ; int n ; int X ,Y ; int[] d ; int[][] dist ; int sqr( int a){ return (a * a);} int dist( int X, int Y, int i){ return (sqr((X - x[i])) + sqr((Y - y[i])));} int[] dp ; byte[][] pred ; int rec( int mask){ if ( (dp[mask] == -1)) { int res = (1 << 29);  boolean ok = false; for ( int i = 0;(i < n);++i) if ( ((mask & (1 << i)) > 0)) {ok = true; int mm = (mask & (1 << i)); for ( int j = i;(j < n);j++) if ( ((mask & (1 << j)) > 0)) { int nmask = (mm & (1 << j));  int a = (((rec(nmask) + d[i]) + d[j]) + dist[i][j]); if ( (a < res)) {res = a; pred[0][mask] = (byte)i; pred[1][mask] = (byte)j; } } break;} if ( !ok) res = 0; dp[mask] = res; } return dp[mask];} void solve()throws IOException { X = ni(); Y = ni(); n = ni(); x = new int[n]; y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = ni(); y[i] = ni(); }d = new int[n]; dist = new int[n][n]; for ( int i = 0;(i < n);++i) d[i] = dist(X,Y,i); for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);j++) {dist[i][j] = dist(x[i],y[i],j); }pred = new byte[2][(1 << n)]; dp = new int[(1 << n)]; Arrays.fill(dp,-1); out.println(rec(((1 << n) - 1))); int a = ((1 << n) - 1); while((a > 0)){if ( (pred[0][a] != pred[1][a])) out.print((((((0 + " ") + (pred[0][a] + 1)) + " ") + (pred[1][a] + 1)) + " ")); else out.print((((0 + " ") + (pred[0][a] + 1)) + " ")); int na = (a & (1 << pred[0][a])); na &= (1 << pred[1][a]); a = na; }out.println(0); } public Solution()throws IOException{ Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } String ns()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int ni()throws IOException { return Integer.valueOf(ns());} public static void main( String[] args)throws IOException,InterruptedException { Thread th = new Thread(null,new Solution(),"",536870912); th.start(); th.join(); } }
5	public class A{ public static void main( String[] args){ try(Scanner s=new Scanner(System.in)){final int n = s.nextInt(); final int m = s.nextInt(); final int k = s.nextInt(); final int[] a = new int[n]; for ( int i = 0;(i < a.length);++i) {a[i] = s.nextInt(); }Arrays.sort(a); int i = (a.length - 1);  int available = k;  int filters = 0; while(((available < m) && (i >= 0))){available -= 1; available += a[i]; filters++; i--; }if ( (available < m)) {System.out.println(-1); } else {System.out.println(filters); } }} }
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(); } }
1	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ int n = sc.nextInt();  String s = sc.next();  int sum = 0; for ( int i = 0;(i < s.length());i++) {if ( (s.charAt(i) == '+')) {sum++; } if ( ((s.charAt(i) == '-') && (sum != 0))) {sum--; } }System.out.println(sum); }} }
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 c1523 implements Runnable{ public static void main( String[] args){ try{new Thread(null,new c1523(),"process",(1 << 26)).start(); }catch (Exception e){ System.out.println(e); } } static class Task{ static final int oo = Integer.MAX_VALUE; static final long OO = Long.MAX_VALUE; public void solve( int testNumber, FastReader sc, PrintWriter out){ int N = sc.nextInt();  int[] arr = sc.readArray(N);  Stack<Integer> cur = new Stack<>();  StringBuilder sb = new StringBuilder(""); for ( int i = 0;(i < N);i++) {if ( (arr[i] == 1)) {cur.add(1); } else {while((cur.peek() != (arr[i] - 1)))cur.pop(); cur.pop(); cur.add(arr[i]); }for ( int each :cur) {sb.append((each + ".")); }sb.deleteCharAt((sb.length() - 1)); sb.append("\n"); }out.println(sb); } } static long binpow( long a, long b, long m){ a %= m; long res = 1; while((b > 0)){if ( ((b & 1) == 1)) res = ((res * a) % m); a = ((a * a) % m); b >>= 1; }return res;} 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());} long nextLong(){ return Long.parseLong(next());} int[] readArray( int size){ int[] a = new int[size]; for ( int i = 0;(i < size);i++) {a[i] = nextInt(); }return a;} } }
0	public class Cf270a{ public static void main( String[] args)throws IOException { InputStreamReader fin = new InputStreamReader(System.in);  Scanner scr = new Scanner(fin);  int n = scr.nextInt();  int x = 0;  int y = 0; if ( ((n % 2) == 0)) {x = 4; y = (n - x); } else {x = 9; y = (n - x); } PrintWriter fout = new PrintWriter(System.out); fout.print(((x + " ") + y)); fout.flush(); fout.close(); } }
5	public class kMultRedo{ static int n ; static int k ; public static void main( String[] args){ Set<Integer> set = new TreeSet<Integer>();  FastScanner s = new FastScanner(); n = s.nextInt(); k = s.nextInt(); int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); }Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( ((a[i] % k) != 0)) {set.add(a[i]); } else {if ( !set.contains((a[i] / k))) {set.add(a[i]); } }}System.out.println(set.size()); } public 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());} } }
0	public class A{ public static void main( String[] args){ FastScanner sc = new FastScanner();  long a = sc.nextLong();  long b = sc.nextLong();  long result = 0L; while(((a != 0) && (b != 0))){if ( (a > b)) {result += (a / b); a = (a % b); } else {result += (b / a); b = (b % a); } long gcd = gcd(a,b); a /= gcd; b /= gcd; }System.out.println(result); } static private long gcd( long a, long b){ while(((a != 0) && (b != 0))){if ( (a < b)) { long tmp = a; a = b; b = tmp; } a %= b; }return (a + b);} public 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());} } }
1	public class Main{ public static void main( String[] args){ var sc = new Scanner(System.in);  var pw = new PrintWriter(System.out);  int T = Integer.parseInt(sc.next()); for ( int t = 0;(t < T);t++) { int n = Integer.parseInt(sc.next());  boolean ok = false; if ( ((n % 2) == 0)) { int a = (n / 2);  int b = (int)Math.sqrt(a); if ( ((b * b) == a)) {ok = true; } } if ( ((n % 4) == 0)) { int a = (n / 4);  int b = (int)Math.sqrt(a); if ( ((b * b) == a)) {ok = true; } } if ( ok) {pw.println("YES"); } else {pw.println("NO"); }}pw.flush(); } }
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(); } }
3	public class Main{ static FastScanner sc = new FastScanner(); static Output out = new Output(System.out); static final int[] dx = {0,1,0,-1}; static final int[] dy = {-1,0,1,0}; static final long MOD = (long)(1e9 + 7); static final long INF = (Long.MAX_VALUE / 2); static final int e5 = (int)1e5; public static class Solver{ public Solver(){ int N = sc.nextInt();  boolean[] flag = new boolean[101]; for ( int i = 0;(i < N);i++) {flag[sc.nextInt()] = true; } int ans = 0; for ( int i = 1;(i <= 100);i++) {if ( flag[i]) {ans++; for ( int j = (i * 2);(j <= 100);j += i) {flag[j] = false; }} }out.println(ans); } public static void sort( int[] a){ shuffle(a); Arrays.sort(a); } public static void sort( long[] a){ shuffle(a); Arrays.sort(a); } public static void shuffle( int[] arr){ int n = arr.length;  Random rnd = new Random(); for ( int i = 0;(i < n);++i) { int tmp = arr[i];  int randomPos = (i + rnd.nextInt((n - i))); arr[i] = arr[randomPos]; arr[randomPos] = tmp; }} public static void shuffle( long[] arr){ int n = arr.length;  Random rnd = new Random(); for ( int i = 0;(i < n);++i) { long tmp = arr[i];  int randomPos = (i + rnd.nextInt((n - i))); arr[i] = arr[randomPos]; arr[randomPos] = tmp; }} } public static void main( String[] args){ new Solver(); out.flush(); } static class FastScanner{ private 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;} static private boolean isPrintableChar( int c){ return ((33 <= c) && (c <= 126));} private void skipUnprintable(){ while((hasNextByte() && !isPrintableChar(buffer[ptr])))ptr++; } public boolean hasNext(){ skipUnprintable(); 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 nextLong(){ 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))) {return (minus?-n:n);} else {throw (new NumberFormatException());}b = readByte(); }} public int nextInt(){ return (int)nextLong();} } static class Output extends PrintWriter{ private long startTime ; public Output( PrintStream ps){ super(ps); } public void print( int[] a, String separator){ for ( int i = 0;(i < a.length);i++) {if ( (i == 0)) print(a[i]); else print((separator + a[i])); }println(); } public void print( long[] a, String separator){ for ( int i = 0;(i < a.length);i++) {if ( (i == 0)) print(a[i]); else print((separator + a[i])); }println(); } public void print( String[] a, String separator){ for ( int i = 0;(i < a.length);i++) {if ( (i == 0)) print(a[i]); else print((separator + a[i])); }println(); } public void print( ArrayList a, String separator){ for ( int i = 0;(i < a.size());i++) {if ( (i == 0)) print(a.get(i)); else print((separator + a.get(i))); }println(); } } }
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.readInt();  int[] a = in.readIntArray(n);  int swap = 0; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( (a[i] > a[j])) swap ^= 1;  int m = in.readInt(); while((m-- > 0)){ int l = in.readInt();  int r = in.readInt();  int s = ((r - l) + 1); s = ((s * (s - 1)) / 2); swap ^= s; out.println((((swap & 1) == 0)?"even":"odd")); }} } 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); } } }
1	public class Main{ public static void main( String[] args){ try{ Parserdoubt pd = new Parserdoubt(System.in);  int t = pd.nextInt();  int inde = 0,indo = 0,o = 0,e = 0; for ( int i = 0;(i < t);i++) {if ( ((pd.nextInt() % 2) == 0)) {inde = i; e++; } else {o++; indo = i; }}if ( (o == 1)) {System.out.println((indo + 1)); } else {System.out.println((inde + 1)); } }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 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++];} }
0	public class A235{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long a = in.nextLong(); if ( ((a % 2) == 0)) { long result = cal(a); result = Math.max(result,cal((a + 1))); result = Math.max(result,cal2(a)); System.out.println(Math.max(result,a)); } else { long result = (((a - 1) * (a - 2)) * (a - 0)); System.out.println(Math.max(result,a)); }} static long cal( long a){ long result = ((a - 1) * (a - 2)); result /= gcd((a - 1),(a - 2)); long gcd = gcd(result,(a - 3)); result *= (a - 3); result /= gcd; return result;} static long cal2( long a){ long result = (a * (a - 1)); result /= gcd((a - 1),a); long gcd = gcd(result,(a - 3)); result *= (a - 3); result /= gcd; return result;} static private long gcd( long l, long i){ if ( ((l == 0) || (i == 0))) {return 1;} if ( ((l % i) == 0)) {return i;} return gcd(i,(l % i));} }
5	public class solver{ FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ new solver().solve(); } public void solve(){ int n = in.nextInt();  int[] tab = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {tab[i] = in.nextInt(); sum += tab[i]; }Arrays.sort(tab); int v1 = 0;  int count = 0; for ( int i = (tab.length - 1);(i >= 0);i--) {v1 += tab[i]; count++; if ( (v1 > getSum(i,tab))) {break;} }out.println(count); in.close(); out.close(); } public int getSum( int index, int[] tab){ int sum = 0; for ( int i = 0;(i < index);i++) sum += tab[i]; return sum;} } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ System.err.println(e); return "";} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} void close(){ try{br.close(); }catch (IOException e){ } } }
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());} } }
0	public class LCM{ public static long gcd( long a, long b){ while(true){a = (a % b); if ( (a == 0)) return b; b = (b % a); if ( (b == 0)) return a; }} public static void main( String[] args)throws java.lang.Exception { Scanner in = new Scanner(System.in);  long n = in.nextInt(); if ( (n > 2)) {if ( (gcd(n,(n - 2)) > 1)) {if ( (gcd(n,(n - 3)) > 1)) {System.out.println((((n - 1) * (n - 2)) * (n - 3))); } else System.out.println(((n * (n - 1)) * (n - 3))); } else System.out.println(((n * (n - 1)) * (n - 2))); } else System.out.println(n); } }
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 Main3{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int N = sc.nextInt();  String S = sc.next();  HashSet<Character> unique = new HashSet<>(); for ( char c :S.toCharArray()) {unique.add(c); } int number = unique.size();  Hashtable<Character,Integer> indexes = new Hashtable<>();  TreeSet<Integer> tree = new TreeSet<>();  int min = (N + 1);  int total = 0; for ( int i = 0;(i < N);i++) { char c = S.charAt(i); if ( !indexes.containsKey(c)) {total++; indexes.put(c,i); tree.add(i); } else { int old = indexes.get(c); indexes.put(c,i); tree.remove(old); tree.add(i); }if ( (total == number)) { int dist = ((tree.last() - tree.first()) + 1); min = Math.min(dist,min); } }System.out.println(min); } }
3	public class Template{ String fileName = ""; long INF = (Long.MAX_VALUE / 3); int MODULO = (((1000 * 1000) * 1000) + 7); long[] fenwik ; int BORDER = ((1000 * 1000) + 100); void solve()throws IOException { int n = readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);++i) {a[i] = readInt(); }fenwik = new long[BORDER]; long ans = 0; for ( int i = (n - 1);(i >= 0);--i) {ans += sumFenwik(a[i]); incFenwik(a[i],1); } boolean even = ((ans % 2) == 0);  int m = readInt(); for ( int i = 0;(i < m);++i) { int l = readInt();  int r = readInt(); if ( (((((r - l) + 1) / 2) % 2) == 1)) {even = !even; } out.println((even?"even":"odd")); }} void incFenwik( int i, int delta){ for ( ;(i < BORDER);i = (i | (i + 1))) {fenwik[i] += delta; }} long sumFenwik( int r){ long sum = 0; for ( ;(r >= 0);r = ((r & (r + 1)) - 1)) {sum += fenwik[r]; }return sum;} int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} long binPow( long a, long b, long m){ if ( (b == 0)) {return 1;} if ( ((b % 2) == 1)) {return (((a % m) * (binPow(a,(b - 1),m) % m)) % m);} else { long c = binPow(a,(b / 2),m); return ((c * c) % m);}} public static void main( String[] args)throws NumberFormatException,IOException { new Template().run(); } void run()throws NumberFormatException,IOException { solve(); out.close(); } BufferedReader in ; PrintWriter out ; StringTokenizer tok ; String delim = " "; Random rnd = new Random(); Template()throws FileNotFoundException{ try{in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); }catch (Exception e){ if ( fileName.isEmpty()) {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {in = new BufferedReader(new FileReader((fileName + ".in"))); out = new PrintWriter((fileName + ".out")); }} tok = new StringTokenizer(""); } String readLine()throws IOException { return in.readLine();} String readString()throws IOException { while(!tok.hasMoreTokens()){ String nextLine = readLine(); if ( (null == nextLine)) {return null;} tok = new StringTokenizer(nextLine); }return tok.nextToken();} int readInt()throws NumberFormatException,IOException { return Integer.parseInt(readString());} }
3	public class Main{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  int numbers[] = new int[n]; for ( int i = 0;(i < n);i++) {numbers[i] = scanner.nextInt(); }scanner.close(); Arrays.sort(numbers); boolean[] colored = new boolean[n];  int res = 0; for ( int i = 0;(i < n);i++) {if ( !colored[i]) {res += 1; } for ( int j = i;(j < n);j++) {if ( ((numbers[j] % numbers[i]) == 0)) {colored[j] = true; } }}System.out.println(res); } }
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)); } }
1	public class B{ public static void main( String[] args){ FastScanner fs = new FastScanner();  int T = fs.nextInt(); for ( int tt = 0;(tt < T);tt++) { int n = fs.nextInt();  boolean isEven = ((n % 2) == 0); while(((n % 2) == 0))n /= 2; if ( (isSquare(n) && isEven)) {System.out.println("YES"); } else {System.out.println("NO"); }}} static boolean isSquare( long n){ long sqrt = (long)Math.sqrt(n); for ( int i = (int)Math.max(1,(sqrt - 5));(i <= (sqrt + 5));i++) if ( ((i * i) == n)) return true; return false;} 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());} } }
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{ String[] str ; long mod = ((long)1e9 + 7); long[][] dp ; public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt(); str = new String[n]; dp = new long[(n + 2)][(n + 2)]; for ( int i = 0;(i < dp.length);i++) {Arrays.fill(dp[i],-1); }for ( int i = 0;(i < n);i++) {str[i] = in.readString(); }if ( (str[0].charAt(0) == 'f')) {out.print(solve(1,1)); } else {out.print(solve(1,0)); }} long solve( int n, int horiz){ if ( (horiz < 0)) return 0; if ( (n >= (str.length - 1))) {return 1;} if ( (dp[n][horiz] != -1)) {return dp[n][horiz];} if ( (str[n].charAt(0) == 'f')) {return dp[n][horiz] = solve((n + 1),(horiz + 1));} else { long ans1 = solve(n,(horiz - 1)); ans1 += solve((n + 1),horiz); ans1 = (ans1 % mod); return dp[n][horiz] = ans1;}} } 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));} } }
5	public class A{ public void solve()throws Exception { int n = nextInt();  int[] p = nextArr(n); Arrays.sort(p); int sum = 0; for ( int i = 0;(i < n);++i) sum += p[i]; int curr = 0; for ( int i = (n - 1);(i >= 0);--i) {curr += p[i]; if ( (curr > (sum - curr))) halt((n - i)); }} boolean showDebug = true; static boolean useFiles = false; static String inFile = "input.txt"; static String outFile = "output.txt"; double EPS = 1e-7; int INF = Integer.MAX_VALUE; long INFL = Long.MAX_VALUE; double INFD = Double.MAX_VALUE; long timer = System.currentTimeMillis(); static class InputReader{ private byte[] buf ; private int bufPos = 0,bufLim = -1; private InputStream stream ; public InputReader( InputStream stream, int size){ buf = new byte[size]; this.stream = stream; } private void fillBuf()throws IOException { bufLim = stream.read(buf); bufPos = 0; } char read()throws IOException { if ( (bufPos >= bufLim)) fillBuf(); return (char)buf[bufPos++];} } static InputReader inputReader ; static BufferedWriter outputWriter ; char nextChar()throws IOException { return inputReader.read();} char nextNonWhitespaceChar()throws IOException { char c = inputReader.read(); while((c <= ' '))c = inputReader.read(); return c;} String nextWord()throws IOException { StringBuilder sb = new StringBuilder();  char c = inputReader.read(); while((c <= ' '))c = inputReader.read(); while((c > ' ')){sb.append(c); c = inputReader.read(); }return new String(sb);} int nextInt()throws IOException { int r = 0;  char c = nextNonWhitespaceChar();  boolean neg = false; if ( (c == '-')) neg = true; else r = (c - 48); c = nextChar(); while(((c >= '0') && (c <= '9'))){r *= 10; r += (c - 48); c = nextChar(); }return (neg?-r:r);} long nextLong()throws IOException { long r = 0;  char c = nextNonWhitespaceChar();  boolean neg = false; if ( (c == '-')) neg = true; else r = (c - 48); c = nextChar(); while(((c >= '0') && (c <= '9'))){r *= 10L; r += (c - 48L); c = nextChar(); }return (neg?-r:r);} double nextDouble()throws NumberFormatException,IOException { return Double.parseDouble(nextWord());} int[] nextArr( int size)throws NumberFormatException,IOException { int[] arr = new int[size]; for ( int i = 0;(i < size);++i) arr[i] = nextInt(); return arr;} void print( Object o)throws IOException { outputWriter.write(o.toString()); } void println( Object o)throws IOException { outputWriter.write(o.toString()); outputWriter.newLine(); } void print( Object... o)throws IOException { for ( int i = 0;(i < o.length);++i) {if ( (i != 0)) outputWriter.write(' '); outputWriter.write(o[i].toString()); }} void println( Object... o)throws IOException { print(o); outputWriter.newLine(); } void printn( Object o, int n)throws IOException { String s = o.toString(); for ( int i = 0;(i < n);++i) {outputWriter.write(s); if ( (i != (n - 1))) outputWriter.write(' '); }} void printArr( int[] arr)throws IOException { for ( int i = 0;(i < arr.length);++i) {if ( (i != 0)) outputWriter.write(' '); outputWriter.write(Integer.toString(arr[i])); }} void printArr( long[] arr)throws IOException { for ( int i = 0;(i < arr.length);++i) {if ( (i != 0)) outputWriter.write(' '); outputWriter.write(Long.toString(arr[i])); }} void printArr( double[] arr)throws IOException { for ( int i = 0;(i < arr.length);++i) {if ( (i != 0)) outputWriter.write(' '); outputWriter.write(Double.toString(arr[i])); }} void printArr( String[] arr)throws IOException { for ( int i = 0;(i < arr.length);++i) {if ( (i != 0)) outputWriter.write(' '); outputWriter.write(arr[i]); }} void printArr( char[] arr)throws IOException { for ( char c :arr) outputWriter.write(c); } void halt( Object... o)throws IOException { if ( (o.length != 0)) println(o); outputWriter.flush(); outputWriter.close(); System.exit(0); } public static void main( String[] args)throws Exception { Locale.setDefault(Locale.US); if ( !useFiles) {inputReader = new InputReader(System.in,(1 << 16)); outputWriter = new BufferedWriter(new OutputStreamWriter(System.out),(1 << 16)); } else {inputReader = new InputReader(new FileInputStream(new File(inFile)),(1 << 16)); outputWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(outFile))),(1 << 16)); }new A().solve(); outputWriter.flush(); outputWriter.close(); } }
4	public class Main{ public static void main( String[] args)throws IOException { Scanner in = new Scanner(new FileInputStream("input.txt"));  File file = new File("output.txt");  FileOutputStream fos = new FileOutputStream(file); if ( !file.exists()) {file.createNewFile(); } int N = in.nextInt();  int M = in.nextInt();  int K = in.nextInt();  int[][] fireTime = new int[N][M]; for ( int i = 0;(i < K);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); fireTime[x][y] = -1; for ( int j = 1;(j <= (x + y));j++) {for ( int p = 0;(p <= j);p++) {if ( (((((x - j) + p) >= 0) && ((y - p) >= 0)) && ((fireTime[((x - j) + p)][(y - p)] == 0) || (fireTime[((x - j) + p)][(y - p)] > j)))) {fireTime[((x - j) + p)][(y - p)] = j; } }}for ( int j = 1;(j <= (((x + M) - 1) - y));j++) {for ( int p = 0;(p <= j);p++) {if ( (((((x - j) + p) >= 0) && ((y + p) < M)) && ((fireTime[((x - j) + p)][(y + p)] == 0) || (fireTime[((x - j) + p)][(y + p)] > j)))) {fireTime[((x - j) + p)][(y + p)] = j; } }}for ( int j = 1;(j <= (((N - 1) - x) + y));j++) {for ( int p = 0;(p < j);p++) {if ( (((((x + j) - p) < N) && ((y - p) >= 0)) && ((fireTime[((x + j) - p)][(y - p)] == 0) || (fireTime[((x + j) - p)][(y - p)] > j)))) {fireTime[((x + j) - p)][(y - p)] = j; } }}for ( int j = 1;(j <= (((((N - 1) - x) + M) - 1) - y));j++) {for ( int p = 0;(p <= j);p++) {if ( (((((x + j) - p) < N) && ((y + p) < M)) && ((fireTime[((x + j) - p)][(y + p)] == 0) || (fireTime[((x + j) - p)][(y + p)] > j)))) {fireTime[((x + j) - p)][(y + p)] = j; } }}} int max = -1;  int tx = 1;  int ty = 1; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {if ( (fireTime[i][j] > max)) {max = fireTime[i][j]; tx = (i + 1); ty = (j + 1); } }} String output = ((tx + " ") + ty);  byte[] bA = output.getBytes(); fos.write(bA); fos.flush(); } }
1	public class Main{ public static void main( String[] args){ Main iq = new Main();  Scanner sc = new Scanner(System.in);  int n ; n = sc.nextInt(); int[] naturalNumbers = new int[n]; for ( int i = 0;(i < naturalNumbers.length);i++) {naturalNumbers[i] = sc.nextInt(); }System.out.println(iq.diffInEvenness(n,naturalNumbers)); } public int diffInEvenness( int n, int[] naturalNumbers){ int even ,odd ,lastEvenIndex ,lastOddIndex ; even = odd = lastEvenIndex = lastOddIndex = 0; for ( int i = 0;(i < naturalNumbers.length);i++) {if ( ((naturalNumbers[i] % 2) == 0)) {even++; lastEvenIndex = (i + 1); } else {odd++; lastOddIndex = (i + 1); }}return ((even > odd)?lastOddIndex:lastEvenIndex);} }
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 x1238E{ public static void main( String[] omkar)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int N = Integer.parseInt(st.nextToken());  int M = Integer.parseInt(st.nextToken());  String input = infile.readLine();  int[][] cnt = new int[M][M]; for ( int i = 0;(i < (N - 1));i++) if ( (input.charAt(i) != input.charAt((i + 1)))) {cnt[(input.charAt(i) - 'a')][(input.charAt((i + 1)) - 'a')]++; cnt[(input.charAt((i + 1)) - 'a')][(input.charAt(i) - 'a')]++; } int[] dp = new int[(1 << M)]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; for ( int mask = 0;(mask < dp.length);mask++) for ( int b = 0;(b < M);b++) if ( ((mask & (1 << b)) == 0)) { int submask = (mask | (1 << b));  int cost = 0; for ( int c = 0;(c < M);c++) {if ( ((mask & (1 << c)) > 0)) cost += cnt[b][c]; else cost -= cnt[b][c]; }dp[submask] = Math.min(dp[submask],(dp[mask] + (cost * Integer.bitCount(mask)))); } System.out.println(dp[((1 << M) - 1)]); } }
2	public class Q1{ static ArrayList<Integer> adj[] ,adj2[] ; static int color[] ,cc ; static long mod = 1000000007; static TreeSet<Integer> ts[] ; static boolean b[] ,visited[] ,possible ,ans1 ,ans2 ; static Stack<Integer> s ; static int totalnodes ,colored ,min ,minc ; static int c[] ; static long sum[] ; static HashMap<Integer,Integer> hm ; public static void main( String[] args)throws IOException { in = new InputReader(System.in); out = new PrintWriter(System.out); String n1 = in.readString();  String s1 = in.readString();  long s = Long.parseLong(s1);  long n = Long.parseLong(n1);  long l = (s - 1);  long r = (n + 1);  HashSet<Long> hset = new HashSet<>();  long last = -1; while((l < r)){ long mid = ((l + r) / 2);  long sum = 0; if ( hset.contains(mid)) break; String d = String.valueOf(mid); for ( int i = 0;(i < d.length());i++) {sum = (sum + (d.charAt(i) - '0')); }hset.add(mid); if ( ((mid - sum) >= s)) {last = mid; r = mid; } else {l = mid; }}if ( (last == -1)) out.println("0"); else {out.println(((n - last) + 1)); }out.close(); } static InputReader in ; static PrintWriter out ; static void dfs( int i, int parent){ if ( (color[i] != cc)) ans1 = false; for ( int j :adj[i]) {if ( (j != parent)) {dfs(j,i); } }} static class Node2{ Node2 left = null; Node2 right = null; Node2 parent = null; int data ; } static long gcd( long a, long b){ while((b > 0)){ long temp = b; b = (a % b); a = temp; }return a;} 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 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 int[] nextIntArray( int n){ return nextIntArray(n,0);} public int[] nextIntArray( int n, int off){ int[] arr = new int[(n + off)]; for ( int i = 0;(i < n);i++) {arr[(i + off)] = nextInt(); }return arr;} public long[] nextLongArray( int n){ return nextLongArray(n,0);} public long[] nextLongArray( int n, int off){ long[] arr = new long[(n + off)]; for ( int i = 0;(i < n);i++) {arr[(i + off)] = nextLong(); }return arr;} public String readString(){ int c = snext(); while(isSpaceChar(c)){c = snext(); } StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = snext(); }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));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
2	public class C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long s = 0,mod = 1000000009;  int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt(),c = (n / k); if ( (m <= ((c * (k - 1)) + (n % k)))) System.out.println(m); else { int a = ((m - (c * (k - 1))) - (n % k));  long l = 0,pase = 0;  long pot = BigInteger.valueOf(2).modPow(BigInteger.valueOf(a),BigInteger.valueOf(mod)).longValue(); pot = ((2 * (pot - 1)) % mod); System.out.println(((((pot * k) % mod) + (m - (a * k))) % mod)); }} }
3	public class F_DSU{ public static void main( String[] args)throws Exception { FastReader in = new FastReader(System.in);  PrintWriter pw = new PrintWriter(System.out); n = in.nextInt(); int brr[] = new int[(2 * n)]; for ( int i = 0;(i < (2 * n));i += 2) {brr[i] = in.nextInt(); brr[(i + 1)] = in.nextInt(); }arr = shrink(brr); int imap[] = new int[(2 * n)]; for ( int i = 0;(i < (2 * n));i++) {imap[arr[i]] = brr[i]; } int idx = binarySearch(arr.length); if ( (idx >= arr.length)) pw.println(-1); else pw.println(imap[idx]); pw.close(); } static int n ,arr[] ; static int binarySearch( int H){ int lo = 0,hi = H,mid ; while((lo < hi)){mid = ((lo + hi) / 2); if ( check(mid)) hi = mid; else lo = (mid + 1); }if ( ((lo > 0) && check((lo - 1)))) return (lo - 1); return lo;} static boolean check( int m){ DSU dsu = new DSU((2 * n)); for ( int i = 0;(i < n);i++) { int u = arr[(2 * i)],v = arr[((2 * i) + 1)]; if ( (u > m)) return false; if ( (v > m)) {if ( (++dsu.cycle[dsu.find(u)] >= 2)) return false; } else {if ( !dsu.union(u,v)) {if ( (++dsu.cycle[dsu.find(u)] >= 2)) return false; } else {if ( (dsu.cycle[dsu.find(u)] >= 2)) return false; }}}return true;} static class DSU{ int parent[] ,cycle[] ,n ; DSU( int N){ n = N; parent = new int[N]; cycle = new int[N]; for ( int i = 0;(i < N);i++) {parent[i] = i; }} DSU( int[] p){ parent = p; n = p.length; } int find( int i){ int p = parent[i]; if ( (i == p)) return i; return parent[i] = find(p);} boolean union( int u, int v){ u = find(u); v = find(v); if ( (u != v)) {parent[u] = parent[v]; cycle[v] += cycle[u]; } return (u != v);} } public static int[] shrink( int[] a){ int n = a.length;  long[] b = new long[n]; for ( int i = 0;(i < n);i++) b[i] = (((long)a[i] << 32) | i); Arrays.sort(b); int[] ret = new int[n];  int p = 0; for ( int i = 0;(i < n);i++) {if ( ((i > 0) && (((b[i] ^ b[(i - 1)]) >> 32) != 0))) p++; ret[(int)b[i]] = p; }return ret;} static class FastReader{ InputStream is ; private byte[] inbuf = new byte[1024]; private int lenbuf = 0,ptrbuf = 0; static final int ints[] = new int[128]; public FastReader( InputStream is){ for ( int i = '0';(i <= '9');i++) ints[i] = (i - '0'); this.is = is; } public 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++];} public boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} public 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 << 3) + (num << 1)) + ints[b]); } else {return (minus?-num:num);}b = readByte(); }} public 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));} } }
5	public class Main{ public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out);  Reader in = new Reader();  Main solver = new Main(); solver.solve(out,in); out.flush(); out.close(); } void solve( PrintWriter out, Reader in)throws IOException { int n = in.nextInt();  int m = in.nextInt();  int[] vert = new int[(n + 1)]; for ( int i = 0;(i < n);i++) vert[i] = in.nextInt(); vert[n] = (int)1e9; int cnt = 0,x ,y ;  ArrayList<Integer> arr = new ArrayList<>(); for ( int i = 0;(i < m);i++) {x = in.nextInt(); y = in.nextInt(); in.nextInt(); if ( (x == 1)) arr.add(y); }horz = new int[arr.size()]; for ( int i = 0;(i < arr.size());i++) horz[i] = arr.get(i); Arrays.sort(horz); Arrays.sort(vert); int ans = ((2 * (int)1e5) + 10); for ( int i = 0;(i <= n);i++) { int lesshorz = bs(vert[i],horz.length); ans = Math.min(ans,(((i + horz.length) - lesshorz) - 1)); }out.println(ans); } static int[] horz ; static int bs( int num, int m){ int mid ,lo = 0,hi = (m - 1),r = -1; while((lo <= hi)){mid = ((lo + hi) / 2); if ( (horz[mid] < num)) {lo = (mid + 1); r = mid; } else {hi = (mid - 1); }}return r;} 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 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));} } }
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 Main{ static InputReader in ; public static void main( String[] args)throws IOException { File file = new File("input.txt"); if ( file.exists()) in = new InputReader(new FileInputStream(file)); else in = new InputReader(System.in); int n = in.nextInt(),m = 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 i = (n - 1),ans = 0; while(((k < m) && (i >= 0))){k += (a[i] - 1); i--; ans++; }if ( (m <= k)) System.out.println(ans); else System.out.println("-1"); } static class InputReader{ private BufferedInputStream inp ; private int offset ; private final int size = 5120000; private byte buff[] ; InputReader( InputStream in)throws IOException{ inp = new BufferedInputStream(in); buff = new byte[size]; offset = 0; inp.read(buff,0,size); } int nextInt()throws IOException { int parsedInt = 0;  int i = offset; if ( (buff[i] == 0)) throw (new IOException()); while(((i < size) && ((buff[i] < '0') || (buff[i] > '9'))))i++; while((((i < size) && (buff[i] >= '0')) && (buff[i] <= '9'))){parsedInt *= 10; parsedInt += (buff[i] - '0'); i++; }if ( (i == size)) { int j = 0; for ( ;(offset < buff.length);j++,offset++) buff[j] = buff[offset]; inp.read(buff,j,(size - j)); offset = 0; parsedInt = nextInt(); } else offset = i; return parsedInt;} long nextLong()throws IOException { long parsedLong = 0;  int i = offset; if ( (buff[i] == 0)) throw (new IOException()); while(((i < size) && ((buff[i] < '0') || (buff[i] > '9'))))i++; while((((i < size) && (buff[i] >= '0')) && (buff[i] <= '9'))){parsedLong *= 10L; parsedLong += (buff[i] - '0'); i++; }if ( (i == size)) { int j = 0; for ( ;(offset < buff.length);j++,offset++) buff[j] = buff[offset]; inp.read(buff,j,(size - j)); offset = 0; parsedLong = nextLong(); } else offset = i; return parsedLong;} String next()throws IOException { StringBuilder token = new StringBuilder();  int i = offset; if ( (buff[i] == 0)) throw (new IOException()); while(((i < size) && ((((buff[i] == '\n') || (buff[i] == ' ')) || (buff[i] == '\r')) || (buff[i] == '\t'))))i++; while(((((((i < size) && (buff[i] != '\n')) && (buff[i] != ' ')) && (buff[i] != '\r')) && (buff[i] != '\t')) && (buff[i] != 0))){token.append((char)buff[i]); i++; }if ( (i == size)) { int j = 0; for ( ;(offset < buff.length);j++,offset++) buff[j] = buff[offset]; inp.read(buff,j,(size - j)); offset = 0; return next();} else offset = i; return token.toString();} String nextLine()throws IOException { StringBuilder line = new StringBuilder();  int i = offset; if ( (buff[i] == 0)) throw (new IOException()); while((((i < size) && (buff[i] != '\n')) && (buff[i] != 0))){line.append((char)buff[i]); i++; }if ( ((i < size) && (buff[i] == '\n'))) i++; if ( (i == size)) { int j = 0; for ( ;(offset < buff.length);j++,offset++) buff[j] = buff[offset]; inp.read(buff,j,(size - j)); offset = 0; return nextLine();} else offset = i; line.deleteCharAt((line.length() - 1)); return line.toString();} } }
5	public class ChainReaction implements Closeable{ private InputReader in = new InputReader(System.in); private PrintWriter out = new PrintWriter(System.out); private class Beacon implements Comparable<Beacon>{ private int position ,range ,score ; private Beacon( int position, int range){ this.position = position; this.range = range; } public void setScore( int score){ this.score = score; } } public void solve(){ int n = in.ni(); if ( (n == 1)) {out.println(0); return ;} beacons = new ArrayList<>(); for ( int i = 0;(i < n);i++) {beacons.add(new Beacon(in.ni(),in.ni())); }beacons.sort(Comparator.naturalOrder()); for ( int i = 1;(i < n);i++) { int left = 0,right = (i - 1),position = beacons.get(i).position,range = beacons.get(i).range;  int leftmost = i; while((left <= right)){ int mid = (left + ((right - left) / 2)); if ( ((position - range) <= beacons.get(mid).position)) {leftmost = Math.min(leftmost,mid); right = (mid - 1); } else {left = (mid + 1); }}beacons.get(i).setScore((i - leftmost)); }dp = new Integer[n]; int ans = Integer.MAX_VALUE; for ( int i = (n - 1);(i >= 0);i--) {ans = Math.min((((n - 1) - i) + recurse(i)),ans); }out.println(ans); } private List<Beacon> beacons ; private Integer[] dp ; private int recurse( int idx){ if ( (idx <= 0)) return 0; if ( (dp[idx] != null)) return dp[idx]; int destroyed = beacons.get(idx).score;  int ans = (destroyed + recurse(((idx - destroyed) - 1))); return dp[idx] = ans;} @Override public void close()throws IOException { in.close(); out.close(); } 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 ni(){ return Integer.parseInt(next());} public void close()throws IOException { reader.close(); } } public static void main( String[] args)throws IOException { try(ChainReaction instance=new ChainReaction()){instance.solve(); }} }
4	public class CF_2020_GlobalRound_E{ static boolean verb = true; static void log( Object X){ if ( verb) System.err.println(X); } static void log( Object[] X){ if ( verb) {for ( Object U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X){ if ( verb) {for ( int U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X, int L){ if ( verb) {for ( int i = 0;(i < L);i++) System.err.print((X[i] + " ")); System.err.println(""); } } static void log( long[] X){ if ( verb) {for ( long U :X) System.err.print((U + " ")); System.err.println(""); } } static InputReader reader ; static long[][] binom ; static void buildBinom( int N){ int MAX = (N + 1); binom = new long[(MAX + 1)][]; for ( int i = 0;(i < (MAX + 1));i++) binom[i] = new long[(i + 1)]; binom[0][0] = 1; for ( int i = 1;(i < MAX);i++) {binom[i][0] = 1; binom[i][i] = 1; for ( int j = 0;(j < i);j++) {binom[(i + 1)][(j + 1)] = ((binom[i][j] + binom[i][(j + 1)]) % mod); }}log("binom done"); } static long mod ; static long solve( int n){ long[] pow2 = new long[(n + 1)]; pow2[0] = 1; for ( int i = 1;(i <= n);i++) {pow2[i] = (pow2[(i - 1)] << 1); while((pow2[i] >= mod))pow2[i] -= mod; }buildBinom(n); long[][] dp = new long[(n + 1)][(n + 1)]; dp[1][1] = 1; for ( int i = 1;(i <= n);i++) {dp[i][i] = pow2[(i - 1)]; for ( int j = 1;(j < (i - 1));j++) { int me = ((i - j) - 1); for ( int cn = 1;(cn <= j);cn++) { long a = (dp[j][cn] * binom[(cn + me)][cn]); if ( (a >= mod)) a %= mod; a *= pow2[(me - 1)]; if ( (a >= mod)) a %= mod; dp[i][(cn + me)] += a; if ( (dp[i][(cn + me)] >= mod)) dp[i][(cn + me)] -= mod; }}} long ans = 0; for ( int i = (n / 2);(i <= n);i++) {ans += dp[n][i]; ans %= mod; }return ans;} public static void main( String[] args)throws Exception { log(((400 * 400) * 400)); reader = new InputReader(System.in); int n = reader.readInt(); mod = reader.readInt(); System.out.println(solve(n)); } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
4	public class ViewAngle{ static private int V ,level[][] ,count = -1,lev_dfs[] ,degree = 0,no_vert_conn_comp = 0; static private Stack<Integer> st = new Stack(); static private LinkedList<Integer> adj[] ; static private boolean[][] Visite ; static private boolean[] Visited ; static private TreeSet<Integer> ts = new TreeSet(); static private Queue<Pair> queue = new LinkedList<Pair>(); ViewAngle( int V){ V++; this.V = V; adj = new LinkedList[V]; Visite = new boolean[100][100]; Visited = new boolean[V]; lev_dfs = new int[V]; for ( int i = 0;(i < V);i++) adj[i] = new LinkedList<Integer>(); } static File inFile ,outFile ; static FileWriter fWriter ; static PrintWriter pWriter ; public static void main( String[] args)throws IOException { inFile = new File("input.txt"); outFile = new File("output.txt"); fWriter = new FileWriter(outFile); pWriter = new PrintWriter(fWriter); Scanner sc = new Scanner(inFile);  int n = sc.nextInt();  int m = sc.nextInt();  char c[][] = new char[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {c[i][j] = '.'; }}setup(n,m); int k = sc.nextInt(); for ( int i = 0;(i < k);i++) { int x = sc.nextInt();  int y = sc.nextInt(); queue.add(new Pair((x - 1),(y - 1))); c[(x - 1)][(y - 1)] = 'X'; level[(x - 1)][(y - 1)] = -1; Visite[(x - 1)][(y - 1)] = true; }BFS(c,n,m); pWriter.close(); sc.close(); } public void get( int from, int to){ int h = (lev_dfs[from] - lev_dfs[to]); if ( (h <= 0)) {System.out.println(-1); } else {System.out.println((h - 1)); }} public static void setup( int n, int m){ level = new int[n][m]; Visite = new boolean[n][m]; } static private boolean check( int x, int y, char[][] c){ if ( ((((x >= 0) && (y >= 0)) && ((x < c.length) && (y < c[0].length))) && (c[x][y] == '.'))) {return true;} return false;} public static int BFS( char[][] c, int n, int m){ int count = 0; while(!queue.isEmpty()){ Pair temp = queue.poll();  int x = temp.w;  int y = temp.h; Visite[x][y] = true; if ( (check((x + 1),y,c) && !Visite[(x + 1)][y])) {level[(x + 1)][y] = (level[x][y] + 1); queue.add(new Pair((x + 1),y)); Visite[(x + 1)][y] = true; } if ( (check((x - 1),y,c) && !Visite[(x - 1)][y])) {level[(x - 1)][y] = (level[x][y] + 1); queue.add(new Pair((x - 1),y)); Visite[(x - 1)][y] = true; } if ( (check(x,(y + 1),c) && !Visite[x][(y + 1)])) {level[x][(y + 1)] = (level[x][y] + 1); queue.add(new Pair(x,(y + 1))); Visite[x][(y + 1)] = true; } if ( (check(x,(y - 1),c) && !Visite[x][(y - 1)])) {level[x][(y - 1)] = (level[x][y] + 1); queue.add(new Pair(x,(y - 1))); Visite[x][(y - 1)] = true; } } int prev_lev = -1,x = -1,y = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (level[i][j] >= prev_lev)) {prev_lev = level[i][j]; x = i; y = j; } }}pWriter.println((((x + 1) + " ") + (y + 1))); return V;} private long dfsUtil( int startVertex, boolean[] Visited){ int c = 1;  long cout = 0; degree = 0; Visited[startVertex] = true; st.push(startVertex); while(!st.isEmpty()){ int top = st.pop();  Iterator<Integer> i = adj[top].listIterator(); degree += adj[top].size(); while(i.hasNext()){ int n = i.next(); if ( !Visited[n]) {Visited[n] = true; st.push(n); lev_dfs[n] = top; } }}for ( int i = 1;(i < V);i++) {if ( (lev_dfs[i] != 0)) {System.out.print((lev_dfs[i] + " ")); } }return cout;} } class Pair implements Comparable<Pair>{ int w ; int h ; Pair( int w, int h){ this.w = w; this.h = h; } }
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); } }
4	public class Solution implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); private void init()throws FileNotFoundException { String file = "123"; if ( !file.equals("")) {in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); } else {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); }} public static void main( String[] args){ new Thread(new Solution()).start(); } private String readString(){ while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (IOException e){ e.printStackTrace(); } }return tok.nextToken();} private int readInt(){ return Integer.parseInt(readString());} int[] counts = new int[1000]; private void solve(){ int n = (readInt() + 2);  int m = (readInt() + 2);  boolean[][] graph = new boolean[n][m]; for ( int i = 0;(i < n);i++) {graph[i][(m - 1)] = true; graph[i][0] = true; }for ( int i = 0;(i < m);i++) {graph[(n - 1)][i] = true; graph[0][i] = true; } int k = readInt();  int inFire = 0;  Queue<Point> q = new ArrayDeque<>(); for ( int i = 0;(i < k);i++) { int x = readInt();  int y = readInt();  Point p = new Point(x,y); graph[x][y] = true; q.add(p); }while(!q.isEmpty()){ Point current = q.poll(); inFire++; if ( !graph[(current.x + 1)][current.y]) {graph[(current.x + 1)][current.y] = true; q.add(new Point((current.x + 1),current.y)); } if ( !graph[(current.x - 1)][current.y]) {graph[(current.x - 1)][current.y] = true; q.add(new Point((current.x - 1),current.y)); } if ( !graph[current.x][(current.y + 1)]) {graph[current.x][(current.y + 1)] = true; q.add(new Point(current.x,(current.y + 1))); } if ( !graph[current.x][(current.y - 1)]) {graph[current.x][(current.y - 1)] = true; q.add(new Point(current.x,(current.y - 1))); } if ( q.isEmpty()) {out.print(((current.x + " ") + current.y)); return ;} }} class Point{ int x ,y ; public Point( int x, int y){ this.x = x; this.y = y; } } }
0	public class Main{ public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int res = n;  String str = Integer.toString(n); res = Math.max(res,Integer.parseInt(str.substring(0,(str.length() - 1)))); res = Math.max(res,Integer.parseInt((str.substring(0,(str.length() - 2)) + str.substring((str.length() - 1))))); System.out.println(res); } }
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] + " ")); } }
0	public class C{ static StringBuilder st = new StringBuilder(); public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  Point[] square = new Point[4];  Point[] rotSquare = new Point[4]; for ( int i = 0;(i < 4);i++) square[i] = new Point(sc.nextInt(),sc.nextInt()); for ( int i = 0;(i < 4);i++) rotSquare[i] = new Point(sc.nextInt(),sc.nextInt()); boolean can = false; for ( int x = -100;(x <= 100);x++) for ( int y = -100;(y <= 100);y++) can |= (inside(new Point(x,y),square) & inside(new Point(x,y),rotSquare)); out.println((can?"YES":"NO")); out.flush(); out.close(); } static int crossProduct( Point a, Point b){ int ans = ((a.x * b.y) - (a.y * b.x)); if ( (ans < 0)) return -1; if ( (ans == 0)) return 0; return 1;} static boolean inside( Point a, Point[] points){ boolean allPos = true;  boolean allNeg = true; for ( int i = 0;(i < 4);i++) { Point v1 = new Point((points[i].x - a.x),(points[i].y - a.y));  Point v2 = new Point((points[((i + 1) % 4)].x - a.x),(points[((i + 1) % 4)].y - a.y)); allPos &= (crossProduct(v1,v2) >= 0); allNeg &= (crossProduct(v1,v2) <= 0); }return (allPos | allNeg);} static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(System.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());} } }
2	public class B{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; int ask( int x1, int y1, int x2, int y2)throws IOException { out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); out.flush(); return nextInt();} int inside( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4){ return (inside(x1,x2,x3,x4) & inside(y1,y2,y3,y4));} int inside( int x1, int x2, int y1, int y2){ return (((x1 <= y1) && (y2 <= x2))?1:0);} int askFlipped( int x1, int y1, int x2, int y2)throws IOException { return ask(y1,x1,y2,x2);} boolean check( int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)throws IOException { if ( ((((x1 > x2) || (y1 > y2)) || (x3 > x4)) || (y3 > y4))) {return false;} if ( ((Math.max(x1,x3) <= Math.min(x2,x4)) && (Math.max(y1,y3) <= Math.min(y2,y4)))) {return false;} return (check(x1,y1,x2,y2) && check(x3,y3,x4,y4));} boolean check( int x1, int y1, int x2, int y2)throws IOException { if ( (ask(x1,y1,x2,y2) != 1)) {return false;} if ( (x1 != x2)) {if ( ((ask((x1 + 1),y1,x2,y2) != 0) || (ask(x1,y1,(x2 - 1),y2) != 0))) {return false;} } if ( (y1 != y2)) {if ( ((ask(x1,(y1 + 1),x2,y2) != 0) || (ask(x1,y1,x2,(y2 - 1)) != 0))) {return false;} } return true;} void solve()throws IOException { int n = nextInt();  int low = 0;  int high = n; while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = ask(1,1,mid,n); if ( (ret == 0)) {low = mid; } else {high = mid; }} int minX2 = high; low = 0; high = n; while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = ask(1,1,mid,n); if ( (ret == 2)) {high = mid; } else {low = mid; }} int maxX2 = high; low = 1; high = (n + 1); while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = ask(mid,1,n,n); if ( (ret == 0)) {high = mid; } else {low = mid; }} int maxX1 = low; low = 1; high = (n + 1); while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = ask(mid,1,n,n); if ( (ret == 2)) {low = mid; } else {high = mid; }} int minX1 = low; low = 0; high = n; while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = askFlipped(1,1,mid,n); if ( (ret == 0)) {low = mid; } else {high = mid; }} int minY2 = high; low = 0; high = n; while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = askFlipped(1,1,mid,n); if ( (ret == 2)) {high = mid; } else {low = mid; }} int maxY2 = high; low = 1; high = (n + 1); while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = askFlipped(mid,1,n,n); if ( (ret == 0)) {high = mid; } else {low = mid; }} int maxY1 = low; low = 1; high = (n + 1); while(((high - low) > 1)){ int mid = ((low + high) >> 1);  int ret = askFlipped(mid,1,n,n); if ( (ret == 2)) {low = mid; } else {high = mid; }} int minY1 = low;  int[] x1s = {minX1,maxX1};  int[] x2s = {minX2,maxX2};  int[] y1s = {minY1,maxY1};  int[] y2s = {minY2,maxY2}; for ( int mask = 0;(mask < 8);mask++) { int x1 = x1s[0];  int x3 = x1s[1];  int x2 = x2s[get(mask,0)];  int x4 = x2s[(get(mask,0) ^ 1)];  int y1 = y1s[get(mask,1)];  int y3 = y1s[(get(mask,1) ^ 1)];  int y2 = y2s[get(mask,2)];  int y4 = y2s[(get(mask,2) ^ 1)]; if ( check(x1,y1,x2,y2,x3,y3,x4,y4)) {out.printf("! %d %d %d %d %d %d %d %d\n",x1,y1,x2,y2,x3,y3,x4,y4); out.flush(); return ;} }} int get( int mask, int i){ return ((mask >> i) & 1);} B()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 B(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
4	@SuppressWarnings("unused") public class Fire35C{ InputStream is ; PrintWriter out ; String INPUT = ""; int mod = (int)(Math.pow(10,9) + 7); int v = 0; int max = 0; StringBuilder st = new StringBuilder(); File outFile = new File("output.txt"); void solve()throws IOException { int n = ni();  int m = ni();  boolean visited[][] = new boolean[n][m];  boolean inq[][] = new boolean[n][m];  Queue<Integer> x = new LinkedList<>();  Queue<Integer> y = new LinkedList<>();  Queue<Integer> lev = new LinkedList<>();  int a = -1,b = -1,max = 0;  int k = ni(); while((k-- > 0)){ int u = (ni() - 1);  int v = (ni() - 1); x.add(u); y.add(v); lev.add(1); inq[u][v] = true; }while((x.size() != 0)){ int u = x.poll();  int v = y.poll();  int l = lev.poll(); if ( (max < l)) {a = u; b = v; max = l; } visited[u][v] = true; if ( ((((u - 1) >= 0) && !visited[(u - 1)][v]) && !inq[(u - 1)][v])) {x.add((u - 1)); y.add(v); lev.add((l + 1)); inq[(u - 1)][v] = true; } if ( ((((u + 1) < n) && !visited[(u + 1)][v]) && !inq[(u + 1)][v])) {x.add((u + 1)); y.add(v); lev.add((l + 1)); inq[(u + 1)][v] = true; } if ( ((((v - 1) >= 0) && !visited[u][(v - 1)]) && !inq[u][(v - 1)])) {x.add(u); y.add((v - 1)); lev.add((l + 1)); inq[u][(v - 1)] = true; } if ( ((((v + 1) < m) && !visited[u][(v + 1)]) && !inq[u][(v + 1)])) {x.add(u); y.add((v + 1)); lev.add((l + 1)); inq[u][(v + 1)] = true; } }a++; b++; out.println(((a + " ") + b)); out.close(); } void run()throws Exception { is = (INPUT.isEmpty()?new FileInputStream(new File("input.txt")):new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(new BufferedWriter(new FileWriter(outFile))); long s = System.currentTimeMillis(); solve(); out.flush(); if ( !INPUT.isEmpty()) tr(((System.currentTimeMillis() - s) + "ms")); } public static void main( String[] args)throws Exception { new Fire35C().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) && (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(); }} static long __gcd( long a, long b){ if ( (b == 0)) {return a;} else {return __gcd(b,(a % b));}} static long power( long x, long y, long p){ long res = 1; x = (x % p); while((y > 0)){if ( ((y % 2) == 1)) res = ((res * x) % p); y = (y >> 1); x = ((x * x) % p); }return res;} static long modInverse( long a, int m){ if ( (__gcd(a,m) != 1)) {return -1;} else {return power(a,(m - 2),m);}} static private void tr( Object... o){ System.out.println(Arrays.deepToString(o)); } }
6	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);  TaskE2 solver = new TaskE2(); solver.solve(1,in,out); out.close(); } static class TaskE2{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int t = in.nextInt(); while((t-- > 0)){ int 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(); }} boolean[][] interesting = new boolean[n][m];  boolean[] hasInteresting = new boolean[m]; for ( int i = 0;(i < n);i++) { List<Pair> list = new ArrayList<>(); for ( int j = 0;(j < m);j++) {list.add(new Pair(a[i][j],j)); }Collections.sort(list,Comparator.comparing((pair)->-pair.val)); for ( int j = 0;((j < m) && (j <= n));j++) {interesting[i][list.get(j).pos] = true; hasInteresting[list.get(j).pos] = true; }} boolean[] goodMask = new boolean[(1 << n)]; for ( int mask = 0;(mask < (1 << n));mask++) { int best = Integer.MAX_VALUE;  int cur = mask; do {best = Math.min(best,cur); cur = ((cur >> 1) | ((cur & 1) << (n - 1))); }while((cur != mask));goodMask[mask] = (mask == best); } int[] dp = new int[(1 << n)]; for ( int i = 0;(i < m);i++) {if ( !hasInteresting[i]) {continue;} for ( int j = 0;(j < n);j++) {if ( !interesting[j][i]) {continue;} int supermask = (((1 << n) - 1) - (1 << j));  int val = a[j][i]; for ( int mask = supermask;;mask = ((mask - 1) & supermask)) {if ( ((dp[mask] + val) > dp[(mask | (1 << j))])) {dp[(mask | (1 << j))] = (dp[mask] + val); } if ( (mask == 0)) {break;} }}for ( int mask = 0;(mask < (1 << n));mask++) {if ( !goodMask[mask]) {continue;} int best = 0;  int cur = mask; do {best = Math.max(best,dp[cur]); cur = ((cur >> 1) | ((cur & 1) << (n - 1))); }while((cur != mask));do {dp[cur] = best; cur = ((cur >> 1) | ((cur & 1) << (n - 1))); }while((cur != mask));}}out.println(dp[((1 << n) - 1)]); }} class Pair{ int val ; int pos ; public Pair( int val, int pos){ this.val = val; this.pos = pos; } } } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } public FastScanner( String fileName){ try{br = new BufferedReader(new FileReader(fileName)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public int nextInt(){ return Integer.parseInt(next());} public String next(){ while(((st == null) || !st.hasMoreElements())){ String line = null; try{line = br.readLine(); }catch (IOException e){ } st = new StringTokenizer(line); }return st.nextToken();} } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ public void solve( int testNumber, InputReader in, OutputWriter out){ try{ int n = in.readInt();  int[] x = new int[n],w = new int[n]; in.readIntArrays(x,w); int[] begin = new int[n],end = new int[n]; Arrays.setAll(begin,(i)->(x[i] - w[i])); Arrays.setAll(end,(i)->(x[i] + w[i])); int m = ArrayUtils.compress(begin,end).length;  int[] dp = new int[(m + 1)],order = ArrayUtils.order(end);  int idx = 0; for ( int i = 0;(i < m);i++) {if ( (i > 0)) {dp[i] = dp[(i - 1)]; } while(((idx < n) && (end[order[idx]] == i))){dp[i] = Math.max(dp[i],(dp[begin[order[idx]]] + 1)); idx++; }} int res = dp[(m - 1)]; out.printLine(res); }catch (Exception e){ e.printStackTrace(); } } } static interface IntList extends IntReversableCollection{ public abstract int get( int index); public abstract void set( int index, int value); public abstract void addAt( int index, int value); public abstract void removeAt( int index); public default void swap( int first, int second){ if ( (first == second)) {return ;} int temp = get(first); set(first,get(second)); set(second,temp); } public default IntIterator intIterator(){ return new IntIterator(){private int at ; private boolean removed ; public int value(){ if ( removed) {throw (new IllegalStateException());} return get(at);} public boolean advance(){ at++; removed = false; return isValid();} public boolean isValid(){ return (!removed && (at < size()));} };} public default void add( int value){ addAt(size(),value); } public default IntList sort( IntComparator comparator){ Sorter.sort(this,comparator); return this;} default IntList unique(){ int last = Integer.MIN_VALUE;  IntList result = new IntArrayList();  int size = size(); for ( int i = 0;(i < size);i++) { int current = get(i); if ( (current != last)) {result.add(current); last = current; } }return result;} public default IntList subList(final int from,final int to){ return new IntList(){private final int shift ; private final int size ; {if ( (((from < 0) || (from > to)) || (to > this.size()))) {throw (new IndexOutOfBoundsException(((((("from = " + from) + ", to = ") + to) + ", size = ") + size())));} shift = from; size = (to - from); }public int size(){ return size;} public int get( int at){ if ( ((at < 0) || (at >= size))) {throw (new IndexOutOfBoundsException(((("at = " + at) + ", size = ") + size())));} return this.get((at + shift));} public void addAt( int index, int value){ throw (new UnsupportedOperationException());} public void removeAt( int index){ throw (new UnsupportedOperationException());} public void set( int at, int value){ if ( ((at < 0) || (at >= size))) {throw (new IndexOutOfBoundsException(((("at = " + at) + ", size = ") + size())));} this.set((at + shift),value); } };} } static interface IntComparator{ IntComparator DEFAULT = Integer::compare; int compare( int first, int second); } static interface IntReversableCollection extends IntCollection{ } 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); } } static interface IntStream extends Iterable<Integer>,Comparable<IntStream>{ IntIterator intIterator(); } 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 void readIntArrays( int[]... arrays){ for ( int i = 0;(i < arrays[0].length);i++) {for ( int j = 0;(j < arrays.length);j++) {arrays[j][i] = readInt(); }}} 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{ boolean isSpaceChar( int ch); } } static interface IntCollection extends IntStream{ public int size(); public default void add( int value){ throw (new UnsupportedOperationException());} public default int[] toArray(){ int size = size();  int[] array = new int[size];  int i = 0; for ( IntIterator it = intIterator();it.isValid();it.advance()) {array[i++] = it.value(); }return array;} public default IntCollection addAll( IntStream values){ for ( IntIterator it = values.intIterator();it.isValid();it.advance()) {add(it.value()); }return this;} } static class IntArray extends IntAbstractStream implements IntList{ private int[] data ; public IntArray( int[] arr){ data = arr; } public int size(){ return data.length;} public int get( int at){ return data[at];} public void addAt( int index, int value){ throw (new UnsupportedOperationException());} public void removeAt( int index){ throw (new UnsupportedOperationException());} public void set( int index, int value){ data[index] = value; } } static interface IntIterator{ public int value()throws NoSuchElementException ; public boolean advance(); public boolean isValid(); } static class IntArrayList extends IntAbstractStream implements IntList{ private int size ; private int[] data ; public IntArrayList(){ this(3); } public IntArrayList( int capacity){ data = new int[capacity]; } public IntArrayList( IntCollection c){ this(c.size()); addAll(c); } public IntArrayList( IntStream c){ this(); if ( (c instanceof IntCollection)) {ensureCapacity((IntCollection)c); } addAll(c); } public IntArrayList( IntArrayList c){ size = c.size(); data = c.data.clone(); } public IntArrayList( int[] arr){ size = arr.length; data = arr.clone(); } public int size(){ return size;} public int get( int at){ if ( (at >= size)) {throw (new IndexOutOfBoundsException(((("at = " + at) + ", size = ") + size)));} return data[at];} private void ensureCapacity( int capacity){ if ( (data.length >= capacity)) {return ;} capacity = Math.max((2 * data.length),capacity); data = Arrays.copyOf(data,capacity); } public void addAt( int index, int value){ ensureCapacity((size + 1)); if ( ((index > size) || (index < 0))) {throw (new IndexOutOfBoundsException(((("at = " + index) + ", size = ") + size)));} if ( (index != size)) {System.arraycopy(data,index,data,(index + 1),(size - index)); } data[index] = value; size++; } public void removeAt( int index){ if ( ((index >= size) || (index < 0))) {throw (new IndexOutOfBoundsException(((("at = " + index) + ", size = ") + size)));} if ( (index != (size - 1))) {System.arraycopy(data,(index + 1),data,index,((size - index) - 1)); } size--; } public void set( int index, int value){ if ( (index >= size)) {throw (new IndexOutOfBoundsException(((("at = " + index) + ", size = ") + size)));} data[index] = value; } public int[] toArray(){ return Arrays.copyOf(data,size);} } }
6	public class G1{ static int n ,T ,duration[] ,type[] ; static long dp[][][] ,mod = ((long)1e9 + 7); public static void main( String[] args)throws Exception { new Thread(null,new Runnable(){},"Main",(1 << 28)).start(); } public static void solveIt()throws Exception { Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out); n = in.nextInt(); T = in.nextInt(); dp = new long[3][(T + 1)][(1 << n)]; duration = new int[n]; type = new int[n]; for ( int i = 0;(i < n);i++) {duration[i] = in.nextInt(); type[i] = (in.nextInt() - 1); }for ( long[][] a :dp) for ( long[] b :a) Arrays.fill(b,-1); pw.println(solve(0,T,0)); pw.close(); } static long solve( int lastType, int rem, int mask){ if ( (rem == 0)) return 1; if ( (rem < 0)) return 0; if ( (dp[lastType][rem][mask] != -1)) return dp[lastType][rem][mask]; long res = 0; for ( int i = 0;(i < n);i++) {if ( ((!check(mask,i) && ((lastType != type[i]) || (mask == 0))) && ((rem - duration[i]) >= 0))) {res += solve(type[i],(rem - duration[i]),set(mask,i)); if ( (res >= mod)) res -= mod; } }return dp[lastType][rem][mask] = res;} static boolean check( int N, int pos){ return ((N & (1 << pos)) != 0);} static int set( int N, int pos){ return N = (N | (1 << pos));} }
4	public class cf1497_Div2_E2{ static int[] spf ; public static int factor( int n){ int val = 1; while((n > 1)){ int cnt = 0;  int p = spf[n]; while(((n % p) == 0)){cnt++; n /= p; }if ( ((cnt % 2) == 1)) val *= p; }return val;} public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int t = in.nextInt();  int max = ((int)1e7 + 1);  boolean[] prime = new boolean[(max + 1)]; Arrays.fill(prime,true); prime[0] = prime[1] = false; spf = new int[max]; for ( int i = 2;(i < max);i++) spf[i] = i; for ( int i = 2;((i * i) < max);i++) {if ( prime[i]) {spf[i] = i; for ( int j = (i * i);(j < max);j += i) {prime[j] = false; spf[j] = i; }} } int[] cnts = new int[max]; for ( ;(t > 0);t--) { int n = in.nextInt();  int k = in.nextInt();  int[] vals = new int[n]; for ( int i = 0;(i < n);i++) vals[i] = factor(in.nextInt()); int[][] left = new int[(n + 1)][(k + 1)]; for ( int x = 0;(x <= k);x++) { int l = n;  int now = 0; for ( int i = (n - 1);(i >= 0);i--) {while((((l - 1) >= 0) && ((now + ((cnts[vals[(l - 1)]] > 0)?1:0)) <= x))){l--; now += ((cnts[vals[l]] > 0)?1:0); cnts[vals[l]]++; }left[i][x] = l; if ( (cnts[vals[i]] > 1)) now--; cnts[vals[i]]--; }} int oo = (int)1e9;  int[][] dp = new int[(n + 1)][(k + 1)]; for ( int i = 1;(i <= n);i++) Arrays.fill(dp[i],oo); 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 x = 0;(x <= j);x++) { int l = left[(i - 1)][x]; dp[i][j] = Math.min(dp[i][j],(dp[l][(j - x)] + 1)); }}} int min = Integer.MAX_VALUE; for ( int i = 0;(i <= k);i++) {min = Math.min(min,dp[n][i]); }out.println(min); }out.close(); } 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());} } }
5	public class CottageVillage{ class cl{ int x = 0; int a = 0; cl( int x, int a){ this.x = x; this.a = a; } } class cmp implements Comparator<cl>{ } public CottageVillage(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  cl[] w = new cl[n]; for ( int i = 0;(i < n);i++) w[i] = new cl(sc.nextInt(),sc.nextInt()); Arrays.sort(w,new cmp()); int cnt = 2,diff = 0; for ( int i = 1;(i < n);i++) {diff = (Math.abs(((((2 * w[i].x) - (2 * w[(i - 1)].x)) - w[i].a) - w[(i - 1)].a)) - (2 * k)); if ( (diff > 0)) cnt += 2; else if ( (diff == 0)) cnt++; }System.out.println(cnt); } public static void main( String... args){ new CottageVillage(); } }
4	public class Solution implements Runnable{ public static void main( String... strings)throws InterruptedException { new Thread(new Solution()).start(); } BufferedReader in ; PrintWriter out ; StringTokenizer st ; String next()throws Exception { if ( ((st == null) || !st.hasMoreElements())) st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws Exception { return Integer.parseInt(next());} int n ,m ,k ,xor = 0; boolean[][] used ; HashSet<Long>[] set ; void solve()throws Exception { n = nextInt(); m = nextInt(); k = nextInt(); used = new boolean[n][m]; set = new HashSet[2]; for ( int i = 0;(i < 2);set[i++] = new HashSet<Long>()) ;for ( int i = 0;(i < k);i++) { int x = (nextInt() - 1),y = (nextInt() - 1); used[x][y] = true; set[0].add(((10000L * x) + y)); }for ( ;;xor ^= 1) {set[(xor ^ 1)].clear(); int ansx = -1,ansy = -1; for ( long i :set[xor]) { int x = (int)(i / 10000),y = (int)(i % 10000); if ( (ansx < 0)) {ansx = (x + 1); ansy = (y + 1); } add((x + 1),y); add((x - 1),y); add(x,(y + 1)); add(x,(y - 1)); }if ( (set[(xor ^ 1)].size() == 0)) {out.println(((ansx + " ") + ansy)); break;} }} public void add( int x, int y){ if ( (((((x >= 0) && (y >= 0)) && (x < n)) && (y < m)) && !used[x][y])) return ; set[(xor ^ 1)].add(((10000L * x) + y)); used[x][y] = true; } }
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;} }
6	public class ElongatedMatrix{ public static void main( String[] args){ InputStream input ;  OutputStream output ; try{input = new FileInputStream("input.txt"); output = new FileOutputStream("output.txt"); }catch (FileNotFoundException e){ input = System.in; output = System.out; } Kattio io = new Kattio(input,output); new Solve(io).main(); io.close(); if ( (input instanceof FileInputStream)) try{input.close(); }catch (IOException e){ } if ( (output instanceof FileOutputStream)) try{output.close(); }catch (IOException e){ } } } class Solve{ static final int oo = (int)1e9; Kattio io ; int n ,m ; int[][] a ; int[][][] dp ; int[][] diff ; int[][] slant ; Solve( Kattio io){ this.io = io; } int getbit( int x, int n){ n--; return ((x >> n) & 1);} int setbit( int x, int n){ n--; return (x | (1 << n));} int caldp( int currentRow, int firstRow, int mask){ if ( (dp[currentRow][firstRow][mask] != -1)) return dp[currentRow][firstRow][mask]; dp[currentRow][firstRow][mask] = 0; if ( (mask == ((1 << n) - 1))) dp[currentRow][firstRow][mask] = slant[currentRow][firstRow]; else {for ( int i = 1;(i <= n);i++) if ( (getbit(mask,i) == 0)) {dp[currentRow][firstRow][mask] = Math.max(Math.min(caldp(i,firstRow,setbit(mask,i)),diff[currentRow][i]),dp[currentRow][firstRow][mask]); } }return dp[currentRow][firstRow][mask];} void main(){ n = io.getInt(); m = io.getInt(); a = new int[(n + 1)][(m + 1)]; dp = new int[(n + 1)][(n + 1)][(1 << n)]; for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= m);j++) a[i][j] = io.getInt(); diff = new int[(n + 1)][(n + 1)]; for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= n);j++) {diff[i][j] = oo; for ( int x = 1;(x <= m);x++) diff[i][j] = Math.min(diff[i][j],Math.abs((a[i][x] - a[j][x]))); }slant = new int[(n + 1)][(n + 1)]; for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= n);j++) {slant[i][j] = oo; for ( int x = 1;((x + 1) <= m);x++) slant[i][j] = Math.min(slant[i][j],Math.abs((a[i][x] - a[j][(x + 1)]))); }for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= n);j++) Arrays.fill(dp[i][j],-1); int res = 0; for ( int i = 1;(i <= n);i++) res = Math.max(res,caldp(i,i,setbit(0,i))); io.print(res); } } class Kattio extends PrintWriter{ public Kattio( InputStream i){ super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(i)); } public Kattio( InputStream i, OutputStream o){ super(new BufferedOutputStream(o)); r = new BufferedReader(new InputStreamReader(i)); } public boolean hasMoreTokens(){ return (peekToken() != null);} public int getInt(){ return Integer.parseInt(nextToken());} private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} }
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));} FastScanner in = new FastScanner(inputStream);  FastPrinter out = new FastPrinter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt();  int m = in.nextInt();  int p = in.nextInt();  int[] x = new int[p];  int[] y = new int[p]; for ( int i = 0;(i < p);i++) {x[i] = in.nextInt(); y[i] = in.nextInt(); } int X = x[0];  int Y = y[0];  int D = -1; for ( int dx = 1;(dx <= n);dx++) { int x1 = dx;  int y1 = 1;  int xx = 0;  int yy = 0;  int minD = Integer.MAX_VALUE; for ( int j = 0;(j < p);j++) { int d = (Math.abs((x1 - x[j])) + Math.abs((y1 - y[j]))); if ( (d < minD)) {minD = d; xx = x1; yy = y1; } }if ( (((D < minD) && (minD != 0)) && (minD != Integer.MAX_VALUE))) {D = minD; X = xx; Y = yy; } }for ( int dx = 1;(dx <= n);dx++) { int x1 = dx;  int y1 = m;  int xx = 0;  int yy = 0;  int minD = Integer.MAX_VALUE; for ( int j = 0;(j < p);j++) { int d = (Math.abs((x1 - x[j])) + Math.abs((y1 - y[j]))); if ( (d < minD)) {minD = d; xx = x1; yy = y1; } }if ( (((D < minD) && (minD != 0)) && (minD != Integer.MAX_VALUE))) {D = minD; X = xx; Y = yy; } }for ( int dy = 1;(dy <= m);dy++) { int x1 = 1;  int y1 = dy;  int xx = 0;  int yy = 0;  int minD = Integer.MAX_VALUE; for ( int j = 0;(j < p);j++) { int d = (Math.abs((x1 - x[j])) + Math.abs((y1 - y[j]))); if ( (d < minD)) {minD = d; xx = x1; yy = y1; } }if ( (((D < minD) && (minD != 0)) && (minD != Integer.MAX_VALUE))) {D = minD; X = xx; Y = yy; } }for ( int dy = 1;(dy <= m);dy++) { int x1 = n;  int y1 = dy;  int xx = 0;  int yy = 0;  int minD = Integer.MAX_VALUE; for ( int j = 0;(j < p);j++) { int d = (Math.abs((x1 - x[j])) + Math.abs((y1 - y[j]))); if ( (d < minD)) {minD = d; xx = x1; yy = y1; } }if ( (((D < minD) && (minD != 0)) && (minD != Integer.MAX_VALUE))) {D = minD; X = xx; Y = yy; } }for ( int i = 1;(i <= Math.min(m,n));i++) { int x1 = i;  int y1 = i;  int xx = 0;  int yy = 0;  int minD = Integer.MAX_VALUE; for ( int j = 0;(j < p);j++) { int d = (Math.abs((x1 - x[j])) + Math.abs((y1 - y[j]))); if ( (d < minD)) {minD = d; xx = x1; yy = y1; } }if ( (((D < minD) && (minD != 0)) && (minD != Integer.MAX_VALUE))) {D = minD; X = xx; Y = yy; } }for ( int i = 1,ii = m;((i <= n) && (ii >= 1));i++,ii--) { int x1 = i;  int y1 = ii;  int xx = 0;  int yy = 0;  int minD = Integer.MAX_VALUE; for ( int j = 0;(j < p);j++) { int d = (Math.abs((x1 - x[j])) + Math.abs((y1 - y[j]))); if ( (d < minD)) {minD = d; xx = x1; yy = y1; } }if ( (((D < minD) && (minD != 0)) && (minD != Integer.MAX_VALUE))) {D = minD; X = xx; Y = yy; } }out.println(((X + " ") + Y)); } } static class FastScanner{ public BufferedReader br ; public StringTokenizer st ; public FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } public FastScanner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public String next(){ while(((st == null) || !st.hasMoreElements())){ 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(next());} } static class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } } }
4	public class realfast implements Runnable{ static private final int INF = (int)1e9; long in = 1000000007; long fac[] = new long[1000001]; long inv[] = new long[1000001]; public void solve()throws IOException { int n = readInt();  long m = readInt();  long method[][] = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {method[0][i] = 1; method[i][0] = 1; }for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= n);j++) {for ( int k = i;(k >= 0);k--) {method[i][j] = (((method[i][j] % m) + (method[k][(j - 1)] % m)) % m); }}} long sum[][] = new long[(n + 2)][(n + 2)]; sum[0][0] = 1; long len[][] = new long[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {len[i][0] = 1; len[0][i] = 1; }for ( int i = 2;(i <= n);i++) {for ( int j = 1;(j < i);j++) {len[j][(i - j)] = (((len[(j - 1)][(i - j)] % m) + (len[j][((i - j) - 1)] % m)) % m); }} long gal[] = new long[((2 * n) + 1)]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= n);j++) {gal[(i + j)] = ((gal[(i + j)] + len[i][j]) % m); }}for ( int i = 1;(i <= n);i++) {if ( (i == (n - 1))) continue; for ( int j = 1;(j <= i);j++) {for ( int k = 1;(k <= j);k++) { long val = sum[(i - k)][(j - k)]; val = ((val * method[(j - k)][k]) % m); val = ((val * gal[(k - 1)]) % m); sum[(i + 1)][j] = ((sum[(i + 1)][j] + val) % m); }}} long ans = 0; for ( int i = 1;(i <= n);i++) {ans = ((ans + sum[(n + 1)][i]) % m); }out.println(ans); } public int value( int[] seg, int left, int right, int index, int l, int r){ if ( (left > right)) {return -100000000;} if ( ((right < l) || (left > r))) return -100000000; if ( ((left >= l) && (right <= r))) return seg[index]; int mid = (left + ((right - left) / 2));  int val = value(seg,left,mid,((2 * index) + 1),l,r);  int val2 = value(seg,(mid + 1),right,((2 * index) + 2),l,r); return Math.max(val,val2);} public int gcd( int a, int b){ if ( (a < b)) { int t = a; a = b; b = t; } if ( ((a % b) == 0)) return b; return gcd(b,(a % b));} public long pow( long n, long p, long m){ if ( (p == 0)) return 1; long val = pow(n,(p / 2),m); ;val = ((val * val) % m); if ( ((p % 2) == 0)) return val; else return ((val * n) % m);} public static void main( String[] args){ new Thread(null,new realfast(),"",(128 * (1L << 20))).start(); } static private final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); private BufferedReader reader ; private StringTokenizer tokenizer ; private PrintWriter out ; private String readString()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} @SuppressWarnings private int readInt()throws IOException { return Integer.parseInt(readString());} }
2	public class b817{ public static Scanner scn = new Scanner(System.in); public static void main( String[] args){ long n = scn.nextLong();  long s = scn.nextLong();  long lo = 0;  long hi = n; while((lo <= hi)){ long mid = ((lo + hi) / 2); if ( check(mid,s)) {hi = (mid - 1); } else {lo = (mid + 1); }}if ( check(lo,s)) {System.out.println(((n - lo) + 1)); } else {System.out.println("0"); }} public static boolean check( long n, long s){ long sum = 0;  long a = n; while((n > 0)){sum = (sum + (n % 10)); n = (n / 10); }if ( ((a - sum) >= s)) {return true;} return false;} }
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());} }
2	public class A{ static private final long MOD = 1000000009L; public static void main( String[] args)throws IOException { Scanner in = new Scanner(System.in);  long n = in.nextInt();  long m = in.nextInt();  long k = in.nextInt();  long w = (n - m);  long c = (w * k); if ( (c >= n)) {System.out.println(m); return ;} long rem = (n - c);  long h = (rem / k);  long p = power(2,(h + 1)); p -= 2; p += MOD; p %= MOD; p *= k; p %= MOD; long point = ((p + m) - ((h * k) % MOD)); point += MOD; point %= MOD; System.out.println(point); } static private long power( int num, long power){ if ( (power == 0)) return 1; long res = power(num,(power / 2)); res = ((res * res) % MOD); if ( ((power % 2) != 0)) res *= num; res %= MOD; return res;} }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; void mds( long choosed, long removed, long covered){ if ( (covered == ((1L << n) - 1))) {mds = choosed; return ;} if ( (Long.bitCount(choosed) >= (Long.bitCount(mds) - 1))) return ; long s = covered; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); s |= ((1L << i) | g[i]); }if ( (s != ((1L << n) - 1))) return ; int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) <= 1)) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && ((g[i] & (~removed | ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) k = i; }if ( (k == -1)) return ; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } void println( String s){ System.out.println(s); } public static void main( String[] args){ Locale.setDefault(Locale.US); new P111C().run(); } }
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);  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 m = in.nextInt();  boolean[][] g = new boolean[n][n]; for ( int i = 0;(i < m);++i) { int a = (in.nextInt() - 1);  int b = (in.nextInt() - 1); g[a][b] = true; g[b][a] = true; } long[] am = new long[(n + 1)];  long[][] ways = new long[(1 << n)][n]; for ( int start = 0;(start < n);++start) {for ( int mask = 0;(mask < (1 << (n - start)));++mask) for ( int last = start;(last < n);++last) {ways[mask][(last - start)] = 0; }ways[1][0] = 1; for ( int mask = 0;(mask < (1 << (n - start)));++mask) { int cnt = 0;  int tmp = mask; while((tmp > 0)){++cnt; tmp = (tmp & (tmp - 1)); }for ( int last = start;(last < n);++last) if ( (ways[mask][(last - start)] > 0)) { long amm = ways[mask][(last - start)]; for ( int i = start;(i < n);++i) if ( (((mask & (1 << (i - start))) == 0) && g[last][i])) {ways[(mask | (1 << (i - start)))][(i - start)] += amm; } if ( g[last][start]) am[cnt] += ways[mask][(last - start)]; } }} long res = 0; for ( int cnt = 3;(cnt <= n);++cnt) {if ( ((am[cnt] % 2) != 0)) throw (new RuntimeException()); res += (am[cnt] / 2); }out.println(res); } } 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 (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
0	public class test5{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long x = in.nextLong(); if ( (x >= 3)) {if ( ((x % 2) != 0)) System.out.println(((x * (x - 1)) * (x - 2))); else if ( ((x % 3) == 0)) System.out.println((((x - 3) * (x - 1)) * (x - 2))); else System.out.println(((x * (x - 1)) * (x - 3))); } else System.out.println(x); } }
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)); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  int[] arr = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {arr[i] = in.nextInt(); } int inversions = 0; for ( int i = 1;(i <= n);i++) {for ( int j = (i + 1);(j <= n);j++) {if ( (arr[i] > arr[j])) inversions++; }}inversions %= 2; int q = in.nextInt(); for ( int i = 0;(i < q);i++) { int l = in.nextInt(),r = in.nextInt();  int d = ((r - l) + 1); d = ((d * (d - 1)) / 2); if ( ((d & 1) == 1)) inversions ^= 1; out.println((((inversions & 1) == 1)?"odd":"even")); }} } 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());} } }
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);} }
5	public class Main{ public static void main( String[] args)throws Exception { int n = nextInt();  int a = nextInt();  int b = nextInt();  int[] tasks = new int[n]; for ( int i = 0;(i < n);i++) {tasks[i] = nextInt(); }Arrays.sort(tasks); exit((tasks[b] - tasks[(b - 1)])); } static private PrintWriter out ; static private BufferedReader inB ; static private boolean FILE = false; {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(); } }static private StreamTokenizer in = new StreamTokenizer(inB); static private void exit( Object o)throws Exception { out.println(o); out.flush(); System.exit(0); } static private void println( Object o)throws Exception { out.println(o); out.flush(); } static private void print( Object o)throws Exception { out.print(o); out.flush(); } static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} }
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); } } }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] parts = br.readLine().split("\\s+");  int n = Integer.parseInt(parts[0]);  int a = Integer.parseInt(parts[1]);  int b = Integer.parseInt(parts[2]); parts = br.readLine().split("\\s+"); int[] hard = new int[n]; for ( int i = 0;(i < n);i++) {hard[i] = Integer.parseInt(parts[i]); }Arrays.sort(hard); System.out.println((hard[b] - hard[(b - 1)])); } }
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 Def{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int t = s.nextInt(); while((t-- > 0)){ int n = s.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); } List<Integer> al = new ArrayList<>(); al.add(1); System.out.println(1); for ( int i = 1;(i < n);i++) { int len = al.size(); if ( (arr[i] == 1)) {for ( int j = 0;(j < len);j++) {System.out.print((al.get(j) + ".")); }System.out.println(1); al.add(1); } else if ( ((arr[i] == arr[(i - 1)]) && (arr[i] == 1))) {for ( int j = 0;(j < len);j++) {System.out.print((al.get(j) + ".")); }System.out.println(1); al.add(1); } else {for ( int j = (len - 1);(j > -1);j--) {if ( ((al.get(j) + 1) == arr[i])) {for ( int k = 0;(k < j);k++) {System.out.print((al.get(k) + ".")); }System.out.println(arr[i]); al.set(j,(al.get(j) + 1)); al.subList((j + 1),len).clear(); break;} }}}}s.close(); } }
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)); } }
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(),k = (in.nextInt() - 1),i ;  scores a[] = new scores[n]; for ( i = 0;(i < n);i++) a[i] = new scores(in.nextInt(),in.nextInt()); Arrays.sort(a); int c = 1; for ( i = (k - 1);(i >= 0);i--) {if ( ((a[i].p == a[k].p) && (a[i].t == a[k].t))) c++; else break;}for ( i = (k + 1);(i < n);i++) {if ( ((a[i].p == a[k].p) && (a[i].t == a[k].t))) c++; else break;}out.println(c); } class scores implements Comparable<scores>{ int p ,t ; public scores( int p, int t){ this.p = p; this.t = t; } } }
4	public class Main{ public static void main( String[] args)throws IOException { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter("output.txt");  TaskB solver = new TaskB(); solver.solve(in,out); out.close(); } static private class TaskB{ static final long max = 1000000000000000000L; static final double eps = 0.0000001; static final long mod = 1000000007; static int N ,M ,K ; static long X ,Y ; static boolean F[][][] ; static int D[][] ; void solve( InputReader in, PrintWriter out)throws IOException { N = in.nextInt(); M = in.nextInt(); K = in.nextInt(); F = new boolean[K][N][M]; D = new int[N][M]; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) D[i][j] = Integer.MAX_VALUE; List<Pair> list = new ArrayList<>(); for ( int i = 0;(i < K);i++) {list.add(new Pair((in.nextInt() - 1),(in.nextInt() - 1))); }for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) for ( int k = 0;(k < K);k++) D[i][j] = Math.min(D[i][j],(Math.abs((list.get(k).X - i)) + Math.abs((list.get(k).Y - j)))); int res = Integer.MIN_VALUE; for ( int j = 0;(j < N);j++) for ( int k = 0;(k < M);k++) if ( (D[j][k] > res)) {X = (j + 1); Y = (k + 1); res = D[j][k]; } out.println(((X + " ") + Y)); } class Pair{ int X ,Y ; Pair( int X, int Y){ this.X = X; this.Y = Y; } } long gcd( long A, long B){ if ( (B == 0)) return A; return gcd(B,(A % B));} long pow( long A, long B, long MOD){ if ( (B == 0)) {return 1;} if ( (B == 1)) {return A;} long val = pow(A,(B / 2),MOD); if ( ((B % 2) == 0)) {return ((val * val) % MOD);} else {return ((val * ((val * A) % MOD)) % MOD);}} } static private class InputReader{ StringTokenizer st ; BufferedReader br ; public InputReader( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public InputReader( FileReader s)throws FileNotFoundException{ br = new BufferedReader(s); } 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 int nextInt(){ return Integer.parseInt(next());} public boolean ready(){ try{return br.ready(); }catch (IOException e){ throw (new RuntimeException(e));} } } }
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());} } }
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(); for ( int i = 60;(i >= 0);--i) { long b = (1L << i);  long A = (L & b),B = (R & b); if ( (A != B)) exit(((2 * b) - 1)); }exit(0); } 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();} }
3	public class C{ static private double r ,EPS = 1e-10; public static void solve( FastScanner fs){ int n = fs.nextInt(); r = fs.nextInt(); int[] xCoords = fs.readArray(n);  ArrayList<Point> placed = new ArrayList<>(); for ( int x :xCoords) { double maxY = r; for ( Point p :placed) maxY = Math.max(maxY,getNewY(p,x)); placed.add(new Point(x,maxY)); }for ( Point p :placed) {System.out.printf("%.9f ",p.y); }} static private double getNewY( Point circleCenter, int x){ double dx = Math.abs((x - circleCenter.x)); if ( (dx > (r + r))) return 0; if ( (dx < EPS)) return ((circleCenter.y + r) + r); double hypot = (r + r); return (circleCenter.y + Math.sqrt(((hypot * hypot) - ((double)dx * dx))));} static class Point{ double x ; double y ; public Point( double x, double y){ this.x = x; this.y = y; } } public static void main( String[] args)throws NumberFormatException,IOException { FastScanner scanner = new FastScanner(System.in); solve(scanner); } static private 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());} long nextLong(){ return Long.parseLong(next());} int[] readArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
5	public class Solution{ static class Cottage implements Comparable<Cottage>{ public int x ; public double a ; public Cottage( int x, int a){ this.x = x; this.a = a; } } static final double e = 1e-9; public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int t = in.nextInt();  Cottage[] cottages = new Cottage[n]; for ( int i = 0;(i < n);i++) cottages[i] = new Cottage(in.nextInt(),in.nextInt()); Arrays.sort(cottages); int ans = 2; for ( int i = 1;(i < cottages.length);i++) { double diff = (((cottages[i].x - cottages[(i - 1)].x) - (cottages[(i - 1)].a / 2)) - (cottages[i].a / 2)); ans = ((Math.abs((diff - t)) < e)?(ans + 1):(((diff - t) < -e)?ans:(ans + 2))); }out.print(ans); out.close(); } }
1	public class EdD{ 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 t = sc.nextInt(); for ( int i = 0;(i < t);i++) { int n = sc.nextInt(); if ( ((n % 2) == 1)) out.println("NO"); else {while(((n % 2) == 0)){n /= 2; }verdict((isSquare(n) || isSquare((2 * n)))); }}out.close(); } public static boolean isSquare( int n){ int d = (int)Math.sqrt(n); for ( long s = (d - 2);(s <= (d + 2));s++) {if ( ((s * s) == n)) return true; }return false;} 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);} static void verdict( boolean a){ out.println((a?"YES":"NO")); } 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 cf2{ static final double EPS = 1e-9; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int xr1 = sc.nextInt(),yr1 = sc.nextInt(),xr2 = sc.nextInt(),yr2 = sc.nextInt();  int xr3 = sc.nextInt(),yr3 = sc.nextInt(),xr4 = sc.nextInt(),yr4 = sc.nextInt();  Point pr1 = new Point(xr1,yr1);  Point pr2 = new Point(xr2,yr2);  Point pr3 = new Point(xr3,yr3);  Point pr4 = new Point(xr4,yr4);  LineSegment lr1 = new LineSegment(pr1,pr2);  LineSegment lr2 = new LineSegment(pr2,pr3);  LineSegment lr3 = new LineSegment(pr3,pr4);  LineSegment lr4 = new LineSegment(pr4,pr1);  int xd1 = sc.nextInt(),yd1 = sc.nextInt(),xd2 = sc.nextInt(),yd2 = sc.nextInt();  int xd3 = sc.nextInt(),yd3 = sc.nextInt(),xd4 = sc.nextInt(),yd4 = sc.nextInt();  Point p1 = new Point(xd1,yd1);  Point p2 = new Point(xd2,yd2);  Point p3 = new Point(xd3,yd3);  Point p4 = new Point(xd4,yd4);  Point[] pt = new Point[5]; pt[0] = p1; pt[1] = p2; pt[2] = p3; pt[3] = p4; pt[4] = p1; Polygon pg = new Polygon(pt); if ( (((pg.inside(pr1) || pg.inside(pr2)) || pg.inside(pr3)) || pg.inside(pr4))) {System.out.println("YES"); return ;} LineSegment ld1 = new LineSegment(p1,p2);  LineSegment ld2 = new LineSegment(p2,p3);  LineSegment ld3 = new LineSegment(p3,p4);  LineSegment ld4 = new LineSegment(p4,p1);  Rectangle rec = new Rectangle(new Point(Math.min(Math.min(xr3,xr4),Math.min(xr1,xr2)),Math.min(Math.min(yr3,yr4),Math.min(yr1,yr2))),new Point(Math.max(Math.max(xr3,xr4),Math.max(xr1,xr2)),Math.max(Math.max(yr3,yr4),Math.max(yr1,yr2)))); if ( (((rec.contains(p1) || rec.contains(p2)) || rec.contains(p3)) || rec.contains(p4))) {System.out.println("YES"); return ;} if ( (((ld1.intersect(lr1) || ld1.intersect(lr3)) || ld1.intersect(lr3)) || ld1.intersect(lr4))) {System.out.println("YES"); return ;} if ( (((ld2.intersect(lr1) || ld2.intersect(lr3)) || ld2.intersect(lr3)) || ld2.intersect(lr4))) {System.out.println("YES"); return ;} if ( (((ld3.intersect(lr1) || ld3.intersect(lr3)) || ld3.intersect(lr3)) || ld3.intersect(lr4))) {System.out.println("YES"); return ;} if ( (((ld4.intersect(lr1) || ld4.intersect(lr3)) || ld4.intersect(lr3)) || ld4.intersect(lr4))) {System.out.println("YES"); return ;} System.out.println("NO"); } public static class Polygon{ static final double EPS = 1e-9; Point[] g ; Polygon( Point[] o){ g = o; } double area(){ double area = 0.0; for ( int i = 0;(i < (g.length - 1));++i) area += ((g[i].x * g[(i + 1)].y) - (g[i].y * g[(i + 1)].x)); return (Math.abs(area) / 2.0);} boolean inside( Point p){ double sum = 0.0; for ( int i = 0;(i < (g.length - 1));++i) { double angle = Point.angle(g[i],p,g[(i + 1)]); if ( (((Math.abs(angle) < EPS) || (Math.abs((angle - Math.PI)) < EPS)) && p.between(g[i],g[(i + 1)]))) return true; if ( Point.ccw(p,g[i],g[(i + 1)])) sum += angle; else sum -= angle; }return (Math.abs(((2 * Math.PI) - Math.abs(sum))) < EPS);} } static class LineSegment{ Point p ,q ; LineSegment( Point a, Point b){ p = a; q = b; } boolean intersect( LineSegment ls){ Line l1 = new Line(p,q),l2 = new Line(ls.p,ls.q); if ( l1.parallel(l2)) {if ( l1.same(l2)) return (((p.between(ls.p,ls.q) || q.between(ls.p,ls.q)) || ls.p.between(p,q)) || ls.q.between(p,q)); return false;} Point c = l1.intersect(l2); return (c.between(p,q) && c.between(ls.p,ls.q));} } static class Rectangle{ static final double EPS = 1e-9; Point ll ,ur ; Rectangle( Point a, Point b){ ll = a; ur = b; } double area(){ return ((ur.x - ll.x) * (ur.y - ll.y));} boolean contains( Point p){ return ((((p.x <= (ur.x + EPS)) && ((p.x + EPS) >= ll.x)) && (p.y <= (ur.y + EPS))) && ((p.y + EPS) >= ll.y));} Rectangle intersect( Rectangle r){ Point ll = new Point(Math.max(this.ll.x,r.ll.x),Math.max(this.ll.y,r.ll.y));  Point ur = new Point(Math.min(this.ur.x,r.ur.x),Math.min(this.ur.y,r.ur.y)); if ( ((((((Math.abs((ur.x - ll.x)) > EPS) && (Math.abs((ur.y - ll.y)) > EPS)) && this.contains(ll)) && this.contains(ur)) && r.contains(ll)) && r.contains(ur))) return new Rectangle(ll,ur); return null;} } static class Line{ static final double INF = 1e9,EPS = 1e-9; double a ,b ,c ; Line( Point p, Point q){ if ( (Math.abs((p.x - q.x)) < EPS)) {a = 1; b = 0; c = -p.x; } else {a = ((p.y - q.y) / (q.x - p.x)); b = 1.0; c = ((a * p.x) + p.y); }} Line( Point p, double m){ a = -m; b = 1; c = ((a * p.x) + p.y); } boolean parallel( Line l){ return ((Math.abs((a - l.a)) < EPS) && (Math.abs((b - l.b)) < EPS));} boolean same( Line l){ return (parallel(l) && (Math.abs((c - l.c)) < EPS));} Point intersect( Line l){ if ( parallel(l)) return null; double x = (((b * l.c) - (c * l.b)) / ((a * l.b) - (b * l.a)));  double y ; if ( (Math.abs(b) < EPS)) y = ((-l.a * x) - l.c); else y = ((-a * x) - c); return new Point(x,y);} } public static class Vector{ double x ,y ; Vector( double a, double b){ x = a; y = b; } Vector( Point a, Point b){ this((b.x - a.x),(b.y - a.y)); } Vector scale( double s){ return new Vector((x * s),(y * s));} double dot( Vector v){ return ((x * v.x) + (y * v.y));} double cross( Vector v){ return ((x * v.y) - (y * v.x));} double norm2(){ return ((x * x) + (y * y));} } static class Point implements Comparable<Point>{ static final double EPS = 1e-9; double x ,y ; Point( double a, double b){ x = a; y = b; } static double angle( Point a, Point o, Point b){ Vector oa = new Vector(o,a),ob = new Vector(o,b); return Math.acos((oa.dot(ob) / Math.sqrt((oa.norm2() * ob.norm2()))));} static boolean ccw( Point p, Point q, Point r){ return (new Vector(p,q).cross(new Vector(p,r)) > 0);} public double dist( Point p){ return Math.sqrt((sq((x - p.x)) + sq((y - p.y))));} static double sq( double x){ return (x * x);} boolean between( Point p, Point q){ return ((((x < (Math.max(p.x,q.x) + EPS)) && ((x + EPS) > Math.min(p.x,q.x))) && (y < (Math.max(p.y,q.y) + EPS))) && ((y + EPS) > Math.min(p.y,q.y)));} } 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 Scanner( String file)throws FileNotFoundException{ br = new BufferedReader(new FileReader(file)); } public int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
2	public class Solution{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  Scanner in = new Scanner(System.in);  StringBuilder out = new StringBuilder();  long n = in.nextLong(),k = in.nextLong();  long a = 1,b = 3,c = (-2 * (n + k));  long r1 = ((-b + (long)Math.sqrt(((b * b) - ((4 * a) * c)))) / (2 * a));  long r2 = ((-b - (long)Math.sqrt(((b * b) - ((4 * a) * c)))) / (2 * a)); System.out.println((n - Math.max(r1,r2))); } }
2	public class EhabAndAnotherAnotherXorProblem implements Closeable{ private InputReader in = new InputReader(System.in); private PrintWriter out = new PrintWriter(System.out); public void solve(){ int initial = ask(0,0);  int a = 0,b = 0; if ( (initial == 0)) {for ( int i = 0;(i < 30);i++) { int response = ask((1 << i),0); if ( (response == -1)) {a |= (1 << i); } }b = a; } else {for ( int i = 29;(i >= 0);i--) { int response = ask((a | (1 << i)),(b | (1 << i))); if ( (response != initial)) {if ( (response == 1)) {b |= (1 << i); } else {a |= (1 << i); }initial = ask(a,b); } else {response = ask((a | (1 << i)),b); if ( (response == -1)) {a |= (1 << i); b |= (1 << i); } }}}answer(a,b); } private int ask( int c, int d){ out.printf("? %d %d\n",c,d); out.flush(); return in.ni();} private void answer( int a, int b){ out.printf("! %d %d\n",a,b); out.flush(); } @Override public void close()throws IOException { in.close(); out.close(); } 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 ni(){ return Integer.parseInt(next());} public void close()throws IOException { reader.close(); } } public static void main( String[] args)throws IOException { try(EhabAndAnotherAnotherXorProblem instance=new EhabAndAnotherAnotherXorProblem()){instance.solve(); }} }
2	public class utkarsh{ InputStream is ; PrintWriter out ; long mod = (long)(1e9 + 7),inf = (long)3e18; void solve(){ int q = ni(); while((q-- > 0)){ long n = nl(),k = nl(); if ( (n <= 31)) { long m = (long)Math.pow(4,n);  long x = ((m - 1) / 3); if ( (k > x)) {out.println("NO"); continue;} long b = 0,p = 1,d = 1; x = 2; while((k > b)){n--; k -= p; m /= 4; if ( (m == 0)) break; b += ((d * (m - 1)) / 3); p += x; x <<= 1; d += x; }out.println(((((n >= 0) && (k >= 0)) && (k <= b))?("YES " + n):"NO")); } else {out.println(("YES " + (n - 1))); }}} 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);} long nl(){ long n = 0L;  int b = readByte();  boolean minus = false; while(((b != -1) && (((b >= '0') && (b <= '9')) || (b == '-')))){b = readByte(); }if ( (b == '-')) {minus = true; b = readByte(); } while(((b >= '0') && (b <= '9'))){n = ((n * 10) + (b - '0')); b = readByte(); }return (minus?-n:n);} 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));} }
0	public class Main{ StreamTokenizer in ; 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))); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public void solve()throws Exception { int n = nextInt();  long ans = 0; for ( int i = 0;(i < n);i += 2) ans += 3; out.println(ans); } }
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();} } }
6	public class Main{ static MyScanner scan ; static PrintWriter pw ; static long MOD = 1_000_000_007; static long INF = 1_000_000_000_000_000_000L; static long inf = 2_000_000_000; public static void main( String[] args){ new Thread(null,null,"BaZ",(1 << 27)){}.start(); } static int n ,m ; static int dp[] ,cnt[][] ,sum[] ; static void solve()throws IOException { initIo(false); StringBuilder sb = new StringBuilder(); n = ni(); m = ni(); dp = new int[(1 << m)]; char c[] = ne().toCharArray(); cnt = new int[m][m]; for ( int i = 0;((i + 1) < n);++i) {if ( (c[i] != c[(i + 1)])) {++cnt[(c[i] - 'a')][(c[(i + 1)] - 'a')]; ++cnt[(c[(i + 1)] - 'a')][(c[i] - 'a')]; } }sum = new int[(1 << m)]; calc(0,0,0); Arrays.fill(dp,-1); pl(f(0)); pw.flush(); pw.close(); } static void calc( int mask, int S, int pos){ if ( (pos == m)) {sum[mask] = S; return ;} calc(mask,S,(pos + 1)); int newSum = S; for ( int i = 0;(i < pos);++i) {if ( ((mask & (1 << i)) != 0)) {newSum -= cnt[i][pos]; } else {newSum += cnt[i][pos]; }}for ( int i = (pos + 1);(i < m);++i) {newSum += cnt[i][pos]; }calc((mask | (1 << pos)),newSum,(pos + 1)); } static int f( int mask){ if ( (mask == ((1 << m) - 1))) {return 0;} if ( (dp[mask] != -1)) {return dp[mask];} int min = Integer.MAX_VALUE; for ( int i = 0;(i < m);++i) {if ( ((mask & (1 << i)) == 0)) {min = min(min,(sum[mask] + f((mask | (1 << i))))); } }return dp[mask] = min;} static void initIo( boolean isFileIO)throws IOException { scan = new MyScanner(isFileIO); if ( isFileIO) {pw = new PrintWriter("/Users/amandeep/Desktop/output.txt"); } else {pw = new PrintWriter(System.out,true); }} static int ni()throws IOException { return scan.nextInt();} static String ne()throws IOException { return scan.next();} static void pl(){ pw.println(); } static void p( Object o){ pw.print((o + " ")); } static void pl( Object o){ pw.println(o); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner( boolean readingFromFile)throws IOException{ if ( readingFromFile) {br = new BufferedReader(new FileReader("/Users/amandeep/Desktop/input.txt")); } else {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 DigitsSequence2{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long index = scanner.nextLong(); solution1(index); } static void solution1( Long index){ int i = 1;  long len = 9;  long max = 9; while((len < index)){ long tmp = (9 * (long)Math.pow(10,i)); i++; len += (i * tmp); max += tmp; } long diff = (len - index);  long laterCount = (diff / i);  int remainder = (int)(diff % i);  long current = (max - laterCount);  int k = ((i - 1) - remainder); System.out.println(String.valueOf(current).charAt(k)); } }
5	public class A{ final int MOD = ((int)1e9 + 7); final double eps = 1e-12; final int INF = (int)1e9; public A(){ int N = sc.nextInt();  int K = sc.nextInt();  Long[] A = sc.nextLongs(); sort(A); Set<Long> S = new HashSet<Long>(); for ( long a :A) {if ( (((a % K) == 0) && S.contains((P * (a / K))))) continue; S.add((P * a)); } int res = S.size(); exit(res); } long P = probablePrime(50,new Random()).longValue(); 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 A(); exit(); } static void start(){ t = millis(); } static PrintWriter pw = new PrintWriter(System.out); static long t ; static long millis(){ return System.currentTimeMillis();} }
6	public class LookingForOrder{ static final int INF = (int)1e9; static Point a[] ; static Point o ; static int n ; static int dp[] ; static PrintWriter out ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in); out = new PrintWriter(System.out); o = new Point(sc.nextInt(),sc.nextInt()); n = sc.nextInt(); a = new Point[n]; for ( int i = 0;(i < n);i++) a[i] = new Point(sc.nextInt(),sc.nextInt()); dp = new int[((1 << n) + 5)]; Arrays.fill(dp,-1); out.println(rec(0)); out.print((0 + " ")); path(0); out.println(); out.flush(); out.close(); } static void path( int msk){ if ( (msk == ((1 << n) - 1))) return ; int optimal = rec(msk); for ( int i = 0;(i < n);i++) {if ( ((msk & (1 << i)) == 0)) {if ( ((rec((msk | (1 << i))) + (2 * o.dist(a[i]))) == optimal)) {out.print(((((i + 1) + " ") + 0) + " ")); path((msk | (1 << i))); return ;} for ( int j = 0;(j < n);j++) if ( ((((rec(((msk | (1 << i)) | (1 << j))) + o.dist(a[i])) + a[i].dist(a[j])) + a[j].dist(o)) == optimal)) {out.print(((((((i + 1) + " ") + (j + 1)) + " ") + 0) + " ")); path(((msk | (1 << i)) | (1 << j))); return ;} break;} }} static int rec( int msk){ if ( (msk == ((1 << n) - 1))) return 0; if ( (dp[msk] != -1)) return dp[msk]; int ans = INF; for ( int i = 0;(i < n);i++) {if ( ((msk & (1 << i)) == 0)) {ans = Math.min(ans,(rec((msk | (1 << i))) + (2 * o.dist(a[i])))); for ( int j = 0;(j < n);j++) {if ( (i == j)) continue; if ( ((msk & (1 << j)) == 0)) ans = Math.min(ans,(((rec(((msk | (1 << i)) | (1 << j))) + o.dist(a[i])) + a[i].dist(a[j])) + a[j].dist(o))); }break;} }return dp[msk] = ans;} static class Point{ int x ,y ; public Point( int x, int y){ this.x = x; this.y = y; } public int dist( Point p){ return (((x - p.x) * (x - p.x)) + ((y - p.y) * (y - p.y)));} } static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner( FileReader f){ br = new BufferedReader(f); } public Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(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());} } }
5	public class A{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void solve()throws IOException { int n = readInt();  int m = readInt();  int k = readInt();  int[] a = readArr(n); Arrays.sort(a); for ( int i = 0;(i <= n);i++) { int curR = k; for ( int j = (n - 1);(j >= (n - i));j--) {curR += a[j]; }curR -= i; if ( (curR >= m)) {out.println(i); return ;} }out.println(-1); } 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());} long readLong()throws IOException { return Long.parseLong(readString());} int[] readArr( int n)throws IOException { int[] res = new int[n]; for ( int i = 0;(i < n);i++) {res[i] = readInt(); }return res;} public static void main( String[] args){ new A().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); } } }
0	public final class FollowTrafficRules{ static private double[] acce( double i, double a, double v){ double[] r = new double[2]; r[0] = ((v - i) / a); r[1] = ((((1d / 2d) * a) * pow(r[0],2)) + (i * r[0])); return r;} static private double solve( double i, double a, double l){ double e = sqrt((pow(i,2) + ((2d * a) * l))); e = ((a > 0)?e:(-1d * e)); return ((e - i) / a);} static private double time( double i, double a, double v, double l){ double[] r = acce(i,a,v); if ( (r[1] >= l)) return solve(i,a,l); return (r[0] + ((l - r[1]) / v));} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  double a = sc.nextDouble();  double v = sc.nextDouble();  double l = sc.nextDouble();  double d = sc.nextDouble();  double w = sc.nextDouble();  double t = 0d;  double[] r = acce(0,a,w); if ( ((v <= w) || (r[1] >= d))) t = time(0,a,v,l); else {t += r[0]; t += (2d * time(w,a,v,((d - r[1]) / 2d))); t += time(w,a,v,(l - d)); }System.out.println(t); } }
1	public class BB{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  int a[] = new int[(n + 1)];  boolean used[] = new boolean[100009]; for ( int i = 1;(i <= n);i++) {a[i] = sc.nextInt(); } int cnt = 0;  int id = 0; for ( int i = 1;(i <= n);i++) {if ( !used[a[i]]) {cnt++; used[a[i]] = true; } if ( (cnt == k)) {id = i; break;} } boolean x[] = new boolean[100005];  int y = 0;  int id1 = 0; if ( (id == 0)) {System.out.println(((-1 + " ") + -1)); return ;} for ( int i = id;(i >= 1);i--) {if ( !x[a[i]]) {y++; x[a[i]] = true; } if ( (y == k)) {id1 = i; break;} }System.out.println(((id1 + " ") + id)); } }
5	public class A{ String line ; StringTokenizer inputParser ; BufferedReader is ; FileInputStream fstream ; DataInputStream in ; String FInput = ""; void openInput( String file){ if ( (file == null)) is = new BufferedReader(new InputStreamReader(System.in)); else {try{fstream = new FileInputStream(file); in = new DataInputStream(fstream); is = new BufferedReader(new InputStreamReader(in)); }catch (Exception e){ System.err.println(e); } }} void readNextLine(){ try{line = is.readLine(); inputParser = new StringTokenizer(line," "); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } catch (NullPointerException e){ line = null; } } int NextInt(){ String n = inputParser.nextToken();  int val = Integer.parseInt(n); return val;} void closeInput(){ try{is.close(); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } public static void main( String[] argv){ String filePath = null; if ( (argv.length > 0)) filePath = argv[0]; new A(filePath); } public A( String inputFile){ openInput(inputFile); readNextLine(); int N = NextInt(),M = NextInt(),K = NextInt();  int[] v = new int[N]; readNextLine(); for ( int i = 0;(i < N);i++) {v[i] = NextInt(); }Arrays.sort(v); M -= (K - 1); int id = (N - 1);  int ret = 0; while(((M > 1) && (id >= 0))){M++; M -= v[id--]; ret++; }if ( ((id < 0) && (M > 1))) ret = -1; System.out.println(ret); closeInput(); } }
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();} } }
2	public class Main implements Runnable{ public static void main( String[] args){ new Thread(null,new Main(),"Check2",(1 << 28)).start(); } static long mod = (long)(1e9 + 7); long power( long x, long y, long mod){ if ( (y == 0)) return (1 % mod); if ( (y == 1)) return (x % mod); long res = 1; x = (x % mod); while((y > 0)){if ( ((y % 2) != 0)) {res = ((res * x) % mod); } y = (y / 2); x = ((x * x) % mod); }return res;} 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 ; 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); } } }
2	public class Template{ 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(); } public void solve()throws Exception { long l = nextLong();  long r = nextLong();  long[] x = new long[100];  int kx = 0; while((r > 0)){x[kx++] = (r % 2); r /= 2; } long[] y = new long[100];  int ky = 0; while((l > 0)){y[ky++] = (l % 2); l /= 2; } long[] ans = new long[100];  boolean ok = false; for ( int k = (kx - 1);(k >= 0);k--) {if ( ok) {ans[k] = 1; continue;} if ( (x[k] > y[k])) {ans[k] = 1; ok = true; } } long a = 0;  long p2 = 1; for ( int i = 0;(i < kx);i++) {a += (p2 * ans[i]); p2 *= 2; }out.println(a); } public static void main( String[] args)throws Exception { new Template().run(); } }
1	public class CF1197B{ public static void main( String[] args){ FastReader input = new FastReader();  int n = input.nextInt();  int[] arr = new int[n];  int max = 0;  int maxIndex = 0; for ( int i = 0;(i < n);i++) {arr[i] = input.nextInt(); if ( (arr[i] > max)) {max = arr[i]; maxIndex = i; } } int j = (maxIndex - 1);  int k = (maxIndex + 1); while(((j >= 0) && (k < n))){if ( (arr[j] > arr[k])) {if ( (arr[j] < max)) {max = arr[j]; j--; } else {System.out.println("NO"); return ;}} else {if ( (arr[k] < max)) {max = arr[k]; k++; } else {System.out.println("NO"); return ;}}}if ( (j >= 0)) {while((j >= 0)){if ( (arr[j] < max)) {max = arr[j]; j--; } else {System.out.println("NO"); return ;}}} if ( (k < n)) {while((k < n)){if ( (arr[k] < max)) {max = arr[k]; k++; } else {System.out.println("NO"); return ;}}} if ( ((j == -1) && (k == n))) {System.out.println("YES"); } } 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 A{ public static void main( String[] ar)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String s1[] = br.readLine().split(" ");  String s2[] = br.readLine().split(" ");  int n = Integer.parseInt(s1[0]);  int m = Integer.parseInt(s1[1]);  int a[] = new int[n];  int b[] = new int[n];  int c[] = new int[n];  int d[] = new int[n];  HashSet<Integer> hs = new HashSet<Integer>(); hs.add(0); hs.add(m); int max = 0; for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(s2[i]); if ( ((i % 2) == 0)) b[i] = 1; hs.add(a[i]); }c[0] = a[0]; for ( int i = 1;(i < n);i++) {if ( (b[i] == 0)) c[i] = c[(i - 1)]; else c[i] = ((c[(i - 1)] + a[i]) - a[(i - 1)]); }if ( (b[(n - 1)] == 0)) d[(n - 1)] = (m - a[(n - 1)]); for ( int i = (n - 2);(i >= 0);i--) {if ( (b[i] == 1)) d[i] = d[(i + 1)]; else d[i] = ((d[(i + 1)] + a[(i + 1)]) - a[i]); }max = c[(n - 1)]; if ( (b[(n - 1)] == 0)) max += (m - a[(n - 1)]); for ( int i = (n - 1);(i >= 0);i--) { int u = (a[i] - 1);  int v = (a[i] + 1); if ( !hs.contains(u)) {if ( (b[i] == 0)) { int r = ((((1 + m) - a[i]) - d[i]) + c[(i - 1)]); max = Math.max(max,r); } else { int l = 0; if ( (i > 0)) l = a[(i - 1)];  int r = ((((c[i] - 1) + m) - a[i]) - d[i]); max = Math.max(max,r); }} if ( !hs.contains(v)) {if ( (b[i] == 0)) {if ( (i == (n - 1))) { int r = (c[i] + 1); max = Math.max(max,r); } else { int r = ((((c[i] + 1) + m) - a[(i + 1)]) - d[(i + 1)]); max = Math.max(max,r); }} else {if ( (i == (n - 1))) { int r = (((c[i] + m) - a[i]) - 1); max = Math.max(max,r); } else { int r = ((((((c[i] + m) - a[(i + 1)]) - d[(i + 1)]) + a[(i + 1)]) - 1) - a[i]); max = Math.max(max,r); }}} }System.out.println(max); } }
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(); } }
4	public class C{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int i ,N ;  int T = Integer.parseInt(br.readLine().trim());  StringBuilder sb = new StringBuilder(); while((T-- > 0)){N = Integer.parseInt(br.readLine().trim()); int[] a = new int[N]; for ( i = 0;(i < N);i++) a[i] = Integer.parseInt(br.readLine().trim()); int end = 1;  int[][] ans = new int[N][(N + 10)]; ans[0][0] = 1; for ( i = 1;(i < N);i++) {while(true){if ( (ans[(i - 1)][end] == (a[i] - 1))) break; end--; }for ( int j = 0;(j < end);j++) ans[i][j] = ans[(i - 1)][j]; ans[i][end] = a[i]; end++; }for ( i = 0;(i < N);i++) {for ( int j = 0;((j < N) && (ans[i][j] != 0));j++) {sb.append(ans[i][j]); if ( (ans[i][(j + 1)] != 0)) sb.append('.'); }sb.append("\n"); }}System.out.println(sb); } }
6	public class B{ final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); final PrintWriter printer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); StringTokenizer tokenizer ; final int[][] d ; final int n ; final int[] time ; final Action[] actions ; static private final class Action{ int a ; int b ; public Action( int a){ this.a = this.b = a; } public Action( int a, int b){ this.a = a; this.b = b; } } static private final int dist( int x1, int y1, int x2, int y2){ return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));} private final boolean in( int x, int set){ return (((1 << x) & set) != 0);} private final int off( int x, int set){ return (set ^ (set & (1 << x)));} private final int solve( int set){ if ( (time[set] > 0)) return time[set]; int min = Integer.MAX_VALUE; if ( (set == 0)) min = 0; else { int a ; for ( a = 0;(a < n);a++) if ( in(a,set)) break; int subset = off(a,set);  int aux = ((2 * d[a][a]) + solve(subset)); if ( (aux < min)) {min = aux; actions[set] = new Action(a); } for ( int b = (a + 1);(b < n);b++) if ( in(b,subset)) {aux = (((d[a][a] + d[b][b]) + d[a][b]) + solve(off(b,subset))); if ( (aux < min)) {min = aux; actions[set] = new Action(a,b); } } }time[set] = min; return min;} private B()throws IOException{ int bx = nextInt();  int by = nextInt(); 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(); }reader.close(); d = new int[n][n]; for ( int i = 0;(i < n);i++) {d[i][i] = dist(bx,by,x[i],y[i]); for ( int j = (i + 1);(j < n);j++) d[i][j] = dist(x[i],y[i],x[j],y[j]); } int set = (1 << n); time = new int[set]; actions = new Action[set]; set--; printer.println(solve(set)); printer.print("0"); while((set != 0)){solve(set); Action action = actions[set]; printer.print(action); printer.print(" 0"); set = off(action.a,set); set = off(action.b,set); }printer.println(); printer.close(); } private final int nextInt()throws IOException { return Integer.parseInt(nextToken());} private final 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 { new B(); } }
2	public class B1195{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  long x = sc.nextInt();  long y = sc.nextInt();  long m = ((-3 + Math.round(Math.sqrt((9 + (8 * (x + y)))))) / 2);  long e = (x - m); pw.println(e); pw.flush(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( FileReader r){ br = new BufferedReader(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();} } }
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(); } }
4	public class C2{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = na(n); for ( int i = 0;(i < n);i++) { int v = a[i]; for ( int j = 2;((j * j) <= v);j++) {while(((v % (j * j)) == 0)){v /= (j * j); }}a[i] = v; }Arrays.sort(a); int[] f = new int[n];  int p = 0; for ( int i = 0;(i < n);i++) {if ( ((i > 0) && (a[i] != a[(i - 1)]))) {p++; } f[p]++; }f = Arrays.copyOf(f,(p + 1)); int mod = 1000000007;  int[][] fif = enumFIF(1000,mod);  long[] res = countSameNeighborsSequence(f,fif,mod);  long ans = res[0]; for ( int v :f) {ans = ((ans * fif[0][v]) % mod); }out.println(ans); } public static int[][] enumFIF( int n, int mod){ int[] f = new int[(n + 1)];  int[] invf = new int[(n + 1)]; f[0] = 1; for ( int i = 1;(i <= n);i++) {f[i] = (int)(((long)f[(i - 1)] * i) % mod); } long a = f[n];  long b = mod;  long p = 1,q = 0; while((b > 0)){ long c = (a / b);  long d ; d = a; a = b; b = (d % b); d = p; p = q; q = (d - (c * q)); }invf[n] = (int)((p < 0)?(p + mod):p); for ( int i = (n - 1);(i >= 0);i--) {invf[i] = (int)(((long)invf[(i + 1)] * (i + 1)) % mod); }return new int[][]{f,invf};} public static long[] countSameNeighborsSequence( int[] a, int[][] fif, int mod){ int n = a.length;  int bef = a[0];  int aft = a[0];  long[] dp = new long[bef]; dp[(bef - 1)] = 1; for ( int u = 1;(u < n);u++) { int v = a[u]; aft += v; long[][] ldp = new long[bef][aft]; for ( int i = 0;(i < dp.length);i++) {ldp[i][0] = dp[i]; }for ( int i = 0;(i < v);i++) { long[][] ndp = new long[bef][aft]; for ( int j = 0;(j < bef);j++) {for ( int k = 0;((j + k) < aft);k++) {if ( (ldp[j][k] == 0)) continue; if ( (j > 0)) {ndp[(j - 1)][k] += (ldp[j][k] * j); ndp[(j - 1)][k] %= mod; } if ( (k > 0)) {ndp[j][(k + 1)] += (ldp[j][k] * k); ndp[j][(k + 1)] %= mod; } if ( ((2 * (i - k)) > 0)) {ndp[j][(k + 1)] += (ldp[j][k] * (2 * (i - k))); ndp[j][(k + 1)] %= mod; } if ( ((((((bef + i) + 1) - j) - k) - (2 * (i - k))) > 0)) {ndp[j][k] += (ldp[j][k] * (((((bef + i) + 1) - j) - k) - (2 * (i - k)))); ndp[j][k] %= mod; } }}ldp = ndp; }dp = new long[aft]; for ( int j = 0;(j < bef);j++) {for ( int k = 0;((j + k) < aft);k++) {dp[(j + k)] += ldp[j][k]; if ( (dp[(j + k)] >= mod)) dp[(j + k)] -= mod; }}for ( int j = 0;(j < aft);j++) dp[j] = ((dp[j] * fif[1][v]) % mod); bef = aft; }return dp;} 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 C2().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)); } }
2	public class Main implements Runnable{ private BufferedReader br ; private StringTokenizer tok ; private PrintWriter out ; static final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); int[] a ; int[] b ; int[] p ; int getCeils( int id, int step){ if ( (step > ((a[id] + b[id]) - 1))) {return 0;} if ( (a[id] < b[id])) {if ( (step < a[id])) {return step;} if ( ((step >= a[id]) && (step <= b[id]))) {return a[id];} ++p[id]; return (a[id] - p[id]);} else {if ( (step < b[id])) {return step;} if ( ((step >= b[id]) && (step <= a[id]))) {return b[id];} ++p[id]; return (b[id] - p[id]);}} void solve()throws IOException { int n = nextInt(),x = nextInt(),y = nextInt(),c = nextInt();  long s = 1;  int step = 0; a = new int[4]; b = new int[4]; p = new int[4]; a[0] = (x - 1); b[0] = (n - y); a[1] = (x - 1); b[1] = (y - 1); a[2] = (n - x); b[2] = (y - 1); a[3] = (n - x); b[3] = (n - y); int xf = (x + 1),xb = (x - 1),yf = (y + 1),yb = (y - 1); while((s < c)){++step; if ( (xf <= n)) {++s; ++xf; } if ( (xb > 0)) {++s; --xb; } if ( (yf <= n)) {++s; ++yf; } if ( (yb > 0)) {++s; --yb; } if ( (step == 1)) {continue;} for ( int i = 0;(i < 4);++i) {s += getCeils(i,(step - 1)); }}out.println(step); } public void run(){ try{if ( ONLINE_JUDGE) {br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {br = new BufferedReader(new FileReader(new File("input.txt"))); out = new PrintWriter(new File("output.txt")); }solve(); br.close(); out.close(); }catch (IOException e){ e.printStackTrace(); System.exit(1); } } public static void main( String[] args){ new Main().run(); } String nextToken()throws IOException { while(((tok == null) || !tok.hasMoreTokens()))tok = new StringTokenizer(br.readLine()); return tok.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
0	public class JavaApplication2{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n ; n = s.nextInt(); System.out.print(((n + " ") + "0 0")); } }
0	public class ToyArmy{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine()); System.out.println(((n / 2) * 3)); } }
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(); } static private 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 ; }
6	public final class LookingForOrder{ static private Map<Integer,Integer> es = new HashMap<Integer,Integer>(); static private void init(){ for ( int i = 0;(i <= 24);i++) es.put((1 << i),i); } static private int x ,y ; static private int[] xs ,ys ; static private int sqr( int i){ return (i * i);} static private int dist( int i, int j){ return (((((sqr((x - xs[i])) + sqr((y - ys[i]))) + sqr((xs[i] - xs[j]))) + sqr((ys[i] - ys[j]))) + sqr((x - xs[j]))) + sqr((y - ys[j])));} static private int n ; static private int[] tb ,prevs ; static private int recur( int j){ if ( (((j == 0) || (es.get(j) != null)) || (tb[j] != 0))) return tb[j]; int bl = (j & -j);  int b = (j ^ bl); tb[j] = (recur(bl) + recur(b)); prevs[j] = bl; for ( int i = (es.get(bl) + 1);(i < 25);i++) {if ( (((1 << i) & b) == 0)) continue; int k = (bl | (1 << i));  int v = (dist(es.get(bl),es.get((1 << i))) + recur((j ^ k))); if ( (v >= tb[j])) continue; tb[j] = v; prevs[j] = k; }return tb[j];} public static void main( String[] args){ init(); Scanner s = new Scanner(System.in); x = s.nextInt(); y = s.nextInt(); n = s.nextInt(); xs = new int[n]; ys = new int[n]; tb = new int[(1 << n)]; prevs = new int[(1 << n)]; for ( int i = 0;(i < n);i++) {xs[i] = s.nextInt(); ys[i] = s.nextInt(); tb[(1 << i)] = ((sqr((x - xs[i])) + sqr((y - ys[i]))) << 1); } int all = ((1 << n) - 1); out.println(recur(all)); StringBuilder sb = new StringBuilder();  int p = prevs[all];  int c = all; while(((p != 0) && (p != c))){if ( ((p ^ (p & -p)) == 0)) sb.append((("0 " + (es.get((p & -p)) + 1)) + " ")); else sb.append((((("0 " + (es.get((p & -p)) + 1)) + " ") + (es.get((p ^ (p & -p))) + 1)) + " ")); c = (c ^ p); p = prevs[c]; }if ( ((c ^ (c & -c)) == 0)) sb.append((("0 " + (es.get((c & -c)) + 1)) + " 0")); else sb.append((((("0 " + (es.get((c & -c)) + 1)) + " ") + (es.get((c ^ (c & -c))) + 1)) + " 0")); out.println(sb); } }
6	public class E{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  ArrayList<Integer>[][] nexts = new ArrayList[13][];  ArrayList<Integer>[] bs = new ArrayList[13];  int[][] index = new int[13][];  int[][] eqcl = new int[13][]; for ( int n = 1;(n <= 12);n++) {eqcl[n] = new int[(1 << n)]; bs[n] = new ArrayList<Integer>(); index[n] = new int[(1 << n)]; int ind = 0; for ( int mask = 0;(mask < (1 << n));mask++) { boolean add = true; for ( int k = 0;(k < n);k++) {if ( (rot(mask,k,n) < mask)) add = false; }if ( add) {bs[n].add(mask); index[n][mask] = ind; ind++; } }nexts[n] = new ArrayList[bs[n].size()]; for ( int i = 0;(i < bs[n].size());i++) { int mask = bs[n].get(i); for ( int k = 0;(k < n);k++) {eqcl[n][rot(mask,k,n)] = mask; }nexts[n][i] = new ArrayList<>(); for ( int y = 0;(y < (1 << n));y++) {if ( ((mask & y) == 0)) {nexts[n][i].add(y); } }}} int T = Integer.parseInt(br.readLine());  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); for ( int test = 0;(test < T);test++) { StringTokenizer st = new StringTokenizer(br.readLine());  int n = Integer.parseInt(st.nextToken());  int m = Integer.parseInt(st.nextToken());  int[][] arrt = new int[m][n]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()); for ( int j = 0;(j < m);j++) {arrt[j][i] = Integer.parseInt(st.nextToken()); }} Column[] cols = new Column[m]; for ( int j = 0;(j < m);j++) {cols[j] = new Column(arrt[j]); }Arrays.sort(cols,Collections.reverseOrder()); m = Integer.min(n,m); int[][] arr = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {arr[i][j] = cols[j].arr[i]; }} int[][] max = new int[m][bs[n].size()]; for ( int c = 0;(c < m);c++) {for ( int mask = 0;(mask < (1 << n));mask++) { int curr = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) > 0)) curr += arr[i][c]; } int cl = eqcl[n][mask]; max[c][index[n][cl]] = Integer.max(max[c][index[n][cl]],curr); }} int[][] dp = new int[(m + 1)][bs[n].size()]; for ( int c = 0;(c < m);c++) {for ( int i = 0;(i < bs[n].size());i++) { int mask = bs[n].get(i); for ( int next :nexts[n][i]) { int cl = eqcl[n][next];  int dl = eqcl[n][(mask | next)]; if ( ((dp[c][i] + max[c][index[n][cl]]) > dp[(c + 1)][index[n][dl]])) {dp[(c + 1)][index[n][dl]] = (dp[c][i] + max[c][index[n][cl]]); } }}}bw.write((dp[m][(bs[n].size() - 1)] + "\n")); }bw.flush(); } static int rot( int x, int k, int n){ int a = (x << k);  int b = (x >> (n - k)); return ((a + b) & ((1 << n) - 1));} static class Column implements Comparable<Column>{ int[] arr ; int max ; public Column( int[] arr){ this.arr = arr; max = 0; for ( int k :arr) {max = Integer.max(max,k); }} } }
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)])); } }
5	public class A{ public static void main( String[] args)throws IOException { InputReader in = new InputReader();  int n = in.nextInt();  long k = in.nextInt();  Long[] a = new Long[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextLong(); if ( (k == 1)) System.out.println(n); else { int res = 0; Arrays.sort(a); boolean[] v = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !v[i]) { long cur = a[i];  int cnt = 1; while(true){ int idx = Arrays.binarySearch(a,(cur * k)); if ( (idx < 0)) {res += ((cnt / 2) + (cnt % 2)); break;} v[idx] = true; cur = a[idx]; cnt++; }} }System.out.println(res); }} static class InputReader{ BufferedReader in ; StringTokenizer st ; public InputReader()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(in.readLine()); } public String next()throws IOException { while(!st.hasMoreElements())st = new StringTokenizer(in.readLine()); return st.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} public long nextLong()throws NumberFormatException,IOException { return Long.parseLong(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);  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 ,temp ; while((m-- > 0)){l = (in.nextInt() - 1); r = (in.nextInt() - 1); for ( int i = 0;(i < (((r - l) + 1) / 2));i++) {temp = a[(l + i)]; a[(l + i)] = a[(r - i)]; a[(r - i)] = temp; }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;} } }
6	public class E{ public static void main( String[] args)throws IOException { new E(); } FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); int n ,m ,oo = (1 << 28); int[] dp ,cost ; int[][] to ; char[] w ; E()throws IOException{ n = in.nextInt(); m = in.nextInt(); w = in.next().toCharArray(); to = new int[(m + 1)][(m + 1)]; for ( int i = 0;(i < (n - 1));i++) if ( (w[i] != w[(i + 1)])) {to[(w[i] - 'a')][(w[(i + 1)] - 'a')]++; to[(w[(i + 1)] - 'a')][(w[i] - 'a')]++; } cost = new int[(1 << m)]; for ( int i = 0;(i < (1 << m));i++) for ( int j = 0;(j < m);j++) {if ( (((1 << j) & i) > 0)) continue; for ( int k = 0;(k < m);k++) {if ( (((1 << k) & i) == 0)) continue; cost[i] += to[j][k]; }}dp = new int[(1 << m)]; Arrays.fill(dp,oo); dp[0] = 0; for ( int i = 1;(i < (1 << m));i++) {for ( int j = 0;(j < m);j++) if ( (((i >> j) & 1) > 0)) dp[i] = Math.min(dp[i],dp[(i ^ (1 << j))]); dp[i] += cost[i]; }out.println(dp[((1 << m) - 1)]); out.close(); } void sort( int[] x){ int sz = x.length;  Random r = new Random(); for ( int i = 0;(i < sz);i++) { int j = r.nextInt(sz); x[i] = (x[j] - (x[i] - (x[j] = x[i]))); }Arrays.sort(x); } 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());} } }
3	public class Es1{ static IO io = new IO(); public static void main( String[] args){ int n = io.getInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = io.getInt(); Arrays.sort(a); int[] color = new int[n];  int num = 1; for ( int i = 0;(i < n);i++) {if ( (color[i] == 0)) {for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) color[j] = num; }num++; } }io.println((num - 1)); io.close(); } } class IO extends PrintWriter{ public IO(){ super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(System.in)); } public IO( String fileName){ super(new BufferedOutputStream(System.out)); try{r = new BufferedReader(new FileReader(fileName)); }catch (FileNotFoundException e){ this.println("File Not Found"); } } public boolean hasMoreTokens(){ return (peekToken() != null);} public int getInt(){ return Integer.parseInt(nextToken());} private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); 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); }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;} int b = (((i | (i >> 1)) | (i << 1)) & full); dp[(b2 | b)][i] = min(dp[(b2 | b)][i],(tmp[b1][b2] + Integer.bitCount(i))); }}}} int min = INF; for ( int i = 0;(i < (1 << m));i++) {min = min(min,dp[full][i]); } int ans = ((m * n) - min); println((ans + "")); } void println( String s){ System.out.println(s); } public static void main( String[] args){ new P111C().run(); } }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  Long N = sc.nextLong();  Long ans ; sc.close(); if ( (N <= 2)) System.out.println(N); else {if ( ((N % 6) == 0)) {ans = (((N - 1) * (N - 2)) * (N - 3)); } else if ( ((N % 2) == 0)) {ans = ((N * (N - 1)) * (N - 3)); } else {ans = ((N * (N - 1)) * (N - 2)); }System.out.println(ans); }} }
4	public class Main{ InputStream is ; PrintWriter out ; String INPUT = ""; long MAX = 100000L,MOD = 1000000007L,INF = (long)1e18; boolean isValid( int x, int y, int n, int m){ return ((((x >= 0) && (y >= 0)) && (x < n)) && (y < m));} void solve( int TC)throws Exception { helper hp = new helper(MOD,(int)MAX); hp.initIO("input.txt","output.txt"); int n = hp.nextInt(),m = hp.nextInt();  boolean[][] a = new boolean[n][m];  int k = hp.nextInt();  ArrayDeque<int[]> q = new ArrayDeque<>(); for ( int i = 0;(i < k);i++) { int x = (hp.nextInt() - 1);  int y = (hp.nextInt() - 1); a[x][y] = true; q.add(new int[]{x,y}); } int lastX = 0,lastY = 0;  int[] dx = new int[]{1,-1,0,0};  int[] dy = new int[]{0,0,1,-1}; while(!q.isEmpty()){ int[] X = q.pollFirst(); for ( int i = 0;(i < 4);i++) { int x = (X[0] + dx[i]);  int y = (X[1] + dy[i]); if ( (isValid(x,y,n,m) && !a[x][y])) {a[x][y] = true; lastX = x; lastY = y; q.add(new int[]{x,y}); } }}hp.println((((lastX + 1) + " ") + (lastY + 1))); hp.flush(); } boolean TestCases = false; public static void main( String[] args)throws Exception { new Main().run(); } void run()throws Exception { is = (INPUT.isEmpty()?System.in:new ByteArrayInputStream(INPUT.getBytes())); out = new PrintWriter(System.out); long s = System.currentTimeMillis();  int T = (TestCases?ni():1); for ( int t = 1;(t <= T);t++) solve(t); out.flush(); if ( !INPUT.isEmpty()) tr(((System.currentTimeMillis() - s) + "ms")); } double PI = 3.141592653589793238462643383279502884197169399; 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(); }} int BUF_SIZE = (1024 * 8); byte[] inbuf = new byte[BUF_SIZE]; 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 ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} 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));} void tr( Object... o){ if ( (INPUT.length() > 0)) System.out.println(Arrays.deepToString(o)); } } class helper{ final long MOD ; final int MAXN ; final Random rnd ; public helper( long mod, int maxn){ MOD = mod; MAXN = maxn; rnd = new Random(); } static final int BUFSIZE = (1 << 20); static byte[] buf ; static int index ,total ; static InputStream in ; static BufferedWriter bw ; public void initIO( InputStream is, OutputStream os){ try{in = is; bw = new BufferedWriter(new OutputStreamWriter(os)); buf = new byte[BUFSIZE]; }catch (Exception e){ } } public void initIO( String inputFile, String outputFile){ try{in = new FileInputStream(inputFile); bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile))); buf = new byte[BUFSIZE]; }catch (Exception e){ e.printStackTrace(); } } private int scan()throws Exception { if ( (index >= total)) {index = 0; total = in.read(buf); if ( (total <= 0)) return -1; } return buf[index++];} public int nextInt()throws Exception { 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);} public void println( Object a)throws Exception { bw.write((a.toString() + "\n")); } public void print( Object a)throws Exception { bw.write(a.toString()); } public void flush()throws Exception { bw.flush(); } public static int[] sieve ; public static ArrayList<Integer> primes ; }
6	public class Main2{ static int mod = 1000000007; static FastScanner scanner ; public static void main( String[] args){ scanner = new FastScanner(); int n = scanner.nextInt();  int T = scanner.nextInt();  int[][] songs = new int[n][2]; for ( int i = 0;(i < n);i++) {songs[i][0] = scanner.nextInt(); songs[i][1] = (scanner.nextInt() - 1); } int[] mapping = new int[65536];  int mask = 1; for ( int k = 0;(k < n);k++) {for ( int i = 1;(i < mapping.length);i++) {if ( ((i & mask) != 0)) mapping[i] += songs[k][0]; }mask <<= 1; } int[][][] dp = new int[17][65536][3]; mask = 1; for ( int i = 0;(i < n);i++) {dp[1][mask][songs[i][1]] = 1; mask <<= 1; }for ( int i = 1;(i < n);i++) {mask = 1; for ( int k = 0;(k < n);k++) { int cg = songs[k][1];  int g1 ,g2 ; if ( (cg == 0)) {g1 = 1; g2 = 2; } else if ( (cg == 1)) {g1 = 0; g2 = 2; } else {g1 = 0; g2 = 1; }for ( int j = 1;(j < 65536);j++) {if ( ((j & mask) != 0)) continue; dp[(i + 1)][(j | mask)][cg] = ((dp[(i + 1)][(j | mask)][cg] + ((dp[i][j][g1] + dp[i][j][g2]) % mod)) % mod); }mask <<= 1; }} int res = 0; for ( int k = 0;(k < 17);k++) for ( int i = 1;(i < 65536);i++) {if ( (mapping[i] == T)) res = ((((res + dp[k][i][0]) + dp[k][i][1]) + dp[k][i][2]) % mod); }System.out.println(res); } 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; } } }
1	public class Solution{ static BufferedReader br = null; static PrintWriter pw = null; static StringTokenizer st = null; static String FILENAME = ""; void nline(){ try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } int ni(){ while(((st == null) || !st.hasMoreTokens()))nline(); return Integer.parseInt(st.nextToken());} String nstr(){ String s = ""; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return s;} public void solve(){ int n = ni();  String s = nstr();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ((s.charAt(i) == 'H')?0:1); int hc = 0; for ( int i = 0;(i < n);i++) if ( (a[i] == 0)) hc++;  int min = 1000000; for ( int ss = 0;(ss < n);ss++) { int rc = 0; for ( int i = 0;(i < hc);i++) if ( (a[((i + ss) % n)] == 0)) rc++; if ( ((hc - rc) < min)) min = (hc - rc); }pw.print(min); } public void run(){ solve(); pw.close(); } public static void main( String[] args){ br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); new Solution().run(); } }
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(); } }
1	public class A{ public static void main( String[] args){ FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  boolean change = false; if ( (a > b)) { int t = a; a = b; b = t; change = true; } boolean[] inb = new boolean[n];  int[] numbers = new int[n];  TreeMap<Integer,Integer> num = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {num.put(in.nextInt(),i); } boolean hasAns = true; while(!num.isEmpty()){ Entry<Integer,Integer> last = num.lastEntry();  int key = last.getKey(); if ( num.containsKey((a - key))) {num.remove(key); num.remove((a - key)); } else if ( num.containsKey((b - key))) {inb[num.get(key)] = true; inb[num.get((b - key))] = true; num.remove(key); num.remove((b - key)); } else {hasAns = false; break;}}if ( hasAns) {out.println("YES"); for ( int i = 0;((i < n) && !change);i++) {if ( inb[i]) {out.print("1"); } else {out.print("0"); }if ( (i != (n - 1))) {out.print(" "); } }for ( int i = 0;((i < n) && change);i++) {if ( inb[i]) {out.print("0"); } else {out.print("1"); }if ( (i != (n - 1))) {out.print(" "); } }} else {out.println("NO"); }out.close(); } static class FastScanner{ private BufferedReader reader ; private StringTokenizer tokenizer ; public FastScanner( 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());} } }
2	public class ER23C{ static long s ; public static void main( String[] args)throws java.lang.Exception { InputReader in = new InputReader(System.in);  PrintWriter w = new PrintWriter(System.out);  long n = in.nextLong(); s = in.nextLong(); long l = 0,h = n; while((l < h)){ long mid = ((l + h) / 2); if ( Ok(mid)) h = mid; else l = (mid + 1); }if ( Ok(h)) w.println(((n - h) + 1)); else w.println((n - h)); w.close(); } static boolean Ok( long n){ int sum = 0;  long temp = n; while((n > 0)){sum += (n % 10); n = (n / 10); }return ((temp - sum) >= s);} 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 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 long nextLong(){ return Long.parseLong(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));} } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  TaskC.InputReader in = new TaskC.InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.Solve(in,out); out.close(); } static class TaskC{ private long mod = 1_000_000_007; private int n ; private boolean[] s ; public void Solve( InputReader in, PrintWriter out){ n = in.NextInt(); s = new boolean[n]; for ( int i = 0;(i < n);i++) { String ss = in.Next(); s[i] = (ss.charAt(0) == 'f'); }if ( s[(n - 1)]) {out.println(0); return ;} long[] dpSum = new long[(n + 1)],lastDpSum = new long[(n + 1)]; for ( int i = 0;(i <= n);i++) {lastDpSum[i] = (i + 1); }for ( int i = (n - 2);(i >= 0);i--) {for ( int j = 0;(j <= i);j++) {if ( !s[i]) {dpSum[j] = lastDpSum[j]; } else {dpSum[j] = (lastDpSum[(j + 1)] - lastDpSum[j]); }if ( (j != 0)) {dpSum[j] += dpSum[(j - 1)]; } dpSum[j] %= mod; while((dpSum[j] < 0))dpSum[j] += mod; } long[] temp = dpSum; dpSum = lastDpSum; lastDpSum = temp; }out.println(lastDpSum[0]); } public static int GetMax( int[] ar){ int max = Integer.MIN_VALUE; for ( int a :ar) {max = Math.max(max,a); }return max;} public static int[] GetCount( int[] ar){ return GetCount(ar,GetMax(ar));} public static int[] GetCount( int[] ar, int maxValue){ int[] dp = new int[(maxValue + 1)]; for ( int a :ar) {dp[a]++; }return dp;} } }
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 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);  G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion(); solver.solve(1,in,out); out.close(); } static class G1PlaylistForPolycarpEasyVersion{ static ArrayList<Integer> list ; static int n ; static int req ; static int mod = ((int)1e9 + 7); static int[] dur ; static int[] genre ; static Integer[][][] memo ; public void solve( int testNumber, Scanner sc, PrintWriter pw){ n = sc.nextInt(); req = sc.nextInt(); dur = new int[n]; genre = new int[n]; list = new ArrayList<>(); for ( int i = 0;(i < n);i++) {dur[i] = sc.nextInt(); genre[i] = sc.nextInt(); } int ans = 0; memo = new Integer[(1 << n)][(n + 1)][4]; for ( int i = 0;(i <= n);i++) ans += (bf(0,0,0,i) % mod); pw.print((ans % mod)); } private int bf( int idx, int msk, int before, int max){ if ( (idx == max)) { int sum = 0; for ( int x :list) sum += x; if ( (sum == req)) return 1; return 0;} if ( (memo[msk][max][before] != null)) return (memo[msk][max][before] % mod); int toRet = 0; for ( int i = 0;(i < n);i++) {if ( ((genre[i] != before) && ((msk & (1 << i)) == 0))) {list.add(dur[i]); toRet += bf((idx + 1),(msk | (1 << i)),genre[i],max); toRet %= mod; list.remove((list.size() - 1)); } }return memo[msk][max][before] = (toRet % mod);} } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( FileReader r){ br = new BufferedReader(r); } public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } 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 int nextInt(){ return Integer.parseInt(next());} } }
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))); }} }
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);  BTheHat solver = new BTheHat(); solver.solve(1,in,out); out.close(); } static class BTheHat{ PrintWriter out ; InputReader in ; int n ; public void solve( int testNumber, InputReader in, PrintWriter out){ this.out = out; this.in = in; n = in.NextInt(); int desiredPair = -1;  int result = query(1); if ( (result != 0)) { int l = 2,r = (1 + (n / 2)); while((l < r)){ int m = ((l + r) / 2);  int mRes = query(m); if ( (mRes == 0)) {desiredPair = m; break;} else if ( (mRes == result)) {l = (m + 1); } else {r = m; }}} else {desiredPair = 1; }out.println(("! " + desiredPair)); } private int query( int i){ int iV = queryValue(i);  int iN2V = queryValue((i + (n / 2))); if ( (iV < iN2V)) {return -1;} else if ( (iV > iN2V)) {return 1;} return 0;} private int queryValue( int i){ out.println(("? " + i)); out.flush(); return in.NextInt();} } 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());} } }
5	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();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); Arrays.sort(a); if ( (a[(n - 1)] == 1)) {for ( int i = 1;(i < n);i++) out.print("1 "); out.print(2); return ;} Arrays.sort(a); out.print(1); for ( int i = 1;(i < n);i++) out.print((" " + a[(i - 1)])); } void run(){ try{Locale.setDefault(Locale.US); 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")); in = new BufferedReader(reader); out = new PrintWriter(writer); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } public static void main( String[] args){ new A().run(); } }
6	public class Main16E{ private FastScanner in ; private PrintWriter out ; public void solve()throws IOException { int n = in.nextInt();  double[][] a = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {a[i][j] = in.nextDouble(); }} int k = (1 << n);  double[] p = new double[k];  int[][] b = new int[(n + 1)][]; for ( int i = 0;(i <= n);i++) {b[i] = new int[comb(i,n)]; } int[] bl = new int[(n + 1)]; for ( int i = 0;(i < k);i++) { int c = c2(i); b[c][bl[c]] = i; bl[c]++; }p[(k - 1)] = 1; for ( int i = n;(i >= 2);i--) {for ( int j = 0;(j < b[i].length);j++) { int t = b[i][j];  double pm = 1; pm /= ((i * (i - 1)) / 2); for ( int x = 0;(x < n);x++) {for ( int y = (x + 1);(y < n);y++) {if ( (((t & (1 << x)) > 0) && ((t & (1 << y)) > 0))) {p[(t & (1 << x))] += ((p[t] * pm) * a[y][x]); p[(t & (1 << y))] += ((p[t] * pm) * a[x][y]); } }}}}for ( int i = 0;(i < n);i++) {out.print((p[(1 << i)] + " ")); }} int comb( int n, int m){ int res = 1; for ( int i = 1;(i <= n);i++) {res = (res * ((m - i) + 1)); res /= i; }return res;} int c2( int k){ int res = 0; while((k > 0)){if ( ((k % 2) == 1)) {res++; } k /= 2; }return res;} public void run(){ try{in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } 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());} double nextDouble(){ return Double.parseDouble(next());} } public static void main( String[] arg){ new Main16E().run(); } }
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(); } }
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(); } }
0	public class A{ static void solve( InputReader in, PrintWriter out){ long n = in.nextLong(); out.print(25); } public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream); solve(in,out); out.close(); } 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 long nextLong(){ return Long.parseLong(next());} } }
2	public class B_Round_371_Div1{ public static long MOD = 1000000007; static int c = 0; public static void main( String[] args)throws FileNotFoundException { Scanner in = new Scanner();  int n = in.nextInt();  int minX = -1;  int start = 1;  int end = n; c = 0; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((("? " + mid) + " 1 ") + n) + " ") + n)); System.out.flush(); int v = in.nextInt(); if ( (v == 2)) {minX = mid; start = (mid + 1); } else {end = (mid - 1); }} int maxX = -1; start = minX; end = n; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((("? " + minX) + " 1 ") + mid) + " ") + n)); System.out.flush(); int v = in.nextInt(); if ( (v == 2)) {maxX = mid; end = (mid - 1); } else {start = (mid + 1); }} int minY = -1; start = 1; end = n; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + mid) + " ") + maxX) + " ") + n)); System.out.flush(); int v = in.nextInt(); if ( (v == 2)) {minY = mid; start = (mid + 1); } else {end = (mid - 1); }} int maxY = -1; start = minY; end = n; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + maxX) + " ") + mid)); System.out.flush(); int v = in.nextInt(); if ( (v == 2)) {maxY = mid; end = (mid - 1); } else {start = (mid + 1); }} int middleMinX = maxX; start = minX; end = maxX; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + mid) + " ") + maxY)); System.out.flush(); int v = in.nextInt(); if ( (v == 1)) {middleMinX = mid; end = (mid - 1); } else {start = (mid + 1); }} int middleMaxX = -1; start = (middleMinX + 1); end = maxX; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + mid) + " ") + minY) + " ") + maxX) + " ") + maxY)); System.out.flush(); int v = in.nextInt(); if ( (v == 1)) {middleMaxX = mid; start = (mid + 1); } else {end = (mid - 1); }}if ( (middleMaxX == -1)) { int middleMinY = -1; start = minY; end = maxY; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + maxX) + " ") + mid)); System.out.flush(); int v = in.nextInt(); if ( (v == 1)) {middleMinY = mid; end = (mid - 1); } else {start = (mid + 1); }} int middleMaxY = -1; start = (middleMinY + 1); end = maxY; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + mid) + " ") + maxX) + " ") + maxY)); System.out.flush(); int v = in.nextInt(); if ( (v == 1)) {middleMaxY = mid; start = (mid + 1); } else {end = (mid - 1); }}if ( (minX == maxX)) {System.out.println(((((((((((((((("! " + minX) + " ") + minY) + " ") + maxX) + " ") + middleMinY) + " ") + minX) + " ") + middleMaxY) + " ") + maxX) + " ") + maxY)); System.out.flush(); } else { int[] a = calX(minX,maxX,minY,middleMinY,in);  int[] b = calX(minX,maxX,middleMaxY,maxY,in); check(a); check(b); System.out.println(((((((((((((((("! " + a[0]) + " ") + minY) + " ") + a[1]) + " ") + middleMinY) + " ") + b[0]) + " ") + middleMaxY) + " ") + b[1]) + " ") + maxY)); System.out.flush(); }} else if ( (minY == maxY)) {System.out.println(((((((((((((((("! " + minX) + " ") + minY) + " ") + middleMinX) + " ") + maxY) + " ") + middleMaxX) + " ") + minY) + " ") + maxX) + " ") + maxY)); System.out.flush(); } else { int[] a = calY(minX,middleMinX,minY,maxY,in);  int[] b = calY(middleMaxX,maxX,minY,maxY,in); check(a); check(b); System.out.println(((((((((((((((("! " + minX) + " ") + a[0]) + " ") + middleMinX) + " ") + a[1]) + " ") + middleMaxX) + " ") + b[0]) + " ") + maxX) + " ") + b[1])); System.out.flush(); }} static void check( int[] v){ if ( ((v[0] == -1) || (v[1] == -1))) {throw (new NullPointerException());} } static int increaseC( int c){ if ( (c == 200)) {throw (new NullPointerException());} return (c + 1);} public static int[] calY( int minX, int maxX, int minY, int maxY, Scanner in){ c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + maxX) + " ") + (maxY - 1))); System.out.flush(); int v = in.nextInt(); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + (minY + 1)) + " ") + maxX) + " ") + maxY)); System.out.flush(); int o = in.nextInt(); if ( ((v == 1) && (o == 1))) { int a = -1;  int start = minY;  int end = maxY; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + maxX) + " ") + mid)); System.out.flush(); if ( (in.nextInt() == 1)) {a = mid; end = (mid - 1); } else {start = (mid + 1); }} int b = -1; start = minY; end = a; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + mid) + " ") + maxX) + " ") + a)); System.out.flush(); if ( (in.nextInt() == 1)) {b = mid; start = (mid + 1); } else {end = (mid - 1); }}return new int[]{b,a};} else if ( (v == 1)) { int a = -1;  int start = minY;  int end = maxY; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + maxX) + " ") + mid)); System.out.flush(); if ( (in.nextInt() == 1)) {a = mid; end = (mid - 1); } else {start = (mid + 1); }}return new int[]{minY,a};} else if ( (o == 1)) { int b = -1;  int start = minY;  int end = maxY; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + mid) + " ") + maxX) + " ") + maxY)); System.out.flush(); if ( (in.nextInt() == 1)) {b = mid; start = (mid + 1); } else {end = (mid - 1); }}return new int[]{b,maxY};} else {return new int[]{minY,maxY};}} public static int[] calX( int minX, int maxX, int minY, int maxY, Scanner in){ c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + (maxX - 1)) + " ") + maxY)); System.out.flush(); int v = in.nextInt(); c = increaseC(c); System.out.println(((((((("? " + (minX + 1)) + " ") + minY) + " ") + maxX) + " ") + maxY)); System.out.flush(); int o = in.nextInt(); if ( ((v == 1) && (o == 1))) { int a = -1;  int start = minX;  int end = maxX; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + mid) + " ") + maxY)); System.out.flush(); if ( (in.nextInt() == 1)) {a = mid; end = (mid - 1); } else {start = (mid + 1); }} int b = -1; start = minX; end = a; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + mid) + " ") + minY) + " ") + a) + " ") + maxY)); System.out.flush(); if ( (in.nextInt() == 1)) {b = mid; start = (mid + 1); } else {end = (mid - 1); }}return new int[]{b,a};} else if ( (v == 1)) { int a = -1;  int start = minX;  int end = maxX; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + minX) + " ") + minY) + " ") + mid) + " ") + maxY)); System.out.flush(); if ( (in.nextInt() == 1)) {a = mid; end = (mid - 1); } else {start = (mid + 1); }}return new int[]{minX,a};} else if ( (o == 1)) { int b = -1;  int start = minX;  int end = maxX; while((start <= end)){ int mid = ((start + end) >> 1); c = increaseC(c); System.out.println(((((((("? " + mid) + " ") + minY) + " ") + maxX) + " ") + maxY)); System.out.flush(); if ( (in.nextInt() == 1)) {b = mid; start = (mid + 1); } else {end = (mid - 1); }}return new int[]{b,maxX};} else {return new int[]{minX,maxX};}} 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, long MOD){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long val = pow(a,(b / 2),MOD); 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(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());} } }
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();} }
6	public class Main{ static int N ; static int K ; static int A ; static double dl[] ; static int base[] ; static int needed ; static int b[] = new int[N]; static int l[] = new int[N]; static double best ; static void giveCandies( int i, int remaining){ if ( (remaining == 0)) {check(); return ;} if ( (i == N)) {check(); return ;} int j ;  double ns ;  double orig = dl[i]; for ( j = 0;(j <= remaining);j++) {ns = (orig + (j * 0.1)); if ( (ns <= 1.0)) {dl[i] = ns; giveCandies((i + 1),(remaining - j)); dl[i] = orig; } else {break;}}} static void check(){ int i ,j ,k ;  double res = 0.0;  int total ;  double prob ;  int max = (1 << N);  double sumg ,sumb ;  double pk ,da = (double)A; for ( k = 0;(k < max);k++) {prob = 1.0; total = 0; sumg = 0; sumb = 0; for ( i = 0;(i < N);i++) {if ( ((base[i] & k) > 0)) {prob *= dl[i]; total++; sumg += b[i]; } else {prob *= (1.0 - dl[i]); sumb += b[i]; }}if ( (total >= needed)) {res += prob; } else {pk = (da / (da + sumb)); res += (prob * pk); }}best = Math.max(best,res); } public static void main( String[] args)throws Exception { int i ,j ,k ;  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine()); N = Integer.parseInt(st.nextToken()); K = Integer.parseInt(st.nextToken()); A = Integer.parseInt(st.nextToken()); needed = ((N / 2) + 1); b = new int[N]; l = new int[N]; dl = new double[N]; for ( i = 0;(i < N);i++) {st = new StringTokenizer(br.readLine()); b[i] = Integer.parseInt(st.nextToken()); l[i] = Integer.parseInt(st.nextToken()); dl[i] = ((double)l[i] / 100.0); }base = new int[8]; base[0] = 1; for ( i = 1;(i < N);i++) {base[i] = (base[(i - 1)] * 2); }best = 0.0; giveCandies(0,K); DecimalFormat df = new DecimalFormat("0.0000000000");  String rs = df.format(best);  String mrs = ""; for ( i = 0;(i < rs.length());i++) {if ( (rs.charAt(i) == ',')) {mrs += '.'; } else {mrs += rs.charAt(i); }}System.out.println(mrs); } }
6	public class Main{ public void run(){ Locale.setDefault(Locale.US); Scanner in = new Scanner(System.in);  int n = in.nextInt();  double a[][] = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) a[i][j] = in.nextDouble(); double f[] = new double[(1 << n)]; f[((1 << n) - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask > 0);mask--) { int k = Integer.bitCount(mask); if ( (k == 1)) continue; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) > 0)) {for ( int j = 0;(j < n);j++) {if ( ((mask & (1 << j)) > 0)) {f[(mask & (1 << j))] += ((f[mask] * a[i][j]) / ((k * (k - 1)) / 2)); } }} }}for ( int i = 0;(i < n);i++) System.out.print((f[(1 << i)] + " ")); } public static void main( String[] args){ new Main().run(); } }
2	public class cf1177b{ public static void main( String[] args)throws IOException { long k = rl(),n = -1; for ( long l = 0,r = k;(l <= r);) { long m = (l + ((r - l) / 2)); if ( (f(m) < k)) {n = (m + 1); l = (m + 1); } else {r = (m - 1); }}k -= f((n - 1)); char[] s = Long.toString(n).toCharArray(); prln(s[((int)k - 1)]); close(); } static long f( long x){ if ( (x < 10)) {return x;} long pow10 = 1,cnt = 1; while((x >= (pow10 * 10))){pow10 *= 10; ++cnt; }return ((cnt * ((x - pow10) + 1)) + f((pow10 - 1)));} 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 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 List<List<Integer>> g( int n){ List<List<Integer>> g = new ArrayList<>(); for ( int i = 0;(i < n);++i) g.add(new ArrayList<>()); return g;} static List<Set<Integer>> sg( int n){ List<Set<Integer>> g = new ArrayList<>(); for ( int i = 0;(i < n);++i) g.add(new HashSet<>()); return g;} static void c( List<? extends Collection<Integer>> g, int u, int v){ g.get(u).add(v); g.get(v).add(u); } static void cto( List<? extends Collection<Integer>> g, int u, int v){ g.get(u).add(v); } static void r()throws IOException { input = new StringTokenizer(rline()); } static long rl()throws IOException { return Long.parseLong(rline());} 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(); } }
2	public class Proj implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer str ; public void solve()throws IOException { long l = nextLong();  long r = nextLong();  int g = 0;  long x = (l ^ r);  long i = 1; while((x >= i)){i = (i * 2); }if ( (x >= i)) {out.println(x); } else out.println((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 Proj()).start(); } }
6	public class Main{ static Scanner cin = new Scanner(System.in); private int xs ,ys ,n ; private int[] x ,y ; public static void main( String[] args)throws Exception { new Main().run(); } private void run()throws Exception { xs = cin.nextInt(); ys = cin.nextInt(); n = cin.nextInt(); x = new int[(n + 1)]; y = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {x[i] = cin.nextInt(); y[i] = cin.nextInt(); } int[] res = new int[(1 << n)]; Arrays.fill(res,Integer.MAX_VALUE); int[] ds = new int[n]; for ( int i = 0;(i < n);i++) {ds[i] = (((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys))); } int[][] d = new int[(n + 1)][(n + 1)];  int[] tr = new int[(1 << n)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {d[i][j] = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); }}res[0] = 0; for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( (((i >> j) & 1) != 0)) {if ( ((res[(i - (1 << j))] + (2 * ds[j])) < res[i])) {res[i] = (res[(i - (1 << j))] + (2 * ds[j])); tr[i] = (i - (1 << j)); } for ( int k = (j + 1);(k < n);k++) {if ( (((i >> k) & 1) != 0)) {if ( ((((res[((i - (1 << j)) - (1 << k))] + ds[k]) + ds[j]) + d[k][j]) < res[i])) {res[i] = (((res[((i - (1 << j)) - (1 << k))] + ds[k]) + ds[j]) + d[k][j]); tr[i] = ((i - (1 << j)) - (1 << k)); } } }break;} }}System.out.println(res[((1 << n) - 1)]); int now = ((1 << n) - 1); while((now != 0)){System.out.print("0 "); int dif = (now - tr[now]); for ( int i = 0;((i < n) && (dif != 0));i++) {if ( (((dif >> i) & 1) != 0)) {System.out.print(((i + 1) + " ")); dif -= (1 << i); } }now = tr[now]; }System.out.print("0"); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ int n ; boolean[][] adj ; long[] mem ; int start ; long cycles( int cur, int visited){ if ( ((cur == start) && (visited > 0))) {return ((Integer.bitCount(visited) >= 3)?1:0);} int index = ((visited * n) + cur); if ( (mem[index] != -1)) return mem[index]; long res = 0;  int newvisited = (visited | (1 << cur)); for ( int nxt = 0;(nxt < n);nxt++) if ( adj[cur][nxt]) {if ( ((nxt >= start) && ((nxt == start) || (((visited >> nxt) & 1) == 0)))) {res += cycles(nxt,newvisited); } } return mem[index] = res;} public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.readInt(); int m = in.readInt(); mem = new long[(n * (1 << n))]; adj = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (in.readInt() - 1),b = (in.readInt() - 1); adj[a][b] = true; adj[b][a] = true; } long res = 0; for ( int start = 0;(start < n);start++) {Arrays.fill(mem,-1); this.start = start; res += (cycles(start,0) / 2); }out.printLine(res); } } 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( long 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 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); } } }
6	public class E{ static private final int oo = 1000000000; public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt(); if ( (n > m)) { int t = n; n = m; m = t; } int[][] curr = new int[(1 << n)][(1 << n)]; fill(curr,oo); Arrays.fill(curr[0],0); for ( int j = 0;(j < m);j++) { int[][] next = new int[(1 << n)][(1 << n)]; fill(next,oo); for ( int c0 = 0;(c0 < (1 << n));c0++) for ( int c1 = 0;(c1 < (1 << n));c1++) if ( (curr[c0][c1] != oo)) for ( int c2 = 0;(c2 < ((j == (m - 1))?1:(1 << n)));c2++) { int all = ((1 << n) - 1);  int done = ((((all & (c1 >> 1)) | (all & (c1 << 1))) | c0) | c2); done &= (all ^ c1); next[c1][c2] = Math.min(next[c1][c2],((curr[c0][c1] + n) - Integer.bitCount(done))); } curr = next; } int res = oo; for ( int i = 0;(i < (1 << n));i++) for ( int j = 0;(j < (1 << n));j++) res = Math.min(res,curr[i][j]); System.out.println(((n * m) - res)); } static private void fill( int[][] array, int val){ for ( int[] fill :array) Arrays.fill(fill,val); } }
5	public class Main{ static int T ; public static void main( String[] args){ FastScanner sc = new FastScanner(System.in); T = sc.nextInt(); PrintWriter pw = new PrintWriter(System.out); for ( int i = 0;(i < T);i++) { int n = sc.nextInt();  int[] a = sc.nextIntArray(n);  int[] ans = solve(n,a);  StringJoiner j = new StringJoiner(" "); for ( int each :ans) {j.add(String.valueOf(each)); }pw.println(j.toString()); }pw.flush(); } static int[] solve( int N, int[] A){ shuffle(A); Arrays.sort(A); int cur = A[0];  int time = 1;  double r = 0;  int prev = -1;  int a = -1;  int b = -1; for ( int i = 1;(i < N);i++) {if ( (cur == A[i])) {time++; if ( (time == 2)) {if ( (prev != -1)) { double r1 = ((double)prev / cur); if ( (r1 > r)) {r = r1; a = prev; b = cur; } } prev = cur; } if ( (time == 4)) {return new int[]{cur,cur,cur,cur};} } else {time = 1; cur = A[i]; }}return new int[]{a,a,b,b};} static void shuffle( int[] a){ Random r = ThreadLocalRandom.current(); for ( int i = (a.length - 1);(i >= 0);i--) { int j = r.nextInt((i + 1));  int t = a[i]; a[i] = a[j]; a[j] = t; }} @SuppressWarnings("unused") static class FastScanner{ private BufferedReader reader ; private StringTokenizer tokenizer ; FastScanner( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } String next(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} } return tokenizer.nextToken();} long nextLong(){ return Long.parseLong(next());} int nextInt(){ return Integer.parseInt(next());} int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} int[] nextIntArray( int n, int delta){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = (nextInt() + delta); return a;} } static int max( int... as){ int max = Integer.MIN_VALUE; for ( int a :as) max = Math.max(a,max); return max;} static int min( int... as){ int min = Integer.MAX_VALUE; for ( int a :as) min = Math.min(a,min); return min;} }
2	public class B{ public static void main( String[] args){ PrintWriter out = new PrintWriter(System.out);  Scanner sc = new Scanner(System.in);  long N = sc.nextLong();  long K = sc.nextLong(); if ( (N == 1)) {out.println(0); } else if ( (N <= K)) {out.println(1); } else if ( (N > ((((K - 1) * K) / 2) + 1))) {out.println(-1); } else { long lo = 1;  long hi = Math.max((K - 2),1);  long big = (((K - 2) * (K - 1)) / 2);  long prevmid = -1; for ( int i = 0;(i < 10000);i++) { long mid = ((lo + hi) / 2);  long tmp = ((((K - 2) - mid) * (((K - 2) - mid) + 1)) / 2); if ( (((K + big) - tmp) > N)) {hi = mid; } else if ( (((K + big) - tmp) < N)) {lo = mid; if ( (prevmid == mid)) lo++; lo = Math.min(lo,hi); prevmid = mid; } else {lo = mid; break;}}out.println(((long)lo + 1)); }sc.close(); out.close(); } }
6	public class Main{ static Scanner in ; static PrintWriter out ; public static void main( String[] args)throws Exception { in = new Scanner(System.in); out = new PrintWriter(System.out); int n = in.nextInt();  double[][] p = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) p[i][j] = in.nextDouble(); double[] q = new double[(1 << n)]; q[((1 << n) - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask > 0);mask--) { int count = 0; for ( int t = 0;(t < n);t++) if ( (((1 << t) & mask) != 0)) count++; if ( (count <= 1)) continue; count = ((count * (count - 1)) / 2); for ( int t = 0;(t < n);t++) if ( (((1 << t) & mask) != 0)) for ( int s = 0;(s < t);s++) if ( (((1 << s) & mask) != 0)) {q[(mask - (1 << t))] += ((q[mask] / count) * p[s][t]); q[(mask - (1 << s))] += ((q[mask] / count) * p[t][s]); } }for ( int i = 0;(i < n);i++) out.print((q[(1 << i)] + " ")); out.close(); } }
6	public class taskB{ public static void main( String[] args)throws IOException { new taskB().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; static String TASK = ""; void run()throws IOException { try{reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(System.out); tokenizer = null; solve(); reader.close(); writer.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int b[] ; int l[] ; int add[] ; int n ,k ,A ; double ans = 0; void solve()throws IOException { n = nextInt(); k = nextInt(); A = nextInt(); b = new int[n]; l = new int[n]; add = new int[n]; for ( int i = 0;(i < n);++i) {b[i] = nextInt(); l[i] = nextInt(); }brute(0,k); writer.printf("%.10f",ans); } private void brute( int pos, int yet){ if ( (pos == n)) { double p[] = new double[n]; for ( int i = 0;(i < n);++i) {p[i] = ((l[i] + add[i]) / 100.0); } double r = 0; for ( int i = 0;(i < (1 << n));++i) { double pr = 1;  int sm = 0; for ( int j = 0;(j < n);++j) {if ( ((i & (1 << j)) > 0)) {pr *= p[j]; } else {pr *= (1 - p[j]); sm += b[j]; }} int c = Integer.bitCount(i); if ( (c >= ((n + 2) / 2))) {r += pr; } else {r += (pr * ((1.0 * A) / (A + sm))); }}ans = Math.max(ans,r); } else {for ( int i = 0;(i <= yet);++i) {if ( ((l[pos] + (10 * i)) > 100)) continue; add[pos] = (10 * i); brute((pos + 1),(yet - i)); }}} String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
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 CDS2021{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int t = Integer.parseInt(f.readLine()); for ( int q = 1;(q <= t);q++) { int n = Integer.parseInt(f.readLine());  int[] array = new int[n]; for ( int k = 0;(k < n);k++) {array[k] = Integer.parseInt(f.readLine()); } StringJoiner sj = new StringJoiner("\n");  Stack<Entry> stack = new Stack<Entry>(); sj.add("1"); stack.push(new Entry("1",1)); for ( int k = 1;(k < n);k++) {if ( (array[k] == 1)) { String s = (stack.peek().s + ".1"); sj.add(s); stack.push(new Entry(s,1)); } else {while((!stack.isEmpty() && (stack.peek().last != (array[k] - 1)))){stack.pop(); }if ( stack.isEmpty()) break; String s = "";  int index = stack.peek().s.lastIndexOf("."); if ( (index == -1)) s = ("" + array[k]); else s = (stack.peek().s.substring(0,(index + 1)) + array[k]); sj.add(s); stack.pop(); stack.push(new Entry(s,array[k])); }}out.println(sj.toString()); }out.close(); } public static class Entry{ String s ; int last ; public Entry( String a, int b){ s = a; last = b; } } }
5	public class Main{ class team implements Comparable<team>{ int pro ,time ; } Scanner scan = new Scanner(System.in); void run(){ int n = scan.nextInt();  int k = (scan.nextInt() - 1);  team tm[] = new team[n]; for ( int i = 0;(i < n);i++) {tm[i] = new team(); tm[i].pro = scan.nextInt(); tm[i].time = scan.nextInt(); }Arrays.sort(tm); int sum = 0; for ( int i = k;(i >= 0);i--) if ( ((tm[i].pro == tm[k].pro) && (tm[i].time == tm[k].time))) sum++; for ( int i = k;(i < n);i++) if ( ((tm[i].pro == tm[k].pro) && (tm[i].time == tm[k].time))) sum++; System.out.println((sum - 1)); } public static void main( String[] args){ new Main().run(); } }
1	public class PrB{ public static long time ; public static void main( String[] args)throws Exception { time = System.currentTimeMillis(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine()); n = Integer.parseInt(st.nextToken()); k = Integer.parseInt(st.nextToken()); a = new int[n]; st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(st.nextToken()); int end = end(); if ( (end < 0)) System.out.println("-1 -1"); else System.out.println((((start(end) + 1) + " ") + (end + 1))); br.close(); System.exit(0); } static int n ,k ; static int[] a ; public static int end()throws Exception { boolean[] reached = new boolean[100002];  int rem = k; for ( int i = 0;(i < n);i++) {if ( !reached[a[i]]) {rem--; if ( (rem == 0)) return i; } reached[a[i]] = true; }return -1;} public static int start( int end)throws Exception { boolean[] reached = new boolean[100002];  int rem = k; for ( int i = end;(i >= 0);i--) {if ( !reached[a[i]]) {rem--; if ( (rem == 0)) return i; } reached[a[i]] = true; }return 0;} }
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); } }
4	public class A{ static private final int INF = ((int)1e9 + 7); public static void main( String[] args){ FastScanner fs = new FastScanner();  PrintWriter pr = new PrintWriter(System.out);  int n = fs.nextInt(),m = fs.nextInt(),k = fs.nextInt();  int[][] right = new int[n][(m - 1)],down = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) right[i] = fs.readArray((m - 1)); for ( int i = 0;(i < (n - 1));i++) down[i] = fs.readArray(m); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) pr.print((-1 + " ")); pr.println(); }} else { int[][][] dp = new int[((k / 2) + 1)][n][m]; for ( int r = 1;((2 * r) <= k);r++) {for ( int i = 0;(i < n);i++) Arrays.fill(dp[r][i],INF); for ( int i = 0;(i < n);i++) for ( int j = 0;((j + 1) < m);j++) { int cost = right[i][j]; dp[r][i][j] = Integer.min(dp[r][i][j],(dp[(r - 1)][i][(j + 1)] + cost)); dp[r][i][(j + 1)] = Integer.min(dp[r][i][(j + 1)],(dp[(r - 1)][i][j] + cost)); }for ( int i = 0;((i + 1) < n);i++) for ( int j = 0;(j < m);j++) { int cost = down[i][j]; dp[r][i][j] = Integer.min(dp[r][i][j],(dp[(r - 1)][(i + 1)][j] + cost)); dp[r][(i + 1)][j] = Integer.min(dp[r][(i + 1)][j],(dp[(r - 1)][i][j] + cost)); }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {pr.print(((2 * dp[(k / 2)][i][j]) + " ")); }pr.println(); }}pr.flush(); pr.close(); } 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());} int[] readArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} long nextLong(){ return Long.parseLong(next());} } }
6	public class Main{ static int n ,memo[] ,dS[] ,dd[][] ; static int dp( int idx, int msk){ if ( (msk == ((1 << n) - 1))) return 0; if ( (memo[msk] != -1)) return memo[msk]; while(((msk & (1 << idx)) != 0))++idx; int ret = ((dS[idx] * 2) + dp((idx + 1),(msk | (1 << idx)))); for ( int i = 0;(i < n);++i) if ( ((msk & (1 << i)) == 0)) ret = Math.min(ret,(((dS[i] + dS[idx]) + dd[i][idx]) + dp((idx + 1),((msk | (1 << i)) | (1 << idx))))); return memo[msk] = ret;} static StringBuilder sb = new StringBuilder("0 "); static void print( int idx, int msk){ if ( (msk == ((1 << n) - 1))) return ; int opt = dp(idx,msk); while(((msk & (1 << idx)) != 0))++idx; if ( (((dS[idx] * 2) + dp((idx + 1),(msk | (1 << idx)))) == opt)) {sb.append(((idx + 1) + " 0 ")); print((idx + 1),(msk | (1 << idx))); return ;} for ( int i = 0;(i < n);++i) if ( ((msk & (1 << i)) == 0)) if ( (opt == (((dS[i] + dS[idx]) + dd[i][idx]) + dp((idx + 1),((msk | (1 << i)) | (1 << idx)))))) {sb.append(((((idx + 1) + " ") + (i + 1)) + " 0 ")); print((idx + 1),((msk | (1 << i)) | (1 << idx))); return ;} } public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  Point s = new Point(sc.nextInt(),sc.nextInt()); n = sc.nextInt(); Point[] a = new Point[n]; for ( int i = 0;(i < n);++i) a[i] = new Point(sc.nextInt(),sc.nextInt()); dS = new int[n]; dd = new int[n][n]; for ( int i = 0;(i < n);++i) {dS[i] = dist2(s,a[i]); for ( int j = 0;(j < n);++j) dd[i][j] = dist2(a[i],a[j]); }memo = new int[(1 << n)]; Arrays.fill(memo,-1); out.println(dp(0,0)); print(0,0); out.println(sb); out.flush(); out.close(); } static int dist2( Point a, Point b){ return (sq((a.x - b.x)) + sq((a.y - b.y)));} static int sq( int x){ return (x * x);} 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();} } }
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)])); }} }
3	public class Main{ InputStream is ; PrintWriter out ; String INPUT = ""; long MOD = 1_000_000_007; int inf = Integer.MAX_VALUE; void solve(){ int n = ni();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ni(); } long ans = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[j] < a[i])) ans++; }}if ( ((ans % 2) == 0)) ans = 0; else ans = 1; int m = ni(); for ( int i = 0;(i < m);i++) { long s = nl();  long g = nl();  long sub = (g - s);  long res = ((sub * (sub + 1)) / 2); if ( ((res % 2) == 1)) ans = (1 - ans); if ( (ans == 0)) out.println("even"); else out.println("odd"); }} 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]; 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) && (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(); }} static private void tr( Object... o){ System.out.println(Arrays.deepToString(o)); } }
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)])); } }
0	public class TemplateBuf implements Runnable{ private void solve()throws Exception { long n = nextUnsignedLong(); out.println((n + (n / 2))); } BufferedReader in ; PrintWriter out ; @Override public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in),INPUT_BUF_SIZE); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } final int INPUT_BUF_SIZE = (1024 * 8); final int BUF_SIZE = INPUT_BUF_SIZE; char[] buf = new char[BUF_SIZE]; int ch = -1; int charRead = -1; int charPos = -1; public char nextChar()throws IOException { if ( ((charPos < 0) || (charPos >= charRead))) {charRead = in.read(buf); charPos = 0; } return buf[charPos++];} public long nextUnsignedLong()throws IOException { while((((ch = nextChar()) < '0') || (ch > '9'))); long num = (ch - '0'); while((((ch = nextChar()) >= '0') && (ch <= '9'))){num *= 10; num += (ch - '0'); }return num;} public static void main( String[] args){ new TemplateBuf().run(); } }
6	public class Main implements Runnable{ public static void main( String[] args)throws IOException { new Thread(null,new Main(),"",(1 << 20)).start(); } String file = "input"; BufferedReader input ; PrintWriter out ; int[] x = new int[25]; int[] y = new int[25]; int[][] dist = new int[25][25]; int[] single = new int[25]; int[] c = new int[25]; int INF = (1 << 30); void solve()throws IOException { StringTokenizer st = tokens(); x[0] = nextInt(st); y[0] = nextInt(st); int n = nextInt(); for ( int i = 1;(i <= n);i++) {st = tokens(); x[i] = nextInt(st); y[i] = nextInt(st); }for ( int i = 1;(i <= n);i++) single[i] = (2 * (((x[i] - x[0]) * (x[i] - x[0])) + ((y[i] - y[0]) * (y[i] - y[0])))); for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= n);j++) dist[i][j] = ((((single[i] / 2) + (single[j] / 2)) + ((x[i] - x[j]) * (x[i] - x[j]))) + ((y[i] - y[j]) * (y[i] - y[j]))); int[] dp = new int[(1 << n)];  int[] prev = new int[(1 << n)]; fill(dp,INF); dp[0] = 0; for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( (((i >> j) & 1) != 0)) {if ( (dp[i] > (dp[(i ^ (1 << j))] + single[(j + 1)]))) {dp[i] = (dp[(i ^ (1 << j))] + single[(j + 1)]); prev[i] = (j + 1); } for ( int k = (j + 1);(k < n);k++) if ( (((i >> k) & 1) != 0)) {if ( (dp[i] > (dp[((i ^ (1 << j)) ^ (1 << k))] + dist[(j + 1)][(k + 1)]))) {dp[i] = (dp[((i ^ (1 << j)) ^ (1 << k))] + dist[(j + 1)][(k + 1)]); prev[i] = (((j + 1) * 100) + (k + 1)); } } break;} }}out.println(dp[((1 << n) - 1)]); out.print("0 "); int mask = ((1 << n) - 1); while((mask > 0)){ int s = prev[mask];  int x = (s / 100);  int y = (s % 100); if ( (x == 0)) {out.print((((y + " ") + 0) + " ")); mask -= (1 << (y - 1)); } else {out.print((((((x + " ") + y) + " ") + 0) + " ")); mask -= (1 << (y - 1)); mask -= (1 << (x - 1)); }}} 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());} void print( Object... o){ out.println(deepToString(o)); } }
4	public class C{ String line ; StringTokenizer inputParser ; BufferedReader is ; FileInputStream fstream ; DataInputStream in ; void openInput( String file){ if ( (file == null)) is = new BufferedReader(new InputStreamReader(System.in)); else {try{fstream = new FileInputStream(file); in = new DataInputStream(fstream); is = new BufferedReader(new InputStreamReader(in)); }catch (Exception e){ System.err.println(e); } }} void readNextLine(){ try{line = is.readLine(); inputParser = new StringTokenizer(line," "); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } int NextInt(){ String n = inputParser.nextToken();  int val = Integer.parseInt(n); return val;} void closeInput(){ try{is.close(); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } public static void main( String[] argv){ String filePath = null; if ( (argv.length > 0)) filePath = argv[0];  C c = new C(filePath); } public C( String inputFile){ inputFile = "input.txt"; openInput(inputFile); PrintWriter writer = null; try{writer = new PrintWriter("output.txt"); }catch (FileNotFoundException e){ e.printStackTrace(); } readNextLine(); int N = NextInt();  int M = NextInt(); readNextLine(); int K = NextInt(); readNextLine(); int[][] p = new int[N][M];  int[][] init = new int[K][2]; for ( int i = 0;(i < K);i++) { int x = (NextInt() - 1);  int y = (NextInt() - 1); p[x][y] = 0; init[i][0] = x; init[i][1] = y; } int max = -1;  int maxX = -1,maxY = -1; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) {p[i][j] = 10000; for ( int k = 0;(k < K);k++) { int n = (Math.abs((init[k][0] - i)) + Math.abs((init[k][1] - j))); if ( (n < p[i][j])) p[i][j] = n; }if ( (p[i][j] > max)) {max = p[i][j]; maxX = (i + 1); maxY = (j + 1); } }writer.println(((maxX + " ") + maxY)); closeInput(); writer.close(); } }
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; } }
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()); }} }
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{ final boolean ONLINE_JUDGE = new File("input.txt").exists(); 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 Main().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); } } long modulo = (((1000 * 1000) * 1000) + 7); long binPow( long a, long b){ if ( (b == 0)) return 1; long c = binPow(a,(b / 2));  long ans = ((c * c) % modulo); if ( ((b % 2) == 1)) ans = ((ans * a) % modulo); return ans;} int[] gcd( int a, int b){ int[] res = new int[3]; if ( (a == 0)) {res[0] = b; res[1] = 0; res[2] = -1; return res;} res = gcd((b % a),a); int x = (res[2] + ((b / a) * res[1]));  int y = -res[1]; res[1] = x; res[2] = y; return res;} public void solve()throws IOException { int n = readInt();  HashMap<Character,Integer> mapa = new HashMap<>();  char[] s = readString().toCharArray(); for ( int i = 0;(i < n);i++) {if ( mapa.containsKey(s[i])) { int x = mapa.get(s[i]); mapa.replace(s[i],(x + 1)); } else mapa.put(s[i],1); } int sz = mapa.size(); mapa = new HashMap<>(); int i = 0; while((mapa.size() < sz)){if ( mapa.containsKey(s[i])) { int x = mapa.get(s[i]); mapa.replace(s[i],(x + 1)); } else mapa.put(s[i],1); i++; } int ans = i;  int left = 0;  int right = (i - 1); while((right < n)){while((left < right)){ int y = mapa.get(s[left]); if ( (y == 1)) mapa.remove(s[left]); else mapa.replace(s[left],(y - 1)); if ( (mapa.size() == sz)) {ans = Math.min(ans,(right - left)); left++; } else {left++; break;}}right++; if ( (right < n)) {if ( mapa.containsKey(s[right])) { int x = mapa.get(s[right]); mapa.replace(s[right],(x + 1)); } else mapa.put(s[right],1); } }out.print(ans); } }
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(); } }
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 {if ( (N == 4)) {System.out.printf("12\n"); } 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); }}} }
1	public class A{ public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int k = (scan.nextInt() - 1);  PrimeGen p = new PrimeGen(n);  List<Integer> prims = new ArrayList<Integer>(); for ( int i = 2;(i <= n);i++) {if ( (p.isPrime(i) > 0)) {prims.add(i); } } int sum = 0; for ( int i = 0;(i < (prims.size() - 1));i++) { int c = ((prims.get(i) + prims.get((i + 1))) + 1); if ( ((c <= n) && (p.isPrime(c) > 0))) {sum++; } }System.out.println(((sum >= k)?"YES":"NO")); } static class PrimeGen{ public PrimeGen( int m){ m = (int)Math.sqrt(m); double max = 0;  int r = 1; for ( int i = 0;(i < 4);) {max += ((r * m) / Math.pow(Math.log1p(m),++i)); r *= i; }p = new int[(int)max]; for ( int i = 0,e = 2;(i < p.length);i++) {for ( ;(isPrime(e) < 1);e++) ;p[i] = e++; }this.m = p[(p.length - 1)]; this.m = (this.m * this.m); } int isPrime( int n){ for ( int e :p) if ( (e < 1)) break; else if ( ((n != e) && ((n % e) < 1))) return 0; return 1;} int[] p ; int m ; } }
4	public class P35C{ public static void main( String[] args)throws FileNotFoundException { InputStream inputStream = new FileInputStream("input.txt");  OutputStream outputStream = new FileOutputStream("output.txt");  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(in,out); out.close(); } static class Task{ private class Point{ int x ,y ; public Point( int x, int y){ this.x = x; this.y = y; } } private int dis( int i, int j, Point p2){ return (Math.abs((i - p2.x)) + Math.abs((j - p2.y)));} public void solve( InputReader in, PrintWriter out){ int n = in.nextInt(),m = in.nextInt();  int k = in.nextInt();  Point[] ps = new Point[k]; for ( int i = 0;(i < k);i++) {ps[i] = new Point((in.nextInt() - 1),(in.nextInt() - 1)); } int max = 0;  Point argmax = ps[0]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int val = dis(i,j,ps[0]); for ( int l = 1;(l < k);l++) {val = Math.min(val,dis(i,j,ps[l])); }if ( (val > max)) {max = val; argmax = new Point(i,j); } }}out.println((((argmax.x + 1) + " ") + (argmax.y + 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());} } }
5	public class Solution{ static private StringTokenizer st ; static private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); static private int nextInt(){ return Integer.parseInt(st.nextToken());} static private void initTokenizer()throws Exception { st = new StringTokenizer(reader.readLine()); } public static void main( String[] args)throws Exception { initTokenizer(); int n = nextInt();  int a = nextInt();  int b = nextInt();  int[] h = new int[n]; initTokenizer(); for ( int i = 0;(i < n);i++) {h[i] = nextInt(); }Arrays.sort(h); System.out.print((h[b] - h[(b - 1)])); } }
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 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 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 INF = ((1000 * 1000) * 1000); public void solve( int testNumber, InputReader in, OutputWriter out){ int x0 = in.readInt();  int y0 = in.readInt();  int n = in.readInt();  int[] xs = new int[(n + 1)],ys = new int[(n + 1)]; xs[0] = x0; ys[0] = y0; for ( int i = 1;(i <= n);i++) {xs[i] = in.readInt(); ys[i] = in.readInt(); } int[] one = new int[n]; for ( int i = 0;(i < n);i++) one[i] = (dist(0,(i + 1),xs,ys) * 2); int[][] two = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {two[i][j] = ((dist(0,(i + 1),xs,ys) + dist(0,(j + 1),xs,ys)) + dist((i + 1),(j + 1),xs,ys)); }} int[] dp = new int[(1 << n)]; Arrays.fill(dp,INF); dp[0] = 0; int[] prev = new int[(1 << n)]; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int i = 0;(i < n);i++) {if ( (((mask >> i) & 1) != 0)) continue; ; int nmask = (mask | (1 << i));  int cost = (one[i] + dp[mask]); if ( (cost < dp[nmask])) {dp[nmask] = cost; prev[nmask] = i; } for ( int j = (i + 1);(j < n);j++) {if ( (((mask >> j) & 1) != 0)) continue; int nnmask = (nmask | (1 << j)); cost = (two[i][j] + dp[mask]); if ( (cost < dp[nnmask])) {dp[nnmask] = cost; prev[nnmask] = ((n + (i * n)) + j); } }break;}} int mask = ((1 << n) - 1); out.printLine(dp[mask]); ArrayList<Integer> res = new ArrayList<>(); res.add(0); while((mask > 0)){if ( (prev[mask] < n)) {res.add((prev[mask] + 1)); mask &= (1 << prev[mask]); } else { int ii = ((prev[mask] - n) / n);  int jj = ((prev[mask] - n) % n);  int i = Math.max(ii,jj);  int j = Math.min(ii,jj); res.add((i + 1)); res.add((j + 1)); mask &= (1 << i); mask &= (1 << j); }res.add(0); }Collections.reverse(res); for ( int val :res) out.print((val + " ")); out.printLine(); } int dist( int i, int j, int[] xs, int[] ys){ return (((xs[i] - xs[j]) * (xs[i] - xs[j])) + ((ys[i] - ys[j]) * (ys[i] - ys[j])));} } 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 print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void printLine(){ writer.println(); } public void close(){ writer.close(); } public void printLine( int i){ writer.println(i); } } }
0	public class D{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; double f( int dist, double initSp, int a, int maxSp){ double distToReachMaxSpeed = ((0.5 * ((maxSp * maxSp) - (initSp * initSp))) / a); if ( (dist > distToReachMaxSpeed)) return (((1d * (maxSp - initSp)) / a) + ((dist - distToReachMaxSpeed) / maxSp)); return ((Math.sqrt(((initSp * initSp) + ((2 * a) * dist))) - initSp) / a);} void solve()throws IOException { int a = nextInt();  int maxSp = nextInt();  int len = nextInt();  int signX = nextInt();  int signSp = nextInt(); if ( (maxSp <= signSp)) {out.printf("%.9f\n",f(len,0,a,maxSp)); return ;} double distToReachSignSp = (((0.5 * signSp) * signSp) / a); if ( (distToReachSignSp >= signX)) { double t = Math.sqrt(((2d * signX) / a)); out.printf("%.9f\n",(t + f((len - signX),(t * a),a,maxSp))); return ;} double distToReachMaxThenSign = ((0.5 * (((maxSp * maxSp) + (maxSp * maxSp)) - (signSp * signSp))) / a); if ( (distToReachMaxThenSign <= signX)) { double t = ((((1d * ((2 * maxSp) - signSp)) / a) + ((signX - distToReachMaxThenSign) / maxSp)) + f((len - signX),signSp,a,maxSp)); out.printf("%.9f\n",t); return ;} double xSp = Math.sqrt(((a * signX) + ((signSp * signSp) * 0.5)));  double xTime = (((2 * xSp) - signSp) / a); out.printf("%.9f\n",(xTime + f((len - signX),signSp,a,maxSp))); } void inp()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 D().inp(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
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();} } }
6	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 m = Int();  int A[][] = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {A[i][j] = Int(); }} Sol sol = new Sol(); 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 Sol{ int dif[][] ; int dp[][][] ; public void solution( PrintWriter out, int[][] A){ int n = A.length;  int m = A[0].length;  int res = 0; dif = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < A.length);j++) { int mn = Integer.MAX_VALUE; for ( int k = 0;(k < m);k++) {mn = Math.min(mn,Math.abs((A[i][k] - A[j][k]))); }dif[i][j] = mn; dif[j][i] = mn; }} int state = ((1 << n) - 1); dp = new int[(state + 5)][(n + 1)][(n + 1)]; for ( int i = 0;(i < dp.length);i++) {for ( int j = 0;(j < dp[0].length);j++) {Arrays.fill(dp[i][j],-1); }}for ( int i = 0;(i < n);i++) {res = Math.max(res,dfs(A,(state ^ (1 << i)),i,i)); }out.println(res); } public int dfs( int[][] A, int state, int pre, int start){ if ( (state == 0)) { int mn = Integer.MAX_VALUE; for ( int i = 1;(i < A[0].length);i++) {mn = Math.min(mn,Math.abs((A[start][i] - A[pre][(i - 1)]))); }return mn;} if ( (dp[state][pre][start] != -1)) {return dp[state][pre][start];} int res = 0; for ( int i = 0;(i < A.length);i++) {if ( ((state & (1 << i)) != 0)) { int di = dif[pre][i]; res = Math.max(res,Math.min(di,dfs(A,(state ^ (1 << i)),i,start))); } }dp[state][pre][start] = res; return res;} }
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;} }
4	public class Main{ public static void deal( int n, int m, int k, int[][] d1, int[][] d2){ if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print("-1 "); }System.out.println(); }return ;} int[][][] dp = new int[((k / 2) + 1)][n][m]; for ( int i = 0;(i < (k / 2));i++) {for ( int j = 0;(j < n);j++) {for ( int l = 0;(l < m);l++) { int min = Integer.MAX_VALUE; if ( (j > 0)) min = Math.min(min,(d2[(j - 1)][l] + dp[i][(j - 1)][l])); if ( (j < (n - 1))) min = Math.min(min,(d2[j][l] + dp[i][(j + 1)][l])); if ( (l > 0)) min = Math.min(min,(d1[j][(l - 1)] + dp[i][j][(l - 1)])); if ( (l < (m - 1))) min = Math.min(min,(d1[j][l] + dp[i][j][(l + 1)])); dp[(i + 1)][j][l] = min; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print((dp[(k / 2)][i][j] * 2)); System.out.print(" "); }System.out.println(); }} public static void main( String[] args){ MyScanner scanner = new MyScanner();  int n = scanner.nextInt();  int m = scanner.nextInt();  int k = scanner.nextInt();  int[][] d1 = new int[n][(m - 1)];  int[][] d2 = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {d1[i][j] = scanner.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {d2[i][j] = scanner.nextInt(); }}deal(n,m,k,d1,d2); } 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());} } }
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());} } }
1	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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int numTests = in.nextInt(); for ( int test = 0;(test < numTests);test++) { int n = in.nextInt();  boolean can = false; if ( (((n % 2) == 0) && isSquare((n / 2)))) {can = true; } if ( (((n % 4) == 0) && isSquare((n / 4)))) {can = true; } out.println((can?"YES":"NO")); }} private boolean isSquare( int n){ int x = (int)Math.sqrt(n); while(((x * x) > n)){--x; }while(((x * x) < n)){++x; }return ((x * x) == n);} } 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());} } }
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<Pair>[] g ; String s ; int[][] a ; void solve()throws IOException { int n = in.nextInt();  int m = in.nextInt(); a = new int[n][m]; for ( int i = 0;(i < n);i++) { String s = in.nextLine(); for ( int j = 0;(j < m);j++) {a[i][j] = s.charAt(j); }} int[][] f = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) f[i][j] = inf; for ( int i = 0;(i < n);i++) { int cnt = 0; for ( int j = 0;(j < m);j++) {if ( (a[i][j] == '*')) {f[i][j] = Math.min(f[i][j],cnt); cnt++; } else {cnt = 0; }}}for ( int i = 0;(i < n);i++) { int cnt = 0; for ( int j = (m - 1);(j >= 0);j--) {if ( (a[i][j] == '*')) {f[i][j] = Math.min(f[i][j],cnt); cnt++; } else {cnt = 0; }}}for ( int j = 0;(j < m);j++) { int cnt = 0; for ( int i = 0;(i < n);i++) {if ( (a[i][j] == '*')) {f[i][j] = Math.min(f[i][j],cnt); cnt++; } else {cnt = 0; }}}for ( int j = 0;(j < m);j++) { int cnt = 0; for ( int i = (n - 1);(i >= 0);i--) {if ( (a[i][j] == '*')) {f[i][j] = Math.min(f[i][j],cnt); cnt++; } else {cnt = 0; }}} ArrayList<Item> ans = new ArrayList<>(); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) {if ( ((a[i][j] == '*') && (f[i][j] > 0))) ans.add(new Item((i + 1),(j + 1),f[i][j])); } boolean[][] used = new boolean[n][m]; for ( int i = 0;(i < n);i++) { int cnt = 0; for ( int j = 0;(j < m);j++) {if ( ((a[i][j] == '*') && (f[i][j] > 0))) {cnt = Math.max(cnt,(f[i][j] + 1)); } if ( (cnt > 0)) used[i][j] = true; cnt--; }cnt = 0; for ( int j = (m - 1);(j >= 0);j--) {if ( ((a[i][j] == '*') && (f[i][j] > 0))) {cnt = Math.max(cnt,(f[i][j] + 1)); } if ( (cnt > 0)) used[i][j] = true; cnt--; }}for ( int j = 0;(j < m);j++) { int cnt = 0; for ( int i = 0;(i < n);i++) {if ( ((a[i][j] == '*') && (f[i][j] > 0))) {cnt = Math.max(cnt,(f[i][j] + 1)); } if ( (cnt > 0)) used[i][j] = true; cnt--; }cnt = 0; for ( int i = (n - 1);(i >= 0);i--) {if ( ((a[i][j] == '*') && (f[i][j] > 0))) {cnt = Math.max(cnt,(f[i][j] + 1)); } if ( (cnt > 0)) used[i][j] = true; cnt--; }}for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( ((a[i][j] == '*') && !used[i][j])) {out.println(-1); return ;} out.println(ans.size()); for ( Item i :ans) out.println(((((i.a + " ") + i.b) + " ") + i.c)); } class Item{ int a ; int b ; int c ; Item( int a, int b, int c){ this.a = a; this.b = b; this.c = c; } } 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());} String nextLine()throws IOException { return br.readLine();} } }
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))); }}} static private String toRC( int[] a){ return ((("R" + a[0]) + "C") + a[1]);} static private 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]);} static private 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;} static private 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 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.nextInt();  String word = in.next();  int cnt[] = new int[1000];  int let = 0;  Set<Character> set = new TreeSet<>(); for ( int i = 0;(i < word.length());i++) {set.add(word.charAt(i)); } int uniq = set.size();  int i = 0,j = -1;  int ans = Integer.MAX_VALUE; while(((i < N) && (j < N))){while((((j + 1) < N) && (let < uniq))){j++; if ( (cnt[word.charAt(j)] == 0)) {let++; } cnt[word.charAt(j)]++; }if ( (let == uniq)) ans = Math.min(ans,((j - i) + 1)); cnt[word.charAt(i)]--; if ( (cnt[word.charAt(i)] == 0)) let--; i++; }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());} } }
2	public class Test4{ PrintWriter pw = new PrintWriter(System.out); InputStream is = System.in; Random rnd = new Random(); int a ; void run(){ a = ni(); for ( int q = 0;(q < a);q++) { long nj = ni(),kj = nl();  BigInteger n = BigInteger.valueOf(nj),k = BigInteger.valueOf(kj); if ( ((nj < 40) && (k.compareTo(BigInteger.valueOf(2).pow((2 * (int)nj)).divide(BigInteger.valueOf(3))) > 0))) {System.out.println("NO"); continue;} if ( (nj >= 40)) {System.out.println(("YES " + (nj - 1))); continue;} long log = nj;  BigInteger maxop = BigInteger.valueOf(2).pow((2 * (int)nj)).divide(BigInteger.valueOf(3)),pth = BigInteger.ONE; for ( BigInteger c = BigInteger.ONE;(log > 0);log--,c = c.multiply(BigInteger.valueOf(2)).add(BigInteger.ONE)) {if ( (k.compareTo(c) < 0)) break; pth = c.multiply(BigInteger.valueOf(2)).add(BigInteger.ONE); k = k.subtract(c); maxop = maxop.subtract(c); }maxop = maxop.subtract(pth.multiply(BigInteger.valueOf(2).pow((2 * (int)log)).divide(BigInteger.valueOf(3)))); if ( (k.compareTo(maxop) <= 0)) System.out.println(("YES " + log)); else System.out.println("NO"); }pw.flush(); } public static void main( String[] args){ new Test4().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(); }} }
3	public class CF911D{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  int n = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine());  int[] aa = new int[n]; for ( int i = 0;(i < n);i++) aa[i] = Integer.parseInt(st.nextToken()); boolean odd = false; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( (aa[i] > aa[j])) odd = !odd;  int m = Integer.parseInt(br.readLine()); while((m-- > 0)){st = new StringTokenizer(br.readLine()); int l = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken());  int k = ((r - l) + 1); if ( (((((long)k * (k - 1)) / 2) % 2) != 0)) odd = !odd; pw.println((odd?"odd":"even")); }pw.close(); } }
0	public class program{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( (n == 0)) {System.out.println("0 0 0"); return ;} else if ( (n == 1)) {System.out.println("0 0 1"); return ;} else if ( (n == 2)) {System.out.println("0 1 1"); return ;} else { int ppp = 0;  int pp = 1;  int c = 2; while(true){if ( (((ppp + pp) + c) == n)) {System.out.println(((((ppp + " ") + pp) + " ") + c)); return ;} else {c = ((c + pp) + ppp); int temp = pp; pp = (pp + ppp); ppp = temp; }}}} }
4	public class N718{ static PrintWriter out ; static Scanner sc ; static ArrayList<int[]> q ,w ,x ; static ArrayList<Integer> adj[] ; static HashSet<Integer> primesH ; static boolean prime[] ; static HashSet<Long> tmp ; static int[][][] dist ; static boolean[] v ; static int[] a ,b ,c ,d ; static Boolean[][] dp ; static char[][] mp ; static int A ,B ,n ,m ,h ,ans ,sum ; static long oo = ((long)1e9 + 7); public static void main( String[] args)throws IOException { sc = new Scanner(System.in); out = new PrintWriter(System.out); D(); out.close(); } static private Boolean dp( int i, int j){ if ( (j > (sum / 2))) return false; if ( (i == x.size())) {return ((sum / 2) == j);} if ( (dp[i][j] != null)) return dp[i][j]; return dp[i][j] = (dp((i + 1),(j + x.get(i)[0])) || dp((i + 1),j));} static void D()throws IOException { int t = 1; while((t-- > 0)){ int n = ni(),m = ni(),k = ni();  int[][] ans = new int[n][m]; dist = new int[n][m][4]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j > m);j++) Arrays.fill(dist[i][j],Integer.MAX_VALUE); int x ; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {dist[i][j][2] = x = ni(); dist[i][(j + 1)][3] = x; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {dist[i][j][1] = x = ni(); dist[(i + 1)][j][0] = x; }} int[][] nans = new int[n][m]; if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) Arrays.fill(ans[i],-1); } else {for ( int ii = 0;(ii < (k / 2));ii++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {nans[i][j] = Integer.MAX_VALUE; if ( (i > 0)) nans[i][j] = Math.min(nans[i][j],(ans[(i - 1)][j] + (2 * dist[(i - 1)][j][1]))); if ( (i < (n - 1))) nans[i][j] = Math.min(nans[i][j],(ans[(i + 1)][j] + (2 * dist[(i + 1)][j][0]))); if ( (j > 0)) nans[i][j] = Math.min(nans[i][j],(ans[i][(j - 1)] + (2 * dist[i][(j - 1)][2]))); if ( (j < (m - 1))) nans[i][j] = Math.min(nans[i][j],(ans[i][(j + 1)] + (2 * dist[i][(j + 1)][3]))); }} int[][] tmp = ans; ans = nans; nans = tmp; }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((ans[i][j] + " ")); }ol(""); }}} static private boolean valid( int nx, int ny){ return ((((nx >= 0) && (nx < dist.length)) && (ny >= 0)) && (ny < dist[0].length));} static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} static int ni()throws IOException { return sc.nextInt();} static long nl()throws IOException { return sc.nextLong();} static int[] nai( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); return a;} static int[][] nmi( int n, int m)throws IOException { int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[i][j] = sc.nextInt(); }}return a;} static void ol( String x){ out.println(x); } static void ol( int x){ out.println(x); } 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 double nextDouble()throws IOException { return Double.parseDouble(next());} public long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
3	public class A{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(reader.readLine());  String str[] = reader.readLine().split(" ");  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(str[i]); }Arrays.sort(a); int k = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] == 0)) {continue;} for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {a[j] = 0; } }k++; }System.out.println(k); } }
5	public class C15A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = sc.nextInt();  double nm[][] = new double[n][2];  int a = 0;  int b = 0; for ( int i = 0;(i < n);i++) {a = sc.nextInt(); b = sc.nextInt(); nm[i][0] = (a - ((double)b / 2)); nm[i][1] = (a + ((double)b / 2)); }Arrays.sort(nm,new ArrayColumnComparator(1)); int sum = 0; for ( int i = 0;(i < (n - 1));i++) {if ( ((nm[(i + 1)][0] - nm[i][1]) == t)) sum++; else if ( ((nm[(i + 1)][0] - nm[i][1]) > t)) {sum += 2; } }System.out.println((sum + 2)); } } class ArrayColumnComparator implements Comparator{ private int cm = 0; ArrayColumnComparator( int cm){ this.cm = cm; } }
4	public class D1517{ 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 m = sc.nextInt();  int k = sc.nextInt();  int[][] costRight = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {costRight[i][j] = sc.nextInt(); }} int[][] costDown = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {costDown[i][j] = sc.nextInt(); }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {pw.print((-1 + " ")); }pw.println(); }pw.close(); return ;} int[][][] dp = new int[(k + 1)][n][m]; for ( int w = 2;(w <= k);w += 2) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[w][i][j] = (int)1e9; if ( ((i + 1) < n)) dp[w][i][j] = Math.min(dp[w][i][j],((2 * costDown[i][j]) + dp[(w - 2)][(i + 1)][j])); if ( ((i - 1) >= 0)) dp[w][i][j] = Math.min(dp[w][i][j],((2 * costDown[(i - 1)][j]) + dp[(w - 2)][(i - 1)][j])); if ( ((j + 1) < m)) dp[w][i][j] = Math.min(dp[w][i][j],((2 * costRight[i][j]) + dp[(w - 2)][i][(j + 1)])); if ( ((j - 1) >= 0)) dp[w][i][j] = Math.min(dp[w][i][j],((2 * costRight[i][(j - 1)]) + dp[(w - 2)][i][(j - 1)])); }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {pw.print((dp[k][i][j] + " ")); }pw.println(); }pw.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( FileReader f){ br = new BufferedReader(f); } 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());} } }
5	public class Test{ static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter writer ; static int nextInt()throws 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)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); } static private void solve()throws IOException { int n = nextInt();  int[] a = new int[n];  int first = 0; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); first += a[i]; }Arrays.sort(a); int ans = 1;  int last = a[(n - 1)]; first -= a[(n - ans)]; while(true){if ( (first < last)) break; ans++; last += a[(n - ans)]; first -= a[(n - ans)]; }writer.print(ans); } }
6	public class Main implements Runnable{ private void solution()throws IOException { int n = in.nextInt();  int m = in.nextInt();  boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = in.nextInt();  int y = in.nextInt(); adj[(x - 1)][(y - 1)] = true; adj[(y - 1)][(x - 1)] = true; }final long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);++i) {for ( int mask = 0;(mask < (1 << (n - i)));++mask) {for ( int j = 0;(j < (n - i));++j) {dp[mask][j] = 0; }}dp[0][0] = 1; for ( int mask = 0;(mask < (1 << (n - i)));++mask) {for ( int j = 0;(j < (n - i));++j) {if ( (dp[mask][j] != 0)) { long am = dp[mask][j]; for ( int k = 0;(k < (n - i));++k) {if ( ((((mask >> k) & 1) == 0) && adj[(j + i)][(k + i)])) {dp[(mask | (1 << k))][k] += am; } }} }if ( (((mask >> 0) & 1) != 0)) {res += dp[mask][0]; } }}out.println(((res - m) / 2)); } private class Scanner{ BufferedReader reader ; 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)); }
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)));} } }
1	public class A{ public static void main( String[] args){ boolean[] b = new boolean[11000]; Arrays.fill(b,true); b[0] = b[1] = false; for ( int i = 2;(i < b.length);i++) {if ( !b[i]) continue; for ( int j = 2;((i * j) < b.length);j++) b[(i * j)] = false; } int[] p = new int[11000];  int pn = 0; for ( int i = 0;(i < b.length);i++) {if ( b[i]) p[pn++] = i; } Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int k = scan.nextInt();  int rtn = 0; for ( int j = 0;(p[j] <= n);j++) {for ( int h = 0;(h <= j);h++) {if ( (((p[h] + p[(h + 1)]) + 1) == p[j])) {rtn++; break;} }}System.out.println(((rtn >= k)?"YES":"NO")); } }
6	public class Task2{ public static void main( String[] args)throws IOException { new Task2().solve(); } int mod = 1000000007; PrintWriter out ; int n ; int m ; long base = (1L << 63); long P = 31; int[][] a ; void solve()throws IOException { Reader in = new Reader();  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int sx = in.nextInt();  int sy = 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(); y[i] = in.nextInt(); } int[] dp = new int[(1 << n)];  int[] p = new int[(1 << n)];  int inf = 1000000000; Arrays.fill(dp,inf); dp[0] = 0; for ( int mask = 0;(mask < ((1 << n) - 1));mask++) { int k = -1; if ( (dp[mask] == inf)) continue; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) {k = i; break;} }for ( int i = k;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) { int val = (((dp[mask] + dist(sx,sy,x[i],y[i])) + dist(sx,sy,x[k],y[k])) + dist(x[i],y[i],x[k],y[k])); if ( (val < dp[((mask | (1 << i)) | (1 << k))])) {dp[((mask | (1 << i)) | (1 << k))] = val; p[((mask | (1 << i)) | (1 << k))] = mask; } } }}out.println(dp[((1 << n) - 1)]); int cur = ((1 << n) - 1); out.print((0 + " ")); while((cur != 0)){ int prev = p[cur]; for ( int i = 0;(i < n);i++) {if ( (((cur & (1 << i)) ^ (prev & (1 << i))) != 0)) out.print(((i + 1) + " ")); }out.print((0 + " ")); cur = prev; }out.flush(); out.close(); } int dist( int x1, int y1, int x2, int y2){ return (((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)));} long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % 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());} } }
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){ TreeSet<Integer> set = new TreeSet<>();  int n = in.nextInt(); for ( int i = 0;(i < n);i++) { int x = in.nextInt(); set.add(x); } int ans = 0; while(!set.isEmpty()){ans++; int minimal = set.first();  int cur = minimal; while((cur <= 100)){set.remove(cur); cur += minimal; }}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);} } }
4	public class G{ 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.flush(); out.close(); } static class TaskE{ class MinCostMaxFlow{ ArrayList<Edge> al[] ; Edge ja[][] ; int d[] ; int N ,S ,T ,maxFlow ; int minCost ; final int gmax = (Integer.MAX_VALUE / 100); int edges = 0; class Edge{ int u ,flow ,rid ,cost ; Edge( int a, int b, int c, int d){ u = a; flow = b; cost = c; rid = d; } } void addEdge( int u, int v, int flow, int cost){ int lu = al[u].size(),lv = al[v].size(); al[u].add(new Edge(v,flow,cost,lv)); al[v].add(new Edge(u,0,-cost,lu)); } void convertToArray(){ ja = new Edge[N][]; for ( int i = 0;(i < N);i++) { int sz = al[i].size(); ja[i] = new Edge[sz]; for ( int j = 0;(j < sz);j++) {ja[i][j] = al[i].get(j); }al[i].clear(); }} MinCostMaxFlow( int n, int source, int sink){ N = n; S = source; T = sink; maxFlow = 0; minCost = 0; al = new ArrayList[N]; d = new int[N]; for ( int i = 0;(i < N);i++) {al[i] = new ArrayList<>(); }} int node[] ; int visit[] ; int prv[] ,prve[] ; int dist[] ; boolean simple(){ node = new int[N]; visit = new int[N]; prv = new int[N]; prve = new int[N]; dist = new int[N]; Arrays.fill(dist,gmax); node[0] = S; dist[0] = 0; int front = 1,back = 0; while((front != back)){ int u = node[back++];  int distu = dist[u]; if ( (back == N)) back = 0; visit[u] = 2; for ( int i = 0;(i < ja[u].length);i++) { Edge e = ja[u][i]; if ( (e.flow == 0)) continue; int cdist = (distu + e.cost); if ( (cdist < dist[e.u])) {if ( (visit[e.u] == 0)) {node[front] = e.u; if ( (++front == N)) front = 0; } else if ( (visit[e.u] == 2)) {if ( (--back == -1)) back += N; node[back] = e.u; } visit[e.u] = 1; prve[e.u] = i; prv[e.u] = u; dist[e.u] = cdist; } }}return (visit[T] != 0);} class pair{ int F ; int S ; pair( int a, int b){ F = a; S = b; } } boolean dijkstra(){ visit = new int[N]; prv = new int[N]; prve = new int[N]; dist = new int[N]; Arrays.fill(dist,gmax); PriorityQueue<pair> pq = new PriorityQueue<>((A,B)->Double.compare(A.S,B.S)); pq.add(new pair(S,0)); dist[0] = 0; o:while(!pq.isEmpty()){ pair p = pq.poll(); while((dist[p.F] < p.S)){if ( pq.isEmpty()) break; p = pq.poll(); }visit[p.F] = 2; for ( int i = 0;(i < ja[p.F].length);i++) { Edge e = ja[p.F][i]; if ( (e.flow == 0)) continue; int cdist = (p.S + ((e.cost + d[p.F]) - d[e.u])); if ( (cdist < dist[e.u])) {if ( (visit[e.u] == 2)) return false; pq.add(new pair(e.u,cdist)); dist[e.u] = cdist; prv[e.u] = p.F; prve[e.u] = i; visit[e.u] = 1; } }}return (visit[T] != 0);} int augment(){ int p = T;  int min = gmax; while((p != 0)){ int pp = prv[p],pe = prve[p];  int val = ja[pp][pe].flow; min = Math.min(min,val); p = pp; }p = T; while((p != 0)){ int pp = prv[p],pe = prve[p]; ja[pp][pe].flow -= min; ja[p][ja[pp][pe].rid].flow += min; p = pp; }maxFlow += min; return min;} void updPotential(){ for ( int i = 0;(i < N);i++) {if ( (visit[i] != 0)) {d[i] += (dist[i] - dist[S]); } }} boolean calWithPotential(){ while(dijkstra()){ int min = ((dist[T] + d[T]) - d[S]); minCost += (min * augment()); updPotential(); }return true;} } int n ,m ,k ,c ,d ,a[] ,f[] ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); k = in.nextInt(); c = in.nextInt(); d = in.nextInt(); int maxl = (n + k),T = ((n * maxl) + 1);  MinCostMaxFlow ans = new MinCostMaxFlow((T + 1),0,T); a = new int[(k + 1)]; f = new int[(n + 1)]; for ( int i = 1;(i <= k);i++) {a[i] = in.nextInt(); f[a[i]]++; }for ( int i = 1;(i <= n);i++) {if ( (f[i] == 0)) continue; ans.addEdge(0,i,f[i],0); }for ( int i = 2;(i <= n);i++) {for ( int l = 0;(l < (maxl - 1));l++) {ans.addEdge(((l * n) + i),(((l + 1) * n) + i),k,c); }}for ( int i = 1;(i <= m);i++) { int a = in.nextInt(),b = in.nextInt(); for ( int l = 0;(l < (maxl - 1));l++) {for ( int p = 1;(p <= k);p++) {if ( (a != 1)) ans.addEdge(((n * l) + a),((n * (l + 1)) + b),1,((d * ((2 * p) - 1)) + c)); if ( (b != 1)) ans.addEdge(((n * l) + b),((n * (l + 1)) + a),1,((d * ((2 * p) - 1)) + c)); }}}for ( int l = 1;(l < maxl);l++) {ans.addEdge(((l * n) + 1),T,k,0); }ans.convertToArray(); ans.calWithPotential(); if ( (ans.maxFlow != k)) {out.println("BUG"); } else {out.println((int)ans.minCost); }} } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); st = null; } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} public int nextInt(){ return Integer.parseInt(next());} } }
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 Solution{ static MyScanner sc ; static private PrintWriter out ; static long M2 = (1_000_000_000L + 7); public static void main( String[] s)throws Exception { StringBuilder stringBuilder = new StringBuilder(); if ( (stringBuilder.length() == 0)) {sc = new MyScanner(System.in); } else {sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString()))); }out = new PrintWriter(new OutputStreamWriter(System.out)); initData(); solve(); out.flush(); } static private void initData(){ } static private void solve()throws IOException { int n = sc.nextInt();  int q = sc.nextInt();  int[] vv = sc.na(n);  double[] ans = new double[n]; for ( int i = 0;(i < n);i++) {ans[i] = q; for ( int s = 0;(s < i);s++) {if ( (Math.abs((vv[i] - vv[s])) > (q * 2))) continue; double diff = (((4 * q) * q) - (Math.abs((vv[i] - vv[s])) * Math.abs((vv[i] - vv[s])))); diff = Math.sqrt(diff); ans[i] = Math.max(ans[i],(diff + ans[s])); }out.print((ans[i] + " ")); }} static private long gcd( long l, long l1){ if ( (l > l1)) return gcd(l1,l); if ( (l == 0)) return l1; return gcd((l1 % l),l);} static private long pow( long a, long b, long m){ if ( (b == 0)) return 1; if ( (b == 1)) return a; long pp = pow(a,(b / 2),m); pp *= pp; pp %= m; return ((pp * (((b % 2) == 0)?1:a)) % m);} static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner( BufferedReader br){ this.br = br; } public MyScanner( InputStream in){ this(new BufferedReader(new InputStreamReader(in))); } void findToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }} String next(){ findToken(); return st.nextToken();} int[] na( int n){ int[] k = new int[n]; for ( int i = 0;(i < n);i++) {k[i] = sc.fi(); }return k;} int nextInt(){ return Integer.parseInt(next());} int fi(){ String t = next();  int cur = 0;  boolean n = (t.charAt(0) == '-'); for ( int a = (n?1:0);(a < t.length());a++) {cur = (((cur * 10) + t.charAt(a)) - '0'); }return (n?-cur:cur);} long nextLong(){ return Long.parseLong(next());} } }
0	public class MainA{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int count = 0; count = (n / 2); count = (count + (n - (n / 2))); n = (n - (n / 2)); count = (count + n); System.out.println(count); } }
2	public class Test{ static private long sum( long value){ long ans = 0; while((value > 0)){ans += (value % 10); value /= 10; }return ans;} public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n ,s ,ans = 0; n = scan.nextLong(); s = scan.nextLong(); long current = s; while(((current <= n) && (current <= (s + (20 * 9))))){ long temp = sum(current); if ( ((current - temp) >= s)) {ans++; } current++; }if ( (current <= n)) {ans += ((n - current) + 1); } System.out.println(ans); } }
5	public class CFTest6{ static BufferedReader br ; public static void main( String[] args){ br = new BufferedReader(new InputStreamReader(System.in)); try{ int[] a1 = readIntArr();  int[] a2 = readIntArr(); br.close(); int f = a1[0];  int d = a1[1];  int s = a1[2]; Arrays.sort(a2); if ( (d <= s)) System.out.println(0); else { int cur = ((d - s) + 1);  int num = 0; for ( int i = 0;(i < f);i++) {num++; cur -= a2[((f - i) - 1)]; if ( (cur <= 0)) break; cur++; }if ( (cur > 0)) System.out.println(-1); else {System.out.println(num); }} }catch (IOException e){ e.printStackTrace(); } } public static String readLine()throws IOException { return br.readLine();} public static int[] readIntArr()throws IOException { String[] str = br.readLine().split(" ");  int arr[] = new int[str.length]; for ( int i = 0;(i < arr.length);i++) arr[i] = Integer.parseInt(str[i]); return arr;} }
5	public class A implements Runnable{ final boolean LOCAL = (System.getProperty("ONLINE_JUDGE") == null); BufferedReader in ; PrintWriter out ; StringTokenizer tok ; public static void main( String[] args){ new Thread(null,new A(),"",((256 * 1024) * 1024)).start(); } String readString()throws IOException { while(!tok.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) return null; tok = new StringTokenizer(line); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} 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.sort(a); for ( int need = 0;(need <= n);need++) { int cnt = k; for ( int i = 0;(i < need);i++) {cnt += (a[((n - i) - 1)] - 1); }if ( (cnt >= m)) {out.println(need); return ;} }out.println(-1); } }
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(); } }
1	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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  List<Clause> clauses = new ArrayList<Clause>();  int[] p = new int[n];  Map<Integer,Integer> id = new HashMap<>(); for ( int i = 0;(i < n);i++) {p[i] = in.nextInt(); id.put(p[i],i); }for ( int i = 0;(i < n);i++) { int x = p[i];  Integer j = id.get((a - x)); if ( (j == null)) {clauses.add(new Clause(i,i,true,false)); } else {clauses.add(new Clause(i,j,true,true)); clauses.add(new Clause(j,i,false,false)); }j = id.get((b - x)); if ( (j == null)) {clauses.add(new Clause(i,i,false,true)); } else {clauses.add(new Clause(i,j,false,false)); clauses.add(new Clause(j,i,true,true)); }} SAT2Solver solver = new SAT2Solver(n); if ( !solver.solve(clauses)) {out.println("NO"); return ;} out.println("YES"); for ( int i = 0;(i < n);i++) {if ( (i > 0)) {out.print(" "); } if ( solver.isTrue[i]) {out.print(0); } else {out.print(1); }}out.println(); } class Clause{ int v1 ,v2 ; boolean neg1 ,neg2 ; Clause( int v1, int v2, boolean pos1, boolean pos2){ this.v1 = v1; this.v2 = v2; this.neg1 = !pos1; this.neg2 = !pos2; } } class SAT2Solver{ List<Integer>[] g ; boolean[] isTrue ; int n ; int numComps ; int[] low ; int[] vis ; int[] comp ; boolean[] onStack ; int[] stack ; int sp ; int globalTime ; SAT2Solver( int n){ this.n = n; isTrue = new boolean[(2 * n)]; vis = new int[(2 * n)]; low = new int[(2 * n)]; stack = new int[(2 * n)]; comp = new int[(2 * n)]; onStack = new boolean[(2 * n)]; g = new List[(2 * n)]; } public boolean solve( List<Clause> clauses){ for ( int i = 0;(i < (2 * n));i++) {g[i] = new ArrayList<Integer>(); }for ( Clause clause :clauses) { int v1 = clause.v1;  int v2 = clause.v2;  boolean neg1 = clause.neg1;  boolean neg2 = clause.neg2; if ( neg1) {v1 = negate(v1); } if ( neg2) {v2 = negate(v2); } g[v1].add(v2); }Arrays.fill(vis,-1); Arrays.fill(onStack,false); sp = 0; globalTime = 0; numComps = 0; for ( int i = 0;(i < (2 * n));i++) {if ( (vis[i] < 0)) {dfsTarjan(i); } } int[] firstInComp = new int[numComps]; Arrays.fill(firstInComp,-1); int[] nextSameComp = new int[(2 * n)]; for ( int i = 0;(i < (2 * n));i++) { int c = comp[i]; nextSameComp[i] = firstInComp[c]; firstInComp[c] = i; } List<Integer>[] invertedCompEdges = new List[numComps]; for ( int i = 0;(i < numComps);i++) {invertedCompEdges[i] = new ArrayList<Integer>(); }for ( int i = 0;(i < (2 * n));i++) {for ( int j :g[i]) {invertedCompEdges[comp[j]].add(comp[i]); }} boolean[] compIsTrue = new boolean[numComps]; Arrays.fill(compIsTrue,true); for ( int c = 0;(c < numComps);c++) {if ( !compIsTrue[c]) {continue;} for ( int i = firstInComp[c];(i >= 0);i = nextSameComp[i]) { int nc = comp[negate(i)]; if ( (c == nc)) {return false;} }for ( int i = firstInComp[c];(i >= 0);i = nextSameComp[i]) { int nc = comp[negate(i)]; dfsReject(nc,invertedCompEdges,compIsTrue); }}for ( int i = 0;(i < (2 * n));i++) {isTrue[i] = compIsTrue[comp[i]]; }for ( int i = 0;(i < n);i++) {if ( (isTrue[i] && isTrue[negate(i)])) {throw (new AssertionError());} if ( (!isTrue[i] && !isTrue[negate(i)])) {return false;} }return true;} private int negate( int i){ return (i + ((i < n)?n:-n));} private void dfsReject( int c, List<Integer>[] invertedCompEdges, boolean[] compIsTrue){ if ( !compIsTrue[c]) {return ;} compIsTrue[c] = false; for ( int p :invertedCompEdges[c]) {dfsReject(p,invertedCompEdges,compIsTrue); }} void dfsTarjan( int v){ vis[v] = globalTime; low[v] = globalTime; ++globalTime; stack[sp++] = v; onStack[v] = true; for ( int u :g[v]) {if ( (vis[u] < 0)) {dfsTarjan(u); if ( (low[v] > low[u])) {low[v] = low[u]; } } else if ( (onStack[u] && (low[v] > vis[u]))) {low[v] = vis[u]; } }if ( (low[v] == vis[v])) {while(true){ int u = stack[--sp]; onStack[u] = false; comp[u] = numComps; if ( (u == v)) {break;} }++numComps; } } } } 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{ String rl = in.readLine(); if ( (rl == null)) {return null;} st = new StringTokenizer(rl); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
2	@SuppressWarnings("unchecked") public class P1177B{ public void run()throws Exception { for ( long k = (nextLong() - 1),d = 1,dc = 9,sv = 1;true;k -= dc,d++,sv *= 10,dc = (((sv * 10) - sv) * d)) {if ( (k <= dc)) {println(Long.toString((sv + (k / d))).charAt((int)(k % d))); break;} }} public static void main( String... args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedOutputStream(System.out)); new P1177B().run(); br.close(); pw.close(); System.err.println((("\n[Time : " + (System.currentTimeMillis() - startTime)) + " ms]")); long gct = 0,gcc = 0; for ( GarbageCollectorMXBean garbageCollectorMXBean :ManagementFactory.getGarbageCollectorMXBeans()) {gct += garbageCollectorMXBean.getCollectionTime(); gcc += garbageCollectorMXBean.getCollectionCount(); }System.err.println((((("[GC time : " + gct) + " ms, count = ") + gcc) + "]")); } 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();} void flush(){ pw.flush(); } }
6	public class Main{ public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } void solve(){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ScanReader in = new ScanReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  E2RotateColumnsHardVersion solver = new E2RotateColumnsHardVersion();  int testCount = in.scanInt(); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class E2RotateColumnsHardVersion{ int[][] dp ; int[] cur ; public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int m = in.scanInt();  int[][] ar = new int[n][m];  int[][] max = new int[m][2]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) ar[i][j] = in.scanInt(); }for ( int i = 0;(i < m);i++) {for ( int j = 0;(j < n);j++) {max[i][0] = Math.max(max[i][0],ar[j][i]); }max[i][1] = i; }CodeHash.shuffle(max); Arrays.sort(max,new Comparator<int[]>(){}); dp = new int[2][(1 << n)]; cur = new int[(1 << n)]; for ( int i = 0;(i < Math.min(m,n));i++) {Arrays.fill(cur,0); Arrays.fill(dp[(i & 1)],0); for ( int j = 0;(j < (1 << n));j++) {for ( int k = 0;(k < n);k++) { int sum = 0; for ( int l = 0;(l < n);l++) {if ( ((j & (1 << l)) != 0)) {sum += ar; } }cur[j] = Math.max(cur[j],sum); }}for ( int j = 0;(j < (1 << n));j++) {for ( int k = j;;k = ((k - 1) & j)) {dp[(i & 1)][j] = Math.max(dp[(i & 1)][j],(dp[((i - 1) & 1)][k] + cur[(j ^ k)])); if ( (k == 0)) break; }}}out.println(dp[((Math.min(n,m) & 1) ^ 1)][((1 << n) - 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
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);} } }
5	public class A{ public static void main( String[] args)throws Exception { new A().run(); } void run()throws Exception { BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(sc.readLine());  ArrayList<Integer> a = new ArrayList<Integer>();  StringTokenizer st = new StringTokenizer(sc.readLine()," ");  boolean allOne = true; for ( int i = 0;(i < n);i++) { int val = Integer.parseInt(st.nextToken()); if ( (val != 1)) allOne = false; a.add(val); }if ( allOne) {a.remove((n - 1)); a.add(2); } else a.add(1); Collections.sort(a); System.out.print(a.get(0)); for ( int i = 1;(i < n);i++) System.out.print((" " + a.get(i))); System.out.println(); } }
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());} } }
3	public class Newbie{ static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ solver s = new solver();  int t = 1; while((t > 0)){s.solve(); t--; }out.close(); } static class InputReader{ public BufferedReader br ; public StringTokenizer token ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream),32768); token = null; } public String next(){ while(((token == null) || !token.hasMoreTokens())){try{token = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return token.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } static long m = ((long)1e9 + 7); static class solver{ void solve(){ int n = sc.nextInt();  int ans = 0;  int a[] = new int[(2 * n)]; for ( int i = 0;(i < (2 * n));i++) {a[i] = sc.nextInt(); }for ( int i = 0;(i < (2 * n));i++) {if ( (a[i] > 0)) { int j = 0; for ( j = (i + 1);(a[i] != a[j]);j++) {if ( (a[j] > 0)) ans++; }a[j] = 0; } }System.out.println(ans); } } }
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(); } }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer split = new StringTokenizer(in.readLine());  int n = Integer.parseInt(split.nextToken());  double t = Double.parseDouble(split.nextToken());  House[] xaxis = new House[n]; for ( int i = 0;(i < n);i++) {split = new StringTokenizer(in.readLine()); xaxis[i] = new House(Double.parseDouble(split.nextToken()),Double.parseDouble(split.nextToken())); }Arrays.sort(xaxis); int count = 2; for ( int i = 0;(i < (xaxis.length - 1));i++) { double free = ((xaxis[(i + 1)].getX() - (xaxis[(i + 1)].getSize() / 2.0)) - (xaxis[i].getX() + (xaxis[i].getSize() / 2.0))); if ( ((free / t) == 1.0)) {count++; } else if ( ((free / t) > 1.0)) {count += 2; } }System.out.println(count); } } class House implements Comparable<House>{ private double x ; private double size ; public House( double x, double size){ this.x = x; this.size = size; } public double getX(){ return x;} public double getSize(){ return size;} }
3	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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, Input in, PrintWriter out){ try{ int n = in.readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.readInt(); }Arrays.sort(a); boolean[] b = new boolean[n];  int ans = 0; while(true){ int x = 0; for ( int i = 0;(i < n);i++) {if ( (!b[i] && (x == 0))) {x = a[i]; } if ( ((x != 0) && ((a[i] % x) == 0))) {b[i] = true; } }if ( (x == 0)) {break;} 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 ;} }} } }
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 P220A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] a = new int[n];  List<Integer> b = new ArrayList<Integer>(n); for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); b.add(a[i]); }Collections.sort(b); int c = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b.get(i))) c++; }if ( ((c == 0) || (c == 2))) {System.out.println("YES"); } else {System.out.println("NO"); }} }
4	public class Practice{ public static long mod = ((long)Math.pow(10,9) + 7); public static long tt = 0; public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  int c = 1;  int t = Integer.parseInt(br.readLine()); while((t-- > 0)){ int n = Integer.parseInt(br.readLine());  HashMap<Integer,Integer> map = new HashMap<>();  int curr = 0; for ( int i = 0;(i < n);i++) { int tt = Integer.parseInt(br.readLine()); if ( (tt == 1)) {curr++; map.put(curr,1); } else { ArrayList<Integer> list = new ArrayList<Integer>(map.keySet()); Collections.sort(list); for ( int a = (list.size() - 1);(a >= 0);a--) {if ( (map.get(list.get(a)) == (tt - 1))) {map.put(list.get(a),tt); break;} else {curr--; map.remove(list.get(a)); }}} ArrayList<Integer> list = new ArrayList<Integer>(map.keySet()); Collections.sort(list); StringBuilder str = new StringBuilder(); for ( int a = 0;(a < list.size());a++) {if ( ((list.size() - 1) == a)) {str.append(map.get(list.get(a))); continue;} str.append((map.get(list.get(a)) + ".")); }pw.println(str); }}pw.close(); } }
6	public class D{ Reader in = new Reader(System.in); PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws IOException { new D().run(); } int n ,m ; boolean[][] adjacency ; void run()throws IOException { n = in.nextInt(); m = in.nextInt(); adjacency = new boolean[(n + 1)][n]; for ( int i = 0;(i < m);i++) { int u = in.nextInt(),v = in.nextInt(); adjacency[(u - 1)][(v - 1)] = adjacency[(v - 1)][(u - 1)] = true; }final int MASK_BOUND = (1 << n);  long[][] dp = new long[MASK_BOUND][n]; for ( int i = 0;(i < n);i++) dp[(1 << i)][i] = 1; long sum = 0; for ( int mask = 1;(mask < MASK_BOUND);mask++) { int lowestVertex = (int)(Math.log(lowest(mask)) / Math.log(2)); for ( int i = 0;(i < n);i++) {if ( (bit(i,mask) && (i != lowestVertex))) {for ( int j = 0;(j < n);j++) {if ( adjacency[j][i]) {dp[mask][i] += dp[(mask ^ (1 << i))][j]; } }if ( ((count(mask) >= 3) && adjacency[lowestVertex][i])) sum += dp[mask][i]; } else {}}}out.println((sum / 2)); out.flush(); } int count( int mask){ int count = 0; while((mask > 0)){if ( ((mask & 1) == 1)) count++; mask >>= 1; }return count;} int lowest( int mask){ return (mask & mask);} boolean bit( int index, int mask){ return (((1 << index) & mask) > 0);} 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());} } }
0	public class Main implements Runnable{ public static void main( String[] args){ new Thread(new Main()).start(); } double nextDouble( StreamTokenizer st)throws IOException { st.nextToken(); return st.nval;} Map<String,BigInteger> map = new HashMap<String,BigInteger>(); public void run1()throws IOException { Locale.setDefault(Locale.US); Scanner sc = new Scanner(new InputStreamReader(System.in));  double a = sc.nextDouble();  double vmax = sc.nextDouble();  double l2 = sc.nextDouble();  double l1 = sc.nextDouble(); l2 -= l1; double boundv = sc.nextDouble(); if ( ((boundv >= vmax) || ((((boundv * boundv) / a) / 2) > l1))) {System.out.print(get(0,a,vmax,(l1 + l2))); System.exit(0); } double tmplen = ((((vmax * vmax) / a) / 2) + ((((vmax + boundv) / 2) * (vmax - boundv)) / a)); if ( (tmplen < l1)) {System.out.print((((get(boundv,a,vmax,l2) + (vmax / a)) + ((vmax - boundv) / a)) + ((l1 - tmplen) / vmax))); System.exit(0); } double v = Math.sqrt(((l1 * a) + ((boundv * boundv) / 2))); System.out.print(((get(boundv,a,vmax,l2) + (v / a)) + ((v - boundv) / a))); } double get( double v0, double a, double vmax, double l){ double tmplen = ((((vmax + v0) / 2) * (vmax - v0)) / a); if ( (l >= tmplen)) {return (((vmax - v0) / a) + ((l - tmplen) / vmax));} return ((-v0 + Math.sqrt(((v0 * v0) + ((2 * a) * l)))) / a);} }
1	public class C43 implements Runnable{ public Scanner in ; public PrintWriter out ; static final String TASK_NAME = ""; C43()throws IOException{ in = new Scanner(System.in); out = new PrintWriter(System.out); } void close()throws IOException { out.close(); } public void solve()throws IOException { int n = in.nextInt();  char[] c = in.next().toCharArray();  int t = 0; for ( int i = 0;(i < n);i++) {if ( (c[i] == 'T')) {t++; } } int ct = 0; for ( int i = 0;(i < t);i++) {if ( (c[i] == 'T')) {ct++; } } int r = 0; for ( int i = 0;(i < n);i++) {r = Math.max(r,ct); if ( (c[i] == 'T')) {ct--; } if ( (c[((i + t) % n)] == 'T')) {ct++; } }out.println((t - r)); } public static void main( String[] args)throws IOException { new Thread(new C43()).start(); } }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong(); if ( ((n == 1) || (n == 2))) {System.out.println(n); } else if ( ((n % 2) == 0)) {if ( ((n % 3) == 0)) System.out.println((((n - 1) * (n - 2)) * (n - 3))); else System.out.println(((n * (n - 1)) * (n - 3))); } else {System.out.println(((n * (n - 1)) * (n - 2))); }} }
1	public final class round_364_c{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc = new FastScanner(br); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws Exception { int n = sc.nextInt();  char[] arr = sc.next().toCharArray();  int[] sum = new int[123];  int[][] pre = new int[123][(n + 1)];  char[] a = new char[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = arr[(i - 1)]; } boolean[] v = new boolean[123]; for ( int i = 1;(i <= n);i++) {sum[a[i]]++; v[a[i]] = true; for ( int j = 65;(j <= 90);j++) {pre[j][i] = sum[j]; }for ( int j = 97;(j <= 122);j++) {pre[j][i] = sum[j]; }} long min = Integer.MAX_VALUE; for ( int i = 1;(i <= n);i++) { int low = 0,high = ((n - i) + 1);  boolean got = false; while((low < high)){ int mid = ((low + high) >> 1);  boolean curr = true; for ( int j = 65;(j <= 90);j++) {if ( v[j]) {if ( ((pre[j][(i + mid)] - pre[j][(i - 1)]) <= 0)) {curr = false; break;} } }for ( int j = 97;(j <= 122);j++) {if ( v[j]) {if ( ((pre[j][(i + mid)] - pre[j][(i - 1)]) <= 0)) {curr = false; break;} } }if ( curr) {got = true; high = mid; } else {low = (mid + 1); }}if ( got) {min = Math.min(min,(((i + low) - i) + 1)); } }out.println(min); 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());} }
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();} } }
3	public class D{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt();  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = nextInt(); } int inv = 0; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j < i);j++) {if ( (a[j] > a[i])) inv++; }} int m = nextInt();  boolean odd = ((inv % 2) == 1); for ( int i = 0;(i < m);i++) { int left = nextInt();  int right = nextInt();  long k = ((right - left) + 1); if ( ((((k * (k - 1)) / 2) % 2) == 1)) odd = !odd; if ( odd) pw.println("odd"); else pw.println("even"); }pw.close(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
2	public class code{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int ok ,ok2 ;  int va ,vb ; va = 0; vb = 0; out.println(((("? " + va) + " ") + vb)); out.flush(); ok = sc.nextInt(); for ( int i = 29;(i >= 0);i--) {if ( (ok == 0)) {va += (1 << i); out.println(((("? " + va) + " ") + vb)); out.flush(); ok2 = sc.nextInt(); if ( (ok2 == 1)) {va -= (1 << i); } else {vb += (1 << i); }} else {va += (1 << i); vb += (1 << i); out.println(((("? " + va) + " ") + vb)); out.flush(); ok2 = sc.nextInt(); if ( (ok == ok2)) {vb -= (1 << i); out.println(((("? " + va) + " ") + vb)); out.flush(); ok2 = sc.nextInt(); if ( (ok2 == 1)) {va -= (1 << i); } else {vb += (1 << i); }} else {if ( (ok == 1)) {vb -= (1 << i); out.println(((("? " + va) + " ") + vb)); out.flush(); ok = sc.nextInt(); } else {va -= (1 << i); out.println(((("? " + va) + " ") + vb)); out.flush(); ok = sc.nextInt(); }}}}out.println(((("! " + va) + " ") + vb)); out.flush(); } }
6	public class a implements Runnable{ public static void main( String[] args){ new Thread(null,new a(),"process",(1 << 26)).start(); } static class Task{ static final int inf = Integer.MAX_VALUE; public void solve( int testNumber, FastReader sc, PrintWriter pw){ int n = sc.nextInt();  int[][] arr = new int[n][];  long sums[] = new long[n];  HashMap<Integer,Integer> map1 = new HashMap<>();  HashMap<Integer,Integer> map2 = new HashMap<>();  ArrayList<Integer> arrs = new ArrayList<Integer>(); arrs.add(0); int incc = 1;  long sum = 0; for ( int i = 0;(i < n);i++) { int k = sc.nextInt(); arr[i] = new int[k]; for ( int j = 0;(j < k);j++) {sum += arr[i][j] = sc.nextInt(); sums[i] += arr[i][j]; map1.put(arr[i][j],incc++); map2.put(arr[i][j],i); arrs.add(arr[i][j]); }}if ( ((sum % n) != 0)) {pw.println("No"); return ;} cycle[] masktocyc = new cycle[(1 << n)];  long goal = (sum / n);  ArrayList<cycle> cycs = new ArrayList<cycle>();  int[] graph = new int[incc]; for ( int i = 1;(i < incc);i++) { cycle c = new cycle();  int curr = i;  int val = arrs.get(i);  int ind = map2.get(val); if ( (graph[i] != 0)) continue; do { long ch = ((goal - sums[ind]) + val); if ( (((ch > inf) || (ch < -inf)) || !map1.containsKey((int)ch))) {continue l;} val = (int)ch; graph[curr] = map1.get(val); curr = map1.get(val); c.add(ind,val); ind = map2.get(val); }while((graph[curr] == 0));for ( tup x :c.arr) {if ( (((sums[x.a] - arrs.get(curr)) + x.b) == goal)) break; c.mask -= (1 << x.a); x.a = -inf; x.b = -inf; } int[] freq = new int[15]; for ( tup x :c.arr) {if ( (x.a >= 0)) {freq[x.a]++; if ( (freq[x.a] > 1)) continue l; } }cycs.add(c); masktocyc[c.mask] = c; } ArrayList<cycle>[] dp = new ArrayList[(1 << n)]; for ( int m = 0;(m < (1 << n));m++) {dp[m] = new ArrayList<cycle>(); if ( (masktocyc[m] != null)) {dp[m].add(masktocyc[m]); continue;} for ( int s = m;(s > 0);s = ((s - 1) & m)) {if ( ((dp[s].size() > 0) && (dp[(m ^ s)].size() > 0))) {dp[m].addAll(dp[s]); dp[m].addAll(dp[(m ^ s)]); break;} }}if ( (dp[((1 << n) - 1)].size() > 0)) {pw.println("Yes"); int[] ans1 = new int[n];  int[] ans2 = new int[n]; for ( cycle x :dp[((1 << n) - 1)]) {for ( tup y :x.arr) {if ( (y.b != -inf)) {ans1[map2.get(y.b)] = (y.a + 1); ans2[map2.get(y.b)] = y.b; } }}for ( int i = 0;(i < n);i++) {pw.printf("%d %d%n",ans2[i],ans1[i]); }} else pw.println("No"); } static class cycle{ ArrayList<tup> arr = new ArrayList<>(); int mask = 0; public cycle(){ } void add( int ind, int val){ arr.add(new tup(ind,val)); mask += (1 << ind); } } } static void sort( int[] x){ shuffle(x); Arrays.sort(x); } static void sort( long[] x){ shuffle(x); Arrays.sort(x); } static class tup implements Comparable<tup>{ int a ,b ; tup( int a, int b){ this.a = a; this.b = b; } } static void shuffle( int[] a){ Random get = new Random(); for ( int i = 0;(i < a.length);i++) { int r = get.nextInt((i + 1));  int temp = a[i]; a[i] = a[r]; a[r] = temp; }} static void shuffle( long[] a){ Random get = new Random(); for ( int i = 0;(i < a.length);i++) { int r = get.nextInt((i + 1));  long temp = a[i]; a[i] = a[r]; a[r] = temp; }} 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());} } }
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();  int k = in.nextInt();  long top = (((((1L * k) * (k + 1)) / 2L) - k) + 1); if ( (n == 1L)) {out.print(0); return ;} if ( (n > top)) {out.print(-1); return ;} int ans = 0; if ( (n > 0)) {++ans; n -= k; k -= 2; } while((n > 0)){++ans; n -= k; k--; }out.print(ans); } }
6	public class Main implements Runnable{ private void solution()throws IOException { int n = in.nextInt();  int m = in.nextInt();  boolean[][] adj = new boolean[n][n];  long res = 0; for ( int i = 0;(i < m);++i) { int x = in.nextInt();  int y = in.nextInt(); adj[(x - 1)][(y - 1)] = true; adj[(y - 1)][(x - 1)] = true; }final long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);++i) { int Limit = (1 << (n - i));  int nn = (n - i); for ( int mask = 0;(mask < Limit);++mask) {for ( int j = 0;(j < nn);++j) {dp[mask][j] = 0; }}dp[0][0] = 1; for ( int mask = 0;(mask < Limit);++mask) {if ( ((mask & 1) == 0)) {for ( int j = 0;(j < nn);++j) {if ( (dp[mask][j] != 0)) { long am = dp[mask][j]; for ( int k = 0;(k < nn);++k) {if ( ((((mask >> k) & 1) == 0) && adj[(j + i)][(k + i)])) {dp[(mask | (1 << k))][k] += am; } }} }} else {res += dp[mask][0]; }}}out.println(((res - m) / 2)); } private class Scanner{ BufferedReader reader ; 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)); }
1	public class C implements Runnable{ static private final boolean USE_FILE_IO = false; static private final String FILE_IN = "c.in"; static private final String FILE_OUT = "c.out"; BufferedReader in ; PrintWriter out ; StringTokenizer tokenizer = new StringTokenizer(""); public static void main( String[] args){ new Thread(new C()).start(); } int n ,h ,t ; char[] c ; private void solve()throws IOException { n = nextInt(); c = nextToken().toCharArray(); if ( (c.length != n)) {throw (new IllegalStateException());} for ( char l :c) if ( (l == 'H')) {h++; } t = (n - h); if ( (h == 0)) {out.print(0); return ;} int answer = Integer.MAX_VALUE; for ( int hLo = 0;(hLo < n);hLo++) if ( (c[hLo] == 'H')) { int hHi = ((hLo + h) % n);  int current = 0;  int j = hLo; while((j != hHi)){if ( (c[j] == 'T')) {current++; } j = ((j + 1) % n); }answer = Math.min(answer,current); } out.print(answer); } private String nextToken()throws IOException { while(!tokenizer.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} tokenizer = new StringTokenizer(line); }return tokenizer.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
4	public class temp{ public static void main( String[] str){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int arr[][] = new int[n][m];  int cross[][] = new int[n][(m - 1)];  int up[][] = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {cross[i][j] = sc.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {up[i][j] = sc.nextInt(); }} int[][] fans = new int[n][m]; if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {fans[i][j] = -1; }}} else { int[][][] ans = new int[((k / 2) + 1)][n][m]; for ( int l = 1;(l <= (k / 2));l++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int min = Integer.MAX_VALUE; if ( (i > 0)) {min = Math.min(min,(up[(i - 1)][j] + ans[(l - 1)][(i - 1)][j])); } if ( (j > 0)) {min = Math.min(min,(cross[i][(j - 1)] + ans[(l - 1)][i][(j - 1)])); } if ( (i < (n - 1))) {min = Math.min(min,(up[i][j] + ans[(l - 1)][(i + 1)][j])); } if ( (j < (m - 1))) {min = Math.min(min,(cross[i][j] + ans[(l - 1)][i][(j + 1)])); } ans[l][i][j] = min; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {fans[i][j] = (2 * ans[(k / 2)][i][j]); }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print((fans[i][j] + " ")); }System.out.println(); }} }
3	public class GFG{ static int count = 0; public static void main( String[] args){ Scanner ob = new Scanner(System.in);  int n ;  long MOD = (long)(1e9 + 7);  int f = 0,s = 0; n = ob.nextInt(); long dp[][] = new long[(n + 2)][(n + 2)]; dp[0][1] = 1; char ch = 's';  char p ; for ( int i = 1;(i <= n);i++) {p = ch; ch = ob.next().charAt(0); if ( (p == 'f')) {for ( int j = 1;(j <= n);j++) dp[i][(j + 1)] = dp[(i - 1)][j]; } else {for ( int j = n;(j > 0);j--) {dp[i][j] = ((dp[i][(j + 1)] + dp[(i - 1)][j]) % MOD); }}} long ans = 0; for ( int i = 1;(i <= n);i++) {ans = ((ans + dp[n][i]) % MOD); }System.out.println(ans); } }
1	public class C{ 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());  int counter = 0; for ( int i = 0;(i < ((2 * n) / 3));i++) System.out.println(("0 " + i)); for ( int i = 0;(i < (n - ((2 * n) / 3)));i++) System.out.println(("3 " + ((2 * i) + 1))); } }
3	public class Codeforces908C{ 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 r = Integer.parseInt(st.nextToken());  int[] x = new int[n]; st = new StringTokenizer(f.readLine()); for ( int i = 0;(i < n);i++) {x[i] = Integer.parseInt(st.nextToken()); } double[] y = new double[n]; y[0] = r; double hypSq = ((4 * r) * r); for ( int i = 1;(i < n);i++) { boolean hit = false;  double maxY = 0; for ( int j = 0;(j < i);j++) { int dx = Math.abs((x[i] - x[j])); if ( (dx == (2 * r))) {if ( (y[j] > maxY)) {maxY = y[j]; hit = true; } } else if ( (dx < (2 * r))) { double newY = (y[j] + Math.sqrt((hypSq - (dx * dx)))); if ( (newY > maxY)) {maxY = newY; hit = true; } } }if ( !hit) {y[i] = r; } else {y[i] = maxY; }} StringBuffer s = new StringBuffer(""); for ( int i = 0;(i < n);i++) {s.append((y[i] + " ")); }System.out.println(s.toString().trim()); } }
2	public class candies{ public void run()throws Exception { Scanner file = new Scanner(System.in);  int actions = file.nextInt();  int left = file.nextInt();  int start = 0;  int c = 1; while(true){start += c; if ( ((c + (start - left)) == actions)) break; c++; }System.out.println((start - left)); } public static void main( String[] args)throws Exception { new candies().run(); } }
0	public class Main implements Runnable{ private final String problemname = ""; private final String FILE_IN = (problemname + ".in"); private final String FILE_OUT = (problemname + ".out"); BufferedReader in ; PrintWriter out ; StringTokenizer _st ; public static void main( String[] args){ new Thread(new Main()).start(); } private void seek(){ while(!_st.hasMoreTokens()){ String s ; try{s = in.readLine(); _st = new StringTokenizer(s); }catch (Exception e){ return ;} }} private String next(){ seek(); return _st.nextToken();} private int nextInt(){ return Integer.parseInt(next());} }
3	public class C{ static private int[][][] dp ; static private boolean[] wasLoop ; static private int MOD = 1000000007; static private int n ; public static void solve( FastScanner fs){ n = fs.nextInt(); dp = new int[2][n][n]; for ( int i = 0;(i < dp.length);i++) for ( int j = 0;(j < dp[i].length);j++) Arrays.fill(dp[i][j],-1); wasLoop = new boolean[n]; for ( int i = 0;(i < n);i++) wasLoop[i] = fs.next().equals("f"); int ans = go(0,0,0); System.out.println(ans); } static private int go( int firstInLoop, int index, int indentLevel){ if ( (index >= n)) return 1; if ( (dp[firstInLoop][index][indentLevel] != -1)) return dp[firstInLoop][index][indentLevel]; if ( (firstInLoop == 1)) return dp[firstInLoop][index][indentLevel] = go((wasLoop[index]?1:0),(index + 1),(indentLevel + (wasLoop[index]?1:0))); if ( (indentLevel == 0)) {return dp[firstInLoop][index][indentLevel] = go((wasLoop[index]?1:0),(index + 1),(wasLoop[index]?1:0));} else { int total = 0; total += go(firstInLoop,index,(indentLevel - 1)); total += go((wasLoop[index]?1:0),(index + 1),(indentLevel + (wasLoop[index]?1:0))); total %= MOD; return dp[firstInLoop][index][indentLevel] = total;}} public static void main( String[] args)throws NumberFormatException,IOException { FastScanner scanner = new FastScanner(System.in); solve(scanner); } static private 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());} } }
1	public class A_IQTest{ static int n ; public static void main( String[] args){ Scanner s = new Scanner(System.in); n = s.nextInt(); int[] nums = new int[n]; for ( int i = 0;(i < n);i++) {nums[i] = s.nextInt(); } int ei = -1;  int oi = -1;  int ecnt = 0;  int ocnt = 0; for ( int i = 0;(i < n);i++) {if ( ((nums[i] % 2) == 0)) {ei = i; ecnt++; } else {oi = i; ocnt++; }}if ( (ecnt == 1)) {System.out.println((ei + 1)); } else {System.out.println((oi + 1)); }} }
0	public class a{ public static void main( String[] args)throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out);  long n = input.nextLong(); if ( (n == 1)) out.println(5); else out.println(25); out.close(); } }
0	public class CF125D2A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); System.out.println(("0 0 " + sc.nextInt())); } }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}candidate = new int[n]; xs = new Xorshift(); mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; int[] candidate ; Xorshift xs ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {if ( (Long.bitCount(choosed) < Long.bitCount(mds))) mds = choosed; return ;} int index = 0;  int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) {index = 0; candidate[index++] = i; k = i; } else if ( (Long.bitCount((g[i] & ~covered)) == Long.bitCount((g[k] & ~covered)))) {candidate[index++] = i; } }if ( (k == -1)) return ; k = candidate[xs.nextInt(index)]; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } class Xorshift{ int x ,y ,z ,w ; public Xorshift(){ x = 123456789; y = 362436069; z = 521288629; w = 88675123; } public Xorshift( int seed){ x = _(seed,0); y = _(x,1); z = _(y,2); w = _(z,3); } int _( int s, int i){ return (((1812433253 * (s ^ (s >>> 30))) + i) + 1);} public int nextInt(){ int t = (x ^ (x << 11)); x = y; y = z; z = w; return w = (((w ^ (w >>> 19)) ^ t) ^ (t >>> 8));} public int nextInt( int n){ return (int)(n * nextDouble());} public double nextDouble(){ int a = (nextInt() >>> 5),b = (nextInt() >>> 6); return (((a * 67108864.0) + b) * (1.0 / (1L << 53)));} } 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 P111C().run(); } }
1	public class Main{ public static void main( String[] args)throws IOException { open("input.txt","output.txt",false,true); char[] alph = " ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();  Pattern pat = Pattern.compile("[A-Z]+[\\d]+");  Matcher mat ;  boolean b ;  String s ;  int index ,coef ,row ,col ;  int n = nextInt();  String[] tmp ;  char[] c ; for ( int i = 0;(i < n);i++) {s = nextLine(); c = s.toCharArray(); mat = pat.matcher(s); b = mat.matches(); if ( b) {index = (c.length - 1); coef = 1; row = 0; while(((c[index] >= '0') && (c[index] <= '9'))){row += ((c[index] - '0') * coef); coef *= 10; index--; }coef = 1; col = 0; while((index >= 0)){col += (Arrays.binarySearch(alph,c[index]) * coef); coef *= 26; index--; }out.println(((("R" + row) + "C") + col)); } else {tmp = s.split("R|C"); col = Integer.parseInt(tmp[2]); char[] temp = new char[10];  int len = 0;  int v = 0; while((col > 0)){index = (col % 26); if ( (index == 0)) {index = 26; v = 1; } else v = 0; temp[len] = alph[index]; col = ((col / 26) - v); len++; }for ( int j = (len - 1);(j >= 0);j--) {out.print(temp[j]); }out.println(tmp[1]); }}close(); } static StringTokenizer st ; static StreamTokenizer strTok ; static BufferedReader in ; static PrintWriter out ; static String nextToken( boolean f)throws IOException { if ( f) {return in.readLine();} else {while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();}} static String nextLine()throws IOException { return nextToken(true);} static int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken(false));} static void close(){ out.flush(); out.close(); } static void open( String filein, String fileout, boolean flag, boolean console)throws IOException { if ( flag) {strTok = new StreamTokenizer(new FileReader(new File(filein))); in = new BufferedReader(new FileReader(new File(filein))); out = new PrintWriter(new FileWriter(new File(fileout))); } else {if ( console) {strTok = new StreamTokenizer(new InputStreamReader(System.in,"ISO-8859-1")); in = new BufferedReader(new InputStreamReader(System.in,"ISO-8859-1")); out = new PrintWriter(new OutputStreamWriter(System.out,"ISO-8859-1")); } else {strTok = new StreamTokenizer(new FileReader(new File("input.txt"))); in = new BufferedReader(new FileReader(new File("input.txt"))); out = new PrintWriter(new FileWriter(new File("output.txt"))); }}} }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); System.out.println((n + (n / 2))); } }
1	public class a{ public static void main( String[] args){ 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() % 2); int z = 0; for ( int i = 0;(i < n);i++) z += ((a[i] == 0)?1:0); if ( (z == 1)) z = 0; else z = 1; for ( int i = 0;(i < n);i++) if ( (a[i] == z)) {System.out.println((i + 1)); break;} } }
2	public class R574B{ public static void main( String[] args){ JS scan = new JS();  long n = scan.nextInt();  long put = 1;  long k = scan.nextInt();  long have = 0;  long moves = 0; while((have < k)){have += put; put++; moves++; } long ans = 0; moves += (have - k); ans += (have - k); long lo = 0;  long hi = (n - moves);  long bs = 0; while((lo <= hi)){ long mid = ((lo + hi) / 2);  long left = ((((n - moves) - mid) + put) - 1);  long rr = (tri(left) - tri(put)); if ( (rr <= mid)) {bs = mid; hi = (mid - 1); } else {lo = (mid + 1); }}System.out.println((ans + bs)); } static long tri( long n){ return ((n * (n - 1)) / 2);} 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);} } }
2	public class Problem2 implements Runnable{ public void run(){ Scanner scanner = new Scanner(System.in);  PrintWriter writer = new PrintWriter(System.out);  long n = scanner.nextLong();  long k = scanner.nextLong();  long count = 1; if ( (n == 1)) {writer.println(0); writer.close(); return ;} if ( (k >= n)) {writer.println(1); writer.close(); return ;} long answer = 0; while((k > 1)){if ( (k > 2000)) {if ( ((count + k) <= n)) {if ( ((count + ((((k - 1) + k) - 1000) * 500)) <= n)) {count += ((((k - 1) + k) - 1000) * 500); k -= 1000; answer += 1000; } } } if ( (((count + k) - 1) <= n)) {count += (k - 1); answer++; } if ( (((count + k) - 100000000000000000l) > n)) {k -= 99999999999999999l; } if ( (((count + k) - 10000000000000000l) > n)) {k -= 9999999999999999l; } if ( (((count + k) - 1000000000000000l) > n)) {k -= 999999999999999l; } if ( (((count + k) - 100000000000000l) > n)) {k -= 99999999999999l; } if ( (((count + k) - 10000000000000l) > n)) {k -= 9999999999999l; } if ( (((count + k) - 1000000000000l) > n)) {k -= 999999999999l; } if ( (((count + k) - 100000000000l) > n)) {k -= 99999999999l; } if ( (((count + k) - 10000000000l) > n)) {k -= 9999999999l; } if ( (((count + k) - 1000000000l) > n)) {k -= 999999999l; } if ( (((count + k) - 100000000l) > n)) {k -= 99999999l; } if ( (((count + k) - 10000000l) > n)) {k -= 9999999l; } if ( (((count + k) - 1000000l) > n)) {k -= 999999l; } if ( (((count + k) - 100000l) > n)) {k -= 99999l; } if ( (((count + k) - 10000l) > n)) {k -= 9999l; } if ( (((count + k) - 1000l) > n)) {k -= 999l; } if ( (((count + k) - 100l) > n)) {k -= 99l; } if ( (((n - count) + 1) < k)) {k = ((n - count) + 1); } else {k--; }}if ( (count == n)) {writer.println(answer); } else {writer.println(-1); }writer.close(); } public static void main( String[] args){ new Problem2().run(); } }
0	public class A{ public static void main( String[] args){ long fib[] = {0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073L,4807526976L,7778742049L,12586269025L,20365011074L,32951280099L,53316291173L,86267571272L,139583862445L,225851433717L,365435296162L,591286729879L,956722026041L,1548008755920L,2504730781961L,4052739537881L,6557470319842L,10610209857723L};  int i = Arrays.binarySearch(fib,new Scanner(System.in).nextLong()); if ( (i < 4)) if ( (i == 3)) System.out.println("0 1 1"); else if ( (fib[i] == 1)) System.out.println("0 0 1"); else System.out.println("0 0 0"); else System.out.println(((((fib[(i - 4)] + " ") + fib[(i - 3)]) + " ") + fib[(i - 1)])); } }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long l = sc.nextLong();  long h = sc.nextLong(); sc.close(); if ( ((h - l) < 2)) {System.out.println(-1); return ;} if ( (((h - l) == 2) && ((l % 2) == 1))) {System.out.println(-1); return ;} if ( ((l % 2) == 1)) {++l; } System.out.printf("%d %d %d\n",l,(l + 1L),(l + 2L)); } }
5	public class Main{ public static void main( String[] args)throws Exception { Parserdoubt12 s = new Parserdoubt12(System.in);  int n = s.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); } int copy[] = a.clone(); Arrays.sort(a); int count = 0; for ( int i = 0;(i < copy.length);i++) {if ( (a[i] != copy[i])) count++; }if ( (count <= 2)) System.out.println("YES"); else System.out.println("NO"); } } class Parserdoubt12{ private final int BUFFER_SIZE = (1 << 17); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public Parserdoubt12( 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++];} }
3	public class code5{ InputStream is ; PrintWriter out ; static long mod = (pow(10,9) + 7); static int dx[] = {0,0,1,-1},dy[] = {1,-1,0,0}; String arr[] ; long dp[][] ; void solve()throws IOException { int n = ni();  int a[] = na(n);  int q = ni();  boolean flag = false; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( (a[j] > a[i])) flag ^= true; }}while((q-- != 0)){ int l = (ni() - 1);  int r = (ni() - 1);  int num = ((r - l) + 1);  int tot = ((num * (num - 1)) / 2); if ( ((tot % 2) == 1)) flag ^= true; if ( flag) out.println("odd"); else out.println("even"); }} ArrayList<Integer> al[] ; static long d ,x ,y ; void extendedEuclid( long A, long B){ if ( (B == 0)) {d = A; x = 1; y = 0; } else {extendedEuclid(B,(A % B)); long temp = x; x = y; y = (temp - ((A / B) * y)); }} public static void mergeSort( int[] arr, int l, int r){ if ( ((r - l) >= 1)) { int mid = ((l + r) / 2); mergeSort(arr,l,mid); mergeSort(arr,(mid + 1),r); merge(arr,l,r,mid); } } public static void merge( int[] arr, int l, int r, int mid){ int n1 = ((mid - l) + 1),n2 = (r - mid);  int left[] = new int[n1];  int right[] = new int[n2]; for ( int i = 0;(i < n1);i++) left[i] = arr[(l + i)]; for ( int i = 0;(i < n2);i++) right[i] = arr[((mid + 1) + i)]; int i = 0,j = 0,k = l; while(((i < n1) && (j < n2))){if ( (left[i] > right[j])) {arr[k++] = right[j++]; } else {arr[k++] = left[i++]; }}while((i < n1))arr[k++] = left[i++]; while((j < n2))arr[k++] = right[j++]; } public static void mergeSort( long[] arr, int l, int r){ if ( ((r - l) >= 1)) { int mid = ((l + r) / 2); mergeSort(arr,l,mid); mergeSort(arr,(mid + 1),r); merge(arr,l,r,mid); } } public static void merge( long[] arr, int l, int r, int mid){ int n1 = ((mid - l) + 1),n2 = (r - mid);  long left[] = new long[n1];  long right[] = new long[n2]; for ( int i = 0;(i < n1);i++) left[i] = arr[(l + i)]; for ( int i = 0;(i < n2);i++) right[i] = arr[((mid + 1) + i)]; int i = 0,j = 0,k = l; while(((i < n1) && (j < n2))){if ( (left[i] > right[j])) {arr[k++] = right[j++]; } else {arr[k++] = left[i++]; }}while((i < n1))arr[k++] = left[i++]; while((j < n2))arr[k++] = right[j++]; } public static long gcd( long x, long y){ if ( (y == 0)) return x; else return gcd(y,(x % y));} public static int gcd( int x, int y){ if ( (y == 0)) return x; return gcd(y,(x % y));} public static long gcdExtended( long a, long b, long[] x){ if ( (a == 0)) {x[0] = 0; x[1] = 1; return b;} long[] y = new long[2];  long gcd = gcdExtended((b % a),a,y); x[0] = (y[1] - ((b / a) * y[0])); x[1] = y[0]; return gcd;} 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;} void run()throws Exception { is = System.in; out = new PrintWriter(System.out); solve(); out.flush(); } public static void main( String[] args)throws Exception { new Thread(null,new Runnable(){public void run(){ try{new code5().run(); }catch (Exception e){ e.printStackTrace(); } } },"1",(1 << 26)).start(); } 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 long[] nl( int n){ long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nl(); 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(){ 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(); }} }
0	public class Main{ boolean eof ; public static void main( String[] args)throws IOException { new Main().run(); } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return "-1";} }return st.nextToken();} BufferedReader br ; StringTokenizer st ; PrintWriter out ; void run()throws IOException { InputStream input = System.in;  PrintStream output = System.out; try{ File f = new File("trips.in"); if ( (f.exists() && f.canRead())) {input = new FileInputStream(f); output = new PrintStream("trips.out"); } }catch (Throwable e){ } br = new BufferedReader(new InputStreamReader(input)); out = new PrintWriter(output); solve(); br.close(); out.close(); } long nextLong(){ return Long.parseLong(nextToken());} long ans ; void nod( long a, long b){ if ( ((a == 0) || (b == 0))) {} else if ( (a > b)) {ans += (a / b); nod((a % b),b); } else {ans += (b / a); nod(a,(b % a)); }} void solve(){ long a = nextLong(),b = nextLong(); ans = 0; nod(a,b); out.println(ans); } }
6	public class Fish{ double memo[] = new double[(1 << 18)]; int N ,FULL ; double prob[][] = new double[18][18]; Fish(){ Scanner in = new Scanner(System.in); Arrays.fill(memo,-1); N = in.nextInt(); FULL = ((1 << N) - 1); for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < N);j++) {prob[i][j] = in.nextDouble(); }}for ( int i = 0;(i < N);i++) {System.out.printf("%.6f ",go((1 << i))); }System.out.println(); } public double go( int mask){ if ( (mask == FULL)) return 1.0; if ( (memo[mask] >= 0)) return memo[mask]; double ret = 0;  double mult = (Integer.bitCount(mask) + 1); mult *= ((mult - 1) / 2.0); for ( int i = 0;(i < N);i++) {if ( (((1 << i) & mask) != 0)) {for ( int j = 0;(j < N);j++) {if ( (((1 << j) & mask) == 0)) {ret += ((go((mask | (1 << j))) * prob[i][j]) / mult); } }} }memo[mask] = ret; return ret;} public static void main( String[] args){ new Fish(); } }
2	public class B1177{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long N = in.nextLong();  long answer = solve(N,0,1,1); System.out.println(answer); } static long solve( long N, long offset, long start, int digits){ long thisSection = ((digits * start) * 9);  long fromOffset = (N - offset); if ( (fromOffset > thisSection)) {return solve(N,(offset + thisSection),(10 * start),(digits + 1));} long number = (start + ((fromOffset - 1) / digits));  long posInNumber = ((digits - 1) - ((fromOffset - 1) % digits)); while((posInNumber > 0)){posInNumber--; number /= 10; }return (number % 10);} }
6	public class Fish{ public static void main( String[] args)throws Exception { new Fish(); } public Fish()throws Exception{ 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(); double[] best = new double[(1 << N)]; best[((1 << N) - 1)] = 1; for ( int mask = ((1 << N) - 1);(mask > 0);mask--) { int C = Integer.bitCount(mask); if ( (C == 1)) continue; for ( int i = 0;(i < N);i++) if ( on(mask,i)) for ( int j = (i + 1);(j < N);j++) if ( on(mask,j)) { int nmask = (mask & (1 << j)); best[nmask] += (((P[i][j] * best[mask]) * 2.0) / (C * (C - 1.0))); nmask = (mask & (1 << i)); best[nmask] += (((P[j][i] * best[mask]) * 2.0) / (C * (C - 1.0))); } }for ( int i = 0;(i < N);i++) System.out.printf("%.7f ",(best[(1 << i)] + 1e-9)); System.out.println(); } boolean on( int mask, int pos){ return ((mask & (1 << pos)) > 0);} }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  QuickScanner in = new QuickScanner(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, QuickScanner in, PrintWriter out){ long n = in.nextLong(); out.println(IntegerUtils.pow(5L,n,100)); } } static class QuickScanner{ BufferedReader br ; StringTokenizer st ; InputStream is ; public QuickScanner( InputStream stream){ is = stream; br = new BufferedReader(new InputStreamReader(stream),32768); } String nextToken(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} public long nextLong(){ return Long.parseLong(nextToken());} } }
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[] data = s.readLine().split(" ");  int n = Integer.valueOf(data[0]);  int k = Integer.valueOf(data[1]);  long[] a = new long[n];  String[] ai = s.readLine().split(" "); for ( int i = 0;(i < n);i++) {a[i] = Integer.valueOf(ai[i]); }for ( int i = 0;(i < n);i++) { int tm = (int)(Math.random() * n);  long tmp = a[tm]; a[tm] = a[i]; a[i] = tmp; }Arrays.sort(a); Set<Long> invalid = new HashSet<Long>();  int cnt = 0; for ( int i = 0;(i < n);i++) {if ( !invalid.contains(a[i])) {cnt++; invalid.add((a[i] * k)); } }out.println(cnt); out.flush(); } }
4	public class c{ static int n ; static int[] fs ; static int[] cfs ; static long[][] choose = chooseTable(1001); static long[] fact ; static final long MOD = (long)(1e9 + 7); static long[][] memo ; public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in); n = in.nextInt(); fact = new long[301]; fact[0] = 1; for ( int i = 1;(i < fact.length);i++) {fact[i] = (fact[(i - 1)] * i); fact[i] %= MOD; } HashMap<Long,Integer> map = new HashMap<Long,Integer>(); fs = new int[n]; for ( int i = 0;(i < n);i++) { long v = in.nextLong();  long r = 1; for ( int d = 2;((d * d) <= v);d++) { int cnt = 0; while(((v % d) == 0)){v /= d; cnt ^= 1; }if ( (cnt == 1)) {r *= d; } }r *= v; if ( !map.containsKey(r)) {map.put(r,map.size()); } fs[map.get(r)]++; }cfs = new int[n]; for ( int i = 1;(i < n);i++) {cfs[i] = (cfs[(i - 1)] + fs[(i - 1)]); }memo = new long[(n + 1)][(n + 1)]; for ( long[] arr :memo) Arrays.fill(arr,-1); System.out.println(go(0,0)); } static long go( int color, int priorities){ if ( (color == n)) return ((priorities == 0)?1:0); if ( (memo[color][priorities] != -1)) return memo[color][priorities]; int nonpriorities = ((cfs[color] - priorities) + 1);  long ans = 0; for ( int cntPrio = 0;((cntPrio <= priorities) && (cntPrio <= fs[color]));cntPrio++) {for ( int cntNonPrio = 0;((cntNonPrio <= nonpriorities) && ((cntNonPrio + cntPrio) <= fs[color]));cntNonPrio++) {if ( (((cntPrio + cntNonPrio) == 0) && (fs[color] != 0))) continue; int cntExtra = ((fs[color] - cntPrio) - cntNonPrio);  long tmp = choose(priorities,cntPrio); tmp *= choose(nonpriorities,cntNonPrio); tmp %= MOD; tmp *= multichoose((cntPrio + cntNonPrio),cntExtra); tmp %= MOD; tmp *= go((color + 1),((priorities - cntPrio) + cntExtra)); tmp %= MOD; tmp *= fact[fs[color]]; tmp %= MOD; ans += tmp; ans %= MOD; }}return memo[color][priorities] = ans;} static long[][] chooseTable( int n){ long[][] table = new long[n][]; for ( int x = 0;(x < n);x++) {table[x] = new long[(x + 1)]; table[x][0] = table[x][x] = 1; for ( int y = 1;(y < x);y++) {table[x][y] = (table[(x - 1)][(y - 1)] + table[(x - 1)][y]); table[x][y] %= MOD; }}return table;} static long choose( int n, int k){ if ( (k == 0)) return 1; if ( (k >= choose[n].length)) {return 0;} return choose[n][k];} static long multichoose( int n, int k){ return choose(((n + k) - 1),k);} static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream i){ br = new BufferedReader(new InputStreamReader(i)); } 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 long nextLong()throws IOException { return Long.parseLong(next());} } }
4	public class Main{ public static void main( String[] args)throws Exception { Thread thread = new Thread(null,new TaskAdapter(),"",(1 << 29)); thread.start(); thread.join(); } static class TaskAdapter implements Runnable{ } static class DExplorerSpace{ public void solve( int testNumber, FastInput in, FastOutput out){ int n = in.ri();  int m = in.ri();  int k = in.ri();  int[][] lr = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {lr[i][j] = in.ri(); }} int[][] ud = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ud[i][j] = in.ri(); }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.append(-1).append(' '); }out.println(); }return ;} k /= 2; int inf = (int)1e9;  int[][][] dp = new int[(k + 1)][n][m]; for ( int i = 1;(i <= k);i++) {for ( int j = 0;(j < n);j++) {for ( int t = 0;(t < m);t++) {dp[i][j][t] = inf; if ( (t > 0)) {dp[i][j][t] = Math.min(dp[i][j][t],(dp[(i - 1)][j][(t - 1)] + lr[j][(t - 1)])); } if ( ((t + 1) < m)) {dp[i][j][t] = Math.min(dp[i][j][t],(dp[(i - 1)][j][(t + 1)] + lr[j][t])); } if ( ((j + 1) < n)) {dp[i][j][t] = Math.min(dp[i][j][t],(dp[(i - 1)][(j + 1)][t] + ud[j][t])); } if ( (j > 0)) {dp[i][j][t] = Math.min(dp[i][j][t],(dp[(i - 1)][(j - 1)][t] + ud[(j - 1)][t])); } }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.append((dp[k][i][j] * 2)).append(' '); }out.println(); }} } static class FastOutput implements AutoCloseable,Closeable,Appendable{ static private final int THRESHOLD = (32 << 10); private final Writer os ; private StringBuilder cache = new StringBuilder((THRESHOLD * 2)); public FastOutput append( CharSequence csq){ cache.append(csq); return this;} public FastOutput append( CharSequence csq, int start, int end){ cache.append(csq,start,end); return this;} private void afterWrite(){ if ( (cache.length() < THRESHOLD)) {return ;} flush(); } public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput append( char c){ cache.append(c); afterWrite(); return this;} public FastOutput append( int c){ cache.append(c); afterWrite(); return this;} public FastOutput println(){ return append('\n');} 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();} } 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 ri(){ return readInt();} 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;} } }
4	public class Solution{ static class Reader{ BufferedReader br ; StringTokenizer st ; public Reader(){ 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[] nextArr( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} int nextInt(){ return Integer.parseInt(next());} } void func( PrintWriter o, ArrayList<Integer> a){ for ( int i = 0;(i < a.size());i++) {if ( (i != (a.size() - 1))) o.print((a.get(i) + ".")); else o.println(a.get(i)); }} int dp[][] ; public static void main( String[] args)throws IOException { Reader sc = new Reader();  Solution G = new Solution();  PrintWriter o = new PrintWriter(System.out);  int t = 1; t = sc.nextInt(); int mod = ((int)1e9 + 7);  int x ,x0 ,x1 ,x2 ;  int y ,y0 ,y1 ,y2 ;  int s ,s0 ,s1 ,s2 ;  int n ,m ;  int a[] ,b[] ,in[] ,in1[] ;  long k ,l ;  boolean v[] ,b1 ,b2 ;  String ss ;  char c1[] ;  ArrayList<ArrayList<Integer>> ll = new ArrayList<>();  ArrayList<Integer> a1 = new ArrayList<>();  ArrayList<Integer> a2 = new ArrayList<>();  PriorityQueue<Integer> pq1 = new PriorityQueue<>();  PriorityQueue<Integer> pq2 = new PriorityQueue<>(Collections.reverseOrder());  ArrayDeque<Integer> dq = new ArrayDeque<>();  TreeSet<Integer> h0 = new TreeSet<>();  TreeSet<Integer> h1 = new TreeSet<>();  TreeMap<Integer,Integer> h = new TreeMap<>(); try{while((t-- > 0)){n = sc.nextInt(); a = sc.nextArr(n); b = new int[(int)1e4]; a1.add(a[0]); b[1] = a[0]; for ( int i = 1;(i < n);i++) {G.func(o,a1); x = a1.get((a1.size() - 1)); if ( (a[i] == 1)) {a1.add(a[i]); b[a1.size()] = a[i]; } else if ( (a[i] == (x + 1))) {a1.remove((a1.size() - 1)); a1.add(a[i]); b[a1.size()] = a[i]; } else {while((a1.get((a1.size() - 1)) != (a[i] - 1)))a1.remove((a1.size() - 1)); a1.remove((a1.size() - 1)); a1.add(a[i]); }}G.func(o,a1); h0.clear(); ll.clear(); a1.clear(); a2.clear(); h1.clear(); h.clear(); pq1.clear(); pq2.clear(); } }catch (Throwable e){ e.printStackTrace(); } o.flush(); o.close(); } }
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 a = solve(); out.print(((a == 0)?"tokitsukaze":((a == 1)?"quailty":"once again"))); } int n ,k ; char ch[] ; int a[] ,c0 = 0,c1 = 0; TreeSet<Integer> ts[] = new TreeSet[2]; boolean check(){ int min = 0,max = n; if ( !ts[0].isEmpty()) {min = ts[0].first(); max = ts[0].last(); if ( (((max - min) + 1) > k)) return true; } if ( !ts[1].isEmpty()) {min = ts[1].first(); max = ts[1].last(); if ( (((max - min) + 1) > k)) return true; } return false;} int solve(){ n = in.nextInt(); k = in.nextInt(); ch = in.next().trim().toCharArray(); a = new int[n]; for ( int i = 0;(i < n);i++) c1 += a[i] = (ch[i] - '0'); c0 = (n - c1); for ( int i = 0;(i < k);i++) {if ( (a[i] == 0)) c0--; else c1--; }if ( ((c0 == 0) || (c1 == 0))) return 0; for ( int i = k;(i < n);i++) {if ( (a[i] == 0)) c0--; else c1--; if ( (a[(i - k)] == 0)) c0++; else c1++; if ( ((c0 == 0) || (c1 == 0))) return 0; }for ( int i = 0;(i < 2);i++) ts[i] = new TreeSet<>(); for ( int i = 0;(i < n);i++) {ts[a[i]].add(i); }for ( int i = 0;(i < k);i++) {ts[a[i]].remove(i); }if ( check()) return 2; for ( int i = k;(i < n);i++) {ts[a[i]].remove(i); ts[a[(i - k)]].add((i - k)); if ( check()) return 2; }return 1;} public static class InputReader{ BufferedReader br ; StringTokenizer st ; InputReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } public int nextInt(){ return Integer.parseInt(next());} public String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ } }return st.nextToken();} } }
0	public class Cfbra{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintStream out = System.out; out.println(((in.nextInt() / 2) * 3)); } }
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 final long mod = (((1000L * 1000L) * 1000L) + 9L); public void solve( int testNumber, InputReader in, OutputWriter out){ long n = in.nextLong();  long m = in.nextLong();  long k = in.nextLong();  long z = (n - m);  long left = (m - (z * (k - 1L))); if ( (left < 0)) left = 0;  long res = (IntegerUtlis.pow(2L,(left / k),mod) - 1L); res *= (2L * k); res %= mod; res += (left % k); res %= mod; res += (m - left); res %= mod; res += mod; res %= mod; out.printLine(res); } } 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 long nextLong(){ long sgn = 1;  int c = readSkipSpace(); if ( (c == '-')) {sgn = -1; c = read(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res = ((res * 10L) + (long)(c - '0')); c = read(); }while(!isSpace(c));res *= sgn; return res;} } 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(); } }
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(); } }
0	public class C{ static long n = 0; static void R( long a, long b){ n += (a / b); a = (a % b); if ( (a == 0)) return ; R(b,a); } public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a = sc.nextLong();  long b = sc.nextLong(); R(a,b); System.out.println(n); } }
6	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 int myLevel ; static int[] level ; static int[] loyalty ; static double get( int n){ double ret = 0; for ( int mask = 0;(mask < (1 << n));mask++) { int k = Integer.bitCount(mask);  double prob = 1.;  int sum = 0; for ( int i = 0;(i < n);i++) {if ( (((mask >> i) & 1) == 1)) {prob *= (loyalty[i] * .1); } else {prob *= ((10 - loyalty[i]) * .1); sum += level[i]; }}if ( ((k * 2) > n)) {ret += prob; } else {ret += ((prob * myLevel) / (myLevel + sum)); }}return ret;} static double go( int x, int k, int n){ if ( (x == n)) {return get(n);} double ret = 0; for ( int i = 0;((i <= k) && ((loyalty[x] + i) <= 10));i++) {loyalty[x] += i; ret = Math.max(go((x + 1),(k - i),n),ret); loyalty[x] -= i; }return ret;} public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt();  int k = in.nextInt(); myLevel = in.nextInt(); level = new int[n]; loyalty = new int[n]; for ( int i = 0;(i < n);i++) {level[i] = in.nextInt(); loyalty[i] = (in.nextInt() / 10); }out.println(go(0,k,n)); } } class FastScanner extends BufferedReader{ boolean isEOF ; public FastScanner( InputStream is){ super(new InputStreamReader(is)); } public int read(){ try{ int ret = super.read(); if ( (isEOF && (ret < 0))) {throw (new InputMismatchException());} isEOF = (ret == -1); return ret; }catch (IOException e){ throw (new InputMismatchException());} } static boolean isWhiteSpace( int c){ return ((c >= -1) && (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(!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);} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ long left = in.nextLong();  long right = in.nextLong();  long ans = go(left,right); out.println(ans); } private long go( long A, long B){ int bA = -1; for ( int i = 62;(i >= 0);i--) if ( ((A & (1L << i)) > 0)) {bA = i; break;} int bB = -1; for ( int i = 62;(i >= 0);i--) if ( ((B & (1L << i)) > 0)) {bB = i; break;} if ( (bB == -1)) return 0; if ( (bA < bB)) return allOne(bB); else return go((A ^ (1L << bA)),(B ^ (1L << bB)));} private long allOne( int bits){ long ret = 0; for ( int i = 0;(i <= bits);i++) ret |= (1L << i); return ret;} } 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));} }
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(in,out); out.close(); } } class TaskA{ int n ; int m ; String answer = "I'm too stupid to solve this problem"; public void solve( InputReader in, PrintWriter out){ n = in.nextInt(); out.println(("0 0 " + n)); } } 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());} }
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 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); } }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a ,b ; if ( ((n % 2) == 0)) {a = 4; } else {a = 9; }b = (n - a); System.out.println(((a + " ") + b)); } }
0	public class kresz{ public static double a ; public static double v ; public static double l ; public static double d ; public static double w ; public static double gyorsulut( double v1, double v2){ return Math.abs((((v2 * v2) - (v1 * v1)) / (2 * a)));} public static double gyorsulido( double v1, double v2){ return Math.abs(((v2 - v1) / a));} public static void beolvas()throws IOException { Scanner be = new Scanner(new InputStreamReader(System.in)); a = be.nextDouble(); v = be.nextDouble(); l = be.nextDouble(); d = be.nextDouble(); w = be.nextDouble(); be.close(); } public static void main( String[] args)throws IOException { beolvas(); double s = l;  double t = 0; if ( ((v <= w) || (Math.sqrt(((2 * a) * d)) <= w))) {if ( (gyorsulut(0,v) > l)) {t += gyorsulido(0,Math.sqrt(((2 * a) * l))); s = 0; } else {s -= gyorsulut(0,v); t += gyorsulido(0,v); }} else {if ( (d < (gyorsulut(0,v) + gyorsulut(v,w)))) { double x = Math.sqrt(((a * (d - ((w * w) / (2 * a)))) + (w * w))); s -= (gyorsulut(0,w) + (2 * gyorsulut(w,x))); t += (gyorsulido(0,w) + (2 * gyorsulido(w,x))); } else {s -= (gyorsulut(0,v) + gyorsulut(w,v)); t += (gyorsulido(0,v) + gyorsulido(w,v)); }if ( (gyorsulut(v,w) > (l - d))) { double y = Math.sqrt((((2 * a) * (l - d)) + (w * w))); s -= gyorsulut(w,y); t += gyorsulido(w,y); } else {s -= gyorsulut(w,v); t += gyorsulido(w,v); }}t += (s / v); System.out.println(t); } }
5	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());} long nextLong(){ return Long.parseLong(next());} } static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} public static void main( String[] args)throws IOException { FastReader fr = new FastReader();  int n = fr.nextInt();  int q = fr.nextInt();  long[] a = new long[n];  long[] k = new long[q]; for ( int i = 0;(i < n);i++) a[i] = fr.nextLong(); for ( int i = 0;(i < q);i++) k[i] = fr.nextLong(); long[] pre = new long[n]; pre[0] = a[0]; for ( int i = 1;(i < n);i++) pre[i] = (pre[(i - 1)] + a[i]); long pd = 0; for ( int i = 0;(i < q);i++) { int l = 0;  int r = (n - 1); while((r > l)){ int mid = ((l + r) >> 1); if ( ((pre[mid] - pd) < k[i])) {l = (mid + 1); } else if ( ((pre[mid] - pd) > k[i])) {r = (mid - 1); } else {l = r = mid; }} int ans = 0; if ( ((pre[l] - pd) <= k[i])) {ans = ((n - l) - 1); } else {ans = (n - l); }if ( (ans == 0)) ans = n; pd = (pd + k[i]); if ( (pd >= pre[(n - 1)])) pd = 0; System.out.println(ans); }} }
2	public class Ds{ static long lim ; public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] line = in.readLine().split("\\s+");  long n = Long.parseLong(line[0]); lim = Long.parseLong(line[1]); long pos = -1; for ( int i = 61;(i >= 0);i--) { long shift = (long)Math.pow(2,i); if ( (((pos + shift) - sumOfDigits((pos + shift))) < lim)) {pos += shift; } }pos++; if ( ((pos <= n) && ((pos - sumOfDigits(pos)) >= lim))) {System.out.println(((n - pos) + 1)); } else {System.out.println(0); }} static private long sumOfDigits( long d){ long sum = 0;  long num = d; while((num != 0)){sum += (num % 10); num /= 10; }return sum;} }
6	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);  Fish solver = new Fish(); solver.solve(1,in,out); out.close(); } } class Fish{ public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt();  double[][] p = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {p[i][j] = in.nextDouble(); }} double[] dp = new double[(1 << n)]; dp[((1 << n) - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask >= 0);mask--) { int countPairs = Integer.bitCount(mask); countPairs = ((countPairs * (countPairs - 1)) / 2); for ( int i = 0;(i < n);i++) {if ( (((mask >> i) & 1) == 0)) {continue;} for ( int j = (i + 1);(j < n);j++) {if ( (((mask >> j) & 1) == 0)) {continue;} dp[(mask ^ (1 << j))] += ((dp[mask] * p[i][j]) / countPairs); dp[(mask ^ (1 << i))] += ((dp[mask] * p[j][i]) / countPairs); }}}for ( int i = 0;(i < n);i++) {out.print((dp[(1 << i)] + " ")); }} } class FastScanner extends BufferedReader{ boolean isEOF ; public FastScanner( InputStream is){ super(new InputStreamReader(is)); } public int read(){ try{ int ret = super.read(); if ( (isEOF && (ret < 0))) {throw (new InputMismatchException());} isEOF = (ret == -1); return ret; }catch (IOException e){ throw (new InputMismatchException());} } public String next(){ StringBuilder sb = new StringBuilder();  int c = read(); while(isWhiteSpace(c)){c = read(); }while(!isWhiteSpace(c)){sb.appendCodePoint(c); c = read(); }return sb.toString();} static boolean isWhiteSpace( int c){ return ((c >= -1) && (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(!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 double nextDouble(){ return Double.parseDouble(next());} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
1	public class B{ static Set<Integer> A ; static Set<Integer> B ; static TreeSet<Integer> ts ; static int a ; static int b ; static boolean noAns ; public static void main( String[] args)throws Exception { int n = readInt(); a = readInt(); b = readInt(); ts = new TreeSet<Integer>(); int[] table = new int[n]; for ( int i = 0;(i < n);i++) {table[i] = readInt(); ts.add(table[i]); }A = new HashSet<Integer>(); B = new HashSet<Integer>(); noAns = false; for ( Integer cur :ts) { boolean fitsA = false;  boolean fitsB = false; if ( (A.contains(cur) || B.contains(cur))) {continue;} if ( ts.contains((a - cur))) {fitsA = true; } if ( ts.contains((b - cur))) {fitsB = true; } if ( (fitsA && fitsB)) {continue;} else if ( (fitsA || fitsB)) {noAns = true; } else if ( fitsA) {tour(cur,false); } else if ( fitsB) {tour(cur,true); } }for ( Integer cur :ts) {if ( (A.contains(cur) || B.contains(cur))) {continue;} else {A.add(cur); }}if ( !noAns) {System.out.println("YES"); StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < n);i++) {if ( A.contains(table[i])) {sb.append("0"); } else {sb.append("1"); }sb.append(" "); }System.out.println(sb); } else {System.out.println("NO"); }} static void tour( Integer cur, boolean bb){ if ( (A.contains(cur) || B.contains(cur))) {return ;} if ( bb) {B.add(cur); B.add((b - cur)); if ( ts.contains((a - cur))) {B.add((a - cur)); if ( ts.contains((b - (a - cur)))) {tour((b - (a - cur)),true); } else {noAns = true; }} if ( ts.contains((a - (b - cur)))) {B.add((a - (b - cur))); if ( ts.contains((b - (a - (b - cur))))) {tour((b - (a - (b - cur))),true); } else {noAns = true; }} } else {A.add(cur); A.add((a - cur)); if ( ts.contains((b - cur))) {A.add((b - cur)); if ( ts.contains((a - (b - cur)))) {tour((a - (b - cur)),false); } else {noAns = true; }} if ( ts.contains((b - (a - cur)))) {A.add((b - (a - cur))); if ( ts.contains((a - (b - (a - cur))))) {tour((a - (b - (a - cur))),false); } else {noAns = true; }} }} 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 int readInt()throws Exception { return Integer.parseInt(readString());} }
1	public class ProblemB{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  long a = in.nextLong();  long b = in.nextLong();  long[] x = new long[n]; for ( int i = 0;(i < n);i++) {x[i] = in.nextLong(); } Map<Long,Integer> idxmap = new HashMap<>(); for ( int i = 0;(i < n);i++) {idxmap.put(x[i],i); }if ( (a == b)) {solve1(x,a,idxmap,out); return ;} int[] mark = new int[n]; Arrays.fill(mark,-1); boolean isok = true; for ( int i = 0;(i < n);i++) {if ( (mark[i] != -1)) {continue;} long w = x[i];  long aw = (a - w);  long bw = (b - w); if ( (idxmap.containsKey(aw) && idxmap.containsKey(bw))) {continue;} else if ( idxmap.containsKey(bw)) { long w1 = w;  long w2 = bw; while(true){if ( (!idxmap.containsKey(w1) || !idxmap.containsKey(w2))) {break;} int i1 = idxmap.get(w1);  int i2 = idxmap.get(w2); if ( ((mark[i1] == 0) || (mark[i2] == 0))) {isok = false; } mark[i1] = 1; mark[i2] = 1; if ( (((w1 + a) - b) == w2)) {break;} w1 += (a - b); w2 += (b - a); }} else if ( idxmap.containsKey(aw)) { long w1 = w;  long w2 = aw; while(true){if ( (!idxmap.containsKey(w1) || !idxmap.containsKey(w2))) {break;} int i1 = idxmap.get(w1);  int i2 = idxmap.get(w2); if ( ((mark[i1] == 1) || (mark[i2] == 1))) {isok = false; } mark[i1] = 0; mark[i2] = 0; if ( (((w1 + b) - a) == w2)) {break;} w1 += (b - a); w2 += (a - b); }} }for ( int i = 0;(i < n);i++) {if ( (mark[i] == -1)) {isok = false; break;} }if ( isok) {printAnswer(mark,out); } else {out.println("NO"); }out.flush(); } static private void printAnswer( int[] mark, PrintWriter out){ out.println("YES"); StringBuilder ln = new StringBuilder(); for ( int m :mark) {ln.append(' ').append(m); }out.println(ln.substring(1)); } static private void solve1( long[] x, long a, Map<Long,Integer> idxmap, PrintWriter out){ int[] mark = new int[x.length]; for ( int i = 0;(i < x.length);i++) {if ( (mark[i] == 1)) {continue;} long w = x[i];  long wp = (a - w); if ( idxmap.containsKey(wp)) {mark[i] = mark[idxmap.get(wp)] = 1; } } boolean isok = true; for ( int i = 0;(i < x.length);i++) {if ( (mark[i] == 0)) {isok = false; break;} }if ( isok) {printAnswer(mark,out); } else {out.println("NO"); }out.flush(); } 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 next(){ 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 = next(); while(isSpaceChar(c))c = next(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = next(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = next(); }while(!isSpaceChar(c));return (res * sgn);} public long nextLong(){ int c = next(); while(isSpaceChar(c))c = next(); long sgn = 1; if ( (c == '-')) {sgn = -1; c = next(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = next(); }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); } } }
4	public class Codeforces{ public static void main( String[] args)throws Exception { BufferedReader bu = new BufferedReader(new InputStreamReader(System.in));  StringBuilder sb = new StringBuilder();  int t = Integer.parseInt(bu.readLine()); while((t-- > 0)){ int n = Integer.parseInt(bu.readLine());  int cur[] = new int[n],i ,cr = -1; for ( i = 0;(i < n);i++) { int j ,d = Integer.parseInt(bu.readLine()),f = -1; for ( j = cr;(j >= 0);j--) if ( (cur[j] == (d - 1))) {f = j; break;} if ( (f == -1)) {cr++; f = cr; } cur[f] = d; cr = f; for ( j = (f + 1);(j < n);j++) cur[j] = 0; sb.append(cur[0]); for ( j = 1;(j < n);j++) if ( (cur[j] == 0)) break; else sb.append(("." + cur[j])); sb.append("\n"); }}System.out.print(sb); } }
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(); int[] arr2 = arr.clone(); Arrays.sort(arr2); int diff = 0; for ( int i = 0;(i < n);i++) {if ( (arr2[i] != arr[i])) diff++; }if ( (diff <= 2)) System.out.println("YES"); else System.out.println("NO"); } Scanner in = new Scanner(System.in); StringBuilder buf = new StringBuilder(); public static void main( String[] args)throws Exception { new A(); } public static class Scanner{ BufferedReader br ; String line ; StringTokenizer st ; public Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); } public boolean hasNext()throws IOException { while((((st == null) || !st.hasMoreTokens()) && ((line = br.readLine()) != null)))st = new StringTokenizer(line); return st.hasMoreTokens();} public String next()throws IOException { if ( hasNext()) return st.nextToken(); throw (new NoSuchElementException());} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
2	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{ long n ,x ,y ,c ; public void solve( int testNumber, FastScanner in, FastPrinter out){ n = in.nextLong(); x = in.nextLong(); y = in.nextLong(); c = in.nextLong(); long td = -1,tup = (2 * (n - 1)); while((Math.abs((td - tup)) > 1)){ long mid = ((td + tup) / 2); if ( chk(mid)) tup = mid; else td = mid; }out.println(tup); } private boolean chk( long t){ long ct = -3;  long d = x,w = y; if ( (w > d)) { long tt = w; w = d; d = tt; } if ( (t >= ((d + w) - 2))) ct += (d * w); else if ( ((t < w) && (t < d))) {ct += (((t + 1) * (t + 2)) / 2); } else if ( ((t >= w) && (t < d))) {ct += ((w * (w + 1)) / 2); long k = (t - (w - 1)); ct += (k * w); } else if ( ((t >= w) && (t >= d))) {ct += (w * d); long k = ((w - 2) - (t - d)); ct -= ((k * (k + 1)) / 2); } w = x; d = ((n + 1) - y); if ( (w > d)) { long tt = w; w = d; d = tt; } if ( (t >= ((d + w) - 2))) ct += (d * w); else if ( ((t < w) && (t < d))) {ct += (((t + 1) * (t + 2)) / 2); } else if ( ((t >= w) && (t < d))) {ct += ((w * (w + 1)) / 2); long k = (t - (w - 1)); ct += (k * w); } else if ( ((t >= w) && (t >= d))) {ct += (w * d); long k = ((w - 2) - (t - d)); ct -= ((k * (k + 1)) / 2); } w = ((n + 1) - x); d = y; if ( (w > d)) { long tt = w; w = d; d = tt; } if ( (t >= ((d + w) - 2))) ct += (d * w); else if ( ((t < w) && (t < d))) {ct += (((t + 1) * (t + 2)) / 2); } else if ( ((t >= w) && (t < d))) {ct += ((w * (w + 1)) / 2); long k = (t - (w - 1)); ct += (k * w); } else if ( ((t >= w) && (t >= d))) {ct += (w * d); long k = ((w - 2) - (t - d)); ct -= ((k * (k + 1)) / 2); } w = ((n + 1) - x); d = ((n + 1) - y); if ( (w > d)) { long tt = w; w = d; d = tt; } if ( (t >= ((d + w) - 2))) ct += (d * w); else if ( ((t < w) && (t < d))) {ct += (((t + 1) * (t + 2)) / 2); } else if ( ((t >= w) && (t < d))) {ct += ((w * (w + 1)) / 2); long k = (t - (w - 1)); ct += (k * w); } else if ( ((t >= w) && (t >= d))) {ct += (w * d); long k = ((w - 2) - (t - d)); ct -= ((k * (k + 1)) / 2); } ct -= Math.min(t,(x - 1)); ct -= Math.min(t,(y - 1)); ct -= Math.min(t,(n - x)); ct -= Math.min(t,(n - y)); if ( (ct >= c)) return true; else return false;} } 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());} } public String next(){ StringBuilder sb = new StringBuilder();  int c = read(); while(isWhiteSpace(c)){c = read(); }if ( (c < 0)) {return null;} while(((c >= 0) && !isWhiteSpace(c))){sb.appendCodePoint(c); c = read(); }return sb.toString();} static boolean isWhiteSpace( int c){ return ((c >= 0) && (c <= 32));} public long nextLong(){ return Long.parseLong(next());} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
5	public class Main{ Scanner in ; static PrintWriter out ; static class Scanner{ StreamTokenizer in ; Scanner( InputStream is){ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is))); in.resetSyntax(); in.whitespaceChars(0,32); in.wordChars(33,255); } int nextInt(){ try{in.nextToken(); return Integer.parseInt(in.sval); }catch (IOException e){ throw (new Error());} } } static class Value implements Comparable<Value>{ int x ; int pos ; Value( int x, int pos){ this.x = x; this.pos = pos; } } void solve(){ int n = in.nextInt();  Value ar[] = new Value[n]; for ( int i = 0;(i < n);i++) {ar[i] = new Value(in.nextInt(),i); }Arrays.sort(ar); int cnt = 0; for ( int i = 0;(i < n);i++) {if ( ((ar[i].pos != i) && (ar[ar[i].pos].x != ar[i].x))) {cnt++; } }if ( (cnt > 2)) {out.println("NO"); } else {out.println("YES"); }} public void run(){ in = new Scanner(System.in); out = new PrintWriter(System.out); try{solve(); }finally{out.close(); }} public static void main( String[] args){ new Main().run(); } }
3	public class Main{ static PrintWriter out ; static InputReader ir ; static void solve(){ int n = ir.nextInt();  int r = ir.nextInt();  int[] x = ir.nextIntArray(n);  double[] ret = new double[n]; for ( int i = 0;(i < n);i++) { double ma = r; for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) <= (2 * r))) {ma = Math.max(ma,(ret[j] + Math.sqrt(((4 * (double)Math.pow(r,2)) - Math.pow((x[i] - x[j]),2))))); } }ret[i] = ma; }for ( int i = 0;(i < n);i++) {out.print((ret[i] + ((i == (n - 1))?"\n":" "))); }} public static void main( String[] args)throws Exception { ir = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static class InputReader{ private InputStream in ; private byte[] buffer = new byte[1024]; private int curbuf ; private int lenbuf ; public InputReader( InputStream in){ this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte(){ if ( (curbuf >= lenbuf)) {curbuf = 0; try{lenbuf = in.read(buffer); }catch (IOException e){ throw (new InputMismatchException());} if ( (lenbuf <= 0)) return false; } return true;} private int readByte(){ if ( hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} private void skip(){ while((hasNextByte() && isSpaceChar(buffer[curbuf])))curbuf++; } public boolean hasNext(){ skip(); return hasNextByte();} public String next(){ if ( !hasNext()) throw (new NoSuchElementException()); StringBuilder sb = new StringBuilder();  int b = readByte(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} public int nextInt(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public long nextLong(){ if ( !hasNext()) throw (new NoSuchElementException()); int c = readByte(); while(isSpaceChar(c))c = readByte(); boolean minus = false; if ( (c == '-')) {minus = true; c = readByte(); } long res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res = (((res * 10) + c) - '0'); c = readByte(); }while(!isSpaceChar(c));return (minus?-res:res);} public int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
6	public class Test{ static PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int[][] a = new int[12][2000]; int[][] e = new int[(12 * 2000)][3]; Integer[] se = new Integer[(12 * 2000)]; boolean[] used = new boolean[2000]; int[] dp = new int[(1 << 12)]; int[] one = new int[(1 << 12)]; 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(); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) {a[i][j] = readInt(); int k = ((i * m) + j); e[k][0] = a[i][j]; e[k][1] = j; e[k][2] = i; }for ( int i = ((n * m) - 1);(i >= 0);i--) se[i] = i; Arrays.sort(se,0,(n * m),(i,j)->{ int[] x = e[i],y = e[j]; return ((x[0] == y[0])?((x[1] == y[1])?Integer.compare(x[2],y[2]):Integer.compare(x[1],y[1])):Integer.compare(x[0],y[0]));}); Arrays.fill(used,0,m,false); Arrays.fill(dp,0,(1 << n),-1); dp[0] = 0; int cc = 0; for ( int x = ((n * m) - 1);(x >= 0);x--) { int c = e[se[x]][1]; if ( used[c]) continue; used[c] = true; cc++; if ( (cc > n)) break; Arrays.fill(one,0,(1 << n),0); for ( int i = ((1 << n) - 1);(i > 0);i--) {for ( int r = 0;(r < n);r++) { int sum = 0; for ( int j = 0;(j < n);j++) if ( (((i >> j) & 1) != 0)) sum += a[((j + r) % n)][c]; one[i] = Math.max(one[i],sum); }}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)){dp[(i | p)] = Math.max(dp[(i | p)],(dp[i] + one[p])); p = ((p - 1) & u); } }}writer.println(dp[((1 << n) - 1)]); }} }
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(); } }
2	public class A{ static private final long MOD = 1000000009; public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  long n = in.nextInt();  long correct = in.nextInt();  long k = in.nextInt();  long wrong = (n - correct);  long set = (((wrong * k) + k) - 1); if ( (set >= n)) {out.println(correct); } else { long needExtraCorrect = (n - (((wrong * k) + k) - 1));  long firstSet = ((needExtraCorrect + k) - 1);  long otherSet = (correct - firstSet);  long firstDouble = (firstSet / k); otherSet += (firstSet % k); long[][] mat = new long[][]{{2,(2 * k)},{0,1}};  long[][] A = pow(mat,firstDouble,MOD);  long score = ((A[0][1] + otherSet) % MOD); out.println(score); }out.flush(); } public static long[][] pow( long[][] a, long n, long mod){ long i = 1;  long[][] res = E(a.length);  long[][] ap = mul(E(a.length),a,mod); while((i <= n)){if ( ((n & i) >= 1)) {res = mul(res,ap,mod); } i *= 2; ap = mul(ap,ap,mod); }return res;} public static long[][] E( int n){ long[][] a = new long[n][n]; for ( int i = 0;(i < n);i++) {a[i][i] = 1; }return a;} public static long[][] mul( long[][] a, long[][] b, long mod){ long[][] c = new long[a.length][b[0].length]; if ( (a[0].length != b.length)) {System.err.print("err"); } for ( int i = 0;(i < a.length);i++) {for ( int j = 0;(j < b[0].length);j++) { long sum = 0; for ( int k = 0;(k < a[0].length);k++) {sum = ((sum + (a[i][k] * b[k][j])) % mod); }c[i][j] = sum; }}return c;} 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; } private int next(){ 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 = next(); while(isSpaceChar(c))c = next(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = next(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = next(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
1	public class Solution{ public static void main( String[] str)throws Exception { Scanner sc = new Scanner(System.in);  BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));  int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt(); if ( ((((n % 2) == 0) && ((Math.pow((n / 2),0.5) % 1.0) == 0)) || (((n % 4) == 0) && ((Math.pow((n / 4),0.5) % 1.0) == 0)))) output.write("YES\n"); else {output.write("NO\n"); }}output.flush(); } }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int mod = 1000000007;  String[] input = in.readLine().split(" ");  int n = Integer.parseInt(input[0]);  int a = Integer.parseInt(input[1]);  int b = Integer.parseInt(input[2]);  String[] h = in.readLine().split(" ");  int[] mas = new int[n]; for ( int i = 0;(i < n);i++) {mas[i] = Integer.parseInt(h[i]); }Arrays.sort(mas); int l = mas[(b - 1)];  int r = mas[b];  int count = 0; if ( (l == r)) count = 0; else count = (r - l); out.println(count); out.close(); } }
6	public class Main implements Runnable{ final String filename = ""; public int nextPerm( int[] a, int k){ if ( (a[0] == k)) return -1; int last = 0; for ( int i = (a.length - 1);(i >= 0);i--) if ( (a[i] != 0)) {last = i; break;} int mem = a[last]; a[(last - 1)]++; a[last] = 0; a[(a.length - 1)] = (mem - 1); return 0;} public double poss( int A, int[][] sen, int[] rasp){ int n = sen.length;  double[] possluck = new double[n]; for ( int i = 0;(i < n);i++) possluck[i] = (Math.min(100,(sen[i][1] + (rasp[i] * 10))) / 100.0); double poss = 0; for ( int i = 0;(i < (1 << n));i++) { int kol = 0; for ( int j = 0;(j < n);j++) if ( (((i % (1 << (j + 1))) / (1 << j)) == 1)) kol++;  double thisposs = 1; for ( int j = 0;(j < n);j++) if ( (((i % (1 << (j + 1))) / (1 << j)) == 1)) thisposs *= possluck[j]; else thisposs *= (1 - possluck[j]); if ( (kol > (n / 2))) poss += thisposs; else { double lvl = 0; for ( int j = 0;(j < n);j++) if ( (((i % (1 << (j + 1))) / (1 << j)) == 0)) lvl += sen[j][0]; poss += (thisposs * (A / (A + lvl))); }}return poss;} public void solve()throws Exception { int n = iread(),k = iread(),A = iread();  int[][] sen = new int[n][2]; for ( int i = 0;(i < n);i++) {sen[i][0] = iread(); sen[i][1] = iread(); } double maxposs = 0;  int[] rasp = new int[n]; rasp[(n - 1)] = k; maxposs = Math.max(maxposs,poss(A,sen,rasp)); while((nextPerm(rasp,k) == 0))maxposs = Math.max(maxposs,poss(A,sen,rasp)); out.write((maxposs + "\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(); } }
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); } }
0	public class a{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int N = sc.nextInt(); solve(N); } static void solve( int a){ if ( (((a - 8) % 3) == 0)) {System.out.println(((8 + " ") + (a - 8))); return ;} if ( (((a - 4) % 3) == 0)) {System.out.println(((4 + " ") + (a - 4))); return ;} if ( (((a - 6) % 3) == 0)) {System.out.println(((6 + " ") + (a - 6))); return ;} } }
2	public class B implements Runnable{ static private final String TASK_NAME_FOR_IO = ""; static private final String FILE_IN = (TASK_NAME_FOR_IO + ".in"); static private final String FILE_OUT = (TASK_NAME_FOR_IO + ".out"); BufferedReader in ; PrintWriter out ; StringTokenizer tokenizer = new StringTokenizer(""); public static void main( String[] args){ new Thread(new B()).start(); } private void solve()throws IOException { long n = nextLong();  long k = nextLong(); n--; k--; long answer = 0; while(((n > 0) && (k >= 1))){if ( (k > 2000)) { long step1000 = ((k + (k - 999)) * 500); if ( ((n - step1000) >= 0)) {n -= step1000; answer += 1000; k -= 1000; continue;} } if ( ((n - k) >= 0)) {n -= k; answer++; } k--; k = Math.min(n,k); }if ( (n == 0)) {out.println(answer); } else {out.println(-1); }} private String nextToken()throws IOException { while(!tokenizer.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) {return null;} tokenizer = new StringTokenizer(line); }return tokenizer.nextToken();} private long nextLong()throws IOException { return Long.parseLong(nextToken());} }
6	public class Fish{ static double[][] prob = new double[18][18]; static double[][] dp = new double[2][(1 << 18)]; static ArrayList<Integer>[] adj = new ArrayList[(1 << 18)]; static int n ; public static void init(){ for ( int i = 0;(i < (1 << 18));i++) adj[i] = new ArrayList<Integer>(); for ( int i = 0;(i < (1 << 18));i++) for ( int j = 0;(j < 18);j++) if ( (((i >> j) & 1) == 1)) adj[i].add((i ^ (1 << j))); } public static double value( int cur, int next){ int i = 0;  int z = (cur ^ next);  double p = 0;  int alive = Integer.bitCount(cur); while(((z >> i) != 1))i++; for ( int k = 0;(k < n);k++) if ( (((next >> k) & 1) == 1)) p += prob[k][i]; p /= ((alive * (alive - 1)) / 2); return p;} public static void main( String[] args)throws Exception { Scanner scan = new Scanner(System.in); init(); n = scan.nextInt(); int m = ((1 << n) - 1); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) prob[i][j] = scan.nextDouble(); dp[0][m] = 1; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j <= m);j++) if ( (dp[(i % 2)][j] > 0)) for ( Integer next :adj[j]) dp[((i + 1) % 2)][next] += (value(j,next) * dp[(i % 2)][j]); Arrays.fill(dp[(i % 2)],0); }for ( int i = 0;(i < n);i++) {if ( (i != 0)) System.out.print(" "); System.out.printf("%.6f",dp[((n - 1) % 2)][(1 << i)]); }} }
6	public class LookingForOrder{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int bx = in.nextInt();  int by = in.nextInt(); in.nextLine(); int n = in.nextInt();  int[][] objects = new int[n][2]; for ( int i = 0;(i < n);i++) {objects[i][0] = in.nextInt(); objects[i][1] = in.nextInt(); } int[] cs = new int[n]; for ( int i = 0;(i < n);i++) {cs[i] = (2 * time(objects[i],new int[]{bx,by})); } int[][] cd = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {cd[j][i] = cd[i][j] = ((time(objects[i],new int[]{bx,by}) + time(objects[j],new int[]{bx,by})) + time(objects[i],objects[j])); }} int maxMask = (1 << n);  int[] dp = new int[maxMask];  int[] path = new int[maxMask]; Arrays.fill(dp,-1); dp[0] = 0; for ( int g = 1;(g < maxMask);g++) { int min = Integer.MAX_VALUE;  int minPath = 0;  int h = 31; while(((g & (1 << h)) == 0))h--; h++; int l = 0; while(((g & (1 << l)) == 0))l++; if ( ((g & (1 << l)) > 0)) { int oneleft = (g ^ (1 << l));  int t = (cs[l] + dp[oneleft]); if ( (t < min)) {min = t; minPath = oneleft; } for ( int j = (l + 1);(j < h);j++) {if ( ((oneleft & (1 << j)) > 0)) { int twoleft = (oneleft ^ (1 << j)); t = (cd[l][j] + dp[twoleft]); if ( (t < min)) {min = t; minPath = twoleft; } } }} dp[g] = min; path[g] = minPath; }System.out.println(dp[(maxMask - 1)]); int previous = (maxMask - 1);  int pathElt = path[previous]; System.out.print("0 "); while((previous > 0)){ int bits = (previous - pathElt);  int h = 31; while(((bits & (1 << h)) == 0))h--; int l = 0; while(((bits & (1 << l)) == 0))l++; String el = ((h == l)?("" + (h + 1)):(((h + 1) + " ") + (l + 1))); System.out.print((((el + " ") + 0) + " ")); previous = pathElt; pathElt = path[pathElt]; }System.out.println(); } static int time( int[] a, int[] b){ int x = (b[0] - a[0]);  int y = (b[1] - a[1]); return ((x * x) + (y * y));} }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void shuffle( int[] is){ Random rand = new Random(); for ( int i = (is.length - 1);(i >= 1);i--) { int j = rand.nextInt((i + 1));  int t = is[i]; is[i] = is[j]; is[j] = t; }} void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0};  int[] _ = new int[n]; for ( int i = 0;(i < n);i++) {_[i] = i; }shuffle(_); HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {map.put(_[i],i); }for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[map.get(((y * w) + x))] |= (1L << map.get(((y2 * w) + x2))); } }}}mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; long[] candidate ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {if ( (Long.bitCount(choosed) < Long.bitCount(mds))) mds = choosed; return ;} int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) k = i; if ( false) {} }if ( (k == -1)) return ; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } 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 P111C().run(); } }
0	public class p343a{ public static void main( String[] args){ Scanner sc = new Scanner(System.in); System.out.println(); long a = sc.nextLong();  long b = sc.nextLong(); if ( (a == b)) System.out.println("1"); else if ( (b == 1)) System.out.println(a); else if ( (a == 1)) System.out.println(b); else if ( (a > b)) System.out.println(count(a,b)); else System.out.println(count(b,a)); } public static long count( long a, long b){ long count = 0; while((b != 1)){ long c = (a / b); count += c; long d = (a - (c * b)); a = b; b = d; if ( (b == 1)) {count += a; break;} }return count;} }
3	public class cf908G{ static final int MOD = 1_000_000_007; public static void main( String[] argv){ cf908G pro = new cf908G();  InputStream fin = null; if ( (System.getProperty("ONLINE_JUDGE") == null)) {try{fin = new FileInputStream("input.txt"); }catch (FileNotFoundException e){ e.printStackTrace(); } } else {fin = System.in; }pro.solve(new Scanner(fin),System.out); } private void solve( Scanner scanner, PrintStream out){ long ans = 0;  String X = scanner.next(); for ( int x = 0;(x < 9);x++) {ans = ((ans + solve2(x,X)) % MOD); }out.println((((ans % MOD) + MOD) % MOD)); } private long solve2( int x, String X){ int[][][] f = new int[(X.length() + 1)][(X.length() + 1)][2]; f[0][0][1] = 1; int n = X.length(); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= n);j++) {for ( int u = 0;(u < 2);u++) { int val = f[i][j][u]; if ( (val == 0)) continue; for ( int num = 0;(num < 10);num++) { int Xi = (X.charAt(i) - '0'); if ( ((u == 1) && (num > Xi))) break; int _i = (i + 1);  int _j = ((num <= x)?(j + 1):j);  int _u = (((u == 1) && (num == Xi))?1:0); f[_i][_j][_u] = ((f[_i][_j][_u] + val) % MOD); }}}} long base = 1;  long ret = 0; for ( int i = n;(i > 0);i--) { long t = 0; for ( int j = 0;(j < i);j++) {t = (((t + f[n][j][0]) + f[n][j][1]) % MOD); }ret = ((ret + (base * t)) % MOD); base = ((base * 10) % MOD); }return ret;} }
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);  E1RotateColumnsEasyVersion solver = new E1RotateColumnsEasyVersion(); solver.solve(1,in,out); out.close(); } static class E1RotateColumnsEasyVersion{ int n ; int m ; int[][] arr ; int[][] mskValue ; int[][] memo ; public void solve( int testNumber, Scanner sc, PrintWriter pw){ int q = sc.nextInt(); while((q-- > 0)){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(); int[][] temp = new int[m][n]; for ( int i = 0;(i < m);i++) for ( int j = 0;(j < n);j++) temp[i][j] = arr[j][i]; Arrays.sort(temp,(a,b)->(getMax(b) - getMax(a))); for ( int i = 0;(i < m);i++) for ( int j = 0;(j < n);j++) arr[j][i] = temp[i][j]; mskValue = new int[n][(1 << n)]; for ( int i = 0;(i < Math.min(n,m));i++) {for ( int j = 0;(j < (1 << n));j++) { int max = 0; for ( int shift = 0;(shift < n);shift++) { int sum = 0; for ( int k = 0;(k < n);k++) if ( ((j & (1 << k)) != 0)) sum += arr[((k + shift) % n)][i]; max = Math.max(max,sum); }mskValue[i][j] = max; }}memo = new int[Math.min(n,m)][(1 << n)]; for ( int[] x :memo) Arrays.fill(x,-1); pw.println(dp(0,0)); }} private int getMax( int[] a){ int max = 0; for ( int x :a) max = Math.max(max,x); return max;} private int dp( int idx, int msk){ if ( (msk == ((1 << n) - 1))) return 0; if ( (idx == Math.min(n,m))) return (int)-1e9; int max = Integer.MIN_VALUE; if ( (memo[idx][msk] != -1)) return memo[idx][msk]; int availableBits = (msk ^ ((1 << n) - 1)); for ( int colMask = availableBits;(colMask != 0);colMask = ((colMask - 1) & availableBits)) {max = Math.max(max,(mskValue[idx][colMask] + dp((idx + 1),(msk | colMask)))); }return memo[idx][msk] = max;} } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( FileReader r){ br = new BufferedReader(r); } public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } 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 int nextInt(){ return Integer.parseInt(next());} } }
5	public class D{ static final boolean stdin = true; static final String filename = ""; static FastScanner br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { if ( stdin) {br = new FastScanner(); pw = new PrintWriter(new OutputStreamWriter(System.out)); } else {br = new FastScanner((filename + ".in")); pw = new PrintWriter(new FileWriter((filename + ".out"))); } Solver solver = new Solver(); solver.solve(br,pw); } static class Solver{ static long mod = (long)1e10; public void solve( FastScanner br, PrintWriter pw)throws IOException { int n = br.ni();  Integer[] in = br.nIa(n);  TreeSet<Integer> ts = new TreeSet<Integer>(); for ( int i = 0;(i < n);i++) {ts.add(in[i]); } String twoSol = ""; for ( int i = 0;(i <= 30);i++) {for ( int j :in) {if ( ts.contains((j + (int)Math.pow(2,i)))) {if ( ts.contains((j - (int)Math.pow(2,i)))) {pw.println(3); pw.println(((((j + " ") + (j + (int)Math.pow(2,i))) + " ") + (j - (int)Math.pow(2,i)))); pw.close(); System.exit(0); } else {twoSol = ((j + " ") + (j + (int)Math.pow(2,i))); }} }}if ( twoSol.isEmpty()) {pw.println(1); pw.println(in[0]); } else {pw.println(2); pw.println(twoSol); }pw.close(); } static long gcd( long a, long b){ if ( (a > b)) return gcd(b,a); if ( (a == 0)) return b; return gcd((b % a),a);} static long pow( long a, long b){ if ( (b == 0)) return 1L; long val = pow(a,(b / 2)); if ( ((b % 2) == 0)) return ((val * val) % mod); else return ((((val * val) % mod) * a) % mod);} } public 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)); } Integer[] nIa( int n){ Integer[] arr = new Integer[n]; for ( int i = 0;(i < n);i++) {arr[i] = ni(); }return arr;} String nt(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int ni(){ return Integer.parseInt(nt());} long nl(){ return Long.parseLong(nt());} } }
0	public class Main{ static Scanner in = new Scanner(); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws IOException { long n = in.nextLong(),m = in.nextLong(); out.print(((m / n) + (((m % n) == 0)?0:1))); out.close(); } static class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner(){ br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(""); } public String next()throws IOException { if ( !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken();} public long nextLong()throws IOException { return Long.parseLong(next());} } }
0	public class p472a{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( ((n % 2) == 0)) {System.out.println(("8 " + (n - 8))); } else {System.out.println(("9 " + (n - 9))); }} }
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.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 res = 0;  int mySum = 0;  int hisSum = sum; for ( int i = (n - 1);(i >= 0);i--) {mySum += a[i]; hisSum -= a[i]; res++; if ( (mySum > hisSum)) break; }out.println(res); } } 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());} } 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++) {writer.print(objects[i]); }} public void println( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } }
2	public class test_round_B{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  BigInteger k = sc.nextBigInteger();  BigInteger i = new BigInteger("0");  int d = 0;  BigInteger a = new BigInteger("0"); while((i.compareTo(k) != 1)){if ( (i.compareTo(k) == 0)) {break;} else {d++; BigInteger temp = new BigInteger("0"); for ( int j = 0;(j < d);j++) {temp = temp.multiply(new BigInteger("10")).add(new BigInteger("9")); }i = i.add(new BigInteger(Integer.toString(d)).multiply(temp.subtract(a))); a = temp; }} BigInteger b = a.divide(new BigInteger("10"));  BigInteger t = b;  BigInteger l = t;  int dig = 0; if ( b.equals(new BigInteger("0"))) {dig = 0; } else {while((b.compareTo(new BigInteger("0")) == 1)){dig++; b = b.divide(new BigInteger("10")); }} int flag = (dig + 1);  BigInteger num = new BigInteger("0"); b = t; while((b.compareTo(new BigInteger("0")) == 1)){ BigInteger rev = b.divide(new BigInteger("10")); num = num.add(new BigInteger(Integer.toString(dig)).multiply(b.subtract(rev))); b = b.divide(new BigInteger("10")); dig--; } BigInteger net = k.subtract(num);  BigInteger div = net.divide(new BigInteger(Integer.toString(flag)));  int q ; if ( net.mod(new BigInteger(Integer.toString(flag))).equals(new BigInteger("0"))) {q = 0; t = t.add(div); System.out.println(t.mod(new BigInteger("10"))); } else { BigInteger r = div.multiply(new BigInteger(Integer.toString(flag))); r = net.subtract(r); t = t.add(div.add(new BigInteger("1"))); l = t; int pig = 0; while((t.compareTo(new BigInteger("0")) == 1)){pig++; t = t.divide(new BigInteger("10")); } BigInteger p = new BigInteger(Integer.toString(pig));  BigInteger rem = p.subtract(r); while((rem.compareTo(new BigInteger("0")) == 1)){l = l.divide(new BigInteger("10")); rem = rem.subtract(new BigInteger("1")); }System.out.println(l.mod(new BigInteger("10"))); }} }
2	public class ques3{ 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 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 boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } public String nextString(){ 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 Long nextLong(){ return Long.parseLong(nextString());} } public static void main( String[] args){ InputReader sc = new InputReader(System.in);  long n = sc.nextLong();  long s = sc.nextLong();  long start = 0,end = n; while((start < end)){ long mid = ((start + end) / 2); if ( (func(mid) >= s)) end = mid; else start = (mid + 1); }if ( (func(start) >= s)) System.out.println(((n - start) + 1)); else System.out.println(0); } public static long func( long n){ long temp = n;  int sum = 0; while((temp > 0)){sum += (temp % 10); temp /= 10; }return (n - sum);} }
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))); } }
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); } } }
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); } }
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());} }
4	public class C{ static class Struct{ int x ,y ,count ; public Struct( int xx, int yy, int c){ x = xx; y = yy; count = c; } } public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new FileReader("input.txt"));  int n = sc.nextInt();  int m = sc.nextInt();  FileWriter fw = new FileWriter("output.txt");  boolean[][] grid = new boolean[n][m];  int[] dx = new int[]{1,0,-1,0};  int[] dy = new int[]{0,-1,0,1};  int k = sc.nextInt();  LinkedList<Struct> a = new LinkedList<Struct>(); for ( int i = 0;(i < k);i++) {a.add(new Struct((sc.nextInt() - 1),(sc.nextInt() - 1),0)); } int max = Integer.MIN_VALUE,maxX = -1,maxY = -1; while(!a.isEmpty()){ Struct tmp = a.remove(); if ( (grid[tmp.x][tmp.y] == true)) continue; grid[tmp.x][tmp.y] = true; if ( (tmp.count > max)) {max = tmp.count; maxX = tmp.x; maxY = tmp.y; } for ( int i = 0;(i < 4);i++) { int nx = (tmp.x + dx[i]);  int ny = (tmp.y + dy[i]); if ( ((((nx < n) && (nx >= 0)) && (ny < m)) && (ny >= 0))) {if ( (grid[nx][ny] == false)) {a.add(new Struct(nx,ny,(tmp.count + 1))); } } }}fw.write(((((maxX + 1) + " ") + (maxY + 1)) + "\n")); System.out.println((((maxX + 1) + " ") + (maxY + 1))); fw.flush(); } }
3	public class D{ int N ,M ; int[] a ,l ,r ; private void solve(){ N = nextInt(); a = new int[N]; for ( int i = 0;(i < N);i++) {a[i] = nextInt(); }M = nextInt(); l = new int[M]; r = new int[M]; for ( int i = 0;(i < M);i++) {l[i] = nextInt(); r[i] = 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++; } }for ( int i = 0;(i < M);i++) {count += ((((r[i] - l[i]) + 1) * (r[i] - l[i])) / 2); count %= 2; out.println(((count == 0)?"even":"odd")); }} public static void main( String[] args){ out.flush(); new D().solve(); out.close(); } static private final InputStream in = System.in; static private final PrintWriter out = new PrintWriter(System.out); private final byte[] buffer = new byte[2048]; private int p = 0; private int buflen = 0; private boolean hasNextByte(){ if ( (p < buflen)) return true; p = 0; try{buflen = in.read(buffer); }catch (IOException e){ e.printStackTrace(); } if ( (buflen <= 0)) return false; return true;} public boolean hasNext(){ while((hasNextByte() && !isPrint(buffer[p]))){p++; }return hasNextByte();} private boolean isPrint( int ch){ if ( ((ch >= '!') && (ch <= '~'))) return true; return false;} private int nextByte(){ if ( !hasNextByte()) return -1; return buffer[p++];} public String next(){ if ( !hasNext()) throw (new NoSuchElementException()); StringBuilder sb = new StringBuilder();  int b = -1; while(isPrint(b = nextByte())){sb.appendCodePoint(b); }return sb.toString();} public int nextInt(){ return Integer.parseInt(next());} }
1	public class B{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int t = in.nextInt(); while((t > 0)){t--; int n = in.nextInt(); if ( ((n % 2) != 0)) {System.out.println("NO"); continue;} int a = (n / 2);  int x = (int)Math.sqrt(a); if ( (((x * x) == a) || (((x + 1) * (x + 1)) == a))) {System.out.println("YES"); continue;} a = (n / 4); if ( ((n % 4) != 0)) {System.out.println("NO"); continue;} x = (int)Math.sqrt(a); if ( (((x * x) == a) || (((x + 1) * (x + 1)) == a))) {System.out.println("YES"); continue;} System.out.println("NO"); }} }
5	public class Solution implements Runnable{ public void solve()throws Exception { int n = sc.nextInt();  int a = sc.nextInt();  int b = sc.nextInt();  long h[] = new long[n]; for ( int i = 0;(i < n);++i) {h[i] = sc.nextLong(); }Arrays.sort(h); long l = h[(n - a)];  long r = h[((n - a) - 1)]; out.println((l - r)); } static String filename = ""; static boolean fromFile = false; BufferedReader in ; PrintWriter out ; FastScanner sc ; public static void main( String[] args){ new Thread(null,new Solution(),"",(1 << 25)).start(); } void init()throws Exception { if ( fromFile) {in = new BufferedReader(new FileReader((filename + ".in"))); out = new PrintWriter(new FileWriter((filename + ".out"))); } else {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); }sc = new FastScanner(in); } } 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());} public long nextLong()throws IOException { return Long.parseLong(nextToken());} }
5	public class A implements Runnable{ static private BufferedReader br = null; static private PrintWriter out = null; static private 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());} }
5	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),s = 0;  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); s += a[i]; }Arrays.sort(a); int k = 0,ans = 0; for ( int i = (n - 1);(i >= 0);i--) if ( (k <= (s / 2))) {k += a[i]; ans++; } System.out.println(ans); } }
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;} } }
5	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt();  long k = input.nextInt();  long[] nums = new long[n]; for ( int i = 0;(i < n);i++) {nums[i] = input.nextInt(); }Arrays.sort(nums); Set<Long> wrong = new TreeSet<Long>();  long ans = 0; for ( int i = 0;(i < n);i++) {if ( !wrong.contains(nums[i])) {try{wrong.add((nums[i] * k)); }catch (Exception e){ } ans++; } }System.out.println(ans); } }
5	public class A135{ 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[] ans = new int[n]; if ( (arr[(n - 1)] == 1)) {for ( int i = 0;(i < n);i++) {ans[i] = arr[i]; }ans[(n - 1)] = 2; } else {ans[0] = 1; for ( int i = 1;(i < n);i++) {ans[i] = arr[(i - 1)]; }} StringBuffer buf = new StringBuffer(); for ( int i = 0;(i < n);i++) {buf.append(ans[i]); if ( (i != (n - 1))) buf.append(' '); }System.out.print(buf.toString()); } }
1	public class Solution{ StreamTokenizer in ; PrintWriter out ; public static void main( String[] args)throws Exception { new Solution().run(); } public void run()throws Exception { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} String next()throws Exception { in.nextToken(); return in.sval;} public void solve()throws Exception { int n = nextInt();  String s = next();  String ss = (s + s);  int t = 0; for ( int i = 0;(i < n);i++) {if ( (s.charAt(i) == 'T')) {t++; } }if ( ((t == 1) || (t == (n - 1)))) {out.println(0); } else { int sum = 0; for ( int i = 0;(i < t);i++) {if ( (s.charAt(i) == 'T')) {sum++; } } int max = sum; for ( int i = 0;(i < s.length());i++) {if ( (ss.charAt(i) == 'T')) {if ( (ss.charAt((i + t)) == 'H')) {sum--; } } else {if ( (ss.charAt((i + t)) == 'T')) {sum++; max = Math.max(max,sum); } }}out.println((t - max)); }} }
1	public class Main{ static int mod = 1000000007; static ArrayList<Integer> cd[] ; static int K = 0; public static void main( String[] args)throws Exception,IOException { Reader sc = new Reader(System.in);  int n = sc.nextInt();  int a = sc.nextInt(),b = sc.nextInt(),d[] = new int[n];  HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();  ArrayList<Integer> A = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {d[i] = sc.nextInt(); map.put(d[i],i); } int c = 1; if ( (a > b)) {c--; int x = a; a = b; b = x; } int r[] = new int[n]; if ( (a == b)) {for ( int i = 0;(i < n);i++) {if ( ((d[i] > a) || !map.containsKey((a - d[i])))) {System.out.println("NO"); return ;} }System.out.println("YES"); for ( int i = 0;(i < n);i++) {System.out.print("1 "); }System.out.println(); return ;} sort(d); for ( int j = 0;(j < n);j++) { int i = ((n - j) - 1);  int id = map.get(d[i]),idd = -1; if ( (id < 0)) continue; if ( (d[i] <= a)) {if ( (map.containsKey((a - d[i])) && (0 <= (idd = map.get((a - d[i])))))) {r[id] = r[idd] = ((c + 1) % 2); map.put((a - d[i]),-1); } else if ( (map.containsKey((b - d[i])) && (0 <= (idd = map.get((b - d[i])))))) {r[id] = r[idd] = c; map.put((b - d[i]),-1); } else {System.out.println("NO"); return ;}} else {if ( (map.containsKey((b - d[i])) && (0 <= (idd = map.get((b - d[i])))))) {r[id] = r[idd] = c; map.put((b - d[i]),-1); } else {System.out.println("NO"); return ;}}map.put(d[i],-1); }System.out.println("YES"); for ( int j = 0;(j < n);j++) {System.out.print((r[j] + " ")); }System.out.println(); } } 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());} }
5	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = (in.nextInt() - 1);  Point[] A = new Point[n]; for ( int i = 0;(i < n);i++) A[i] = new Point(in.nextInt(),in.nextInt()); Arrays.sort(A,new Comparator<Point>(){}); int i = k;  int j = k; while((((i >= 0) && (A[i].x == A[k].x)) && (A[i].y == A[k].y)))i--; while((((j < n) && (A[j].x == A[k].x)) && (A[j].y == A[k].y)))j++; System.out.println(((j - i) - 1)); } }
0	public class Hexadecimal{ public static void main( String[] args){ Scanner s = new Scanner(new InputStreamReader(System.in));  int x = s.nextInt(); System.out.println(((((x + " ") + 0) + " ") + 0)); } }
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);  APaintTheNumbers solver = new APaintTheNumbers(); solver.solve(1,in,out); out.close(); } static class APaintTheNumbers{ public void solve( int testNumber, FastReader s, PrintWriter w){ int n = s.nextInt();  boolean[] b = new boolean[n];  int[] a = new int[n];  int ans = 0; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); }func.sort(a); for ( int i = 0;(i < n);i++) {if ( !b[i]) {ans++; b[i] = true; for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {b[j] = true; } }} }w.println(ans); } } static class FastReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private FastReader.SpaceCharFilter filter ; public FastReader( 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 (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
4	public class Main{ public static void solve(){ int n = in.nextInt();  ArrayList<Integer> ans = new ArrayList<>(); out.println(in.nextInt()); ans.add(1); for ( int i = 0;(i < (n - 1));i++) { int cur = in.nextInt(); if ( (ans.isEmpty() || (cur == 1))) ans.add(cur); else {while((ans.isEmpty() && ((ans.get((ans.size() - 1)) + 1) != cur)))ans.remove((ans.size() - 1)); if ( !ans.isEmpty()) ans.remove((ans.size() - 1)); ans.add(cur); } int cnt = 0; for ( int j :ans) {cnt++; out.print((j + ((cnt == ans.size())?"":"."))); }out.println(); }} public static void main( String[] args){ in = new Reader(); out = new Writer(); int t = in.nextInt(); while((t-- > 0))solve(); out.exit(); } static Reader in ; static Writer out ; static class Reader{ static BufferedReader br ; static StringTokenizer st ; public Reader(){ this.br = new BufferedReader(new InputStreamReader(System.in)); } public Reader( String f){ try{this.br = new BufferedReader(new FileReader(f)); }catch (IOException e){ e.printStackTrace(); } } public int nextInt(){ ensureNext(); return Integer.parseInt(st.nextToken());} public double nextDouble(){ ensureNext(); return Double.parseDouble(st.nextToken());} public Long nextLong(){ ensureNext(); return Long.parseLong(st.nextToken());} public String next(){ ensureNext(); return st.nextToken();} private void ensureNext(){ if ( ((st == null) || !st.hasMoreTokens())) {try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } } } } static class Writer{ private PrintWriter pw ; public Writer(){ pw = new PrintWriter(System.out); } public Writer( String f){ try{pw = new PrintWriter(new FileWriter(f)); }catch (IOException e){ e.printStackTrace(); } } public void print( Object o){ pw.print(o.toString()); } public void println( Object o){ pw.println(o.toString()); } public void println(){ pw.println(); } public void flush(){ pw.flush(); } public void exit(){ pw.close(); } } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader inp = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Solver solver = new Solver(); solver.solve(inp,out); out.close(); } static class Solver{ class Node implements Comparable<Node>{ int i ; int cnt ; Node( int i, int cnt){ this.i = i; this.cnt = cnt; } } public int findSet( int i, int[] par){ int x = i;  boolean flag = false; while((par[i] >= 0)){flag = true; i = par[i]; }if ( flag) par[x] = i; return i;} public long pow( long a, long b, long MOD){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long val = pow(a,(b / 2),MOD); if ( ((b % 2) == 0)) {return ((val * val) % MOD);} else {return ((val * ((val * a) % MOD)) % MOD);}} public void remove( ArrayList<Integer>[] al, int x){ for ( int i = 0;(i < al.length);i++) {for ( int j = 0;(j < al[i].size());j++) {if ( (al[i].get(j) == x)) al[i].remove(j); }}} public long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} public static long constructSegment( long[] seg, long[] arr, int low, int high, int pos){ if ( (low == high)) {seg[pos] = arr[low]; return seg[pos];} int mid = ((low + high) / 2);  long t1 = constructSegment(seg,arr,low,mid,((2 * pos) + 1));  long t2 = constructSegment(seg,arr,(mid + 1),high,((2 * pos) + 2)); seg[pos] = (t1 + t2); return seg[pos];} public static long querySegment( long[] seg, int low, int high, int qlow, int qhigh, int pos){ if ( ((qlow <= low) && (qhigh >= high))) {return seg[pos];} else if ( ((qlow > high) || (qhigh < low))) {return 0;} else { long ans = 0;  int mid = ((low + high) / 2); ans += querySegment(seg,low,mid,qlow,qhigh,((2 * pos) + 1)); ans += querySegment(seg,(mid + 1),high,qlow,qhigh,((2 * pos) + 2)); return ans;}} public static int lcs( char[] X, char[] Y, int m, int n){ if ( ((m == 0) || (n == 0))) return 0; if ( (X[(m - 1)] == Y[(n - 1)])) return (1 + lcs(X,Y,(m - 1),(n - 1))); else return Integer.max(lcs(X,Y,m,(n - 1)),lcs(X,Y,(m - 1),n));} public static long recursion( long start, long end, long[] cnt, int a, int b){ long min = 0;  long count = 0;  int ans1 = -1;  int ans2 = -1;  int l = 0;  int r = (cnt.length - 1); while((l <= r)){ int mid = ((l + r) / 2); if ( (cnt[mid] >= start)) {ans1 = mid; r = (mid - 1); } else {l = (mid + 1); }}l = 0; r = (cnt.length - 1); while((l <= r)){ int mid = ((l + r) / 2); if ( (cnt[mid] <= end)) {ans2 = mid; l = (mid + 1); } else {r = (mid - 1); }}if ( (((ans1 == -1) || (ans2 == -1)) || (ans2 < ans1))) {min = a; return a;} else {min = ((b * ((end - start) + 1)) * ((ans2 - ans1) + 1)); }if ( (start == end)) {return min;} long mid = ((end + start) / 2); min = Long.min(min,(recursion(start,mid,cnt,a,b) + recursion((mid + 1),end,cnt,a,b))); return min;} public int dfs_util( ArrayList<Integer>[] al, boolean[] vis, int x, int[] s, int[] lvl){ vis[x] = true; int cnt = 1; for ( int i = 0;(i < al[x].size());i++) {if ( !vis[al[x].get(i)]) {lvl[al[x].get(i)] = (lvl[x] + 1); cnt += dfs_util(al,vis,al[x].get(i),s,lvl); } }s[x] = cnt; return s[x];} private void solve( InputReader inp, PrintWriter out1){ int n = inp.nextInt();  int m = inp.nextInt();  long k = inp.nextLong();  long arr[] = new long[n]; for ( int i = 0;(i < n);i++) {arr[i] = inp.nextLong(); } long ans = 0; for ( int i = 0;(i < m);i++) { long sum = 0; for ( int j = i;(j < n);j++) {if ( ((j % m) == i)) {if ( (sum < 0)) {sum = 0; } sum -= k; } sum += arr[j]; ans = Math.max(ans,sum); }}System.out.println(ans); } } static class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream),32768); tokenizer = null; } 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());} } }
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[] arr = new int[n];  HashMap<Integer,Integer> map = new HashMap<>();  StringTokenizer st = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) { int x = Integer.parseInt(st.nextToken()); arr[i] = x; if ( !map.containsKey(x)) {map.put(x,1); } else {map.replace(x,(map.get(x) + 1)); }} int[] power = new int[31]; for ( int i = 0;(i < 31);i++) {power[i] = (1 << i); } int c = 0; for ( int i = 0;(i < n);i++) { boolean f = false; for ( int j = 0;(j <= 30);j++) { int check = (power[j] - arr[i]); if ( (map.containsKey(check) && (check != arr[i]))) {f = true; break;} if ( ((map.containsKey(check) && (check == arr[i])) && (map.get(check) >= 2))) {f = true; break;} }if ( !f) {c++; } }System.out.println(c); } }
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());} }
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; } } }
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{ static private 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);} } }
6	public class E2{ 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[m][(n + 1)]; for ( int i = 0;(i < n);i++) {ntok(); for ( int e = 0;(e < m);e++) {mat[e][i] = ipar(); }}for ( int i = 0;(i < m);i++) {for ( int e = 0;(e < n);e++) {mat[i][n] = Math.max(mat[i][n],mat[i][e]); }} ArrayList<int[]> list = new ArrayList<>(); for ( int i = 0;(i < m);i++) {list.add(mat[i]); }Collections.sort(list,(a,b)->{return -Integer.compare(a[n],b[n]);}); for ( int i = 0;(i < m);i++) {mat[i] = list.get(i); }m = Math.min(m,n); int[][] dp = new int[(1 << n)][(m + 1)]; for ( int i = (m - 1);(i >= 0);i--) { int[] temp = new int[(1 << n)]; for ( int r = 0;(r < n);r++) {for ( int j = 0;(j < (1 << n));j++) {temp[j] = dp[j][(i + 1)]; }for ( int j = 0;(j < n);j++) { int val = mat[i][((j + r) % n)]; for ( int k = 0;(k < (1 << n));k++) {if ( ((k & (1 << j)) == 0)) {temp[(k | (1 << j))] = Math.max(temp[(k | (1 << j))],(temp[k] + val)); } }}for ( int j = 0;(j < (1 << n));j++) {dp[j][i] = Math.max(dp[j][i],temp[j]); }}}out.println(dp[((1 << n) - 1)][0]); }out.flush(); in.close(); } public void ntok()throws IOException { tok = new StringTokenizer(in.readLine()); } public int ipar(){ return Integer.parseInt(tok.nextToken());} public long lpar(){ return Long.parseLong(tok.nextToken());} public static void main( String[] args)throws IOException { new E2().go(); } }
1	public class B{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int distinct = sc.nextInt();  HashMap<Integer,Integer> set = new HashMap<Integer,Integer>();  int[] ar = new int[n]; for ( int i = 0;(i < n);i++) {ar[i] = sc.nextInt(); if ( set.containsKey(ar[i])) {set.put(ar[i],(set.get(ar[i]) + 1)); } else {set.put(ar[i],1); }if ( (set.size() == distinct)) { int st = 0; for ( int j = 0;(j < i);j++) {st = j; if ( (set.get(ar[j]) > 1)) {set.put(ar[j],(set.get(ar[j]) - 1)); } else {break;}}System.out.println((((st + 1) + " ") + (i + 1))); return ;} }System.out.println("-1 -1"); } }
1	public class Main{ Main()throws IOException{ String a = nextLine();  String b = nextLine();  long ans = 0;  int s = 0; for ( int i = 0;(i < (b.length() - a.length()));++i) {s += ((b.charAt(i) == '1')?1:0); }for ( int i = 0;(i < a.length());++i) {s += ((b.charAt(((i + b.length()) - a.length())) == '1')?1:0); ans += ((a.charAt(i) == '1')?(((b.length() - a.length()) + 1) - s):s); s -= ((b.charAt(i) == '1')?1:0); }out.println(ans); } PrintWriter out = new PrintWriter(System.out,false); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer stok = null; String nextLine()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){stok = new StringTokenizer(in.readLine()); }return stok.nextToken();} public static void main( String[] args)throws IOException { if ( (args.length > 0)) {setIn(new FileInputStream((args[0] + ".inp"))); setOut(new PrintStream((args[0] + ".out"))); } Main solver = new Main(); solver.out.flush(); } }
4	public class template{ public static void main( String[] args)throws Exception { new template().run(); } long MOD = 1_000_000_007; public void run()throws Exception { FastScanner f = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int n = f.nextInt(),m = f.nextInt();  int[] t = new int[n],g = new int[n],c = new int[3]; for ( int i = 0;(i < n);i++) {t[i] = f.nextInt(); c[g[i] = (f.nextInt() - 1)]++; } long[][] dp1 = new long[(c[0] + 1)][(m + 1)];  long[][][] dp2 = new long[(c[1] + 1)][(c[2] + 1)][(m + 1)]; dp1[0][0] = 1; dp2[0][0][0] = 1; for ( int i = 0;(i < n);i++) {if ( (g[i] == 0)) {for ( int j = (dp1.length - 2);(j >= 0);j--) for ( int k = (m - t[i]);(k >= 0);k--) dp1[(j + 1)][(k + t[i])] = ((dp1[(j + 1)][(k + t[i])] + dp1[j][k]) % MOD); } else if ( (g[i] == 1)) {for ( int j = (dp2.length - 2);(j >= 0);j--) for ( int k = (dp2[j].length - 1);(k >= 0);k--) for ( int l = (m - t[i]);(l >= 0);l--) dp2[(j + 1)][k][(l + t[i])] = ((dp2[(j + 1)][k][(l + t[i])] + dp2[j][k][l]) % MOD); } else {for ( int j = (dp2.length - 1);(j >= 0);j--) for ( int k = (dp2[j].length - 2);(k >= 0);k--) for ( int l = (m - t[i]);(l >= 0);l--) dp2[j][(k + 1)][(l + t[i])] = ((dp2[j][(k + 1)][(l + t[i])] + dp2[j][k][l]) % MOD); }} long[][][][] combo = new long[(c[0] + 1)][(c[1] + 1)][(c[2] + 1)][3]; if ( (c[0] != 0)) combo[1][0][0][0] = 1; if ( (c[1] != 0)) combo[0][1][0][1] = 1; if ( (c[2] != 0)) combo[0][0][1][2] = 1; for ( int i = 0;(i <= c[0]);i++) {for ( int j = 0;(j <= c[1]);j++) {for ( int k = 0;(k <= c[2]);k++) {for ( int a = 0;(a < 3);a++) {if ( ((a != 0) && (i < c[0]))) combo[(i + 1)][j][k][0] = ((combo[(i + 1)][j][k][0] + ((combo[i][j][k][a] * (i + 1)) % MOD)) % MOD); if ( ((a != 1) && (j < c[1]))) combo[i][(j + 1)][k][1] = ((combo[i][(j + 1)][k][1] + ((combo[i][j][k][a] * (j + 1)) % MOD)) % MOD); if ( ((a != 2) && (k < c[2]))) combo[i][j][(k + 1)][2] = ((combo[i][j][(k + 1)][2] + ((combo[i][j][k][a] * (k + 1)) % MOD)) % MOD); }}}} long ans = 0; for ( int s = 0;(s <= m);s++) {for ( int x = 0;(x <= c[0]);x++) for ( int y = 0;(y <= c[1]);y++) for ( int z = 0;(z <= c[2]);z++) {ans = ((ans + ((((dp1[x][s] * dp2[y][z][(m - s)]) % MOD) * (((combo[x][y][z][0] + combo[x][y][z][1]) + combo[x][y][z][2]) % MOD)) % MOD)) % MOD); }}out.println(ans); out.flush(); } static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
6	public class D11{ static StreamTokenizer in ; static PrintWriter out ; static int nextInt()throws IOException { in.nextToken(); return (int)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(); m = nextInt(); g = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (nextInt() - 1),b = (nextInt() - 1); g[a][b] = g[b][a] = true; } long ans = 0; for ( int i = n;(i > 0);i--) { long cur = calc(g,(i - 1)); ans += cur; }out.println((ans / 2)); out.flush(); } static int n ,m ,V ; static boolean[][] g ; static long calc( boolean[][] bs, int n){ long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {if ( bs[i][n]) dp[(1 << i)][i]++; }for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) if ( (((i >> j) & 1) == 1)) for ( int k = 0;(k < n);k++) if ( ((((i >> k) & 1) == 0) && bs[j][k])) {dp[(i | (1 << k))][k] += dp[i][j]; } } long res = 0; for ( int i = 0;(i < (1 << n));i++) for ( int j = 0;(j < n);j++) if ( ((Integer.bitCount(i) >= 2) && bs[j][n])) res += dp[i][j]; return res;} }
3	public class typeA{ public static void main( String[] args){ FastReader s = new FastReader();  int n = s.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); } boolean[] arr2 = new boolean[n]; Arrays.sort(arr); for ( int i = 0;(i < arr2.length);i++) {arr2[i] = true; }for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) {arr2[j] = false; } }} int count = 0; for ( int i = 0;(i < n);i++) {if ( (arr2[i] == true)) {count++; } }System.out.println(count); } 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	public class Main{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer tokenizer = new StringTokenizer(reader.readLine());  int n = Integer.parseInt(tokenizer.nextToken());  int k = Integer.parseInt(tokenizer.nextToken()); System.out.println((int)(n - ((-3.0 + Math.sqrt((9.0 + (8.0 * (n + k))))) / 2.0))); } }
3	public class D_Edu_Round_35{ public static long MOD = 1000000007; public static void main( String[] args)throws FileNotFoundException { PrintWriter out = new PrintWriter(System.out);  Scanner in = new Scanner();  int n = in.nextInt();  int[] data = new int[n]; for ( int i = 0;(i < n);i++) {data[i] = in.nextInt(); } FT tree = new FT((n + 1));  int result = 0; for ( int i = (n - 1);(i >= 0);i--) {tree.update(data[i],1); result += tree.get((data[i] - 1)); result %= 2; } int q = in.nextInt();  int[] tmp = new int[n]; for ( int i = 0;(i < q);i++) { int l = (in.nextInt() - 1);  int r = (in.nextInt() - 1);  FT a = new FT((n + 1));  int total = ((r - l) + 1); total = ((total * (total - 1)) / 2); total %= 2; result += total; result %= 2; if ( ((result % 2) == 0)) {out.println("even"); } else {out.println("odd"); }}out.close(); } public static class FT{ int[] data ; FT( int n){ data = new int[n]; } public void update( int index, int value){ while((index < data.length)){data[index] += value; data[index] %= 2; index += (index & index); }} public int get( int index){ int result = 0; while((index > 0)){result += data[index]; result %= 2; index -= (index & index); }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, long MOD){ if ( (b == 0)) {return 1;} if ( (b == 1)) {return a;} long val = pow(a,(b / 2),MOD); 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(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 A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  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 cnt = 0; for ( int i = (n - 1);(i >= 0);i--) {if ( (k >= m)) {System.out.println(cnt); return ;} cnt++; k += (A[i] - 1); }if ( (k >= m)) System.out.println(cnt); else System.out.println(-1); } }
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){ long n = in.nextLong(); if ( (n == 1)) out.println("1"); else if ( (n == 2)) out.println("2"); else if ( ((n % 2) == 1)) out.println(((n * (n - 1)) * (n - 2))); else if ( ((n % 6) == 0)) out.println((((n - 1) * (n - 2)) * (n - 3))); else out.println(((n * (n - 1)) * (n - 3))); } }
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);  DExplorerSpace solver = new DExplorerSpace(); solver.solve(1,in,out); out.close(); } static class DExplorerSpace{ int n ; int m ; int k ; int[][] col ; int[][] row ; long[][][] memo ; public void readInput( Scanner sc){ n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); col = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < (m - 1));j++) col[i][j] = sc.nextInt(); row = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) for ( int j = 0;(j < m);j++) row[i][j] = sc.nextInt(); } public void solve( int testNumber, Scanner sc, PrintWriter pw){ int q = 1; while((q-- > 0)){readInput(sc); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) pw.print((-1 + " ")); pw.println(); }return ;} memo = new long[(k + 1)][n][m]; for ( long[][] x :memo) for ( long[] y :x) Arrays.fill(y,-1); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {pw.print(((2l * dp(i,j,(k / 2))) + " ")); }pw.println(); }}} private long dp( int i, int j, int rem){ if ( (rem == 0)) return 0; if ( (memo[rem][i][j] != -1)) return memo[rem][i][j]; long min = (long)1e18; if ( (j <= (m - 2))) min = Math.min(min,(col[i][j] + dp(i,(j + 1),(rem - 1)))); if ( (j > 0)) min = Math.min(min,(col[i][(j - 1)] + dp(i,(j - 1),(rem - 1)))); if ( (i <= (n - 2))) min = Math.min(min,(row[i][j] + dp((i + 1),j,(rem - 1)))); if ( (i > 0)) min = Math.min(min,(row[(i - 1)][j] + dp((i - 1),j,(rem - 1)))); return memo[rem][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{ static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); static Scanner sc = new Scanner(System.in); static PrintWriter out = new PrintWriter(System.out); static final int inf = 10000000; public static void main( String[] args)throws Exception { double n ,k ; n = sc.nextDouble(); k = sc.nextDouble(); double ans = 0; ans = (Math.sqrt((2.25 + (2 * (n + k)))) - 1.5); System.out.printf("%.0f\n",(n - ans)); } }
6	public class Main{ static private final int SIM = 1; static private final int NAO = 2; public static void main( String[] args){ Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int n = in.nextInt();  int m = in.nextInt();  int[][] a = new int[n][m];  int[][] graphVerticial = null;  int[][] graphDiagonal = null; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {a[i][j] = in.nextInt(); }}graphVerticial = createGraphVertical(n,m,a); graphDiagonal = createGraphDiagonal(n,m,a); int result = 0;  int k = 1;  int piso = 0;  int teto = 1000000000; while(true){k = ((int)Math.ceil(((teto - piso) / 2.0)) + piso); if ( isOk(n,k,graphVerticial,graphDiagonal)) {result = Math.max(result,k); piso = k; } else {teto = (k - 1); }if ( (teto <= piso)) break; }System.out.println(result); } public static int[][] createGraphVertical( int n, int m, int[][] a){ int[][] graph = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i == j)) continue; if ( (i > j)) {graph[i][j] = graph[j][i]; continue;} graph[i][j] = Integer.MAX_VALUE; for ( int k = 0;(k < m);k++) {graph[i][j] = Math.min(graph[i][j],Math.abs((a[i][k] - a[j][k]))); }}}return graph;} public static int[][] createGraphDiagonal( int n, int m, int[][] a){ int[][] graph = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {graph[i][j] = Integer.MAX_VALUE; for ( int k = 0;(k < (m - 1));k++) {graph[i][j] = Math.min(graph[i][j],Math.abs((a[j][k] - a[i][(k + 1)]))); }}}return graph;} public static int hasPath( int n, int k, int origem, int destino, int conjunto, int[][] graph, int[][][] pd){ if ( (pd[origem][destino][conjunto] != 0)) return pd[origem][destino][conjunto]; if ( (conjunto == 0)) {return ((origem == destino)?SIM:NAO);} else if ( (origem == destino)) {return NAO;} for ( int i = 0;(i < n);i++) {if ( (i == origem)) continue; int novoConjunto = (conjunto - (1 << i));  boolean pertenceConjunto = (((conjunto >> i) % 2) == 1); if ( ((pertenceConjunto && (graph[origem][i] >= k)) && (hasPath(n,k,i,destino,novoConjunto,graph,pd) == SIM))) {pd[origem][destino][conjunto] = SIM; return pd[origem][destino][conjunto];} }pd[origem][destino][conjunto] = NAO; return pd[origem][destino][conjunto];} public static boolean isOk( int n, int k, int[][] graphVertical, int[][] graphDiagonal){ int conjunto = ((int)Math.pow(2,n) - 1);  int[][][] pd = new int[n][n][(int)Math.pow(2,n)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( ((i == j) && (n > 1))) continue; int novoConjunto = (conjunto - (1 << i)); if ( ((graphDiagonal[i][j] >= k) && (hasPath(n,k,i,j,novoConjunto,graphVertical,pd) == SIM))) {return true;} }}return false;} public static void print( int[][] graph){ for ( int i = 0;(i < graph.length);i++) {for ( int j = 0;(j < graph.length);j++) {System.out.print((graph[i][j] + " ")); }System.out.println(); }} public static void print( int n){ List<Integer> bits = new Vector<>(); while((n > 0)){bits.add((n % 2)); n /= 2; }for ( int i = (bits.size() - 1);(i >= 0);i--) {System.out.print(bits.get(i)); }System.out.println(); } }
0	public class e{ 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)); }} 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>();  int n = in.nextInt();  int r = in.nextInt();  double theta = ((double)360 / (double)n);  double b = (1 - ((double)2 / (double)(1 - Math.cos((((double)2 * Math.PI) / (double)n)))));  double x = (Math.sqrt((1 - b)) - 1);  double ans = ((double)r / (double)x); System.out.println(ans); } }
5	public class codeforces{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt();  long U = in.nextLong();  long[] E = new long[n];  double max = -1; for ( int i = 0;(i < n);i++) E[i] = in.nextLong(); for ( int k = 1;(k < (n - 1));k++) { int i = (k + 1),j = (n - 1),mid = 0;  double T = 0; while((i < j)){mid = (int)Math.ceil(((double)(i + j) / 2)); if ( ((E[mid] - E[(k - 1)]) <= U)) i = mid; else j = (mid - 1); }j = k; k = i; i = (j - 1); T = (E[k] - E[j]); T /= (E[k] - E[i]); if ( ((E[k] - E[i]) <= U)) max = Math.max(max,T); k = j; }pw.println(max); pw.flush(); pw.close(); } public static long GCD( long a, long b){ if ( (b == 0)) return a; else return GCD(b,(a % b));} 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); } } }
5	public class Main{ public static void main( String[] args){ new Main().run(); } void run(){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  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 ret = 0,it = 0; for ( int i = 0;(i < n);++i) { int val = (((a[i] % k) == 0)?(a[i] / k):-1); while(((it < i) && (a[it] < val)))++it; if ( ((it == i) || (a[it] != val))) {++ret; } else {a[i] = 0; }}out.println(ret); out.close(); } } class InputReader{ BufferedReader buff ; StringTokenizer tokenizer ; InputReader( InputStream stream){ buff = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } boolean hasNext(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens()))try{tokenizer = new StringTokenizer(buff.readLine()); }catch (Exception e){ return false;} return true;} String next(){ if ( !hasNext()) throw (new RuntimeException()); return tokenizer.nextToken();} int nextInt(){ return Integer.parseInt(next());} }
0	public class CF{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  TaskA t = new TaskA(); System.out.println(t.solve(n)); } } class TaskA{ public long solve( long n){ if ( (n < 3)) return n; else if ( ((n % 2) == 1)) return ((n * (n - 1)) * (n - 2)); else if ( ((n % 3) != 0)) return ((n * (n - 1)) * (n - 3)); else return (((n - 1) * (n - 2)) * (n - 3));} }
1	public class B{ public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static void main( String[] args)throws IOException { readInput(); out.close(); } static boolean sq( long x){ long l = 1;  long r = ((int)Math.sqrt(1e16) + 1); while(((l + 1) < r)){ long m = ((l + r) >> 1); if ( ((m * m) > x)) r = m; else l = m; }return ((l * l) == x);} static boolean solve( long x){ if ( ((x & 1) == 1)) return false; if ( ((x & (x - 1)) == 0)) return true; long num = 2; while(((num < x) && ((x % num) == 0))){if ( sq((x / num))) return true; num *= 2; }return false;} public static void readInput()throws IOException { int t = Integer.parseInt(br.readLine()); while((t-- > 0)){ int x = Integer.parseInt(br.readLine()); out.println((solve(x)?"YES":"NO")); }} }
0	public class LCMChallenge{ 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) == 1)) {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))); }}} }
3	public class Main{ static private final int MAX = (5000 + 10),mod = 1000000007; static private char[] S ; static private int n ; static private Integer[][] dp = new Integer[MAX][MAX]; static private int solve( int pos, int open){ if ( (pos == n)) return ((open == 0)?1:0); if ( (dp[pos][open] != null)) return dp[pos][open]; int res = 0; if ( (S[pos] == 's')) {res = solve((pos + 1),open); if ( (open > 0)) res += solve(pos,(open - 1)); if ( (res >= mod)) res -= mod; } else {res = solve((pos + 1),(open + 1)); }return dp[pos][open] = res;} public static void main( String[] args)throws Exception { IO io = new IO(null,null); n = io.getNextInt(); S = new char[n]; for ( int i = 0;(i < n);i++) S[i] = io.getNext().charAt(0); io.println(solve(0,0)); io.close(); } } class IO{ private BufferedReader br ; private StringTokenizer st ; private PrintWriter writer ; private String inputFile ,outputFile ; public String getNext()throws FileNotFoundException,IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int getNextInt()throws FileNotFoundException,IOException { return Integer.parseInt(getNext());} public void print( double x, int num_digits)throws IOException { writer.printf((("%." + num_digits) + "f"),x); } public void println( double x, int num_digits)throws IOException { writer.printf((("%." + num_digits) + "f\n"),x); } public void print( Object o)throws IOException { writer.print(o.toString()); } public void println( Object o)throws IOException { writer.println(o.toString()); } public IO( String x, String y)throws FileNotFoundException,IOException{ inputFile = x; outputFile = y; if ( (x != null)) br = new BufferedReader(new FileReader(inputFile)); else br = new BufferedReader(new InputStreamReader(System.in)); if ( (y != null)) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile))); else writer = new PrintWriter(new OutputStreamWriter(System.out)); } protected void close()throws IOException { br.close(); writer.close(); } }
1	public class A{ int n ; void run()throws IOException { Scanner sc = new Scanner(new InputStreamReader(System.in)); n = sc.nextInt(); int i ,tmp ,even ,odd ,e ,o ; even = odd = e = o = 0; for ( i = 1;(i <= n);i++) {tmp = sc.nextInt(); if ( ((tmp % 2) == 0)) {e++; if ( (even == 0)) even = i; } else {o++; if ( (odd == 0)) odd = i; }}if ( (e > 1)) System.out.println(odd); else System.out.println(even); } public static void main( String[] args)throws IOException { new A().run(); } }
5	public class Main{ static private StreamTokenizer in ; static private PrintWriter out ; static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws Exception { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); int n = nextInt(),t = (nextInt() * 2);  int[][] a = new int[n][2]; for ( int i = 0;(i < n);i++) {a[i][0] = (nextInt() * 2); a[i][1] = (nextInt() * 2); }Arrays.sort(a,new Comparator<int[]>(){}); int s = 2; for ( int i = 0;(i < (n - 1));i++) { int g = ((a[(i + 1)][0] - a[i][0]) - ((a[(i + 1)][1] + a[i][1]) / 2)); if ( (g > t)) s += 2; if ( (g == t)) s += 1; }out.println(s); out.flush(); } }
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 A{ static StreamTokenizer st ; static PrintWriter pw ; static class Sort implements Comparable<Sort>{ int x ,y ; } public static void main( String[] args)throws IOException { st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt();  int k = nextInt();  Sort[] a = new Sort[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = new Sort(); a[i].x = nextInt(); a[i].y = nextInt(); }Arrays.sort(a,1,(n + 1)); int ans = 0; for ( int i = 1;(i <= n);i++) {if ( ((a[i].x == a[k].x) && (a[i].y == a[k].y))) ans++; }System.out.println(ans); pw.close(); } static private int nextInt()throws IOException { st.nextToken(); return (int)st.nval;} }
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 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());} } }
0	public class Main{ void solve( Scanner in, PrintWriter out){ 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(); } }
6	public class DarkAssembly extends Thread{ public DarkAssembly(){ this.input = new BufferedReader(new InputStreamReader(System.in)); this.output = new PrintWriter(System.out); this.setPriority(Thread.MAX_PRIORITY); } static class Senator{ int loyalty ; int level ; public Senator( int level, int loyalty){ this.level = level; this.loyalty = loyalty; } } static private double doIt( Senator[] senators, int A){ double probability = .0; for ( int mask = 0;(mask < (1 << senators.length));++mask) { int sum = A;  double current = 1.0; for ( int i = 0;(i < senators.length);++i) {if ( ((mask & (1 << i)) != 0)) {current *= (.01 * senators[i].loyalty); } else {current *= (.01 * (100 - senators[i].loyalty)); sum += senators[i].level; }}if ( (getOnes(mask) > (senators.length / 2))) {probability += current; } else {probability += ((current * (double)A) / sum); }}return probability;} static private double go( Senator[] senators, int candies, int A, int current){ if ( (current == senators.length)) {return doIt(senators,A);} else { double result = go(senators,candies,A,(current + 1)); if ( ((candies > 0) && (senators[current].loyalty < 100))) {senators[current].loyalty += 10; result = Math.max(result,go(senators,(candies - 1),A,current)); senators[current].loyalty -= 10; } return result;}} static int getOnes( int mask){ int result = 0; while((mask != 0)){mask &= (mask - 1); ++result; }return result;} public static void main( String[] args){ new DarkAssembly().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 BufferedReader input ; private PrintWriter output ; private StringTokenizer tokens = null; }
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());} }
1	public class Waw{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextLong(); long[] p = new long[n]; p[(n - 1)] = a[(n - 1)]; for ( int i = (n - 2);(i >= 0);i--) {if ( (a[i] < p[(i + 1)])) p[i] = (p[(i + 1)] - 1); else p[i] = a[i]; } long max = p[0];  long res = (p[0] - a[0]); for ( int i = 1;(i < n);i++) {if ( (max < p[i])) max = p[i]; res += (max - a[i]); }System.out.println(res); } }
6	public class CF_8C implements Runnable{ int[] step = new int[(1 << 24)]; int[] steplast = new int[(1 << 24)]; int n ; int vs[] = new int[24]; int vd[][] = new int[24][24]; int x_bag ,y_bag ; int x[] = new int[24],y[] = new int[24]; private void solve()throws IOException { x_bag = nextInt(); y_bag = nextInt(); n = nextInt(); for ( int i = 0;(i < n);i++) {x[i] = nextInt(); y[i] = nextInt(); }for ( int i = 0;(i < n);i++) {vs[i] = (2 * (((x[i] - x_bag) * (x[i] - x_bag)) + ((y[i] - y_bag) * (y[i] - y_bag)))); }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {vd[i][j] = (((((((x[i] - x_bag) * (x[i] - x_bag)) + ((y[i] - y_bag) * (y[i] - y_bag))) + ((x[j] - x_bag) * (x[j] - x_bag))) + ((y[j] - y_bag) * (y[j] - y_bag))) + ((x[i] - x[j]) * (x[i] - x[j]))) + ((y[i] - y[j]) * (y[i] - y[j]))); }}for ( int i = 1;(i < (1 << n));i++) { int j ,k = 0,l ,m ,lastState ; for ( j = 1;(((i & j) == 0) && (j < (1 << n)));j <<= 1) {k++; }lastState = (i & j); step[i] = (step[lastState] + vs[k]); steplast[i] = lastState; m = k; for ( l = (j << 1);(l < (1 << n));l <<= 1) {m++; if ( ((lastState & l) != 0)) {if ( (step[i] > (step[(lastState & l)] + vd[k][m]))) {step[i] = (step[(lastState & l)] + vd[k][m]); steplast[i] = (lastState & l); } } }}writer.println(step[((1 << n) - 1)]); int i = ((1 << n) - 1); writer.print("0 "); while((i != 0)){for ( int j = 1,m = 1;(j <= i);j <<= 1,m++) {if ( ((j & (i ^ steplast[i])) != 0)) {writer.print((m + " ")); } }writer.print("0 "); i = steplast[i]; }} public static void main( String[] args){ new CF_8C().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 Rules{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int a = in.nextInt();  double maxSpeed = in.nextInt();  double len = in.nextInt();  double delayDist = in.nextInt();  double delaySpeed = in.nextInt();  double timeToDelayAtMax = travelS(a,0.0,maxSpeed,delayDist);  double timeToDelayAtDelay = travelS(a,0.0,delaySpeed,delayDist); if ( (Math.abs((timeToDelayAtMax - timeToDelayAtDelay)) < 0.00001)) { double time = travelS(a,0.0,maxSpeed,len); System.out.printf("%.9f\n",time); return ;} double lowV = delaySpeed;  double highV = maxSpeed;  int loopCount = 1000;  double[] initial = null;  double[] secondary = null; while((loopCount-- > 0)){ double guessV = ((lowV + highV) / 2.0); initial = travelA(a,0.0,guessV); secondary = travelA(a,guessV,Math.min(delaySpeed,maxSpeed)); if ( ((initial[1] + secondary[1]) < delayDist)) {lowV = guessV; } else {highV = guessV; }} double totalTime = 0.0;  double finalSpeed = 0.0; initial = travelA(a,0.0,lowV); secondary = travelA(a,lowV,delaySpeed); totalTime = (initial[0] + secondary[0]); double totalDist = (initial[1] + secondary[1]); totalTime += ((delayDist - totalDist) / maxSpeed); totalTime += travelS(a,delaySpeed,maxSpeed,(len - delayDist)); System.out.printf("%.9f\n",totalTime); } public static double[] travelA( int a, double startSpeed, double endSpeed){ if ( (startSpeed > endSpeed)) a = -a;  double time = ((endSpeed - startSpeed) / a);  double dist = ((((0.5 * a) * time) * time) + (startSpeed * time)); return new double[]{time,dist};} public static double travelS( int a, double startSpeed, double maxSpeed, double dist){ double timeToMax = ((maxSpeed - startSpeed) / a);  double targetTime = ((-startSpeed + Math.sqrt(((startSpeed * startSpeed) + ((2 * a) * dist)))) / a); if ( (targetTime < timeToMax)) return targetTime; double partialDist = ((((0.5 * timeToMax) * timeToMax) * a) + (startSpeed * timeToMax));  double remainingDist = (dist - partialDist); targetTime = (remainingDist / maxSpeed); return (targetTime + timeToMax);} }
2	public class B{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; long f( int x, int y, int sz){ if ( (x > y)) { int tmp = x; x = y; y = tmp; } if ( (sz <= x)) return (((long)sz * (sz + 1)) / 2); if ( (sz >= ((x + y) - 1))) return ((long)x * y); long val = ((x * (x + 1)) / 2); if ( (sz <= y)) return (val + ((long)(sz - x) * x)); long rest = (((x + y) - 1) - sz); return (((long)x * y) - (((long)rest * (rest + 1)) / 2));} long count( int x, int y, int n, int time){ long DL = f((x + 1),(y + 1),(time + 1));  long DR = f((n - x),(y + 1),(time + 1));  long UL = f((x + 1),(n - y),(time + 1));  long UR = f((n - x),(n - y),(time + 1));  long L = Math.min((x + 1),(time + 1));  long R = Math.min((n - x),(time + 1));  long U = Math.min((n - y),(time + 1));  long D = Math.min((y + 1),(time + 1)); return ((((((((DL + DR) + UL) + UR) - L) - R) - U) - D) + 1);} void solve()throws IOException { int n = nextInt();  int x = (nextInt() - 1);  int y = (nextInt() - 1);  long need = nextLong(); if ( (need == 1)) {out.println(0); return ;} int low = 0;  int high = (Math.max(x,((n - 1) - x)) + Math.max(y,((n - 1) - y))); while((low < (high - 1))){ int mid = (int)(((long)low + high) / 2); if ( (count(x,y,n,mid) >= need)) high = mid; else low = mid; }out.println(high); } B()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 B(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} }
4	public class Main{ static ArrayList<Edge> graph ; static ArrayList<ArrayList<Integer>> graphForKuhn ; static int n ,m ,u = 0; static int mt[] ; static int used[] ; public static void main( String[] args){ formGraph(); System.out.println(getAnswer()); } static boolean kuhn( int start){ if ( (used[start] == u)) return false; used[start] = u; for ( int i = 0;(i < graphForKuhn.get(start).size());i++) { int to = graphForKuhn.get(start).get(i); if ( ((mt[to] == -1) || kuhn(mt[to]))) {mt[to] = start; return true;} }return false;} static private int getAnswer(){ int currentAnswer = Integer.MAX_VALUE; for ( int cur = 0;(cur < n);cur++) { int adj = 0,otheradj = 0,answer = 0; for ( int j = 0;(j < n);j++) {graphForKuhn.get(j).clear(); mt[j] = -1; }for ( int j = 0;(j < m);j++) {if ( ((graph.get(j).from == cur) || (graph.get(j).to == cur))) adj++; else {graphForKuhn.get(graph.get(j).from).add(graph.get(j).to); otheradj++; }}for ( int j = 0;(j < n);j++) {u++; kuhn(j); } int tsz = 0; for ( int j = 0;(j < n);j++) {if ( (mt[j] != -1)) tsz++; }answer = ((((((2 * (n - 1)) + 1) - adj) + otheradj) - (2 * tsz)) + (n - 1)); currentAnswer = Math.min(answer,currentAnswer); }return currentAnswer;} static private void formGraph(){ Scanner in = new Scanner(System.in); n = in.nextInt(); m = in.nextInt(); graph = new ArrayList<Edge>(m); for ( int i = 0;(i < m);i++) { int x = in.nextInt();  int y = in.nextInt(); graph.add(new Edge((x - 1),(y - 1))); }graphForKuhn = new ArrayList<ArrayList<Integer>>(n); for ( int i = 0;(i < n);i++) graphForKuhn.add(new ArrayList<Integer>(n)); mt = new int[n]; used = new int[n]; in.close(); } } class Edge{ int from ; int to ; public Edge( int from, int to){ this.from = from; this.to = to; } }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int f1 = 0;  int f2 = 1;  int f3 = 1; while((f3 < n)){f1 = f2; f2 = f3; f3 = (f1 + f2); }if ( (n == 0)) {System.out.println(((((0 + " ") + 0) + " ") + 0)); } else if ( (f3 == n)) {System.out.println(((((f1 + " ") + f1) + " ") + (f2 - f1))); } else {System.out.println("I'm too stupid to solve this problem"); }} }
2	public class Main{ public static void main( String[] args){ for ( Scanner cin = new Scanner(System.in);cin.hasNextLong();System.out.println(Math.max(0,((Long.highestOneBit((cin.nextLong() ^ cin.nextLong())) << 1) - 1)))) ;} }
4	public class Main{ public static void main( String[] args)throws Exception { Scanner s = new Scanner(System.in);  int n = s.nextInt(),m = s.nextInt(),K = s.nextInt();  int[][] p = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {p[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(); }}if ( ((K % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print("-1 "); }System.out.println(); }return ;} long[][][] dp = new long[(K + 1)][n][m]; for ( int k = 2;(k <= K);k += 2) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { long res = Long.MAX_VALUE; if ( ((i + 1) < n)) {res = Math.min(res,(dp[(k - 2)][(i + 1)][j] + (v[i][j] * 2))); } if ( ((i - 1) >= 0)) {res = Math.min(res,(dp[(k - 2)][(i - 1)][j] + (v[(i - 1)][j] * 2))); } if ( ((j + 1) < m)) {res = Math.min(res,(dp[(k - 2)][i][(j + 1)] + (p[i][j] * 2))); } if ( ((j - 1) >= 0)) {res = Math.min(res,(dp[(k - 2)][i][(j - 1)] + (p[i][(j - 1)] * 2))); } dp[k][i][j] = res; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {System.out.print((dp[K][i][j] + " ")); }System.out.println(); }} }
6	public class E{ public static void main( String[] args){ new E(new Scanner(System.in)); } public E( Scanner in){ int N = in.nextInt();  double[][] g = new double[N][N]; for ( int j = 0;(j < N);j++) for ( int i = 0;(i < N);i++) g[i][j] = in.nextDouble(); double[] memo = new double[(1 << N)]; memo[((1 << N) - 1)] = 1.0; for ( int m = ((1 << N) - 1);(m > 0);m--) { int cnt = 0; for ( int i = 0;(i < N);i++) { int m1 = (1 << i); if ( ((m1 & m) > 0)) cnt++; } int sum = ((cnt * (cnt - 1)) / 2); for ( int i = 0;(i < N);i++) { int m1 = (1 << i); if ( ((m1 & m) == 0)) continue; for ( int j = (i + 1);(j < N);j++) { int m2 = (1 << j); if ( ((m2 & m) == 0)) continue; memo[(m - m1)] += ((g[i][j] * memo[m]) / sum); memo[(m - m2)] += ((g[j][i] * memo[m]) / sum); }}} StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < N);i++) { double res = memo[(1 << i)]; sb.append(String.format("%.8f",res)); sb.append(' '); }System.out.println(sb.toString().trim()); } }
6	public class thing{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  String s = in.next();  int[][] count = new int[m][m];  int[] dp = new int[(1 << m)]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; for ( int i = 1;(i < n);i++) { int a = (s.charAt(i) - 'a');  int b = (s.charAt((i - 1)) - 'a'); count[a][b]++; count[b][a]++; }for ( int i = 1;(i < (1 << m));i++) { int pos = set_bits(i); for ( int j = 0;((i >> j) != 0);j++) {if ( (((i >> j) & 1) == 0)) continue; int sum = 0; for ( int mask = i,y = 0;(y < m);mask >>= 1,y++) {if ( (y == j)) continue; if ( ((mask & 1) == 1)) sum += count[j][y]; else sum -= count[j][y]; } int calc = (dp[(i - (1 << j))] + (pos * sum)); dp[i] = Math.min(dp[i],calc); }}System.out.println(dp[((1 << m) - 1)]); } public static int set_bits( int n){ int count = 0; while((n > 0)){count += (n & 1); n >>= 1; }return count;} }
2	public class template{ public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));  int n = sc.nextInt();  int k = sc.nextInt();  long left = 0;  long right = n;  long mid = (left + (right / 2)); while((left <= right)){mid = ((left + right) / 2); if ( (((((mid + 1) * mid) / 2) - (n - mid)) == k)) {pw.println((n - mid)); pw.close(); break;} else if ( (((((mid + 1) * mid) / 2) - (n - mid)) > k)) {right = (mid - 1); } else left = (mid + 1); }} } @SuppressWarnings("all") 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());} }
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);  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; }
1	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));  StringTokenizer st = new StringTokenizer(f.readLine());  int n = Integer.parseInt(st.nextToken());  int a = Integer.parseInt(st.nextToken());  int b = Integer.parseInt(st.nextToken()); st = new StringTokenizer(f.readLine()); HashMap<Integer,Integer> in = new HashMap<Integer,Integer>();  int[][] locs = new int[n][2]; for ( int i = 0;(i < n);i++) { int num = Integer.parseInt(st.nextToken()); locs[i] = new int[]{num,i}; in.put(num,i); } boolean ok = true;  int swap = 0; if ( (a > b)) {swap = 1; int t = a; a = b; b = t; } Arrays.sort(locs,new Comparator<int[]>(){}); int[] inB = new int[n]; for ( int[] i :locs) {if ( in.containsKey((b - i[0]))) {inB[i[1]] = (1 - swap); in.remove((b - i[0])); } else if ( in.containsKey((a - i[0]))) {inB[i[1]] = swap; in.remove((a - i[0])); } else ok = false; } StringBuffer p = new StringBuffer(); for ( int i = 0;(i < (n - 1));i++) {p.append(inB[i]); p.append(" "); }p.append(inB[(n - 1)]); if ( ok) {out.println("YES"); out.println(p.toString()); } else {out.println("NO"); }out.close(); System.exit(0); } }
3	public class R455D2PC{ public static void main( String[] args){ final int MAX = 5000; final int MODULO = 1000000007;  Scanner in = new Scanner(System.in);  int n = in.nextInt(); in.nextLine(); int pre = 0;  int size = 0;  int[] block = new int[MAX]; for ( int i = 0;(i < n);i++) { String command = in.nextLine(); if ( command.startsWith("s")) {block[size++] = pre; pre = 0; } else {pre++; }}if ( (pre != 0)) {System.out.println(0); return ;} int[][] result = new int[2][(MAX + 1)];  int currentMax = 0;  int preIndex = 0; result[preIndex][0] = 1; for ( int i = 1;(i < size);i++) { int currentIndex = (preIndex ^ 1);  int j = block[(i - 1)]; for ( int k = currentMax;(k >= 0);k--) {result[currentIndex][(k + j)] = ((result[currentIndex][((k + j) + 1)] + result[preIndex][k]) % MODULO); }for ( int k = (j - 1);(k >= 0);k--) {result[currentIndex][k] = result[currentIndex][j]; }currentMax += j; preIndex = currentIndex; } int sum = 0; for ( int i = 0;(i <= currentMax);i++) {sum = ((sum + result[preIndex][i]) % MODULO); }System.out.println(sum); } }
0	public class AlexAndARhombus{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); System.out.println(((n * n) + ((n - 1) * (n - 1)))); sc.close(); } }
1	public class B implements Runnable{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; OutputWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new B(),"",(128 * (1L << 20))).start(); } void init()throws FileNotFoundException { Locale.setDefault(Locale.US); if ( 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"); }} long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } String delim = " "; String readString()throws IOException { while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken(delim);} String readLine()throws IOException { return in.readLine();} final char NOT_A_SYMBOL = '\0'; int readInt()throws IOException { return Integer.parseInt(readString());} int[] readIntArray( int size)throws IOException { int[] array = new int[size]; for ( int index = 0;(index < size);++index) {try{array[index] = readInt(); }catch (Exception e){ System.err.println(index); return null;} }return array;} int[] readIntArrayWithDecrease( int size)throws IOException { int[] array = readIntArray(size); for ( int i = 0;(i < size);++i) {array[i]--; }return array;} long readLong()throws IOException { return Long.parseLong(readString());} double readDouble()throws IOException { return Double.parseDouble(readString());} Point readPoint()throws IOException { int x = readInt();  int y = readInt(); return new Point(x,y);} static class IntIndexPair{ static Comparator<IntIndexPair> increaseComparator = new Comparator<B.IntIndexPair>(){}; static Comparator<IntIndexPair> decreaseComparator = new Comparator<B.IntIndexPair>(){}; int value ,index ; public IntIndexPair( int value, int index){ super(); this.value = value; this.index = index; } } static class OutputWriter extends PrintWriter{ final int DEFAULT_PRECISION = 12; protected int precision ; protected String format ,formatWithSpace ; {precision = DEFAULT_PRECISION; format = createFormat(precision); formatWithSpace = (format + " "); }public OutputWriter( OutputStream out){ super(out); } public OutputWriter( String fileName)throws FileNotFoundException{ super(fileName); } private String createFormat( int precision){ return (("%." + precision) + "f");} @Override public void print( double d){ printf(format,d); } public void printWithSpace( double d){ printf(formatWithSpace,d); } public 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); } public void printlnAll( double... d){ printAll(d); println(); } } static final int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; static final int[][] steps8 = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{1,-1},{-1,1}}; void solve()throws IOException { int n = readInt();  int a = readInt();  int b = readInt();  Map<Integer,Integer> numbers = new HashMap<>();  int[] p = readIntArray(n); for ( int index = 0;(index < n);++index) {numbers.put(p[index],index); } Set<Integer> used = new HashSet<Integer>();  Deque<Integer> q = new ArrayDeque<Integer>();  int[] answers = new int[n]; for ( int i = 0;(i < n);++i) {if ( used.contains(p[i])) continue; int leftSize = 0; for ( int number = p[i],cur = a,next = b;(numbers.containsKey(number) && !used.contains(number));number = (cur - number),cur = ((a ^ b) ^ cur),next = ((a ^ b) ^ next)) {q.addFirst(number); used.add(number); ++leftSize; }for ( int number = (b - p[i]),cur = a,next = b;(numbers.containsKey(number) && !used.contains(number));number = (cur - number),cur = ((a ^ b) ^ cur),next = ((a ^ b) ^ next)) {q.addLast(number); used.add(number); } int curColor = (leftSize & 1); if ( ((q.size() & 1) == 1)) { int first = q.peekFirst(); if ( (((curColor == 0) && ((first << 1) == b)) || ((curColor == 1) && ((first << 1) == a)))) {q.poll(); curColor ^= 1; int firstIndex = numbers.get(first); answers[firstIndex] = curColor; } else { int last = q.peekLast(); if ( (((curColor == 0) && ((last << 1) == a)) || ((curColor == 1) && ((first << 1) == b)))) {q.poll(); int firstIndex = numbers.get(first); answers[firstIndex] = curColor; } else {out.println("NO"); return ;}}} while((q.size() > 0)){ int first = q.poll();  int second = q.poll();  int firstIndex = numbers.get(first);  int secondIndex = numbers.get(second); answers[firstIndex] = curColor; answers[secondIndex] = curColor; }}out.println("YES"); for ( int answer :answers) {out.print((answer + " ")); }out.println(); } }
2	public class Main{ private InputStream is ; private PrintWriter out ; int time = 0,dp[][] ,DP[][] ,start[] ,parent[] ,end[] ,val[] ,black[] ,MOD = (int)(1e9 + 7),arr[] ,arr1[] ; int MAX = 10000000,N ,K ,p ; ArrayList<Integer>[] amp ,amp1 ; boolean b[] ,b1[] ; Pair prr[] ; char ch[][] ; HashSet<Integer> hs = new HashSet<>(); public static void main( String[] args)throws Exception { new Thread(null,new Runnable(){},"1",(1 << 26)).start(); new Main().soln(); } void solve(){ long n = nl(),s = nl();  long low = 1,high = (n + 1);  long ans = high; while((low <= high)){ long mid = ((high + low) / 2); if ( ((mid - getSum(mid)) >= s)) {high = (mid - 1); ans = mid; } else {low = (mid + 1); }}System.out.println(Math.max(0,((n - ans) + 1))); } int getSum( long s){ String str = Long.toString(s);  int ans = 0; for ( char ch :str.toCharArray()) ans += (ch - '0'); return ans;} int recur( int x){ int ans = 0; b[x] = true; for ( int i :amp[x]) {if ( !b[i]) {b[i] = true; ans = Math.max(recur(i),ans); b[i] = false; } }return (1 + ans);} int max = 0; int getParent( int x){ if ( (parent[x] != x)) {parent[x] = getParent(parent[x]); } return parent[x];} int max( int x, int y){ if ( (x > y)) return x; return y;} void dfs( int x){ b[x] = true; for ( int i :amp[x]) {if ( !b[i]) {dfs(i); } }} 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));} public long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} long power( long x, long y, int mod){ long ans = 1; while((y > 0)){if ( ((y % 2) == 0)) {x = ((x * x) % mod); y /= 2; } else {ans = ((x * ans) % mod); y--; }}return ans;} void soln(){ is = System.in; out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); } 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); }
5	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){ 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(); if ( (m <= k)) out.println(0); else {m -= (k - 1); Arrays.sort(a); int ans = 0; for ( int i = (n - 1);(i >= 0);i--) {ans++; m -= a[i]; if ( (m <= 0)) break; m++; }if ( (m > 0)) out.println(-1); else out.println(ans); }} } 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 int nextInt(){ return Integer.parseInt(next());} }
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 Main{ public static int n ; public static double[] dp ; public static double[][] p ; public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextInt(); dp = new double[(1 << n)]; p = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {p[i][j] = in.nextDouble(); }}for ( int i = 0;(i < (1 << n));i++) {dp[i] = -1; }dp[((1 << n) - 1)] = 1; DecimalFormat d = new DecimalFormat("0.000000"); System.out.print(d.format(f((1 << 0)))); for ( int i = 1;(i < n);i++) {System.out.print((" " + d.format(f((1 << i))))); }} public static double f( int mask){ if ( (dp[mask] > -0.5)) return dp[mask]; dp[mask] = 0; int vivos = 1; for ( int i = 0;(i < n);i++) if ( (((mask >> i) % 2) == 1)) vivos++;  double pares = ((vivos * (vivos - 1)) / 2); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (((mask & (1 << i)) != 0) && ((mask & (1 << j)) == 0))) {dp[mask] += ((f((mask | (1 << j))) * p[i][j]) / pares); } }}return dp[mask];} }
0	public class ex1{ public static void main( String[] args){ int n ,i ,j ;  Scanner scan = new Scanner(System.in); n = Integer.parseInt(scan.nextLine()); if ( (n >= 0)) System.out.println(n); else if ( (n < 0)) {n = (-1 * n); i = (n / 10); j = (((n / 100) * 10) + (n % 10)); i = -i; j = -j; if ( (i >= j)) System.out.println(i); else System.out.println(j); } } }
5	public class test{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int t = in.nextInt();  House[] houses = new House[n]; for ( int i = 0;(i < n);i++) {houses[i] = new House(in.nextInt(),in.nextInt()); }Arrays.sort(houses); int count = 2; for ( int i = 0;(i < (n - 1));i++) { double start = (houses[i].x + ((double)houses[i].a / 2));  double end = (houses[(i + 1)].x - ((double)houses[(i + 1)].a / 2)); if ( ((end - start) == t)) count++; if ( ((end - start) > t)) count += 2; }System.out.println(count); } } class House implements Comparable<House>{ int x ; int a ; public House( int _x, int _a){ x = _x; a = _a; } }
0	public class HexadecimalsTheorem{ public void solve(){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  ArrayList<Long> a = new ArrayList<Long>(); a.add(0l); a.add(1L); a.add(1L); int i = 1,j = 2; while(((a.get(i) + a.get(j)) <= n)){a.add((a.get(i) + a.get(j))); i++; j++; }if ( a.contains(n)) {if ( (n == 0)) {System.out.println("0 0 0"); } else if ( (n == 1)) {System.out.println("0 0 1"); } else if ( (n == 2)) {System.out.println("0 1 1"); } else {System.out.println(((((a.get((j - 4)) + " ") + a.get((j - 3))) + " ") + a.get((j - 1)))); }} else {System.out.println("I'm too stupid to solve this problem"); }} public static void main( String[] args){ new HexadecimalsTheorem().solve(); } }
1	public class IQTest implements Runnable{ public static void main( String[] args)throws Exception { new IQTest().run(); } private void solve()throws Exception { int n = nextInt();  int a[] = new int[n]; for ( int i = 0;(i < a.length);i++) {a[i] = nextInt(); } int c0 = 0,c1 = 0; for ( int i = 0;(i < a.length);i++) {a[i] = (a[i] % 2); if ( (a[i] == 0)) c0++; else c1++; } int f = 0; if ( (c0 > c1)) f = 1; else f = 0; int r = 0; for ( int i = 0;(i < a.length);i++) {if ( (a[i] == f)) {r = (i + 1); break;} }out.println(r); } private BufferedReader in ; PrintWriter out ; StringTokenizer tokenizer ; public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new BufferedOutputStream(System.out)); solve(); out.flush(); in.close(); out.close(); }catch (Exception e){ e.printStackTrace(); } } String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(in.readLine()); }return tokenizer.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
2	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long k = in.nextLong();  long t = 1;  long l = 1; if ( (k <= 9)) {System.out.print(k); System.exit(0); } long x = 9; while(true){++l; t *= 10; x += ((9 * l) * t); if ( (x >= k)) {break;} }if ( (x == k)) {System.out.print(9); System.exit(0); } x -= ((9 * l) * t); long a = ((k - x) / l); if ( (((k - x) % l) == 0)) {x = ((t + a) - 1); System.out.print((x % 10)); } else {k -= (x + (a * l)); x = (t + a); String s = Long.toString(x); System.out.print(s.charAt(((int)k - 1))); }} }
2	public class b2{ public static void main( String[] args)throws IOException { input.init(System.in); int n = input.nextInt(),x = input.nextInt(),y = input.nextInt(),c = input.nextInt();  long lo = 0,hi = (2 * n); while((hi > (lo + 1))){ long mid = ((hi + lo) / 2);  long covered = go(n,x,y,mid); if ( (covered < c)) lo = mid; else hi = mid; }if ( (go(n,x,y,lo) < c)) lo++; System.out.println(lo); } public static long go( int n, int x, int y, long d){ long res = ((d * d) + ((d + 1) * (d + 1)));  long maxLeft = (d - x); if ( (maxLeft >= 0)) res -= ((maxLeft + 1) * (maxLeft + 1));  long maxTop = (d - y); if ( (maxTop >= 0)) res -= ((maxTop + 1) * (maxTop + 1));  long maxRight = (d - ((n + 1) - x)); if ( (maxRight >= 0)) res -= ((maxRight + 1) * (maxRight + 1));  long maxBot = (d - ((n + 1) - y)); if ( (maxBot >= 0)) res -= ((maxBot + 1) * (maxBot + 1));  long maxTopLeft = (d - (x + y)); if ( (maxTopLeft >= 0)) res += (((maxTopLeft + 1) * (maxTopLeft + 2)) / 2);  long maxTopRight = (d - (((n + 1) - x) + y)); if ( (maxTopRight >= 0)) res += (((maxTopRight + 1) * (maxTopRight + 2)) / 2);  long maxBotLeft = (d - (x + ((n + 1) - y))); if ( (maxBotLeft >= 0)) res += (((maxBotLeft + 1) * (maxBotLeft + 2)) / 2);  long maxBotRight = (d - (((n + 1) - x) + ((n + 1) - y))); if ( (maxBotRight >= 0)) res += (((maxBotRight + 1) * (maxBotRight + 2)) / 2); return res;} }
5	public class Main implements Runnable{ class Segment{ int l ,r ; Segment( int l, int r){ this.l = l; this.r = r; } } public void _main()throws IOException { int n = nextInt();  int t = nextInt();  int[] x = new int[n];  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = nextInt(); a[i] = nextInt(); } Set<Segment> set = new HashSet<Segment>(); for ( int i = 0;(i < n);i++) { int l = ((2 * x[i]) + a[i]);  int r = (((2 * x[i]) + a[i]) + (2 * t));  boolean ok = true; for ( int j = 0;(j < n);j++) {if ( (i == j)) continue; int L = Math.max(l,((2 * x[j]) - a[j]));  int R = Math.min(r,((2 * x[j]) + a[j])); if ( (L < R)) {ok = false; break;} }if ( ok) set.add(new Segment(l,r)); l = (((2 * x[i]) - a[i]) - (2 * t)); r = ((2 * x[i]) - a[i]); ok = true; for ( int j = 0;(j < n);j++) {if ( (i == j)) continue; int L = Math.max(l,((2 * x[j]) - a[j]));  int R = Math.min(r,((2 * x[j]) + a[j])); if ( (L < R)) {ok = false; break;} }if ( ok) set.add(new Segment(l,r)); }out.print(set.size()); } 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(); } }
1	public class Solution{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; int n ,k ; boolean[] prime ; int[] primes ; void sieve(){ prime = new boolean[(n + 1)]; Arrays.fill(prime,true); prime[0] = prime[1] = false; int cnt = 0; for ( int i = 2;(i <= n);++i) if ( prime[i]) {++cnt; for ( int j = (i + i);(j <= n);j += i) prime[j] = false; } primes = new int[cnt]; cnt = 0; for ( int i = 0;(i <= n);++i) if ( prime[i]) primes[cnt++] = i; } void solve()throws IOException { n = ni(); k = ni(); sieve(); int cnt = 0; for ( int i = 2;(i <= n);++i) {if ( !prime[i]) continue; boolean ok = false; for ( int j = 0;(j < (primes.length - 1));++j) if ( (((primes[j] + primes[(j + 1)]) + 1) == i)) {ok = true; break;} if ( ok) ++cnt; }if ( (cnt >= k)) out.println("YES"); else out.println("NO"); } public Solution()throws IOException{ Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } String ns()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int ni()throws IOException { return Integer.valueOf(ns());} public static void main( String[] args)throws IOException { new Solution(); } }
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());} } }
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); }
4	public class sdffsdf{ public static void main( String[] args){ try{ File file = new File("input.txt");  Scanner sc = new Scanner(file);  String s = sc.nextLine();  String[] seperatedd = s.split(" ");  int x = Integer.parseInt(seperatedd[0]);  int y = Integer.parseInt(seperatedd[1]);  int[][] grid = new int[x][y]; for ( int i = 0;(i < x);i++) {for ( int j = 0;(j < y);j++) {grid[i][j] = 0; }}s = sc.nextLine(); int z = Integer.parseInt(s);  LinkedList<Point> BFS = new LinkedList<Point>(); s = sc.nextLine(); String[] seperated = s.split(" "); for ( int i = 0;(i < seperated.length);i = (i + 2)) { Point temp = new Point(); temp.x = (Integer.parseInt(seperated[i]) - 1); temp.y = (Integer.parseInt(seperated[(i + 1)]) - 1); grid[temp.x][temp.y] = 1; BFS.addLast(temp); }while(!BFS.isEmpty()){ Point temp = new Point(); temp = BFS.removeFirst(); int k = temp.x;  int l = temp.y; if ( (((l + 1) >= y) || (grid[k][(l + 1)] == 1))) { Point temp1 = new Point(); temp1.x = k; temp1.y = (l + 1); grid[temp1.x][temp1.y] = 1; BFS.addLast(temp1); } if ( (((k + 1) >= x) || (grid[(k + 1)][l] == 1))) { Point temp1 = new Point(); temp1.x = (k + 1); temp1.y = l; grid[temp1.x][temp1.y] = 1; BFS.addLast(temp1); } if ( (((l - 1) < 0) || (grid[k][(l - 1)] == 1))) { Point temp1 = new Point(); temp1.x = k; temp1.y = (l - 1); grid[temp1.x][temp1.y] = 1; BFS.addLast(temp1); } if ( (((k - 1) < 0) || (grid[(k - 1)][l] == 1))) { Point temp1 = new Point(); temp1.x = (k - 1); temp1.y = l; grid[temp1.x][temp1.y] = 1; BFS.addLast(temp1); } if ( BFS.isEmpty()) {try{ File fil = new File("output.txt");  PrintWriter out = new PrintWriter(fil);  int v1 = ((int)temp.getX() + 1);  int v2 = ((int)temp.getY() + 1); out.println(((v1 + " ") + v2)); out.close(); }catch (Exception e){ } } } }catch (Exception e){ System.out.println("nbvnb"); } } }
0	public class A{ public static void main( String[] args)throws IOException { try(BufferedReader reader=new BufferedReader(new InputStreamReader(System.in))){ String input ; while((((input = reader.readLine()) != null) && (input.length() > 0))){ int n = Integer.parseInt(input);  int start = 4;  int end = (n - start); while((start <= end)){if ( ((((start % 2) == 0) || ((start % 3) == 0)) && (((end % 2) == 0) || ((end % 3) == 0)))) {System.out.println(((start + " ") + end)); break;} ++start; --end; }} }} }
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(); } }
3	public class PC1229{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  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]; for ( int i = 0;(i < n);i++) { double maxY = r; for ( int j = 0;(j < i);j++) {if ( ((x[j] <= (x[i] + (2 * r))) && (x[j] >= (x[i] - (2 * r))))) {maxY = Math.max(maxY,(ans[j] + Math.sqrt((((4 * r) * r) - (Math.abs((x[i] - x[j])) * Math.abs((x[i] - x[j]))))))); } }ans[i] = maxY; }for ( int i = 0;(i < n);i++) {System.out.println(ans[i]); }sc.close(); } }
6	public class LookingForOrder{ static int[] x ,y ; static int[] dp ; static int n ; static int dist( int i, int j){ return (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j])));} static int solve( int mask){ if ( (mask == ((1 << n) - 1))) return 0; if ( (dp[mask] != -1)) return dp[mask]; int ans = Integer.MAX_VALUE;  int j = 0; for ( int i = 1;(i < n);i++) if ( ((mask & (1 << i)) == 0)) {if ( (j == 0)) {ans = Math.min(ans,((2 * dist(0,i)) + solve((mask | (1 << i))))); j = i; } else ans = Math.min(ans,(((dist(0,i) + dist(i,j)) + dist(j,0)) + solve(((mask | (1 << i)) | (1 << j))))); } return dp[mask] = ans;} static void prnt( int mask){ if ( (mask == ((1 << n) - 1))) return ; int j = 0; for ( int i = 1;(i < n);i++) if ( ((mask & (1 << i)) == 0)) {if ( (j == 0)) {j = i; if ( (dp[mask] == ((2 * dist(0,i)) + solve((mask | (1 << i)))))) {out.print(((" " + i) + " 0")); prnt((mask | (1 << i))); return ;} } else if ( (dp[mask] == (((dist(0,i) + dist(i,j)) + dist(j,0)) + solve(((mask | (1 << i)) | (1 << j)))))) {out.print(((((" " + i) + " ") + j) + " 0")); prnt(((mask | (1 << i)) | (1 << j))); return ;} } } public static void main( String[] args)throws IOException { sc = new StringTokenizer(br.readLine()); int a = nxtInt();  int b = nxtInt(); n = (nxtInt() + 1); x = new int[n]; y = new int[n]; dp = new int[(1 << n)]; Arrays.fill(dp,-1); x[0] = a; y[0] = b; for ( int i = 1;(i < n);i++) {x[i] = nxtInt(); y[i] = nxtInt(); }out.println(solve((1 << 0))); out.print(0); prnt((1 << 0)); out.println(); br.close(); out.close(); } static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter out = new PrintWriter(System.out); static StringTokenizer sc ; static String nxtTok()throws IOException { while(!sc.hasMoreTokens())sc = new StringTokenizer(br.readLine()); return sc.nextToken();} static int nxtInt()throws IOException { return Integer.parseInt(nxtTok());} }
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));} } }
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); } } }
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());} }
2	public class Main{ public static void main( String[] args){ try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  String[] param = br.readLine().split(" ");  long n = (Long.parseLong(param[0]) - 1);  long k = (Long.parseLong(param[1]) - 1);  long max = ((k * (k + 1)) / 2);  long answer ; if ( (n > max)) answer = -1; else { long margin = (max - n);  long m = Math.max(0,((long)Math.floor(((1.0 + Math.sqrt((1 + (8 * margin)))) / 2.0)) - 1));  long min = ((m * (m + 1)) / 2); while((min <= margin)){m++; min = ((m * (m + 1)) / 2); }answer = ((k - m) + 1); }pw.println(answer); pw.close(); br.close(); }catch (IOException e){ e.printStackTrace(); return ;} } }
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 % 2) == 0)) {z.write((((((l + " ") + (l + 1)) + " ") + (l + 2)) + "\n")); } else {z.write(((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3)) + "\n")); }}z.flush(); } }
6	public class ProblemD{ static int N ; static boolean[][] graph ; public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  String[] data = s.readLine().split(" ");  int n = Integer.valueOf(data[0]); N = n; int m = Integer.valueOf(data[1]); graph = new boolean[n][n]; for ( int i = 0;(i < m);i++) { String[] line = s.readLine().split(" ");  int a = (Integer.valueOf(line[0]) - 1);  int b = (Integer.valueOf(line[1]) - 1); graph[a][b] = true; graph[b][a] = true; } long ans = 0; for ( int i = 0;(i < n);i++) {ans += doit(i); }ans /= 2; out.println(ans); out.flush(); } static long doit( int n){ long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {if ( graph[i][n]) {dp[(1 << i)][i] = 1; } }for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( (dp[i][j] >= 1)) {for ( int k = 0;(k < n);k++) {if ( (graph[j][k] && ((i & (1 << k)) == 0))) {dp[(i | (1 << k))][k] += dp[i][j]; } }} }} long ret = 0; for ( int i = 0;(i < (1 << n));i++) {if ( (Integer.bitCount(i) >= 2)) {for ( int j = 0;(j < n);j++) {if ( graph[j][n]) {ret += dp[i][j]; } }} }return ret;} }
6	public class cf11d{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt();  boolean[][] g = new boolean[n][n];  boolean[] ok = new boolean[(1 << n)];  int[] f = new int[(1 << n)]; for ( int i = 1;(i < (1 << n));i++) {ok[i] = (Integer.bitCount(i) >= 3); f[i] = first(i); }for ( int i = 0;(i < m);i++) { int a = (in.nextInt() - 1);  int b = (in.nextInt() - 1); g[a][b] = g[b][a] = true; } long[][] dp = new long[n][(1 << n)]; for ( int i = 0;(i < n);i++) dp[i][(1 << i)] = 1; for ( int i = 1;(i < (1 << n));i++) for ( int j = 0;(j < n);j++) for ( int k = (f[i] + 1);(k < n);k++) if ( (((i & (1 << k)) == 0) && g[j][k])) dp[k][(i ^ (1 << k))] += dp[j][i];  long ret = 0; for ( int i = 1;(i < (1 << n));i++) for ( int j = 0;(j < n);j++) if ( (ok[i] && (j != f[i]))) ret += (g[j][f[i]]?dp[j][i]:0); System.out.println((ret / 2)); } static int first( int x){ int ret = 0; while(((x % 2) == 0)){x /= 2; ret++; }return ret;} }
0	public class C236{ public static void main( String[] args){ new C236().run(); } void run(){ InputScanner scanner = new InputScanner(System.in);  PrintStream printer = new PrintStream(System.out);  int n = scanner.nextInt();  long answer ; if ( (n == 1)) {answer = 1; } else if ( (n == 2)) {answer = 2; } else {if ( ((n & 1) != 0)) {answer = (((long)n * (long)(n - 1)) * (long)(n - 2)); } else {if ( ((n % 3) == 0)) {answer = (((long)(n - 1) * (long)(n - 2)) * (long)(n - 3)); } else {answer = (((long)n * (long)(n - 1)) * (long)(n - 3)); }}}printer.println(answer); } class InputScanner{ BufferedInputStream bis ; byte[] buffer = new byte[1024]; int currentChar ; int charCount ; public InputScanner( InputStream stream){ bis = new BufferedInputStream(stream); } public byte read(){ if ( (charCount == -1)) throw (new InputMismatchException()); if ( (currentChar >= charCount)) {currentChar = 0; try{charCount = bis.read(buffer); }catch (IOException e){ throw (new InputMismatchException());} if ( (charCount <= 0)) return -1; } return buffer[currentChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sign = 1; if ( (c == '-')) {sign = -1; c = read(); } int rep = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); rep *= 10; rep += (c - '0'); c = read(); }while(!isSpaceChar(c));return (rep * sign);} public boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public void close(){ try{bis.close(); }catch (IOException e){ e.printStackTrace(); } } } }
5	public class con111_A{ public static void main(final String[] args)throws IOException { final BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); final int n = Integer.parseInt(br.readLine()); final int[] a = new int[n]; final String[] parts = br.readLine().split(" "); for ( int i = 0;(i < n);++i) {a[i] = Integer.parseInt(parts[i]); }System.out.println(solve(n,a)); } static private int solve(final int n,final int[] a){ Arrays.sort(a); int sum = 0; for ( int i = 0;(i < n);++i) {sum += a[i]; } int res = 0;  int ms = 0; for ( int i = (n - 1);(i >= 0);--i) {if ( (ms > (sum / 2))) {break;} else {ms += a[i]; ++res; }}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);  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[] a = new int[n]; for ( int i = 0;(i < n);++i) a[i] = in.nextInt(); boolean[] done = new boolean[n];  int res = 0; while(true){ int bi = -1; for ( int i = 0;(i < n);++i) if ( !done[i]) {if ( ((bi < 0) || (a[i] < a[bi]))) bi = i; } if ( (bi < 0)) break; ++res; for ( int i = 0;(i < n);++i) if ( (!done[i] && ((a[i] % a[bi]) == 0))) done[i] = true; }out.println(res); } } 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 Hexadecimal{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt(); System.out.print(("0 0 " + n)); } }
4	public class CF_2020_GlobalRound_E{ static boolean verb = true; static void log( Object X){ if ( verb) System.err.println(X); } static void log( Object[] X){ if ( verb) {for ( Object U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X){ if ( verb) {for ( int U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X, int L){ if ( verb) {for ( int i = 0;(i < L);i++) System.err.print((X[i] + " ")); System.err.println(""); } } static void log( long[] X){ if ( verb) {for ( long U :X) System.err.print((U + " ")); System.err.println(""); } } static InputReader reader ; static long[][] binom ; static void buildBinom( int N){ int MAX = (N + 1); binom = new long[(MAX + 1)][]; for ( int i = 0;(i < (MAX + 1));i++) binom[i] = new long[(i + 1)]; binom[0][0] = 1; for ( int i = 1;(i < MAX);i++) {binom[i][0] = 1; binom[i][i] = 1; for ( int j = 0;(j < i);j++) {binom[(i + 1)][(j + 1)] = ((binom[i][j] + binom[i][(j + 1)]) % mod); }}log("binom done"); } static long mod ; static long solve( int n){ long[] pow2 = new long[(n + 1)]; pow2[0] = 1; for ( int i = 1;(i <= n);i++) {pow2[i] = (pow2[(i - 1)] << 1); while((pow2[i] >= mod))pow2[i] -= mod; }buildBinom(n); long[][] dp = new long[(n + 1)][(n + 1)]; dp[1][1] = 1; for ( int i = 1;(i <= n);i++) {dp[i][i] = pow2[(i - 1)]; for ( int j = 1;(j < (i - 1));j++) { int me = ((i - j) - 1); for ( int cn = 1;(cn <= j);cn++) {dp[i][(cn + me)] += ((((dp[j][cn] * binom[(cn + me)][cn]) % mod) * pow2[(me - 1)]) % mod); dp[i][(cn + me)] %= mod; }}} long ans = 0; for ( int i = 0;(i <= n);i++) {ans += dp[n][i]; ans %= mod; }return ans;} public static void main( String[] args)throws Exception { log(((400 * 400) * 400)); reader = new InputReader(System.in); int n = reader.readInt(); mod = reader.readInt(); System.out.println(solve(n)); } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
6	public class DarkAssembly extends Thread{ public DarkAssembly(){ this.input = new BufferedReader(new InputStreamReader(System.in)); this.output = new PrintWriter(System.out); this.setPriority(Thread.MAX_PRIORITY); } static class Senator{ int loyalty ; int level ; public Senator( int level, int loyalty){ this.level = level; this.loyalty = loyalty; } } static private double doIt( Senator[] senators, int A){ double probability = .0; for ( int mask = 0;(mask < (1 << senators.length));++mask) { int sum = A;  double current = 1.0; for ( int i = 0;(i < senators.length);++i) {if ( ((mask & (1 << i)) != 0)) {current *= (.01 * senators[i].loyalty); } else {current *= (.01 * (100 - senators[i].loyalty)); sum += senators[i].level; }}if ( (Integer.bitCount(mask) > (senators.length / 2))) {probability += current; } else {probability += ((current * (double)A) / sum); }}return probability;} static private double go( Senator[] senators, int candies, int A, int current){ if ( (current == senators.length)) {return doIt(senators,A);} else { double result = go(senators,candies,A,(current + 1)); if ( ((candies > 0) && (senators[current].loyalty < 100))) {senators[current].loyalty += 10; result = Math.max(result,go(senators,(candies - 1),A,current)); senators[current].loyalty -= 10; } return result;}} private void solve()throws Throwable { int n = nextInt();  int k = nextInt();  int A = nextInt();  Senator[] senators = new Senator[n]; for ( int i = 0;(i < n);++i) {senators[i] = new Senator(nextInt(),nextInt()); }output.printf("%.10f",go(senators,k,A,0)); } public static void main( String[] args){ new DarkAssembly().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 BufferedReader input ; private PrintWriter output ; private StringTokenizer tokens = null; }
0	public class Main{ long solve( long a, long b){ if ( (a == 0)) {return 0;} long answer = (a / b); a %= b; if ( (a != 0)) {answer += (1 + solve((b - a),a)); } return answer;} public void run(){ try{ long a = reader.nextLong();  long b = reader.nextLong(); writer.println(solve(a,b)); }catch (IOException ex){ } writer.close(); } InputReader reader ; PrintWriter writer ; Main(){ reader = new InputReader(); writer = new PrintWriter(System.out); } public static void main( String[] args){ new Main().run(); } } class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; InputReader(){ reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = new StringTokenizer(""); } String next()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} Long nextLong()throws IOException { return Long.parseLong(next());} }
1	public class SingleWildcard{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int a = input.nextInt();  int b = input.nextInt();  char[] s1 = new char[a]; s1 = input.next().toCharArray(); char[] s2 = new char[b]; s2 = input.next().toCharArray(); boolean condition = false; for ( int i = 0;(i < a);i++) {if ( (s1[i] == '*')) {condition = true; break;} }if ( !condition) {if ( match(s1,s2)) {System.out.println("YES"); } else System.out.println("NO"); return ;} else { int i = 0; if ( ((s1.length - 1) > s2.length)) {System.out.println("NO"); return ;} while((((i < s1.length) && (i < s2.length)) && (s1[i] == s2[i]))){i++; } int j = (s2.length - 1);  int k = (s1.length - 1); while(((((j >= 0) && (k >= 0)) && (s1[k] == s2[j])) && (i <= j))){j--; k--; }if ( ((((i == k) && (i >= 0)) && (i < s1.length)) && (s1[i] == '*'))) {System.out.println("YES"); return ;} System.out.println("NO"); }} static boolean match( char[] s1, char[] s2){ if ( (s1.length != s2.length)) return false; for ( int i = 0;(i < s1.length);i++) {if ( (s1[i] != s2[i])) return false; }return true;} }
1	public class C{ String line ; StringTokenizer inputParser ; BufferedReader is ; FileInputStream fstream ; DataInputStream in ; void openInput( String file){ if ( (file == null)) is = new BufferedReader(new InputStreamReader(System.in)); else {try{fstream = new FileInputStream(file); in = new DataInputStream(fstream); is = new BufferedReader(new InputStreamReader(in)); }catch (Exception e){ System.err.println(e); } }} void readNextLine(){ try{line = is.readLine(); inputParser = new StringTokenizer(line," "); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } int NextInt(){ String n = inputParser.nextToken();  int val = Integer.parseInt(n); return val;} void closeInput(){ try{is.close(); }catch (IOException e){ System.err.println(("Unexpected IO ERROR: " + e)); } } public static void main( String[] argv){ String filePath = null; if ( (argv.length > 0)) filePath = argv[0];  C c = new C(filePath); } public C( String inputFile){ openInput(inputFile); readNextLine(); int N = NextInt();  boolean[] p = new boolean[N]; readNextLine(); int h = 0; for ( int i = 0;(i < N);i++) {p[i] = (line.charAt(i) == 'H'); if ( p[i]) h++; } int ret = N; for ( int i = 0;(i < N);i++) { int m = 0; for ( int j = i;(j < (i + h));j++) { int n = (j % N); if ( !p[n]) m++; }ret = Math.min(ret,m); }System.out.println(ret); closeInput(); } }
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 CFC{ static int n ; static int[][] dp ; static boolean[] s ; public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in); n = in.nextInt(); if ( (n == 1)) {System.out.println(1); return ;} dp = new int[n][(n + 1)]; s = new boolean[n]; for ( int i = 0;(i < n);i++) s[i] = in.next().equals("s"); for ( int j = 0;(j < n);j++) {if ( s[(n - 2)]) dp[(n - 1)][j] = (j + 1); else dp[(n - 1)][j] = 1; } int suma ,sumb ; for ( int i = (n - 2);(i >= 0);i--) {if ( ((i == 0)?true:s[(i - 1)])) {if ( s[i]) {for ( int j = 0;(j < n);j++) {dp[i][j] = ((((j == 0)?0:dp[i][(j - 1)]) + dp[(i + 1)][j]) % 1000000007); }} else {for ( int j = 0;(j < n);j++) {dp[i][j] = ((((j == 0)?0:dp[i][(j - 1)]) + dp[(i + 1)][(j + 1)]) % 1000000007); }}} else {if ( s[i]) {for ( int j = 0;(j < n);j++) {dp[i][j] = dp[(i + 1)][j]; }} else {for ( int j = 0;(j < n);j++) {dp[i][j] = dp[(i + 1)][(j + 1)]; }}}}System.out.println(dp[0][0]); } static private 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 C{ InputStream is ; FastWriter out ; String INPUT = ""; void solve(){ for ( int T = ni();(T > 0);T--) go(); } void go(){ int n = ni();  int[] st = new int[n];  int sp = 0; for ( int i = 0;(i < n);i++) { int x = ni(); if ( (x == 1)) {st[sp++] = 1; } else {while((sp > 0)){if ( ((st[(sp - 1)] + 1) == x)) {st[(sp - 1)]++; break;} else {sp--; }}}for ( int j = 0;(j < sp);j++) {if ( (j > 0)) out.print("."); out.print(st[j]); }out.println(); }} 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 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[] 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{ static private 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;} static private 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;} static private 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)); } }
3	public class C{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  List<String> commands = IntStream.range(0,n).boxed().map((x)->s.next()).collect(Collectors.toList());  List<Integer> ways = new ArrayList<>(); ways.add(1); boolean lastWasS = false; for ( String command :commands) { boolean isS = "s".equals(command); if ( lastWasS) {for ( int i = 1;(i < ways.size());++i) { int waysNumber = ((ways.get((i - 1)) + ways.get(i)) % 1_000_000_007); ways.set(i,waysNumber); }} if ( !isS) {ways.add(0); } lastWasS = isS; }System.out.println(ways.stream().reduce(0,(a,b)->((a + b) % 1_000_000_007))); } }
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)); } }
5	public class A{ int IOMode = 0; String taskName = ""; void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); Arrays.sort(a); int z = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != 1)) z++; }if ( ((z == 0) && (n > 1))) a[(n - 2)] = 2; if ( ((n == 1) && (a[0] == 1))) {out.println(2); return ;} out.print("1 "); for ( int i = 0;(i < (n - 1));i++) out.print((a[i] + " ")); } public static void main( String[] args)throws IOException { if ( ((args.length > 0) && args[0].equals("Abra"))) debugMode = true; new A().run(); } long startTime = System.nanoTime(),tempTime = startTime,finishTime = startTime; long startMem = Runtime.getRuntime().totalMemory(),finishMem = startMem; void run()throws IOException { init(); if ( debugMode) {con.println("Start"); con.println("Console output:"); } solve(); finishTime = System.nanoTime(); finishMem = Runtime.getRuntime().totalMemory(); out.flush(); if ( debugMode) { int maxSymbols = 1000,c = 0;  BufferedReader tbr = new BufferedReader(new FileReader("input.txt"));  char[] a = new char[maxSymbols]; tbr.read(a); if ( (a[0] != 0)) {con.println(); con.println("File input:"); con.print(a); } boolean left = true; for ( int i = 0;(i < maxSymbols);i++) left = (left && (a[i] != 0)); if ( left) con.println("..."); else con.println(); tbr = new BufferedReader(new FileReader("output.txt")); a = new char[maxSymbols]; tbr.read(a); if ( (a[0] != 0)) {con.println(); con.println("File output:"); con.print(a); } left = true; for ( int i = 0;(i < maxSymbols);i++) left = (left && (a[i] != 0)); if ( left) con.println("..."); else con.println(); con.println((("Time passed: " + ((finishTime - startTime) / 1000000000.0)) + " sec")); con.println((("Memory used: " + (finishMem - startMem)) + " bytes")); con.println((("Total memory: " + Runtime.getRuntime().totalMemory()) + " bytes")); } } static boolean debugMode = false; PrintStream con = System.out; void init()throws IOException { if ( (debugMode && (IOMode != 3))) {br = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); } else switch(IOMode){ case 0:br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); break; case 1:br = new BufferedReader(new FileReader((taskName + ".in"))); out = new PrintWriter(new FileWriter((taskName + ".out"))); break; case 2:br = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); break; case 3:out = new PrintWriter(new FileWriter("input.txt")); break; } } BufferedReader br ; PrintWriter out ; StringTokenizer in ; boolean hasMoreTokens()throws IOException { while(((in == null) || !in.hasMoreTokens())){ String line = br.readLine(); if ( (line == null)) return false; in = new StringTokenizer(line); }return true;} String nextString()throws IOException { return (hasMoreTokens()?in.nextToken():null);} int nextInt()throws IOException { return Integer.parseInt(nextString());} }
6	public class ASimpleTask{ static StreamTokenizer st ; static int nextInt(){ try{st.nextToken(); }catch (IOException e){ e.printStackTrace(); } return (int)st.nval;} static int[][] edges ; static long[][] dp ; public static void main( String[] args){ st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); int n = nextInt();  int m = nextInt(); edges = new int[n][n]; for ( int i = 0;(i < m);i++) { int from = (nextInt() - 1);  int to = (nextInt() - 1); edges[from][to] = edges[to][from] = 1; }dp = new long[((1 << n) + 1)][(n + 1)]; for ( int mask = 1;(mask < (1 << n));mask++) {for ( int i = 0;(i < n);i++) {if ( ((Integer.bitCount(mask) == 1) && ((mask & (1 << i)) != 0))) {dp[mask][i] = 1; continue;} if ( (((Integer.bitCount(mask) > 1) && ((mask & (1 << i)) != 0)) && (first(mask,n) != i))) {for ( int j = 0;(j < n);j++) {if ( (edges[i][j] == 1)) {dp[mask][i] += dp[(mask ^ (1 << i))][j]; } }} }} long count = 0; for ( int mask = 1;(mask < (1 << n));mask++) {for ( int i = 0;(i < n);i++) {if ( ((Integer.bitCount(mask) >= 3) && (edges[i][first(mask,n)] != 0))) count += dp[mask][i]; }}System.out.println((count / 2)); } static int first( int mask, int n){ for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) return i; }return -1;} }
1	public class B138{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int a[] = new int[100004];  int b[] = new int[100004];  int n ,m ,ans = 0,dau ,cuoi = -1; n = sc.nextInt(); m = sc.nextInt(); for ( int i = 0;(i < 100004);i++) a[i] = 0; for ( int i = 0;(i < n);i++) {b[i] = sc.nextInt(); if ( (a[b[i]] == 0)) {a[b[i]] = 1; ans++; if ( (ans == m)) {cuoi = (i + 1); break;} } }for ( int i = (cuoi - 1);(i >= 00);i--) {if ( (a[b[i]] == 1)) {a[b[i]] = 0; ans--; if ( (ans == 0)) {System.out.println((((i + 1) + " ") + cuoi)); System.exit(0); } } }System.out.println("-1 -1"); } }
1	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  Pattern rc_style = Pattern.compile("R[0-9]+C[0-9]+");  int n = input.nextInt(); while((n-- > 0)){ String str = input.next();  Matcher m = rc_style.matcher(str); if ( m.matches()) { String nums[] = str.split("[RC]");  String row = nums[1];  String col = nums[2];  String buffer = "";  int col_num = Integer.valueOf(col); while((col_num > 0)){if ( ((col_num % 26) > 0)) {buffer += (char)(((col_num % 26) + 'A') - 1); col_num /= 26; } else {buffer += 'Z'; col_num /= 26; col_num--; }}for ( int i = (buffer.length() - 1);(i >= 0);i--) System.out.print(buffer.charAt(i)); System.out.println(row); } else { String col = str.split("[0-9]+")[0];  String row = str.split("[A-Z]+")[1];  int col_num = 0;  int shift = 1; for ( int i = (col.length() - 1);(i >= 0);i--) {col_num += ((int)((col.charAt(i) - 'A') + 1) * shift); shift *= 26; }System.out.println(((("R" + row) + "C") + col_num)); }}} }
3	public class Main{ public static void main( String[] args){ 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 ;  int count = 0;  int c = 0; while((count != n)){min = 1000; for ( int i = 0;(i < n);i++) {if ( (a[i] < min)) {min = a[i]; } }for ( int i = 0;(i < n);i++) {if ( ((a[i] != 1000) && ((a[i] % min) == 0))) {count++; a[i] = 1000; } }c++; }System.out.println(c); } }
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)))); }} }
4	public class ProblemC{ static int[] dx = {1,0,0,-1}; static int[] dy = {0,1,-1,0}; public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new FileWriter("output.txt"));  String[] nm = s.readLine().split(" ");  int n = Integer.valueOf(nm[0]);  int m = Integer.valueOf(nm[1]);  int k = Integer.valueOf(s.readLine());  int[][] dp = new int[n][m]; for ( int i = 0;(i < n);i++) {Arrays.fill(dp[i],Integer.MAX_VALUE); } String[] st = s.readLine().split(" ");  int[][] trees = new int[k][2]; for ( int l = 0;(l < k);l++) {trees[l][0] = (Integer.valueOf(st[(l * 2)]) - 1); trees[l][1] = (Integer.valueOf(st[((l * 2) + 1)]) - 1); } int maxtime = -1;  int max_x = -1;  int max_y = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int minDist = (n + m); for ( int l = 0;(l < k);l++) {minDist = Math.min(minDist,(Math.abs((i - trees[l][0])) + Math.abs((j - trees[l][1])))); }if ( (maxtime < minDist)) {maxtime = minDist; max_x = (i + 1); max_y = (j + 1); } }}out.println(((max_x + " ") + max_y)); out.flush(); } }
6	public class Main11D{ private FastScanner in ; private PrintWriter out ; public void solve()throws IOException { int N = in.nextInt();  int M = in.nextInt();  int[][] edges = new int[N][N]; for ( int i = 0;(i < M);i++) { int a = (in.nextInt() - 1);  int b = (in.nextInt() - 1); edges[a][b] = 1; edges[b][a] = 1; } int globalCountMasks = (1 << N);  int[][] masks = new int[(N + 1)][];  int[] countMasks = new int[(N + 1)]; for ( int i = 0;(i <= N);i++) {masks[i] = new int[combinations(N,i)]; }for ( int i = 0;(i < globalCountMasks);i++) { int c = countBit1(i); masks[c][countMasks[c]] = i; countMasks[c]++; } long globalCountCycles = 0;  long[][] count = new long[globalCountMasks][N]; for ( int a = 0;(a < (N - 2));a++) { int aBit = (1 << a); count[aBit][a] = 1; long countCycles = 0; for ( int i = 2;(i <= N);i++) {for ( int m = 0;(m < countMasks[i]);m++) { int mask = masks[i][m]; if ( ((mask & aBit) == 0)) continue; if ( ((mask & (aBit - 1)) > 0)) continue; count[mask][a] = 0; for ( int v = (a + 1);(v < N);v++) { int vBit = (1 << v); if ( ((mask & vBit) == 0)) continue; count[mask][v] = 0; for ( int t = a;(t < N);t++) {if ( ((((mask & (1 << t)) == 0) || (t == v)) || (edges[v][t] == 0))) continue; count[mask][v] += count[(mask ^ vBit)][t]; }if ( ((edges[a][v] == 1) && (mask != (aBit | vBit)))) {countCycles += count[mask][v]; } }}}globalCountCycles += (countCycles / 2); }out.println(globalCountCycles); } private int countBit1( int k){ int c = 0; while((k > 0)){c += (k & 1); k >>= 1; }return c;} private int combinations( int n, int k){ if ( ((k > n) || (k < 0))) {throw (new IllegalArgumentException());} int r = 1; for ( int i = 1;(i <= k);i++) {r = ((r * ((n + 1) - i)) / i); }return r;} public void run(){ try{in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } 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 Main11D().run(); } }
3	public class C{ static long time = System.currentTimeMillis(); public static void main( String[] args)throws IOException { FastReader infile = new FastReader(System.in);  int N = infile.nextInt();  int R = infile.nextInt();  double[] xPos = new double[N]; for ( int x = 0;(x < N);x++) xPos[x] = infile.nextDouble(); double[] yPos = new double[N]; Arrays.fill(yPos,R); for ( int x = 1;(x < N);x++) {for ( int y = 0;(y < x);y++) if ( (Math.abs((xPos[x] - xPos[y])) <= (2 * R))) {yPos[x] = Math.max(yPos[x],(yPos[y] + Math.sqrt((((2 * R) * (2 * R)) - (Math.abs((xPos[x] - xPos[y])) * Math.abs((xPos[x] - xPos[y]))))))); } }System.out.print(yPos[0]); for ( int x = 1;(x < N);x++) System.out.print((" " + yPos[x])); } } class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader( String file)throws IOException{ br = new BufferedReader(new FileReader(file)); } public FastReader( InputStream i)throws IOException{ 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());} double nextDouble(){ return Double.parseDouble(next());} }
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); }} }
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);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } } class TaskC{ public void solve( int testNumber, InputReader in, OutputWriter out){ int maxdist = -1,maxrow = -1,maxcol = -1;  int rows = in.ri(),cols = in.ri();  int k = in.ri();  IntPair[] points = new IntPair[k]; for ( int i = 0;(i < k);i++) points[i] = new IntPair(in.ri(),in.ri()); for ( int row = 1;(row <= rows);row++) {for ( int col = 1;(col <= cols);col++) { int mindist = Integer.MAX_VALUE; for ( int i = 0;(i < k);i++) mindist = Math.min(mindist,(Math.abs((row - points[i].first)) + Math.abs((col - points[i].second)))); if ( (mindist > maxdist)) {maxdist = mindist; maxrow = row; maxcol = col; } }}out.printLine(maxrow,maxcol); } } 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 ri(){ return readInt();} 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 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(); } } class IntPair implements Comparable<IntPair>{ public int first ,second ; public IntPair( int first, int second){ this.first = first; this.second = second; } }
4	public class C{ public static void main( String[] args)throws Exception { new C(new Scanner(new File("input.txt")),new PrintWriter("output.txt")); } int oo = 987654321; int W ,H ; public C( Scanner in, PrintWriter out){ W = in.nextInt(); H = in.nextInt(); int[][] grid = new int[W][H]; for ( int[] gri :grid) Arrays.fill(gri,oo); ArrayDeque<Node> q = new ArrayDeque<Node>();  int K = in.nextInt(); for ( int u = 0;(u < K);u++) {q.add(new Node((in.nextInt() - 1),(in.nextInt() - 1),0)); while((q.size() > 0)){ Node cur = q.poll(); if ( (grid[cur.x][cur.y] <= cur.d)) continue; grid[cur.x][cur.y] = cur.d; if ( ((cur.x + 1) < W)) q.add(new Node((cur.x + 1),cur.y,(cur.d + 1))); if ( (cur.x > 0)) q.add(new Node((cur.x - 1),cur.y,(cur.d + 1))); if ( ((cur.y + 1) < H)) q.add(new Node(cur.x,(cur.y + 1),(cur.d + 1))); if ( (cur.y > 0)) q.add(new Node(cur.x,(cur.y - 1),(cur.d + 1))); }} int res = 0; for ( int j = 0;(j < H);j++) for ( int i = 0;(i < W);i++) res = Math.max(res,grid[i][j]); for ( int j = 0;(j < H);j++) for ( int i = 0;(i < W);i++) if ( (res == grid[i][j])) {out.printf("%d %d%n",(i + 1),(j + 1)); out.close(); return ;} } } class Node{ int x ,y ,d ; public Node( int xx, int yy, int dd){ x = xx; y = yy; d = dd; } }
4	public class D{ static int mod = (int)(1e9 + 7); static InputReader in ; static PrintWriter out ; static void solve(){ in = new InputReader(System.in); out = new PrintWriter(System.out); int t = 1; while((t-- > 0)){ int n = in.nextInt();  int m = in.nextInt();  int K = in.nextInt();  long[][] x = new long[n][]; for ( int i = 0;(i < n);i++) {x[i] = in.nextLongArray((m - 1)); } long[][] y = new long[(n - 1)][]; for ( int i = 0;(i < (n - 1));i++) {y[i] = in.nextLongArray(m); }if ( ((K % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print("-1 "); }out.println(); }continue;} K /= 2; long[][][] dp = new long[(K + 1)][n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {for ( int k = 1;(k <= K);k++) {dp[k][i][j] = Integer.MAX_VALUE; }}}for ( int k = 1;(k <= K);k++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( ((i + 1) < n)) {dp[k][i][j] = Math.min(dp[k][i][j],(dp[(k - 1)][(i + 1)][j] + (2 * y[i][j]))); } if ( ((i - 1) >= 0)) {dp[k][i][j] = Math.min(dp[k][i][j],(dp[(k - 1)][(i - 1)][j] + (2 * y[(i - 1)][j]))); } if ( ((j + 1) < m)) {dp[k][i][j] = Math.min(dp[k][i][j],(dp[(k - 1)][i][(j + 1)] + (2 * x[i][j]))); } if ( ((j - 1) >= 0)) {dp[k][i][j] = Math.min(dp[k][i][j],(dp[(k - 1)][i][(j - 1)] + (2 * x[i][(j - 1)]))); } }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((dp[K][i][j] + " ")); }out.println(); }}out.close(); } public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } 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 int abs( int a, int b){ return (int)Math.abs((a - b));} static long abs( long a, long b){ return (long)Math.abs((a - b));} static int min( int a, int b){ if ( (a > b)) {return b;} else {return a;}} static long min( long a, long b){ if ( (a > b)) {return b;} else {return a;}} 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 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){ 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); } } }
6	public class D{ public void run( Scanner in, PrintWriter out){ int n = in.nextInt();  int[][] graph = new int[n][n];  int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); graph[x][y] = 1; graph[y][x] = 1; } long[][] dyn = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {dyn[(1 << i)][i] = 1; } long answer = 0; for ( int mask = 1;(mask < (1 << n));mask++) { int start = Integer.numberOfTrailingZeros(mask); for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) continue; for ( int j = (start + 1);(j < n);j++) {if ( ((graph[i][j] > 0) && ((mask & (1 << j)) == 0))) {dyn[(mask + (1 << j))][j] += dyn[mask][i]; } }if ( (graph[i][start] > 0)) {answer += dyn[mask][i]; } }}out.println(((answer - m) / 2)); } public static void main( String[] args){ try(Scanner in=new Scanner(System.in);PrintWriter out=new PrintWriter(System.out)){new D().run(in,out); }catch (Exception e){ e.printStackTrace(); } } }
5	public class codeee{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( (n == 1)) {System.out.println(1); return ;} int[] mas = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {mas[i] = sc.nextInt(); sum += mas[i]; }Arrays.sort(mas); int sum1 = 0;  int ans = 0; for ( int i = 0;(i < n);i++) {sum1 += mas[((n - i) - 1)]; if ( (sum1 > (sum - sum1))) {ans = i; break;} }System.out.println((ans + 1)); } }
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();} }
2	public class A implements Runnable{ static BufferedReader in ; static PrintWriter out ; static StringTokenizer st ; static Random rnd ; final long MODULO = 1000000009; private void solve()throws IOException { int moves = nextInt(),rightMoves = nextInt(),sequence = nextInt();  long answer = solveSmart(moves,rightMoves,sequence); out.println(answer); } private long solveSmart( long moves, long rightMoves, long sequence){ long fullSequences = (moves / sequence);  long canReset = Math.min(fullSequences,(moves - rightMoves));  long remainSequences = (fullSequences - canReset);  long answer = ((rightMoves - (remainSequences * sequence)) + getAnswerSequences(remainSequences,sequence)); answer %= MODULO; return answer;} private long getAnswerSequences( long count, long length){ long first = ((getPow(2,(count + 1)) - 2) % MODULO);  long result = (first * length); result %= MODULO; result += MODULO; result %= MODULO; return result;} private int getPow( int n, long p){ return BigInteger.valueOf(2).modPow(BigInteger.valueOf(p),BigInteger.valueOf(MODULO)).intValue();} 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(1); } } private 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();} private int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
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); }
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());} } }
0	public class C72A{ static BufferedReader br ; public static void main( String[] args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); long n = toLong();  long res = (n + (n / 2)); System.out.println(res); } public static long toLong()throws Exception { return Long.parseLong(br.readLine());} }
1	public class B{ private Scanner in ; private PrintWriter out ; public void solve(){ String str = in.next();  List<String> sp = new ArrayList<String>();  StringBuilder sb = null;  int kind = -1; for ( int i = 0;(i < str.length());i++) { char c = str.charAt(i); if ( (((c >= 'A') && (c <= 'Z')) && (kind != 0))) {if ( (sb != null)) {sp.add(sb.toString()); } sb = new StringBuilder(); kind = 0; } if ( (((c >= '0') && (c <= '9')) && (kind != 1))) {if ( (sb != null)) {sp.add(sb.toString()); } sb = new StringBuilder(); kind = 1; } sb.append(c); }sp.add(sb.toString()); if ( (sp.size() == 2)) { String bc = sp.get(0);  int v = 0; for ( int i = 0;(i < bc.length());i++) {v = ((26 * v) + ((bc.charAt(i) - 'A') + 1)); }out.println(((("R" + sp.get(1)) + "C") + Integer.toString(v))); } else { int v = Integer.parseInt(sp.get(3));  StringBuilder sbb = new StringBuilder(); for ( ;(v > 0);v /= 26) {v--; sbb.append((char)((v % 26) + 'A')); }sbb.reverse(); out.println((sbb.toString() + sp.get(1))); }out.flush(); } public void run()throws Exception { in = new Scanner(System.in); out = new PrintWriter(System.out); int n = in.nextInt(); for ( int i = 1;(i <= n);i++) { long t = System.currentTimeMillis(); solve(); }} public static void main( String[] args)throws Exception { new B().run(); } }
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();} }
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);  G1PleilistDlyaPolikarpaUproshennayaVersiya solver = new G1PleilistDlyaPolikarpaUproshennayaVersiya(); solver.solve(1,in,out); out.close(); } static class G1PleilistDlyaPolikarpaUproshennayaVersiya{ static final int MOD = ((int)1e9 + 7); int n ; int t ; int[][] a = new int[15][2]; long[][] mem = new long[(1 << 15)][4]; public void solve( int testNumber, InputReader in, PrintWriter out){ for ( int i = 0;(i < (1 << 15));i++) {for ( int h = 0;(h < 4);h++) {mem[i][h] = -1; }}n = in.nextInt(); t = in.nextInt(); for ( int i = 0;(i < n);i++) {a[i][0] = in.nextInt(); a[i][1] = in.nextInt(); }out.println(doit(0,0,0)); } private long doit( int mask, int genre, int sum){ if ( (mem[mask][genre] != -1)) {return mem[mask][genre];} if ( (sum > t)) {mem[mask][genre] = 0; return mem[mask][genre];} if ( (sum == t)) {mem[mask][genre] = 1; return mem[mask][genre];} long ct = 0; for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) > 0) || (genre == a[i][1]))) {continue;} ct = ((ct + doit((mask | (1 << i)),a[i][1],(sum + a[i][0]))) % MOD); }mem[mask][genre] = ct; return mem[mask][genre];} } 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{ 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(); } } }
3	public class Codeforces{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); final double eps = 1e-7;  String toks[] = in.readLine().split(" ");  int n = Integer.parseInt(toks[0]);  double r = Double.parseDouble(toks[1]);  double x[] = new double[n]; toks = in.readLine().split(" "); for ( int i = 0;(i < n);i++) {x[i] = Double.parseDouble(toks[i]); } double lo ,hi ,mid ;  double y[] = new double[n]; y[0] = r; for ( int i = 1;(i < n);i++) {y[i] = r; for ( int j = 0;(j < i);j++) {lo = y[j]; hi = (2000 * 2000); while((Math.abs((hi - lo)) >= eps)){mid = ((hi + lo) / 2); if ( ((Math.sqrt((((x[i] - x[j]) * (x[i] - x[j])) + ((y[j] - mid) * (y[j] - mid)))) + eps) > (2 * r))) {hi = mid; } else {lo = mid; }}if ( (Math.sqrt((((x[i] - x[j]) * (x[i] - x[j])) + ((y[j] - lo) * (y[j] - lo)))) < ((2 * r) + eps))) {y[i] = Math.max(y[i],lo); } }}for ( double z :y) {System.out.printf(Locale.US,"%.7f ",z); }} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  QuickScanner in = new QuickScanner(inputStream);  QuickWriter out = new QuickWriter(outputStream);  TaskG solver = new TaskG(); solver.solve(1,in,out); out.close(); } static class TaskG{ static int MAXL = (700 + 1); static IntModular MOD = new IntModular(); int n ; char[] digits ; int[] pow10 ; int[] ones ; int[][][] way ; public void solve( int testNumber, QuickScanner in, QuickWriter out){ digits = new char[MAXL]; n = in.next(digits); initPow(); int res = MOD.mul(calc(9),9); for ( int digit = 0;(digit < 9);++digit) {res = MOD.sub(res,calc(digit)); }out.println(res); } void initPow(){ pow10 = new int[(n + 1)]; ones = new int[(n + 1)]; pow10[0] = 1; for ( int i = 1;(i <= n);++i) {pow10[i] = MOD.mul(pow10[(i - 1)],10); ones[i] = MOD.add(MOD.mul(ones[(i - 1)],10),1); }} int calc( int targetDigit){ if ( (way == null)) {way = new int[2][2][(n + 1)]; } int t = 0; clearCnt(t); way[t][0][0] = 1; for ( int i = 0;(i < n);++i) { int digit = (digits[i] - '0'); clearCnt((t ^ 1)); for ( int cnt = 0;(cnt <= n);++cnt) if ( (way[t][0][cnt] > 0)) { int newCnt = ((targetDigit < digit)?(cnt + 1):cnt); way[(t ^ 1)][0][newCnt] = MOD.add(way[(t ^ 1)][0][newCnt],way[t][0][cnt]); way[(t ^ 1)][1][cnt] = MOD.add(way[(t ^ 1)][1][cnt],MOD.mul(Math.min((targetDigit + 1),digit),way[t][0][cnt])); way[(t ^ 1)][1][(cnt + 1)] = MOD.add(way[(t ^ 1)][1][(cnt + 1)],MOD.mul(Math.max(((digit - targetDigit) - 1),0),way[t][0][cnt])); } for ( int cnt = 0;(cnt <= n);++cnt) if ( (way[t][1][cnt] > 0)) {way[(t ^ 1)][1][cnt] = MOD.add(way[(t ^ 1)][1][cnt],MOD.mul((targetDigit + 1),way[t][1][cnt])); way[(t ^ 1)][1][(cnt + 1)] = MOD.add(way[(t ^ 1)][1][(cnt + 1)],MOD.mul((9 - targetDigit),way[t][1][cnt])); } t ^= 1; } int res = 0; for ( int cnt = 0;(cnt <= n);++cnt) {res = MOD.add(res,MOD.mul(MOD.mul(ones[(n - cnt)],pow10[cnt]),MOD.add(way[t][0][cnt],way[t][1][cnt]))); }return res;} void clearCnt( int t){ for ( int free = 0;(free < 2);++free) {Arrays.fill(way[t][free],0); }} } static class QuickWriter{ private final PrintWriter writer ; public QuickWriter( OutputStream outputStream){ this.writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public QuickWriter( 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 IntModular{ static private final int MOD = 1000000007; public final int mod ; private final int[] x ; public IntModular(){ this(MOD); } public IntModular( int mod){ this.mod = mod; this.x = new int[2]; } public int add( int a, int b){ return fix((a + b),mod);} public int sub( int a, int b){ return fix((a - b),mod);} public int mul( int a, int b){ return mul(a,b,mod);} public static int mul( int a, int b, int mod){ return ((a > 0)?((b < (mod / a))?(a * b):(int)(((long)a * b) % mod)):0);} public static int fix( int a, int mod){ a = slightFix(a,mod); return (((0 <= a) && (a < mod))?a:slightFix((a % mod),mod));} static private int slightFix( int a, int mod){ return ((a >= mod)?(a - mod):((a < 0)?(a + mod):a));} } static class QuickScanner{ static private final int BUFFER_SIZE = 1024; private InputStream stream ; private byte[] buffer ; private int currentPosition ; private int numberOfChars ; public QuickScanner( InputStream stream){ this.stream = stream; this.buffer = new byte[BUFFER_SIZE]; this.currentPosition = 0; this.numberOfChars = 0; } public int next( char[] s){ return next(s,0);} public int next( char[] s, int startIdx){ int b = nextNonSpaceChar();  int res = 0; do {s[startIdx++] = (char)b; b = nextChar(); ++res; }while(!isSpaceChar(b));return res;} public int nextNonSpaceChar(){ int res = nextChar(); for ( ;(isSpaceChar(res) || (res < 0));res = nextChar()) ;return res;} public int nextChar(){ if ( (numberOfChars == -1)) {throw (new RuntimeException());} if ( (currentPosition >= numberOfChars)) {currentPosition = 0; try{numberOfChars = stream.read(buffer); }catch (Exception e){ throw (new RuntimeException(e));} if ( (numberOfChars <= 0)) {return -1;} } return buffer[currentPosition++];} public boolean isSpaceChar( int c){ return (((c == ' ') || (c == '\t')) || isEndOfLineChar(c));} public boolean isEndOfLineChar( int c){ return (((c == '\n') || (c == '\r')) || (c < 0));} } }
0	public class myTemplate{ public static void main( String[] args)throws Exception { java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));  int ch[] ,arr[] ;  int x ,i ,j ,k ,t ,n = Integer.parseInt(br.readLine()); if ( (n > 0)) System.out.println(n); else {x = (n / 100); x = ((x * 10) + (n % 10)); if ( ((n / 10) > x)) System.out.println((n / 10)); else System.out.println(x); }} }
5	public class Main implements Runnable{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private Random rnd ; private void solve()throws IOException { int n = nextInt();  int[] a = new int[n];  int max = 0; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); if ( (a[i] > a[max])) max = i; } int value = 1; if ( (a[max] == 1)) value = 2; a[max] = value; Arrays.sort(a); for ( int i = 0;(i < n);i++) {out.print(a[i]); out.print(' '); }} public static void main( String[] args){ new Main().run(); } public void run(){ try{try{in = new BufferedReader(new FileReader("INPUT.TXT")); out = new PrintWriter(new FileWriter("OUTPUT.TXT")); }catch (FileNotFoundException e){ 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());} }
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); } }
4	public class PracticeProblem{ public static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader()throws FileNotFoundException{ br = new BufferedReader(new FileReader(new File("input.txt"))); } 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 FastReader in ; public static PrintWriter out ; public static final int INF = Integer.MAX_VALUE; public static int n ,m ; public static final int[] dr = {-1,0,0,+1}; public static final int[] dc = {0,-1,+1,0}; public static void main( String[] args)throws FileNotFoundException { in = new FastReader(); out = new PrintWriter(new File("output.txt")); solve(); out.close(); } static private void solve(){ n = in.nextInt(); m = in.nextInt(); int k = in.nextInt();  int[][] timeToBurn = new int[n][m]; for ( int i = 0;(i < n);i++) Arrays.fill(timeToBurn[i],INF); for ( int i = 0;(i < k);i++) { int r = (in.nextInt() - 1);  int c = (in.nextInt() - 1); for ( int j = 0;(j < n);j++) {for ( int l = 0;(l < m);l++) {timeToBurn[j][l] = min(timeToBurn[j][l],(abs((r - j)) + abs((c - l)))); }}} int max = -1;  Point p = null; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (timeToBurn[i][j] > max)) {max = timeToBurn[i][j]; p = new Point(i,j); } }}out.println((((p.x + 1) + " ") + (p.y + 1))); } }
4	public class C{ static BufferedReader br ; static StringTokenizer st ; static PrintWriter pw ; static String nextToken(){ try{while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(br.readLine()); } }catch (IOException e){ e.printStackTrace(); } return st.nextToken();} static int nextInt(){ return Integer.parseInt(nextToken());} public static void main( String[] args){ br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); solve(); pw.close(); } static private void solve(){ int t = nextInt();  int[] stack = new int[1000000]; for ( int i = 0;(i < t);i++) { int n = nextInt(); stack[0] = nextInt(); int id = 1; pp(stack,id); for ( int j = 1;(j < n);j++) { int x = nextInt(); if ( (x == 1)) {stack[id++] = x; } else {while(true){ int p = stack[--id]; if ( ((p + 1) == x)) {stack[id++] = x; break;} }}pp(stack,id); }}} static private void pp( int[] stack, int size){ for ( int i = 0;(i < (size - 1));i++) {pw.print((stack[i] + ".")); }pw.println(stack[(size - 1)]); } }
5	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){ int n = in.nextInt();  int k = in.nextInt();  HashSet<Integer> set = new HashSet<Integer>();  int a[] = new int[n]; for ( int i = 0;(i < n);++i) {a[i] = in.nextInt(); }Arrays.sort(a); int ans = 0;  int ptr = -1;  boolean chosen[] = new boolean[n]; for ( int i = 0;(i < n);++i) {while((((ptr + 1) < i) && ((a[(ptr + 1)] * (long)k) <= a[i]))){++ptr; }if ( (((((a[i] % k) != 0) || (ptr == -1)) || !chosen[ptr]) || ((a[ptr] * (long)k) != a[i]))) {++ans; chosen[i] = true; } }out.println(ans); } } class InputReader{ BufferedReader reader ; 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 (Exception e){ throw (new UnknownError());} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} }
4	public class FireAgain{ public static void main( String[] args)throws IOException { System.setIn(new FileInputStream("input.txt")); System.setOut(new PrintStream("output.txt")); BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  String s[] = r.readLine().split("\\s+");  int n = Integer.parseInt(s[0]);  int m = Integer.parseInt(s[1]);  int k = Integer.parseInt(r.readLine());  int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) a[i][j] = Integer.MAX_VALUE; }assert ((k >= 1) && (k < (n * m))); int max = 0;  StringTokenizer st = new StringTokenizer(r.readLine()); assert (st.countTokens() == k); for ( ;(k > 0);k--) { int x = (Integer.parseInt(st.nextToken()) - 1);  int y = (Integer.parseInt(st.nextToken()) - 1); assert ((((x >= 1) && (x <= n)) && (y >= 1)) && (y <= n)); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int d = (Math.abs((i - x)) + Math.abs((j - y))); if ( (a[i][j] > d)) a[i][j] = d; if ( ((k == 1) && (a[i][j] > max))) max = a[i][j]; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (a[i][j] == max)) {System.out.println((((i + 1) + " ") + (j + 1))); return ;} }}} }
5	public class Solution{ void solve()throws Exception { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); int[] b = a.clone(); Arrays.sort(b); int cnt = 0; for ( int i = 0;(i < n);i++) if ( (a[i] != b[i])) cnt++; if ( (cnt <= 2)) System.out.println("YES"); else System.out.println("NO"); } BufferedReader reader ; PrintWriter writer ; StringTokenizer stk ; void run()throws Exception { reader = new BufferedReader(new InputStreamReader(System.in)); stk = null; writer = new PrintWriter(new PrintWriter(System.out)); solve(); reader.close(); writer.close(); } int nextInt()throws Exception { return Integer.parseInt(nextToken());} String nextLine()throws Exception { return reader.readLine();} String nextToken()throws Exception { if ( ((stk == null) || !stk.hasMoreTokens())) {stk = new StringTokenizer(nextLine()); return nextToken();} return stk.nextToken();} public static void main( String[] args)throws Exception { new Solution().run(); } }
4	public class Main{ public static void main( String[] args)throws IOException { Scanner c = new Scanner(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int N = c.nextInt();  int M = c.nextInt();  int A[][] = new int[N][M]; for ( int i = 0;(i < N);i++) Arrays.fill(A[i],(Integer.MAX_VALUE / 100)); int K = c.nextInt(); for ( int i = 0;(i < K);i++) { int x = (c.nextInt() - 1);  int y = (c.nextInt() - 1); for ( int i1 = 0;(i1 < N);i1++) {for ( int j1 = 0;(j1 < M);j1++) A[i1][j1] = Math.min(A[i1][j1],(Math.abs((i1 - x)) + Math.abs((j1 - y)))); }} int maxi = 0;  int maxj = 0; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {if ( (A[i][j] > A[maxi][maxj])) {maxi = i; maxj = j; } }}out.println((((maxi + 1) + " ") + (maxj + 1))); out.close(); } }
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 ;} }
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 m = s; while((((m - digitAdd(m)) < s) && (m <= n))){m++; }System.out.println(Math.max(((n - m) + 1),0)); } static private int digitAdd( long s){ int sum = 0; for ( long i = 0,j = 1L;(i < ((int)Math.log10(s) + 1));i++,j *= 10) {sum += ((s / j) % 10); }return sum;} }
2	public class PipelineRedo{ public static void main( String[] args){ FastScanner sc = new FastScanner();  long n = (sc.nextLong() - 1);  long k = (sc.nextInt() - 1); if ( (n == 0)) {System.out.println(0); return ;} else if ( (n <= k)) {System.out.println(1); return ;} else if ( (n > ((k * (k + 1)) / 2))) {System.out.println(-1); return ;} long rightSum = ((k * (k + 1)) / 2);  long lo = 1;  long hi = k; while((lo < hi)){ long mid = (lo + (((hi - lo) + 1) / 2));  long val = (rightSum - ((mid * (mid - 1)) / 2)); if ( (val <= n)) {hi = (mid - 1); } else {lo = mid; }}if ( ((rightSum - (((lo + 1) * lo) / 2)) == n)) {System.out.println(((k - (lo + 1)) + 1)); } else {System.out.println((1 + ((k - (lo + 1)) + 1))); }} public 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());} long nextLong(){ return Long.parseLong(nextToken());} } }
5	public class Main{ private void solve()throws IOException { int n = nextInt();  int[] arr = new int[n];  int count = 0; for ( int x = 0;(x < n);x++) {arr[x] = nextInt(); count += arr[x]; }Arrays.sort(arr); count /= 2; int result = 0,sum = 0; for ( int x = (arr.length - 1);(x >= 0);x--) {sum += arr[x]; result++; if ( (sum > count)) {break;} }System.out.println(result); } public static void main( String[] args){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); new Main().solve(); out.close(); }catch (Throwable e){ System.out.println(e); 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());} static long nextLong()throws IOException { return Long.parseLong(nextToken());} }
6	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  double value[][] = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) value[i][j] = in.nextDouble(); double ans[] = new double[(1 << n)];  int mask = (1 << n); ans[((1 << n) - 1)] = 1.0; for ( int i = (mask - 1);(i >= 0);i--) { int cnt = Integer.bitCount(i);  int pairs = ((cnt * (cnt - 1)) / 2); for ( int j = 0;(j < n);j++) {if ( (((i >> j) & 1) == 0)) continue; for ( int k = (j + 1);(k < n);k++) {if ( (((i >> k) & 1) == 0)) continue; ans[(i ^ (1 << k))] += ((ans[i] * value[j][k]) / pairs); ans[(i ^ (1 << j))] += ((ans[i] * value[k][j]) / pairs); }}}for ( int i = 0;(i < n);i++) System.out.print((ans[(1 << i)] + " ")); } }
2	public class D{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int tc = sc.nextInt(); out:while((tc-- > 0)){ long n = sc.nextInt();  long k = sc.nextLong(); if ( (n >= 32)) {pw.println(("YES " + (n - 1))); continue;} long steps = 0; for ( int i = 1;;i++) { long cnt = ((1l << (i + 1)) - 1); steps += ((1l << i) - 1); if ( (steps > k)) break; if ( (steps > f(n))) break; long rem = (k - steps); if ( (rem <= ((f(n) - steps) - (cnt * f((n - i)))))) {pw.println(("YES " + (n - i))); continue out;} }pw.println("NO"); }pw.flush(); pw.close(); } static long f( long n){ if ( (n == 0)) return 0; long ans = 0; for ( int i = 0;(i < n);i++) {ans += (1l << (2 * i)); }return ans;} static int[][] matMul( int[][] A, int[][] B, int p, int q, int r){ int[][] C = new int[p][r]; for ( int i = 0;(i < p);++i) for ( int j = 0;(j < r);++j) for ( int k = 0;(k < q);++k) C[i][j] += (A[i][k] * B[k][j]); return C;} 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());} public long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
2	public class B{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long k = sc.nextLong(); if ( (n == 1)) {System.out.println(0); } else if ( (n <= k)) {System.out.println(1); } else {n--; k--; BigInteger K = BigInteger.valueOf(k);  BigInteger N = BigInteger.valueOf(n);  BigInteger high = BigInteger.valueOf((k + 1));  BigInteger low = BigInteger.valueOf(1);  BigInteger mid ; while((low.compareTo(high) < 0)){mid = low.add(high.subtract(low).shiftRight(1)); BigInteger elemCnt = K.subtract(mid).add(BigInteger.ONE);  BigInteger sum = elemCnt.multiply(mid.shiftLeft(1).add(elemCnt.subtract(BigInteger.ONE))).shiftRight(1); if ( (sum.compareTo(N) > 0)) {low = mid.add(BigInteger.valueOf(1)); } else {high = mid; }} BigInteger elemCnt = K.subtract(low).add(BigInteger.ONE);  BigInteger sum = elemCnt.multiply(low.shiftLeft(1).add(elemCnt.subtract(BigInteger.ONE))).shiftRight(1);  BigInteger rem = N.subtract(sum); if ( rem.equals(BigInteger.ZERO)) {System.out.println(elemCnt); } else if ( (rem.compareTo(low) < 0)) {System.out.println(elemCnt.add(BigInteger.ONE)); } else {System.out.println(-1); }}} }
4	public class Main{ static boolean used[][] ; static int n ; static int m ; public static void main( String[] args)throws IOException { br = new BufferedReader(new FileReader("input.txt")); PrintWriter out = new PrintWriter("output.txt"); n = nextInt(); m = nextInt(); int k = nextInt(); used = new boolean[n][m]; Deque<point> deq = new ArrayDeque<>(); for ( int i = 0;(i < k);i++) {deq.addLast(new point((nextInt() - 1),(nextInt() - 1))); used[deq.peekLast().x][deq.peekLast().y] = true; } point last = new point(0,0); while(!deq.isEmpty()){ point v = deq.pollFirst();  int x = v.x;  int y = v.y; if ( checker(x,(y + 1))) {last = new point(x,(y + 1)); deq.addLast(new point(x,(y + 1))); used[x][(y + 1)] = true; } if ( checker(x,(y - 1))) {last = new point(x,(y - 1)); deq.addLast(new point(x,(y - 1))); used[x][(y - 1)] = true; } if ( checker((x + 1),y)) {last = new point((x + 1),y); deq.addLast(new point((x + 1),y)); used[(x + 1)][y] = true; } if ( checker((x - 1),y)) {last = new point((x - 1),y); deq.addLast(new point((x - 1),y)); used[(x - 1)][y] = true; } }out.println((((last.x + 1) + " ") + (last.y + 1))); out.close(); } static boolean checker( int x, int y){ if ( (((((x < n) && (y < m)) && (x >= 0)) && (y >= 0)) && !used[x][y])) return true; return false;} static StringTokenizer st = new StringTokenizer(""); static BufferedReader br ; static String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(next());} } class point{ int x ,y ; public point( int x, int y){ this.x = x; this.y = y; } }
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{ int MAXN = 200005; PrintWriter out ; InputReader in ; public void solve( int testNumber, InputReader in, PrintWriter out){ this.out = out; this.in = in; long n = nl();  long k = nl();  long i = 0; k += n; for ( i = 0;(i < MAXN);i++) { long x = ((i * (i + 3)) / 2); if ( (k == x)) {pn((n - i)); return ;} }} long nl(){ return in.nextLong();} void pn( long zx){ out.println(zx); } } 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 long nextLong(){ return Long.parseLong(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));} } }
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 = 0,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); } } }
1	public class Main{ public static void main( String[] args)throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = nextInt(),k = nextInt();  int[] primes = new int[(n + 1)]; for ( int i = 2;(i <= n);i++) {if ( (primes[i] == 0)) {primes[i] = 1; for ( int j = (i * 2);(j <= n);j += i) primes[j] = 2; } } ArrayList<Integer> res = new ArrayList<Integer>();  HashSet<Integer> p = new HashSet<Integer>(),v = new HashSet<Integer>(); for ( int i = 2;(i <= n);i++) {if ( (primes[i] == 1)) {res.add(i); p.add(i); } } int c = 0; if ( (res.size() >= 3)) {for ( int i = 2;(i < res.size());i++) { int zz = ((res.get((i - 2)) + res.get((i - 1))) + 1); if ( p.contains(zz)) v.add(zz); }c = v.size(); } if ( (c >= k)) {out.println("YES"); } else {out.println("NO"); }in.close(); out.close(); } 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 NumberFormatException,IOException { return Integer.parseInt(nextString());} }
5	public class A135{ public static void main( String[] args)throws Exception { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(r.readLine());  int[] ar = new int[n];  StringTokenizer st = new StringTokenizer(r.readLine()); for ( int x = 0;(x < n);x++) {ar[x] = Integer.parseInt(st.nextToken()); }Arrays.sort(ar); if ( (n == 1)) {System.out.println(((ar[0] == 1)?"2":"1")); return ;} if ( (ar[(n - 1)] == 1)) {ar[(n - 2)] = 2; } System.out.print("1"); for ( int x = 0;(x < (n - 1));x++) {System.out.print((" " + ar[x])); }System.out.println(); } }
2	public class A{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void solve()throws IOException { final int mod = (((1000 * 1000) * 1000) + 9);  long n = readInt();  long m = readInt();  long k = readInt();  long fail = (n - m);  long posl = (n / k); if ( ((n % k) != 0)) {posl++; } if ( (posl <= fail)) {out.println(m); } else { long d = (fail - posl);  long res = ((k - 1) * fail); m -= ((k - 1) * fail); long z = (m / k); res += (m % k); res %= mod; long x = binpow(2,(z + 1),mod); x -= 2; x += mod; x %= mod; x *= k; res += x; res %= mod; out.println(res); }} long binpow( long a, long n, long mod){ long res = 1; while((n != 0))if ( ((n & 1) != 0)) {res *= a; res = (res % mod); --n; } else {a *= a; a = (a % mod); n >>= 1; }return res;} 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());} long readLong()throws IOException { return Long.parseLong(readString());} public static void main( String[] args){ new A().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); } } }
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{ final int P = ((int)1e9 + 7); int n ; char[] commands ; int[][] memo ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); commands = new char[n]; memo = new int[n][12345]; for ( int i = 0;(i < n);i++) {commands[i] = in.next().charAt(0); for ( int j = 0;(j < 12345);j++) {memo[i][j] = -1; }}out.print(solve(1,0)); } int add( int a, int b){ return (((a % P) + (b % P)) % P);} int solve( int i, int indents){ if ( (i == n)) return 1; if ( (memo[i][indents] != -1)) return memo[i][indents]; int answer ; if ( (commands[(i - 1)] == 'f')) {answer = solve((i + 1),(indents + 1)); } else {if ( (indents == 0)) {answer = solve((i + 1),indents); } else {answer = add(solve(i,(indents - 1)),solve((i + 1),indents)); }}return memo[i][indents] = answer;} } static class InputReader{ private StringTokenizer tokenizer ; private BufferedReader reader ; public InputReader( InputStream inputStream){ reader = new BufferedReader(new InputStreamReader(inputStream)); } private void fillTokenizer(){ if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {try{tokenizer = new StringTokenizer(reader.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} } } public String next(){ fillTokenizer(); return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
6	public class EdC{ static long[] mods = {1000000007,998244353,1000000009}; static long mod = mods[0]; public static MyScanner sc ; public static PrintWriter out ; static char[][] grid ; static int n ; static int t ; static int[][] dp ; static int[] times ; static int[] genre ; public static void main( String[] omkar)throws Exception { sc = new MyScanner(); out = new PrintWriter(System.out); n = sc.nextInt(); t = sc.nextInt(); times = new int[n]; genre = new int[n]; for ( int j = 0;(j < n);j++) {times[j] = sc.nextInt(); genre[j] = sc.nextInt(); }dp = new int[(1 << n)][4]; for ( int j = 0;(j < (1 << n));j++) Arrays.fill(dp[j],-1); for ( int j = 0;(j < (1 << n));j++) {letsgodp(j,1); letsgodp(j,2); letsgodp(j,3); } int ans = 0; for ( int j = 0;(j < (1 << n));j++) { int time = 0; for ( int k = 0;(k < n);k++) {if ( (((1 << k) & j) != 0)) {time += times[k]; } }if ( (time == t)) {ans += dp[j][1]; ans %= mod; ans += dp[j][2]; ans %= mod; ans += dp[j][3]; ans %= mod; } }out.println(ans); out.close(); } public static void letsgodp( int mask, int dg){ if ( (dp[mask][dg] != -1)) return ; dp[mask][dg] = 0; for ( int j = 0;(j < n);j++) {if ( ((((1 << j) & mask) != 0) && (genre[j] == dg))) { int submask = (mask - (1 << j));  int og1 = (((genre[j] + 1) > 3)?(genre[j] - 2):(genre[j] + 1));  int og2 = (((genre[j] + 2) > 3)?(genre[j] - 1):(genre[j] + 2)); if ( (submask != 0)) {letsgodp(submask,og1); letsgodp(submask,og2); dp[mask][dg] += (dp[submask][og1] + dp[submask][og2]); dp[mask][dg] %= mod; } else {dp[mask][dg] = 1; }} }} public static void sort( int[] array){ ArrayList<Integer> copy = new ArrayList<Integer>(); 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());} } }
4	public class D{ static void sort( int[] A){ int n = A.length;  Random rnd = new Random(); for ( int i = 0;(i < n);++i) { int tmp = A[i];  int randomPos = (i + rnd.nextInt((n - i))); A[i] = A[randomPos]; A[randomPos] = tmp; }Arrays.sort(A); } public static void main( String[] args){ Scanner sc = new Scanner(System.in); { int n = sc.nextInt();  int m = sc.nextInt();  int steps = sc.nextInt();  long arr[][][] = new long[n][m][5]; for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < (m - 1));k++) { long num = sc.nextLong(); arr[j][k][1] = num; arr[j][(k + 1)][3] = num; }}for ( int j = 0;(j < (n - 1));j++) {for ( int k = 0;(k < m);k++) { long num = sc.nextLong(); arr[j][k][2] = num; arr[(j + 1)][k][4] = num; }} long temp[][] = new long[n][m];  long ans[][] = new long[n][m]; for ( int i = 0;(i < (steps / 2));i++) {for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < m);k++) { long min = Long.MAX_VALUE; if ( (k > 0)) { long f = (arr[j][k][3] + ans[j][(k - 1)]); min = Math.min(min,f); } if ( (k < (m - 1))) { long f = (arr[j][k][1] + ans[j][(k + 1)]); min = Math.min(min,f); } if ( (j > 0)) { long f = (arr[j][k][4] + ans[(j - 1)][k]); min = Math.min(min,f); } if ( (j < (n - 1))) { long f = (arr[j][k][2] + ans[(j + 1)][k]); min = Math.min(min,f); } temp[j][k] = min; }}for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < m);k++) {ans[j][k] = temp[j][k]; }}} StringBuilder p = new StringBuilder(); for ( int j = 0;(j < n);j++) {for ( int k = 0;(k < m);k++) {if ( ((steps % 2) != 0)) {p.append((-1 + " ")); } else {p.append(((2 * ans[j][k]) + " ")); }}p.append("\n"); }System.out.println(p); }} }
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 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 N = sc.nextInt();  int M = sc.nextInt();  int K = sc.nextInt();  int[] array = new int[N]; for ( int i = 0;(i < N);i++) array[i] = sc.nextInt(); Arrays.sort(array); int val = K;  int index = (N - 1); while(((index >= 0) && (val < M))){val--; val += array[index]; index--; }if ( (val < M)) System.out.println("-1"); else System.out.println(((N - 1) - index)); } }
4	public class Main{ public static int n ,m ; public static void main( String[] arg){ FastScanner scan = null;  PrintWriter out = null; try{scan = new FastScanner(new FileInputStream("input.txt")); out = new PrintWriter(new FileOutputStream("output.txt")); }catch (FileNotFoundException e){ scan = new FastScanner(System.in); out = new PrintWriter(System.out); } n = scan.nextInt(); m = scan.nextInt(); int k = scan.nextInt();  int[][] board = new int[(n + 1)][(m + 1)];  String[] ins = scan.nextLine().split(" ",-1);  List<Integer> ps = new ArrayList<Integer>(); for ( int i = 0;(i < (2 * k));i += 2) { int a = Integer.parseInt(ins[i]);  int b = Integer.parseInt(ins[(i + 1)]); board[a][b] = 1; ps.add(((a * 2001) + b)); } int retx = 1,rety = 1;  int[] dx = {0,1,0,-1};  int[] dy = {1,0,-1,0}; while(true){ boolean find = false;  List<Integer> ps2 = new ArrayList<Integer>(); for ( Integer p :ps) { int i = (p / 2001);  int j = (p % 2001); for ( int q = 0;(q < 4);q++) { int nx = (i + dx[q]);  int ny = (j + dy[q]); if ( (in(nx,ny) && (board[nx][ny] == 0))) {board[nx][ny] = 1; retx = nx; rety = ny; find = true; ps2.add(((nx * 2001) + ny)); } }board[i][j] = 2; }ps = ps2; if ( !find) break; }out.println(((retx + " ") + rety)); out.close(); } public static boolean in( int i, int j){ return (((1 <= i) && (i <= n)) && ((1 <= j) && (j <= m)));} 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();} String nextLine(){ try{return br.readLine(); }catch (Exception e){ return null;} } int nextInt(){ return Integer.parseInt(next());} } }
6	public class c8{ static int n ; static int[] ds ; static int[][] g ; public static void main( String[] args){ Scanner input = new Scanner(System.in);  int x = input.nextInt(),y = input.nextInt(); n = input.nextInt(); int[] xs = new int[n],ys = new int[n]; for ( int i = 0;(i < n);i++) {xs[i] = input.nextInt(); ys[i] = input.nextInt(); }ds = new int[n]; g = new int[n][n]; for ( int i = 0;(i < n);i++) {ds[i] = (((x - xs[i]) * (x - xs[i])) + ((y - ys[i]) * (y - ys[i]))); for ( int j = 0;(j < n);j++) {g[i][j] = (((xs[i] - xs[j]) * (xs[i] - xs[j])) + ((ys[i] - ys[j]) * (ys[i] - ys[j]))); }} int[] dp = new int[(1 << n)]; Arrays.fill(dp,987654321); dp[0] = 0; for ( int i = 0;(i < (1 << n));i++) {if ( (dp[i] == 987654321)) continue; for ( int a = 0;(a < n);a++) {if ( ((i & (1 << a)) > 0)) continue; dp[(i | (1 << a))] = Math.min(dp[(i | (1 << a))],(dp[i] + (2 * ds[a]))); for ( int b = (a + 1);(b < n);b++) {if ( ((i & (1 << b)) > 0)) continue; dp[((i | (1 << a)) | (1 << b))] = Math.min(dp[((i | (1 << a)) | (1 << b))],(((dp[i] + ds[a]) + ds[b]) + g[a][b])); }break;}} Stack<Integer> stk = new Stack<Integer>(); stk.add(0); int i = ((1 << n) - 1); trace:while((i > 0)){for ( int a = 0;(a < n);a++) {if ( ((i & (1 << a)) == 0)) continue; if ( (dp[i] == (dp[(i - (1 << a))] + (2 * ds[a])))) {stk.add((a + 1)); stk.add(0); i -= (1 << a); continue trace;} for ( int b = (a + 1);(b < n);b++) {if ( ((i & (1 << b)) == 0)) continue; if ( (dp[i] == (((dp[((i - (1 << a)) - (1 << b))] + ds[a]) + ds[b]) + g[a][b]))) {stk.add((a + 1)); stk.add((b + 1)); stk.add(0); i -= ((1 << a) + (1 << b)); continue trace;} }}}System.out.println(dp[((1 << n) - 1)]); while(!stk.isEmpty())System.out.print((stk.pop() + " ")); } }
0	public class A{ static private 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 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); } }
1	public class Solution{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);++i) {arr[i] = scanner.nextInt(); } boolean isOdd = false; if ( (((((arr[0] % 2) == 0) && ((arr[1] % 2) == 0)) || (((arr[0] % 2) == 0) && ((arr[2] % 2) == 0))) || (((arr[1] % 2) == 0) && ((arr[2] % 2) == 0)))) {isOdd = true; } if ( isOdd) {for ( int i = 0;(i < n);++i) {if ( ((arr[i] % 2) == 1)) {System.out.println((i + 1)); break;} }} else {for ( int i = 0;(i < n);++i) {if ( ((arr[i] % 2) == 0)) {System.out.println((i + 1)); break;} }}} }
6	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); int vNum ; int eNum ; boolean[][] g ; void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); vNum = nextInt(); eNum = nextInt(); g = new boolean[vNum][vNum]; for ( int e = 0;(e < eNum);e++) { int u = (nextInt() - 1);  int v = (nextInt() - 1); g[u][v] = g[v][u] = true; }out.println(optimizedDP()); out.close(); } long optimizedDP(){ long[] count = new long[(vNum + 1)];  long[][] dp = new long[(1 << vNum)][vNum]; for ( int last = (vNum - 1);(last >= 0);last--) { int size = (1 << last); for ( int mask = 0;(mask < size);mask++) fill(dp[mask],0,last,0L); for ( int nv = 0;(nv < last);nv++) if ( g[last][nv]) dp[(1 << nv)][nv] = 1L; for ( int mask = 0;(mask < size);mask++) { int len = (Integer.bitCount(mask) + 1); for ( int v = 0;(v < last);v++) { long cval = dp[mask][v]; if ( (cval == 0L)) continue; if ( g[v][last]) count[len] += cval; for ( int nv = 0;(nv < last);nv++) {if ( g[v][nv]) { int nmask = (mask | (1 << nv)); if ( (nmask != mask)) dp[nmask][nv] += cval; } }}}} long ret = 0L; for ( int len = 3;(len <= vNum);len++) {if ( ((count[len] % 2) != 0)) System.err.println("ERROR!"); ret += (count[len] >> 1); }return ret;} static long b2mb( long b){ return (b >> 20);} String nextToken()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
0	public class Main{ static final double eps = 1e-10; public static void main( String[] args){ Scanner cin = new Scanner(System.in);  double a ,v ;  double l ,d ,w ;  double time ; a = cin.nextDouble(); v = cin.nextDouble(); l = cin.nextDouble(); d = cin.nextDouble(); w = cin.nextDouble(); if ( (v < (w + eps))) { double t1 = (v / a);  double len_bond = ((v * v) / (2 * a)); if ( ((len_bond + eps) > l)) {time = Math.sqrt(((2 * l) / a)); } else { double t2 = ((l - len_bond) / v); time = (t1 + t2); }System.out.println(time); } else { double len_bondv = ((v * v) / (2 * a));  double len_bondw = ((w * w) / (2 * a)); if ( ((len_bondw + eps) > d)) {if ( ((len_bondv + eps) > l)) time = Math.sqrt(((2 * l) / a)); else { double t1 = (v / a);  double t2 = ((l - len_bondv) / v); time = (t1 + t2); }} else { double len_bonds = (((v * v) - (w * w)) / (2 * a)); if ( ((len_bondv + len_bonds) < (d + eps))) time = (((v / a) + (((d - len_bondv) - len_bonds) / v)) + ((v - w) / a)); else { double f = Math.sqrt(((d * a) + ((w * w) / 2))); time = ((f / a) + ((f - w) / a)); }if ( ((len_bonds + eps) > (l - d))) { double lv = Math.sqrt(((((l - d) * 2) * a) + (w * w))); time += ((lv - w) / a); } else {time += (((v - w) / a) + (((l - d) - len_bonds) / v)); }}System.out.println(time); }} }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int a = (n / 2);  int b = ((n / 2) + (n % 2)); if ( ((((a % 2) != 0) && ((a % 3) != 0)) || (((b % 2) != 0) && ((b % 3) != 0)))) {a--; b++; } if ( ((((a % 2) != 0) && ((a % 3) != 0)) || (((b % 2) != 0) && ((b % 3) != 0)))) {a--; b++; } System.out.println(((a + " ") + b)); } }
6	public class E implements Runnable{ public static void main( String[] args)throws IOException { new Thread(null,new E(),"",(1 << 20)).start(); } BufferedReader input ; PrintWriter out ; String file = "input"; void solve()throws IOException { int n = Integer.parseInt(input.readLine());  double[][] p = new double[n][n]; for ( int i = 0;(i < n);i++) { StringTokenizer st = new StringTokenizer(input.readLine()); for ( int j = 0;(j < n);j++) {p[i][j] = Double.parseDouble(st.nextToken()); }} double[] dp = new double[(1 << n)];  int mask = ((1 << n) - 1); dp[mask] = 1; for ( int w = mask;(w > 0);w--) { int count = 0; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( ((((w >> i) & 1) != 0) && (((w >> j) & 1) != 0))) count++; if ( (count == 0)) continue; for ( int i = 0;(i < n);i++) for ( int j = (i + 1);(j < n);j++) if ( ((((w >> i) & 1) != 0) && (((w >> j) & 1) != 0))) {dp[(w ^ (1 << i))] += (((1.0 / count) * p[j][i]) * dp[w]); dp[(w ^ (1 << j))] += (((1.0 / count) * p[i][j]) * dp[w]); } }for ( int i = 0;(i < n);i++) System.out.print((dp[(1 << i)] + " ")); } }
1	public class a{ public static long mod = ((long)Math.pow(10,9) + 7); public static int k = 0; public static int gcd( int x, int y){ if ( (y == 0)) return x; return gcd(y,(x % y));} public static int min[] ; public static int max[] ; public static void build( int s, int e, int p, int[] a){ if ( (s == e)) {min[p] = a[s]; max[p] = a[s]; return ;} int mid = ((s + e) / 2); build(s,mid,(p * 2),a); build((mid + 1),e,((p * 2) + 1),a); min[p] = Math.min(min[(p * 2)],min[((p * 2) + 1)]); max[p] = Math.max(max[(p * 2)],max[((p * 2) + 1)]); } public static int getMin( int s, int e, int p, int from, int to){ if ( ((s > to) || (e < from))) return Integer.MAX_VALUE; if ( ((s >= from) && (e <= to))) return min[p]; int mid = ((s + e) / 2);  int a = getMin(s,mid,(p * 2),from,to);  int b = getMin((mid + 1),e,((p * 2) + 1),from,to); return Math.min(a,b);} public static int getMax( int s, int e, int p, int from, int to){ if ( ((s > to) || (e < from))) return Integer.MIN_VALUE; if ( ((s >= from) && (e <= to))) return max[p]; int mid = ((s + e) / 2);  int a = getMax(s,mid,(p * 2),from,to);  int b = getMax((mid + 1),e,((p * 2) + 1),from,to); return Math.max(a,b);} public static boolean ch[] ; public static ArrayList<Integer> prime ; public static Queue<Integer> pp ; public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringBuilder qq = new StringBuilder();  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  String y[] = in.readLine().split(" ");  int n = Integer.parseInt(y[0]);  int a = Integer.parseInt(y[1]);  int b = Integer.parseInt(y[2]);  int arr[] = new int[n];  HashMap<Integer,Integer> mp = new HashMap(); y = in.readLine().split(" "); boolean flag = true; for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(y[i]); if ( ((arr[i] >= a) && (arr[i] >= b))) {flag = false; } mp.put(arr[i],i); }if ( !flag) {System.out.println("NO"); return ;} boolean ch[] = new boolean[n];  int ans[] = new int[n]; for ( int i = 0;(i < n);i++) { int k = i; while((true && !ch[k])){if ( (((mp.containsKey((a - arr[k])) && !ch[mp.get((a - arr[k]))]) && mp.containsKey((b - arr[k]))) && !ch[mp.get((b - arr[k]))])) {break;} else if ( (mp.containsKey((a - arr[k])) && !ch[mp.get((a - arr[k]))])) {ch[k] = true; ans[k] = 0; ch[mp.get((a - arr[k]))] = true; ans[mp.get((a - arr[k]))] = 0; int s = (b - (a - arr[k])); if ( mp.containsKey(s)) {k = mp.get(s); } else break;} else if ( (mp.containsKey((b - arr[k])) && !ch[mp.get((b - arr[k]))])) {ans[k] = 1; ans[mp.get((b - arr[k]))] = 1; ch[k] = true; ch[mp.get((b - arr[k]))] = true; int s = (a - (b - arr[k])); if ( mp.containsKey(s)) {k = mp.get(s); } else break;} else {System.out.println("NO"); return ;}}}qq.append("YES\n"); for ( int i = 0;(i < ans.length);i++) {qq.append((ans[i] + " ")); }System.out.println(qq); } }
6	public class E{ int bitcount( int x){ int c = 0; for ( ;(x != 0);c++) x &= (x - 1); return c;} boolean bit( int x, int i){ if ( (i < 0)) return false; return ((((x >> i) & 1) == 1)?true:false);} int solve( int n, int m){ if ( (m > n)) { int x = m; m = n; n = x; } int maxmask = (1 << m);  int[][][] dp = new int[(n + 1)][maxmask][maxmask]; for ( int i = 0;(i <= n);i++) for ( int j = 0;(j < maxmask);j++) for ( int k = 0;(k < maxmask);k++) dp[i][j][k] = inf; for ( int i = 0;(i < maxmask);i++) dp[0][0][i] = bitcount(i); for ( int i = 1;(i <= n);i++) for ( int b = 0;(b < maxmask);b++) for ( int c = 0;(c < maxmask);c++) for ( int a = 0;(a < maxmask);a++) { boolean nospider = false; for ( int j = 0;(j < m);j++) if ( not(((((bit(a,j) || bit(c,j)) || bit(b,(j - 1))) || bit(b,j)) || bit(b,(j + 1))))) {nospider = true; break;} if ( nospider) continue; dp[i][b][c] = Math.min(dp[i][b][c],(dp[(i - 1)][a][b] + bitcount(c))); } int res = inf; for ( int b = 0;(b < maxmask);b++) res = Math.min(res,dp[n][b][0]); return ((n * m) - res);} void main()throws IOException { int n ; while(((n = nextInt()) != EOF)){ int m = nextInt(); out.println(solve(n,m)); }} public static void main( String[] args){ new E().run(); } int inf = (int)1e9; final int EOF = -1; boolean not( boolean p){ return !p;} BufferedReader fin ; StringTokenizer st ; PrintWriter out ; public void run(){ try{fin = new BufferedReader(new InputStreamReader(System.in)); st = null; out = new PrintWriter(System.out); main(); fin.close(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } int nextInt()throws IOException { return Integer.parseInt(nextToken());} String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = fin.readLine(); if ( (line == null)) return "-1"; else st = new StringTokenizer(line); }return st.nextToken();} }
5	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);  Task solver = new Task();  int testCount = 1; for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } } class Task{ int n ; int[] a ; int[] b ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.readInt(); a = new int[n]; b = new int[n]; for ( int i = 0;(i < n);++i) a[i] = b[i] = in.readInt(); sort(0,(n - 1)); int different = 0; for ( int i = 0;(i < n);++i) if ( (a[i] != b[i])) ++different; out.println(((different <= 2)?"YES":"NO")); } public void sort( int lo, int hi){ if ( (lo < hi)) { int mid = ((lo + hi) / 2); sort(lo,mid); sort((mid + 1),hi); merge(lo,mid,hi); } } public void merge( int lo, int mid, int hi){ int n1 = ((mid - lo) + 1);  int n2 = ((hi - (mid + 1)) + 1);  int[] x = new int[(n1 + 1)];  int[] y = new int[(n2 + 1)]; for ( int i = 0;(i < n1);++i) x[i] = b[(lo + i)]; for ( int j = 0;(j < n2);++j) y[j] = b[((mid + 1) + j)]; x[n1] = y[n2] = Integer.MAX_VALUE; for ( int k = lo,i = 0,j = 0;(k <= hi);++k) b[k] = ((x[i] < y[j])?x[i++]:y[j++]); } } 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 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();} public static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} }
2	public class Main{ public static boolean check( BigInteger a, BigInteger b){ long n = 0;  String aStr = a.toString(); for ( int i = 0;(i < aStr.length());i++) {n += Long.valueOf((aStr.charAt(i) - '0')); }return (a.subtract(BigInteger.valueOf(n)).compareTo(b) >= 0);} public static void main( String[] args){ try(BufferedReader in=new BufferedReader(new InputStreamReader(System.in))){ String[] str = in.readLine().split(" ");  BigInteger n = new BigInteger(str[0]);  BigInteger s = new BigInteger(str[1]);  BigInteger left = BigInteger.ONE;  BigInteger right = new BigInteger(n.toString()).add(BigInteger.TEN);  BigInteger TWO = BigInteger.ONE.add(BigInteger.ONE);  BigInteger t ; while((right.subtract(left).compareTo(BigInteger.ONE) > 0)){t = left.add(right.subtract(left).divide(TWO)); if ( check(t,s)) {right = t; } else {left = t; }} BigInteger result = n.subtract(right).add(BigInteger.ONE); if ( (result.compareTo(BigInteger.ZERO) <= 0)) {System.out.println(0); } else {System.out.println(result); } }catch (IOException e){ e.printStackTrace(); } } }
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 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();} }
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); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastInputReader in = new FastInputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ int n ,a ,b ; Map<Integer,Integer> position ; int[] p ; int[] group ; public void solve( int testNumber, FastInputReader in, PrintWriter out){ n = in.nextInt(); a = in.nextInt(); b = in.nextInt(); position = new TreeMap<Integer,Integer>(); p = new int[n]; group = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = in.nextInt(); group[i] = -1; position.put(p[i],i); }for ( int i = 0;(i < n);i++) {if ( (getMate(i) != -1)) continue; out.println("NO"); return ;}for ( int i = 0;(i < n);i++) { boolean aMate = position.containsKey((a - p[i]));  boolean bMate = position.containsKey((b - p[i])); if ( (aMate && bMate)) continue; if ( (group[i] != -1)) continue; if ( !solve(i)) {out.println("NO"); return ;} }for ( int i = 0;(i < n);i++) {if ( (group[i] != -1)) continue; if ( !solve(i)) {out.println("NO"); return ;} }out.println("YES"); for ( int i = 0;(i < n);i++) {out.print(group[i]); out.print(" "); }out.println(); } private boolean solve( int index){ int mate = getMate(index); if ( (mate == -1)) return false; assign(index,mate); if ( (getMate(index) != -1)) return solve(getMate(index)); else return ((getMate(mate) == -1) || solve(getMate(mate)));} private void assign( int index, int mate){ int sum = (p[index] + p[mate]); if ( (sum == a)) {group[index] = group[mate] = 0; return ;} if ( (sum == b)) {group[index] = group[mate] = 1; return ;} throw (new RuntimeException("Wrong assignment :("));} private int getMate( int index){ int[] possibleMates = new int[]{(a - p[index]),(b - p[index])}; for ( int mate :possibleMates) {if ( position.containsKey(mate)) { int mateIndex = position.get(mate); if ( (group[mateIndex] == -1)) return mateIndex; } }return -1;} } class FastInputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastInputReader( 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 C{ static int[] dp ; static int[] f ; static void solve(){ dp = new int[(1 << n)]; f = new int[(1 << n)]; Arrays.fill(dp,(1 << 29)); dp[0] = 0; for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) { int ni = (i | (1 << j)); if ( (i != ni)) { int v = ((d[j] * 2) + dp[i]); if ( (v < dp[ni])) {dp[ni] = v; f[ni] = i; } for ( int k = (j + 1);(k < n);k++) { int nni = (ni | (1 << k)); if ( (ni != nni)) { int vv = (((d[j] + t[j][k]) + d[k]) + dp[i]); if ( (vv < dp[nni])) {dp[nni] = vv; f[nni] = i; } } }break;} }}out.println(dp[(dp.length - 1)]); int idx = (dp.length - 1); out.print("0 "); while((idx != 0)){ int road = (idx ^ f[idx]); for ( int i = 0;(i < n);i++) if ( (((road >> i) & 1) == 1)) out.print(((i + 1) + " ")); idx = f[idx]; out.print("0 "); }out.println(); } static int[] d ; static int[][] t ; static int n ; public static void main( String[] args){ Scanner sc = new Scanner(in);  int x = sc.nextInt();  int y = sc.nextInt(); n = sc.nextInt(); int[] dx = new int[n];  int[] dy = new int[n]; for ( int i = 0;(i < n);i++) {dx[i] = sc.nextInt(); dy[i] = sc.nextInt(); }d = new int[n]; for ( int i = 0;(i < n);i++) {d[i] = (((x - dx[i]) * (x - dx[i])) + ((y - dy[i]) * (y - dy[i]))); }t = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {t[i][j] = (((dx[i] - dx[j]) * (dx[i] - dx[j])) + ((dy[i] - dy[j]) * (dy[i] - dy[j]))); }}solve(); } }
1	public class primes{ public static void main( String[] args){ ArrayList<Integer> numb = new ArrayList<Integer>();  Scanner br1 = new Scanner(System.in);  int n = br1.nextInt();  int steps = br1.nextInt(); if ( (n >= 3)) numb.add(3); for ( int j = 4;(j <= n);j++) {if ( (chekprime(j) == 0)) {numb.add(j); } } int counter = 0; for ( int give = 0;(give < numb.size());give++) {if ( "YES".equals(sumup(numb,2,numb.get(give)))) {counter++; } }if ( (counter >= steps)) System.out.println("YES"); else System.out.println("NO"); } public static String sumup( ArrayList<Integer> list, int number, int NUM){ String ret = "NO";  ArrayList<Integer> result = new ArrayList<Integer>();  ArrayList<Integer>[] arList = new ArrayList[number]; for ( int i = 0;(i < number);i++) {arList[i] = new ArrayList<Integer>(); arList[i] = (ArrayList<Integer>)list.clone(); for ( int k = 0;(k < i);k++) {arList[i].add(0,arList[i].remove((arList[i].size() - 1))); }} int[] temp = new int[list.size()]; for ( int z = 0;(z < list.size());z++) {for ( int count = 0;(count < number);count++) {temp[z] += arList[count].get(z); }result.add(temp[z]); }if ( result.contains((NUM - 1))) {ret = "YES"; } return ret;} public static int chekprime( int n){ int flag = 0; for ( int i = 2;(i <= (Math.sqrt(n) + 1));i++) {if ( ((n % i) == 0)) {flag = 1; break;} }return flag;} }
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){ if ( (idx == n)) return ((((remSum == 0) && (remCnt1 == 0)) && (remCnt2 == 0))?1:0); if ( (((remSum < 0) || (remCnt1 < 0)) || (remCnt2 < 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 ( (g[idx] == 1)) ans += dp2((idx + 1),(remCnt1 - 1),remCnt2,(remSum - t[idx])); else if ( (g[idx] == 2)) ans += dp2((idx + 1),remCnt1,(remCnt2 - 1),(remSum - t[idx])); return memo2[idx][remCnt1][remCnt2][remSum] = ans;} static private int dp3( int cnt0, int cnt1, int cnt2, int last){ if ( (((cnt0 < 0) || (cnt1 < 0)) || (cnt2 < 0))) return 0; if ( (((cnt0 + cnt1) + cnt2) == 0)) return 1; if ( (memo3[last][cnt0][cnt1][cnt2] != -1)) return memo3[last][cnt0][cnt1][cnt2]; long ans = 0; if ( (last != 0)) ans += dp3((cnt0 - 1),cnt1,cnt2,0); if ( (last != 1)) ans += dp3(cnt0,(cnt1 - 1),cnt2,1); if ( (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();} } }
2	public class Alpha_Round{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));  String[] in = reader.readLine().split(" ");  long n = Long.parseLong(in[0]);  long k = Long.parseLong(in[1]);  long D = ((9 + (8 * k)) + (8 * n));  long m = (long)((-3 + Math.sqrt(D)) / 2); writer.write(((n - m) + "")); writer.close(); } }
1	public class Main{ static HashMap<Integer,Integer> hm ; static int[] array ; static boolean marked[] ; static int a ,b ; static int[] ans ; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n ; n = sc.nextInt(); a = sc.nextInt(); b = sc.nextInt(); hm = new HashMap<Integer,Integer>(); array = new int[n]; marked = new boolean[n]; for ( int i = 0;(i < n);++i) {array[i] = sc.nextInt(); hm.put(array[i],i); }if ( (a == b)) { boolean flag = true; for ( int i = 0;(i < n);++i) if ( !hm.containsKey((a - array[i]))) flag = false; if ( !flag) System.out.println("NO"); else {System.out.println("YES"); for ( int i = 0;(i < n);++i) System.out.print("0 "); }} else {ans = new int[n]; for ( int i = 0;(i < n);++i) if ( marked[i]) continue; else {if ( (hm.containsKey((a - array[i])) && !hm.containsKey((b - array[i])))) {propagateA(i); } else if ( (!hm.containsKey((a - array[i])) && hm.containsKey((b - array[i])))) {propagateB(i); } else if ( (!hm.containsKey((a - array[i])) && !hm.containsKey((b - array[i])))) {System.out.println("NO"); System.exit(0); } }for ( int i = 0;(i < n);++i) if ( marked[i]) continue; else {start(i); }System.out.println("YES"); for ( int i = 0;(i < n);++i) System.out.print((ans[i] + " ")); System.exit(0); }} static void propagateA( int index){ int i = index; while(!marked[i]){if ( (hm.containsKey((a - array[i])) && !marked[hm.get((a - array[i]))])) {marked[i] = true; ans[i] = 0; i = hm.get((a - array[i])); marked[i] = true; ans[i] = 0; if ( (hm.containsKey((b - array[i])) && !marked[hm.get((b - array[i]))])) {i = hm.get((b - array[i])); } } else {System.out.println("NO"); System.exit(0); }}} static void propagateB( int index){ int i = index; while(!marked[i]){if ( (hm.containsKey((b - array[i])) && !marked[hm.get((b - array[i]))])) {marked[i] = true; ans[i] = 1; i = hm.get((b - array[i])); marked[i] = true; ans[i] = 1; if ( (hm.containsKey((a - array[i])) && !marked[hm.get((a - array[i]))])) {i = hm.get((a - array[i])); } } else {System.out.println("NO"); System.exit(0); }}} static void start( int index){ int i = index; while(!marked[i]){if ( !marked[hm.get((a - array[i]))]) {marked[i] = true; ans[i] = 0; i = hm.get((a - array[i])); marked[i] = true; ans[i] = 0; i = hm.get((b - array[i])); } }} }
0	public class Codechef{ public static void main( String[] args)throws java.lang.Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int x = (m % (int)Math.pow(2,n)); System.out.println(x); } }
0	public class ProblemA{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(new InputStreamReader(System.in));  int n = sc.nextInt(); if ( ((n % 2) == 0)) {System.out.println((((n - 4) + " ") + 4)); } else {System.out.println((((n - 9) + " ") + 9)); }} }
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++]);} } }
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());} } }
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(); } } class TaskC{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  Queue<Point> points = new LinkedList<Point>();  int[][] burnTime = new int[n][m];  boolean[][] visited = new boolean[n][m]; for ( int i = 0;(i < k);i++) { int x = (in.nextInt() - 1);  int y = (in.nextInt() - 1); visited[x][y] = true; burnTime[x][y] = 0; points.add(new Point(x,y)); } int[] dx = new int[]{-1,0,0,1};  int[] dy = new int[]{0,-1,1,0}; while((points.size() != 0)){ Point cur = points.poll();  int x = cur.x;  int y = cur.y; for ( int i = 0;(i < dx.length);i++) { int nextX = (x + dx[i]);  int nextY = (y + dy[i]); if ( (((((nextX >= 0) && (nextX < n)) && (nextY >= 0)) && (nextY < m)) && (((burnTime[x][y] + 1) < burnTime[nextX][nextY]) || !visited[nextX][nextY]))) {points.add(new Point(nextX,nextY)); visited[nextX][nextY] = true; burnTime[nextX][nextY] = (burnTime[x][y] + 1); } }} int x ,y ; x = y = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (burnTime[i][j] > burnTime[x][y])) {x = i; y = j; } }}out.printf("%d %d",(x + 1),(y + 1)); } } class Point{ int x ; int y ; public Point( int x, int y){ this.x = x; this.y = y; } } 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 D911{ void solve(){ int n = ni();  int[] a = ia(n);  int Q = ni();  String[] ans = {"even","odd"};  int cur = (merge(a,0,(n - 1)) % 2); while((Q-- > 0)){ int l = ni(),r = ni(); cur ^= ((((r - l) + 1) / 2) % 2); out.println(ans[cur]); }} int merge( int[] a, int l, int r){ if ( (l >= r)) return 0; int mid = ((l + r) >> 1);  int v1 = merge(a,l,mid);  int v2 = merge(a,(mid + 1),r);  int[] rep = new int[((r - l) + 1)];  int ptr0 = 0,ptr1 = l,ptr2 = (mid + 1);  long len = ((mid - l) + 1);  int ret = 0; while(((ptr1 <= mid) && (ptr2 <= r))){if ( (a[ptr1] <= a[ptr2])) {len--; rep[ptr0++] = a[ptr1++]; } else {ret += len; rep[ptr0++] = a[ptr2++]; }}while((ptr1 <= mid))rep[ptr0++] = a[ptr1++]; while((ptr2 <= r))rep[ptr0++] = a[ptr2++]; for ( int i = 0;(i < ptr0);i++) a[(l + i)] = rep[i]; return ((v1 + v2) + ret);} public static void main( String[] args){ new D911().run(); } private byte[] bufferArray = new byte[1024]; private int bufLength = 0; private int bufCurrent = 0; InputStream inputStream ; PrintWriter out ; public void run(){ inputStream = System.in; out = new PrintWriter(System.out); solve(); out.flush(); } int nextByte(){ if ( (bufLength == -1)) throw (new InputMismatchException()); if ( (bufCurrent >= bufLength)) {bufCurrent = 0; try{bufLength = inputStream.read(bufferArray); }catch (IOException e){ throw (new InputMismatchException());} if ( (bufLength <= 0)) return -1; } return bufferArray[bufCurrent++];} boolean isSpaceChar( int x){ return ((x < 33) || (x > 126));} boolean isDigit( int x){ return ((x >= '0') && (x <= '9'));} int nextNonSpace(){ int x ; while((((x = nextByte()) != -1) && isSpaceChar(x)));return x;} int ni(){ long ans = nl(); if ( ((ans >= Integer.MIN_VALUE) && (ans <= Integer.MAX_VALUE))) return (int)ans; throw (new InputMismatchException());} long nl(){ long ans = 0;  boolean neg = false;  int x = nextNonSpace(); if ( (x == '-')) {neg = true; x = nextByte(); } while(!isSpaceChar(x)){if ( isDigit(x)) {ans = (((ans * 10) + x) - '0'); x = nextByte(); } else throw (new InputMismatchException());}return (neg?-ans:ans);} String ns(){ StringBuilder sb = new StringBuilder();  int x = nextNonSpace(); while(!isSpaceChar(x)){sb.append((char)x); x = nextByte(); }return sb.toString();} char[] ca(){ return ns().toCharArray();} char[][] ca( int n){ char[][] ans = new char[n][]; for ( int i = 0;(i < n);i++) ans[i] = ca(); return ans;} int[] ia( int n){ int[] ans = new int[n]; for ( int i = 0;(i < n);i++) ans[i] = ni(); return ans;} }
2	public class DigitSequence{ public DigitSequence(){ } public static void main( String[] args){ Scanner in = new Scanner(System.in);  long k = in.nextLong();  long[] end = new long[12]; end[0] = -1; for ( int i = 1;(i < end.length);i++) {end[i] = (i * (long)Math.pow(10,i)); end[i] -= (((long)Math.pow(10,i) - 1) / 9); } int st = 0; for ( int i = 1;(i < end.length);i++) {if ( ((k >= (end[(i - 1)] + 1)) && (k <= end[i]))) st = i; } long diff = (k - end[(st - 1)]);  long mod = (((diff + st) - 1) % st);  long digit = -1;  int addOn = 0; if ( (mod == 0)) addOn = 1; if ( (mod == (st - 1))) addOn = -1; digit = (diff / (st * (long)Math.pow(10,((st - 1) - mod)))); digit += addOn; digit %= 10; System.out.println(digit); } }
0	public class A{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  long l = s.nextLong();  long r = s.nextLong(); s.close(); if ( (((r - l) < 2) || (((r - l) == 2) && ((l % 2) == 1)))) {System.out.print("-1"); return ;} long beg = (((l % 2) == 0)?l:(l + 1)); if ( ((beg + 2) > r)) System.out.print("-1"); else System.out.print(((((beg + " ") + (beg + 1)) + " ") + (beg + 2))); } }
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 ( (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;} }
2	public class A{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; void solve()throws IOException { int tot = nextInt();  int ok = nextInt();  int k = nextInt();  int maxBad = (tot / k); if ( ((tot - maxBad) >= ok)) {out.println(ok); return ;} int dbl = ((ok + (tot / k)) - tot);  int dblPoints = (pow(2,(dbl + 1)) - 2); while((dblPoints < 0))dblPoints += MOD; dblPoints = (int)(((long)dblPoints * k) % MOD); int rest = (ok - (dbl * k));  int ans = (dblPoints + rest); if ( (ans >= MOD)) ans -= MOD; out.println(ans); } static int pow( int a, int b){ int ret = 1; while((b != 0)){if ( ((b & 1) == 1)) ret = (int)(((long)ret * a) % MOD); a = (int)(((long)a * a) % MOD); b >>= 1; }return ret;} static final int MOD = 1000000009; A()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 A(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
1	@SuppressWarnings("unchecked") public class P701A{ Map<Character,Integer> cc = new HashMap(72); void add( char c){ cc.put(c,(cc.getOrDefault(c,0) + 1)); } void rem( char c){ Integer cnt = (cc.get(c) - 1); if ( (cnt != 0)) {cc.put(c,cnt); } else {cc.remove(c); }} public void run()throws Exception { int n = nextInt();  char[] s = next().toCharArray();  BitSet bs = new BitSet(); for ( char c :s) {bs.set(c); } int t = bs.cardinality();  int m = Integer.MAX_VALUE; for ( int i = 0,j = 0;(i < n);i++) {while(((j < n) && (cc.size() < t))){add(s[j]); j++; }if ( (cc.size() == t)) {m = Math.min(m,(j - i)); } rem(s[i]); }println(m); } public static void main( String... args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedOutputStream(System.out)); new P701A().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 next()throws IOException { return nextToken();} String nextLine()throws IOException { return br.readLine();} int gcd( int a, int b){ return ((b > 0)?gcd(b,(a % b)):a);} }
6	public class cf111c{ public static int n ,m ,maxm ; public static int[][][] dp ; public static int[] s ; public static int cal( int cur){ int res = 0; while((cur > 0)){res++; cur = (cur & (cur - 1)); }return res;} public static boolean check( int a, int b, int c){ int res = ((maxm - 1) & ((((b | (b << 1)) | (b >> 1)) | a) | c)); if ( (res == (maxm - 1))) return true; else return false;} public static void main( String[] argv){ Scanner in = new Scanner(System.in); n = in.nextInt(); m = in.nextInt(); if ( (n < m)) { int t = m; m = n; n = t; } maxm = (1 << m); int i ,j ,k ,l ; dp = new int[(n + 1)][(1 << m)][(1 << m)]; s = new int[(1 << m)]; for ( i = 0;(i < (n + 1));i++) {for ( j = 0;(j < maxm);j++) {Arrays.fill(dp[i][j],100); }}for ( i = 0;(i < maxm);i++) {s[i] = cal(i); dp[0][0][i] = 0; }for ( i = 1;(i <= n);i++) {for ( j = 0;(j < maxm);j++) {for ( k = 0;(k < maxm);k++) {for ( l = 0;(l < maxm);l++) {if ( ((dp[(i - 1)][k][l] != 100) && check(k,l,j))) {dp[i][l][j] = Math.min((dp[(i - 1)][k][l] + s[l]),dp[i][l][j]); } }}}} int ans = 100; for ( i = 0;(i < maxm);i++) ans = Math.min(dp[n][i][0],ans); System.out.println(((n * m) - ans)); return ;} }
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); } }
4	public class D{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int t = 1; for ( int i = 0;(i < t);i++) {solve(sc,pw); }pw.close(); } static void solve( Scanner in, PrintWriter out){ int n = in.nextInt(),m = in.nextInt(),k = in.nextInt();  int[][] ri = new int[n][(m - 1)];  int[][] dn = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {ri[i][j] = in.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {dn[i][j] = in.nextInt(); }} long[][][] dp = new long[n][m][(k + 1)]; if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((-1 + " ")); }out.println(); }} else {for ( int l = 2;(l <= k);l += 2) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { long dm = Long.MAX_VALUE; if ( (i > 0)) { int pi = (i - 1),pj = j; dm = Math.min(dm,(dp[pi][pj][(l - 2)] + (dn[pi][pj] * 2))); } if ( (j > 0)) { int pi = i,pj = (j - 1); dm = Math.min(dm,(dp[pi][pj][(l - 2)] + (ri[pi][pj] * 2))); } if ( (i < (n - 1))) {dm = Math.min(dm,(dp[(i + 1)][j][(l - 2)] + (dn[i][j] * 2))); } if ( (j < (m - 1))) {dm = Math.min(dm,(dp[i][(j + 1)][(l - 2)] + (ri[i][j] * 2))); } dp[i][j][l] = dm; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (dp[i][j][k] == Long.MAX_VALUE)) {out.print((-1 + " ")); } else {out.print((dp[i][j][k] + " ")); }}out.println(); }}} static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} }
0	public class ProblemA{ static final int INF = 100000000; public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  String[] nmd = in.readLine().split(" ");  long a = Long.valueOf(nmd[0]);  long b = Long.valueOf(nmd[1]);  long cnt = 0; while(true){if ( (a == 0)) {break;} if ( (a >= b)) {cnt += (a / b); a = (a % b); } else {if ( ((b % a) == 0)) {cnt += ((b / a) - 1); b = a; } else {cnt += (b / a); b = (b % a); }}}out.println(cnt); out.flush(); } }
3	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int N = Integer.parseInt(sc.next());  int[] a = new int[N];  int[] flag = new int[N];  int ans = 0; for ( int i = 0;(i < N);i++) {a[i] = Integer.parseInt(sc.next()); }Arrays.sort(a); for ( int i = 0;(i < N);i++) { int used = 0; for ( int j = 0;(j < N);j++) {if ( (flag[j] == 1)) {continue;} else {if ( ((a[j] % a[i]) == 0)) {used = 1; flag[j] = 1; } }}if ( (used == 1)) {ans++; } }System.out.println(ans); } }
2	public class D{ static long l ,r ; static long[][][][][] dp ; public static void main( String[] args)throws IOException { InputReader in = new InputReader(); l = in.nextLong(); r = in.nextLong(); dp = new long[65][2][2][2][2]; for ( int i = 0;(i < 65);i++) for ( int j = 0;(j < 2);j++) for ( int k = 0;(k < 2);k++) for ( int a = 0;(a < 2);a++) dp[i][j][k][a][0] = dp[i][j][k][a][1] = -1; System.out.println(go(63,0,0,0,0)); } public static long go( int i, int a1, int a2, int b1, int b2){ if ( (i == -1)) return 0; if ( (dp[i][a1][a2][b1][b2] != -1)) return dp[i][a1][a2][b1][b2]; int f1 = 3,f2 = 3;  int bl = ((int)(l >> i) & 1),br = (int)((r >> i) & 1); if ( ((a2 == 0) && (br == 0))) f1 &= 1; if ( ((a1 == 0) && (bl == 1))) f1 &= 2; if ( ((b2 == 0) && (br == 0))) f2 &= 1; if ( ((b1 == 0) && (bl == 1))) f2 &= 2;  long res = 0; for ( int x = 0;(x < 2);x++) {for ( int y = 0;(y < 2);y++) {if ( ((((f1 >> x) & 1) == 1) && (((f2 >> y) & 1) == 1))) {res = Math.max(res,(((long)(x ^ y) << i) + go((i - 1),(((x > bl) || (a1 == 1))?1:0),(((x < br) || (a2 == 1))?1:0),(((y > bl) || (b1 == 1))?1:0),(((y < br) || (b2 == 1))?1:0)))); } }}return dp[i][a1][a2][b1][b2] = res;} static class InputReader{ BufferedReader in ; StringTokenizer st ; public InputReader()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(in.readLine()); } public String next()throws IOException { while(!st.hasMoreElements())st = new StringTokenizer(in.readLine()); return st.nextToken();} public long nextLong()throws NumberFormatException,IOException { return Long.parseLong(next());} } }
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();  int i ,j ;  BigDecimal initial = new BigDecimal(10); initial = initial.pow(100); int x[] = new int[N];  BigDecimal y[] = new BigDecimal[N]; Arrays.fill(y,initial); for ( i = 0;(i < N);i++) {x[i] = in.nextInt(); }for ( i = 0;(i < N);i++) { BigDecimal y2 = new BigDecimal(r); for ( j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) <= (2 * r))) { double xDiff = (x[i] - x[j]); xDiff *= xDiff; xDiff = (((4 * r) * r) - xDiff); xDiff = Math.sqrt(xDiff); BigDecimal yNew = new BigDecimal(xDiff); yNew = yNew.add(y[j]); if ( (yNew.compareTo(y2) > 0)) {y2 = yNew; } } }y[i] = y2; }for ( i = 0;(i < N);i++) {out.print((y[i] + " ")); }} } 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());} } 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 close(){ writer.close(); } } }
3	public class Codeshefcode{ public static void main( String[] args)throws IOException { Solver Machine = new Solver(); Machine.Solve(); Machine.Finish(); } } class Solver{ Reader ip = new Reader(System.in); PrintWriter op = new PrintWriter(System.out); public void Solve()throws IOException { int n = ip.i();  int r = ip.i();  double x[] = new double[n];  double y[] = new double[n]; for ( int i = 0;(i < n);i++) x[i] = ip.i(); for ( int i = 0;(i < n);i++) { double my = 0; for ( int j = 0;(j < i);j++) my = max(my,func(x[j],y[j],r,x[i])); y[i] = my; }for ( int i = 0;(i < n);i++) p(((y[i] + r) + " ")); pln(""); } double abd( double x, double y){ return ((x > y)?(x - y):(y - x));} double func( double x1, double y1, double r, double x2){ if ( (abd(x1,x2) > (2 * r))) return 0; if ( (abd(x1,x2) == (2 * r))) return y1; double dx = (x1 - x2);  double dx2 = (dx * dx);  double val = sqrt((((4 * r) * r) - dx2)); return (y1 + val);} void Finish(){ op.flush(); op.close(); } void p( Object o){ op.print(o); } void pln( Object o){ op.println(o); } } class Reader{ BufferedReader reader ; StringTokenizer tokenizer ; Reader( InputStream input){ reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); } String s()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} int i()throws IOException { return Integer.parseInt(s());} }
2	public class Main{ public static void main( String[] args)throws IOException { new Main().solve(); } public Main(){ } MyReader in = new MyReader(); PrintWriter out = new PrintWriter(System.out); void solve()throws IOException { long n = in.nextLong();  long k = in.nextLong();  long sum = 1;  long count = 0;  long index = (k - 1);  long[] delta = {1000000000,100000000,10000000,1000000,100000,10000,1000,100,10,1,0}; while((index > 0)){if ( ((index + sum) <= n)) {for ( int d = 0;(d < delta.length);d++) {if ( (delta[d] < index)) { long m = ((((2 * index) - delta[d]) * (delta[d] + 1)) / 2); if ( ((m + sum) <= n)) {sum += m; index -= (delta[d] + 1); count += (delta[d] + 1); } } }} else {index = (n - sum); }}if ( (sum == n)) {out.println(count); } else {out.println(-1); }out.close(); } } class MyReader{ private BufferedReader in ; String[] parsed ; int index = 0; public MyReader(){ in = new BufferedReader(new InputStreamReader(System.in)); } public long nextLong()throws NumberFormatException,IOException { if ( ((parsed == null) || (parsed.length == index))) {read(); } return Long.parseLong(parsed[index++]);} private void read()throws IOException { parsed = in.readLine().split(" "); index = 0; } public String readLine()throws IOException { return in.readLine();} }
6	public class D{ private Scanner in ; private PrintWriter out ; private boolean[][] g ; public void solve(){ n = ni(); int m = ni(); g = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int f = ni();  int t = ni(); g[(f - 1)][(t - 1)] = true; g[(t - 1)][(f - 1)] = true; } long ret = 0L; cache = new long[(20 << 19)]; for ( int i = 0;(i < n);i++) {start = i; ret += rec((1 << start),i,0); }out.println((ret / 2)); } private long[] cache ; private int n ; private int start ; private long rec( int passed, int cur, int depth){ int code = ((cur << 19) | passed); if ( (cache[code] != 0)) return cache[code]; long ret = 0L; if ( (g[cur][start] && (depth >= 2))) ret++; for ( int i = (start + 1);(i < n);i++) {if ( (((passed & (1 << i)) == 0) && g[cur][i])) {ret += rec((passed | (1 << i)),i,(depth + 1)); } }cache[code] = ret; return ret;} public void run()throws Exception { in = new Scanner(System.in); System.setOut(new PrintStream(new BufferedOutputStream(System.out))); out = new PrintWriter(System.out); int n = 1; for ( int i = 1;(i <= n);i++) { long t = System.currentTimeMillis(); solve(); out.flush(); System.err.printf("%04d/%04d %7d%n",i,n,(System.currentTimeMillis() - t)); }} public static void main( String[] args)throws Exception { new D().run(); } private int ni(){ return Integer.parseInt(in.next());} }
4	public class Main{ public static void main( String[] args)throws NumberFormatException,IOException { Scanner sc = new Scanner(new File("input.txt"));  int n = sc.nextInt();  int m = sc.nextInt(); sc.nextLine(); int k = sc.nextInt();  int les[][] = new int[n][m];  PrintWriter out = new PrintWriter(new FileWriter("output.txt"));  ArrayList<Integer[]> list = new ArrayList(); sc.nextLine(); for ( int i = 0;(i < k);i++) { Integer[] ii = new Integer[2]; ii[0] = (sc.nextInt() - 1); ii[1] = (sc.nextInt() - 1); list.add(ii); }sc.close(); int maxr = 0;  int maxi = 0;  int maxj = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int minr = 100000;  int mini = 0;  int minj = 0; for ( int f = 0;(f < k);f++) { Integer[] ii = list.get(f);  int ww = Math.abs((ii[0] - i));  int hh = Math.abs((ii[1] - j));  int r = (ww + hh); if ( (r < minr)) {minr = r; mini = i; minj = j; } }if ( ((maxr < minr) && (minr < 100000))) {maxi = mini; maxj = minj; maxr = minr; } }}out.print((((maxi + 1) + " ") + (maxj + 1))); out.close(); } }
1	public class Third{ 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();  String a = in.readString();  char c[] = a.toCharArray();  HashSet<Character> ht = new HashSet<Character>();  Deque<Character> q = new LinkedList<Character>();  HashSet<Character> hs = new HashSet<Character>();  HashMap<Character,Integer> hm = new HashMap<Character,Integer>(); for ( int i = 0;(i < n);i++) {ht.add(c[i]); } int t = ht.size(); q.addLast(c[0]); hs.add(c[0]); hm.put(c[0],1); int ans = Integer.MAX_VALUE; if ( (hs.size() == t)) {ans = min(ans,q.size()); } for ( int i = 1;(i < n);i++) {q.addLast(c[i]); hs.add(c[i]); if ( hm.containsKey(c[i])) { int x = hm.get(c[i]); hm.put(c[i],(x + 1)); } else hm.put(c[i],1); while((hs.size() == t)){ans = min(ans,q.size()); char ch = q.peekFirst();  int x = hm.get(ch); if ( (x == 1)) break; else {hm.put(ch,(x - 1)); q.pollFirst(); }}}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 int min( int a, int b){ if ( (a > b)) return b; else return a;} public static long min( long a, long b){ if ( (a > b)) return b; else return a;} 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); } } }
4	public class Codeforces{ public static void main( String[] args)throws Exception { BufferedReader bu = new BufferedReader(new InputStreamReader(System.in));  StringBuilder sb = new StringBuilder();  String s[] = bu.readLine().split(" ");  int n = Integer.parseInt(s[0]),m = Integer.parseInt(s[1]),k = Integer.parseInt(s[2]);  int i ,j ,max = (n * m),in[][] = new int[n][m],x = 0; if ( ((k % 2) == 1)) {for ( i = 0;(i < n);i++) {for ( j = 0;(j < m);j++) sb.append("-1 "); sb.append("\n"); }System.out.print(sb); return ;} for ( i = 0;(i < n);i++) for ( j = 0;(j < m);j++) in[i][j] = x++; ArrayList<Edge> g[] = new ArrayList[max]; for ( i = 0;(i < max);i++) g[i] = new ArrayList<>(); for ( i = 0;(i < n);i++) {s = bu.readLine().split(" "); for ( j = 0;(j < (m - 1));j++) { int u = in[i][j],v = in[i][(j + 1)],w = Integer.parseInt(s[j]); g[u].add(new Edge(v,w)); g[v].add(new Edge(u,w)); }}for ( i = 0;(i < (n - 1));i++) {s = bu.readLine().split(" "); for ( j = 0;(j < m);j++) { int u = in[i][j],v = in[(i + 1)][j],w = Integer.parseInt(s[j]); g[u].add(new Edge(v,w)); g[v].add(new Edge(u,w)); }}k /= 2; int dp[][] = new int[k][max]; for ( i = 0;(i < max);i++) {dp[0][i] = Integer.MAX_VALUE; for ( Edge e :g[i]) dp[0][i] = Math.min(dp[0][i],(2 * e.w)); }for ( i = 1;(i < k);i++) for ( j = 0;(j < max);j++) {dp[i][j] = Integer.MAX_VALUE; for ( Edge e :g[j]) dp[i][j] = Math.min(dp[i][j],(dp[(i - 1)][e.v] + (2 * e.w))); }for ( i = 0;(i < n);i++) {for ( j = 0;(j < m);j++) sb.append((dp[(k - 1)][in[i][j]] + " ")); sb.append("\n"); }System.out.print(sb); } static class Edge{ int v ,w ,d ; Edge( int a, int b){ v = a; w = b; d = 0; } } }
5	public class A implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok ; public static void main( String[] args){ new Thread(null,new A(),"",((64 * 1024) * 1024)).start(); } String readString()throws IOException { while(!tok.hasMoreTokens()){ String line = in.readLine(); if ( (line == null)) return null; tok = new StringTokenizer(line); }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} long readLong()throws IOException { return Long.parseLong(readString());} void debug( Object... o){ if ( LOCAL) {System.err.println(Arrays.deepToString(o)); } } static final boolean LOCAL = (System.getProperty("ONLINE_JUDGE") == null); void solve()throws IOException { int n = readInt();  long k = readLong(); if ( (k == 1)) {out.println(n); return ;} long[] a = new long[n]; for ( int i = 0;(i < n);i++) {a[i] = readLong(); }Mergesort.sort(a); int ans = 0;  boolean[] processed = new boolean[n]; debug(a); for ( int i = 0;(i < n);i++) {if ( processed[i]) {continue;} processed[i] = true; long cur = a[i]; ans++; int index = Arrays.binarySearch(a,(cur * k)); if ( (index >= 0)) {processed[index] = true; } }out.println(ans); } }
3	public class C{ FastScanner in ; PrintWriter out ; boolean systemIO = true; public void solve(){ int n = in.nextInt();  int r = (2 * in.nextInt());  int[] x = new int[n]; for ( int i = 0;(i < x.length);i++) {x[i] = in.nextInt(); } double[] y = new double[n]; for ( int i = 0;(i < y.length);i++) {y[i] = (r / 2); }for ( int i = 0;(i < y.length);i++) {for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) == r)) {y[i] = Math.max(y[i],y[j]); } else if ( (Math.abs((x[i] - x[j])) < r)) {y[i] = Math.max(y[i],(y[j] + Math.sqrt(((r * r) - ((x[j] - x[i]) * (x[j] - x[i])))))); } }}for ( int i = 0;(i < y.length);i++) {out.print((y[i] + " ")); }} 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 C().run(); } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastInput in = new FastInput(inputStream);  FastOutput out = new FastOutput(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, FastInput in, FastOutput out){ long n = in.nextLong();  long s = in.nextLong();  long cnt = 0;  long res = 0; for ( long i = s;(i <= Math.min((s + 200),n));i++) { long d = i;  int sum = 0; while((d > 0)){ long l = (d % 10); sum += l; d /= 10; }if ( ((i - sum) >= s)) {cnt++; } } long tmp = (n - Math.min(n,(s + 200))); if ( (tmp < 0)) tmp = 0; cnt += tmp; out.println(cnt); } } static class FastInput{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private FastInput.SpaceCharFilter filter ; public FastInput( 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(){ 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 FastOutput{ private final PrintWriter writer ; public FastOutput( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public FastOutput( Writer writer){ this.writer = new PrintWriter(writer); } public void close(){ writer.close(); } public void println( long i){ writer.println(i); } } }
2	public class DigitSequenceA{ public static void main( String[] args)throws IOException { FastReader in = new FastReader();  double digit = in.nextDouble();  double temp = digit;  long[] seq = new long[13]; for ( int i = 1;(i < 13);i++) {seq[i] = ((9 * (long)Math.pow(10,(i - 1))) * (i)+seq[(i - 1)]); } int power = 0; for ( int i = 0;(i < 13);i++) {if ( ((temp - seq[i]) > 0)) {continue;} else {power = i; break;}} long place = (long)Math.ceil((digit - seq[(power - 1)])); place = (long)Math.ceil((place / power)); if ( (((digit - seq[(power - 1)]) % power) > 0)) {place++; } long num = (long)((place + Math.pow(10,(power - 1))) - 1);  String num2 = Long.toString(num);  long end = (seq[(power - 1)] + (place * power));  long answer = (long)(power - (end - digit)); System.out.println(num2.charAt(((int)answer - 1))); } 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();} double nextDouble(){ return Double.parseDouble(next());} } }
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))); }} }
4	public class C{ void run()throws IOException { int n = ni(),m = ni(),k = ni(),q = (n * m),h = 0,t = 0,inf = 123456;  int[] x = new int[q],y = new int[q];  int[][] d = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) d[i][j] = inf; for ( int i = 0;(i < k);i++) { int u = (ni() - 1),v = (ni() - 1); d[u][v] = 0; x[t] = u; y[t] = v; t++; }if ( (k < q)) while((t != h)){ int u = x[h],v = y[h];  int l = (d[u][v] + 1); h++; if ( ((u > 0) && (d[(u - 1)][v] > l))) {d[(u - 1)][v] = l; x[t] = (u - 1); y[t] = v; t++; } if ( ((u < (n - 1)) && (d[(u + 1)][v] > l))) {d[(u + 1)][v] = l; x[t] = (u + 1); y[t] = v; t++; } if ( ((v > 0) && (d[u][(v - 1)] > l))) {d[u][(v - 1)] = l; x[t] = u; y[t] = (v - 1); t++; } if ( ((v < (m - 1)) && (d[u][(v + 1)] > l))) {d[u][(v + 1)] = l; x[t] = u; y[t] = (v + 1); t++; } } int max = 0,tx = 0,ty = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (d[i][j] > max)) {max = d[i][j]; tx = i; ty = j; } pw.print((((1 + tx) + " ") + (1 + ty))); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int ni()throws IOException { return Integer.parseInt(next());} PrintWriter pw ; BufferedReader br ; StringTokenizer st ; public static void main( String[] args)throws IOException { BufferedReader _br = new BufferedReader(new FileReader(new File("input.txt")));  PrintWriter _pw = new PrintWriter(new FileWriter(new File("output.txt"))); new C(_br,_pw).run(); _br.close(); _pw.close(); } public C( BufferedReader _br, PrintWriter _pw){ br = _br; pw = _pw; } }
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); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, Scanner in, PrintWriter out){ out.println(solve(in.nextLong(),in.nextLong())); } long solve( long l, long r){ if ( (l == r)) return 0; long ans = (l ^ (l + 1)); for ( int i = 0;(i < 62);i++) {l |= (1l << i); if ( ((l + 1) <= r)) ans = ((1l << (i + 2l)) - 1); }return 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 long nextLong(){ return Long.parseLong(nextToken());} }
4	public class Main{ void run(){ Locale.setDefault(Locale.US); boolean oj = (System.getProperty("ONLINE_JUDGE") != null); try{if ( oj) {sc = new FastScanner(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); } else {sc = new FastScanner(new FileReader("in.txt")); out = new PrintWriter(new FileWriter("out.txt")); } }catch (Exception e){ System.exit(-1); } long tB = System.currentTimeMillis(); solve(); if ( !oj) System.err.println(("Time: " + ((System.currentTimeMillis() - tB) / 1e3))); out.flush(); } class FastScanner{ BufferedReader br ; StringTokenizer st = new StringTokenizer(""); FastScanner( InputStreamReader a){ br = new BufferedReader(a); } FastScanner( FileReader a){ br = new BufferedReader(a); } String next(){ while(!st.hasMoreTokens())try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ return null;} return st.nextToken();} String readLine(){ try{return br.readLine(); }catch (Exception e){ return null;} } int nextInt(){ return Integer.parseInt(next());} } FastScanner sc ; PrintWriter out ; public static void main( String[] args){ new Main().run(); } void exit( int val){ out.flush(); System.exit(val); } int n ,m ; boolean[][] grid ; ArrayList<Integer>[] gr ; int c ; int[] mt ; boolean[] u ; boolean try_kuhn( int v){ if ( u[v]) return false; u[v] = true; for ( int to :gr[v]) {if ( ((to == c) || !grid[v][to])) continue; if ( ((mt[to] == -1) || try_kuhn(mt[to]))) {mt[to] = v; return true;} }return false;} void solve(){ n = sc.nextInt(); m = sc.nextInt(); grid = new boolean[(n + 1)][(n + 1)]; gr = new ArrayList[(n + 1)]; for ( int v = 1;(v <= n);++v) gr[v] = new ArrayList<Integer>(); for ( int it = 0;(it < m);++it) { int a = sc.nextInt();  int b = sc.nextInt(); grid[a][b] = true; gr[a].add(b); } int ans = Integer.MAX_VALUE; for ( c = 1;(c <= n);++c) { int curAns = 0; for ( int v = 1;(v <= n);++v) if ( (v != c)) {if ( !grid[c][v]) ++curAns; if ( !grid[v][c]) ++curAns; } if ( !grid[c][c]) ++curAns; mt = new int[(n + 1)]; fill(mt,-1); for ( int i = 1;(i <= n);++i) if ( (i != c)) {u = new boolean[(n + 1)]; try_kuhn(i); } int szMt = 0; for ( int i = 1;(i <= n);++i) if ( (mt[i] != -1)) ++szMt; curAns += ((n - 1) - szMt); for ( int a = 1;(a <= n);++a) {for ( int b :gr[a]) {if ( (((a == c) || (b == c)) || !grid[a][b])) continue; if ( (a == mt[b])) ++curAns; }}ans = min(ans,curAns); }out.println(ans); } }
4	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 String next(){ return readString();} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new Main(),"Main",(1 << 27)).start(); } public Integer[] sort( Integer[] a){ Arrays.sort(a); return a;} public Long[] sort( Long[] a){ Arrays.sort(a); return a;} public static long gcd( long a, long b){ if ( (b == 0)) return a; else return gcd(b,(a % b));} public static int gcd( int a, int b){ if ( (b == 0)) return a; else return gcd(b,(a % b));} public static int dfs( int s, ArrayList<Integer>[] g, long[] dist, boolean[] v, PrintWriter w, int p){ v[s] = true; int ans = 1;  int t = g[s].size(); for ( int i = 0;(i < t);i++) { int x = g[s].get(i); if ( !v[x]) {ans = Math.min(ans,dfs(x,g,dist,v,w,s)); } else if ( (x != p)) {ans = 0; } }return ans;} public 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); if ( ((y % 2) == 0)) return p; else return ((x * p) % m);} int oo = (int)1e9; int[] parent ; int[] dist ; int[] height ; boolean[] vis ; char[][] g ; long[][][] dp ; long mod ; int n ; int m ; int k ; long[][] pre ; int[][] col ; int[][] row ; PrintWriter w = new PrintWriter(System.out); public long sol( int i, int j, int steps){ if ( (steps == 0)) return 0; else if ( (dp[i][j][steps] != oo)) return dp[i][j][steps]; else { long ans = oo; if ( ((i - 1) > -1)) {ans = Math.min(ans,(sol((i - 1),j,(steps - 1)) + row[(i - 1)][j])); } if ( ((i + 1) < n)) {ans = Math.min(ans,(sol((i + 1),j,(steps - 1)) + row[i][j])); } if ( ((j - 1) > -1)) {ans = Math.min(ans,(sol(i,(j - 1),(steps - 1)) + col[i][(j - 1)])); } if ( ((j + 1) < m)) {ans = Math.min(ans,(sol(i,(j + 1),(steps - 1)) + col[i][j])); } dp[i][j][steps] = Math.min(dp[i][j][steps],ans); return dp[i][j][steps];}} }
3	public class naloga1{ static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws Exception { StringTokenizer st = new StringTokenizer(in.readLine());  int n = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken());  int[] x = new int[n]; st = new StringTokenizer(in.readLine()); for ( int i = 0;(i < n);i++) {x[i] = Integer.parseInt(st.nextToken()); } sim a = new sim(n,r); for ( int i :x) {a.add(i); }for ( double d :a.cy) {out.print((d + " ")); }out.println(); out.close(); } } class sim{ double[] cx ; int[] ccx ; double[] cy ; int count ; int n ; int r ; sim( int nn, int rr){ r = rr; n = nn; cx = new double[n]; ccx = new int[n]; cy = new double[n]; count = 0; } void add( int x){ double lowest = r; for ( int i = 0;(i < count);i++) {if ( (Math.abs((ccx[i] - x)) <= (2 * r))) { double dy = Math.sqrt((((4 * r) * r) - ((ccx[i] - x) * (ccx[i] - x)))); lowest = Math.max(lowest,(cy[i] + dy)); } }ccx[count] = x; cy[count] = lowest; cx[count++] = x; } }
4	public class SolutionE extends Thread{ 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 private final FastReader scanner = new FastReader(); static private final PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ new Thread(null,new SolutionE(),"Main",(1 << 26)).start(); } static final int[] primeFactors = getSmallestPrimeFactorInIntervalInclusive(10_000_000); public static int[] getSmallestPrimeFactorInIntervalInclusive( int maxN){ int[] result = new int[(maxN + 1)]; result[1] = 1; for ( int i = 2;(i <= maxN);i++) {if ( (result[i] == 0)) {for ( int j = i;(j <= maxN);j += i) {result[j] = (((result[(j / i)] % i) == 0)?(result[(j / i)] / i):(result[(j / i)] * i)); }} }return result;} static private void solve(){ int n = scanner.nextInt();  int k = scanner.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = primeFactors[scanner.nextInt()]; } Map<Integer,Integer> lastSeenIndex = new HashMap<>();  int[] revertPointers = new int[n]; for ( int i = 0;(i < n);i++) {if ( (lastSeenIndex.get(a[i]) != null)) {revertPointers[i] = lastSeenIndex.get(a[i]); } else {revertPointers[i] = -1; }lastSeenIndex.put(a[i],i); } int[][] maxSegment = new int[n][(k + 1)]; for ( int j = 0;(j <= k);j++) { int pointerLeft = 0;  int pointerRight = 0;  boolean[] changed = new boolean[n];  int amountChanged = 0; while((pointerLeft < n)){if ( ((pointerRight < n) && (revertPointers[pointerRight] < pointerLeft))) {pointerRight++; } else if ( (((pointerRight < n) && (revertPointers[pointerRight] >= pointerLeft)) && (amountChanged < j))) {changed[revertPointers[pointerRight]] = true; pointerRight++; amountChanged++; } else {if ( changed[pointerLeft]) {amountChanged--; } maxSegment[pointerLeft][j] = pointerRight; pointerLeft++; }}} int[][] dp = new int[(n + 1)][(k + 1)]; for ( int j = 0;(j <= k);j++) {dp[n][j] = 0; }for ( int i = (n - 1);(i >= 0);i--) {for ( int j = 0;(j <= k);j++) {dp[i][j] = (n + 1); for ( int x = 0;(x <= j);x++) { int nextJumpTo = maxSegment[i][x]; dp[i][j] = Math.min(dp[i][j],(dp[nextJumpTo][(j - x)] + 1)); }}}out.println(dp[0][k]); } }
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 TaskC{ SubsetGenerator sg = new SubsetGenerator(); Node[] nodes ; int n ; Map<Long,Node> map ; long notExist ; long[] mask2Key ; Map<Long,LongList> sequence ; DigitUtils.BitOperator bo = new DigitUtils.BitOperator(); boolean[] dp ; public void solve( int testNumber, FastInput in, FastOutput out){ n = in.readInt(); nodes = new Node[n]; for ( int i = 0;(i < n);i++) {nodes[i] = new Node(); nodes[i].id = i; }map = new LinkedHashMap<>(200000); for ( int i = 0;(i < n);i++) { int k = in.readInt(); for ( int j = 0;(j < k);j++) { long x = in.readInt(); map.put(x,nodes[i]); nodes[i].sum += x; }} long total = 0; for ( Node node :nodes) {total += node.sum; }if ( ((total % n) != 0)) {out.println("No"); return ;} long avg = (total / n); notExist = (long)1e18; mask2Key = new long[(1 << n)]; Arrays.fill(mask2Key,notExist); sequence = new HashMap<>(200000); for ( Map.Entry<Long,Node> kv :map.entrySet()) {for ( Node node :nodes) {node.handled = false; } long key = kv.getKey();  Node node = kv.getValue(); node.handled = true; int mask = bo.setBit(0,node.id,true);  LongList list = new LongList(15); list.add(key); long req = (avg - (node.sum - key));  boolean valid = true; while(true){if ( (req == key)) {break;} Node next = map.get(req); if ( ((next == null) || next.handled)) {valid = false; break;} next.handled = true; list.add(req); req = (avg - (next.sum - req)); mask = bo.setBit(mask,next.id,true); }if ( !valid) {continue;} mask2Key[mask] = key; sequence.put(key,list); }dp = new boolean[(1 << n)]; for ( int i = 0;(i < (1 << n));i++) {dp[i] = (mask2Key[i] != notExist); sg.setSet(i); while((!dp[i] && sg.hasNext())){ int next = sg.next(); if ( ((next == 0) || (next == i))) {continue;} dp[i] = (dp[i] || (dp[next] && dp[(i - next)])); }}if ( !dp[((1 << n) - 1)]) {out.println("No"); return ;} populate(((1 << n) - 1)); out.println("Yes"); for ( Node node :nodes) {out.append(node.out).append(' ').append((node.to + 1)).append('\n'); }} public void populate( int mask){ if ( (mask2Key[mask] != notExist)) { LongList list = sequence.get(mask2Key[mask]);  int m = list.size(); for ( int i = 0;(i < m);i++) { long v = list.get(i);  long last = list.get(DigitUtils.mod((i - 1),m));  Node which = map.get(v);  Node to = map.get(last); which.out = v; which.to = to.id; }return ;} sg.setSet(mask); while(sg.hasNext()){ int next = sg.next(); if ( ((next == 0) || (next == mask))) {continue;} if ( (dp[next] && dp[(mask - next)])) {populate(next); populate((mask - next)); return ;} }} } static class LongList{ private int size ; private int cap ; private long[] data ; static private final long[] EMPTY = new long[0]; public LongList( int cap){ this.cap = cap; if ( (cap == 0)) {data = EMPTY; } else {data = new long[cap]; }} public LongList( LongList list){ this.size = list.size; this.cap = list.cap; this.data = Arrays.copyOf(list.data,size); } public LongList(){ this(0); } private void ensureSpace( int need){ int req = (size + need); if ( (req > cap)) {while((cap < req)){cap = Math.max((cap + 10),(2 * cap)); }data = Arrays.copyOf(data,cap); } } private void checkRange( int i){ if ( ((i < 0) || (i >= size))) {throw (new ArrayIndexOutOfBoundsException());} } public long get( int i){ checkRange(i); return data[i];} public void add( long x){ ensureSpace(1); data[size++] = x; } public int size(){ return size;} public String toString(){ return Arrays.toString(Arrays.copyOf(data,size));} } static class SubsetGenerator{ private int[] meanings = new int[33]; private int[] bits = new int[33]; private int remain ; private int next ; public void setSet( int set){ int bitCount = 0; while((set != 0)){meanings[bitCount] = (set & -set); bits[bitCount] = 0; set -= meanings[bitCount]; bitCount++; }remain = (1 << bitCount); next = 0; } public boolean hasNext(){ return (remain > 0);} private void consume(){ remain = (remain - 1); int i ; for ( i = 0;(bits[i] == 1);i++) {bits[i] = 0; next -= meanings[i]; }bits[i] = 1; next += meanings[i]; } public int next(){ int returned = next; consume(); return returned;} } static class Node{ int id ; long sum ; boolean handled ; long out ; long to ; } 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 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 append( char c){ cache.append(c); return this;} public FastOutput append( long c){ cache.append(c); return this;} public FastOutput println( String 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();} } }
0	public class Problem1{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  long n = Long.parseLong(br.readLine()); if ( ((n % 2) == 0)) {System.out.println(((4 + " ") + (n - 4))); } else {System.out.println(((9 + " ") + (n - 9))); }} }
6	public class Order implements Runnable{ private Scanner in = new Scanner(System.in); private PrintWriter out = new PrintWriter(System.out); private int xs ,ys ,n ; private int[] x ,y ; public static void main( String[] args){ new Thread(new Order()).start(); } private void read(){ xs = in.nextInt(); ys = in.nextInt(); n = in.nextInt(); x = new int[n]; y = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = in.nextInt(); y[i] = in.nextInt(); }} private void solve(){ int[] res = new int[(1 << n)];  int[] last = new int[(1 << n)]; Arrays.fill(res,Integer.MAX_VALUE); int[] ds = new int[n]; for ( int i = 0;(i < n);i++) {ds[i] = (((x[i] - xs) * (x[i] - xs)) + ((y[i] - ys) * (y[i] - ys))); } int[][] d = new int[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) d[i][j] = (((x[i] - x[j]) * (x[i] - x[j])) + ((y[i] - y[j]) * (y[i] - y[j]))); }res[0] = 0; for ( int i = 1;(i < (1 << n));i++) {for ( int j = 0;(j < n);j++) {if ( (((i >> j) & 1) != 0)) {if ( ((res[(i - (1 << j))] + (2 * ds[j])) < res[i])) {res[i] = (res[(i - (1 << j))] + (2 * ds[j])); last[i] = (i - (1 << j)); } for ( int k = (j + 1);(k < n);k++) {if ( (((i >> k) & 1) != 0)) {if ( ((((res[((i - (1 << j)) - (1 << k))] + ds[j]) + ds[k]) + d[j][k]) < res[i])) {res[i] = (((res[((i - (1 << j)) - (1 << k))] + ds[j]) + ds[k]) + d[j][k]); last[i] = ((i - (1 << j)) - (1 << k)); } } }break;} }} int cur = ((1 << n) - 1); out.println(res[cur]); while((cur != 0)){out.print("0 "); int dif = (cur - last[cur]); for ( int i = 0;((i < n) && (dif != 0));i++) {if ( (((dif >> i) & 1) != 0)) {out.print(((i + 1) + " ")); dif -= (1 << i); } }cur = last[cur]; }out.println("0"); } private void write(){ } }
2	public class Main{ public static void main( String[] args)throws Exception { Thread thread = new Thread(null,new TaskAdapter(),"",(1 << 29)); thread.start(); thread.join(); } static class TaskAdapter implements Runnable{ } static class BSearchingRectangles{ FastInput in ; FastOutput out ; int n ; public void solve( int testNumber, FastInput in, FastOutput out){ this.in = in; this.out = out; n = in.readInt(); IntBinarySearch upDown = new IntBinarySearch(){public boolean check( int mid){ return (query(1,n,1,mid) >= 1);} };  IntBinarySearch leftRight = new IntBinarySearch(){public boolean check( int mid){ return (query(1,mid,1,n) >= 1);} };  int threshold = upDown.binarySearch(1,n);  int[] r1 ;  int[] r2 ; if ( ((query(1,n,1,threshold) == 1) && (query(1,n,(threshold + 1),n) == 1))) {r1 = find(1,n,1,threshold); r2 = find(1,n,(threshold + 1),n); } else {threshold = leftRight.binarySearch(1,n); r1 = find(1,threshold,1,n); r2 = find((threshold + 1),n,1,n); }out.append("! "); output(r1); output(r2); out.flush(); } public void output( int[] ans){ for ( int x :ans) {out.append(x).append(' '); }} public int[] find( int l, int r, int d, int u){ IntBinarySearch downIBS = new IntBinarySearch(){public boolean check( int mid){ return (query(l,r,mid,u) == 0);} };  int y1 = downIBS.binarySearch(d,u); if ( (query(l,r,y1,u) == 0)) {y1--; } IntBinarySearch upIBS = new IntBinarySearch(){public boolean check( int mid){ return (query(l,r,d,mid) >= 1);} };  int y2 = upIBS.binarySearch(d,u);  IntBinarySearch leftIBS = new IntBinarySearch(){public boolean check( int mid){ return (query(mid,r,d,u) == 0);} };  int x1 = leftIBS.binarySearch(l,r); if ( (query(x1,r,d,u) == 0)) {x1--; } IntBinarySearch rightIBS = new IntBinarySearch(){public boolean check( int mid){ return (query(l,mid,d,u) >= 1);} };  int x2 = rightIBS.binarySearch(l,r); return new int[]{x1,y1,x2,y2};} public int query( int l, int r, int d, int u){ if ( ((l > r) || (d > u))) {return 0;} out.printf("? %d %d %d %d",l,d,r,u).println().flush(); return in.readInt();} } abstract static class IntBinarySearch{ public abstract boolean check( int mid){ } public int binarySearch( int l, int r){ if ( (l > r)) {throw (new IllegalArgumentException());} while((l < r)){ int mid = DigitUtils.floorAverage(l,r); if ( check(mid)) {r = mid; } else {l = (mid + 1); }}return l;} } 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 FastOutput implements AutoCloseable,Closeable,Appendable{ private StringBuilder cache = new StringBuilder((10 << 20)); private final Writer os ; public FastOutput append( CharSequence csq){ cache.append(csq); return this;} public FastOutput append( CharSequence csq, int start, int end){ cache.append(csq,start,end); return this;} public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput append( char c){ cache.append(c); return this;} public FastOutput append( int c){ cache.append(c); return this;} public FastOutput append( String c){ cache.append(c); return this;} public FastOutput printf( String format, Object... args){ cache.append(String.format(format,args)); return this;} public FastOutput println(){ cache.append(System.lineSeparator()); 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();} } }
1	public class C{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt();  char[] a = next().toCharArray();  int[] cnt = new int[256]; for ( int i = 0;(i < n);i++) {cnt[a[i]]++; } int alldiff = 0; for ( int i = 0;(i < 256);i++) {if ( (cnt[i] > 0)) alldiff++; }Arrays.fill(cnt,0); int diff = 0,right = -1,ans = (n + 5); for ( int i = 0;(i < n);i++) {if ( (right < i)) {cnt[a[i]]++; diff = 1; right = i; } while(((right < (n - 1)) && (diff < alldiff))){right++; cnt[a[right]]++; if ( (cnt[a[right]] == 1)) diff++; }if ( ((diff == alldiff) && (((right - i) + 1) < ans))) {ans = ((right - i) + 1); } cnt[a[i]]--; if ( (cnt[a[i]] == 0)) diff--; }System.out.println(ans); pw.close(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
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")); } }
0	public class Main{ public static void main( String[] args)throws IOException { new Main().solve(); } void solve()throws IOException { MyReader in = new MyReader();  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(); out.print("0 0 "); out.print(n); out.close(); } } class MyReader{ private BufferedReader in ; String[] parsed ; int index = 0; public MyReader(){ in = new BufferedReader(new InputStreamReader(System.in)); } public int nextInt()throws NumberFormatException,IOException { if ( ((parsed == null) || (parsed.length == index))) {read(); } return Integer.parseInt(parsed[index++]);} private void read()throws IOException { parsed = in.readLine().split(" "); index = 0; } public String readLine()throws IOException { return in.readLine();} }
5	public class Main{ static private BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main( String[] args)throws NumberFormatException,IOException { String[] s = br.readLine().trim().split(" ");  int n = Integer.parseInt(s[0]);  int m = Integer.parseInt(s[1]);  long b[] = new long[n]; s = br.readLine().trim().split(" "); for ( int i = 0;(i < n);i++) {b[i] = Integer.parseInt(s[i]); } long g[] = new long[m]; s = br.readLine().trim().split(" "); for ( int i = 0;(i < m);i++) {g[i] = Integer.parseInt(s[i]); }Arrays.sort(b); Arrays.sort(g); if ( (g[0] < b[(n - 1)])) {System.out.println("-1"); } else if ( (g[0] == b[(n - 1)])) { long ans = 0; for ( int i = 0;(i < m);i++) {ans += g[i]; }for ( int i = 0;(i < (n - 1));i++) {ans += (m * b[i]); }System.out.println(ans); } else { long ans = 0; for ( int i = 0;(i < m);i++) {ans += g[i]; }for ( int i = 0;(i < (n - 1));i++) {ans += (m * b[i]); }ans += (b[(n - 1)] - b[(n - 2)]); System.out.println(ans); }} }
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); } }
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(); } }
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 B{ 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()); st = new StringTokenizer(br.readLine()); int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(st.nextToken()); int l = 0,r = 0;  int[] t = new int[100001];  int kk = 0;  int min = (1 << 25),ll = -1,rr = -1; while((r < n)){ int x = a[r++]; t[x]++; if ( (t[x] == 1)) kk++; while(((r < n) && (kk < k))){x = a[r++]; t[x]++; if ( (t[x] == 1)) kk++; }while(((kk == k) && (l < r))){x = a[l]; if ( (t[x] == 1)) break; t[x]--; l++; }if ( (kk == k)) { int m = ((r - l) + 1); if ( (m < min)) {ll = (l + 1); rr = r; min = m; } } }System.out.println(((ll + " ") + rr)); } }
1	public class round569d2b{ public static void main( String[] args){ FastScanner in = new FastScanner(System.in);  int n = in.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = in.nextInt(); }if ( ((n % 2) == 0)) {for ( int i = 0;(i < n);i++) {if ( (arr[i] >= 0)) {arr[i] = ((-1 * arr[i]) - 1); } }} else { int max = Integer.MIN_VALUE;  int maxIndex = 0; for ( int i = 0;(i < n);i++) { int elem = arr[i]; if ( (elem < 0)) {elem = ((-1 * elem) - 1); } if ( (elem > max)) {max = elem; maxIndex = i; } }for ( int i = 0;(i < n);i++) {if ( (i == maxIndex)) {if ( (arr[i] < 0)) {arr[i] = ((-1 * arr[i]) - 1); } } else {if ( (arr[i] >= 0)) {arr[i] = ((-1 * arr[i]) - 1); } }}} StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < n);i++) {sb.append((arr[i] + " ")); }System.out.println(sb); } public static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} static class Tuple3<X,Y,Z>{ public final X x ; public final Y y ; public final Z z ; public Tuple3( X x, Y y, Z z){ this.x = x; this.y = y; this.z = z; } public String toString(){ return (((((("(" + x) + ",") + y) + ",") + z) + ")");} } static Tuple3<Integer,Integer,Integer> gcdExtended( int a, int b, int x, int y){ if ( (a == 0)) {x = 0; y = 1; return new Tuple3(0,1,b);} int x1 = 1,y1 = 1;  Tuple3<Integer,Integer,Integer> tuple = gcdExtended((b % a),a,x1,y1);  int gcd = tuple.z; x1 = tuple.x; y1 = tuple.y; x = (y1 - ((b / a) * x1)); y = x1; return new Tuple3(x,y,gcd);} static int inv( int a, int m){ int m0 = m,t ,q ;  int x0 = 0,x1 = 1; if ( (m == 1)) return 0; while((a > 1)){q = (a / m); t = m; m = (a % m); a = t; t = x0; x0 = (x1 - (q * x0)); x1 = t; }if ( (x1 < 0)) x1 += m0; return x1;} static class FastScanner{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int chars ; public FastScanner( InputStream stream){ this.stream = stream; } int read(){ if ( (chars == -1)) throw (new InputMismatchException()); if ( (curChar >= chars)) {curChar = 0; try{chars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (chars <= 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();} } }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String x[] = br.readLine().split(" ");  long l = Long.parseLong(x[0]);  long r = Long.parseLong(x[1]); if ( ((l % 2) != 0)) {l++; } if ( ((l + 2) > r)) {System.out.println("-1"); } else {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); }} }
4	public class ExplorerSpace{ static private 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(); }} static private 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(); } }
6	public class Main{ void solve(){ int n = ni(),m = ni();  int a[][] = new int[(n + 1)][(m + 1)]; for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= m);j++) a[i][j] = ni(); if ( (n == 1)) { int mn = Integer.MAX_VALUE; for ( int i = 1;(i < m);i++) mn = Math.min(mn,Math.abs((a[1][i] - a[1][(i + 1)]))); pw.println(mn); return ;} mn1 = new int[(n + 1)][(n + 1)]; mn2 = new int[(n + 1)][(n + 1)]; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= n);j++) {if ( (i == j)) continue; mn1[i][j] = mn2[i][j] = Integer.MAX_VALUE; for ( int k = 1;(k <= m);k++) {mn1[i][j] = Math.min(mn1[i][j],Math.abs((a[i][k] - a[j][k]))); }for ( int k = 1;(k < m);k++) {mn2[i][j] = Math.min(mn2[i][j],Math.abs((a[i][(k + 1)] - a[j][k]))); }}}dp = new int[17][(1 << 16)][17]; for ( int i = 1;(i < 17);i++) for ( int j = 0;(j < (1 << 16));j++) Arrays.fill(dp[i][j],-1); int ans = 0; for ( int i = 1;(i <= n);i++) {ans = Math.max(ans,go(2,(1 << (i - 1)),i,i,n)); }pw.println(ans); } int mn1[][] ,mn2[][] ; int dp[][][] ; int go( int i, int mask, int prev, int first, int n){ if ( (i > n)) {return mn2[first][prev];} if ( (dp[first][mask][prev] != -1)) return dp[first][mask][prev]; int cc = 0; for ( int k = 1;(k <= n);k++) {if ( ((mask & (1 << (k - 1))) == 0)) {cc = Math.max(cc,Math.min(mn1[prev][k],go((i + 1),(mask | (1 << (k - 1))),k,first,n))); } }dp[first][mask][prev] = cc; return cc;} long M = ((long)1e9 + 7); InputStream is ; PrintWriter pw ; String INPUT = ""; void run()throws Exception { is = (INPUT.isEmpty()?System.in:new ByteArrayInputStream(INPUT.getBytes())); pw = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); pw.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) && !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 ( (INPUT.length() > 0)) System.out.println(Arrays.deepToString(o)); } }
5	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);  A solver = new A(); solver.solve(1,in,out); out.close(); } } class A{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.readInt();  int a = in.readInt();  int b = in.readInt();  int[] hs = new int[n]; for ( int i = 0;(i < n);i++) {hs[i] = in.readInt(); }Arrays.sort(hs); out.println((hs[b] - hs[(b - 1)])); } } class InputReader{ BufferedReader in ; public InputReader( InputStream stream){ in = new BufferedReader(new InputStreamReader(stream)); } public int skipSpace(){ int c ; try{while(true){c = in.read(); if ( (c < 0)) {throw (new InputMismatchException());} if ( (c > 32)) {break;} } }catch (IOException e){ throw (new InputMismatchException());} return c;} public int readInt(){ int res = 0;  boolean sign = false;  int c = skipSpace(); try{if ( (c == '-')) {sign = true; c = in.read(); } while(true){if ( ((c >= '0') && (c <= '9'))) {res = (((res * 10) + c) - '0'); } else {throw (new InputMismatchException());}c = in.read(); if ( (c <= 32)) {break;} }if ( sign) {res = -res; } return res; }catch (IOException e){ throw (new InputMismatchException());} } }
6	public class Main{ static MyScanner scan ; static PrintWriter pw ; static long MOD = 1_000_000_007; static long INF = 1_000_000_000_000_000_000L; static long inf = 2_000_000_000; public static void main( String[] args){ new Thread(null,null,"BaZ",(1 << 27)){}.start(); } static int n ,m ,need ,a[][] ,dp[][][] ,real[][] ; static void solve()throws IOException { initIo(false); StringBuilder sb = new StringBuilder();  int t = ni(); while((t-- > 0)){n = ni(); m = ni(); a = new int[n][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {a[i][j] = ni(); }}need = min(n,m); Pair max_in_cols[] = new Pair[m]; for ( int COL = 0;(COL < m);++COL) { int max = 0; for ( int i = 0;(i < n);++i) {max = max(max,a[i][COL]); }max_in_cols[COL] = new Pair(max,COL); }real = new int[n][need]; Arrays.sort(max_in_cols); for ( int i = 0;(i < need);++i) { int COL = max_in_cols[((m - 1) - i)].y; for ( int j = 0;(j < n);++j) {real[j][i] = a[j][COL]; }}dp = new int[need][(n + 1)][(1 << n)]; for ( int i = 0;(i < need);++i) {for ( int j = 0;(j <= n);++j) {for ( int k = 0;(k < (1 << n));++k) {dp[i][j][k] = -1; }}}pl(f(0,n,0)); }pw.flush(); pw.close(); } static int f( int idx, int bias, int mask){ if ( (idx == need)) {return 0;} if ( (dp[idx][bias][mask] != -1)) {return dp[idx][bias][mask];} if ( (bias == n)) { int max = 0; for ( int b = 0;(b < n);++b) {max = max(max,f(idx,b,mask)); }dp[idx][bias][mask] = max; return max;} else { int max = f((idx + 1),n,mask); for ( int i = 0;(i < n);++i) {if ( ((mask & (1 << i)) == 0)) {max = max(max,(real[(((i - bias) + n) % n)][idx] + f(idx,bias,(mask | (1 << i))))); } }dp[idx][bias][mask] = max; return max;}} static class Pair implements Comparable<Pair>{ int x ,y ; Pair( int x, int y){ this.x = x; this.y = y; } } static void initIo( boolean isFileIO)throws IOException { scan = new MyScanner(isFileIO); if ( isFileIO) {pw = new PrintWriter("/Users/amandeep/Desktop/output.txt"); } else {pw = new PrintWriter(System.out,true); }} static int ni()throws IOException { return scan.nextInt();} static void pl(){ pw.println(); } static void p( Object o){ pw.print((o + " ")); } static void pl( Object o){ pw.println(o); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner( boolean readingFromFile)throws IOException{ if ( readingFromFile) {br = new BufferedReader(new FileReader("/Users/amandeep/Desktop/input.txt")); } else {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 Main{ static int mod = (int)(1e9 + 7); static int MAX = ((int)2e5 + 5); static void solve(){ int n = i();  String[] s = new String[n]; for ( int i = 0;(i < n);i++) {s[i] = s(); } int[][] dp = new int[n][n]; dp[0][0] = 1; for ( int i = 1;(i < n);i++) {if ( s[(i - 1)].equals("f")) {for ( int j = (i - 1);(j >= 0);j--) {dp[i][(j + 1)] = dp[(i - 1)][j]; }} else { int suff = 0; for ( int j = (i - 1);(j >= 0);j--) {suff += dp[(i - 1)][j]; if ( (suff >= mod)) suff -= mod; dp[i][j] = suff; }}} int sum = 0; for ( int i = 0;(i < n);i++) {sum = (sum + dp[(n - 1)][i]); if ( (sum >= mod)) sum -= mod; }out.println(sum); out.close(); } static InputReader sc = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } 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 gcdExtended( long a, long b, long[] x){ if ( (a == 0)) {x[0] = 0; x[1] = 1; return b;} long[] y = new long[2];  long gcd = gcdExtended((b % a),a,y); x[0] = (y[1] - ((b / a) * y[0])); x[1] = y[0]; return gcd;} 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));} 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 int[] nextIntArray( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }return a;} public long[] nextLongArray( int n){ long a[] = new long[n]; for ( int i = 0;(i < n);i++) {a[i] = nextLong(); }return a;} public String nextLine(){ int c = snext(); while(isSpaceChar(c))c = snext(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = snext(); }while(!isEndOfLine(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));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static int i(){ return sc.nextInt();} static String s(){ return sc.nextLine();} }
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());} }
0	public class AgainTwentyfive{ public static void main( String[] args){ System.out.println("25"); } }
6	public class E{ public static void main( String[] args)throws Exception { FastScanner sc = new FastScanner(System.in);  FastPrinter out = new FastPrinter(System.out);  E runner = new E(); runner.run(sc,out); out.close(); } int N ,L ; long[][] mat ; long[] dp ; public void run( FastScanner sc, FastPrinter out)throws Exception { L = sc.nextInt(); N = sc.nextInt(); mat = new long[N][N]; char[] arr = sc.next().toCharArray(); for ( int i = 0;(i < (L - 1));i++) { int cur = (arr[i] - 'a');  int next = (arr[(i + 1)] - 'a'); if ( (cur != next)) {mat[cur][next]++; mat[next][cur]++; } }dp = new long[(1 << N)]; Arrays.fill(dp,-1); dp[((1 << N) - 1)] = 0; long ans = solve(0); out.println(ans); } private long solve( int mask){ if ( (dp[mask] == -1)) { long value = 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)) {value += mat[i][j]; } }} } long ans = Long.MAX_VALUE; for ( int i = 0;(i < N);i++) {if ( ((mask & (1 << i)) == 0)) { long temp = solve((mask | (1 << i))); if ( (temp < ans)) {ans = temp; } } }ans += value; dp[mask] = ans; } return dp[mask];} static class FastScanner{ private final int BUFFER_SIZE = (1 << 10); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ,bytesRead ; public FastScanner(){ this(System.in); } public FastScanner( InputStream stream){ din = new DataInputStream(stream); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public FastScanner( String fileName)throws IOException{ Path p = Paths.get(fileName); buffer = Files.readAllBytes(p); bytesRead = buffer.length; } boolean isEndline( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} String next()throws Exception { int c = readOutSpaces();  StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c));return res.toString();} boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} 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 { if ( (din == null)) {bufferPointer = 0; bytesRead = -1; } else {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++];} private int readOutSpaces()throws IOException { while(true){if ( (bufferPointer == bytesRead)) fillBuffer();  int c = buffer[bufferPointer++]; if ( !isSpaceChar(c)) {return c;} }} public void close()throws IOException { if ( (din == null)) return ; din.close(); } } static class FastPrinter{ static final char ENDL = '\n'; StringBuilder buf ; PrintWriter pw ; public FastPrinter( OutputStream stream){ buf = new StringBuilder(); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))); } public FastPrinter( String fileName)throws Exception{ buf = new StringBuilder(); pw = new PrintWriter(new BufferedWriter(new FileWriter(fileName))); } public FastPrinter( StringBuilder buf){ this.buf = buf; } public void print( int a){ buf.append(a); } public void print( long a){ buf.append(a); } public void print( char a){ buf.append(a); } public void print( char[] a){ buf.append(a); } public void print( double a){ buf.append(a); } public void print( String a){ buf.append(a); } public void print( Object a){ buf.append(a.toString()); } public void println(){ buf.append(ENDL); } public void println( int a){ buf.append(a); buf.append(ENDL); } public void println( long a){ buf.append(a); buf.append(ENDL); } public void println( char a){ buf.append(a); buf.append(ENDL); } public void println( char[] a){ buf.append(a); buf.append(ENDL); } public void println( double a){ buf.append(a); buf.append(ENDL); } public void println( String a){ buf.append(a); buf.append(ENDL); } public void println( Object a){ buf.append(a.toString()); buf.append(ENDL); } public void close(){ pw.print(buf); pw.close(); } public void flush(){ pw.print(buf); pw.flush(); buf.setLength(0); } } }
3	public class HelloWorld{ public static void main( String[] args){ final long MOD = 1000000007;  Scanner scan = new Scanner(System.in);  int now = 1;  int maxStatements = scan.nextInt();  long[] dp = new long[(maxStatements + 1)]; dp[now] = 1; while((maxStatements > 0)){ String add = scan.next(); if ( add.equals("f")) {now++; } else {for ( int k = 1;(k <= now);k++) {dp[k] = ((dp[k] + dp[(k - 1)]) % MOD); }}maxStatements--; }System.out.println(dp[now]); } }
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"); }}} }
1	public class Cf1017A{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  int result = 1;  int thomasSum = 0;  StringTokenizer stk ; stk = new StringTokenizer(br.readLine()); int first = Integer.parseInt(stk.nextToken());  int second = Integer.parseInt(stk.nextToken());  int third = Integer.parseInt(stk.nextToken());  int fourth = Integer.parseInt(stk.nextToken()); thomasSum = (((first + second) + third) + fourth); int tmp ; for ( int i = 1;(i < n);i++) {stk = new StringTokenizer(br.readLine()); first = Integer.parseInt(stk.nextToken()); second = Integer.parseInt(stk.nextToken()); third = Integer.parseInt(stk.nextToken()); fourth = Integer.parseInt(stk.nextToken()); tmp = (((first + second) + third) + fourth); if ( (tmp > thomasSum)) result++; }System.out.println(result); } }
5	public class Main{ public static void main( String[] args){ try{new Main().solve(); }catch (Exception e){ e.printStackTrace(); } } ArrayList<Edge>[] edge ; int n ,m ,cnt = 0; int ord ; int[] order ; int[] vis ; Edge[] e ; private void solve()throws Exception { InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); n = in.nextInt(); m = in.nextInt(); edge = new ArrayList[(n + 1)]; e = new Edge[m]; vis = new int[(n + 1)]; order = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {edge[i] = new ArrayList<>(); }for ( int i = 1;(i <= m);i++) { int s = in.nextInt(),t = in.nextInt(),c = in.nextInt(); edge[s].add(new Edge(s,t,c,i)); } int l = 0,r = 1000000000; while((l < r)){ int mid = ((l + r) >>> 1); if ( judge(mid,false)) r = mid; else l = (mid + 1); }out.print((l + " ")); judge(l,true); Arrays.sort(e,0,cnt,Comparator.comparingInt((x)->x.id)); int ans = 0;  int[] a = new int[m]; for ( int i = 0;(i < cnt);i++) {if ( (order[e[i].s] < order[e[i].t])) a[ans++] = e[i].id; }out.println(ans); for ( int i = 0;(i < ans);i++) {out.print((a[i] + " ")); }out.println(); out.flush(); } boolean judge( int min, boolean mod){ Arrays.fill(vis,0); cycle = false; for ( int i = 1;(i <= n);i++) {if ( (vis[i] == 0)) {dfs(i,min,mod); if ( cycle) return false; } }return true;} boolean cycle = false; void dfs( int cur, int min, boolean mod){ if ( cycle) return ; vis[cur] = 1; for ( Edge e :edge[cur]) {if ( (e.c <= min)) {if ( mod) this.e[cnt++] = e; continue;} if ( (vis[e.t] == 1)) {cycle = true; return ;} else if ( (vis[e.t] == 0)) dfs(e.t,min,mod); }vis[cur] = 2; if ( mod) order[cur] = ord++; } } class Edge{ int s ,t ,c ,id ; Edge( int a, int b, int c, int d){ s = a; t = b; this.c = c; id = d; } } class InputReader{ StreamTokenizer tokenizer ; public InputReader( InputStream stream){ tokenizer = new StreamTokenizer(new BufferedReader(new InputStreamReader(stream))); tokenizer.ordinaryChars(33,126); tokenizer.wordChars(33,126); } public String next()throws IOException { tokenizer.nextToken(); return tokenizer.sval;} public int nextInt()throws IOException { return Integer.parseInt(next());} }
3	public class TaskC{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),r = sc.nextInt();  int[] xcords = new int[n];  double[] ycords = new double[n];  double y = r,x = 0,px = 0,ty = 0; for ( int i = 0;(i < n);i++) {xcords[i] = sc.nextInt(); x = xcords[i]; y = r; for ( int j = 0;(j < i);j++) {px = xcords[j]; if ( (Math.abs((px - x)) > (r * 2))) continue; ty = (Math.sqrt((((4 * r) * r) - ((x - px) * (x - px)))) + ycords[j]); y = Math.max(y,ty); }ycords[i] = y; }for ( int i = 0;(i < n);i++) {System.out.print((ycords[i] + " ")); }} }
3	public class C{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt();  int r = sc.nextInt();  double ans[] = new double[n];  int[] x = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = sc.nextInt(); }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))) {ans[i] = Math.max(ans[i],(ans[j] + Math.sqrt((((4 * r) * r) - (d * d))))); } }out.print((ans[i] + " ")); }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( 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();} } }
0	public class HexadecimalTheorem{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  PrintWriter out = new PrintWriter(System.out); out.printf("%d %d %d%n",0,0,n); out.flush(); } }
0	public class K603{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a = sc.nextLong();  long b = sc.nextLong(); if ( ((b - a) < 2)) {System.out.println(-1); } else if ( (((b - a) == 2) && ((a % 2) == 1))) {System.out.println(-1); } else if ( (((b - a) == 2) && ((a % 2) == 0))) {System.out.println(((((a + " ") + (a + 1)) + " ") + (a + 2))); } else {if ( ((a % 2) == 0)) {System.out.println(((((a + " ") + (a + 1)) + " ") + (a + 2))); } else {System.out.println((((((a + 1) + " ") + (a + 2)) + " ") + (a + 3))); }}} }
2	public class Main{ BufferedReader in ; StringTokenizer str = null; private String next()throws Exception { if ( ((str == null) || !str.hasMoreElements())) str = new StringTokenizer(in.readLine()); return str.nextToken();} private long nextLong()throws Exception { return Long.parseLong(next());} public void run()throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); long l = nextLong();  long r = nextLong();  int bit = 63; while(((bit >= 0) && (hasBit(l,bit) == hasBit(r,bit)))){bit--; }System.out.println(((1L << (bit + 1)) - 1)); } private boolean hasBit( long x, int i){ return ((x & (1L << i)) > 0);} public static void main( String[] args)throws Exception { new Main().run(); } }
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); } }
1	public class A{ static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} static PrintWriter out = new PrintWriter(System.out); static boolean prime( int n){ int j = 2; while(((j * j) <= n))if ( ((n % j) == 0)) return false; else j++; return true;} public static void main( String[] args)throws IOException { int n = nextInt(),k = nextInt(),a[] = new int[n];  int s = 0; for ( int i = 2;(i <= n);i++) if ( prime(i)) a[s++] = i;  int m = 0; for ( int i = 2;(i < s);i++) for ( int j = (i - 1);(j > 0);j--) if ( (a[i] == ((a[j] + a[(j - 1)]) + 1))) {m++; break;} if ( (m >= k)) out.println("YES"); else out.println("NO"); out.flush(); } }
6	public class e{ private void main(){ Scanner stdin = new Scanner(System.in);  PrintStream stdout = System.out;  int n = stdin.nextInt();  double[][] p = new double[n][n];  double[][] ans = new double[(1 << n)][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) p[i][j] = stdin.nextDouble(); double[] dieChance = new double[n];  ArrayList<Integer> sel = new ArrayList<Integer>(); for ( int i = 0;(i < (1 << n));i++) {sel.clear(); for ( int k = 0;(k < n);k++) {if ( ((i & (1 << k)) != 0)) sel.add(k); }if ( (sel.size() == 1)) {ans[i][sel.get(0)] = 0; continue;} for ( int j :sel) dieChance[j] = 0; for ( int j :sel) for ( int k :sel) dieChance[k] += p[j][k]; for ( int j :sel) dieChance[j] /= ((sel.size() * (sel.size() - 1)) / 2); for ( int j :sel) {ans[i][j] = dieChance[j]; for ( int k :sel) ans[i][j] += (dieChance[k] * ans[(i - (1 << k))][j]); }}for ( double d :ans[((1 << n) - 1)]) stdout.format("%f ",(1 - d)); stdout.println(); } public static void main( String[] args){ new e().main(); } }
1	public class CF1009E{ static final int MD = 998244353; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine());  int[] aa = new int[(1 + n)]; for ( int i = 1,a = 0;(i <= n);i++) aa[i] = a = ((a + Integer.parseInt(st.nextToken())) % MD); int[] pp = new int[n]; pp[0] = 1; for ( int i = 1,p = 1;(i < n);i++) {pp[i] = p; p = ((p * 2) % MD); } int d = 0;  long ans = 0; for ( int i = (n - 1);(i >= 0);i--) {d = ((((d * 2) % MD) + aa[((n - 1) - i)]) % MD); ans = ((ans + ((long)(d + aa[(n - i)]) * pp[i])) % MD); }System.out.println(ans); } }
6	public class B implements Runnable{ int a ; int[] b ; int[] l ; public void solve()throws IOException { int n = in.nextInt();  int k = in.nextInt(); a = in.nextInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = in.nextInt(); l[i] = in.nextInt(); }out.println(best(0,k)); } double best( int cur, int left){ double r = 0.0; if ( (cur < l.length)) {for ( int i = 0;((i <= left) && ((l[cur] + (10 * i)) <= 100));i++) {l[cur] += (i * 10); r = Math.max(r,best((cur + 1),(left - i))); l[cur] -= (i * 10); }} else {for ( int m = 0;(m < (1 << l.length));m++) { int sum = 0;  double p = 1.0;  int pro = 0; for ( int i = 0;(i < l.length);i++) {if ( ((m & (1 << i)) == 0)) {p *= (1.0 - (l[i] * 0.01)); sum += b[i]; } else {p *= (l[i] * 0.01); pro++; }}if ( ((pro * 2) > l.length)) {r += p; } else {r += ((p * a) / (a + sum)); }}}return r;} public Scanner in ; public PrintWriter out ; B()throws IOException{ in = new Scanner(System.in); out = new PrintWriter(System.out); } void close()throws IOException { out.close(); } public static void main( String[] args)throws IOException { new Thread(new B()).start(); } }
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)));} }
3	public class Codeforces908C{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int r = sc.nextInt();  int[] x = new int[n];  double[] res = new double[n]; for ( int i = 0;(i < n);i++) {x[i] = sc.nextInt(); res[i] = (double)r; for ( int j = (i - 1);(j >= 0);j--) { int diff = (x[j] - x[i]); if ( (Math.abs((x[j] - x[i])) <= (2 * r))) {res[i] = Math.max(res[i],(res[j] + Math.sqrt((((4 * r) * r) - (diff * diff))))); } }}for ( int i = 0;(i < n);i++) {System.out.print((res[i] + " ")); }System.out.println(""); } }
0	public class Main{ public void solve()throws IOException { int n = nextInt(); output.println(((n / 2) * 3)); } public void run()throws IOException { input = new BufferedReader(new InputStreamReader(System.in)); output = new PrintWriter(System.out); solve(); input.close(); output.close(); } BufferedReader input ; PrintWriter output ; StringTokenizer tok ; String nextToken()throws IOException { while(((tok == null) || !tok.hasMoreTokens()))tok = new StringTokenizer(input.readLine()); return tok.nextToken();} int nextInt()throws IOException { return Integer.valueOf(nextToken());} public static void main( String[] args)throws IOException { new Main().run(); } }
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)); } }
0	public class coins{ public static void main( String[] args)throws IOException { InputStreamReader read = new InputStreamReader(System.in);  BufferedReader in = new BufferedReader(read);  int i ,k ,n ,v ;  String a ; a = in.readLine(); for ( i = 0;(i < a.length());i++) {if ( (a.charAt(i) == ' ')) break; }n = Integer.parseInt(a.substring(0,i)); v = Integer.parseInt(a.substring((i + 1))); k = (v % n); v = (v / n); if ( (k > 0)) v++; System.out.println(v); } }
4	public class Main{ static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ boolean env = (System.getProperty("ONLINE_JUDGE") != null); if ( !env) {try{br = new BufferedReader(new FileReader("src\\input.txt")); }catch (FileNotFoundException e){ e.printStackTrace(); } } 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());} } static long MOD = ((long)1e9 + 7); static FastReader sc = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static int hor[][] ,ver[][] ; static int moves[][] = {{-1,0},{1,0},{0,-1},{0,1}}; static int n ,m ; static int dp[][][] ; static int solve( int x, int y, int k){ if ( (k == 0)) {return 0;} if ( (dp[x][y][k] != 0)) return dp[x][y][k]; int min = (int)MOD; for ( int[] mo :moves) { int X = (x + mo[0]),Y = (y + mo[1]); if ( ((((X < 0) || (X >= n)) || (Y < 0)) || (Y >= m))) continue; int val = 0; if ( (mo[0] == 1)) val = ver[x][y]; else if ( (mo[0] == -1)) val = ver[(x - 1)][y]; else if ( (mo[1] == 1)) val = hor[x][y]; else val = hor[x][(y - 1)]; min = Math.min(min,((2 * val) + solve(X,Y,(k - 2)))); }return dp[x][y][k] = min;} public static void main( String[] args)throws java.lang.Exception { int test = 1; while((test-- > 0)){n = sc.nextInt(); m = sc.nextInt(); int k = sc.nextInt(); if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) out.print((-1 + " ")); out.println(); }continue;} hor = new int[n][(m - 1)]; ver = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {hor[i][j] = sc.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ver[i][j] = sc.nextInt(); }}dp = new int[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((solve(i,j,k) + " ")); }out.println(); }}out.flush(); out.close(); } }
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(); } }
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]);} } }
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"); }} }
0	public class Test{ static int pos = 0; static int arr[] ; static LinkedList l1 = new LinkedList(); public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  long n = in.nextLong();  long count = 1;  long temp = (n / 2); temp += count; System.out.println(temp); } }
6	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();  int k = Int();  int A[][] = new int[n][2]; for ( int i = 0;(i < A.length);i++) {A[i][0] = Int(); A[i][1] = (Int() - 1); }Arrays.sort(A,(a,b)->{return (a[1] - b[1]);}); Solution sol = new Solution(out); sol.solution(A,k); }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; } int mod = 1000000007; long dp3[][][][] ; public void solution( int[][] A, int T){ long res = 0;  int n = A.length;  long dp1[][] = new long[(n + 1)][(T + 1)];  long dp2[][][] = new long[(n + 1)][(n + 1)][(T + 1)]; dp3 = new long[(n + 1)][(n + 1)][(n + 1)][3]; long f[] = new long[(n + 1)]; f[0] = f[1] = 1; for ( int i = 2;(i < f.length);i++) {f[i] = (f[(i - 1)] * i); f[i] %= mod; }for ( int i = 0;(i < dp3.length);i++) {for ( int j = 0;(j < dp3[0].length);j++) {for ( int k = 0;(k < dp3[0][0].length);k++) {Arrays.fill(dp3[i][j][k],-1); }}}dp1[0][0] = 1; for ( int i = 0;(i < A.length);i++) { int p = A[i][0],type = A[i][1]; if ( (type == 0)) { long newdp[][] = new long[dp1.length][dp1[0].length]; for ( int cnt = 1;(cnt <= n);cnt++) {for ( int j = 1;(j < dp1[0].length);j++) {if ( (j >= p)) {newdp[cnt][j] += dp1[(cnt - 1)][(j - p)]; newdp[cnt][j] %= mod; } }}for ( int cnt = 0;(cnt <= n);cnt++) {for ( int j = 0;(j < dp1[0].length);j++) {newdp[cnt][j] += dp1[cnt][j]; newdp[cnt][j] %= mod; }}dp1 = newdp; } else {break;}}dp2[0][0][0] = 1; for ( int i = 0;(i < A.length);i++) { int p = A[i][0],type = A[i][1]; if ( (type != 0)) { long newdp[][][] = new long[dp2.length][dp2[0].length][dp2[0][0].length]; for ( int a = 0;(a < dp2.length);a++) {for ( int b = 0;(b < dp2[0].length);b++) {for ( int j = 0;(j < dp2[0][0].length);j++) {if ( (j >= p)) {if ( (type == 1)) {if ( ((a - 1) >= 0)) {newdp[a][b][j] += dp2[(a - 1)][b][(j - p)]; } } else {if ( ((b - 1) >= 0)) {newdp[a][b][j] += dp2[a][(b - 1)][(j - p)]; } }} newdp[a][b][j] %= mod; }}}for ( int a = 0;(a < dp2.length);a++) {for ( int b = 0;(b < dp2[0].length);b++) {for ( int j = 0;(j < dp2[0][0].length);j++) {newdp[a][b][j] += dp2[a][b][j]; newdp[a][b][j] %= mod; }}}dp2 = newdp; } }dp3[1][0][0][0] = 1; dp3[0][1][0][1] = 1; dp3[0][0][1][2] = 1; dfs(n,n,n,0); dfs(n,n,n,1); dfs(n,n,n,2); for ( int i = 0;(i < dp3.length);i++) {for ( int j = 0;(j < dp3[0].length);j++) {for ( int k = 0;(k < dp3[0][0].length);k++) {for ( int cur = 0;(cur < 3);cur++) {for ( int t = 0;(t <= T);t++) { int aprice = t;  int bcprice = (T - t);  long cnt1 = dp1[i][aprice];  long cnt2 = dp2[j][k][bcprice];  long combination = dp3[i][j][k][cur];  long p1 = ((cnt1 * f[i]) % mod);  long p2 = ((((f[j] * f[k]) % mod) * cnt2) % mod);  long p3 = ((p1 * p2) % mod); res += ((p3 * combination) % mod); res %= mod; }}}}}out.println(res); } public long dfs( int a, int b, int c, int cur){ if ( (((a < 0) || (b < 0)) || (c < 0))) {return 0;} if ( (((a == 0) && (b == 0)) && (c == 0))) {return 0;} if ( (dp3[a][b][c][cur] != -1)) return dp3[a][b][c][cur]; long res = 0; if ( (cur == 0)) {res += dfs((a - 1),b,c,1); res %= mod; res += dfs((a - 1),b,c,2); res %= mod; } else if ( (cur == 1)) {res += dfs(a,(b - 1),c,0); res %= mod; res += dfs(a,(b - 1),c,2); res %= mod; } else {res += dfs(a,b,(c - 1),0); res %= mod; res += dfs(a,b,(c - 1),1); res %= mod; }res %= mod; dp3[a][b][c][cur] = res; return res;} }
6	public class b{ static int n ,k ,A ; static int[] l ,p ; static double[][][] memo ; public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextInt(); k = in.nextInt(); A = in.nextInt(); memo = new double[(n + 1)][(n + 1)][(1 << n)]; l = new int[n]; p = new int[n]; for ( int i = 0;(i < n);i++) {l[i] = in.nextInt(); p[i] = in.nextInt(); }System.out.printf("%.10f%n",go(0,k)); } static double go( int pos, int left){ if ( (pos == n)) {for ( int i = 0;(i <= n);i++) for ( int j = 0;(j <= n);j++) Arrays.fill(memo[i][j],-1); return go2(0,((n / 2) + 1),0);} double best = go((pos + 1),left); if ( (left == 0)) return best; if ( (p[pos] < 100)) {p[pos] += 10; best = Math.max(best,go(pos,(left - 1))); p[pos] -= 10; } return best;} static double go2( int pos, int needed, int mask){ if ( (needed == 0)) return 1.0; if ( (pos == n)) { int tot = 0; for ( int i = 0;(i < n);i++) if ( ((mask & (1 << i)) != 0)) tot += l[((n - i) - 1)]; return (A / ((A + tot) + 0.0));} if ( (memo[pos][needed][mask] != -1)) return memo[pos][needed][mask]; double a = ((p[pos] / 100.) * go2((pos + 1),(needed - 1),(mask * 2)));  double b = ((1 - (p[pos] / 100.)) * go2((pos + 1),needed,((mask * 2) + 1))); return memo[pos][needed][mask] = (a + b);} }
2	public class Main{ public static void main( String[] args){ setup(); xuly(); } static private long dp[][] = new long[20][170]; static private void setup(){ dp[0][0] = 1; for ( int i = 1;(i < 20);i++) for ( int j = 0;(j < 170);j++) for ( int k = Math.max((j - 9),0);(k <= j);k++) dp[i][j] += dp[(i - 1)][k]; } static private int sumD( long x){ int ret = 0; while((x > 0)){ret += (x % 10); x /= 10; }return ret;} static private long numSatisfy( long limit, int sumDigit){ long ret = 0;  int curSum = sumD(limit); if ( (curSum == sumDigit)) ret++; for ( int i = 0;(i < 20);i++) { int bound = (int)(limit % 10); curSum -= bound; for ( int d = 0;((d < bound) && ((curSum + d) <= sumDigit));d++) ret += dp[i][((sumDigit - curSum) - d)]; limit /= 10; }return ret;} static private void xuly(){ Scanner scanner = new Scanner(System.in);  long n = scanner.nextLong();  long s = scanner.nextLong();  long ans = 0; for ( int sum = 1;(sum < 170);sum++) if ( (n >= (s + sum))) ans += (numSatisfy(n,sum) - numSatisfy(((s + sum) - 1),sum)); System.out.print(ans); } }
2	public class B_574{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] input = br.readLine().split(" ");  int N = Integer.valueOf(input[0]);  int K = Integer.valueOf(input[1]);  long sum = 0; for ( int i = 0;(i < N);i++) {if ( ((sum - (N - i)) == K)) {System.out.println(Integer.valueOf((N - i))); return ;} sum += (i + 1); }System.out.println("0"); } }
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(); } }
5	public class Houses implements Runnable{ private void solve()throws IOException { int n = nextInt();  int t = nextInt();  int[] x = new int[n];  int[] a = new int[n]; for ( int i = 0;(i < n);++i) {x[i] = (nextInt() * 2); a[i] = nextInt(); } Set<Integer> res = new HashSet<Integer>(); for ( int i = 0;(i < n);++i) {if ( valid(n,t,x,a,((x[i] + a[i]) + t))) res.add(((x[i] + a[i]) + t)); if ( valid(n,t,x,a,((x[i] - a[i]) - t))) res.add(((x[i] - a[i]) - t)); }writer.println(res.size()); } private boolean valid( int n, int t, int[] x, int[] a, int pos){ for ( int i = 0;(i < n);++i) {if ( (Math.abs((pos - x[i])) < (a[i] + t))) return false; }return true;} public static void main( String[] args){ new Houses().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();} }
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(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
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(); } } }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long l = in.nextLong();  long r = in.nextLong(); if ( ((r - l) < 2)) System.out.println(-1); else {if ( ((l % 2) == 0)) System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); else {if ( ((r - l) < 3)) System.out.println(-1); else System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); }}} }
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());} } }
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();  Set<Pair> set = new HashSet<Pair>();  Pair prev = null; for ( int i = 0;(i < k);i++) { int x = in.nextInt();  int y = in.nextInt(); burned[(x - 1)][(y - 1)] = true; set.add(prev = new Pair((x - 1),(y - 1))); }while(!set.isEmpty()){ Set<Pair> tempset = new HashSet<>(); for ( Pair p :set) { 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])])) {tempset.add(new Pair((x + dx[i]),(y + dy[i]))); burned[(x + dx[i])][(y + dy[i])] = true; } }}set = tempset; }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();} } }
4	public class q3{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int tests = Integer.parseInt(br.readLine()); for ( int test = 1;(test <= tests);test++) { String[] parts = br.readLine().split(" ");  int n = Integer.parseInt(parts[0]);  StringBuilder temp = new StringBuilder();  int curr = Integer.parseInt(br.readLine()); temp.append("1"); System.out.println(1); for ( int i = 0;(i < (n - 1));i++) {curr = Integer.parseInt(br.readLine()); if ( (curr == 1)) {temp.append('.').append('1'); System.out.println(temp); } else {while((temp.length() > 0)){ int idx = (temp.length() - 1); while(((idx >= 0) && (temp.charAt(idx) != '.')))idx--; idx++; int val = Integer.parseInt(temp.substring(idx)); temp.delete(idx,temp.length()); if ( (curr == (val + 1))) {temp.append(String.valueOf(curr)); break;} temp.deleteCharAt((temp.length() - 1)); }System.out.println(temp); }}}} }
4	public class Main{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  int T = Integer.parseInt(br.readLine()); while((T-- > 0)){ int N = Integer.parseInt(br.readLine());  Stack<LN> nodes = new Stack<>();  int a0 = Integer.parseInt(br.readLine());  LN root = new LN(1,0,""); nodes.add(root); pw.println(root); for ( int i = 0;(i < (N - 1));i++) { int ai = Integer.parseInt(br.readLine()); while(!nodes.isEmpty()){ LN nn = nodes.pop(); if ( (ai == 1)) { LN e = new LN(1,(nn.depth + 1),nn.toString()); nodes.add(nn); nodes.add(e); pw.println(e); break;} else if ( (nn.lv == (ai - 1))) { LN e = new LN(ai,nn.depth,nn.base); nodes.add(e); pw.println(e); break;} }}}pw.flush(); } static class LN{ int lv ; int depth ; String base ; public LN( int lv, int depth, String prev){ this.lv = lv; this.depth = depth; base = prev; } @Override public String toString(){ StringBuilder bob = new StringBuilder(base); if ( (depth > 0)) {bob.append("."); } bob.append(lv); return bob.toString();} } }
4	public class C35{ public static void main( String[] args)throws IOException { Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter("output.txt");  int n = in.nextInt(),m = in.nextInt();  int k = in.nextInt();  int[] x = new int[k];  int[] y = new int[k];  int res = 0; for ( int i = 0;(i < k);i++) {x[i] = in.nextInt(); y[i] = in.nextInt(); } int xx = 1,yy = 1; for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= m);j++) { int cnt = Integer.MAX_VALUE; for ( int l = 0;(l < k);l++) { int time = (Math.abs((i - x[l])) + Math.abs((j - y[l]))); cnt = Math.min(cnt,time); }if ( (cnt > res)) {res = cnt; xx = i; yy = j; } res = Math.max(res,cnt); }out.print(((xx + " ") + yy)); out.close(); } }
6	public class C{ public static void main( String[] args){ new C(); } final int oo = (int)1e9; int Hx ,Hy ; int N ; int[][] P ; int[] memo ; int[][] soln ; int[] dist1 ; int[][] dist2 ; C(){ Scanner in = new Scanner(System.in); Hx = in.nextInt(); Hy = in.nextInt(); N = in.nextInt(); P = new int[N][2]; for ( int i = 0;(i < N);++i) {P[i][0] = in.nextInt(); P[i][1] = in.nextInt(); }memo = new int[(1 << N)]; Arrays.fill(memo,-1); soln = new int[2][(1 << N)]; dist1 = new int[N]; Arrays.fill(dist1,-1); dist2 = new int[N][N]; for ( int[] d :dist2) Arrays.fill(d,-1); int res = go(((1 << N) - 1)); System.out.println(res); int set = ((1 << N) - 1); while((set > 0)){System.out.print("0 "); System.out.print(((soln[0][set] + 1) + " ")); if ( (soln[1][set] > -1)) System.out.print(((soln[1][set] + 1) + " ")); if ( (soln[1][set] > -1)) {set -= ((1 << soln[0][set]) + (1 << soln[1][set])); } else {set -= (1 << soln[0][set]); }}System.out.println("0"); } int go( int set){ if ( (set == 0)) return 0; if ( (memo[set] > -1)) return memo[set]; int res = oo;  int i = 0; while(!on(set,i))++i; res = (dist(i) + go((set - (1 << i)))); soln[0][set] = i; soln[1][set] = -1; for ( int j = (i + 1);(j < N);++j) {if ( on(set,j)) { int tmp = (dist(i,j) + go(((set - (1 << i)) - (1 << j)))); if ( (tmp < res)) {res = tmp; soln[0][set] = i; soln[1][set] = j; } } }return memo[set] = res;} int dist( int i){ if ( (dist1[i] > -1)) return dist1[i]; int dx = (P[i][0] - Hx);  int dy = (P[i][1] - Hy); return dist1[i] = (2 * ((dx * dx) + (dy * dy)));} int dist( int i, int j){ if ( (dist2[i][j] > -1)) return dist2[i][j]; int res = 0,dx ,dy ; dx = (P[i][0] - Hx); dy = (P[i][1] - Hy); res += ((dx * dx) + (dy * dy)); dx = (P[i][0] - P[j][0]); dy = (P[i][1] - P[j][1]); res += ((dx * dx) + (dy * dy)); dx = (P[j][0] - Hx); dy = (P[j][1] - Hy); res += ((dx * dx) + (dy * dy)); return dist2[i][j] = res;} boolean on( int set, int loc){ return ((set & (1 << loc)) > 0);} }
0	public class ToyArmies{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong(); System.out.print(String.format("%d",(long)(n * 1.5))); } }
4	public class D{ static boolean isValid( int n, int m, int i, int j){ return ((((0 <= i) && (i < n)) && (0 <= j)) && (j < m));} public static void main( String[] args)throws IOException { Soumit sc = new Soumit();  int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  StringBuilder sb = new StringBuilder(); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {sb.append("-1 "); }sb.append("\n"); }System.out.println(sb); System.exit(0); } k /= 2; long[][] horizontaledge = new long[n][(m - 1)];  long[][] verticaledge = new long[(n - 1)][m]; for ( int i = 0;(i < n);i++) horizontaledge[i] = sc.nextLongArray((m - 1)); for ( int i = 0;(i < (n - 1));i++) verticaledge[i] = sc.nextLongArray(m); long[][][] dp = new long[11][n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dp[0][i][j] = 0; }}for ( int i = 1;(i <= k);i++) {for ( int j1 = 0;(j1 < n);j1++) {for ( int j2 = 0;(j2 < m);j2++) { long min = (Long.MAX_VALUE / 2000); if ( isValid(n,m,(j1 - 1),j2)) {min = Math.min((dp[(i - 1)][(j1 - 1)][j2] + verticaledge[(j1 - 1)][j2]),min); } if ( isValid(n,m,(j1 + 1),j2)) {min = Math.min(min,(dp[(i - 1)][(j1 + 1)][j2] + verticaledge[j1][j2])); } if ( isValid(n,m,j1,(j2 - 1))) {min = Math.min(min,(dp[(i - 1)][j1][(j2 - 1)] + horizontaledge[j1][(j2 - 1)])); } if ( isValid(n,m,j1,(j2 + 1))) {min = Math.min(min,(dp[(i - 1)][j1][(j2 + 1)] + horizontaledge[j1][j2])); } dp[i][j1][j2] = min; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {sb.append((dp[k][i][j] * 2)).append(" "); }sb.append("\n"); }System.out.println(sb); sc.close(); } static class Soumit{ private final int BUFFER_SIZE = (1 << 18); private final DataInputStream din ; private final byte[] buffer ; private PrintWriter pw ; private int bufferPointer ,bytesRead ; StringTokenizer st ; public Soumit(){ din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Soumit( String file_name)throws IOException{ din = new DataInputStream(new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public void println( String a){ pw.println(a); } public void print( String a){ pw.print(a); } public String readLine()throws IOException { byte[] buf = new byte[3000064];  int cnt = 0,c ; while(((c = read()) != -1)){if ( (c == '\n')) break; buf[cnt++] = (byte)c; }return new String(buf,0,cnt);} public void sort( int[] arr){ ArrayList<Integer> arlist = new ArrayList<>(); for ( int i :arr) arlist.add(i); Collections.sort(arlist); for ( int i = 0;(i < arr.length);i++) arr[i] = arlist.get(i); } public void sort( long[] arr){ ArrayList<Long> arlist = new ArrayList<>(); for ( long i :arr) arlist.add(i); Collections.sort(arlist); for ( int i = 0;(i < arr.length);i++) arr[i] = arlist.get(i); } public long[] nextLongArray( int n)throws IOException { long[] arr = new long[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextLong(); }return arr;} 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)) din.close(); if ( (pw != null)) pw.close(); } } }
1	public class Main{ static Reader scan ; static PrintWriter pw ; static int n ,k ,left[] ,right[] ,arr[] ; static long MOD = 1000000007,count[] ,dp[] ; public static void main( String[] args){ new Thread(null,null,"BaZ",(1 << 25)){}.start(); } static void solve()throws IOException { scan = new Reader(); pw = new PrintWriter(System.out,true); StringBuilder sb = new StringBuilder(); n = ni(); k = ni(); int stack[] = new int[1000001];  int top = -1; arr = new int[n]; left = new int[n]; right = new int[n]; for ( int i = 0;(i < n);++i) {arr[i] = ni(); while(((top >= 0) && (arr[stack[top]] <= arr[i])))top--; if ( (top == -1)) left[i] = 0; else left[i] = (stack[top] + 1); stack[++top] = i; }top = -1; for ( int i = (n - 1);(i >= 0);--i) {while(((top >= 0) && (arr[stack[top]] < arr[i])))top--; if ( (top == -1)) right[i] = (n - 1); else right[i] = (stack[top] - 1); stack[++top] = i; }dp = new long[(n + 1)]; for ( int i = 0;(i <= n);++i) {if ( (i < k)) continue; dp[i] = (dp[((i - k) + 1)] + ((i - k) + 1)); }count = new long[n]; long ans = 0; for ( int i = 0;(i < n);++i) { int len = ((right[i] - left[i]) + 1);  int lef = (i - left[i]);  int rig = (right[i] - i);  long count = ((dp[len] - dp[lef]) - dp[rig]); if ( (count >= MOD)) count %= MOD; ans += (count * arr[i]); if ( (ans >= MOD)) ans %= MOD; }pl(ans); pw.flush(); pw.close(); } static int ni()throws IOException { return scan.nextInt();} static void pl(){ pw.println(); } static void p( Object o){ pw.print((o + " ")); } static void pl( Object o){ pw.println(o); } 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;} 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(); } } }
0	public class ChessKing{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long size = input.nextLong();  long a = input.nextLong();  long b = input.nextLong();  long sum = (a + b);  long d = (sum - 2);  long d1 = ((size * 2) - sum); if ( (d < d1)) System.out.println("White"); else if ( (d > d1)) System.out.println("Black"); else System.out.println("White"); } }
1	public class Round364C{ public static void main( String[] args)throws NumberFormatException,IOException { Scanner sc = new Scanner(System.in); n = sc.nextInt(); k = 0; String line = sc.nextLine();  ArrayList<Character> poks = new ArrayList<Character>();  boolean ex[] = new boolean[256]; for ( int i = 0;(i < n);i++) {if ( !ex[line.charAt(i)]) {ex[line.charAt(i)] = true; poks.add(line.charAt(i)); } } int l = 0;  int r = 0;  int dist = 1;  int occ[] = new int[256]; occ[line.charAt(0)] = 1; int min = n; while((r < n)){if ( (dist == poks.size())) min = Math.min(min,((r - l) + 1)); if ( ((l < r) && (dist == poks.size()))) {occ[line.charAt(l)]--; if ( (occ[line.charAt(l)] == 0)) dist--; l++; continue;} if ( (r < (n - 1))) {occ[line.charAt((r + 1))]++; if ( (occ[line.charAt((r + 1))] == 1)) dist++; } r++; }System.out.println(min); } static int n ,k ; static int dp[][][] ; static class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner( FileReader f){ br = new BufferedReader(f); } public boolean ready()throws IOException { return br.ready();} Scanner( 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();} String nextLine()throws IOException { return br.readLine();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} } }
2	public class CFEdu23C{ static long sum( long n){ long ans = 0; while((n > 0)){ans += (n % 10); n /= 10; }return ans;} static long BS( long l, long h, long s){ if ( (l <= h)) { long m = ((l + h) / 2l); if ( (((m - sum(m)) >= s) && ((m == 1) || (((m - 1) - sum((m - 1))) < s)))) return m; else if ( ((m - sum(m)) >= s)) return BS(l,(m - 1),s); else return BS((m + 1),h,s);} return (h + 1);} 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(),s = in.nextLong();  long x = BS(0,n,s); out.print(((n - x) + 1)); out.close(); } public static final long l = (int)(1e9 + 7); 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());} public int nextInt(){ return Integer.parseInt(next());} } }
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();} }
2	public class LittleGirlAndXor{ static long L ,R ; static Long[][][][][] dp = new Long[64][2][2][2][2]; public static long go( int index, int low1, int high1, int low2, int high2){ if ( (index == -1)) {return 0;} if ( (dp[index][low1][high1][low2][high2] != null)) return dp[index][low1][high1][low2][high2]; int bit1 = (((L & (1L << index)) == 0)?0:1);  int bit2 = (((R & (1L << index)) == 0)?0:1);  long res = 0; for ( int i = 0;(i < 2);i++) {for ( int j = 0;(j < 2);j++) { int nl1 = low1,nh1 = high1,nl2 = low2,nh2 = high2;  boolean can = true; if ( (low1 == 0)) {if ( (i == bit1)) {nl1 = 0; } else if ( (i < bit1)) {can = false; } else if ( (i > bit1)) {nl1 = 1; } } if ( (high1 == 0)) {if ( (i == bit2)) {nh1 = 0; } else if ( (i < bit2)) {nh1 = 1; } else if ( (i > bit2)) {can = false; } } if ( (low2 == 0)) {if ( (j == bit1)) {nl2 = 0; } else if ( (j < bit1)) {can = false; } else if ( (j > bit1)) {nl2 = 1; } } if ( (high2 == 0)) {if ( (j == bit2)) {nh2 = 0; } else if ( (j < bit2)) {nh2 = 1; } else if ( (j > bit2)) {can = false; } } if ( can) { long xor = (i ^ j); res = Math.max(res,((xor << index) + go((index - 1),nl1,nh1,nl2,nh2))); } }}return dp[index][low1][high1][low2][high2] = res;} public static void main( String[] args){ InputReader r = new InputReader(System.in); L = r.nextLong(); R = r.nextLong(); System.out.println(go(63,0,0,0,0)); } 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());} } }
2	public class A1177{ public static long exponential( long a, long b){ long result = 1; for ( int i = 0;(i < b);i++) {result *= a; }return result;} public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long k = scanner.nextLong();  long sum = 0;  long i = 1; while(true){ long interval = ((9 * exponential(10,(i - 1))) * i); if ( ((sum + interval) >= k)) {break;} else {i++; sum += interval; }} long t = (k - sum);  long targetNumber = (exponential(10,(i - 1)) + ((t - 1) / i));  String s = ("" + targetNumber);  int hedef = (int)((t - 1) % i); System.out.println(s.charAt(hedef)); } }
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());} } }
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();} } }
2	public class B{ static FastReader scan ; static PrintWriter out ; public static void main( String[] args)throws FileNotFoundException { Solver solver = new Solver(); scan = new FastReader(); out = new PrintWriter(System.out); int testCases = 1; for ( int i = 1;(i <= testCases);i++) {solver.solve(); }out.close(); } static class Solver{ void solve(){ long n = scan.nextLong(),k = scan.nextLong();  long low = 0,high = n; while(true){ long mid = ((low + high) / 2);  long s = sum((n - mid)); if ( ((s - mid) == k)) {out.println(mid); return ;} else if ( ((s - mid) < k)) {high = (mid - 1); } else low = (mid + 1); }} static long sum( long a){ if ( (a == 0)) return 0; return (((a + 1) * a) / 2);} } 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());} long nextLong(){ return Long.parseLong(next());} double nextDouble(){ return Double.parseDouble(next());} } }
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"); }} }
2	public class Main{ static class Reader{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ,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 s(){ 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 long l(){ 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 i(){ 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));} } public static long check( long mid, long x, long y, long n){ long ans = ((((2 * mid) * mid) + (2 * mid)) + 1);  long uleft = Math.max(0,((mid - x) + 1));  long dleft = Math.max(0,(mid - (n - x)));  long lleft = Math.max(0,((mid - y) + 1));  long rleft = Math.max(0,(mid - (n - y))); ans -= ((((uleft * uleft) + (dleft * dleft)) + (lleft * lleft)) + (rleft * rleft)); ans += ((Math.max(0,(mid - ((x + y) - 1))) * (Math.max(0,(mid - ((x + y) - 1))) + 1)) / 2); ans += ((Math.max(0,(mid - ((x + n) - y))) * (Math.max(0,(mid - ((x + n) - y))) + 1)) / 2); ans += ((Math.max(0,(mid - ((y + n) - x))) * (Math.max(0,(mid - ((y + n) - x))) + 1)) / 2); ans += ((Math.max(0,(mid - ((((n - x) + n) - y) + 1))) * (Math.max(0,(mid - ((((n - x) + n) - y) + 1))) + 1)) / 2); return ans;} public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out);  Reader sc = new Reader();  long n = sc.l();  long x = sc.l();  long y = sc.l();  long c = sc.l();  long low = 0;  long high = (long)Math.pow(10,9); while((low < high)){ long mid = ((low + high) / 2); if ( (check(mid,x,y,n) >= c)) high = mid; else low = (mid + 1); }out.println(low); out.flush(); } }
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); }
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 centerCount = (mat?1:0); for ( int i = 0;(i < N);i++) {if ( (i != center)) {if ( mat[i][center]) {centerCount++; } if ( mat[center][i]) {centerCount++; } } mat[i][center] = false; mat[center][i] = false; } int other = (M - centerCount);  int matches = bipartiteMatching(mat); return ((((((((2 * N) - 1) - centerCount) + 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 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();} } }
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));} } }
6	public class G1{ static final int mod = (int)(1e9 + 7); static final int UNCALC = -1; static int[][][] memo ; static int n ,t[] ,genre[] ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out); n = sc.nextInt(); t = new int[n]; int T = sc.nextInt(); genre = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = sc.nextInt(); genre[i] = sc.nextInt(); }memo = new int[4][(1 << n)][(T + 1)]; for ( int[][] a :memo) for ( int[] b :a) Arrays.fill(b,UNCALC); out.println(dp(0,0,T)); out.flush(); out.close(); } static int dp( int last, int mask, int rem){ if ( (rem == 0)) return 1; if ( (memo[last][mask][rem] != UNCALC)) return memo[last][mask][rem]; int cnt = 0; for ( int i = 0;(i < n);i++) {if ( (((genre[i] == last) || (t[i] > rem)) || ((mask & (1 << i)) != 0))) continue; cnt = ((cnt + dp(genre[i],(mask | (1 << i)),(rem - t[i]))) % mod); }return memo[last][mask][rem] = cnt;} 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 int nextInt()throws IOException { return Integer.parseInt(next());} public double nextDouble()throws IOException { return Double.parseDouble(next());} public Long nextLong()throws IOException { return Long.parseLong(next());} public boolean ready()throws IOException { return br.ready();} } }
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)); } }
3	public class Codechef{ 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); ArrayList<Integer> al = new ArrayList();  int k = a[0];  int count = 0; for ( int j = 0;(j < n);j++) {k = a[j]; if ( (Collections.frequency(al,a[j]) == 0)) {for ( int i = 0;(i < n);i++) {if ( ((a[i] % k) == 0)) {al.add(a[i]); } }count++; } }System.out.println(count); } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } static class TaskD{ static int n ; static int m ; static int steps ; static long[][] distJ ; static long[][] distI ; static long[][][] memo ; public void solve( int testNumber, InputReader in, OutputWriter out){ n = in.nextInt(); m = in.nextInt(); steps = in.nextInt(); memo = new long[n][m][steps]; distJ = new long[n][(m - 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {distJ[i][j] = in.nextLong(); }}distI = new long[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {distI[i][j] = in.nextLong(); }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( ((steps % 2) != 0)) {out.print((-1 + " ")); } else {out.print(((2 * lowestCost(i,j,(steps / 2))) + " ")); }}out.println(); }} private long lowestCost( int i, int j, int distance){ if ( (distance == 0)) {return 0;} if ( (memo[i][j][distance] > 0)) {return memo[i][j][distance];} long minDist = Long.MAX_VALUE; if ( (j < (m - 1))) {minDist = Math.min(minDist,(distJ[i][j] + lowestCost(i,(j + 1),(distance - 1)))); } if ( (j > 0)) {minDist = Math.min(minDist,(distJ[i][(j - 1)] + lowestCost(i,(j - 1),(distance - 1)))); } if ( (i < (n - 1))) {minDist = Math.min(minDist,(distI[i][j] + lowestCost((i + 1),j,(distance - 1)))); } if ( (i > 0)) {minDist = Math.min(minDist,(distI[(i - 1)][j] + lowestCost((i - 1),j,(distance - 1)))); } memo[i][j][distance] = minDist; return minDist;} } 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(); } } 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 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 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{ 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(); } }
0	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();} long nextLong(){ return Long.parseLong(next());} } static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} public static void main( String[] args)throws IOException { FastReader fr = new FastReader();  long n = fr.nextLong();  long x = fr.nextLong();  long y = fr.nextLong();  long w = (((Long.min(x,y) - 1) + (x - Long.min(x,y))) + (y - Long.min(x,y)));  long b = (((n - Long.max(x,y)) + (Long.max(x,y) - x)) + (Long.max(x,y) - y)); if ( (w <= b)) System.out.println("White"); else System.out.println("Black"); } }
0	public class Rules implements Runnable{ private Scanner in = new Scanner(System.in); private PrintWriter out = new PrintWriter(System.out); private double a ,v ,l ,d ,w ; private double ans ; public static void main( String[] args){ new Thread(new Rules()).start(); } private void read(){ a = in.nextInt(); v = in.nextInt(); l = in.nextInt(); d = in.nextInt(); w = in.nextInt(); } private double remaining( double v0, double dst){ double t = ((v - v0) / a);  double d = ((((a * t) * t) / 2) + (t * v0)); if ( (d > dst)) return ((Math.sqrt(((v0 * v0) + ((2 * a) * dst))) - v0) / a); return (t + ((dst - d) / v));} private void solve(){ if ( (((w * w) >= ((2 * a) * d)) || (w >= v))) {ans = remaining(0,l); return ;} { double t1 = (v / a);  double t2 = ((v - w) / a);  double dd = (((((a * t1) * t1) / 2) + (((a * t2) * t2) / 2)) + (w * t2)); if ( (dd < d)) {ans = (((t1 + t2) + ((d - dd) / v)) + remaining(w,(l - d))); return ;} } double t1 = (w / a);  double rd = (d - (((t1 * t1) * a) / 2));  double t2 = ((Math.sqrt(((w * w) + (a * rd))) - w) / a); ans = ((t1 + (2 * t2)) + remaining(w,(l - d))); } private void write(){ out.printf("%.7f\n",ans); } }
1	public class Dialog1{ static private int n ; static private String s ; static private char[] a ; public static void main( String[] args){ Scanner input = new Scanner(System.in); n = input.nextInt(); s = input.next(); a = s.toCharArray(); for ( int i = 0;(i < 200);++i) { int cur = i;  boolean fl = true; for ( int j = 0;(j < n);++j) {if ( (a[j] == '+')) ++cur; else --cur; if ( (cur < 0)) fl = false; }if ( fl) {System.out.print(cur); return ;} }} }
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));} }
1	public class B implements Runnable{ void Solution()throws IOException { int n = nextInt(),k = nextInt();  int[] mas = new int[n]; for ( int i = 0;(i < n);i++) mas[i] = nextInt(); int l = 0,r = 0;  HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); map.put(mas[l],1); int cur = 1; while(true){if ( (cur == k)) {print((l + 1),(r + 1)); return ;} r++; if ( (r >= n)) break; int kol = (map.containsKey(mas[r])?map.remove(mas[r]):0); if ( (kol == 0)) {cur++; map.put(mas[r],1); } else map.put(mas[r],(kol + 1)); while(true){kol = map.remove(mas[l]); if ( (kol == 1)) {map.put(mas[l],1); break;} else map.put(mas[l++],(kol - 1)); }}print(-1,-1); } public static void main( String[] args){ new B().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer tokenizer ; public void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); Solution(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(0); } } void print( Object... obj){ for ( int i = 0;(i < obj.length);i++) {if ( (i != 0)) out.print(" "); out.print(obj[i]); }} void println( Object... obj){ print(obj); out.println(); } String nextLine()throws IOException { return in.readLine();} String next()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(nextLine()); return tokenizer.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} }
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"); } }
0	public class Main{ public static void main( String[] args){ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); try{ String[] str = reader.readLine().split(" ");  BigInteger b1 = new BigInteger(str[0]);  BigInteger b2 = new BigInteger(str[1]); if ( (b2.subtract(b1).compareTo(new BigInteger("1")) < 1)) {System.out.println(-1); return ;} if ( (b2.subtract(b1).compareTo(new BigInteger("2")) == 0)) { BigInteger b = b1.add(new BigInteger("1"));  BigInteger c = b1.add(new BigInteger("2")); if ( !b1.gcd(c).equals(new BigInteger("1"))) {System.out.println(((((b1.toString() + " ") + b.toString()) + " ") + c.toString())); } else {System.out.println(-1); }return ;} BigInteger b = b1.add(new BigInteger("1"));  BigInteger c = b1.add(new BigInteger("2"));  BigInteger d = b1.add(new BigInteger("3")); if ( b1.remainder(new BigInteger("2")).equals(new BigInteger("1"))) {System.out.println(((((b.toString() + " ") + c.toString()) + " ") + d.toString())); } else {System.out.println(((((b1.toString() + " ") + b.toString()) + " ") + c.toString())); } }catch (IOException e){ e.printStackTrace(); } } }
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[][][] ; static private 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;} }
3	public class Main{ static final int MAXN = 1005; static final long MOD = 1_000_000_007; static final boolean DEBUG = false; static int n ,m ; static long stlr[][] = new long[MAXN][MAXN],bell[] = new long[MAXN],occ[] ; static PrintStream cerr = System.err; public static void main( String[] args){ Readin(); stlr[0][0] = bell[0] = 1; for ( int i = 1;(i <= m);i++) for ( int j = 1;(j <= i);j++) {stlr[i][j] = ((stlr[(i - 1)][(j - 1)] + (stlr[(i - 1)][j] * (long)j)) % MOD); bell[i] = ((bell[i] + stlr[i][j]) % MOD); }if ( DEBUG) for ( int i = 1;(i <= m);i++) cerr.println(((("Bell[" + i) + "] =") + bell[i])); Arrays.sort(occ); if ( DEBUG) {cerr.println("After Sorting"); for ( int i = 0;(i < m);i++) cerr.println((occ[i] + " ")); } long ans = 1; for ( int i = 0,j = 0;(i < m);i = j) {for ( j = (i + 1);((j < m) && (occ[i] == occ[j]));j++) ;ans = ((ans * bell[(j - i)]) % MOD); }System.out.println(ans); } static void Readin(){ Scanner cin ; if ( !DEBUG) cin = new Scanner(System.in); else {try{cin = new Scanner(new File("input.txt")); }catch (FileNotFoundException e){ if ( DEBUG) cerr.println("Not Fount input.txt"); return ;} }m = cin.nextInt(); n = cin.nextInt(); occ = new long[m]; for ( int i = 0;(i < n);i++) { String s = cin.next(); for ( int j = 0;(j < m);j++) occ[j] |= ((long)(s.charAt(j) - '0') << i); }cin.close(); } }
1	public class b{ public static void main( String[] args){ FS in = new FS(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  Integer[] arr = new Integer[n];  int numZ = 0; for ( int i = 0;(i < n);i++) {arr[i] = in.nextInt(); if ( (arr[i] == 0)) numZ++; }Arrays.sort(arr); if ( (numZ > 1)) {System.out.println("cslnb"); return ;} int numDup = 0;  int[] arr2 = new int[n]; for ( int i = 0;(i < n);i++) {arr2[i] = arr[i]; if ( (i != 0)) {if ( (arr2[i] == arr2[(i - 1)])) {arr2[(i - 1)]--; numDup++; } } }if ( (numDup > 1)) {System.out.println("cslnb"); return ;} for ( int i = 0;(i < n);i++) {if ( (i != 0)) {if ( (arr2[i] == arr2[(i - 1)])) {System.out.println("cslnb"); return ;} } } long num = 0; if ( (numDup == 1)) num++; for ( int i = 0;(i < n);i++) {num += (arr2[i] - i); }if ( ((num % 2) == 0)) {System.out.println("cslnb"); } else {System.out.println("sjfnb"); }out.close(); } static class FS{ BufferedReader in ; StringTokenizer token ; public FS( InputStream str){ in = new BufferedReader(new InputStreamReader(str)); } public String next(){ if ( ((token == null) || !token.hasMoreElements())) {try{token = new StringTokenizer(in.readLine()); }catch (IOException ex){ } return next();} return token.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
2	public class E implements Runnable{ public static void main( String[] args){ new Thread(null,new E(),"_cf",(1 << 28)).start(); } long oo = (long)2e18; long getVal( int n){ if ( (n > 31)) return oo; long last = 0,cur = 0; for ( int i = 1;(i <= n);i++) {cur = (1 + (4 * last)); last = cur; }return cur;} 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)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);} } }
5	public class Solution{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),k = in.nextInt();  int x[] = new int[n]; for ( int i = 0;(i < n);i++) { int p = in.nextInt(),t = in.nextInt(); x[i] = (((50 - p) * 100) + t); }Arrays.sort(x); int cnt = 0; for ( int q :x) if ( (q == x[(k - 1)])) cnt++; System.out.println(cnt); } }
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{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] p = new int[n]; for ( int i = 0;(i < n);++i) p[i] = in.nextInt(); Map<Integer,Integer> position = new HashMap<>(n); for ( int i = 0;(i < n);++i) position.put(p[i],i); DisjointSet sets = new DisjointSet(n); for ( int i = 0;(i < n);++i) {if ( position.containsKey((a - p[i]))) sets.joinSet(i,position.get((a - p[i]))); if ( position.containsKey((b - p[i]))) sets.joinSet(i,position.get((b - p[i]))); } Group[] groups = new Group[n]; for ( int i = 0;(i < n);++i) if ( (sets.getSet(i) == i)) groups[i] = new Group(); for ( int i = 0;(i < n);++i) groups[sets.getSet(i)].value.add(p[i]); int[] answer = new int[n]; for ( Group group :groups) if ( (group != null)) {if ( group.check(a)) {for ( int key :group.value) answer[position.get(key)] = 0; } else if ( group.check(b)) {for ( int key :group.value) answer[position.get(key)] = 1; } else {out.println("NO"); return ;}} out.println("YES"); for ( int i = 0;(i < n);++i) {if ( (i > 0)) out.print(' '); out.print(answer[i]); }out.println(); } class Group{ Set<Integer> value = new HashSet<>(); boolean check( int sum){ for ( int key :value) if ( !value.contains((sum - key))) return false; return true;} } } class InputReader{ private BufferedReader reader ; private 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());} } class DisjointSet{ private final int[] label ; private int numSets ; private Listener listener ; public DisjointSet( int n, Listener listener){ label = new int[n]; Arrays.fill(label,-1); numSets = n; this.listener = listener; } public DisjointSet( int n){ this(n,null); } public int getSet( int at){ if ( (label[at] < 0)) return at; return label[at] = getSet(label[at]);} public boolean sameSet( int u, int v){ return (getSet(u) == getSet(v));} public boolean joinSet( int u, int v){ if ( sameSet(u,v)) return false; u = getSet(u); v = getSet(v); if ( (label[u] < label[v])) { int tmp = u; u = v; v = tmp; } label[v] += label[u]; label[u] = v; --numSets; if ( (listener != null)) listener.joined(u,v); return true;} static public interface Listener{ public void joined( int joinedRoot, int root); } }
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); } } }
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); } }
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(); } }
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; }} }
2	public class BDigitSequence{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long k = scan.nextLong();  long digits = 1;  long counter = 9L; while((k > (counter * digits))){k -= (counter * digits); counter *= 10; digits++; } long num = (long)Math.ceil(((double)k / digits));  String s = String.valueOf((((long)Math.pow(10,(digits - 1)) - 1) + num)); System.out.println(s.charAt((int)(((k + digits) - 1) % digits))); } }
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();} } }
0	public class Task235A{ public static void main( String... args)throws NumberFormatException,IOException { Solution.main(System.in,System.out); } static class Scanner{ private final BufferedReader br ; private String[] cache ; private int cacheIndex ; Scanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); cache = new String[0]; cacheIndex = 0; } int nextInt()throws IOException { if ( (cacheIndex >= cache.length)) {cache = br.readLine().split(" "); cacheIndex = 0; } return Integer.parseInt(cache[cacheIndex++]);} void close()throws IOException { br.close(); } } static class Solution{ public static void main( InputStream is, OutputStream os)throws NumberFormatException,IOException { PrintWriter pw = new PrintWriter(os);  Scanner sc = new Scanner(is);  long n = sc.nextInt(); if ( (n < 3)) {pw.println(n); } else {if ( ((n % 2) != 0)) {pw.println(((n * (n - 1)) * (n - 2))); } else {if ( ((n % 3) != 0)) {pw.println(((n * (n - 1)) * (n - 3))); } else { long cand1 = (((n * (n - 1)) * (n - 2)) / 2);  long cand2 = (((n - 1) * (n - 2)) * (n - 3)); pw.println(Math.max(cand1,cand2)); }}}pw.flush(); sc.close(); } } }
2	public class Main3{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  long l = s.nextLong();  long r = s.nextLong();  String a = Long.toBinaryString(l);  String b = Long.toBinaryString(r); while((a.length() < b.length()))a = ("0" + a); while((b.length() < a.length()))b = ("0" + b); String ans = "";  int ix = -1; for ( int i = 0;(i < a.length());i++) {if ( (a.charAt(i) != b.charAt(i))) {break;} ans += a.charAt(i); ix++; }for ( int i = (ix + 1);(i < a.length());i++) { int c1 = (a.charAt(i) - '0');  int c2 = (b.charAt(i) - '0'); if ( ((c1 == 0) && (c2 == 0))) ans += "1"; else if ( ((c1 == 1) && (c2 == 1))) ans += "0"; else ans += (char)(c1 + '0'); } long a1 = Long.parseLong(ans,2);  long a2 = Long.parseLong(b,2);  long xor = (a1 ^ a2); System.out.println(xor); } }
6	public class E{ public static void main( String[] args){ FastScanner scanner = new FastScanner();  PrintWriter out = new PrintWriter(System.out,false);  int t = scanner.nextInt(); while((t-- > 0)){ int n = scanner.nextInt();  int m = scanner.nextInt();  Col[] cols = new Col[m];  int[][] mat = new int[m][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {mat[j][i] = scanner.nextInt(); }}for ( int i = 0;(i < m);i++) {cols[i] = new Col(mat[i]); }Arrays.sort(cols); int maxMask = (1 << n);  int[] dp = new int[maxMask]; Arrays.fill(dp,-1); dp[0] = 0; int sz = Math.min(n,m);  int[][] ss = new int[sz][maxMask]; for ( int i = 0;(i < sz);i++) { int[] curArr = cols[i].arr.clone(); for ( int j = 0;(j < n);j++) {for ( int mask = 0;(mask < maxMask);mask++) { int cur = 0; for ( int k = 0;(k < n);k++) if ( (((1 << k) & mask) > 0)) cur += curArr[k]; ss[i][mask] = Math.max(ss[i][mask],cur); }curArr = shift(curArr); }}for ( int i = 0;(i < Math.min(n,m));i++) {for ( int mask = (maxMask - 1);(mask >= 0);mask--) {for ( int smask = mask;(smask >= 0);smask = ((smask - 1) & mask)) {if ( (dp[smask] == -1)) continue; dp[mask] = Math.max(dp[mask],(dp[smask] + ss[i][(mask ^ smask)])); if ( (smask == 0)) break; }}}out.println(dp[(maxMask - 1)]); }out.flush(); } static int[] shift( int[] a){ int[] b = new int[a.length]; b[0] = a[(a.length - 1)]; for ( int i = 0;(i < (a.length - 1));i++) {b[(i + 1)] = a[i]; }return b;} static class Col implements Comparable<Col>{ int[] arr ; int[] sorted ; public Col( int[] a){ arr = a; sorted = arr.clone(); Arrays.sort(sorted); } } 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 CF159DIV2{ FastScanner 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); for ( int i = 0;(i < (a.length / 2));i++) { int tmp = a[i]; a[i] = a[((n - i) - 1)]; a[((n - i) - 1)] = tmp; } int need = m;  int have = k;  int ans = 0;  int it = 0; while((have < need)){have += (a[it++] - 1); ans++; if ( (it >= n)) break; }if ( (have >= need)) {out.println(ans); } else {out.println(-1); }} void runIO(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } class FastScanner{ BufferedReader br ; 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)); } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] args){ new CF159DIV2().runIO(); } }
3	public class ques1{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int b = sc.nextInt();  ArrayList<Integer> ar = new ArrayList<>(); for ( int i = 0;(i < b);i++) {ar.add(sc.nextInt()); }Collections.sort(ar); int count = 0;  int i = 0; while((ar.size() != 0)){ int tmep = ar.get(i);  int v = ar.remove(i); count++; int j = 0; while((j < ar.size())){if ( ((ar.get(j) % tmep) == 0)) { int a = ar.remove(j); } else j++; }}System.out.println(count); } }
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 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);} }
6	public class Main{ public static BufferedReader in ; public static PrintWriter out ; public static void main( String[] args)throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); boolean showLineError = true; if ( showLineError) {solve(); out.close(); } else {try{solve(); }catch (Exception e){ } finally{out.close(); }}} static private void solve()throws IOException { String[] line = nss();  int n = Integer.parseInt(line[0]);  int m = Integer.parseInt(line[1]);  boolean[][] matrix = new boolean[n][n]; for ( int i = 0;(i < m);i++) {line = nss(); int u = (Integer.parseInt(line[0]) - 1);  int v = (Integer.parseInt(line[1]) - 1); matrix[u][v] = matrix[v][u] = true; } long[][] dp = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) dp[(1 << i)][i] = 1; long ret = 0; for ( int mask = 0;(mask < (1 << n));mask++) {for ( int last = 0;(last < n);last++) if ( ((mask & (1 << last)) != 0)) { int first = -1; for ( first = 0;(first < n);first++) if ( ((mask & (1 << first)) != 0)) break; for ( int add = first;(add < n);add++) if ( (((mask & (1 << add)) == 0) && matrix[last][add])) dp[(mask + (1 << add))][add] += dp[mask][last]; if ( ((Long.bitCount(mask) > 2) && matrix[first][last])) ret += dp[mask][last]; } }out.println((ret / 2L)); } static private String[] nss()throws IOException { return in.readLine().split(" ");} }
2	public class C{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = Long.parseLong(in.next());  long s = Long.parseLong(in.next()); if ( !check(n,s)) {System.out.println(0); } else { long min = 1;  long max = n; while((min != max)){ long mid = ((min + max) / 2); if ( check(mid,s)) {max = mid; } else {min = (mid + 1); }}System.out.println(((n - min) + 1)); }} public static boolean check( long x, long s){ if ( ((x - sumd(x)) < s)) {return false;} else {return true;}} public static long sumd( long x){ long sum = 0; while((x != 0)){sum += (x % 10); x /= 10; }return sum;} }
0	public class Main{ static private void solve()throws IOException { long n = nextLong(); out.println(25); } public static void main( String[] args)throws Exception { File file = new File("System.in");  InputStream input = System.in;  PrintStream output = System.out; if ( (file.exists() && file.canRead())) {input = new FileInputStream(file); output = new PrintStream("System.out"); } br = new BufferedReader(new InputStreamReader(input)); out = new PrintWriter(output); solve(); out.close(); } static private BufferedReader br ; static private StringTokenizer st ; static private PrintWriter out ; static private boolean hasNextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String line = br.readLine(); if ( (line == null)) {return false;} st = new StringTokenizer(line); }return true;} static private String nextToken()throws IOException { return (hasNextToken()?st.nextToken():null);} static private long nextLong()throws IOException { return Long.parseLong(nextToken());} }
6	public class C{ public static void main( String[] args){ new C(new Scanner(System.in)); } vect[] vs ; int N ; int oo = 987654321; ArrayList<choice> cs ; choice[][] cg ; int MF ; int[] memo ; int[] next ; int go( int m){ if ( (m == MF)) return 0; if ( (memo[m] != -1)) return memo[m]; int res = oo;  int nxt = -1;  int i = 0; for ( i = 0;(i < N);i++) {if ( (((1 << i) & m) == 0)) break; }for ( int j = 0;(j < N);j++) { choice cc = cg[i][j]; if ( ((m & cc.m) > 0)) continue; int r2 = (cc.cost + go((m | cc.m))); if ( (r2 < res)) {res = r2; nxt = cc.index; } }memo[m] = res; next[m] = nxt; return res;} public C( Scanner in){ vect vt = new vect(in.nextInt(),in.nextInt()); N = in.nextInt(); vs = new vect[(N + 1)]; vs[N] = vt; for ( int i = 0;(i < N);i++) vs[i] = new vect(in.nextInt(),in.nextInt()); cs = new ArrayList<choice>(); cg = new choice[N][N]; for ( int i = 0;(i < N);i++) { choice cc = new choice(cs.size(),(2 * vs[i].dist(vt)),(1 << i)); cc.add(i); cs.add(cc); cg[i][i] = cc; }for ( int i = 0;(i < N);i++) {for ( int j = (i + 1);(j < N);j++) { int dist = vs[i].dist(vt); dist += vs[i].dist(vs[j]); dist += vs[j].dist(vt); choice cc = new choice(cs.size(),dist,((1 << i) | (1 << j))); cc.add(i); cc.add(j); cs.add(cc); cg[i][j] = cc; cg[j][i] = cc; }}MF = ((1 << N) - 1); next = new int[(MF + 1)]; memo = new int[(MF + 1)]; Arrays.fill(next,-1); Arrays.fill(memo,-1); int res = go(0); System.out.println(res); int m = 0;  StringBuilder sb = new StringBuilder(); while((m != -1)){sb.append(0); sb.append(' '); int i = next[m]; if ( (i == -1)) break; choice cc = cs.get(i); for ( int j :cc.iv) {sb.append(f(j)); sb.append(' '); }m = (m | cc.m); }System.out.println(sb.toString().trim()); } int f( int i){ if ( (i == N)) return 0; return (i + 1);} } class choice{ int cost ; int m ; int index ; ArrayList<Integer> iv ; public choice( int ii, int c, int mm){ index = ii; cost = c; m = mm; iv = new ArrayList<Integer>(2); } void add( int i){ iv.add(i); } } class vect{ int x ,y ; public vect( int i, int j){ x = i; y = j; } int dist( vect rhs){ int xx = (x - rhs.x);  int yy = (y - rhs.y); return ((xx * xx) + (yy * yy));} }
6	public class LookingForOrder{ static int n ; static int[] x ,y ,memo ; static StringBuilder sb ; static int distance( int i, int j){ int dx = (x[i] - x[j]);  int dy = (y[i] - y[j]); return ((dx * dx) + (dy * dy));} public static int dp( int msk){ if ( (msk == ((1 << (n + 1)) - 2))) return 0; if ( (memo[msk] != -1)) return memo[msk]; int ans = 10000000;  boolean found = false; for ( int i = 1;((i <= n) && !found);i++) for ( int j = i;((j <= n) && ((msk & (1 << i)) == 0));j++) if ( ((msk & (1 << j)) == 0)) {found = true; int newM = (msk | (1 << i)); newM |= (1 << j); ans = Math.min(ans,(dp(newM) + Math.min(((distance(0,i) + distance(i,j)) + distance(j,0)),((distance(0,j) + distance(j,i)) + distance(i,0))))); } return memo[msk] = ans;} public static void print( int msk){ if ( (msk == ((1 << (n + 1)) - 2))) return ; for ( int i = 1;(i <= n);i++) for ( int j = i;((j <= n) && ((msk & (1 << i)) == 0));j++) if ( ((msk & (1 << j)) == 0)) { int newM = (msk | (1 << i)); newM |= (1 << j); int d1 = ((distance(0,i) + distance(i,j)) + distance(j,0));  int d2 = ((distance(0,j) + distance(j,i)) + distance(i,0)); if ( (dp(msk) == (dp(newM) + Math.min(d1,d2)))) {if ( (i == j)) sb.append((("0 " + i) + " ")); else if ( (d1 < d2)) sb.append((((("0 " + i) + " ") + j) + " ")); else sb.append((((("0 " + j) + " ") + i) + " ")); print(newM); return ;} } } public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int xS = sc.nextInt(),yS = sc.nextInt(); n = sc.nextInt(); x = new int[(n + 1)]; y = new int[(n + 1)]; x[0] = xS; y[0] = yS; for ( int i = 1;(i <= n);i++) {x[i] = sc.nextInt(); y[i] = sc.nextInt(); }memo = new int[(1 << (n + 1))]; Arrays.fill(memo,-1); sb = new StringBuilder(); sb.append((dp(0) + "\n")); print(0); sb.append("0"); System.out.println(sb); } static class Scanner{ BufferedReader br ; StringTokenizer st ; 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();} } }
1	public class Main{ static private StreamTokenizer in ; static private PrintWriter out ; static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws Exception { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); int n = nextInt();  byte f = (byte)nextInt();  byte s = (byte)nextInt();  byte t = (byte)nextInt();  boolean bf = false;  boolean bs = false;  boolean bt = false; if ( ((f & 1) == 0)) {bf = true; } if ( ((s & 1) == 0)) {bs = true; } if ( ((t & 1) == 0)) {bt = true; } if ( ((bf && bs) && bt)) {System.out.println(1); return ;} if ( ((bf && bs) && bt)) {System.out.println(2); return ;} if ( ((bf && bs) && bt)) {System.out.println(3); return ;} if ( ((bf && !bs) && !bt)) {System.out.println(1); return ;} if ( ((!bf && bs) && !bt)) {System.out.println(2); return ;} if ( ((!bf && !bs) && bt)) {System.out.println(3); return ;} for ( int i = 4;(i <= n);i++) { byte g = (byte)nextInt(); if ( (((g + f) & 1) == 1)) {System.out.println(i); return ;} }out.flush(); } }
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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ 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 a = in.nextInt();  int b = in.nextInt();  int[] is = in.nextIntArray(n);  Map<Integer,Integer> id = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {id.put(is[i],i); } SCC.V[] vs = new SCC.V[(n * 2)]; for ( int i = 0;(i < vs.length);i++) vs[i] = new SCC.V(); for ( int i = 0;(i < n);i++) {if ( id.containsKey((a - is[i]))) { int j = id.get((a - is[i])); vs[i].add(vs[j]); vs[(j + n)].add(vs[(i + n)]); } else {vs[i].add(vs[(i + n)]); }if ( id.containsKey((b - is[i]))) { int j = id.get((b - is[i])); vs[(i + n)].add(vs[(j + n)]); vs[j].add(vs[i]); } else {vs[(i + n)].add(vs[i]); }}SCC.scc(vs); for ( int i = 0;(i < n);i++) {if ( (vs[i].comp == vs[(i + n)].comp)) {out.println("NO"); return ;} }out.println("YES"); for ( int i = 0;(i < n);i++) {if ( (vs[i].comp > vs[(i + n)].comp)) {out.print("0 "); } else {out.print("1 "); }}out.println(); } } 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());} public int[] nextIntArray( int n){ int[] is = new int[n]; for ( int i = 0;(i < n);i++) {is[i] = nextInt(); }return is;} }
2	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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ int n ; MyInput in ; PrintWriter out ; public void solve( int testNumber, MyInput in, PrintWriter out){ this.in = in; this.out = out; n = in.nextInt(); if ( (((n / 2) % 2) == 1)) {answer(-1); return ;} int low = 0,high = (n / 2);  int diff = (query((low + (n / 2))) - query(low)); while((diff != 0)){ int mid = ((low + high) / 2);  int d = (query((mid + (n / 2))) - query(mid)); if ( ((d == 0) || ((diff > 0) == (d > 0)))) {diff = d; low = mid; } else {high = mid; }}answer(low); } int query( int i){ out.println(("? " + ((i % n) + 1))); out.flush(); return in.nextInt();} void answer( int i){ out.println(("! " + ((i < 0)?i:((i % n) + 1)))); } } static class MyInput{ private final BufferedReader in ; static private int pos ; static private int readLen ; static private final char[] buffer = new char[(1024 * 8)]; static private char[] str = new char[((500 * 8) * 2)]; static private boolean[] isDigit = new boolean[256]; static private boolean[] isSpace = new boolean[256]; static private 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 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;} } }
3	public class code_1{ public static void main( String[] args){ 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(); Arrays.sort(a); for ( int i = 0;(i < (n - 1));i++) {if ( (a[i] != -1)) {for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) a[j] = -1; }} } int count = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != -1)) count++; }System.out.println(count); } }
4	public class Main1{ static int dr[] = {0,0,1,-1}; static int dc[] = {1,-1,0,0}; static boolean isValid( int r, int c){ if ( ((((r >= n) || (r < 0)) || (c >= m)) || (c < 0))) return false; return true;} static int grid[][] ; static int n ,m ; public static void main( String[] args)throws IOException { FastReader input = new FastReader();  PrintWriter out = new PrintWriter("output.txt"); n = input.nextInt(); m = input.nextInt(); grid = new int[n][m]; int k = input.nextInt(); for ( int i = 0;(i < n);i++) {Arrays.fill(grid[i],Integer.MAX_VALUE); } Queue<Pair> q = new LinkedList<Pair>(); for ( int i = 0;(i < k);i++) { int x = (input.nextInt() - 1);  int y = (input.nextInt() - 1); q.add(new Pair(x,y)); grid[x][y] = 0; while(!q.isEmpty()){ Pair cur = q.poll(); for ( int j = 0;(j < dr.length);j++) { int r = cur.x;  int c = cur.y;  int nr = (r + dr[j]);  int nc = (c + dc[j]);  int dist = (grid[r][c] + 1); if ( (isValid(nr,nc) && (grid[nr][nc] > dist))) {grid[nr][nc] = dist; q.add(new Pair(nr,nc)); } }}} int max = -1;  int x = -1;  int y = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (grid[i][j] > max)) {max = grid[i][j]; x = (i + 1); y = (j + 1); } }}out.println(((x + " ") + y)); out.flush(); } static class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader()throws FileNotFoundException{ br = new BufferedReader(new FileReader(new File("input.txt"))); } String next()throws IOException { while(((st == null) || !st.hasMoreElements())){st = new StringTokenizer(br.readLine()); }return st.nextToken();} int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} } static class Pair implements Comparable<Pair>{ int x ; int y ; Pair( int x, int y){ this.x = x; this.y = y; } } static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} }
0	public class ProblemA{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long[] answer = new long[3]; if ( (n == 1)) {answer[0] = 0; answer[1] = 0; answer[2] = 1; } else if ( (n > 1)) { long f1 = 0;  long f2 = 1;  long m = 0; while((m < n)){answer[0] = answer[1]; answer[1] = f1; answer[2] = f2; m = (f1 + f2); f1 = f2; f2 = m; }answer[2] = answer[1]; } System.out.println(((((answer[0] + " ") + answer[1]) + " ") + answer[2])); } }
1	public class Iq{ static void metod()throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] m = new int[n]; for ( int i = 0;(i < n);i++) m[i] = in.nextInt(); byte k = 0; if ( ((m[0] % 2) == 0)) {if ( ((m[1] % 2) == 0)) {k = 0; } else {if ( ((m[2] % 2) == 0)) {System.out.println(2); return ;} else {System.out.println(1); return ;}}} else {if ( ((m[1] % 2) == 1)) {k = 1; } else {if ( ((m[2] % 2) == 0)) {System.out.println(1); return ;} else {System.out.println(2); return ;}}}if ( (k == 0)) {for ( int i = 0;(i < m.length);i++) {if ( ((m[i] % 2) == 1)) {System.out.println((i + 1)); break;} }} else {for ( int i = 0;(i < m.length);i++) {if ( ((m[i] % 2) == 0)) {System.out.println((i + 1)); break;} }}} public static void main( String[] args)throws Exception { Iq.metod(); } }
3	public class AG1{ public static void main( String[] Args){ FastReader scan = new FastReader();  int n = scan.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = scan.nextInt(); }Arrays.sort(arr); boolean[] done = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( !done[i]) {done[i] = true; ans++; for ( int j = (i + 1);(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) {done[j] = true; } }} }System.out.println(ans); } 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());} } }
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());} } }
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());} } }
6	public class CF008C{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int x = s.nextInt();  int y = s.nextInt();  int n = s.nextInt();  int[] xx = new int[(n + 1)];  int[] yy = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {xx[i] = s.nextInt(); yy[i] = s.nextInt(); }xx[n] = x; yy[n] = y; int[][] dp = 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]); dp[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 = (dp[a][n] + dp[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 = ((dp[a][n] + dp[b][n]) + dp[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); } }
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; } } }
0	public class D{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  double a = in.nextDouble();  double v = in.nextDouble();  double l = in.nextDouble();  double d = in.nextDouble();  double w = in.nextDouble();  double ans = 0;  double maxSpeedBySign = Math.sqrt(((2 * a) * d));  double speedAtSign = -1; if ( (v <= w)) {if ( (maxSpeedBySign <= v)) {ans += Math.sqrt(((2 * d) / a)); speedAtSign = maxSpeedBySign; } else {ans += (v / a); double distanceLeftTillSign = (d - (((v * v) / a) / 2)); ans += (distanceLeftTillSign / v); speedAtSign = v; }} else {if ( (maxSpeedBySign <= w)) {ans += Math.sqrt(((2 * d) / a)); speedAtSign = maxSpeedBySign; } else { double S = ((d / 2) - (((w * w) / 4) / a));  double X = (d - S);  double speed = Math.sqrt(((2 * a) * X)); if ( (speed <= v)) {ans += Math.sqrt(((2 * X) / a)); ans += ((speed - w) / a); speedAtSign = w; } else { double distanceToAc = (((v * v) / a) / 2);  double distanceToDe = ((((v * v) - (w * w)) / a) / 2); ans += Math.sqrt(((2 * distanceToAc) / a)); ans += (((d - distanceToAc) - distanceToDe) / v); ans += ((v - w) / a); }speedAtSign = w; }}l -= d; double timeToGetMaxSpeed = ((v - speedAtSign) / a);  double timeToReachEnd = ((((-2 * speedAtSign) + Math.sqrt((((4 * speedAtSign) * speedAtSign) + ((8 * a) * l)))) / 2) / a); if ( (timeToGetMaxSpeed < timeToReachEnd)) {ans += timeToGetMaxSpeed; double distanceCoveredToMaxSpeed = ((speedAtSign * timeToGetMaxSpeed) + (((0.5 * a) * timeToGetMaxSpeed) * timeToGetMaxSpeed)); l -= distanceCoveredToMaxSpeed; ans += (l / v); } else {ans += timeToReachEnd; }System.out.println(ans); } }
2	public class TestClass implements Runnable{ public static void main( String[] args){ new Thread(null,new TestClass(),"TESTCLASS",(1 << 18)).start(); } public long get( long a){ String str = Long.toString(a);  int ans = 0; for ( char ch :str.toCharArray()) ans += (ch - '0'); return ans;} 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); } } }
2	public class Main{ PrintWriter out = new PrintWriter(System.out,false); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer stok = null; String next(){ while(((stok == null) || !stok.hasMoreTokens()))try{stok = new StringTokenizer(in.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} return stok.nextToken();} public static void main( String[] args)throws IOException { if ( (args.length > 0)) {setIn(new FileInputStream((args[0] + ".inp"))); setOut(new PrintStream((args[0] + ".out"))); } Main solver = new Main(); solver.out.flush(); } long n = parseLong(next()),k = parseLong(next()); long delta = (9 + (8 * (n + k))); long a = ((-3 + (long)sqrt(delta)) / 2); long b = (n - a); {out.println(b); }}
6	public class Main{ private FastScanner in ; private PrintWriter out ; public void solve()throws IOException { int N = in.nextInt();  int M = in.nextInt();  int[][] edges = new int[N][N]; for ( int i = 0;(i < M);i++) { int a = (in.nextInt() - 1);  int b = (in.nextInt() - 1); edges[a][b] = 1; edges[b][a] = 1; } int globalCountMasks = (1 << N);  int[][] masks = new int[(N + 1)][];  int[] countMasks = new int[(N + 1)]; for ( int i = 0;(i <= N);i++) {masks[i] = new int[combinations(N,i)]; }for ( int i = 0;(i < globalCountMasks);i++) { int c = countBit1(i); masks[c][countMasks[c]] = i; countMasks[c]++; } long globalCountCycles = 0;  long[][] count = new long[globalCountMasks][N]; for ( int a = 0;(a < (N - 2));a++) { int aBit = (1 << a); count[aBit][a] = 1; long countCycles = 0; for ( int i = 2;(i <= N);i++) {for ( int m = 0;(m < countMasks[i]);m++) { int mask = masks[i][m]; if ( ((mask & aBit) == 0)) continue; if ( ((mask & (aBit - 1)) > 0)) continue; count[mask][a] = 0; for ( int v = (a + 1);(v < N);v++) { int vBit = (1 << v); if ( ((mask & vBit) == 0)) continue; count[mask][v] = 0; for ( int t = a;(t < N);t++) {if ( ((((mask & (1 << t)) == 0) || (t == v)) || (edges[v][t] == 0))) continue; count[mask][v] += count[(mask ^ vBit)][t]; }if ( ((edges[a][v] == 1) && (mask != (aBit | vBit)))) {countCycles += count[mask][v]; } }}}globalCountCycles += (countCycles / 2); }out.println(globalCountCycles); } private int countBit1( int k){ int c = 0; while((k > 0)){c += (k & 1); k >>= 1; }return c;} private int combinations( int n, int k){ if ( ((k > n) || (k < 0))) {throw (new IllegalArgumentException());} int r = 1; for ( int i = 1;(i <= k);i++) {r = ((r * ((n + 1) - i)) / i); }return r;} public void run(){ try{in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } 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 Main().run(); } }
3	public class USACO{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(reader.readLine());  StringTokenizer st = new StringTokenizer(reader.readLine()," ");  int[] perm = new int[n];  int count = 0; for ( int i = 0;(i < n);i++) {perm[i] = Integer.parseInt(st.nextToken()); for ( int j = 0;(j < i);j++) {if ( (perm[j] > perm[i])) {count++; } }}count = (count % 2); int m = Integer.parseInt(reader.readLine()); for ( int i = 0;(i < m);i++) { StringTokenizer st2 = new StringTokenizer(reader.readLine()," ");  int a = Integer.parseInt(st2.nextToken());  int b = Integer.parseInt(st2.nextToken()); if ( (((((b - a) + 1) % 4) == 2) || ((((b - a) + 1) % 4) == 3))) {count++; count = (count % 2); } if ( ((count % 2) == 0)) {System.out.println("even"); } else {System.out.println("odd"); }}} }
0	public class Soldiers{ public static void main( String[] args)throws IOException { new Soldiers().run(); } void run()throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); int n = nextInt(); pw.println((3 * (n / 2))); pw.close(); } BufferedReader br ; StringTokenizer st ; PrintWriter pw ; 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());} }
1	public class B{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int t = Integer.parseInt(br.readLine()); while((t-- > 0)){ String[] s1 = br.readLine().split(" ");  int n = Integer.parseInt(s1[0]);  int x = 1;  boolean ans = true; while(((n % 2) == 0)){x *= 2; n /= 2; }if ( (x == 1)) ans = false;  int z = (int)Math.sqrt(n); if ( ((z * z) != n)) ans = false; if ( ans) System.out.println("YES"); else System.out.println("NO"); }} }
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 ; } }
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] + " ")); } }
4	public class C{ Scanner in ; PrintWriter out ; String INPUT = ""; void solve(){ 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 max = -1;  int maxi = -1;  int maxj = -1; 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((x[l] - i)) + Math.abs((y[l] - j)))); }if ( (min > max)) {max = min; maxi = i; maxj = j; } }}out.println((((maxi + 1) + " ") + (maxj + 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());} }
4	public class Main{ public static void main( String[] args)throws Exception { Thread thread = new Thread(null,new TaskAdapter(),"",(1 << 29)); thread.start(); thread.join(); } static class TaskAdapter implements Runnable{ } static class EPhoenixAndComputers{ public void solve( int testNumber, FastInput in, FastOutput out){ int n = in.ri();  int mod = in.ri();  CachedPow2 cp = new CachedPow2(2,mod,(n + 1),(mod - 1));  Combination comb = new Combination((n + 1),mod);  long[][][] dp = new long[(n + 1)][(n + 1)][2]; dp[0][0][0] = 1; for ( int i = 1;(i <= n);i++) {for ( int j = 0;(j <= n);j++) {dp[i][j][0] = dp[(i - 1)][j][1]; for ( int k = 0;(k < i);k++) { int len = (i - k);  int last = (j - len); if ( (last >= 0)) {dp[i][j][1] += ((((dp[k][last][0] * cp.pow((len - 1))) % mod) * comb.combination(j,len)) % mod); } }dp[i][j][1] %= mod; }} long ans = 0; for ( int i = 0;(i <= n);i++) {ans += dp[n][i][1]; }ans %= mod; out.println(ans); } } static class FastOutput implements AutoCloseable,Closeable,Appendable{ static private final int THRESHOLD = (32 << 10); private final Writer os ; private StringBuilder cache = new StringBuilder((THRESHOLD * 2)); public FastOutput append( CharSequence csq){ cache.append(csq); return this;} public FastOutput append( CharSequence csq, int start, int end){ cache.append(csq,start,end); return this;} private void afterWrite(){ if ( (cache.length() < THRESHOLD)) {return ;} flush(); } public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput append( char c){ cache.append(c); afterWrite(); return this;} public FastOutput append( long c){ cache.append(c); afterWrite(); return this;} public FastOutput println( long c){ return append(c).println();} public FastOutput println(){ return append('\n');} 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();} } static interface IntegerEntryIterator{ boolean hasNext(); void next(); int getEntryKey(); int getEntryValue(); } 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 ri(){ return readInt();} public int readInt(){ boolean rev = false; skipBlank(); if ( ((next == '+') || (next == '-'))) {rev = (next == '-'); next = read(); } int val = 0; while(((next >= '0') && (next <= '9'))){val = (((val * 10) - next) + '0'); next = read(); }return (rev?val:-val);} } static class Hasher{ private long time = (System.nanoTime() + (System.currentTimeMillis() * 31L)); public int shuffle( long z){ z += time; z = ((z ^ (z >>> 33)) * 0x62a9d9ed799705f5L); return (int)(((z ^ (z >>> 28)) * 0xcb24d0a5c88c35b3L) >>> 32);} public int hash( int x){ return shuffle(x);} } static interface IntCombination{ } static class MultiplicativeFunctionSieve{ static MultiplicativeFunctionSieve instance = new MultiplicativeFunctionSieve((1 << 16)); public int[] primes ; public boolean[] isComp ; public int primeLength ; public int[] smallestPrimeFactor ; public int[] expOfSmallestPrimeFactor ; int limit ; public static MultiplicativeFunctionSieve getInstance( int n){ if ( (n <= (1 << 16))) {return instance;} return new MultiplicativeFunctionSieve(n);} public int[] getEuler(){ int[] euler = new int[(limit + 1)]; euler[1] = 1; for ( int i = 2;(i <= limit);i++) {if ( !isComp[i]) {euler[i] = (i - 1); } else {if ( (expOfSmallestPrimeFactor[i] == i)) {euler[i] = (i - (i / smallestPrimeFactor[i])); } else {euler[i] = (euler[expOfSmallestPrimeFactor[i]] * euler[(i / expOfSmallestPrimeFactor[i])]); }}}return euler;} public MultiplicativeFunctionSieve( int limit){ this.limit = limit; isComp = new boolean[(limit + 1)]; primes = new int[(limit + 1)]; expOfSmallestPrimeFactor = new int[(limit + 1)]; smallestPrimeFactor = new int[(limit + 1)]; primeLength = 0; for ( int i = 2;(i <= limit);i++) {if ( !isComp[i]) {primes[primeLength++] = i; expOfSmallestPrimeFactor[i] = smallestPrimeFactor[i] = i; } for ( int j = 0,until = (limit / i);((j < primeLength) && (primes[j] <= until));j++) { int pi = (primes[j] * i); smallestPrimeFactor[pi] = primes[j]; expOfSmallestPrimeFactor[pi] = ((smallestPrimeFactor[i] == primes[j])?(expOfSmallestPrimeFactor[i] * expOfSmallestPrimeFactor[primes[j]]):expOfSmallestPrimeFactor[primes[j]]); isComp[pi] = true; if ( ((i % primes[j]) == 0)) {break;} }}} } static class Factorial{ int[] fact ; int[] inv ; int mod ; public int getMod(){ return mod;} public Factorial( int[] fact, int[] inv, int mod){ this.mod = mod; this.fact = fact; this.inv = inv; fact[0] = inv[0] = 1; int n = Math.min(fact.length,mod); for ( int i = 1;(i < n);i++) {fact[i] = i; fact[i] = (int)(((long)fact[i] * fact[(i - 1)]) % mod); }if ( ((n - 1) >= 0)) {inv[(n - 1)] = BigInteger.valueOf(fact[(n - 1)]).modInverse(BigInteger.valueOf(mod)).intValue(); } for ( int i = (n - 2);(i >= 1);i--) {inv[i] = (int)(((long)inv[(i + 1)] * (i + 1)) % mod); }} public Factorial( int limit, int mod){ this(new int[Math.min((limit + 1),mod)],new int[Math.min((limit + 1),mod)],mod); } public int fact( int n){ if ( (n >= mod)) {return 0;} return fact[n];} public int invFact( int n){ if ( (n >= mod)) {throw (new IllegalArgumentException());} return inv[n];} } static class CachedPow2{ private int[] first ; private int[] second ; private int mod ; private int low ; private int mask ; private int phi ; private int xphi ; public CachedPow2( int x, int mod){ this(x,mod,CachedEulerFunction.get(mod)); } public CachedPow2( int x, int mod, int phi){ this(x,mod,mod,phi); } public CachedPow2( int x, int mod, int limit, int phi){ this.phi = phi; limit = Math.min(limit,mod); this.mod = mod; int log = Log2.ceilLog((limit + 1)); low = ((log + 1) / 2); mask = ((1 << low) - 1); first = new int[(1 << low)]; second = new int[(1 << (log - low))]; first[0] = 1; for ( int i = 1;(i < first.length);i++) {first[i] = (int)(((long)x * first[(i - 1)]) % mod); }second[0] = 1; long step = (((long)x * first[(first.length - 1)]) % mod); for ( int i = 1;(i < second.length);i++) {second[i] = (int)((second[(i - 1)] * step) % mod); }xphi = DigitUtils.modPow(x,phi,mod); } public int pow( int exp){ return (int)(((long)first[(exp & mask)] * second[(exp >> low)]) % mod);} } static class Combination implements IntCombination{ final Factorial factorial ; int modVal ; public Combination( Factorial factorial){ this.factorial = factorial; this.modVal = factorial.getMod(); } public Combination( int limit, int mod){ this(new Factorial(limit,mod)); } public int combination( int m, int n){ if ( ((n > m) || (n < 0))) {return 0;} return (int)(((((long)factorial.fact(m) * factorial.invFact(n)) % modVal) * factorial.invFact((m - n))) % modVal);} } static class IntegerHashMap{ private int now ; private int[] slot ; private int[] version ; private int[] next ; private int[] keys ; private int[] values ; private int alloc ; private boolean[] removed ; private int mask ; private int size ; private boolean rehash ; private Hasher hasher = new Hasher(); public IntegerHashMap( int cap, boolean rehash){ now = 1; this.mask = ((1 << (32 - Integer.numberOfLeadingZeros((cap - 1)))) - 1); slot = new int[(mask + 1)]; version = new int[slot.length]; next = new int[(cap + 1)]; keys = new int[(cap + 1)]; values = new int[(cap + 1)]; removed = new boolean[(cap + 1)]; this.rehash = rehash; } private void doubleCapacity(){ int newSize = Math.max((next.length + 10),(next.length * 2)); next = Arrays.copyOf(next,newSize); keys = Arrays.copyOf(keys,newSize); values = Arrays.copyOf(values,newSize); removed = Arrays.copyOf(removed,newSize); } public void alloc(){ alloc++; if ( (alloc >= next.length)) {doubleCapacity(); } next[alloc] = 0; removed[alloc] = false; size++; } private void rehash(){ int[] newSlots = new int[Math.max(16,(slot.length * 2))];  int[] newVersions = new int[newSlots.length];  int newMask = (newSlots.length - 1); for ( int i = 0;(i < slot.length);i++) {access(i); if ( (slot[i] == 0)) {continue;} int head = slot[i]; while((head != 0)){ int n = next[head];  int s = (hash(keys[head]) & newMask); next[head] = newSlots[s]; newSlots[s] = head; head = n; }}this.slot = newSlots; this.version = newVersions; now = 0; this.mask = newMask; } private int hash( int x){ return hasher.hash(x);} public void put( int x, int y){ put(x,y,true); } public void put( int x, int y, boolean cover){ int h = hash(x);  int s = (h & mask); access(s); if ( (slot[s] == 0)) {alloc(); slot[s] = alloc; keys[alloc] = x; values[alloc] = y; } else { int index = findIndexOrLastEntry(s,x); if ( (keys[index] != x)) {alloc(); next[index] = alloc; keys[alloc] = x; values[alloc] = y; } else if ( cover) {values[index] = y; } }if ( (rehash && (size >= slot.length))) {rehash(); } } public int getOrDefault( int x, int def){ int h = hash(x);  int s = (h & mask); access(s); if ( (slot[s] == 0)) {return def;} int index = findIndexOrLastEntry(s,x); return ((keys[index] == x)?values[index]:def);} private int findIndexOrLastEntry( int s, int x){ int iter = slot[s]; while((keys[iter] != x)){if ( (next[iter] != 0)) {iter = next[iter]; } else {return iter;}}return iter;} private void access( int i){ if ( (version[i] != now)) {version[i] = now; slot[i] = 0; } } public IntegerEntryIterator iterator(){ return new IntegerEntryIterator(){ int index = 1; int readIndex = -1; public boolean hasNext(){ while(((index <= alloc) && removed[index])){index++; }return (index <= alloc);} public int getEntryKey(){ return keys[readIndex];} public int getEntryValue(){ return values[readIndex];} public void next(){ if ( !hasNext()) {throw (new IllegalStateException());} readIndex = index; index++; } };} public String toString(){ IntegerEntryIterator iterator = iterator();  StringBuilder builder = new StringBuilder("{"); while(iterator.hasNext()){iterator.next(); builder.append(iterator.getEntryKey()).append("->").append(iterator.getEntryValue()).append(','); }if ( (builder.charAt((builder.length() - 1)) == ',')) {builder.setLength((builder.length() - 1)); } builder.append('}'); return builder.toString();} } }
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); } }
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());} } }
4	public class C{ public static void main( String[] args)throws Exception { final int fuck = 2001;  Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = in.nextInt(),m = in.nextInt();  int[] D = new int[(fuck * fuck)],Q = new int[(fuck * (fuck + 1))],dx = new int[]{1,-1,0,0},dy = new int[]{0,0,-1,1}; Arrays.fill(D,-1); int H = -1,T = 0;  int k = in.nextInt(),ans = 0; for ( int i = 0;(i < k);++i) { int x = in.nextInt(),y = in.nextInt(); D[((x * fuck) + y)] = 0; ++H; H %= Q.length; ans = Q[H] = ((x * fuck) + y); }while((H >= T)){ int idx = Q[T++]; T %= Q.length; int x = (idx / fuck),y = (idx % fuck); for ( int i = 0;(i < 4);++i) { int wtf = (((dx[i] + x) * fuck) + (dy[i] + y)); if ( ((((((dx[i] + x) <= n) && ((dx[i] + x) >= 1)) && ((dy[i] + y) <= m)) && ((dy[i] + y) >= 1)) && (D[wtf] == -1))) {D[wtf] = (D[idx] + 1); ++H; H %= Q.length; Q[H] = wtf; if ( (D[wtf] >= D[ans])) ans = wtf; } }}out.println((((ans / fuck) + " ") + (ans % fuck))); out.close(); in.close(); } }
4	public class Main{ public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static long MOD = (long)(1e9 + 7); static long MOD2 = (MOD * MOD); static FastReader sc = new FastReader(); static int pInf = Integer.MAX_VALUE; static int nInf = Integer.MIN_VALUE; static long ded = ((long)1e17 + 9); public static void main( String[] args)throws Exception { int test = 1; for ( int i = 1;(i <= test);i++) {solve(); }out.flush(); out.close(); } static int n ,m ; static int[][] hor ,ver ; static Long[][][] dp ; static void solve(){ n = sc.nextInt(); m = sc.nextInt(); int k = sc.nextInt(); dp = new Long[(n + 1)][(m + 1)][(k + 1)]; hor = new int[n][(m - 1)]; ver = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {hor[i][j] = sc.nextInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ver[i][j] = sc.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 = (k / 2); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { long[] dp = new long[(k + 1)]; for ( int l = 1;(l <= k);l++) {dp[l] = cal(i,j,l); }for ( int l = 1;(l <= k);l++) {for ( int g = 1;(g < l);g++) {dp[l] = Math.min(dp[l],(dp[g] + dp[(l - g)])); }}out.print(((2 * dp[k]) + " ")); }out.println(); }} static long cal( int i, int j, int k){ if ( (k == 0)) return 0; if ( (dp[i][j][k] != null)) return dp[i][j][k]; long ans = ded; for ( int h = 0;(h < 4);h++) { int ni = (i + di[h]);  int nj = (j + dj[h]); if ( e(ni,nj)) { int cost = 0; if ( (ni == i)) {if ( (nj > j)) {cost = hor[i][j]; } else {cost = hor[i][nj]; }} if ( (nj == j)) {if ( (ni > i)) {cost = ver[i][j]; } else {cost = ver[ni][j]; }} ans = Math.min(ans,(cost)+cal(ni,nj,(k - 1))); } }return dp[i][j][k] = ans;} static int[] di = new int[]{0,-1,0,1}; static int[] dj = new int[]{-1,0,1,0}; static boolean e( int i, int j){ return ((((i >= 0) && (j >= 0)) && (i < n)) && (j < m));} public static long mul( long a, long b){ return (((a % MOD) * (b % MOD)) % MOD);} static final Random random = new Random(); static long countSetBits( long n){ if ( (n == 0)) return 0; return (1 + countSetBits((n & (n - 1))));} static long gcd( long A, long B){ if ( (B == 0)) return A; return gcd(B,(A % B));} static long fastExpo( long x, long n){ if ( (n == 0)) return 1; if ( ((n & 1) == 0)) return (fastExpo(((x * x) % MOD),(n / 2)) % MOD); return (((x % MOD) * fastExpo(((x * x) % MOD),((n - 1) / 2))) % MOD);} public static long modpow( long a, long b){ if ( (b == 0)) {return 1;} long x = modpow(a,(b / 2)); x = ((x * x) % MOD); if ( ((b % 2) == 1)) {return ((x * a) % MOD);} return x;} 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 Twins{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] val = new int[n]; for ( int i = 0;(i < n);i++) val[i] = in.nextInt(); Arrays.sort(val); int sum = 0,count = 0; for ( int i = (n - 1);(i >= 0);i--) {count++; sum += val[i]; int his = 0; for ( int j = 0;(j < i);j++) his += val[j]; if ( (his < sum)) break; }System.out.println(count); } }
0	public class Main{ public static void main( String[] args)throws FileNotFoundException { Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt(); if ( ((n % 2) == 0)) {System.out.println(((4 + " ") + (n - 4))); } else {System.out.println(((9 + " ") + (n - 9))); }in.close(); out.close(); } }
3	public class A{ FastScanner in ; PrintWriter out ; void solve(){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }Arrays.sort(a); int res = 0; for ( int i = 0;(i < n);i++) { boolean ok = false; for ( int j = 0;(j < i);j++) {if ( ((a[i] % a[j]) == 0)) {ok = true; } }if ( !ok) {res++; } }out.println(res); } void runIO(){ in = new FastScanner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } class FastScanner{ BufferedReader br ; 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)); } String next(){ 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();} boolean hasMoreTokens(){ while(((st == null) || !st.hasMoreTokens())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return false; st = new StringTokenizer(s); }return true;} int nextInt(){ return Integer.parseInt(next());} } public static void main( String[] args){ new A().runIO(); } }
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"); }} }
3	public class Main{ public static void main( String[] args){ solve(System.in,System.out); } static void solve( InputStream inStream, PrintStream printStream){ Scanner in = new Scanner(inStream);  int n = in.nextInt();  long[] sums = new long[n]; for ( int i = 1;(i < n);i++) {sums[i] = 0; }sums[0] = 1; long mod = 1000000007; for ( int i = 0;(i < n);i++) {if ( in.next().equals("f")) {for ( int j = (n - 1);(j > 0);j--) {sums[j] = sums[(j - 1)]; }sums[0] = 0; } else {for ( int j = (n - 2);(j >= 0);j--) {sums[j] += sums[(j + 1)]; if ( (sums[j] >= mod)) {sums[j] -= mod; } }}}printStream.println(sums[0]); } }
5	public class r220a{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int N = in.nextInt();  ArrayList<Integer> list = new ArrayList<Integer>();  ArrayList<Integer> sort = new ArrayList<Integer>(); for ( int i = 0;(i < N);i++) { int k = in.nextInt(); list.add(k); sort.add(k); }Collections.sort(sort); int count = 0; for ( int i = 0;(i < N);i++) {if ( (sort.get(i).intValue() != list.get(i).intValue())) count++; }if ( ((count != 2) && (count != 0))) System.out.println("NO"); else System.out.println("YES"); } }
5	public class Round159ProblemA{ public static void main( String[] args){ Reader r = new Reader();  int filters = r.nextInt();  int devices = r.nextInt();  int sockets = r.nextInt();  List<Integer> filtery = new ArrayList<>(); for ( int i = 0;(i < filters);i++) {filtery.add((r.nextInt() - 1)); }if ( (devices <= sockets)) {System.out.println(0); return ;} else {Collections.shuffle(filtery); Collections.sort(filtery); devices -= sockets; int act = (filtery.size() - 1);  int result = 0; while((devices > 0)){if ( (act < 0)) {System.out.println(-1); return ;} devices -= filtery.get(act); act--; result++; }System.out.println(result); }} static class Reader{ StreamTokenizer in ; public Reader(){ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); } public int nextInt(){ try{in.nextToken(); }catch (IOException e){ e.printStackTrace(); } return (int)in.nval;} } }
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(); } }
5	public class C{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = null; private void solution()throws IOException { int n = nextInt();  int[] mas = new int[n]; for ( int i = 0;(i < n);i++) {mas[i] = nextInt(); }Arrays.sort(mas); if ( (mas[(n - 1)] == 1)) {mas[(n - 1)] = 2; } else {mas[(n - 1)] = 1; }Arrays.sort(mas); for ( int i = 0;(i < n);i++) {System.out.print((mas[i] + " ")); }} String nextToken()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(bf.readLine()); } return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} public static void main( String[] args)throws IOException { new C().solution(); } }
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);  SquareFreeDivisionHardVersion solver = new SquareFreeDivisionHardVersion(); solver.solve(1,in,out); out.close(); } static class SquareFreeDivisionHardVersion{ static final int MAX = 10000001; public void solve( int testNumber, InputReader in, OutputWriter out){ int t = in.nextInt();  int[] d = PrimesAndDivisors.generateDivisors(MAX);  int[] reduced = new int[MAX]; for ( int i = 1;(i < MAX);i++) { int val = i; reduced[i] = 1; while((val != 1)){ int prime = d[val],exponent = 0; while(((val % prime) == 0)){val /= prime; exponent ^= 1; }if ( (exponent > 0)) reduced[i] *= prime; }} int counter = 0;  int[] seen = new int[MAX]; for ( int jjjj = 0;(jjjj < t);jjjj++) { int n = in.nextInt(),k = in.nextInt();  int[] a = in.readIntArray(n); for ( int x :a) seen[reduced[x]] = -1; int[][] dp = new int[(n + 1)][(k + 1)];  TreeSet<Integer> ts = new TreeSet<>();  int num = 0; for ( int i = 0;(i < n);i++) { int R = reduced[a[i]]; if ( (seen[R] != -1)) {ts.add(-seen[R]); if ( (ts.size() > (k + 1))) ts.remove(ts.last()); num++; } Arrays.fill(dp[i],(n + 1)); for ( int j = num;(j <= k);j++) dp[i][j] = 1; seen[R] = i; int u = 0; for ( int r :ts) {for ( int j = u;(j <= k);j++) dp[i][j] = Integer.min(dp[i][j],(dp[-r][(j - u)] + 1)); u++; }}out.println(dp[(n - 1)][k]); }} } 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[] readIntArray( int size){ int[] array = new int[size]; for ( int i = 0;(i < size);i++) {array[i] = readInt(); }return array;} 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 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 println( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }writer.print('\n'); } public void close(){ writer.close(); } } }
0	public class A{ public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  String cur = sc.nextToken();  int first = Integer.parseInt(cur); if ( (cur.length() > 1)) { String second = cur.substring(0,(cur.length() - 1)); if ( Character.isDigit(second.charAt((second.length() - 1)))) {first = Math.max(first,Integer.parseInt(second)); } } if ( (cur.length() > 2)) { String third = (cur.substring(0,(cur.length() - 2)) + cur.charAt((cur.length() - 1))); if ( Character.isDigit(cur.charAt((cur.length() - 2)))) {first = Math.max(first,Integer.parseInt(third)); } } System.out.println(first); out.close(); } public 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();} } }
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());} }
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)); } }
6	public class B{ int n ,k ,A ; int[] b ; int[] l ; double ans ; double cal(){ double total = 0; for ( int mask = 0;(mask < (1 << n));mask++) { int bit = Integer.bitCount(mask);  double p = 1; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) != 0)) p *= (l[i] / 10.0); else p *= (1.0 - (l[i] / 10.0)); }if ( ((bit * 2) > n)) total += p; else { int B = 0; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) {B += b[i]; } }total += (p * (A / (double)(A + B))); }}return total;} void rec( int d, int remain){ ans = max(ans,cal()); if ( (remain == 0)) return ; for ( int i = d;(i < n);i++) {if ( (l[i] == 10)) continue; l[i]++; rec(i,(remain - 1)); l[i]--; }} public B()throws Exception{ n = in.nextInt(); k = in.nextInt(); A = in.nextInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = in.nextInt(); l[i] = (in.nextInt() / 10); }ans = 0; rec(0,k); System.out.print(ans); } Scanner in = new Scanner(System.in); StringBuilder buf = new StringBuilder(); public static void main( String[] args)throws Exception { new B(); } }
4	@SuppressWarnings("unused") public class round35C{ static class state{ int x ,y ,time ; public state( int xx, int yy, int t){ x = xx; y = yy; time = t; } } static int N ,M ; static int[] dx = new int[]{1,-1,0,0}; static int[] dy = new int[]{0,0,1,-1}; static Queue<state> bfs = new LinkedList<round35C.state>(); public static Point runBFS(){ boolean[][] vis = new boolean[(N + 1)][(M + 1)];  int max = (int)1e9;  int bestx = -1;  int besty = -1; while(!bfs.isEmpty()){ state p = bfs.poll();  int x = p.x;  int y = p.y;  int time = p.time; if ( vis[x][y]) continue; vis[x][y] = true; if ( (time > max)) {max = time; bestx = (x + 1); besty = (y + 1); } for ( int i = 0;(i < 4);++i) { int nx = (x + dx[i]);  int ny = (y + dy[i]); if ( ((((nx < 0) || (ny < 0)) || (nx >= N)) || (ny >= M))) continue; if ( (vis[nx][ny] == false)) bfs.offer(new state(nx,ny,(time + 1))); }}return new Point(bestx,besty);} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter("output.txt");  String[] use = null; use = br.readLine().split(" "); N = parseInt(use[0]); M = parseInt(use[1]); int K = parseInt(br.readLine()); use = br.readLine().split(" "); for ( int i = 0;(i < (2 * K));i += 2) { int f = (parseInt(use[i]) - 1);  int t = (parseInt(use[(i + 1)]) - 1); bfs.offer(new state(f,t,0)); } Point ans = runBFS(); out.println(((ans.x + " ") + ans.y)); out.flush(); out.close(); } }
5	public class P015A{ public static void main( String[] args){ Scanner inScanner = new Scanner(System.in);  int n = inScanner.nextInt();  int t = inScanner.nextInt();  House[] houses = new House[n]; for ( int i = 0;(i < n);i++) houses[i] = new House(inScanner.nextInt(),inScanner.nextInt()); Arrays.sort(houses); int sum = 2; for ( int i = 1;(i < n);i++) { double space = (houses[i].leftX - houses[(i - 1)].rightX); if ( (space >= t)) sum++; if ( (space > t)) sum++; }System.out.println(sum); } static private class House implements Comparable<House>{ int x ; double leftX ; double rightX ; public House( int x, int size){ super(); this.x = x; leftX = (x - ((double)size / 2)); rightX = (x + ((double)size / 2)); } } }
0	public class CFA_200{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long x = sc.nextLong();  long y = sc.nextLong(); System.out.println(Wilf_tree(x,y)); sc.close(); } static long Wilf_tree( long a, long b){ if ( ((a == 0) || (b == 0))) return 0; if ( (a >= b)) return ((a / b) + Wilf_tree((a % b),b)); else return ((b / a) + Wilf_tree(a,(b % a)));} }
4	public class C{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(in,out); out.close(); } static class Task{ int M ; public void solve( InputReader in, PrintWriter out){ int n = in.nextInt(); M = in.nextInt(); if ( (n <= 1)) {out.println(n); return ;} int[][] Ckn = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {Ckn[i][i] = 1; Ckn[0][i] = 1; for ( int j = (i - 1);(j >= 1);j--) {Ckn[j][i] = add(Ckn[(j - 1)][(i - 1)],Ckn[j][(i - 1)]); }} int ans = 0;  int[][] dp = new int[(n + 1)][(n + 1)]; dp[1][1] = 1; for ( int i = 2;(i <= n);i++) {dp[i][i] = mul(2,dp[(i - 1)][(i - 1)]); for ( int j = 1;(j <= (i - 1));j++) {for ( int k = 1;(k <= j);k++) {dp[i][j] = add(dp[i][j],mul(mul(dp[k][k],dp[((i - k) - 1)][(j - k)]),Ckn[k][j])); }}}for ( int i = 0;(i <= n);i++) ans = add(ans,dp[n][i]); out.println(ans); } public int add( int a, int b){ a += b; if ( (a >= M)) a -= M; return a;} public int mul( int a, int b){ long res = ((long)a * (long)b); res %= M; return (int)res;} } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){ String line = null; try{line = br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} if ( (line == null)) {return null;} st = new StringTokenizer(line); }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} } }
3	public class Main{ static ArrayList a[] = new ArrayList[200001]; static int Count( int[][] a, int n){ dsu d = new dsu(n); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (a[i][j] == 0)) {d.union(i,j); } }} int cnt = 0;  boolean chk[] = new boolean[n]; for ( int i = 0;(i < n);i++) { int p = d.root(i); if ( !chk[p]) {chk[p] = true; cnt++; } }return cnt;} public void solve(){ InputReader in = new InputReader(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt(); if ( ((a == 1) || (b == 1))) { int ans[][] = new int[n][n];  int temp = ((a == 1)?b:a); for ( int i = 1;(i <= (n - temp));i++) {ans[i][(i - 1)] = 1; ans[(i - 1)][i] = 1; } int freq = Count(ans,n); if ( (freq != 1)) {pw.println("NO"); } else {pw.println("YES"); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i == j)) {pw.print(0); } else pw.print(((ans[i][j] + ((temp == b)?1:0)) % 2)); }pw.println(); }}} else {pw.print("NO"); }pw.flush(); pw.close(); } public static void main( String[] args)throws Exception { new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } 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 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); } } public static long mod = 1000000007; public static int d ; public static int p ; public static int q ; public void extended( int a, int b){ if ( (b == 0)) {d = a; p = 1; q = 0; } else {extended(b,(a % b)); int temp = p; p = q; q = (temp - ((a / b) * q)); }} public static int GCD( int a, int b){ if ( (b == 0)) return a; else return GCD(b,(a % b));} } class dsu{ int parent[] ; dsu( int n){ parent = new int[(n + 1)]; for ( int i = 0;(i <= n);i++) {parent[i] = i; }} int root( int n){ while((parent[n] != n)){parent[n] = parent[parent[n]]; n = parent[n]; }return n;} void union( int _a, int _b){ int p_a = root(_a);  int p_b = root(_b); parent[p_a] = p_b; } }
5	public class p7{ 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());} long nextLong(){ return Long.parseLong(next());} } public static void main( String[] args){ FastReader sc = new FastReader();  int n = sc.nextInt();  int k = sc.nextInt();  long one = ((long)Math.pow(2,k) - 1);  long[] arr = new long[(n + 1)]; arr[0] = 0; for ( int i = 1;(i <= n);i++) {arr[i] = sc.nextLong(); arr[i] ^= arr[(i - 1)]; } Map<Long,Long> count = new HashMap<>(); for ( int i = 0;(i <= n);i++) { Long key = Math.min(arr[i],(arr[i] ^ one));  Long val = count.get(key); if ( (val == null)) val = 0L; count.put(key,(val + 1)); } long num = n;  long ans = ((num * (num + 1)) / 2); for ( Map.Entry<Long,Long> ent :count.entrySet()) { Long cnt = ent.getValue();  long num1 = (cnt / 2);  long num2 = ((cnt + 1) / 2); ans -= ((num1 * (num1 - 1)) / 2); ans -= ((num2 * (num2 - 1)) / 2); }System.out.println(ans); } }
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(); } }
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.nextInt(),m = in.nextInt(),k = in.nextInt();  int ans = -1;  int i ;  int a[] = new int[n]; for ( i = 0;(i < n);i++) a[i] = in.nextInt(); Arrays.sort(a); int p = k,c = 0; for ( i = (n - 1);(i >= 0);i--) {if ( (p >= m)) break; p += (a[i] - 1); c++; }if ( (p >= m)) out.printLine(c); else out.printLine(-1); } } 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());} } 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{ static private InputStream stream ; static private byte[] buf = new byte[1024]; static private int curChar ; static private int numChars ; static private SpaceCharFilter filter ; static private PrintWriter pw ; static private long count = 0,mod = 1000000007; public static final 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)); } static private 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; } static private boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} static private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} static 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++];} static private 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);} static private 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);} static private 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();} static private boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return isWhitespace(c);} private interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } }
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 ProblemA{ public void solve(){ boolean oj = true; try{ Reader reader = (oj?new InputStreamReader(System.in):new FileReader("A.in"));  Writer writer = (oj?new OutputStreamWriter(System.out):new FileWriter("A.out"));  BufferedReader br = new BufferedReader(reader);  PrintWriter out = new PrintWriter(writer);  MyTokenizer tok = new MyTokenizer(br.readLine());  int n = (int)tok.getNum();  int k = (int)tok.getNum();  boolean[] isPrime = new boolean[(n + 1)]; for ( int i = 1;(i <= n);i++) isPrime[i] = true; isPrime[1] = false; isPrime[2] = true; for ( int i = 2;((i * i) <= n);i++) for ( int j = (2 * i);(j <= n);j += i) isPrime[j] = false; int[] primes = new int[n];  int cur = 0; for ( int i = 2;(i <= n);i++) if ( isPrime[i]) {primes[cur] = i; cur++; } int count = 0; for ( int i = 0;(i < (cur - 1));i++) {if ( ((((primes[i] + primes[(i + 1)]) + 1) <= n) && isPrime[((primes[i] + primes[(i + 1)]) + 1)])) count++; }if ( (count >= k)) out.printf("YES"); else out.printf("NO"); br.close(); out.close(); reader.close(); writer.close(); }catch (Exception ex){ ex.printStackTrace(); } } public static void main( String[] args){ ProblemA f = new ProblemA(); f.solve(); } private class MyTokenizer{ private String s ; private int cur ; public MyTokenizer( String s){ this.s = s; cur = 0; } public void skip(){ while(((cur < s.length()) && ((s.charAt(cur) == ' ') || (s.charAt(cur) == '\n')))){cur++; }} public double getNum(){ skip(); String snum = ""; while(((cur < s.length()) && (((s.charAt(cur) >= '0') && (s.charAt(cur) <= '9')) || (s.charAt(cur) == '.')))){snum += s.charAt(cur); cur++; }return Double.valueOf(snum);} } }
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);  C908 solver = new C908(); solver.solve(1,in,out); out.close(); } static class C908{ int N ; int R ; int[] x ; double[] ans ; public void solve( int testNumber, FastScanner s, PrintWriter out){ N = s.nextInt(); R = s.nextInt(); x = s.nextIntArray(N); ans = new double[N]; Arrays.fill(ans,R); for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) <= (2 * R))) { double dy = Math.sqrt((Math.pow((2 * R),2) - Math.pow((x[i] - x[j]),2))); ans[i] = Math.max(ans[i],(ans[j] + dy)); } }}for ( double d :ans) out.print((d + " ")); out.println(); } } 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));} 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();} public int[] nextIntArray( int N){ int[] ret = new int[N]; for ( int i = 0;(i < N);i++) ret[i] = this.nextInt(); return ret;} } }
2	public class My{ public static void main( String[] args){ new My().go(); } void go(){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  int k = in.nextInt();  int mn = 0,mx = (k + 1); while((mn < mx)){ int mid = ((mn + mx) / 2); if ( works(n,k,mid)) {mx = mid; } else {mn = (mid + 1); }}if ( (mn > k)) {pl("-1"); } else {pl(((mn - 1) + "")); }} boolean works( long n, int k, int use){ return (((1 + T((k - 1))) - T((k - use))) >= n);} long T( int n){ return ((n * (long)(n + 1)) / 2);} void pl( String s){ System.out.println(s); } }
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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } static class TaskA{ public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); }Arrays.sort(a); boolean[] dead = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( dead[i]) {continue;} ++ans; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {dead[j] = true; } }}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());} } }
3	public class D{ private void solve(){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = nextInt(),m = nextInt();  boolean[][] used = new boolean[(n + 1)][(m + 1)]; for ( int j = 1;(j <= ((m + 1) / 2));j++) { int x1 = 1,x2 = n; for ( int i = 1;(i <= n);i++) {if ( ((x1 <= n) && !used[x1][j])) {out.println(((x1 + " ") + j)); used[x1++][j] = true; } if ( ((x2 > 0) && !used[x2][((m - j) + 1)])) {out.println(((x2 + " ") + ((m - j) + 1))); used[x2--][((m - j) + 1)] = true; } }}out.close(); } public static void main( String[] args){ new D().solve(); } private BufferedReader br ; private StringTokenizer st ; private PrintWriter out ; private String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw (new RuntimeException(e));} }return st.nextToken();} private int nextInt(){ return Integer.parseInt(next());} }
0	public class Main{ static Scanner scan = new Scanner(System.in); static PrintStream out = System.out; static int n ; static void solve(){ System.out.println(((((0 + " ") + 0) + " ") + n)); } public static void main( String[] args){ n = scan.nextInt(); solve(); } }
3	public class PaintNumbers{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] nums = new int[n]; for ( int i = 0;(i < n);i++) {nums[i] = in.nextInt(); } boolean[] visited = new boolean[n];  int min = Integer.MAX_VALUE;  int a = 0;  boolean cont = true; while(cont){for ( int i = 0;(i < n);i++) {if ( !visited[i]) {min = Math.min(min,nums[i]); } }cont = false; for ( int i = 0;(i < n);i++) {if ( (!visited[i] && ((nums[i] % min) == 0))) {cont = true; visited[i] = true; } }a++; min = Integer.MAX_VALUE; }System.out.println((a - 1)); } }
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());} } }
2	public class Main{ static private long pow( long base, long coe){ if ( (coe == 0)) return 1; if ( (coe == 1)) return base; long res = pow(base,(coe / 2)); if ( ((coe % 2) == 0)) {return (res * res);} else {return ((res * res) * base);}} static private void getLen( long n){ long tmp = 0;  int cnt = 0; while((tmp < n)){++cnt; tmp += ((cnt * 9) * pow(10,(cnt - 1))); }if ( (tmp == n)) System.out.println("9"); else {tmp -= ((cnt * 9) * pow(10,(cnt - 1))); long ans = ((((n - tmp) - 1) / cnt) + pow(10,(cnt - 1))); System.out.println(String.valueOf(ans).charAt((int)(((n - tmp) - 1) % cnt))); }} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(); getLen(n); } }
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 size = in.readInt();  int[] array = IOUtils.readIntArray(in,size); Arrays.sort(array); if ( (array[(size - 1)] == 1)) array[(size - 1)] = 2; else array[(size - 1)] = 1; Arrays.sort(array); out.printLine(Array.wrap(array).toArray()); } } 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 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 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{ static final boolean debug = false; static final String fileName = ""; static final boolean useFiles = false; public static void main( String[] args)throws FileNotFoundException { PrintWriter writer = new PrintWriter(System.out); new Task(new InputReader(System.in),writer).solve(); writer.close(); } } 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();} } class Task{ public void solve(){ out.println(25); } private InputReader in ; private PrintWriter out ; Task( InputReader in, PrintWriter out){ this.in = in; this.out = out; } }
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(""); boolean[] erat = new boolean[(1000 + 1)]; int[] primes = new int[(1000 + 1)]; int pNum = 0; void run()throws IOException { for ( int i = 2;(i <= 1000);i++) {if ( !erat[i]) {primes[pNum++] = i; for ( int j = (i * i);(j <= 1000);j += i) erat[j] = true; } } int[] cnt = new int[(1000 + 1)]; cnt[2] = 0; for ( int i = 3;(i <= 1000);i++) {cnt[i] = cnt[(i - 1)]; if ( !erat[i]) { int r = (i - 1); for ( int j = 1;(j < pNum);j++) {if ( (r == (primes[(j - 1)] + primes[j]))) {cnt[i]++; break;} }} }in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = nextInt();  int k = nextInt(); out.println(((k <= cnt[n])?"YES":"NO")); 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());} }
3	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int r = sc.nextInt();  int d = (2 * r);  int[] xCoordinates = new int[n];  double[] yCoordinates = new double[n]; for ( int i = 0;(i < n);i++) yCoordinates[i] = r; for ( int i = 0;(i < n);i++) xCoordinates[i] = sc.nextInt(); double y = 0; for ( int i = 0;(i < n);i++) {y = r; for ( int j = 0;(j < i);j++) {if ( (Math.abs((xCoordinates[i] - xCoordinates[j])) <= (2 * r))) { int dx = Math.abs((xCoordinates[i] - xCoordinates[j]));  double dy = Math.sqrt(((d * d) - (dx * dx))); if ( ((dy + yCoordinates[j]) > y)) y = (dy + yCoordinates[j]); } }yCoordinates[i] = y; }for ( int i = 0;(i < n);i++) System.out.print((yCoordinates[i] + " ")); sc.close(); } }
6	public class CF111C extends PrintWriter{ CF111C(){ super(System.out,true); } Scanner sc = new Scanner(System.in); public static void main( String[] $){ CF111C o = new CF111C(); o.main(); o.flush(); } int encode( int[] aa, int m){ int a = 0; for ( int j = 0;(j < m);j++) a = ((a * 3) + aa[j]); return a;} void decode( int[] aa, int m, int a, int base){ for ( int j = (m - 1);(j >= 0);j--) {aa[j] = (a % base); a /= base; }} void main(){ int n = sc.nextInt();  int m = sc.nextInt(); if ( (n < m)) { int tmp = n; n = m; m = tmp; } int p = 1; for ( int j = 0;(j < m);j++) p *= 3; int[] dp = new int[p];  int[] dq = new int[p];  int[] aa = new int[m];  int[] bb = new int[m]; for ( int j = 0;(j < m);j++) aa[j] = 1; Arrays.fill(dp,-1); dp[encode(aa,m)] = 0; while((n-- > 0)){Arrays.fill(dq,-1); for ( int a = 0;(a < p);a++) {if ( (dp[a] < 0)) continue; decode(aa,m,a,3); for ( int b = 0;(b < (1 << m));b++) {decode(bb,m,b,2); boolean bad = false; for ( int j = 0;(j < m);j++) if ( ((aa[j] == 0) && (bb[j] == 0))) {bad = true; break;} if ( bad) continue; int cnt = 0; for ( int j = 0;(j < m);j++) if ( (bb[j] == 1)) {bb[j] = 2; cnt++; } for ( int j = 0;(j < m);j++) if ( ((bb[j] == 0) && (((aa[j] == 2) || ((j > 0) && (bb[(j - 1)] == 2))) || (((j + 1) < m) && (bb[(j + 1)] == 2))))) bb[j] = 1;  int a_ = encode(bb,m); dq[a_] = Math.max(dq[a_],((dp[a] + m) - cnt)); }} int[] tmp = dp; dp = dq; dq = tmp; } int ans = 0; for ( int a = 0;(a < p);a++) {if ( (dp[a] <= ans)) continue; decode(aa,m,a,3); boolean bad = false; for ( int j = 0;(j < m);j++) if ( (aa[j] == 0)) {bad = true; break;} if ( !bad) ans = dp[a]; }println(ans); } }
0	public class A{ public static void main( String[] args){ System.out.println(((new java.util.Scanner(System.in).nextInt() / 2) * 3)); } }
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 Tsk1{ static void metod()throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt();  String s = in.next();  String ss = (s + s);  int t = 0; for ( int i = 0;(i < n);i++) {if ( (s.charAt(i) == 'T')) {t++; } }if ( ((t == 1) || (t == (n - 1)))) {System.out.println(0); } else { int sum = 0; for ( int i = 0;(i < t);i++) {if ( (s.charAt(i) == 'T')) {sum++; } } int max = sum; for ( int i = 0;(i < s.length());i++) {if ( (ss.charAt(i) == 'T')) {if ( (ss.charAt((i + t)) == 'H')) {sum--; } } else {if ( (ss.charAt((i + t)) == 'T')) {sum++; max = Math.max(max,sum); } }}System.out.println((t - max)); }} public static void main( String[] args)throws Exception { Tsk1.metod(); } }
5	public class A_135{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int[] mas = new int[n]; for ( int i = 0;(i < n);i++) {mas[i] = in.nextInt(); }Arrays.sort(mas); PrintWriter out = new PrintWriter(System.out);  boolean isEd = true; for ( int i = 0;(i < n);i++) if ( (mas[i] != 1)) {isEd = false; break;} if ( !isEd) out.print('1'); for ( int i = 0;(i < (n - 1));i++) {out.print(' '); out.print(mas[i]); }if ( isEd) out.print(" 2"); out.flush(); } }
2	public class A{ BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter out ; long MOD = 1000000009; public long mod_add( long n1, long n2){ return ((n1 + n2) % MOD);} public long mod_time( long n1, long n2){ return ((n1 * n2) % MOD);} public long mod_power( long a, int k){ if ( (k == 0)) return 1; if ( ((k % 2) == 0)) return mod_power(((a * a) % MOD),(k / 2)); return ((a * mod_power(a,(k - 1))) % MOD);} public void solve()throws IOException { int N = nextInt();  int M = (N - nextInt());  int K = nextInt();  int full = ((N / K) - M); if ( (full < 0)) {out.println((N - M)); return ;} long ans = mod_time((K * 2),(mod_power(2,full) - 1)); ans = mod_add(ans,((N - M) - (full * K))); out.println(ans); } public static void main( String[] args){ new A().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();} }
3	public class Main{ 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();  double answer[] = new double[N];  int[] x = new int[N]; for ( int i = 0;(i < N);i++) x[i] = sc.nextInt(); for ( int i = 0;(i < N);i++) {answer[i] = R; for ( int j = 0;(j < i);j++) { int dist = Math.abs((x[i] - x[j])); if ( (dist <= (2 * R))) { double t = (answer[j] + Math.sqrt((((4 * R) * R) - (dist * dist)))); answer[i] = Math.max(answer[i],t); } }}for ( int i = 0;(i < N);++i) out.print((answer[i] + " ")); out.println(); 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());} } }
5	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = in.nextInt(); for ( int i = (n - 1);(i > 0);i--) arr[i] -= arr[(i - 1)]; arr[0] = 0; Arrays.sort(arr); long sum = 0; for ( int i = (n - k);(i >= 0);i--) sum += arr[i]; System.out.println(sum); } }
3	public class C{ static int n ,r ,x[] ; static double ans[] ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out); n = sc.nextInt(); r = sc.nextInt(); x = new int[n]; ans = new double[n]; for ( int i = 0;(i < n);i++) x[i] = sc.nextInt(); for ( int i = 0;(i < n);i++) {ans[i] = r; for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) > (2 * r))) continue; int deltaxsq = ((x[i] - x[j]) * (x[i] - x[j]));  int deltaysq = (((4 * r) * r) - deltaxsq);  double deltay = Math.sqrt(deltaysq); ans[i] = Math.max(ans[i],(ans[j] + deltay)); }pw.print((ans[i] + " ")); }pw.flush(); pw.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 int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
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)); }}} }
6	public class D{ Reader in = new Reader(System.in); PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws IOException { new D().run(); } int n ,m ; boolean[][] adjacency ; void run()throws IOException { n = in.nextInt(); m = in.nextInt(); adjacency = new boolean[(n + 1)][n]; for ( int i = 0;(i < m);i++) { int u = in.nextInt(),v = in.nextInt(); adjacency[(u - 1)][(v - 1)] = adjacency[(v - 1)][(u - 1)] = true; }final int MAX_MASK = ((1 << n) - 1);  long[][] dp = new long[(MAX_MASK + 1)][n]; for ( int i = 0;(i < n);i++) dp[(1 << i)][i] = 1; long sum = 0; for ( int mask = 1;(mask <= MAX_MASK);mask++) { int lowestBit = first(mask); for ( int i = 0;(i < n);i++) {if ( (bit(i,mask) && (i != lowestBit))) {for ( int j = 0;(j < n);j++) {if ( adjacency[j][i]) {dp[mask][i] += dp[(mask ^ (1 << i))][j]; } }if ( ((count(mask) >= 3) && adjacency[lowestBit][i])) sum += dp[mask][i]; } else {}}}out.println((sum / 2)); out.flush(); } int count( int mask){ int count = 0; while((mask > 0)){if ( ((mask & 1) == 1)) count++; mask >>= 1; }return count;} int first( int mask){ int index = 0; while((mask > 0)){if ( ((mask & 1) == 1)) return index; mask >>= 1; index++; }return -1;} boolean bit( int index, int mask){ return (((1 << index) & mask) > 0);} 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());} } }
4	public class incendio{ static StringTokenizer _stk ; static BufferedReader input ; static PrintWriter output ; static String next(){ return _stk.nextToken();} static int nextInt(){ return Integer.parseInt(next());} static String readln()throws IOException { String l = input.readLine(); _stk = ((l == null)?null:new StringTokenizer(l," ")); return l;} public static void main( String[] args)throws IOException { input = new BufferedReader(new FileReader("input.txt")); output = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); new incendio(); output.close(); } incendio()throws IOException{ readln(); M = nextInt(); N = nextInt(); readln(); final int K = nextInt();  int xf[] = new int[K],yf[] = new int[K]; readln(); for ( int i = 0;(i < K);i++) {xf[i] = nextInt(); yf[i] = nextInt(); } int best = -1,xbest = 0,ybest = 0; for ( int i = 1;(i <= M);i++) {for ( int j = 1;(j <= N);j++) { int dist = Integer.MAX_VALUE; for ( int k = 0;(k < K);k++) {dist = Math.min(dist,(Math.abs((i - xf[k])) + Math.abs((j - yf[k])))); }if ( (dist > best)) {best = dist; xbest = i; ybest = j; } }}output.println(((xbest + " ") + ybest)); } int M ,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);  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();  Team[] t = new Team[N]; for ( int i = 0;(i < N);i++) t[i] = new Team(in.nextInt(),in.nextInt()); Arrays.sort(t); int p_k = t[(k - 1)].p,t_k = t[(k - 1)].t;  int count = 0; for ( int i = 0;(i < N);i++) if ( ((t[i].p == p_k) && (t[i].t == t_k))) count++; out.println(count); } } class Team implements Comparable<Team>{ int p ,t ; Team( int a, int b){ p = a; t = b; } }
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 A{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni(),m = ni(),K = ni();  int[] a = na(n); a = radixSort(a); if ( (K >= m)) {out.println(0); return ;} int p = 1; for ( int i = (n - 1);(i >= 0);i--) {K += (a[i] - 1); if ( (K >= m)) {out.println(p); return ;} p++; }out.println(-1); } 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 Code1{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = Integer.valueOf(sc.nextLine()); if ( ((n % 2) == 0)) System.out.println(((4 + " ") + (n - 4))); else {System.out.println(((9 + " ") + (n - 9))); }} }
1	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  int a[] = new int[100]; for ( int i = 0;(i < n);i++) a[i] = (in.nextInt() % 2); if ( ((a[0] == a[1]) || (a[0] == a[2]))) {for ( int i = 1;(i < n);i++) if ( (a[i] != a[0])) {System.out.println((i + 1)); break;} } else {System.out.println(1); }} }
2	public class Main{ static long[] dx = new long[]{0,1,0,-1}; static long[] dy = new long[]{-1,0,1,0}; public static void main( String[] args){ Scanner r = new Scanner(System.in);  long N = r.nextLong();  long X = r.nextLong();  long Y = r.nextLong();  long C = r.nextLong();  long lo = 0,hi = (N * 2); while((lo < hi)){ long T = ((lo + hi) / 2);  long[] NX = new long[4];  long[] NY = new long[4]; for ( int d = 0;(d < 4);d++) {NX[d] = (X + (dx[d] * T)); NY[d] = (Y + (dy[d] * T)); } long ret = (((T + 1) * (T + 1)) + (T * T)); ret -= half((1 - NY[0])); ret -= half((NY[2] - N)); ret -= half((NX[1] - N)); ret -= half((1 - NX[3])); ret += quarter(((1 - NY[0]) - ((N - X) + 1))); ret += quarter(((1 - NY[0]) - X)); ret += quarter(((NY[2] - N) - ((N - X) + 1))); ret += quarter(((NY[2] - N) - X)); if ( (ret < C)) lo = (T + 1); else hi = T; }System.out.println(lo); } static private long half( long x){ if ( (x <= 0)) return 0; else return ((2 * quarter(x)) - x);} static private long quarter( long x){ if ( (x <= 0)) return 0; return ((x * (x + 1)) / 2);} }
1	public class B{ private 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[] f = new int[(100000 + 2)];  int min = Integer.MAX_VALUE;  int cur = 0;  int start = 0;  int from = -1,to = -1; for ( int i = 0;(i < n);i++) {f[a[i]]++; if ( (f[a[i]] == 1)) cur++; if ( (cur == k)) {while((f[a[start]] > 1)){f[a[start]]--; start++; }if ( (((i - start) + 1) < min)) {min = ((i - start) + 1); from = start; to = i; } } }pl(((from == -1)?"-1 -1":(((1 + from) + " ") + (1 + to)))); } public static void main( String[] args){ new B().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 ; }
5	public class Template{ 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();} int nextInt(){ return Integer.parseInt(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(); } public void solve()throws Exception { int n = nextInt();  int k = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } boolean[] ok = new boolean[n]; Arrays.fill(ok,true); Arrays.sort(a); if ( (k != 1)) {for ( int i = 0;(i < n);i++) {if ( ((a[i] % k) == 0)) { int x = (a[i] / k);  int ind = Arrays.binarySearch(a,x); if ( ((ind >= 0) && ok[ind])) {ok[i] = false; } } }} int ans = 0; for ( int i = 0;(i < n);i++) {if ( ok[i]) {ans++; } }out.println(ans); } public static void main( String[] args)throws Exception { new Template().run(); } }
1	public class B1{ static Scanner in ; public static void main( String[] args)throws FileNotFoundException { in = new Scanner(System.in); int tn = in.nextInt(); for ( int i = 0;(i < tn);i++) { String s = in.next();  char[] c = s.toCharArray();  boolean second = true; second &= (c[0] == 'R'); int r = s.indexOf("C"); if ( (r > 0)) {second &= (isNumber(s.substring(1,r)) && isNumber(s.substring((r + 1)))); } else {second = false; }if ( second) {System.out.println((toLetters(s.substring((r + 1))) + s.substring(1,r))); } else {r = 0; while(((c[r] >= 'A') && (c[r] <= 'Z'))){r++; }System.out.println(((("R" + s.substring(r)) + "C") + fromLetters(s.substring(0,r)))); }}} static private int fromLetters( String s){ int r = 0;  int l = s.length(); for ( int i = 0;(i < l);i++) {r = (((r * 26) + s.charAt(i)) - 'A'); }r++; for ( int i = 1,c = 26;(i < l);i++,c *= 26) {r += c; }return r;} static private String toLetters( String s){ int x = (new Integer(s) - 1);  int c = 26;  int l = 1; while(true){if ( (x < c)) { String r = ""; for ( int i = 0;(i < l);i++) {r = ((char)('A' + (x % 26)) + r); x /= 26; }return r;} x -= c; c *= 26; l++; }} static private boolean isNumber( String s){ try{ int x = new Integer(s);  }catch (NumberFormatException e){ return false;} return true;} }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(); System.out.println((3 * (n / 2))); } }
3	public class paint{ static PriorityQueue<Integer> sequence ; public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out,true);  int numSeq = Integer.parseInt(f.readLine()); sequence = new PriorityQueue<Integer>(); StringTokenizer st = new StringTokenizer(f.readLine()); for ( int i = 0;(i < numSeq);i++) {sequence.add(Integer.parseInt(st.nextToken())); } int numColors = 0; while((sequence.size() > 0)){numColors++; int smallest = sequence.poll();  PriorityQueue<Integer> temp = new PriorityQueue<Integer>(); for ( int each :sequence) {if ( ((each % smallest) != 0)) {temp.add(each); } }sequence = temp; }System.out.println(numColors); out.close(); } }
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();  int k = Int();  int A[][] = new int[n][2];  int a = 0,b = 0,c = 0; for ( int i = 0;(i < A.length);i++) {A[i][0] = Int(); A[i][1] = (Int() - 1); if ( (A[i][1] == 0)) a++; else if ( (A[i][1] == 1)) b++; else c++; } Solution sol = new Solution(out); sol.solution(A,k,a,b,c); }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; } int mod = 1000000007; long dp3[][][][] ; public void solution( int[][] A, int T, int x, int y, int z){ long res = 0;  int n = A.length;  long dp1[][] = new long[(x + 1)][(T + 1)];  long dp2[][][] = new long[(y + 1)][(z + 1)][(T + 1)]; dp3 = new long[(x + 2)][(y + 2)][(z + 2)][3]; long f[] = new long[(n + 10)]; f[0] = f[1] = 1; for ( int i = 2;(i < f.length);i++) {f[i] = (f[(i - 1)] * i); f[i] %= mod; }for ( int i = 0;(i < dp3.length);i++) {for ( int j = 0;(j < dp3[0].length);j++) {for ( int k = 0;(k < dp3[0][0].length);k++) {Arrays.fill(dp3[i][j][k],-1); }}}dp1[0][0] = 1; long newdp1[][] = new long[dp1.length][dp1[0].length]; for ( int i = 0;(i < A.length);i++) { int p = A[i][0],type = A[i][1]; if ( (type == 0)) {for ( int cnt = 1;(cnt <= x);cnt++) {for ( int j = 1;(j < dp1[0].length);j++) {if ( (j >= p)) {newdp1[cnt][j] += dp1[(cnt - 1)][(j - p)]; newdp1[cnt][j] %= mod; } }}for ( int cnt = 0;(cnt <= x);cnt++) {for ( int j = 0;(j < dp1[0].length);j++) {dp1[cnt][j] += newdp1[cnt][j]; dp1[cnt][j] %= mod; newdp1[cnt][j] = 0; }}} }dp2[0][0][0] = 1; long newdp2[][][] = new long[dp2.length][dp2[0].length][dp2[0][0].length]; for ( int i = 0;(i < A.length);i++) { int p = A[i][0],type = A[i][1]; if ( (type != 0)) {for ( int a = 0;(a < dp2.length);a++) {for ( int b = 0;(b < dp2[0].length);b++) {for ( int j = 0;(j < dp2[0][0].length);j++) {if ( (j >= p)) {if ( (type == 1)) {if ( ((a - 1) >= 0)) {newdp2[a][b][j] += dp2[(a - 1)][b][(j - p)]; } } else {if ( ((b - 1) >= 0)) {newdp2[a][b][j] += dp2[a][(b - 1)][(j - p)]; } }} newdp2[a][b][j] %= mod; }}}for ( int a = 0;(a < dp2.length);a++) {for ( int b = 0;(b < dp2[0].length);b++) {for ( int j = 0;(j < dp2[0][0].length);j++) {dp2[a][b][j] += newdp2[a][b][j]; dp2[a][b][j] %= mod; newdp2[a][b][j] = 0; }}}} }dp3[1][0][0][0] = 1; dp3[0][1][0][1] = 1; dp3[0][0][1][2] = 1; for ( int i = 0;(i < dp3.length);i++) {for ( int j = 0;(j < dp3[0].length);j++) {for ( int k = 0;(k < dp3[0][0].length);k++) {for ( x = 0;(x < dp3[0][0][0].length);x++) {if ( (dp3[i][j][k][x] == -1)) {dfs(i,j,k,x); } }}}}for ( int i = 0;(i < (dp3.length - 1));i++) {for ( int j = 0;(j < (dp3[0].length - 1));j++) {for ( int k = 0;(k < (dp3[0][0].length - 1));k++) {for ( int cur = 0;(cur < 3);cur++) {for ( int t = 0;(t <= T);t++) { int aprice = t;  int bcprice = (T - t);  long cnt1 = dp1[i][aprice];  long cnt2 = dp2[j][k][bcprice];  long combination = dp3[i][j][k][cur];  long p1 = ((cnt1 * f[i]) % mod);  long p2 = ((((f[j] * f[k]) % mod) * cnt2) % mod);  long p3 = ((p1 * p2) % mod); res += ((p3 * combination) % mod); res %= mod; }}}}}out.println(res); } public long dfs( int a, int b, int c, int cur){ if ( (((a < 0) || (b < 0)) || (c < 0))) {return 0;} if ( (((a == 0) && (b == 0)) && (c == 0))) {return 0;} if ( (dp3[a][b][c][cur] != -1)) return dp3[a][b][c][cur]; long res = 0; if ( (cur == 0)) {res += dfs((a - 1),b,c,1); res %= mod; res += dfs((a - 1),b,c,2); res %= mod; } else if ( (cur == 1)) {res += dfs(a,(b - 1),c,0); res %= mod; res += dfs(a,(b - 1),c,2); res %= mod; } else {res += dfs(a,b,(c - 1),0); res %= mod; res += dfs(a,b,(c - 1),1); res %= mod; }res %= mod; dp3[a][b][c][cur] = res; return res;} }
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);  TaskBR574D2 solver = new TaskBR574D2(); solver.solve(1,in,out); out.close(); } static class TaskBR574D2{ public void solve( int testNumber, Scanner in, PrintWriter out){ long n = in.nextLong();  long k = in.nextLong();  long r = ((long)(Math.sqrt((9 + (8 * (n + k)))) - 3) / 2); out.println((n - r)); } } }
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)])); } static private StreamTokenizer in ; static private PrintWriter out ; static private BufferedReader inB ; static private boolean FILE = false; static private 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); }static private void println( Object o)throws Exception { out.println(o); out.flush(); } static private void exit( Object o)throws Exception { println(o); exit(); } static private void exit(){ System.exit(0); } static private final int INF = Integer.MAX_VALUE; static private final int MINF = Integer.MIN_VALUE; }
4	public class ArFireAgain{ int n ,m ,k ; int dx[] = {0,0,1,-1,1,1,-1,-1}; int dy[] = {1,-1,0,0,1,-1,1,-1}; int[][] dist ; ArrayList<Pair> arr ; Scanner sc ; PrintWriter out ; public void solve(){ try{sc = new Scanner(new FileReader("input.txt")); out = new PrintWriter("output.txt"); }catch (FileNotFoundException e){ e.printStackTrace(); } n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); arr = new ArrayList<Pair>(); for ( int i = 0;(i < k);i++) { int x = (sc.nextInt() - 1);  int y = (sc.nextInt() - 1);  Pair p = new Pair(x,y); arr.add(p); } Pair last = bfs(); out.println(((last.x + " ") + last.y)); out.flush(); out.close(); } boolean isValid( int x, int y){ return ((((x >= 0) && (y >= 0)) && (x < n)) && (y < m));} private Pair bfs(){ Queue<Pair> q = new LinkedList<Pair>(); dist = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {dist[i][j] = -1; }}for ( int i = 0;(i < k);i++) {dist[arr.get(i).x][arr.get(i).y] = 0; q.add(arr.get(i)); }while(!q.isEmpty()){ Pair cur = q.remove(); for ( int d = 0;(d < 4);d++) { int X = (cur.x + dx[d]);  int Y = (cur.y + dy[d]); if ( (isValid(X,Y) && (dist[X][Y] == -1))) {dist[X][Y] = (dist[cur.x][cur.y] + 1); Pair p = new Pair(X,Y); q.add(p); } }} Pair res = null;  int maxx = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (dist[i][j] > maxx)) {maxx = dist[i][j]; res = new Pair((i + 1),(j + 1)); } }}return res;} class Pair{ int x ,y ; Pair( int x, int y){ this.x = x; this.y = y; } } public static void main( String[] args){ new ArFireAgain().solve(); } }
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(); } }
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)][n]; for ( int start = 0;(start < n);++start) {for ( int mask = 0;(mask < (1 << (n - start)));++mask) for ( int last = start;(last < n);++last) {ways[mask][(last - start)] = 0; }ways[1][0] = 1; for ( int mask = 0;(mask < (1 << (n - start)));++mask) { int cnt = 0;  int tmp = mask; while((tmp > 0)){++cnt; tmp = (tmp & (tmp - 1)); }for ( int last = start;(last < n);++last) if ( (ways[mask][(last - start)] > 0)) { long amm = ways[mask][(last - start)]; for ( int i = start;(i < n);++i) if ( (((mask & (1 << (i - start))) == 0) && g[last][i])) {ways[(mask | (1 << (i - start)))][(i - start)] += amm; } if ( g[last][start]) am[cnt] += ways[mask][(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();} }
6	public class BNew{ double gAns = 0; public static void main( String[] args)throws IOException { new BNew().solve(); } private void solve()throws IOException { MyScanner in = new MyScanner(new BufferedReader(new InputStreamReader(System.in)));  int n = in.nextInt();  int k = in.nextInt();  int A = in.nextInt();  List<Senator> allSenators = new ArrayList<Senator>(); for ( int i = 0;(i < n);i++) { int level = in.nextInt();  int loyalty = in.nextInt(); allSenators.add(new Senator(level,loyalty)); }allSenators = Collections.unmodifiableList(allSenators); int npow2 = (1 << n); rec(allSenators,0,k,A); for ( int okSenatorMask = 0;(okSenatorMask < npow2);okSenatorMask++) { List<Senator> okSenators = copy(getSenatorsByMask(okSenatorMask,allSenators)); liftLeastSenators(okSenators,k); List<Senator> updatedSenators = new ArrayList<Senator>(okSenators);  List<Senator> otherSenators = getSenatorsByMask(((npow2 - 1) - okSenatorMask),allSenators); updatedSenators.addAll(otherSenators); check(updatedSenators,A); }in.close(); PrintWriter pw = new PrintWriter(System.out); System.out.printf("%.6f\n",gAns); pw.close(); } private void rec( List<Senator> senators, int senatorId, int k, int A){ if ( (senatorId == senators.size())) {check(senators,A); return ;} Senator senator = senators.get(senatorId);  int up = Math.min(k,((100 - senator.loyalty) / 10)); final int old = senator.loyalty; for ( int i = 0;(i <= up);i++) {senator.loyalty = (old + (i * 10)); rec(senators,(senatorId + 1),(k - i),A); }senator.loyalty = old; } private void check( List<Senator> senators, double A){ double winProp = 0.0; for ( int mask = 0;(mask < (1 << senators.size()));mask++) { double caseP = 1.0;  int okCnt = 0;  int notOkLevelSum = 0; for ( int i = 0;(i < senators.size());i++) { Senator senator = senators.get(i);  double senatorLoyalty = (senator.loyalty / 100.0);  boolean ok = ((mask & (1 << i)) != 0); if ( ok) {caseP *= senatorLoyalty; okCnt++; } else {caseP *= (1 - senatorLoyalty); notOkLevelSum += senator.level; }}if ( ((okCnt * 2) > senators.size())) {winProp += caseP; } else { double killProp = (A / (A + notOkLevelSum)); winProp += (caseP * killProp); }}gAns = Math.max(gAns,winProp); } List<Senator> copy( List<Senator> senators){ List<Senator> copied = new ArrayList<Senator>(); for ( Senator senator :senators) {copied.add(new Senator(senator.level,senator.loyalty)); }return copied;} void liftLeastSenators( List<Senator> senators, int k){ if ( senators.isEmpty()) {return ;} for ( int i = 0;(i < k);i++) { Senator least = senators.get(0); for ( Senator senator :senators) {if ( (senator.loyalty < least.loyalty)) {least = senator; } }if ( (least.loyalty < 100)) {least.loyalty += 10; } }} List<Senator> getSenatorsByMask( int mask, List<Senator> allSenators){ List<Senator> list = new ArrayList<Senator>(); for ( int i = 0;(i < allSenators.size());i++) {if ( ((mask & (1 << i)) != 0)) {list.add(allSenators.get(i)); } }return list;} static class Senator{ final int level ; int loyalty ; Senator( int level, int loyalty){ this.level = level; this.loyalty = loyalty; } } static class MyScanner{ final BufferedReader myBr ; StringTokenizer st = new StringTokenizer(""); MyScanner( BufferedReader br){ myBr = br; } String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(myBr.readLine()); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} void close()throws IOException { myBr.close(); } } }
0	@SuppressWarnings("unused") public class A{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt();  TreeSet<Integer> set = new TreeSet<Integer>(); set.add(n); try{ String s = Integer.toString(n); s = s.substring(0,(s.length() - 1)); set.add(Integer.parseInt(s)); }catch (Exception e){ } try{ String s = Integer.toString(n); s = (s.substring(0,(s.length() - 2)) + s.charAt((s.length() - 1))); set.add(Integer.parseInt(s)); }catch (Exception e){ } System.out.println(max(set)); } }
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(); } }
3	public class Main{ static int x[] = new int[1005]; static double ans[] = new double[1005]; static int nn ,r ; public static void main( String[] args)throws IOException { StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  Scanner sc = new Scanner(System.in);  int huiwoqingchun = 0; nn = sc.nextInt(); r = sc.nextInt(); for ( int i = 1;(i <= nn);i++) {x[i] = sc.nextInt(); }ans[1] = r; int lajitimu = 0; for ( int i = 2;(i <= nn);i++) {ans[i] = r; for ( int j = 1;(j < i);j++) {if ( (Math.abs((x[j] - x[i])) > (2 * r))) continue; ans[i] = Math.max(ans[i],(ans[j] + Math.sqrt((((4 * r) * r) - ((x[j] - x[i]) * (x[j] - x[i])))))); }} double buzhidaoganma = 0; for ( int c = 1;(c <= nn);c++) System.out.printf("%.12f ",ans[c]); } }
3	public class CFC{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; final long MOD = (((1000L * 1000L) * 1000L) + 7); int[] dx = {0,-1,0,1}; int[] dy = {1,0,-1,0}; void solve()throws IOException { int n = nextInt();  long[] dp0 = new long[(10 + n)];  long[] dp1 = new long[(10 + n)];  long[] pre = new long[(10 + n)]; dp0[0] = 1; String[] arr = new String[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextString(); } String s = "s"; for ( int i = 0;(i < n);i++) {Arrays.fill(dp1,0); if ( (i == 0)) {dp0[0] = 1; dp1[0] = 1; } else {if ( arr[(i - 1)].equals(s)) {for ( int j = 0;(j <= (n + 5));j++) {dp1[j] = pre[j]; }} else {for ( int j = 1;(j <= (n + 5));j++) {dp1[j] = dp0[(j - 1)]; }}}Arrays.fill(pre,0); pre[(n + 5)] = dp1[(n + 5)]; for ( int j = (n + 4);(j >= 0);j--) {pre[j] = (pre[(j + 1)] + dp1[j]); pre[j] %= MOD; }for ( int j = 0;(j <= (n + 5));j++) {dp0[j] = dp1[j]; }} long res = 0; for ( int j = 0;(j <= (n + 5));j++) {res += dp0[j]; res %= MOD; }out(res); } private void out( Object o){ out.print(o); } public CFC()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 CFC(); } 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());} }
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[] = in.nextIntArray(n);  long dp[][] = new long[n][n];  long ct = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (ar[i] > ar[j])) {dp[i][j]++; ct++; } }}for ( int i = (n - 2);(i >= 0);i--) {for ( int j = (i + 1);(j < n);j++) {dp[i][j] += dp[(i + 1)][j]; }} int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int l = (in.nextInt() - 1);  int r = (in.nextInt() - 1);  long val = ((r - l) + 1);  long estimated = ((val * (val - 1)) / 2);  long change = (estimated - dp[l][r]); ct = (ct - dp[l][r]); dp[l][r] = change; ct += dp[l][r]; if ( ((ct % 2) == 0)) {out.println("even"); } else {out.println("odd"); }}} } 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 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){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
0	public class Govnokod{ public static void main( String[] args){ try{ InputStreamReader isr = new InputStreamReader(System.in);  BufferedReader br = new BufferedReader(isr); while(true){ String str = br.readLine();  int i = Integer.parseInt(str); System.out.println(((i * 2) - (i / 2))); return ;} }catch (Exception e){ e.printStackTrace(); } } }
4	public class D{ BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); StringTokenizer stringTokenizer ; String next()throws IOException { while(((stringTokenizer == null) || !stringTokenizer.hasMoreTokens())){stringTokenizer = new StringTokenizer(reader.readLine()); }return stringTokenizer.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} final int MOD = (((1000 * 1000) * 1000) + 7); @SuppressWarnings void solve()throws IOException { final int n = nextInt();  int m = nextInt();  int[] from = new int[m];  int[] to = new int[m]; for ( int i = 0;(i < m);i++) {from[i] = nextInt(); to[i] = nextInt(); } int ans = solve(n,m,from,to); writer.println(ans); writer.close(); } private int solve(final int n, int m, int[] from, int[] to){ final List<List<Integer>> g = new ArrayList<>(); final List<List<Integer>> rg = new ArrayList<>(); for ( int i = 0;(i <= n);i++) {g.add(new ArrayList<Integer>()); rg.add(new ArrayList<Integer>()); } int[] c = new int[(n + 1)];  int[] loop = new int[(n + 1)]; for ( int i = 0;(i < m);i++) { int u = from[i];  int v = to[i]; g.get(u).add(v); rg.get(v).add(u); c[u]++; c[v]++; if ( (u == v)) {loop[u]++; } } class Utils{ int[] prev = new int[(n + 1)]; int[] next = new int[(n + 1)]; int[] used = new int[(n + 1)]; int mark ; int forbidden ; int maxMatch(){ maxMatch = 0; for ( int i = 1;(i <= n);i++) {mark = i; if ( findPath(i)) {maxMatch++; } }return maxMatch;} boolean findPath( int u){ if ( (u == forbidden)) {return false;} used[u] = mark; for ( int v :g.get(u)) {if ( (v == forbidden)) {continue;} if ( ((prev[v] == 0) || ((used[prev[v]] != mark) && findPath(prev[v])))) {prev[v] = u; next[u] = v; return true;} }return false;} int maxMatch = 0; void amend( int u){ if ( findPath(u)) {maxMatch++; } } } int ans = Integer.MAX_VALUE; for ( int i = 1;(i <= n);i++) { Utils utils = new Utils(); utils.forbidden = i; utils.maxMatch(); ans = Math.min(ans,((((((2 * n) - 1) - c[i]) + loop[i]) + (((m - c[i]) + loop[i]) - utils.maxMatch)) + ((n - 1) - utils.maxMatch))); }return ans;} public static void main( String[] args)throws IOException { new D().solve(); } }
6	public class E{ public static void main( String[] args){ new E().solve(); } private int c( int n){ return ((n * (n - 1)) / 2);} public void solve(){ Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  double[][] pb = new double[n][n]; for ( int i = 0;(i < n);++i) for ( int j = 0;(j < n);++j) pb[i][j] = sc.nextDouble(); int m = (1 << n);  double[] dp = new double[m]; dp[0] = 1.0f; for ( int i = 1;(i < m);++i) for ( int j = 0;(j < n);++j) if ( ((i & (1 << j)) != 0)) for ( int k = 0;(k < n);++k) if ( ((i & (1 << k)) == 0)) dp[i] += ((pb[k][j] * dp[(i & (1 << j))]) / c(((n - Integer.bitCount(i)) + 1)));  int w = ((1 << n) - 1); for ( int i = 0;(i < (n - 1));++i) System.out.printf("%.6f ",dp[(w & (1 << i))]); System.out.printf("%.6f\n",dp[(w & (1 << (n - 1)))]); } }
0	public class Main{ public static void main( String[] args){ new Main().run(); } void run(){ Locale.setDefault(Locale.US); try(Scanner in=new Scanner(System.in);PrintWriter out=new PrintWriter(System.out)){solve(in,out); }catch (Exception e){ e.printStackTrace(); } } private void solve( Scanner in, PrintWriter out){ String a = in.nextLine(); out.println("25"); } }
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)); } }
3	public class D{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int inv = 0;  int n = sc.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < arr.length);i++) arr[i] = sc.nextInt(); for ( int i = 0;(i < arr.length);i++) for ( int j = (i + 1);(j < arr.length);j++) if ( (arr[i] > arr[j])) inv++;  boolean odd = ((inv % 2) != 0);  int q = sc.nextInt(); for ( int i = 0;(i < q);i++) { int l = sc.nextInt();  int r = sc.nextInt();  int sz = ((r - l) + 1);  int tot = ((sz * (sz - 1)) / 2); if ( ((tot % 2) != 0)) odd = !odd; if ( odd) pw.println("odd"); else pw.println("even"); }pw.flush(); pw.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(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());} public boolean ready()throws IOException { return br.ready();} } }
2	public class a{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  OutputStream out = new BufferedOutputStream(System.out);  String s[] = br.readLine().trim().split("\\ ");  BigInteger a1 = new BigInteger(s[0]);  BigInteger a = new BigInteger(s[0]);  String q = a.toString();  String q1 = q.substring((q.length() - 1),q.length()); a = a.subtract(new BigInteger(q1)); BigInteger c = new BigInteger("1");  BigInteger b = new BigInteger(s[1]);  int z = check(a,a.toString(),b); if ( (z == 1)) {out.write("0".getBytes()); out.flush(); return ;} while((a.compareTo(c) > 0)){ BigInteger d = a; if ( (d.subtract(c).compareTo(new BigInteger("9")) == -1)) {break;} else { BigInteger mid = a; mid = mid.add(c); mid = mid.divide(new BigInteger("2")); if ( (check(mid,mid.toString(),b) == 1)) {c = mid; c = c.add(new BigInteger("1")); } else {a = mid; }}}q = a.toString(); q1 = q.substring((q.length() - 1),q.length()); a = a.subtract(new BigInteger(q1)); BigInteger ans = a1.subtract(a); ans = ans.add(new BigInteger("1")); out.write(ans.toString().getBytes()); out.flush(); } static int check( BigInteger a, String s, BigInteger b){ int l = s.length();  long z = 0; for ( int i = 0;(i < l);i++) {z += Long.parseLong(s.substring(i,(i + 1))); } BigInteger c = a.subtract(new BigInteger(Long.toString(z))); return (-1 * c.compareTo(b));} }
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());} }
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(); } }
1	public class Main{ BufferedReader in ; StringTokenizer str = null; PrintWriter out ; private String next()throws Exception { while(((str == null) || !str.hasMoreElements()))str = new StringTokenizer(in.readLine()); return str.nextToken();} private int nextInt()throws Exception { return Integer.parseInt(next());} final int oo = Integer.MAX_VALUE; int[][] s ; int n ,ALL ; public void run()throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); n = nextInt(); char[] a = next().toCharArray(); s = new int[n][52]; boolean[] set = new boolean[52]; for ( int i = 0;(i < n);++i) { int pos = get(a[i]); if ( !set[pos]) {++ALL; set[pos] = true; } for ( int j = 0;(j < 52);++j) {if ( (i > 0)) {s[i][j] += s[(i - 1)][j]; } if ( (j == pos)) {s[i][j]++; } }} int ret = oo; for ( int i = 0;(i < n);++i) {ret = Math.min(ret,get(i)); }out.println(ret); out.close(); } private int get( int i){ int lo = (i - 1),hi = n; while(((hi - lo) > 1)){ int m = (lo + ((hi - lo) / 2));  int c = 0; for ( int j = 0;(j < 52);++j) {if ( (sum(j,i,m) > 0)) {++c; } }if ( (c < ALL)) {lo = m; } else {hi = m; }}if ( (hi != n)) {return ((hi - i) + 1);} return oo;} private int sum( int pos, int l, int r){ int ret = s[r][pos]; if ( (l > 0)) ret -= s[(l - 1)][pos]; return ret;} private int get( char x){ if ( (('a' <= x) && (x <= 'z'))) return (int)(x - 'a'); return (int)((x - 'A') + 26);} public static void main( String[] args)throws Exception { new Main().run(); } }
2	public class B implements Runnable{ static private final boolean ONLINE_JUDGE = true; private BufferedReader in ; private PrintWriter out ; private StringTokenizer tok = new StringTokenizer(""); private void init()throws FileNotFoundException { Locale.setDefault(Locale.US); String fileName = ""; if ( (ONLINE_JUDGE && fileName.isEmpty())) {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else {if ( fileName.isEmpty()) {in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); } else {in = new BufferedReader(new FileReader((fileName + ".in"))); out = new PrintWriter((fileName + ".out")); }}} String readString(){ while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken();} int readInt(){ return Integer.parseInt(readString());} public static void main( String[] args){ new B().run(); } long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } @Override public void run(){ try{timeBegin = System.currentTimeMillis(); init(); int n = readInt();  int[] rect1 = solve1(n);  int[] rect2 = solve2(n,rect1); out.printf("! %s %s %s %s %s %s %s %s\n",rect1[0],rect1[1],rect1[2],rect1[3],rect2[0],rect2[1],rect2[2],rect2[3]); out.flush(); out.close(); time(); }catch (Exception e){ e.printStackTrace(); System.exit(-1); } } int ask( int x1, int y1, int x2, int y2){ out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); out.flush(); return readInt();} int ask( int x1, int y1, int x2, int y2, int[] rect){ out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); out.flush(); int res = readInt(); if ( ((((rect[0] >= x1) && (rect[2] <= x2)) && (rect[1] >= y1)) && (rect[3] <= y2))) {res--; } return res;} int[] dropTopAndLeft1( int x2, int y2){ int x1 = x2,y1 = y2;  int left = 1,right = x2; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(mid,1,x2,y2); if ( (count >= 1)) {x1 = mid; left = (mid + 1); } if ( (count == 0)) {right = (mid - 1); } }left = 1; right = y2; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(x1,mid,x2,y2); if ( (count >= 1)) {y1 = mid; left = (mid + 1); } if ( (count == 0)) {right = (mid - 1); } }return new int[]{x1,y1,x2,y2};} private int[] solve1( int n){ int x = -1;  int left = 1,right = n; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(1,1,mid,n); if ( (count >= 1)) {x = mid; right = (mid - 1); } if ( (count == 0)) {left = (mid + 1); } }left = 1; right = n; int y = -1; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(1,1,x,mid); if ( (count >= 1)) {y = mid; right = (mid - 1); } if ( (count == 0)) {left = (mid + 1); } }return dropTopAndLeft1(x,y);} private int[] solve2( int n, int[] rect){ int x = -1;  int left = 1,right = n; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(mid,1,n,n,rect); if ( (count >= 1)) {x = mid; left = (mid + 1); } if ( (count == 0)) {right = (mid - 1); } }left = 1; right = n; int y = -1; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(x,mid,n,n,rect); if ( (count >= 1)) {y = mid; left = (mid + 1); } if ( (count == 0)) {right = (mid - 1); } }return dropTopAndLeft2(x,y,n,rect);} int[] dropTopAndLeft2( int x1, int y1, int n, int[] rect){ int x2 = x1,y2 = y1;  int left = x1,right = n; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(x1,y1,mid,n,rect); if ( (count >= 1)) {x2 = mid; right = (mid - 1); } if ( (count == 0)) {left = (mid + 1); } }left = y1; right = n; while((left <= right)){ int mid = ((left + right) >> 1);  int count = ask(x1,y1,x2,mid,rect); if ( (count == 1)) {y2 = mid; right = (mid - 1); } if ( (count == 0)) {left = (mid + 1); } }return new int[]{x1,y1,x2,y2};} }
0	public class A{ static long l ,r ,A ,B ,C ; static long GCD( long a, long b){ if ( (b == 0)) return a; return GCD(b,(a % b));} static boolean gcd( long a, long b){ return (GCD(a,b) == 1);} static boolean found( long a, long b, long c){ if ( ((b <= a) || (c <= b))) return false; if ( (((a > r) || (b > r)) || (c > r))) return false; if ( ((gcd(a,b) && gcd(b,c)) && !gcd(a,c))) {A = a; B = b; C = c; return true;} if ( found((a + 1),(b + 1),(c + 1))) return true; if ( found((a + 1),b,(c + 1))) return true; if ( found((a + 1),(b + 1),c)) return true; if ( found(a,b,(c + 1))) return true; if ( found(a,(b + 1),(c + 1))) return true; if ( found(a,(b + 1),c)) return true; return found((a + 1),b,c);} public static void main( String[] args){ Scanner sc = new Scanner(System.in); l = sc.nextLong(); r = sc.nextLong(); if ( found(l,(l + 1),(l + 2))) System.out.println(((((A + " ") + B) + " ") + C)); else System.out.println(-1); } }
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){ 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 SimpleCycles(); 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++];} @Override public void close(){ try{stream.close(); }catch (IOException ignored){ } } } interface Solver{ public void solve( int testNumber, InputReader in, PrintWriter out); } class SimpleCycles implements Solver{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  boolean[][] g = new boolean[n][n]; for ( int i = 0;(i < m);++i) { int u = in.nextInt();  int v = in.nextInt(); --u; --v; g[u][v] = g[v][u] = true; } HashMap<Integer,Integer> pointer = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);++i) {pointer.put((1 << i),i); } long[][] dm = new long[(1 << n)][n]; for ( int i = 0;(i < n);++i) {dm[(1 << i)][i] = 1; }for ( int i = 0;(i < (1 << n));++i) {for ( int j = 0;(j < n);++j) {if ( (dm[i][j] == 0)) continue; int k = pointer.get((i - (i & (i - 1)))); for ( int u = (k + 1);(u < n);++u) {if ( (g[j][u] && ((i & (1 << u)) == 0))) {dm[(i | (1 << u))][u] += dm[i][j]; } }}} long res = 0; for ( int i = 0;(i < (1 << n));++i) {for ( int j = 0;(j < n);++j) if ( (Integer.bitCount(i) >= 3)) { int c = pointer.get((i - (i & (i - 1)))); if ( g[c][j]) res += (long)dm[i][j]; } }out.print((res / 2)); } }
3	public class MainG{ static StdIn in = new StdIn(); static PrintWriter out = new PrintWriter(System.out); static long M = ((long)1e9 + 7); public static void main( String[] args){ char[] cs = in.next().toCharArray();  int n = cs.length;  int[] x = new int[n]; for ( int i = 0;(i < n);++i) x[i] = (cs[i] - '0'); long[] dp1 = new long[(n + 1)]; for ( int i = 0;(i < n);++i) dp1[(i + 1)] = ((x[i] + (dp1[i] * 10)) % M); long ans = 0; for ( int d1 = 1;(d1 <= 9);++d1) { long[][] dp2 = new long[2][(n + 1)]; for ( int i = 0;(i < n);++i) {dp2[0][(i + 1)] = ((x[i] >= d1)?(((10 * dp2[0][i]) + 1) % M):dp2[0][i]); for ( int d2 = 0;(d2 < x[i]);++d2) dp2[1][(i + 1)] = ((((d2 >= d1)?(((10 * (dp2[0][i] + dp2[1][i])) + dp1[i]) + 1):(dp2[0][i] + dp2[1][i])) + dp2[1][(i + 1)]) % M); for ( int d2 = x[i];(d2 <= 9);++d2) dp2[1][(i + 1)] = ((((d2 >= d1)?((10 * dp2[1][i]) + dp1[i]):dp2[1][i]) + dp2[1][(i + 1)]) % M); }ans += (dp2[0][n] + dp2[1][n]); }out.println((ans % M)); out.close(); } 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(); } } }
2	public class Main{ BufferedReader in ; StringTokenizer str = null; PrintWriter out ; private String next()throws Exception { if ( ((str == null) || !str.hasMoreElements())) str = new StringTokenizer(in.readLine()); return str.nextToken();} private long nextLong()throws Exception { return Long.parseLong(next());} public void run()throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); long n = nextLong(); if ( (n == 1)) {System.out.println(0); return ;} long k = nextLong();  long t = (((1 - (k - 1)) + ((k * (k + 1)) / 2)) - 1); if ( (t < n)) {System.out.println(-1); return ;} long l = 0;  long r = k; while(((r - l) > 1)){ long m = ((r + l) / 2);  long s = (((1 - m) + ((k * (k + 1)) / 2)) - (((k - m) * ((k - m) + 1)) / 2)); if ( (s >= n)) {r = m; } else {l = m; }}System.out.println(r); out.close(); } public static void main( String[] args)throws Exception { new Main().run(); } }
5	public class Solution15A{ 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 Solution15A().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); } } class Square implements Comparable<Square>{ public Square( int x, int a){ this.x = x; this.a = a; } public int a ,x ; } void solve()throws IOException { int n = readInt();  int t = readInt();  Square[] houses = new Square[n]; for ( int i = 0;(i < n);i++) { int a = readInt();  int b = readInt(); houses[i] = new Square(a,b); }Arrays.sort(houses); int count = 0; for ( int i = 0;(i < n);i++) {if ( (i == 0)) count++; else {if ( (((houses[i].x - (houses[i].a / 2.0)) - t) > (houses[(i - 1)].x + (houses[(i - 1)].a / 2.0)))) count++; }if ( (i == (n - 1))) count++; else {if ( (((houses[i].x + (houses[i].a / 2.0)) + t) <= (houses[(i + 1)].x - (houses[(i + 1)].a / 2.0)))) count++; }}out.println(count); } static long gcd( long a, long b){ while((a != b)){if ( (a < b)) a -= b; else b -= a; }return a;} }
6	public class CF16E{ private void solve( InputReader in, PrintWriter out){ int n = in.nextInt();  double[][] prob = new double[n][n]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {prob[i][j] = in.nextDouble(); }} int[] fish = new int[n]; for ( int i = 0;(i < n);i++) {fish[i] = (1 << i); } double[] res = new double[(1 << n)]; res[0] = 1.0; for ( int mask = 1;(mask < ((1 << n) - 1));mask++) {for ( int i = 0;(i < n);i++) {if ( ((mask & fish[i]) == 0)) {continue;} int lastMask = (mask ^ fish[i]);  int live = n; for ( int j = 0;(j < n);j++) {if ( ((lastMask & fish[j]) != 0)) {live--; } } double p = 0.0; for ( int j = 0;(j < n);j++) {if ( (((lastMask & fish[j]) != 0) || (j == i))) {continue;} p += prob[j][i]; }res[mask] += ((((res[lastMask] * p) * 2) / live) / (live - 1)); }}for ( int i = 0;(i < n);i++) {out.printf("%.6f ",res[(((1 << n) - 1) ^ fish[i])]); }} public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out); new CF16E().solve(in,out); out.close(); } 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 double nextDouble(){ return Double.parseDouble(next());} } }
6	public class Main{ public class BasicInputOutput{ private StringTokenizer strtoken ; private BufferedReader bufferReader ; private BufferedWriter bufferWriter ; private String delim = " \t\n\r\f"; BasicInputOutput(){ delim = " \t\n\r\f"; initialize(); } BasicInputOutput( String s){ delim = s; initialize(); } private void initialize(){ bufferReader = new BufferedReader(new InputStreamReader(System.in)); bufferWriter = new BufferedWriter(new PrintWriter(System.out)); strtoken = null; } private void checkStringTokenizer()throws IOException { if ( ((strtoken == null) || (strtoken.hasMoreTokens() == false))) strtoken = new StringTokenizer(bufferReader.readLine(),delim); } public int getNextInt()throws IOException { checkStringTokenizer(); return Integer.parseInt(strtoken.nextToken());} public double getNextDouble()throws IOException { checkStringTokenizer(); return Double.parseDouble(strtoken.nextToken());} public void write( String var)throws IOException { bufferWriter.write(var); } public <T> void write( char sep, T... var)throws IOException { if ( (var.length == 0)) return ; bufferWriter.write(var[0].toString()); for ( int i = 1;(i < var.length);i++) bufferWriter.write((sep + var[i].toString())); } public void flush()throws IOException { bufferWriter.flush(); } } public static void main( String[] args){ try{new Main().run(); }catch (Exception ex){ ex.printStackTrace(); } } private BasicInputOutput iohandler ; private int n ; private double[][] mat ; private double[][] sum ; private double[] dp ; private int tolive ; private void run()throws Exception { initialize(); solve(); } private void initialize()throws Exception { iohandler = new BasicInputOutput(); n = iohandler.getNextInt(); mat = new double[n][n]; sum = new double[((1 << n) + 10)][n]; dp = new double[(1 << n)]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) {mat[i][j] = iohandler.getNextDouble(); }} private int bitCount( int mask){ int ret = 0; while((mask > 0)){ret++; mask &= (mask - 1); }return ret;} private void solve()throws Exception { double[] ans = new double[n];  int ub = (1 << n); for ( int i = 1;(i < ub);i++) {for ( int j = 0;(j < n);j++) {sum[i][j] = 0; for ( int k = 0;(k < n);k++) if ( ((i & (1 << k)) != 0)) sum[i][j] += mat[k][j];  int cntbit = bitCount(i); if ( (cntbit > 1)) sum[i][j] /= (((double)cntbit * (cntbit - 1.)) / 2.); }}dp[(ub - 1)] = 1.; for ( int mask = (ub - 1);(mask >= 1);mask--) {if ( (dp[mask] == 0.)) continue; for ( int i = 0;(i < n);i++) {if ( ((mask & (1 << i)) == 0)) continue; dp[(mask - (1 << i))] += (sum[mask][i] * dp[mask]); }}for ( int i = 0;(i < n);i++) ans[i] = dp[(1 << i)]; iohandler.write((ans[0] + "")); for ( int i = 1;(i < n);i++) iohandler.write((" " + ans[i])); iohandler.write("\n"); iohandler.flush(); } }
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))); }} }
1	public class TimePass{ InputStream is ; PrintWriter out ; String INPUT = ""; boolean codechef = true; void solve(){ int t = ni(); while((t-- > 0)){ int n = ni();  int root = (int)Math.sqrt((n / 2));  int rootn = (int)Math.sqrt(n); if ( ((n == 1) || ((n % 2) != 0))) {out.println("NO"); continue;} if ( (((root * root) == (n / 2)) || (((rootn * rootn) == n) && ((rootn % 2) == 0)))) {out.println("YES"); } else {out.println("NO"); }}} static long __gcd( long n1, long n2){ long gcd = 1; for ( int i = 1;((i <= n1) && (i <= n2));++i) {if ( (((n1 % i) == 0) && ((n2 % i) == 0))) {gcd = i; } }return gcd;} static long[][] dp ; static long desc( int[] a, int l, int r){ if ( (l == r)) return 0; if ( (dp[l][r] != -1)) return dp[l][r]; dp[l][r] = ((a[r] - a[l]) + Math.min(desc(a,(l + 1),r),desc(a,l,(r - 1)))); return dp[l][r];} static int getMax( int[] arr, int n){ int mx = arr[0]; for ( int i = 1;(i < n);i++) if ( (arr[i] > mx)) mx = arr[i]; return mx;} static void countSort( int[] arr, int n, int exp){ int output[] = new int[n];  int i ;  int count[] = new int[10]; Arrays.fill(count,0); for ( i = 0;(i < n);i++) count[((arr[i] / exp) % 10)]++; for ( i = 1;(i < 10);i++) count[i] += count[(i - 1)]; for ( i = (n - 1);(i >= 0);i--) {output[(count[((arr[i] / exp) % 10)] - 1)] = arr[i]; count[((arr[i] / exp) % 10)]--; }for ( i = 0;(i < n);i++) arr[i] = output[i]; } static int MAX = 1500; static int prime[] ,countdiv[] ; static long gcd( long a, long b){ if ( (a == 0)) return b; return gcd((b % a),a);} static int pow( int a, int b, int p){ long ans = 1,base = a; while((b != 0)){if ( ((b & 1) != 0)) {ans *= base; ans %= p; } base *= base; base %= p; b >>= 1; }return (int)ans;} void run()throws Exception { if ( codechef) oj = true; 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 TimePass().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)); } }
3	public class PaintTheNumers{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int nums = sc.nextInt();  HashSet<Integer> elements = new HashSet<Integer>(); for ( int i = 0;(i < nums);i++) {elements.add(sc.nextInt()); } ArrayList<Integer> sortedElements = new ArrayList<Integer>(elements); Collections.sort(sortedElements); ArrayList<Integer> lcms = new ArrayList<Integer>(); for ( int i = 0;(i < sortedElements.size());i++) { int ele = sortedElements.get(i); for ( int j = 0;(j < lcms.size());j++) {if ( ((ele % lcms.get(j)) == 0)) {continue outer;} }lcms.add(ele); }System.out.println(lcms.size()); sc.close(); } }
1	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();} boolean isPrime( int x){ for ( int i = 2;((i * i) <= x);i++) {if ( ((x % i) == 0)) {return false;} }return true;} void solve(){ int n = nextInt();  int k = nextInt();  ArrayList<Integer> primes = new ArrayList<Integer>(); for ( int i = 2;(i <= n);i++) {if ( isPrime(i)) {primes.add(i); } } int ans = 0; for ( int i = 0;(i < primes.size());i++) {for ( int j = 0;(j < (i - 1));j++) {if ( (((primes.get(j) + primes.get((j + 1))) + 1) == primes.get(i).intValue())) {ans++; break;} }}if ( (ans >= k)) {out.println("YES"); } else {out.println("NO"); }} }
3	public class maestro{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int N = sc.nextInt();  long mod = ((long)Math.pow(10,9) + 7);  long[][] arr = new long[N][N]; arr[0][0] = 1; for ( int i = 1;(i < N);i++) { char c = sc.next().charAt(0); if ( (c == 'f')) {for ( int j = 1;(j < N);j++) arr[i][j] = arr[(i - 1)][(j - 1)]; } else { long sum = 0; for ( int j = (N - 1);(j >= 0);j--) {sum = ((sum + arr[(i - 1)][j]) % mod); arr[i][j] = sum; }}} long ans = 0; for ( int i = 0;(i < N);i++) ans = ((ans + arr[(N - 1)][i]) % mod); System.out.println(ans); } }
4	public class Solve{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int size = ((int)1e7 + 1);  int[] pr = new int[size]; for ( int i = 0;(i < size);i++) {pr[i] = i; }for ( int i = 2;((i * i) < size);i++) {if ( (pr[i] == i)) { int val = (i * i); for ( int j = val;(j <= size);j += val) {pr[j] = (j / val); }} } int t = sc.nextInt();  int[] dp = new int[size]; Arrays.fill(dp,-1); while((t-- > 0)){ int n = sc.nextInt();  int k = sc.nextInt();  int[] ar = new int[n]; for ( int i = 0;(i < n);i++) { int a = sc.nextInt(); ar[i] = pr[a]; } int[] ans = new int[(k + 1)];  int[] ind = new int[(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int h = k;(h >= 0);h--) {if ( (dp[ar[i]] >= ind[h])) {ans[h]++; ind[h] = i; } if ( ((h > 0) && ((ans[(h - 1)] < ans[h]) || ((ans[(h - 1)] == ans[h]) && (ind[(h - 1)] > ind[h]))))) {ans[h] = ans[(h - 1)]; ind[h] = ind[(h - 1)]; } }dp[ar[i]] = i; }out.println((ans[k] + 1)); for ( int i = 0;(i < n);i++) dp[ar[i]] = -1; }out.close(); } }
2	public class C{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ long n = nl();  long S = nl();  long d = 1000000000000000000L; out.println(dfs(d,n,S)); } long dfs( long d, long n, long S){ if ( (d == 0)) return 0L; long ret = 0; for ( int i = 0;(i <= (n / d));i++) {if ( (S <= 0)) {ret += Math.min(((n - (i * d)) + 1),d); } else if ( (S < d)) {ret += dfs((d / 10),((i == (n / d))?(n % d):(d - 1)),S); } S -= (d - 1); }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 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)); } }
6	public class Main{ void solve(){ int m = ni();  long a[][] = new long[m][];  HashMap<Long,Integer> mp = new HashMap<>();  long TS = 0;  long sm[] = new long[m]; for ( int i = 0;(i < m);i++) { int sz = ni(); a[i] = new long[sz]; for ( int j = 0;(j < sz);j++) {a[i][j] = nl(); mp.put(a[i][j],i); sm[i] += a[i][j]; }TS += sm[i]; }if ( ((TS % m) != 0)) {pw.println("No"); return ;} TS /= m; ArrayList<Node> ansForMask[] = new ArrayList[(1 << m)]; for ( int i = 0;(i < (1 << m));i++) ansForMask[i] = new ArrayList<>(); ArrayList<Node> tempList = new ArrayList<>();  int vis[] = new int[m]; for ( int i = 0;(i < m);i++) {for ( int j = 0;(j < a[i].length);j++) { int mask = 0; tempList.clear(); long val = a[i][j],req = Long.MAX_VALUE;  int idx = i,idx2 ; Arrays.fill(vis,0); if ( (sm[i] == TS)) {mask = (1 << i); if ( (ansForMask[mask].size() == 0)) ansForMask[mask].add(new Node(val,i,i)); continue;} while((vis[idx] == 0)){req = (TS - (sm[idx] - val)); if ( !mp.containsKey(req)) continue out; idx2 = mp.get(req); if ( ((vis[idx] == 1) || (idx == idx2))) continue out; if ( (vis[idx2] == 1)) break; vis[idx] = 1; mask += (1 << idx); tempList.add(new Node(req,idx2,idx)); idx = idx2; val = req; }if ( (req != a[i][j])) continue out; mask += (1 << idx); tempList.add(new Node(a[i][j],i,idx)); if ( (ansForMask[mask].size() == 0)) {ansForMask[mask].addAll(tempList); } }} int dp[] = new int[(1 << m)]; dp[0] = 1; for ( int mask = 1;(mask < (1 << m));mask++) {if ( (ansForMask[mask].size() != 0)) {dp[mask] = 1; continue;} for ( int s = mask;(s > 0);s = ((s - 1) & mask)) {if ( ((dp[s] == 1) && (dp[(mask ^ s)] == 1))) {dp[mask] = 1; ansForMask[mask].addAll(ansForMask[s]); ansForMask[mask].addAll(ansForMask[(mask ^ s)]); continue out;} }}if ( (dp[((1 << m) - 1)] == 0)) {pw.println("No"); return ;} pw.println("Yes"); Pair ans[] = new Pair[m]; for ( Node p :ansForMask[((1 << m) - 1)]) {ans[p.id1] = new Pair(p.c,p.id2); }for ( int i = 0;(i < m);i++) pw.println(((ans[i].c + " ") + (ans[i].p + 1))); } class Pair{ long c ; int p ; public Pair( long c, int p){ this.c = c; this.p = p; } } class Node{ long c ; int id1 ; int id2 ; public Node( long c, int id1, int id2){ this.c = c; this.id1 = id1; this.id2 = id2; } } long M = ((long)1e9 + 7); PrintWriter pw ; StringTokenizer st ; BufferedReader br ; void run()throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); pw.flush(); } public static void main( String[] args)throws Exception { new Main().run(); } String ns(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int ni(){ return Integer.parseInt(ns());} long nl(){ return Long.parseLong(ns());} }
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(); } }
6	public class Main{ static Scanner scn = new Scanner(System.in); static FastScanner sc = new FastScanner(); static Mathplus mp = new Mathplus(); static PrintWriter ot = new PrintWriter(System.out); static Random rand = new Random(); static int mod = 1000000007; static long inf = (long)1e17; static int[] dx = {0,1,0,-1}; static int[] dy = {1,0,-1,0}; static int max ; public static void main( String[] args){ int N = sc.nextInt();  ArrayList<Integer>[] l = new ArrayList[N];  HashMap<Long,Integer> map = new HashMap<Long,Integer>();  long sum = 0;  long[] s = new long[N]; for ( int i = 0;(i < N);i++) {l[i] = new ArrayList<Integer>(); int n = sc.nextInt(); for ( int j = 0;(j < n);j++) { int a = sc.nextInt(); map.put((long)a,i); s[i] += a; sum += a; l[i].add(a); }}if ( ((Math.abs(sum) % N) != 0)) {System.out.println("NO"); return ;} long make = (sum / N);  boolean[] dp = new boolean[(1 << N)];  int[] first = new int[(1 << N)];  int[] bef = new int[(1 << N)]; Arrays.fill(first,mod); for ( int i = 0;(i < N);i++) {for ( int a :l[i]) { int used = 0;  boolean f = true;  long now = a;  int see = i; while(true){ long next = (make - (s[see] - now)); if ( (next == a)) {break;} if ( !map.containsKey(next)) {f = false; break;} else { int k = map.get(next); if ( (mp.contains(used,k) && (k != i))) {f = false; break;} else {used = mp.bitadd(used,k); now = next; see = k; }}}if ( f) {dp[mp.bitadd(used,i)] = true; first[mp.bitadd(used,i)] = a; } }}dp[0] = true; for ( int i = 1;(i < (1 << N));i++) {for ( int j = i;(j > 0);j = ((j - 1) & i)) {if ( (dp[(i ^ j)] && dp[j])) {dp[i] = true; bef[i] = j; } }}if ( !dp[((1 << N) - 1)]) {System.out.println("NO"); } else {System.out.println("YES"); ArrayDeque<Integer> q = new ArrayDeque<Integer>();  int[] ans1 = new int[N];  int[] ans2 = new int[N]; q.add(((1 << N) - 1)); while(!q.isEmpty()){ int Q = q.poll(); if ( (first[Q] == mod)) {q.add(bef[Q]); q.add((Q ^ bef[Q])); } else { int a = first[Q];  long now = a;  int befo = map.get((long)a); while(true){ long next = (make - (s[befo] - now)); if ( (next == a)) { int k = map.get(next); ans1[k] = (int)next; ans2[k] = befo; break;} int k = map.get(next); ans1[k] = (int)next; ans2[k] = befo; now = next; befo = k; }}}for ( int i = 0;(i < N);i++) {System.out.println(((ans1[i] + " ") + (ans2[i] + 1))); }}} } class TrieNode{ int[] Exist = new int[26]; int weight = 0; TrieNode(){ for ( int i = 0;(i < 26);i++) {Exist[i] = -1; }} } class Range{ int l ; int r ; int length ; Range( int L, int R){ l = L; r = R; length = ((R - L) + 1); } boolean isIn( int x){ return ((l <= x) && (x <= r));} } class UnionFindTree{ int[] root ; int[] rank ; int[] size ; int[] edge ; int num ; UnionFindTree( int N){ root = new int[N]; rank = new int[N]; size = new int[N]; edge = new int[N]; num = N; for ( int i = 0;(i < N);i++) {root[i] = i; size[i] = 1; }} public int find( int x){ if ( (root[x] == x)) {return x;} else {return find(root[x]);}} public void unite( int x, int y){ x = find(x); y = find(y); if ( (x == y)) {edge[x]++; return ;} else {num--; if ( (rank[x] < rank[y])) {root[x] = y; size[y] += size[x]; edge[y] += (edge[x] + 1); } else {root[y] = x; size[x] += size[y]; edge[x] += (edge[y] + 1); if ( (rank[x] == rank[y])) {rank[x]++; } }}} public boolean same( int x, int y){ return (find(x) == find(y));} } class Graph{ ArrayList<Edge>[] list ; int size ; TreeSet<LinkEdge> Edges = new TreeSet<LinkEdge>(new LinkEdgeComparator()); Graph( int N){ size = N; list = new ArrayList[N]; for ( int i = 0;(i < N);i++) {list[i] = new ArrayList<Edge>(); }} void addEdge( int a, int b){ list[a].add(new Edge(b,1)); } void addWeightedEdge( int a, int b, long c){ list[a].add(new Edge(b,c)); } long[][] bfs( int s){ long[][] L = new long[2][size]; for ( int i = 0;(i < size);i++) {L[0][i] = -1; L[1][i] = -1; }L[0][s] = 0; ArrayDeque<Integer> Q = new ArrayDeque<Integer>(); Q.add(s); while(!Q.isEmpty()){ int v = Q.poll(); for ( Edge e :list[v]) { int w = e.to;  long c = e.cost; if ( (L[0][w] == -1)) {L[0][w] = (L[0][v] + c); L[1][w] = v; Q.add(w); } }}return L;} RootedTree dfsTree( int i){ int[] u = new int[size];  RootedTree r = new RootedTree(size); dfsTree(i,u,r); return r;} private void dfsTree( int i, int[] u, RootedTree r){ u[i] = 1; for ( Edge e :list[i]) {if ( (u[e.to] == 0)) {r.list[i].add(e); u[e.to] = 1; dfsTree(e.to,u,r); } }} } class RootedTree extends Graph{ RootedTree( int N){ super(N); } } class LinkEdge{ long L ; int a ; int b ; LinkEdge( long l, int A, int B){ L = l; a = A; b = B; } public boolean equals( Object o){ LinkEdge O = (LinkEdge)o; return (((O.a == this.a) && (O.b == this.b)) && (O.L == this.L));} } class Edge{ int to ; long cost ; Edge( int a, long b){ to = a; cost = b; } } class LinkEdgeComparator implements Comparator<LinkEdge>{ } class Pair{ long a ; long b ; Pair( long p, long q){ this.a = p; this.b = q; } public boolean equals( Object o){ Pair O = (Pair)o; return ((O.a == this.a) && (O.b == this.b));} } class SampleComparator implements Comparator<Pair>{ } class LongIntPair{ long a ; int b ; LongIntPair( long p, int q){ this.a = p; this.b = q; } public boolean equals( Object o){ Pair O = (Pair)o; return ((O.a == this.a) && (O.b == this.b));} } class LongIntSampleComparator implements Comparator<LongIntPair>{ } class IntIntPair{ int a ; int b ; IntIntPair( int p, int q){ this.a = p; this.b = q; } public boolean equals( Object o){ Pair O = (Pair)o; return ((O.a == this.a) && (O.b == this.b));} } class DoubleTriplet{ double a ; double b ; double c ; DoubleTriplet( double p, double q, double r){ this.a = p; this.b = q; this.c = r; } public boolean equals( Object o){ DoubleTriplet O = (DoubleTriplet)o; return (((O.a == this.a) && (O.b == this.b)) && (O.c == this.c));} } class FastScanner{ private final java.io.InputStream in = System.in; private final byte[] b = new byte[1024]; private int p = 0; private int bl = 0; private boolean hNB(){ if ( (p < bl)) {return true;} else {p = 0; try{bl = in.read(b); }catch (IOException e){ e.printStackTrace(); } if ( (bl <= 0)) {return false;} }return true;} private int rB(){ if ( hNB()) return b[p++]; else return -1;} static private boolean iPC( int c){ return ((33 <= c) && (c <= 126));} private void sU(){ while((hNB() && !iPC(b[p])))p++; } public boolean hN(){ sU(); return hNB();} public String next(){ if ( !hN()) throw (new NoSuchElementException()); StringBuilder sb = new StringBuilder();  int b = rB(); while(iPC(b)){sb.appendCodePoint(b); b = rB(); }return sb.toString();} public long nextLong(){ if ( !hN()) throw (new NoSuchElementException()); long n = 0;  boolean m = false;  int b = rB(); if ( (b == '-')) {m = true; b = rB(); } if ( ((b < '0') || ('9' < b))) {throw (new NumberFormatException());} while(true){if ( (('0' <= b) && (b <= '9'))) {n *= 10; n += (b - '0'); } else if ( ((b == -1) || !iPC(b))) {return (m?-n:n);} else {throw (new NumberFormatException());}b = rB(); }} public int nextInt(){ if ( !hN()) throw (new NoSuchElementException()); long n = 0;  boolean m = false;  int b = rB(); if ( (b == '-')) {m = true; b = rB(); } if ( ((b < '0') || ('9' < b))) {throw (new NumberFormatException());} while(true){if ( (('0' <= b) && (b <= '9'))) {n *= 10; n += (b - '0'); } else if ( ((b == -1) || !iPC(b))) {return (int)(m?-n:n);} else {throw (new NumberFormatException());}b = rB(); }} } class Mathplus{ int mod = 1000000007; long[] fac ; long[] revfac ; long[][] comb ; long[] pow ; long[] revpow ; boolean isBuild = false; boolean isBuildc = false; boolean isBuildp = false; int mindex = -1; int maxdex = -1; void buildFac(){ fac = new long[10000003]; revfac = new long[10000003]; fac[0] = 1; for ( int i = 1;(i <= 10000002);i++) {fac[i] = ((fac[(i - 1)] * i) % mod); }revfac[10000002] = (rev(fac[10000002]) % mod); for ( int i = 10000001;(i >= 0);i--) {revfac[i] = ((revfac[(i + 1)] * (i + 1)) % mod); }isBuild = true; } public boolean contains( int S, int i){ return (((S >> i) & 1) == 1);} public int bitremove( int S, int i){ return (S & (1 << i));} public int bitadd( int S, int i){ return (S | (1 << i));} long max( long[] a){ long M = 0; for ( int i = 0;(i < a.length);i++) {if ( (M < a[i])) {M = a[i]; maxdex = i; } }return M;} int max( int[] a){ int M = 0; for ( int i = 0;(i < a.length);i++) {if ( (M < a[i])) {M = a[i]; maxdex = i; } }return M;} long min( long[] a){ long m = Long.MAX_VALUE; for ( int i = 0;(i < a.length);i++) {if ( (m > a[i])) {m = a[i]; mindex = i; } }return m;} int min( int[] a){ int m = Integer.MAX_VALUE; for ( int i = 0;(i < a.length);i++) {if ( (m > a[i])) {m = a[i]; mindex = i; } }return m;} long gcd( long a, long b){ a = Math.abs(a); b = Math.abs(b); if ( (a == 0)) return b; if ( (b == 0)) return a; if ( ((a % b) == 0)) return b; else return gcd(b,(a % b));} int igcd( int a, int b){ if ( ((a % b) == 0)) return b; else return igcd(b,(a % b));} public long comb( int a, int num){ if ( ((a - num) < 0)) return 0; if ( (num < 0)) return 0; if ( !isBuild) buildFac(); return ((fac[a] * ((revfac[num] * revfac[(a - num)]) % mod)) % mod);} long rev( long l){ return pow(l,(mod - 2));} void buildpow( int l, int i){ pow = new long[(i + 1)]; pow[0] = 1; for ( int j = 1;(j <= i);j++) {pow[j] = (pow[(j - 1)] * l); if ( (pow[j] > mod)) pow[j] %= mod; }} void buildrevpow( int l, int i){ revpow = new long[(i + 1)]; revpow[0] = 1; for ( int j = 1;(j <= i);j++) {revpow[j] = (revpow[(j - 1)] * l); if ( (revpow[j] > mod)) revpow[j] %= mod; }} long pow( long l, long i){ if ( (i == 0)) return 1; else {if ( ((i % 2) == 0)) { long val = pow(l,(i / 2)); return ((val * val) % mod);} else return ((pow(l,(i - 1)) * l) % mod);}} }
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)); }} }
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());} } }
4	public class Main{ public static void main( String[] args)throws IOException { InputStream input = System.in;  OutputStream output = System.out;  InputReader in = new InputReader(new FileReader(new File("input.txt")));  PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));  Solution s = new Solution(); s.solve(1,in,out); out.close(); } static class Solution{ static int[][] grid ; static int[] dx = {0,0,1,-1}; static int[] dy = {1,-1,0,0}; static int n ,m ; public void solve( int cs, InputReader in, PrintWriter out){ n = in.nextInt(); m = in.nextInt(); int k = in.nextInt(); grid = new int[n][m]; for ( int[] d :grid) Arrays.fill(d,-1); for ( int i = 0;(i < k);i++) { Pair tree = new Pair((in.nextInt() - 1),(in.nextInt() - 1)); bfs(tree); } int max = 0,idx1 = 0,idx2 = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (grid[i][j] > max)) {max = grid[i][j]; idx1 = i; idx2 = j; } }}out.printf("%d %d%n",(idx1 + 1),(idx2 + 1)); } public boolean isValid( int i, int j){ return ((((i >= 0) && (i < n)) && (j >= 0)) && (j < m));} static class Pair{ int x ,y ; public Pair( int x, int y){ this.x = x; this.y = y; } } public void bfs( Pair src){ Queue<Pair> q = new LinkedList<>(); grid[src.x][src.y] = 0; q.add(src); while(!q.isEmpty()){ Pair p = q.poll(); for ( int k = 0;(k < 4);k++) { int nx = (p.x + dx[k]);  int ny = (p.y + dy[k]); if ( isValid(nx,ny)) {if ( ((grid[nx][ny] > (grid[p.x][p.y] + 1)) || (grid[nx][ny] == -1))) {grid[nx][ny] = (grid[p.x][p.y] + 1); q.add(new Pair(nx,ny)); } } }}} } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream i){ br = new BufferedReader(new InputStreamReader(i),32768); st = null; } public InputReader( FileReader s){ br = new BufferedReader(s); 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 int nextInt(){ return Integer.parseInt(next());} } }
3	public class Main{ public static void main( String[] args)throws IOException { int n = in.nextInt();  int[] a = in.nextIntArray(n); sort(a); int ans = 0;  boolean[] done = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( done[i]) continue; ans++; for ( int j = (i + 1);(j < n);j++) if ( ((a[j] % a[i]) == 0)) done[j] = true; }out.write((ans + "\n")); out.flush(); } public static FastReader in = new FastReader(); public static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); } class FastReader{ BufferedReader br ; StringTokenizer st ; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.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());} public long nextLong(){ return Long.parseLong(next());} public double nextDouble(){ return Double.parseDouble(next());} public int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} }
0	public class loser{ static class InputReader{ public BufferedReader br ; public StringTokenizer token ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream),32768); token = null; } public String next(){ while(((token == null) || !token.hasMoreTokens())){try{token = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return token.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } static void shuffle( long[] a){ List<Long> l = new ArrayList<>(); for ( int i = 0;(i < a.length);i++) l.add(a[i]); Collections.shuffle(l); for ( int i = 0;(i < a.length);i++) a[i] = l.get(i); } public static void main( String[] args){ InputReader sc = new InputReader(System.in);  int k = sc.nextInt();  int n = sc.nextInt();  int s = sc.nextInt();  int p = sc.nextInt();  long d = (long)Math.ceil(((double)n / s)); if ( (d == 0)) d = 1; d = (k * d); long ans = (long)Math.ceil(((double)d / p)); System.out.println(ans); } }
2	public class B176{ public static void main( String[] args){ Scanner in = new Scanner(new BufferedInputStream(System.in));  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  long n = (in.nextLong() - 1);  long k = (in.nextLong() - 1); if ( (((k * (k + 1)) / 2) < n)) out.println(-1); else if ( (n == 0)) out.println(0); else if ( (n < k)) out.println(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++; out.println(ans); }out.close(); } static private 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);} }
1	public class Solution{ public static void main( String[] args)throws IOException { PrintWriter pw = new PrintWriter(System.out);  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()); st = new StringTokenizer(br.readLine()); String str = st.nextToken();  char[] arr = str.toCharArray(); Arrays.sort(arr); int weight = (arr[0] - 96);  char a = arr[0];  int included = 1; for ( int i = 1;(i < arr.length);++i) {if ( (included == k)) break; char c = arr[i]; if ( ((c - a) < 2)) continue; weight += (arr[i] - 96); ++included; a = arr[i]; }if ( (included == k)) pw.println(weight); else pw.println(-1); pw.close(); } }
5	public class Main{ public static void main( String[] args)throws IOException { Scanner c = new Scanner(System.in);  int N = c.nextInt();  int A[] = new int[N]; for ( int i = 0;(i < N);i++) {A[i] = c.nextInt(); }Arrays.sort(A); int sum = 0; for ( int i = 0;(i < N);i++) {sum += A[i]; } int my = 0;  int coins = 0; for ( int i = (N - 1);(i >= 0);i--) {coins++; my += A[i]; if ( (my > (sum - my))) {System.out.println(coins); break;} }} }
0	public class P1{ public static void main( String[] args){ System.out.println("25"); } }
5	public class A implements Runnable{ String file = "input"; boolean TEST = (System.getProperty("ONLINE_JUDGE") == null); void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); int[] b = a.clone(); qsort(b); int count = 0; for ( int i = 0;(i < a.length);i++) if ( (a[i] != b[i])) count++; if ( ((count == 0) || (count == 2))) out.println("YES"); else out.println("NO"); } void qsort( int[] a){ List<Integer> as = new ArrayList<Integer>(); for ( int x :a) as.add(x); Collections.shuffle(as); for ( int i = 0;(i < a.length);i++) a[i] = as.get(i); sort(a); } Random rnd = new Random(); void sortInt( int[] a){ sortInt(a,0,(a.length - 1)); } void sortInt( int[] a, int from, int to){ if ( (from >= to)) return ; int i = (from - 1);  int p = (rnd.nextInt(((to - from) + 1)) + from);  int t = a[p]; a[p] = a[to]; a[to] = t; for ( int j = from;(j < to);j++) if ( (a[j] <= a[to])) {i++; t = a[i]; a[i] = a[j]; a[j] = t; } t = a[(i + 1)]; a[(i + 1)] = a[to]; a[to] = t; sortInt(a,(i + 2),to); while(((i >= 0) && (a[i] == a[(i + 1)])))i--; sortInt(a,from,i); } String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(input.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} BufferedReader input ; PrintWriter out ; StringTokenizer st ; int test ; void init()throws IOException { if ( TEST) input = new BufferedReader(new FileReader((file + ".in"))); else input = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new BufferedOutputStream(System.out)); } public static void main( String[] args)throws IOException { new Thread(null,new A(),"",(1 << 22)).start(); } }
4	public class Main{ static class Run implements Runnable{ final boolean consoleIO = false; final String inFile = "input.txt"; final String outFile = "output.txt"; int n ,m ,k ; int[][] field ; boolean[][] visited ; LinkedList<Point> queue ; int[][] steps = {{0,1},{1,0},{0,-1},{-1,0}}; void wave(){ for ( Point p :queue) visited[p.y][p.x] = true; while(!queue.isEmpty()){ Point cur = queue.removeFirst(); for ( int i = 0;(i < steps.length);++i) { Point tmp = new Point((cur.x + steps[i][0]),(cur.y + steps[i][1])); if ( (ok(tmp) && !visited[tmp.y][tmp.x])) {queue.add(tmp); visited[tmp.y][tmp.x] = true; field[tmp.y][tmp.x] = (field[cur.y][cur.x] + 1); } }}} boolean ok( Point p){ return ((((p.x >= 0) && (p.y >= 0)) && (p.x < n)) && (p.y < m));} @Override public void run(){ n = nextInt(); m = nextInt(); k = nextInt(); queue = new LinkedList<Point>(); for ( int i = 0;(i < k);++i) queue.add(new Point((nextInt() - 1),(nextInt() - 1))); field = new int[m][n]; visited = new boolean[m][n]; wave(); Point maxP = new Point(0,0);  int maxV = Integer.MIN_VALUE; for ( int i = 0;(i < m);++i) for ( int j = 0;(j < n);++j) if ( (field[i][j] > maxV)) {maxV = field[i][j]; maxP = new Point(j,i); } print((((maxP.x + 1) + " ") + (maxP.y + 1))); close(); } 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 C{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  Solver solver = new Solver(); solver.solve(in,out); out.close(); } static class Solver{ public void solve( InputReader in, PrintWriter out){ int n = in.nextInt();  String s = in.next();  HashMap<Character,Integer> map = new HashMap<>(); for ( int i = 0;(i < n);++i) {map.put(s.charAt(i),0); } int l = 0,r = 0,cnt = 0,ans = n;  char c ; while((l < n)){while(((r < n) && (cnt < map.size()))){c = s.charAt(r); map.put(c,(map.get(c) + 1)); if ( (map.get(c) == 1)) ++cnt; ++r; }if ( ((cnt == map.size()) && ((r - l) < ans))) ans = (r - l); c = s.charAt(l); map.put(c,(map.get(c) - 1)); if ( (map.get(c) == 0)) --cnt; ++l; }out.println(ans); } } 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{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 Main{ public static void main( String[] args)throws FileNotFoundException { ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in),new PrintWriter(System.out)); new Main(io).solve(); io.close(); } ConsoleIO io ; Main( ConsoleIO io){ this.io = io; } ConsoleIO opt ; Main( ConsoleIO io, ConsoleIO opt){ this.io = io; this.opt = opt; } List<List<Integer>> gr = new ArrayList<>(); long MOD = 1_000_000_007; public void solve(){ StringBuilder sb = new StringBuilder();  int q = io.ri(); for ( int i = 0;(i < q);i++) { long n = io.readLong();  long k = io.readLong(); if ( (i > 0)) sb.append(System.lineSeparator());  boolean done = false; if ( ((n == 2) && (k == 3))) {sb.append("NO"); done = true; } for ( int p = 0;((n > 0) && !done);p++,n--) { long count = (1L << (p * 2)); if ( (k > count)) {k -= count; } else { long path = ((p == 0)?1:((((1L << (p - 1)) * 2) + (((1L << (p - 1)) - 1) * 2)) + 1)); if ( (k < path)) {sb.append(("YES " + n)); } else {sb.append(("YES " + (n - 1))); }done = true; }}if ( !done) {sb.append("NO"); } }io.writeLine(sb.toString()); } } class ConsoleIO{ BufferedReader br ; PrintWriter out ; public ConsoleIO( Reader reader, PrintWriter writer){ br = new BufferedReader(reader); out = writer; } public void flush(){ this.out.flush(); } public void close(){ this.out.close(); } public void writeLine( String s){ this.out.println(s); } public int read( char[] buf, int len){ try{return br.read(buf,0,len); }catch (Exception ex){ return -1;} } public String readLine(){ try{return br.readLine(); }catch (Exception ex){ return "";} } public int ri(){ try{ int r = 0;  boolean start = false;  boolean neg = false; while(true){ int c = br.read(); if ( ((c >= '0') && (c <= '9'))) {r = (((r * 10) + c) - '0'); start = true; } else if ( (!start && (c == '-'))) {start = true; neg = true; } else if ( (start || (c == -1))) return (neg?-r:r); } }catch (Exception ex){ return -1;} } public long readLong(){ try{ long r = 0;  boolean start = false;  boolean neg = false; while(true){ int c = br.read(); if ( ((c >= '0') && (c <= '9'))) {r = (((r * 10) + c) - '0'); start = true; } else if ( (!start && (c == '-'))) {start = true; neg = true; } else if ( (start || (c == -1))) return (neg?-r:r); } }catch (Exception ex){ return -1;} } }
5	public class ProblemA{ private void solve()throws IOException { Scanner stdin = new Scanner(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int n = Integer.valueOf(stdin.nextInt());  int[] p = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = stdin.nextInt(); }Arrays.sort(p); if ( (p[(n - 1)] == 1)) {p[(n - 1)] = 2; } else {p[(n - 1)] = 1; out.print((p[(n - 1)] + " ")); n--; }for ( int i = 0;(i < n);i++) {out.print((p[i] + " ")); }out.flush(); out.close(); } public static void main( String[] args)throws IOException { ProblemA solver = new ProblemA(); solver.solve(); } }
5	public class a{ static int a ; static Scanner sc = new Scanner(System.in); public static void main( String[] args)throws IOException { int n = sc.nextInt();  int p = n;  int m = sc.nextInt();  int k = sc.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = (sc.nextInt() - 1); }Arrays.sort(a); int j = 0; for ( int i = 0;(i < n);i++) {if ( (m > k)) {k = (k + a[((n - i) - 1)]); j++; } }if ( (m > k)) System.out.println(-1); else System.out.println(j); } }
4	public class C{ static private FastReader fr = new FastReader(); static private PrintWriter out = new PrintWriter(System.out); static private Random random = new Random(); public static void main( String[] args)throws IOException { StringBuilder sb = new StringBuilder();  int t = fr.nextInt(); while((t-- > 0)){ int n = fr.nextInt();  int[] arr = fr.nextIntArray(n); sb.append(1).append("\n"); List<Integer> state = new ArrayList<>(); state.add(1); for ( int i = 1;(i < n);i++) { List<Integer> nextState = new ArrayList<>();  boolean found = false;  int till = -1; for ( int j = (state.size() - 1);(j >= 0);j--) {if ( ((state.get(j) + 1) == arr[i])) {till = j; found = true; break;} }if ( found) {for ( int j = 0;(j < till);j++) {nextState.add(state.get(j)); }nextState.add(arr[i]); sb.append(nextState.get(0)); for ( int z = 1;(z < nextState.size());z++) {sb.append(".").append(nextState.get(z)); }sb.append("\n"); } if ( !found) {nextState.addAll(state); nextState.add(arr[i]); sb.append(nextState.get(0)); for ( int z = 1;(z < nextState.size());z++) {sb.append(".").append(nextState.get(z)); }sb.append("\n"); } state = nextState; }}System.out.print(sb.toString()); } static class FastReader{ 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 (IOException e){ e.printStackTrace(); } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public int[] nextIntArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} public long nextLong(){ return Long.parseLong(next());} } static long power( long x, long y, long p){ long res = 1; x = (x % p); while((y > 0)){if ( ((y % 2) == 1)) res = ((res * x) % p); y = (y >> 1); x = ((x * x) % p); }return res;} static long modInverse( long n, long p){ return power(n,(p - 2),p);} }
3	public class PythInd{ public static final int MOD = 1000000007; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = Integer.parseInt(sc.nextLine());  String[] sTypes = new String[n]; for ( int i = 0;(i < n);i++) {sTypes[i] = sc.nextLine(); }sc.close(); int[][] dp = new int[n][n]; dp[0][0] = 1; for ( int i = 0;(i < (dp.length - 1));i++) {if ( sTypes[i].equals("s")) { int curSum = 0; for ( int j = (i + 1);(j >= 0);j--) {curSum = ((dp[i][j] + curSum) % MOD); dp[(i + 1)][j] += curSum; dp[(i + 1)][j] %= MOD; }} else {for ( int j = 1;(j <= (i + 1));j++) {dp[(i + 1)][j] += dp[i][(j - 1)]; dp[(i + 1)][j] %= MOD; }}} int ans = 0; for ( int i = 0;(i < dp[0].length);i++) {ans = ((ans + dp[(n - 1)][i]) % MOD); }System.out.println(ans); } }
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); } }
0	public class two_squares{ public static void main( String[] args)throws Exception { new two_squares().run(); } public void run()throws Exception { FastIO file = new FastIO();  double x1 = file.nextInt();  double y1 = file.nextInt();  double x2 = file.nextInt();  double y2 = file.nextInt();  double x3 = file.nextInt();  double y3 = file.nextInt();  double x4 = file.nextInt();  double y4 = file.nextInt();  double minx1 ,maxx1 ,miny1 ,maxy1 ; minx1 = Math.min(x1,Math.min(x2,Math.min(x3,x4))); maxx1 = Math.max(x1,Math.max(x2,Math.max(x3,x4))); miny1 = Math.min(y1,Math.min(y2,Math.min(y3,y4))); maxy1 = Math.max(y1,Math.max(y2,Math.max(y3,y4))); double x5 = file.nextInt();  double y5 = file.nextInt();  double x6 = file.nextInt();  double y6 = file.nextInt();  double x7 = file.nextInt();  double y7 = file.nextInt();  double x8 = file.nextInt();  double y8 = file.nextInt();  double minx2 ,maxx2 ,miny2 ,maxy2 ; minx2 = Math.min(x5,Math.min(x6,Math.min(x7,x8))); maxx2 = Math.max(x5,Math.max(x6,Math.max(x7,x8))); miny2 = Math.min(y5,Math.min(y6,Math.min(y7,y8))); maxy2 = Math.max(y5,Math.max(y6,Math.max(y7,y8))); Point _1 ,_2 ,_3 ,_4 ,_5 ,_6 ,_7 ,_8 ,_9 ,_10 ,_11 ,_12 ,_13 ,_14 ,_15 ,_16 ; _1 = new Point(x1,y1); _2 = new Point(x2,y2); _3 = new Point(x3,y3); _4 = new Point(x4,y4); _5 = new Point(x5,y5); _6 = new Point(x6,y6); _7 = new Point(x7,y7); _8 = new Point(x8,y8); _9 = new Point(minx1,maxy1); _10 = new Point(minx1,miny1); _11 = new Point(maxx1,maxy1); _12 = new Point(maxx1,miny1); double m1 = ((minx2 + maxx2) / 2);  double m2 = ((miny2 + maxy2) / 2); _13 = new Point(minx2,m2); _14 = new Point(m1,miny2); _15 = new Point(maxx2,m2); _16 = new Point(m1,maxy2); Point[] a = {_1,_2,_3,_4};  Point[] b = {_5,_6,_7,_8};  boolean works = false;  Line[] aa = {new Line(_9,_10),new Line(_10,_12),new Line(_12,_11),new Line(_11,_9)};  Line[] bb = {new Line(_13,_14),new Line(_14,_15),new Line(_15,_16),new Line(_16,_13)}; for ( int i = 0;(i < 4);i++) {for ( int j = 0;(j < 4);j++) {if ( (aa[i].intersection(bb[i]) != null)) {works = true; } }}for ( Point p :b) {if ( ((((p.x >= minx1) && (p.x <= maxx1)) && (p.y >= miny1)) && (p.y <= maxy1))) {works = true; } }for ( Point p :a) { boolean result = false; for ( int i = 0,j = (b.length - 1);(i < b.length);j = i++) {if ( (((b[i].y > p.y) != (b[j].y > p.y)) && (p.x < ((((b[j].x - b[i].x) * (p.y - b[i].y)) / (b[j].y - b[i].y)) + b[i].x)))) {result = !result; } }if ( result) works = true; }System.out.println((works?"YES":"NO")); } public static class Point{ double x ,y ; public Point( double a, double b){ x = a; y = b; } } public static class Line{ Point a ,b ; public Line( Point x, Point y){ a = x; b = y; } public Point intersection( Line o){ double x1 = a.x;  double y1 = a.y;  double x2 = b.x;  double y2 = b.y;  double x3 = o.a.x;  double y3 = o.a.y;  double x4 = o.b.x;  double y4 = o.b.y;  double denom = (((y4 - y3) * (x2 - x1)) - ((x4 - x3) * (y2 - y1)));  double ua = ((((x4 - x3) * (y1 - y3)) - ((y4 - y3) * (x1 - x3))) / denom);  double ub = ((((x2 - x1) * (y1 - y3)) - ((y2 - y1) * (x1 - x3))) / denom); if ( ((((ua >= 0.0f) && (ua <= 1.0f)) && (ub >= 0.0f)) && (ub <= 1.0f))) {return new Point((int)(x1 + (ua * (x2 - x1))),(int)(y1 + (ua * (y2 - y1))));} return null;} } public static class FastIO{ BufferedReader br ; StringTokenizer st ; public FastIO(){ 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 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 long gcd( long x, long y){ if ( (x == 0)) return y; else return gcd((y % x),x);} }
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)); } }
4	public class C{ 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();  ArrayList<Integer> arrli[] = new ArrayList[n]; for ( int i = 0;(i < n);i++) {arrli[i] = new ArrayList<>(); }for ( int i = 0;(i < n);i++) { int tmp = input.scanInt(); if ( (i == 0)) {arrli[0].add(1); continue;} if ( (tmp == 1)) {for ( int j = 0;(j < arrli[(i - 1)].size());j++) {arrli[i].add(arrli[(i - 1)].get(j)); }arrli[i].add(tmp); continue;} int indx = -1; for ( int j = 0;(j < arrli[(i - 1)].size());j++) {if ( (arrli[(i - 1)].get(j) == (tmp - 1))) {indx = j; } }for ( int j = 0;(j < indx);j++) {arrli[i].add(arrli[(i - 1)].get(j)); }arrli[i].add(tmp); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < arrli[i].size());j++) {ans.append(arrli[i].get(j)); if ( (j != (arrli[i].size() - 1))) {ans.append("."); } }ans.append("\n"); }}System.out.println(ans); } }
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); } }
4	public class practice{ public static void main( String[] args)throws FileNotFoundException { Scanner scn = new Scanner(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = scn.nextInt(),m = scn.nextInt(),k = scn.nextInt();  int[][] inf = new int[k][2]; for ( int i = 0;(i < k);i++) {inf[i][0] = scn.nextInt(); inf[i][1] = scn.nextInt(); } int ans = 0,x = 1,y = 1; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) { int temp = Integer.MAX_VALUE; for ( int l = 0;(l < k);l++) {temp = Math.min(temp,(Math.abs((i - inf[l][0])) + Math.abs((j - inf[l][1])))); }if ( (temp > ans)) {ans = temp; x = i; y = j; } }}out.print(((x + " ") + y)); out.close(); } }
2	public class ProblemD{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer tok ; private final String DELIMETER = " "; private final boolean ENABLE_MULTITEST = false; private final boolean DEBUG = true; private final String FILENAME = null; public void run()throws Exception { initInputOutput(); do {init(); solve(); }while((hasMoreTokens() && ENABLE_MULTITEST));finish(); } private void init()throws Exception { } private void solve()throws Exception { String a = Long.toBinaryString(nextLong());  String b = Long.toBinaryString(nextLong()); while((a.length() < 64)){a = ("0" + a); }while((b.length() < 64)){b = ("0" + b); } char[] res = new char[a.length()];  int cur = 0; while(((cur < a.length()) && (a.charAt(cur) == b.charAt(cur)))){res[cur] = '0'; cur++; }while((cur < res.length)){res[cur] = '1'; cur++; }out.println(Long.valueOf(new String(res),2)); } public static void main( String[] args)throws Exception { ProblemD solution = new ProblemD(); solution.run(); } private void initInputOutput()throws Exception { if ( (FILENAME == null)) {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"); }} private String nextWord()throws Exception { if ( updateTokenizer()) {return null;} else {return tok.nextToken();}} private boolean hasMoreTokens()throws Exception { return !updateTokenizer();} private boolean updateTokenizer()throws Exception { while(((tok == null) || !tok.hasMoreTokens())){ String nextLine = in.readLine(); if ( ((nextLine == null) || nextLine.isEmpty())) {return true;} tok = new StringTokenizer(nextLine,DELIMETER); }return false;} private int nextInt()throws Exception { return Integer.parseInt(nextWord());} private long nextLong()throws Exception { return Long.parseLong(nextWord());} private void finish()throws Exception { in.close(); out.close(); } private void print( String s){ if ( DEBUG) {System.out.print(s); } } private void println( String s){ if ( DEBUG) {System.out.println(s); } } private void println(){ if ( DEBUG) {System.out.println(); } } }
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{ static final int MODULO = (int)(1e9 + 7); 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] = removeSquares(in.nextInt()); Arrays.sort(a); 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 - 1)] + c[(i - 1)][j]) % MODULO); }} int[] fact = new int[(n + 1)]; fact[0] = 1; for ( int i = 1;(i < fact.length);++i) {fact[i] = (int)((i * (long)fact[(i - 1)]) % MODULO); } int i = 0;  int[] ways = new int[]{1}; while((i < n)){ int j = i; while(((j < n) && (a[j] == a[i])))++j; int m = (j - i);  int[] nways = new int[(j + 1)]; for ( int old = 0;(old < ways.length);++old) { long w = ways[old]; for ( int blocks = 1;(blocks <= m);++blocks) {for ( int intoOld = 0;((intoOld <= old) && (intoOld <= blocks));++intoOld) {nways[((old - intoOld) + (m - blocks))] = (int)((nways[((old - intoOld) + (m - blocks))] + ((((((((w * c[old][intoOld]) % MODULO) * c[((i + 1) - old)][(blocks - intoOld)]) % MODULO) * c[(m - 1)][(blocks - 1)]) % MODULO) * fact[m]) % MODULO)) % MODULO); }}}i = j; ways = nways; }out.println(ways[0]); } private int removeSquares( int x){ for ( int i = 2;((i * i) <= x);++i) {while(((x % (i * i)) == 0)){x /= (i * i); }}return x;} } 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 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);  TaskG2 solver = new TaskG2(); solver.solve(1,in,out); out.close(); } static class TaskG2{ static final int MOD = (1000000000 + 7); static final int MAXN = 51; int getWays( int i, int j, int k, int l, int[][][][] ways, boolean[][][][] cached){ if ( (((i + j) + k) == 0)) return ((l == -1)?1:0); if ( (l < 0)) return 0; if ( cached[i][j][k][l]) return ways[i][j][k][l]; int s = ((i + j) + k);  long value = 0; if ( ((l == 0) && (i != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays((i - 1),j,k,x,ways,cached); } } if ( ((l == 1) && (j != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays(i,(j - 1),k,x,ways,cached); } } if ( ((l == 2) && (k != 0))) {for ( int x = -1;(x < 3);x++) if ( (x != l)) {value += getWays(i,j,(k - 1),x,ways,cached); } } ways[i][j][k][l] = (int)(value % MOD); cached[i][j][k][l] = true; return ways[i][j][k][l];} int totalWays( int i, int j, int k, int[][][][] ways, boolean[][][][] cached, int[] factorial){ long ret = 0; for ( int l = 0;(l < 3);l++) ret += getWays(i,j,k,l,ways,cached); ret *= factorial[i]; ret %= MOD; ret *= factorial[j]; ret %= MOD; ret *= factorial[k]; ret %= MOD; return (int)ret;} int add( int type, int value, int[] sizes, int sum, int[][][][] dp){ sizes[type]++; if ( (type == 0)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 1;(i <= sizes[0]);i++) for ( int j = 0;(j <= sizes[1]);j++) for ( int k = 0;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[(i - 1)][j][k][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} if ( (type == 1)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 0;(i <= sizes[0]);i++) for ( int j = 1;(j <= sizes[1]);j++) for ( int k = 0;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[i][(j - 1)][k][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} if ( (type == 2)) {for ( int s = (sum + value);(s >= value);s--) {for ( int i = 0;(i <= sizes[0]);i++) for ( int j = 0;(j <= sizes[1]);j++) for ( int k = 1;(k <= sizes[2]);k++) {dp[i][j][k][s] += dp[i][j][(k - 1)][(s - value)]; if ( (dp[i][j][k][s] >= MOD)) dp[i][j][k][s] -= MOD; }}} return (sum + value);} public void solve( int testNumber, InputReader in, OutputWriter out){ int[][][][] ways = new int[MAXN][MAXN][MAXN][3];  boolean[][][][] cached = new boolean[MAXN][MAXN][MAXN][3];  int n = in.nextInt(),T = in.nextInt();  ArrayList<Integer>[] ar = new ArrayList[3]; for ( int i = 0;(i < 3);i++) ar[i] = new ArrayList<Integer>(); int total_sum = 0; for ( int i = 0;(i < n);i++) { int t = in.nextInt(),g = in.nextInt(); ar[(g - 1)].add(t); total_sum += t; }if ( (T > total_sum)) {out.println(0); return ;} int min_index = 0,mn = 0; for ( int i = 0;(i < 3);i++) {if ( (ar[i].size() > mn)) {mn = ar[i].size(); min_index = i; } } int[][][][] dp = new int[(ar[((1 + min_index) % 3)].size() + 1)][(ar[((2 + min_index) % 3)].size() + 1)][1][(total_sum + 1)];  int[][][][] dp2 = new int[1][1][(mn + 1)][(total_sum + 1)]; dp[0][0][0][0] = dp2[0][0][0][0] = 1; int[] sizes = {0,0,0};  int sum = 0;  int[] order = {((min_index + 1) % 3),((min_index + 2) % 3)};  int type = 0; for ( int i :order) {for ( int v :ar[i]) sum = add(type,v,sizes,sum,dp); type++; }sum = 0; sizes[0] = sizes[1] = sizes[2] = 0; for ( int i :ar[min_index]) sum = add(2,i,sizes,sum,dp2); int[] factorial = new int[MAXN]; factorial[0] = 1; for ( int i = 1;(i < MAXN);i++) factorial[i] = (int)(((factorial[(i - 1)] * 1L) * i) % MOD); long answer = 0; for ( int i = 0;(i < dp.length);i++) for ( int j = 0;(j < dp[0].length);j++) for ( int k = 0;(k <= mn);k++) for ( int s = 0;(s <= T);s++) { long x = (((dp[i][j][0][s] * 1L) * totalWays(i,j,k,ways,cached,factorial)) % MOD); x *= dp2[0][0][k][(T - s)]; x %= MOD; answer += x; }out.println((answer % MOD)); } } 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); } } 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 println( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }writer.print('\n'); } public void close(){ writer.close(); } } }
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);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } static class TaskB{ double ans = 0; int[] candy ; int[] b ; int[] l ; int[] curLoyal ; int n ; int k ; int A ; public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.nextInt(); k = in.nextInt(); A = in.nextInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = in.nextInt(); l[i] = in.nextInt(); }candy = new int[n]; curLoyal = new int[n]; comb(0,k); out.println(ans); } void comb( int ind, int unusedCandy){ if ( (ind == n)) {for ( int i = 0;(i < n);i++) {curLoyal[i] = Math.min(((candy[i] * 10) + l[i]),100); }calc(); } else {for ( int i = 0;(i <= unusedCandy);i++) {candy[ind] = i; comb((ind + 1),(unusedCandy - i)); }}} void calc(){ double res = 0;  int allBits = ((1 << n) - 1); for ( int vote = 0;(vote <= allBits);vote++) { double curProb = 1;  int sumPower = A;  int enemyCnt = 0; for ( int voteInd = 0;(voteInd < n);voteInd++) {if ( ((vote & (1 << voteInd)) == 0)) {curProb *= (100 - curLoyal[voteInd]); sumPower += b[voteInd]; enemyCnt++; } else {curProb *= curLoyal[voteInd]; }curProb /= 100; }if ( ((2 * enemyCnt) >= n)) {curProb *= A; curProb /= sumPower; } res += curProb; }ans = Math.max(ans,res); } } static 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(); }catch (IOException e){ return null;} } public String next(){ while(((stt == null) || !stt.hasMoreTokens())){stt = new StringTokenizer(nextLine()); }return stt.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
2	public class cf276d{ static BufferedReader br ; static Scanner sc ; static PrintWriter out ; public static void initA(){ try{br = new BufferedReader(new InputStreamReader(System.in)); sc = new Scanner(System.in); out = new PrintWriter(System.out); }catch (Exception e){ } } public static Long[] getLongArr(){ try{ StringTokenizer temp = new StringTokenizer(br.readLine());  int n = temp.countTokens();  Long temp2[] = new Long[n]; for ( int i = 0;(i < n);i++) {temp2[i] = Long.parseLong(temp.nextToken()); }return temp2; }catch (Exception e){ } return null;} public static void print( Object a){ out.println(a); } public static int nextInt(){ return sc.nextInt();} public static double nextDouble(){ return sc.nextDouble();} public static void main( String[] ar){ initA(); solve(); out.flush(); } public static void print2( Object o){ System.out.println(o); } public static void solve(){ Long xx[] = getLongArr();  long l = xx[0];  long r = xx[1];  BigInteger a = BigInteger.valueOf(l);  BigInteger b = BigInteger.valueOf(r); if ( (l == r)) {print(0); return ;} String a2 = a.toString(2);  String b2 = b.toString(2);  int selisihpjg = Math.abs((a2.length() - b2.length())); while((selisihpjg-- > 0)){a2 = ("0" + a2); } String out = ""; for ( int i = 0;(i < b2.length());i++) {if ( (a2.charAt(i) != b2.charAt(i))) {for ( int ii = i;(ii < b2.length());ii++) {out += "1"; }print2(new BigInteger(out,2)); return ;} }} }
5	public class A{ private Scanner in ; private PrintWriter out ; public void solve(){ int n = ni();  int t = ni();  Pair[] p = new Pair[n]; for ( int i = 0;(i < n);i++) {p[i] = new Pair(); p[i].x = ni(); p[i].a = ni(); }Arrays.sort(p); int ct = 2; for ( int i = 0;(i < (n - 1));i++) { float d = (((p[(i + 1)].x - ((float)p[(i + 1)].a / 2)) - p[i].x) - ((float)p[i].a / 2)); if ( (Math.abs((d - t)) < EPS)) {ct++; } else if ( (d > t)) {ct += 2; } }out.println(ct); } double EPS = 0.0001; static private class Pair implements Comparable<Pair>{ public int x ; public int a ; } public void run()throws Exception { in = new Scanner(System.in); System.setOut(new PrintStream(new BufferedOutputStream(System.out))); out = new PrintWriter(System.out); int n = 1; for ( int i = 1;(i <= n);i++) { long t = System.currentTimeMillis(); solve(); out.flush(); }} public static void main( String[] args)throws Exception { new A().run(); } private int ni(){ return Integer.parseInt(in.next());} }
1	public class Main{ static private 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)));}}} static private 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(),"")))); }}} }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); if ( ((n % 2) == 0)) {System.out.println((((n - 4) + " ") + (n - (n - 4)))); } else {System.out.println((((n - 9) + " ") + (n - (n - 9)))); }} }
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));} static private class pair{ int x ; int y ; public pair( int x, int y){ this.x = x; this.y = y; } } }
3	public class Main{ static int max = Integer.MAX_VALUE,min = Integer.MIN_VALUE; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st ; static int max( int a, int b){ return Math.max(a,b);} static int min( int a, int b){ return Math.min(a,b);} static int i()throws IOException { if ( !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return Integer.parseInt(st.nextToken());} static void pl( String pl){ System.out.println(pl); } static void pl( int pl){ System.out.println(pl); } static void pl( char pl){ System.out.println(pl); } static void pl( double pl){ System.out.println(pl); } static void pl( long pl){ System.out.println(pl); } static void pl( boolean pl){ System.out.println(pl); } static void pl(){ System.out.println(); } static int[] ari( int n)throws IOException { int ar[] = new int[n]; if ( !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); for ( int x = 0;(x < n);x++) ar[x] = Integer.parseInt(st.nextToken()); return ar;} static int[][] ari( int n, int m)throws IOException { int ar[][] = new int[n][m]; for ( int x = 0;(x < n);x++) {st = new StringTokenizer(br.readLine()); for ( int y = 0;(y < m);y++) ar[x][y] = Integer.parseInt(st.nextToken()); }return ar;} public static void main( String[] args)throws Exception { st = new StringTokenizer(br.readLine()); int n = i();  int ar[] = ari(n); Arrays.sort(ar); int c = 0; for ( int x = 0;(x < n);x++) {if ( (ar[x] != -1)) {c++; for ( int y = (x + 1);(y < n);y++) {if ( (ar[y] != -1)) {if ( ((ar[y] % ar[x]) == 0)) {ar[y] = -1; } } }ar[x] = -1; } }pl(c); } }
4	public class C2{ String filename = null; InputReader sc ; void solve(){ int n = sc.nextInt();  int[] a = sc.nextArray(n);  int[] ps = new int[n];  int[] q = new int[n];  int[] qs = new int[n];  int nq = 0; for ( int i = 1;(i < n);i++) {if ( (a[i] == 1)) {qs[nq] = (i - 1); q[nq++] = (a[(i - 1)] + 1); ps[i] = (i - 1); } else {if ( (a[i] == (a[(i - 1)] + 1))) {qs[nq] = (i - 1); q[nq++] = 1; ps[i] = (i - 1); } else {for ( int j = (nq - 1);(j >= 0);j--) {if ( (a[i] == q[j])) {ps[i] = qs[j]; nq = j; break;} }}}} int[] parents = ps;  String[] strs = new String[n]; strs[0] = "1"; System.out.println(strs[0]); for ( int i = 1;(i < n);i++) { String p = strs[parents[i]]; if ( (a[i] == 1)) {strs[i] = (p + ".1"); } else { int lastDot = p.lastIndexOf("."); if ( (lastDot == -1)) {strs[i] = (a[i] + ""); } else {strs[i] = ((p.substring(0,lastDot) + ".") + a[i]); }}System.out.println(strs[i]); }} public void run()throws FileNotFoundException { if ( (filename == null)) {sc = new InputReader(System.in); } else {sc = new InputReader(new FileInputStream(new File(filename))); } int nTests = sc.nextInt(); for ( int test = 0;(test < nTests);test++) {solve(); }} public static void main( String[] args){ C2 sol = new C2(); try{sol.run(); }catch (FileNotFoundException e){ e.printStackTrace(); } } 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 int[] nextArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }return a;} } }
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 PhytonIndenter{ static private Scanner scanner = new Scanner(System.in); static private int lineCount ; static private String[] commands ; public static void main( String[] args){ lineCount = scanner.nextInt(); scanner.nextLine(); commands = new String[lineCount]; for ( int i = 0;(i < lineCount);i++) {commands[i] = scanner.nextLine(); }resolveWithDP(); } static private void resolveWithDP(){ long dp[][] = new long[lineCount][5002];  long mod = 1000000007; dp[0][0] = 1; for ( int i = 1;(i < lineCount);i++) {if ( "f".equalsIgnoreCase(commands[(i - 1)])) {dp[i][0] = 0; for ( int j = 1;(j <= i);j++) {dp[i][j] = dp[(i - 1)][(j - 1)]; }} else { long sum = 0; for ( int j = (i - 1);(j >= 0);j--) {sum += (dp[(i - 1)][j] % mod); dp[i][j] = sum; }}} long result = 0; for ( int i = 0;(i < lineCount);i++) {result += (dp[(lineCount - 1)][i] % mod); result %= mod; }System.out.println((result % mod)); } }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong(); if ( (n == 1)) System.out.println(1); else if ( (n == 2)) System.out.println(2); else if ( ((n % 2) == 0)) { int cnt = nPrime(n); if ( (cnt == 1)) System.out.println(((n * (n - 1)) * (n - 3))); else if ( (cnt > 1)) System.out.println((((n - 1) * (n - 2)) * (n - 3))); } else System.out.println(((n * (n - 1)) * (n - 2))); } public static int nPrime( long n){ int cnt = 1; if ( ((n % 3) == 0)) cnt++; return cnt;} }
4	public class ExplorerSpace{ int[][] horizontal ,vertical ; int n ,m ; long[][][] dp ; int large = Integer.MAX_VALUE; boolean isValid( int i, int j){ return ((((i >= 0) && (j >= 0)) && (i < n)) && (j < m));} long getMin( int i, int j, int k){ if ( (k == 0)) return 0; if ( (dp[i][j][k] != -1)) return dp[i][j][k]; long ans = large; for ( int a = 0;(a < 2);a++) {for ( int d = 0;(d < 2);d++) { int dx = ((a == 0)?((d == 0)?+1:-1):0);  int dy = ((a == 1)?((d == 0)?+1:-1):0);  int x = (i + dx);  int y = (j + dy); if ( isValid(x,y)) {if ( (dx == 0)) {ans = Math.min((horizontal[i][Math.min(j,y)] + getMin(x,y,(k - 1))),ans); } else {ans = Math.min((vertical[Math.min(i,x)][j] + getMin(x,y,(k - 1))),ans); }} }}dp[i][j][k] = ans; return ans;} void solve()throws IOException { n = getInt(); m = getInt(); dp = new long[(n + 1)][(m + 1)][11]; for ( int i = 0;(i < (n + 1));i++) {for ( int j = 0;(j < (m + 1));j++) {for ( int k = 0;(k < 11);k++) {dp[i][j][k] = -1; }}} int k = getInt(); horizontal = new int[n][(m - 1)]; vertical = new int[(n - 1)][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {horizontal[i][j] = getInt(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {vertical[i][j] = getInt(); }}if ( ((k % 2) != 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {print("-1 "); }println(""); }} else {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { long ans = (2 * getMin(i,j,(k / 2))); print((ans + " ")); }println(""); }}} public static void main( String[] args)throws Exception { if ( isOnlineJudge()) {in = new BufferedReader(new InputStreamReader(System.in)); out = new BufferedWriter(new OutputStreamWriter(System.out)); new ExplorerSpace().solve(); out.flush(); } else { Thread judge = new Thread(); in = new BufferedReader(new FileReader("input.txt")); out = new BufferedWriter(new FileWriter("output.txt")); judge.start(); new ExplorerSpace().solve(); out.flush(); judge.suspend(); }} static boolean isOnlineJudge(){ try{return ((System.getProperty("ONLINE_JUDGE") != null) || (System.getProperty("LOCAL") == null)); }catch (Exception e){ return true;} } static BufferedReader in ; static StringTokenizer st ; static BufferedWriter out ; static String getLine()throws IOException { return in.readLine();} static String getToken()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) st = new StringTokenizer(getLine()); return st.nextToken();} static int getInt()throws IOException { return Integer.parseInt(getToken());} static void print( Object s)throws IOException { out.write(String.valueOf(s)); } static void println( Object s)throws IOException { out.write(String.valueOf(s)); out.newLine(); } }
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)); } static private 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); }} } static private 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++]); }}} static private 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 a = (readInt() - 1);  int b = (readInt() - 1);  int[] d = new int[n]; for ( int i = 0;(i < n);i++) {d[i] = readInt(); }mergeSort(d); out.print((d[(b + 1)] - d[b])); } }
3	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 HashSet<Pair> graph[] ; static boolean oj = (System.getProperty("ONLINE_JUDGE") != null); public static void main( String[] args)throws Exception { String st[] = nl();  int n = pi(st[0]);  int input[] = new int[n]; st = nl(); for ( int i = 0;(i < n);i++) {input[i] = pi(st[i]); } int ans = 0; Arrays.sort(input); boolean dp[] = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !dp[i]) {ans++; for ( int j = input[i];(j <= 200);j += input[i]) {for ( int k = i;(k < n);k++) {if ( ((input[k] == j) && !dp[k])) dp[k] = true; }}} }out.println(ans); 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; } } }
1	public class C{ public static int mod = (1000000000 + 7); public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String n = br.readLine();  int k = Integer.parseInt(br.readLine());  int l = n.length(); if ( (k == 0)) {System.out.println(1); } else { int max = 1000; if ( (l <= 10)) {max = Integer.min(1000,Integer.parseInt(n,2)); } int[] steps = new int[(max + 1)]; for ( int i = 2;(i <= max);i++) { int ones = numberOfOnes(i); steps[i] = (1 + steps[ones]); }if ( (l <= 10)) { int ans = 0; for ( int i = 1;(i <= max);i++) {if ( (steps[i] == k)) {ans++; } }System.out.println(ans); } else { int[][] C = binomial(max);  int ans = 0;  int count = 0; for ( int i = 0;(i < l);i++) {if ( (n.charAt(i) == '1')) {for ( int j = count;(j < max);j++) {if ( (steps[j] == (k - 1))) {ans = ((ans + C[((l - i) - 1)][(j - count)]) % mod); if ( ((i == 0) && (k == 1))) {ans = (((ans + mod) - 1) % mod); } } }count++; } } int ones = 0; for ( int i = 0;(i < l);i++) {if ( (n.charAt(i) == '1')) {ones++; } }if ( (steps[ones] == (k - 1))) {ans = ((ans + 1) % mod); } System.out.println(ans); }}} public static int numberOfOnes( int x){ char[] s = Integer.toBinaryString(x).toCharArray();  int count = 0; for ( char c :s) {if ( (c == '1')) {count++; } }return count;} public static int[][] binomial( int n){ int[][] C = new int[(n + 1)][(n + 1)]; for ( int i = 0;(i <= n);i++) {C[i][0] = 1; for ( int j = 1;(j <= i);j++) {C[i][j] = (((C[(i - 1)][(j - 1)] % mod) + (C[(i - 1)][j] % mod)) % mod); }}return C;} }
0	public class A{ public void processInput()throws IOException { Scanner in = new Scanner(System.in);  long n = in.nextLong();  long res = go(n); System.out.printf(Locale.ENGLISH,"%d\n",res); in.close(); } public long go( long n){ long res = n;  String str = String.valueOf(n);  StringBuilder sb = new StringBuilder(str); sb.deleteCharAt((str.length() - 1)); if ( ((sb.length() > 0) && !sb.toString().equals("-"))) {res = Math.max(res,Long.valueOf(sb.toString())); } if ( (str.length() > 1)) {if ( (str.charAt((str.length() - 2)) != '-')) {sb = new StringBuilder(str); sb.deleteCharAt((str.length() - 2)); res = Math.max(res,Long.valueOf(sb.toString())); } } return res;} public static void main( String[] args)throws Exception { A a = new A(); a.processInput(); } }
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); } }
1	public class GFG{ 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 c = sc.nextInt();  int ans = 0;  int t = sc.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) { int nn = sc.nextInt(); ans += a; if ( (b < c)) {ans += ((t - nn) * (c - b)); } }System.out.println(ans); } }
2	public class digitSequence{ static void MainSolution(){ long k = (nl() - 1); for ( int i = 1;;i++) { long temp = ((9L * i) * fastPow(10,(i - 1))); if ( (k < temp)) { long x = (k / i);  long y = (k % i);  long ans = ((x + fastPow(10,(i - 1))) / fastPow(10,((i - y) - 1))); pl((ans % 10)); break;} k -= temp; }} static long fastPow( long b, long e){ if ( (e == 0)) return 1; if ( ((e & 1) == 1)) return ((b * fastPow(b,(e >> 1))) * fastPow(b,(e >> 1))); return (fastPow(b,(e >> 1)) * fastPow(b,(e >> 1)));} static int mod9 = 1_000_000_007; static int n ,m ,l ,k ,t ; static AwesomeInput input = new AwesomeInput(System.in); static PrintWriter pw = new PrintWriter(System.out,true); static class AwesomeInput{ private InputStream letsDoIT ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; private AwesomeInput( InputStream incoming){ this.letsDoIT = incoming; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = letsDoIT.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} private long ForLong(){ 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 String ForString(){ 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{ boolean isSpaceChar( int ch); } } static long nl(){ return input.ForLong();} static void pl(){ pw.println(); } static void pl( Object o){ pw.println(o); } public static void main( String[] args){ new Thread(null,null,"Vengeance",(1 << 25)){}.start(); } }
0	public class Round313A{ static private 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 Main{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt(),min[] = new int[n];  boolean used[] = new boolean[n];  HashSet<Integer> set = new HashSet<>(); for ( int i = 0;(i < n);i++) {min[i] = scan.nextInt(); }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (min[i] > min[j])) {if ( ((min[i] % min[j]) == 0)) min[i] = min[j]; } else if ( ((min[j] % min[i]) == 0)) min[j] = min[i]; }}for ( int i = 0;(i < n);i++) {set.add(min[i]); }System.out.print(set.size()); } }
5	public class Main{ public static void main( String[] argv){ new Main().run(); } void run(){ in = new Scanner(System.in); out = new PrintWriter(System.out); try{solve(); }finally{out.close(); }} PrintWriter out ; Scanner in ; class Pair{ int x ; int y ; Pair( int x, int y){ this.x = x; this.y = y; } } void solve(){ int n = in.nextInt();  int k = in.nextInt();  Pair[] a = new Pair[n]; for ( int i = 0;(i < n);i++) {a[i] = new Pair(in.nextInt(),in.nextInt()); }Arrays.sort(a,new Comparator<Pair>(){}); int cnt = 1;  int ans = 0;  int[] res = new int[n]; res[0] = 1; for ( int i = 1;(i < n);i++) {if ( ((a[i].x == a[(i - 1)].x) && (a[i].y == a[(i - 1)].y))) {cnt++; } res[i] = cnt; } int el = res[(k - 1)]; for ( int i = 0;(i < n);i++) {if ( (res[i] == el)) {ans++; } }out.println(ans); } }
1	public class Contest25_A{ static int[] parity ; public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int numberEntries = scan.nextInt(); scan.nextLine(); String[] numbers = scan.nextLine().split(" "); numbers = parity(numbers); int evenOdd = evenOdd(parity); for ( int i = 0;(i < parity.length);i++) {if ( (parity[i] == evenOdd)) {System.out.println((i + 1)); System.exit(0); } }} public static int evenOdd( int[] parity){ int numberOnes = 0;  int numberZeroes = 0;  int one = parity[0];  int two = parity[1];  int three = parity[2]; if ( (one == 1)) numberOnes++; else numberZeroes++; if ( (two == 1)) numberOnes++; else numberZeroes++; if ( (three == 1)) numberOnes++; else numberZeroes++; if ( (numberOnes >= 2)) return 0; else return 1;} public static String[] parity( String[] numbers){ parity = new int[numbers.length]; for ( int i = 0;(i < numbers.length);i++) {parity[i] = (Integer.parseInt(numbers[i]) % 2); numbers[i] = Integer.toString(parity[i]); }return numbers;} }
2	public class Main{ static class Task{ PrintWriter out ; int[] num = new int[3]; public void solve( MyScanner in, PrintWriter out){ this.out = out; long n = in.nextLong();  long s = in.nextLong();  long l = 1;  long r = n; while(((r - l) > 5)){ long x = ((l + r) / 2);  long ans = ans(x); if ( (ans >= s)) {r = x; } else {l = x; }}for ( long i = l;(i <= r);i++) {if ( (ans(i) >= s)) {out.println(((n - i) + 1)); return ;} }out.println(0); } long ans( long n){ long res = n; while((n > 9)){res -= (n % 10); n /= 10; }res -= n; return res;} } public static void main( String[] args){ MyScanner in = new MyScanner();  PrintWriter out = new PrintWriter(System.out);  Task solver = new Task(); solver.solve(in,out); 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();} long nextLong(){ return Long.parseLong(next());} } }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  List<Integer> fibs = new ArrayList<Integer>();  int fib0 = 0;  int fib1 = 1;  int fibN = (fib0 + fib1); fibs.add(fib0); fibs.add(fib1); while((fibN < 1000000000)){fibs.add(fibN); fib0 = fib1; fib1 = fibN; fibN = (fib0 + fib1); } int n = Integer.parseInt(br.readLine()); if ( (n == 0)) {System.out.println(((((0 + " ") + 0) + " ") + 0)); } else {if ( (n == 1)) {System.out.println(((((0 + " ") + 0) + " ") + 1)); } else {if ( (n == 2)) {System.out.println(((((0 + " ") + 1) + " ") + 1)); } else { int i = fibs.indexOf(n); System.out.println(((((fibs.get((i - 4)) + " ") + fibs.get((i - 3))) + " ") + fibs.get((i - 1)))); }}}} }
6	public class x1242C2{ public static void main( String[] hi)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int N = Integer.parseInt(st.nextToken());  long[] sums = new long[N];  ArrayList<Integer>[] boxes = new ArrayList[N]; for ( int i = 0;(i < N);i++) {boxes[i] = new ArrayList<Integer>(); st = new StringTokenizer(infile.readLine()); int a = Integer.parseInt(st.nextToken()); while((a-- > 0))boxes[i].add(Integer.parseInt(st.nextToken())); for ( int x :boxes[i]) sums[i] += x; } long lmaosum = 0L; for ( long x :sums) lmaosum += x; if ( ((Math.abs(lmaosum) % N) != 0)) {System.out.println("No"); return ;} long target = (lmaosum / N);  HashMap<Long,Integer> map = new HashMap<Long,Integer>(); for ( int k = 0;(k < N);k++) for ( int x :boxes[k]) map.put((long)x,k); HashMap<Long,Long> edges = new HashMap<Long,Long>(); for ( int k = 0;(k < N);k++) for ( int x :boxes[k]) { long nextval = ((target - sums[k]) + x); if ( map.containsKey(nextval)) edges.put((long)x,nextval); } Node[] dp = new Node[(1 << N)]; dp[0] = new Node(-69,-69,0); Node[] subsets = new Node[(1 << N)]; for ( int b = 0;(b < N);b++) for ( int i = 0;(i < boxes[b].size());i++) {if ( !edges.containsKey((long)boxes[b].get(i))) continue; long curr = edges.get((long)boxes[b].get(i));  int submask = 0;  boolean cyclic = true; while((curr != boxes[b].get(i))){ int k = map.get(curr); if ( (((submask & (1 << k)) > 0) || !edges.containsKey((long)curr))) {cyclic = false; break;} submask |= (1 << k); curr = edges.get((long)curr); }submask |= (1 << b); if ( cyclic) subsets[submask] = new Node(-69,i,b); }for ( int mask = 1;(mask < (1 << N));mask++) for ( int submask = mask;(submask > 0);submask = ((submask - 1) & mask)) if ( ((dp[(mask ^ submask)] != null) && (subsets[submask] != null))) {dp[mask] = new Node((mask ^ submask),subsets[submask].dex,subsets[submask].start); break;} if ( (dp[((1 << N) - 1)] == null)) System.out.println("No"); else { StringBuilder sb = new StringBuilder("Yes\n");  long[][] res = new long[N][2]; for ( int i = 0;(i < N);i++) res[i][1] = -1L; int currmask = ((1 << N) - 1); while((currmask != 0)){ int submask = dp[currmask].mask;  int i = dp[currmask].dex;  int b = dp[currmask].start;  long nextval = ((target - sums[b]) + boxes[b].get(i));  int curr = map.get(nextval); res[map.get(nextval)][0] = nextval; res[map.get(nextval)][1] = b; while(true){ int lol = map.get(nextval); nextval = edges.get(nextval); res[map.get(nextval)][0] = nextval; if ( (res[map.get(nextval)][1] != -1)) break; res[map.get(nextval)][1] = lol; }currmask = dp[currmask].mask; }for ( int k = 0;(k < N);k++) sb.append((res[k][0] + " ")).append((res[k][1] + 1)).append("\n"); System.out.print(sb); }} } class Node{ public int mask ; public int dex ; public int start ; public Node( int a, int b, int c){ mask = a; dex = b; start = c; } }
3	public class TaskA{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringBuilder sb = new StringBuilder();  int n = Integer.parseInt(br.readLine());  String[] s = br.readLine().split(" ");  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(s[i]); }Arrays.sort(arr); boolean[] vis = new boolean[n];  int nColours = 0;  int nVis = 0;  int index = 0; while((nVis < n)){while(((index < n) && (nVis < n))){if ( vis[index]) {index++; continue;} int val = arr[index]; nColours++; while(((index < n) && (nVis < n))){if ( vis[index]) {index++; continue;} if ( ((arr[index] % val) == 0)) {vis[index] = true; nVis++; } index++; }index = 0; }}System.out.println(nColours); } }
0	public class Test{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int k = 1;  int t = 0;  int y = 2;  int[] a = new int[100000]; if ( (n == 0)) {System.out.println(((((0 + " ") + 0) + " ") + 0)); } else if ( (n == 1)) {System.out.println(((((0 + " ") + 0) + " ") + 1)); } else if ( (n == 2)) {System.out.println(((((0 + " ") + 1) + " ") + 1)); } else {a[0] = 0; a[1] = 1; a[y] = (a[(y - 2)] + a[(y - 1)]); while((a[(y - 1)] < n)){a[y] = (a[(y - 2)] + a[(y - 1)]); ++y; }System.out.println(((((a[(y - 2)] + " ") + a[(y - 4)]) + " ") + a[(y - 5)])); }} }
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)); }} }
1	public class pillar{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a[] = new int[200005]; for ( int i = 1;(i <= n);i++) a[i] = sc.nextInt(); for ( int i = 2;(i < n);i++) if ( ((a[(i - 1)] > a[i]) && (a[i] < a[(i + 1)]))) {System.out.println("NO"); return ;} System.out.println("YES"); } }
5	public class CottageTown{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  String[] in = sc.nextLine().split(" ");  int n = Integer.parseInt(in[0]);  int t = Integer.parseInt(in[1]);  int[] coor = new int[n];  int[] side = new int[n]; for ( int i = 0;(i < n);i++) {in = sc.nextLine().split(" "); coor[i] = Integer.parseInt(in[0]); side[i] = Integer.parseInt(in[1]); }quickSort(coor,0,(n - 1),side); int count = 2;  double dist ; for ( int i = 0;(i < (n - 1));i++) {dist = ((coor[(i + 1)] - coor[i]) - ((double)(side[(i + 1)] + side[i]) / 2.0)); if ( (dist > t)) {count += 2; } else if ( (dist == t)) {count += 1; } }System.out.println(count); } static private int partition( int[] arr, int left, int right, int[] temp){ int i = left,j = right;  int tmp ;  int pivot = arr[((left + right) / 2)]; while((i <= j)){while((arr[i] < pivot)){i++; }while((arr[j] > pivot)){j--; }if ( (i <= j)) {tmp = arr[i]; arr[i] = arr[j]; arr[j] = tmp; tmp = temp[i]; temp[i] = temp[j]; temp[j] = tmp; i++; j--; } }return i;} static private void quickSort( int[] arr, int left, int right, int[] temp){ int index = partition(arr,left,right,temp); if ( (left < (index - 1))) {quickSort(arr,left,(index - 1),temp); } if ( (index < right)) {quickSort(arr,index,right,temp); } } }
2	public class B{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));  Solver solver = new Solver(); solver.solve(in,out); out.close(); } static class Solver{ int n ; int n2 ; InputReader in ; PrintWriter out ; public void solve( InputReader in, PrintWriter out){ this.in = in; this.out = out; n = in.readInt(); n2 = (n / 2); int res = find(); out.print("! "); out.println(res); } public int find(){ if ( ((n % 4) != 0)) return -1; int c = compare(0); if ( (c == 0)) return 1; int s = 1;  int f = (n2 - 1); if ( (c > 0)) {s = (n2 + 1); f = (n - 1); } while((s <= f)){ int m = ((s + f) / 2);  int v = compare(m); if ( (v == 0)) return (m + 1); else if ( (v < 0)) s = (m + 1); else f = (m - 1); }return -1;} public int compare( int z){ out.print("? "); out.println((z + 1)); out.flush(); int r1 = in.readInt(); out.print("? "); out.println((((z + n2) % n) + 1)); out.flush(); int r2 = in.readInt(); return (r1 - r2);} } static class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream){ this.reader = new BufferedReader(new InputStreamReader(stream)); } public String read(){ try{if ( ((tokenizer == null) || !tokenizer.hasMoreTokens())) {tokenizer = new StringTokenizer(reader.readLine()); } }catch (IOException ex){ throw (new RuntimeException(ex));} return tokenizer.nextToken();} public int readInt(){ return Integer.parseInt(read());} } }
5	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),sum = 0;  Integer[] A = new Integer[n]; for ( int i = 0;(i < n);i++) {A[i] = sc.nextInt(); sum += A[i]; }Arrays.sort(A,Collections.reverseOrder()); int c = 0,ans = 0; while((ans <= sum)){ans += A[c]; sum -= A[c]; c++; }System.out.println(c); } }
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));}} }
3	public class Code3{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = in.nextInt();  double r = (double)in.nextInt();  double[] a = new double[n]; for ( int i = 0;(i < n);i++) a[i] = (double)in.nextInt(); double[] ans = new double[n]; ans[0] = r; for ( int i = 1;(i < n);i++) { double max = Double.MIN_VALUE; for ( int j = 0;(j < i);j++) {if ( (Math.abs((a[i] - a[j])) <= (2 * r))) { double cur = ((4 * r) * r); cur -= ((a[i] - a[j]) * (a[i] - a[j])); cur = Math.sqrt(cur); cur += ans[j]; max = Math.max(max,cur); } }if ( (max == Double.MIN_VALUE)) ans[i] = r; else ans[i] = max; }for ( int i = 0;(i < n);i++) pw.print((ans[i] + " ")); pw.flush(); pw.close(); } 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 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); } } public static long mod = 1000000007; public static int d ; public static int p ; public static int q ; public static int GCD( int a, int b){ if ( (b == 0)) return a; else return GCD(b,(a % b));} public static long GCD( long a, long b){ if ( (b == 0)) return a; else return GCD(b,(a % b));} public static void extendedEuclid( int A, int B){ if ( (B == 0)) {d = A; p = 1; q = 0; } else {extendedEuclid(B,(A % B)); int temp = p; p = q; q = (temp - ((A / B) * q)); }} public static int modularExponentiation( int x, int n, int M){ int result = 1; while((n > 0)){if ( ((n % 2) == 1)) result = ((result * x) % M); x = ((x * x) % M); n = (n / 2); }return result;} public static long modularExponentiation( long x, long n, long M){ long result = 1; while((n > 0)){if ( ((n % 2) == 1)) result = ((result * x) % M); x = ((x * x) % M); n = (n / 2); }return result;} }
6	public class D11{ static boolean[][] g ; static int n ,m ; public static void main( String[] args)throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); n = input.nextInt(); m = input.nextInt(); g = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (input.nextInt() - 1),b = (input.nextInt() - 1); g[a][b] = g[b][a] = true; } long res = 0; map = new HashMap<Integer,Long>(); for ( int i = (n - 1);(i >= 0);i--) {memo = new long[(i + 1)][(1 << (i + 1))]; for ( long[] A :memo) Arrays.fill(A,-1); res += (count(i,i,(1 << i)) / 2); }out.println(res); out.close(); } static long[][] memo ; static HashMap<Integer,Long> map ; static long count( int at, int start, int mask){ if ( (memo[at][mask] != -1)) return memo[at][mask]; int bits = Integer.bitCount(mask); if ( ((at == start) && (bits > 2))) return 1; long res = 0; for ( int i = 0;(i <= start);i++) {if ( !g[at][i]) continue; if ( ((i != start) && ((mask & (1 << i)) > 0))) continue; if ( ((i == start) && (bits <= 2))) continue; res += count(i,start,(mask | (1 << i))); }return memo[at][mask] = res;} }
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();} } }
5	public class A{ static StreamTokenizer st ; static class Sort implements Comparable<Sort>{ int val ; } public static void main( String[] args)throws IOException { st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int n = nextInt();  Sort[] a = new Sort[(n + 1)];  int[] b = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = new Sort(); a[i].val = nextInt(); b[i] = a[i].val; }Arrays.sort(a,1,(n + 1)); int k1 = 0,k2 = 0; for ( int i = 1;(i <= n);i++) {if ( (b[i] != a[i].val)) {if ( (k1 == 0)) k1 = i; else if ( (k2 == 0)) k2 = i; else {System.out.println("NO"); return ;}} }if ( (k1 == 0)) System.out.println("YES"); else if ( (k2 == 0)) System.out.println("NO"); else {if ( ((b[k1] == a[k2].val) && (b[k2] == a[k1].val))) System.out.println("YES"); else System.out.println("NO"); }pw.close(); } static private int nextInt()throws IOException { st.nextToken(); return (int)st.nval;} }
5	public class A{ @SuppressWarnings static private void solve()throws IOException { ArrayList<Num> c = new ArrayList<Num>(); n = nextInt(); a = nextInt(); b = nextInt(); for ( int i = 0;(i < n);i++) { int next = nextInt();  boolean found = false; for ( int j = 0;(j < c.size());j++) {if ( (c.get(j).num == next)) {c.get(j).freq++; found = true; break;} }if ( !found) c.add(new Num(next)); }Collections.sort(c); int below = 0;  int above = n;  boolean f = false; for ( int i = 0;(i < c.size());i++) {below += c.get(i).freq; above -= c.get(i).freq; if ( ((below == b) && (above == a))) {if ( (i == c.size())) break; System.out.println((c.get((i + 1)).num - c.get(i).num)); f = true; break;} }if ( !f) System.out.println(0); } static int n ; static int a ; static int b ; public static void main( String[] args){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); 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());} } class Num implements Comparable<Num>{ int num ; int freq ; Num( int n){ num = n; freq = 1; } }
6	public class Sol2{ public static final int MXN = (1 << 21); public static int good[][] ; public static void main( String[] args)throws IOException { FastIO sc = new FastIO(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt();  int m = sc.nextInt();  int num[][] = new int[m][m];  String str = sc.next(); for ( int i = 0;(i < (str.length() - 1));i++) { int a = (str.charAt(i) - 'a');  int b = (str.charAt((i + 1)) - 'a'); num[a][b]++; num[b][a]++; } int lowbit[] = new int[MXN];  int dp[] = new int[MXN]; for ( int i = 0;(i < MXN);i++) {dp[i] = Integer.MAX_VALUE; }dp[0] = 0; good = new int[MXN][m]; for ( int msk = 0;(msk < (1 << m));msk++) {for ( int i = 0;(i < m);i++) { int low = Integer.numberOfTrailingZeros(Integer.lowestOneBit(msk)); if ( (low == 32)) low = 0; good[msk][i] = (good[(msk ^ (1 << low))][i] + num[i][low]); }}for ( int msk = 0;(msk < (1 << m));msk++) { int bits = (Integer.bitCount(msk) + 1); for ( int i = 0;(i < m);i++) {if ( ((msk & (1 << i)) != 0)) continue; int nxt = (msk | (1 << i)); dp[nxt] = Math.min(dp[nxt],(dp[msk] + (bits * (good[msk][i] - good[(((1 << m) - 1) ^ nxt)][i])))); }}out.println(dp[((1 << m) - 1)]); out.close(); } static class FastIO{ InputStream dis ; byte[] buffer = new byte[(1 << 17)]; int pointer = 0; public FastIO( String fileName)throws IOException{ dis = new FileInputStream(fileName); } public FastIO( InputStream is)throws IOException{ dis = is; } int nextInt()throws IOException { int ret = 0;  byte b ; do {b = nextByte(); }while((b <= ' ')); boolean negative = false; if ( (b == '-')) {negative = true; b = nextByte(); } while(((b >= '0') && (b <= '9'))){ret = (((10 * ret) + b) - '0'); b = nextByte(); }return (negative?-ret:ret);} byte nextByte()throws IOException { if ( (pointer == buffer.length)) {dis.read(buffer,0,buffer.length); pointer = 0; } return buffer[pointer++];} String next()throws IOException { StringBuffer ret = new StringBuffer();  byte b ; do {b = nextByte(); }while((b <= ' '));while((b > ' ')){ret.appendCodePoint(b); b = nextByte(); }return ret.toString();} } }
1	public class A implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; public static final String filename = ""; public void solve()throws IOException { int n = nextInt();  int[] a = new int[(n + 1)];  ArrayList<Integer> pr = new ArrayList<Integer>(); for ( int i = 2;(i < (n + 1));i++) {if ( (a[i] != 0)) continue; pr.add(i); for ( int j = (2 * i);(j < (n + 1));j += i) {a[j] = 1; }} int k = nextInt(); for ( int i = 2;(i < (n + 1));i++) {if ( (a[i] != 0)) continue; for ( int j = 1;(j < pr.size());j++) {if ( (i == ((pr.get(j) + pr.get((j - 1))) + 1))) {k--; break;} }}if ( (k > 0)) {out.println("NO"); return ;} out.println("YES"); } public static void main( String[] args){ new Thread(new A()).start(); } public String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
3	public class Main{ static private BufferedReader br ; static private StringTokenizer st ; static private PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int qq = Integer.MAX_VALUE; for ( int casenum = 1;(casenum <= qq);casenum++) { int n = readInt();  int[] l = new int[n]; for ( int i = 0;(i < n);i++) {l[i] = readInt(); } int ret = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (l[i] > l[j])) {ret++; } }} int qqq = readInt(); while((qqq-- > 0)){ int a = readInt();  int b = readInt();  int d = (b - a); ret ^= ((d * (d + 1)) / 2); pw.println((((ret % 2) == 0)?"even":"odd")); }}exitImmediately(); } static private void exitImmediately(){ pw.close(); System.exit(0); } static private int readInt()throws IOException { return Integer.parseInt(nextToken());} static private String nextLine()throws IOException { String s = br.readLine(); if ( (s == null)) {exitImmediately(); } st = null; return s;} static private String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(nextLine().trim()); }return st.nextToken();} }
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(); } }
6	public class flags1225 implements Runnable{ static int n ,k ,a ,b[] ,loy[] ; static boolean decision[] ; static double ans ,max ; static void check( int i){ if ( (i == n)) {checkAgain(); return ;} decision[i] = true; check((i + 1)); if ( (loy[i] < 100)) {decision[i] = false; check((i + 1)); } } static void checkAgain(){ double prob = 1;  int enemyEnergy = 0;  int count = 0; for ( int i = 0;(i < n);i++) {if ( decision[i]) {count++; prob *= loy[i]; } else {prob = (prob * (100 - loy[i])); enemyEnergy += b[i]; }} double killProb = ((double)a / (a + enemyEnergy)); if ( (count > (n / 2))) {ans += prob; return ;} prob *= killProb; ans += prob; } static void rec( int sum, int i){ if ( ((i == n) || (sum == 0))) {ans = 0; check(0); max = max(ans,max); return ;} for ( int j = 0;(j <= sum);j = (j + 10)) {if ( ((loy[i] + j) > 100)) continue; loy[i] += j; rec((sum - j),(i + 1)); loy[i] -= j; }} static private boolean fileIOMode = false; static private String problemName = "harmful"; static private BufferedReader in ; static private PrintWriter out ; static private StringTokenizer tokenizer ; public static void main( String[] args)throws Exception { Locale.setDefault(Locale.ENGLISH); if ( fileIOMode) {in = new BufferedReader(new FileReader((problemName + ".in"))); out = new PrintWriter((problemName + ".out")); } else {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); }tokenizer = new StringTokenizer(""); new Thread(new flags1225()).start(); } static private String nextLine(){ try{return in.readLine(); }catch (IOException e){ return null;} } static private String nextToken(){ while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(nextLine()); }return tokenizer.nextToken();} static private int nextInt(){ return Integer.parseInt(nextToken());} }
5	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 TaskB(); 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 TaskB implements Solver{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.readInt();  int m = in.readInt();  int k = in.readInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.readInt(); Arrays.sort(a); if ( (k >= m)) {out.println(0); } else {for ( int i = (n - 1);(i >= 0);i--) {k += (a[i] - 1); if ( (k >= m)) {out.println((n - i)); return ;} }if ( (k < m)) out.println(-1); }} }
5	public class c{ public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  int n = in.nextInt(),m = in.nextInt();  long bounty = in.nextInt(),increase = in.nextInt();  int damage = in.nextInt();  int[] mh = new int[n];  int[] sh = new int[n];  int[] reg = new int[n];  long countKilled = 0;  ArrayList<Event> es = new ArrayList<>();  Event[] regen = new Event[n]; for ( int i = 0;(i < n);i++) {mh[i] = in.nextInt(); sh[i] = in.nextInt(); reg[i] = in.nextInt(); if ( (sh[i] <= damage)) countKilled++; if ( (reg[i] > 0)) { int time = (((((damage + 1) - sh[i]) + reg[i]) - 1) / reg[i]); if ( ((time > 0) && (mh[i] >= (damage + 1)))) { Event e2 = new Event(time,i,(damage + 1)); regen[i] = e2; es.add(e2); } } }for ( int i = 0;(i < m);i++) { Event e = new Event(in.nextInt(),(in.nextInt() - 1),in.nextInt()); es.add(e); if ( (reg[e.e] > 0)) { int time = (((((damage + 1) - e.h) + reg[e.e]) - 1) / reg[e.e]); if ( ((time > 0) && (mh[e.e] >= (damage + 1)))) { Event e2 = new Event((e.t + time),e.e,(damage + 1)); e.regen = e2; es.add(e2); } } }Collections.sort(es,(a,b)->(a.t - b.t)); long ans = (countKilled * bounty);  int lastTime = 0; for ( Event e :es) {if ( (e.t == -1)) continue; if ( ((regen[e.e] != e) && (regen[e.e] != null))) {regen[e.e].t = -1; regen[e.e] = null; } if ( (lastTime != e.t)) {ans = Math.max(ans,(countKilled * (bounty + ((e.t - 1) * increase)))); } if ( (sh[e.e] <= damage)) countKilled--; sh[e.e] = e.h; if ( (sh[e.e] <= damage)) countKilled++; if ( (e.regen != null)) {regen[e.e] = e.regen; } lastTime = e.t; }if ( (countKilled != 0)) {if ( (increase > 0)) ans = -1; else ans = Math.max(ans,(countKilled * bounty)); } System.out.println(ans); } static class Event{ int t ; int e ; int h ; Event regen ; public Event( int tt, int ee, int hh){ t = tt; e = ee; h = hh; } } 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 code0{ public static void main( String[] args){ Scanner scr = new Scanner(System.in);  int c = 0,e = 0,d = 0;  int a = scr.nextInt(); d = (a / 2); if ( ((a >= 11) && ((a % 2) == 1))) {c = 9; e = (a - 9); } else {c = (a - 4); e = 4; }System.out.print(((c + " ") + e)); } }
5	public class a{ void solve()throws Exception { 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 sum = 0; if ( (k >= m)) {out.println(0); return ;} sum = ((a[(n - 1)] + k) - 1); int j = 1; for ( int i = (n - 2);((i >= 0) && (sum < m));i--,j++) {sum += (a[i] - 1); }if ( (sum < m)) {out.println(-1); } else {out.println(j); }} FastScanner in ; PrintWriter out ; String input = ""; String output = ""; void run(){ try{if ( (input.length() > 0)) {in = new FastScanner(new BufferedReader(new FileReader(input))); } else in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); if ( (output.length() > 0)) out = new PrintWriter(new FileWriter(output)); else out = new PrintWriter(System.out); solve(); out.flush(); out.close(); }catch (Exception ex){ ex.printStackTrace(); out.flush(); out.close(); } finally{out.close(); }} public static void main( String[] args){ new a().run(); } class FastScanner{ BufferedReader bf ; StringTokenizer st ; public FastScanner( BufferedReader bf){ this.bf = bf; } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(bf.readLine()); return st.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(next());} } }
6	public class E{ static private final int oo = 1000000000; public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  int n = in.nextInt();  int m = in.nextInt(); if ( (n > m)) { int t = n; n = m; m = t; } int[][] curr = new int[(1 << n)][(1 << n)]; fill(curr,oo); Arrays.fill(curr[0],0); for ( int j = 0;(j < m);j++) { int[][] next = new int[(1 << n)][(1 << n)]; fill(next,oo); for ( int c0 = 0;(c0 < (1 << n));c0++) for ( int c1 = 0;(c1 < (1 << n));c1++) if ( (curr[c0][c1] != oo)) for ( int c2 = 0;(c2 < ((j == (m - 1))?1:(1 << n)));c2++) { int done = 0; for ( int i = 0;(i < n);i++) if ( (((1 << i) & c1) == 0)) { int up = (i - 1);  int down = (i + 1); if ( ((up >= 0) && (((1 << up) & c1) != 0))) done |= (1 << i); if ( ((down < n) && (((1 << down) & c1) != 0))) done |= (1 << i); if ( (((1 << i) & c0) != 0)) done |= (1 << i); if ( (((1 << i) & c2) != 0)) done |= (1 << i); } next[c1][c2] = Math.min(next[c1][c2],((curr[c0][c1] + n) - Integer.bitCount(done))); } curr = next; } int res = oo; for ( int i = 0;(i < (1 << n));i++) for ( int j = 0;(j < (1 << n));j++) res = Math.min(res,curr[i][j]); System.out.println(((n * m) - res)); } static private void fill( int[][] array, int val){ for ( int[] fill :array) Arrays.fill(fill,val); } }
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;} } }
3	public class mainA{ public static PrintWriter out = new PrintWriter(System.out); public static FastScanner enter = new FastScanner(System.in); public static void main( String[] args)throws IOException { solve(); out.close(); } public static boolean[] was ; static private void solve()throws IOException { int n = enter.nextInt();  int[] arr = new int[n]; was = new boolean[n]; for ( int i = 0;(i < n);i++) {arr[i] = enter.nextInt(); }Arrays.sort(arr); int ans = 0; for ( int i = 0;(i < n);i++) {if ( was[i]) continue; find(i,arr); ans++; }out.println(ans); } public static void find( int num, int[] arr){ for ( int i = (num + 1);(i < arr.length);i++) {if ( ((arr[i] % arr[num]) == 0)) was[i] = true; }} static class FastScanner{ BufferedReader br ; StringTokenizer stok ; FastScanner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } String next()throws IOException { while(((stok == null) || !stok.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) {return null;} stok = new StringTokenizer(s); }return stok.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} } }
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; for ( int i = 0;(i < N);i++) { boolean[][] mat = makeAdjMat(N,edgeFrom,edgeTo); best = Math.min(best,count(mat,i,M)); }System.out.println(best); } public static int count( boolean[][] mat, int center, int M){ 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();} } }
4	public class C{ public static void main( String[] args)throws Exception { File in = new File("input.txt"),out = new File("output.txt");  Scanner s ;  PrintWriter pw ; if ( in.exists()) {s = new Scanner(in); pw = new PrintWriter(out); } else {s = new Scanner(System.in); pw = new PrintWriter(System.out); } int n = s.nextInt(),m = s.nextInt();  int k = s.nextInt();  List<int[]> list = new ArrayList<int[]>(); for ( int t = 0;(t < k);++t) {list.add(new int[]{(s.nextInt() - 1),(s.nextInt() - 1)}); } int max = 0,mi = 1,mj = 1; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) { int min = Integer.MAX_VALUE; for ( int[] p :list) {min = Math.min(min,(Math.abs((i - p[0])) + Math.abs((j - p[1])))); }if ( (min > max)) {max = Math.max(max,min); mi = (i + 1); mj = (j + 1); } }}pw.println(((mi + " ") + mj)); pw.close(); } }
0	public class ElevatorOrStairs{ static private final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); static private final OutputStreamWriter writer = new OutputStreamWriter(System.out); public static void main( String... strings)throws Exception { String[] specs = reader.readLine().split(" ");  int x = Integer.parseInt(specs[0]);  int y = Integer.parseInt(specs[1]);  int z = Integer.parseInt(specs[2]);  int t1 = Integer.parseInt(specs[3]);  int t2 = Integer.parseInt(specs[4]);  int t3 = Integer.parseInt(specs[5]); reader.close(); String ans = solve(x,y,z,t1,t2,t3); writer.append(ans); writer.flush(); writer.close(); } static private String solve( int x, int y, int z, int t1, int t2, int t3){ int time_using_stairs = (Math.abs((x - y)) * t1);  int elevator_time_between_floor = (Math.abs((x - z)) * t2);  int elevator_from_z_to_x = (elevator_time_between_floor + (2 * t3));  int time_using_elevator = ((elevator_from_z_to_x + (Math.abs((x - y)) * t2)) + t3); if ( (time_using_elevator <= time_using_stairs)) {return "YES";} return "NO";} }
3	public class probC{ static int r ; static ArrayList<Circ> curr = new ArrayList<Circ>(); public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); r = sc.nextInt(); int[] xC = new int[n]; for ( int i = 0;(i < n);i++) xC[i] = sc.nextInt(); double ans[] = new double[n]; ans[0] = r; curr.add(new Circ(xC[0],r)); for ( int i = 1;(i < n);i++) { double max = r; for ( int k = 0;(k < curr.size());k++) { double cur = (curr.get(k).y + Math.sqrt((((4 * r) * r) - ((xC[i] - curr.get(k).x) * (xC[i] - curr.get(k).x))))); if ( ((((4 * r) * r) - ((xC[i] - curr.get(k).x) * (xC[i] - curr.get(k).x))) >= 0)) max = Math.max(cur,max); }ans[i] = max; curr.add(new Circ(xC[i],max)); }for ( int i = 0;(i < n);i++) System.out.print((ans[i] + " ")); sc.close(); } static class Circ{ double x ,y ; public Circ( double a, double b){ x = a; y = b; } } }
6	public class Main{ static int V ; static ArrayList<Integer> adjList[] ; static int first( int a){ int idx = 0; while(((a > 0) && ((a & 1) == 0))){idx++; a >>= 1; }return idx;} static long Number_Of_Simple_Cycles(){ long dp[][] = new long[(1 << V)][V]; for ( int i = 0;(i < V);++i) dp[(1 << i)][i] = 1; for ( int mask = 1;(mask < (1 << V));++mask) {if ( (Integer.bitCount(mask) <= 1)) continue; for ( int current = 0;(current < V);++current) {if ( (((1 << current) & mask) == 0)) continue; for ( int last :adjList[current]) if ( (current != first(mask))) {dp[mask][current] += dp[(mask ^ (1 << current))][last]; } }} long ans = 0;  int allVisited = ((1 << V) - 1); for ( int mask = 1;(mask < (1 << V));++mask) {if ( (Integer.bitCount(mask) < 3)) continue; for ( int u = 0;(u < V);++u) {if ( adjList[u].contains(first(mask))) ans += dp[mask][u]; }}return (ans >> 1);} public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  StringBuilder sb = new StringBuilder();  PrintWriter out = new PrintWriter(System.out); V = sc.nextInt(); adjList = new ArrayList[V]; for ( int i = 0;(i < V);++i) adjList[i] = new ArrayList<>(); int E = sc.nextInt(); while((E-- > 0)){ int v = (sc.nextInt() - 1);  int u = (sc.nextInt() - 1); adjList[v].add(u); adjList[u].add(v); }out.print(Number_Of_Simple_Cycles()); 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 int nextInt()throws IOException { return Integer.parseInt(next());} public boolean ready()throws IOException { return br.ready();} } }
5	public class CottageVillage{ Scanner in ; PrintWriter out ; CottageVillage(){ in = new Scanner(System.in); out = new PrintWriter(System.out); } public void finalize(){ out.flush(); in.close(); out.close(); } int ans( House a, House b, int t){ int diff = (b.cordl - a.cordr); if ( (diff < t)) return 0; if ( (diff == t)) return 1; return 2;} void solve(){ int n = in.nextInt(),t = (in.nextInt() * 2);  House[] hs = new House[n]; for ( int i = 0;(i < n);++i) { int c = in.nextInt(),l = in.nextInt(); hs[i] = new House(((2 * c) - l),((2 * c) + l)); }Arrays.sort(hs); int co = 2; for ( int i = 0;(i < (n - 1));++i) co += ans(hs[i],hs[(i + 1)],t); out.println(co); } public static void main( String[] args)throws FileNotFoundException { CottageVillage t = new CottageVillage(); t.solve(); t.finalize(); } } class House implements Comparable<House>{ public int cordl ,cordr ; public House( int c, int l){ cordl = c; cordr = l; } }
6	public class InVoker{ static long mod = 1000000007; static long mod2 = 998244353; static FastReader inp = new FastReader(); static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args){ InVoker g = new InVoker(); g.main(); out.close(); } int dp[] ; int freq[][] ; int m ; void main(){ int n = inp.nextInt(); m = inp.nextInt(); String s = inp.next(); dp = new int[(1 << m)]; Arrays.fill(dp,-1); freq = new int[m][m]; for ( int i = 0;(i < (n - 1));i++) { int x = (s.charAt(i) - 'a');  int y = (s.charAt((i + 1)) - 'a'); if ( (x == y)) continue; freq[x][y]++; freq[y][x]++; }out.println(go(0,0)); } int go( int pos, int mask){ if ( (pos == m)) return 0; if ( (dp[mask] != -1)) return dp[mask]; int gg = Integer.MAX_VALUE; for ( int i = 0;(i < m);i++) {if ( (((mask >> i) & 1) == 1)) continue; int cost = 0; for ( int j = 0;(j < m);j++) {if ( (((mask >> j) & 1) == 1)) cost += (freq[i][j] * pos); else cost -= (freq[i][j] * pos); }cost += go((pos + 1),(mask | (1 << i))); gg = Math.min(gg,cost); }return dp[mask] = gg;} void sort( int[] a){ ArrayList<Integer> list = new ArrayList<>(); for ( int x :a) list.add(x); Collections.sort(list); for ( int i = 0;(i < a.length);i++) a[i] = list.get(i); } void sort( long[] a){ ArrayList<Long> list = new ArrayList<>(); for ( long x :a) list.add(x); Collections.sort(list); for ( int i = 0;(i < a.length);i++) a[i] = list.get(i); } 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());} long nextLong(){ return Long.parseLong(next());} } long fact[] ; long invFact[] ; long mul( long a, long b){ return ((a * b) % mod);} long add( long a, long b){ return ((a + b) % mod);} long power( long x, long y){ long gg = 1; while((y > 0)){if ( ((y % 2) == 1)) gg = mul(gg,x); x = mul(x,x); y /= 2; }return gg;} static long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} void print( int[] a){ int n = a.length; for ( int i = 0;(i < n);i++) out.print((a[i] + " ")); } void print( long[] a){ int n = a.length; for ( int i = 0;(i < n);i++) out.print((a[i] + " ")); } }
4	public class p3{ 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();} byte nextByte(){ return Byte.parseByte(next());} short nextShort(){ return Short.parseShort(next());} } public static void main( String[] args){ FastReader fr = new FastReader();  byte t = fr.nextByte(); while((t-- > 0)){ short n = fr.nextShort();  short a[] = new short[n]; for ( short i = -1;(++i < n);) a[i] = fr.nextShort(); String s = "1"; System.out.println(s); for ( short i = 0;(++i < n);) {if ( (a[i] == 1)) {s += ".1"; System.out.println(s); } else if ( (a[i] == (a[(i - 1)] + 1))) { int c = s.lastIndexOf("."); s = (s.substring(0,(c + 1)) + a[i]); System.out.println(s); } else {for ( ;;) {s = s.substring(0,s.lastIndexOf(".")); int c = s.lastIndexOf(".");  int b = Integer.parseInt(s.substring((c + 1),s.length())); if ( ((b + 1) == a[i])) {s = (s.substring(0,(c + 1)) + a[i]); System.out.println(s); break;} }}}}} }
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")); }} }
0	public class T{ public static void main( String[] args)throws IOException { T t = new T(); t.run(); t.close(); } private void close(){ sc.close(); pw.close(); } BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); Scanner sc = new Scanner(reader); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); void run()throws IOException { int n = sc.nextInt(); if ( ((n % 2) == 0)) {pw.print(((4 + " ") + (n - 4))); } else {pw.print(((9 + " ") + (n - 9))); }} }
5	public class Main{ static long initTime ; static final Random rnd = new Random(7777L); static boolean writeLog = false; public static void main( String[] args)throws IOException { initTime = System.currentTimeMillis(); try{writeLog = "true".equals(System.getProperty("LOCAL_RUN_7777")); }catch (SecurityException e){ } 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){ } long prevTime = System.currentTimeMillis(); new Main().run(); log((("Total time: " + (System.currentTimeMillis() - prevTime)) + " ms")); log(("Memory status: " + memoryStatus())); }catch (IOException e){ e.printStackTrace(); } } },"1",(1L << 24)).start(); } void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); in.close(); } void solve()throws IOException { int n = nextInt();  long k = nextLong();  int[] a = nextIntArray(n);  Set<Long> bad = new TreeSet<Long>(); sort(a); int ans = 0; for ( int x :a) {if ( !bad.contains((long)x)) {bad.add((x * k)); ans++; } }out.println(ans); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); String nextToken()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} int[] nextIntArray( int size)throws IOException { int[] ret = new int[size]; for ( int i = 0;(i < size);i++) ret[i] = nextInt(); return ret;} static String memoryStatus(){ return (((((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20) + "/") + (Runtime.getRuntime().totalMemory() >> 20)) + " MB");} static long prevTimeStamp = Long.MIN_VALUE; static long elapsedTime(){ return (System.currentTimeMillis() - prevTimeStamp);} static void log( String format, Object... args){ if ( writeLog) System.err.println(String.format(Locale.US,format,args)); } }
5	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(),k = nextInt(),s = nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = -nextInt(); Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( (s >= k)) {out.println(i); return ;} s += -a[i]; s--; }if ( (s < k)) out.println(-1); else out.println(n); } 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(); } }
3	public class Main{ public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  FastScanner sc = new FastScanner();  int dp[][] = new int[6000][6000];  char a[] = new char[6000]; final int n = sc.nextInt();  boolean flag = false;  int cnt = 0;  char pre = 'f'; for ( int i = 1;(i <= n);i++) {a[i] = sc.next().charAt(0); }dp[1][1] = 1; final int mod = ((int)1e9 + 7); dp[1][1] = 1; for ( int i = 2;(i <= n);i++) {if ( (a[(i - 1)] == 's')) { int now = 0; for ( int j = 5050;(j >= 1);j--) {now = ((now + dp[(i - 1)][j]) % mod); dp[i][j] = now; }} else {for ( int j = 5050;(j >= 1);j--) {dp[i][j] = (dp[(i - 1)][(j - 1)] % mod); }}} int ans = 0; for ( int i = 0;(i <= 5050);i++) {ans += (dp[n][i] % mod); ans %= mod; }out.println((ans % mod)); out.flush(); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; private FastScanner(){ try{br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } private String next(){ if ( st.hasMoreTokens()) return st.nextToken(); try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } return st.nextToken();} private int nextInt(){ return Integer.parseInt(next());} private long nextLong(){ return Long.parseLong(next());} private double nextDouble(){ return Double.parseDouble(next());} } }
3	public class A{ void solve(){ int n = ni();  long r = ni();  int x[] = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) x[i] = ni(); double ans[] = new double[(n + 1)]; ans[1] = r; for ( int i = 2;(i <= n);i++) { double mx = 0; for ( int j = 1;(j < i);j++) { double xx = Math.abs((x[i] - x[j])); if ( (xx > (2 * r))) {mx = Math.max(mx,r); } else {xx *= xx; mx = Math.max(mx,(ans[j] + Math.sqrt((((4 * r) * r) - xx)))); }}ans[i] = mx; }for ( int i = 1;(i <= n);i++) pw.print((ans[i] + " ")); } long M = ((long)1e9 + 7); InputStream is ; PrintWriter pw ; String INPUT = ""; void run()throws Exception { is = (INPUT.isEmpty()?System.in:new ByteArrayInputStream(INPUT.getBytes())); pw = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); pw.flush(); if ( !INPUT.isEmpty()) 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 = 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 void tr( Object... o){ if ( (INPUT.length() > 0)) System.out.println(Arrays.deepToString(o)); } }
6	public class C implements Runnable{ String file = "input"; boolean TEST = false; void solve()throws IOException { rows = nextInt(); cols = nextInt(); if ( (cols > rows)) { int t = rows; rows = cols; cols = t; } dp = new int[rows][cols][(1 << cols)][(1 << cols)][(1 << cols)]; for ( int i = 0;(i < rows);i++) for ( int j = 0;(j < cols);j++) for ( int k = 0;(k < (1 << cols));k++) for ( int u = 0;(u < (1 << cols));u++) for ( int v = 0;(v < (1 << cols));v++) dp[i][j][k][u][v] = -1; out.println(go(0,0,0,0,0)); } int rows ,cols ; int[][][][][] dp ; int INF = (1 << 20); int go( int i, int j, int a, int b, int c){ if ( (i == rows)) {return ((((a == 0) && (b == 0)) && (c == 0))?0:-INF);} if ( ((((i + 1) == rows) && (b != 0)) && (c != 0))) return -INF; if ( (((i + 2) == rows) && (c != 0))) return -INF; if ( (j == cols)) {return go((i + 1),0,b,c,0);} if ( (dp[i][j][a][b][c] != -1)) return dp[i][j][a][b][c]; if ( !test(a,j,-1,-1)) return go(i,(j + 1),a,b,c); int res = -INF; if ( test(a,j,-1,-1)) res = max(res,go(i,(j + 1),set(a,j,-1,-1),b,c)); if ( (test(a,j,-1,-1) && test(b,j,-1,-1))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,j,-1,-1),c) + 1)); if ( (((j + 2) <= cols) && test(a,j,(j + 1),-1))) res = max(res,(go(i,(j + 2),set(a,j,(j + 1),-1),b,c) + 1)); if ( (((j + 3) <= cols) && test(a,j,(j + 1),(j + 2)))) res = max(res,(go(i,(j + 2),set(a,j,(j + 1),(j + 2)),b,c) + 2)); if ( ((test(a,j,-1,-1) && test(b,j,-1,-1)) && test(c,j,-1,-1))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,j,-1,-1),set(c,j,-1,-1)) + 2)); if ( (((((j - 1) >= 0) && test(a,j,-1,-1)) && test(b,(j - 1),j,-1)) && test(c,j,-1,-1))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,(j - 1),j,-1),set(c,j,-1,-1)) + 3)); if ( (((((j + 2) <= cols) && test(a,j,-1,-1)) && test(b,j,(j + 1),-1)) && test(c,j,-1,-1))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,j,(j + 1),-1),set(c,j,-1,-1)) + 3)); if ( ((((j + 3) <= cols) && test(a,j,(j + 1),(j + 2))) && test(b,(j + 1),-1,-1))) res = max(res,(go(i,(j + 3),set(a,j,(j + 1),(j + 2)),set(b,(j + 1),-1,-1),c) + 3)); if ( ((((j + 2) <= cols) && ((j - 1) >= 0)) && test(b,(j - 1),j,(j + 1)))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,(j - 1),j,(j + 1)),c) + 3)); if ( (((((j + 2) <= cols) && ((j - 1) >= 0)) && test(b,(j - 1),j,(j + 1))) && test(c,j,-1,-1))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,(j - 1),j,(j + 1)),set(c,j,-1,-1)) + 4)); if ( (((j + 2) <= cols) && test(b,j,(j + 1),-1))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,j,(j + 1),-1),c) + 2)); if ( (((j - 1) >= 0) && test(b,(j - 1),j,-1))) res = max(res,(go(i,(j + 1),set(a,j,-1,-1),set(b,(j - 1),j,-1),c) + 2)); if ( ((((j + 2) <= cols) && test(a,j,(j + 1),-1)) && test(b,j,-1,-1))) res = max(res,(go(i,(j + 2),set(a,j,(j + 1),-1),set(b,j,-1,-1),c) + 2)); if ( ((((j + 2) <= cols) && test(a,j,(j + 1),-1)) && test(b,(j + 1),-1,-1))) res = max(res,(go(i,(j + 2),set(a,j,(j + 1),-1),set(b,(j + 1),-1,-1),c) + 2)); return dp[i][j][a][b][c] = res;} int set( int a, int i, int j, int k){ if ( (i != -1)) a |= (1 << i); if ( (j != -1)) a |= (1 << j); if ( (k != -1)) a |= (1 << k); return a;} boolean test( int a, int i, int j, int k){ if ( ((i != -1) && (((a >> i) & 1) != 0))) return false; if ( ((j != -1) && (((a >> j) & 1) != 0))) return false; if ( ((k != -1) && (((a >> k) & 1) != 0))) return false; return true;} String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(input.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} BufferedReader input ; PrintWriter out ; StringTokenizer st ; int test ; void init()throws IOException { if ( TEST) input = new BufferedReader(new FileReader((file + ".in"))); else input = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new BufferedOutputStream(System.out)); } public static void main( String[] args)throws IOException { new Thread(null,new C(),"",(1 << 20)).start(); } }
5	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);  TaskG solver = new TaskG(); solver.solve(1,in,out); out.close(); } static class TaskG{ static int[][] g ; static int n ; static int[] a ; static int[][] edges ; static long[] dp ; static long[] dpPathToRootWithDetours ; static int time = 0; static int[] appearance ; static int[] firstAppearance ; static int[] depth ; public static void dfs( int i, int parE){ firstAppearance[i] = time; appearance[time++] = i; dp[i] = a[i]; for ( int eIndex :g[i]) {if ( (eIndex == parE)) continue; int child = ((i ^ edges[eIndex][0]) ^ edges[eIndex][1]); dfs(child,eIndex); appearance[time++] = i; dp[i] += Math.max((dp[child] - (edges[eIndex][2] * 2)),0); }} public static void dfs2( int i, int parE){ if ( (i == 0)) {dpPathToRootWithDetours[i] = dp[i]; } else { int par = ((i ^ edges[parE][0]) ^ edges[parE][1]); depth[i] = (depth[par] + 1); dpPathToRootWithDetours[i] = (dpPathToRootWithDetours[par] - Math.max(0,(dp[i] - (edges[parE][2] * 2)))); dpPathToRootWithDetours[i] -= edges[parE][2]; dpPathToRootWithDetours[i] += dp[i]; long myPathWeight = Math.max((dp[i] - (edges[parE][2] * 2)),0);  long change = ((dp[par] - myPathWeight) - (edges[parE][2] * 2)); change = Math.max(change,0); dp[i] += change; }for ( int eIndex :g[i]) {if ( (eIndex == parE)) continue; dfs2(((i ^ edges[eIndex][0]) ^ edges[eIndex][1]),eIndex); }} public void solve( int testNumber, InputReader in, PrintWriter out){ n = in.NextInt(); int q = in.NextInt(); a = in.NextIntArray(n); edges = new int[(n - 1)][3]; { long[] count = new long[n]; for ( int i = 0;(i < (n - 1));i++) { int u = (in.NextInt() - 1);  int v = (in.NextInt() - 1);  int w = in.NextInt(); edges[i][0] = u; edges[i][1] = v; edges[i][2] = w; count[u]++; count[v]++; }g = new int[n][]; for ( int i = 0;(i < n);i++) {g[i] = new int[(int)count[i]]; }for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < 2);j++) {g[edges[i][j]][(int)--count[edges[i][j]]] = i; }}}dp = new long[n]; dpPathToRootWithDetours = new long[n]; depth = new int[n]; firstAppearance = new int[n]; appearance = new int[(((n - 1) * 2) + 1)]; dfs(0,-1); dfs2(0,-1); GraphLowestCommonAncestor.LCA lca = GraphLowestCommonAncestor.createLCA(appearance,firstAppearance,depth); firstAppearance = null; depth = null; appearance = null; edges = null; g = null; for ( int i = 0;(i < q);i++) { int u = (in.NextInt() - 1);  int v = (in.NextInt() - 1);  int lcaI = lca.getLCA(u,v);  long res = (((dpPathToRootWithDetours[u] + dpPathToRootWithDetours[v]) - (2 * dpPathToRootWithDetours[lcaI])) + dp[lcaI]); out.println(res); }} } static class MinRangeSparseTable implements ISearchInRange{ private final int[][] sparseTables ; private final long[] array ; private final boolean reverseOrdered ; public MinRangeSparseTable( long[] array, boolean reverseOrdered){ this.reverseOrdered = reverseOrdered; this.array = array; int LCALength = IntegerExtension.getNumberOfBits(array.length); sparseTables = new int[LCALength][]; sparseTables[0] = new int[array.length]; for ( int i = 0;(i < array.length);i++) {sparseTables[0][i] = i; }for ( int i = 1;(i < LCALength);i++) { int size = (1 << i);  int jumpSize = (1 << (i - 1)); sparseTables[i] = new int[((sparseTables[0].length - size) + 1)]; for ( int j = 0;(j < sparseTables[i].length);j++) {sparseTables[i][j] = min(sparseTables[(i - 1)][j],sparseTables[(i - 1)][(j + jumpSize)]); }}} private int min( int a, int b){ return (((array[a] < array[b]) ^ reverseOrdered)?a:b);} public Pair<Long,Long> queryIndexValueInRange( long l, long r){ int size = (int)((r - l) + 1);  int LCAIndex = (IntegerExtension.getNumberOfBits(size) - 1);  int sizeNeeded = (1 << LCAIndex);  int res = min(sparseTables[LCAIndex][(int)l],sparseTables[LCAIndex][(int)((r - sizeNeeded) + 1)]); return new Pair<>((long)res,array[res]);} public MinRangeSparseTable( long[] array){ this(array,false); } } 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 int[] NextIntArray( int n){ return NextIntArray(n,0);} public int[] NextIntArray( int n, int offset){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = (NextInt() + offset); }return a;} } static interface ISearchInRange{ } }
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(){ int t = in.nextInt(); for ( int i = 0;(i < t);i++) {out.println(work()); }out.flush(); } long mod = 1000000007; long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} int work(){ int n = in.nextInt();  int m = in.nextInt();  int[][] A = new int[n][m];  int[][] B = new int[n][m];  int[][] R = new int[m][2]; for ( int i = 0;(i < m);i++) R[i][1] = i; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {A[i][j] = in.nextInt(); R[j][0] = Math.max(R[j][0],A[i][j]); }}Arrays.sort(R,new Comparator<int[]>(){}); for ( int j = 0;(j < m);j++) { int index = R[j][1]; for ( int i = 0;(i < n);i++) {B[i][j] = A[i][index]; }}m = Math.min(n,m); int[][] dp = new int[m][(1 << n)];  int[][] rec = new int[m][(1 << n)]; for ( int j = 0;(j < m);j++) {for ( int s = 0;(s < n);s++) {for ( int i = 1;(i < (1 << n));i++) { int sum = 0; for ( int b = 0;(b < n);b++) {if ( (((1 << b) & i) > 0)) {sum += B[((b + s) % n)][j]; } }rec[j][i] = Math.max(sum,rec[j][i]); }}}for ( int j = 0;(j < m);j++) {for ( int i = 0;(i < (1 << n));i++) {if ( (j == 0)) {dp[j][i] = rec[j][i]; } else {for ( int p = (i + 1);;p++) {if ( (p >= (1 << n))) break; p = (p | i); dp[j][p] = Math.max(dp[j][p],(rec[j][i] + dp[(j - 1)][(p ^ i)])); }}}}return dp[(m - 1)][((1 << n) - 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());} }
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; }} }
1	public class ChainReaction{ public static void main( String[] args){ Scanner kb = new Scanner(System.in);  int num = kb.nextInt();  int[] beacons = new int[1000002]; for ( int i = 0;(i < num);i++) {beacons[kb.nextInt()] = kb.nextInt(); } int[] dp = new int[1000002];  int max = 0; if ( (beacons[0] != 0)) dp[0] = 1; for ( int i = 1;(i < dp.length);i++) {if ( (beacons[i] == 0)) {dp[i] = dp[(i - 1)]; } else { int index = ((i - 1) - beacons[i]); if ( (index < 0)) dp[i] = 1; else dp[i] = (1 + dp[index]); }max = Math.max(max,dp[i]); }System.out.println((num - max)); } }
3	public class template{ public static void main( String[] args)throws Exception { FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  Integer[] arr = new Integer[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); }Arrays.sort(arr); int ct = 0;  boolean[] ar = new boolean[n]; for ( int i = 0;(i < n);i++) {if ( !ar[i]) {ar[i] = true; ct++; int x = arr[i]; for ( int j = 0;(j < n);j++) {if ( ((arr[j] % x) == 0)) {ar[j] = true; } }} }pw.println(ct); pw.close(); } } @SuppressWarnings("all") class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( BufferedReader d){ br = d; } 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());} }
4	public class C{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(in,out); out.close(); } static class Task{ double eps = 0.00000001; static final int MAXN = 10000001; static int spf[] = new int[MAXN]; Map<Integer,Set<Integer>> dp = new HashMap<>(); public int lowerIndex( List<Integer> arr, int n, int x){ int l = 0,h = (n - 1); while((l <= h)){ int mid = ((l + h) / 2); if ( (arr.get(mid) >= x)) h = (mid - 1); else l = (mid + 1); }return l;} public int upperIndex( List<Integer> arr, int n, int y){ int l = 0,h = (n - 1); while((l <= h)){ int mid = ((l + h) / 2); if ( (arr.get(mid) <= y)) l = (mid + 1); else h = (mid - 1); }return h;} InputReader in ; PrintWriter out ; public void solve( InputReader in, PrintWriter out){ this.in = in; this.out = out; int t = in.nextInt(); while((t-- > 0)){ int n = in.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = in.nextInt(); int[] cur = new int[n];  int idx = 0; for ( int num :arr) {if ( ((idx < n) && (num == (cur[idx] + 1)))) {cur[idx] = num; printRes(cur,idx); idx++; } else {for ( int i = idx;(i >= 0);i--) {if ( ((i < n) && (num != (cur[i] + 1)))) cur[i] = 0; else {cur[i] = num; printRes(cur,i); i++; idx = i; break;}}}}}} public void printRes( int[] cur, int idx){ for ( int i = 0;(i < idx);i++) out.print((cur[i] + ".")); out.println(cur[idx]); } public static void swap( char[] array, int i, int j){ char temp = array[i]; array[i] = array[j]; array[j] = temp; } public static void reverse( char[] array, int start, int end){ for ( int i = start,j = (end - 1);(i < j);i++,j--) {swap(array,i,j); }} public int _gcd( int a, int b){ if ( (b == 0)) {return a;} else {return _gcd(b,(a % b));}} } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream)); } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){ String line = null; try{line = br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} if ( (line == null)) {return null;} st = new StringTokenizer(line); }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} } }
4	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new FileReader("input.txt"));  String dimensions = br.readLine();  String extractDim = "";  int n = 0,m ; for ( int i = 0;(i < dimensions.length());i++) {if ( (dimensions.charAt(i) == ' ')) {n = Integer.parseInt(extractDim); extractDim = ""; continue;} extractDim += dimensions.charAt(i); }m = Integer.parseInt(extractDim); String burningTrees = br.readLine();  int k = Integer.parseInt(burningTrees);  Point[] coord = new Point[k];  String coordSet = br.readLine();  int spaceCount = 0;  String newCoord = "";  int s = 0; for ( int i = 0;(i < coordSet.length());i++) {if ( (coordSet.charAt(i) == ' ')) spaceCount++; if ( (spaceCount == 2)) { String extractCoord = "";  int x = 0,y ; for ( int j = 0;(j < newCoord.length());j++) {if ( (newCoord.charAt(j) == ' ')) {x = Integer.parseInt(extractCoord); extractCoord = ""; continue;} extractCoord += newCoord.charAt(j); }y = Integer.parseInt(extractCoord); coord[s] = new Point(x,y); s++; newCoord = ""; spaceCount = 0; continue;} newCoord += coordSet.charAt(i); } String extractCoord = "";  int x = 0,y ; for ( int j = 0;(j < newCoord.length());j++) {if ( (newCoord.charAt(j) == ' ')) {x = Integer.parseInt(extractCoord); extractCoord = ""; continue;} extractCoord += newCoord.charAt(j); }y = Integer.parseInt(extractCoord); coord[s] = new Point(x,y); s++; br.close(); int[][] forest = new int[(n + 2)][(m + 2)]; for ( int i = 0;(i < forest.length);i++) {for ( int j = 0;(j < forest[i].length);j++) {if ( ((((i == 0) || (i == (n + 1))) || (j == 0)) || (j == (m + 1)))) forest[i][j] = 0; else forest[i][j] = 1; }} Queue<Point> q = new LinkedList<>(); for ( int i = 0;(i < coord.length);i++) {forest[coord[i].x][coord[i].y] = 0; q.add(coord[i]); } Point tree = new Point(); while(!q.isEmpty()){ Point temp = q.remove(); forest[temp.x][temp.y] = 0; if ( q.isEmpty()) tree = new Point(temp.x,temp.y); for ( int i = -1;(i <= 1);i++) {for ( int j = -1;(j <= 1);j++) {if ( (((i != 0) && (j != 0)) || ((i == 0) && (j == 0)))) continue; if ( (forest[(temp.x + i)][(temp.y + j)] == 0)) continue; else {forest[(temp.x + i)][(temp.y + j)] = 0; q.add(new Point((temp.x + i),(temp.y + j))); }}}} BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt")); bw.write(((tree.x + " ") + tree.y)); bw.close(); } }
5	public class A{ int n ; int[] a ; public void run()throws IOException { Scanner s = new Scanner(new InputStreamReader(System.in)); n = s.nextInt(); a = new int[n]; long sum = 0; for ( int i = 0;(i < n);i++) {a[i] = s.nextInt(); sum += a[i]; }Arrays.sort(a); long mysum = 0;  int count = 0; for ( int i = (n - 1);(i > -1);i--) {if ( (mysum > sum)) break; count++; mysum += a[i]; sum -= a[i]; }System.out.println(count); } public static void main( String[] args)throws IOException { new A().run(); } }
5	public class loser{ static class InputReader{ public BufferedReader br ; public StringTokenizer token ; public InputReader( InputStream stream){ br = new BufferedReader(new InputStreamReader(stream),32768); token = null; } public String next(){ while(((token == null) || !token.hasMoreTokens())){try{token = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return token.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } static class card{ int l ; int r ; public card( int ch, int i){ this.l = ch; this.r = i; } } static class sort implements Comparator<card>{ } static void shuffle( long[] a){ List<Long> l = new ArrayList<>(); for ( int i = 0;(i < a.length);i++) l.add(a[i]); Collections.shuffle(l); for ( int i = 0;(i < a.length);i++) a[i] = l.get(i); } public static void main( String[] args){ InputReader sc = new InputReader(System.in);  int n = sc.nextInt();  int s = sc.nextInt();  card c[] = new card[n]; for ( int i = 0;(i < n);i++) { int x = sc.nextInt();  int y = sc.nextInt(); c[i] = new card(x,y); }Arrays.sort(c,new sort()); int time = 0; for ( int i = (n - 1);(i >= 0);i--) {time += (s - c[i].l); if ( ((c[i].r - time) > 0)) time += (c[i].r - time); s = c[i].l; }if ( (c[0].l != 0)) time += c[0].l; System.out.println(time); } }
5	public class Solution{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int[] a = new int[n];  boolean has_more_than_one = false; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); if ( (a[i] > 1)) has_more_than_one = true; }Arrays.sort(a); if ( (n == 1)) {if ( (a[0] == 1)) out.print(2); else out.print(1); } else {out.print((1 + " ")); for ( int i = 1;(i < n);i++) {if ( (has_more_than_one || (i < (n - 1)))) out.print((a[(i - 1)] + " ")); else out.println(2); }}out.close(); } }
3	public class PaintColor{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  String input[] = br.readLine().split(" ");  int c = 0;  Set<Integer> s = new HashSet<>();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(input[i]); }Arrays.sort(arr); for ( int i = 0;(i < n);i++) {if ( !s.contains(arr[i])) {c++; for ( int j = i;(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) {s.add(arr[j]); } }} }System.out.println(c); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  StreamInputReader in = new StreamInputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, StreamInputReader in, PrintWriter out){ int N = in.readInt();  int K = in.readInt();  int[] A = new int[N]; for ( int i = 0;(i < N);i++) A[i] = in.readInt(); int num = 0;  int left = 0;  int right = 0;  int[] seen = new int[100005]; while(((right < N) && (num < K))){if ( (seen[A[right]] == 0)) num++; seen[A[right]]++; right++; }right--; if ( (num == K)) {while((seen[A[left]] > 1)){seen[A[left]]--; left++; }out.print((((left + 1) + " ") + (right + 1))); return ;} out.print("-1 -1"); } } 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++];} }
3	public class P911d{ static private void solve(){ int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } int cnt = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) {cnt++; } }}cnt %= 2; int m = nextInt(); for ( int i = 0;(i < m);i++) { int l = nextInt();  int r = nextInt();  int size = ((r - l) + 1);  long sum = (((long)size * (size - 1)) / 2); sum %= 2; cnt += sum; cnt %= 2; System.out.println(((cnt == 0)?"even":"odd")); }} static private void run(){ br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } static private StringTokenizer st ; static private BufferedReader br ; static private PrintWriter out ; static private String next(){ while(((st == null) || !st.hasMoreElements())){ String s ; try{s = br.readLine(); }catch (IOException e){ return null;} st = new StringTokenizer(s); }return st.nextToken();} static private int nextInt(){ return Integer.parseInt(next());} public static void main( String[] args){ run(); } }
4	public class D{ static FastIO f ; static long ve[][] ,he[][] ; public static void main( String[] args)throws IOException { f = new FastIO(); int n = f.ni(),m = f.ni(),k = f.ni(),i ,j ; ve = new long[(n - 1)][]; he = new long[n][]; long[][] ans = new long[n][m],pans = new long[n][m],temp ; for ( i = 0;(i < n);i++) he[i] = f.nla((m - 1)); for ( i = 0;(i < (n - 1));i++) ve[i] = f.nla(m); if ( ((k % 2) == 1)) {for ( i = 0;(i < n);i++) Arrays.fill(ans[i],-1L); } else {k /= 2; while((k-- > 0)){for ( i = 0;(i < n);i++) {for ( j = 0;(j < m);j++) {ans[i][j] = Integer.MAX_VALUE; if ( (i != 0)) ans[i][j] = Math.min(ans[i][j],(pans[(i - 1)][j] + (2 * edge(i,j,(i - 1),j)))); if ( (i != (n - 1))) ans[i][j] = Math.min(ans[i][j],(pans[(i + 1)][j] + (2 * edge(i,j,(i + 1),j)))); if ( (j != 0)) ans[i][j] = Math.min(ans[i][j],(pans[i][(j - 1)] + (2 * edge(i,j,i,(j - 1))))); if ( (j != (m - 1))) ans[i][j] = Math.min(ans[i][j],(pans[i][(j + 1)] + (2 * edge(i,j,i,(j + 1))))); }}temp = pans; pans = ans; ans = temp; }temp = pans; pans = ans; ans = temp; }for ( i = 0;(i < n);i++) {for ( j = 0;(j < m);j++) {f.out((ans[i][j] + " ")); }f.out("\n"); }f.flush(); } public static long edge( int i, int j, int x, int y){ if ( (i == x)) return he[i][Math.min(j,y)]; else return ve[Math.min(i,x)][j];} public static class FastIO{ BufferedReader br ; BufferedWriter bw ,be ; StringTokenizer st ; public FastIO(){ br = new BufferedReader(new InputStreamReader(System.in)); bw = new BufferedWriter(new OutputStreamWriter(System.out)); be = new BufferedWriter(new OutputStreamWriter(System.err)); st = new StringTokenizer(""); } private void read()throws IOException { st = new StringTokenizer(br.readLine()); } public String ns()throws IOException { while(!st.hasMoreTokens())read(); return st.nextToken();} public int ni()throws IOException { return Integer.parseInt(ns());} public long nl()throws IOException { return Long.parseLong(ns());} public long[] nla( int n)throws IOException { long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nl(); return a;} public void out( String s)throws IOException { bw.write(s); } public void flush()throws IOException { bw.flush(); be.flush(); } public void err( String s)throws IOException { be.write(s); } } }
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;} static private 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();} } }
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);  G1playlist solver = new G1playlist(); solver.solve(1,in,out); out.close(); } static class G1playlist{ int mod = 1000000007; public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int T = in.scanInt();  int[][] song = new int[n][2]; for ( int i = 0;(i < n);i++) {song[i][0] = in.scanInt(); song[i][1] = (in.scanInt() - 1); } int[][][] dp = new int[(T + 1)][(1 << n)][3]; for ( int i = 0;(i < n);i++) if ( (song[i][0] <= T)) {dp[song[i][0]][(1 << i)][song[i][1]] = 1; } for ( int t = 0;(t <= T);t++) {for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < 3);j++) {if ( (dp[t][i][j] == 0)) continue; for ( int k = 0;(k < n);k++) {if ( (((((1 << k) & i) == 0) && ((t + song[k][0]) <= T)) && (song[k][1] != j))) dp[(t + song[k][0])][((1 << k) | i)][song[k][1]] = ((dp[(t + song[k][0])][((1 << k) | i)][song[k][1]] + dp[t][i][j]) % mod); }}}} long ans = 0; for ( int i = 0;(i < (1 << n));i++) {for ( int j = 0;(j < 3);j++) {ans = ((ans + dp[T][i][j]) % mod); }}out.println(ans); } } 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
6	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  QuickScanner in = new QuickScanner(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, QuickScanner in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  boolean[][] is = new boolean[n][n]; for ( int i = 0;(i < n);i++) {is[i][i] = true; } long[][] dp = new long[((1 << n) | 1)][n]; for ( int i = 0;(i < m);i++) { int u = (in.nextInt() - 1);  int v = (in.nextInt() - 1); is[u][v] = is[v][u] = true; dp[((1 << u) + (1 << v))][v] = 1; dp[((1 << u) + (1 << v))][u] = 1; } int k = 0;  long res = 0; for ( int mask = 1;(mask < (1 << n));++mask) { boolean f = true; for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) != 0) && (dp[mask][i] == 0))) {if ( f) {f = false; k = i; } else {for ( int j = (k + 1);(j < n);j++) {if ( (((mask & (1 << j)) != 0) && is[i][j])) {dp[mask][i] += dp[(mask - (1 << i))][j]; } }}if ( is[k][i]) res += dp[mask][i]; } }}out.println((res >> 1)); } } static class QuickScanner{ BufferedReader br ; StringTokenizer st ; InputStream is ; public QuickScanner( InputStream stream){ is = stream; br = new BufferedReader(new InputStreamReader(stream),32768); } String nextToken(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} int nextInt(){ return Integer.parseInt(nextToken());} } }
6	public class B{ int n ,k ; double A ; int[] b ,l ; double ans ; double curAns ; void check( boolean[] used){ int cnt = 0; for ( boolean t :used) if ( t) cnt++;  double prob = 1; for ( int i = 0;(i < n);i++) {if ( used[i]) prob *= ((double)l[i] / (double)100); else prob *= (1 - ((double)l[i] / (double)100)); }if ( ((2 * cnt) > n)) {curAns += prob; } else { int level = 0; for ( int i = 0;(i < n);i++) if ( !used[i]) level += b[i]; curAns += (prob * (A / ((double)A + level))); }} void go( int i, boolean[] used){ if ( (n == i)) {check(used); return ;} used[i] = true; go((i + 1),used); used[i] = false; go((i + 1),used); } void candies( int k, int i){ if ( (i == n)) {curAns = 0; go(0,new boolean[n]); if ( (curAns > ans)) ans = curAns; return ;} candies(k,(i + 1)); for ( int j = 1;((j <= k) && ((l[i] + (10 * j)) <= 100));j++) {l[i] += (10 * j); candies((k - j),(i + 1)); l[i] -= (10 * j); }} void solve()throws Exception { n = nextInt(); k = nextInt(); A = nextInt(); b = new int[n]; l = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = nextInt(); l[i] = nextInt(); }ans = 0; candies(k,0); out.printf("%.12f",ans); } void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); Locale.setDefault(Locale.US); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } BufferedReader in ; StringTokenizer st ; PrintWriter out ; final String filename = new String("B").toLowerCase(); 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());} public static void main( String[] args){ new B().run(); } }
6	public class Ok_Simple{ static BufferedReader reader ; static StringTokenizer tokenizer ; static boolean am[][] ; static long dp[][] ; static int n ; public static void main( String[] args)throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); int m ; n = NextInt(); m = NextInt(); am = new boolean[n][n]; dp = new long[n][(1 << n)]; for ( int i = 0;(i < n);++i) Arrays.fill(dp[i],-1); for ( int i = 0;(i < m);++i) { int a = (NextInt() - 1);  int b = (NextInt() - 1); am[a][b] = am[b][a] = true; }; long res = 0; for ( int a = 0;(a < n);++a) res += solve(a,(1 << a)); System.out.println((res / 2)); } static private long solve( int b, int mask){ int a = 0; for ( int i = 0;(i < n);++i) if ( (((mask >> i) & 1) != 0)) {a = i; break;} if ( (dp[b][mask] >= 0)) return dp[b][mask]; long res = 0; if ( (am[b][a] && (Integer.bitCount(mask) > 2))) res = 1; for ( int i = (a + 1);(i < n);++i) if ( ((((mask >> i) & 1) == 0) && am[b][i])) res += solve(i,(mask ^ (1 << i))); return dp[b][mask] = res;} 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();} }
1	public class Main{ boolean eof ; public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return "-1";} }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} void solve(){ int n = nextInt(),k = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);++i) {a[i] = (nextInt() - 1); } int[] b = new int[100000];  int p = 0; for ( int i = 0;(i < n);++i) {++b[a[i]]; if ( (b[a[i]] == 1)) {++p; } if ( (k == p)) { int j ; for ( j = 0;(j <= i);++j) {if ( (b[a[j]] > 1)) {--b[a[j]]; } else {break;}}out.print((((j + 1) + " ") + (i + 1))); return ;} }out.print("-1 -1"); } BufferedReader br ; StringTokenizer st ; PrintWriter out ; void run(){ try{br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); br.close(); out.close(); }catch (Throwable e){ e.printStackTrace(); System.exit(1); } } public static void main( String[] args){ new Main().run(); } }
2	public class B{ public static void main( String[] args){ doIt(); } static void doIt(){ Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  long n = sc.nextLong();  long k = sc.nextLong();  long msum = ((((k - 1) * k) / 2) + 1);  long u = k;  long l = 0;  long m = ((u + l) / 2); while((l < u)){m = (((u + l) / 2) + ((u + l) % 2)); long sum = (((m - 1) * m) / 2); if ( (n <= (msum - sum))) l = m; else u = (m - 1); }m = (((u + l) / 2) + ((u + l) % 2)); if ( ((msum - (((m - 1) * m) / 2)) < n)) System.out.println(-1); else System.out.println((k - m)); } }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  String inp = in.nextLine(); System.out.println(25); } }
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);  ProblemCFireAgain solver = new ProblemCFireAgain(); solver.solve(1,in,out); out.close(); } static class ProblemCFireAgain{ static private final byte[] dx = {-1,0,0,1}; static private final byte[] dy = {0,-1,1,0}; static private int[][] lvl ; static private int max ; static private int n ; static private int m ; static private int k ; static private ProblemCFireAgain.Pair[] bgn ; static private ProblemCFireAgain.Pair res ; static private void bfs2d(){ Queue<ProblemCFireAgain.Pair> bfsq = new LinkedList<ProblemCFireAgain.Pair>(); for ( ProblemCFireAgain.Pair src :bgn) {lvl[src.a][src.b] = 0; bfsq.add(src); }while(!bfsq.isEmpty()){ ProblemCFireAgain.Pair op = bfsq.poll();  int plvl = lvl[op.a][op.b]; if ( (plvl > max)) {res = op; max = plvl; } for ( int i = 0;(i < 4);i++) { int newX = (op.a + dx[i]);  int newY = (op.b + dy[i]); if ( (((((newX > 0) && (newX <= n)) && (newY > 0)) && (newY <= m)) && (lvl[newX][newY] == -1))) {bfsq.add(new ProblemCFireAgain.Pair(newX,newY)); lvl[newX][newY] = (plvl + 1); } }}} public void solve( int testNumber, InputReader _in, PrintWriter _out){ try(InputReader in=new InputReader(new FileInputStream("input.txt"));PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter("output.txt")))){n = in.nextInt(); m = in.nextInt(); k = in.nextInt(); bgn = new ProblemCFireAgain.Pair[k]; for ( int i = 0;(i < k);i++) {bgn[i] = new ProblemCFireAgain.Pair(in.nextInt(),in.nextInt()); }max = Integer.MIN_VALUE; lvl = new int[(n + 5)][(m + 5)]; for ( int i = 0;(i < (n + 4));i++) {Arrays.fill(lvl[i],-1); }bfs2d(); out.println(res); }catch (Exception e){ } } } static class InputReader implements AutoCloseable{ 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{ String str ; if ( ((str = reader.readLine()) != null)) tokenizer = new StringTokenizer(str); else return null; }catch (IOException e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} public void close()throws Exception { reader.close(); } } }
0	public class A199{ static int n[][] = new int[][]{{-1,0},{1,0},{0,-1},{0,1}}; public static void main( String[] args)throws IOException { new A199().solve(); } public void solve()throws IOException { Scanner scan = new Scanner(System.in);  int N = scan.nextInt(); System.out.println(("0 0 " + N)); } }
0	public class Main implements Runnable{ PrintWriter out ; Scanner in ; public static void main( String[] args)throws IOException { new Thread(new Main()).start(); } public void solve()throws IOException { int n = in.nextInt(); if ( (n >= 0)) {out.println(n); } else { String s = String.valueOf(n);  int l = s.length();  String s1 = s.substring(0,(l - 2)); if ( (s.charAt((l - 1)) > s.charAt((l - 2)))) {s1 += s.charAt((l - 2)); } else {s1 += s.charAt((l - 1)); }out.println(Integer.parseInt(s1)); }} }
0	public class Solution{ public static void main( String[] args){ Scanner t = new Scanner(System.in);  long l = t.nextLong();  long r = t.nextLong(); if ( ((r - l) < 2)) System.out.println(-1); else if ( (((r - l) < 3) && ((l % 2) != 0))) {if ( ((l % 3) != 0)) System.out.println(-1); else if ( (((l + 3) % 2) == 0)) System.out.println(-1); else System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 3))); } else {while(((l % 2) != 0))l++; System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); }} }
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());} } }
1	public class Elektronnietablici{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer in ; static PrintWriter out = new PrintWriter(System.out); public static String nextToken()throws IOException { while(((in == null) || !in.hasMoreTokens())){in = new StringTokenizer(br.readLine()); }return in.nextToken();} public static int nextInt()throws IOException { return Integer.parseInt(nextToken());} public static void main( String[] args)throws IOException { int n = nextInt();  String S ; for ( int i = 0;(i < n);i++) {S = nextToken(); int f = 0; if ( (((S.charAt(0) == 'R') && (S.charAt(1) >= '1')) && (S.charAt(1) <= '9'))) {for ( int j = 2;(j < S.length());j++) {if ( ((S.charAt(j) >= 'A') && (S.charAt(j) <= 'Z'))) {f = 1; break;} }} if ( (f == 0)) { String T1 = "";  String ans = "R";  int j ; for ( j = 0;((S.charAt(j) >= 'A') && (S.charAt(j) <= 'Z'));j++) {T1 += S.charAt(j); }ans += (S.substring(j,S.length()) + "C"); int len = j; j--; int p = 1;  int z = 0; for ( ;(j >= 0);j--) {z += ((S.charAt(j) - 'A') * p); p *= 26; }p = 1; for ( int k = 0;(k < len);k++) {z += p; p *= 26; }ans += z; out.println(ans); } else { String T1 = "";  String ans = "";  int j ; for ( j = 1;(S.charAt(j) != 'C');j++) {ans += S.charAt(j); }T1 = S.substring((j + 1),S.length()); int z = Integer.parseInt(T1);  int p = 1;  int len = 0; while((p <= z)){z -= p; p *= 26; len++; }p /= 26; T1 = ""; for ( int k = (len - 1);(k >= 0);k--) { int l = (z / p); T1 += (char)((z / p) + 'A'); z -= (l * p); p /= 26; }ans = (T1 + ans); out.println(ans); }}out.close(); } }
3	public class PythonIndentation{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int N = Integer.parseInt(in.readLine());  int[][] dp = new int[N][N]; dp[0][0] = 1; for ( int i = 1;(i < N);++i) { char lastCmd = in.readLine().charAt(0);  int[] sum = new int[N]; sum[(N - 1)] = dp[(i - 1)][(N - 1)]; for ( int j = (N - 2);(j >= 0);--j) sum[j] = ((sum[(j + 1)] + dp[(i - 1)][j]) % 1000000007); for ( int j = 0;(j < N);++j) {if ( ((lastCmd == 'f') && (j > 0))) dp[i][j] = dp[(i - 1)][(j - 1)]; else if ( (lastCmd == 's')) dp[i][j] = sum[j]; }} int ans = 0; for ( int i = 0;(i < N);++i) ans = ((ans + dp[(N - 1)][i]) % 1000000007); System.out.println(ans); } }
1	public class B{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));  int t = sc.nextInt(); for ( int z = 0;(z < t);++z) { int n = sc.nextInt(); if ( ((n % 2) == 1)) {System.out.println("NO"); continue;} n /= 2; int sqrt = (int)Math.sqrt(n); if ( ((sqrt * sqrt) == n)) {System.out.println("YES"); continue;} if ( ((n % 2) == 1)) {System.out.println("NO"); continue;} n /= 2; sqrt = (int)Math.sqrt(n); if ( ((sqrt * sqrt) == n)) {System.out.println("YES"); continue;} 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);  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){ int n = in.nextInt();  int k = in.nextInt();  int arr[] = new int[n]; in.getArray(arr); int ansl = -1;  int ansr = n;  int occ[] = new int[100100];  boolean f[] = new boolean[n]; Arrays.fill(occ,0); Arrays.fill(f,true); int pk = 0; for ( int l = 0,r = 0;((r < n) && (l < n));) { int num = arr[r]; if ( f[r]) {f[r] = false; occ[num]++; if ( (occ[num] == 1)) {pk++; } } if ( (pk < k)) {r++; } else if ( (pk == k)) {if ( ((r - l) <= (ansr - ansl))) {ansl = (l + 1); ansr = (r + 1); } num = arr[l]; occ[num]--; if ( (occ[num] == 0)) {pk--; } l++; } else {num = arr[l]; occ[num]--; if ( (occ[num] == 0)) {pk--; } l++; }}if ( (ansl == -1)) {ansr = -1; } out.println(((ansl + " ") + ansr)); } } 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());} public void getArray( int[] arr){ for ( int i = 0;(i < arr.length);i++) {arr[i] = nextInt(); }} }
4	public class c{ static boolean used[][] ; static int n ; static int m ; static int a[][] ; public static void main( String[] args)throws Exception { Scanner in = new Scanner(new File("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt")); n = in.nextInt(); m = in.nextInt(); int k = in.nextInt();  int x[] = new int[k];  int y[] = new int[k]; for ( int i = 0;(i < k);i++) {x[i] = in.nextInt(); y[i] = in.nextInt(); } int max = 0;  int xx = 1;  int yy = 1; for ( int i = 1;(i <= n);i++) for ( int j = 1;(j <= m);j++) { int count = Integer.MAX_VALUE; for ( int l = 0;(l < k);l++) count = Math.min((Math.abs((i - x[l])) + Math.abs((j - y[l]))),count); if ( (max < count)) {max = count; xx = i; yy = j; } }out.println(((xx + " ") + yy)); 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);  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();  long MOD = 1000000007;  long[] current = new long[(n + 3)]; current[0] = 1; for ( int i = 0;(i < (n - 1));i++) { String s = in.next(); if ( s.equals("f")) {for ( int j = (i + 1);(j > 0);j--) {current[j] = current[(j - 1)]; current[j] %= MOD; }current[0] = 0; } else {for ( int j = (i + 1);(j >= 0);j--) {current[j] = (current[(j + 1)] + current[j]); current[j] %= MOD; }}} long result = 0; for ( int i = 0;(i <= n);i++) {result += current[i]; result %= MOD; }out.println(result); } } static class InputReader{ static private BufferedReader in ; static private StringTokenizer tok ; public InputReader( InputStream in){ this.in = new BufferedReader(new InputStreamReader(in)); } public int nextInt(){ return Integer.parseInt(next());} public String next(){ try{while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); } }catch (IOException ex){ System.err.println(("An IOException was caught :" + ex.getMessage())); } return tok.nextToken();} } }
0	public class Main{ public static long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} public static long lcm( long a, long b, long c){ long d = ((a / gcd(a,b)) * b); return ((c / gcd(c,d)) * d);} public static long max( long a, long b){ return ((a > b)?a:b);} public static void main( String[] args){ InputReader in = new InputReader();  PrintWriter out = new PrintWriter(System.out);  long n = in.nextLong(); if ( (n <= 2)) out.println(n); else out.println(max(lcm(n,(n - 1),(n - 2)),max(lcm(n,(n - 1),(n - 3)),lcm((n - 1),(n - 2),(n - 3))))); out.close(); } } class InputReader{ BufferedReader buf ; StringTokenizer tok ; InputReader(){ buf = new BufferedReader(new InputStreamReader(System.in)); } boolean hasNext(){ while(((tok == null) || !tok.hasMoreElements())){try{tok = new StringTokenizer(buf.readLine()); }catch (Exception e){ return false;} }return true;} String next(){ if ( hasNext()) return tok.nextToken(); return null;} long nextLong(){ return Long.parseLong(next());} }
6	public final class CF_599_D1_C{ static boolean verb = true; static void log( Object X){ if ( verb) System.err.println(X); } static void log( Object[] X){ if ( verb) {for ( Object U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X){ if ( verb) {for ( int U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X, int L){ if ( verb) {for ( int i = 0;(i < L);i++) System.err.print((X[i] + " ")); System.err.println(""); } } static void log( long[] X){ if ( verb) {for ( long U :X) System.err.print((U + " ")); System.err.println(""); } } static void output( Object o){ outputWln((("" + o) + "\n")); } static void outputWln( Object o){ try{out.write(("" + o)); }catch (Exception e){ } } static long mod = 1000000007; static BufferedWriter out ; static InputReader reader ; static void explore( ArrayList<Integer>[] components, ArrayList<Integer> bob, int[][] move, ArrayList<int[]>[] howto, int[][] list){ for ( int x :bob) {if ( (components[x].size() == 1)) { int tm[] = howto[x].get(0);  int L = howto[x].size(); howto[x].add(tm); for ( int i = 0;(i < L);i++) { int[] cur = howto[x].get(i);  int[] nx = howto[x].get((i + 1));  int a = cur[0];  int a2 = nx[0];  int b2 = nx[1]; move[a2][0] = list[a2][b2]; move[a2][1] = a; }} else {explore(components,components[x],move,howto,list); }}} static void process()throws Exception { out = new BufferedWriter(new OutputStreamWriter(System.out)); reader = new InputReader(System.in); int k = reader.readInt();  int[][] list = new int[k][];  long[] sum = new long[k];  int[] L = new int[k];  HashMap<Integer,int[]> target = new HashMap<Integer,int[]>();  long tot = 0; for ( int i = 0;(i < k);i++) {L[i] = reader.readInt(); list[i] = new int[L[i]]; for ( int j = 0;(j < L[i]);j++) {list[i][j] = reader.readInt(); sum[i] += list[i][j]; target.put(list[i][j],new int[]{i,j}); }tot += sum[i]; } int MX = (1 << k);  int AX = 1000000001;  ArrayList<int[]>[] howto = new ArrayList[MX]; log("ok with the data"); if ( ((tot % k) != 0)) {output("No"); } else {tot /= k; for ( int i = 0;(i < k);i++) {if ( (sum[i] == tot)) { int mask = (1 << i);  ArrayList<int[]> cand = new ArrayList<int[]>(); cand.add(new int[]{i,0}); howto[mask] = cand; } else for ( int j = 0;(j < L[i]);j++) { int u = i;  int v = j;  boolean ok = true;  int src_u = u;  int src_v = v;  int mask = 0;  boolean goon = true;  ArrayList<int[]> cand = new ArrayList<int[]>(); while(goon){cand.add(new int[]{u,v}); ok = false; goon = false; long need = (tot - ((long)sum[u] - (long)list[u][v])); if ( (Math.abs(need) <= AX)) { int nd = (int)need;  int[] tm = target.get(nd); if ( (tm != null)) { int nxu = tm[0];  int nxv = tm[1]; if ( ((mask & (1 << nxu)) == 0)) {mask |= (1 << nxu); if ( (nxu == src_u)) {if ( (nxv == src_v)) ok = true; } else {u = nxu; v = nxv; ok = true; goon = true; }} } } }if ( ok) {if ( (howto[mask] == null)) {howto[mask] = cand; } } }}log("step 1 done"); ArrayList<Integer> msk = new ArrayList<Integer>();  ArrayList[] components = new ArrayList[MX]; for ( int m = 0;(m < MX);m++) {if ( (howto[m] != null)) {components[m] = new ArrayList<Integer>(); components[m].add(m); } } int[] visited = new int[MX]; for ( int a = 0;(a < MX);a++) {if ( (howto[a] != null)) { ArrayList<Integer> add = new ArrayList<Integer>(); for ( int b :msk) {if ( ((b & a) == 0)) { int c = (b | a); log((("creating c:" + c) + " ")); if ( (components[c] == null)) {components[c] = new ArrayList<Integer>(); components[c].add(a); components[c].add(b); add.add(c); } } }msk.add(a); for ( int c :add) {msk.add(c); }} }if ( (components[(MX - 1)] != null)) {output("Yes"); int[][] move = new int[k][2]; explore(components,components[(MX - 1)],move,howto,list); for ( int i = 0;(i < k);i++) {output(((move[i][0] + " ") + (move[i][1] + 1))); }} else {output("No"); }}try{out.close(); }catch (Exception e){ } } public static void main( String[] args)throws Exception { process(); } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
3	public class Codeforces913F{ public static void main( String[] args)throws IOException { Scanner input = new Scanner(System.in);  int n = input.nextInt();  int a = input.nextInt();  int b = input.nextInt(); input.close(); final int mod = 998244353;  int frac = multiply(a,inverse(b,mod),mod);  int reverse = (((mod + 1) - frac) % mod);  int[] fracpower = new int[(n + 1)];  int[] reversepower = new int[(n + 1)]; fracpower[0] = 1; reversepower[0] = 1; for ( int i = 1;(i <= n);i++) {fracpower[i] = multiply(fracpower[(i - 1)],frac,mod); reversepower[i] = multiply(reversepower[(i - 1)],reverse,mod); } int[][] dp1 = new int[(n + 1)][(n + 1)]; dp1[2][1] = 1; for ( int i = 3;(i <= n);i++) {for ( int j = 1;(j < i);j++) {if ( (j == 1)) {dp1[i][j] = fracpower[(i - 1)]; } else {dp1[i][j] = multiply(dp1[(i - 1)][(j - 1)],fracpower[(i - j)],mod); }if ( (j == (i - 1))) {dp1[i][j] += reversepower[(i - 1)]; dp1[i][j] %= mod; } else {dp1[i][j] += multiply(dp1[(i - 1)][j],reversepower[j],mod); dp1[i][j] %= mod; }}} int[][] dp2 = new int[(n + 1)][(n + 1)]; dp2[1][1] = 1; dp2[2][1] = 1; dp2[2][2] = 0; for ( int i = 3;(i <= n);i++) { int val = 0; for ( int j = 1;(j < i);j++) {dp2[i][j] = multiply(dp2[j][j],dp1[i][j],mod); val += dp2[i][j]; val %= mod; }dp2[i][i] = (((mod + 1) - val) % mod); } int[] EV = new int[(n + 1)]; EV[1] = 0; EV[2] = 1; for ( int i = 3;(i <= n);i++) { int val = 0; for ( int j = 1;(j < i);j++) { int r = ((((j * (i - j)) + ((j * (j - 1)) / 2)) + EV[(i - j)]) + EV[j]); r %= mod; val += multiply(dp2[i][j],r,mod); val %= mod; }val += multiply(((i * (i - 1)) / 2),dp2[i][i],mod); val %= mod; int s = (((mod + 1) - dp2[i][i]) % mod); EV[i] = multiply(val,inverse(s,mod),mod); }System.out.println(EV[n]); } public static int multiply( int a, int b, int mod){ long x = ((long)a * (long)b); return (int)(x % mod);} public static int inverse( int a, int n){ int m = n;  int r1 = 1;  int r2 = 0;  int r3 = 0;  int r4 = 1; while(((a > 0) && (n > 0))){if ( (n >= a)) {r3 -= (r1 * (n / a)); r4 -= (r2 * (n / a)); n = (n % a); } else { int tmp = a; a = n; n = tmp; tmp = r1; r1 = r3; r3 = tmp; tmp = r2; r2 = r4; r4 = tmp; }}if ( (a == 0)) {if ( (r3 >= 0)) return (r3 % m); else return (m + (r3 % m));} else {if ( (r1 >= 0)) return (r1 % m); else return (m + (r1 % m));}} }
1	public class Main{ static final long MOD = 998244353L; static final int INF = 1000000005; static final int NINF = -1000000005; static FastScanner sc ; static PrintWriter pw ; static final int[][] dirs = {{-1,0},{1,0},{0,-1},{0,1}}; public static void main( String[] args){ sc = new FastScanner(); pw = new PrintWriter(System.out); int Q = sc.ni(); for ( int q = 0;(q < Q);q++) { int N = sc.ni();  String ans = "NO"; if ( (((N % 2) == 0) && isSquare((N / 2)))) ans = "YES"; if ( (((N % 4) == 0) && isSquare((N / 4)))) ans = "YES"; pw.println(ans); }pw.close(); } public static boolean isSquare( int x){ int s = (int)Math.round(Math.sqrt(x)); return ((s * s) == x);} public static void sort( int[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( long[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( int[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<int[]>(){}); } public static void sort( long[][] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long[] temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr,new Comparator<long[]>(){}); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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());} long nl(){ return Long.parseLong(next());} } }
6	public class LookingForOrder{ public Scanner in = new Scanner(System.in); public PrintStream out = System.out; public int[] go ; public int[][] cost ; public int[] sol ; public Pair[] how ; public int n ,lim ; public Pair bag ; public Pair[] obj ; public void main(){ bag = new Pair(in.nextInt(),in.nextInt()); n = in.nextInt(); obj = new Pair[n]; for ( int i = 0;(i < n);++i) obj[i] = new Pair(in.nextInt(),in.nextInt()); go = new int[n]; cost = new int[n][n]; for ( int i = 0;(i < n);++i) {go[i] = squDist(bag,obj[i]); for ( int j = 0;(j < n);++j) cost[i][j] = squDist(obj[i],obj[j]); }lim = (1 << n); sol = new int[lim]; Arrays.fill(sol,-1); how = new Pair[lim]; out.println(solve((lim - 1))); Pair T ;  int set = (lim - 1); out.print("0"); while((set > 0)){solve(set); T = how[set]; out.print((" " + (T.x + 1))); set = off(T.x,set); if ( (T.y >= 0)) {out.print((" " + (T.y + 1))); set = off(T.y,set); } out.print(" 0"); }out.println(); } public int oo = 987654321; public boolean in( int x, int set){ return (((1 << x) & set) != 0);} public int off( int x, int set){ return (set ^ (set & (1 << x)));} public int solve( int set){ if ( (sol[set] >= 0)) return sol[set]; int ret ; if ( (set == 0)) ret = 0; else {ret = oo; int x ,y ,sub ,c ; for ( x = 0;(x < n);++x) if ( in(x,set)) break; sub = off(x,set); c = ((go[x] + go[x]) + solve(sub)); if ( (c < ret)) {how[set] = new Pair(x,-1); ret = c; } for ( y = (x + 1);(y < n);++y) if ( in(y,set)) {c = (((go[x] + cost[x][y]) + go[y]) + solve(off(y,sub))); if ( (c < ret)) {ret = c; how[set] = new Pair(x,y); } } }return sol[set] = ret;} public int squDist( int ax, int ay, int bx, int by){ int dx ,dy ; dx = (ax - bx); dy = (ay - by); return ((dx * dx) + (dy * dy));} public int squDist( Pair p, Pair q){ return squDist(p.x,p.y,q.x,q.y);} private class Pair implements Comparable<Pair>{ public int x ,y ; public Pair( int xx, int yy){ x = xx; y = yy; } } public static void main( String[] args){ new LookingForOrder().main(); } }
3	public class C{ static int[][] memo ; static int n ; static char[] c ; static int mod = ((int)1e9 + 7); static int dp( int ind, int loops){ if ( (ind == n)) return ((loops == 0)?1:0); if ( (memo[ind][loops] != -1)) return memo[ind][loops]; long ans = 0; if ( (c[ind] == 's')) {ans = ((ans + dp((ind + 1),loops)) % mod); if ( (loops > 0)) ans = ((ans + dp(ind,(loops - 1))) % mod); } else {ans = ((ans + dp((ind + 1),(loops + 1))) % mod); }return memo[ind][loops] = (int)ans;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out); n = sc.nextInt(); memo = new int[(n + 1)][(n + 1)]; for ( int[] i :memo) Arrays.fill(i,-1); c = new char[n]; for ( int i = 0;(i < c.length);i++) {c[i] = sc.next().charAt(0); }out.println(dp(0,0)); out.flush(); out.close(); } static class Scanner{ BufferedReader bf ; StringTokenizer st ; public Scanner( InputStream i){ bf = new BufferedReader(new InputStreamReader(i)); } public String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(bf.readLine()); return st.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} } }
1	public class Main{ static class MyReader{ private BufferedReader reader = null; private StringTokenizer tokenizer = null; MyReader( Reader r)throws IOException{ reader = new BufferedReader(r); } 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();} } public static void main( String[] args)throws IOException { PrintWriter writer = new PrintWriter(new OutputStreamWriter(System.out));  MyReader reader = new MyReader(new InputStreamReader(System.in));  int n = reader.nextInt();  int k = reader.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);++i) a[i] = reader.nextInt(); int j = 0;  HashMap<Integer,Integer> map = new HashMap<>(); for ( int i = 0;(i < n);++i) {if ( map.containsKey(a[i])) map.put(a[i],(map.get(a[i]) + 1)); else {map.put(a[i],1); if ( (map.size() == k)) {j = (i + 1); break;} }}if ( (map.size() < k)) {System.out.println("-1 -1"); return ;} for ( int i = 0;(i < n);++i) {if ( (map.get(a[i]) == 1)) {System.out.println((((i + 1) + " ") + j)); return ;} map.put(a[i],(map.get(a[i]) - 1)); }} }
5	public class Main{ public static void main( String[] args){ new Main().solve(); } void solve(){ Scanner cin = new Scanner(System.in); while(cin.hasNextInt()){ int n = cin.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);++i) {arr[i] = cin.nextInt(); }Arrays.sort(arr); int ret[] = new int[n]; ret[0] = 1; for ( int i = 0;(i < (n - 1));++i) {ret[(i + 1)] = arr[i]; }if ( (arr[(n - 1)] == 1)) {ret[(n - 1)] = 2; } String glue = ""; for ( int i = 0;(i < n);++i) {System.out.print((glue + ret[i])); glue = " "; }System.out.println(); }} }
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);  OnTheBench solver = new OnTheBench(); solver.solve(1,in,out); out.close(); } static class OnTheBench{ long MOD = ((long)1e9 + 7); long[][] C = new long[333][333]; public void solve( int testNumber, InputReader in, PrintWriter out){ int N = in.nextInt();  DisjointSet dsu = new DisjointSet(N);  long[] arr = new long[N]; setC(); for ( int i = 0;(i < N);i++) {arr[i] = in.nextInt(); }for ( int i = 0;(i < N);i++) {for ( int j = (i + 1);(j < N);j++) { long sqrt = (long)Math.sqrt((arr[i] * arr[j]));  long sqrt2 = (long)Math.ceil(Math.sqrt((arr[i] * arr[j]))); if ( (((sqrt * sqrt) == (arr[i] * arr[j])) || ((sqrt2 * sqrt2) == (arr[i] * arr[j])))) {dsu.merge(i,j); } }} ArrayList<Integer> sz = new ArrayList<>(); sz.add(0); HashMap<Integer,Integer> seen = new HashMap<>();  long mult = 1; for ( int i = 0;(i < N);i++) {if ( !seen.containsKey(dsu.find(i))) {seen.put(dsu.find(i),sz.size()); sz.add(0); } sz.set(seen.get(dsu.find(i)),(sz.get(seen.get(dsu.find(i))) + 1)); }for ( int i :sz) {mult *= fact(i); mult %= MOD; } long[][] dp = new long[sz.size()][333];  int sum = 0; dp[0][0] = 1; for ( int n = 1;(n < dp.length);n++) {for ( int ij = 1;(ij <= sz.get(n));ij++) {for ( int y = 0;(y <= sum);y++) {for ( int j = 0;(j <= Math.min(y,ij));j++) { int i = (ij - j); dp[n][(((y - j) + sz.get(n)) - ij)] += ((((((dp[(n - 1)][y] * C[((sum + 1) - y)][i]) % MOD) * C[y][j]) % MOD) * C[(sz.get(n) - 1)][(ij - 1)]) % MOD); dp[n][(((y - j) + sz.get(n)) - ij)] %= MOD; }}}sum += sz.get(n); }out.println(((dp[(sz.size() - 1)][0] * mult) % MOD)); } void setC(){ for ( int i = 0;(i <= 332);i++) {C[i][0] = 1; for ( int j = 1;(j <= i);j++) {C[i][j] = (C[(i - 1)][j] + C[(i - 1)][(j - 1)]); C[i][j] %= MOD; }}} long fact( int i){ long res = 1; while((i > 0)){res *= i; res %= MOD; i--; }return res;} } 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());} } static class DisjointSet{ int[] rank ; int[] par ; public DisjointSet( int N){ rank = new int[N]; par = new int[N]; for ( int i = 0;(i < N);i++) {rank[i] = 1; par[i] = i; }} public int find( int x){ if ( (x == par[x])) {return x;} return par[x] = find(par[x]);} public void merge( int x, int y){ int parX = find(x);  int parY = find(y); if ( (parX != parY)) {if ( (rank[parX] > rank[parY])) {par[parY] = parX; rank[parX] += rank[parY]; } else {par[parX] = parY; rank[parY] += rank[parX]; }} } } }
3	public class Main{ public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } void solve(){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ScanReader in = new ScanReader(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, ScanReader in, PrintWriter out){ int n = in.scanInt();  int[] hash = new int[101];  boolean[] hash1 = new boolean[101]; for ( int i = 0;(i < n);i++) hash[in.scanInt()]++; int ans = 0; for ( int i = 1;(i <= 100);i++) {if ( hash1[i]) continue; if ( (hash[i] == 0)) continue; for ( int j = i;(j <= 100);j += i) hash1[j] = true; ans++; }out.println(ans); } } 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
1	public class Equator{ public static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static StringTokenizer st ; public static void main( String[] args)throws IOException { int n = nextInt();  int[] a = intArray(n);  long s = 0; for ( int x :a) s += x; long m = 0; for ( int i = 0;(i < n);i++) {m += a[i]; if ( ((m * 2) >= s)) {System.out.println((i + 1)); return ;} }} public static String nextString()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(in.readLine()); return st.nextToken();} public static int nextInt()throws IOException { return Integer.parseInt(nextString());} public static long nextLong()throws IOException { return Long.parseLong(nextString());} public static int[] intArray( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} public static int[][] intArray( int n, int m)throws IOException { int[][] a = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) a[i][j] = nextInt(); return a;} }
2	public class P287B{ Scanner sc = new Scanner(System.in); 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 ub = ((((k * (k + 1)) / 2) - (((k - m) * ((k - m) + 1)) / 2)) - (m - 1)); if ( (ub >= n)) {right = m; } else {left = m; }}println(("" + ((right > k)?-1:right))); } void println( String s){ System.out.println(s); } public static void main( String[] args){ Locale.setDefault(Locale.US); new P287B().run(); } }
6	public class Main{ static private boolean check( int n, int m, int k){ for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {for ( int l = 0;(l < (1 << n));l++) {dp[i][j][l] = -1; }}}for ( int i = 0;(i < n);i++) {if ( dfs(i,i,n,m,k,0)) {return true;} }return false;} static private boolean dfs( int first, int current, int n, int m, int k, int bitmap){ bitmap |= (1 << current); if ( (bitmap == ((1 << n) - 1))) {if ( (n == 1)) {if ( (m > 1)) {if ( (rowMinDist[current] >= k)) {return true;} else {return false;}} else {return true;}} else {if ( (m > 1)) {if ( (minDistBetweenHeadAndTail[first][current] >= k)) {return true;} else {return false;}} else {return true;}}} else {if ( (dp[first][current][bitmap] >= 0)) {if ( (dp[first][current][bitmap] > 0)) {return true;} else {return false;}} short ans = 0; for ( int i = 0;(i < n);i++) {if ( (((bitmap & (1 << i)) == 0) && (minDistBetweenRow[current][i] >= k))) {if ( dfs(first,i,n,m,k,bitmap)) {ans = 1; break;} } }dp[first][current][bitmap] = ans; if ( (ans > 0)) {return true;} else {return false;}}} static private short[][][] dp = new short[20][20][(1 << 17)]; static private int[][] input = new int[20][10010]; static private int[][] minDistBetweenRow = new int[20][20]; static private int[][] minDistBetweenHeadAndTail = new int[20][20]; static private int[] rowMinDist = new int[20]; public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int i ,j ,k ,n ,m ; n = scan.nextInt(); m = scan.nextInt(); for ( i = 0;(i < n);i++) {for ( j = 0;(j < m);j++) {input[i][j] = scan.nextInt(); }}for ( i = 0;(i < n);i++) {for ( j = (i + 1);(j < n);j++) { int minDist = -1; for ( k = 0;(k < m);k++) { int dist = Math.abs((input[i][k] - input[j][k])); if ( ((dist < minDist) || (minDist < 0))) {minDist = dist; } }minDistBetweenRow[i][j] = minDistBetweenRow[j][i] = minDist; }}for ( i = 0;(i < n);i++) {for ( j = 0;(j < n);j++) {if ( (i != j)) { int minDist = -1; for ( k = 0;(k < (m - 1));k++) { int dist = Math.abs((input[j][k] - input[i][(k + 1)])); if ( ((dist < minDist) || (minDist < 0))) {minDist = dist; } }minDistBetweenHeadAndTail[i][j] = minDist; } }}for ( i = 0;(i < n);i++) { int minDist = -1; for ( j = 0;(j < (m - 1));j++) { int dist = Math.abs((input[i][j] - input[i][(j + 1)])); if ( ((dist < minDist) || (minDist < 0))) {minDist = dist; } }rowMinDist[i] = minDist; } int low = 0,high = 1000000010; while((low < high)){ int mid = ((low + high) / 2); if ( check(n,m,mid)) {low = (mid + 1); } else {high = mid; }}System.out.println((high - 1)); } }
1	public class Main{ static private boolean _READ_FROM_FILE = (System.getProperty("ONLINE_JUDGE") == null); static private Scanner in ; static private void core(){ int n = in.nextInt();  ArrayList<Character> all = new ArrayList<Character>(); for ( char ch :in.next().toCharArray()) {all.add(ch); } int res = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int now = calc(all); res = Math.min(res,now); all.add(all.get(0)); all.remove(0); }System.out.println(res); } static private int calc( ArrayList<Character> all){ int nh = 0; for ( char ch :all) {if ( (ch == 'H')) ++nh; } int r1 = 0; for ( int i = 0;(i < nh);i++) {if ( (all.get(i) != 'H')) ++r1; } int nt = (all.size() - nh);  int r2 = 0; for ( int i = 0;(i < nt);i++) {if ( (all.get(i) != 'T')) ++r2; }return Math.min(r1,r2);} public static void main( String[] args)throws FileNotFoundException { if ( _READ_FROM_FILE) System.setIn(new FileInputStream("in.in")); in = new Scanner(System.in); core(); } }
5	public class CodeForce{ private void solve()throws IOException { final int N = nextInt();  int[] A = new int[N]; for ( int i = 0;(i < N);i++) A[i] = nextInt(); 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.print((A[i] + " ")); } public static void main( String[] args){ new CodeForce().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; public void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(new FileOutputStream(new File("output.txt"))); 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 Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  TaskC.InputReader in = new TaskC.InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskC solver = new TaskC(); solver.Solve(in,out); out.close(); } static class TaskC{ void Solve( InputReader in, PrintWriter out){ int n = in.NextInt();  double r = in.NextInt();  double[] x = new double[n]; for ( int i = 0;(i < n);i++) x[i] = in.NextInt(); double[] y = new double[n]; for ( int i = 0;(i < n);i++) { double maxY = r; for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) <= (2 * r))) { double currentY = (Math.sqrt((((2 * r) * (2 * r)) - ((x[i] - x[j]) * (x[i] - x[j])))) + y[j]); maxY = Math.max(maxY,currentY); } }y[i] = maxY; }out.print(y[0]); for ( int i = 1;(i < n);i++) {out.print((" " + y[i])); }out.println(); } static int GetMax( int[] ar){ int max = Integer.MIN_VALUE; for ( int a :ar) {max = Math.max(max,a); }return max;} static int[] GetCount( int[] ar){ return GetCount(ar,GetMax(ar));} static int[] GetCount( int[] ar, int maxValue){ int[] dp = new int[(maxValue + 1)]; for ( int a :ar) {dp[a]++; }return dp;} } }
3	public class Main{ public static void main( String[] args){ File file = new File("in.txt");  File fileOut = new File("out.txt");  InputStream inputStream = null;  OutputStream outputStream = null; inputStream = System.in; outputStream = System.out; InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(1,in,out); out.close(); } } class Task{ private final int mod = 1000000007; public void solve( int testNumber, InputReader in, PrintWriter out){ Integer n = in.nextInt();  List<Character> comm = new ArrayList<>(n); for ( int i = 0;(i < n);i++) {comm.add(in.next().charAt(0)); } long[][] dp = new long[n][n]; dp[0][0] = 1; for ( int i = 1;(i < n);i++) { Character lastComm = comm.get((i - 1)); if ( lastComm.equals('f')) {dp[i][0] = 0; for ( int j = 1;(j < n);j++) {dp[i][j] = dp[(i - 1)][(j - 1)]; }} else { Long suffixSum = dp[(i - 1)][(n - 1)]; for ( int j = (n - 1);(j >= 0);j--) {dp[i][j] = suffixSum; if ( (j > 0)) {suffixSum += (dp[(i - 1)][(j - 1)] % mod); } }}} Long finalSum = 0L; for ( int i = 0;(i < n);i++) {finalSum += (dp[(n - 1)][i] % mod); }out.println((finalSum % mod)); } } 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());} }
2	public final class CF_524_D2_D{ static boolean verb = true; static void log( Object X){ if ( verb) System.err.println(X); } static void log( Object[] X){ if ( verb) {for ( Object U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X){ if ( verb) {for ( int U :X) System.err.print((U + " ")); System.err.println(""); } } static void log( int[] X, int L){ if ( verb) {for ( int i = 0;(i < L);i++) System.err.print((X[i] + " ")); System.err.println(""); } } static void log( long[] X){ if ( verb) {for ( long U :X) System.err.print((U + " ")); System.err.println(""); } } static void output( Object o){ outputWln((("" + o) + "\n")); } static void outputWln( Object o){ try{out.write(("" + o)); }catch (Exception e){ } } static BufferedWriter out ; static InputReader reader ; static long mod = 1000000007; static void process()throws Exception { out = new BufferedWriter(new OutputStreamWriter(System.out)); reader = new InputReader(System.in); long mymax = (1L << 62); log(mymax); long cut = 0;  int it = 0;  long squares = 1;  int GX = 32;  long[] maxgen = new long[GX]; while((cut < 2000000000000000000L)){maxgen[it] = cut; it++; cut = (1 + (4 * cut)); squares *= 4; } int T = reader.readInt(); for ( int t = 0;(t < T);t++) { int n = reader.readInt();  long k = reader.readLong(); if ( (n >= GX)) {output(("YES " + (n - 1))); } else { long pieces = 3;  long minc = 1;  int size = (n - 1);  long maxc = (1 + maxgen[size]); while(((size > 0) && (maxc < k))){minc += pieces; maxc += (pieces + (maxgen[(size - 1)] * ((2 * pieces) - 1))); size--; pieces = ((2 * pieces) + 1); }if ( ((minc <= k) && (maxc >= k))) {output(("YES " + size)); } else {output("NO"); }}}try{out.close(); }catch (Exception EX){ } } public static void main( String[] args)throws Exception { process(); } static final class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } private int read()throws IOException { if ( (curChar >= numChars)) {curChar = 0; numChars = stream.read(buf); if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public final int readInt()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } int res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} public final long readLong()throws IOException { int c = read();  boolean neg = false; while(isSpaceChar(c)){c = read(); } char d = (char)c; if ( (d == '-')) {neg = true; c = read(); } long res = 0; do {res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));if ( neg) return -res; return res;} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
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{ static private final int MOD = ((int)1e9 + 7); static private 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); } } }
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 { InputReader in = new InputReader(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));} static class InputReader{ public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next()throws Exception { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(reader.readLine()); return tokenizer.nextToken();} public int nextInt()throws Exception { return Integer.parseInt(next());} } }
0	public class Main{ static void solve()throws IOException { int n = nextInt(); if ( (n >= 0)) {System.out.println(n); } else { String string = String.valueOf(n);  int v1 = Integer.valueOf(string.substring(0,(string.length() - 1)));  int v2 = Integer.valueOf((string.substring(0,(string.length() - 2)) + string.charAt((string.length() - 1)))); if ( (v1 >= v2)) {System.out.println(v1); } else {System.out.println(v2); }}} public static void main( String[] args)throws Exception { reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(System.out); setTime(); solve(); 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());} }
1	public class B{ 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]);  int k = i(arr[1]);  int[] A = new int[n]; arr = in.readLine().split(" "); for ( int i = 0;(i < n);i++) A[i] = i(arr[i]); int st = 0;  int cnt = 0;  int[] cnts = new int[(((100 * 100) * 10) + 1)]; for ( int i = 0;(i < n);i++) {cnts[A[i]]++; if ( (cnts[A[i]] == 1)) cnt++; else while((cnts[A[st]] > 1)){cnts[A[st]]--; st++; }if ( (cnt == k)) {System.out.println((((st + 1) + " ") + (i + 1))); return ;} }System.out.println(((-1 + " ") + -1)); } }
4	public class practice{ 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 scn = new Reader("input.txt");  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = scn.nextInt(),m = scn.nextInt(),k = scn.nextInt();  int[][] inf = new int[k][2]; for ( int i = 0;(i < k);i++) {inf[i][0] = scn.nextInt(); inf[i][1] = scn.nextInt(); } int ans = 0,x = 1,y = 1; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) { int temp = Integer.MAX_VALUE; for ( int l = 0;(l < k);l++) {temp = Math.min(temp,(Math.abs((i - inf[l][0])) + Math.abs((j - inf[l][1])))); }if ( (temp > ans)) {ans = temp; x = i; y = j; } }}out.print(((x + " ") + y)); out.close(); } }
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);  G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion(); solver.solve(1,in,out); out.close(); } static class G1PlaylistForPolycarpEasyVersion{ public void solve( int testNumber, InputReader sc, PrintWriter out){ int n = sc.nextInt();  int T = sc.nextInt();  int mod = ((int)1e9 + 7);  int dp[][][] = new int[(1 << n)][226][3];  int t[] = new int[n];  int g[] = new int[n]; for ( int i = 0;(i < n);++i) {t[i] = sc.nextInt(); g[i] = (sc.nextInt() - 1); dp[(1 << i)][t[i]][g[i]] = 1; }for ( int i = 0;(i < (1 << n));++i) {for ( int j = 0;(j < n);++j) {if ( (((i >> j) & 1) == 1)) { int newMask = (i ^ (1 << j)); for ( int k = t[j];(k <= T);++k) {for ( int l = 0;(l < 3);++l) {if ( (l == g[j])) continue; dp[i][k][g[j]] = ((dp[i][k][g[j]] + dp[newMask][(k - t[j])][l]) % mod); }}} }} long ans = 0; for ( int i = 0;(i < (1 << n));++i) {for ( int j = 0;(j < 3);++j) {ans += dp[i][T][j]; }}ans %= mod; out.print(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 (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
0	public class Main{ private StreamTokenizer in ; private PrintWriter out ; public static void main( String[] args)throws IOException { new Main().run(); } private void run()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); out.print(25); out.flush(); } }
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); } static private 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;} }
3	public class A{ 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 { ntok(); int n = ipar();  ArrayList<Integer> list = new ArrayList<>(); ntok(); for ( int i = 0;(i < n);i++) {list.add(ipar()); }Collections.sort(list); HashSet<Integer> set = new HashSet<>(); for ( int x :list) { boolean add = true; for ( int y :set) {if ( ((x % y) == 0)) {add = false; break;} }if ( add) {set.add(x); } }out.println(set.size()); out.flush(); in.close(); } public void ntok()throws IOException { tok = new StringTokenizer(in.readLine()); } public int ipar(){ return Integer.parseInt(tok.nextToken());} public long lpar(){ return Long.parseLong(tok.nextToken());} public static void main( String[] args)throws IOException { new A().go(); } }
1	public class Solution1515B{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  Solver1515B solver = new Solver1515B();  int n = in.nextInt(); for ( int i = 0;(i < n);i++) {solver.solve(i,in,out); }out.close(); } static class Solver1515B{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  boolean f = false; if ( ((n % 2) == 0)) { int s = (int)Math.sqrt((n / 2)); if ( ((s * s) == (n / 2))) {f = true; } } if ( ((n % 4) == 0)) { int s = (int)Math.sqrt((n / 4)); if ( ((s * s) == (n / 4))) {f = true; } } if ( f) {out.println("YES"); } else {out.println("NO"); }} } 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 ToyArmy{ public static void main( String[] args){ int n = new Scanner(System.in).nextInt(); System.out.println((n + (n / 2))); } }
5	public class A{ static MyScanner sc ; static PrintWriter pw ; public static void main( String[] args)throws Throwable { sc = new MyScanner(); pw = new PrintWriter(System.out); n = sc.nextInt(); T = sc.nextLong(); p = new int[n]; l = new int[n]; x = new int[n]; t = new int[n]; adj = new ArrayList[n]; for ( int i = 0;(i < n);i++) x[i] = sc.nextInt(); for ( int i = 0;(i < n);i++) t[i] = sc.nextInt(); adj[0] = new ArrayList<>(); for ( int i = 1;(i < n);i++) {adj[i] = new ArrayList<>(); p[i] = (sc.nextInt() - 1); l[i] = sc.nextInt(); adj[p[i]].add(i); }ftCnt = new long[N]; ftSum = new long[N]; ans = new long[n]; dfs(0); pw.println(ans[0]); pw.flush(); pw.close(); } static int n ; static long T ; static int[] p ,l ,x ,t ; static ArrayList<Integer>[] adj ; static long[] ans ; static void dfs( int u){ update(t[u],x[u],((1L * x[u]) * t[u])); ans[u] = getMaxCnt(); long[] vals = {-1,-1,-1}; for ( int v :adj[u]) {T -= (2 * l[v]); dfs(v); vals[0] = ans[v]; Arrays.sort(vals); T += (2 * l[v]); }if ( (u != 0)) {if ( (vals[1] != -1)) ans[u] = Math.max(ans[u],vals[1]); } else {if ( (vals[2] != -1)) ans[u] = Math.max(ans[u],vals[2]); }update(t[u],-x[u],((-1L * x[u]) * t[u])); } static int N = ((int)1e6 + 2); static long[] ftCnt ,ftSum ; static void update( int idx, long cnt, long val){ while((idx < N)){ftCnt[idx] += cnt; ftSum[idx] += val; idx += (idx & -idx); }} static long getSum( int idx){ long ret = 0; while((idx > 0)){ret += ftSum[idx]; idx -= (idx & -idx); }return ret;} static long getCnt( int idx){ long ret = 0; while((idx > 0)){ret += ftCnt[idx]; idx -= (idx & -idx); }return ret;} static long getMaxCnt(){ int start = 1,end = (N - 1),ans = (N - 1); while((start <= end)){ int mid = ((start + end) / 2); if ( (getSum(mid) >= T)) {ans = mid; end = (mid - 1); } else start = (mid + 1); } long remT = (T - ((ans > 1)?getSum((ans - 1)):0));  long cnt = ((ans > 1)?getCnt((ans - 1)):0);  long cntOfVal = (getCnt(ans) - cnt); cnt += Math.min(cntOfVal,(remT / ans)); return cnt;} 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());} } }
2	public class ProblemA{ static private 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(); } }
4	public class Main{ static int[][] to = {{1,0},{0,1},{-1,0},{0,-1}}; public static void main( String[] args)throws FileNotFoundException { InputReader in = new InputReader(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int[][][] cost = new int[n][m][4]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int u = in.nextInt(); cost[i][j][1] = u; cost[i][(j + 1)][3] = u; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) { int u = in.nextInt(); cost[i][j][0] = u; cost[(i + 1)][j][2] = u; }}if ( ((k % 2) == 0)) {k = (k / 2); int[][][] dp = new int[(k + 1)][n][m]; for ( int i = 0;(i <= k);i++) {for ( int x = 0;(x < n);x++) {for ( int y = 0;(y < m);y++) {if ( (i == 0)) {dp[i][x][y] = 0; } else { int min = 1000000000; for ( int way = 0;(way < to.length);way++) { int nextx = (x + to[way][0]);  int nexty = (y + to[way][1]); if ( ((((nextx >= 0) && (nextx < n)) && (nexty >= 0)) && (nexty < m))) {min = Math.min(min,(dp[(i - 1)][nextx][nexty] + cost[x][y][way])); } }dp[i][x][y] = min; }}}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (j == (m - 1))) {out.printf("%d\n",(dp[k][i][j] * 2)); } else {out.printf("%d ",(dp[k][i][j] * 2)); }}}} else {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (j == (m - 1))) {out.printf("-1\n"); } else {out.printf("-1 "); }}}}out.close(); } static 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 in){ br = new BufferedReader(new InputStreamReader(in)); } 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());} } }
2	public class Main{ FastScanner in ; PrintWriter out ; static final String FILE = ""; public static final int TEST = 0; class Interact{ Rect a ,b ; public Interact( int x11, int y11, int x12, int y12, int x21, int y21, int x22, int y22){ a = new Rect(x11,y11,x12,y12); b = new Rect(x21,y21,x22,y22); } int query( int x1, int y1, int x2, int y2){ int ans = 0; if ( ((((x1 <= a.x1) && (x2 >= a.x2)) && (y1 <= a.y1)) && (y2 >= a.y2))) ans++; if ( ((((x1 <= b.x1) && (x2 >= b.x2)) && (y1 <= b.y1)) && (y2 >= b.y2))) ans++; return ans;} } Interact interact ; class Rect{ int x1 ,y1 ,x2 ,y2 ; public Rect(){ } public Rect( int x1, int y1, int x2, int y2){ this.x1 = x1; this.y1 = y1; this.x2 = x2; this.y2 = y2; } } int calls ; int query( int x1, int y1, int x2, int y2, Rect rect){ calls++; if ( (calls >= 190)) throw (new RuntimeException()); if ( (TEST == 0)) {out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); out.flush(); int ans = in.nextInt(); if ( ((((x1 <= rect.x1) && (x2 >= rect.x2)) && (y1 <= rect.y1)) && (y2 >= rect.y2))) ans--; return ans;} else { int ans = interact.query(x1,y1,x2,y2); if ( ((((x1 <= rect.x1) && (x2 >= rect.x2)) && (y1 <= rect.y1)) && (y2 >= rect.y2))) ans--; return ans;}} static int binarySearchFirstTrue( IntPredicate predicate, int fromInclusive, int toInclusive){ int a = fromInclusive,b = toInclusive; while((a != b)){ int la = a,lb = b;  int mid = ((a + b) / 2); if ( predicate.test(mid)) b = mid; else a = mid; if ( ((la == a) && (lb == b))) {if ( predicate.test(a)) b = a; else a = b; } }return a;} static int binarySearchLastTrue( IntPredicate predicate, int fromInclusive, int toInclusive){ int a = fromInclusive,b = toInclusive; while((a != b)){ int la = a,lb = b;  int mid = ((a + b) / 2); if ( predicate.test(mid)) a = mid; else b = mid; if ( ((la == a) && (lb == b))) {if ( predicate.test(b)) a = b; else b = a; } }return a;} static Rect rect ; void test(){ Random random = new Random(13); for ( int test = 0;(test < 1000);test++) {}} void solve(){ rect = new Rect(); if ( (TEST == 0)) { int n = in.nextInt();  List<Rect> list = new ArrayList<>(); for ( int r = 0;(r < 2);r++) { int x2 = binarySearchFirstTrue((i)->(query(1,1,i,n,rect) >= 1),1,n);  int x1 = binarySearchLastTrue((i)->(query(i,1,x2,n,rect) >= 1),1,x2);  int y2 = binarySearchFirstTrue((i)->(query(x1,1,x2,i,rect) >= 1),1,n);  int y1 = binarySearchLastTrue((i)->(query(x1,i,x2,y2,rect) >= 1),1,y2); rect = new Rect(x1,y1,x2,y2); list.add(rect); }out.println(((("! " + list.get(0)) + " ") + list.get(1))); out.flush(); } else { int n = in.nextInt();  int x11 = in.nextInt(),y11 = in.nextInt(),x12 = in.nextInt(),y12 = in.nextInt();  int x21 = in.nextInt(),y21 = in.nextInt(),x22 = in.nextInt(),y22 = in.nextInt(); interact = new Interact(x11,y11,x12,y12,x21,y21,x22,y22); List<Rect> list = new ArrayList<>(); for ( int r = 0;(r < 2);r++) { int x2 = binarySearchFirstTrue((i)->(query(1,1,i,n,rect) >= 1),1,n);  int x1 = binarySearchLastTrue((i)->(query(i,1,x2,n,rect) >= 1),1,x2);  int y2 = binarySearchFirstTrue((i)->(query(x1,1,x2,i,rect) >= 1),1,n);  int y1 = binarySearchLastTrue((i)->(query(x1,i,x2,y2,rect) >= 1),1,y2); rect = new Rect(x1,y1,x2,y2); list.add(rect); }out.println(((("! " + list.get(0)) + " ") + list.get(1))); out.flush(); }} 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();} public int nextInt(){ return Integer.parseInt(next());} } }
1	public class FirstClass{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int n = Integer.parseInt(br.readLine());  int arr[] = new int[n];  StringTokenizer st1 = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {arr[i] = Integer.parseInt(st1.nextToken()); } int max = -1;  boolean flag = true; for ( int i = 0;(i < n);i++) {if ( (arr[i] > (max + 1))) {flag = false; out.println((i + 1)); break;} else {max = Math.max(max,arr[i]); }}if ( flag) out.println(-1); out.flush(); 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){ int N = in.nextInt(); if ( (N >= 0)) out.println(N); else {N = Math.abs(N); int v1 = (N / 10);  int v2 = (((N / 100) * 10) + (N % 10)); out.println(Math.max(v1,v2)); }} } 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));} }
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();  HashMap<Character,Integer> indexMap = new HashMap<>(); for ( int i = 0;(i < n);i++) { char c = s.charAt(i); if ( !indexMap.containsKey(c)) {indexMap.put(c,indexMap.size()); } } int[] last = new int[indexMap.size()]; Arrays.fill(last,-1_000_000); int answer = n; for ( int i = 0;(i < n);i++) { int index = indexMap.get(s.charAt(i)); last[index] = i; int first = i; for ( int a :last) first = Math.min(first,a); int visits = ((i - first) + 1); answer = Math.min(answer,visits); }out.println(answer); } } }
1	public class CF268_TwoSets{ public static void main( String[] args){ MyScanner in = new MyScanner();  int N = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] vals = new int[N];  HashMap<Integer,Integer> val2Ind = new HashMap<Integer,Integer>(); for ( int i = 0;(i < N);i++) {vals[i] = in.nextInt(); val2Ind.put(vals[i],i); } int[] setAssignment = new int[N];  int[] friendA = new int[N];  int[] friendB = new int[N]; Arrays.fill(setAssignment,-1); Arrays.fill(friendA,-1); Arrays.fill(friendB,-1); for ( int i = 0;(i < N);i++) { Integer friendAInd = val2Ind.get((a - vals[i])); if ( (friendAInd != null)) {friendA[i] = friendAInd; } Integer friendBInd = val2Ind.get((b - vals[i])); if ( (friendBInd != null)) {friendB[i] = friendBInd; } } Queue<Integer> toProc = new ArrayDeque<Integer>(); for ( int i = 0;(i < N);i++) { int friends = 0; if ( (friendA[i] != -1)) {friends++; } if ( (friendB[i] != -1)) {friends++; } if ( (friends == 1)) {toProc.add(i); } }while(!toProc.isEmpty()){ int ind = toProc.poll(); if ( (setAssignment[ind] != -1)) {continue;} if ( (friendA[ind] != -1)) { int other = friendA[ind]; if ( (setAssignment[other] == -1)) {setAssignment[ind] = 0; setAssignment[other] = 0; if ( (friendB[other] != -1)) { int otherOther = friendB[other]; friendB[otherOther] = -1; toProc.add(otherOther); } } else {System.out.println("NO"); return ;}} else if ( (friendB[ind] != -1)) { int other = friendB[ind]; if ( (setAssignment[other] == -1)) {setAssignment[ind] = 1; setAssignment[other] = 1; if ( (friendA[other] != -1)) { int otherOther = friendA[other]; friendA[otherOther] = -1; toProc.add(otherOther); } } else {System.out.println("NO"); return ;}} else {System.out.println("NO"); return ;}}for ( int i = 0;(i < N);i++) {if ( (setAssignment[i] != -1)) {continue;} if ( ((friendA[i] == -1) && (friendB[i] == -1))) {System.out.println("NO"); return ;} setAssignment[i] = 0; setAssignment[friendA[i]] = 0; }System.out.println("YES"); StringBuilder sb = new StringBuilder(); for ( int i = 0;(i < N);i++) {sb.append(setAssignment[i]); sb.append(" "); }sb.deleteCharAt((sb.length() - 1)); System.out.println(sb); } 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());} } }
2	public class OlyaAndMagicalSquare{ public static void solveCase( FastIO io){ int N = io.nextInt();  long K = io.nextLong();  CountMap cm = new CountMap(); cm.increment(N,BigInteger.ONE); long rem = K;  int moves = 1;  int sqSize = N; while((sqSize > 0)){ long need = ((1L << moves) - 1);  BigInteger biNeed = BigInteger.valueOf(need); cm.decrement(sqSize,biNeed); if ( (need > rem)) {break;} cm.increment((sqSize - 1),biNeed.multiply(BigInteger.valueOf(4))); rem -= need; ++moves; --sqSize; } BigInteger biRem = BigInteger.valueOf(rem); for ( int i = N;(i > 0);--i) { BigInteger have = cm.getCount(i); if ( (have.compareTo(biRem) >= 0)) {biRem = BigInteger.ZERO; break;} biRem = biRem.subtract(have); cm.decrement(i,have); cm.increment((i - 1),have.multiply(BigInteger.valueOf(4))); }if ( biRem.equals(BigInteger.ZERO)) {io.printf("YES %d\n",sqSize); } else {io.println("NO"); }} static private class CountMap extends HashMap<Integer,BigInteger>{ public void increment( int k, BigInteger v){ put(k,getCount(k).add(v)); } public void decrement( int k, BigInteger v){ BigInteger next = getCount(k).subtract(v); if ( next.equals(BigInteger.ZERO)) {remove(k); } else {put(k,next); }} public BigInteger getCount( int k){ return getOrDefault(k,BigInteger.ZERO);} } public static void solve( FastIO io){ int T = io.nextInt(); for ( int t = 0;(t < T);++t) {solveCase(io); }} public static class FastIO{ private InputStream reader ; private PrintWriter writer ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public FastIO( InputStream r, OutputStream w){ reader = r; writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(w))); } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = reader.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public String nextString(){ 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 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);} public int[] nextIntArray( int n){ return nextIntArray(n,0);} public int[] nextIntArray( int n, int off){ int[] arr = new int[(n + off)]; for ( int i = 0;(i < n);i++) {arr[(i + off)] = nextInt(); }return arr;} public long[] nextLongArray( int n){ return nextLongArray(n,0);} public long[] nextLongArray( int n, int off){ long[] arr = new long[(n + off)]; for ( int i = 0;(i < n);i++) {arr[(i + off)] = nextLong(); }return arr;} 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));} 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 printArray( int[] arr){ for ( int i = 0;(i < arr.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(arr[i]); }} public void printArray( long[] arr){ for ( int i = 0;(i < arr.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(arr[i]); }} public void printf( String format, Object... args){ print(String.format(format,args)); } public void flush(){ writer.flush(); } } public static void main( String[] args){ FastIO io = new FastIO(System.in,System.out); solve(io); io.flush(); } }
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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, Scanner in, PrintWriter out){ long numQuestions = in.nextInt();  long numCorrectlyAnsweredQuestions = in.nextInt();  long sizeForDoublingScore = in.nextInt();  long score = 0;  long numIncorrectlyAnsweredQuestions = (numQuestions - numCorrectlyAnsweredQuestions);  long numDoublings = Math.max(((numQuestions / sizeForDoublingScore) - numIncorrectlyAnsweredQuestions),0); score += ((2 * sizeForDoublingScore) * Long.parseLong(new BigInteger("2").modPow(new BigInteger(String.valueOf(numDoublings)),new BigInteger("1000000009")).subtract(BigInteger.ONE).toString())); score += (numCorrectlyAnsweredQuestions - (sizeForDoublingScore * numDoublings)); score %= 1000000009; out.println(score); } }
5	public class C{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = null; PrintWriter out ; public void solution()throws IOException { int n = nextInt();  int a[] = new int[n];  int b[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); b[i] = a[i]; }Arrays.sort(a); int ans = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) {ans++; } }if ( ((ans == 2) || (ans == 0))) {System.out.println("YES"); } else {System.out.println("NO"); }} public String nextToken()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(bf.readLine()); } return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} public void print( int[] a){ for ( int i = 0;(i < a.length);i++) {System.out.print((a[i] + " ")); }} public static void main( String[] args)throws IOException { new C().solution(); } }
3	public class inversion__count{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = s.nextInt(); } int m = s.nextInt();  int count = 0; for ( int i = 1;(i <= n);i++) {for ( int j = (i + 1);(j <= n);j++) {if ( (a[i] > a[j])) {count++; } }}if ( ((count % 2) == 0)) {count = 0; } else {count = 1; }for ( int i = 0;(i < m);i++) { int l = s.nextInt();  int r = s.nextInt(); if ( (l == r)) {if ( ((count & 1) == 1)) {System.out.println("odd"); } else {System.out.println("even"); }continue;} int d = ((r - l) + 1);  int segcount = 0;  int temp = ((d * (d - 1)) / 2); if ( (((temp & 1) == 1) && ((count & 1) == 1))) {count = 0; System.out.println("even"); } else if ( (((temp & 1) == 1) && ((count & 1) == 0))) {count = 1; System.out.println("odd"); } else {if ( ((count & 1) == 1)) {System.out.println("odd"); } else {System.out.println("even"); }}}} }
0	public class A{ BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter out ; public void solve()throws IOException { int N = nextInt(); if ( (N >= 0)) {out.println(N); return ;} int ans = (N / 10);  int ans2 = (((N / 100) * 10) + (N % 10)); out.println(Math.max(ans,ans2)); } public static void main( String[] args){ new A().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();} }
6	public class Main{ 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();  int k = sc.nextInt();  int[][] buckets = new int[k][];  long[] bucketSum = new long[k];  Map<Integer,Integer> map = new HashMap<>((k * 10000));  long target = 0; for ( int i = 0;(i < k);i++) { int n = sc.nextInt();  int[] arr = new int[n]; for ( int j = 0;(j < n);j++) {arr[j] = sc.nextInt(); target += arr[j]; map.put(arr[j],i); bucketSum[i] += arr[j]; }buckets[i] = arr; }if ( ((target % k) != 0)) {System.out.println("No"); return ;} else {target /= k; } int[] bitmask = new int[(1 << k)]; Arrays.fill(bitmask,-1); for ( int i = 0;(i < k);i++) {for ( int j = 0;(j < buckets[i].length);j++) { int start = buckets[i][j];  int next = ((int)(target - bucketSum[i]) + start);  Set<Integer> visited = new HashSet<>();  Set<Integer> visitedBuckets = new HashSet<>(); visited.add(start); visitedBuckets.add(i); int bitset = (1 << i); while(map.containsKey(next)){ int bucket = map.get(next); if ( (start == next)) {bitmask[bitset] = start; break;} else if ( visited.contains(next)) {break;} else if ( visitedBuckets.contains(bucket)) {break;} visited.add(next); visitedBuckets.add(bucket); next = ((int)(target - bucketSum[bucket]) + next); bitset |= (1 << bucket); }}} boolean[] dp = new boolean[(1 << k)]; Arrays.fill(dp,false); int[] build = new int[(1 << k)]; Arrays.fill(build,-1); for ( int i = 0;(i < dp.length);i++) {dp[i] = (bitmask[i] != -1); }for ( int m = 0;(m < (1 << k));m++) {if ( !dp[m]) {for ( int s = m;(s != 0);s = ((s - 1) & m)) {if ( (dp[s] && dp[(m ^ s)])) {dp[m] = true; build[m] = s; break;} }} }System.out.println((dp[(dp.length - 1)]?"Yes":"No")); ArrayList<Integer> path = new ArrayList<>(); rec(path,build,bitmask,((1 << k) - 1)); int[] picked = new int[k];  int[] out = new int[k]; if ( dp[(dp.length - 1)]) {for ( int i :path) { int prev = i;  int next = ((int)(target - bucketSum[map.get(prev)]) + prev); picked[map.get(next)] = next; out[map.get(next)] = map.get(prev); while((next != i)){ int t = next; next = ((int)(target - bucketSum[map.get(next)]) + next); prev = t; out[map.get(next)] = map.get(prev); picked[map.get(next)] = next; }}for ( int i = 0;(i < out.length);i++) {System.out.println(((picked + " ") + (out[i] + 1))); }} } public static void rec( ArrayList<Integer> path, int[] build, int[] bitmask, int i){ if ( ((i >= 0) && (i < bitmask.length))) {return ;} if ( (bitmask[i] != -1)) {path.add(bitmask[i]); } else {rec(path,build,bitmask,build[i]); rec(path,build,bitmask,(i ^ build[i])); }} }
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 int mod = 1000000007; public int MAXN = 333; public int[][] w1 ; public long[] fact ; public long[] ifact ; public void solve( int testNumber, InputReader in, OutputWriter out){ long[][] e = Factorials.getFIF(MAXN,mod); fact = e[0]; ifact = e[1]; w1 = new int[MAXN][MAXN]; w1[0][0] = 1; for ( int i = 1;(i < MAXN);i++) {for ( int j = 1;(j < MAXN);j++) {for ( int k = 1;(k <= i);k++) {w1[i][j] += w1[(i - k)][(j - 1)]; if ( (w1[i][j] >= mod)) w1[i][j] -= mod; }}} int n = in.nextInt();  int[] arr = in.readIntArray(n);  boolean[] marked = new boolean[n];  int[] fs = new int[n];  int fidx = 0; for ( int i = 0;(i < n);i++) {if ( marked[i]) continue; int count = 0; for ( int j = 0;(j < n);j++) {if ( isSquare(((1L * arr[i]) * arr[j]))) {if ( marked[j]) System.exit(1); marked[j] = true; count++; } }fs[fidx++] = count; }fs = Arrays.copyOf(fs,fidx); long x = 1; for ( int j :fs) x = ((x * fact[j]) % mod); x = ((x * solve(fs)) % mod); out.println(x); } public boolean isSquare( long x){ long d = (long)Math.sqrt(x); while(((d * d) < x))d++; while(((d * d) > x))d--; return ((d * d) == x);} public int solve( int[] freq){ int d = AUtils.sum(freq);  int b = AUtils.max(freq); if ( (d == 0)) return 1; if ( (((b + b) - 1) > d)) return 0; int[] dp = new int[1]; dp[0] = 1; for ( int j = 0;(j < freq.length);j++) {if ( (freq[j] == 0)) continue; int[] nxt = new int[(dp.length + freq[j])]; for ( int pgr = 0;(pgr < dp.length);pgr++) {for ( int cgr = 1;(cgr <= freq[j]);cgr++) {nxt[(pgr + cgr)] += (((((1L * dp[pgr]) * w1[freq[j]][cgr]) % mod) * ifact[cgr]) % mod); if ( (nxt[(pgr + cgr)] >= mod)) nxt[(pgr + cgr)] -= mod; }}dp = nxt; } int res = 0; for ( int i = 0;(i < dp.length);i++) { long x = (((1L * dp[i]) * fact[i]) % mod); if ( (((d - i) % 2) == 0)) res += x; else res -= x; if ( (res >= mod)) res -= mod; if ( (res < 0)) res += mod; }return res;} } 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[] readIntArray( int tokens){ int[] ret = new int[tokens]; for ( int i = 0;(i < tokens);i++) {ret[i] = nextInt(); }return ret;} public int read(){ if ( (this.numChars == -1)) {throw (new InputMismatchException());} else {if ( (this.curChar >= this.numChars)) {this.curChar = 0; try{this.numChars = this.stream.read(this.buf); }catch (IOException var2){ throw (new InputMismatchException());} if ( (this.numChars <= 0)) {return -1;} } return this.buf[this.curChar++];}} public 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 static boolean isSpaceChar( int c){ return (((((c == 32) || (c == 10)) || (c == 13)) || (c == 9)) || (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 close(){ writer.close(); } public void println( long i){ writer.println(i); } } }
3	public class Main{ static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter writer ; static String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} static int nextInt()throws IOException { return Integer.parseInt(nextToken());} static void banana()throws IOException { int n = nextInt();  int[] a = new int[n];  int[] color = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); } int c = 0; while(true){ int mn = 1000; for ( int i = 0;(i < n);i++) {if ( (color[i] == 0)) {mn = Math.min(mn,a[i]); } }if ( (mn == 1000)) {break;} c++; for ( int i = 0;(i < n);i++) {if ( (color[i] == 0)) {if ( ((a[i] % mn) == 0)) {color[i] = c; } } }}writer.println(c); } public static void main( String[] args)throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = null; writer = new PrintWriter(System.out); banana(); reader.close(); writer.close(); } }
6	public class Main implements Runnable{ int n ; long[][] f ; boolean[][] e ; int bit( int value){ return (1 << value);} void solve()throws IOException { n = nextInt(); int m = nextInt(); f = new long[(1 << n)][n]; e = new boolean[n][n]; for ( int i = 0;(i < (1 << n));++i) {for ( int j = 0;(j < n);++j) {f[i][j] = -1; }}for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < n);++j) {f[(bit(i) | bit(j))][j] = 0; e[i][j] = false; }}for ( int i = 0;(i < m);++i) { int u = (nextInt() - 1);  int v = (nextInt() - 1); e[u][v] = true; e[v][u] = true; if ( (u < v)) {f[(bit(u) | bit(v))][v] = 1; } else {f[(bit(v) | bit(u))][u] = 1; }} long answer = 0; for ( int i = 1;(i < (1 << n));++i) { int start = 0; while((((1 << start) & i) == 0)){++start; } int s = bit(start); for ( int nxt = (start + 1);(nxt < n);++nxt) { int b = bit(nxt); if ( (((b & i) > 0) && ((b | s) != i))) {if ( e[start][nxt]) {answer += clc(i,nxt); } } }}writer.print((answer >> 1)); } long clc( int maska, int last){ if ( (f[maska][last] == -1)) { int first = 0; while((((1 << first) & maska) == 0)){++first; }f[maska][last] = 0; for ( int b = (first + 1);(b < n);++b) {if ( ((bit(b) & maska) > 0)) {if ( e[b][last]) {f[maska][last] += clc((maska ^ bit(last)),b); } } }} return f[maska][last];} public static void main( String[] args)throws InterruptedException { new Thread(null,new Runnable(){public void run(){ new Main().run(); } },"1",(1 << 25)).start(); } @Override public void run(){ try{ boolean fromStandart = true; reader = new BufferedReader((fromStandart?new InputStreamReader(System.in):new FileReader(INFILE))); writer = new PrintWriter(new BufferedWriter((fromStandart?new OutputStreamWriter(System.out):new FileWriter(OUTFILE)))); tokenizer = null; solve(); writer.flush(); }catch (Exception error){ error.printStackTrace(); System.exit(1); } } static final String INFILE = "input.txt"; static final String OUTFILE = "output.txt"; BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; 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 C{ static private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static private PrintStream out = System.out; public static void main( String[] args)throws NumberFormatException,IOException { int n = Integer.parseInt(in.readLine());  char[] s = in.readLine().toCharArray();  HashSet<Character> all = new HashSet<Character>(); for ( char c :s) all.add(c); int totalCount = all.size();  HashMap<Character,Integer> cnts = new HashMap<Character,Integer>();  int ans = Integer.MAX_VALUE;  int x = 0; for ( int y = 0;(y < n);++y) {if ( !cnts.containsKey(s[y])) cnts.put(s[y],0); cnts.put(s[y],(cnts.get(s[y]) + 1)); if ( (cnts.size() < totalCount)) continue; while((cnts.get(s[x]) > 1)){cnts.put(s[x],(cnts.get(s[x]) - 1)); ++x; }ans = Math.min(ans,((y - x) + 1)); }out.println(ans); } }
5	public class A{ BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; 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); } } String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(reader.readLine()); return tokenizer.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < a.length);i++) {a[i] = nextInt(); }Arrays.sort(a); if ( (a[(a.length - 1)] == 1)) {for ( int i = 0;(i < (a.length - 1));i++) {writer.print((1 + " ")); }writer.println((2 + "")); return ;} for ( int i = 0;(i < a.length);i++) {if ( (i == 0)) writer.print((1 + " ")); else writer.print((a[(i - 1)] + " ")); }writer.println(); } public static void main( String[] args){ new A().run(); } }
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;} }} }
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(); } }
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());} } }
3	public class q4{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));  int query = in.nextInt(); while((query-- > 0)){ int n = in.nextInt();  int k = in.nextInt();  char[] arr = new char[n];  String code = in.next(); for ( int i = 0;(i < n);i++) {arr[i] = code.charAt(i); } int r = 0;  int g = 0;  int b = 0; for ( int i = 0;(i < k);i++) {if ( ((i % 3) == 0)) {if ( (arr[i] == 'R')) {g++; b++; } else if ( (arr[i] == 'G')) {r++; b++; } else {r++; g++; }} else if ( ((i % 3) == 1)) {if ( (arr[i] == 'G')) {g++; b++; } else if ( (arr[i] == 'B')) {r++; b++; } else {r++; g++; }} else {if ( (arr[i] == 'B')) {g++; b++; } else if ( (arr[i] == 'R')) {r++; b++; } else {r++; g++; }}} int rMin = r;  int gMin = g;  int bMin = b; for ( int j = k;(j < n);j++) {if ( (((((j % 3) == 0) && (arr[j] != 'R')) || (((j % 3) == 1) && (arr[j] != 'G'))) || (((j % 3) == 2) && (arr[j] != 'B')))) {r++; } if ( ((((((j - k) % 3) == 0) && (arr[(j - k)] != 'R')) || ((((j - k) % 3) == 1) && (arr[(j - k)] != 'G'))) || ((((j - k) % 3) == 2) && (arr[(j - k)] != 'B')))) {r--; } rMin = Math.min(r,rMin); if ( (((((j % 3) == 0) && (arr[j] != 'G')) || (((j % 3) == 1) && (arr[j] != 'B'))) || (((j % 3) == 2) && (arr[j] != 'R')))) {g++; } if ( ((((((j - k) % 3) == 0) && (arr[(j - k)] != 'G')) || ((((j - k) % 3) == 1) && (arr[(j - k)] != 'B'))) || ((((j - k) % 3) == 2) && (arr[(j - k)] != 'R')))) {g--; } gMin = Math.min(gMin,g); if ( (((((j % 3) == 0) && (arr[j] != 'B')) || (((j % 3) == 1) && (arr[j] != 'R'))) || (((j % 3) == 2) && (arr[j] != 'G')))) {b++; } if ( ((((((j - k) % 3) == 0) && (arr[(j - k)] != 'B')) || ((((j - k) % 3) == 1) && (arr[(j - k)] != 'R'))) || ((((j - k) % 3) == 2) && (arr[(j - k)] != 'G')))) {b--; } bMin = Math.min(bMin,b); }out.println(Math.min(Math.min(rMin,gMin),bMin)); }out.flush(); } }
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(); } } }
0	public class a{ public static void main( String[] args){ Scanner br = new Scanner(System.in);  long n = br.nextLong(); System.out.println("25"); } }
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());} } }
4	@SuppressWarnings("unused") public class C{ static long inf = (long)1e15; public static void main( String[] args)throws IOException { FastScanner fs = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int tt = fs.nextInt(); outer:while((tt-- > 0)){ int n = fs.nextInt();  int[] a = fs.readArray(n);  ArrayList<Integer>[] l = new ArrayList[n]; for ( int i = 0;(i < n);i++) l[i] = new ArrayList<Integer>(); l[0].add(1); for ( int i = 1;(i < n);i++) {if ( (a[i] == 1)) {for ( int j = 0;(j < l[(i - 1)].size());j++) l[i].add(l[(i - 1)].get(j)); l[i].add(1); } else { int ind = -1; for ( int j = (l[(i - 1)].size() - 1);(j >= 0);j--) {if ( ((l[(i - 1)].get(j) + 1) == a[i])) {ind = j; break;} }for ( int j = 0;(j < ind);j++) l[i].add(l[(i - 1)].get(j)); l[i].add(a[i]); }}for ( int i = 0;(i < n);i++) {out.print(l[i].get(0)); for ( int j = 1;(j < l[i].size());j++) out.print(("." + l[i].get(j))); out.println(); }}out.close(); } static final Random random = new Random(); 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();} public int nextInt(){ return Integer.parseInt(next());} public int[] readArray( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} } }
5	public class A{ final String filename = new String("A").toLowerCase(); void solve()throws Exception { int n = nextInt();  int[] a = new int[n];  int m = -1; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); if ( ((m == -1) || (a[i] > a[m]))) {m = i; } }if ( (a[m] == 1)) a[m] = 2; else a[m] = 1; Arrays.sort(a); for ( int i = 0;(i < n);i++) {out.print((a[i] + " ")); }} void run(){ try{in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } BufferedReader in ; StringTokenizer st ; PrintWriter out ; 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());} public static void main( String[] args){ new A().run(); } }
4	public class FireAgain{ Scanner in ; PrintWriter out ; public static void main( String[] args)throws IOException { new FireAgain().run(); } void run()throws IOException { in = new Scanner(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); solve(); in.close(); out.close(); } private void solve(){ int N = in.nextInt();  int M = in.nextInt();  int[][] burn = new int[(N + 1)][(M + 1)];  int K = in.nextInt();  int[] qx = new int[(N * M)];  int[] qy = new int[(N * M)];  int first = 0;  int last = 0; for ( int i = 0;(i < K);i++) {qx[last] = in.nextInt(); qy[last] = in.nextInt(); burn[qx[last]][qy[last]] = 1; last++; }while((first < last)){ int x = qx[first];  int y = qy[first]; if ( (((x - 1) > 0) && (burn[(x - 1)][y] == 0))) {burn[(x - 1)][y] = 1; qx[last] = (x - 1); qy[last] = y; last++; } if ( (((y - 1) > 0) && (burn[x][(y - 1)] == 0))) {burn[x][(y - 1)] = 1; qx[last] = x; qy[last] = (y - 1); last++; } if ( (((x + 1) <= N) && (burn[(x + 1)][y] == 0))) {burn[(x + 1)][y] = 1; qx[last] = (x + 1); qy[last] = y; last++; } if ( (((y + 1) <= M) && (burn[x][(y + 1)] == 0))) {burn[x][(y + 1)] = 1; qx[last] = x; qy[last] = (y + 1); last++; } first++; }out.println(((qx[(last - 1)] + " ") + qy[(last - 1)])); } }
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(); } }
0	public class Task5d{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  double a = sc.nextDouble();  double v = sc.nextDouble();  double l = sc.nextDouble();  double d = sc.nextDouble();  double w = sc.nextDouble();  double t = 0; if ( (w >= v)) { double t1 = (v / a);  double s1 = (((a * t1) * t1) / 2); if ( (s1 > l)) {t = Math.sqrt(((2 * l) / a)); } else {t = (t1 + ((l - s1) / v)); }} else { double t2 = Math.sqrt(((2 * d) / a)); if ( ((a * t2) <= w)) { double t1 = (v / a);  double s1 = (((a * t1) * t1) / 2); if ( (s1 > l)) {t = Math.sqrt(((2 * l) / a)); } else {t = (t1 + ((l - s1) / v)); }} else { double tup = (v / a);  double tdown = ((v - w) / a);  double sup = (((a * tup) * tup) / 2);  double sdown = ((v * tdown) - (((a * tdown) * tdown) / 2)); if ( ((sup + sdown) <= d)) { double tmax = (((d - sup) - sdown) / v); t = ((tup + tmax) + tdown); } else { double tw = (w / a);  double sw = (((a * tw) * tw) / 2);  double sl = ((d - sw) / 2);  double dis = ((w * w) + ((2 * a) * sl));  double tu1 = ((-w - Math.sqrt(dis)) / a); if ( (tu1 < 0)) {tu1 = ((-w + Math.sqrt(dis)) / a); } t = (tw + (2 * tu1)); } double sreup = ((w * tdown) + (((a * tdown) * tdown) / 2)); if ( (sreup <= (l - d))) {t += tdown; t += (((l - d) - sreup) / v); } else { double dis = ((w * w) - ((2 * a) * (d - l)));  double tu1 = ((-w - Math.sqrt(dis)) / a); if ( (tu1 < 0)) {tu1 = ((-w + Math.sqrt(dis)) / a); } t += tu1; }}}System.out.println(t); } }
5	public class Main{ public static void main( String[] args)throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(r.readLine());  String[] line = r.readLine().split("[ ]+");  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = Integer.parseInt(line[i]); Arrays.sort(a); boolean found = false; for ( int i = 0;((i < n) && !found);i++) if ( (a[i] != 1)) found = true; if ( found) {System.out.println(1); for ( int i = 1;(i < n);i++) System.out.println(a[(i - 1)]); } else {for ( int i = 0;(i < (n - 1));i++) System.out.println(1); System.out.println(2); }} }
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);  TaskG solver = new TaskG(); solver.solve(1,in,out); out.close(); } static class TaskG{ static final long MODULO = (long)(1e9 + 7); public void solve( int testNumber, InputReader in, PrintWriter out){ String x = in.next();  int[][] comb = new int[(x.length() + 2)][(x.length() + 2)]; comb[0][0] = 1; for ( int i = 1;(i < comb.length);++i) {comb[i][0] = 1; for ( int j = 1;(j < comb.length);++j) {comb[i][j] = ((comb[(i - 1)][(j - 1)] + comb[(i - 1)][j]) % (int)MODULO); }} int[][] pow = new int[11][(x.length() + 2)]; for ( int i = 0;(i < pow.length);++i) {pow[i][0] = 1; for ( int j = 1;(j < pow[i].length);++j) {pow[i][j] = (int)((i * (long)pow[i][(j - 1)]) % MODULO); }} int[] oneSum = new int[(x.length() + 2)]; for ( int i = 1;(i < oneSum.length);++i) {oneSum[i] = (int)(((10 * (long)oneSum[(i - 1)]) + 1) % MODULO); } int[][] s1 = new int[10][(x.length() + 1)];  int[][] s2 = new int[10][(x.length() + 1)]; for ( int what = 1;(what <= 9);++what) {for ( int max = 0;(max <= x.length());++max) { long sum1 = 0;  long sum2 = 0; for ( int equalExtra = 0;(equalExtra <= max);++equalExtra) { long cways = 1; cways *= comb[max][equalExtra]; cways %= MODULO; cways *= pow[what][(max - equalExtra)]; cways %= MODULO; sum1 += (cways * oneSum[equalExtra]); sum1 %= MODULO; sum2 += cways; sum2 %= MODULO; }s1[what][max] = (int)sum1; s2[what][max] = (int)sum2; }} int[] sofar = new int[10];  long res = 0; for ( int firstLess = 0;(firstLess < x.length());++firstLess) { int min = 0;  int max = (x.charAt(firstLess) - '0'); if ( (firstLess < (x.length() - 1))) --max; for ( int dig = min;(dig <= max);++dig) {++sofar[dig]; int totalSofar = (firstLess + 1);  int sofarBigger = 0; for ( int what = 9;(what >= 1);--what) { int sofarThisOrLess = (totalSofar - sofarBigger);  int sofarThis = sofar[what];  int sofarLess = (sofarThisOrLess - sofarThis); for ( int bigger = sofarBigger;((bigger + sofarThisOrLess) <= x.length());++bigger) { long ways = comb[(x.length() - totalSofar)][(bigger - sofarBigger)]; ways *= pow[(9 - what)][(bigger - sofarBigger)]; ways %= MODULO; long sum1 = s1[what][((x.length() - bigger) - sofarThisOrLess)];  long sum2 = s2[what][((x.length() - bigger) - sofarThisOrLess)];  long sum = (((sum1 * (long)pow[10][sofarThis]) + (sum2 * oneSum[sofarThis])) % MODULO); sum *= pow[10][bigger]; sum %= MODULO; res = ((res + (((sum * ways) % MODULO) * what)) % MODULO); }sofarBigger += sofarThis; }--sofar[dig]; }++sofar[(x.charAt(firstLess) - '0')]; }out.println(res); } } 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();} } }
2	public class b{ 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();  double n = (double)sc.nextLong();  double k = (double)sc.nextLong();  double div = ((9 + (8 * n)) + (8 * k));  double ss = Math.sqrt(div); ss = ((ss - 3) / 2); System.out.println((int)(n - ss)); } }
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);  G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion(); solver.solve(1,in,out); out.close(); } static class G1PlaylistForPolycarpEasyVersion{ long mod = ((int)1e9 + 7); public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int T = in.nextInt();  int[] t = new int[n];  int[] g = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = in.nextInt(); g[i] = in.nextInt(); } long[] fact = new long[(n + 1)]; fact[0] = 1; for ( int i = 1;(i <= n);i++) {fact[i] = ((fact[(i - 1)] * i) % mod); } ArrayList<Integer> masks = new ArrayList<>();  long val = 0; for ( int i = 1;(i < (1 << n));i++) { int time = 0;  int[] count = new int[3]; for ( int j = 0;(j < n);j++) {if ( ((i & (1 << j)) != 0)) {time += t[j]; count[(g[j] - 1)]++; } }if ( (time == T)) {masks.add(i); Arrays.sort(count); long v = ((((fact[count[0]] * fact[count[1]]) % mod) * fact[count[2]]) % mod); val += ((countUtil(count[0],count[1],count[2]) * v) % mod); } }out.println((val % mod)); } long countWays( int p, int q, int r, int last){ if ( (((p < 0) || (q < 0)) || (r < 0))) return 0; if ( ((((p == 1) && (q == 0)) && (r == 0)) && (last == 0))) return 1; if ( ((((p == 0) && (q == 1)) && (r == 0)) && (last == 1))) return 1; if ( ((((p == 0) && (q == 0)) && (r == 1)) && (last == 2))) return 1; if ( (last == 0)) return ((countWays((p - 1),q,r,1) + countWays((p - 1),q,r,2)) % mod); if ( (last == 1)) return ((countWays(p,(q - 1),r,0) + countWays(p,(q - 1),r,2)) % mod); if ( (last == 2)) return ((countWays(p,q,(r - 1),0) + countWays(p,q,(r - 1),1)) % mod); return 0;} long countUtil( int p, int q, int r){ return ((((countWays(p,q,r,0) + countWays(p,q,r,1)) % mod) + countWays(p,q,r,2)) % mod);} } 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));} } }
2	public class c{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long n = scan.nextLong();  long s = scan.nextLong(); scan.close(); long start = (s - (s % 10)); while(((start <= n) && !isBig(start,s))){start += 10; }if ( (start > n)) {System.out.println(0); } else {System.out.println(((n - start) + 1)); }} static private boolean isBig( long a, long s){ char[] digits = ("" + a);  int counter = 0; for ( int i = 0;(i < digits.length);i++) {counter += (digits[i] - '0'); }return ((a - counter) >= s);} }
0	public class Test{ static int pos = 0; static int arr[] ; static LinkedList l1 = new LinkedList(); public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int k = in.nextInt(),n = in.nextInt(),s = in.nextInt(),p = in.nextInt();  int paper = (n / s); if ( ((n % s) != 0)) paper++; paper *= k; int fin = (paper / p); if ( ((paper % p) != 0)) fin++; System.out.println(fin); } }
5	public class A implements Runnable{ 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()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} public static void main( String[] args){ new Thread(null,new A(),"",(128 * (1L << 20))).start(); } long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } long memoryTotal ,memoryFree ; void memory(){ memoryFree = Runtime.getRuntime().freeMemory(); System.err.println((("Memory = " + ((memoryTotal - memoryFree) >> 10)) + " KB")); } boolean DEBUG = false; void solve()throws IOException { int n = readInt();  int[] a = new int[n];  Integer[] b = new Integer[n]; for ( int i = 0;(i < n);++i) {a[i] = readInt(); b[i] = a[i]; }Arrays.sort(b); int count = 0; for ( int i = 0;(i < n);++i) {if ( (a[i] != b[i])) {count++; } }if ( ((count == 2) || (count == 0))) {out.println("YES"); } else {out.println("NO"); }} }
3	public class P911D{ public static void main( String[] args){ FastScanner scan = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int n = scan.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = scan.nextInt(); int inv = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (arr[i] > arr[j])) inv++; }}inv &= 1; int[] cumul = new int[(n + 1)]; for ( int i = 2;(i < cumul.length);i++) {cumul[i] = ((cumul[(i - 1)] + i) - 1); } int q = scan.nextInt(); for ( int i = 0;(i < q);i++) { int a = (scan.nextInt() - 1);  int b = (scan.nextInt() - 1); inv += cumul[((b - a) + 1)]; inv &= 1; if ( (inv == 0)) pw.println("even"); else pw.println("odd"); }pw.flush(); } static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ try{br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } } public String next(){ if ( st.hasMoreTokens()) return st.nextToken(); try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); } return st.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
3	public class A{ public static void main( String[] args){ Scanner input = new Scanner();  StringBuilder output = new StringBuilder();  int n = input.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = input.nextInt(); }Arrays.sort(a); boolean[] colored = new boolean[n];  int colors = 0; for ( int i = 0;(i < n);i++) {if ( !colored[i]) {colors++; colored[i] = true; for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {colored[j] = true; } }} }System.out.println(colors); } static private class Scanner{ BufferedReader br ; StringTokenizer st ; public Scanner( Reader in){ br = new BufferedReader(in); } public Scanner(){ 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());} long nextLong(){ return Long.parseLong(next());} } }
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];} }
2	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(),k = sc.nextLong();  long ans = 0,sum = 0; while((ans < n)){if ( ((sum - (n - ans)) == k)) break; ans++; sum += ans; }sc.close(); System.out.println((n - ans)); } }
3	public class Main{ void pre()throws Exception { } void solve( int TC)throws Exception { int n = ni();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); Arrays.sort(a); int ans = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] == -1)) continue; ans++; for ( int j = (i + 1);(j < n);j++) if ( ((a[j] % a[i]) == 0)) a[j] = -1; }pn(ans); } void exit( boolean b){ if ( !b) System.exit(0); } long IINF = (long)1e18,mod = ((long)1e9 + 7); final int INF = (int)1e9,MX = ((int)2e6 + 5); DecimalFormat df = new DecimalFormat("0.00000000"); double PI = 3.141592653589793238462643383279502884197169399,eps = 1e-6; static boolean multipleTC = false,memory = false,fileIO = false; FastReader in ; PrintWriter out ; void run()throws Exception { if ( fileIO) {in = new FastReader("input.txt"); out = new PrintWriter("output.txt"); } else {in = new FastReader(); out = new PrintWriter(System.out); } int T = (multipleTC?ni():1); pre(); for ( int t = 1;(t <= T);t++) solve(t); out.flush(); out.close(); } 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(); } 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 bit( long n){ return ((n == 0)?0:(1 + bit((n & (n - 1)))));} void pn( Object o){ out.println(o); } int ni()throws Exception { return Integer.parseInt(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()throws Exception { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new Exception(e.toString()));} }return st.nextToken();} String nextLine()throws Exception { String str = ""; try{str = br.readLine(); }catch (IOException e){ throw (new Exception(e.toString()));} return str;} } }
1	public class Speadsheets{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = Integer.parseInt(sc.nextLine());  String code = ""; for ( int i = 0;(i < n);i++) { long chResult = 0;  long chResult1 = 0;  long nResult = 0;  long nResult1 = 0;  boolean t = false;  boolean k = false; code = sc.nextLine(); for ( int j = 0;(j < code.length());j++) { char c = code.charAt(j); if ( (('Z' - c) < 33)) {if ( t) {chResult1 = chResult; chResult = 0; t = false; k = true; } chResult = ((chResult * 26) + (26 - ('Z' - c))); } else {t = true; if ( k) {nResult1 = nResult; nResult = 0; k = false; } nResult = ((nResult * 10) + (9 - ('9' - c))); }}if ( (chResult1 == 0)) {System.out.println(((("R" + nResult) + "C") + chResult)); } else {System.out.println((convert(nResult) + nResult1)); }}} static private String convert( long number){ String[] chars = new String[]{"Z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y"};  String result = "";  int rem = 0;  int m = 0; while((number > 0)){m = 0; rem = (int)(number % 26); result = (chars[rem] + result); if ( ((number % 26) == 0)) {m = 1; } number = (number / 26); number = (number - m); }return result;} }
2	public class B{ static char[] in = new char[1000000]; public static void main( String[] arg)throws Throwable { int n = nextInt();  int k = nextInt();  long ate = 0;  long ans = -1; for ( long i = 1;(ans < 0);++i) { long test = ((i * (i + 1)) / 2); if ( (test < k)) continue; long adding_moves = i;  long eating_moves = (n - i); if ( ((test - eating_moves) == k)) ans = eating_moves; }System.out.println(ans); } public static long nextLong()throws Throwable { long i = System.in.read();  boolean neg = false; while((i < 33))i = System.in.read(); if ( (i == 45)) {neg = true; i = 48; } i = (i - 48); int j = System.in.read(); while((j > 32)){i *= 10; i += (j - 48); j = System.in.read(); }return (neg?-i:i);} public static int nextInt()throws Throwable { return (int)nextLong();} }
2	public class Main{ @SuppressWarnings public static void main( String[] args)throws IOException { Reader ob = new Reader();  Writer out = new Writer(System.out);  Random oo = new Random();  long k = ob.nL(),ans = 0,p = 9,num = 0; for ( int i = 1;(i < 18);i++) {if ( ((num + (i * p)) < k)) {num += (i * p); p *= 10; ans = 0; for ( int j = 0;(j < i);j++) ans = (9 + (ans * 10)); } else { long left = (k - num);  long r = (left / i); left -= (r * i); ans += r; if ( (left > 0)) { String s = Long.toString((ans + 1)); out.pln(s.charAt(((int)left - 1))); } else { String s = Long.toString(ans); out.pln(s.charAt(((i - 1) - (int)left))); }break;}}out.flush(); } static void sort( int[] a){ RA(a); Arrays.sort(a); } public static Pairs[] RA( Pairs[] array){ Random rgen = new Random(); for ( int i = 0;(i < array.length);i++) { int randomPosition = rgen.nextInt(array.length);  Pairs temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; }return array;} public static int[] RA( 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; }return array;} static void sort( long[] a){ RA(a); Arrays.sort(a); } public static long[] RA( long[] array){ Random rgen = new Random(); for ( int i = 0;(i < array.length);i++) { int randomPosition = rgen.nextInt(array.length);  long temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; }return array;} static void sort( String[] a){ RA(a); Arrays.sort(a); } public static String[] RA( String[] array){ Random rgen = new Random(); for ( int i = 0;(i < array.length);i++) { int randomPosition = rgen.nextInt(array.length);  String temp = array[i]; array[i] = array[randomPosition]; array[randomPosition] = temp; }return array;} static long gcd( long a, long b){ if ( (a < b)) return gcd(b,a); else if ( (b == 0)) return a; else return gcd(b,(a % b));} static long pow( long a, long b, long mod){ if ( (b == 0)) return 1; long t = pow(a,(b >> 1),mod); t = ((t * t) % mod); if ( ((b & 1) == 1)) t = (t * a); if ( (t >= mod)) t %= mod; return t;} static long pow( long a, long b){ if ( (b == 0)) return 1; long t = pow(a,(b >> 1)); t = (t * t); if ( ((b & 1) == 1)) t = (t * a); return t;} static int max( int... a){ int m = a[0]; for ( int i = 0;(i < a.length);i++) m = Math.max(m,a[i]); return m;} static long max( long... a){ long m = a[0]; for ( int i = 0;(i < a.length);i++) m = Math.max(m,a[i]); return m;} static int min( int... a){ int m = a[0]; for ( int i = 0;(i < a.length);i++) m = Math.min(m,a[i]); return m;} static long min( long... a){ long m = a[0]; for ( int i = 0;(i < a.length);i++) m = Math.min(m,a[i]); return m;} static class Writer{ private final PrintWriter p ; Writer( OutputStream o){ p = new PrintWriter(new BufferedWriter(new OutputStreamWriter(o))); } void p( Object... o1){ for ( Object o11 :o1) {p.print((o11 + "")); }} void p( String s){ p.print(s); } void pln( Object... o1){ p(o1); p.println(); } void flush(){ p.flush(); } void close(){ p.close(); } } static class Reader{ private byte[] buf = new byte[1024]; private int curChar ; private int snumChars ; int flag = 0; FileReader file ; Reader(){ } Reader( String x)throws IOException{ flag = 1; file = new FileReader(x); } 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 nL(){ 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 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);} 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));} } }
0	public class LCMChallenge{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextInt(); if ( (n == 1l)) System.out.println(1); else if ( (n == 2l)) System.out.println(2); else { long c1 = ((n * (n - 1)) * (n - 2));  long c2 = ((n * (n - 1)) * (n - 3));  long c3 = (((n - 1) * (n - 2)) * (n - 3)); if ( ((n % 2) == 0)) c1 /= 2; else c3 /= 2; if ( ((n % 3) == 0)) c2 /= 3;  long ans = Math.max(c1,c2); ans = Math.max(ans,c3); System.out.println(ans); }} }
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)); }}} }
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)); } }
1	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); int t = 1,c = 0; for ( int i = 1;(i < n);i++) {if ( (a[i] == a[(i - 1)])) {if ( (((i - 2) >= 0) && (a[(i - 2)] == (a[(i - 1)] - 1)))) {System.out.println("cslnb"); return ;} c++; } if ( ((a[i] == a[(i - 1)]) && (a[i] == 0))) {System.out.println("cslnb"); return ;} }if ( (c > 1)) {System.out.println("cslnb"); return ;} for ( int i = 0;(i < n);i++) {if ( (((a[i] - i) % 2) != 0)) t = (t ^ 1); }if ( (t == 1)) System.out.println("cslnb"); else System.out.println("sjfnb"); } }
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);  EPhoenixAndComputers solver = new EPhoenixAndComputers(); solver.solve(1,in,out); out.close(); } static class EPhoenixAndComputers{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt(),m = in.nextInt();  ModInt mod = new ModInt(m);  int[] factorial = new int[(n + 1)];  int[][] binomial = new int[(n + 1)][(n + 1)];  int[] two = new int[(n + 1)]; for ( int i = 0;(i <= n);i++) {binomial[i][0] = 1; for ( int j = 1;(j <= i);j++) binomial[i][j] = mod.add(binomial[(i - 1)][j],binomial[(i - 1)][(j - 1)]); factorial[i] = ((i == 0)?1:mod.multiply(factorial[(i - 1)],i)); two[i] = ((i == 0)?1:mod.multiply(2,two[(i - 1)])); } int[][] dp = new int[(n + 1)][(n + 1)]; dp[0][0] = 1; int answer = 0; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= i);j++) {for ( int x = 1;(x <= i);x++) {dp[i][j] = mod.add(dp[i][j],mod.multiply(binomial[i][x],mod.multiply(two[(x - 1)],dp[(i - x)][(j - 1)]))); }}}for ( int k = 0;(k < n);k++) {answer = mod.add(answer,dp[(n - k)][(k + 1)]); }out.println(answer); } } 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 println( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }writer.print('\n'); } public void close(){ writer.close(); } } static class ModInt{ int modulo ; public ModInt( int m){ modulo = m; } public int add( int x, int y){ x += y; if ( (x >= modulo)) x -= modulo; return x;} public int multiply( int x, int y){ return (int)(((x * 1L) * y) % modulo);} } 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); } } }
1	public class Problem01B implements Runnable{ static final long[] x10 = new long[]{1,26,(26 * 26),((26 * 26) * 26),(((26 * 26) * 26) * 26),((((26 * 26) * 26) * 26) * 26),(((((26 * 26) * 26) * 26) * 26) * 26)}; void solve()throws NumberFormatException,IOException { int n = nextInt(); for ( int i = 0;(i < n);i++) { String t = nextToken().toUpperCase();  StringBuffer rowString = new StringBuffer(t.length());  StringBuffer numb1 = new StringBuffer(t.length());  StringBuffer numb2 = new StringBuffer(t.length());  int stage = 0; for ( int j = 0;(j < t.length());j++) {; char charAt = t.charAt(j); if ( (charAt >= 'A')) {if ( (stage == 0)) {rowString.append(charAt); } else {stage++; }} else {if ( ((stage == 0) || (stage == 2))) stage++; switch(stage){ case 1:numb1.append(charAt); break; case 3:numb2.append(charAt); break; } }}if ( (stage == 1)) { long result = convertString(rowString); System.out.print("R"); System.out.print(numb1.toString()); System.out.print("C"); System.out.println(result); } else { StringBuffer tmp = convertNumber(Long.parseLong(numb2.toString())); System.out.print(tmp.toString()); System.out.println(numb1.toString()); }}} public StringBuffer convertNumber( long n){ StringBuffer sb2 = new StringBuffer();  long nmod26 = (n % 26);  long ndiv26 = (n / 26); while(((ndiv26 > 0) || (nmod26 > 0))){ long tmp = 0; if ( (nmod26 > 0)) {sb2.append((char)(('A' + nmod26) - 1)); tmp = ndiv26; } else {sb2.append('Z'); tmp = (ndiv26 - 1); }nmod26 = (tmp % 26); ndiv26 = (tmp / 26); }return sb2.reverse();} public long convertString( StringBuffer sb){ long result = 0; for ( int i = 0;(i < sb.length());i++) { long l = (((sb.charAt(i) - 'A') + 1) * x10[((sb.length() - i) - 1)]); result += l; }return result;} StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args){ new Problem01B().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 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());} } }
6	public class Main{ void pre()throws Exception { } int n ,t ; void solve( int TC)throws Exception { n = ni(); t = ni(); int[][] song = new int[n][]; for ( int i = 0;(i < n);i++) song[i] = new int[]{ni(),(ni() - 1)}; long[][] dp = new long[(1 << n)][3]; for ( int i = 0;(i < dp.length);i++) for ( int j = 0;(j < dp[i].length);j++) dp[i][j] = -1; pn(start(dp,song,0,-1)); } long start( long[][] dp, int[][] song, int mask, int prev){ long ti = 0; for ( int i = 0;(i < n);i++) {if ( (((mask >> i) & 1) == 1)) ti += song[i][0]; }if ( (ti == t)) return 1; if ( ((prev != -1) && (dp[mask][prev] != -1))) return dp[mask][prev]; long ans = 0; for ( int i = 0;(i < n);i++) {if ( (((((mask >> i) & 1) == 0) && (song[i][1] != prev)) && ((ti + song[i][0]) <= t))) ans = ((ans + start(dp,song,(mask | (1 << i)),song[i][1])) % mod); }if ( (prev != -1)) dp[mask][prev] = ans; return ans;} long mod = ((long)1e9 + 7),IINF = (long)1e18; final int INF = (int)1e9,MX = ((int)2e5 + 5); DecimalFormat df = new DecimalFormat("0.00000000000"); double PI = 3.141592653589793238462643383279502884197169399,eps = 1e-8; static boolean multipleTC = false,memory = false; FastReader in ; PrintWriter out ; void run()throws Exception { in = new FastReader(); out = new PrintWriter(System.out); int T = (multipleTC?ni():1); pre(); for ( int t = 1;(t <= T);t++) solve(t); out.flush(); out.close(); } 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(); } 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 bit( long n){ return ((n == 0)?0:(1 + bit((n & (n - 1)))));} void pn( Object o){ out.println(o); } int ni()throws Exception { return Integer.parseInt(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()throws Exception { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ throw (new Exception(e.toString()));} }return st.nextToken();} String nextLine()throws Exception { String str = ""; try{str = br.readLine(); }catch (IOException e){ throw (new Exception(e.toString()));} return str;} } }
6	public class Main implements Runnable{ private int n ; private int nn ; private long[][] dp ; private boolean[][] gr ; private void solve()throws Throwable { n = nextInt(); nn = (1 << n); gr = new boolean[n][n]; dp = new long[n][nn]; for ( int i = 0;(i < n);i++) {Arrays.fill(dp[i],-1); } int m = nextInt(); for ( int i = 0;(i < m);i++) { int a = (nextInt() - 1),b = (nextInt() - 1); gr[a][b] = gr[b][a] = true; }for ( int i = 0;(i < n);i++) {dp[i][0] = 0; }for ( int mask = 1;(mask < nn);mask++) { int bCount = Integer.bitCount(mask); if ( (bCount < 2)) {dp[Integer.numberOfTrailingZeros(mask)][mask] = 0; } else if ( (bCount == 2)) { int msk = mask;  int one = Integer.numberOfTrailingZeros(msk); msk ^= (1 << one); int two = Integer.numberOfTrailingZeros(msk); dp[two][mask] = (gr[one][two]?1:0); } } long count = 0; for ( int mask = 1;(mask < nn);mask++) {if ( (Integer.bitCount(mask) < 3)) continue; int i = Integer.numberOfTrailingZeros(mask); for ( int j = (i + 1);(j < n);j++) { int jj = (1 << j); if ( (gr[i][j] && ((jj & mask) != 0))) {count += Dp(j,mask); } }}pw.println((count / 2)); } private long Dp( int j, int mask){ if ( (dp[j][mask] != -1)) return dp[j][mask]; int i = Integer.numberOfTrailingZeros(mask); assert (i < j); int m = (mask ^ (1 << j));  long ans = 0; for ( int p = (i + 1);(p < n);p++) {if ( !gr[p][j]) continue; if ( ((mask & (1 << p)) == 0)) continue; ans += Dp(p,m); }dp[j][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);} } }
6	public class cf8c{ static int n ; static int[] bb ; static int[] memo ; static int[][] cost ; static FastIO in = new FastIO(),out = in; public static void main( String[] args){ vec2 cen = new vec2(in.nextInt(),in.nextInt()); n = in.nextInt(); cost = new int[n][n]; vec2[] v = new vec2[n]; for ( int i = 0;(i < n);i++) v[i] = new vec2(in.nextInt(),in.nextInt()); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) cost[i][j] = ((v[i].dist(cen) + v[i].dist(v[j])) + v[j].dist(cen)); memo = new int[(1 << n)]; bb = new int[(1 << n)]; Arrays.fill(memo,-1); out.println(go(0)); build(0); out.close(); } static void build( int mask){ if ( (mask == ((1 << n) - 1))) {out.println(0); return ;} int first = 0; while(((mask & (1 << first)) != 0))first++; int second = bb[mask]; out.print((("0 " + (first + 1)) + " ")); if ( (second != first)) out.print(((second + 1) + " ")); build(((mask | (1 << first)) | (1 << second))); } static int go( int mask){ if ( (mask == ((1 << n) - 1))) return 0; if ( (memo[mask] != -1)) return memo[mask]; int first = 0;  int ans = Integer.MAX_VALUE; while(((mask & (1 << first)) != 0))first++; for ( int second = first;(second < n);second++) {if ( ((mask & (1 << second)) != 0)) continue; int tans = (cost[first][second] + go(((mask | (1 << first)) | (1 << second)))); if ( (tans < ans)) {ans = tans; bb[mask] = second; } }return memo[mask] = ans;} static class vec2{ int x ,y ; vec2( int a, int b){ x = a; y = b; } vec2 sub( vec2 v){ return new vec2((x - v.x),(y - v.y));} int dist( vec2 v){ return sub(v).mag2();} int mag2(){ return ((x * x) + (y * y));} } static class FastIO extends PrintWriter{ BufferedReader br ; StringTokenizer st ; public FastIO(){ this(System.in,System.out); } public FastIO( InputStream in, OutputStream out){ super(new BufferedWriter(new OutputStreamWriter(out))); br = new BufferedReader(new InputStreamReader(in)); scanLine(); } public void scanLine(){ try{st = new StringTokenizer(br.readLine().trim()); }catch (Exception e){ throw (new RuntimeException(e.getMessage()));} } public int numTokens(){ if ( !st.hasMoreTokens()) {scanLine(); return numTokens();} return st.countTokens();} public String next(){ if ( !st.hasMoreTokens()) {scanLine(); return next();} return st.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;  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.readInt();  int[] a = in.readIntArray(n); ArrayUtils.sort(a); boolean[] done = new boolean[n];  int answer = 0; for ( int i = 0;(i < n);i++) {if ( done[i]) {continue;} answer++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {done[j] = true; } }}out.printLine(answer); } } static interface IntStream extends Iterable<Integer>,Comparable<IntStream>{ public IntIterator intIterator(); } static interface IntComparator{ public static final IntComparator DEFAULT = (first,second)->{if ( (first < second)) {return -1;} if ( (first > second)) {return 1;} return 0;}; public int compare( int first, int second); } static class IntArray extends IntAbstractStream implements IntList{ private int[] data ; public IntArray( int[] arr){ data = arr; } public int size(){ return data.length;} public int get( int at){ return data[at];} public void addAt( int index, int value){ throw (new UnsupportedOperationException());} public void removeAt( int index){ throw (new UnsupportedOperationException());} public void set( int index, int value){ data[index] = value; } } static interface IntIterator{ public int value()throws NoSuchElementException ; public boolean advance(); public boolean isValid(); } 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[] readIntArray( int size){ int[] array = new int[size]; for ( int i = 0;(i < size);i++) {array[i] = readInt(); }return array;} 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 interface IntCollection extends IntStream{ public int size(); public default void add( int value){ throw (new UnsupportedOperationException());} public default IntCollection addAll( IntStream values){ for ( IntIterator it = values.intIterator();it.isValid();it.advance()) {add(it.value()); }return this;} } static interface IntReversableCollection extends IntCollection{ } static class IntArrayList extends IntAbstractStream implements IntList{ private int size ; private int[] data ; public IntArrayList(){ this(3); } public IntArrayList( int capacity){ data = new int[capacity]; } public IntArrayList( IntCollection c){ this(c.size()); addAll(c); } public IntArrayList( IntStream c){ this(); if ( (c instanceof IntCollection)) {ensureCapacity((IntCollection)c); } addAll(c); } public IntArrayList( IntArrayList c){ size = c.size(); data = c.data.clone(); } public IntArrayList( int[] arr){ size = arr.length; data = arr.clone(); } public int size(){ return size;} public int get( int at){ if ( (at >= size)) {throw (new IndexOutOfBoundsException(((("at = " + at) + ", size = ") + size)));} return data[at];} private void ensureCapacity( int capacity){ if ( (data.length >= capacity)) {return ;} capacity = Math.max((2 * data.length),capacity); data = Arrays.copyOf(data,capacity); } public void addAt( int index, int value){ ensureCapacity((size + 1)); if ( ((index > size) || (index < 0))) {throw (new IndexOutOfBoundsException(((("at = " + index) + ", size = ") + size)));} if ( (index != size)) {System.arraycopy(data,index,data,(index + 1),(size - index)); } data[index] = value; size++; } public void removeAt( int index){ if ( ((index >= size) || (index < 0))) {throw (new IndexOutOfBoundsException(((("at = " + index) + ", size = ") + size)));} if ( (index != (size - 1))) {System.arraycopy(data,(index + 1),data,index,((size - index) - 1)); } size--; } public void set( int index, int value){ if ( (index >= size)) {throw (new IndexOutOfBoundsException(((("at = " + index) + ", size = ") + size)));} data[index] = value; } } static interface IntList extends IntReversableCollection{ public abstract int get( int index); public abstract void set( int index, int value); public abstract void addAt( int index, int value); public abstract void removeAt( int index); public default void swap( int first, int second){ if ( (first == second)) {return ;} int temp = get(first); set(first,get(second)); set(second,temp); } public default IntIterator intIterator(){ return new IntIterator(){private int at ; private boolean removed ; public int value(){ if ( removed) {throw (new IllegalStateException());} return get(at);} public boolean advance(){ at++; removed = false; return isValid();} public boolean isValid(){ return (!removed && (at < size()));} };} public default void add( int value){ addAt(size(),value); } public default IntList sort( IntComparator comparator){ Sorter.sort(this,comparator); return this;} public default IntList subList(final int from,final int to){ return new IntList(){private final int shift ; private final int size ; {if ( (((from < 0) || (from > to)) || (to > this.size()))) {throw (new IndexOutOfBoundsException(((((("from = " + from) + ", to = ") + to) + ", size = ") + size())));} shift = from; size = (to - from); }public int size(){ return size;} public int get( int at){ if ( ((at < 0) || (at >= size))) {throw (new IndexOutOfBoundsException(((("at = " + at) + ", size = ") + size())));} return this.get((at + shift));} public void addAt( int index, int value){ throw (new UnsupportedOperationException());} public void removeAt( int index){ throw (new UnsupportedOperationException());} public void set( int at, int value){ if ( ((at < 0) || (at >= size))) {throw (new IndexOutOfBoundsException(((("at = " + at) + ", size = ") + size())));} this.set((at + shift),value); } };} } 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{ static Vector<Integer> primes ; public static void main( String[] args)throws IOException { InputReader myScanner = new InputReader();  int n = myScanner.nextInt(),k = myScanner.nextInt(); myScanner.hasNext(); int all[] = new int[n];  boolean numbers[] = new boolean[100100];  int diff[] = new int[n]; all[0] = myScanner.nextInt(); diff[0] = 1; numbers[all[0]] = true; int r = -1; if ( (k == 1)) r = 1; for ( int i = 1;(i < all.length);i++) {all[i] = myScanner.nextInt(); diff[i] = diff[(i - 1)]; if ( !numbers[all[i]]) {if ( ((r == -1) && ((diff[i] + 1) == k))) r = (i + 1); numbers[all[i]] = true; diff[i]++; } }if ( (r == -1)) System.out.println(((-1 + " ") + -1)); else {numbers = new boolean[100010]; int l = 0,cnt = 1; numbers[all[(r - 1)]] = true; if ( (k == 1)) System.out.println(((1 + " ") + 1)); else {for ( int i = (r - 2);(i >= 0);i--) {if ( !numbers[all[i]]) {numbers[all[i]] = true; cnt++; } if ( (cnt == k)) {l = (i + 1); break;} }System.out.println(((l + " ") + r)); }}} static class InputReader{ BufferedReader buff ; StringTokenizer tok ; String cur ; public InputReader()throws IOException{ buff = new BufferedReader(new InputStreamReader(System.in)); tok = new StringTokenizer(cur = buff.readLine()); } public boolean hasNext()throws IOException { if ( !tok.hasMoreElements()) {cur = buff.readLine(); if ( (cur == null)) return false; tok = new StringTokenizer(cur); } return true;} public String next()throws IOException { while(!tok.hasMoreElements())tok = new StringTokenizer(cur = buff.readLine()); return tok.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} } }
1	public class Cgr14{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader sc = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Solver solver = new Solver();  int t = sc.nextInt(); while((t-- != 0)){solver.solve(sc,out); }out.close(); } static class Solver{ public void solve( InputReader sc, PrintWriter out){ long n = sc.nextInt();  long l = 1;  long r = (long)1e5; while((l <= r)){ long mid = ((l + r) / 2);  long needed = ((mid * mid) * 2); if ( (needed == n)) {out.println("YES"); return ;} if ( (needed > n)) {r = (mid - 1); } else {l = (mid + 1); }}l = 1; r = (long)1e5; while((l <= r)){ long mid = ((l + r) / 2);  long needed = ((mid * mid) * 4); if ( (needed == n)) {out.println("YES"); return ;} if ( (needed > n)) {r = (mid - 1); } else {l = (mid + 1); }}out.println("NO"); } } static void sort( int[] arr){ Random rand = new Random();  int n = arr.length; for ( int i = 0;(i < n);i++) { int idx = rand.nextInt(n); if ( (idx == i)) continue; arr[i] ^= arr[idx]; arr[idx] ^= arr[i]; arr[i] ^= arr[idx]; }Arrays.sort(arr); } static void sort( long[] arr){ Random rand = new Random();  int n = arr.length; for ( int i = 0;(i < n);i++) { int idx = rand.nextInt(n); if ( (idx == i)) continue; arr[i] ^= arr[idx]; arr[idx] ^= arr[i]; arr[i] ^= arr[idx]; }Arrays.sort(arr); } static class InputReader{ private boolean finished = false; 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 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(){ 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 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));} 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();}} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } 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;} } }
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 A{ private class Pair{ public final int prob ; public final int time ; public Pair( int prob, int time){ this.prob = prob; this.time = time; } } private void solve()throws IOException { int n = nextInt();  int k = nextInt();  Pair[] p = new Pair[n]; for ( int i = 0;(i < n);i++) {p[i] = new Pair(nextInt(),nextInt()); }Arrays.sort(p,new Comparator<Pair>(){}); int time = p[(k - 1)].time;  int prob = p[(k - 1)].prob;  int res = 0; for ( int i = 0;(i < n);i++) {if ( ((p[i].time == time) && (p[i].prob == prob))) {res++; } }println(res); } private String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} private int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} private void print( Object o){ writer.print(o); } private void println( Object o){ writer.println(o); } private void printf( String format, Object... o){ writer.printf(format,o); } public static void main( String[] args){ long time = System.currentTimeMillis(); Locale.setDefault(Locale.US); new A().run(); System.err.printf("%.3f\n",(1e-3 * (System.currentTimeMillis() - time))); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; private void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (IOException e){ e.printStackTrace(); System.exit(13); } } }
4	public class Main{ public static void main( String[] args)throws FileNotFoundException,IOException { File file = new File("input.txt");  Scanner sc = new Scanner(file);  File outFile = new File("output.txt");  PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(outFile)));  int w = sc.nextInt();  int h = sc.nextInt();  boolean[][] map = new boolean[(h + 1)][(w + 1)];  int x = -1,y = -1;  Queue<Point> open = new LinkedList<Point>();  int k = sc.nextInt(); for ( int i = 0;(i < k);i++) { int tx = sc.nextInt();  int ty = sc.nextInt(); map[ty][tx] = true; x = tx; y = ty; open.add(new Point(x,y)); } int dx[] = {1,-1,0,0};  int dy[] = {0,0,1,-1}; while(!open.isEmpty()){ Point p = open.poll(); for ( int i = 0;(i < 4);i++) { int nx = (p.x + dx[i]);  int ny = (p.y + dy[i]); if ( (((((nx > 0) && (nx <= w)) && (ny > 0)) && (ny <= h)) && !map[ny][nx])) {map[ny][nx] = true; x = nx; y = ny; open.add(new Point(nx,ny)); } }}pw.println(((x + " ") + y)); pw.close(); } }
1	public class B{ public static void main( String[] args)throws IOException { InputReader in = new InputReader();  int n = in.nextInt();  int k = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); if ( (k > n)) {System.out.println(((-1 + " ") + -1)); return ;} int[] v = new int[100010];  int cnt = 0; for ( int i = 0;(i < k);i++) {if ( (v[a[i]] == 0)) {cnt++; } v[a[i]]++; } int i = k; while(((cnt < k) && (i < n))){if ( (v[a[i]] == 0)) {cnt++; } v[a[i]]++; i++; }if ( (cnt != k)) {System.out.println(((-1 + " ") + -1)); } else { int st = 0; while((((st < n) && (st < i)) && (v[a[st]] > 1))){v[a[st]]--; st++; }System.out.println((((st + 1) + " ") + i)); }} static class InputReader{ BufferedReader in ; StringTokenizer st ; public InputReader()throws IOException{ in = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(in.readLine()); } public String next()throws IOException { while(!st.hasMoreElements())st = new StringTokenizer(in.readLine()); return st.nextToken();} public int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(next());} } }
5	public class P166A{ public static void main( String[] args){ Scanner myScanner = new Scanner(System.in);  int n = myScanner.nextInt();  int k = myScanner.nextInt();  Team[] queue = new Team[n]; for ( int i = 0;(i < n);i++) {queue[i] = new Team(myScanner.nextInt(),myScanner.nextInt()); }Arrays.sort(queue); int counter = 0;  int i = 0;  int p = -1;  int t = -1; for ( ;(i < k);i++) {if ( ((p == queue[i].problems) && (t == queue[i].penalty))) counter++; else {p = queue[i].problems; t = queue[i].penalty; counter = 1; }}for ( ;(i < n);i++) {if ( ((p == queue[i].problems) && (t == queue[i].penalty))) counter++; else break;}System.out.println(counter); } static class Team implements Comparable<Team>{ int problems ; int penalty ; public Team( int problems, int penalty){ this.problems = problems; this.penalty = penalty; } } }
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){ final int SIZE = 256; final int UNDEF = -1;  int nPixels = in.nextInt();  int groupSize = in.nextInt();  int[] a = in.nextIntArray(nPixels);  boolean[] exists = new boolean[SIZE];  int[] left = new int[SIZE];  int[] right = new int[SIZE];  int[] ret = new int[nPixels]; Arrays.fill(ret,UNDEF); for ( int i = 0;(i < nPixels);i++) {for ( int p = 0;(p < SIZE);p++) {if ( ((exists[p] && (left[p] <= a[i])) && (a[i] <= right[p]))) {ret[i] = left[p]; left[a[i]] = left[p]; right[a[i]] = right[p]; break;} }if ( (ret[i] == UNDEF)) { int l = Math.max(((a[i] - groupSize) + 1),0);  int r = ((l + groupSize) - 1); for ( int p = (a[i] - 1);(p >= 0);p--) {if ( exists[p]) {if ( (p >= l)) { int d = (p - l); l = (p + 1); r += (d + 1); } if ( (right[p] >= l)) {right[p] = (l - 1); } } }for ( int p = (a[i] + 1);(p < SIZE);p++) {if ( (exists[p] && (left[p] <= r))) {r = (left[p] - 1); } }left[a[i]] = l; right[a[i]] = r; ret[i] = l; } exists[a[i]] = true; }out.print(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 print( int[] array){ for ( int i = 0;(i < array.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(array[i]); }} 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 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 interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
1	public class R364C{ public static void main( String[] args)throws NumberFormatException,IOException { Scanner s = new Scanner(System.in);  BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int n = Integer.parseInt(f.readLine());  char[] a = f.readLine().toCharArray();  int difTypes = 0;  TreeSet<Character> types = new TreeSet<Character>(); for ( int i = 0;(i < n);i++) {if ( !types.contains(a[i])) {types.add(a[i]); } } int i = 0,j = 0; difTypes = types.size(); int curTypes = 0;  int min = Integer.MAX_VALUE;  TreeSet<Character> has = new TreeSet<Character>();  HashMap<Character,Integer> freq = new HashMap<Character,Integer>(); while(((i < n) && (j < n))){has.add(a[j]); if ( !freq.containsKey(a[j])) {freq.put(a[j],1); } else {freq.put(a[j],(freq.get(a[j]) + 1)); }j++; curTypes = has.size(); if ( (curTypes == difTypes)) min = Math.min(min,(j - i)); while(((i < n) && (has.size() == difTypes))){ int Freq = freq.get(a[i]); if ( ((Freq - 1) == 0)) {has.remove(a[i]); freq.put(a[i],(freq.get(a[i]) - 1)); i++; break;} freq.put(a[i],(freq.get(a[i]) - 1)); i++; if ( (curTypes == difTypes)) min = Math.min(min,(j - i)); }curTypes = has.size(); }System.out.println(min); } }
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	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),md = sc.nextInt();  int k = ((n + 1) / 2);  int ans = 0;  int[][] dp = new int[(k + 1)][(n + 1)]; dp[0][0] = 1; for ( int h = 1;(h <= k);h++) for ( int l = h;(l <= ((n - h) + 1));l++) dp[h][l] = (int)((((dp[h][(l - 1)] * 2L) + dp[(h - 1)][(l - 1)]) * h) % md); for ( int h = 1;(h <= k);h++) ans = ((ans + dp[h][((n - h) + 1)]) % md); System.out.println(ans); } }
4	public class FireAgain{ static int dx[] = {0,0,1,-1}; static int dy[] = {1,-1,0,0}; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(new File("input.txt"));  BufferedWriter write = new BufferedWriter(new FileWriter("output.txt"));  int n = sc.nextInt();  int m = sc.nextInt();  boolean[][] v = new boolean[n][m];  int k = sc.nextInt();  Queue<Integer> q = new LinkedList<Integer>(); for ( int i = 0;(i < k);i++) { int x = (sc.nextInt() - 1);  int y = (sc.nextInt() - 1); q.add(x); q.add(y); v[x][y] = true; } int lastx = 0;  int lasty = 0; while(!q.isEmpty()){lastx = q.poll(); lasty = q.poll(); for ( int i = 0;(i < 4);i++) { int r = (lastx + dx[i]);  int c = (lasty + dy[i]); if ( (((((r >= 0) && (c >= 0)) && (r < n)) && (c < m)) && !v[r][c])) {v[r][c] = true; q.add(r); q.add(c); } }}write.write((((lastx + 1) + " ") + (lasty + 1))); write.close(); } }
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); }} }
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();} }
1	public class Main implements Runnable{ BufferedReader in ; PrintStream out ; StringTokenizer st = new StringTokenizer(""); static boolean local = false; public static void main( String[] args)throws Exception { if ( (args.length > 0)) local = true; new Thread(new Main()).start(); } boolean seekForToken(){ try{while(!st.hasMoreTokens()){ String s = in.readLine(); if ( (s == null)) {return false;} st = new StringTokenizer(s); }return true; }catch (IOException e){ e.printStackTrace(); return false;} } int nextInt(){ return Integer.parseInt(nextToken());} String nextToken(){ seekForToken(); return st.nextToken();} }
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;} static private 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 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 ; } }
2	public class Main{ class IO{ BufferedReader reader ; PrintWriter writer ; StringTokenizer tokenizer ; IO(){ reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(new BufferedOutputStream(System.out)); tokenizer = new StringTokenizer(""); } IO( String file)throws FileNotFoundException{ reader = new BufferedReader(new FileReader(file)); writer = new PrintWriter(new BufferedOutputStream(System.out)); tokenizer = new StringTokenizer(""); } String next()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){ String line = reader.readLine(); if ( (line == null)) return null; tokenizer = new StringTokenizer(line); }return tokenizer.nextToken();} public Long nextLong()throws IOException { return Long.parseLong(next());} public void write( Object obj){ writer.print(obj.toString()); } public void close(){ writer.close(); } } IO io ; Main(){ io = new IO(); } Main( String file)throws FileNotFoundException{ io = new IO(file); } void solve()throws IOException { long n = io.nextLong(),s = io.nextLong();  long min = s; while(true){min++; long sum = 0,tem = min; while((tem > 0)){sum += (tem % 10); tem /= 10; }if ( ((min - sum) >= s)) break; }io.write(Math.max(0,((n - min) + 1))); } void close(){ io.close(); } public static void main( String[] args)throws IOException { Main solver = new Main(); solver.solve(); solver.close(); } }
4	public class teama{ static int mod = 2_000_000_007; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  int T = Integer.parseInt(br.readLine()); for ( int t = 0;(t < T);t++) { int N = Integer.parseInt(br.readLine());  Stack<Integer> stack = new Stack(); for ( int i = 0;(i < N);i++) { int a = Integer.parseInt(br.readLine()); if ( (a != 1)) {while(((stack.peek() + 1) != a)){stack.pop(); }stack.pop(); } stack.push(a); boolean dummy = false; for ( int j :stack) {if ( dummy) {pw.print("."); } pw.print(j); dummy = true; }pw.println(); }}pw.close(); br.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]; 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]) dp[mask][i] += dp[(mask ^ (1 << i))][j]; }}} long answer = 0; for ( int mask = 1;(mask < (1 << n));mask++) {if ( (Integer.bitCount(mask) < 3)) continue; int first = Integer.numberOfTrailingZeros(mask); for ( int i = 0;(i < n);i++) {if ( graph[first][i]) answer += dp[mask][i]; }}System.out.println((answer / 2)); scan.close(); } }
3	public class _909C{ static private final int MOD = 1000000007; static private 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(); } }
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();} } }
3	public class Main{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt();  Integer[] a = new Integer[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); int ans = 0;  boolean[] taken = new boolean[n]; Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( taken[i]) continue; ans++; for ( int j = i;(j < n);j++) if ( ((a[j] % a[i]) == 0)) taken[j] = true; }out.println(ans); out.flush(); out.close(); } 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();} } }
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());} } }
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 KF{ public static void main( String[] args)throws IOException { B jk = new B(); } } class B{ PrintWriter out = new PrintWriter(System.out); Scanner in = new Scanner(System.in); long l = in.nextLong(); long r = in.nextLong(); B(){ if ( (Math.abs((r - l)) >= 2)) {if ( ((l % 2) == 0)) {out.print(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else {if ( (Math.abs((r - l)) == 2)) {out.print("-1"); } else {out.print((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); }}} else {out.print("-1"); }out.flush(); } }
6	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),m = sc.nextInt();  int g[] = new int[(1 << m)];  StringBuffer s = new StringBuffer(sc.next()); s = s.insert(0,'A'); int D = ((1 << m) - 1); for ( int i = 1;(i < n);i++) { int x = (s.charAt(i) - 'a'),y = (s.charAt((i + 1)) - 'a'); if ( (x != y)) g[((1 << x) | (1 << y))]++; }for ( int j = 0;(j < m);j++) for ( int i = 0;(i <= D);i++) if ( (((i >> j) & 1) != 0)) g[i] += g[(i ^ (1 << j))];  int f[] = new int[(1 << m)]; Arrays.fill(f,(Integer.MAX_VALUE / 2)); f[0] = 0; for ( int i = 0;(i <= D);i++) for ( int j = 0;(j < m);j++) if ( (((i >> j) & 1) == 0)) f[(i | (1 << j))] = Math.min(f[(i | (1 << j))],(((f[i] + g[D]) - g[i]) - g[(D ^ i)])); System.out.println(f[D]); } }
2	@SuppressWarnings("unchecked") public class P1177B{ public void run()throws Exception { for ( long k = (nextLong() - 1),d = 1,dc = 9,sv = 1;true;k -= dc,d++,sv *= 10,dc = ((sv * d) * 9)) {if ( (k <= dc)) {println(Long.toString((sv + (k / d))).charAt((int)(k % d))); break;} }} public static void main( String... args)throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedOutputStream(System.out)); new P1177B().run(); br.close(); pw.close(); System.err.println((("\n[Time : " + (System.currentTimeMillis() - startTime)) + " ms]")); long gct = 0,gcc = 0; for ( GarbageCollectorMXBean garbageCollectorMXBean :ManagementFactory.getGarbageCollectorMXBeans()) {gct += garbageCollectorMXBean.getCollectionTime(); gcc += garbageCollectorMXBean.getCollectionCount(); }System.err.println((((("[GC time : " + gct) + " ms, count = ") + gcc) + "]")); } 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();} void flush(){ pw.flush(); } }
0	public class Main{ public static void main( String[] YAHIA_MOSTAFA){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(),x = sc.nextLong(),y = sc.nextLong();  long xb ,xw ,yb ,yw ; xw = (x - 1); yw = (y - 1); xb = (n - x); yb = (n - y); if ( ((x == n) && (y == n))) {System.out.println("Black"); return ;} long c1 = 0,c2 = 0;  long f = Math.max(xb,yb);  long h = Math.max(xw,yw); if ( (h <= f)) System.out.println("White"); else System.out.println("Black"); } }
4	public class B{ static int[][] hor ; static int[][] ver ; static int n ; static int m ; static int k ; static long[][][] dp ; static long dist( int row, int col){ if ( ((k % 2) == 1)) return Integer.MAX_VALUE; return (2 * make(row,col,(k / 2)));} static long make( int row, int col, int moves){ if ( (moves == 0)) {return 0;} if ( (dp[row][col][moves] != -1)) return dp[row][col][moves]; long ans = Long.MAX_VALUE; if ( ((col - 1) >= 0)) {ans = Math.min(ans,(hor[row][(col - 1)] + make(row,(col - 1),(moves - 1)))); } if ( ((col + 1) < m)) {ans = Math.min(ans,(hor[row][col] + make(row,(col + 1),(moves - 1)))); } if ( ((row - 1) >= 0)) {ans = Math.min(ans,(ver[(row - 1)][col] + make((row - 1),col,(moves - 1)))); } if ( ((row + 1) < n)) {ans = Math.min(ans,(ver[row][col] + make((row + 1),col,(moves - 1)))); } dp[row][col][moves] = ans; return ans;} public static void main( String[] args){ FastScanner fs = new FastScanner();  PrintWriter out = new PrintWriter(System.out); n = fs.nextInt(); m = fs.nextInt(); k = fs.nextInt(); hor = new int[n][m]; ver = new int[n][m]; dp = new long[505][505][24]; for ( int i = 0;(i < 505);i++) for ( int j = 0;(j < 505);j++) for ( int k = 0;(k < 24);k++) dp[i][j][k] = -1; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) { int a = fs.nextInt(); hor[i][j] = a; }}for ( int row = 0;(row < (n - 1));row++) {for ( int col = 0;(col < m);col++) { int a = fs.nextInt(); ver[row][col] = a; }}for ( int row = 0;(row < n);row++) {for ( int col = 0;(col < m);col++) { long d = dist(row,col); if ( (d < Integer.MAX_VALUE)) {out.print((d + " ")); } else out.print("-1 "); }out.println(); }out.close(); } 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());} } public static int[] sort( int[] arr){ List<Integer> temp = new ArrayList(); for ( int i :arr) temp.add(i); Collections.sort(temp); int start = 0; for ( int i :temp) arr[start++] = i; return arr;} }
0	public class helloWorld{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int a = in.nextInt();  int b = in.nextInt();  int c = in.nextInt();  int n = in.nextInt();  int ans = (n - ((a + b) - c)); if ( (((((ans < 1) || (a >= n)) || (b >= n)) || (c > a)) || (c > b))) ans = -1; System.out.println(ans); in.close(); } }
1	public class Main{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int m = scan.nextInt();  int[] game = new int[n];  int[] bill = new int[m]; for ( int i = 0;(i < n);i++) {game[i] = scan.nextInt(); }for ( int i = 0;(i < m);i++) {bill[i] = scan.nextInt(); } int i = 0;  int j = 0;  int ans = 0; while((i < m)){ boolean f = true; for ( int k = j;(k < n);k++) {if ( (bill[i] >= game[k])) {ans++; i++; j = (k + 1); f = false; break;} }if ( f) {break;} }System.out.println(ans); } }
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)); } static private 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());} }
1	public class X{ 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 s2 = br.readLine();  int i = 0;  char c1 ,c2 ;  int cost = 0; while((i < n)){c1 = s1.charAt(i); c2 = s2.charAt(i); if ( (c1 != c2)) {if ( ((((i + 1) < n) && (s1.charAt((i + 1)) != s2.charAt((i + 1)))) && (s1.charAt(i) != s1.charAt((i + 1))))) {cost += 1; i++; } else {cost += 1; }} i++; }System.out.println(cost); } }
5	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] wide = new int[n],sta = new int[n];  HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {wide[i] = sc.nextInt(); hm.put(wide[i],(i + 1)); }Util.sort(wide); sc.nextLine(); String s = sc.nextLine();  int tp = 0,pos = 0;  StringBuilder out = new StringBuilder(); for ( int i = 0;(i < s.length());i++) { int t ; if ( (s.charAt(i) == '0')) {t = wide[pos++]; sta[tp++] = t; } else t = sta[--tp]; out.append((hm.get(t) + " ")); }System.out.println(out.toString()); sc.close(); } }
3	public class lc1 implements Runnable{ 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 interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new lc1(),"lc1",(1 << 26)).start(); } }
1	public class B{ static final int[] num = new int[7]; {for ( int i = 1,c = 1;(i <= 6);i++,c *= 26) num[i] = (num[(i - 1)] + c); }public void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); while((n-- > 0)){ String s = sc.next(); System.out.println((s.matches("R[0-9]+C[0-9]+")?toABdd(s):toRC(s))); }} String toRC( String s){ String ss = s.split("[0-9]+")[0];  String sn = s.split("[A-Z]+")[1];  int r = 0; for ( char c :ss.toCharArray()) r = (((r * 26) + c) - 'A'); r += num[ss.length()]; int c = Integer.parseInt(sn); return ((("R" + c) + "C") + r);} String toABdd( String s){ String[] ss = s.split("[RC]");  int c = Integer.parseInt(ss[1]);  int r = Integer.parseInt(ss[2]);  int a = 0; while((r > num[++a]));a--; r -= num[a]; char[] cs = new char[a]; for ( int i = 0;(i < a);i++,r /= 26) cs[((a - i) - 1)] = (char)((r % 26) + 'A'); return (new String(cs) + c);} public static void main( String... args){ new B().run(); } }
3	public class C{ public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int n = in.nextInt();  double r = in.nextInt();  double[] x = new double[(n + 1)];  double[] y = new double[(n + 1)]; for ( int i = 1;(i <= n);i++) {x[i] = in.nextInt(); } int[] lastx = new int[1001]; for ( int i = 1;(i <= n);i++) { double s = (x[i] - r),e = (x[i] + r); for ( int j = (int)Math.max(0,s);(j <= (int)Math.min(1000,e));j++) {if ( (lastx[j] == 0)) {y[i] = Math.max(y[i],findY(x[i],x[i],(0 - r),(2 * r))); } else {y[i] = Math.max(y[i],findY(x[lastx[j]],x[i],y[lastx[j]],(2 * r))); }lastx[j] = i; }}for ( int i = 1;(i <= n);i++) {out.println(y[i]); }out.close(); } public static double findY( double x1, double x2, double y1, double d){ return Math.max((y1 + Math.sqrt(((((-1 * Math.pow(x1,2)) + ((2 * x1) * x2)) + Math.pow(d,2)) - Math.pow(x2,2)))),(y1 - Math.sqrt(((((-1 * Math.pow(x1,2)) + ((2 * x1) * x2)) + Math.pow(d,2)) - Math.pow(x2,2)))));} 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();} } }
6	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();  int k = Int();  int A[][] = new int[n][2];  int a = 0,b = 0,c = 0; for ( int i = 0;(i < A.length);i++) {A[i][0] = Int(); A[i][1] = (Int() - 1); if ( (A[i][1] == 0)) a++; else if ( (A[i][1] == 1)) b++; else c++; }Arrays.sort(A,(x,y)->{return (x[0] - y[0]);}); Solution sol = new Solution(out); sol.solution(A,k,a,b,c); }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; } int mod = 1000000007; long dp3[][][][] ; public void solution( int[][] A, int T, int x, int y, int z){ long res = 0;  int n = A.length;  long dp1[][] = new long[(x + 2)][(T + 1)];  long dp2[][][] = new long[(y + 2)][(z + 2)][(T + 2)]; dp3 = new long[(x + 2)][(y + 2)][(z + 2)][3]; long f[] = new long[(n + 10)]; f[0] = f[1] = 1; for ( int i = 2;(i < f.length);i++) {f[i] = (f[(i - 1)] * i); f[i] %= mod; }for ( int i = 0;(i < dp3.length);i++) {for ( int j = 0;(j < dp3[0].length);j++) {for ( int k = 0;(k < dp3[0][0].length);k++) {Arrays.fill(dp3[i][j][k],-1); }}}dp1[0][0] = 1; for ( int i = 0;(i < A.length);i++) { int p = A[i][0],type = A[i][1]; if ( (type == 0)) { long newdp[][] = new long[dp1.length][dp1[0].length]; for ( int cnt = 1;(cnt <= x);cnt++) {for ( int j = 1;(j < dp1[0].length);j++) {if ( (j >= p)) {newdp[cnt][j] += dp1[(cnt - 1)][(j - p)]; newdp[cnt][j] %= mod; } }}for ( int cnt = 0;(cnt <= x);cnt++) {for ( int j = 0;(j < dp1[0].length);j++) {newdp[cnt][j] += dp1[cnt][j]; newdp[cnt][j] %= mod; }}dp1 = newdp; } }dp2[0][0][0] = 1; for ( int i = 0;(i < A.length);i++) { int p = A[i][0],type = A[i][1]; if ( (type != 0)) { long newdp[][][] = new long[dp2.length][dp2[0].length][dp2[0][0].length]; for ( int a = 0;(a < dp2.length);a++) {for ( int b = 0;(b < dp2[0].length);b++) {for ( int j = 0;(j < dp2[0][0].length);j++) {if ( (j >= p)) {if ( (type == 1)) {if ( ((a - 1) >= 0)) {newdp[a][b][j] += dp2[(a - 1)][b][(j - p)]; } } else {if ( ((b - 1) >= 0)) {newdp[a][b][j] += dp2[a][(b - 1)][(j - p)]; } }} newdp[a][b][j] %= mod; }}}for ( int a = 0;(a < dp2.length);a++) {for ( int b = 0;(b < dp2[0].length);b++) {for ( int j = 0;(j < dp2[0][0].length);j++) {newdp[a][b][j] += dp2[a][b][j]; newdp[a][b][j] %= mod; }}}dp2 = newdp; } }dp3[1][0][0][0] = 1; dp3[0][1][0][1] = 1; dp3[0][0][1][2] = 1; for ( int i = 0;(i < dp3.length);i++) {for ( int j = 0;(j < dp3[0].length);j++) {for ( int k = 0;(k < dp3[0][0].length);k++) {for ( x = 0;(x < dp3[0][0][0].length);x++) {if ( (dp3[i][j][k][x] == -1)) {dfs(i,j,k,x); } }}}}for ( int i = 0;(i < dp3.length);i++) {for ( int j = 0;(j < dp3[0].length);j++) {for ( int k = 0;(k < dp3[0][0].length);k++) {for ( int cur = 0;(cur < 3);cur++) {for ( int t = 0;(t <= T);t++) { int aprice = t;  int bcprice = (T - t);  long cnt1 = dp1[i][aprice];  long cnt2 = dp2[j][k][bcprice];  long combination = dp3[i][j][k][cur];  long p1 = ((cnt1 * f[i]) % mod);  long p2 = ((((f[j] * f[k]) % mod) * cnt2) % mod);  long p3 = ((p1 * p2) % mod); res += ((p3 * combination) % mod); res %= mod; }}}}}out.println(res); } public long dfs( int a, int b, int c, int cur){ if ( (((a < 0) || (b < 0)) || (c < 0))) {return 0;} if ( (((a == 0) && (b == 0)) && (c == 0))) {return 0;} if ( (dp3[a][b][c][cur] != -1)) return dp3[a][b][c][cur]; long res = 0; if ( (cur == 0)) {res += dfs((a - 1),b,c,1); res %= mod; res += dfs((a - 1),b,c,2); res %= mod; } else if ( (cur == 1)) {res += dfs(a,(b - 1),c,0); res %= mod; res += dfs(a,(b - 1),c,2); res %= mod; } else {res += dfs(a,b,(c - 1),0); res %= mod; res += dfs(a,b,(c - 1),1); res %= mod; }res %= mod; dp3[a][b][c][cur] = res; return res;} }
6	public class Main{ static int MOD = 1000000007; void solve()throws IOException { int[] nT = ril(2);  int n = nT[0];  int T = nT[1];  int[][] tg = new int[n][]; for ( int i = 0;(i < n);i++) tg[i] = ril(2); int[][][] dp = new int[(T + 1)][(1 << n)][3]; for ( int ti = 1;(ti <= T);ti++) {for ( int mask = 1;(mask <= (1 << n));mask++) {for ( int j = 0;(j < n);j++) {if ( (((1 << j) & mask) == 0)) continue; int time = tg[j][0];  int genre = (tg[j][1] - 1); if ( ((ti - time) < 0)) continue; long base = dp[ti][mask][genre];  long add = 0; if ( ((ti - time) == 0)) {add = 1; } else {for ( int g = 0;(g < 3);g++) add += dp[(ti - time)][(mask ^ (1 << j))][g]; add -= dp[(ti - time)][(mask ^ (1 << j))][genre]; }dp[ti][mask][genre] = (int)((base + add) % MOD); }}} long ans = 0; for ( int g = 0;(g < 3);g++) ans += dp[T][((1 << n) - 1)][g]; pw.println((ans % MOD)); } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); public static void main( String[] args)throws IOException { Main m = new Main(); m.solve(); m.close(); } void close()throws IOException { pw.flush(); pw.close(); br.close(); } int[] ril( int n)throws IOException { int[] nums = new int[n];  int c = 0; for ( int i = 0;(i < n);i++) { int sign = 1; c = br.read(); int x = 0; if ( (c == '-')) {sign = -1; c = br.read(); } while(((c >= '0') && (c <= '9'))){x = (((x * 10) + c) - '0'); c = br.read(); }nums[i] = (x * sign); }while(((c != '\n') && (c != -1)))c = br.read(); return nums;} long[] rll( int n)throws IOException { long[] nums = new long[n];  int c = 0; for ( int i = 0;(i < n);i++) { int sign = 1; c = br.read(); long x = 0; if ( (c == '-')) {sign = -1; c = br.read(); } while(((c >= '0') && (c <= '9'))){x = (((x * 10) + c) - '0'); c = br.read(); }nums[i] = (x * sign); }while(((c != '\n') && (c != -1)))c = br.read(); return nums;} void sort( int[] A){ Random r = new Random(); for ( int i = (A.length - 1);(i > 0);i--) { int j = r.nextInt((i + 1));  int temp = A[i]; A[i] = A[j]; A[j] = temp; }Arrays.sort(A); } }
6	public class E{ static double[] dp ; static int[] oneCount ; static int end ; static int n ; static double[][] prob ; public static double solve( int mask){ if ( (mask == end)) return 1; int oneC = 0,zeroC = 0; for ( int i = 0;(i < n);i++) {if ( ((mask | (1 << i)) == mask)) oneC++; else zeroC++; } double res = 0; for ( int i = 0;(i < n);i++) {if ( ((mask | (1 << i)) != mask)) continue; for ( int j = 0;(j < n);j++) {if ( ((mask | (1 << j)) == mask)) continue; res += (((1.0 / ((oneC * (oneC + 1)) / 2)) * prob[i][j]) * solve((mask | (1 << j)))); }}return dp[mask] = res;} public static void main( String[] args){ 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(); dp = new double[(1 << n)]; oneCount = new int[(1 << n)]; int c ; for ( int i = 0;(i < dp.length);i++) {c = 0; for ( int j = 0;(j < n);j++) {if ( ((i | (1 << j)) == i)) c++; }oneCount[i] = c; }end = ((1 << n) - 1); double res ,rad ;  int count ; for ( int k = end;(k > 0);k--) {if ( (k == end)) dp[k] = 1; else {res = 0; count = oneCount[k]; count = (count * (count + 1)); count >>= 1; rad = (1.0 / count); for ( int i = 0;(i < n);i++) {if ( ((k | (1 << i)) != k)) continue; for ( int j = 0;(j < n);j++) {if ( ((k | (1 << j)) == k)) continue; res += ((rad * prob[i][j]) * dp[(k | (1 << j))]); }}dp[k] = res; }}for ( int i = 0;(i < n);i++) System.out.print((dp[(1 << i)] + " ")); } }
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());} }
5	public class Solution{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; boolean isCross( double l1, double r1, double l2, double r2){ double r = min(r1,r2);  double l = max(l1,l2); return (r > l);} boolean check( double xl, double xr, double[] l, double[] r, int n){ boolean ok = false; for ( int j = 0;(j < n);++j) ok |= isCross(xl,xr,l[j],r[j]); return ok;} void solve()throws IOException { int n = ni();  double t = ni();  double[] l = new double[n];  double[] r = new double[n]; for ( int i = 0;(i < l.length);i++) { double x = ni();  double len = ni(); l[i] = (x - (len / 2.0)); r[i] = (x + (len / 2.0)); } HashSet<Double> set = new HashSet<Double>(); for ( int i = 0;(i < n);++i) { double xl = (l[i] - t);  double xr = l[i];  boolean ok = check(xl,xr,l,r,n); if ( !ok) set.add(xl); xl = r[i]; xr = (r[i] + t); ok = check(xl,xr,l,r,n); if ( !ok) set.add(xl); }out.println(set.size()); } public Solution()throws IOException{ Locale.setDefault(Locale.US); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); in.close(); out.close(); } String ns()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} int ni()throws IOException { return Integer.valueOf(ns());} public static void main( String[] args)throws IOException { new Solution(); } }
3	public class A{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = na(n); Arrays.sort(a); boolean[] done = new boolean[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( !done[i]) {ans++; for ( int j = (i + 1);(j < n);j++) {if ( ((a[j] % a[i]) == 0)) {done[j] = true; } }} }out.println(ans); } 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]; 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 Main{ public static void process()throws IOException { int n = ni();  int[] A = new int[n];  int point = -1; for ( int _i = 0;(_i < n);_i++) { int x = ni(); if ( (x == 1)) {point++; A[point] = 1; } else {while((x != (A[point] + 1))){A[point] = 0; point--; }}A[point] = x; for ( int i = 0;(i < point);i++) p((A[i] + ".")); pn(A[point]); }} static AnotherReader sc ; static PrintWriter out ; public static void main( String[] args)throws IOException { boolean oj = (System.getProperty("ONLINE_JUDGE") != null); if ( oj) {sc = new AnotherReader(); out = new PrintWriter(System.out); } else {sc = new AnotherReader(100); out = new PrintWriter("output.txt"); } int t = 1; t = ni(); while((t-- > 0)){process(); }out.flush(); out.close(); } static void pn( Object o){ out.println(o); } static void p( Object o){ out.print(o); } static int ni()throws IOException { return sc.nextInt();} static long nl()throws IOException { return sc.nextLong();} static long gcd( long a, long b)throws IOException { return ((b == 0)?a:gcd(b,(a % b)));} static int gcd( int a, int b)throws IOException { return ((b == 0)?a:gcd(b,(a % b)));} static int bit( long n)throws IOException { return ((n == 0)?0:(1 + bit((n & (n - 1)))));} static class AnotherReader{ BufferedReader br ; StringTokenizer st ; AnotherReader()throws FileNotFoundException{ br = new BufferedReader(new InputStreamReader(System.in)); } AnotherReader( int a)throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt")); } String next()throws IOException { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }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());} String nextLine()throws IOException { String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} } }
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))); }}}} }
6	public class s11_d{ public static void main( String[] args)throws IOException { new s11_d().run(); } int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} StreamTokenizer in ; Writer writer ; Reader reader ; void run()throws IOException { boolean oj = (System.getProperty("ONLINE_JUDGE") != null); reader = (oj?new InputStreamReader(System.in,"ISO-8859-1"):new FileReader("input/is11_d.txt")); writer = new OutputStreamWriter(System.out,"ISO-8859-1"); in = new StreamTokenizer(new BufferedReader(reader)); PrintWriter out = new PrintWriter(writer);  int n = nextInt();  int e = nextInt();  boolean[][] is = new boolean[(n + 1)][(n + 1)]; for ( int i = 0;(i < e);i++) { int a = (nextInt() - 1);  int b = (nextInt() - 1); is[a][b] = true; is[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) && is[last][i])) {ways[((mask | (1 << (i - start))) >> 1)][(i - start)] += amm; } if ( is[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); }out.println(res); out.flush(); 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);  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){ long n = in.nextLong();  long s = in.nextLong(); if ( ((n - digitSum(n)) < s)) {out.println(0); return ;} long left = 0;  long right = n; while((left < right)){ long mid = (left + ((right - left) / 2)); if ( ((mid - digitSum(mid)) >= s)) {right = mid; } else {left = (mid + 1); }}out.println(((n - left) + 1)); } long digitSum( long a){ long result = 0; while((a > 0)){result += (a % 10); a /= 10; }return result;} } static class InputReader{ static private BufferedReader in ; static private StringTokenizer tok ; public InputReader( InputStream in){ this.in = new BufferedReader(new InputStreamReader(in)); } public long nextLong(){ return Long.parseLong(next());} public String next(){ try{while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); } }catch (IOException ex){ System.err.println(("An IOException was caught :" + ex.getMessage())); } return tok.nextToken();} } }
3	public class Loader{ static private final Scanner in = new Scanner(System.in); public static void main( String[] args){ int n = in.nextInt();  ArrayList<Integer> l = new ArrayList<>(); for ( int i = 0;(i < n);i++) {l.add(in.nextInt()); }Collections.sort(l); int k = 0; for ( int i = 0;(i < l.size());i++) {if ( (l.get(i) == 0)) continue; for ( int j = (i + 1);(j < l.size());j++) {if ( (l.get(j) == 0)) continue; if ( ((l.get(j) % l.get(i)) == 0)) {l.set(j,0); } }l.set(i,0); k++; }System.out.println(k); } }
6	public class realfast implements Runnable{ static private final int INF = (int)1e9; int time[] = new int[15]; int g[] = new int[15]; public void solve()throws IOException { int n = readInt();  int t = readInt(); for ( int i = 0;(i < n);i++) {time[i] = readInt(); g[i] = readInt(); } long dp[][] = new long[(int)Math.pow(2,n)][4]; for ( int i = 0;(i < (int)Math.pow(2,n));i++) {for ( int j = 0;(j <= 3);j++) dp[i][j] = -1; } long val = cal(dp,0,0,0,t); out.println(val); } public long cal( long[][] dp, int mask, int genre, int t, int T){ int val = dp.length; if ( (t > T)) {return 0;} if ( (t == T)) {return 1;} if ( (dp[mask][genre] != -1)) return dp[mask][genre]; dp[mask][genre] = 0; int i = 1;  int count = 0; while((i < val)){if ( (((i & mask) == 0) && (g[count] != genre))) {dp[mask][genre] = (((dp[mask][genre] % 1000000007) + (cal(dp,(mask | i),g[count],(t + time[count]),T) % 1000000007)) % 1000000007); } i = (2 * i); count++; }return dp[mask][genre];} public static void main( String[] args){ new Thread(null,new realfast(),"",(128 * (1L << 20))).start(); } static private final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); private BufferedReader reader ; private StringTokenizer tokenizer ; private PrintWriter out ; private String readString()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} @SuppressWarnings private int readInt()throws IOException { return Integer.parseInt(readString());} }
2	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(); } static class TaskB{ FastReader in ; PrintWriter out ; int n ; public void solve( int testNumber, FastReader in, PrintWriter out){ this.in = in; this.out = out; n = in.nextInt(); if ( ((n % 4) != 0)) {out.println("! -1"); return ;} int low = 0;  int high = (n >> 1); if ( (BValue(low) == 0)) {out.println(("! " + (low + 1))); return ;} int fSign = Integer.signum(BValue(low)); while(((high - low) > 1)){ int mid = ((high + low) >> 1);  int mSign = Integer.signum(BValue(mid)); if ( (mSign == 0)) {out.println(("! " + (mid + 1))); return ;} if ( (mSign == -fSign)) {high = mid; } else {low = mid; }}out.println("! -1"); } public int BValue( int index){ out.println(("? " + (index + 1))); out.flush(); int f = in.nextInt(); out.println(("? " + ((index + 1) + (n >> 1)))); out.flush(); int s = in.nextInt(); return (f - s);} } 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));} } }
0	public class again_25{ public static void main( String[] ar)throws IOException { long n ;  BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); n = Long.parseLong(br.readLine()); System.out.println("25"); } }
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(); } }
2	public class A{ InputStream is ; PrintWriter out ; String INPUT = ""; public static long pow( long a, long n, long mod){ long ret = 1;  int x = (63 - Long.numberOfLeadingZeros(n)); for ( ;(x >= 0);x--) {ret = ((ret * ret) % mod); if ( ((n << (63 - x)) < 0)) ret = ((ret * a) % mod); }return ret;} void solve(){ int n = ni(),m = ni(),K = ni(); if ( (m <= (((n / K) * (K - 1)) + (n % K)))) {out.println(m); } else { int mod = 1000000009;  int f = (m - (((n / K) * (K - 1)) + (n % K))); out.println((((((pow(2,(f + 1),mod) + mod) - 2) * K) + (m - (f * K))) % 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 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 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)); } }
2	public class OlyaAndMagicalSquare{ public static void solveCase( FastIO io){ int N = io.nextInt();  long K = io.nextLong();  CountMap cm = new CountMap(); cm.increment(N,BigInteger.ONE); long rem = K;  int moves = 1;  int sqSize = N; while((sqSize > 0)){ long need = ((1L << moves) - 1);  BigInteger biNeed = BigInteger.valueOf(need); cm.decrement(sqSize,biNeed); if ( (need > rem)) {break;} cm.increment((sqSize - 1),biNeed.multiply(BigInteger.valueOf(4))); rem -= need; ++moves; --sqSize; } BigInteger biRem = BigInteger.valueOf(rem); for ( int i = N;(i > 0);--i) { BigInteger have = cm.getCount(i); if ( (have.compareTo(biRem) >= 0)) {biRem = BigInteger.ZERO; break;} biRem = biRem.subtract(have); cm.decrement(i,have); cm.increment((i - 1),have.multiply(BigInteger.valueOf(4))); }if ( biRem.equals(BigInteger.ZERO)) {io.printf("YES %d\n",sqSize); } else {io.println("NO"); }} static private class CountMap extends HashMap<Integer,BigInteger>{ public void increment( int k, BigInteger v){ put(k,getCount(k).add(v)); } public void decrement( int k, BigInteger v){ BigInteger next = getCount(k).subtract(v); if ( next.equals(BigInteger.ZERO)) {remove(k); } else {put(k,next); }} public BigInteger getCount( int k){ return getOrDefault(k,BigInteger.ZERO);} } public static void solve( FastIO io){ int T = io.nextInt(); for ( int t = 0;(t < T);++t) {solveCase(io); }} public static class FastIO{ private InputStream reader ; private PrintWriter writer ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public FastIO( InputStream r, OutputStream w){ reader = r; writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(w))); } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = reader.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public String nextString(){ 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 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);} public int[] nextIntArray( int n){ return nextIntArray(n,0);} public int[] nextIntArray( int n, int off){ int[] arr = new int[(n + off)]; for ( int i = 0;(i < n);i++) {arr[(i + off)] = nextInt(); }return arr;} public long[] nextLongArray( int n){ return nextLongArray(n,0);} public long[] nextLongArray( int n, int off){ long[] arr = new long[(n + off)]; for ( int i = 0;(i < n);i++) {arr[(i + off)] = nextLong(); }return arr;} 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));} 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 printArray( int[] arr){ for ( int i = 0;(i < arr.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(arr[i]); }} public void printArray( long[] arr){ for ( int i = 0;(i < arr.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(arr[i]); }} public void printf( String format, Object... args){ print(String.format(format,args)); } public void flush(){ writer.flush(); } } public static void main( String[] args){ FastIO io = new FastIO(System.in,System.out); solve(io); io.flush(); } }
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());} } }
5	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } StreamTokenizer in ; PrintWriter out ; int nextInt()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)); solve(); out.flush(); } void solve()throws IOException { int N = nextInt();  int m = nextInt();  int k = nextInt();  ArrayList<Integer> ts = new ArrayList<Integer>(); for ( int i = 0;(i < N);i++) {ts.add(nextInt()); } int count = 0,pos = 0; Collections.sort(ts); int jj = (ts.size() - 1); while((m > k)){if ( ((jj < 0) || (k == 0))) {pos = 1; break;} else {k += (ts.get(jj) - 1); jj--; count++; }}if ( (pos == 0)) out.println(count); else out.println("-1"); } }
3	public class code5{ InputStream is ; PrintWriter out ; static long mod = (pow(10,9) + 7); static int dx[] = {0,0,1,-1},dy[] = {1,-1,0,0}; String arr[] ; long dp[][] ; void solve()throws IOException { int n = ni(); arr = new String[n]; for ( int i = 0;(i < n);i++) arr[i] = ns(); dp = new long[(n + 1)][(n + 1)]; dp[0][0] = 1; for ( int i = 0;(i < n);i++) { long next[] = new long[(n + 1)]; for ( int j = 0;(j <= i);j++) {if ( (arr[i].charAt(0) == 's')) {next[0] += dp[i][j]; next[(j + 1)] -= dp[i][j]; } else {next[(j + 1)] += dp[i][j]; next[(j + 2)] -= dp[i][j]; }} long count = 0; for ( int j = 0;(j < n);j++) {count += next[j]; count = ((count + mod) % mod); dp[(i + 1)][j] = count; }} long ans = 0; for ( int i = 0;(i < n);i++) {ans += dp[(n - 1)][i]; ans %= mod; }out.print(ans); } long rec( int index, int level){ if ( (index >= (arr.length - 1))) return 1; if ( (dp[index][level] != -1)) return dp[index][level]; dp[index][level] = 0; if ( (arr[index].charAt(0) == 's')) {dp[index][level] += rec((index + 1),level); dp[index][level] %= mod; if ( (level > 0)) {dp[index][level] += rec((index + 1),0); dp[index][level] %= mod; } } else {dp[index][level] += rec((index + 1),(level + 1)); dp[index][level] %= mod; }return dp[index][level];} double a[] ,b[] ,p ; ArrayList<Integer> al[] ; static long d ,x ,y ; void extendedEuclid( long A, long B){ if ( (B == 0)) {d = A; x = 1; y = 0; } else {extendedEuclid(B,(A % B)); long temp = x; x = y; y = (temp - ((A / B) * y)); }} public static void mergeSort( int[] arr, int l, int r){ if ( ((r - l) >= 1)) { int mid = ((l + r) / 2); mergeSort(arr,l,mid); mergeSort(arr,(mid + 1),r); merge(arr,l,r,mid); } } public static void merge( int[] arr, int l, int r, int mid){ int n1 = ((mid - l) + 1),n2 = (r - mid);  int left[] = new int[n1];  int right[] = new int[n2]; for ( int i = 0;(i < n1);i++) left[i] = arr[(l + i)]; for ( int i = 0;(i < n2);i++) right[i] = arr[((mid + 1) + i)]; int i = 0,j = 0,k = l; while(((i < n1) && (j < n2))){if ( (left[i] > right[j])) {arr[k++] = right[j++]; } else {arr[k++] = left[i++]; }}while((i < n1))arr[k++] = left[i++]; while((j < n2))arr[k++] = right[j++]; } public static void mergeSort( long[] arr, int l, int r){ if ( ((r - l) >= 1)) { int mid = ((l + r) / 2); mergeSort(arr,l,mid); mergeSort(arr,(mid + 1),r); merge(arr,l,r,mid); } } public static void merge( long[] arr, int l, int r, int mid){ int n1 = ((mid - l) + 1),n2 = (r - mid);  long left[] = new long[n1];  long right[] = new long[n2]; for ( int i = 0;(i < n1);i++) left[i] = arr[(l + i)]; for ( int i = 0;(i < n2);i++) right[i] = arr[((mid + 1) + i)]; int i = 0,j = 0,k = l; while(((i < n1) && (j < n2))){if ( (left[i] > right[j])) {arr[k++] = right[j++]; } else {arr[k++] = left[i++]; }}while((i < n1))arr[k++] = left[i++]; while((j < n2))arr[k++] = right[j++]; } public static long gcd( long x, long y){ if ( (y == 0)) return x; else return gcd(y,(x % y));} public static int gcd( int x, int y){ if ( (y == 0)) return x; return gcd(y,(x % y));} public static long gcdExtended( long a, long b, long[] x){ if ( (a == 0)) {x[0] = 0; x[1] = 1; return b;} long[] y = new long[2];  long gcd = gcdExtended((b % a),a,y); x[0] = (y[1] - ((b / a) * y[0])); x[1] = y[0]; return gcd;} 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;} void run()throws Exception { is = System.in; out = new PrintWriter(System.out); solve(); out.flush(); } public static void main( String[] args)throws Exception { new Thread(null,new Runnable(){public void run(){ try{new code5().run(); }catch (Exception e){ e.printStackTrace(); } } },"1",(1 << 26)).start(); } 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 long[] nl( int n){ long[] a = new long[n]; for ( int i = 0;(i < n);i++) a[i] = nl(); 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(){ 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(); }} }
2	public class B{ final int INF = 1_000_000_000; void solve(){ int n = readInt();  int k = readInt();  long l = 0;  long r = INF; while(((r - l) > 1)){ long m = ((r + l) >> 1); if ( ((((m * (m + 1)) / 2) + m) >= (k + n))) r = m; else l = m; }out.print((n - r)); } public static void main( String[] args){ new B().run(); } private void run(){ try{init(); solve(); out.close(); }catch (Exception e){ e.printStackTrace(); System.exit(-1); } } private BufferedReader in ; private StringTokenizer tok = new StringTokenizer(""); private PrintWriter out ; private void init(){ in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } private String readLine(){ try{return in.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} } private String readString(){ while(!tok.hasMoreTokens()){ String nextLine = readLine(); if ( (nextLine == null)) return null; tok = new StringTokenizer(nextLine); }return tok.nextToken();} private int readInt(){ return Integer.parseInt(readString());} private long readLong(){ return Long.parseLong(readString());} }
4	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; for ( int i = 1;(i < 40000);i++) squares.add((i * i)); while((tt++ < t)){ boolean res = solve(); }out.close(); } static HashSet<Integer> squares = new HashSet(); static boolean solve(){ long res = 0;  int n = sc.ni();  long m = sc.nl();  long[][][] dp = new long[2][(n + 3)][(n + 3)];  long[][][] dp2 = new long[2][(n + 3)][(n + 3)]; dp[0][2][1] = dp[1][2][2] = dp2[0][1][1] = 1L; for ( int i = 3;(i <= n);i++) { long[][] bef = dp[0];  long[][] aft = dp[1];  long[][] nbef = new long[(n + 3)][(n + 3)];  long[][] naft = new long[(n + 3)][(n + 3)]; for ( int len = 1;(len <= i);len++) {for ( int ind = 1;(ind <= len);ind++) {nbef[(len + 1)][1] += bef[len][ind]; nbef[(len + 1)][(ind + 1)] -= bef[len][ind]; naft[(len + 1)][(ind + 1)] += bef[len][ind]; naft[(len + 1)][(ind + 1)] += aft[len][ind]; nbef[(len + 1)][1] += (dp2[0][len][ind] + dp2[1][len][ind]); }}for ( int len = 1;(len <= i);len++) {for ( int ind = 1;(ind <= len);ind++) {nbef[len][ind] = (((nbef[len][ind] + nbef[len][(ind - 1)]) + (10000000L * m)) % m); naft[len][ind] = (((naft[len][ind] + naft[len][(ind - 1)]) + (10000000L * m)) % m); }}dp2 = dp; dp = new long[][][]{nbef,naft}; }for ( long[] row :dp[0]) for ( long i :row) res += i; for ( long[] row :dp[1]) for ( long i :row) res += i; out.println((res % m)); 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());} long nl(){ return Long.parseLong(next());} } }
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(); } }
5	public class Main{ public static void main( String[] args)throws IOException { Scanner c = new Scanner(System.in);  int n = c.nextInt();  int a = c.nextInt();  int b = c.nextInt();  int C[] = new int[n]; for ( int i = 0;(i < n);i++) C[i] = c.nextInt(); Arrays.sort(C); int petya = C[(n - a)]; System.out.println((C[(n - a)] - C[((n - a) - 1)])); } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Parser in = new Parser(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, Parser in, OutputWriter out){ long a = in.nextLong();  long b = in.nextLong();  long cnt = 0; while(((a != 0) && (b != 0))){if ( (a > b)) {cnt += (a / b); a %= b; } else {cnt += (b / a); b = (b % a); }}out.println(cnt); } } class Parser{ private BufferedReader din ; private StringTokenizer tokenizer ; public Parser( InputStream in){ din = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{tokenizer = new StringTokenizer(din.readLine()); }catch (Exception e){ throw (new UnknownError());} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} } class OutputWriter extends PrintWriter{ public OutputWriter( Writer out){ super(out); } public OutputWriter( OutputStream out){ super(out); } }
1	public class C{ public static void main( String[] args)throws IOException { File inputFile = new File("entradaC"); if ( inputFile.exists()) System.setIn(new FileInputStream(inputFile));  BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringBuilder out = new StringBuilder();  String line = ""; while(((line = in.readLine()) != null)){ int n = Integer.parseInt(line);  char[] p = in.readLine().toCharArray();  HashMap<Character,Integer> dif = new HashMap<>(); for ( int i = 0;(i < p.length);i++) dif.put(p[i],0); int ndif = dif.size();  int head = 0,tail = 0,cnt = 0,ans = Integer.MAX_VALUE,cur ; while((head < n)){cur = dif.get(p[head]); if ( (cur == 0)) cnt++; dif.put(p[head],(cur + 1)); head++; if ( (cnt == ndif)) ans = Math.min(ans,(head - tail)); while(((tail < head) && (cnt == ndif))){cur = dif.get(p[tail]); if ( (cur == 1)) cnt--; dif.put(p[tail],(cur - 1)); tail++; if ( (cnt == ndif)) ans = Math.min(ans,(head - tail)); }}if ( (ndif == 1)) ans = 1; out.append((ans + "\n")); }System.out.print(out); } }
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 int INF = (int)1e9; static int MAXN = ((int)4e5 + 5); static int MOD = ((int)1e9 + 7); static int q ,t ,n ,m ,k ; static double pi = Math.PI; void solve()throws IOException { n = in.nextInt(); m = in.nextInt(); k = in.nextInt(); int[][] right = new int[n][m],left = new int[n][m],up = new int[n][m],down = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {right[i][j] = in.nextInt(); left[i][(j + 1)] = right[i][j]; }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {down[i][j] = in.nextInt(); up[(i + 1)][j] = down[i][j]; }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print("-1 "); }out.println(); }return ;} int[][][] dp = new int[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {for ( int kk = 1;(kk <= k);kk++) {dp[i][j][kk] = INF; }}}for ( int step = 2;(step <= k);step += 2) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( (i != 0)) {dp[i][j][step] = Math.min(dp[i][j][step],(dp[(i - 1)][j][(step - 2)] + (up[i][j] * 2))); } if ( (i != (n - 1))) {dp[i][j][step] = Math.min(dp[i][j][step],(dp[(i + 1)][j][(step - 2)] + (down[i][j] * 2))); } if ( (j != 0)) {dp[i][j][step] = Math.min(dp[i][j][step],(dp[i][(j - 1)][(step - 2)] + (left[i][j] * 2))); } if ( (j != (m - 1))) {dp[i][j][step] = Math.min(dp[i][j][step],(dp[i][(j + 1)][(step - 2)] + (right[i][j] * 2))); } }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((dp[i][j][k] + " ")); }out.println(); }} 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); } }
2	public class Main{ public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } void solve(){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ScanReader in = new ScanReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  BSportMafia solver = new BSportMafia(); solver.solve(1,in,out); out.close(); } static class BSportMafia{ public long findsqrt( long a){ long b = (long)Math.sqrt(a); for ( long tt = Math.max(0,(b - 10));(tt <= (b + 10));tt++) if ( ((tt * tt) == a)) return tt; return -1;} public void solve( int testNumber, ScanReader in, PrintWriter out){ long n = in.scanInt();  long k = in.scanInt(); out.println((n - ((-3 + findsqrt((9 + (8 * (k + n))))) / 2))); } } 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
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); } }
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)); } }
1	public class Test{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String s = in.readLine();  String[] p = in.readLine().split(" ");  List<Integer> a = new ArrayList<Integer>(); for ( String k :p) {a.add(Integer.parseInt(k)); } int n = a.size();  int c1 = 0;  int c2 = 0;  int c1p = 0;  int c2p = 0; for ( int i = 0;(i < n);i++) {if ( ((a.get(i) % 2) == 0)) {c1++; c1p = i; } else {c2++; c2p = i; }}if ( (c1 < c2)) {System.out.println((c1p + 1)); } else {System.out.println((c2p + 1)); }} }
4	public class D_Rnd718_Explorer{ static int row ,col ; static int INF = 1_000_000_000; static int[] dx = {0,0,1,-1}; static int[] dy = {1,-1,0,0}; public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  String[] in = scan.readLine().split(" "); row = parse(in[0]); col = parse(in[1]); int k = parse(in[2]);  int[][] xMove = new int[row][(col - 1)]; for ( int i = 0;(i < row);i++) {in = scan.readLine().split(" "); for ( int j = 0;(j < (col - 1));j++) xMove[i][j] = parse(in[j]); } int[][] yMove = new int[(row - 1)][col]; for ( int i = 0;(i < (row - 1));i++) {in = scan.readLine().split(" "); for ( int j = 0;(j < col);j++) yMove[i][j] = parse(in[j]); } int[][] output = new int[row][col]; if ( ((k % 2) != 0)) fill(-1,output); else { Point[][] grid = new Point[row][col]; for ( int i = 0;(i < row);i++) for ( int j = 0;(j < col);j++) grid[i][j] = new Point(i,j); parseMoves(grid,xMove,yMove); solve(grid,k,output); }print(output,out); out.flush(); } static private void solve( Point[][] grid, int k, int[][] output){ int target = (k / 2);  int[][][] dist = new int[row][col][(k / 2)]; fill(dist,grid); for ( int steps = 1;(steps < target);steps++) {for ( int i = 0;(i < row);i++) {for ( int j = 0;(j < col);j++) {dist[i][j][steps] = getDist(i,j,steps,dist,grid); }}}for ( int i = 0;(i < row);i++) for ( int j = 0;(j < col);j++) output[i][j] = (dist[i][j][(target - 1)] << 1); } static private int getDist( int y, int x, int steps, int[][][] dist, Point[][] grid){ for ( int d = 0;(d < 4);d++) { int i = (y + dy[d]);  int j = (x + dx[d]); if ( valid(i,j)) {dist[y][x][steps] = Math.min(dist[y][x][steps],(dist[i][j][(steps - 1)] + grid[y][x].weight[d])); } }return dist[y][x][steps];} static private void fill( int[][][] dist, Point[][] grid){ for ( int i = 0;(i < row);i++) for ( int j = 0;(j < col);j++) for ( int s = 0;(s < dist[0][0].length);s++) dist[i][j][s] = INF; for ( int i = 0;(i < row);i++) for ( int j = 0;(j < col);j++) for ( int d = 0;(d < 4);d++) dist[i][j][0] = Math.min(dist[i][j][0],grid[i][j].weight[d]); } static private boolean valid( int y, int x){ return ((((y >= 0) && (x >= 0)) && (y < row)) && (x < col));} static private void parseMoves( Point[][] grid, int[][] xMove, int[][] yMove){ for ( int i = 0;(i < xMove.length);i++) {for ( int j = 0;(j < xMove[i].length);j++) {grid[i][j].weight[2] = xMove[i][j]; grid[i][(j + 1)].weight[3] = xMove[i][j]; }}for ( int i = 0;(i < yMove.length);i++) {for ( int j = 0;(j < yMove[i].length);j++) {grid[i][j].weight[0] = yMove[i][j]; grid[(i + 1)][j].weight[1] = yMove[i][j]; }}} static private void fill( int val, int[][] output){ for ( int i = 0;(i < output.length);i++) Arrays.fill(output[i],val); } static private void print( int[][] ray, PrintWriter out){ for ( int i = 0;(i < ray.length);i++) {out.print(ray[i][0]); for ( int j = 1;(j < ray[i].length);j++) out.print((" " + ray[i][j])); out.println(); }} public static int parse( String num){ return Integer.parseInt(num);} static class Point{ int[] weight = new int[4]; int x ,y ; public Point( int i, int j){ y = i; x = j; Arrays.fill(weight,INF); } } }
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"); }} }
4	public class SolutionC{ public static void main( String[] args)throws Exception { Scanner sc = new Scanner(new File("input.txt"));  PrintWriter output = new PrintWriter("output.txt");  int N = sc.nextInt();  int M = sc.nextInt();  int K = sc.nextInt();  int[] x = new int[K];  int[] y = new int[K]; for ( int i = 0;(i < K);i++) {x[i] = sc.nextInt(); y[i] = sc.nextInt(); } int max = -1,max_x = -1,max_y = -1; for ( int i = 1;(i <= N);i++) {for ( int j = 1;(j <= M);j++) { int min = Integer.MAX_VALUE; for ( int k = 0;(k < K);k++) {min = Math.min(min,(Math.abs((x[k] - i)) + Math.abs((y[k] - j)))); }if ( (min > max)) {max = min; max_x = i; max_y = j; } }}output.println(((max_x + " ") + max_y)); output.flush(); } }
2	public class B1177{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  Long n = Long.parseLong(br.readLine());  long[] p = new long[15];  int i ; p[0] = 1; for ( i = 1;(i < 15);p[i] = (p[(i - 1)] * 10),i++) ;for ( i = 1;(((i * p[(i - 1)]) * 9L) < n);n -= ((i * p[(i - 1)]) * 9L),i++) ;n--; int v = (int)(n % i); n /= i; n += p[(i - 1)]; String s = n.toString(); System.out.println(s.charAt(v)); } }
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();} } }
0	public class ProblemA_72{ 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 ProblemA_72().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(); out.print((n + (n / 2))); } }
2	public class ProblemC{ public static final String FILE_IN = "std.in"; public static final String FILE_OUT = "std.out"; static private boolean debugMode = true; static private 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(); } static private 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)); }} static private 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);}} }
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 GB_A{ FastScanner in ; PrintWriter out ; public static void main( String[] arg){ new GB_A().run(); } public void solve()throws IOException { int n = in.nextInt();  int r = in.nextInt();  int[] a = new int[n];  double[] ans = new double[n]; a[0] = in.nextInt(); ans[0] = r; for ( int i = 1;(i < n);i++) {a[i] = in.nextInt(); double max = r; for ( int j = (i - 1);(j >= 0);j--) {if ( (Math.abs((a[i] - a[j])) <= (2 * r))) { double d = (Math.sqrt((((4 * r) * r) - ((a[i] - a[j]) * (a[i] - a[j])))) + ans[j]); max = Math.max(max,d); } }ans[i] = max; }for ( int i = 0;(i < n);i++) {out.println(ans[i]); }} public void run(){ try{in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( BufferedReader bufferedReader){ br = new BufferedReader(new InputStreamReader(System.in)); } 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());} } }
4	public class Main{ static final int primeCount = 452; static final int[] prime = new int[primeCount]; static void build_prime(){ boolean[] notPrime = new boolean[3200]; for ( int i = 2;(i < 3200);i++) {if ( notPrime[i]) continue; for ( int j = (i * i);(j < 3200);j += i) {notPrime[j] = true; }} int count = 0; for ( int i = 2;(i < 3200);i++) {if ( notPrime[i]) continue; prime[count++] = i; }} static private void run( Reader in, PrintWriter out)throws IOException { int n = in.nextInt();  int m = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = getReal(in.nextInt()); } int[] pre = new int[n]; for ( int i = 0;(i < n);i++) pre[i] = -1; TreeMap<Integer,Integer> exist = new TreeMap<>(); for ( int i = 0;(i < n);i++) { Integer result = exist.get(a[i]); if ( (result != null)) {pre[i] = result; } exist.put(a[i],i); } int[][] left = new int[(m + 1)][n]; for ( int i = 0;(i <= m);i++) { int start = 0;  PriorityQueue<Integer> inSame = new PriorityQueue<>(); for ( int j = 0;(j < n);j++) {if ( (pre[j] >= start)) {inSame.add(pre[j]); if ( (inSame.size() > i)) {start = (inSame.poll() + 1); } } left[i][j] = start; }} int[][] dp = new int[n][(m + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= m);j++) {dp[i][j] = Integer.MAX_VALUE; }for ( int j = 0;(j <= m);j++) {for ( int k = 0;(k <= j);k++) {if ( (left[k][i] == 0)) {dp[i][j] = 1; } else {dp[i][j] = Math.min(dp[i][j],(dp[(left[k][i] - 1)][(j - k)] + 1)); }}}}out.println(dp[(n - 1)][m]); } static int getReal( int x){ int result = 1; for ( int i = 0;(i < primeCount);i++) {if ( ((x % prime[i]) == 0)) { int count = 0; while(((x % prime[i]) == 0)){count++; x /= prime[i]; }if ( ((count % 2) == 1)) {result *= prime[i]; } } }result *= x; return result;} public static void main( String[] args)throws IOException { Reader in = new Reader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); build_prime(); int t = in.nextInt(); for ( int i = 0;(i < t);i++) {run(in,out); }out.flush(); in.close(); out.close(); } static class Reader{ BufferedReader reader ; StringTokenizer st ; Reader( InputStreamReader stream){ reader = new BufferedReader(stream,32768); st = null; } void close()throws IOException { reader.close(); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(reader.readLine()); }catch (IOException e){ throw (new RuntimeException(e));} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
5	public class Task15a{ public static class House implements Comparable<House>{ int x ,s ; public House( int x, int s){ super(); this.x = x; this.s = s; } } public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int t = (sc.nextInt() * 2);  House[] hs = new House[n]; for ( int i = 0;(i < n);i++) {hs[i] = new House((sc.nextInt() * 2),sc.nextInt()); }Arrays.sort(hs); int res = 2; for ( int i = 0;(i < (n - 1));i++) { int curr = (((hs[(i + 1)].x - hs[i].x) - hs[(i + 1)].s) - hs[i].s); if ( (curr > t)) res += 2; if ( (curr == t)) res += 1; }System.out.println(res); } }
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);  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 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; }
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 + "")); } }
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(); } }
2	public class zz{ static int mod = ((int)1e9 + 7); public static void main( String[] args)throws Exception { MScanner sc = new MScanner(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  int k = sc.nextInt();  int x = ((-3 + (int)Math.sqrt((9 + ((4 * 1.0) * (((2 * k) * 1.0) + ((2 * n) * 1.0)))))) / 2); pw.println((n - x)); 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 A implements Runnable{ private MyScanner in ; private PrintWriter out ; private void solve(){ int n = in.nextInt();  int[] a = new int[n];  int all = 0; for ( int i = 0;(i < n);++i) {a[i] = in.nextInt(); all += a[i]; }Arrays.sort(a); int sum = 0,ans = 0; for ( int i = (n - 1);(i >= 0);--i) {sum += a[i]; ++ans; if ( (sum > (all - sum))) {break;} }out.println(ans); } @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(); } } public String next(){ 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(next());} } }
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;} }
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;} }
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(); } }
0	public class main{ public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static PrintWriter pw = new PrintWriter(System.out); public static String line ; public static StringTokenizer st ; public static ArrayList<ArrayList<Integer>> adjList ; public static void main( String[] args)throws Exception { String s = br.readLine(); pw.print(25); pw.print("\n"); pw.close(); br.close(); } }
1	public class A1{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  long size = scan.nextLong();  int numberOfSpecial = scan.nextInt();  long pageSize = scan.nextLong();  long[] specialItemsArray = new long[numberOfSpecial]; for ( int i = 0;(i < numberOfSpecial);i++) {specialItemsArray[i] = scan.nextLong(); } int totalRemoved = 0;  int step = 0;  long currentPageIndex = BigDecimal.valueOf(specialItemsArray[0]).divide(BigDecimal.valueOf(pageSize),2,RoundingMode.UP).setScale(0,RoundingMode.CEILING).longValue();  int specialItemArrayIndex = 1; while((specialItemArrayIndex < numberOfSpecial)){ long pageIndex = BigDecimal.valueOf((specialItemsArray[specialItemArrayIndex] - totalRemoved)).divide(BigDecimal.valueOf(pageSize),2,RoundingMode.UP).setScale(0,RoundingMode.CEILING).longValue(); if ( (currentPageIndex != pageIndex)) {step++; totalRemoved = specialItemArrayIndex; currentPageIndex = BigDecimal.valueOf((specialItemsArray[specialItemArrayIndex] - totalRemoved)).divide(BigDecimal.valueOf(pageSize),2,RoundingMode.UP).setScale(0,RoundingMode.CEILING).longValue(); } specialItemArrayIndex++; }System.out.println((step + 1)); } }
3	public class Codeforces911D{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] sp = br.readLine().split(" ");  int n = Integer.parseInt(sp[0]);  int[] a = new int[n]; sp = br.readLine().split(" "); for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(sp[i]); } int inversions = 0; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) {inversions++; } }}inversions = (inversions % 2); sp = br.readLine().split(" "); int m = Integer.parseInt(sp[0]); for ( int i = 0;(i < m);i++) {sp = br.readLine().split(" "); int l = Integer.parseInt(sp[0]);  int r = Integer.parseInt(sp[1]); if ( (((((r - l) + 1) % 4) == 2) || ((((r - l) + 1) % 4) == 3))) {inversions = (1 - inversions); } if ( (inversions == 1)) {System.out.println("odd"); } else {System.out.println("even"); }}} }
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 ; }
5	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int a[] = new int[n];  int b[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); for ( int i = 0;(i < n);i++) b[i] = sc.nextInt(); int c[] = new int[(2 * n)]; c[0] = a[0]; for ( int i = 1;(i < n);i++) {c[(i * 2)] = a[i]; c[((i * 2) - 1)] = b[i]; if ( ((a[i] == 1) || (b[i] == 1))) {System.out.print(-1); System.exit(0); } }c[((2 * n) - 1)] = b[0]; if ( ((a[0] == 1) || (b[0] == 1))) {System.out.print(-1); System.exit(0); } System.out.println(bin_search(c,m)); } static private double bin_search( int[] c, int m){ double start = 0;  double end = Integer.MAX_VALUE;  double mid ; while(((start + 0.0000001) < end)){mid = ((start + end) / 2); if ( test(mid,m,c)) end = mid; else start = mid; }return end;} static private boolean test( double fuel, int m, int[] c){ for ( int i = 0;(i < c.length);i++) {fuel -= ((m + fuel) / c[i]); if ( (fuel < 0)) {return false;} }return true;} }
0	public class Contest1_1{ public static void main( String[] ar)throws Exception { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));  int input = Integer.parseInt(buff.readLine()); if ( (input == 0)) {System.out.println("0 0 0"); } else if ( (input == 1)) {System.out.println("0 0 1"); } else if ( (input == 2)) {System.out.println("0 1 1"); } else if ( (input == 3)) {System.out.println("1 1 1"); } else { int output[] = checkFibo(input);  int get[] = checkFibo(output[1]); output[0] = get[1]; output[1] = get[2]; System.out.print(output[0]); System.out.print((" " + output[1])); System.out.println((" " + output[2])); }} public static int[] checkFibo( int input){ int output[] = new int[3];  int fibo_1 = 0;  int fibo_2 = 1;  int temp = 0; while((fibo_2 != input)){temp = fibo_2; output[1] = fibo_1; output[2] = fibo_2; fibo_2 += fibo_1; fibo_1 = temp; }return output;} }
0	public class Prob235A{ public static void main( String[] Args){ Scanner scan = new Scanner(System.in);  int x = scan.nextInt(); if ( (x < 3)) {if ( (x == 1)) System.out.println(1); else System.out.println(2); } else { long answer = x; if ( ((x % 2) == 1)) {answer *= (x - 1); answer *= (x - 2); } else if ( ((x % 3) != 0)) {answer *= (x - 1); answer *= (x - 3); } else {answer = (x - 1); answer *= (x - 2); answer *= (x - 3); }System.out.println(answer); }} }
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(),k = nextInt();  Team[] A = new Team[n]; for ( int i = 0;(i < n);i++) {A[i] = new Team(); A[i].p = nextInt(); A[i].t = nextInt(); }Arrays.sort(A); k--; int sum = 0; for ( int i = 0;(i < n);i++) if ( (A[k].compareTo(A[i]) == 0)) sum++; out.print(sum); out.close(); } class Team implements Comparable{ public int p ,t ; public int compareTo( Object obj){ Team a = (Team)obj; if ( ((p > a.p) || ((p == a.p) && (t < a.t)))) return -1; else if ( ((p == a.p) && (t == a.t))) return 0; else return 1;} } }
1	public class B{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  Pattern rc_style = Pattern.compile("R[0-9]+C[0-9]+");  int n = input.nextInt(); while((n-- > 0)){ String str = input.next();  Matcher m = rc_style.matcher(str); if ( m.matches()) { String nums[] = str.split("[RC]");  String row = nums[1];  String col = nums[2];  String buffer = "";  int col_num = Integer.valueOf(col); while((col_num > 0)){if ( ((col_num % 26) > 0)) {buffer += (char)(((col_num % 26) + 'A') - 1); col_num /= 26; } else {buffer += 'Z'; col_num /= 26; col_num--; }}for ( int i = (buffer.length() - 1);(i >= 0);--i) {System.out.print(buffer.charAt(i)); }System.out.println(row); } else { String col = str.split("[0-9]+")[0];  String row = str.split("[A-Z]+")[1];  int col_num = 0;  int shift = 1; for ( int i = (col.length() - 1);(i >= 0);--i) {col_num += ((int)((col.charAt(i) - 'A') + 1) * shift); shift *= 26; }System.out.println(((("R" + row) + "C") + col_num)); }}} }
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); 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 < 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();} }
1	public class phoenixandpuzzle{ public static void main( String[] args)throws IOException { BufferedReader fin = new BufferedReader(new InputStreamReader(System.in));  int t = Integer.parseInt(fin.readLine());  StringBuilder fout = new StringBuilder();  HashSet<Integer> dict = new HashSet<Integer>();  int pointer = 1;  int area = 0; while((area >= 0)){area = ((pointer * pointer) * 2); dict.add(area); pointer++; }pointer = 1; area = 0; while((area >= 0)){area = ((pointer * pointer) * 4); dict.add(area); pointer++; }while((t-- > 0)){ int n = Integer.parseInt(fin.readLine()); if ( dict.contains(n)) {fout.append("YES\n"); } else {fout.append("NO\n"); }}System.out.print(fout); } }
5	public class r114{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int a = sc.nextInt();  int b = sc.nextInt();  ArrayList<Integer> l = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {l.add(sc.nextInt()); }Collections.sort(l); int pet = l.get((n - a));  int vas = l.get((b - 1)); if ( (pet <= vas)) {System.out.println(0); } else System.out.println((pet - vas)); sc.close(); } }
5	public class R113_D2_A{ public static void main( String[] args)throws NumberFormatException,IOException { InputReader4 in = new InputReader4(System.in);  int n = in.readInt();  int k = in.readInt();  p[] inp = new p[n]; for ( int i = 0;(i < inp.length);i++) {inp[i] = new p(in.readInt(),in.readInt()); }Arrays.sort(inp); for ( int i = 0;(i < inp.length);) { int j = (i + 1); while((((j < inp.length) && (inp[i].x == inp[j].x)) && (inp[i].y == inp[j].y))){j++; } int num = (j - i); if ( (k <= num)) {System.out.println(num); return ;} else k -= num; i = j; }} static class p implements Comparable<p>{ int x ; int y ; public p( int a, int b){ x = a; y = b; } } static class InputReader4{ private InputStream stream ; private byte[] buf = new byte[1000]; private int curChar ,numChars ; public InputReader4( 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();} } }
2	public class Main{ public static void main( String[] args)throws Exception { FastReader sc = new FastReader();  OutputStream outputStream = System.out;  PrintWriter out = new PrintWriter(outputStream);  Main mm = new Main();  long n = sc.nextLong();  long k = sc.nextLong();  long l = 0;  long r = 1000000000;  long ans = -1; while((l <= r)){ long mid = ((l + r) / 2); if ( ((n - mid) <= 0)) {r = (mid - 1); } else { long temp = (((n - mid) * ((n - mid) + 1)) - (2 * mid)); if ( (temp == (2 * k))) {ans = mid; break;} else if ( (temp < (2 * k))) {r = (mid - 1); } else if ( (temp > (2 * k))) {l = (mid + 1); } }}System.out.println(ans); } } 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());} }
0	public class A235{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextInt(); if ( (n == 1)) {System.out.println(1); return ;} else if ( (n == 2)) {System.out.println(2); return ;} else if ( (n == 3)) {System.out.println(6); return ;} if ( ((n % 2) == 0)) {if ( ((n % 3) == 0)) System.out.println((((n - 1) * (n - 2)) * (n - 3))); else System.out.println((((n - 1) * n) * (n - 3))); } else {System.out.println(((n * (n - 1)) * (n - 2))); }} }
4	public class Main{ public static void main( String[] args){ FastReader input = new FastReader();  PrintWriter out = new PrintWriter(System.out);  int T = input.nextInt(); while((T-- > 0)){ int n = input.nextInt();  int b[] = new int[n]; for ( int i = 0;(i < n);i++) {b[i] = input.nextInt(); } StringBuilder sb = new StringBuilder("");  int arr[] = new int[(n + 1)]; out.println('1'); sb.append('1'); int size = 1; arr[(size - 1)] = 1; for ( int i = 1;(i < n);i++) { int a = b[i]; if ( (a == 1)) {size++; arr[(size - 1)] = 1; sb.append(".1"); out.println(sb.toString()); } else {sb = new StringBuilder(""); int in = 0; for ( int j = (size - 1);(j >= 0);j--) {if ( (arr[j] == (a - 1))) {in = j; break;} }for ( int j = 0;(j < in);j++) {sb.append((arr[j] + ".")); }sb.append(a); size = (in + 1); arr[(size - 1)] = a; out.println(sb.toString()); }}}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());} } }
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 Lcm{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter pw = new PrintWriter(System.out);  long n = Long.parseLong(br.readLine()); if ( (n <= 2)) pw.println(n); else {if ( ((n % 6) == 0)) {pw.println((((n - 1) * (n - 2)) * (n - 3))); } else if ( ((n % 2) == 0)) {pw.println(((n * (n - 1)) * (n - 3))); } else {pw.println(((n * (n - 1)) * (n - 2))); }}pw.flush(); } }
5	public class A{ public static void main( String[] Args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st ; st = new StringTokenizer(br.readLine()); int n = Integer.valueOf(st.nextToken());  int m = Integer.valueOf(st.nextToken());  int k = Integer.valueOf(st.nextToken()); st = new StringTokenizer(br.readLine()); int sock[] = new int[n]; for ( int i = 0;(i < n);i++) {sock[i] = Integer.valueOf(st.nextToken()); }Arrays.sort(sock); m -= k; int count = 0;  int index = (sock.length - 1); while((m > 0)){if ( (index < 0)) {System.out.println("-1"); return ;} m++; m -= sock[index]; index--; count++; }System.out.println(count); } }
3	public class Main{ BufferedReader br ; PrintWriter pw ; StringTokenizer st ; long mod = (long)(1e9 + 7); public static void main( String[] args){ new Main().run(); } void solve()throws IOException { int n = nextInt();  boolean p[] = new boolean[n]; for ( int i = 0;(i < n);i++) { String s = nextToken(); if ( (s.charAt(0) == 'f')) p[i] = true; } long d[][] = new long[n][n]; d[0][0] = 1; for ( int i = 1;(i < n);i++) {if ( p[(i - 1)]) {d[i][0] = 0; for ( int j = 1;(j < n);j++) {d[i][j] = d[(i - 1)][(j - 1)]; }} else { long sum = 0; for ( int j = (n - 1);(j >= 0);j--) {sum += d[(i - 1)][j]; sum %= mod; d[i][j] = sum; }}} long sum = 0; for ( int i = 0;(i < n);i++) {sum += d[(n - 1)][i]; sum %= mod; }pw.print(sum); } void run(){ try{br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new OutputStreamWriter(System.out)); solve(); pw.close(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(br.readLine()); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
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.nextLong();  long k = in.nextLong();  long b = ((2 * n) + 3);  long c = (((n * n) - (2 * k)) + n);  long d = ((b * b) - (4 * c));  long val = ((b - (long)Math.sqrt(d)) / 2); out.println(val); } } 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 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(); } }
0	public class D{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; double f( int dist, double initSp, int a, int maxSp){ double distToReachMaxSpeed = ((0.5 * ((maxSp * maxSp) - (initSp * initSp))) / a); if ( (dist > distToReachMaxSpeed)) return (((1d * (maxSp - initSp)) / a) + ((dist - distToReachMaxSpeed) / maxSp)); return ((Math.sqrt(((initSp * initSp) + ((2 * a) * dist))) - initSp) / a);} void solve()throws IOException { int a = nextInt();  int maxSp = nextInt();  int len = nextInt();  int signX = nextInt();  int signSp = nextInt(); if ( (maxSp <= signSp)) {out.printf("%.9f\n",f(len,0,a,maxSp)); return ;} double distToReachSignSp = (((0.5 * signSp) * signSp) / a); if ( (distToReachSignSp >= signX)) {out.printf("%.9f\n",f(len,0,a,maxSp)); return ;} double distToReachMaxThenSign = ((0.5 * (((maxSp * maxSp) + (maxSp * maxSp)) - (signSp * signSp))) / a); if ( (distToReachMaxThenSign <= signX)) { double t = ((((1d * ((2 * maxSp) - signSp)) / a) + ((signX - distToReachMaxThenSign) / maxSp)) + f((len - signX),signSp,a,maxSp)); out.printf("%.9f\n",t); return ;} double xSp = Math.sqrt(((a * signX) + ((signSp * signSp) * 0.5)));  double xTime = (((2 * xSp) - signSp) / a); out.printf("%.9f\n",(xTime + f((len - signX),signSp,a,maxSp))); } void inp()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 D().inp(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
1	public class B{ public static PrintStream out = System.out; public static InputReader in = new InputReader(System.in); static class Node implements Comparable<Node>{ int res ; Node( int pp){ p = pp; } int p ; @Override public boolean equals( Object o){ return (p == (Node)o);} } public static void main( String[] args){ int N ,a ,b ; N = in.nextInt(); int[] label ; a = in.nextInt(); b = in.nextInt(); if ( (a < b)) {label = new int[]{0,1}; } else { int tmp = a; a = b; b = tmp; label = new int[]{1,0}; } Node[] nodes = new Node[N]; for ( int i = 0;(i < N);i++) {nodes[i] = new Node(in.nextInt()); } TreeSet<Node> ts = new TreeSet<>(); for ( int i = 0;(i < N);i++) {ts.add(nodes[i]); }while(!ts.isEmpty()){ Node n = ts.first();  Node an = new Node((a - n.p));  Node bn = new Node((b - n.p));  SortedSet<Node> ats = ts.tailSet(an);  SortedSet<Node> bts = ts.tailSet(bn);  Node an2 = (ats.isEmpty()?null:ats.first());  Node bn2 = (bts.isEmpty()?null:bts.first());  Node n2 = null;  int l = 0; if ( ((bn2 != null) && bn2.equals(bn))) {n2 = bn2; l = label[1]; } else if ( ((an2 != null) && an2.equals(an))) {n2 = an2; l = label[0]; } else {NO(); }if ( !n.equals(n2)) {ts.remove(n); n.res = l; } ts.remove(n2); n2.res = l; }out.println("YES"); for ( int i = 0;(i < nodes.length);i++) {if ( (i != 0)) out.print(" "); out.print(nodes[i].res); }out.println(); } static void NO(){ out.println("NO"); System.exit(0); } } 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 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);  G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion(); solver.solve(1,in,out); out.close(); } static class G1PlaylistForPolycarpEasyVersion{ long mod = ((long)1e9 + 7); public void solve( int testNumber, InputReader s, PrintWriter w){ int n = s.nextInt(),T = s.nextInt();  int[] t = new int[(n + 1)];  int[] g = new int[(n + 1)];  int[] f = new int[4]; for ( int i = 1;(i <= n);i++) {t[i] = s.nextInt(); g[i] = s.nextInt(); f[g[i]]++; } long[] fact = new long[(n + 1)]; fact[0] = 1; for ( int i = 1;(i <= n);i++) fact[i] = ((fact[(i - 1)] * i) % mod); long[][][][] perm = new long[(f[1] + 1)][(f[2] + 1)][(f[3] + 1)][(3 + 1)];  long[][][] sumPerm = new long[(f[1] + 1)][(f[2] + 1)][(f[3] + 1)]; perm[0][0][0][0] = 1; for ( int a = 0;(a <= f[1]);a++) {for ( int b = 0;(b <= f[2]);b++) {for ( int c = 0;(c <= f[3]);c++) {if ( ((a - 1) >= 0)) perm[a][b][c][1] = (((sumPerm[(a - 1)][b][c] - perm[(a - 1)][b][c][1]) + mod) % mod); if ( ((b - 1) >= 0)) perm[a][b][c][2] = (((sumPerm[a][(b - 1)][c] - perm[a][(b - 1)][c][2]) + mod) % mod); if ( ((c - 1) >= 0)) perm[a][b][c][3] = (((sumPerm[a][b][(c - 1)] - perm[a][b][(c - 1)][3]) + mod) % mod); for ( int i = 0;(i <= 3);i++) sumPerm[a][b][c] = ((sumPerm[a][b][c] + perm[a][b][c][i]) % mod); }}} long[][][][][] dp = new long[(n + 1)][(f[1] + 1)][(f[2] + 1)][(f[3] + 1)][(T + 1)]; dp[0][0][0][0][0] = 1; for ( int i = 1;(i <= n);i++) {for ( int a = 0;(a <= f[1]);a++) {for ( int b = 0;(b <= f[2]);b++) {for ( int c = 0;(c <= f[3]);c++) {for ( int j = 0;(j <= T);j++) {dp[i][a][b][c][j] = dp[(i - 1)][a][b][c][j]; if ( ((j - t[i]) >= 0)) {if ( ((g[i] == 1) && (a > 0))) {dp[i][a][b][c][j] = ((dp[i][a][b][c][j] + dp[(i - 1)][(a - 1)][b][c][(j - t[i])]) % mod); } else if ( ((g[i] == 2) && (b > 0))) {dp[i][a][b][c][j] = ((dp[i][a][b][c][j] + dp[(i - 1)][a][(b - 1)][c][(j - t[i])]) % mod); } else if ( ((g[i] == 3) && (c > 0))) {dp[i][a][b][c][j] = ((dp[i][a][b][c][j] + dp[(i - 1)][a][b][(c - 1)][(j - t[i])]) % mod); } } }}}}} long res = 0; for ( int a = 0;(a <= f[1]);a++) for ( int b = 0;(b <= f[2]);b++) for ( int c = 0;(c <= f[3]);c++) res = ((res + ((((((((dp[n][a][b][c][T] * sumPerm[a][b][c]) % mod) * fact[a]) % mod) * fact[b]) % mod) * fact[c]) % mod)) % mod); w.println(res); } } 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); } } }
1	public class Solution{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; void solve()throws IOException { int n = nextInt();  int k = nextInt();  ArrayList<Integer> ps = new ArrayList<Integer>();  boolean[] prime = new boolean[(n + 1)]; Arrays.fill(prime,true); prime[0] = prime[1] = false; for ( int i = 2;(i <= n);++i) {if ( prime[i]) {ps.add(i); for ( int j = (2 * i);(j <= n);j += i) {prime[j] = false; }} }for ( int i = 0;(i < (ps.size() - 1));++i) { int t = ((ps.get(i) + ps.get((i + 1))) + 1); if ( ((t <= n) && prime[t])) {--k; } }out.println(((k <= 0)?"YES":"NO")); } 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(); } }
2	public class Tests{ public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long inputNum = 0;  String finalResult = ""; inputNum = scanner.nextLong(); long upperLimitResult = 0;  long lowerLimitResult = 0;  int multiplier = 0; do {multiplier++; lowerLimitResult = upperLimitResult; upperLimitResult += ((9 * Math.pow(10,(multiplier - 1))) * multiplier); }while((inputNum > upperLimitResult)); long remainderFromLowerRange = (inputNum - lowerLimitResult);  long repititions = 0; if ( (multiplier > 1)) repititions = ((((remainderFromLowerRange - 1) > 0)?(remainderFromLowerRange - 1):0) / multiplier);  long currentNumber = (long)(Math.pow(10,(multiplier - 1)) + repititions); remainderFromLowerRange = (remainderFromLowerRange - (repititions * multiplier)); long digitIndex = ((remainderFromLowerRange < multiplier)?(multiplier - remainderFromLowerRange):(remainderFromLowerRange % multiplier)); if ( (multiplier == 1)) {finalResult = ((remainderFromLowerRange % 10) + ""); } else { int charToGet = (int)((multiplier - 1) - digitIndex); finalResult = ((currentNumber + "") + ""); }System.out.print(finalResult); scanner.close(); } }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long r ,l ; r = sc.nextLong(); l = sc.nextLong(); if ( ((r + 2) > l)) {System.out.print("-1"); return ;} if ( ((r % 2) == 0)) {System.out.print(r); System.out.print(" "); System.out.print((r + 1)); System.out.print(" "); System.out.print((r + 2)); return ;} if ( ((r + 3) <= l)) {System.out.print((r + 1)); System.out.print(" "); System.out.print((r + 2)); System.out.print(" "); System.out.print((r + 3)); return ;} System.out.print("-1"); } }
5	public class Main{ static private 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); } static private class Node implements Comparable<Node>{ public int l ; public int r ; public Node( int l, int r){ this.l = l; this.r = r; } } }
2	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  String s = sc.nextLine();  String[] info = s.split(" ");  long n = Long.parseLong(info[0]);  long k = Long.parseLong(info[1]); sc.close(); long maximum = (((k * (k - 1)) / 2) + 1); if ( (n == 1)) System.out.println(0); else if ( (n > maximum)) System.out.println(-1); else { long left = 0,right = (k - 1); while(((left + 1) < right)){ long mid = ((right + left) / 2); if ( ((((mid * (((k - 1) + k) - mid)) / 2) + 1) >= n)) right = mid; else left = mid; }System.out.println(right); }} }
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[] a = in.readIntArray(n);  long count = 0; for ( int i = 1;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( (a[j] > a[i])) count++; }} boolean even = (((count % 2) == 0)?true:false);  int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int left = in.nextInt();  int right = in.nextInt();  int diff = (right - left); if ( (((diff % 4) == 1) || ((diff % 4) == 2))) {even = !even; } if ( even) {out.println("even"); } else {out.println("odd"); }}} } static class InputReader{ static private BufferedReader in ; static private StringTokenizer tok ; public InputReader( InputStream in){ this.in = new BufferedReader(new InputStreamReader(in)); } public int nextInt(){ return Integer.parseInt(next());} public int[] readIntArray( int n){ int[] ar = new int[n]; for ( int i = 0;(i < n);i++) {ar[i] = nextInt(); }return ar;} public String next(){ try{while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); } }catch (IOException ex){ System.err.println(("An IOException was caught :" + ex.getMessage())); } return tok.nextToken();} } }
4	public class EdF{ 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 t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  Stack<Integer> st = new Stack<>();  Stack<Integer> temporary = new Stack<>(); for ( int j = 0;(j < n);j++) { int val = sc.nextInt();  boolean found = false; while(!st.isEmpty()){ int temp = st.peek(); if ( (val == (temp + 1))) {found = true; st.pop(); break;} else {temporary.add(st.pop()); }}if ( !found) {while(!temporary.isEmpty()){st.add(temporary.pop()); }} st.add(val); ArrayList<Integer> arr = new ArrayList<>(); for ( int s :st) {arr.add(s); }for ( int s = 0;(s < (arr.size() - 1));s++) {out.print(arr.get(s)); out.print("."); }out.println(arr.get((arr.size() - 1))); temporary.clear(); }}out.close(); } 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());} } }
1	public class evenness{ public static void main( String[] args){ try{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int i ,n ,temp = 1;  String str = "";  int[] arr ;  int r ; while((temp != '\n')){temp = System.in.read(); str = str.concat(Character.toString((char)temp)); }str = str.replaceAll("[^0-9]",""); n = Integer.parseInt(str); temp = 1; str = ""; arr = new int[n]; for ( i = 0;(i < n);i++) {while(((temp != ' ') && (temp != -1))){temp = System.in.read(); str = str.concat(Character.toString((char)temp)); }str = str.replaceAll("[^0-9]",""); arr[i] = Integer.parseInt(str); str = ""; temp = 1; }r = (arr[2] % 2); if ( ((arr[0] % 2) == (arr[1] % 2))) {r = (arr[0] % 2); } for ( i = 0;(i < n);i++) {if ( ((arr[i] % 2) != r)) {System.out.println((i + 1)); break;} } }catch (Exception e){ System.out.println(("OH NOES " + e)); } } }
6	public class Main{ public static void main( String[] args)throws IOException { new Thread(null,new Runnable(){public void run(){ try{ long prevTime = System.currentTimeMillis(); new Main().run(); System.err.println((("Total time: " + (System.currentTimeMillis() - prevTime)) + " ms")); System.err.println(("Memory status: " + memoryStatus())); }catch (IOException e){ e.printStackTrace(); } } },"1",(1L << 24)).start(); } void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); Object o = solve(); if ( (o != null)) out.println(o); out.close(); in.close(); } int n ; Point[] ps ; int[] dp ; private Object solve()throws IOException { int o_x = ni();  int o_y = ni(); n = ni(); ps = new Point[n]; for ( int i = 0;(i < n);i++) ps[i] = new Point((ni() - o_x),(ni() - o_y)); dp = new int[(1 << n)]; Arrays.fill(dp,Integer.MAX_VALUE); dp[0] = 0; int[] path_x = new int[(1 << n)];  int[] path_y = new int[(1 << n)]; for ( int mask = 1;(mask < (1 << n));mask++) { int i = min(mask);  int min_val = (dp[(mask - (1 << i))] + (2 * ps[i].norm)); if ( (min_val < dp[mask])) {dp[mask] = min_val; path_x[mask] = i; path_y[mask] = i; } for ( int j = (i + 1);(j < n);j++) if ( ((mask & (1 << j)) != 0)) { int newMask = ((mask - (1 << i)) - (1 << j));  int val = (((dp[newMask] + ps[i].norm) + ps[j].norm) + ps[i].dist(ps[j])); if ( (val < dp[mask])) {dp[mask] = val; path_x[mask] = i; path_x[mask] = j; } } }pln(dp[((1 << n) - 1)]); int maskPath = ((1 << n) - 1);  LinkedList<Long> list = new LinkedList<Long>(); while((maskPath != 0)){ long x = path_x[maskPath];  long y = path_y[maskPath]; list.addFirst(0L); list.addFirst((y + 1)); maskPath -= (1 << y); if ( (x != y)) {list.addFirst((x + 1)); maskPath -= (1 << x); } }list.addFirst(0L); show(list); return null;} private int min( int mask){ int ret = 0; while(((mask % 2) == 0)){mask /= 2; ret++; }return ret;} private void show( LinkedList<Long> list){ int index = 0; for ( long a :list) {if ( (index == 0)) {p(a); } else {p((" " + a)); }index++; }pln(); } class Point{ int x ; int y ; int norm ; public Point( int x, int y){ this.x = x; this.y = y; this.norm = ((x * x) + (y * y)); } public int dist( Point other){ int dx = (x - other.x);  int dy = (y - other.y); return ((dx * dx) + (dy * dy));} } BufferedReader in ; PrintWriter out ; StringTokenizer strTok = new StringTokenizer(""); String nextToken()throws IOException { while(!strTok.hasMoreTokens())strTok = new StringTokenizer(in.readLine()); return strTok.nextToken();} int ni()throws IOException { return Integer.parseInt(nextToken());} long nl()throws IOException { return Long.parseLong(nextToken());} double nd()throws IOException { return Double.parseDouble(nextToken());} static String memoryStatus(){ return (((((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) >> 20) + "/") + (Runtime.getRuntime().totalMemory() >> 20)) + " MB");} public void pln(){ out.println(); } public void pln( int arg){ out.println(arg); } public void pln( long arg){ out.println(arg); } public void pln( double arg){ out.println(arg); } public void pln( String arg){ out.println(arg); } public void pln( boolean arg){ out.println(arg); } public void pln( char arg){ out.println(arg); } public void pln( float arg){ out.println(arg); } public void pln( Object arg){ out.println(arg); } public void p( int arg){ out.print(arg); } public void p( long arg){ out.print(arg); } public void p( double arg){ out.print(arg); } public void p( String arg){ out.print(arg); } public void p( boolean arg){ out.print(arg); } public void p( char arg){ out.print(arg); } public void p( float arg){ out.print(arg); } public void p( Object arg){ out.print(arg); } }
2	public class B{ public static void main( String[] args){ InputReader in = new InputReader();  int n = in.nextInt();  int k = in.nextInt();  long numCandies = 1;  int turns = 1,add = 2; while((numCandies < k)){++turns; numCandies += add++; } int res = 0; if ( (numCandies > k)) {turns += (numCandies - k); res += (numCandies - k); numCandies = k; } if ( (turns == n)) {System.out.println(res); } else {while((turns != n)){res += add; turns += (add++ + 1); }System.out.println(res); }} static class InputReader{ public BufferedReader br ; public StringTokenizer st ; public InputReader(){ br = new BufferedReader(new InputStreamReader(System.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 int nextInt(){ return Integer.parseInt(next());} } }
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(); } }
5	public class A{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ni(); }Arrays.sort(a); if ( (a[(n - 1)] > 1)) {a[(n - 1)] = 1; Arrays.sort(a); } else {a[(n - 1)] = 2; }for ( int i = 0;(i < n);i++) {if ( (i > 0)) out.print(" "); out.print(a[i]); }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 A().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 A630{ public static void main( String[] args){ System.out.println(25); } }
0	public class Codechef{ static int max = Integer.MIN_VALUE; static int res = 0; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long a[] = new long[14];  long b[] = new long[14];  long p ,q ,r ,s ,max = 0; for ( int i = 0;(i < 14);i++) a[i] = sc.nextInt(); for ( int i = 0;(i < 14);i++) {p = (a[i] % 14); q = (a[i] / 14); r = 0; s = 0; for ( int j = 0;(j < 14);j++) b[j] = a[j]; b[i] = 0; int j = ((i + 1) % 14); for ( ;(r < p);r++) {b[j]++; j = ((j + 1) % 14); }for ( j = 0;(j < 14);j++) {b[j] += q; if ( ((b[j] % 2) == 0)) s += b[j]; }max = Math.max(max,s); }System.out.println(max); } }
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); } }
1	public class HammingDistancesSum{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  String a = sc.nextLine(),b = sc.nextLine();  long sum = 0;  int frequency[][] = new int[200010][2]; for ( int i = 1;(i <= b.length());i++) {for ( int j = 0;(j < 2);j++) frequency[i][j] = frequency[(i - 1)][j]; frequency[i][Character.getNumericValue(b.charAt((i - 1)))]++; }for ( int i = 0;(i < a.length());i++) { int c = Character.getNumericValue(a.charAt(i)); for ( int j = 0;(j < 2);j++) { int flippingTerm = Math.abs((c - j));  int endOfWindowValue = frequency[(((b.length() - a.length()) + i) + 1)][j];  int startOfWindowOffset = frequency[i][j]; sum += (flippingTerm * (endOfWindowValue - startOfWindowOffset)); }}System.out.println(sum); sc.close(); } }
2	public class Main{ FastScanner in ; PrintWriter out ; void run(){ in = new FastScanner(); out = new PrintWriter(System.out); solve(); out.close(); } class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ br = new BufferedReader(new InputStreamReader(System.in)); } public FastScanner( String s){ try{br = new BufferedReader(new FileReader(s)); }catch (FileNotFoundException e){ e.printStackTrace(); } } public String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ } }return st.nextToken();} public int nextInt(){ return Integer.parseInt(nextToken());} public long nextLong(){ return Long.parseLong(nextToken());} } public static void main( String[] args){ new Main().run(); } void solve(){ int t = in.nextInt(); for ( int sdfsdf = 0;(sdfsdf < t);sdfsdf++) { long n = in.nextLong();  long k = in.nextLong(); if ( (n == 1)) {if ( (k == 1)) {out.println("YES 0"); } else {out.println("NO"); }continue;} if ( (k == 3)) {if ( (n == 2)) {out.println("NO"); } else {out.println(("YES " + (n - 1))); }continue;} long cuts = 1;  long squares = 4;  int zoom = 1; while((k > (cuts + squares))){cuts += squares; squares *= 4; zoom++; }if ( (zoom > n)) {out.println("NO"); continue;} if ( ((zoom == n) && (k > cuts))) {out.println("NO"); continue;} long current_cuts = (k - cuts); if ( (current_cuts > (squares - ((2L * Math.sqrt(squares)) - 1L)))) {out.println(("YES " + ((n - zoom) - 1L))); } else {out.println(("YES " + (n - zoom))); }}} }
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); } static private 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;} }
6	public class C8{ static int[] mem ; static int[] bag ; static int[][] items ; static int[] close ; static PrintWriter pw ; static int n ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in); pw = new PrintWriter(System.out); bag = new int[2]; bag[0] = sc.nextInt(); bag[1] = sc.nextInt(); n = sc.nextInt(); items = new int[n][2]; for ( int i = 0;(i < n);i++) {items[i][0] = sc.nextInt(); items[i][1] = sc.nextInt(); }mem = new int[(1 << n)]; Arrays.fill(mem,-1); pw.println(dp(0)); trace(0); pw.print(0); pw.flush(); } static int dp( int mask){ if ( (mask == ((1 << n) - 1))) return 0; if ( (mem[mask] != -1)) return mem[mask]; int ans = (int)1e9; for ( int i = 0;(i < n);i++) if ( (((1 << i) & mask) == 0)) {ans = ((getDisBag(i) * 2) + dp((mask | (1 << i)))); for ( int j = (i + 1);(j < n);j++) if ( (((1 << j) & mask) == 0)) ans = Math.min(ans,(((getDisBag(i) + getDis(i,j)) + getDisBag(j)) + dp(((mask | (1 << i)) | (1 << j))))); break;} return mem[mask] = ans;} static int getDis( int i, int j){ return (((items[i][0] - items[j][0]) * (items[i][0] - items[j][0])) + ((items[i][1] - items[j][1]) * (items[i][1] - items[j][1])));} static int getDisBag( int i){ return (((items[i][0] - bag[0]) * (items[i][0] - bag[0])) + ((items[i][1] - bag[1]) * (items[i][1] - bag[1])));} static void trace( int mask){ if ( (mask == ((1 << n) - 1))) return ; int ans = (int)1e9; for ( int i = 0;(i < n);i++) if ( (((1 << i) & mask) == 0)) {ans = ((getDisBag(i) * 2) + dp((mask | (1 << i)))); if ( (mem[mask] == ans)) {pw.print((((0 + " ") + (i + 1)) + " ")); trace((mask | (1 << i))); return ;} for ( int j = (i + 1);(j < n);j++) if ( (((1 << j) & mask) == 0)) if ( (mem[mask] == (((getDisBag(i) + getDis(i,j)) + getDisBag(j)) + dp(((mask | (1 << i)) | (1 << j)))))) {pw.print((((((0 + " ") + (i + 1)) + " ") + (j + 1)) + " ")); trace(((mask | (1 << i)) | (1 << j))); return ;} } } 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 a{ public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out); input.init(System.in); long a = input.nextLong(),b = input.nextLong(); if ( (a == b)) {out.println(0); out.close(); return ;} long res = 0; for ( int i = 0;(i < 63);i++) {if ( ((a % (1l << i)) >= (b % (1l << i)))) res += (1l << i); else if ( ((b / (1l << i)) > (a / (1l << i)))) res += (1l << i); }out.println(res); out.close(); } public static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} }
5	public class a{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  double w = in.nextDouble();  int tot = 2;  Interval[] houses = new Interval[n]; for ( int i = 0;(i < n);i++) { double center = in.nextDouble();  double wid = in.nextDouble(); houses[i] = new Interval((center - (wid / 2)),(center + (wid / 2))); }Arrays.sort(houses); for ( int i = 1;(i < n);i++) { double dist = (houses[i].s - houses[(i - 1)].e); if ( ((dist + 1e-6) >= w)) {tot += 2; if ( (Math.abs((w - dist)) < 1e-6)) tot--; } }System.out.println(tot); } } class Interval implements Comparable<Interval>{ double s ,e ; Interval( double a, double b){ s = a; e = b; } }
0	public class programA{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine()); if ( ((n % 2) == 0)) System.out.println(((n / 2) + 1)); else System.out.println((int)Math.ceil(((double)n / 2))); } }
2	public class D{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long L = sc.nextLong();  long R = sc.nextLong();  long res = Math.max(((2 * Long.highestOneBit((L ^ R))) - 1),0); System.out.println(res); } }
0	public class ToyArmy{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(); System.out.println(((n / 2) + n)); } }
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"); } }
1	public class Primes{ static Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); public static void main( String[] args){ int n = in.nextInt(),k = in.nextInt(),count = 0;  boolean[] isP = new boolean[(n + 1)]; for ( int i = 2;(i <= n);i++) isP[i] = true; ArrayList<Integer> primes = new ArrayList<Integer>(); for ( int i = 2;(i <= n);i++) if ( isP[i]) {primes.add(i); if ( (i <= Math.sqrt(n))) for ( int j = (2 * i);(j <= n);j += i) isP[j] = false; } for ( int i = 0;(i < (primes.size() - 1));i++) { int sum = ((primes.get(i) + primes.get((i + 1))) + 1); if ( ((sum <= n) && isP[sum])) count++; }if ( (count >= k)) System.out.println("YES"); else System.out.println("NO"); } }
2	public class Main{ public static void main( String[] args)throws Exception { Thread thread = new Thread(null,new TaskAdapter(),"",(1 << 29)); thread.start(); thread.join(); } static class TaskAdapter implements Runnable{ } static class AQuiz{ int mod = ((int)1e9 + 9); Power pow = new Power(mod); public void solve( int testNumber, FastInput in, FastOutput out){ int n = in.ri();  int m = in.ri();  int k = in.ri();  long mayPut = ((long)(n - m) * (k - 1)); if ( (mayPut >= m)) {out.println(m); return ;} long ans = dup((m - mayPut),k); ans += mayPut; ans %= mod; out.println(ans); } public long dup( long n, long k){ long r = (n % k); n -= r; long m = (n / k);  long ans = (k * (pow.pow(2,(m + 1)) - 2)); ans += r; ans = DigitUtils.mod(ans,mod); return ans;} } static class FastOutput implements AutoCloseable,Closeable,Appendable{ static private final int THRESHOLD = (32 << 10); private final Writer os ; private StringBuilder cache = new StringBuilder((THRESHOLD * 2)); public FastOutput append( CharSequence csq){ cache.append(csq); return this;} public FastOutput append( CharSequence csq, int start, int end){ cache.append(csq,start,end); return this;} private void afterWrite(){ if ( (cache.length() < THRESHOLD)) {return ;} flush(); } public FastOutput( Writer os){ this.os = os; } public FastOutput( OutputStream os){ this(new OutputStreamWriter(os)); } public FastOutput append( char c){ cache.append(c); afterWrite(); return this;} public FastOutput append( int c){ cache.append(c); afterWrite(); return this;} public FastOutput append( long c){ cache.append(c); afterWrite(); return this;} public FastOutput println( int c){ return append(c).println();} public FastOutput println( long c){ return append(c).println();} public FastOutput println(){ return append('\n');} 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();} } 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 ri(){ return readInt();} 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 interface InverseNumber{ } static class Power implements InverseNumber{ int mod ; public Power( int mod){ this.mod = mod; } public int pow( int x, long n){ if ( (n == 0)) {return (1 % mod);} long r = pow(x,(n >> 1)); r = ((r * r) % mod); if ( ((n & 1) == 1)) {r = ((r * x) % mod); } return (int)r;} } }
6	public class ElongatedMatrix2{ public static void main( String[] args){ FastScanner scanner = new FastScanner();  int N = scanner.nextInt();  int M = scanner.nextInt();  int[][] arr = new int[N][M]; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {arr[i][j] = scanner.nextInt(); }} int[][] distRow = new int[N][N];  int[][] distTop = new int[N][N]; for ( int i = 0;(i < N);i++) {for ( int j = (i + 1);(j < N);j++) { int curMin = Integer.MAX_VALUE; for ( int k = 0;(k < M);k++) {curMin = Math.min(curMin,Math.abs((arr[i][k] - arr[j][k]))); }distRow[i][j] = distRow[j][i] = curMin; }}for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < N);j++) { int curMin = Integer.MAX_VALUE; for ( int k = 0;((k + 1) < M);k++) {curMin = Math.min(curMin,Math.abs((arr[i][k] - arr[j][(k + 1)]))); }distTop[i][j] = curMin; }} int maxMask = (1 << N);  int[][][] dp = new int[maxMask][N][N]; for ( int i = 0;(i < maxMask);i++) {for ( int j = 0;(j < N);j++) {Arrays.fill(dp[i][j],Integer.MAX_VALUE); }}for ( int mask = 1;(mask < maxMask);mask++) {for ( int j = 0;(j < N);j++) {if ( ((mask & (1 << j)) == 0)) continue; for ( int k = 0;(k < N);k++) {if ( ((mask & (1 << k)) == 0)) continue; if ( ((j == k) && ((mask - (1 << k)) != 0))) continue; for ( int i = 0;(i < N);i++) {if ( ((mask & (1 << i)) > 0)) continue; int curMask = (mask | (1 << i)); if ( (dp[curMask][i][k] != Integer.MAX_VALUE)) dp[curMask][i][k] = Math.max(dp[curMask][i][k],Math.min(dp[mask][j][k],distRow[i][j])); else dp[curMask][i][k] = Math.min(dp[mask][j][k],distRow[i][j]); }}}}maxMask--; int max = 0; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < N);j++) {if ( ((i == j) && (N != 1))) continue; max = Math.max(max,Math.min(dp[maxMask][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());} } }
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); } }
5	public class Replacement{ 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);  int[] arr = new int[n];  String[] sp = r.readLine().split("[ ]+"); for ( int i = 0;(i < sp.length);i++) {arr[i] = new Integer(sp[i]); }Arrays.sort(arr); if ( (arr[(arr.length - 1)] == 1)) {arr[(arr.length - 1)] = 2; Arrays.sort(arr); for ( int i = 0;(i < n);i++) {if ( (i == (n - 1))) {System.out.println(arr[i]); } else System.out.print((arr[i] + " ")); }return ;} arr[(arr.length - 1)] = 1; Arrays.sort(arr); for ( int i = 0;(i < n);i++) {if ( (i == (n - 1))) {System.out.println(arr[i]); } else System.out.print((arr[i] + " ")); }} }
4	public class Main{ static PrintWriter pw ; static _Scanner sc ; public static void main( String[] args)throws Exception { sc = new _Scanner(System.in); pw = new PrintWriter(System.out); int t = 1; while((t-- > 0)){solve(); }pw.flush(); } static private void solve()throws Exception { int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt();  int[][] h = new int[n][(m - 1)];  int[][] v = new int[(n - 1)][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < (m - 1));++j) {h[i][j] = sc.nextInt(); }}for ( int i = 0;(i < (n - 1));++i) {for ( int j = 0;(j < m);++j) {v[i][j] = sc.nextInt(); }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {if ( (j > 0)) {pw.print(" "); } pw.print(-1); }pw.println(); }return ;} k = (k / 2); long[][] d = new long[n][m]; for ( int ki = 0;(ki < k);++ki) { long[][] dk = new long[n][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) { long val = Integer.MAX_VALUE; if ( (j < (m - 1))) {val = Math.min(val,(d[i][(j + 1)] + h[i][j])); } if ( (i < (n - 1))) {val = Math.min(val,(d[(i + 1)][j] + v[i][j])); } if ( (j > 0)) {val = Math.min(val,(d[i][(j - 1)] + h[i][(j - 1)])); } if ( (i > 0)) {val = Math.min(val,(d[(i - 1)][j] + v[(i - 1)][j])); } dk[i][j] = val; }}d = dk; }for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {if ( (j > 0)) {pw.print(" "); } pw.print((d[i][j] * 2)); }pw.println(); }} static class _Scanner{ StringTokenizer st ; BufferedReader br ; _Scanner( InputStream system){ br = new BufferedReader(new InputStreamReader(system)); } _Scanner( String file)throws Exception{ br = new BufferedReader(new FileReader(file)); } String nextToken()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} long nextLong()throws IOException { return Long.parseLong(nextToken());} boolean ready()throws IOException { return br.ready();} } }
1	public class Main{ static int n ; static int a ; static int b ; static int g ; static int ref ; static int refg ; static HashSet<Integer> cgroup ; static HashMap<Integer,Integer> indexmap ; static HashSet<Integer> nums ; static HashSet<Integer> used ; public static void main( String[] args){ Scanner scan = new Scanner(System.in); n = scan.nextInt(); a = scan.nextInt(); b = scan.nextInt(); boolean[] where = new boolean[n]; indexmap = new HashMap<Integer,Integer>(); used = new HashSet<Integer>(); nums = new HashSet<Integer>(); if ( (a == b)) b = 0; for ( int i = 0;(i < n);i++) { int x = scan.nextInt(); nums.add(x); indexmap.put(x,i); }scan.close(); for ( int x :nums) {if ( used.contains(x)) continue; cgroup = new HashSet<Integer>(); cgroup.add(x); g = -1; refg = -1; ref = -1; used.add(x); if ( (!spawn(x,a,b) || !spawn(x,b,a))) {System.out.println("NO"); return ;} if ( (((cgroup.size() % 2) == 1) && (ref == -1))) {System.out.println("NO"); return ;} else { boolean w = true; if ( (g == a)) w = false; for ( int k :cgroup) {where[indexmap.get(k)] = w; }}}System.out.println("YES"); for ( int i = 0;(i < where.length);i++) if ( where[i]) System.out.print("1 "); else System.out.print("0 "); } static private boolean spawn( int x, int ab, int abo){ int xab = (ab - x); if ( (xab == x)) {ref = x; refg = ab; } else {if ( nums.contains(xab)) {cgroup.add(xab); used.add(xab); spawn(xab,abo,ab); } else {if ( (g == -1)) g = abo; else if ( (g != abo)) {return false;} }}return true;} }
2	public class DTask{ static Scanner in ; static int[] first = new int[4]; static int[] second = new int[4]; static PrintWriter out ; static int n ; public static void main( String[] args)throws IOException { in = new Scanner(System.in); out = new PrintWriter(System.out); n = (in.nextInt() + 1); first = new int[]{0,0,n,n}; second = new int[]{0,0,n,n}; for ( int i = 0;(i < first.length);i++) { boolean inc = (i < 2); search(first,i,inc,false); if ( !inc) {first[i] += 1; } }for ( int i = 0;(i < second.length);i++) { boolean inc = (i < 2); search(second,i,inc,true); if ( !inc) {second[i] += 1; } } String s = "!"; for ( int i = 0;(i < 4);i++) {s += (" " + second[i]); }for ( int i = 0;(i < 4);i++) {s += (" " + first[i]); }out.println(s); out.flush(); } static void search( int[] arr, int i, boolean inc, boolean cond){ int start = 0;  int end = n; while(true){if ( ((end - start) <= 1)) {arr[i] = start; return ;} int mid = ((start + end) / 2); arr[i] = mid; int n = ask(arr,cond); if ( (n > 0)) {if ( inc) {start = mid; } else {end = mid; }} else {if ( inc) {end = mid; } else {start = mid; }}}} static int ask( int[] arr, boolean cond){ if ( ((arr[1] > arr[3]) || (arr[0] > arr[2]))) {return 0;} arr = Arrays.copyOf(arr,4); String q = ""; q += "?"; for ( int i = 0;(i < arr.length);i++) { int x = Math.min(arr[i],(n - 1)); x = Math.max(x,1); q += (" " + x); }out.println(q); out.flush(); int x = in.nextInt(); if ( cond) {x -= (within(arr,first)?1:0); } return x;} static boolean within( int[] outer, int[] inner){ return ((((outer[0] <= inner[0]) && (outer[1] <= inner[1])) && (outer[2] >= inner[2])) && (outer[3] >= inner[3]));} }
6	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);  E2RotateColumnsHardVersion solver = new E2RotateColumnsHardVersion();  int testCount = Integer.parseInt(in.next()); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class E2RotateColumnsHardVersion{ public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  E2RotateColumnsHardVersion.Column[] columns = new E2RotateColumnsHardVersion.Column[m]; for ( int i = 0;(i < columns.length);++i) columns[i] = new E2RotateColumnsHardVersion.Column(new int[n]); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {columns[j].v[i] = in.nextInt(); if ( (i == (n - 1))) columns[j].initMax(); }}Arrays.sort(columns,new Comparator<E2RotateColumnsHardVersion.Column>(){}); if ( (columns.length > n)) columns = Arrays.copyOf(columns,n);  long[] dp = new long[(1 << n)]; for ( E2RotateColumnsHardVersion.Column c :columns) { long[] ndp = new long[(1 << n)]; System.arraycopy(dp,0,ndp,0,dp.length); for ( int rot = 0;(rot < n);++rot) { long[] temp = new long[(1 << n)]; System.arraycopy(dp,0,temp,0,dp.length); for ( int i = 0,pos = rot;(i < n);++i,++pos) {if ( (pos >= n)) pos = 0;  int val = c.v[pos]; for ( int j = 0;(j < temp.length);++j) {if ( ((j & (1 << i)) == 0)) temp[(j | (1 << i))] = Math.max(temp[(j | (1 << i))],(temp[j] + val)); }}for ( int i = 0;(i < ndp.length);++i) ndp[i] = Math.max(ndp[i],temp[i]); }dp = ndp; }out.println(dp[(dp.length - 1)]); } } 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 String next(){ return nextString();} 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);} public String nextString(){ int c = pread(); while(isSpaceChar(c))c = pread(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = pread(); }while(!isSpaceChar(c));return res.toString();} private boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} } }
2	public class DigitsSequence{ 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)]); } }
0	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);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, FastScanner in, FastPrinter out){ int n = in.nextInt(); if ( ((n % 2) == 0)) {if ( ((n % 4) == 0)) out.println((((n / 2) + " ") + (n / 2))); else out.println(((6 + " ") + (n - 6))); } else {out.println(((9 + " ") + (n - 9))); }} } 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);} } class FastPrinter extends PrintWriter{ public FastPrinter( OutputStream out){ super(out); } public FastPrinter( Writer out){ super(out); } }
3	public class D{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),sum = 0;  int[] a = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) {a[i] = in.nextInt(); }for ( int i = 1;(i <= n);++i) for ( int j = (i + 1);(j <= n);++j) sum += ((a[i] > a[j])?1:0); int m = in.nextInt(); sum &= 1; for ( int i = 1;(i <= m);i++) { int l = in.nextInt(),r = in.nextInt(); if ( (((((r - l) + 1) / 2) % 2) == 1)) sum ^= 1; System.out.println(((sum == 1)?"odd":"even")); }} }
0	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String[] line = br.readLine().split(" ");  long l = Long.parseLong(line[0]);  long r = Long.parseLong(line[1]); if ( (((r - l) < 2) || (((r - l) == 2) && ((l % 2) == 1)))) System.out.println("-1"); else { Long start = (l + (l % 2)); System.out.println(((((start + " ") + (start + 1)) + " ") + (start + 2))); }} }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long A = in.nextLong();  long B = in.nextLong(); System.out.println(f(A,B)); } static long f( long A, long B){ if ( (A == 0)) return 0; if ( (A < B)) return f(B,A); else { long k = (A / B); return (k + f((A - (B * k)),B));}} }
5	public class Codeforces_R136_Div1_A implements Runnable{ private void solve()throws IOException { int n = scanner.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < a.length);i++) {a[i] = scanner.nextInt(); } boolean sorted = true; for ( int i = 0;(i < a.length);i++) {if ( !isOk(a,i)) {sorted = false; } }if ( sorted) {out.println("YES"); return ;} List<Integer> idx = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) {if ( !isOk(a,i)) {idx.add(i); } }if ( (idx.size() > 6)) {out.println("NO"); return ;} for ( int i = 0;(i < idx.size());i++) {for ( int j = 0;(j < n);j++) {swap(a,idx.get(i),j); if ( (isOk(a,idx) && isOk(a,j))) {out.println("YES"); return ;} swap(a,idx.get(i),j); }}out.println("NO"); } private boolean isOk( int[] a, int i){ boolean ordered = true; if ( ((i > 0) && (a[(i - 1)] <= a[i]))) {ordered = false; } if ( ((i < (a.length - 1)) && (a[i] <= a[(i + 1)]))) {ordered = false; } return ordered;} private boolean isOk( int[] a, List<Integer> idx){ for ( int i :idx) {if ( !isOk(a,i)) return false; }return true;} private void swap( int[] a, int i, int j){ int tmp = a[i]; a[i] = a[j]; a[j] = tmp; } final int BUF_SIZE = ((1024 * 1024) * 8); final int INPUT_BUFFER_SIZE = ((1024 * 1024) * 8); final int BUF_SIZE_INPUT = 1024; final int BUF_SIZE_OUT = 1024; boolean inputFromFile = false; String filenamePrefix = "A-small-attempt0"; String inSuffix = ".in"; String outSuffix = ".out"; PrintStream out ; ByteScanner scanner ; ByteWriter writer ; public void run(){ try{ InputStream bis = null;  OutputStream bos = null; if ( inputFromFile) { File baseFile = new File(getClass().getResource("/").getFile()); bis = new BufferedInputStream(new FileInputStream(new File(baseFile,(filenamePrefix + inSuffix))),INPUT_BUFFER_SIZE); bos = new BufferedOutputStream(new FileOutputStream(new File(baseFile,(filenamePrefix + outSuffix)))); out = new PrintStream(bos); } else {bis = new BufferedInputStream(System.in,INPUT_BUFFER_SIZE); bos = new BufferedOutputStream(System.out); out = new PrintStream(bos); }scanner = new ByteScanner(bis,BUF_SIZE_INPUT,BUF_SIZE); writer = new ByteWriter(bos,BUF_SIZE_OUT); solve(); out.flush(); }catch (Exception e){ e.printStackTrace(); System.exit(1); } } public interface Constants{ static final byte ZERO = '0'; static final byte NINE = '9'; static final byte SPACEBAR = ' '; static final byte MINUS = '-'; static final char FLOAT_POINT = '.'; } public static class EofException extends IOException{ } public static class ByteWriter implements Constants{ int bufSize = 1024; byte[] byteBuf = new byte[bufSize]; OutputStream os ; public ByteWriter( OutputStream os, int bufSize){ this.os = os; this.bufSize = bufSize; } } public static class ByteScanner implements Constants{ InputStream is ; public ByteScanner( InputStream is, int bufSizeInput, int bufSize){ this.is = is; this.bufSizeInput = bufSizeInput; this.bufSize = bufSize; byteBufInput = new byte[this.bufSizeInput]; byteBuf = new byte[this.bufSize]; } public ByteScanner( byte[] data){ byteBufInput = data; bufSizeInput = data.length; bufSize = data.length; byteBuf = new byte[bufSize]; byteRead = data.length; bytePos = 0; } private int bufSizeInput ; private int bufSize ; byte[] byteBufInput ; byte by = -1; int byteRead = -1; int bytePos = -1; byte[] byteBuf ; int totalBytes ; boolean eofMet = false; private byte nextByte()throws IOException { if ( ((bytePos < 0) || (bytePos >= byteRead))) {byteRead = ((is == null)?-1:is.read(byteBufInput)); bytePos = 0; if ( (byteRead < 0)) {byteBufInput[bytePos] = -1; if ( eofMet) throw (new EofException()); eofMet = true; } } return byteBufInput[bytePos++];} private void readToken()throws IOException { readToken((byte)0x21); } private void readToken( byte acceptFrom)throws IOException { totalBytes = 0; while(((by = nextByte()) < acceptFrom));byteBuf[totalBytes++] = by; while(((by = nextByte()) >= acceptFrom)){byteBuf[totalBytes++] = by; }} public int nextInt()throws IOException { readToken(); int num = 0,i = 0;  boolean sign = false; if ( (byteBuf[i] == MINUS)) {sign = true; i++; } for ( ;(i < totalBytes);i++) {num *= 10; num += (byteBuf[i] - ZERO); }return (sign?-num:num);} } public static void main( String[] args){ new Codeforces_R136_Div1_A().run(); } }
2	public class Main2{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long s = input.nextLong();  long e = input.nextLong(); System.out.println(count(s,e)); } public static long count( long s, long e){ int ncount = 0;  long es = e; while((es != 0)){es /= 2; ncount++; }while((ncount >= 0)){if ( (((((s >> (ncount - 1)) & 1) == 1) && (((e >> (ncount - 1)) & 1) == 0)) || ((((s >> (ncount - 1)) & 1) == 0) && (((e >> (ncount - 1)) & 1) == 1)))) {break;} ncount--; }if ( (ncount >= 0)) {return ((long)Math.pow(2,ncount) - 1);} else {return 0;}} }
4	public class P35C{ int n ,m ; int[][] fire ; public P35C()throws FileNotFoundException{ Scanner in = new Scanner(new FileReader("input.txt")); n = in.nextInt(); m = in.nextInt(); int k = in.nextInt(); fire = new int[k][2]; for ( int i = 0;(i < k);i++) {fire[i][0] = in.nextInt(); fire[i][1] = in.nextInt(); }in.close(); int[] last = new int[2];  int lastBurn = -1; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) { int burn = Integer.MAX_VALUE; for ( int l = 0;(l < k);l++) { int burnAux = dist(i,j,fire[l][0],fire[l][1]); burn = Math.min(burn,burnAux); }if ( (burn >= lastBurn)) {lastBurn = burn; last[0] = i; last[1] = j; } }} PrintStream out = new java.io.PrintStream("output.txt"); out.print(((last[0] + " ") + last[1])); out.close(); } int dist( int x1, int y1, int x2, int y2){ return (Math.abs((x2 - x1)) + Math.abs((y2 - y1)));} public static void main( String[] args)throws FileNotFoundException { new P35C(); } }
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)); } }
0	public class Counterexample{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long l = sc.nextLong(),r = sc.nextLong(); if ( (((l % 2) == 0) && ((r - l) >= 2))) System.out.print(((((l + " ") + (l + 1)) + " ") + (l + 2))); else if ( (((l % 2) == 1) && ((r - l) >= 3))) System.out.print((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); else System.out.print("-1"); } }
5	public class pr988B{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int n = Integer.parseInt(br.readLine());  ArrayList<String> a = new ArrayList<>(); for ( int i = 0;(i < n);i++) {a.add(br.readLine()); }if ( solve(n,a)) {out.println("YES"); for ( String s :a) {out.println(s); }} else out.println("NO"); out.flush(); out.close(); } static private boolean solve( int n, ArrayList<String> a){ a.sort(Comparator.comparingInt(String::length)); for ( int i = 0;(i < (n - 1));i++) {if ( !a.get((i + 1)).contains(a.get(i))) return false; }return true;} }
2	public class TaskB_AF{ 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_cf371 solver = new TaskB_cf371(); solver.solve(1,in,out); out.close(); } static class TaskB_cf371{ List<Rectangle> rects ; public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int xLeft = 1,xRight = n;  int xSeparate = -1; while((xLeft <= xRight)){ int e = ((xLeft + xRight) / 2);  int t = makeRequest(in,out,1,1,e,n); if ( (t == 1)) {xSeparate = e; xRight = (e - 1); } else if ( (t == 0)) {xLeft = (e + 1); } else {xRight = (e - 1); }}rects = new ArrayList<Rectangle>(); if ( ((xSeparate != -1) && (makeRequest(in,out,(xSeparate + 1),1,n,n) == 1))) {detectRectangle(in,out,1,1,xSeparate,n); detectRectangle(in,out,(xSeparate + 1),1,n,n); out.print("! "); for ( Rectangle r :rects) {out.print((r.toString() + " ")); }out.println(); out.flush(); return ;} int yLeft = 1,yRight = n;  int ySeparate = -1; while((yLeft <= yRight)){ int e = ((yLeft + yRight) / 2);  int t = makeRequest(in,out,1,1,n,e); if ( (t == 1)) {ySeparate = e; yRight = (e - 1); } else if ( (t == 0)) {yLeft = (e + 1); } else {yRight = (e - 1); }}if ( (ySeparate != -1)) {detectRectangle(in,out,1,1,n,ySeparate); detectRectangle(in,out,1,(ySeparate + 1),n,n); out.print("! "); for ( Rectangle r :rects) {out.print((r.toString() + " ")); }out.println(); out.flush(); return ;} throw (new AssertionError("!"));} private void detectRectangle( InputReader in, PrintWriter out, int xMin, int yMin, int xMax, int yMax){ int xLeft = -1,xRight = -1,yLeft = -1,yRight = -1;  int left = xMin,right = xMax; while((left <= right)){ int e = ((left + right) / 2); if ( (makeRequest(in,out,xMin,yMin,e,yMax) == 1)) {xRight = e; right = (e - 1); } else {left = (e + 1); }}left = xMin; right = xRight; while((left <= right)){ int e = ((left + right) / 2); if ( (makeRequest(in,out,e,yMin,xRight,yMax) == 1)) {xLeft = e; left = (e + 1); } else {right = (e - 1); }}left = yMin; right = yMax; while((left <= right)){ int e = ((left + right) / 2); if ( (makeRequest(in,out,xLeft,yMin,xRight,e) == 1)) {yRight = e; right = (e - 1); } else {left = (e + 1); }}left = yMin; right = yRight; while((left <= right)){ int e = ((left + right) / 2); if ( (makeRequest(in,out,xLeft,e,xRight,yRight) == 1)) {yLeft = e; left = (e + 1); } else {right = (e - 1); }}rects.add(new Rectangle(xLeft,yLeft,xRight,yRight)); } private int makeRequest( InputReader in, PrintWriter out, int x1, int y1, int x2, int y2){ out.print(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); out.println(); out.flush(); return in.nextInt();} class Rectangle{ int x1 ; int x2 ; int y1 ; int y2 ; public Rectangle( int x1, int y1, int x2, int y2){ this.x1 = x1; this.x2 = x2; this.y1 = y1; this.y2 = y2; } public String toString(){ StringBuilder b = new StringBuilder(""); b.append(x1).append(' '); b.append(y1).append(' '); b.append(x2).append(' '); b.append(y2); return b.toString();} } } static 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(); }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());} } }
5	public class A111_div2{ static boolean test = false; static String testDataFile = "testdata.txt"; static String feedFile = "feed.txt"; CompetitionType type = CompetitionType.CF; static private String ENDL = "\n"; private void solve()throws Throwable { int n = iread();  int[] vals = new int[n];  double tot = 0; for ( int i = 0;(i < n);i++) { int value = iread(); vals[i] = value; tot += value; }Arrays.sort(vals); int pick = 0;  int worth = 0; for ( int i = (vals.length - 1);(i >= 0);i--) {worth += vals[i]; pick++; if ( (worth > (tot / 2.0d))) {break;} }out.write((pick + ENDL)); out.flush(); } public int iread()throws Exception { return Integer.parseInt(wread());} public String wread()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)throws Throwable { if ( test) { BufferedReader testdataReader = new BufferedReader(new FileReader(testDataFile));  String readLine = testdataReader.readLine();  int casenr = 0; out:while(true){ BufferedWriter w = new BufferedWriter(new FileWriter(feedFile)); if ( !readLine.equals("input")) {break;} while(true){readLine = testdataReader.readLine(); if ( readLine.equals("output")) {break;} w.write((readLine + "\n")); }w.close(); System.out.println((("Answer on case " + casenr) + ": ")); new A111_div2().solve(); System.out.println("Expected answer: "); while(true){readLine = testdataReader.readLine(); if ( (readLine == null)) {break;} if ( readLine.equals("input")) {break;} System.out.println(readLine); }System.out.println("----------------"); }testdataReader.close(); } else {new A111_div2().solve(); }out.close(); } public A111_div2()throws Throwable{ if ( test) {in = new BufferedReader(new FileReader(new File(feedFile))); } } InputStreamReader inp = new InputStreamReader(System.in); BufferedReader in = new BufferedReader(inp); static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); enum CompetitionType{CF,OTHER}}
6	public class ProblemD{ private double survive( int round, int set){ if ( (sur[round][set] >= 0)) return sur[round][set]; double res = 0.0;  int count = 0; for ( int i = 0;(i < n);i++) {if ( ((set & (1 << i)) > 0)) { double res2 = 0.0; for ( int j = 0;(j < n);j++) if ( ((set & (1 << j)) == 0)) {res2 += (survive((round - 1),(set + (1 << j))) * a[i][j]); count++; } res += res2; } }count = ((((n - round) + 1) * (n - round)) / 2); sur[round][set] = (res / count); return sur[round][set];} int n ; double[][] a ,sur ; public void solve(){ boolean oj = true; try{ Reader reader = (oj?new InputStreamReader(System.in):new FileReader("inputD.txt"));  Writer writer = (oj?new OutputStreamWriter(System.out):new FileWriter("outputD.txt"));  BufferedReader br = new BufferedReader(reader);  PrintWriter out = new PrintWriter(writer);  MyTokenizer tok = new MyTokenizer(br.readLine()); n = (int)tok.getNum(); a = new double[n][n]; int all = ((1 << n) - 1); sur = new double[n][(all + 1)]; for ( int i = 0;(i < n);i++) {tok = new MyTokenizer(br.readLine()); for ( int j = 0;(j < n);j++) {a[i][j] = tok.getNum(); }for ( int j = 0;(j <= all);j++) sur[i][j] = -1; } DecimalFormat format = new DecimalFormat("0.000000"); sur[0][all] = 1; double[] res = new double[n]; for ( int i = 0;(i < n);i++) {res[i] = survive((n - 1),(1 << i)); String sres = format.format(res[i]).replace(',','.'); out.printf("%s ",sres); }br.close(); out.close(); reader.close(); writer.close(); }catch (Exception ex){ ex.printStackTrace(); } } public static void main( String[] args){ ProblemD f = new ProblemD(); f.solve(); } private class MyTokenizer{ private String s ; private int cur ; public MyTokenizer( String s){ this.s = s; cur = 0; } public void skip(){ while(((cur < s.length()) && ((s.charAt(cur) == ' ') || (s.charAt(cur) == '\n')))){cur++; }} public double getNum(){ skip(); String snum = ""; while(((cur < s.length()) && (((s.charAt(cur) >= '0') && (s.charAt(cur) <= '9')) || (s.charAt(cur) == '.')))){snum += s.charAt(cur); cur++; }return Double.valueOf(snum);} } }
2	public class CFContest{ public static void main( String[] args)throws Exception { boolean local = (System.getProperty("ONLINE_JUDGE") == null);  boolean async = false;  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; public Task( FastIO io, Debug debug){ this.io = io; this.debug = debug; } @Override public void run(){ solve(); } public void solve(){ int n = io.readInt();  int k = io.readInt();  int l = 0;  int r = n; while((l < r)){ int m = (((l + r) + 1) >> 1); if ( (when(n,m) < k)) {r = (m - 1); } else {l = m; }}io.cache.append(l); } public long when( int n, int t){ long put = (n - t); return ((((put + 1) * put) / 2) - t);} } public static class FastIO{ public final StringBuilder cache = new StringBuilder(); 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 << 13)]; 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 + " = ")); } } }
1	public class Main{ Scanner in ; PrintWriter out ; boolean isFirst( String line){ int pos = 0; while(((pos < line.length()) && Character.isLetter(line.charAt(pos)))){pos++; }while(((pos < line.length()) && Character.isDigit(line.charAt(pos)))){pos++; }return (pos != line.length());} void solve(){ int n = in.nextInt(); in.nextLine(); for ( int i = 1;(i <= n);i++) { String line = in.nextLine(); line = line.toUpperCase(); if ( isFirst(line)) { int pos = 1;  long row = 0; while(Character.isDigit(line.charAt(pos))){row *= 10; row += (line.charAt(pos) - '0'); pos++; }pos++; long col = 0; while(((pos < line.length()) && Character.isDigit(line.charAt(pos)))){col *= 10; col += (line.charAt(pos) - '0'); pos++; } StringBuilder sb = new StringBuilder(); while((col > 0)){sb.append((char)('A' + ((col - 1) % 26))); col--; col /= 26; }sb = sb.reverse(); out.print(sb); out.println(row); } else { int pos = 0;  long col = 0; while(((pos < line.length()) && Character.isLetter(line.charAt(pos)))){col *= 26; col += ((line.charAt(pos) - 'A') + 1); pos++; } long row = 0; while(((pos < line.length()) && Character.isDigit(line.charAt(pos)))){row *= 10; row += (line.charAt(pos) - '0'); pos++; }out.println(((("R" + row) + "C") + col)); }}} void run(){ in = new Scanner(System.in); out = new PrintWriter(System.out); try{solve(); }finally{out.close(); }} public static void main( String[] args){ new Main().run(); } }
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));} }
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(); } }
2	public class Div1_503B{ 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 N = Integer.parseInt(reader.readLine()); printer.println("? 1"); printer.flush(); int v1 = Integer.parseInt(reader.readLine()); printer.println(("? " + (1 + (N / 2)))); printer.flush(); int v2 = Integer.parseInt(reader.readLine()); if ( (((v1 + v2) % 2) != 0)) {printer.println("! -1"); printer.close(); return ;} if ( (v1 == v2)) {printer.println("! 1"); printer.close(); return ;} boolean less = (v1 < v2);  int low = 1;  int high = (1 + (N / 2)); while((low != high)){ int mid = ((low + high) >> 1); printer.println(("? " + mid)); printer.flush(); int r1 = Integer.parseInt(reader.readLine());  int q2 = (mid + (N / 2)); if ( (q2 > N)) {q2 -= N; } printer.println(("? " + q2)); printer.flush(); int r2 = Integer.parseInt(reader.readLine()); if ( (r1 == r2)) {printer.println(("! " + mid)); printer.close(); return ;} if ( ((r1 < r2) == less)) {low = (mid + 1); } else {high = (mid - 1); }}printer.println(("! " + low)); printer.close(); return ;} }
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));} }
3	public class Main{ static long[][] c ; static long[] arr ; static long n ,m ,k ; static long dp[][][] ; public static void main( String[] args)throws IOException { Reader.init(System.in); int n = Reader.nextInt();  int[] arr = new int[n];  int[] mark = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = Reader.nextInt(); }Arrays.sort(arr); int[] v = new int[n];  int ans = 0; for ( int i = 0;(i < n);i++) {if ( (v[i] == 0)) {for ( int j = i;(j < n);j++) {if ( ((arr[j] % arr[i]) == 0)) {v[j] = arr[i]; } }} } TreeSet<Integer> s = new TreeSet<>(); for ( int i = 0;(i < n);i++) {s.add(v[i]); }System.out.println(s.size()); } }
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 N = Integer.parseInt(input[0]),M = Integer.parseInt(input[1]);  boolean[][] connected = new boolean[(N + 1)][N];  long[][] walks = new long[(1 << N)][N];  long res = 0; for ( int i = 0;(i < M);i++) {input = kek.readLine().split(" "); int A = (Integer.parseInt(input[0]) - 1),B = (Integer.parseInt(input[1]) - 1); connected[A][B] = connected[B][A] = true; }for ( int i = 0;(i < N);i++) {walks[(1 << i)][i] = 1; }for ( int i = 1;(i < (1 << N));i++) { int temp = (int)(Math.log((i & -i)) / 0.6931471805599453); for ( int j = 0;(j < N);j++) {if ( ((((1 << j) & i) > 0) && (j != temp))) {for ( int k = 0;(k < N);k++) {if ( connected[k][j]) {walks[i][j] += walks[(i ^ (1 << j))][k]; } } int count = 0,track = i; while((track > 0)){if ( ((track % 2) == 1)) {count++; } track /= 2; }if ( ((count >= 3) && connected[temp][j])) {res += walks[i][j]; } } }}outkek.println((res / 2)); kek.close(); outkek.close(); } }
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)));} }
0	public class A{ static void solve()throws IOException { long a = nextLong(),b = nextLong();  long answer = get(a,b); out.println(answer); } static private long get( long p, long q){ if ( (p == 0)) {return 0;} if ( (q == 1)) {return p;} if ( (p == 1)) {return q;} if ( (p >= q)) {return ((p / q) + get((p % q),q));} return ((q / p) + get(p,(q % p)));} static BufferedReader br ; static StringTokenizer st ; static PrintWriter out ; public static void main( String[] args)throws IOException { InputStream input = System.in;  PrintStream output = System.out;  File file = new File("a.in"); if ( (file.exists() && file.canRead())) {input = new FileInputStream(file); } br = new BufferedReader(new InputStreamReader(input)); out = new PrintWriter(output); solve(); out.close(); } static long nextLong()throws IOException { return Long.parseLong(nextToken());} 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();} }
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 A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long l = in.nextLong();  long r = in.nextLong();  long a = 0;  long b = 0;  long c = 0; if ( ((r - l) < 2)) System.out.println(-1); else if ( (((r - l) < 3) && ((l % 2) == 1))) System.out.println(-1); else {if ( ((l % 2) == 0)) {a = l; b = (l + 1); c = (l + 2); } else {if ( (l == 1)) {a = 2; b = 3; c = 4; } else {a = (l + 1); b = (l + 2); c = (l + 3); }}System.out.println(((((a + " ") + b) + " ") + c)); }} }
0	public class sample{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); System.out.println((n + (n / 2))); } }
4	public class C429{ static InputStream is ; static int[] counts ; static int[] sufsum ; static long mod = (long)(1e9 + 7); static long[][] choose ; static long[][] memo ; public static void main( String[] args)throws IOException { is = System.in; int n = ni();  int[] a = na(n);  long[] fact = new long[(n + 2)]; fact[0] = 1; for ( int i = 1;(i < fact.length);i++) {fact[i] = ((fact[(i - 1)] * i) % mod); } HashMap<Integer,ArrayList<Integer>> hm = new HashMap<>(); for ( int i = 0;(i < a.length);i++) { int cp = a[i];  int sfree = 1; for ( int p = 2;(((p * p) <= a[i]) && (cp > 1));p++) { int count = 0; while(((cp % p) == 0)){cp /= p; count++; }if ( ((count % 2) == 1)) sfree *= p; }if ( (cp != 1)) sfree *= cp; if ( !hm.containsKey(sfree)) hm.put(sfree,new ArrayList<Integer>()); hm.get(sfree).add(a[i]); }counts = new int[hm.size()]; int dex = 0;  long bigmult = 1; for ( Integer key :hm.keySet()) { ArrayList<Integer> list = hm.get(key); counts[dex++] = list.size(); bigmult = ((bigmult * fact[list.size()]) % mod); }Arrays.sort(counts); sufsum = new int[counts.length]; for ( int i = (counts.length - 2);(i >= 0);i--) {sufsum[i] = (sufsum[(i + 1)] + counts[(i + 1)]); }choose = new long[((2 * n) + 3)][((2 * n) + 3)]; for ( int i = 0;(i < choose.length);i++) {choose[i][0] = 1; for ( int j = 1;(j <= i);j++) {choose[i][j] = ((choose[(i - 1)][j] + choose[(i - 1)][(j - 1)]) % mod); }}memo = new long[counts.length][700]; for ( int i = 0;(i < memo.length);i++) {Arrays.fill(memo[i],-1); }System.out.println(((bigmult * dp((counts.length - 2),(counts[(counts.length - 1)] - 1))) % mod)); } static long dp( int dex, int need){ if ( (dex == -1)) {if ( (need == 0)) return 1; return 0;} if ( (memo[dex][need] != -1)) return memo[dex][need]; int numspots = (sufsum[dex] + 1);  long ret = 0;  int c = counts[dex]; for ( int numdivs = 1;(numdivs <= c);numdivs++) { long toadd = 0; for ( int gotoneed = 0;((gotoneed <= need) && (gotoneed <= numdivs));gotoneed++) { long temp = choose[need][gotoneed]; temp *= choose[(numspots - need)][(numdivs - gotoneed)]; temp %= mod; temp *= dp((dex - 1),(((need - gotoneed) + c) - numdivs)); temp %= mod; toadd += temp; toadd %= mod; }toadd *= choose[(c - 1)][(numdivs - 1)]; toadd %= mod; ret += toadd; ret %= mod; }return memo[dex][need] = ret;} static private byte[] inbuf = new byte[1024]; public static int lenbuf = 0,ptrbuf = 0; static 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++];} static private boolean isSpaceChar( int c){ return ((c >= 33) && (c <= 126));} static private int skip(){ int b ; while((((b = readByte()) != -1) && isSpaceChar(b)));return b;} static private String ns(){ int b = skip();  StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){sb.appendCodePoint(b); b = readByte(); }return sb.toString();} static 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));} static private int[] na( int n){ int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = ni(); return a;} static 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(); }} }
2	public class B2{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  BigInteger n = new BigInteger(scan.next());  BigInteger k = new BigInteger(scan.next());  BigInteger a = k.subtract(bi(1));  BigInteger lim = k.multiply(a).divide(bi(2)); lim = lim.add(bi(1)); if ( (n.compareTo(lim) > 0)) {System.out.println(-1); } else {if ( n.equals(1)) {System.out.println(0); } else { BigInteger remain2 = lim.subtract(n).add(bi(1)); remain2 = remain2.multiply(bi(2)); double temp = remain2.doubleValue();  long flr = (long)Math.sqrt(temp);  BigInteger flr2 = bi(flr);  BigInteger rnd2 = remain2.subtract(flr2.multiply(flr2));  long rnd = (remain2.longValue() - (flr * flr)); if ( (rnd2.compareTo(flr2) <= 0)) {System.out.println(k.subtract(flr2)); } else {System.out.println(k.subtract(flr2.add(bi(1)))); }}}} public static BigInteger bi( int n1){ return new BigInteger(("" + n1));} public static BigInteger bi( long n1){ return new BigInteger(("" + n1));} }
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 * 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))); } }
6	public class x1185G1b{ static long MOD = 1000000007L; public static void main( String[] args)throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(infile.readLine());  int N = Integer.parseInt(st.nextToken());  int T = Integer.parseInt(st.nextToken());  Song[] arr = new Song[N]; for ( int i = 0;(i < N);i++) {st = new StringTokenizer(infile.readLine()); int a = Integer.parseInt(st.nextToken());  int b = (Integer.parseInt(st.nextToken()) - 1); arr[i] = new Song(a,b); } long[][] dp = new long[(1 << N)][3]; Arrays.fill(dp[0],1L); for ( int mask = 0;(mask < dp.length);mask++) {for ( int i = 0;(i < N);i++) if ( ((mask & (1 << i)) == 0)) { Song c = arr[i]; if ( ((mask == 0) && (c.t <= T))) {dp[(mask | (1 << i))][c.g]++; dp[(mask | (1 << i))][c.g] %= MOD; } else {for ( int gen = 0;(gen < 3);gen++) if ( (gen != c.g)) {dp[(mask | (1 << i))][c.g] += dp[mask][gen]; dp[(mask | (1 << i))][c.g] %= MOD; } }} } long res = 0L; for ( int mask = 1;(mask < dp.length);mask++) for ( int i = 0;(i < 3);i++) { int sum = 0; for ( int b = 0;(b < N);b++) if ( ((mask & (1 << b)) > 0)) sum += arr[b].t; if ( (sum == T)) res = ((res + dp[mask][i]) % MOD); }System.out.println(res); } } class Song{ public int t ; public int g ; public Song( int a, int b){ t = a; g = b; } }
6	public class C{ static int[] DP ; static Point[] Next ; static int[][] pair ; static int[] single ; static int n ; public static int get( int mask){ if ( ((mask + 1) == (1 << n))) return 0; if ( (DP[mask] != -1)) return DP[mask]; int x = 0; for ( ;;x++) if ( ((mask & (1 << x)) == 0)) break; int min = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) {if ( (((mask & (1 << i)) != 0) || (i == x))) continue; int temp = (pair[x][i] + get(((mask | (1 << i)) | (1 << x)))); if ( (temp < min)) {min = temp; Next[mask] = new Point(x,i); } } int temp = (single[x] + get((mask | (1 << x)))); if ( (temp < min)) {min = temp; Next[mask] = new Point(x,-1); } return DP[mask] = min;} public static void main( String[] args){ Scanner in = new Scanner(System.in);  Point start = new Point(in.nextInt(),in.nextInt()); n = in.nextInt(); Point[] A = new Point[n]; for ( int i = 0;(i < n);i++) A[i] = new Point(in.nextInt(),in.nextInt()); DP = new int[(1 << n)]; Next = new Point[(1 << n)]; Arrays.fill(DP,-1); pair = new int[n][n]; single = new int[n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) { int dx1 = (A[i].x - start.x);  int dy1 = (A[i].y - start.y);  int dx2 = (A[j].x - A[i].x);  int dy2 = (A[j].y - A[i].y);  int dx3 = (A[j].x - start.x);  int dy3 = (A[j].y - start.y); pair[i][j] = ((((((dx1 * dx1) + (dy1 * dy1)) + (dx2 * dx2)) + (dy2 * dy2)) + (dx3 * dx3)) + (dy3 * dy3)); single[i] = (2 * ((dx1 * dx1) + (dy1 * dy1))); } int ans = get(0); System.out.println(ans); int mask = 0; while(((mask + 1) != (1 << n))){ Point temp = Next[mask]; if ( (temp.y == -1)) System.out.print((("0 " + (temp.x + 1)) + " ")); else {System.out.print((((("0 " + (temp.x + 1)) + " ") + (temp.y + 1)) + " ")); mask |= (1 << temp.y); }mask |= (1 << temp.x); }System.out.println("0"); } }
3	public class GB2017C{ static int n ,r ; static int[] x ; static Map<Integer,Double> horo ; public static void main( String[] args){ FastScanner sc = new FastScanner();  StringBuilder sb = new StringBuilder(); n = sc.nextInt(); r = sc.nextInt(); x = new int[n]; horo = new HashMap<Integer,Double>(); for ( int x = 0;(x <= (r * 2));x++) { double y = (2.0 * Math.sqrt(((r * r) - ((r - (x / 2.0)) * (r - (x / 2.0)))))); horo.put(x,y); }for ( int i = 0;(i < n);i++) {x[i] = sc.nextInt(); } List<Double> y = new ArrayList<Double>(); for ( int i = 0;(i < n);i++) { double max = r; for ( int j = 0;(j < y.size());j++) { int dx = intersects(i,j); if ( (dx >= 0)) { double dy = horo.get(dx); max = Math.max(max,(dy + y.get(j))); } }y.add(max); }for ( int i = 0;(i < n);i++) {sb.append((y.get(i) + " ")); }System.out.println(sb); } static int intersects( int i, int j){ if ( (Math.abs((x[i] - x[j])) <= (2 * r))) {return ((2 * r) - Math.abs((x[i] - x[j])));} else return -1;} 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());} long nextLong(){ return Long.parseLong(next());} } }
4	public class ExplorerSpace{ static private 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 long[][][] 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 long[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] = Long.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(); }} static private 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(); } }
3	public class NewYearAndCurling{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  StringTokenizer t = new StringTokenizer(in.readLine());  int N = Integer.parseInt(t.nextToken());  int R = Integer.parseInt(t.nextToken());  int[] x = new int[N]; t = new StringTokenizer(in.readLine()); for ( int i = 0;(i < N);++i) x[i] = Integer.parseInt(t.nextToken()); double[] y = new double[N]; for ( int i = 0;(i < N);++i) { double max = R; for ( int j = 0;(j < i);++j) { int xDiff = Math.abs((x[i] - x[j])); if ( (xDiff <= (2 * R))) max = Math.max(max,(y[j] + Math.sqrt((((4 * R) * R) - (xDiff * xDiff))))); }y[i] = max; }out.print(y[0]); for ( int i = 1;(i < N);++i) out.print((" " + y[i])); out.println(); in.close(); out.close(); } }
3	public class Solution1 implements Runnable{ static final int MAX = 1000000007; 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 Solution1(),"Solution1",(1 << 26)).start(); } public static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} static int max = -1; }
1	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n ,k ; n = sc.nextInt(); k = sc.nextInt(); int a = ((n - k) / 2);  StringBuilder s = new StringBuilder();  int i ; while((s.length() < n)){i = 0; while(((i < a) && (s.length() < n))){s.append("0"); i++; }if ( (s.length() < n)) s.append("1"); }System.out.println(s); } }
5	public class Main{ public static void main( String[] args){ Scanner read = new Scanner(new BufferedInputStream(System.in));  int n = read.nextInt();  int[] arr = new int[n];  int sum = 0;  int sum2 = 0;  int coin = 0; for ( int i = 0;(i < n);i++) {arr[i] = read.nextInt(); sum += arr[i]; }Arrays.sort(arr); for ( int i = (n - 1);(i >= 0);i--) {sum2 += arr[i]; sum -= arr[i]; coin++; if ( (sum2 > sum)) break; }System.out.println(coin); } }
2	public class D{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  long l = s.nextLong();  long r = s.nextLong();  long a = (l ^ r);  long b = a; while((b != 0)){a = b; b = ((b - 1) & b); }if ( (a != 0)) {a = ((a << 1) - 1); } System.out.println(a); } }
1	public class Abra{ void solve()throws IOException { int n = nextInt(); br.readLine(); int h = 0,t = 0;  String s = br.readLine(); for ( int i = 0;(i < n);i++) {if ( ((char)s.charAt(i) == 'H')) h++; else t++; } int m = 10001; for ( int j = 0;(j < n);j++) { int z = 0; for ( int i = 0;(i < n);i++) {if ( ((i + 1) <= h)) {if ( (s.charAt(((i + j) % n)) != 'H')) z++; } else {if ( (s.charAt(((i + j) % n)) != 'T')) z++; }}if ( (z < m)) m = z; }out.println((m / 2)); } public static void main( String[] args)throws IOException { new Abra().run(); } 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;} 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{ static private 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(); } 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 selectionTime = 0; void run()throws IOException { long 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(); }
5	public class Task{ static final boolean readFromFile = false; static final String fileInputName = "input.txt",fileOutputName = "output.txt"; public static void main( String[] args){ FileInputStream fileInputStream ;  FileOutputStream fileOutputStream ;  InputStream inputStream = System.in;  OutputStream outputStream = System.out; if ( readFromFile) {try{fileInputStream = new FileInputStream(new File(fileInputName)); fileOutputStream = new FileOutputStream(new File(fileOutputName)); }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{ private PrintWriter out ; private InputReader in ; public void solve(){ int n = in.nextInt();  double t = in.nextDouble(),a[] = new double[n],x[] = new double[n]; for ( int i = 0;(i < n);i++) {x[i] = in.nextDouble(); a[i] = in.nextDouble(); } int ans = 2; for ( int i = 0;(i < (n - 1));i++) for ( int j = (i + 1);(j < n);j++) if ( (x[j] < x[i])) { double buf = x[i]; x[i] = x[j]; x[j] = buf; buf = a[i]; a[i] = a[j]; a[j] = buf; } for ( int i = 0;(i < (n - 1));i++) {if ( (((x[i] + (a[i] / 2)) + t) < (x[(i + 1)] - (a[(i + 1)] / 2)))) ans += 2; if ( (((x[i] + (a[i] / 2)) + t) == (x[(i + 1)] - (a[(i + 1)] / 2)))) ans++; }out.println(ans); } Solver( InputReader in, PrintWriter out){ this.in = in; this.out = out; } } class InputReader{ StringTokenizer tok ; BufferedReader buf ; 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 int nextInt(){ return Integer.parseInt(next());} public double nextDouble(){ return Double.parseDouble(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(); } } }
2	public class A{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int mod = ((int)1e9 + 9); long n ,m ,k ; void run(){ n = sc.nextLong(); m = sc.nextLong(); k = sc.nextLong(); solve(); } void solve(){ long ans = 0;  long s = (n - m);  long remain = max((n - (s * k)),0); ans = (m - remain); long r = (remain % k); ans = ((ans + r) % mod); remain -= r; long a = (remain / k);  long add = (((((powMod(2,a,mod) - 1) * k) % mod) * 2) % mod); ans = ((ans + add) % mod); println((ans + "")); } long powMod( long x, long k, long mod){ if ( (k == 0)) {return (1 % mod);} else if ( ((k % 2) == 0)) {return powMod(((x * x) % mod),(k / 2),mod);} else {return ((x * powMod(x,(k - 1),mod)) % mod);}} 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 A().run(); } }
2	public class templ implements Runnable{ void merge1( int[] arr, int l, int m, int r){ int n1 = ((m - l) + 1);  int n2 = (r - m);  int L[] = new int[n1];  int R[] = new int[n2]; for ( int i = 0;(i < n1);++i) L[i] = arr[(l + i)]; for ( int j = 0;(j < n2);++j) R[j] = arr[((m + 1) + j)]; int i = 0,j = 0;  int k = l; while(((i < n1) && (j < n2))){if ( (L[i] <= R[j])) {arr[k] = L[i]; i++; } else {arr[k] = R[j]; j++; }k++; }while((i < n1)){arr[k] = L[i]; i++; k++; }while((j < n2)){arr[k] = R[j]; j++; k++; }} void sort1( int[] arr, int l, int r){ if ( (l < r)) { int m = ((l + r) / 2); sort1(arr,l,m); sort1(arr,(m + 1),r); merge1(arr,l,m,r); } } public static void main( String[] args)throws Exception { new Thread(null,new templ(),"templ",(1 << 27)).start(); } static class InputReader{ private final InputStream stream ; private final byte[] buf = new byte[8192]; private int curChar ,snumChars ; public InputReader( InputStream stream){ this.stream = stream; } 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 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));} } }
3	public class C{ static int n ; static double sqr( double v){ return (v * v);} static double sqrt( double v){ return Math.sqrt(v);} static double r ,x[] ,res[] ; static void MainMethod()throws Exception { n = reader.nextInt(); r = reader.nextDouble(); int i ,j ; x = new double[n]; res = new double[n]; for ( i = 0;(i < n);i++) x[i] = reader.nextDouble(); res[0] = r; for ( i = 1;(i < n);i++) {res[i] = r; for ( j = 0;(j < i);j++) {if ( (Math.abs((x[i] - x[j])) <= (2 * r))) {res[i] = Math.max(res[i],(sqrt((sqr((2 * r)) - sqr((x[i] - x[j])))) + res[j])); } }}for ( i = 0;(i < n);i++) printer.print((res[i] + " ")); } public static void main( String[] args)throws Exception { MainMethod(); printer.close(); } static PrintWriter printer = new PrintWriter(new OutputStreamWriter(System.out)); }
3	public class MainG{ static StdIn in = new StdIn(); static PrintWriter out = new PrintWriter(System.out); static long M = ((long)1e9 + 7); public static void main( String[] args){ char[] cs = in.next().toCharArray();  int n = cs.length;  int[] x = new int[n]; for ( int i = 0;(i < n);++i) x[i] = (cs[i] - '0'); long[] dp1 = new long[(n + 1)]; for ( int i = 0;(i < n);++i) dp1[(i + 1)] = ((x[i] + (dp1[i] * 10)) % M); long ans = 0; for ( int d1 = 1;(d1 <= 9);++d1) { long[][] dp2 = new long[2][(n + 1)]; for ( int i = 0;(i < n);++i) {dp2[0][(i + 1)] = ((x[i] >= d1)?(((10 * dp2[0][i]) + 1) % M):dp2[0][i]); dp2[1][(i + 1)] = ((x[i] >= d1)?(((10 * dp2[1][i]) + dp1[i]) % M):dp2[1][i]); for ( int d2 = 0;(d2 < x[i]);++d2) dp2[1][(i + 1)] = ((((d2 >= d1)?(((10 * (dp2[0][i] + dp2[1][i])) + dp1[i]) + 1):(dp2[0][i] + dp2[1][i])) + dp2[1][(i + 1)]) % M); for ( int d2 = (x[i] + 1);(d2 <= 9);++d2) dp2[1][(i + 1)] = ((((d2 >= d1)?((10 * dp2[1][i]) + dp1[i]):dp2[1][i]) + dp2[1][(i + 1)]) % M); }ans += (dp2[0][n] + dp2[1][n]); }out.println((ans % M)); out.close(); } 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(); } } }
1	public class Main{ public static void main( String[] args)throws Exception { int i ,j ,k ;  int counter[] = new int[2];  int a[] = new int[200];  int needed ;  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int N = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine()); for ( i = 1;(i <= N);i++) {a[i] = Integer.parseInt(st.nextToken()); counter[(a[i] % 2)]++; }if ( (counter[0] == 1)) {needed = 0; } else {needed = 1; }for ( i = 1;(i <= N);i++) {if ( ((a[i] % 2) == needed)) {System.out.println(i); return ;} }} }
5	public class A{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; void solve()throws IOException { int n = nextInt();  int[] a = new int[n];  boolean onlyOnes = true; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); if ( (a[i] != 1)) onlyOnes = false; }Arrays.sort(a); if ( onlyOnes) {for ( int i = 0;(i < (n - 1));i++) out.print("1 "); out.print(2); } else {out.print("1 "); for ( int i = 0;(i < (n - 1));i++) out.print((a[i] + " ")); }} void inp()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 A().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());} }
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 R035C{ public static final int INF = 987654321; public static final long LINF = 987654321987654321L; public static final double EPS = 1e-9; Scanner scanner ; PrintWriter out ; int[][] iss ; public R035C(){ 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 ( (iss[nx][ny] != 0)) {continue;} np.count = (cur.count + 1); iss[nx][ny] = np.count; q.add(np); }}return p;} private void solve(){ this.n = scanner.nextInt(); this.m = scanner.nextInt(); this.iss = new int[n][m]; int k = scanner.nextInt(); q = new PriorityQueue<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); iss[x][y] = 1; } Point p = bfs(); out.println((((p.x + 1) + " ") + (p.y + 1))); } private void finish(){ this.out.close(); } public static void main( String[] args){ R035C obj = new R035C(); obj.solve(); obj.finish(); } }
2	public class DigitQueries{ public static void main( String[] args)throws IOException { FastReader in = new FastReader();  int q = 1; while((q-- > 0)){ long k ; k = in.nextLong(); Query(k); }} static void Query( long k){ long x = 0;  long sum = 0; while((sum < k)){sum += ((9 * Math.pow(10,x)) * (x + 1)); if ( (sum > k)) {sum -= ((9 * Math.pow(10,x)) * (x + 1)); break;} x++; } long y = (k - sum);  long last = 0; last = (((long)Math.pow(10,x) + ((long)y / (x + 1))) - 1); long z = (y % (x + 1)); if ( (z != 0)) {last = ((long)(last + 1) / (long)Math.pow(10,((x + 1) - z))); } System.out.println((last % 10)); } 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());} } }
5	public class A{ static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} static PrintWriter out = new PrintWriter(System.out); public static void main( String[] args)throws IOException { int n = nextInt(),t = nextInt(),x[] = new int[n],a[] = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = nextInt(); a[i] = nextInt(); }for ( int i = 0;(i < (n - 1));i++) for ( int j = (i + 1);(j < n);j++) if ( (x[i] > x[j])) { int p = x[i]; x[i] = x[j]; x[j] = p; p = a[i]; a[i] = a[j]; a[j] = p; } double l[] = new double[n];  double r[] = new double[n]; for ( int i = 0;(i < n);i++) {l[i] = (x[i] - (a[i] / 2.0)); r[i] = (x[i] + (a[i] / 2.0)); } int res = 2; for ( int i = 1;(i < n);i++) {if ( (Math.abs(((l[i] - r[(i - 1)]) - t)) < 0.000001)) res++; else if ( ((l[i] - r[(i - 1)]) > t)) res += 2; }out.println(res); out.flush(); } }
0	public class Main{ static private final double EPS = 1e-11; public static void main( String[] args)throws IOException { new Main().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); double a = nextDouble();  double v = nextDouble();  double l = nextDouble();  double d = nextDouble();  double w = nextDouble();  double ans = 0.0; if ( ((v < (w + EPS)) || (((sqr(w) / 2) / a) > (d - EPS)))) { double t1 = sqrt(((2 * l) / a));  double t2 = (v / a); if ( (t1 < (t2 + EPS))) {ans = t1; } else {ans = (t2 + ((l - ((a * sqr(t2)) / 2)) / v)); }} else { double t1 = (v / a);  double t2 = ((v - w) / a);  double s12 = ((((a * sqr(t1)) / 2) + (w * t2)) + ((a * sqr(t2)) / 2)); if ( (s12 < (d + EPS))) {ans += ((t1 + t2) + ((d - s12) / v)); } else { double ta = sqrt(((d / a) + (sqr((w / a)) / 2)));  double tb = (ta - (w / a)); ans += (ta + tb); } double r = (l - d);  double tm = ((v - w) / a);  double tx = ((sqrt((sqr(w) + ((2 * a) * r))) - w) / a); if ( (tx < (tm + EPS))) {ans += tx; } else {ans += (tm + (((r - (w * tm)) - ((a * sqr(tm)) / 2)) / v)); }}out.printf(Locale.US,"%.12f%n",ans); out.close(); } double sqr( double x){ return (x * x);} String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} double nextDouble()throws IOException { return Double.parseDouble(nextToken());} }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  String ns = sc.next(); sc.close(); int n1 = Integer.parseInt(ns);  int n2 = Integer.parseInt(ns.substring(0,(ns.length() - 1)));  int n3 = Integer.parseInt((ns.substring(0,(ns.length() - 2)) + ns.substring((ns.length() - 1))));  int max = n1; max = ((n2 > max)?n2:max); max = ((n3 > max)?n3:max); System.out.println(max); } }
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);  mysolver mysol = new mysolver(); mysol.solve(in,out); out.close(); } } class mysolver{ public long mod = 1000000007; int M ,N ; boolean bpm( boolean[][] bpGraph, int u, boolean[] seen, int[] matchR){ for ( int v = 0;(v < N);v++) {if ( (bpGraph[u][v] && !seen[v])) {seen[v] = true; if ( ((matchR[v] < 0) || bpm(bpGraph,matchR[v],seen,matchR))) {matchR[v] = u; return true;} } }return false;} int maxBPM( boolean[][] bpGraph){ int matchR[] = new int[N]; Arrays.fill(matchR,-1); int result = 0; for ( int u = 0;(u < M);u++) { boolean seen[] = new boolean[N]; if ( bpm(bpGraph,u,seen,matchR)) result++; }return result;} public void solve( InputReader in, OutputWriter out){ PrintWriter pout = new PrintWriter(new BufferedOutputStream(System.out));  int n = in.readInt();  int m = in.readInt();  boolean eg[][] = new boolean[n][n]; for ( int i = 0;(i < n);i++) {Arrays.fill(eg[i],false); }for ( int i = 0;(i < m);i++) { int x = (in.readInt() - 1);  int y = (in.readInt() - 1); eg[x][y] = true; } int minimum = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) { int ct = 0;  int addedges = 0; if ( (eg[i][i] == false)) {addedges++; } else {ct++; }for ( int j = 0;(j < n);j++) {if ( ((j != i) && (eg[i][j] == false))) {addedges++; } else if ( ((j != i) && (eg[i][j] == true))) {ct++; } if ( ((j != i) && (eg[j][i] == false))) {addedges++; } else if ( ((j != i) && (eg[j][i] == true))) {ct++; } } boolean row[] = new boolean[n];  boolean col[] = new boolean[n]; for ( int j = 0;(j < n);j++) {row[j] = eg[i][j]; col[j] = eg[j][i]; eg[i][j] = false; eg[j][i] = false; }N = n; M = n; int matching = maxBPM(eg); addedges += ((((n - 1) + m) - ct) - (2 * matching)); minimum = Math.min(minimum,addedges); for ( int j = 0;(j < n);j++) {eg[i][j] = row[j]; eg[j][i] = col[j]; }}System.out.println(minimum); pout.close(); } } 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 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 close(){ writer.close(); } }
2	public class Main{ static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st = new StringTokenizer(""); static PrintWriter pw = new PrintWriter(System.out); public static String next()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(br.readLine()); }return st.nextToken();} public static int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args)throws IOException { new Main().run(); } void run()throws IOException { long n = nextInt();  long k = nextInt();  long d = (9 + (8 * (n + k))); pw.print((n - ((-3 + (int)Math.sqrt(d)) / 2))); pw.close(); } }
2	public class B{ static StringTokenizer st ; static BufferedReader br ; static PrintWriter pw ; public static void main( String[] args)throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int n = nextInt();  int left = 0,right = n;  int x1 = 0,y1 = 0,x2 = 0,y2 = 0,x3 = 0,y3 = 0,x4 = 0,y4 = 0; while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + 1) + " ") + 1) + " ") + mid) + " ") + n)); int ans = nextInt(); if ( (ans == 2)) right = mid; else left = mid; }x4 = right; left = 0; right = n; while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + 1) + " ") + 1) + " ") + mid) + " ") + n)); int ans = nextInt(); if ( (ans >= 1)) right = mid; else left = mid; }x2 = right; left = 1; right = (n + 1); while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + mid) + " ") + 1) + " ") + n) + " ") + n)); int ans = nextInt(); if ( (ans >= 1)) left = mid; else right = mid; }x3 = left; left = 1; right = (n + 1); while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + mid) + " ") + 1) + " ") + n) + " ") + n)); int ans = nextInt(); if ( (ans >= 2)) left = mid; else right = mid; }x1 = left; left = 0; right = n; while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + 1) + " ") + 1) + " ") + n) + " ") + mid)); int ans = nextInt(); if ( (ans >= 2)) right = mid; else left = mid; }y4 = right; left = 0; right = n; while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + 1) + " ") + 1) + " ") + n) + " ") + mid)); int ans = nextInt(); if ( (ans >= 1)) right = mid; else left = mid; }y2 = right; left = 1; right = (n + 1); while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + 1) + " ") + mid) + " ") + n) + " ") + n)); int ans = nextInt(); if ( (ans >= 1)) left = mid; else right = mid; }y3 = left; left = 1; right = (n + 1); while(((right - left) > 1)){ int mid = ((left + right) >> 1); System.out.println(((((((("? " + 1) + " ") + mid) + " ") + n) + " ") + n)); int ans = nextInt(); if ( (ans >= 2)) left = mid; else right = mid; }y1 = left; if ( ((y3 <= y2) && (x3 <= x2))) {System.out.println(((((((((((((((("! " + x3) + " ") + y3) + " ") + x2) + " ") + y2) + " ") + x1) + " ") + y1) + " ") + x4) + " ") + y4)); return ;} System.out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); int ans1 = nextInt(); System.out.println(((((((("? " + x3) + " ") + y3) + " ") + x4) + " ") + y4)); int ans2 = nextInt(); if ( ((ans1 == 1) && (ans2 == 1))) {System.out.println(((((((((((((((("! " + x1) + " ") + y1) + " ") + x2) + " ") + y2) + " ") + x3) + " ") + y3) + " ") + x4) + " ") + y4)); return ;} System.out.println(((((((("? " + x1) + " ") + y3) + " ") + x2) + " ") + y4)); ans1 = nextInt(); System.out.println(((((((("? " + x3) + " ") + y1) + " ") + x4) + " ") + y2)); ans2 = nextInt(); if ( ((ans1 == 1) && (ans2 == 1))) {System.out.println(((((((((((((((("! " + x1) + " ") + y3) + " ") + x2) + " ") + y4) + " ") + x3) + " ") + y1) + " ") + x4) + " ") + y2)); return ;} System.out.println(((((((("? " + x1) + " ") + y1) + " ") + x4) + " ") + y2)); ans1 = nextInt(); System.out.println(((((((("? " + x3) + " ") + y3) + " ") + x2) + " ") + y4)); ans2 = nextInt(); if ( ((ans1 == 1) && (ans2 == 1))) {System.out.println(((((((((((((((("! " + x1) + " ") + y1) + " ") + x4) + " ") + y2) + " ") + x3) + " ") + y3) + " ") + x2) + " ") + y4)); return ;} System.out.println(((((((("? " + x1) + " ") + y3) + " ") + x2) + " ") + y2)); ans1 = nextInt(); System.out.println(((((((("? " + x3) + " ") + y1) + " ") + x4) + " ") + y4)); ans2 = nextInt(); if ( ((ans1 == 1) && (ans2 == 1))) {System.out.println(((((((((((((((("! " + x1) + " ") + y3) + " ") + x2) + " ") + y2) + " ") + x3) + " ") + y1) + " ") + x4) + " ") + y4)); return ;} pw.close(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} }
0	public class CodeForces{ public static void main( String[] args){ Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in))); System.out.println(((input.nextInt() / 2) + 1)); } }
2	public class Main{ static class Task{ int NN = 1000001; int MOD = 1000000007; int INF = 2000000000; long INFINITY = 2000000000000000000L; public void solve( InputReader in, PrintWriter out){ long k = in.nextLong(); for ( long mul = 1,d = 1;;mul *= 10,++d) {if ( (k > ((9 * mul) * d))) {k -= ((9 * mul) * d); } else {for ( long i = 1;(i <= 9);++i) {if ( (k > (mul * d))) {k -= (mul * d); } else {--k; long num = (k / d); k %= d; String str = String.valueOf(num); while((str.length() < (d - 1))){str = ("0" + str); }str = (String.valueOf(i) + str); out.println(str.charAt((int)k)); return ;}}}}} } 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 long nextLong(){ return Long.parseLong(next());} } }
5	public class Main{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),t = sc.nextInt(),x ,a ,kol = 2;  ArrayList<Double> al = new ArrayList<Double>(); for ( int i = 0;(i < n);i++) {x = sc.nextInt(); a = sc.nextInt(); al.add((x - (a / 2.))); al.add((x + (a / 2.))); }Collections.sort(al); double d0 = 0;  int k = 0,kn = al.size(); for ( Double d :al) {if ( (k == 2)) {if ( ((d - d0) > t)) kol += 2; else if ( ((d - d0) == t)) kol++; d0 = d; k = 1; } else {k++; d0 = d; }}System.out.print(kol); } }
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);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ final int MOD = (int)(1e9 + 7); long[][] C ; long[] fact ; public void solve( int testNumber, FastScanner in, PrintWriter out){ int n = in.nextInt(); precalc(n); int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); a[i] = removeSquares(a[i]); } int[] g = getGroupSizes(a);  long ans = solve(g); for ( int x :g) {ans = ((ans * fact[x]) % MOD); }out.println(ans); } private long solve( int[] a){ long[] d = new long[1]; d[0] = 1; int totalPositions = 1; for ( int x :a) { long[] nd = new long[((d.length + x) + 1)]; for ( int s = 0;(s < d.length);s++) {if ( (d[s] == 0)) {continue;} for ( int m = 1;(m <= x);m++) {for ( int p = 0;((p <= s) && (p <= m));p++) { long cur = d[s]; cur = ((cur * C[s][p]) % MOD); cur = ((cur * C[(totalPositions - s)][(m - p)]) % MOD); cur = ((cur * f(x,m)) % MOD); int ns = (((s + x) - m) - p); if ( ((ns >= 0) && (ns < nd.length))) {nd[ns] += cur; if ( (nd[ns] >= MOD)) {nd[ns] -= MOD; } } }}}if ( (totalPositions == 1)) {totalPositions = (x + 1); } else {totalPositions += x; }d = nd; }return d[0];} private long f( int n, int k){ if ( (n < k)) {return 0;} n -= k; return C[((n + k) - 1)][(k - 1)];} private void precalc( int n){ fact = new long[(n + 1)]; fact[0] = 1; for ( int i = 1;(i < fact.length);i++) {fact[i] = ((i * fact[(i - 1)]) % MOD); }C = new long[1000][1000]; 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 - 1)] + C[(i - 1)][j]); if ( (C[i][j] >= MOD)) {C[i][j] -= MOD; } }}} private int[] getGroupSizes( int[] a){ Arrays.sort(a); List<Integer> res = new ArrayList<>(); for ( int i = 0;(i < a.length);) { int j = i; while(((j < a.length) && (a[i] == a[j]))){++j; }res.add((j - i)); i = j; } int[] r = new int[res.size()]; for ( int i = 0;(i < r.length);i++) {r[i] = res.get(i); }return r;} private int removeSquares( int n){ int res = 1; for ( int d = 2;((d * d) <= n);d++) {if ( ((n % d) == 0)) { int cur = 0; while(((n % d) == 0)){n /= d; ++cur; }if ( ((cur % 2) == 1)) {res *= d; } } }if ( (n > 1)) {res *= n; } return res;} } 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());} } }
6	public class P111C{ Scanner sc = new Scanner(System.in); int INF = (1 << 28); double EPS = 1e-9; int h ,w ; void run(){ h = sc.nextInt(); w = sc.nextInt(); solve(); } void solve(){ n = (w * h); g = new long[n]; int[] dx = {0,0,-1,1};  int[] dy = {-1,1,0,0}; for ( int y = 0;(y < h);y++) {for ( int x = 0;(x < w);x++) {for ( int k = 0;(k < 4);k++) { int x2 = (x + dx[k]);  int y2 = (y + dy[k]); if ( ((((x2 >= 0) && (x2 < w)) && (y2 >= 0)) && (y2 < h))) {g[((y * w) + x)] |= (1L << ((y2 * w) + x2)); } }}}candidate = new int[n]; xs = new Xorshift(); mds = ((1L << n) - 1); mds(0,0,0); println(((n - Long.bitCount(mds)) + "")); } int n ; long[] g ; long mds ; int[] candidate ; Xorshift xs ; void mds( long choosed, long removed, long covered){ if ( (Long.bitCount(choosed) >= Long.bitCount(mds))) return ; if ( (covered == ((1L << n) - 1))) {if ( (Long.bitCount(choosed) < Long.bitCount(mds))) mds = choosed; return ;} { long s = covered; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); s |= ((1L << i) | g[i]); }if ( (s != ((1L << n) - 1))) {return ;} } int index = 0;  int k = -1; for ( long remained = (~removed & ((1L << n) - 1));(remained != 0);remained &= (remained - 1)) { int i = Long.numberOfTrailingZeros(remained); if ( (((covered >>> i) & 1) == 1)) {if ( (Long.bitCount((g[i] & ~covered)) == 0)) {mds(choosed,(removed | (1L << i)),covered); return ;} else if ( ((Long.bitCount((g[i] & ~covered)) == 1) && (((g[i] & ~covered) & ~removed) != 0))) {mds(choosed,(removed | (1L << i)),covered); return ;} } else {if ( (Long.bitCount((g[i] & ~removed)) == 0)) {mds((choosed | (1L << i)),(removed | (1L << i)),((covered | (1L << i)) | g[i])); return ;} else if ( ((Long.bitCount((g[i] & ~removed)) == 1) && (((g[i] & ~removed) | (g[i] & ~covered)) == (g[i] & ~removed)))) { int j = Long.numberOfTrailingZeros((g[i] & ~removed)); mds((choosed | (1L << j)),((removed | (1L << i)) | (1L << j)),((covered | (1L << j)) | g[j])); return ;} }if ( ((k == -1) || (Long.bitCount((g[i] & ~covered)) > Long.bitCount((g[k] & ~covered))))) {index = 0; candidate[index++] = i; k = i; } else if ( (Long.bitCount((g[i] & ~covered)) == Long.bitCount((g[k] & ~covered)))) {candidate[index++] = i; } }if ( (k == -1)) return ; k = candidate[xs.nextInt(index)]; mds((choosed | (1L << k)),(removed | (1L << k)),((covered | (1L << k)) | g[k])); mds(choosed,(removed | (1L << k)),covered); } class Xorshift{ int x ,y ,z ,w ; public Xorshift(){ x = 123456789; y = 362436069; z = 521288629; w = 88675123; } public Xorshift( int seed){ x = _(seed,0); y = _(x,1); z = _(y,2); w = _(z,3); } int _( int s, int i){ return (((1812433253 * (s ^ (s >>> 30))) + i) + 1);} public int nextInt(){ int t = (x ^ (x << 11)); x = y; y = z; z = w; return w = (((w ^ (w >>> 19)) ^ t) ^ (t >>> 8));} public int nextInt( int n){ return (int)(n * nextDouble());} public double nextDouble(){ int a = (nextInt() >>> 5),b = (nextInt() >>> 6); return (((a * 67108864.0) + b) * (1.0 / (1L << 53)));} } 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 P111C().run(); } }
5	public class A{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; class Team implements Comparable<Team>{ int ac ; int penalty ; public Team( int ac, int penalty){ this.ac = ac; this.penalty = penalty; } @Override public int compareTo( Team o){ if ( (ac != o.ac)) return ((ac > o.ac)?-1:1); return ((penalty == o.penalty)?0:((penalty < o.penalty)?-1:1));} } void solve()throws IOException { int n = nextInt();  int k = (nextInt() - 1);  Team[] a = new Team[n]; for ( int i = 0;(i < n);i++) a[i] = new Team(nextInt(),nextInt()); Arrays.sort(a); for ( int i = 0;(i < n);) { int j = i; while(((j < n) && (a[j].compareTo(a[i]) == 0)))j++; if ( ((i <= k) && (k < j))) {out.println((j - i)); return ;} i = j; }} void inp()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 A().inp(); } String nextToken(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ eof = true; return null;} }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong(); if ( (n == 0)) System.out.println(0); else if ( ((n % 2) == 1)) System.out.println(((n + 1) / 2)); else System.out.println((n + 1)); } }
3	public class task1{ static class Point{ double x ; double y ; Point( double x, double y){ this.x = x; this.y = y; } } public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int arr[] = new int[n];  int c[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); }Arrays.sort(arr); int count = 1; c[0] = 1; for ( int i = 1;(i < arr.length);i++) {for ( int j = 0;(j < i);j++) {if ( ((arr[i] % arr[j]) == 0)) {c[i] = c[j]; break;} }if ( (c[i] == 0)) {c[i] = (count + 1); count++; } }System.out.println(count); } }
6	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); int INF = (Integer.MAX_VALUE >> 1); void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int x0 = nextInt();  int y0 = nextInt();  int N = nextInt();  int FULL_MASK = ((1 << N) - 1);  int[] xs = new int[N];  int[] ys = new int[N]; for ( int i = 0;(i < N);i++) {xs[i] = nextInt(); ys[i] = nextInt(); } int[][] dist = new int[N][N]; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < N);j++) dist[i][j] = ((dist(x0,y0,xs[i],ys[i]) + dist(xs[i],ys[i],xs[j],ys[j])) + dist(xs[j],ys[j],x0,y0)); int[] dp = new int[(1 << N)];  int[] pr = new int[(1 << N)]; Arrays.fill(dp,INF); dp[0] = 0; for ( int mask = 0;(mask < FULL_MASK);mask++) { int i = Integer.numberOfTrailingZeros(~mask);  int imask = (mask | (1 << i)); for ( int j = i;(j < N);j++) { int jmask = (mask | (1 << j)); if ( (jmask == mask)) continue; int ijmask = (imask | jmask);  int nval = (dp[mask] + dist[i][j]); if ( (dp[ijmask] > nval)) {dp[ijmask] = nval; pr[ijmask] = mask; } }}out.println(dp[FULL_MASK]); out.print("0"); for ( int mask = FULL_MASK;(mask != 0);mask = pr[mask]) { int diff = (mask ^ pr[mask]);  int i = Integer.numberOfTrailingZeros(diff); diff &= (1 << i); int j = Integer.numberOfTrailingZeros(diff); if ( (i != 32)) out.print((" " + (i + 1))); if ( (j != 32)) out.print((" " + (j + 1))); out.print(" 0"); }out.println(); out.close(); } int dist( int x1, int y1, int x2, int y2){ return (sqr((x2 - x1)) + sqr((y2 - y1)));} int sqr( int x){ return (x * x);} String nextToken()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(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); } }
4	public class C{ public static void main( String[] args)throws IOException { FastScanner scn = new FastScanner();  PrintWriter out = new PrintWriter(System.out); for ( int tc = scn.nextInt();(tc > 0);tc--) { int N = scn.nextInt();  int[] arr = new int[N]; for ( int i = 0;(i < N);i++) {arr[i] = scn.nextInt(); } StringBuilder[] ans = new StringBuilder[N]; ans[0] = new StringBuilder("1"); ArrayDeque<Integer> st = new ArrayDeque<>(); st.addLast(0); for ( int i = 1;(i < N);i++) {ans[i] = new StringBuilder(); if ( (arr[i] == 1)) {st.addLast(i); ans[i].append((ans[(i - 1)].toString() + ".1")); } else {while((arr[st.getLast()] != (arr[i] - 1))){st.removeLast(); } int pos = st.removeLast();  String[] prev = ans[pos].toString().split("[.]"); for ( int j = 0,sz = (prev.length - 1);(j < sz);j++) {ans[i].append((prev[j] + ".")); }ans[i].append((arr[i] + "")); st.addLast(i); }}for ( StringBuilder str :ans) {out.println(str); }}out.close(); } static private int gcd( int num1, int num2){ int temp = 0; while((num2 != 0)){temp = num1; num1 = num2; num2 = (temp % num2); }return num1;} static private class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner(){ this.br = new BufferedReader(new InputStreamReader(System.in)); this.st = new StringTokenizer(""); } String next(){ while(!st.hasMoreTokens()){try{st = new StringTokenizer(br.readLine()); }catch (IOException err){ err.printStackTrace(); } }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
0	public class A{ public static void main( String[] args)throws Exception { new A().doit(); } private void doit()throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  long a = Long.parseLong(st.nextToken());  long b = Long.parseLong(st.nextToken());  long ans = 0; while(((a > 0) && (b > 0))){if ( (a > b)) {ans += (a / b); a %= b; } else {ans += (b / a); b %= a; }}System.out.println(ans); } }
2	public class Main{ InputStream is ; PrintWriter out ; String INPUT = ""; boolean local = false; int inf = 0x7FFFFFFF; int MOD = (int)(1e9 + 7); double eps = 1e-5; double PI = Math.acos(-1); void solve(){ long maxn = nl();  long L = 1,R = maxn,ans = -1; while((L <= R)){ long mid = ((L + R) / 2); if ( (ask(1,1,mid,maxn) < 1)) L = (mid + 1); else {R = (mid - 1); ans = mid; }}if ( ((ask(1,1,ans,maxn) == 1) && (ask((ans + 1),1,maxn,maxn) == 1))) { Yts1999 a1 = gao(1,1,ans,maxn);  Yts1999 a2 = gao((ans + 1),1,maxn,maxn); answer(a1,a2); } else {L = 1; R = maxn; ans = -1; while((L <= R)){ long mid = ((L + R) / 2); if ( (ask(1,1,maxn,mid) < 1)) L = (mid + 1); else {R = (mid - 1); ans = mid; }} Yts1999 a1 = gao(1,1,maxn,ans);  Yts1999 a2 = gao(1,(ans + 1),maxn,maxn); answer(a1,a2); }} void answer( Yts1999 a1, Yts1999 a2){ out.print("!"); a1.print(); a2.print(); out.flush(); } int ask( long a, long b, long c, long d){ out.printf("? %d %d %d %d",a,b,c,d); out.println(); out.flush(); return ni();} Yts1999 gao( long x1, long x2, long y1, long y2){ long a1 = 0,a2 = 0,a3 = 0,a4 = 0;  long L ,R ; L = x1; R = y1; while((L <= R)){ long mid = ((L + R) / 2); if ( (ask(mid,x2,y1,y2) == 1)) {a1 = mid; L = (mid + 1); } else R = (mid - 1); }L = x1; R = y1; while((L <= R)){ long mid = ((L + R) / 2); if ( (ask(x1,x2,mid,y2) == 1)) {a3 = mid; R = (mid - 1); } else L = (mid + 1); }L = x2; R = y2; while((L <= R)){ long mid = ((L + R) / 2); if ( (ask(x1,mid,y1,y2) == 1)) {a2 = mid; L = (mid + 1); } else R = (mid - 1); }L = x2; R = y2; while((L <= R)){ long mid = ((L + R) / 2); if ( (ask(x1,x2,y1,mid) == 1)) {a4 = mid; R = (mid - 1); } else L = (mid + 1); }return new Yts1999(a1,a2,a3,a4);} public class Yts1999 implements Comparable{ public long a ,b ,c ,d ; public Yts1999( long a, long b, long c, long d){ this.a = a; this.b = b; this.c = c; this.d = d; } public void print(){ out.printf(" %d %d %d %d",a,b,c,d); } } long[] exgcd( long a, long b){ if ( (b == 0)) return new long[]{1,0,a}; long[] res = exgcd(b,(a % b));  long t = res[0]; res[0] = res[1]; res[1] = t; res[1] -= ((a / b) * res[0]); return res;} long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} private void run(){ is = (local?new ByteArrayInputStream(INPUT.getBytes()):System.in); 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 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) && !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 void tr( Object... o){ if ( local) System.out.println(Arrays.deepToString(o)); } }
5	public class Solution implements Runnable{ class Pair implements Comparable<Pair>{ int col ; int time ; int place ; public Pair(){ } public Pair( int col, int time){ this.col = col; this.time = time; } @Override public int compareTo( Pair arg0){ if ( (col == arg0.col)) {return (time - arg0.time);} return (arg0.col - col);} } public void solve()throws Exception { int n = sc.nextInt();  int k = sc.nextInt();  ArrayList<Pair> a = new ArrayList<Pair>(); for ( int i = 0;(i < n);++i) {a.add(new Pair(sc.nextInt(),sc.nextInt())); }Collections.sort(a); int place = 1;  int placex = 0;  int ans2 = 0;  int ans1 = 0; for ( int i = 0;(i < n);++i) {if ( ((i > 0) && (a.get(i).compareTo(a.get((i - 1))) != 0))) {++place; ++placex; } else {++placex; }a.get(i).place = place; if ( (placex == k)) {ans1 = place; } }for ( int i = 0;(i < n);++i) {if ( (a.get(i).place == ans1)) {++ans2; } }out.println(ans2); } static String filename = ""; static boolean fromFile = false; BufferedReader in ; PrintWriter out ; FastScanner sc ; public static void main( String[] args){ new Thread(null,new Solution(),"",(1 << 25)).start(); } void init()throws Exception { if ( fromFile) {in = new BufferedReader(new FileReader((filename + ".in"))); out = new PrintWriter(new FileWriter((filename + ".out"))); } else {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); }sc = new FastScanner(in); } } 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());} }
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)); } }
5	public class A{ private void solve()throws IOException { int n = nextInt();  Integer[] a = new Integer[n];  Integer[] b = new Integer[n]; for ( int i = 0;(i < n);i++) {a[i] = b[i] = nextInt(); }Arrays.sort(a); int k = 0; for ( int i = 0;(i < n);i++) {if ( !a[i].equals(b[i])) {k++; } }if ( (k <= 2)) {println("YES"); } else {println("NO"); }} private String nextToken()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} private int nextInt()throws NumberFormatException,IOException { return Integer.parseInt(nextToken());} private void print( Object o){ writer.print(o); } private void println( Object o){ writer.println(o); } private void printf( String format, Object... o){ writer.printf(format,o); } public static void main( String[] args){ long time = System.currentTimeMillis(); Locale.setDefault(Locale.US); new A().run(); System.err.printf("%.3f\n",(1e-3 * (System.currentTimeMillis() - time))); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter writer ; private void run(){ try{reader = new BufferedReader(new InputStreamReader(System.in)); writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); }catch (IOException e){ e.printStackTrace(); System.exit(13); } } }
1	public class Main{ static Scanner in ; static PrintWriter out ; public static void main( String[] args)throws Exception { in = new Scanner(System.in); out = new PrintWriter(System.out); int n = in.nextInt();  int k = in.nextInt();  boolean[] p = new boolean[(n + 5)];  int[] pp = new int[(n + 5)];  int ind = 0; Arrays.fill(p,true); p[0] = false; p[1] = false; for ( int i = 2;(i < (n + 5));i++) if ( p[i]) {pp[ind++] = i; for ( int j = (2 * i);(j < (n + 5));j += i) p[j] = false; } boolean[] b = new boolean[(n + 1)]; for ( int i = 0;(i < (ind - 1));i++) if ( ((((pp[i] + pp[(i + 1)]) + 1) <= n) && p[((pp[i] + pp[(i + 1)]) + 1)])) b[((pp[i] + pp[(i + 1)]) + 1)] = true;  int kol = 0; for ( int i = 2;(i <= n);i++) if ( b[i]) kol++; if ( (kol >= k)) out.println("YES"); else out.println("NO"); out.close(); } }
5	public class Main{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer = null; public static void main( String[] args)throws IOException { new Main().execute(); } int ni()throws IOException { return Integer.parseInt(ns());} String ns()throws IOException { while(((tokenizer == null) || !tokenizer.hasMoreTokens()))tokenizer = new StringTokenizer(br.readLine()); return tokenizer.nextToken();} int totalCases ,testNum ; int k ,n ; void execute()throws IOException { totalCases = 1; for ( testNum = 1;(testNum <= totalCases);testNum++) {input(); solve(); }} void solve(){ int a = arr[(k - 1)].a;  int b = arr[(k - 1)].b;  int count = 0; for ( int i = 0;(i < n);i++) {if ( ((arr[i].a == a) && (arr[i].b == b))) count++; }System.out.println(count); } class Pair implements Comparable<Pair>{ int a ,b ; Pair( int _a, int _b){ a = _a; b = _b; } } Pair[] arr ; boolean input()throws IOException { n = ni(); k = ni(); arr = new Pair[n]; for ( int i = 0;(i < n);i++) { Pair p = new Pair(ni(),ni()); arr[i] = p; }Arrays.sort(arr); return true;} }
0	public class A{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); System.out.println((((n % 2) == 0)?((4 + " ") + (n - 4)):((9 + " ") + (n - 9)))); } }
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(); } }
2	public class Digits_Sequence_Hard_Edition_Kamel{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long k = sc.nextLong(); getResult(k); sc.close(); } static void getResult( long k){ long val = 0; ; long ten = 1;  int i = 1; while(true){val = ((9l * ten) * i); if ( (k <= val)) {decompose(k,ten,i); System.exit(0); } else {k -= val; ten = (ten * 10l); i++; }}} static void decompose( long offset, long ten, int size){ long val = ((ten - 1) + (long)Math.ceil(((double)offset / size)));  int digit = ((int)(((offset % size) - 1) + size) % size);  String result = String.valueOf(val).substring(digit,(digit + 1)); System.out.print(result); } }
2	public class Main{ static Scanner cin = new Scanner(System.in); static int n ,x ,y ; static long c ; static private long f( int mid){ long block = (1 + (((4 * (long)(mid + 1)) * mid) / 2));  int l = (y - mid);  int r = (y + mid);  int u = (x - mid);  int d = (x + mid); if ( (l <= 0)) block -= ((long)(1 - l) * (1 - l)); if ( (r > n)) block -= ((long)(r - n) * (r - n)); if ( (u <= 0)) block -= ((long)(1 - u) * (1 - u)); if ( (d > n)) block -= ((long)(d - n) * (d - n)); if ( ((u <= 0) && ((1 - u) > ((n - y) + 1)))) { int t = ((1 - u) - ((n - y) + 1)); block += (((long)t * (1 + t)) / 2); } if ( ((u <= 0) && ((1 - u) > y))) { int t = ((1 - u) - y); block += (((long)t * (1 + t)) / 2); } if ( ((d > n) && ((d - n) > ((n - y) + 1)))) { int t = ((d - n) - ((n - y) + 1)); block += (((long)t * (1 + t)) / 2); } if ( ((d > n) && ((d - n) > y))) { int t = ((d - n) - y); block += (((long)t * (1 + t)) / 2); } return block;} public static void main( String[] args){ n = cin.nextInt(); x = cin.nextInt(); y = cin.nextInt(); c = cin.nextLong(); int low = 0,high = 1000000000;  int ans = -1; while((low <= high)){ int mid = ((low + high) / 2); if ( (f(mid) >= c)) {ans = mid; high = (mid - 1); } else {low = (mid + 1); }}System.out.println(ans); } }
2	public class F{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  PrintWriter writer = new PrintWriter(System.out);  StringTokenizer st = new StringTokenizer(reader.readLine());  long n = Integer.parseInt(st.nextToken());  long k = Integer.parseInt(st.nextToken());  long l = 0;  long r = n; while((l <= r)){ long min = ((l + r) / 2); if ( ((((min * (min + 1)) / 2) - (n - min)) == k)) {System.out.println((n - min)); return ;} else if ( ((((min * (min + 1)) / 2) - (n - min)) > k)) {r = (min - 1); } else {l = (min + 1); }}} }
0	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long num = in.nextLong();  long lcm = 1; if ( (num == 2)) {System.out.println(2); System.exit(0); } else if ( (((num % 2) == 0) && ((num % 3) != 0))) lcm = ((num * (num - 1)) * (num - 3)); else if ( (((num % 2) == 0) && ((num % 3) == 0))) lcm = (((num - 1) * (num - 2)) * (num - 3)); else if ( (((num % 2) != 0) && (num > 2))) lcm = ((num * (num - 1)) * (num - 2)); System.out.println(lcm); } }
5	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){ int n = in.nextInt();  int arr[] = new int[n]; in.getArray(arr); int arrc[] = new int[n]; for ( int i = 0;(i < n);i++) {arrc[i] = arr[i]; }Library.sort(arrc); int c = 0; for ( int i = 0;(i < n);i++) {if ( (arrc[i] != arr[i])) {c++; } }if ( (c > 2)) {out.println("NO"); } else {out.println("YES"); }} } 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());} public void getArray( int[] arr){ for ( int i = 0;(i < arr.length);i++) {arr[i] = nextInt(); }} }
0	public class CodeForces{ public void solve()throws IOException { int n = nextInt();  int arr[] = new int[1000]; arr[0] = 0; arr[1] = 1; arr[2] = 1; if ( (n == 0)) {out.print("0 0 0"); } else if ( (n == 1)) {out.print("0 0 1"); } else { int c = 2; while((arr[c] != n)){c++; arr[c] = (arr[(c - 1)] + arr[(c - 2)]); }out.print(((((arr[(c - 2)] + " ") + arr[(c - 2)]) + " ") + arr[(c - 3)])); }} public static void main( String[] args){ new CodeForces().run(); } BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter out ; boolean isOuterFile = false; public void run(){ try{if ( isOuterFile) {reader = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt"))); out = new PrintWriter(System.out); } else {reader = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); }tokenizer = null; 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();} }
0	public class Main{ long solve( long a, long b){ return ((b == 0)?0:((a / b) + solve(b,(a % b))));} public void run(){ try{ long a = reader.nextLong();  long b = reader.nextLong(); writer.println(solve(a,b)); }catch (IOException ex){ } writer.close(); } InputReader reader ; PrintWriter writer ; Main(){ reader = new InputReader(); writer = new PrintWriter(System.out); } public static void main( String[] args){ new Main().run(); } } class InputReader{ BufferedReader reader ; StringTokenizer tokenizer ; InputReader(){ reader = new BufferedReader(new InputStreamReader(System.in)); tokenizer = new StringTokenizer(""); } String next()throws IOException { while(!tokenizer.hasMoreTokens()){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} Long nextLong()throws IOException { return Long.parseLong(next());} }
0	public class trafficerules{ public static void main( String[] args)throws Exception { if ( "Satayev".equals(System.getProperty("user.name"))) { long start = System.nanoTime(); new trafficerules().solve(new FileInputStream("input")); System.err.printf("Time elapsed: %d ms.\n",((System.nanoTime() - start) / 1000000)); } else new trafficerules().solve(System.in); } void solve( InputStream is)throws Exception { Scanner in = new Scanner(is);  double a = in.nextDouble(),maxv = in.nextDouble(),s = in.nextDouble(),d = in.nextDouble(),w = in.nextDouble(); if ( (maxv < w)) w = maxv;  double t = 0;  double t1 = (w / a);  double s1 = (((a * t1) * t1) / 2);  double v1 = w; if ( (s1 < d)) {v1 = w; if ( (v1 >= maxv)) t1 += ((d - s1) / v1); else { double tt = ((maxv - v1) / a);  double ss = ((v1 * tt) + (((a * tt) * tt) / 2)); ss *= 2; if ( ((s1 + ss) < d)) t1 += ((tt * 2) + (((d - s1) - ss) / maxv)); else {ss = ((d - s1) / 2); double A = (a / 2);  double B = v1;  double C = -ss;  double D = ((B * B) - ((4 * A) * C)); tt = (((-B + Math.sqrt(D)) / 2) / A); t1 += (tt * 2); }}s1 = d; } if ( (s1 > d)) {s1 = d; t1 = Math.sqrt(((2 * s1) / a)); v1 = (a * t1); } t += t1; double t2 = ((maxv - v1) / a);  double s2 = ((v1 * t2) + (((a * t2) * t2) / 2));  double v2 = maxv; if ( ((s1 + s2) < s)) {v2 = maxv; t2 += (((s - s1) - s2) / v2); } if ( ((s1 + s2) > s)) {s -= s1; double A = (a / 2);  double B = v1;  double C = -s;  double D = ((B * B) - ((4 * A) * C)); t2 = (((-B + Math.sqrt(D)) / 2) / A); } t += t2; System.out.println(t); } }
2	public class Main{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong();  long res = solve(n,k); System.out.println(res); } static private long solve( long n, long k){ return solveEq(1,(-3 - (2 * n)),(((n * n) + n) - (2 * k)));} static private long solveEq( long a, long b, long c){ long delta = ((b * b) - ((4 * a) * c)); return ((-b - (long)Math.sqrt(delta)) / (2 * a));} }
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)])); } }
5	public class Success{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int a = scan.nextInt();  int b = scan.nextInt();  int[] t = new int[n]; for ( int i = 0;(i < n);i++) {t[i] = scan.nextInt(); }Arrays.sort(t); System.out.println((t[b] - t[(b - 1)])); } }
0	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){ int n = in.nextInt(); if ( (n >= 0)) {out.print(n); return ;} if ( ((n / 10) >= (((n / 100) * 10) + (n % 10)))) {out.print((n / 10)); return ;} out.print((((n / 100) * 10) + (n % 10))); } } 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 int nextInt(){ return Integer.parseInt(next());} }
4	public class Problem implements Runnable{ static private final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); private BufferedReader in ; private PrintWriter out ; private StringTokenizer tok = new StringTokenizer(""); private void init()throws FileNotFoundException { Locale.setDefault(Locale.US); String fileName = ""; in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); } String readString(){ while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken();} int readInt(){ return Integer.parseInt(readString());} public static void main( String[] args){ new Problem().run(); } long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } @Override public void run(){ try{timeBegin = System.currentTimeMillis(); init(); solve(); out.close(); time(); }catch (Exception e){ e.printStackTrace(); System.exit(-1); } } int[][] dist ; int n ,m ; private void solve()throws IOException { n = readInt(); m = readInt(); int k = readInt(); dist = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) dist[i][j] = -1; for ( int i = 0;(i < k);i++) {dist[(readInt() - 1)][(readInt() - 1)] = 0; }for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (dist[i][j] == 0)) bfs(i,j);  int max = 0,X = 0,Y = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (dist[i][j] >= max)) {max = dist[i][j]; X = (i + 1); Y = (j + 1); } out.println(((X + " ") + Y)); } public void bfs( int x, int y){ int[] dx = {0,1,0,-1};  int[] dy = {1,0,-1,0}; dist[x][y] = 0; ArrayDeque<P> q = new ArrayDeque<>(); q.add(new P(x,y)); while(!q.isEmpty()){ P v = q.poll(); for ( int i = 0;(i < 4);i++) { int nx = (v.x + dx[i]);  int ny = (v.y + dy[i]); if ( (inside(nx,ny) && ((dist[nx][ny] == -1) || ((dist[nx][ny] > (dist[v.x][v.y] + 1)) && (dist[nx][ny] != 0))))) {q.add(new P(nx,ny)); dist[nx][ny] = (dist[v.x][v.y] + 1); } }}} public boolean inside( int x, int y){ if ( ((((x < n) && (y < m)) && (x >= 0)) && (y >= 0))) {return true;} return false;} } class P{ int x ,y ; public P( int x, int y){ this.x = x; this.y = y; } }
3	public class Main{ static private Scanner scanner = new Scanner(System.in); public static void main( String[] args){ int n = scanInt();  List<Integer> a = scanList(n);  int m = scanInt();  List<Integer> left = new ArrayList<>();  List<Integer> right = new ArrayList<>(); for ( int i = 0;(i < m);i++) {left.add(scanInt()); right.add(scanInt()); } String even = "even";  String odd = "odd";  int inversions = 0; for ( int i = 0;(i < a.size());i++) {for ( int j = i;(j < a.size());j++) {if ( (a.get(i) > a.get(j))) {++inversions; } }}inversions = (inversions % 2); for ( int i = 0;(i < m);i++) {inversions = ((inversions + ((((right.get(i) - left.get(i)) + 1) / 2) % 2)) % 2); println((((inversions % 2) == 0)?even:odd)); }} static private Integer get( int digit, List<Integer> numbers){ Integer toReturn = null; for ( Integer number :numbers) {if ( (number <= digit)) {toReturn = number; break;} }return toReturn;} static private List<Integer> scanList( int length){ List<Integer> integers = new ArrayList<>(); for ( int i = 0;(i < length);i++) {integers.add(scanner.nextInt()); }return integers;} static private int scanInt(){ return scanner.nextInt();} static private void println( int n){ System.out.println(n); } static private void print( int n){ System.out.print(n); } static private void println( String s){ System.out.println(s); } static private void print( String s){ System.out.print(s); } static private void print( int[] a){ for ( int i = 0;(i < a.length);i++) {System.out.print((a[i] + " ")); }} }
3	public class A{ void solve(){ int n = ni();  int P[] = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) P[i] = ni(); a = new int[(n + 1)]; BIT = new long[(n + 1)]; long cnt = 0;  long p = 0; for ( int i = n;(i >= 1);i--) {p += querry(P[i]); if ( (p >= M)) p %= M; update(n,P[i],1); } int d = 0; if ( ((p % 2) == 0)) d = 1;  int m = ni(); while((m-- > 0)){ int l = ni(),r = ni();  long sz = ((r - l) + 1); sz = ((sz * (sz - 1)) / 2); if ( ((d == 1) && ((sz % 2) == 0))) d = 1; else if ( ((d == 1) && ((sz % 2) != 0))) d = 0; else if ( ((d == 0) && ((sz % 2) == 0))) d = 0; else if ( ((d == 0) && ((sz % 2) != 0))) d = 1; if ( (d == 1)) pw.println("even"); else pw.println("odd"); }} int a[] ; long BIT[] ; void update( int n, int x, int val){ a[x] = val; for ( ;(x <= n);x += (x & -x)) BIT[x] += val; } long querry( int x){ long ans = 0; for ( ;(x > 0);x -= (x & -x)) ans += BIT[x]; return ans;} static long d ,x ,y ; static void extendedEuclid( long A, long B){ if ( (B == 0)) {d = A; x = 1; y = 0; } else {extendedEuclid(B,(A % B)); long temp = x; x = y; y = (temp - ((A / B) * y)); }} long M = ((long)1e9 + 7); InputStream is ; PrintWriter pw ; String INPUT = ""; void run()throws Exception { is = (INPUT.isEmpty()?System.in:new ByteArrayInputStream(INPUT.getBytes())); pw = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); pw.flush(); if ( !INPUT.isEmpty()) 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 = 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 void tr( Object... o){ if ( (INPUT.length() > 0)) System.out.println(Arrays.deepToString(o)); } }
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(); } }
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;} }
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());} } }
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();} } }
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[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); } int inv = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( (a[j] > a[i])) {inv++; } }} int m = in.nextInt(); for ( int i = 0;(i < m);i++) { int l = in.nextInt();  int r = in.nextInt();  int s = ((((r - l) + 1) * (r - l)) / 2); inv = ((inv + s) % 2); out.println((((inv % 2) == 0)?"even":"odd")); }} } static 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(); }catch (IOException e){ return null;} } public String next(){ while(((stt == null) || !stt.hasMoreTokens())){stt = new StringTokenizer(nextLine()); }return stt.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class D{ static byte[] buf = new byte[(1 << 26)]; static int bp = -1; public static void main( String[] args)throws IOException { DataInputStream in = new DataInputStream(System.in); in.read(buf,0,(1 << 26)); int n = nni();  int m = nni();  int k = nni(); if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);++i) { StringBuilder ans = new StringBuilder();  String sp = ""; for ( int j = 0;(j < m);++j) {ans.append((sp + "-1")); sp = " "; }System.out.println(ans); }return ;} int[][] lr = new int[n][(m - 1)];  int[][] ud = new int[(n - 1)][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < (m - 1));++j) {lr[i][j] = nni(); }}for ( int i = 0;(i < (n - 1));++i) {for ( int j = 0;(j < m);++j) {ud[i][j] = nni(); }} int[][][] ans = new int[((k / 2) + 1)][n][m]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {for ( int q = 1;(q <= (k / 2));++q) {ans[q][i][j] = 123456789; }}}for ( int uq = 0;(uq < (k / 2));++uq) {for ( int ui = 0;(ui < n);++ui) {for ( int uj = 0;(uj < m);++uj) { int w = ans[uq][ui][uj]; if ( ((ui > 0) && ((w + ud[(ui - 1)][uj]) < ans[(uq + 1)][(ui - 1)][uj]))) {ans[(uq + 1)][(ui - 1)][uj] = (w + ud[(ui - 1)][uj]); } if ( ((ui < (n - 1)) && ((w + ud[ui][uj]) < ans[(uq + 1)][(ui + 1)][uj]))) {ans[(uq + 1)][(ui + 1)][uj] = (w + ud[ui][uj]); } if ( ((uj > 0) && ((w + lr[ui][(uj - 1)]) < ans[(uq + 1)][ui][(uj - 1)]))) {ans[(uq + 1)][ui][(uj - 1)] = (w + lr[ui][(uj - 1)]); } if ( ((uj < (m - 1)) && ((w + lr[ui][uj]) < ans[(uq + 1)][ui][(uj + 1)]))) {ans[(uq + 1)][ui][(uj + 1)] = (w + lr[ui][uj]); } }}}for ( int i = 0;(i < n);++i) { StringBuilder as = new StringBuilder();  String sp = ""; for ( int j = 0;(j < m);++j) {as.append((sp + (ans[(k / 2)][i][j] * 2))); sp = " "; }System.out.println(as); }} public static int nni(){ int ret = 0;  byte b = buf[++bp]; while(true){ret = (((ret * 10) + b) - '0'); b = buf[++bp]; if ( ((b < '0') || (b > '9'))) {while((((buf[(bp + 1)] == '\r') || (buf[(bp + 1)] == '\n')) || (buf[(bp + 1)] == ' '))){++bp; }break;} }return ret;} }
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(); } }
2	public class B{ public static void main( String[] args)throws Exception { new B().solve(System.in,System.out); } void solve( InputStream _in, PrintStream out)throws IOException { Scanner sc = new Scanner(_in);  long n = sc.nextLong();  long x = (sc.nextLong() - 1);  long y = (sc.nextLong() - 1);  long c = sc.nextLong();  long ub = (2 * n);  long lb = -1; while(((lb + 1) < ub)){ long k = ((lb + ub) / 2);  long l ,u ,r ,d ; l = Math.max(0,(x - k)); u = Math.max(0,(y - k)); r = Math.min((n - 1),(x + k)); d = Math.min((n - 1),(y + k)); long ss = 0;  long lu = (x - (k - (y - u))); if ( (l < lu)) { long a = (lu - l); ss += ((a * (a + 1)) / 2); } long ld = (x - (k - (d - y))); if ( (l < ld)) { long a = (ld - l); ss += ((a * (a + 1)) / 2); } long ru = (x + (k - (y - u))); if ( (ru < r)) { long a = (r - ru); ss += ((a * (a + 1)) / 2); } long rd = (x + (k - (d - y))); if ( (rd < r)) { long a = (r - rd); ss += ((a * (a + 1)) / 2); } long cc = ((((r + 1) - l) * ((d + 1) - u)) - ss); if ( (c <= cc)) {ub = k; } else {lb = k; }}out.println(ub); } }
3	public class Main{ 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[200005];  int cnt = 0,c ; while(((c = read()) != -1)){if ( ((c == '\n') || (c == ' '))) {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;} 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 class FastScanner{ private final BufferedReader bufferedReader ; private StringTokenizer stringTokenizer ; public FastScanner(){ bufferedReader = new BufferedReader(new InputStreamReader(System.in)); } public String next(){ while(((stringTokenizer == null) || !stringTokenizer.hasMoreElements())){try{stringTokenizer = new StringTokenizer(bufferedReader.readLine()); }catch (IOException e){ throw (new RuntimeException("Can't read next value",e));} }return stringTokenizer.nextToken();} public int nextInt(){ return Integer.parseInt(next());} } static void closeall()throws IOException { printWriter.close(); sc.close(); in.close(); } static Scanner sc = new Scanner(System.in); static Reader in = new Reader(); static FastScanner fastScanner = new FastScanner(); static PrintWriter printWriter = new PrintWriter(new BufferedOutputStream(System.out)); static BufferedReader read = new BufferedReader(new InputStreamReader(System.in)); static long INF = (long)1e18; int V ,E ; ArrayList<Integer> adj[] ; HashMap<Integer,Integer> path ; Main(){ } Main( int v, int e){ V = v; E = e; adj = new ArrayList[v]; path = new HashMap<Integer,Integer>(); for ( int i = 0;(i < v);i++) adj[i] = new ArrayList<>(); } static long gcd( long a, long b){ if ( (a < b)) { long t = a; a = b; b = t; } long r = (a % b); if ( (r == 0)) return b; return gcd(b,r);} static int max( int a, int b){ return (int)Math.max(a,b);} static long max( long a, long b){ return (long)Math.max(a,b);} static long mod = 1000000007; public static void main( String[] args)throws IOException { int n = in.nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextInt(); int inv = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( (a[j] > a[i])) inv++; }}inv %= 2; int q = in.nextInt(); for ( int i = 0;(i < q);i++) { int l = in.nextInt();  int r = in.nextInt();  int num = ((r - l) + 1); inv = ((inv + ((num * (num - 1)) / 2)) % 2); if ( (inv == 0)) printWriter.println("even"); else printWriter.println("odd"); }closeall(); } }
3	public class Round584_a{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st ;  int n = Integer.parseInt(br.readLine()); st = new StringTokenizer(br.readLine()); int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(st.nextToken()); }Arrays.sort(a); boolean vis[] = new boolean[n];  int count = 0; for ( int i = 0;(i < n);i++) {if ( !vis[i]) {for ( int j = i;(j < n);j++) {if ( !vis[j]) {if ( ((a[j] % a[i]) == 0)) {vis[j] = true; } } }count++; } }System.out.println(count); } }
2	public class submitting{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  StringTokenizer st = new StringTokenizer(sc.nextLine());  long n = Integer.parseInt(st.nextToken());  long k = Integer.parseInt(st.nextToken());  long put = (n / 2);  long lower = 0;  long upper = n; while(((((put * (put + 1)) / 2) - (n - put)) != k)){if ( ((((put * (put + 1)) / 2) - (n - put)) > k)) {upper = (put - 1); put = ((lower + upper) / 2); } else {lower = (put + 1); put = ((lower + upper) / 2); }}System.out.println((n - put)); sc.close(); } }
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)); } }
4	public class D{ static private long INF = 2000000000000000000L,M = 1000000007,MM = 998244353; static private int N = 0; static private long[][][] dp ; static private long[][] ff ; static private long[][] ss ; public static void process()throws IOException { int n = sc.nextInt(),m = sc.nextInt(),k = sc.nextInt(); ff = new long[n][m]; ss = new long[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < (m - 1));j++) {ff[i][j] = sc.nextLong(); }}for ( int i = 0;(i < (n - 1));i++) {for ( int j = 0;(j < m);j++) {ss[i][j] = sc.nextLong(); }}if ( ((k % 2) == 1)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) System.out.print((-1 + " ")); System.out.println(); }return ;} dp = new long[(n + 1)][(m + 1)][11]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= m);j++) Arrays.fill(dp[i][j],-1); }for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= m);j++) {dp[i][j][0] = 0; }}k /= 2; long ans[][] = new long[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {ans[i][j] = (solve(i,j,k,n,m) * 2L); }}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) print((ans[i][j] + " ")); println(); }} static private long solve( int i, int j, int k, int n, int m){ if ( (dp[i][j][k] != -1)) return dp[i][j][k]; long ans = Long.MAX_VALUE; if ( ((i + 1) < n)) {ans = min(ans,(ss[i][j] + solve((i + 1),j,(k - 1),n,m))); } if ( ((i - 1) >= 0)) {ans = min(ans,(ss[(i - 1)][j] + solve((i - 1),j,(k - 1),n,m))); } if ( ((j + 1) < m)) {ans = min(ans,(ff[i][j] + solve(i,(j + 1),(k - 1),n,m))); } if ( ((j - 1) >= 0)) {ans = min(ans,(ff[i][(j - 1)] + solve(i,(j - 1),(k - 1),n,m))); } return dp[i][j][k] = ans;} static FastScanner sc ; static PrintWriter out ; public static void main( String[] args)throws IOException { boolean oj = true; if ( oj) {sc = new FastScanner(); out = new PrintWriter(System.out); } else {sc = new FastScanner(100); out = new PrintWriter("output.txt"); } int t = 1; while((t-- > 0)){process(); }out.flush(); out.close(); } static void println( Object o){ out.println(o); } static void println(){ out.println(); } static void print( Object o){ out.print(o); } static int max( int x, int y){ return Math.max(x,y);} static int min( int x, int y){ return Math.min(x,y);} static int abs( int x){ return Math.abs(x);} static long abs( long x){ return Math.abs(x);} static long sqrt( long z){ long sqz = (long)Math.sqrt(z); while((((sqz * 1L) * sqz) < z)){sqz++; }while((((sqz * 1L) * sqz) > z)){sqz--; }return sqz;} static long max( long x, long y){ return Math.max(x,y);} static long min( long x, long y){ return Math.min(x,y);} public static int gcd( int a, int b){ BigInteger b1 = BigInteger.valueOf(a);  BigInteger b2 = BigInteger.valueOf(b);  BigInteger gcd = b1.gcd(b2); return gcd.intValue();} public static long gcd( long a, long b){ BigInteger b1 = BigInteger.valueOf(a);  BigInteger b2 = BigInteger.valueOf(b);  BigInteger gcd = b1.gcd(b2); return gcd.longValue();} static class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner()throws FileNotFoundException{ br = new BufferedReader(new InputStreamReader(System.in)); } FastScanner( int a)throws FileNotFoundException{ br = new BufferedReader(new FileReader("input.txt")); } String next()throws IOException { while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} long nextLong()throws IOException { return Long.parseLong(next());} } }
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(); } }
3	public class prob3{ static Parser sc = new Parser(System.in); static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static int p[] = new int[100005]; public static void main( String[] args)throws IOException { int n = sc.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); } int swap = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < i);j++) {if ( (arr[i] < arr[j])) {swap++; } }}swap %= 2; int m = sc.nextInt(); for ( int i = 0;(i < m);i++) { int a = sc.nextInt(),b = sc.nextInt(); swap += (((b - a) * ((b - a) + 1)) / 2); swap %= 2; if ( ((swap % 2) == 0)) {System.out.println("even"); } else {System.out.println("odd"); }}} public static int find( int a){ while((p[a] != a)){a = p[a]; }return a;} static class Parser{ private final int BUFFER_SIZE = (1 << 20); private InputStream din ; private byte[] buffer ; private int bufferPointer ; private int bytesRead ; private SpaceCharFilter filter ; public Parser( InputStream in){ din = in; buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public int nextInt()throws IOException { int result = 0;  byte c = read(); while((c <= ' '))c = read(); boolean neg = (c == '-'); if ( neg) c = read(); while(((c >= '0') && (c <= '9'))){result = (((result * 10) + c) - '0'); c = read(); }if ( neg) return -result; return result;} 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); } public byte read()throws IOException { if ( (bufferPointer == bytesRead)) fillBuffer(); return buffer[bufferPointer++];} private void fillBuffer()throws IOException { bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); if ( (bytesRead == -1)) buffer[0] = -1; } } }
3	public class Main{ private FastScanner in ; private PrintWriter out ; private void solve()throws IOException { solveC(); } private void solveC()throws IOException { int n = in.nextInt(),prev = -1;  long sum ,mod = ((long)1e9 + 7),p ;  long[] deep = new long[(n + 10)]; deep[0] = 1; char c ; for ( int cur = 0;(cur < n);cur++) {c = in.nextLine().charAt(0); if ( ((prev + 1) != cur)) {sum = 0; if ( (c == 'f')) {for ( int i = (deep.length - 1);(i > 0);i--) {sum += deep[(i - 1)]; sum %= mod; deep[i] = sum; }deep[0] = 0; } else {for ( int i = (deep.length - 1);(i >= 0);i--) {sum += deep[i]; sum %= mod; deep[i] = sum; }}} if ( (c != 's')) {if ( (cur == (prev + 1))) {for ( int i = (deep.length - 1);(i > 0);i--) {deep[i] = deep[(i - 1)]; }deep[0] = 0; } prev = cur; } } long ans = 0; for ( int i = 0;(i < deep.length);i++) {ans += deep[i]; ans %= mod; }out.println(ans); } 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());} String nextLine()throws IOException { return br.readLine();} } 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(); } }
5	public class BetaRound15_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 BetaRound15_A()).start(); } class House implements Comparable<House>{ int left ,right ; House( int left, int right){ this.left = left; this.right = right; } } int getAns( House h1, House h2, int t){ int d = (h2.left - h1.right); if ( (d < t)) return 0; if ( (d == t)) return 1; return 2;} void solve()throws IOException { int n = readInt();  int t = (readInt() * 2);  House[] h = new House[n]; for ( int i = 0;(i < n);i++) { int c = (readInt() * 2);  int b = readInt(); h[i] = new House((c - b),(c + b)); }Arrays.sort(h); int ans = 2; for ( int i = 1;(i < n);i++) {ans += getAns(h[(i - 1)],h[i],t); }out.print(ans); } }
4	public class CF_35C{ public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));  StringTokenizer st1 = new StringTokenizer(f.readLine());  int n = Integer.parseInt(st1.nextToken());  int m = Integer.parseInt(st1.nextToken());  boolean[][] visited = new boolean[n][m];  int k = Integer.parseInt(f.readLine());  LinkedList<state1> ll = new LinkedList<state1>();  StringTokenizer st = new StringTokenizer(f.readLine()); for ( int i = 0;(i < k);i++) { int x = Integer.parseInt(st.nextToken());  int y = Integer.parseInt(st.nextToken()); ll.add(new state1((x - 1),(y - 1))); visited[(x - 1)][(y - 1)] = true; } int lastx = 1;  int lasty = 1; while(!ll.isEmpty()){ state1 focus = ll.remove(); lastx = (focus.x + 1); lasty = (focus.y + 1); visited[focus.x][focus.y] = true; if ( (((focus.x + 1) < n) && !visited[(focus.x + 1)][focus.y])) {ll.add(new state1((focus.x + 1),focus.y)); visited[(focus.x + 1)][focus.y] = true; } if ( (((focus.x - 1) >= 0) && !visited[(focus.x - 1)][focus.y])) {ll.add(new state1((focus.x - 1),focus.y)); visited[(focus.x - 1)][focus.y] = true; } if ( (((focus.y + 1) < m) && !visited[focus.x][(focus.y + 1)])) {ll.add(new state1(focus.x,(focus.y + 1))); visited[focus.x][(focus.y + 1)] = true; } if ( (((focus.y - 1) >= 0) && !visited[focus.x][(focus.y - 1)])) {ll.add(new state1(focus.x,(focus.y - 1))); visited[focus.x][(focus.y - 1)] = true; } }out.println(((lastx + " ") + lasty)); out.close(); } } class state1{ int x ,y ; state1( int x, int y){ this.x = x; this.y = y; } }
4	public class C{ public static void main( String[] args){ FastScanner sc = new FastScanner();  int T = sc.nextInt();  StringBuilder sb = new StringBuilder(); while((T-- > 0)){ int n = sc.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); } int[] p = new int[n];  int[] base = new int[n]; p[0] = -1; base[0] = -1; boolean[] used = new boolean[n]; for ( int i = 1;(i < n);i++) {if ( (arr[i] == 1)) {p[i] = (i - 1); base[i] = (i - 1); } else {for ( int j = (i - 1);(j >= 0);j--) {if ( used[j]) continue; if ( (arr[j] == (arr[i] - 1))) {p[i] = j; used[j] = true; base[i] = base[j]; break;} else used[j] = true; }}} StringBuilder[] res = new StringBuilder[n]; res[0] = new StringBuilder("1"); sb.append("1\n"); for ( int i = 1;(i < n);i++) {if ( (base[i] == -1)) {res[i] = new StringBuilder(); } else {res[i] = new StringBuilder(res[base[i]]); res[i].append("."); }res[i].append((arr[i] + "")); sb.append(res[i]); sb.append("\n"); }} PrintWriter pw = new PrintWriter(System.out); pw.println(sb.toString().trim()); pw.flush(); } static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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());} } }
2	public class _____A implements Runnable{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; OutputWriter out ; StringTokenizer tok = new StringTokenizer(""); public static void main( String[] args){ new Thread(null,new _____A(),"",(128 * (1L << 20))).start(); } void init()throws FileNotFoundException { Locale.setDefault(Locale.US); if ( 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"); }} long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } String delim = " "; String readString()throws IOException { while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null;} }return tok.nextToken(delim);} String readLine()throws IOException { return in.readLine();} final char NOT_A_SYMBOL = '\0'; int readInt()throws IOException { return Integer.parseInt(readString());} long readLong()throws IOException { return Long.parseLong(readString());} double readDouble()throws IOException { return Double.parseDouble(readString());} Point readPoint()throws IOException { int x = readInt();  int y = readInt(); return new Point(x,y);} class OutputWriter extends PrintWriter{ final int DEFAULT_PRECISION = 12; int precision ; String format ,formatWithSpace ; {precision = DEFAULT_PRECISION; format = createFormat(precision); formatWithSpace = (format + " "); }public OutputWriter( OutputStream out){ super(out); } public OutputWriter( String fileName)throws FileNotFoundException{ super(fileName); } private String createFormat( int precision){ return (("%." + precision) + "f");} @Override public void print( double d){ printf(format,d); } public void printWithSpace( double d){ printf(formatWithSpace,d); } public 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); } public void printlnAll( double... d){ printAll(d); println(); } } int[][] steps = {{-1,0},{1,0},{0,-1},{0,1}}; int[][] steps8 = {{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{1,-1},{-1,1}}; long md = (((1000 * 1000) * 1000) + 9); void solve()throws IOException { int n = readInt();  int m = readInt();  int k = readInt();  long count = (n / k);  long mod = (n % k);  long maxM = ((count * (k - 1)) + mod); if ( (maxM >= m)) {out.println((m % md)); return ;} long d = (m - maxM);  long mul = (((((binpow(2,d) - 1) + md) % md) * 2) % md);  long ans = ((mul * k) % md); ans = (((ans + (((((count - d) * (k - 1)) % md) + md) % md)) + mod) % md); out.println(ans); } long binpow( long a, long n){ if ( (n == 0)) return 1; if ( ((n & 1) == 0)) { long b = binpow(a,(n >> 1)); return ((b * b) % md);} else {return ((binpow(a,(n - 1)) * a) % md);}} }
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 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(); } static private int nextInt()throws IOException { return Integer.parseInt(next());} static private String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){st = new StringTokenizer(in.readLine()); }return st.nextToken();} }
0	public class A{ public static void main( String[] args){ Kattio io = new Kattio(System.in);  int n = io.getInt();  int ans = 0;  int V = n;  int A = n; A -= (n / 2); ans += (n / 2); V -= A; ans += A; A -= (n / 2); ans += (n / 2); io.println(ans); io.flush(); } } class Kattio extends PrintWriter{ public Kattio( InputStream i){ super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(i)); } public Kattio( InputStream i, OutputStream o){ super(new BufferedOutputStream(o)); r = new BufferedReader(new InputStreamReader(i)); } public boolean hasMoreTokens(){ return (peekToken() != null);} public int getInt(){ return Integer.parseInt(nextToken());} private BufferedReader r ; private String line ; private StringTokenizer st ; private String token ; private String peekToken(){ if ( (token == null)) try{while(((st == null) || !st.hasMoreTokens())){line = r.readLine(); if ( (line == null)) return null; st = new StringTokenizer(line); }token = st.nextToken(); }catch (IOException e){ } return token;} private String nextToken(){ String ans = peekToken(); token = null; return ans;} }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastReader in = new FastReader(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, FastReader in, OutputWriter out){ 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[] ans = new double[n]; ans[0] = r; for ( int i = 1;(i < n);i++) {ans[i] = r; double maxY = 0; for ( int j = 0;(j < i);j++) {if ( (Math.abs((x[j] - x[i])) <= (2.0 * r))) { double y = (ans[j] + Math.sqrt((((4 * r) * r) - ((x[j] - x[i]) * (x[j] - x[i]))))); ans[i] = Math.max(ans[i],y); } }}for ( int i = 0;(i < n);i++) {if ( (i > 0)) out.print(" "); out.printf("%.8f",ans[i]); }} } 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());} public double nextDouble(){ return Double.parseDouble(next());} } static class OutputWriter extends PrintWriter{ public OutputWriter( OutputStream os, boolean autoFlush){ super(os,autoFlush); } public OutputWriter( Writer out){ super(out); } public OutputWriter( Writer out, boolean autoFlush){ super(out,autoFlush); } public OutputWriter( String fileName)throws FileNotFoundException{ super(fileName); } public OutputWriter( String fileName, String csn)throws FileNotFoundException,UnsupportedEncodingException{ super(fileName,csn); } public OutputWriter( File file)throws FileNotFoundException{ super(file); } public OutputWriter( File file, String csn)throws FileNotFoundException,UnsupportedEncodingException{ super(file,csn); } public OutputWriter( OutputStream out){ super(out); } public void close(){ super.close(); } } }
3	public class Main3 implements Runnable{ public static void main( String[] args){ new Thread(null,new Main3(),"",((128 * 1024) * 1024)).start(); } static private Scanner in = new Scanner(System.in); }
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)); } }
0	public class Contest200C{ public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(in.readLine());  long a = Long.parseLong(st.nextToken());  long b = Long.parseLong(st.nextToken()); System.out.println(min(a,b)); } static long min( long a, long b){ if ( ((a <= 0) || (b <= 0))) return 0; return ((a / b) + min(b,(a % b)));} }
0	public class LuxuriousHouses{ public static void main( String[] args)throws IOException { System.out.println(25); } }
4	public class Main{ static MyScanner scan ; static PrintWriter pw ; static long MOD = 1_000_000_007; static long INF = 2_000_000_000_000_000_000L; static long inf = 2_000_000_000; public static void main( String[] args){ new Thread(null,null,"_",(1 << 27)){}.start(); } static void solve()throws java.lang.Exception { initIo(false,""); StringBuilder sb = new StringBuilder();  int t = ni(); while((t-- > 0)){ int n = ni();  ArrayList<ArrayList<Integer>> ans = new ArrayList<>();  ArrayList<Integer> prev = new ArrayList<>(); prev.add(1); ni(); for ( int i = 1;(i < n);i++) { int x = ni(); ans.add(prev); ArrayList<Integer> next = new ArrayList<>();  int idx = -1; for ( int j = (prev.size() - 1);(j >= 0);--j) {if ( (prev.get(j) == (x - 1))) {for ( int k = 0;(k < j);++k) {next.add(prev.get(k)); }next.add(x); idx = j; break;} }if ( (idx == -1)) {assert_in_range("x",x,1,1); for ( int e :prev) {next.add(e); }next.add(1); } prev = next; }ans.add(prev); for ( ArrayList<Integer> list :ans) {print(list); }}pw.flush(); pw.close(); } static void print( ArrayList<Integer> list){ for ( int i = 0;(i < list.size());i++) {pw.print(list.get(i)); if ( (i == (list.size() - 1))) {continue;} pw.print("."); }pl(); } static void assert_in_range( String varName, int n, int l, int r){ if ( ((n >= l) && (n <= r))) return ; System.out.println(((((((varName + " is not in range. Actual: ") + n) + " l : ") + l) + " r: ") + r)); System.exit(1); } static void assert_in_range( String varName, long n, long l, long r){ if ( ((n >= l) && (n <= r))) return ; System.out.println(((((((varName + " is not in range. Actual: ") + n) + " l : ") + l) + " r: ") + r)); System.exit(1); } static void initIo( boolean isFileIO, String suffix)throws IOException { scan = new MyScanner(isFileIO,suffix); if ( isFileIO) {pw = new PrintWriter((("/Users/dsds/Desktop/output" + suffix) + ".txt")); } else {pw = new PrintWriter(System.out,true); }} static int ni()throws IOException { return scan.nextInt();} static void pl(){ pw.println(); } static void p( Object o){ pw.print((o + " ")); } static void pl( Object o){ pw.println(o); } static class MyScanner{ BufferedReader br ; StringTokenizer st ; MyScanner( boolean readingFromFile, String suffix)throws IOException{ if ( readingFromFile) {br = new BufferedReader(new FileReader((("/Users/ddfds/Desktop/input" + suffix) + ".txt"))); } else {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());} } }
1	public class TwoSets<V>{ static private int n ; static private int a ; static private int b ; static private List<Node<Integer>> nodes = new LinkedList<Node<Integer>>(); static private Map<Integer,Node<Integer>> datas = new HashMap<Integer,Node<Integer>>(); static private Node<Integer> first ; static private Node<Integer> second ; static private TwoSets<Integer> sets = new TwoSets<Integer>(); public Node<V> makeSet( V x){ Node<V> node = new Node<V>(); node.node = x; node.parent = node; node.rank = 0; return node;} public void link( Node<V> x, Node<V> y){ if ( (x.rank > y.rank)) {y.parent = x; } else {x.parent = y; if ( (x.rank == y.rank)) {y.rank++; } }} public Node<V> findSet( Node<V> x){ if ( (x.parent != x)) {x.parent = findSet(x.parent); } return x.parent;} public void union( Node<V> x, Node<V> y){ Node<V> rtX = findSet(x);  Node<V> rtY = findSet(y); if ( (rtX.parent != rtY.parent)) {link(rtX,rtY); } } private int getColor( Node<V> node){ int color ;  Node<V> parent = findSet(node); color = parent.color; return color;} private void setColor( Node<V> node, int color){ Node<V> parent = findSet(node); parent.color = color; } static private Node<Integer> getOrInitNode( Integer key){ Node<Integer> node = datas.get(key); if ( (node == null)) {node = sets.makeSet(key); datas.put(key,node); } return node;} static private void initNodes( Scanner scanner){ int key ;  Node<Integer> node ; for ( int i = 0;(i < n);i++) {key = scanner.nextInt(); node = getOrInitNode(key); nodes.add(node); }} static private void unionAll( Node<Integer> value){ int color = sets.getColor(value); if ( (color == 0)) {if ( (first == null)) {first = value; } else {sets.union(first,value); }} else if ( (color == 1)) {if ( (second == null)) {second = value; } else {sets.union(second,value); }} } static private int getKey( Node<Integer> value, int color){ int key = value.node; if ( (color == 0)) {key = (a - key); } else {key = (b - key); }return key;} static private boolean checkOpposite( Node<Integer> value, int color){ boolean valid ; if ( value.inprogress) {valid = Boolean.TRUE; } else {value.inprogress = Boolean.TRUE; int opColor = (1 - color);  int key = getKey(value,opColor);  Node<Integer> node = datas.get(key); valid = (value.node.equals(key) || (node == null)); if ( !valid) {key = getKey(node,color); Node<Integer> child = datas.get(key); valid = (child != null); if ( valid) {valid = checkOpposite(child,color); if ( valid) {sets.union(value,node); sets.union(value,child); value.inprogress = Boolean.FALSE; } } } value.inprogress = Boolean.FALSE; }return valid;} static private boolean checkNodes( Node<Integer> value, int color){ boolean valid ;  int key = getKey(value,color);  int opColor = (1 - color);  Node<Integer> node = datas.get(key); valid = (value.node.equals(key) || (node != null)); if ( valid) {valid = checkOpposite(value,color); if ( valid) {sets.union(value,node); sets.setColor(value,color); } else if ( (color == 0)) {valid = checkNodes(value,opColor); } } else if ( (color == 0)) {valid = checkNodes(value,opColor); } return valid;} static private void format( StringBuilder builder, int i){ if ( (i > 0)) {builder.append(' '); } } static private String printNodes(){ String text ;  StringBuilder builder = new StringBuilder();  Iterator<Node<Integer>> iterator = nodes.iterator();  int i = 0;  Node<Integer> node ; while(iterator.hasNext()){format(builder,i); node = iterator.next(); builder.append(sets.getColor(node)); i++; }text = builder.toString().trim(); return text;} static private boolean checkNodes( int color){ boolean valid = Boolean.TRUE; for ( Node<Integer> value :nodes) {if ( (sets.getColor(value) == -1)) {valid = checkNodes(value,color); if ( valid) {unionAll(value); } else {break;}} }return valid;} static private void calculate(){ int color = 0;  boolean valid = checkNodes(color);  String message = "NO"; if ( valid) {message = "YES"; String array = printNodes(); System.out.println(message); System.out.println(array); } else {System.out.println(message); }} public static void main( String[] args){ Scanner scanner = new Scanner(System.in); try{n = scanner.nextInt(); a = scanner.nextInt(); b = scanner.nextInt(); initNodes(scanner); calculate(); }finally{scanner.close(); }} }
3	public class Main{ public static void main( String[] args)throws Exception { IO io = new IO(null,null);  int n = io.getNextInt(),ans = 0;  int[] A = new int[n]; for ( int i = 0;(i < n);i++) {A[i] = io.getNextInt(); for ( int j = 0;(j < i);j++) ans ^= ((A[j] > A[i])?1:0); } String[] word = {"even","odd"};  int m = io.getNextInt(); for ( int i = 0;(i < m);i++) { int l = io.getNextInt(),r = io.getNextInt();  int len = ((r - l) + 1);  long tot = ((len * (len - 1L)) / 2); ans ^= (tot & 1); io.println(word[ans]); }io.close(); } } class IO{ private BufferedReader br ; private StringTokenizer st ; private PrintWriter writer ; private String inputFile ,outputFile ; public String getNext()throws FileNotFoundException,IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(br.readLine()); return st.nextToken();} public int getNextInt()throws FileNotFoundException,IOException { return Integer.parseInt(getNext());} public void print( double x, int num_digits)throws IOException { writer.printf((("%." + num_digits) + "f"),x); } public void println( double x, int num_digits)throws IOException { writer.printf((("%." + num_digits) + "f\n"),x); } public void print( Object o)throws IOException { writer.print(o.toString()); } public void println( Object o)throws IOException { writer.println(o.toString()); } public IO( String x, String y)throws FileNotFoundException,IOException{ inputFile = x; outputFile = y; if ( (x != null)) br = new BufferedReader(new FileReader(inputFile)); else br = new BufferedReader(new InputStreamReader(System.in)); if ( (y != null)) writer = new PrintWriter(new BufferedWriter(new FileWriter(outputFile))); else writer = new PrintWriter(new OutputStreamWriter(System.out)); } protected void close()throws IOException { br.close(); writer.close(); } }
0	public class Main{ public static void main( String[] args)throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  int num = Integer.parseInt(in.readLine()); System.out.println(((num / 2) * 3)); } }
6	public class Main{ public static void main( String[] args){ new Thread(null,new Runnable(){},"1",(1 << 26)).start(); } void solve(){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  ScanReader in = new ScanReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  E2RotateColumnsHardVersion solver = new E2RotateColumnsHardVersion();  int testCount = in.scanInt(); for ( int i = 1;(i <= testCount);i++) solver.solve(i,in,out); out.close(); } static class E2RotateColumnsHardVersion{ int[][] dp ; int[] cur ; public void solve( int testNumber, ScanReader in, PrintWriter out){ int n = in.scanInt();  int m = in.scanInt();  int[][] ar = new int[n][m];  int[][] max = new int[m][2]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) ar[i][j] = in.scanInt(); for ( int i = 0;(i < m);i++) {for ( int j = 0;(j < n);j++) max[i][0] = Math.max(max[i][0],ar[j][i]); max[i][1] = i; }CodeHash.shuffle(max); Arrays.sort(max,(o1,o2)->(-o1[0] + o2[0])); dp = new int[2][(1 << n)]; cur = new int[(1 << n)]; for ( int i = 0;(i < Math.min(m,n));i++) {Arrays.fill(cur,0); Arrays.fill(dp[(i & 1)],0); for ( int j = 0;(j < (1 << n));j++) {for ( int k = 0;(k < n);k++) { int sum = 0; for ( int l = 0;(l < n);l++) {if ( ((j & (1 << l)) != 0)) {sum += ar; } }cur[j] = Math.max(cur[j],sum); }}for ( int j = 0;(j < (1 << n));j++) {for ( int k = j;;k = ((k - 1) & j)) {dp[(i & 1)][j] = Math.max(dp[(i & 1)][j],(dp[((i - 1) & 1)][k] + cur[(j ^ k)])); if ( (k == 0)) break; }}}out.println(dp[((Math.min(n,m) & 1) ^ 1)][((1 << n) - 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 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(); } }return (neg * integer);} private boolean isWhiteSpace( int n){ if ( (((((n == ' ') || (n == '\n')) || (n == '\r')) || (n == '\t')) || (n == -1))) return true; else return false;} } }
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)); }} }
5	public class A{ private void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = nextInt(); }Arrays.sort(a); int sum = 0; for ( int i = (a.length - 1);(i >= 0);i--) {sum += a[i]; int k = 0; for ( int j = 0;(j < i);j++) k += a[j]; if ( (sum > k)) {pl((a.length - i)); return ;} }} 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 ; }
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());} } }
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(); } static class TaskE{ HashMap<Integer,Integer> map = new HashMap<>(); boolean[] dp ; boolean[] vis ; boxPair[] ans ; int two( int bit){ return (1 << bit);} boolean contain( int mask, int bit){ return ((two(bit) & mask) > 0);} int get( long val){ if ( ((val > Integer.MAX_VALUE) || (val < Integer.MIN_VALUE))) return -1; int key = (int)val; if ( (map.containsKey(key) == false)) return -1; return map.get(key);} boolean rec( int mask, boolean[] hasCycle){ if ( hasCycle[mask]) return true; if ( (vis[mask] == true)) return dp[mask]; vis[mask] = true; for ( int i = (mask & (mask - 1));(i > 0);i = (mask & (i - 1))) {if ( (rec(i,hasCycle) && rec((i ^ mask),hasCycle))) {return dp[mask] = true;} }return dp[mask] = false;} void findPath( int mask, boolean[] hasCycle, ArrayList<boxPair>[] maskPath){ if ( hasCycle[mask]) {for ( boxPair b :maskPath[mask]) {ans[get(b.addTo)] = b; }return ;} for ( int i = (mask & (mask - 1));(i > 0);i = (mask & (i - 1))) {if ( (rec(i,hasCycle) && rec((i ^ mask),hasCycle))) {findPath(i,hasCycle,maskPath); findPath((i ^ mask),hasCycle,maskPath); return ;} }} public void solve( int testNumber, InputReader in, PrintWriter out){ int k = in.nextInt();  int[][] a = new int[k][];  int[] n = new int[k];  long[] sum = new long[k];  long S = 0; for ( int i = 0;(i < k);i++) {n[i] = in.nextInt(); a[i] = new int[n[i]]; for ( int j = 0;(j < n[i]);j++) {a[i][j] = in.nextInt(); sum[i] += a[i][j]; map.put(a[i][j],i); }S += sum[i]; }if ( ((S % k) != 0)) out.println("No"); else { ArrayList<boxPair>[] maskPath = new ArrayList[two(k)];  boolean[] hasCycle = new boolean[two(k)]; for ( int i = 0;(i < two(k));i++) {maskPath[i] = new ArrayList<>(); } long balance = (S / k); for ( int i = 0;(i < k);i++) {for ( int j = 0;(j < n[i]);j++) { long remove = a[i][j];  int curID = i;  int curMask = 0;  ArrayList<boxPair> curPath = new ArrayList<>(); while(true){curMask |= two(curID); remove = (balance - (sum[curID] - remove)); int nxtID = get(remove); curPath.add(new boxPair(curID,(int)remove)); if ( ((nxtID == i) && (remove == a[i][j]))) {if ( (hasCycle[curMask] == false)) {hasCycle[curMask] = true; maskPath[curMask] = curPath; } break;} if ( ((nxtID == -1) || contain(curMask,nxtID))) break; curID = nxtID; }}}vis = new boolean[two(k)]; dp = new boolean[two(k)]; if ( (rec((two(k) - 1),hasCycle) == false)) out.println("No"); else {ans = new boxPair[k]; findPath((two(k) - 1),hasCycle,maskPath); out.println("Yes"); for ( int i = 0;(i < k);i++) {out.println(((ans[i].addTo + " ") + (ans[i].boxID + 1))); }}}} class boxPair{ int boxID ; int addTo ; boxPair( int _boxID, int _addTo){ this.boxID = _boxID; this.addTo = _addTo; } } } static class InputReader{ InputStream is ; private byte[] inbuf = new byte[1024]; private int lenbuf = 0; private int ptrbuf = 0; static final int[] ints = new int[128]; public InputReader( InputStream is){ for ( int i = '0';(i <= '9');i++) ints[i] = (i - '0'); this.is = is; } public 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++];} 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 << 3) + (num << 1)) + ints[b]); } else {return (minus?-num:num);}b = readByte(); }} } }
5	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());} class Dom implements Comparable<Dom>{ int x ,a ; } void solve()throws Exception { int n = nextInt();  int t = (nextInt() * 2);  Dom[] a = new Dom[n]; for ( int i = 0;(i < n);i++) {a[i] = new Dom(); a[i].x = (nextInt() * 2); a[i].a = nextInt(); }Arrays.sort(a); int ans = 2; for ( int i = 0;(i < (n - 1));i++) {if ( (t < (((a[(i + 1)].x - a[(i + 1)].a) - a[i].x) - a[i].a))) ans += 2; if ( (t == (((a[(i + 1)].x - a[(i + 1)].a) - a[i].x) - a[i].a))) ans += 1; }out.print(ans); } }
0	public class Main{ public static void main( String[] args)throws Exception { FastReader sc = new FastReader();  OutputStream outputStream = System.out;  PrintWriter out = new PrintWriter(outputStream);  int n = sc.nextInt();  HashMap<String,Integer> map = new HashMap<String,Integer>(); for ( int i = 0;(i < n);i++) {map.put(sc.next(),1); } ArrayList<String> list = new ArrayList<String>();  int count = 0; if ( !map.containsKey("purple")) {count++; list.add("Power"); } if ( !map.containsKey("green")) {count++; list.add("Time"); } if ( !map.containsKey("blue")) {count++; list.add("Space"); } if ( !map.containsKey("orange")) {count++; list.add("Soul"); } if ( !map.containsKey("red")) {count++; list.add("Reality"); } if ( !map.containsKey("yellow")) {count++; list.add("Mind"); } System.out.println(count); for ( String s :list) {System.out.println(s); }} } 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());} }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int in = sc.nextInt(); System.out.println(((in / 2) + in)); System.exit(0); } }
1	public class Main{ static private final int MAX_SIZE = 100005; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  int a = sc.nextInt();  int b = sc.nextInt(); if ( ((((m + 1) / 60) < a) || ((((m + 1) / 60) == a) && (((m + 1) % 60) <= b)))) {out(0,0); System.exit(0); } for ( int i = 2;(i <= n);i++) { int x = sc.nextInt();  int y = sc.nextInt();  int bb = ((b + (2 * m)) + 2);  int aa = (a + (bb / 60)); bb %= 60; if ( ((aa < x) || ((aa == x) && (bb <= y)))) {b = ((b + m) + 1); a = (a + (b / 60)); b %= 60; out(a,b); System.exit(0); } a = x; b = y; }b = ((b + m) + 1); a = (a + (b / 60)); b = (b % 60); out(a,b); } static private void out( int a, int b){ cout(a); cout(" "); cout(b); } static private void cout( Object a){ System.out.print(a); } }
6	public class AMain{ static int n ; static int[] best ; static int[][] dist ; static int[] home ; static LinkedList<Integer> ret ; public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  State curr = new State(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())); n = Integer.parseInt(br.readLine()); 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())); }dist = new int[n][n]; home = new int[n]; for ( int i = 0;(i < n);i++) {home[i] = dist(curr,list[i]); }for ( int i = 0;(i < n);i++) {dist[i][i] = (2 * home[i]); for ( int j = (i + 1);(j < n);j++) {dist[i][j] = ((dist(list[i],list[j]) + home[i]) + home[j]); }}best = new int[(1 << n)]; Arrays.fill(best,-1); best[0] = 0; System.out.println(solve((-1 + (1 << n)))); ret = new LinkedList<Integer>(); resolve((-1 + (1 << n))); for ( int x :ret) System.out.print((x + " ")); } public static int dist( State a, State b){ int x = (a.x - b.x);  int y = (a.y - b.y); return ((x * x) + (y * y));} public static void resolve( int curr){ ret.addLast(0); for ( int i = 0;(i < n);i++) {if ( ((curr & (1 << i)) == 0)) continue; for ( int j = (i + 1);(j < n);j++) {if ( ((curr & (1 << j)) == 0)) {continue;} if ( ((dist[i][j] + solve(((curr ^ (1 << i)) ^ (1 << j)))) == best[curr])) {ret.addLast((i + 1)); ret.addLast((j + 1)); resolve(((curr - (1 << i)) - (1 << j))); return ;} }if ( (best[curr] == (dist[i][i] + solve((curr ^ (1 << i)))))) {ret.addLast((i + 1)); resolve((curr - (1 << i))); return ;} }} public static int solve( int curr){ if ( (best[curr] != -1)) return best[curr]; int ret = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) {if ( ((curr & (1 << i)) == 0)) continue; for ( int j = (i + 1);(j < n);j++) {if ( ((curr & (1 << j)) == 0)) {continue;} ret = Math.min(ret,(dist[i][j] + solve(((curr ^ (1 << i)) ^ (1 << j))))); }ret = Math.min(ret,(dist[i][i] + solve((curr ^ (1 << i))))); break;}best[curr] = ret; return ret;} static class State{ public int x ,y ; public State( int a, int b){ x = a; y = b; } } }
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();} }
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))); }} }
1	public class cf1 implements Runnable{ 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 interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new cf1(),"cf1",(1 << 26)).start(); } }
3	public class CC{ public static void main( String[] args)throws Throwable { MyScanner sc = new MyScanner();  PrintWriter pw = new PrintWriter(System.out); n = sc.nextInt(); s = new char[n]; for ( int i = 0;(i < n);i++) s[i] = sc.next().charAt(0); mem = new int[((2 * n) + 1)][(n + 1)]; for ( int[] x :mem) Arrays.fill(x,-1); pw.println(dp(0,0)); pw.flush(); pw.close(); } static int n ; static char[] s ; static int[][] mem ; static int dp( int i, int j){ if ( (i == n)) return ((j == 0)?1:0); if ( (mem[i][j] != -1)) return mem[i][j]; int ans = 0; if ( (s[i] == 'f')) {ans += dp((i + 1),(j + 1)); ans %= mod; } else {ans += dp((i + 1),j); ans %= mod; if ( (j > 0)) {ans += dp(i,(j - 1)); ans %= mod; } }return mem[i][j] = ans;} static int mod = (int)(1e9 + 7); 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 first{ static int max = 1000000000; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int[] tab = new int[n]; for ( int i = 0;(i < n);i++) {tab[i] = sc.nextInt(); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (i != j)) if ( ((tab[i] >= tab[j]) && ((tab[i] % tab[j]) == 0))) {tab[i] = max; } }} int res = 0; for ( int i = 0;(i < n);i++) {if ( (tab[i] != max)) res++; }System.out.println(res); } }
1	public class A{ static private Scanner sc = new Scanner(new InputStreamReader(System.in)); public static void main( String[] args)throws IOException { BitSet b = new BitSet(1001);  BitSet p = primes(1001); for ( int i = 0;(i < (ps.length - 1));i++) {b.set(((ps[i] + ps[(i + 1)]) + 1)); } int n = sc.nextInt(),k = sc.nextInt(); for ( int x = 0;(x <= n);x++) {if ( (b.get(x) && p.get(x))) k--; }System.out.println(((k > 0)?"NO":"YES")); } static private BitSet primes( int n){ BitSet b = new BitSet((n + 1)); b.set(2,n); for ( int p = 2;(p <= n);p++) {if ( b.get(p)) {for ( int x = (p * 2);(x <= n);x += p) {b.clear(x); }} }return b;} static private int[] ps = 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}; }
0	public class A{ public static void main( String[] args)throws IOException { Scanner in = new Scanner(System.in); System.out.println(rec(in.nextLong(),in.nextLong())); } static private long rec( long a, long b){ return ((b == 0)?0:((a / b) + rec(b,(a % b))));} }
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(); } }
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; }
5	public class A implements Runnable{ final boolean ONLINE_JUDGE = (System.getProperty("ONLINE_JUDGE") != null); BufferedReader in ; PrintWriter out ; StringTokenizer tok ; 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(null,new A(),"",((256 * 1024) * 1024)).start(); } void solve()throws IOException { int n = readInt();  int[] a = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {a[i] = readInt(); sum += a[i]; }Utils.mergeSort(a); int s = 0,c = 0; for ( int i = (n - 1);(i >= 0);i--) {s += a[i]; c++; if ( ((2 * s) > sum)) {break;} }out.println(c); } }
1	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();  long ans = 0; for ( int i = 2;((2 * i) <= n);i++) {ans += (i * ((n / i) - 1)); }ans *= 4; pw.print(ans); 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());} }
3	public class Problem911D{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(),i ,j ;  int ar[] = new int[n];  int inv = 0; for ( i = 0;(i < n);i++) {ar[i] = sc.nextInt(); }for ( i = 0;(i < n);i++) {for ( j = 0;(j < n);j++) {if ( ((i > j) && (ar[i] < ar[j]))) {inv = ((inv + 1) % 2); } }} int q = sc.nextInt(); for ( i = 0;(i < q);i++) { int l = sc.nextInt();  int r = sc.nextInt();  int c = ((((r - l) * ((r - l) + 1)) / 2) % 2); inv = ((inv + c) % 2); if ( (inv == 0)) System.out.println("even"); else System.out.println("odd"); }} }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  BigInteger l = sc.nextBigInteger();  BigInteger r = sc.nextBigInteger();  BigInteger a = l.add(BigInteger.ZERO); while((a.compareTo(r) < 0)){ BigInteger b = a.add(BigInteger.ONE); while((b.compareTo(r) < 0)){try{a.modInverse(b); }catch (ArithmeticException e){ b = b.add(BigInteger.ONE); continue;} BigInteger c = b.add(BigInteger.ONE); while((c.compareTo(r) <= 0)){try{b.modInverse(c); try{a.modInverse(c); }catch (ArithmeticException e){ System.out.printf("%s %s %s\n",a.toString(),b.toString(),c.toString()); return ;} }catch (ArithmeticException e){ } c = c.add(BigInteger.ONE); }b = b.add(BigInteger.ONE); }a = a.add(BigInteger.ONE); }System.out.println("-1"); } }
2	public class CFFF{ static PrintWriter out ; static final int oo = 987654321; static final long mod = ((long)1e9 + 9); public static void main( String[] args){ MScanner sc = new MScanner(); out = new PrintWriter(System.out); long N = sc.nextLong();  long M = sc.nextLong();  long K = sc.nextLong(); if ( (M <= (N - (N / K)))) out.println(M); else { long ans = ((((fastModExpo(2,(((M - (((N - (N % K)) / K) * (K - 1))) - (N % K)) + 1),mod) - 2) * K) + M) - (((M - (((N - (N % K)) / K) * (K - 1))) - (N % K)) * K)); out.println(((mod + ans) % mod)); }out.close(); } static long fastModExpo( int base, long pow, long mod){ if ( (pow == 0)) return 1L; if ( ((pow & 1) == 1)) return ((base * fastModExpo(base,(pow - 1),mod)) % mod); long temp = fastModExpo(base,(pow / 2),mod); return ((temp * temp) % mod);} static class MScanner{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public MScanner(){ stream = System.in; } 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));} int nextInt(){ return Integer.parseInt(next());} int[] nextInt( int N){ int[] ret = new int[N]; for ( int a = 0;(a < N);a++) ret[a] = nextInt(); return ret;} int[][] nextInt( int N, int M){ int[][] ret = new int[N][M]; for ( int a = 0;(a < N);a++) ret[a] = nextInt(M); return ret;} long nextLong(){ return Long.parseLong(next());} long[] nextLong( int N){ long[] ret = new long[N]; for ( int a = 0;(a < N);a++) ret[a] = nextLong(); return ret;} double nextDouble(){ return Double.parseDouble(next());} double[] nextDouble( int N){ double[] ret = new double[N]; for ( int a = 0;(a < N);a++) ret[a] = nextDouble(); return ret;} 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();} String[] next( int N){ String[] ret = new String[N]; for ( int a = 0;(a < N);a++) ret[a] = next(); return ret;} String nextLine(){ int c = read(); while(isEndline(c))c = read(); StringBuilder res = new StringBuilder(); do {res.appendCodePoint(c); c = read(); }while(!isEndline(c));return res.toString();} String[] nextLine( int N){ String[] ret = new String[N]; for ( int a = 0;(a < N);a++) ret[a] = nextLine(); return ret;} } }
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());} } }
1	public class HamstersAndTigers{ public static void main( String[] args){ Scanner sc = new Scanner(new BufferedInputStream(System.in));  int numAnimals = sc.nextInt();  String positions = sc.next();  int numTigers = 0;  int numHamsters = 0; for ( int i = 0;(i < positions.length());i++) {if ( (positions.charAt(i) == 'T')) {numTigers++; } else {numHamsters++; }} int minDifference = Integer.MAX_VALUE;  StringBuilder tigerChars = new StringBuilder(1000);  StringBuilder hamsterChars = new StringBuilder(1000); for ( int i = 0;(i < numHamsters);i++) {hamsterChars.append('H'); } StringBuilder remainingTigerChars = new StringBuilder(1000); for ( int i = 0;(i < numTigers);i++) {remainingTigerChars.append('T'); }for ( int i = 0;(i <= numTigers);i++) { StringBuilder generated = new StringBuilder(); generated.append(tigerChars); generated.append(hamsterChars); generated.append(remainingTigerChars); if ( (remainingTigerChars.length() >= 1)) {remainingTigerChars.deleteCharAt((remainingTigerChars.length() - 1)); } tigerChars.append('T'); int diffCount = stringDiffCount(positions,generated.toString()); if ( (diffCount < minDifference)) {minDifference = diffCount; } }hamsterChars = new StringBuilder(1000); tigerChars = new StringBuilder(1000); for ( int i = 0;(i < numTigers);i++) {tigerChars.append('T'); } StringBuilder remainingHamsterChars = new StringBuilder(1000); for ( int i = 0;(i < numHamsters);i++) {remainingHamsterChars.append('H'); }for ( int i = 0;(i <= numHamsters);i++) { StringBuilder generated = new StringBuilder(); generated.append(hamsterChars); generated.append(tigerChars); generated.append(remainingHamsterChars); if ( (remainingHamsterChars.length() >= 1)) {remainingHamsterChars.deleteCharAt((remainingHamsterChars.length() - 1)); } hamsterChars.append('H'); int diffCount = stringDiffCount(positions,generated.toString()); if ( (diffCount < minDifference)) {minDifference = diffCount; } }System.out.println((minDifference / 2)); } static private int stringDiffCount( String strOne, String strTwo){ int diffCount = 0; for ( int i = 0;(i < strOne.length());i++) {if ( (strOne.charAt(i) != strTwo.charAt(i))) {diffCount++; } }return diffCount;} }
2	public class Problem{ public static void main( String[] args)throws Exception { Scanner input = new Scanner(System.in);  int side = (input.nextInt() - 1);  int x = (input.nextInt() - 1);  int y = (input.nextInt() - 1);  long target = input.nextLong();  int[] to_sides = {y,(side - x),(side - y),x};  int[] to_corners = {((y + 1) + ((side - x) + 1)),(((side - x) + 1) + ((side - y) + 1)),(((side - y) + 1) + (x + 1)),((x + 1) + (y + 1))};  int min = Math.min(Math.min(y,x),Math.min((side - x),(side - y)));  int[] after_pass = {1,1,1,1};  int[] corner_share = {1,1,1,1};  int steps = 0,i ;  long init = 1;  int grown = 4; while((init < target)){init += grown; steps++; if ( (steps >= min)) {for ( i = 0;(i < 4);i++) {if ( (steps > to_sides[i])) {init -= after_pass[i]; after_pass[i] += 2; } if ( (steps >= to_corners[i])) {init += corner_share[i]++; } }} grown += 4; }System.out.println(steps); } }
5	public class CottageVillage{ public static void main( String... args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int k = sc.nextInt();  TreeMap<Integer,Integer> tm = new TreeMap<Integer,Integer>(); while((n-- > 0)){tm.put(sc.nextInt(),sc.nextInt()); } int cnt = 2,x = 0,a = 0;  double diff = 0; for ( Map.Entry<Integer,Integer> e :tm.entrySet()) {if ( ((x != 0) || (a != 0))) {diff = Math.abs((((e.getKey() - x) - (e.getValue() * 0.5)) - (a * 0.5))); if ( ((diff - k) > 0)) cnt += 2; else if ( ((diff - k) == 0)) cnt++; } x = e.getKey(); a = e.getValue(); }System.out.println(cnt); } }
4	public class C{ static int ar[] ; static HashMap<String,ArrayList<String>> map ; static int location = 0; static StringBuilder sb ; static int N ; public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));  int t = Integer.parseInt(br.readLine()); while((t-- > 0)){ int n = Integer.parseInt(br.readLine()); ar = new int[n]; location = 0; map = new HashMap<String,ArrayList<String>>(); sb = new StringBuilder(); N = n; for ( int i = 0;(i < n);i++) {ar[i] = Integer.parseInt(br.readLine()); } int idx = 2; location = 1; sb.append("1\n"); while((location < n)){if ( (ar[location] == 1)) {nl(((idx - 1) + ".")); } else {sb.append((idx + "\n")); idx++; location++; }}System.out.println(sb); }} public static void nl( String l){ int idx = 1; while((location < N)){if ( (idx == ar[location])) {sb.append(((l + idx) + "\n")); idx++; location++; } else if ( (ar[location] == 1)) {nl(((l + (idx - 1)) + ".")); } else {return ;}}} }
3	public class CODE2{ static private InputStream stream ; static private byte[] buf = new byte[1024]; static private int curChar ,MAX ; static private int numChars ; static private SpaceCharFilter filter ; static private PrintWriter pw ; static private long count = 0,mod = 1000000007; static int BIT[] ; static private boolean primer[] ; public static final 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(); } static StringBuilder sb ; 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 long co = 0,ans = 0; static int parent[] ; static int size[] ,color[] ,res[] ,k ; static ArrayList<Integer> al[] ; static long MOD = ((long)1e9 + 7); static int[] levl ; static int[] eat ; static int price[] ; public static void solve(){ int n = nextInt();  int a[] = new int[n]; a = nextIntArray(n); int invcount = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) invcount++; }} int m = nextInt();  int initial = (invcount % 2); while((m-- != 0)){ int l = nextInt();  int r = nextInt();  int diff = ((r - l) + 1);  int totalpair = ((diff * (diff - 1)) / 2); if ( ((((totalpair % 2) + initial) % 2) == 1)) {pw.println("odd"); initial = 1; } else {pw.println("even"); initial = 0; }}} static int find( int x){ if ( (parent[x] == x)) return x; else {parent[x] = find(parent[x]); return parent[x];}} static int col[] ; static int no_vert = 0; static private void dfs( int start){ Visited[start] = true; if ( (al[color[start]].size() >= k)) {res[start] = al[color[start]].get((al[color[start]].size() - k)); } al[color[start]].add(start); for ( int i :adj[start]) {if ( !Visited[i]) {dfs(i); } }al.remove((al[color[start]].size() - 1)); } static int indeg[] ; static HashSet<Integer> hs ; static boolean prime[] ; static int spf[] ; public static void InputReader( InputStream stream1){ stream = stream1; } static private boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} static private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} static 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++];} static private 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);} static private 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);} static private 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();} static private int[] nextIntArray( int n){ int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextInt(); }return arr;} static private 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 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)); } static private 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); }} } static private 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++]); }}} static private 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); } } class Lol implements Comparable<Lol>{ int x ; int y ; public Lol( int x, int y){ this.x = x; this.y = y; } } public void solve()throws IOException { int n = readInt();  int k = readInt(); k--; Lol[] a = new Lol[n]; for ( int i = 0;(i < n);i++) { int x = readInt();  int y = readInt(); a[i] = new Lol(x,y); }Arrays.sort(a); int ans = 1; for ( int i = (k + 1);(i > -1);i++) {if ( (i == n)) break; if ( ((a[i].x == a[k].x) && (a[i].y == a[k].y))) {ans++; } else break;}if ( (k != 0)) {for ( int i = (k - 1);(i >= 0);i--) {if ( ((a[i].x == a[k].x) && (a[i].y == a[k].y))) {ans++; } else break;}} out.print(ans); } }
1	public class Main implements Runnable{ BufferedReader in ; StringTokenizer st = new StringTokenizer(""); public static void main( String[] args)throws Exception { new Thread(new Main()).start(); } boolean seekForToken(){ try{while(!st.hasMoreTokens()){ String s = in.readLine(); if ( (s == null)) {return false;} st = new StringTokenizer(s); }return true; }catch (IOException e){ e.printStackTrace(); return false;} } int nextInt(){ return Integer.parseInt(nextToken());} String nextToken(){ seekForToken(); return st.nextToken();} }
3	public class ProblemA{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(bf.readLine());  StringTokenizer st1 = new StringTokenizer(bf.readLine());  int n = Integer.parseInt(st.nextToken());  int r = Integer.parseInt(st.nextToken());  int[] xcoords = new int[n]; for ( int i = 0;(i < n);i++) {xcoords[i] = Integer.parseInt(st1.nextToken()); } double[] ycoords = new double[n]; for ( int i = 0;(i < n);i++) { ArrayList<Integer> nodes = new ArrayList<Integer>(); for ( int j = 0;(j < i);j++) {if ( (Math.abs(((xcoords[j] - xcoords[i]) + 0.0)) <= (2 * r))) nodes.add(j); }if ( nodes.isEmpty()) {ycoords[i] = r; continue;} else { double min = -1; for ( int k = 0;(k < nodes.size());k++) { double tmp = (ycoords[nodes.get(k)] + Math.sqrt((((4 * r) * r) - ((xcoords[i] - xcoords[nodes.get(k)]) * (xcoords[i] - xcoords[nodes.get(k)]))))); if ( (tmp > min)) {min = tmp; } }ycoords[i] = min; }}for ( int i = 0;(i < ycoords.length);i++) {System.out.print((ycoords[i] + " ")); }} }
1	public class abc{ public static int check( StringBuilder s){ int countRemove = 0; if ( !s.toString().contains("xxx")) return countRemove; else {for ( int i = 1;(i < (s.length() - 1));i++) {if ( (((s.charAt((i - 1)) == 'x') && (s.charAt(i) == 'x')) && (s.charAt((i + 1)) == 'x'))) {countRemove++; } }return countRemove;}} public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  String s = sc.next();  StringBuilder sb = new StringBuilder(""); sb.append(s); System.out.println(check(sb)); } }
5	public class Solution implements Runnable{ public void solve()throws Exception { int n = sc.nextInt();  int k = sc.nextInt();  TreeSet<Integer> bad = new TreeSet<>();  int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = sc.nextInt(); Arrays.sort(a); int result = 0; for ( int i = 0;(i < n);i++) {if ( !bad.contains(a[i])) {result++; long next = ((long)a[i] * k); if ( (next <= 1000000000)) bad.add((int)next); } }out.println(result); } BufferedReader in ; PrintWriter out ; FastScanner sc ; static Throwable uncaught ; public static void main( String[] args)throws Throwable { Thread t = new Thread(null,new Solution(),"",(1 << 26)); 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());} }
6	public class Main{ static final int MAXN = 24; int[] x = new int[MAXN]; int[] y = new int[MAXN]; int[][] dist = new int[MAXN][MAXN]; int[] single = new int[MAXN]; int sqr( int x){ return (x * x);} void run( int nT){ int xs = cin.nextInt();  int ys = cin.nextInt();  int n = cin.nextInt(); for ( int i = 0;(i < n);++i) {x[i] = cin.nextInt(); y[i] = cin.nextInt(); }for ( int i = 0;(i < n);++i) {for ( int j = (i + 1);(j < n);++j) {dist[i][j] = (((((sqr((x[i] - xs)) + sqr((y[i] - ys))) + sqr((x[i] - x[j]))) + sqr((y[i] - y[j]))) + sqr((x[j] - xs))) + sqr((y[j] - ys))); }}for ( int i = 0;(i < n);++i) {single[i] = ((sqr((x[i] - xs)) + sqr((y[i] - ys))) * 2); } int[] dp = new int[(1 << n)];  int[] pre = new int[(1 << n)];  int tot = (1 << n); for ( int s = 1;(s < tot);++s) { int i ; for ( i = 0;(i < n);++i) {if ( ((s & (1 << i)) != 0)) break; }dp[s] = (dp[(s ^ (1 << i))] + single[i]); pre[s] = (i + 1); for ( int j = (i + 1);(j < n);++j) {if ( ((s & (1 << j)) != 0)) { int cur = (dp[((s ^ (1 << i)) ^ (1 << j))] + dist[i][j]); if ( (cur < dp[s])) {dp[s] = cur; pre[s] = (((i + 1) * 100) + (j + 1)); } } }}out.println(dp[(tot - 1)]); int now = (tot - 1); out.print("0"); while((now > 0)){ int what = pre[now];  int px = ((what % 100) - 1);  int py = ((what / 100) - 1); if ( (px >= 0)) {out.print(" "); out.print((px + 1)); now ^= (1 << px); } if ( (py >= 0)) {out.print(" "); out.print((py + 1)); now ^= (1 << py); } out.print(" "); out.print("0"); }out.println(""); } public static void main( String[] argv){ Main solved = new Main();  int T = 1; for ( int nT = 1;(nT <= T);++nT) {solved.run(nT); }solved.out.close(); } InputReader cin = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); } class InputReader{ BufferedReader reader ; 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());} }
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(); } }
1	public class Round1B{ public static void main( String[] args)throws Exception { new Round1B().run(); } private void run()throws Exception { Scanner sc = new Scanner(System.in);  int tc = Integer.parseInt(sc.nextLine().trim()); while((tc > 0)){ String s = sc.nextLine().trim(); if ( s.matches("R[0-9]+C[0-9]+")) { Pattern p = Pattern.compile("R([0-9]+)C([0-9]+)");  Matcher m = p.matcher(s); if ( m.matches()) { int rows = Integer.parseInt(m.group(1));  int cols = Integer.parseInt(m.group(2));  String col = ""; while((cols > 0)){ int mod = ((cols - 1) % 26); col = ((char)('A' + mod) + col); cols = ((cols - 1) / 26); }System.out.println((col + rows)); } else {throw (new Exception());}} else { Pattern p = Pattern.compile("([A-Z]+)([0-9]+)");  Matcher m = p.matcher(s); if ( m.matches()) { int rows = Integer.parseInt(m.group(2));  int cols = 0;  int mul = 1; for ( int i = (m.group(1).length() - 1);(i >= 0);i--) {cols += (mul * ((m.group(1).charAt(i) - 'A') + 1)); mul *= 26; }System.out.printf("R%dC%d\n",rows,cols); } else {throw (new Exception());}}tc--; }sc.close(); } }
2	public class B{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long k = sc.nextLong(); if ( (((((k - 1) * k) / 2) + 1) < n)) {System.out.println(-1); return ;} long left = 0;  long right = k; while((left < right)){ long m = ((left + right) / 2); if ( (((((k * (k - 1)) / 2) - (((k - m) * ((k - m) - 1)) / 2)) + 1) < n)) left = (m + 1); else right = m; }System.out.println(left); } }
6	public class Main{ static final boolean _DEBUG = false; static private class MyScanner{ BufferedReader br ; StringTokenizer st ; public MyScanner( BufferedReader _br){ br = _br; } String next(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (Exception e){ e.printStackTrace(); return "";} }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } static MyScanner scan ; static PrintWriter out ; static int debugCount = 0; public static void main( String[] args)throws IOException { scan = new MyScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); Main inst = new Main(); inst.execute(); out.close(); } int N ,M ,pow ; int[] counts ; int[][][] dp ; void execute(){ N = scan.nextInt(); M = scan.nextInt(); if ( (N < M)) { int temp = N; N = M; M = temp; } pow = (1 << M); counts = new int[pow]; dp = new int[N][pow][pow]; for ( int[][] i :dp) {for ( int[] j :i) {Arrays.fill(j,-1); }}for ( int i = 0;(i < pow);i++) {counts[i] = Integer.bitCount(i); dp[0][i][0] = counts[i]; } int spiders = Integer.MAX_VALUE; for ( int y = 0;(y < (N - 1));y++) {for ( int i = 0;(i < pow);i++) {for ( int j = 0;(j < pow);j++) {if ( (dp[y][i][j] == -1)) {continue;} for ( int k = 0;(k < pow);k++) {if ( ((((((i | (i << 1)) | (i >> 1)) | j) | k) & (pow - 1)) == (pow - 1))) { int value = (dp[y][i][j] + counts[k]); if ( ((dp[(y + 1)][k][i] == -1) || (dp[(y + 1)][k][i] > value))) {dp[(y + 1)][k][i] = value; } } }}}}for ( int i = 0;(i < pow);i++) {for ( int j = 0;(j < pow);j++) {if ( ((dp[(N - 1)][i][j] != -1) && (((((i | (i << 1)) | (i >> 1)) | j) & (pow - 1)) == (pow - 1)))) {spiders = Math.min(spiders,dp[(N - 1)][i][j]); } }}out.println(((N * M) - spiders)); } }
5	public class R2_D2_A{ public static void main( String[] args){ InputReader in = new InputReader(System.in);  int n = in.readInt();  int a = in.readInt();  int b = in.readInt();  Integer[] inp = new Integer[n]; for ( int i = 0;(i < inp.length);i++) {inp[i] = in.readInt(); }Arrays.sort(inp); int petya = inp[(inp.length - a)];  int next = inp[((inp.length - a) - 1)];  int diff = (petya - next); System.out.println(diff); } 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();} } }
6	public class Main{ public static void main( String[] args)throws IOException { InputStream fin = System.in;  Scanner cin = new Scanner(fin);  int n = cin.nextInt();  int m = cin.nextInt();  int bound = (1 << n);  boolean[][] mp = new boolean[n][n];  long[][] dp = new long[bound][n];  int used = 0;  long ret = 0; for ( int i = 0;(i < n);i++) {Arrays.fill(mp[i],false); }for ( int i = 0;(i < m);i++) { int u = (cin.nextInt() - 1);  int v = (cin.nextInt() - 1); mp[u][v] = mp[v][u] = true; }for ( int k = 0;(k < n);k++) {for ( int i = k;(i < bound);i++) {Arrays.fill(dp[i],0); }dp[(1 << k)][k] = 1; for ( int mask = (1 << k);(mask < bound);mask++) {if ( ((mask & used) != 0)) continue; for ( int i = k;(i < n);i++) {if ( (dp[mask][i] != 0)) {if ( (mp[k][i] && (bitcount(mask) > 2))) ret += dp[mask][i]; for ( int j = k;(j < n);j++) {if ( (((mask & (1 << j)) == 0) && mp[i][j])) {dp[(mask ^ (1 << j))][j] += dp[mask][i]; } }} }}used |= (1 << k); }System.out.println((ret / 2)); fin.close(); cin.close(); } static private int bitcount( int mask){ int ret = 0; while((mask > 0)){ret += (mask & 1); mask >>= 1; }return ret;} }
4	public class Main{ public static void main(final String[] args)throws IOException { try(Scanner scan=new Scanner(System.in);PrintWriter print=new PrintWriter(System.out)){final int n = scan.nextInt(); final int m = scan.nextInt(); final Pair<Integer,Integer>[] arcs = new Pair[m]; for ( int k = 0;(k < m);++k) { int i = scan.nextInt();  int j = scan.nextInt(); --i; --j; arcs[k] = new Pair(i,j); }print.println(calcMinNumStepsToCenterPermGraph(new DirectedGraph(n,arcs))); }} public static int calcMinNumStepsToCenterPermGraph(final DirectedGraph graph){ int result = Integer.MAX_VALUE; for ( DirectedGraph.Vertex center :graph.vertices) { int num = (((((2 * graph.vertices.length) - 1) - graph.getOutcomingArcs(center).size()) - graph.getIncomingArcs(center).size()) + (graph.containsArc(center,center)?1:0)); final int n = (graph.vertices.length - 1); final List<Pair<Integer,Integer>> edges = CollectionFactory.createArrayList(); for ( DirectedGraph.Arc arc :graph.arcs) {if ( (!center.equals(arc.from) && !center.equals(arc.to))) { int i = arc.from.index;  int j = arc.to.index; if ( (i > center.index)) {--i; } if ( (j > center.index)) {--j; } edges.add(new Pair(i,j)); } }final int matching = GraphUtils.calcNumMatchingBipartite(n,n,edges); num += (edges.size() - matching); num += (n - matching); result = Math.min(result,num); }return result;} public static class DirectedGraph{ public static class Vertex{ public final int index ; public Vertex( int index){ this.index = index; } @Override public boolean equals( Object o){ if ( (this == o)) return true; if ( ((o == null) || (getClass() != o.getClass()))) return false; Vertex vertex = (Vertex)o; if ( (index != vertex.index)) return false; return true;} @Override public int hashCode(){ return index;} } public static class Arc{ public final Vertex from ; public final Vertex to ; public Arc( Vertex from, Vertex to){ this.from = from; this.to = to; } @Override public boolean equals( Object o){ if ( (this == o)) return true; if ( ((o == null) || (getClass() != o.getClass()))) return false; Arc arc = (Arc)o; if ( !from.equals(arc.from)) return false; if ( !to.equals(arc.to)) return false; return true;} @Override public int hashCode(){ int result = from.hashCode(); result = ((31 * result) + to.hashCode()); return result;} } public final Vertex[] vertices ; public final Arc[] arcs ; public DirectedGraph(final int n,final Pair<Integer,Integer>[] arcs){ vertices = new Vertex[n]; this.arcs = new Arc[arcs.length]; for ( int i = 0;(i < n);++i) {vertices[i] = new Vertex(i); }for ( int i = 0;(i < arcs.length);++i) {this.arcs[i] = new Arc(vertices[arcs[i].first],vertices[arcs[i].second]); }} public List<Arc> getOutcomingArcs(final Vertex v){ final List<Arc> result = CollectionFactory.createArrayList(); for ( Arc arc :arcs) {if ( arc.from.equals(v)) {result.add(arc); } }return result;} public List<Arc> getIncomingArcs(final Vertex v){ final List<Arc> result = CollectionFactory.createArrayList(); for ( Arc arc :arcs) {if ( arc.to.equals(v)) {result.add(arc); } }return result;} public boolean containsArc(final Vertex from,final Vertex to){ for ( Arc arc :arcs) {if ( (arc.from.equals(from) && arc.to.equals(to))) {return true;} }return false;} } public static class MatrixIntMod{ final int mod ; final int[][] data ; public MatrixIntMod(final int n,final int m,final int mod){ this.mod = mod; this.data = new int[n][m]; for ( int i = 0;(i < n);++i) {Arrays.fill(data[i],0); }} public MatrixIntMod(final int[][] data,final int mod){ this(data.length,data[0].length,mod); for ( int i = 0;(i < data.length);++i) {for ( int j = 0;(j < data[i].length);++j) {this.data[i][j] = ModNumberUtils.norm(mod,data[i][j]); }}} public MatrixIntMod(final int[] data,final int mod){ this(data.length,1,mod); for ( int i = 0;(i < data.length);++i) {this.data[i][0] = ModNumberUtils.norm(mod,data[i]); }} public int[] all(){ int n = data.length;  int m = data[0].length; final int[] res = new int[(n * m)];  int k = 0; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < m);++j) {res[k++] = data[i][j]; }}return res;} public MatrixIntMod mult(final MatrixIntMod val){ if ( (data[0].length != val.data.length)) throw (new RuntimeException("dimensions for mult are wrong")); final int n = data.length; final int m = data[0].length; final int l = val.data[0].length; final MatrixIntMod res = new MatrixIntMod(n,l,mod); for ( int i = 0;(i < n);++i) {for ( int j = 0;(j < l);++j) {for ( int k = 0;(k < m);++k) {res.data[i][j] = ModNumberUtils.add(mod,res.data[i][j],ModNumberUtils.mult(mod,data[i][k],val.data[k][j])); }}}return res;} public int[] mult(final int[] ar){ return mult(new MatrixIntMod(ar,mod)).all();} public MatrixIntMod power(final long t){ if ( (t == 0)) return eye(data.length,mod); MatrixIntMod res = power((t >> 1)); res = res.mult(res); if ( ((t & 1) == 1)) {res = res.mult(this); } return res;} public static MatrixIntMod eye(final int n,final int mod){ final MatrixIntMod res = new MatrixIntMod(n,n,mod); if ( (mod > 1)) {for ( int i = 0;(i < n);++i) {res.data[i][i] = 1; }} return res;} } public static class Pair<X,Y>{ public X first ; public Y second ; public Pair(final X first,final Y second){ this.first = first; this.second = second; } } }
1	public class A{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine());  int[] list = new int[n]; for ( int i = 0;(i < list.length);i++) list[i] = Integer.parseInt(st.nextToken()); int odd = 0;  int even = 0; for ( int x :list) if ( ((x % 2) == 1)) {odd++; } else {even++; }for ( int i = 1;(i <= list.length);i++) {if ( (((list[(i - 1)] % 2) == 1) && (odd == 1))) {System.out.println(i); return ;} else if ( (((list[(i - 1)] % 2) == 0) && (even == 1))) {System.out.println(i); return ;} }} }
4	public class CF387D{ static class A{ ArrayList<Integer> list = new ArrayList<>(); int u ,v ,d ; } static int INF = Integer.MAX_VALUE; static boolean bfs( A[] aa, int n){ LinkedList<Integer> q = new LinkedList<>(); 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); } }
6	public class LookingOrder{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));  String[] line = in.readLine().split("\\s+");  int xs = Integer.parseInt(line[0]);  int ys = Integer.parseInt(line[1]);  int n = Integer.parseInt(in.readLine());  int[] x = new int[n];  int[] y = new int[n]; for ( int i = 0;(i < n);++i) {line = in.readLine().split("\\s+"); x[i] = Integer.parseInt(line[0]); y[i] = Integer.parseInt(line[1]); } int maxBitmap = (1 << n);  long[] dis = new long[maxBitmap];  int[] last = new int[maxBitmap]; dis[0] = 0; int ci = 0;  int[][] dismap = new int[n][n]; for ( int i = 0;(i < n);++i) {for ( int j = 0;(j <= i);++j) { int delx ,dely ; if ( (i == j)) {delx = (x[i] - xs); dely = (y[i] - ys); } else {delx = (x[i] - x[j]); dely = (y[i] - y[j]); }dismap[i][j] = ((delx * delx) + (dely * dely)); }}for ( int i = 1;(i < maxBitmap);++i) {if ( ((i & (1 << ci)) == 0)) ++ci;  int i2 = (i - (1 << ci));  long min = (dis[i2] + (2 * dismap[ci][ci])); last[i] = ci; for ( int j = 0;(j < ci);++j) {if ( ((i & (1 << j)) != 0)) { long m = (((dis[(i2 - (1 << j))] + dismap[ci][ci]) + dismap[j][j]) + dismap[ci][j]); if ( (m < min)) {min = m; last[i] = j; } } }dis[i] = min; }out.write(("" + dis[(maxBitmap - 1)])); out.newLine(); out.write("0"); int bmap = (maxBitmap - 1); ci = (n - 1); while((bmap != 0)){while((((bmap & (1 << ci)) == 0) && (ci >= 0)))--ci; int ci2 = last[bmap]; if ( (ci2 != ci)) {out.write(((((" " + (ci + 1)) + " ") + (ci2 + 1)) + " 0")); bmap -= ((1 << ci) + (1 << ci2)); } else {out.write(((" " + (ci + 1)) + " 0")); bmap -= (1 << ci); }}out.close(); } }
5	public class Main{ static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); public static void main( String[] args){ int n = nextInt();  int m = nextInt();  long b[] = new long[n];  long g[] = new long[m]; for ( int i = 0;(i < n);i++) b[i] = nextInt(); for ( int i = 0;(i < m);i++) g[i] = nextInt(); Arrays.sort(b); Arrays.sort(g); if ( (b[(n - 1)] > g[0])) System.out.println("-1"); else if ( (b[(n - 1)] == g[0])) { long sum = 0; for ( int i = 0;(i < m);i++) sum += g[i]; for ( int i = 0;(i < (n - 1));i++) {sum += (m * b[i]); }System.out.println(sum); } else { long sum = 0; for ( int i = 0;(i < m);i++) sum += g[i]; sum += b[(n - 1)]; sum += (b[(n - 2)] * (m - 1)); for ( int i = 0;(i < (n - 2));i++) {sum += (m * b[i]); }System.out.println(sum); }} static int nextInt(){ try{st.nextToken(); }catch (IOException e){ e.printStackTrace(); } return (int)st.nval;} }
2	public class CodeForces{ static private MyPrinter out ; public static void solve()throws IOException { Scanner sc = new Scanner(System.in);  long l = sc.nextLong();  long r = sc.nextLong();  String ls = Long.toBinaryString(l);  String rs = Long.toBinaryString(r); while((ls.length() < rs.length())){ls = ("0" + ls); } String res = "";  boolean ok = false; for ( int i = 0;(i < ls.length());i++) {if ( ok) {res += "1"; } else {if ( (ls.charAt(i) != rs.charAt(i))) {res += "1"; ok = true; } }} long all = 0; for ( int i = 0;(i < res.length());i++) {all += (long)Math.pow((long)2,(((long)res.length() - 1) - i)); }System.out.println(all); } public static void main( String[] args)throws IOException { out = new MyPrinter(System.out); solve(); out.close(); } } class MyPrinter{ private BufferedWriter out ; public MyPrinter( OutputStream os){ out = new BufferedWriter(new PrintWriter(os)); } public MyPrinter( File f)throws IOException{ out = new BufferedWriter(new FileWriter(f)); } public void println( int i)throws IOException { out.write(Integer.toString(i)); out.newLine(); } public void println( double d)throws IOException { out.write(Double.toString(d)); out.newLine(); } public void println( long l)throws IOException { out.write(Long.toString(l)); out.newLine(); } public void println( String s)throws IOException { out.write(s); out.newLine(); } public void println( char c)throws IOException { out.write(Character.toString(c)); out.newLine(); } public void close()throws IOException { out.flush(); out.close(); } }
3	public class C{ public static Scanner sc = new Scanner(System.in); public static StringTokenizer st ; public static PrintWriter pw = new PrintWriter(System.out); static final boolean debugmode = true; public static int k = 7; public static long STMOD = (1000000000 + k); public static void main( String[] args){ int disks = getInt();  int radii = getInt(); if ( (disks == 1)) {System.out.println(radii); } else { double[][] diskcenters = new double[disks][2]; for ( int i = 0;(i < disks);i++) {diskcenters[i][0] = getInt(); }diskcenters[0][1] = radii; for ( int i = 1;(i < disks);i++) { double cmax = 0; for ( int prev = 0;(prev < i);prev++) {cmax = Math.max(cmax,calcintersection(diskcenters[prev][0],diskcenters[prev][1],radii,diskcenters[i][0],radii)); }diskcenters[i][1] = cmax; }for ( int i = 0;(i < diskcenters.length);i++) {System.out.print((Double.toString(diskcenters[i][1]) + " ")); }System.out.print("\n"); }} public static double calcintersection( double x1, double y1, double r1, double x2, double r2){ if ( !intersects((x1 - r1),(x1 + r1),(x2 - r1),(x2 + r2))) {return r2;} else if ( (x1 == x2)) {return ((y1 + r1) + r2);} double lo = y1;  double hi = (y1 + (2 * r2)); while((Math.abs((lo - hi)) > 0.0000001)){ double mid = ((lo + hi) / 2.0);  int u = colide(x1,y1,r1,x2,mid,r2); if ( (u == 1)) {lo = mid; } else if ( (u == 0)) {hi = mid; } else {return mid;}}return ((lo + hi) / 2.0);} public static boolean intersects( double l1, double r1, double l2, double r2){ if ( ((l2 <= l1) && (r2 >= l1))) {return true;} if ( ((l2 <= r1) && (r2 >= r1))) {return true;} if ( ((l1 <= l2) && (r2 <= r1))) {return true;} else if ( ((l2 <= l1) && (r1 <= r2))) {return true;} return false;} public static int colide( double x1, double y1, double r1, double x2, double y2, double r2){ double dist = Math.sqrt((Math.pow((x1 - x2),2) + Math.pow((y2 - y1),2))); if ( (dist > (r1 + r2))) {return 0;} else if ( (dist == (r1 + r2))) {return 2;} else {return 1;}} public static int getInt(){ if ( ((st != null) && st.hasMoreTokens())) {return Integer.parseInt(st.nextToken());} st = new StringTokenizer(sc.nextLine()); return Integer.parseInt(st.nextToken());} }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int T = sc.nextInt();  int t = (T / 2); System.out.println((t * 3)); } }
0	public class Main{ static boolean LOCAL = (System.getSecurityManager() == null); Scanner sc = new Scanner(System.in); void run(){ double a = sc.nextDouble(),v = sc.nextDouble();  double L = sc.nextDouble(),d = sc.nextDouble(),w = sc.nextDouble(); w = min(w,v); double t = 0; if ( (((w * w) / (2 * a)) <= d)) {if ( (((((v * v) + ((2 * v) * (v - w))) - ((v - w) * (v - w))) / (2 * a)) <= d)) {t = ((((2 * v) - w) / a) + ((d - ((((v * v) + ((2 * v) * (v - w))) - ((v - w) * (v - w))) / (2 * a))) / v)); } else { double A = a,B = w,C = (((w * w) / (2 * a)) - d); t = ((w / a) + (((-B + sqrt(max(0,((B * B) - (A * C))))) / A) * 2)); }if ( (((((2 * w) * (v - w)) + ((v - w) * (v - w))) / (2 * a)) <= (L - d))) {t += (((v - w) / a) + (((L - d) - ((((2 * w) * (v - w)) + ((v - w) * (v - w))) / (2 * a))) / v)); } else { double A = a,B = w,C = (-2 * (L - d)); t += ((-B + sqrt(max(0,((B * B) - (A * C))))) / A); }} else if ( (((v * v) / (2 * a)) <= L)) {t = ((v / a) + ((L - ((v * v) / (2 * a))) / v)); } else {t = sqrt(((2 * L) / a)); }System.out.printf("%.10f%n",t); } class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); eat(""); } void eat( String s){ st = new StringTokenizer(s); } String nextLine(){ try{return br.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} } boolean hasNext(){ while(!st.hasMoreTokens()){ String s = nextLine(); if ( (s == null)) return false; eat(s); }return true;} String next(){ hasNext(); return st.nextToken();} double nextDouble(){ return Double.parseDouble(next());} } public static void main( String[] args){ if ( LOCAL) {try{System.setIn(new FileInputStream("in.txt")); }catch (Throwable e){ LOCAL = false; } } if ( !LOCAL) {try{Locale.setDefault(Locale.US); System.setOut(new PrintStream(new BufferedOutputStream(System.out))); }catch (Throwable e){ } } new Main().run(); System.out.flush(); } }
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); } }
3	public class Main{ static InputReader in = new InputReader(System.in); static PrintWriter out = new PrintWriter(System.out); static int oo = (int)1e9; static int mod = 1000000007; public static void main( String[] args)throws IOException { int n = in.nextInt();  int[] a = in.nextIntArray(n); Arrays.sort(a); boolean[] color = new boolean[n];  int cnt = 0; for ( int i = 0;(i < n);++i) {if ( !color[i]) {cnt++; for ( int j = i;(j < n);j++) {if ( ((a[j] % a[i]) == 0)) color[j] = true; }} }System.out.println(cnt); out.close(); } static int gcd( int a, int b){ return ((b == 0)?a:gcd(b,(a % b)));} static long gcd( long a, long b){ return ((b == 0)?a:gcd(b,(a % b)));} } 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 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 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){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} private boolean isEndOfLine( int c){ return (((c == '\n') || (c == '\r')) || (c == -1));} }
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());} }
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());} } }
6	public class C{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int[][] a = new int[n][];  Map<Long,Long> ci = new HashMap<>();  long[] sums = new long[n]; for ( int i = 0;(i < n);i++) { int K = ni(); a[i] = na(K); for ( int j = 0;(j < K);j++) {ci.put((long)a[i][j],(((long)i << 32) | j)); sums[i] += a[i][j]; }} long S = 0; for ( long v :sums) {S += v; }if ( ((S % n) != 0)) {out.println("No"); return ;} S /= n; int[] offsets = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {offsets[(i + 1)] = (offsets[i] + a[i].length); } int m = offsets[n];  int[] f = new int[m]; Arrays.fill(f,-1); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < a[i].length);j++) { long T = ((a[i][j] + S) - sums[i]); if ( ci.containsKey(T)) { long code = ci.get(T);  int from = (offsets[i] + j);  int to = (offsets[(int)(code >>> 32)] + (int)code); if ( ((from != to) && (i == (int)(code >>> 32)))) continue; f[from] = to; } }} int[][] cs = getCycles(f);  int[][] zcs = new int[(1 << n)][]; for ( int[] c :cs) { int ptn = 0; for ( int k :c) { int ind = Arrays.binarySearch(offsets,k); if ( (ind < 0)) ind = (-ind - 2); ptn |= (1 << ind); }if ( (Integer.bitCount(ptn) != c.length)) continue; zcs[ptn] = c; } boolean[] dp = new boolean[(1 << n)]; dp[0] = true; for ( int i = 1;(i < (1 << n));i++) {if ( (zcs[i] != null)) { int mask = (((1 << n) - 1) ^ i); for ( int j = mask;(j >= 0);j--) {j &= mask; dp[(i | j)] |= dp[j]; }} }if ( dp[((1 << n) - 1)]) { int[] vals = new int[n];  int[] tos = new int[n];  int cur = ((1 << n) - 1); inner:while((cur > 0)){for ( int k = cur;(k >= 0);k--) {k &= cur; if ( (dp[(cur ^ k)] && (zcs[k] != null))) {for ( int l = 0;(l < zcs[k].length);l++) { int nl = (((l + zcs[k].length) - 1) % zcs[k].length);  int fclus = Arrays.binarySearch(offsets,zcs[k][l]);  int tclus = Arrays.binarySearch(offsets,zcs[k][nl]); if ( (fclus < 0)) fclus = (-fclus - 2); if ( (tclus < 0)) tclus = (-tclus - 2);  int val = a[fclus][(zcs[k][l] - offsets[fclus])]; vals[fclus] = val; tos[fclus] = tclus; }cur ^= k; continue inner;} }}out.println("Yes"); for ( int i = 0;(i < n);i++) {out.println(((vals[i] + " ") + (tos[i] + 1))); }} else {out.println("No"); }} int[][] getCycles( int[] f){ int n = f.length;  int[][] ret = new int[n][];  boolean[] ved = new boolean[n];  int[] touched = new int[n]; Arrays.fill(touched,-1); int[] path = new int[n];  int q = 0; for ( int i = 0;(i < n);i++) { int p = 0; for ( int j = i;(j != -1);j = f[j]) {if ( (touched[j] != -1)) {ret[q++] = Arrays.copyOfRange(path,touched[j],p); break;} if ( ved[j]) break; touched[j] = p; path[p++] = j; ved[j] = true; }for ( int k = 0;(k < p);k++) {touched[path[k]] = -1; }}return Arrays.copyOf(ret,q);} 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[] 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)); } }
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);  DEhabIEsheOdnaOcherednayaZadachaNaXor solver = new DEhabIEsheOdnaOcherednayaZadachaNaXor(); solver.solve(1,in,out); out.close(); } static class DEhabIEsheOdnaOcherednayaZadachaNaXor{ public void solve( int testNumber, InputReader in, PrintWriter out){ int c = 0;  int d = 0;  int prevSign = 0;  int nextSign ;  boolean zeroOut = true; for ( int i = 29;(i >= 0);i--) {if ( zeroOut) {print(c,d,out); prevSign = read(in); } print(((1 << i) | c),((1 << i) | d),out); nextSign = read(in); if ( (prevSign == nextSign)) {zeroOut = false; print(((1 << i) | c),d,out); nextSign = read(in); if ( (nextSign < 0)) {c = ((1 << i) | c); d = ((1 << i) | d); } } else {zeroOut = true; if ( (nextSign < 0)) c = ((1 << i) | c); else d = ((1 << i) | d); }}out.printf("! %d %d",c,d); out.flush(); } private void print( int c, int d, PrintWriter out){ out.printf("? %d %d\n",c,d); out.flush(); } private int read( InputReader in){ return in.nextInt();} } static class InputReader{ private final BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); } 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;} } }
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); } }
2	public class JavaApplication4{ static long k ,n ,ans ; private static long binsearch( long l, long r){ if ( (l == r)) return l; long m = ((l + r) / 2);  long res = ((m * (((k + k) - m) + 1)) / 2); if ( (res >= n)) return binsearch(l,m); else return binsearch((m + 1),r);} public static void main( String[] args){ Scanner in = new Scanner(System.in); n = in.nextLong(); k = in.nextLong(); n--; k--; if ( (((k * (k + 1)) / 2) < n)) ans = -1; else ans = binsearch(0,k); System.out.println(ans); } }
4	public class C{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(new FileReader("input.txt"));  PrintWriter out = new PrintWriter(new File("output.txt"));  int N = in.nextInt();  int M = in.nextInt();  int K = in.nextInt();  int[] X = new int[K],Y = new int[K]; for ( int i = 0;(i < K);i++) {X[i] = in.nextInt(); Y[i] = in.nextInt(); } int d = -1;  int a = -1;  int b = -1; for ( int i = 1;(i <= N);i++) for ( int j = 1;(j <= M);j++) { int h = Integer.MAX_VALUE; for ( int p = 0;(p < K);p++) h = Math.min(h,(Math.abs((i - X[p])) + Math.abs((j - Y[p])))); if ( (h > d)) {d = h; a = i; b = j; } }out.print(((a + " ") + b)); out.close(); } }
2	public class ReallyBigNumbers1{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long s = sc.nextLong();  int r = 0;  long l = 0L;  long u = n; if ( (((l - sumDigits(l)) < s) && ((u - sumDigits(u)) < s))) {System.out.println(0); return ;} long specified = 0L; while(true){ long m = ((l + u) / 2L); if ( (((m - sumDigits(m)) >= s) && (((m - 1) - sumDigits((m - 1))) < s))) {specified = m; break;} if ( (l > u)) break; else {if ( ((m - sumDigits(m)) >= s)) u = (m - 1); else l = (m + 1); }}System.out.println(((n - specified) + 1)); } public static int sumDigits( long n){ char[] a = (n + "");  int sum = 0; for ( int k = 0;(k < a.length);k++) {sum += Integer.parseInt((a[k] + "")); }return sum;} }
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){ 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{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.readInt();  int[] a = IOUtils.readIntArray(in,n); MiscUtils.decreaseByOne(a); int m = in.readInt();  int parity = (inversions(a) % 2);  boolean[] lengthToParityFlip = new boolean[(n + 1)]; for ( int length = 1;(length < lengthToParityFlip.length);length++) {lengthToParityFlip[length] = ((((length * (length - 1)) / 2) % 2) == 1); }for ( int query = 0;(query < m);query++) { int l = (in.readInt() - 1),r = (in.readInt() - 1);  int length = ((r - l) + 1); if ( lengthToParityFlip[length]) {parity ^= 1; } out.printLine(((parity == 0)?"even":"odd")); }} private int inversions( int[] a){ int res = 0; for ( int j = 0;(j < a.length);j++) {for ( int i = (j + 1);(i < a.length);i++) {if ( (a[i] < a[j])) {res++; } }}return res;} } 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 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 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 ,kk ,bb ; int[] uu ,vv ,uv ,cost ,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_]; kk = new int[n_]; bb = new int[n_]; uu = new int[m_]; vv = new int[m_]; uv = new int[m_]; cost = 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)); } void dijkstra( int s){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((kk[u] != kk[v])?(kk[u] - kk[v]):(u - v)))); pq.add(s); Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first;  int k = (kk[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) && (kk[v] > k)))) {if ( (pi[v] < INF)) pq.remove(v); pi[v] = p; kk[v] = k; bb[v] = h_; pq.add(v); } } }} void push( int s, int t){ int c = INF; for ( int u = t,h_ ,h ;(u != s);u ^= uv[h]) {h = ((h_ = bb[u]) >> 1); c = Math.min(c,cc[h_]); }for ( int u = t,h_ ,h ;(u != s);u ^= uv[h]) {h = ((h_ = bb[u]) >> 1); cc[h_] -= c; cc[(h_ ^ 1)] += c; }} int edmonds_karp( int s, int t){ System.arraycopy(cost,0,cost_,0,m_); while(true){dijkstra(s); if ( (pi[t] == INF)) break; push(s,t); for ( int h = 0;(h < m_);h++) { int u = uu[h],v = vv[h]; if ( ((pi[u] != INF) && (pi[v] != INF))) cost_[h] += (pi[u] - pi[v]); }} 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 CF_111_A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(),sum = 0,sum2 = 0;  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = in.nextInt(); sum += a[i]; }Arrays.sort(a); for ( int i = (n - 1);(i >= 0);i--) {sum2 += a[i]; if ( ((sum2 * 2) > sum)) {System.out.println((((n - 1) - i) + 1)); System.exit(0); } }} }
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(); }} }
4	public class C implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer st ; Random rnd ; short[] qx ,qy ; boolean[][] used ; final int[] dx = {1,-1,0,0}; final int[] dy = {0,0,1,-1}; void solve()throws IOException { int n = nextInt(),m = nextInt(); qx = new short[(n * m)]; qy = new short[(n * m)]; used = new boolean[n][m]; int k = nextInt(),qs = 0,qt = 0; for ( int i = 0;(i < k);i++) { int x = (nextInt() - 1),y = (nextInt() - 1); used[x][y] = true; qx[qt] = (short)x; qy[qt] = (short)y; ++qt; } int rx = 0,ry = 0; while((qs < qt)){ int cx = qx[qs],cy = qy[qs]; ++qs; rx = cx; ry = cy; for ( int z = 0;(z < 4);z++) { int nx = (cx + dx[z]),ny = (cy + dy[z]); if ( (((((nx >= 0) && (ny >= 0)) && (nx < n)) && (ny < m)) && !used[nx][ny])) {used[nx][ny] = true; qx[qt] = (short)nx; qy[qt] = (short)ny; ++qt; } }}out.println((((rx + 1) + " ") + (ry + 1))); } public static void main( String[] args){ final boolean oldChecker = false; if ( oldChecker) {new Thread(null,new C(),"yarrr",(1 << 24)).start(); } else {new C().run(); }} public void run(){ try{try{in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter(new FileWriter("output.txt")); }catch (FileNotFoundException e){ 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());} }
4	public class Main{ public static void main( String[] args)throws IOException { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(new FileReader("input.txt"));  PrintWriter out = new PrintWriter("output.txt");  TaskB solver = new TaskB(); solver.solve(in,out); out.close(); } static private class TaskB{ static final long max = 1000000000000000000L; static final double eps = 0.0000001; static final long mod = 1000000007; static int N ,M ,K ; static long X ,Y ; static boolean F[][][] ; static int D[][] ; void solve( InputReader in, PrintWriter out)throws IOException { N = in.nextInt(); M = in.nextInt(); K = in.nextInt(); F = new boolean[K][N][M]; D = new int[N][M]; for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) D[i][j] = Integer.MAX_VALUE; List<Pair> list = new ArrayList<>(); for ( int i = 0;(i < K);i++) {list.add(new Pair((in.nextInt() - 1),(in.nextInt() - 1))); }for ( int i = 0;(i < N);i++) for ( int j = 0;(j < M);j++) for ( int k = 0;(k < K);k++) D[i][j] = Math.min(D[i][j],(Math.abs((list.get(k).X - i)) + Math.abs((list.get(k).Y - j)))); int res = Integer.MIN_VALUE; for ( int j = 0;(j < N);j++) for ( int k = 0;(k < M);k++) if ( (D[j][k] > res)) {X = (j + 1); Y = (k + 1); res = D[j][k]; } out.println(((X + " ") + Y)); } boolean check( int X, int Y){ return ((((X < 0) || (X >= N)) || (Y < 0)) || (Y >= M));} class Pair{ int X ,Y ; Pair( int X, int Y){ this.X = X; this.Y = Y; } } long gcd( long A, long B){ if ( (B == 0)) return A; return gcd(B,(A % B));} long pow( long A, long B, long MOD){ if ( (B == 0)) {return 1;} if ( (B == 1)) {return A;} long val = pow(A,(B / 2),MOD); if ( ((B % 2) == 0)) {return ((val * val) % MOD);} else {return ((val * ((val * A) % MOD)) % MOD);}} } static private class InputReader{ StringTokenizer st ; BufferedReader br ; public InputReader( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public InputReader( FileReader s)throws FileNotFoundException{ br = new BufferedReader(s); } 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 int nextInt(){ return Integer.parseInt(next());} public boolean ready(){ try{return br.ready(); }catch (IOException e){ throw (new RuntimeException(e));} } } }
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();} } }
5	public class 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[] ar = new int[n]; for ( int i = 0;(i < n);i++) {ar[i] = sc.nextInt(); }Arrays.sort(ar); if ( (ar[(b - 1)] == ar[b])) {System.out.println(0); } else {System.out.println((ar[b] - ar[(b - 1)])); }} }
5	public class Main{ public static void main( String[] args)throws IOException { PrintWriter out = new PrintWriter(System.out);  Reader in = new Reader();  Main solver = new Main(); solver.solve(out,in); out.flush(); out.close(); } static int INF = ((((int)1e5 * 4) * 4) + 5); static int maxn = (((int)1e5 * 2) + 1); static int mod = ((int)1e9 + 7); static int n ,m ,k ,t ,q ,x ,a ,b ,y ; static ArrayList<Integer> adj[] ; static int[] dist ,parent ,back ; static boolean[] vis ,vist ; static int root = 0,ans = 1; void solve( PrintWriter out, Reader in)throws IOException { n = in.nextInt(); if ( (n == 1)) {out.println(1); return ;} adj = new ArrayList[(n + 1)]; for ( int i = 1;(i <= n);i++) adj[i] = new ArrayList<Integer>(); int u ,v ; for ( int i = 0;(i < (n - 1));i++) {u = in.nextInt(); v = in.nextInt(); adj[u].add(v); adj[v].add(u); }vist = new boolean[(n + 1)]; vis = new boolean[(n + 1)]; vist[1] = true; makeroot(1); parent = new int[(n + 1)]; dist = new int[(n + 1)]; back = new int[(n + 1)]; dfs(root,0); calcdist(root); vist = new boolean[(n + 1)]; vis = new boolean[(n + 1)]; vist[root] = true; PriorityQueue<Node> pq = new PriorityQueue<Node>(); for ( int i = 1;(i <= n);i++) {if ( (i != root)) pq.add(new Node(i,dist[i])); } Node elm ;  int rt = root; out.print(1); makeroot(root); removeNodes(root,rt); ans += dist[rt]; out.print((" " + ans)); int itr = 2; for ( int i = 2;(i <= n);i++) {elm = pq.remove(); if ( vis[elm.idx]) continue; removeNodes(back[elm.idx],elm.idx); ans += (elm.dist + 1); out.print((" " + ans)); itr++; }for ( int i = itr;(i < n);i++) out.print((" " + ans)); out.println(); } static class Node implements Comparable<Node>{ int dist ,idx ; Node( int idx, int dist){ this.idx = idx; this.dist = dist; } } static void removeNodes( int s, int e){ vis[s] = true; while((s != e)){vis[s] = true; s = parent[s]; }vis[s] = true; return ;} static int calcdist( int s){ int res = 0;  int tmp = 0; for ( int e :adj[s]) {if ( (e != parent[s])) {tmp = calcdist(e); if ( ((1 + tmp) > res)) {res = (1 + tmp); back[s] = back[e]; } } }if ( (res == 0)) back[s] = s; return dist[s] = res;} static void dfs( int s, int p){ for ( int e :adj[s]) {if ( (e != p)) {parent[e] = s; dfs(e,s); } }return ;} static void makeroot( int s){ Queue<Integer> q = new LinkedList<>(); q.add(s); int elm = 0; while((q.size() != 0)){elm = q.remove(); for ( int e :adj[elm]) {if ( !vist[e]) {vist[e] = true; q.add(e); root = e; } }}return ;} 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));} } }
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.nextInt();  int r = in.nextInt();  int[] x = in.readIntArray(n);  double[] y = new double[n]; for ( int i = 0;(i < n);i++) {y[i] = r; for ( int j = 0;(j < i);j++) { double d = Math.abs((x[j] - x[i])); if ( (d <= (2 * r))) { double yy = Math.sqrt((((4.0 * r) * r) - (d * d))); y[i] = Math.max(y[i],(y[j] + yy)); } }}for ( int i = 0;(i < n);i++) {out.print((y[i] + " ")); }} } static class InputReader{ static private BufferedReader in ; static private StringTokenizer tok ; public InputReader( InputStream in){ this.in = new BufferedReader(new InputStreamReader(in)); } public int nextInt(){ return Integer.parseInt(next());} public int[] readIntArray( int n){ int[] ar = new int[n]; for ( int i = 0;(i < n);i++) {ar[i] = nextInt(); }return ar;} public String next(){ try{while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); } }catch (IOException ex){ System.err.println(("An IOException was caught :" + ex.getMessage())); } return tok.nextToken();} } }
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(((a > 1) && (b > 1))){if ( (a < b)) {res += (b / a); b %= a; } else {res += (a / b); a %= b; }}if ( (a == 1)) res += b; else res += a; out.println(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 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 Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int[][] x = new int[200010][10];  String a = sc.nextLine();  String b = sc.nextLine();  int n = a.length();  int m = b.length(); for ( int i = 1;(i <= m);i++) {for ( int j = 0;(j < 2);j++) {x[i][j] = x[(i - 1)][j]; }++x[i][(b.charAt((i - 1)) - '0')]; } long res = 0; for ( int i = 0,c ;(i < n);i++) {c = (a.charAt(i) - '0'); for ( int j = 0;(j < 2);j++) {res += (Math.abs((c - j)) * (x[(((m - n) + i) + 1)][j] - x[i][j])); }}System.out.println(res); } }
0	public class Main{ Scanner cin = new Scanner(new BufferedInputStream(System.in)); long n ; long maxlcm ; void run(){ n = cin.nextInt(); if ( ((n == 1) || (n == 2))) maxlcm = n; else if ( (n >= 3)) {if ( ((n % 2) != 0)) {maxlcm = ((n * (n - 1)) * (n - 2)); } else if ( ((n % 3) != 0)) maxlcm = ((n * (n - 1)) * (n - 3)); else maxlcm = (((n - 1) * (n - 2)) * (n - 3)); } System.out.println(maxlcm); } public static void main( String[] args){ new Main().run(); } }
0	public class D{ static Scanner in = new Scanner(new BufferedInputStream(System.in)); static PrintWriter out = new PrintWriter(System.out); static double getTime( double v, double a, double l, double r){ return ((-v + Math.sqrt(((v * v) - ((2 * a) * (l - r))))) / a);} static double getVelocity( double v, double t, double l, double r){ return ((t == 0)?v:(((2 * (r - l)) / t) - v));} public static void main( String[] args)throws IOException { double a = in.nextDouble(),v = in.nextDouble(),l = in.nextDouble(),d = in.nextDouble(),w = Math.min(v,in.nextDouble());  double x = ((v * v) / (2 * a)),y = (d - (((v * v) - (w * w)) / (2 * a))),z = (d + (((v * v) - (w * w)) / (2 * a)));  double L ,R ,T = 0,V = 0,t ; L = 0; R = x; if ( ((x > y) && (x < z))) {R = ((x + y) / 2); } else if ( (x > l)) {R = l; } t = getTime(V,a,L,R); V = getVelocity(V,t,L,R); T += t; if ( (x < y)) {T += ((y - x) / v); } L = y; R = d; if ( ((x > y) && (x < z))) {L = ((x + y) / 2); } else if ( (x >= z)) {L = R; } t = getTime(V,-a,L,R); V = getVelocity(V,t,L,R); T += t; L = d; R = z; if ( (x >= z)) {R = L; } else if ( (z > l)) {R = l; } t = getTime(V,a,L,R); V = getVelocity(V,t,L,R); T += t; L = z; R = l; if ( (x > z)) {L = x; } if ( (L < R)) {T += ((R - L) / v); } out.format(Locale.US,"%.12f%n",T); out.close(); } }
2	public class Main{ public static void main( String[] args)throws IOException { InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Answer solver = new Answer(); solver.solve(in,out); out.close(); } } class Answer{ private int sumd( long x){ int sum = 0; while((x != 0)){sum += (x % 10); x /= 10; }return sum;} private long bin( long l, long r, long s){ if ( (l > r)) {return -1;} long x = ((l + r) >> 1);  int sum = sumd(x); if ( ((x - sum) < s)) {return bin((x + 1),r,s);} long t = bin(l,(x - 1),s); if ( (t != -1)) {return t;} return x;} public void solve( InputReader in, PrintWriter out)throws IOException { long n = in.nextLong();  long s = in.nextLong();  long t = bin(1,n,s); if ( (t == -1)) {out.print("0"); } else { long ans = ((n - t) + 1); out.print(ans); }} } class InputReader{ private BufferedReader reader ; private StringTokenizer tokenizer ; 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 long nextLong(){ return Long.parseLong(next());} }
5	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt();  long totalBlocks = 0;  long a[] = new long[n]; for ( int i = 0;(i < n);++i) {a[i] = sc.nextLong(); totalBlocks += a[i]; }Arrays.sort(a); long selected = 0; for ( int i = 0;(i < n);++i) {if ( (a[i] > selected)) selected++; } long leftCols = (a[(n - 1)] - selected);  long remBlocks = ((totalBlocks - leftCols) - n); System.out.print(remBlocks); } }
5	public class A{ BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = null; private void solve()throws IOException { int n = nextInt();  int k = nextInt();  int p[] = new int[n];  int t[] = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = nextInt(); t[i] = nextInt(); }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( ((p[i] < p[j]) || ((p[i] == p[j]) && (t[i] > t[j])))) { int tmp = p[i]; p[i] = p[j]; p[j] = tmp; tmp = t[i]; t[i] = t[j]; t[j] = tmp; } }} int pN = p[(k - 1)];  int tN = t[(k - 1)];  int counter = 0; for ( int i = 0;(i < n);i++) {if ( ((p[i] == pN) && (t[i] == tN))) {counter++; } }System.out.println(counter); } String nextToken()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(bf.readLine()); } return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(nextToken());} public static void main( String[] args)throws IOException { new A().solve(); } }
3	public class Main{ void solve(){ int n = ni();  int a[] = new int[(n + 1)]; for ( int i = 1;(i <= n);i++) a[i] = ni(); int vis[] = new int[101];  int ans = 0; Arrays.sort(a,1,(n + 1)); for ( int i = 1;(i <= n);i++) {if ( (vis[a[i]] == 1)) continue; ans++; for ( int j = a[i];(j <= 100);j += a[i]) vis[j] = 1; }pw.println(ans); } long M = ((long)1e9 + 7); PrintWriter pw ; StringTokenizer st ; BufferedReader br ; void run()throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); pw.flush(); } public static void main( String[] args)throws Exception { new Main().run(); } String ns(){ while(((st == null) || !st.hasMoreElements())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} int ni(){ return Integer.parseInt(ns());} }
4	public class CF{ class W implements Comparable<W>{ int id ,sz ; W( int id, int sz){ this.id = id; this.sz = sz; } } int[] left ; int center ; boolean[] used ; boolean go( int v){ if ( used[v]) return false; used[v] = true; for ( int i = 0;(i < g[v].size());++i) { int to = g[v].get(i); if ( (to == center)) continue; if ( ((left[to] == -1) || go(left[to]))) {left[to] = v; return true;} }return false;} ArrayList<Integer>[] g ; void solve(){ int n = in.nextInt();  int m = in.nextInt(); used = new boolean[n]; g = new ArrayList[n]; for ( int i = 0;(i < n);i++) g[i] = new ArrayList<>(); for ( int i = 0;(i < m);i++) {g[(in.nextInt() - 1)].add((in.nextInt() - 1)); } long st = System.currentTimeMillis();  int ans = Integer.MAX_VALUE;  W[] a = new W[n]; for ( int i = 0;(i < n);i++) {a[i] = new W(i,g[i].size()); }left = new int[n]; Arrays.sort(a); for ( int centerId = 0;(centerId < n);centerId++) {center = a[centerId].id; if ( ((System.currentTimeMillis() - st) > 800)) break; int cost = (n - g[center].size()); Arrays.fill(left,-1); for ( int i = 0;(i < n);i++) if ( (i != center)) { boolean has = false; for ( int j = 0;(j < g[i].size());j++) {if ( (g[i].get(j) == center)) has = true; }Arrays.fill(used,false); if ( !go(i)) {if ( has) {cost += g[i].size(); } else {cost += (g[i].size() + 2); }} else {if ( has) {cost += (g[i].size() - 2); } else {cost += g[i].size(); }}} ans = Math.min(ans,cost); }out.println(ans); } FastScaner in ; PrintWriter out ; void run(){ in = new FastScaner(System.in); out = new PrintWriter(System.out); solve(); out.close(); } public static void main( String[] args){ Locale.setDefault(Locale.US); new CF().run(); } class FastScaner{ BufferedReader br ; StringTokenizer st ; FastScaner( InputStream is){ br = new BufferedReader(new InputStreamReader(is)); } FastScaner( File f){ try{br = new BufferedReader(new FileReader(f)); }catch (FileNotFoundException e){ e.printStackTrace(); } } String next(){ while(((st == null) || !st.hasMoreElements())){ String s = null; try{s = br.readLine(); }catch (IOException e){ e.printStackTrace(); } if ( (s == null)) return null; st = new StringTokenizer(s); }return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} } }
1	public class B{ public static void main( String[] args){ Scanner scr = new Scanner(System.in);  int n = scr.nextInt();  int k = scr.nextInt();  int[] a = new int[(n + 1)];  int[] d = new int[100001];  int tk = 0;  int l = 1;  int r = -1;  boolean find = false; for ( int i = 1;(i <= n);i++) {a[i] = scr.nextInt(); if ( (d[a[i]] == 0)) {d[a[i]] = 1; tk++; if ( (find && (tk == k))) {find = true; r = i; } } }if ( (r > 0)) { int[] cd = new int[100001]; tk = 0; find = false; for ( int j = r;(j >= l);j--) {if ( (cd[a[j]] == 0)) {cd[a[j]] = 1; tk++; if ( (find && (tk == k))) {find = true; l = j; break;} } }System.out.println(((l + " ") + r)); } else {System.out.println("-1 -1"); }} }
2	public class B{ public static void main( String[] args)throws Exception { new B().run(); } public void run()throws Exception { FastIO file = new FastIO();  long n = file.nextLong();  long k = file.nextLong();  long lo = 1;  long hi = n;  long ans = 0; while((lo <= hi)){ long mi = (lo + ((hi - lo) / 2));  long q = (((mi * (mi + 1)) / 2) - (n - mi)); if ( (q == k)) {ans = (n - mi); break;} else if ( (q < k)) {lo = (mi + 1); } else {hi = (mi - 1); }}System.out.println(ans); } public static class FastIO{ BufferedReader br ; StringTokenizer st ; public FastIO(){ 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 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 long gcd( long x, long y){ if ( (x == 0)) return y; else return gcd((y % x),x);} }
0	public class Main{ public static Scanner scan = new Scanner(System.in); public static boolean bg = true; public static void main( String[] args)throws Exception { long n1 = Integer.parseInt(scan.next()); if ( (n1 == 1)) {System.out.println(1); System.exit(0); } if ( (n1 == 2)) {System.out.println(2); System.exit(0); } if ( (n1 == 3)) {System.out.println(6); System.exit(0); } if ( ((n1 % 2) == 0)) {if ( ((n1 % 3) == 0)) {n1 -= 1; n1 = ((n1 * (n1 - 1)) * (n1 - 2)); System.out.println(n1); } else {n1 = ((n1 * (n1 - 1)) * (n1 - 3)); System.out.println(n1); }} else {n1 = ((n1 * (n1 - 1)) * (n1 - 2)); System.out.println(n1); }} }
0	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 a ,v ; int l ,d ,w ; void run()throws IOException { a = in.nextInt(); v = in.nextInt(); l = in.nextInt(); d = in.nextInt(); w = in.nextInt(); double totalTime = 0.0; if ( (v >= w)) {if ( ((w * w) >= ((2 * a) * d))) { double x = Math.sqrt(((2 * a) * d)); totalTime = (x / a); if ( (((v * v) - (x * x)) >= ((2 * a) * (l - d)))) totalTime += (((-2 * x) + Math.sqrt((((4 * x) * x) + ((8 * a) * (l - d))))) / (2 * a)); else totalTime += (((v - x) / (1.0 * a)) + (((l - d) - (((v * v) - (x * x)) / (2.0 * a))) / v)); } else {if ( ((((2 * v) * v) - (w * w)) <= ((2 * a) * d))) {totalTime = (((v / (1.0 * a)) + ((v - w) / (1.0 * a))) + ((d - ((((2 * v) * v) - (w * w)) / (2.0 * a))) / v)); } else { double x = Math.sqrt(((((2 * a) * d) + (w * w)) / 2.0)); totalTime = ((x / a) + ((x - w) / a)); }if ( (((v * v) - (w * w)) >= ((2 * a) * (l - d)))) totalTime += (((-2 * w) + Math.sqrt((((4 * w) * w) + ((8 * a) * (l - d))))) / (2 * a)); else totalTime += (((v - w) / (1.0 * a)) + (((l - d) - (((v * v) - (w * w)) / (2.0 * a))) / v)); }} else {if ( ((v * v) >= ((2 * a) * l))) totalTime = Math.sqrt(((l * 2.0) / a)); else totalTime = ((v / (1.0 * a)) + ((l - ((v * v) / (2.0 * a))) / v)); }out.printf("%.10f",totalTime); out.flush(); } 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());} } }
6	public class Main{ static class TaskAdapter implements Runnable{ } public static void main( String[] args)throws Exception { Thread thread = new Thread(null,new TaskAdapter(),"",(1 << 28)); thread.start(); thread.join(); } static class EKeyboardPurchase{ private final int iinf = 1_000_000_000; public EKeyboardPurchase(){ } public void solve( int kase, InputReader in, Output pw){ int n = in.nextInt(),m = in.nextInt();  int[] arr = in.nextIntChar((o)->(o - 'a'));  int[][] sum = new int[m][(1 << m)]; { int[][] cnt = new int[m][m]; for ( int i = 0;(i < (n - 1));i++) { int a = arr[i],b = arr[(i + 1)]; cnt[a][b]++; cnt[b][a]++; }for ( int i = 0;(i < m);i++) {for ( int j = 1;(j < (1 << m));j++) { int x = (j & -j); sum[i][j] = (sum[i][(j ^ x)] + cnt[i][(31 - Integer.numberOfLeadingZeros(x))]); }}} int[] mbit = new int[(1 << m)]; for ( int i = 1;(i < (1 << m));i++) {mbit[i] = Integer.numberOfTrailingZeros((i & -i)); } int[] dp = new int[(1 << m)]; for ( int i = 1;(i < (1 << m));i++) { int ans = iinf,ci = i; for ( int j = mbit[ci];(ci > 0);ci -= (1 << j),j = mbit[ci]) { int cur = (dp[(i ^ (1 << j))] + sum[j][(i ^ (1 << j))]);  int x = (((1 << m) - 1) ^ i);  int cm = i; for ( int k = mbit[cm];(cm > 0);cm -= (1 << k),k = mbit[cm]) {cur += sum[k][x]; }cur -= sum[j][x]; ans = Math.min(ans,cur); }dp[i] = ans; }pw.println(dp[(dp.length - 1)]); } } static interface InputReader{ String next(); int nextInt(); default int[] nextIntChar( Function<Character,Integer> f){ String s = next();  int[] ret = new int[s.length()]; for ( int i = 0;(i < s.length());i++) {ret[i] = f.apply(s.charAt(i)); }return ret;} } static class FastReader implements InputReader{ private final int BUFFER_SIZE = (1 << 16); private DataInputStream din ; private byte[] buffer ; private int bufferPointer ; private int bytesRead ; public FastReader( InputStream is){ din = new DataInputStream(is); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String next(){ StringBuilder ret = new StringBuilder(64);  byte c = skip(); while(((c != -1) && !isSpaceChar(c))){ret.appendCodePoint(c); c = read(); }return ret.toString();} public int nextInt(){ int ret = 0;  byte c = skipToDigit();  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 boolean isSpaceChar( byte b){ return (((((b == ' ') || (b == '\r')) || (b == '\n')) || (b == '\t')) || (b == '\f'));} private byte skip(){ byte ret ; while(isSpaceChar(ret = read()));return ret;} private boolean isDigit( byte b){ return ((b >= '0') && (b <= '9'));} private byte skipToDigit(){ byte ret ; while((!isDigit(ret = read()) && (ret != '-')));return ret;} private void fillBuffer(){ try{bytesRead = din.read(buffer,bufferPointer = 0,BUFFER_SIZE); }catch (IOException e){ e.printStackTrace(); throw (new InputMismatchException());} if ( (bytesRead == -1)) {buffer[0] = -1; } } private byte read(){ if ( (bytesRead == -1)) {throw (new InputMismatchException());} else if ( (bufferPointer == bytesRead)) {fillBuffer(); } return buffer[bufferPointer++];} } static class Output implements Closeable,Flushable{ public StringBuilder sb ; public OutputStream os ; public int BUFFER_SIZE ; public String lineSeparator ; public Output( OutputStream os){ this(os,(1 << 16)); } public Output( OutputStream os, int bs){ BUFFER_SIZE = bs; sb = new StringBuilder(BUFFER_SIZE); this.os = new BufferedOutputStream(os,(1 << 17)); lineSeparator = System.lineSeparator(); } public void println( int i){ println(String.valueOf(i)); } public void println( String s){ sb.append(s); println(); } public void println(){ sb.append(lineSeparator); } private void flushToBuffer(){ try{os.write(sb.toString().getBytes()); }catch (IOException e){ e.printStackTrace(); } sb = new StringBuilder(BUFFER_SIZE); } public void flush(){ try{flushToBuffer(); os.flush(); }catch (IOException e){ e.printStackTrace(); } } public void close(){ flush(); try{os.close(); }catch (IOException e){ e.printStackTrace(); } } } }
1	public class C701{ public static int f( char c){ if ( ((c >= 'a') && (c <= 'z'))) {return (c - 'a');} else {return ((26 + c) - 'A');}} public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(reader.readLine());  char[] ch = reader.readLine().toCharArray();  LinkedList<Integer>[] p = new LinkedList[52]; for ( int i = 0;(i < 52);i++) {p[i] = new LinkedList<>(); } int[] fc = new int[n]; for ( int i = 0;(i < n);i++) { int cc = f(ch[i]); p[cc].add(i); fc[i] = cc; } int en = 0; for ( int i = 0;(i < 52);i++) {if ( (p[i].size() > 0)) en = Math.max(en,p[i].poll()); } int mx = (en + 1); for ( int i = 0;(i < n);i++) {if ( (p[fc[i]].size() == 0)) break; en = Math.max(en,p[fc[i]].poll()); mx = Math.min(mx,(en - i)); }System.out.println(mx); } }
5	public class LittleElephantAndProblem{ boolean DEBUG = true; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringBuilder out = new StringBuilder(); StringTokenizer st = null; String s()throws IOException { if ( ((st == null) || !st.hasMoreTokens())) {st = new StringTokenizer(in.readLine()); } return st.nextToken();} int i()throws IOException { return Integer.parseInt(s());} int i( String s)throws IOException { return Integer.parseInt(s);} void fl(){ System.out.print(out); } int n = i(); public LittleElephantAndProblem()throws IOException{ List<Integer> a = new ArrayList<Integer>();  List<Integer> b = new ArrayList<Integer>(); for ( int i = 0;(i < n);++i) { int x = i(); a.add(x); b.add(x); }sort(b); int d = 0; for ( int i = 0;(i < n);++i) {if ( ((int)a.get(i) != (int)b.get(i))) {++d; } }if ( (d > 2)) {out.append("NO\n"); } else {out.append("YES\n"); }fl(); } public static void main( String[] args)throws IOException { new LittleElephantAndProblem(); } }
6	public class ACMIND{ static FastReader scan ; static PrintWriter pw ; static long MOD = 1_000_000_007; static long INF = 1_000_000_000_000_000_000L; static long inf = 2_000_000_000; public static void main( String[] args){ new Thread(null,null,"BaZ",(1 << 25)){}.start(); } static int n ,g[] ,t[] ,T ; static int dp[][] ; static void solve()throws IOException { scan = new FastReader(); pw = new PrintWriter(System.out,true); StringBuilder fast = new StringBuilder(); n = ni(); T = ni(); g = new int[n]; t = new int[n]; for ( int i = 0;(i < n);++i) {t[i] = ni(); g[i] = ni(); } int MAX = (1 << n); dp = new int[MAX][4]; for ( int i = 0;(i < MAX);++i) {for ( int j = 0;(j < 4);++j) {dp[i][j] = -1; }}pl(f(((1 << n) - 1),0)); pw.flush(); pw.close(); } static int f( int mask, int prev){ if ( (dp[mask][prev] != -1)) {return dp[mask][prev];} int left = T; for ( int i = 0;(i < n);++i) {if ( ((mask & (1 << i)) == 0)) {left -= t[i]; } }if ( (left == 0)) {return 1;} int cnt = 0; for ( int i = 0;(i < n);++i) {if ( ((mask & (1 << i)) != 0)) {if ( ((g[i] != prev) && (left >= t[i]))) {cnt += f((mask ^ (1 << i)),g[i]); if ( (cnt >= MOD)) {cnt -= MOD; } } } }return dp[mask][prev] = cnt;} static int ni()throws IOException { return scan.nextInt();} static void pl(){ pw.println(); } static void p( Object o){ pw.print((o + " ")); } static void pl( Object o){ pw.println(o); } 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;} 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(); } } }
5	public class problemA{ 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[] hs = new int[n]; for ( int i = 0;(i < n);i++) {hs[i] = sc.nextInt(); }Arrays.sort(hs); System.out.println((hs[b] - hs[(b - 1)])); } }
1	public class C138B{ static private StringTokenizer st ; public static void nextLine( BufferedReader br)throws IOException { st = new StringTokenizer(br.readLine()); } public static int nextInt(){ return Integer.parseInt(st.nextToken());} public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); nextLine(br); int n = nextInt();  int k = nextInt();  int[] a = new int[n]; nextLine(br); for ( int i = 0;(i < n);i++) a[i] = nextInt(); int bp = 0,fp = 0,count = 0;  boolean good = false;  int[] mark = new int[100001]; for ( fp = 0;(fp < n);fp++) {if ( (mark[a[fp]] == 0)) {count++; } mark[a[fp]]++; if ( (count == k)) {good = true; break;} }if ( !good) {System.out.println("-1 -1"); return ;} for ( bp = 0;(bp < fp);bp++) {if ( (mark[a[bp]] > 1)) {mark[a[bp]]--; } else break;}System.out.println((((bp + 1) + " ") + (fp + 1))); } }
1	public class codeforces2{ public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int tc = sc.ni(); for ( int rep = 0;(rep < tc);rep++) { long n = sc.nl(); if ( ((n % 2) == 1)) {pw.println("NO"); } else {n /= 2; if ( perfectSquare(n)) {pw.println("YES"); } else if ( (((n % 2) == 0) && perfectSquare((n / 2)))) {pw.println("YES"); } else {pw.println("NO"); }}}pw.close(); } public static boolean perfectSquare( long n){ long lo = 0;  long hi = n; while((lo < hi)){ long k = ((lo + hi) / 2); if ( ((k * k) < n)) lo = (k + 1); else hi = k; }return ((lo * lo) == n);} static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} public static void sort( int[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  int temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } public static void sort( long[] arr){ Random rgen = new Random(); for ( int i = 0;(i < arr.length);i++) { int r = rgen.nextInt(arr.length);  long temp = arr[i]; arr[i] = arr[r]; arr[r] = temp; }Arrays.sort(arr); } } class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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());} long nl(){ return Long.parseLong(next());} }
3	public class java2{ public static void main( String[] args){ Scanner r = new Scanner(System.in);  int n = r.nextInt();  int[] l = new int[1005];  int[] ri = new int[1005];  int[] candy = new int[1005]; for ( int i = 1;(i <= n);++i) {l[i] = r.nextInt(); }for ( int i = 1;(i <= n);++i) {ri[i] = r.nextInt(); }for ( int i = 1;(i <= n);++i) {if ( ((l[i] > (i - 1)) || (ri[i] > (n - i)))) {System.out.println("NO"); System.exit(0); } candy[i] = ((n - l[i]) - ri[i]); }for ( int i = 1;(i <= n);++i) { int left = 0,right = 0; for ( int j = 1;(j <= (i - 1));++j) {if ( (candy[j] > candy[i])) {++left; } }for ( int j = (i + 1);(j <= n);++j) {if ( (candy[j] > candy[i])) {++right; } }if ( ((left != l[i]) || (right != ri[i]))) {System.out.println("NO"); System.exit(0); } }System.out.println("YES"); for ( int i = 1;(i <= n);++i) {System.out.print((candy[i] + " ")); }} }
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(),a = in.nextInt(),b = in.nextInt(),i ,c = 0;  int ar[] = new int[n]; for ( i = 0;(i < n);i++) ar[i] = in.nextInt(); Arrays.sort(ar); out.println((ar[b] - ar[(b - 1)])); } }
4	public class Main{ static boolean LOCAL = (System.getSecurityManager() == null); Scanner in = new Scanner(System.in); private int[] B ; private int[] A ; private int n ; private int m ; void run(){ n = in.nextInt(); m = in.nextInt(); A = new int[m]; B = new int[m]; for ( int i = 0;(i < m);i++) {A[i] = (in.nextInt() - 1); B[i] = (in.nextInt() - 1); } int ans = Integer.MAX_VALUE; for ( int i = 0;(i < n);i++) {ans = min(ans,solve(i)); }out.println(ans); } int solve( int x){ int ans = (((3 * (n - 1)) + 1) + m);  V[] vs = new V[(n * 2)]; for ( int i = 0;(i < vs.length);i++) vs[i] = new V(); for ( int i = 0;(i < m);i++) {if ( ((A[i] == x) || (B[i] == x))) ans -= 2; else vs[A[i]].connect(vs[(n + B[i])]); }return (ans - (2 * bipartiteMatching(vs)));} class V extends ArrayList<V>{ V pair ; boolean used ; void connect( V v){ add(v); v.add(this); } } int bipartiteMatching( V[] vs){ int match = 0; for ( V v :vs) if ( (v.pair == null)) {for ( V u :vs) u.used = false; if ( dfs(v)) match++; } return match;} boolean dfs( V v){ v.used = true; for ( V u :v) { V w = u.pair; if ( ((w == null) || (!w.used && dfs(w)))) {v.pair = u; u.pair = v; return true;} }return false;} public static void main( String[] args){ if ( LOCAL) {try{System.setIn(new FileInputStream("./../../in.txt")); }catch (Throwable e){ LOCAL = false; } } long start = 0; if ( LOCAL) start = System.nanoTime(); new Main().run(); if ( LOCAL) System.err.printf("[Time : %.6f s]%n",((System.nanoTime() - start) * 1e-9)); } } class Scanner{ BufferedReader br ; StringTokenizer st ; Scanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); eat(""); } void eat( String s){ st = new StringTokenizer(s); } String nextLine(){ try{return br.readLine(); }catch (IOException e){ return null;} } boolean hasNext(){ while(!st.hasMoreTokens()){ String s = nextLine(); if ( (s == null)) return false; eat(s); }return true;} String next(){ hasNext(); return st.nextToken();} int nextInt(){ return Integer.parseInt(next());} }
1	public class ProbB 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"); static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter writer ; static private String alphabet ; static 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)); }}} static private String oneInt( String row, int col){ return ((("R" + col) + "C") + toNum(row));} static 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;} static private String twoInts( Integer row, Integer col){ return (toAlpha(col) + row);} static 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 ProbB()); thread.start(); thread.join(); } static int nextInt()throws Exception { return Integer.parseInt(nextToken());} static String nextToken()throws Exception { while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(reader.readLine()); }return tokenizer.nextToken();} }
1	public class Main{ static class FastReader{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ,numChars ; public FastReader(){ this(System.in); } public FastReader( 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 long l(){ 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 i(){ 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));} public void scanIntArr( int[] arr){ for ( int li = 0;(li < arr.length);++li) {arr[li] = i(); }} } public static void main( String[] args)throws IOException { PrintWriter pw = new PrintWriter(System.out);  FastReader fr = new FastReader();  int n = fr.i();  int[] arr = new int[n]; fr.scanIntArr(arr); int min = Integer.MAX_VALUE;  int max = Integer.MIN_VALUE;  long sum = 0; if ( (n == 1)) {pw.println(arr[0]); pw.flush(); pw.close(); return ;} for ( int i = 0;(i < n);++i) {if ( (arr[i] < min)) min = arr[i]; if ( (arr[i] > max)) max = arr[i]; sum += Math.abs(arr[i]); }if ( (min > 0)) {sum -= (2 * min); } if ( (max < 0)) {sum += (2 * max); } pw.println(sum); pw.flush(); pw.close(); } }
5	public class Beacon8{ public static void main( String[] args)throws IOException { Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  Map<Integer,Integer> beacons = new TreeMap<>(); for ( int i = 0;(i < n);i++) { int index = scan.nextInt();  int power = scan.nextInt(); beacons.put(index,power); } int[] indicesArr = new int[n];  int arrInd = 0; for ( int index :beacons.keySet()) {indicesArr[arrInd] = index; arrInd++; } int[] nDestroys = new int[n]; for ( int i = 0;(i < n);i++) { int bIndex = Arrays.binarySearch(indicesArr,(indicesArr[i] - beacons.get(indicesArr[i]))); if ( (bIndex < 0)) bIndex = (bIndex + 1); nDestroys[i] = (i - bIndex); } int[] totalBeacons = new int[n];  int maxBeacons = 1; totalBeacons[0] = 1; for ( int i = 1;(i < n);i++) {if ( (nDestroys[i] == 0)) totalBeacons[i] = (totalBeacons[(i - 1)] + 1); else {if ( (((i - nDestroys[i]) - 1) >= 0)) totalBeacons[i] = (totalBeacons[((i - nDestroys[i]) - 1)] + 1); else totalBeacons[i] = 1; }if ( (totalBeacons[i] > maxBeacons)) maxBeacons = totalBeacons[i]; }System.out.println((n - maxBeacons)); } }
0	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long k = sc.nextLong(); System.out.println(solve(n,k)); sc.close(); } static long solve( long n, long k){ return Math.max(0,((Math.min(n,(k - 1)) - ((k + 2) / 2)) + 1));} }
1	public class C_138B{ static private BufferedReader in ; static private StringTokenizer st ; static private 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(); } }
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 Rules{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  double a = in.nextInt();  double v = in.nextInt();  double l = in.nextInt();  double d = in.nextInt();  double w = in.nextInt(); if ( (v <= w)) { double t = (v / a); if ( ((((0.5 * t) * t) * a) > l)) {t = Math.sqrt(((2 * l) / a)); } else {t += ((l - (((0.5 * t) * t) * a)) / v); }System.out.printf("%.5f",t); } else { double total = 0.0;  double t = (v / a);  double t2 = ((v - w) / a);  double tempt = Math.sqrt(((2.0 * d) / a)); if ( ((tempt * a) <= w)) {total += tempt; w = (tempt * a); } else if ( ((((((0.5 * t) * t) * a) + (v * t2)) - (((0.5 * t2) * t2) * a)) > d)) { double as = (2.0 * a);  double bs = (4.0 * w);  double cs = (((w * w) / (a)-2.0) * d);  double delta = ((bs * bs) - ((4.0 * as) * cs));  double root = ((-bs + Math.sqrt(delta)) / (2.0 * as)); if ( (root < 0.0)) {root = ((-bs - Math.sqrt(delta)) / (2.0 * as)); } total += ((2.0 * root) + (w / a)); } else {total += (t + t2); double smd = ((((d - (((0.5 * t) * t) * a)) - (v * t2)) + (((0.5 * t2) * t2) * a)) / v); total += smd; } double t3 = ((v - w) / a); if ( (((w * t3) + (((0.5 * t3) * t3) * a)) > (l - d))) { double as = (0.5 * a);  double bs = w;  double cs = (d - l);  double delta = ((bs * bs) - ((4.0 * as) * cs));  double root = ((-bs + Math.sqrt(delta)) / (2.0 * as)); if ( (root < 0.0)) {root = ((-bs - Math.sqrt(delta)) / (2.0 * as)); } total += root; } else {total += t3; double t4 = (((l - ((w * t3) + (((0.5 * t3) * t3) * a))) - d) / v); total += t4; }System.out.printf("%.5f",total); }} }
6	public class Main{ static private int[] x = new int[26],y = new int[26],dp = new int[(1 << 24)],pre = new int[(1 << 24)]; static private 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 D{ static int bot ; static int n ,m ; static int[][] a ; static int[][] Min ; static int[][] memo ; static int K ; static int dp( int msk, int ones, int last){ if ( (ones == n)) {return ((Min[last][bot] >= K)?1:0);} if ( (memo[last][msk] != -1)) return memo[last][msk]; int ans = 0; for ( int nxt = 0;(nxt < n);nxt++) if ( (((msk & (1 << nxt)) == 0) && (Min[last][nxt] >= K))) {ans |= dp((msk | (1 << nxt)),(ones + 1),nxt); } return memo[last][msk] = ans;} static boolean check( int top, int bottom){ for ( int j = 0;((j + 1) < m);j++) { int diff = Math.abs((a[bottom][j] - a[top][(j + 1)])); if ( (diff < K)) return false; }return true;} public static void main( String[] args)throws IOException { Scanner sc = new Scanner();  PrintWriter out = new PrintWriter(System.out); n = sc.nextInt(); m = sc.nextInt(); a = new int[n][m]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) a[i][j] = sc.nextInt(); Min = new int[n][n]; if ( (n == 1)) { int lo = 0,hi = (int)1e9;  int ans = 0; while((lo <= hi)){K = ((lo + hi) >> 1); if ( check(0,0)) {ans = K; lo = (K + 1); } else hi = (K - 1); }System.out.println(ans); return ;} for ( int i1 = 0;(i1 < n);i1++) for ( int i2 = 0;(i2 < n);i2++) {if ( (i1 == i2)) continue; int min = (int)1e9; for ( int j = 0;(j < m);j++) min = Math.min(Math.abs((a[i1][j] - a[i2][j])),min); Min[i1][i2] = min; }memo = new int[n][(1 << n)]; int ans = 0;  int lo = 0,hi = (int)1e9; while((lo <= hi)){K = ((lo + hi) >> 1); for ( int[] x :memo) Arrays.fill(x,-1); int ok = 0; for ( int top = 0;((top < n) && (ok == 0));top++) for ( int bottom = 0;((bottom < n) && (ok == 0));bottom++) {bot = bottom; if ( ((top == bottom) || !check(top,bottom))) continue; int dp = dp(((1 << top) | (1 << bottom)),2,top); ok |= dp; }if ( (ok == 1)) {ans = K; lo = (K + 1); } else hi = (K - 1); }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());} } }
3	public class ProblemC{ public static void main( String[] args){ FastScanner input = new FastScanner();  int n = input.nextInt();  int radius = input.nextInt();  ArrayList<Integer> diskXToFall = new ArrayList<Integer>(); for ( int a = 0;(a < n);a++) {diskXToFall.add(input.nextInt()); } ArrayList<P> stationaryDisks = new ArrayList<P>(); for ( int a = 0;(a < n);a++) { double highCollision = radius; for ( P i :stationaryDisks) {if ( ((Math.abs((diskXToFall.get(a) - i.x)) - 1e-8) <= (2 * radius))) { double hypot = (2 * radius);  double leg = Math.abs((diskXToFall.get(a) - i.x));  double yOffset = Math.sqrt(Math.abs(((hypot * hypot) - (leg * leg)))); highCollision = Math.max(highCollision,(yOffset + i.y)); } }stationaryDisks.add(new P(diskXToFall.get(a),highCollision)); }for ( int a = 0;(a < n);a++) {System.out.print((stationaryDisks.get(a).y + " ")); }} static class P implements Comparable<P>{ final double x ,y ; P( double x, double y){ this.x = x; this.y = y; } P sub( P that){ return new P((x - that.x),(y - that.y));} P add( P that){ return new P((x + that.x),(y + that.y));} double dot( P that){ return ((x * that.x) + (y * that.y));} P scale( double s){ return new P((x * s),(y * s));} double length(){ return sqrt(((x * x) + (y * y)));} double length2(){ return ((x * x) + (y * y));} P rightNormal(){ return new P(y,-x);} P normalize(){ double n = length(); return ((n > 0)?new P((x / n),(y / n)):origin());} P scaleToLength( double l){ return normalize().scale(l);} P project( P a){ return scale((a.dot(this) / length2()));} P reflect( P a){ return project(a).scale(2.0).sub(a);} P rotateCCW( double sinT, double cosT){ return new P(((x * cosT) - (y * sinT)),((x * sinT) + (y * cosT)));} double theta(){ return atan2(y,x);} boolean isOrigin(){ return ((x == 0) && (y == 0));} public String toString(){ return String.format("(%f,%f)",this.x,this.y);} static P origin(){ return new P(0,0);} double det( P that){ return ((this.x * that.y) - (this.y * that.x));} double crossproduct( P that){ return this.det(that);} double dist( P to){ return sub(to).length();} double signedParallelogramArea( P b, P c){ return b.sub(this);} boolean isCollinearWith( P b, P c){ return (abs(signedParallelogramArea(b,c)) <= EPS);} boolean isCCW( P b, P c){ return (signedParallelogramArea(b,c) > 0);} P[] solveDotProductConstrainedByNorm( double b, double C){ P a = this; if ( a.isOrigin()) throw (new Error("degenerate case")); boolean transpose = (abs(a.x) > abs(a.y)); a = (transpose?new P(a.y,a.x):a); Double[] x = solvequadratic(a.length2(),((2.0 * b) * a.x),((b * b) - (((a.y * a.y) * C) * C)));  P[] p = new P[x.length]; for ( int i = 0;(i < x.length);i++) { double x1 = x[i];  double x2 = ((-b - (a.x * x1)) / a.y); p[i] = (transpose?new P(x2,x1):new P(x1,x2)); }return p;} @Override public int compareTo( P that){ if ( (abs((this.x - that.x)) > EPS)) return Double.compare(this.x,that.x); return Double.compare(this.y,that.y);} } static Double[] solvequadratic( double a, double b, double c){ double D = ((b * b) - ((4 * a) * c)); if ( (D < -EPS)) return new Double[]{}; D = max(D,0); if ( (D == 0)) return new Double[]{((-b / 2.0) / a)}; double d = sqrt(D); if ( (signum(b) == 0)) return new Double[]{((d / 2.0) / a),((-d / 2.0) / a)}; double x1 = ((-b - (signum(b) * d)) / (2 * a));  double x2 = (c / (a * x1)); return new Double[]{Math.min(x1,x2),Math.max(x1,x2)};} static double EPS = 1e-6; static class Line{ P p ,q ,d ; Line( P p, P q){ this.p = p; this.q = q; d = q.sub(p); } P getPointFromParameter( double t){ return p.add(d.scale(t));} P reflect( P d2){ return d.reflect(d2);} P project( P a){ return p.add(d.project(a.sub(p)));} @Override public String toString(){ return String.format("[%s => %s]",p,q);} double[] intersectionParameters( Line l){ P dneg = p.sub(q);  double D = l.d.det(dneg); if ( (D == 0.0)) return null; P rp = p.sub(l.p); return new double[]{(l.d.det(rp) / D),(rp.det(dneg) / D)};} P[] intersectsCircle( Circle c){ P x = project(c.c);  double D = x.dist(c.c); if ( (D > (c.R + EPS))) return new P[0]; double h = sqrt(max(0,((c.R * c.R) - (D * D)))); if ( (h == 0)) return new P[]{x}; return new P[]{x.add(d.scaleToLength(h)),x.add(d.scaleToLength(-h))};} boolean isInBounds( P r){ return (abs(((p.dist(q) - p.dist(r)) - q.dist(r))) <= EPS);} } static class Circle{ P c ; double R ; Circle( P c, double R){ this.c = c; this.R = R; } @Override public String toString(){ return String.format("{%s, %.03f}",c,R);} boolean isInside( P p){ return (R > (p.dist(c) - EPS));} P[] intersectsCircle( Circle that){ double r1 = this.R;  double r2 = that.R;  P m = that.c.sub(this.c);  P[] r1sol = m.solveDotProductConstrainedByNorm(((((r2 * r2) - (r1 * r1)) - m.length2()) / 2),r1);  P[] is = new P[r1sol.length]; for ( int i = 0;(i < r1sol.length);i++) is[i] = this.c.add(r1sol[i]); return is;} static Circle getCircumCircle( P a, P b){ P c = a.add(b).scale(.5); return new Circle(c,c.dist(a));} static Circle getCircumCircle( P a, P b, P c){ P B = b.sub(a);  P C = c.sub(a);  double d = (2 * B.crossproduct(C)); if ( (abs(d) < EPS)) return getCircumCircle(new P(min(a.x,min(b.x,c.x)),min(a.y,min(b.y,c.y))),new P(max(a.x,max(b.x,c.x)),max(a.y,max(b.y,c.y)))); double z1 = B.length2();  double z2 = C.length2();  P cc = new P(((C.y * z1) - (B.y * z2)),((B.x * z2) - (C.x * z1))).scale((1.0 / d)); return new Circle(cc.add(a),cc.length());} } static class Polygon{ P[] p ; Polygon( Collection<P> c){ this.p = c.toArray(new P[c.size()]); } Polygon( P[] p){ this.p = (P[])p.clone(); } double signedArea(){ double area = 0.0; for ( int i = 0;(i < p.length);i++) {area += p[i].det(p[((i + 1) % p.length)]); }return (area / 2.0);} public boolean contains_WN( P q){ int wn = 0;  int n = p.length; for ( int i = 0;(i < n);i++) { P p = this.p[i],pn = this.p[((i + 1) % n)]; if ( (p.y <= q.y)) {if ( (pn.y > q.y)) if ( p.isCCW(pn,q)) ++wn;  } else {if ( (pn.y <= q.y)) if ( !p.isCCW(pn,q)) --wn;  }}return (wn != 0);} @Override public String toString(){ return Arrays.toString(p);} } 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());} long nextLong(){ return Long.parseLong(next());} double nextDouble(){ return Double.parseDouble(next());} } }
1	public class B{ public static void main( String[] args)throws Exception { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));  String[] parts = bf.readLine().trim().split("[ ]+");  int N = Integer.parseInt(parts[0]);  int K = Integer.parseInt(parts[1]);  int[] nums = new int[N];  int idx = 0;  String line = bf.readLine(); for ( int i = 0;(i < line.length());i++) { char c = line.charAt(i); if ( (c == ' ')) idx++; else { int d = (c - '0'); nums[idx] = ((10 * nums[idx]) + d); }} int from = -1,to = -1;  HashMap<Integer,Integer> count = new HashMap<Integer,Integer>(); for ( int i = 0;(i < N);i++) { Integer q = count.get(nums[i]); if ( (q == null)) count.put(nums[i],1); else count.put(nums[i],(q + 1)); if ( (count.size() == K)) {to = i; break;} }if ( (count.size() < K)) {System.out.println("-1 -1"); return ;} for ( from = 0;(from <= to);from++) { Integer q = count.get(nums[from]); if ( (q == 1)) count.remove(nums[from]); else count.put(nums[from],(q - 1)); if ( (count.size() < K)) break; }System.out.println((((from + 1) + " ") + (to + 1))); } }
5	public class stacks{ public static void main( String[] args)throws Exception { FastIO sc = new FastIO(System.in);  PrintWriter pw = new PrintWriter(System.out);  int n = sc.nextInt();  int m = sc.nextInt();  long remove = 0;  int[] heights = new int[(n + 1)]; for ( int i = 0;(i < n);i++) {heights[i] = sc.nextInt(); remove += heights[i]; }Arrays.sort(heights); long keep = 0; for ( int i = n;(i > 0);i--) {if ( (heights[(i - 1)] >= heights[i])) {heights[(i - 1)] = (heights[i] - 1); } keep += (heights[i] - heights[(i - 1)]); }pw.println((remove - keep)); pw.close(); } static class FastIO{ InputStream dis ; byte[] buffer = new byte[(1 << 17)]; int pointer = 0; public FastIO( String fileName)throws Exception{ dis = new FileInputStream(fileName); } public FastIO( InputStream is)throws Exception{ dis = is; } int nextInt()throws Exception { int ret = 0;  byte b ; do {b = nextByte(); }while((b <= ' ')); boolean negative = false; if ( (b == '-')) {negative = true; b = nextByte(); } while(((b >= '0') && (b <= '9'))){ret = (((10 * ret) + b) - '0'); b = nextByte(); }return (negative?-ret:ret);} byte nextByte()throws Exception { if ( (pointer == buffer.length)) {dis.read(buffer,0,buffer.length); pointer = 0; } return buffer[pointer++];} } }
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());} }
6	public class Main{ public static void main( String[] args){ new Main().run(); } boolean[][] graph ; public void run(){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int m = sc.nextInt(); graph = new boolean[n][n]; for ( int i = 0;(i < m);i++) { int a = (sc.nextInt() - 1);  int b = (sc.nextInt() - 1); graph[a][b] = true; graph[b][a] = true; } long res = 0; for ( int i = 3;(i <= n);i++) {res += solve(i); }System.out.println(res); } long solve( int n){ long[][] dp = new long[(1 << n)][n]; dp[(1 << (n - 1))][(n - 1)] = 1; for ( int i = 0;(i < (1 << n));++i) {for ( int l = 0;(l < n);++l) if ( (dp[i][l] > 0)) {for ( int x = 0;(x < (n - 1));++x) if ( (graph[l][x] && (((i >> x) & 1) == 0))) {dp[(i | (1 << x))][x] += dp[i][l]; } } } long res = 0; for ( int i = 0;(i < (1 << n));++i) if ( (Integer.bitCount(i) >= 3)) {for ( int l = 0;(l < n);++l) {if ( graph[l][(n - 1)]) res += dp[i][l]; }} return (res / 2);} }
6	public class Main{ static int[][][] dp ; public static void main( String[] args){ Scanner r = new Scanner(System.in);  int n = r.nextInt();  int m = r.nextInt(); if ( (n > m)) { int t = n; n = m; m = t; } dp = new int[(m + 1)][(1 << 7)][(1 << 7)]; for ( int[][] i :dp) for ( int[] j :i) Arrays.fill(j,-1); int min = go(m,0,((1 << n) - 1),n,m); System.out.println(((n * m) - min)); } static private int go( int rem, int prev, int need, int n, int m){ if ( (rem == 0)) return ((prev == 0)?0:(1 << 20)); if ( (dp[rem][prev][need] != -1)) return dp[rem][prev][need]; int min = (1 << 20); for ( int now = 0;(now < (1 << n));now++) {if ( ((~now & prev) != 0)) continue; int after = (((need & ~now) & (now << 1)) & (now >> 1));  int next = (~now & ((1 << n) - 1));  int current = (Integer.bitCount(now) + go((rem - 1),after,next,n,m)); min = Math.min(min,current); }return dp[rem][prev][need] = min;} }
2	public class Pipeline{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong(); if ( (n == 1)) {System.out.println(0); return ;} if ( (k >= n)) {System.out.println(1); return ;} long total = ((((k + 2) * (k - 1)) / 2) - (k - 2)); if ( (total < n)) {System.out.println(-1); return ;} int i = 2,j = (int)k; while((i <= j)){ int m = ((i + j) / 2); total = ((((k + m) * ((k - m) + 1)) / 2) - (k - m)); if ( (total == n)) {System.out.println(((k - m) + 1)); return ;} if ( (total < n)) j = (m - 1); else i = (m + 1); }System.out.println(((k - i) + 2)); } }
5	public class Contest169ProblemA implements Runnable{ void solve()throws NumberFormatException,IOException { int n = nextInt(),a = nextInt(),b = nextInt();  ArrayList<Integer> tasks = new ArrayList<Integer>(); for ( int i = 0;(i < n);++i) {tasks.add(nextInt()); }Collections.sort(tasks); int l1 = tasks.get((b - 1));  int l2 = tasks.get(b); if ( ((l2 - l1) >= 0)) {out.print((l2 - l1)); } else {out.print((l2 - l1)); }} StringTokenizer st ; BufferedReader in ; PrintWriter out ; public static void main( String[] args){ new Thread(new Contest169ProblemA()).start(); } 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());} }
0	public class MAIN{ public static void main( String[] args){ Scanner sn = new Scanner(System.in);  int n ,n1 ,n2 ,n3 ;  int arr[] = {0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170}; n = sn.nextInt(); if ( (n == 2)) {n1 = n2 = 1; n3 = 0; } else if ( (n == 1)) {n3 = n2 = 0; n1 = 1; } else if ( (n == 0)) {n1 = n2 = n3 = 0; } else if ( (n == 3)) {n1 = n2 = n3 = 1; } else { int index = bsearch(arr,0,(arr.length - 1),n); n1 = arr[(index - 1)]; n2 = arr[(index - 3)]; n3 = arr[(index - 4)]; }System.out.println(((((n3 + " ") + n2) + " ") + n1)); } static int bsearch( int[] arr, int l, int h, int n){ if ( (l > h)) return -1; int mid = ((l + h) / 2); if ( (n == arr[mid])) return mid; else if ( (n > arr[mid])) return bsearch(arr,(mid + 1),h,n); else return bsearch(arr,l,(mid - 1),n);} }
3	public class A extends PrintWriter{ void run(){ int n = nextInt();  int m = 101;  boolean[] c = new boolean[m]; for ( int i = 0;(i < n);i++) { int v = nextInt(); c[v] = true; } int ans = 0; for ( int v = 1;(v < m);v++) {if ( c[v]) {++ans; for ( int u = v;(u < m);u += v) {c[u] = false; }} }println(ans); } String next(){ while(!tokenizer.hasMoreTokens())tokenizer = new StringTokenizer(nextLine()); return tokenizer.nextToken();} boolean hasNext(){ while(!tokenizer.hasMoreTokens()){ String line = nextLine(); if ( (line == null)) {return false;} tokenizer = new StringTokenizer(line); }return true;} int nextInt(){ return Integer.parseInt(next());} String nextLine(){ try{return reader.readLine(); }catch (IOException err){ return null;} } public A( OutputStream outputStream){ super(outputStream); } static BufferedReader reader ; static StringTokenizer tokenizer = new StringTokenizer(""); static Random rnd = new Random(); static boolean OJ ; public static void main( String[] args)throws IOException { OJ = (System.getProperty("ONLINE_JUDGE") != null); A solution = new A(System.out); if ( OJ) {reader = new BufferedReader(new InputStreamReader(System.in)); solution.run(); } else {reader = new BufferedReader(new FileReader(new File((A.class.getName() + ".txt")))); long timeout = System.currentTimeMillis(); while(solution.hasNext()){solution.run(); solution.println(); solution.println("----------------------------------"); }solution.println(("time: " + (System.currentTimeMillis() - timeout))); }solution.close(); reader.close(); } }
5	public class TaskA{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out); new TaskA().solve(in,out); in.close(); out.close(); } private void solve( Scanner in, PrintWriter out){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int answer = 0;  int counter = k;  int[] a = new int[n]; for ( int i = 0;(i < n);++i) a[i] = in.nextInt(); Arrays.sort(a); int[] b = Arrays.copyOf(a,a.length); for ( int i = 0;(i < n);++i) a[i] = b[((n - i) - 1)]; for ( int i = 0;(i < n);++i) {if ( (counter < m)) {counter += (a[i] - 1); ++answer; } else break;}if ( (counter < m)) out.println("-1"); else out.println(answer); } }
1	public class Solution extends Thread{ static final int MAXNUM = (1 << 20); String next()throws IOException { while(!st.hasMoreTokens())st = new StringTokenizer(in.readLine()); return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} BufferedReader in ; StringTokenizer st ; public static void main( String[] args){ Locale.setDefault(Locale.US); new Thread(new Solution()).start(); } }
4	public class C{ public static void main( String... args)throws Exception { Foster sc = new Foster();  PrintWriter p = new PrintWriter(out);  int t = sc.nextInt(); while((t-- != 0)){ int n = sc.nextInt();  int a[] = sc.intArray(n);  ArrayList<ArrayList<Integer>> arr = new ArrayList<>(); for ( int i = 0;(i < n);i++) { ArrayList<Integer> temp = new ArrayList<>(); if ( ((i - 1) < 0)) {temp.add(1); } else { ArrayList<Integer> inner = arr.get((i - 1));  int last = inner.get((inner.size() - 1));  ArrayDeque<Integer> q = new ArrayDeque<>(); for ( int j :inner) {q.addLast(j); }if ( ((last + 1) == a[i])) {q.pollLast(); q.addLast(a[i]); } else if ( (a[i] == 1)) {q.addLast(a[i]); } else {while((!q.isEmpty() && ((a[i] - q.peekLast()) != 1))){q.pollLast(); }if ( q.isEmpty()) q.addLast(a[i]); else {q.pollLast(); q.addLast(a[i]); }}while(!q.isEmpty()){temp.add(q.pollFirst()); }}arr.add(temp); }for ( int i = 0;(i < arr.size());i++) {p.print(arr.get(i).get(0)); for ( int j = 1;(j < arr.get(i).size());j++) {p.print(("." + arr.get(i).get(j))); }p.println(); }}p.close(); } static long[] sort( long[] a){ ArrayList<Long> arr = new ArrayList<>(); for ( long i :a) {arr.add(i); }Collections.sort(arr); for ( int i = 0;(i < arr.size());i++) {a[i] = arr.get(i); }return a;} static int[] sort( int[] a){ ArrayList<Integer> arr = new ArrayList<>(); for ( int i :a) {arr.add(i); }Collections.sort(arr); for ( int i = 0;(i < arr.size());i++) {a[i] = arr.get(i); }return a;} static class Foster{ BufferedReader br = new BufferedReader(new InputStreamReader(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());} int[] intArray( int n){ int arr[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = nextInt(); }return arr;} } }
6	public class cfe{ static DataReader input ; static int LARGE_INT = 1000000007; static final int[] BM = {1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,(1 << 17),(1 << 18),(1 << 19),(1 << 20)}; public static void main( String[] args)throws IOException { input = new DataReader(); PrintWriter out = new PrintWriter(System.out);  int N = nextInt(),M = nextInt(),P = (1 << M);  String x = nextStr();  int c1 = (x.charAt(0) - 'a');  int[][] pair_count = new int[M][M]; for ( int i = 1;(i < N);i++) { int c2 = (x.charAt(i) - 'a'); if ( (c1 < c2)) pair_count[c1][c2]++; else if ( (c1 > c2)) pair_count[c2][c1]++; c1 = c2; } int[] group_count = new int[P]; for ( int mask = 1;(mask < P);mask++) { int j ; for ( j = 0;(j < M);j++) {if ( ((mask & BM[j]) > 0)) break; } int nmask = (mask ^ BM[j]);  int val = group_count[nmask]; for ( int i = 0;(i < j);i++) {if ( ((mask & BM[i]) > 0)) val -= pair_count[i][j]; else val += pair_count[i][j]; }for ( int i = (j + 1);(i < M);i++) {if ( ((mask & BM[i]) > 0)) val -= pair_count[j][i]; else val += pair_count[j][i]; }group_count[mask] = val; } int[][] dp = new int[(M + 1)][P]; for ( int mask = 1;(mask < P);mask++) {dp[0][mask] = 0; int k = Integer.bitCount(mask);  int val = LARGE_INT; for ( int j = 0;(j < M);j++) {if ( ((mask & BM[j]) > 0)) { int nmask = (mask ^ BM[j]); val = Math.min(val,(dp[(k - 1)][nmask] + group_count[nmask])); } }dp[k][mask] = val; }out.println(dp[M][(P - 1)]); out.flush(); out.close(); } static int nextInt()throws IOException { return Integer.parseInt(input.next());} static String nextStr()throws IOException { return input.next();} static class DataReader{ BufferedReader br ; StringTokenizer st ; public DataReader()throws IOException{ br = new BufferedReader(new InputStreamReader(System.in)); } boolean hasNext()throws IOException { while(((st == null) || !st.hasMoreElements())){ String line = br.readLine(); if ( (line == null)) {return false;} st = new StringTokenizer(line); }return true;} String next()throws IOException { if ( hasNext()) return st.nextToken(); else return null;} } }
5	public class A15{ static StreamTokenizer in ; static PrintWriter out ; static int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} public static void main( String[] args)throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); int n = nextInt(),t = nextInt();  int[] x = new int[n];  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {x[i] = nextInt(); a[i] = nextInt(); } int ans = 0; for ( int i = 0;(i < n);i++) { boolean left = true,right = true; for ( int j = 0;(j < n);j++) if ( ((x[j] < x[i]) && (((a[i] + (2 * t)) + a[j]) >= (2 * Math.abs((x[i] - x[j])))))) left = false; else if ( ((x[j] > x[i]) && (((a[i] + (2 * t)) + a[j]) > (2 * Math.abs((x[i] - x[j])))))) right = false; if ( left) ans++; if ( right) ans++; }out.println(ans); out.flush(); } }
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); } }
4	public class D{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni(),m = ni();  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[] nfrom = new int[m];  int[] nto = new int[m];  int min = 999999999; for ( int i = 0;(i < n);i++) { int p = 0; for ( int j = 0;(j < m);j++) {if ( ((from[j] != i) && (to[j] != i))) {nfrom[p] = from[j]; nto[p] = to[j]; p++; } } int[][] g = packD(n,nfrom,nto,p);  int mat = doBipartiteMatchingHKNoRec(g,n);  int ch = ((p - mat) + ((n - 1) - mat)); ch += (((2 * n) - 1) - (m - p)); min = Math.min(min,ch); }out.println(min); } public static int doBipartiteMatchingHKNoRec( int[][] g, int m){ int n = g.length; if ( (n == 0)) return 0; int[] from = new int[m];  int[] to = new int[n]; Arrays.fill(to,-1); Arrays.fill(from,n); int[] d = new int[(n + 1)];  int mat = 0;  int[] stack = new int[(n + 1)];  int[] adjind = new int[(n + 1)]; while(true){Arrays.fill(d,-1); int[] q = new int[n];  int r = 0; for ( int i = 0;(i < n);i++) {if ( (to[i] == -1)) {d[i] = 0; q[r++] = i; } }for ( int p = 0;(p < r);p++) { int cur = q[p]; for ( int adj :g[cur]) { int nex = from[adj]; if ( (d[nex] == -1)) {if ( (nex != n)) q[r++] = nex; d[nex] = (d[cur] + 1); } }}if ( (d[n] == -1)) break; for ( int i = 0;(i < n);i++) {if ( (to[i] == -1)) { int sp = 1; stack[0] = i; adjind[0] = 0; boolean prevB = false; outer:while((sp >= 1)){ int cur = stack[(sp - 1)]; if ( (cur == n)) {prevB = true; sp--; continue;} for ( ;(adjind[(sp - 1)] < (2 * g[cur].length));) { int adj = g[cur][(adjind[(sp - 1)] / 2)]; if ( ((adjind[(sp - 1)] % 2) == 0)) { int nex = from[adj]; if ( (d[nex] == (d[cur] + 1))) {stack[sp] = nex; adjind[sp] = 0; adjind[(sp - 1)]++; sp++; continue outer;} else {adjind[(sp - 1)] += 2; }} else {if ( prevB) {to[cur] = adj; from[adj] = cur; prevB = true; sp--; continue outer;} adjind[(sp - 1)]++; }}d[cur] = -1; prevB = false; sp--; }if ( prevB) mat++; } }}return mat;} public static int[][] packD( 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 < n);i++) g[i] = new int[p[i]]; for ( int i = 0;(i < sup);i++) {g[from[i]][--p[from[i]]] = to[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 D().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 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)); } }
1	public class B{ static FastScanner fs ; public static void main( String[] args){ fs = new FastScanner(); int t = fs.nextInt(); while((t-- > 0))solve(); } public static void solve(){ int n = (fs.nextInt() * 2);  int sq = (int)Math.sqrt(n);  int sq2 = (int)Math.sqrt((n / 2)); if ( ((sq * sq) == n)) System.out.println("YES"); else if ( (((sq2 * sq2) == (n / 2.0)) && ((sq2 % 2) == 0))) System.out.println("YES"); else System.out.println("NO"); } static int gcd( int a, int b){ if ( (a == 0)) return b; return gcd((b % a),a);} static final Random random = new Random(); 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());} } }
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 TwentyFive{ public static void main( String[] args){ System.out.println(25); } }
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 N ; public void solve( int testNumber, InputReader in, PrintWriter out){ N = in.nextInt(); int low = 1;  int lowVal = getval(1,out,in);  int high = ((N / 2) + 1);  int highVal = -lowVal; if ( ((Math.abs(lowVal) % 2) == 1)) {out.println("! -1"); out.flush(); } else {while((low < high)){ int mid = ((low + high) / 2);  int a = getval(mid,out,in); if ( (Integer.signum(a) == 0)) {out.println(("! " + mid)); out.flush(); return ;} else {if ( (Integer.signum(a) == Integer.signum(lowVal))) {low = (mid + 1); } else {high = mid; }}}out.println(("! " + low)); out.flush(); }} int getval( int i, PrintWriter out, InputReader in){ out.println(("? " + i)); out.flush(); int a = in.nextInt(); out.println(("? " + (i + (N / 2)))); out.flush(); int b = in.nextInt(); return (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());} } }
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());} }
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(); } } }
5	public class A{ BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; void solve()throws IOException { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); Arrays.sort(a); int sum = 0; for ( int i = 0;(i < n);i++) sum += a[i]; int cur = 0; for ( int i = (n - 1);(i >= 0);i--) {cur += a[i]; if ( (cur > (sum - cur))) {out.println((n - i)); return ;} }} void inp()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 A().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());} }
5	public class Template{ 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();} int nextInt(){ return Integer.parseInt(next());} long nextLong(){ return Long.parseLong(next());} public void run()throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); Long start = System.currentTimeMillis();  int n = nextInt();  long k = nextLong();  long[] a = new long[n];  TreeMap<Long,Integer> st = new TreeMap<Long,Integer>(); for ( int i = 0;(i < n);i++) {a[i] = nextLong(); st.put(a[i],1); }Arrays.sort(a); for ( int i = 0;(i < n);i++) {if ( ((a[i] % k) == 0)) { long x = (a[i] / k); if ( st.containsKey(x)) { int y = st.get(x); st.remove(a[i]); st.put(a[i],(y + 1)); } } } int ans = 0; for ( int i = 0;(i < n);i++) {ans += ((st.get(a[((n - i) - 1)]) + 1) / 2); if ( ((a[((n - i) - 1)] % k) == 0)) { long x = (a[((n - i) - 1)] / k); if ( st.containsKey(x)) {st.remove(x); st.put(x,0); } } }out.println(ans); Long end = System.currentTimeMillis(); out.close(); } public static void main( String[] args)throws Exception { new Template().run(); } }
5	public class Test{ static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter writer ; static int nextInt()throws 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)); tokenizer = null; writer = new PrintWriter(System.out); solve(); reader.close(); writer.close(); } static private void solve()throws IOException { int n = nextInt();  int[] mas = new int[n];  int sum = 0; for ( int i = 0;(i < n);i++) {mas[i] = nextInt(); sum += mas[i]; }Arrays.sort(mas); int cs = 0;  int res = 0; for ( int i = (n - 1);(i >= 0);i--) {cs += mas[i]; sum -= mas[i]; res++; if ( (cs > sum)) break; }writer.println(res); } }
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);  TaskG1 solver = new TaskG1(); solver.solve(1,in,out); out.close(); } static class TaskG1{ final int mod = ((int)1e9 + 7); int[][][] dp ; int rec( int mask, int time, int T, int genre, int[] ts, int[] gs){ if ( (time > T)) return 0; if ( (time == T)) return 1; if ( (mask == ((1 << ts.length) - 1))) return 0; int res = dp[genre][time][mask]; if ( (res != -1)) return res; res = 0; for ( int i = 0;(i < ts.length);i++) {if ( (((mask & (1 << i)) == 0) && ((mask == 0) || (gs[i] != genre)))) {res += rec((mask | (1 << i)),(time + ts[i]),T,gs[i],ts,gs); if ( (res >= mod)) res -= mod; } }return dp[genre][time][mask] = res;} public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] ts = new int[n];  int[] gs = new int[n];  int T = in.nextInt(); for ( int i = 0;(i < n);i++) {ts[i] = in.nextInt(); gs[i] = (in.nextInt() - 1); }dp = new int[3][T][(1 << n)]; for ( int[][] aux :dp) {for ( int[] aux2 :aux) Arrays.fill(aux2,-1); } int ans = rec(0,0,T,0,ts,gs); 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);} } }
4	public class Solution{ public static void main( String[] args){ FastScanner sc = new FastScanner();  PrintWriter pw = new PrintWriter(System.out);  int tc = 1; for ( int rep = 0;(rep < tc);rep++) {solve(sc,pw); }pw.close(); } public static void solve( FastScanner sc, PrintWriter pw){ int n = sc.ni();  int m = sc.ni();  int k = sc.ni();  int[][] arr = sc.to2di(n,(m - 1));  int[][] arr2 = sc.to2di((n - 1),m); if ( ((k % 2) == 1)) { String s = ""; for ( int j = 0;(j < m);j++) {s += "-1"; if ( (j != (m - 1))) {s += " "; } }for ( int i = 0;(i < n);i++) {pw.println(s); }return ;} Integer[][][] dp = new Integer[n][m][(k + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {fill(dp,i,j,k,n,m,arr,arr2); }}for ( int i = 0;(i < n);i++) { String s = ""; for ( int j = 0;(j < m);j++) {s += dp[i][j][k]; if ( (j != (m - 1))) {s += " "; } }pw.println(s); }} public static int fill( Integer[][][] dp, int x, int y, int k, int n, int m, int[][] arr, int[][] arr2){ if ( (dp[x][y][k] != null)) {return dp[x][y][k];} if ( (k == 0)) {dp[x][y][k] = 0; return 0;} int min = Integer.MAX_VALUE; if ( (x > 0)) { int curVal = ((2 * arr2[(x - 1)][y]) + fill(dp,(x - 1),y,(k - 2),n,m,arr,arr2)); min = Math.min(min,curVal); } if ( (y > 0)) { int curVal = ((2 * arr[x][(y - 1)]) + fill(dp,x,(y - 1),(k - 2),n,m,arr,arr2)); min = Math.min(min,curVal); } if ( (x < (n - 1))) { int curVal = ((2 * arr2[x][y]) + fill(dp,(x + 1),y,(k - 2),n,m,arr,arr2)); min = Math.min(min,curVal); } if ( (y < (m - 1))) { int curVal = ((2 * arr[x][y]) + fill(dp,x,(y + 1),(k - 2),n,m,arr,arr2)); min = Math.min(min,curVal); } dp[x][y][k] = min; return min;} } class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner(){ 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[][] to2di( int m, int n){ int[][] ans = new int[m][n]; for ( int i = 0;(i < m);i++) { String[] r = nextLine().split("[ ]"); for ( int j = 0;(j < n);j++) {ans[i][j] = Integer.parseInt(r[j]); }}return ans;} long nl(){ return Long.parseLong(next());} String nextLine(){ String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); System.out.println((int)(n + (n / 2))); } }
6	public class B{ static int first( int n){ int res = 0; while(((n > 0) && ((n & 1) == 0))){n >>= 1; res++; }return res;} public static void main( String[] args)throws Exception { Scanner bf = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int n = bf.nextInt(),m = bf.nextInt();  ArrayList<Integer>[] adjList = new ArrayList[n]; for ( int i = 0;(i < adjList.length);i++) {adjList[i] = new ArrayList<Integer>(); }for ( int i = 0;(i < m);i++) { int u = (bf.nextInt() - 1),v = (bf.nextInt() - 1); adjList[u].add(v); adjList[v].add(u); } long[][] memo = new long[(1 << n)][n]; for ( int i = 0;(i < n);i++) {memo[(1 << i)][i] = 1; } long ans = 0; for ( int i = 1;(i < (1 << n));i++) {if ( (Integer.bitCount(i) == 1)) continue; for ( int j = 0;(j < n);j++) {if ( (((i & (1 << j)) == 0) || (j == first(i)))) continue; for ( int v :adjList[j]) memo[i][j] += memo[(i ^ (1 << j))][v]; }}for ( int i = 1;(i < (1 << n));i++) {if ( (Integer.bitCount(i) < 3)) continue; int t = first(i); for ( int j = 0;(j < n);j++) {if ( adjList[j].contains(t)) ans += memo[i][j]; }}out.println((ans / 2)); out.flush(); out.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( FileReader fileReader){ br = new BufferedReader(fileReader); } 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 AA{ static class O implements Comparable<O>{ int problems ; int penalty ; public O( int p, int pp){ problems = p; penalty = pp; } } public static void main( String[] args)throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in));  String s = r.readLine();  String[] sp = s.split("[ ]+");  int n = new Integer(sp[0]),k = (new Integer(sp[1]) - 1);  O[] arr = new O[n]; for ( int i = 0;(i < arr.length);i++) {s = r.readLine(); sp = s.split("[ ]+"); arr[i] = new O(new Integer(sp[0]),new Integer(sp[1])); }Arrays.sort(arr); int res = 1;  int i = (k + 1); while((((i < arr.length) && (arr[i].problems == arr[k].problems)) && (arr[i].penalty == arr[k].penalty))){i++; res++; }i = (k - 1); while((((i >= 0) && (arr[i].problems == arr[k].problems)) && (arr[i].penalty == arr[k].penalty))){i--; res++; }System.out.println(res); } }
1	public class Main{ static final double eps = 1e-8; public static void main( String[] args)throws IOException { try{ int n = nextInt();  int k = nextInt();  int[] a = new int[n];  int[] d = new int[n];  int[] dr = new int[n];  boolean used[] = new boolean[100001]; a[0] = nextInt(); used[a[0]] = true; d[0] = 1; for ( int i = 1;(i < n);i++) {a[i] = nextInt(); if ( !used[a[i]]) {used[a[i]] = true; d[i] = (d[(i - 1)] + 1); } else {d[i] = d[(i - 1)]; }}Arrays.fill(used,false); int r = Arrays.binarySearch(d,k); if ( (r < 0)) {pw.println("-1 -1"); return ;} while(((r > 0) && (d[r] == d[(r - 1)])))r--; used[a[r]] = true; dr[r] = 1; for ( int i = (r - 1);(i >= 0);i--) {if ( !used[a[i]]) {used[a[i]] = true; dr[i] = (dr[(i + 1)] + 1); } else {dr[i] = dr[(i + 1)]; }} int l = 0; while((((l < (n - 1)) && (dr[l] == dr[(l + 1)])) && ((r - l) >= k)))l++; pw.println((((l + 1) + " ") + (r + 1))); }finally{pw.close(); }} static Scanner sc = new Scanner(System.in); static PrintWriter pw = new PrintWriter(System.out); static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st ; static int nextInt()throws IOException { in.nextToken(); return (int)in.nval;} }
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);} } }
1	public class TaskB{ public static int strIndex ; public static void main( String[] args)throws IOException { Scanner scanner = new Scanner(System.in);  int n = scanner.nextInt();  char[] s = scanner.next().toCharArray();  int[][] r = new int[n][54];  Set<Character> chars = new HashSet<>(); for ( int i = 0;(i < n);++i) chars.add(s[i]); List<Character> all = new ArrayList<>(); for ( Character c :chars) all.add(c); for ( int i = (n - 1);(i >= 0);--i) {for ( int j = 0;(j < 54);++j) {if ( (i == (n - 1))) {r[i][j] = -1; } else {r[i][j] = r[(i + 1)][j]; }}r[i][getCode(s[i])] = i; } int res = n; for ( int i = 0;(i < n);++i) { int mx = 1;  boolean fl = false; for ( Character c :all) {if ( (r[i][getCode(c)] == -1)) {fl = true; break;} mx = Math.max(mx,((r[i][getCode(c)] - i) + 1)); }if ( fl) {System.out.println(res); return ;} res = Math.min(res,mx); }System.out.println(res); scanner.close(); } public static int getCode( char a){ if ( Character.isUpperCase(a)) return (a - 'A'); return ((a - 'a') + 26);} }
2	public class SolutionB{ 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();} long nextLong()throws IOException { return Long.parseLong(next());} public static void main( String[] args)throws IOException { new SolutionB().run(); } void run()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } void solve()throws IOException { long n = nextLong();  long k = nextLong();  long m = num1(k); if ( (m < n)) {out.println(-1); return ;} if ( (m == n)) {out.println((k - 1)); return ;} long ans = binS(n,k); out.println((k - ans)); } long num1( long k){ long r = (((k * (k + 1)) / 2) - 1); r = (r - (k - 2)); return r;} long num2( long k){ return (num1(k) - 1);} long binS( long n, long k){ long start ,end ,mid ; start = 2; end = k; long ret = -1; while((start <= end)){mid = ((start + end) / 2); if ( ((num1(k) - num2(mid)) == n)) {return mid;} else if ( ((num1(k) - num2(mid)) < n)) {end = (mid - 1); } else {ret = mid; start = (mid + 1); }}return ret;} }
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))); }}}} }
4	public class Main implements Runnable{ public void _main()throws IOException { int height = nextInt();  int width = nextInt();  int k = nextInt();  int[] r = new int[k];  int[] c = new int[k]; for ( int i = 0;(i < k);i++) {r[i] = (nextInt() - 1); c[i] = (nextInt() - 1); } int res = 0,R = r[0],C = c[0]; for ( int i = 0;(i < height);i++) for ( int j = 0;(j < width);j++) { int cur = Integer.MAX_VALUE; for ( int z = 0;(z < k);z++) cur = Math.min(cur,(Math.abs((i - r[z])) + Math.abs((j - c[z])))); if ( (res < cur)) {res = cur; R = i; C = j; } }out.print((((R + 1) + " ") + (C + 1))); } private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private String next()throws IOException { while(((st == null) || !st.hasMoreTokens()))st = new StringTokenizer(in.readLine()); return st.nextToken();} private int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args){ new Thread(new Main()).start(); } }
2	public class OlyaAndMagicalSquare{ void solve(){ long[] dp = new long[32]; dp[0] = 0; for ( int i = 1;(i < 32);i++) {dp[i] = ((4 * dp[(i - 1)]) + 1); } int T = in.nextInt(); L:while((T-- > 0)){ int n = in.nextInt();  long k = in.nextLong(); if ( (n > 31)) {out.println(("YES " + (n - 1))); continue;} long tot = 0; for ( int a = (n - 1);(a >= 0);a--) {k -= ((1L << (n - a)) - 1); if ( (k < 0)) break; if ( (k == 0)) {out.println(("YES " + a)); continue L;} long limit = ((1L << ((n + 1) - a)) - 3); if ( ((k <= tot) || ((dp[a] > 0) && (((((k - tot) + dp[a]) - 1) / dp[a]) <= limit)))) {out.println(("YES " + a)); continue L;} tot += (dp[a] * limit); }out.println("NO"); }} public static void main( String[] args){ in = new FastScanner(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(System.out); new OlyaAndMagicalSquare().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());} public long nextLong(){ return Long.parseLong(nextToken());} } }
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;} }
2	public class B{ public static void main( String[] argv){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long k = in.nextLong();  long max = (((k * (k - 1)) / 2L) + 1L);  long ans = -1; if ( (n == 1)) {System.out.println(0); return ;} if ( (max < n)) {ans = -1; } else if ( (max == n)) {ans = (k - 1); } else {if ( (k >= n)) {ans = 1; } else { long low = 1;  long high = (k - 1); while((high > (low + 1))){ long mid = ((low + high) / 2);  long sum = ((((mid + (k - 1)) * (k - mid)) / 2) + 1); if ( (sum >= n)) {low = mid; } else {high = mid; }}ans = (k - low); }}System.out.println(ans); return ;} }
2	public class Main{ public static void main( String[] args)throws IOException { FastScanner in = new FastScanner(System.in);  PrintWriter out = new PrintWriter(System.out); new Main().run(in,out); out.close(); } public static long mod = 17352642619633L; void run( FastScanner in, PrintWriter out){ long K = in.nextLong();  long lo = 1;  long hi = ((long)1e12 + 1); while((lo < hi)){ long m = ((lo + hi) >> 1);  long d = numDigitsLte(m); if ( (d <= K)) {lo = (m + 1); } else {hi = m; }} long numDigits = numDigitsLte(lo); if ( (numDigitsLte((lo - 1)) == K)) {out.println(((((lo - 1) % 10) + 10) % 10)); } else { int offset = (int)(numDigits - K);  List<Long> digits = new ArrayList<>(); while((lo > 0)){digits.add((lo % 10)); lo /= 10; }out.println(digits.get(offset)); }} static long[] dig = new long[15]; {for ( int i = 1;(i < dig.length);i++) {dig[i] = ((9 * (long)Math.pow(10,(i - 1))) * i); }for ( int i = 1;(i < dig.length);i++) {dig[i] += dig[(i - 1)]; }} long numDigitsLte( long m){ if ( (m <= 9)) return m; int numDigits = 0;  long M = m; while((M > 0)){numDigits++; M /= 10; } long ret = dig[(numDigits - 1)]; ret += (((m - (long)Math.pow(10,(numDigits - 1))) + 1) * numDigits); return ret;} static class FastScanner{ BufferedReader br ; StringTokenizer st ; public FastScanner( InputStream in){ br = new BufferedReader(new InputStreamReader(in)); st = null; } 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 acm{ public static BigInteger n ; public static BigInteger TWO = new BigInteger("2"); public static BigInteger solve( BigInteger x, BigInteger y, BigInteger c){ BigInteger res = c.add(BigInteger.ONE).multiply(c.add(BigInteger.ONE)); res = res.add(c.multiply(c)); BigInteger k ; k = c.subtract(x.subtract(BigInteger.ONE)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.subtract(k.multiply(k)); k = c.subtract(y.subtract(BigInteger.ONE)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.subtract(k.multiply(k)); k = c.subtract(n.subtract(x)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.subtract(k.multiply(k)); k = c.subtract(n.subtract(y)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.subtract(k.multiply(k)); k = c.subtract(x.add(y).subtract(BigInteger.ONE)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.add(k.multiply(k.add(BigInteger.ONE)).divide(TWO)); k = c.subtract(x.add(n).subtract(y)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.add(k.multiply(k.add(BigInteger.ONE)).divide(TWO)); k = c.subtract(y.add(n).subtract(x)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.add(k.multiply(k.add(BigInteger.ONE)).divide(TWO)); k = c.subtract(n.subtract(x).add(n.subtract(y)).add(BigInteger.ONE)); if ( (k.compareTo(BigInteger.ZERO) > 0)) res = res.add(k.multiply(k.add(BigInteger.ONE)).divide(TWO)); return res;} public static void main( String[] args){ TWO = new BigInteger("2"); Scanner in = new Scanner(System.in); n = new BigInteger(in.next()); BigInteger x = new BigInteger(in.next());  BigInteger y = new BigInteger(in.next());  BigInteger c = new BigInteger(in.next());  BigInteger left = new BigInteger("0");  BigInteger right = new BigInteger("1000000000000"); while((left.compareTo(right) < 0)){ BigInteger val = left.add(right).divide(TWO); if ( (solve(x,y,val).compareTo(c) >= 0)) right = val; else left = val.add(BigInteger.ONE); }System.out.println(left); } }
1	public class Codeshefcode{ static final long r = 1000000007; static FasterScanner ip = new FasterScanner(); static PrintWriter op = new PrintWriter(System.out); public static void main( String[] args)throws IOException { int n = ip.i();  TreeMap<Character,Integer> map = new TreeMap<Character,Integer>();  TreeSet<Character> set = new TreeSet<Character>();  char c[] = ip.S().toCharArray(); for ( char t :c) set.add(t); int size = set.size(); for ( int i = 0;(i < size);i++) map.put(set.pollFirst(),i); int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = map.get(c[i]); int erl[][] = new int[size][n]; for ( int i = 0;(i < size);i++) for ( int j = (n - 1);(j >= 0);j--) erl[i][j] = ((a[j] == i)?j:((j == (n - 1))?-1:erl[i][(j + 1)])); long min = Long.MAX_VALUE; for ( int i = 0;(i < n);i++) { long maxt = Long.MIN_VALUE; for ( int j = 0;(j < size);j++) if ( (erl[j][i] != -1)) maxt = Long.max(maxt,((erl[j][i] - i) + 1)); else {maxt = Long.MAX_VALUE; break;}min = Long.min(min,maxt); }op.print(min); Finish(); } static void Finish(){ op.flush(); op.close(); } } class FasterScanner{ private InputStream mIs ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; public FasterScanner(){ this(System.in); } public FasterScanner( 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 S(){ 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 i(){ 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));} }
5	public class Test{ public static void main( String[] args)throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));  String[] line = reader.readLine().split(" ");  int w = Integer.valueOf(line[0]);  int h = Integer.valueOf(line[1]);  int n = Integer.valueOf(line[2]);  Request[] requests = new Request[n]; for ( int i = 0;(i < n);i++) {line = reader.readLine().split(" "); requests[i] = new Request(line[0],Integer.valueOf(line[1])); }for ( long e :solve(h,w,requests)) System.out.println(e); } static private long[] solve( int h, int w, Request[] requests){ TreeSet<Integer> hTree = new TreeSet<>();  TreeSet<Integer> wTree = new TreeSet<>();  Queue<CoordinateWithSize> hHeap = new PriorityQueue<>();  Queue<CoordinateWithSize> wHeap = new PriorityQueue<>(); hTree.add(0); hTree.add(h); wTree.add(0); wTree.add(w); hHeap.add(new CoordinateWithSize(0,h)); wHeap.add(new CoordinateWithSize(0,w)); long[] res = new long[requests.length]; for ( int i = 0;(i < requests.length);i++) { Request request = requests[i]; switch(request.type){ case "H":{if ( !hTree.contains(request.coordinate)) { int higher = hTree.higher(request.coordinate);  int lower = hTree.lower(request.coordinate); hHeap.add(new CoordinateWithSize(lower,(request.coordinate - lower))); hHeap.add(new CoordinateWithSize(request.coordinate,(higher - request.coordinate))); hTree.add(request.coordinate); } break;} case "V":{if ( !wTree.contains(request.coordinate)) { int higher = wTree.higher(request.coordinate);  int lower = wTree.lower(request.coordinate); wHeap.add(new CoordinateWithSize(lower,(request.coordinate - lower))); wHeap.add(new CoordinateWithSize(request.coordinate,(higher - request.coordinate))); wTree.add(request.coordinate); } break;} default :throw (new IllegalStateException((("Unknown type [type=" + request.type) + "]"))); } while(true){ CoordinateWithSize c = hHeap.peek(); if ( ((hTree.higher(c.coordinate) - c.coordinate) == c.size)) break; hHeap.remove(); }while(true){ CoordinateWithSize c = wHeap.peek(); if ( ((wTree.higher(c.coordinate) - c.coordinate) == c.size)) break; wHeap.remove(); }res[i] = ((1L * hHeap.peek().size) * wHeap.peek().size); }return res;} static private class CoordinateWithSize implements Comparable<CoordinateWithSize>{ private final int coordinate ; private final int size ; public CoordinateWithSize( int coordinate, int size){ this.coordinate = coordinate; this.size = size; } } static private class Request{ private final String type ; private final int coordinate ; public Request( String type, int coordinate){ this.type = type; this.coordinate = coordinate; } } }
0	public class A72{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt(); System.out.println(((n * 3) / 2)); } }
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);} }
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);} }
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(); } }
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(); } static class TaskB{ ArrayList<PointInt[]> al ; TaskB.Interactor interactor ; public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt(); interactor = new TaskB.IOInteractor(new Scanner(in.getStream()),out.getWriter()); Assert.assertTrue((interactor.query(1,1,n,n) == 2)); int lx = 1,rx = n,ly = 1,ry = n; for ( int it = 0;(it < 20);++it) { int tx = ((lx + rx) / 2); if ( (interactor.query(1,1,tx,n) >= 1)) rx = tx; else lx = tx; int ty = ((ly + ry) / 2); if ( (interactor.query(1,1,n,ty) >= 1)) ry = ty; else ly = ty; }al = new ArrayList<>(); if ( ((interactor.query(1,1,lx,n) == 1) && (interactor.query((lx + 1),1,n,n) == 1))) {dfs(1,1,lx,n); dfs((lx + 1),1,n,n); } else if ( ((interactor.query(1,1,rx,n) == 1) && (interactor.query((rx + 1),1,n,n) == 1))) {dfs(1,1,rx,n); dfs((rx + 1),1,n,n); } else if ( ((interactor.query(1,1,n,ly) == 1) && (interactor.query(1,(ly + 1),n,n) == 1))) {dfs(1,1,n,ly); dfs(1,(ly + 1),n,n); } else if ( ((interactor.query(1,1,n,ry) == 1) && (interactor.query(1,(ry + 1),n,n) == 1))) {dfs(1,1,n,ry); dfs(1,(ry + 1),n,n); } else {throw (new RuntimeException("WTF"));}Assert.assertTrue((al.size() == 2)); interactor.answer(al.get(0)[0].x,al.get(0)[0].y,al.get(0)[1].x,al.get(0)[1].y,al.get(1)[0].x,al.get(1)[0].y,al.get(1)[1].x,al.get(1)[1].y); } private void dfs( int x1, int y1, int x2, int y2){ int t ; t = x1; for ( int i = 0;(i < 20);++i) { int x = ((t + x2) / 2); if ( (interactor.query(x1,y1,x,y2) == 1)) x2 = x; else t = x; }if ( (interactor.query(x1,y1,t,y2) == 1)) x2 = t; t = x2; for ( int i = 0;(i < 20);++i) { int x = ((t + x1) / 2); if ( (interactor.query(x,y1,x2,y2) == 1)) x1 = x; else t = x; }if ( (interactor.query(t,y1,x2,y2) == 1)) x1 = t; t = y1; for ( int i = 0;(i < 20);++i) { int y = ((t + y2) / 2); if ( (interactor.query(x1,y1,x2,y) == 1)) y2 = y; else t = y; }if ( (interactor.query(x1,y1,x2,t) == 1)) y2 = t; t = y2; for ( int i = 0;(i < 20);++i) { int y = ((t + y1) / 2); if ( (interactor.query(x1,y,x2,y2) == 1)) y1 = y; else t = y; }if ( (interactor.query(x1,t,x2,y2) == 1)) y1 = t; al.add(new PointInt[]{new PointInt(x1,y1),new PointInt(x2,y2)}); } interface Interactor{ int query( int x1, int y1, int x2, int y2); void answer( int x11, int y11, int x12, int y12, int x21, int y21, int x22, int y22); } } 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;} public InputStream getStream(){ return stream;} } static class PointInt{ public int x ; public int y ; public PointInt( int x, int y){ this.x = x; this.y = y; } public PointInt(){ x = 0; y = 0; } } 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 PrintWriter getWriter(){ return writer;} public void close(){ 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(); } }
5	public class Solution{ void solve()throws Exception { int n = nextInt();  int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); int[] b = a.clone(); mySort(b); int cnt = 0; for ( int i = 0;(i < n);i++) if ( (a[i] != b[i])) cnt++; if ( (cnt <= 2)) System.out.println("YES"); else System.out.println("NO"); } private void mySort( int[] a){ if ( (a.length <= 1)) return ; int n = a.length;  int[] left = new int[(n / 2)];  int[] right = new int[(n - (n / 2))]; for ( int i = 0;(i < n);i++) if ( (i < left.length)) left[i] = a[i]; else right[(i - left.length)] = a[i]; mySort(left); mySort(right); int i = 0;  int j = 0; while(((i < left.length) || (j < right.length))){if ( (i == left.length)) a[(i + j)] = right[j++]; else if ( (j == right.length)) a[(i + j)] = left[i++]; else if ( (left[i] < right[j])) a[(i + j)] = left[i++]; else a[(i + j)] = right[j++]; }} BufferedReader reader ; PrintWriter writer ; StringTokenizer stk ; void run()throws Exception { reader = new BufferedReader(new InputStreamReader(System.in)); stk = null; solve(); reader.close(); } int nextInt()throws Exception { return Integer.parseInt(nextToken());} String nextLine()throws Exception { return reader.readLine();} String nextToken()throws Exception { if ( ((stk == null) || !stk.hasMoreTokens())) {stk = new StringTokenizer(nextLine()); return nextToken();} return stk.nextToken();} public static void main( String[] args)throws Exception { new Solution().run(); } }
0	public class Ideone{ public static void main( String[] args)throws java.lang.Exception { Scanner sc = new Scanner(System.in);  long l = sc.nextLong();  long r = sc.nextLong(); if ( ((l % 2) == 0)) {if ( (r >= (l + 2))) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else {System.out.println(-1); }} else {if ( (r >= (l + 3))) {System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); } else {System.out.println(-1); }}} }
6	public class C2{ Scanner in ; PrintWriter out ; String INPUT = ""; void solve(){ int n = ni();  int m = ni();  boolean[][] f = new boolean[99][99]; cache = new HashSet<Long>(); out.println(((n * m) - rec(f,n,m,0,0,0))); } Set<Long> cache ; long hash( boolean[][] f, int n, int m, int r, int c, int cur){ long x = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( f[i][j]) x |= (1L << ((i * m) + j)); }}x = ((x * n) + r); x = ((x * m) + c); x = ((x * 41) + cur); return x;} int rec( boolean[][] f, int n, int m, int r, int c, int cur){ if ( (r == n)) return cur; if ( (c >= m)) return rec(f,n,m,(r + 1),0,cur); long h = hash(f,n,m,r,c,cur); if ( cache.contains(h)) return 99999; cache.add(h); int min = (f[r][c]?rec(f,n,m,r,(c + 1),cur):99999); { boolean[] memo = new boolean[]{f[r][c],f[(r + 1)][c],f[r][(c + 1)]}; f[r][c] = true; f[(r + 1)][c] = true; f[r][(c + 1)] = true; min = Math.min(min,rec(f,n,m,r,(c + 2),(cur + 1))); f[r][c] = memo[0]; f[(r + 1)][c] = memo[1]; f[r][(c + 1)] = memo[2]; }{ boolean[] memo = new boolean[]{f[r][c],f[(r + 1)][c],f[(r + 2)][c],f[(r + 1)][(c + 1)],(((c - 1) >= 0)?f[(r + 1)][(c - 1)]:false)}; f[r][c] = true; f[(r + 1)][c] = true; f[(r + 2)][c] = true; f[(r + 1)][(c + 1)] = true; if ( ((c - 1) >= 0)) f[(r + 1)][(c - 1)] = true; min = Math.min(min,rec(f,n,m,r,(c + 1),(cur + 1))); f[r][c] = memo[0]; f[(r + 1)][c] = memo[1]; f[(r + 2)][c] = memo[2]; f[(r + 1)][(c + 1)] = memo[3]; if ( ((c - 1) >= 0)) f[(r + 1)][(c - 1)] = memo[4]; }{ boolean[] memo = new boolean[]{f[r][c],f[r][(c + 1)],f[r][(c + 2)],f[(r + 1)][(c + 1)]}; f[r][c] = true; f[r][(c + 1)] = true; f[r][(c + 2)] = true; f[(r + 1)][(c + 1)] = true; min = Math.min(min,rec(f,n,m,r,(c + 3),(cur + 1))); f[r][c] = memo[0]; f[r][(c + 1)] = memo[1]; f[r][(c + 2)] = memo[2]; f[(r + 1)][(c + 1)] = memo[3]; }return min;} 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 C2().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)); } }
2	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader sc = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Task solver = new Task(); solver.solve(1,sc,out); out.close(); } static class Task{ public void solve( int testNumber, InputReader sc, PrintWriter out){ double n = sc.nextInt();  double k = sc.nextInt();  double ans = (n - (-1.5 + Math.sqrt(((9.0 / 4) + (2 * (n + k)))))); out.printf("%.0f\n",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());} } }
4	public class C{ public static void main( String[] args)throws FileNotFoundException { Scanner in = new Scanner(new FileReader(new File("input.txt")));  PrintWriter out = new PrintWriter(new File("output.txt"));  int n = in.nextInt();  int m = in.nextInt();  int[][] T = new int[n][m];  int k = in.nextInt();  int[] X = new int[k];  int[] Y = new int[k]; for ( int i = 0;(i < k);i++) {X[i] = (in.nextInt() - 1); Y[i] = (in.nextInt() - 1); } int max = 0; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) { int min = Integer.MAX_VALUE; for ( int ii = 0;(ii < k);ii++) min = Math.min(min,(Math.abs((i - X[ii])) + Math.abs((j - Y[ii])))); max = Math.max(max,T[i][j] = min); }for ( int i = 0;(i < n);i++) for ( int j = 0;(j < m);j++) if ( (T[i][j] == max)) {out.println((((i + 1) + " ") + (j + 1))); out.flush(); return ;} } }
5	public class Median_Segments_general{ public static void main( String[] args){ Scanner s = new Scanner(System.in);  int n = s.nextInt();  int m = s.nextInt();  int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); }System.out.println((func(n,m,arr) - func(n,(m + 1),arr))); } public static long func( int n, int m, int[] arr){ HashMap<Long,Integer> map = new HashMap<>(); map.put((long)0,1); long sum = 0;  long res = 0;  long add = 0; for ( int i = 0;(i < n);i++) {if ( (arr[i] < m)) {sum--; if ( map.containsKey(sum)) {add -= map.get(sum); } } else {if ( map.containsKey(sum)) {add += map.get(sum); } sum++; }res += add; if ( map.containsKey(sum)) {map.put(sum,(map.get(sum) + 1)); } else {map.put(sum,1); }}return res;} }
1	public class a{ boolean[] isp ; ArrayList<Integer> primes ; private void solve()throws Exception { int n = nextInt();  int k = nextInt();  int cnt = 0; primes = new ArrayList<Integer>(); isp = new boolean[(n + 1)]; Arrays.fill(isp,true); for ( int i = 2;(i <= n);++i) {for ( int j = 2;((j * j) <= i);++j) if ( ((i % j) == 0)) isp[i] = false; if ( isp[i]) primes.add(i); }for ( int i = 2;(i <= n);++i) if ( isp[i]) { boolean can = false; for ( int j = 0;(j < (primes.size() - 1));++j) { int sum = ((primes.get(j) + primes.get((j + 1))) + 1); if ( (i == sum)) can = true; }if ( can) ++cnt; } if ( (cnt >= k)) out.print("YES"); else out.print("NO"); } public void run(){ try{solve(); }catch (Exception e){ NOO(e); } finally{out.close(); }} PrintWriter out ; BufferedReader in ; StringTokenizer St ; void NOO( Exception e){ e.printStackTrace(); System.exit(1); } int nextInt(){ return Integer.parseInt(nextToken());} String nextToken(){ while(!St.hasMoreTokens()){try{ String line = in.readLine(); St = new StringTokenizer(line); }catch (Exception e){ NOO(e); } }return St.nextToken();} private a( String name){ try{in = new BufferedReader(new FileReader((name + ".in"))); St = new StringTokenizer(""); out = new PrintWriter(new FileWriter((name + ".out"))); }catch (Exception e){ NOO(e); } } private a(){ try{in = new BufferedReader(new InputStreamReader(System.in)); St = new StringTokenizer(""); out = new PrintWriter(System.out); }catch (Exception e){ NOO(e); } } public static void main( String[] args){ Locale.setDefault(Locale.US); new a().run(); } }
6	public class Main implements Runnable{ int[] conf ,L ,B ; int n ,k ,A ,sz ; double[] kill ; double best = 0; double solv(){ double res = 0;  double[] a = new double[n]; for ( int i = 0;(i < n);i++) a[i] = (Math.min(100,(L[i] + (10 * conf[i]))) / 100.0); double[] dp1 = new double[sz];  double[] dp2 = new double[sz]; dp1[0] = 1; for ( int i = 0;(i < n);i++) {for ( int msk = 0;(msk < sz);msk++) {dp2[msk] += (dp1[msk] * a[i]); dp2[(msk | (1 << i))] += (dp1[msk] * (1 - a[i])); }for ( int msk = 0;(msk < sz);msk++) {dp1[msk] = dp2[msk]; dp2[msk] = 0; }}for ( int msk = 0;(msk < sz);msk++) {if ( ((n - Integer.bitCount(msk)) > (n / 2))) res += dp1[msk]; else res += (dp1[msk] * kill[msk]); }return res;} void gen( int n, int k){ if ( (n == 0)) {conf[0] = k; double x = solv(); if ( (x > best)) best = x; return ;} for ( int i = 0;(i <= k);i++) {conf[n] = i; gen((n - 1),(k - i)); }conf[n] = 0; } void solve()throws IOException { n = nextInt(); k = nextInt(); A = nextInt(); B = new int[n]; L = new int[n]; for ( int i = 0;(i < n);i++) {B[i] = nextInt(); L[i] = nextInt(); }sz = (1 << n); conf = new int[n]; kill = new double[sz]; for ( int msk = 0;(msk < sz);msk++) { int sum = 0; for ( int i = 0;(i < n);i++) if ( ((msk & (1 << i)) > 0)) {sum += B[i]; } kill[msk] = ((A * 1.) / (A + sum)); }gen((n - 1),k); out.printf(Locale.US,"%1.9f",best); } BufferedReader br ; StringTokenizer st ; PrintWriter out ; String next()throws IOException { while(((st == null) || !st.hasMoreTokens())){ String s = br.readLine(); if ( (s == null)) return null; st = new StringTokenizer(s,", \t"); }return st.nextToken();} int nextInt()throws IOException { return Integer.parseInt(next());} public static void main( String[] args){ new Thread(new Main()).start(); } }
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());} }
2	public class Main{ public static void main( String[] args)throws IOException { InputStreamReader r = new InputStreamReader(System.in);  BufferedReader f = new BufferedReader(r);  Scanner sc = new Scanner(System.in);  long n = sc.nextLong();  long m = sc.nextLong();  long sum = 0; if ( (n == 1)) {} else {for ( long i = 1;(i <= n);i++) {sum += i; if ( ((sum - (n - i)) == m)) {sum = (n - i); break;} }}System.out.println(sum); } }
0	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } StreamTokenizer in ; PrintWriter out ; public void run()throws IOException { in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); } public double nextInt()throws IOException { in.nextToken(); return in.nval;} public void solve()throws IOException { double a = nextInt(),v = nextInt(),l = nextInt(),d = nextInt(),w = nextInt();  double s = ((w * w) / (2 * a)); if ( ((s > d) || (w > v))) { double t = ((v * v) / (2 * a)); if ( (t > l)) { double f = ((2 * l) / a); out.print(String.format("%.10f",Math.sqrt(f))); return ;} double f = (v / a);  double k = ((l - t) / v); out.print(String.format("%.10f",(f + k))); return ;} double t ; if ( (((((2 * v) * v) - (w * w)) / (2 * a)) < d)) t = (((v / a) + ((v - w) / a)) + ((d - ((((2 * v) * v) - (w * w)) / (2 * a))) / v)); else { double v1 = Math.sqrt(((((2 * a) * d) + (w * w)) / 2)); t = ((v1 / a) + ((v1 - w) / a)); } double r = (l - d);  double tr = (((v * v) - (w * w)) / (2 * a)); if ( (tr > r)) { double t1 = ((-w + Math.sqrt(((w * w) + ((2 * a) * r)))) / a); out.print(String.format("%.10f",(t + t1))); return ;} r -= (((v * v) - (w * w)) / (2 * a)); t += ((v - w) / a); out.print(String.format("%.10f",(t + (r / v)))); } }
4	public class _1523_C{ public static void main( String[] args)throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  int t = Integer.parseInt(in.readLine()); while((t-- > 0)){ int n = Integer.parseInt(in.readLine());  int[] a = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(in.readLine()); } boolean[][] used = new boolean[n][(n + 1)];  boolean[] used2 = new boolean[n];  String[][] res = new String[n][2]; res[0][0] = "1"; res[0][1] = ""; for ( int i = 1;(i < n);i++) {if ( (a[i] == 1)) {for ( int j = (i - 1);(j >= 0);j--) {if ( (!used[j][a[i]] && !used2[j])) {res[i][0] = (res[j][0] + ".1"); res[i][1] = res[j][0]; used[j][a[i]] = true; break;} }} else {for ( int j = (i - 1);(j >= 0);j--) {if ( ((!used[j][a[i]] && !used2[j]) && (a[j] == (a[i] - 1)))) {if ( res[j][1].equals("")) {res[i][0] = ("" + a[i]); } else {res[i][0] = ((res[j][1] + ".") + a[i]); }res[i][1] = res[j][1]; used[j][a[i]] = true; break;} used2[j] = true; }}}for ( int i = 0;(i < n);i++) {out.println(res[i][0]); }}in.close(); out.close(); } }
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[] ; static private 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;} static private 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(); } }
0	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); System.out.println(("0 0 " + n)); } }
0	public class Fibonacci{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  long num = 0; num = input.nextLong(); while(((num < 0) || (num > Math.pow(10,9)))){System.out.println("Invalid"); num = input.nextLong(); }System.out.println(("0 0 " + num)); } }
6	public class Main{ public Main(){ super(); } public static void main( String... args){ Main main = new Main(); main.start(); } public void start(){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  double a[][] = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) a[i][j] = Double.parseDouble(in.next()); int nn = (1 << n);  double p[] = new double[nn]; Arrays.fill(p,-1.0); p[(nn - 1)] = 1.0; DecimalFormat f = new DecimalFormat(); f.applyPattern("0.000000"); for ( int i = 0;(i < n);i++) {if ( (i != 0)) System.out.print(" "); System.out.print(f.format(this.probability(a,p,(1 << i)))); }} private double probability( double[][] a, double[] p, int i){ if ( (p[i] >= 0.0)) return p[i]; double ans = 0;  int count = Integer.bitCount(i);  int n = a.length; for ( int j = 0;(j < n);j++) { int jj = (1 << j); if ( ((jj & i) == 0)) { double d = this.probability(a,p,(jj | i));  double dPair = (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 += ((d * dPair) * s); } }p[i] = ans; return p[i];} }
2	public class A{ static private Scanner in ; final int M = 1000000009; public void run(){ int n = in.nextInt();  int m = in.nextInt();  int k = in.nextInt();  int z = (n - m); if ( (z >= (n / k))) {System.out.println(m); return ;} int f = (n - (k * z));  int last = ((f % k) + ((k - 1) * z)); f /= k; int ans = BigInteger.ONE.shiftLeft((f + 1)).remainder(BigInteger.valueOf(M)).intValue(); System.out.println((((((ans + M) - 2L) * k) + last) % M)); } public static void main( String[] args){ Locale.setDefault(Locale.US); in = new Scanner(System.in); new A().run(); in.close(); } }
3	public class Main{ public static void main( String[] args){ 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(); long no = 0; for ( int i = 0;(i < (n - 1));i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) no++; }}no %= 2; int m = in.nextInt();  int te ;  String te2 = "odd",te1 = "even"; for ( int i = 0;(i < m);i++) {te = (in.nextInt() - in.nextInt()); te = (-te + 1); if ( ((((te * (te - 1)) / 2) % 2) == 0)) {if ( (no == 0)) System.out.println("even"); else System.out.println("odd"); } else {no = ((no + 1) % 2); if ( (no == 0)) System.out.println("even"); else System.out.println("odd"); }}} }
3	public class Main{ public static String taskName = ""; public class Task{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int r = in.nextInt();  int[] x = new int[n]; for ( int i = 0;(i < n);i++) x[i] = in.nextInt(); double[] y = new double[n]; for ( int i = 0;(i < n);i++) {y[i] = r; for ( int j = 0;(j < i);j++) { int dx = Math.abs((x[i] - x[j])); if ( (dx <= (2 * r))) y[i] = Math.max(y[i],(y[j] + Math.abs(Math.sqrt((((4 * r) * r) - (dx * dx)))))); }System.out.print((y[i] + " ")); }System.out.println(); } } public static void main( String[] args)throws FileNotFoundException { if ( !taskName.isEmpty()) {System.setIn(new BufferedInputStream(new FileInputStream((taskName + ".in")))); System.setOut(new PrintStream(new BufferedOutputStream(new FileOutputStream((taskName + ".out"))))); } InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  Main main = new Main(); main.run(in,out); out.close(); } public void run( InputReader in, PrintWriter out){ Task solver = new Task(); solver.solve(1,in,out); } 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());} } }
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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ long LL = in.nextLong();  long RR = in.nextLong();  long L = LL;  long R = RR;  long ans = 0L;  long X = Long.highestOneBit(R); while(((X > 0L) && ((L & X) == (R & X))))X >>= 1; while((X > 0L)){ long a = (L & X);  long b = (R & X); if ( ((a ^ b) == X)) ans |= X; else {if ( (b == 0L)) {if ( ((R | X) <= RR)) {R |= X; ans |= X; } else if ( ((L | X) <= RR)) {L |= X; ans |= X; } } else {if ( ((L ^ X) >= LL)) {L ^= X; ans |= X; } else if ( ((R ^ X) >= LL)) {R ^= X; ans |= X; } }}X >>= 1; }out.println(ans); } } 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());} }
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(); } int parity = 0; for ( int i = 0;(i < n);i++) { int count = 0; for ( int j = (i + 1);(j < n);j++) {if ( (arr[j] < arr[i])) {parity ^= 1; } }} int m = s.nextInt(); for ( int i = 0;(i < m);i++) { int l = s.nextInt(),r = s.nextInt(); if ( (((((r - l) + 1) / 2) % 2) == 1)) {parity ^= 1; } System.out.println(((parity == 1)?"odd":"even")); }} }
1	public class Main{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int a[] = new int[100004];  int b[] = new int[100004];  int n ,m ,ans = 0,dau ,cuoi = -1; n = sc.nextInt(); m = sc.nextInt(); for ( int i = 0;(i < 100004);i++) a[i] = 0; for ( int i = 0;(i < n);i++) {b[i] = sc.nextInt(); if ( (a[b[i]] == 0)) {a[b[i]] = 1; ans++; if ( (ans == m)) {cuoi = (i + 1); break;} } }for ( int i = (cuoi - 1);(i >= 00);i--) {if ( (a[b[i]] == 1)) {a[b[i]] = 0; ans--; if ( (ans == 0)) {System.out.println((((i + 1) + " ") + cuoi)); System.exit(0); } } }System.out.println("-1 -1"); } }
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);  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.readInt();  char[] str = IOUtils.readCharArray(in,n); for ( int i = 0;(i < n);i++) {if ( (str[i] <= 'Z')) {str[i] = (char)(str[i] - 'A'); } else {str[i] = (char)((str[i] - 'a') + 26); }} IntHashSet set = new IntHashSet(); for ( char c :str) {set.add(c); } int max = (26 + 26);  int[][] next = new int[max][n]; ArrayUtils.fill(next,-1); for ( int i = (n - 2);(i >= 0);i--) {for ( int ch = 0;(ch < max);ch++) {next[ch][i] = next[ch][(i + 1)]; }next[str[(i + 1)]][i] = (i + 1); } int ans = (int)1e9; final int tagetCnt = set.size(); for ( int s = 0;(s < n);s++) { boolean[] used = new boolean[max]; used[str[s]] = true; int cnt = 1;  int pos = s; while((cnt < tagetCnt)){ int nextPos = n; for ( int ch = 0;(ch < max);ch++) {if ( !used[ch]) {if ( (next[ch][pos] == -1)) {continue;} nextPos = Math.min(nextPos,next[ch][pos]); } }pos = nextPos; if ( (nextPos == n)) {break;} ++cnt; used[str[nextPos]] = true; }if ( (pos == n)) {break;} ans = Math.min(ans,((pos - s) + 1)); }out.printLine(ans); } } static interface IntCollection extends IntStream{ public int size(); public default void add( int value){ throw (new UnsupportedOperationException());} public default IntCollection addAll( IntStream values){ for ( IntIterator it = values.intIterator();it.isValid();it.advance()) {add(it.value()); }return this;} } static interface IntStream extends Iterable<Integer>,Comparable<IntStream>{ public IntIterator intIterator(); } static class IntHashSet extends IntAbstractStream implements IntSet{ static private final Random RND = new Random(); static private final int[] SHIFTS = new int[4]; static private final byte PRESENT_MASK = 1; static private final byte REMOVED_MASK = 2; private int size ; private int realSize ; private int[] values ; private byte[] present ; private int step ; private int ratio ; {for ( int i = 0;(i < 4);i++) {SHIFTS[i] = (RND.nextInt(31) + 1); }}public IntHashSet(){ this(3); } public IntHashSet( int capacity){ capacity = Math.max(capacity,3); values = new int[capacity]; present = new byte[capacity]; ratio = 2; initStep(capacity); } public IntHashSet( IntCollection c){ this(c.size()); addAll(c); } public IntHashSet( int[] arr){ this(new IntArray(arr)); } private void initStep( int capacity){ step = (RND.nextInt((capacity - 2)) + 1); while((IntegerUtils.gcd(step,capacity) != 1)){step++; }} public IntIterator intIterator(){ return new IntIterator(){private int position = ((size == 0)?values.length:-1); public int value()throws NoSuchElementException { if ( (position == -1)) {advance(); } if ( (position >= values.length)) {throw (new NoSuchElementException());} if ( ((present[position] & PRESENT_MASK) == 0)) {throw (new IllegalStateException());} return values[position];} public boolean advance()throws NoSuchElementException { if ( (position >= values.length)) {throw (new NoSuchElementException());} position++; while(((position < values.length) && ((present[position] & PRESENT_MASK) == 0))){position++; }return isValid();} public boolean isValid(){ return (position < values.length);} };} public int size(){ return size;} public void add( int value){ ensureCapacity((((realSize + 1) * ratio) + 2)); int current = getHash(value); while((present[current] != 0)){if ( (((present[current] & PRESENT_MASK) != 0) && (values[current] == value))) {return ;} current += step; if ( (current >= values.length)) {current -= values.length; } }while(((present[current] & PRESENT_MASK) != 0)){current += step; if ( (current >= values.length)) {current -= values.length; } }if ( (present[current] == 0)) {realSize++; } present[current] = PRESENT_MASK; values[current] = value; size++; } private int getHash( int value){ int hash = IntHash.hash(value);  int result = hash; for ( int i :SHIFTS) {result ^= (hash >> i); }result %= values.length; if ( (result < 0)) {result += values.length; } return result;} private void ensureCapacity( int capacity){ if ( (values.length < capacity)) {capacity = Math.max((capacity * 2),values.length); rebuild(capacity); } } private void rebuild( int capacity){ initStep(capacity); int[] oldValues = values;  byte[] oldPresent = present; values = new int[capacity]; present = new byte[capacity]; size = 0; realSize = 0; for ( int i = 0;(i < oldValues.length);i++) {if ( ((oldPresent[i] & PRESENT_MASK) == PRESENT_MASK)) {add(oldValues[i]); } }} } static interface IntList extends IntReversableCollection{ public abstract int get( int index); public abstract void addAt( int index, int value); public abstract void removeAt( int index); public default IntIterator intIterator(){ return new IntIterator(){private int at ; private boolean removed ; public int value(){ if ( removed) {throw (new IllegalStateException());} return get(at);} public boolean advance(){ at++; removed = false; return isValid();} public boolean isValid(){ return (!removed && (at < size()));} };} public default void add( int value){ addAt(size(),value); } } 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 char readCharacter(){ int c = read(); while(isSpaceChar(c)){c = read(); }return (char)c;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } static interface IntReversableCollection extends IntCollection{ } 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); } } static class IntArray extends IntAbstractStream implements IntList{ private int[] data ; public IntArray( int[] arr){ data = arr; } public int size(){ return data.length;} public int get( int at){ return data[at];} public void addAt( int index, int value){ throw (new UnsupportedOperationException());} public void removeAt( int index){ throw (new UnsupportedOperationException());} } static interface IntSet extends IntCollection{ } static interface IntIterator{ public int value()throws NoSuchElementException ; public boolean advance(); public boolean isValid(); } }
0	public class A{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long l = in.nextLong();  long r = in.nextLong(); if ( ((r - l) < 2)) {System.out.println("-1"); } else if ( (((r - l) == 2) && ((l % 2) == 1))) {System.out.println("-1"); } else {if ( ((l % 2) == 0)) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); } else {System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); }}} }
4	public class Solution implements Runnable{ Scanner input ; PrintWriter output ; private void solve()throws Exception { int n = nextInt();  int m = nextInt();  int k = nextInt();  int[] r = new int[k];  int[] c = new int[k]; for ( int i = 0;(i < k);i++) {r[i] = nextInt(); c[i] = nextInt(); } int best = -1;  int bestr = -1;  int bestc = -1; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) { int d = (n + m); for ( int q = 0;(q < k);q++) {d = Math.min(d,(Math.abs((i - r[q])) + Math.abs((j - c[q])))); }if ( (d < best)) continue; best = d; bestr = i; bestc = j; }}out(((bestr + " ") + bestc)); } private int nextInt()throws Exception { return input.nextInt();} private void out( String s){ output.println(s); } public Solution()throws IOException{ input = new Scanner(new FileReader("input.txt")); output = new PrintWriter("output.txt"); } public static void main( String[] args)throws IOException { Locale.setDefault(Locale.US); new Thread(new Solution()).start(); } }
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();  long K = in.readLong();  long[] a = new long[N]; for ( int i = 0;(i < N);++i) {a[i] = in.readLong(); } ArrayShuffler s = new ArrayShuffler(); s.shuffle(a); Arrays.sort(a); boolean[] taken = new boolean[N]; Arrays.fill(taken,true); int i = 0;  int j = (i + 1);  int res = N; while((i < a.length)){if ( (taken[i] == false)) {i++; if ( (j <= i)) j = (i + 1); continue;} while(((j < a.length) && (a[j] < (a[i] * K)))){j++; }if ( (j < a.length)) {if ( (a[j] == (a[i] * K))) {taken[j] = false; res--; } } i++; if ( (j <= i)) j = (i + 1); }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 int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } else if ( (c == '+')) {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 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(); } } class ArrayShuffler{ static Random random = new Random(7428429L); public void shuffle( long[] p){ for ( int i = 0;(i < p.length);++i) { int j = (i + random.nextInt((p.length - i)));  long temp = p[i]; p[i] = p[j]; p[j] = temp; }} }
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(); } }
6	public class B{ public static void main( String[] args)throws Exception { new B().run(); } double ans = 0; int n ,candy ,A ,half ; void run()throws Exception { Scanner sc = new Scanner(System.in); n = sc.nextInt(); candy = sc.nextInt(); A = sc.nextInt(); half = (n / 2); S[] ss = new S[n]; for ( int i = 0;(i < n);i++) {ss[i] = new S(sc.nextInt(),sc.nextInt()); }Arrays.sort(ss); int need = 0; for ( int i = (n - 1);(i >= ((n - half) - 1));i--) need += ((100 - ss[i].loyal) / 10); if ( (need <= candy)) {System.out.println(1.0); return ;} tra(ss,0,candy); System.out.printf("%.10f\n",ans); } void tra( S[] ss, int pos, int rest){ if ( (pos == n)) { double sum = 0;  int lim = (1 << n); for ( int m = 0;(m < lim);m++) { int app = Integer.bitCount(m);  double p = 1;  int B = 0; for ( int i = 0;(i < n);i++) {if ( (((m >> i) & 1) == 1)) {p = ((p * ss[i].loyal) / 100); } else {p = ((p * (100 - ss[i].loyal)) / 100); B += ss[i].level; }}if ( (app > half)) sum += p; else {sum += ((p * A) / (A + B)); }}ans = max(ans,sum); return ;} for ( int i = 0;(i <= rest);i++) { int old = ss[pos].loyal;  int nl = (ss[pos].loyal + (i * 10)); if ( (nl > 100)) break; ss[pos].loyal = nl; tra(ss,(pos + 1),(rest - i)); ss[pos].loyal = old; }} } class S implements Comparable<S>{ int level ,loyal ; S( int a, int b){ level = a; loyal = b; } }
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();} } }
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(); } }
4	public class Main{ static private HashMap<String,Integer> nodes ; static private void dfs( String cur, PrintWriter out){ if ( (cur.length() > 0)) {out.println(cur.substring(1)); } int children = nodes.get(cur); for ( int i = 1;(i <= children);i++) {dfs(((cur + ".") + i),out); }} public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int t = Integer.parseInt(f.readLine()); while((t-- > 0)){ int n = Integer.parseInt(f.readLine()); nodes = new HashMap<>(); nodes.put("",0); String cur = ""; for ( int i = 0;(i < n);i++) { int a = Integer.parseInt(f.readLine()); while((nodes.get(cur) != (a - 1))){cur = cur.substring(0,cur.lastIndexOf(".")); }nodes.put(cur,a); cur = ((cur + ".") + a); nodes.put(cur,0); }dfs("",out); }f.close(); out.close(); } }
0	public class Ideone{ public static void main( String[] args)throws java.lang.Exception { int n ,a ,b ;  Scanner obj = new Scanner(System.in); n = obj.nextInt(); if ( ((n % 4) == 0)) {a = (n / 2); b = (n / 2); System.out.println(((a + " ") + b)); } else if ( (((n % 2) == 0) && ((n % 4) != 0))) {a = ((n / 2) - 1); b = ((n / 2) + 1); System.out.println(((a + " ") + b)); } else if ( ((n % 2) != 0)) {a = 4; b = 0; while((b != 1)){b = (n - a); if ( ((b % 3) == 0)) {System.out.println(((a + " ") + b)); break;} else {a = (a + 2); }}} } }
1	public class C{ static int[] arr ; static int L ; public static void rotate(){ int tmp = arr[0]; for ( int i = 1;(i < L);i++) arr[(i - 1)] = arr[i]; arr[(L - 1)] = tmp; } public static void main( String[] args){ Scanner input = new Scanner(System.in); L = input.nextInt(); String s = input.next(); arr = new int[L]; for ( int i = 0;(i < L);i++) {arr[i] = ((s.charAt(i) == 'H')?1:0); } int count = 99999; for ( int A = 0;(A < L);A++) { int[] tmp = new int[L]; System.arraycopy(arr,0,tmp,0,arr.length); int ans = 0; for ( int i = 0;(i < L);i++) {if ( (tmp[i] == 1)) continue; for ( int j = (L - 1);(j > i);j--) {if ( (tmp[j] == 0)) continue; ans++; tmp[i] = 1; tmp[j] = 0; break;}}count = Math.min(count,ans); rotate(); }System.out.println(count); } }
2	public class Main{ static int len( long n){ int res = 0; while((n > 0)){n /= 10; res++; }return res;} static long big( int len){ long p = 1; while((len-- > 0))p *= 10; return (p - 1);} static long small( int len){ return (big((len - 1)) + 1);} static long cnt( long n){ int len = len(n);  long cnt = 0; for ( int l = 1;(l < len);l++) cnt += ((1l * l) * ((big(l) - small(l)) + 1)); cnt += ((1l * len) * (n - small(len))); return cnt;} public static void main( String[] args)throws Exception { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  long k = sc.nextLong(); if ( (k == 1)) {System.out.println(1); return ;} long lo = 1,hi = k,res = 1; while((lo <= hi)){ long mid = ((lo + hi) >> 1L); if ( (cnt(mid) < k)) {res = mid; lo = (mid + 1); } else {hi = (mid - 1); }} ArrayList<Integer> digits = new ArrayList<>();  long tmp = res; while((tmp > 0)){digits.add((int)(tmp % 10)); tmp /= 10; }Collections.reverse(digits); out.println(digits.get((int)((k - cnt(res)) - 1))); out.flush(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( FileReader f){ br = new BufferedReader(f); } 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();} } }
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[] input = IOUtils.readIntArray(in,n); Arrays.sort(input); int x = input[(b - 1)];  int y = input[b]; out.println((y - x)); } }
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());} } }
3	public class indent{ static int N ,M ,K ; static String s ; static StringTokenizer st ; static int[] d ; static long 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());  char[] d = new char[N]; for ( int i = 0;(i < N);i++) {d[i] = br.readLine().charAt(0); } long[][] dp = new long[N][N];  boolean det = (d[0] == 'f'); dp[0][0] = 1; for ( int i = 1;(i < N);i++) { long sum = 0; for ( int j = 0;(j < N);j++) {sum = ((((dp[(i - 1)][j] % MOD) + (sum % MOD)) + MOD) % MOD); }if ( (d[i] == 'f')) {if ( det) {for ( int j = 1;(j < N);j++) {dp[i][j] = (dp[(i - 1)][(j - 1)] % MOD); }continue;} for ( int j = 0;(j < N);j++) {dp[i][j] = (sum % MOD); sum -= (dp[(i - 1)][j] % MOD); }det = true; } else if ( (d[i] == 's')) {if ( det) {det = false; for ( int j = 1;(j < N);j++) {dp[i][j] = (dp[(i - 1)][(j - 1)] % MOD); }continue;} for ( int j = 0;(j < N);j++) {dp[i][j] = (sum % MOD); sum = ((((sum - dp[(i - 1)][j]) % MOD) + MOD) % MOD); }} } long ans = 0; for ( long e :dp[(dp.length - 1)]) {ans = (((ans + e) + MOD) % MOD); }System.out.println(ans); } }
3	public class Codeforce{ 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(); } int color = 0; Arrays.sort(arr); for ( int i = 0;(i < n);i++) {if ( (arr[i] != 0)) { int col = arr[i]; color++; for ( int j = i;(j < n);j++) {if ( ((arr[j] % col) == 0)) arr[j] = 0; }} }System.out.println(color); sc.close(); } }
4	public class D7182{ public static void main( String[] args)throws IOException { init_io(); int N = nint(),M = nint(),K = nint(); if ( ((K % 2) == 0)) { int[][][] grid = new int[(K + 1)][N][M];  int[][][] edges = new int[4][N][M]; for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < (M - 1));j++) {edges[0][i][j] = edges[2][i][(j + 1)] = nint(); }}for ( int i = 0;(i < (N - 1));i++) {for ( int j = 0;(j < M);j++) {edges[1][i][j] = edges[3][(i + 1)][j] = nint(); }}for ( int k = 1;(k <= (K / 2));k++) {for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) { int min = Integer.MAX_VALUE; if ( (i != (N - 1))) {min = Math.min(min,(grid[(k - 1)][(i + 1)][j] + edges[1][i][j])); } if ( (j != (M - 1))) {min = Math.min(min,(grid[(k - 1)][i][(j + 1)] + edges[0][i][j])); } if ( (i != 0)) {min = Math.min(min,(grid[(k - 1)][(i - 1)][j] + edges[3][i][j])); } if ( (j != 0)) {min = Math.min(min,(grid[(k - 1)][i][(j - 1)] + edges[2][i][j])); } grid[k][i][j] = min; }}}for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {out.print(((grid[(K / 2)][i][j] * 2) + " ")); }out.println(); }} else {for ( int i = 0;(i < N);i++) {for ( int j = 0;(j < M);j++) {out.print((-1 + " ")); }out.println(); }}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))); } }
0	public class Main{ public static void main( String[] args)throws IOException { new Main().run(); } BufferedReader in ; PrintWriter out ; StringTokenizer st = new StringTokenizer(""); private void run()throws IOException { if ( new File("input.txt").exists()) in = new BufferedReader(new FileReader("input.txt")); else in = new BufferedReader(new InputStreamReader(System.in)); if ( new File("output.txt").exists()) out = new PrintWriter("output.txt"); else out = new PrintWriter(System.out); solve(); in.close(); out.close(); } void solve()throws IOException { long l = nextLong();  long r = nextLong(); l += (l % 2); if ( ((l + 2) > r)) out.println("-1"); else {out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); }} String nextToken()throws IOException { while(!st.hasMoreTokens()){st = new StringTokenizer(in.readLine()); }return st.nextToken();} long nextLong()throws IOException { return Long.parseLong(nextToken());} }
6	public class Ideone{ static double p[][] ; static double dp[] ; static int n ; public static int BitCount( int u){ int uCount ; uCount = ((u - ((u >> 1) & 033333333333)) - ((u >> 2) & 011111111111)); return (((uCount + (uCount >> 3)) & 030707070707) % 63);} public static double f( int mask){ if ( (dp[mask] > -0.5)) return dp[mask]; dp[mask] = 0; int ones = BitCount(mask);  double pairs = ((ones * (ones + 1)) >> 1); for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (((mask & (1 << i)) != 0) && ((mask & (1 << j)) == 0))) dp[mask] += ((f((mask | (1 << j))) * p[i][j]) / pairs); }}return dp[mask];} public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); n = Integer.parseInt(bf.readLine()); p = new double[n][n]; for ( int i = 0;(i < n);i++) { StringTokenizer st = new StringTokenizer(bf.readLine()); for ( int j = 0;(j < n);j++) {p[i][j] = Double.parseDouble(st.nextToken()); }}dp = new double[(1 << n)]; Arrays.fill(dp,-1.0); dp[((1 << n) - 1)] = 1.; for ( int i = 0;(i < (n - 1));i++) {System.out.print((f((1 << i)) + " ")); }System.out.println(f((1 << (n - 1)))); } }
1	public class A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int ans = 0; for ( int i = 1;(i <= n);i++) {ans += (((i * 2) <= n)?i:((n - i) + 1)); }System.out.println(ans); } }
0	public class Test3{ public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int x = Integer.parseInt(br.readLine());  int y = Integer.parseInt(br.readLine()); System.out.print((int)(y % Math.pow(2,x))); } }
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;} } static private 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();} } }
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());} } }
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); } }
5	public class a{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  int n = in.nextInt();  long k = in.nextLong();  Long[] a = new Long[n]; for ( int i = 0;(i < n);i++) a[i] = in.nextLong(); HashSet<Long> hash = new HashSet<Long>(); Arrays.sort(a); for ( int i = 0;(i < n);i++) if ( !hash.contains(a[i])) {hash.add((a[i] * k)); } System.out.println(hash.size()); } }
5	public class ProblemA{ public static void main( String[] args)throws IOException { BufferedReader s = new BufferedReader(new InputStreamReader(System.in));  String[] data = s.readLine().split(" ");  int n = Integer.valueOf(data[0]);  int a = Integer.valueOf(data[1]);  int b = Integer.valueOf(data[2]);  long[] h = new long[n];  String[] line = s.readLine().split(" "); for ( int i = 0;(i < n);i++) {h[i] = Integer.valueOf(line[i]); }Arrays.sort(h); System.out.println((h[b] - h[(b - 1)])); } }
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.readInt();  boolean[] isF = new boolean[n]; for ( int i = 0;(i < n);i++) {isF[i] = (in.readCharacter() == 'f'); } FenwickTree[] fenwickTrees = new FenwickTree[(n + 1)]; for ( int i = 0;(i < fenwickTrees.length);i++) {fenwickTrees[i] = new FenwickTree((n + 1)); }fenwickTrees[n].add(0,1); for ( int idx = (n - 1);(idx >= 0);idx--) {for ( int indentLevel = 0;(indentLevel < n);indentLevel++) { long fenwickRes ; if ( isF[idx]) {fenwickRes = fenwickTrees[(idx + 1)].get((indentLevel + 1),(indentLevel + 1)); } else {fenwickRes = fenwickTrees[(idx + 1)].get(0,indentLevel); }fenwickTrees[idx].add(indentLevel,(fenwickRes % MiscUtils.MOD7)); }}out.printLine(fenwickTrees[0].get(0,0)); } } 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 char readCharacter(){ int c = read(); while(isSpaceChar(c)){c = read(); }return (char)c;} 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( long i){ writer.println(i); } } static class FenwickTree{ private final long[] value ; public FenwickTree( int size){ value = new long[size]; } public long get( int from, int to){ return (get(to) - get((from - 1)));} private long get( int to){ to = Math.min(to,(value.length - 1)); long result = 0; while((to >= 0)){result += value[to]; to = ((to & (to + 1)) - 1); }return result;} public void add( int at, long value){ while((at < this.value.length)){this.value[at] += value; at = (at | (at + 1)); }} } }
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 ,kk ,bb ; int[] uu ,vv ,cost ,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_]; kk = new int[n_]; bb = new int[n_]; uu = new int[m_]; vv = new int[m_]; cost = 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; cost[h] = cos; cc[((h << 1) ^ 0)] = cap; aa_[u].add(((h << 1) ^ 0)); aa_[v].add(((h << 1) ^ 1)); } void dijkstra( int s){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((kk[u] != kk[v])?(kk[u] - kk[v]):(u - v)))); pq.add(s); Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first;  int k = (kk[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 ^ uu[h]) ^ vv[h]); if ( ((pi[v] > p) || ((pi[v] == p) && (kk[v] > k)))) {if ( (pi[v] < INF)) pq.remove(v); pi[v] = p; kk[v] = k; bb[v] = h_; pq.add(v); } } }} void push( int s, int t){ int c = INF; for ( int u = t,h_ ,h ;(u != s);u ^= (uu[h] ^ vv[h])) {h = ((h_ = bb[u]) >> 1); c = Math.min(c,cc[h_]); }for ( int u = t,h_ ,h ;(u != s);u ^= (uu[h] ^ vv[h])) {h = ((h_ = bb[u]) >> 1); cc[h_] -= c; cc[(h_ ^ 1)] += c; }} int edmonds_karp( int s, int t){ System.arraycopy(cost,0,cost_,0,m_); while(true){dijkstra(s); if ( (pi[t] == INF)) break; push(s,t); for ( int h = 0;(h < m_);h++) { int u = uu[h],v = vv[h]; if ( ((pi[u] != INF) && (pi[v] != INF))) cost_[h] += (pi[u] - pi[v]); }} 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))); } }
0	public class A{ static private StreamTokenizer in ; static private PrintWriter out ; static private int nextInt()throws Exception { in.nextToken(); return (int)in.nval;} {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(); out.println(((n * 3) / 2)); out.flush(); } }
2	public class Main{ public static void main( String[] args){ new Main().run(); } Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); void run(){ work(); out.flush(); } void work(){ long r = in.nextLong();  long b = 0; for ( ;;b++) { long num = ((9 * (long)Math.pow(10,(double)b)) * (b + 1)); if ( ((r - num) <= 0)) {break;} r -= num; } long base = (long)Math.pow(10,(double)b);  long c = ((r - 1) / (b + 1));  int m = (int)((r - 1) % (b + 1)); base += c; String str = (base + ""); out.println(str.charAt(m)); } }
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();} }
1	public class CommentaryBoxes{ public static void main( String[] args){ FastReader in = new FastReader();  long n = in.nextLong();  long m = in.nextLong();  long a = in.nextLong();  long b = in.nextLong();  long total = 0;  long val = (n % m); if ( ((n % m) != 0)) { long x = (val * b);  long y = ((m - val) * a); total = Math.min(x,y); } System.out.println(Math.abs(total)); } public 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());} } }
3	public class Main{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));  int n = Integer.parseInt(br.readLine());  StringTokenizer tokenizer = new StringTokenizer(br.readLine());  boolean[] arr = new boolean[101];  int[] nums = new int[(n + 1)];  int colors = 0; for ( int i = 1;(i <= n);i++) {nums[i] = Integer.parseInt(tokenizer.nextToken()); arr[nums[i]] = true; }Arrays.parallelSort(nums); for ( int i = 1;(i <= n);i++) { boolean newColor = false; if ( !arr[nums[i]]) {continue;} for ( int j = nums[i];(j <= 100);j += nums[i]) {if ( arr[j]) {arr[j] = false; newColor = true; } }if ( newColor) {colors++; } }bw.write(String.valueOf(colors)); br.close(); bw.close(); } }
5	public class MicroWorld{ 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());  int[] temp = new int[1000001];  StringTokenizer st1 = new StringTokenizer(br.readLine()); for ( int i = 0;(i < n);i++) {temp[Integer.parseInt(st1.nextToken())]++; } int b = (k + 1); for ( int i = 1000000;(i > 0);i--) {if ( (temp[i] > 0)) {if ( (b <= k)) {n -= temp[i]; } b = 1; } else {b++; }}System.out.println(n); } }
4	public class Main implements Runnable{ public void solve()throws IOException { int N = nextInt();  int M = nextInt();  int B = nextInt();  int[][] burn = new int[B][2]; for ( int i = 0;(i < B);i++) {burn[i][0] = nextInt(); burn[i][1] = nextInt(); } int ansx = -1;  int ansy = -1;  int ans = -1; for ( int i = 1;(i <= N);i++) {for ( int j = 1;(j <= M);j++) { int burnAt = Integer.MAX_VALUE; for ( int k = 0;(k < B);k++) { int now = distance(i,j,burn[k][0],burn[k][1]); burnAt = Math.min(burnAt,now); }if ( (burnAt >= ans)) {ans = burnAt; ansx = i; ansy = j; } }}out.println(((ansx + " ") + ansy)); } private int distance( int x, int y, int xx, int yy){ return (Math.abs((xx - x)) + Math.abs((yy - y)));} public static void main( String[] args){ new Main().run(); } public void run(){ try{in = new BufferedReader(new FileReader(new File("input.txt"))); out = new PrintWriter(new FileWriter(new File("output.txt"))); tok = null; solve(); in.close(); out.close(); }catch (IOException e){ System.exit(0); } } public String nextToken()throws IOException { while(((tok == null) || !tok.hasMoreTokens())){tok = new StringTokenizer(in.readLine()); }return tok.nextToken();} public int nextInt()throws IOException { return Integer.parseInt(nextToken());} PrintWriter out ; BufferedReader in ; StringTokenizer tok ; }
0	public class Ideone{ public static void main( String[] args)throws java.lang.Exception { Scanner sc = new Scanner(System.in);  int n = sc.nextInt(); if ( ((n % 2) == 0)) {System.out.println(((4 + " ") + (n - 4))); } else { int a = Math.min(9,(n - 9));  int b = Math.max(9,(n - 9)); System.out.println(((a + " ") + b)); }} }
2	public class A{ static private final int mod = ((int)1e9 + 9); final IOFast io = new IOFast(); long k ; boolean ok( long n, long m, long x){ long u = (k * x);  long val = u; val += (((m - u) / (k - 1)) * k); if ( (((m - u) % (k - 1)) == 0)) val -= 1; else val += ((m - u) % (k - 1)); return (val <= n);} long rec( long n, long m, long cur){ long pow = 1;  long p = 1000; for ( int i = 0;(i < p);i++) pow = ((pow * 2) % mod); while(true){if ( ok(n,m,0)) {return ((m + cur) % mod);} if ( !ok((n - (p * k)),(m - (p * k)),p)) {n -= (p * k); m -= (p * k); cur = ((cur * pow) % mod); cur += ((((pow - 1) * 2) * k) % mod); cur %= mod; continue;} n -= k; m -= k; cur += k; cur = ((cur * 2) % mod); }} public void run()throws IOException { long n = io.nextLong();  long m = io.nextLong(); k = io.nextLong(); io.out.println(rec(n,m,0)); if ( true) return ; long low = -1,high = ((m / k) + 1); while(((high - low) > 1)){ long mid = ((low + high) / 2); if ( !ok(n,m,mid)) {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{ static private final long serialVersionUID = -8565341110209207657L; } public static class IOFast{ private BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); private PrintWriter out = new PrintWriter(System.out); static private int pos ,readLen ; static private final char[] buffer = new char[(1024 * 8)]; static private final char[] str = new char[((500000 * 8) * 2)]; static private boolean[] isDigit = new boolean[256]; static private boolean[] isSpace = new boolean[256]; static private 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);} } }
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(); } }
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);  G1PlaylistForPolycarpEasyVersion solver = new G1PlaylistForPolycarpEasyVersion(); solver.solve(1,in,out); out.close(); } static class G1PlaylistForPolycarpEasyVersion{ final long mod = 1000000007; PrintWriter out ; InputReader in ; int n ; int time ; int[][] arr ; long[][][] dp ; long go( int last, int t, int mask){ if ( (t > time)) return 0; if ( (t == time)) {return 1l;} if ( (mask == ((1 << n) - 1))) return 0; if ( (dp[last][t][mask] != -1)) return dp[last][t][mask]; long cnt = 0;  int i = 0,j = 0; for ( i = 0;(i < n);i++) {if ( (((mask & (1 << i)) == 0) && (arr[i][1] != last))) {cnt += go(arr[i][1],(t + arr[i][0]),(mask | (1 << i))); cnt %= mod; } }dp[last][t][mask] = cnt; return cnt;} public void solve( int testNumber, InputReader in, PrintWriter out){ this.out = out; this.in = in; n = ni(); time = ni(); arr = new int[n][2]; int i = 0; for ( i = 0;(i < n);i++) {arr[i][0] = ni(); arr[i][1] = (ni() - 1); }dp = new long[3][(time + 1)][(1 << n)]; for ( i = 0;(i < 3);i++) {for ( int j = 0;(j <= time);j++) Arrays.fill(dp[i][j],-1); } long ans = ((((go(0,0,0) + go(1,0,0)) % mod) + go(2,0,0)) % mod); ans *= modPow(2,(mod - 2)); ans %= mod; pn(ans); } int ni(){ return in.nextInt();} void pn( Object o){ out.println(o); } long modPow( long a, long p){ long o = 1; while((p > 0)){if ( ((p & 1) == 1)) o = mul(o,a); a = mul(a,a); p >>= 1; }return o;} 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;} } 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));} } }
2	public class Main{ PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next()throws IOException { if ( !tok.hasMoreTokens()) {tok = new StringTokenizer(in.readLine()); } return tok.nextToken();} int ni()throws IOException { return Integer.parseInt(next());} void solve()throws IOException { int n = ni(),k = ni();  int puts = (int)Math.sqrt((2 * k));  int t = ((puts * (puts + 1)) / 2); puts++; while((t < k)){t += puts; puts++; } int turns = (puts - 1); while(((t - k) != (n - turns))){t += puts; puts++; turns++; }System.out.println((t - k)); } public static void main( String[] args)throws IOException { new Main().solve(); } }
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 k = nextInt();  T[] ts = new T[n]; for ( int i = 0;(i < n);i++) {ts[i] = new T(nextInt(),nextInt()); }Arrays.sort(ts,new Comparator<T>(){}); int t = ts[(k - 1)].t;  int p = ts[(k - 1)].p;  int res = 0; for ( int i = 0;(i < n);i++) {if ( ((ts[i].p == p) && (ts[i].t == t))) {res++; } }out.println(res); } class T{ int p ; int t ; public T( int p, int t){ this.p = p; this.t = t; } } private void end(){ out.close(); } }
4	public final class Solution{ static PrintWriter out = new PrintWriter(System.out); static FastReader in = new FastReader(); static long mod = ((long)1e9 + 7); static Pair[] moves = new Pair[]{new Pair(-1,0),new Pair(1,0),new Pair(0,-1),new Pair(0,1)}; public static void main( String[] args){ int n = i();  int m = i();  int k = i();  int[][] a = new int[n][(m - 1)]; for ( int i = 0;(i < n);i++) {a[i] = input((m - 1)); } int[][] b = new int[(n - 1)][m]; for ( int i = 0;(i < (n - 1));i++) {b[i] = input(m); }if ( ((k % 2) > 0)) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print((-1 + " ")); }out.println(); }out.flush(); return ;} int[][][] f = new int[n][m][((k / 2) + 1)]; for ( int s = 1;(s <= (k / 2));s++) {for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) { int ans = -1; if ( (j > 0)) {ans = (f[i][(j - 1)][(s - 1)] + a[i][(j - 1)]); } if ( (i > 0)) { int t = (f[(i - 1)][j][(s - 1)] + b[(i - 1)][j]); ans = ((ans == -1)?t:Math.min(ans,t)); } if ( (i < (n - 1))) { int t = (f[(i + 1)][j][(s - 1)] + b[i][j]); ans = ((ans == -1)?t:Math.min(ans,t)); } if ( (j < (m - 1))) { int t = (f[i][(j + 1)][(s - 1)] + a[i][j]); ans = ((ans == -1)?t:Math.min(ans,t)); } f[i][j][s] = ans; }}}for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {out.print(((f[i][j][(k / 2)] * 2) + " ")); }out.println(); }out.flush(); } static int lowerBound( int[] A, int low, int high, int x){ if ( (low > high)) {if ( (x >= A[high])) {return A[high];} } int mid = ((low + high) / 2); if ( (A[mid] == x)) {return A[mid];} if ( (((mid > 0) && (A[(mid - 1)] <= x)) && (x < A[mid]))) {return A[(mid - 1)];} if ( (x < A[mid])) {return lowerBound(A,low,(mid - 1),x);} return lowerBound(A,(mid + 1),high,x);} static void print( char[] A){ for ( char c :A) {out.print(c); }out.println(); } static void print( boolean[] A){ for ( boolean c :A) {out.print((c + " ")); }out.println(); } static void print( int[] A){ for ( int c :A) {out.print((c + " ")); }out.println(); } static void print( long[] A){ for ( long i :A) {out.print((i + " ")); }out.println(); } static void print( List<Integer> A){ for ( int a :A) {out.print((a + " ")); }} static int i(){ return in.nextInt();} static int[] input( int N){ int A[] = new int[N]; for ( int i = 0;(i < N);i++) {A[i] = in.nextInt(); }return A;} static int GCD( int a, int b){ if ( (b == 0)) {return a;} else {return GCD(b,(a % b));}} static long GCD( long a, long b){ if ( (b == 0)) {return a;} else {return GCD(b,(a % b));}} } class Pair{ int i ,j ; Pair( int i, int j){ this.i = i; this.j = j; } } 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());} long nextLong(){ return Long.parseLong(next());} String nextLine(){ String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} }
0	public class LCMChallenge{ public static void main( String[] args){ Scanner cin = new Scanner(System.in);  int n = cin.nextInt(); if ( (n < 3)) {System.out.println(n); } else if ( ((n % 2) == 1)) {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))); }}} }
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();} }
3	public class problemA{ public static void main( String[] args){ Scanner scan = new Scanner(System.in);  int n = scan.nextInt();  int[] numbs = new int[n];  int[] smallest_color = new int[n]; for ( int i = 0;(i < n);i++) {numbs[i] = scan.nextInt(); }Arrays.sort(numbs); int count = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < n);j++) {if ( (smallest_color[j] == 0)) {count++; smallest_color[j] = numbs[i]; break;} if ( ((numbs[i] % smallest_color[j]) == 0)) {break;} }}System.out.println(count); } }
5	public class Main{ Scanner in ; static PrintWriter out ; static class Scanner{ StreamTokenizer in ; Scanner( InputStream is){ in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is))); in.resetSyntax(); in.whitespaceChars(0,32); in.wordChars(33,255); } String readLine(){ try{in.nextToken(); asserT((in.ttype == StreamTokenizer.TT_WORD)); return in.sval; }catch (IOException e){ throw (new Error());} } int nextInt(){ return Integer.parseInt(readLine());} } void solve(){ int n = in.nextInt();  long k = in.nextInt();  int ar[] = new int[n];  TreeMap<Integer,Integer> nums = new TreeMap<Integer,Integer>(); for ( int i = 0;(i < n);i++) {ar[i] = in.nextInt(); nums.put(ar[i],i); }if ( (k == 1)) {out.println(n); return ;} int next[] = new int[n]; Arrays.fill(next,-1); int count = 0; for ( int i = 0;(i < n);i++) { long val = (ar[i] * k);  int intVal = (int)val; if ( (intVal == val)) {if ( nums.containsKey(intVal)) { int idx = nums.get(intVal); next[i] = idx; continue;} } if ( ((ar[i] % k) == 0)) {intVal = (ar[i] / (int)k); if ( nums.containsKey(intVal)) {continue;} } count++; }for ( int i = 0;(i < n);i++) { int curr = nums.pollFirstEntry().getValue();  boolean odd = false; while((next[curr] != -1)){if ( !odd) {count++; } int to = next[curr]; next[curr] = -1; curr = to; odd = !odd; if ( (next[curr] == -1)) {if ( !odd) {count++; } } }}out.println(count); } static void asserT( boolean e){ if ( !e) {throw (new Error());} } public void run(){ in = new Scanner(System.in); out = new PrintWriter(System.out); try{solve(); }finally{out.close(); }} public static void main( String[] args){ new Main().run(); } }
4	public class Main{ 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 FileReader("input.txt")); out = new PrintWriter("output.txt"); } 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 Main().run(); } public static void mergeSort( int[] a){ mergeSort(a,0,(a.length - 1)); } static private 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); }} } static private 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++]); }}} static private 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); } } class Point{ double x ; double y ; Point( double x, double y){ this.x = x; this.y = y; } } public long gcd( long a, long b){ if ( ((a == 0) || (b == 0))) return max(a,b); if ( ((a % b) == 0)) return b; else return gcd(b,(a % b));} ArrayList<Integer> primes ; boolean[] isPrime ; public long binPowMod( long a, long b, long mod){ if ( (b == 0)) {return (1 % mod);} if ( ((b % 2) != 0)) {return (((a % mod) * (binPowMod(a,(b - 1),mod) % mod)) % mod);} else { long temp = (binPowMod(a,(b / 2),mod) % mod);  long ans = ((temp * temp) % mod); return ans;}} int type[] ; boolean vis[] ; HashMap<Integer,HashSet<Integer>> g ; int componentNum[] ; int p[] ; int find( int x){ if ( (x == p[x])) {return x;} return p[x] = find(p[x]);} boolean merge( int x, int y){ x = find(x); y = find(y); if ( (p[x] == p[y])) {return false;} p[y] = x; return true;} int s ; int n ; int m ; boolean isVisited[][] ; char[][] maze ; int[] dx = {0,0,-1,1}; int[] dy = {1,-1,0,0}; void dfs( int x, int y){ isVisited[x][y] = true; for ( int i = 0;(i < 4);i++) { int currX = (x + dx[i]);  int currY = (y + dy[i]); if ( ((maze[currX][currY] == '.') && !isVisited[currX][currY])) {dfs(currX,currY); } }} public void solve()throws IOException { n = readInt(); m = readInt(); maze = new char[(n + 2)][(m + 2)]; for ( int i = 0;(i < (n + 2));i++) {maze[i][0] = '#'; maze[i][(m + 1)] = '#'; }for ( int j = 0;(j < (m + 2));j++) {maze[0][j] = '#'; maze[(n + 1)][j] = '#'; }for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) {maze[i][j] = '.'; }} int[][] dist = new int[(n + 2)][(m + 2)]; for ( int i = 0;(i < (n + 2));i++) {for ( int j = 0;(j < (m + 2));j++) {dist[i][j] = Integer.MAX_VALUE; }} ArrayDeque<Integer> xValues = new ArrayDeque<Integer>();  ArrayDeque<Integer> yValues = new ArrayDeque<Integer>();  int k = readInt(); for ( int i = 0;(i < k);i++) { int currX = readInt();  int currY = readInt(); xValues.add(currX); yValues.add(currY); dist[currX][currY] = 0; }while(!xValues.isEmpty()){ int x = xValues.poll();  int y = yValues.poll(); for ( int i = 0;(i < 4);i++) { int currX = (x + dx[i]);  int currY = (y + dy[i]); if ( ((maze[currX][currY] == '.') && (dist[currX][currY] > (dist[x][y] + 1)))) {dist[currX][currY] = (dist[x][y] + 1); xValues.add(currX); yValues.add(currY); } }} int maxDist = 0;  int indexX = 0;  int indexY = 0; for ( int i = 1;(i <= n);i++) {for ( int j = 1;(j <= m);j++) {if ( (dist[i][j] >= maxDist)) {maxDist = dist[i][j]; indexX = i; indexY = j; } }}out.print(((indexX + " ") + indexY)); } }
4	public class Main{ static BufferedReader reader ; static StringTokenizer st ; static private void setReader(){ reader = new BufferedReader(new InputStreamReader(System.in)); } static private void updateST()throws IOException { if ( ((st == null) || !st.hasMoreElements())) st = new StringTokenizer(reader.readLine()); } static private 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); } }
1	public class B{ public static void main( String[] args)throws Exception { new B().solve(); } void solve()throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));  String[] sp = in.readLine().split(" ");  int n = Integer.parseInt(sp[0]);  int k = Integer.parseInt(sp[1]);  int[] a = new int[n]; sp = in.readLine().split(" "); for ( int i = 0;(i < n);i++) {a[i] = Integer.parseInt(sp[i]); } HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();  int r = 0; map.put(a[r],1); while((map.size() < k)){r++; if ( (r == n)) {System.out.println("-1 -1"); return ;} if ( map.containsKey(a[r])) {map.put(a[r],(map.get(a[r]) + 1)); } else {map.put(a[r],1); }} int l = 0; while((map.get(a[l]) > 1)){map.put(a[l],(map.get(a[l]) - 1)); l++; }System.out.println((((l + 1) + " ") + (r + 1))); } }
2	public class Solution{ static FastScanner fs = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); static int n ,d ; public static void main( String[] args)throws IOException { int tt = 1; while((tt-- > 0)){n = fs.nextInt(); int l = 1,r = (1 + (n / 2)); d = getB(l); if ( ((d % 2) != 0)) {out.println("! -1"); out.flush(); return ;} if ( (d == 0)) {out.println("! 1"); out.flush(); return ;} while((l < r)){ int mid = ((l + r) / 2); if ( check(mid)) {l = (mid + 1); } else {r = mid; } int f = 1; }out.println(("! " + l)); }out.close(); } static boolean check( int i){ int k = getB(i); if ( (sig(d) == sig(k))) {return true;} return false;} static int getB( int i){ out.println(("? " + i)); out.flush(); int x1 = fs.nextInt();  int j = (i + (n / 2)); if ( (j > n)) j -= n; out.println(("? " + j)); out.flush(); int x2 = fs.nextInt(); return (x1 - x2);} static int sig( int x){ if ( (x > 0)) return 1; else if ( (x < 0)) return -1; return 0;} static final Random random = new Random(); 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();} public int nextInt(){ return Integer.parseInt(next());} } }
4	public final class on_the_bench{ 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[] parent ,size ; static int maxn = (int)500; static long mod = (long)(1e9 + 7); static int[] fact ,inv_fact ; static int getParent( int u){ if ( (u == parent[u])) {return u;} else { int val = getParent(parent[u]); parent[u] = val; return val;}} static void merge( int u, int v){ int x = getParent(u),y = getParent(v); if ( (x != y)) {parent[y] = x; size[x] += size[y]; size[y] = 0; } } static int add( long a, long b){ long ret = (a + b); if ( (ret >= mod)) {ret %= mod; } return (int)ret;} static int mul( long a, long b){ long ret = (a * b); if ( (ret >= mod)) {ret %= mod; } return (int)ret;} static int pow( long a, long b){ long x = 1,y = a; while((b > 0)){if ( ((b % 2) == 1)) {x = mul(x,y); } y = mul(y,y); b = (b / 2); }return (int)(x % mod);} static void build(){ fact = new int[maxn]; inv_fact = new int[maxn]; fact[0] = 1; for ( int i = 1;(i < maxn);i++) {fact[i] = mul(fact[(i - 1)],i); }inv_fact[(maxn - 1)] = pow(fact[(maxn - 1)],(mod - 2)); for ( int i = (maxn - 2);(i >= 0);i--) {inv_fact[i] = mul(inv_fact[(i + 1)],(i + 1)); }} static int[] mul_poly( int[] a, int[] b, int deg1, int deg2){ int[] ret = new int[((deg1 + deg2) + 1)]; for ( int i = 0;(i <= deg1);i++) {for ( int j = 0;(j <= deg2);j++) { int curr = mul(a[i],b[j]); ret[(i + j)] = add(ret[(i + j)],curr); }}return ret;} static int C( int n, int r){ if ( (((n - r) < 0) || (Math.min(n,r) < 0))) {return 0;} int val1 = fact[n],val2 = inv_fact[r],val3 = inv_fact[(n - r)];  int mul = mul(val2,val3); return mul(val1,mul);} public static void main( String[] args)throws Exception { int n = sc.nextInt(); build(); int[] a = new int[n]; parent = new int[n]; size = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = sc.nextInt(); parent[i] = i; size[i] = 1; }for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) { long curr = ((a[i] * 1L) * a[j]),now = (long)Math.sqrt(curr); if ( ((now * now) == curr)) {merge(i,j); } }} List<Integer> list = new ArrayList<>(); for ( int i = 0;(i < n);i++) {if ( (getParent(i) == i)) {list.add(size[i]); } } int res = 0;  int[] poly = new int[1]; poly[0] = 1; for ( int i = 0;(i < list.size());i++) { int size = list.get(i);  int[] arr = new int[size]; arr[0] = 1; for ( int j = 1;(j < size);j++) { int now1 = C(size,j),now2 = mul(fact[(size - 1)],inv_fact[((size - 1) - j)]);  int qq = mul(now1,now2); arr[j] = qq; }poly = mul_poly(poly,arr,(poly.length - 1),(size - 1)); }for ( int i = 1,x = 1;(i < poly.length);i++,x *= -1) { int now = add(x,mod);  int curr = mul(fact[(n - i)],poly[i]); curr = mul(curr,now); res = add(res,curr); } int zz = mul(res,(mod - 1)); res = add(fact[n],zz); out.println(res); 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 int nextInt()throws Exception { return Integer.parseInt(nextToken());} }
2	public class Template implements Runnable{ BufferedReader in ; PrintWriter out ; StringTokenizer tok = new StringTokenizer(""); void init()throws FileNotFoundException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } String readString()throws IOException { while(!tok.hasMoreTokens()){try{tok = new StringTokenizer(in.readLine()," :"); }catch (Exception e){ return null;} }return tok.nextToken();} int readInt()throws IOException { return Integer.parseInt(readString());} public static void main( String[] args){ new Thread(null,new Template(),"",(((1l * 200) * 1024) * 1024)).start(); } long timeBegin ,timeEnd ; void time(){ timeEnd = System.currentTimeMillis(); System.err.println(("Time = " + (timeEnd - timeBegin))); } long memoryTotal ,memoryFree ; void memory(){ memoryFree = Runtime.getRuntime().freeMemory(); System.err.println((("Memory = " + ((memoryTotal - memoryFree) >> 10)) + " KB")); } int fx = -1; int sx = -1; int fy = -1; int sy = -1; int query( int x1, int y1, int x2, int y2)throws IOException { out.println(((((((("? " + x1) + " ") + y1) + " ") + x2) + " ") + y2)); out.flush(); int res = readInt(); if ( ((((fx >= x1) && (sx <= x2)) && (fy >= y1)) && (sy <= y2))) res--; return res;} int[] bs( int n)throws IOException { int l = 1;  int r = n;  int lx = 0,rx = 0,ly = 0,ry = 0; while((l <= r)){ int mid = ((l + r) >> 1); if ( (query(1,1,mid,n) > 0)) {rx = mid; r = (mid - 1); } else {l = (mid + 1); }}l = 1; r = rx; while((l <= r)){ int mid = ((l + r) >> 1); if ( (query(mid,1,rx,n) > 0)) {lx = mid; l = (mid + 1); } else {r = (mid - 1); }}l = 1; r = n; while((l <= r)){ int mid = ((l + r) >> 1); if ( (query(lx,mid,rx,n) > 0)) {ly = mid; l = (mid + 1); } else {r = (mid - 1); }}l = ly; r = n; while((l <= r)){ int mid = ((l + r) >> 1); if ( (query(lx,ly,rx,mid) > 0)) {ry = mid; r = (mid - 1); } else {l = (mid + 1); }}fx = lx; sx = rx; fy = ly; sy = ry; return new int[]{lx,ly,rx,ry};} void solve()throws IOException { int n = readInt();  int[] a = bs(n);  int[] b = bs(n); out.print("! "); for ( int i :a) out.print((i + " ")); for ( int i :b) out.print((i + " ")); } }
3	public class TaskA implements Runnable{ long m = ((int)1e9 + 7); PrintWriter w ; InputReader c ; public void sort( int[] arr){ int n = arr.length,mid ,h ,s ,l ,i ,j ,k ;  int[] res = new int[n]; for ( s = 1;(s < n);s <<= 1) {for ( l = 0;(l < (n - 1));l += (s << 1)) {h = min(((l + (s << 1)) - 1),(n - 1)); mid = min(((l + s) - 1),(n - 1)); i = l; j = (mid + 1); k = l; while(((i <= mid) && (j <= h)))res[k++] = ((arr[i] <= arr[j])?arr[i++]:arr[j++]); while((i <= mid))res[k++] = arr[i++]; while((j <= h))res[k++] = arr[j++]; for ( k = l;(k <= h);k++) arr[k] = res[k]; }}} static long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % b));} public int[] scanArrayI( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = c.nextInt(); return a;} 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 interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } public static void main( String[] args)throws Exception { new Thread(null,new TaskA(),"TaskA",(1 << 26)).start(); } }
3	public class Main{ PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next()throws IOException { if ( !tok.hasMoreTokens()) {tok = new StringTokenizer(in.readLine()); } return tok.nextToken();} int ni()throws IOException { return Integer.parseInt(next());} void solve()throws IOException { int n = ni();  int[] A = new int[n]; for ( int x = 0;(x < n);x++) A[x] = ni(); Arrays.sort(A); ArrayList<Integer> B = new ArrayList(); B.add(A[0]); int ans = 1; for ( int x = 1;(x < n);x++) {for ( int y = 0;(y < B.size());y++) {if ( ((A[x] % B.get(y)) == 0)) continue Outer; }ans++; B.add(A[x]); }System.out.println(ans); } public static void main( String[] args)throws IOException { new Main().solve(); } }
2	public class C3{ InputStream is ; PrintWriter out ; String INPUT = ""; void solve(){ long n = nl();  long S = nl();  long ret = Math.max(0,((n - S) + 1)); for ( long i = S;((i <= (S + 300)) && (i <= n));i++) { long b = i; for ( long x = i;(x > 0);x /= 10) {b -= (x % 10); }if ( (b < S)) ret--; }out.println(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 C3().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)); } }
1	public class b implements Runnable{ PrintWriter out = null; public int toint( String s){ int res = 0; for ( int i = 0;(i < s.length());i++) {res *= 10; res += (s.charAt(i) - '0'); }return res;} public void tostr( int k){ if ( (k == 0)) return ; tostr(((k - 1) / 26)); out.print((char)('A' + ((k - 1) % 26))); } public int fromstr( String s){ if ( (s.length() == 0)) return 0; int r = ((s.charAt((s.length() - 1)) - 'A') + 1); r += (26 * fromstr(s.substring(0,(s.length() - 1)))); return r;} public static void main( String[] args){ new Thread(new b()).start(); } }
5	public class Main{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt();  int a = input.nextInt();  int b = input.nextInt();  int x[] = new int[n]; for ( int i = 0;(i < n);i++) x[i] = input.nextInt(); Arrays.sort(x); int y[] = new int[n]; for ( int i = 0;(i < n);i++) y[i] = x[((n - i) - 1)]; System.out.println((y[(a - 1)] - y[a])); } }
4	public class Main{ public static class Task{ public class MinCostFlowBF{ List<Edge>[] graph ; class Edge{ int to ,f ,cap ,cost ,rev ; Edge( int v, int cap, int cost, int rev){ this.to = v; this.cap = cap; this.cost = cost; this.rev = rev; } } public MinCostFlowBF( int n){ graph = new List[n]; for ( int i = 0;(i < n);i++) graph[i] = new ArrayList<Edge>(); } public void addEdge( int s, int t, int cap, int cost){ graph[s].add(new Edge(t,cap,cost,graph[t].size())); graph[t].add(new Edge(s,0,-cost,(graph[s].size() - 1))); } void bellmanFord( int s, int[] dist, int[] prevnode, int[] prevedge, int[] curflow){ int n = graph.length; Arrays.fill(dist,0,n,Integer.MAX_VALUE); dist[s] = 0; curflow[s] = Integer.MAX_VALUE; boolean[] inqueue = new boolean[n];  int[] q = new int[n];  int qt = 0; q[qt++] = s; for ( int qh = 0;(((qh - qt) % n) != 0);qh++) { int u = q[(qh % n)]; inqueue[u] = false; for ( int i = 0;(i < graph[u].size());i++) { Edge e = graph[u].get(i); if ( (e.f >= e.cap)) continue; int v = e.to;  int ndist = (dist[u] + e.cost); if ( (dist[v] > ndist)) {dist[v] = ndist; prevnode[v] = u; prevedge[v] = i; curflow[v] = Math.min(curflow[u],(e.cap - e.f)); if ( !inqueue[v]) {inqueue[v] = true; q[(qt++ % n)] = v; } } }}} public int[] minCostFlow( int s, int t, int maxf){ int n = graph.length;  int[] dist = new int[n];  int[] curflow = new int[n];  int[] prevedge = new int[n];  int[] prevnode = new int[n];  int flow = 0;  int flowCost = 0; while((flow < maxf)){bellmanFord(s,dist,prevnode,prevedge,curflow); if ( (dist[t] == Integer.MAX_VALUE)) break; int df = Math.min(curflow[t],(maxf - flow)); flow += df; for ( int v = t;(v != s);v = prevnode[v]) { Edge e = graph[prevnode[v]].get(prevedge[v]); e.f += df; graph[v].get(e.rev).f -= df; flowCost += (df * e.cost); }}return new int[]{flow,flowCost};} } public void solve( Scanner sc, PrintWriter pw)throws IOException { int n = sc.nextInt();  int m = sc.nextInt();  int k = sc.nextInt();  int c = sc.nextInt();  int d = sc.nextInt();  int[] pos = new int[n]; for ( int i = 0;(i < k);i++) {pos[(sc.nextInt() - 1)]++; } int T = 100;  MinCostFlowBF mf = new MinCostFlowBF((((T + 1) * n) + 2)); for ( int i = 0;(i < n);i++) {if ( (pos[i] > 0)) mf.addEdge(0,(i + 1),pos[i],0); }for ( int i = 0;(i < T);i++) {for ( int j = 0;(j < n);j++) {mf.addEdge(((1 + (i * n)) + j),((1 + ((i + 1) * n)) + j),k,0); }}for ( int i = 0;(i <= T);i++) {for ( int j = 1;(j <= k);j++) {mf.addEdge((1 + (i * n)),(((T + 1) * n) + 1),1,(c * i)); }}for ( int i = 0;(i < m);i++) { int a = (sc.nextInt() - 1);  int b = (sc.nextInt() - 1); for ( int j = 0;(j < T);j++) { int cost = 0; for ( int l = 1;(l <= k);l++) {mf.addEdge(((1 + (j * n)) + a),((1 + ((j + 1) * n)) + b),1,(((l * l) * d) - cost)); mf.addEdge(((1 + (j * n)) + b),((1 + ((j + 1) * n)) + a),1,(((l * l) * d) - cost)); cost = ((l * l) * d); }}} int[] flowAndCost = mf.minCostFlow(0,(((T + 1) * n) + 1),k); System.err.println(flowAndCost[0]); pw.println(flowAndCost[1]); } } static long TIME_START ,TIME_END ; public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));  Runtime runtime = Runtime.getRuntime();  long usedMemoryBefore = (runtime.totalMemory() - runtime.freeMemory()); TIME_START = System.currentTimeMillis(); Task t = new Task(); t.solve(sc,pw); TIME_END = System.currentTimeMillis(); long usedMemoryAfter = (runtime.totalMemory() - runtime.freeMemory()); pw.close(); System.err.println(("Memory increased: " + ((usedMemoryAfter - usedMemoryBefore) / 1000000))); System.err.println((("Time used: " + (TIME_END - TIME_START)) + ".")); } 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();} } }
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){ int n = in.nextInt(); if ( ((n % 2) == 0)) {out.println(((4 + " ") + (n - 4))); } else {out.println(((9 + " ") + (n - 9))); }} } 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();} public int nextInt(){ return Integer.parseInt(next());} }
4	public class codeforces{ public static void main( String[] args)throws Exception { int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  int[] a = sc.nextIntArray(n);  LinkedList<Integer> ll = new LinkedList<Integer>(); for ( int i = 0;(i < n);i++) {if ( (a[i] == 1)) {ll.addLast(a[i]); } else if ( ll.isEmpty()) {ll.addLast(a[i]); } else {while((ll.getLast() == (a[i] - 1))){ll.removeLast(); }ll.removeLast(); ll.addLast(a[i]); } int ii = 0; for ( int j :ll) {pw.print(j); if ( (ii != (ll.size() - 1))) {pw.print('.'); } ii++; }pw.println(); }}pw.close(); } static class Scanner{ StringTokenizer st ; BufferedReader br ; public Scanner( InputStream s){ br = new BufferedReader(new InputStreamReader(s)); } public Scanner( FileReader r){ br = new BufferedReader(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 long nextLong()throws IOException { return Long.parseLong(next());} public int[] nextIntArray( int n)throws IOException { int[] a = new int[n]; for ( int i = 0;(i < n);i++) a[i] = nextInt(); return a;} public boolean ready()throws IOException { return br.ready();} } static long mod = 1000000007; static Random rn = new Random(); static Scanner sc = new Scanner(System.in); static PrintWriter pw = new PrintWriter(System.out); }
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; } } }
2	public class cf256b{ public static void main( String[] args){ Scanner in = new Scanner(System.in);  long n = in.nextLong();  long x = (in.nextLong() - 1);  long y = (in.nextLong() - 1);  long c = in.nextLong();  long lo = 0,hi = ((2 * n) + 10); while(((hi - lo) > 2)){ long mid = ((hi + lo) / 2); if ( (calc(n,x,y,mid) >= c)) hi = mid; else lo = mid; }while((calc(n,x,y,lo) < c))lo++; System.out.println(lo); } static long calc( long n, long x, long y, long t){ long ans = (((2 * t) * (t + 1)) + 1);  long top = Math.max(0,(t - x));  long bottom = Math.max(0,(t - ((n - 1) - x)));  long left = Math.max(0,(t - y));  long right = Math.max(0,(t - ((n - 1) - y))); ans -= ((((top * top) + (bottom * bottom)) + (left * left)) + (right * right)); long tl = Math.max(0,(t - ((x + y) + 1)));  long tr = Math.max(0,(t - ((x + ((n - 1) - y)) + 1)));  long bl = Math.max(0,(t - ((((n - 1) - x) + y) + 1)));  long br = Math.max(0,(t - ((((n - 1) - x) + ((n - 1) - y)) + 1))); ans += ((((((tl * tl) + tl) / 2) + (((tr * tr) + tr) / 2)) + (((bl * bl) + bl) / 2)) + (((br * br) + br) / 2)); return 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 = 350;  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());} } }
3	public class Main1{ 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 s = new Reader();  int n = s.nextInt(),i ,j ,ans = 0;  int[] a = new int[101]; for ( i = 0;(i < n);i++) {a[s.nextInt()]++; }for ( i = 1;(i <= 100);i++) {if ( (a[i] > 0)) {ans++; for ( j = i;(j <= 100);j++) {if ( ((j % i) == 0)) {a[j] = 0; } }} }System.out.println(ans); } }
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 ,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_]; uu = new int[m_]; vv = new int[m_]; uv = new int[m_]; cost = 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)); } boolean dijkstra( int s, int t){ Arrays.fill(pi,INF); pi[s] = 0; TreeSet<Integer> pq = new TreeSet<>((u,v)->((pi[u] != pi[v])?(pi[u] - pi[v]):((dd[u] != dd[v])?(dd[u] - dd[v]):(u - v)))); pq.add(s); Integer first ; while(((first = pq.pollFirst()) != null)){ int u = first;  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)))) {if ( (pi[v] != INF)) pq.remove(v); pi[v] = p; dd[v] = d; bb[v] = h_; pq.add(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){ cost_ = Arrays.copyOf(cost,m_); while(dijkstra(s,t)){push1(s,t); for ( int h = 0;(h < m_);h++) { int u = uu[h],v = vv[h]; if ( ((pi[u] != INF) && (pi[v] != INF))) cost_[h] += (pi[u] - pi[v]); }} 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 codeforces{ static int count = 0; static boolean f = false; static int[] arr ; static PrintWriter pw = new PrintWriter(System.out); static void solve( int index, int mask){ if ( (index == arr.length)) { int sum1 = 0;  int sum2 = 0; for ( int i = 0;(i < arr.length);i++) {if ( ((mask & (1 << i)) != 0)) sum1 += arr[i]; }return ;} solve((index + 1),(mask | (1 << index))); solve((index + 1),mask); } public static void main( String[] args)throws IOException,InterruptedException { Scanner sc = new Scanner(System.in);  int x = sc.nextInt();  int y = sc.nextInt();  pair[] arr = new pair[x]; for ( int i = 0;(i < x);i++) arr[i] = new pair(i,sc.nextInt(),0); for ( int i = 0;(i < x);i++) arr[i].y = sc.nextInt(); Arrays.sort(arr); PriorityQueue<Integer> qq = new PriorityQueue<>();  Long[] list = new Long[x];  long sum = 0; for ( int i = 0;(i < x);i++) { pair w = arr[i]; if ( (qq.size() < y)) {qq.add(w.y); sum += w.y; list[w.i] = sum; } else if ( !qq.isEmpty()) {sum += w.y; list[w.i] = sum; int first = qq.poll(); if ( (w.y > first)) {sum -= first; qq.add(w.y); } else {qq.add(first); sum -= w.y; }} else list[w.i] = (long)w.y; }for ( Long w :list) pw.print((w + " ")); pw.flush(); pw.close(); } static class pair implements Comparable<pair>{ String name ; int x ,y ,i ; public pair( String name, int x){ this.name = name; this.x = x; } public pair( int i, int x, int y){ this.i = i; this.x = x; this.y = y; } public int compareTo( pair o){ return (x - o.x);} } 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();} } }
3	public class New_Year_and_Curling{ static final double E = 0.00001; public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int n = sc.nextInt();  int r = sc.nextInt();  double[] y = new double[n];  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = sc.nextInt(); double top = r;  int x = arr[i]; for ( int j = 0;(j < i);j++) {if ( (Math.abs((arr[j] - x)) <= (2 * r))) {top = Math.max(top,(y[j] + Math.sqrt((((4 * r) * r) - ((arr[j] - x) * (arr[j] - x)))))); } }y[i] = top; double res = y[i]; System.out.print((res + " ")); }} }
3	public class first{ 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 < a.length);i++) {a[i] = s.nextInt(); }Arrays.sort(a); int count = 0; for ( int i = 0;(i < a.length);i++) {if ( (a[i] != 0)) { int x = a[i]; count++; for ( int j = i;(j < a.length);j++) {if ( ((a[j] % x) == 0)) {a[j] = 0; } }} }System.out.println(count); } }
5	public class LittleElephant{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  int n = input.nextInt();  int temp ;  ArrayList<Integer> a2 = new ArrayList<Integer>();  ArrayList<Integer> a1 = new ArrayList<Integer>();  int count = 0;  int temp1 ,temp2 ; for ( int i = 0;(i < n);i++) {temp = input.nextInt(); a2.add(temp); a1.add(temp); }Collections.sort(a2); input.close(); for ( int i = 0;(i < n);i++) {temp1 = a2.get(i); temp2 = a1.get(i); if ( (temp1 != temp2)) {count++; } }if ( ((count == 2) || (count == 0))) {System.out.println("YES"); } else {System.out.println("NO"); }} }
1	public class codef8{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  int num = sc.nextInt();  int beacon[] = new int[1000001];  int pos[] = new int[num]; for ( int i = 0;(i < num);i++) { int position = sc.nextInt(); beacon[position] = sc.nextInt(); pos[i] = position; } int dp[] = new int[1000001];  int max = 0; if ( (beacon[0] != 0)) dp[0] = 1; for ( int i = 1;(i <= 1000000);i++) {if ( (beacon[i] == 0)) {dp[i] = dp[(i - 1)]; } else { int j = ((i - beacon[i]) - 1); if ( (j < 0)) {dp[i] = 1; } else {dp[i] = (dp[j] + 1); }}max = Math.max(max,dp[i]); }System.out.println((num - max)); } }
5	public class P113A{ public static void main( String[] args){ Scanner sc = new Scanner(System.in);  PrintStream out = System.out;  int n = sc.nextInt();  int k = sc.nextInt();  List<Team> l = new ArrayList<Team>(); for ( int i = 0;(i < n);i++) {l.add(new Team(sc.nextInt(),sc.nextInt())); }Collections.sort(l,new Comparator<Team>(){}); int f = (k - 1);  int la = (k - 1);  Team p = l.get((k - 1)); while((((la < n) && (l.get(la).s == p.s)) && (l.get(la).t == p.t)))la++; while((((f >= 0) && (l.get(f).s == p.s)) && (l.get(f).t == p.t)))f--; out.println(((la - f) - 1)); } static class Team{ int s ; int t ; public Team( int a, int b){ s = a; t = b; } } }
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 InputReader scan ; static int ni()throws IOException { return scan.nextInt();} static double nd()throws IOException { return scan.nextDouble();} static void pl()throws IOException { pw.println(); } static void pl( Object o)throws IOException { pw.println(o); } static void p( Object o)throws IOException { pw.print((o + " ")); } 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 InputReader(System.in); pw = new PrintWriter(System.out,true); StringBuilder sb = new StringBuilder();  int n = ni();  double r = ni();  double x[] = new double[n]; for ( int i = 0;(i < n);++i) x[i] = nd(); double y[] = new double[n]; y[0] = r; for ( int i = 1;(i < n);++i) { double max = -1; for ( int j = 0;(j < i);++j) { double xx = (((4 * r) * r) - ((x[i] - x[j]) * (x[i] - x[j]))); if ( (xx >= 0)) max = max(max,(sqrt(xx) + y[j])); }if ( (max == -1)) max = r; y[i] = max; }for ( int i = 0;(i < n);++i) p(y[i]); pl(); Calendar CAL2 = Calendar.getInstance(); CAL2.setTime(new Date()); double Execution_Time = ((double)(CAL2.getTimeInMillis() - CAL1.getTimeInMillis()) / 1000.000); pw.flush(); pw.close(); } 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 String nextLine(){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  String str = ""; try{str = br.readLine(); }catch (IOException e){ e.printStackTrace(); } return str;} 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 double nextDouble(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } double res = 0; while((!isSpaceChar(c) && (c != '.'))){if ( ((c == 'e') || (c == 'E'))) return (res * Math.pow(10,nextInt())); if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }if ( (c == '.')) {c = read(); double m = 1; while(!isSpaceChar(c)){if ( ((c == 'e') || (c == 'E'))) return (res * Math.pow(10,nextInt())); if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); m /= 10; res += ((c - '0') * m); c = read(); }} 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); } } }
4	public class EG14{ public static long MOD ; public static int MAX = 405; public static long[] fac ; public static long[] ifac ; public static void main( String[] args)throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in));  PrintWriter out = new PrintWriter(System.out);  StringTokenizer st = new StringTokenizer(f.readLine());  int n = Integer.parseInt(st.nextToken()); MOD = Long.parseLong(st.nextToken()); long[] pow2 = new long[MAX]; pow2[0] = 1L; for ( int k = 1;(k < MAX);k++) {pow2[k] = (((2L * pow2[(k - 1)]) + MOD) % MOD); }fac = new long[MAX]; ifac = new long[MAX]; fac[0] = 1L; ifac[0] = 1L; for ( int k = 1;(k < MAX);k++) {fac[k] = ((((long)k * fac[(k - 1)]) + MOD) % MOD); ifac[k] = modInverse(fac[k],MOD); } long[][] dp = new long[n][(n + 1)]; for ( int k = 0;(k < n);k++) {dp[k][(k + 1)] = pow2[k]; }for ( int k = 2;(k < n);k++) {for ( int j = 1;(j <= n);j++) {if ( (dp[(k - 2)][(j - 1)] == 0)) continue; long start = dp[(k - 2)][(j - 1)]; for ( int add = 1;;add++) {if ( ((((k + add) - 1) >= n) || (((j + add) - 1) > n))) break; long adder = (((start * pow2[(add - 1)]) + MOD) % MOD); adder = (((adder * choose(((j + add) - 1),(j - 1))) + MOD) % MOD); dp[((k + add) - 1)][((j + add) - 1)] = (((dp[((k + add) - 1)][((j + add) - 1)] + adder) + MOD) % MOD); }}} long answer = 0L; for ( int k = 1;(k <= n);k++) {answer = (((answer + dp[(n - 1)][k]) + MOD) % MOD); }out.println(answer); out.close(); } public static long choose( int a, int b){ long prod = (((fac[a] * ifac[b]) + MOD) % MOD); return (((prod * ifac[(a - b)]) + MOD) % MOD);} public static long modInverse( long a, long m){ long m0 = m;  long y = 0L;  long x = 1L; if ( (m == 1L)) return 0L; while((a > 1L)){ long q = (a / m);  long t = m; m = (a % m); a = t; t = y; y = (x - (q * y)); x = t; }if ( (x < 0L)) x += m0; return x;} }
4	public class FireAgain{ Point coordinate ; Queue<Point> q = new LinkedList<Point>(); int m ,n ; boolean[][] arr ; PrintStream out ; void bfs( Point start){ while(!q.isEmpty()){ Point front = q.poll();  Point p = new Point(); p.x = (front.x - 1); p.y = front.y; if ( ((((p.x >= 1) && (p.x <= n)) && (p.y <= m)) && (p.y >= 1))) {if ( !arr[p.x][p.y]) {arr[p.x][p.y] = true; q.add(p); } } p = new Point(); p.x = (front.x + 1); p.y = front.y; if ( ((((p.x >= 1) && (p.x <= n)) && (p.y <= m)) && (p.y >= 1))) if ( !arr[p.x][p.y]) {arr[p.x][p.y] = true; q.add(p); } p = new Point(); p.x = front.x; p.y = (front.y + 1); if ( ((((p.x >= 1) && (p.x <= n)) && (p.y <= m)) && (p.y >= 1))) if ( !arr[p.x][p.y]) {arr[p.x][p.y] = true; q.add(p); } p = new Point(); p.x = front.x; p.y = (front.y - 1); if ( ((((p.x >= 1) && (p.x <= n)) && (p.y <= m)) && (p.y >= 1))) if ( !arr[p.x][p.y]) {arr[p.x][p.y] = true; q.add(p); } if ( (q.size() == 0)) out.print(((front.x + " ") + front.y)); }} public static void main( String[] args)throws FileNotFoundException { FireAgain fa = new FireAgain();  Scanner Scan = new Scanner(new FileInputStream("input.txt")); fa.out = new PrintStream(new File("output.txt")); fa.n = Scan.nextInt(); fa.m = Scan.nextInt(); int k = Scan.nextInt(); fa.arr = new boolean[2001][2001]; for ( int i = 0;(i < k);i++) {fa.coordinate = new Point(); fa.coordinate.x = Scan.nextInt(); fa.coordinate.y = Scan.nextInt(); fa.q.add(fa.coordinate); fa.arr[fa.coordinate.x][fa.coordinate.y] = true; }fa.bfs(fa.q.peek()); } }
4	public class B{ public static void main( String[] args)throws IOException { Reader scan = new Reader();  int t = scan.nextInt(); for ( int tt = 0;(tt < t);tt++) { int n = scan.nextInt();  int arr[] = new int[n]; for ( int i = 0;(i < n);i++) arr[i] = scan.nextInt(); List<Integer> list = new ArrayList<>();  int j = -1;  StringBuilder s = new StringBuilder(); for ( int i = 0;(i < n);i++) {if ( (list.isEmpty() || (arr[i] == 1))) {list.add(arr[i]); j++; } else if ( (arr[i] == (list.get(j) + 1))) {list.set(j,arr[i]); } else {for ( int k = j;(k >= 0);k--) {if ( (arr[i] == (list.get(k) + 1))) {list.set(k,arr[i]); break;} else {list.remove(k); j--; }}}s.delete(0,s.length()); for ( Integer p :list) {s.append((p + ".")); }s.deleteCharAt((s.length() - 1)); System.out.println(s.toString()); }}scan.close(); } 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(); } } }
4	public class Main{ public static void main( String[] args)throws IOException { InputReader in = new InputReader(new FileReader(new File("input.txt")));  PrintWriter out = new PrintWriter(new FileWriter(new File("output.txt")));  Solution s = new Solution(); s.solve(1,in,out); out.close(); } static class Solution{ double EPS = 0.0000001; public void solve( int cs, InputReader in, PrintWriter out){ int n = in.nextInt(),m = in.nextInt();  Graph g = new Graph(n,m);  int k = in.nextInt(); for ( int[] v :g.vis) Arrays.fill(v,-1); while((k-- > 0)){ Pair start = new Pair((in.nextInt() - 1),(in.nextInt() - 1)); g.bfs(start); } int idx1 = 0,idx2 = 0,max = 0; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);++j) {if ( (g.vis[i][j] > max)) {idx1 = i; idx2 = j; max = g.vis[i][j]; } }}out.println((((idx1 + 1) + " ") + (idx2 + 1))); } static class Pair{ int x ,y ; public Pair( int x, int y){ this.x = x; this.y = y; } } static class Graph{ LinkedList<Integer> adj[] ; int n ,e ; int[][] vis ; public Graph( int n, int e){ this.n = n; this.e = e; adj = new LinkedList[n]; for ( int i = 0;(i < n);++i) adj[i] = new LinkedList<>(); vis = new int[n][e]; } int[] dx = {0,0,1,-1}; int[] dy = {1,-1,0,0}; void bfs( Pair src){ Queue<Pair> q = new LinkedList<>(); vis[src.x][src.y] = 0; q.add(src); while(!q.isEmpty()){ Pair p = q.poll(); for ( int k = 0;(k < 4);k++) { int ni = (p.x + dx[k]);  int nj = (p.y + dy[k]); if ( (isValid(ni,nj) && ((vis[ni][nj] == -1) || ((vis[p.x][p.y] + 1) < vis[ni][nj])))) {vis[ni][nj] = (vis[p.x][p.y] + 1); q.add(new Pair(ni,nj)); } }}} boolean isValid( int i, int j){ return ((((i >= 0) && (i < n)) && (j >= 0)) && (j < e));} } } static class InputReader{ BufferedReader br ; StringTokenizer st ; public InputReader( InputStream i){ br = new BufferedReader(new InputStreamReader(i),32768); st = null; } public InputReader( FileReader s){ br = new BufferedReader(s); 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 int nextInt(){ return Integer.parseInt(next());} } }
5	public class c{ class IO{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer st ; Random rnd = new Random(); 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());} } void run()throws IOException { IO read = new IO();  int n = read.nextInt();  int a[] = new int[n],b[] = new int[n]; for ( int i = 0;(i < n);i++) a[i] = b[i] = read.nextInt(); Arrays.sort(b); int cnt = 0; for ( int i = 0;(i < n);i++) if ( (a[i] != b[i])) cnt++; if ( ((cnt == 0) || (cnt == 2))) read.out.println("YES"); else read.out.println("NO"); read.out.close(); } public static void main( String[] args)throws IOException { new c().run(); } }
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(); } }
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());} } }
0	public class Main2{ public static void main( String[] args){ Scanner input = new Scanner(System.in);  String st = input.nextLine(); System.out.println(bank(st)); } public static int bank( String st){ StringBuilder sb = new StringBuilder(st);  int st1 = Integer.parseInt((sb.substring(0,(st.length() - 2)) + sb.substring((st.length() - 1),st.length())));  int st2 = Integer.parseInt(sb.substring(0,(st.length() - 1)));  int st3 = Integer.parseInt(st); return Math.max(st3,Math.max(st1,st2));} }
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){ if ( (idx == n)) return ((((remSum == 0) && (remCnt1 == 0)) && (remCnt2 == 0))?1:0); if ( (((remSum < 0) || (remCnt1 < 0)) || (remCnt2 < 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 ( (g[idx] == 1)) ans += dp2((idx + 1),(remCnt1 - 1),remCnt2,(remSum - t[idx])); else if ( (g[idx] == 2)) ans += dp2((idx + 1),remCnt1,(remCnt2 - 1),(remSum - t[idx])); if ( (ans >= MOD)) ans -= MOD; return memo2[idx][remCnt1][remCnt2][remSum] = ans;} static private 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();} } }
1	public class B{ public static void main( String[] args)throws IOException { new B().solve(); } void solve()throws IOException { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); int n = Integer.parseInt(in.readLine()); while((n-- > 0)){ String s = in.readLine();  int pr = s.indexOf('R');  int pc = s.indexOf('C'); if ( (((pr == 0) && (pc > 1)) && Character.isDigit(s.charAt(1)))) { int r = Integer.parseInt(s.substring(1,pc));  int c = Integer.parseInt(s.substring((pc + 1),s.length())); out.println((i2s(c) + r)); } else { int i = 0; while(!Character.isDigit(s.charAt(i)))++i; out.println(((("R" + Integer.parseInt(s.substring(i,s.length()))) + "C") + s2i(s.substring(0,i)))); }}out.close(); } int s2i( String s){ int r = 0; for ( int i = 0;(i < s.length());++i) {r = ((r * 26) + ((s.charAt(i) - 'A') + 1)); }return r;} String i2s( int i){ StringBuffer s = new StringBuffer(); while((i > 0)){i -= 1; s.append((char)('A' + (i % 26))); i /= 26; }return s.reverse().toString();} BufferedReader in ; PrintWriter out ; }
3	public class C{ static double ycoord( double xi, double yi, double xj, double r){ if ( (Math.abs((xi - xj)) > (2 * r))) return r; double dist = Math.sqrt((((4 * r) * r) - ((xi - xj) * (xi - xj)))); return Math.max((yi + dist),r);} public static void main( String[] args)throws Exception { FastScanner sc = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int n = sc.nextInt();  double r = sc.nextInt();  double[] xcoords = new double[n];  double[] ycoords = new double[n]; Arrays.fill(ycoords,Integer.MIN_VALUE); ycoords[0] = r; for ( int i = 0;(i < n);i++) {xcoords[i] = sc.nextDouble(); }System.out.print((r + " ")); for ( int i = 1;(i < n);++i) {for ( int j = 0;(j < i);j++) {ycoords[i] = Math.max(ycoord(xcoords[j],ycoords[j],xcoords[i],r),ycoords[i]); }System.out.print((ycoords[i] + " ")); }out.flush(); } static class FastScanner{ public BufferedReader reader ; public StringTokenizer tokenizer ; public FastScanner(){ 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 double nextDouble(){ return Double.parseDouble(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.nextInt();  int[] a = in.nextIntArray(n);  int[] b = a.clone(); ArrayUtils.safeSort(b); int diff = 0; for ( int i = 0;(i < n);i++) {if ( (a[i] != b[i])) diff++; }out.println(((diff <= 2)?"YES":"NO")); } } 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 println( String x){ writer.println(x); } public void close(){ writer.close(); } }
5	public class Main{ public static void main( String[] args)throws Exception { Scanner in = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int testCases = 1;  Task solver = new Task(); for ( int i = 1;(i <= testCases);++i) solver.solve(in,out); out.close(); } } class Task{ public void solve( Scanner in, PrintWriter out){ int n = in.nextInt();  int a = in.nextInt();  int b = in.nextInt();  int[] complexity = new int[n]; for ( int i = 0;(i < n);++i) complexity[i] = in.nextInt(); Arrays.sort(complexity); out.println((complexity[b] - complexity[(b - 1)])); } }
1	public class B{ 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());} long nextLong(){ return Long.parseLong(next());} } static FastReader s = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static private int ri(){ return s.nextInt();} static private long rl(){ return s.nextLong();} 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));} public static void main( String[] args){ StringBuilder ans = new StringBuilder();  int t = ri(); while((t-- > 0)){ long n = rl(); if ( ((n % 2) == 1)) {ans.append("NO\n"); continue;} if ( ((n % 4) == 0)) { long val = (n / 4);  long sq = (long)Math.sqrt(val); if ( ((sq * sq) == val)) {ans.append("YES\n"); continue;} } if ( ((n % 2) == 0)) { long val = (n / 2);  long sq = (long)Math.sqrt(val); if ( ((sq * sq) == val)) {ans.append("YES\n"); continue;} } ans.append("NO\n"); }out.print(ans.toString()); out.flush(); } }
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); } } }
1	public class TaskA implements Runnable{ private InputReader in ; private PrintWriter out ; public static void main( String[] args){ new Thread(new TaskA()).start(); } public TaskA(){ in = new InputReader(System.in); out = new PrintWriter(System.out); } static private 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);} 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))){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();} } }
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)); } static private 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);} }
4	public class D{ BufferedReader reader ; StringTokenizer tokenizer ; PrintWriter out ; public void solve()throws IOException { int N = nextInt();  int M = nextInt();  boolean[][] graph = new boolean[N][N]; for ( int i = 0;(i < M);i++) {graph[(nextInt() - 1)][(nextInt() - 1)] = true; } int best = Integer.MAX_VALUE; for ( int c = 0;(c < N);c++) { int withC = 0; for ( int i = 0;(i < N);i++) {if ( (i == c)) {if ( graph[c][i]) withC++; } else {if ( graph[c][i]) withC++; if ( graph[i][c]) withC++; }} int notC = (M - withC);  List<Integer>[] g = new List[N]; for ( int i = 0;(i < N);i++) {g[i] = new ArrayList<Integer>(); }for ( int i = 0;(i < N);i++) {if ( (i == c)) continue; for ( int j = 0;(j < N);j++) {if ( (j == c)) continue; if ( !graph[i][j]) continue; g[i].add(j); }} int glen = maxMatching(g,N);  int need = (((((2 * N) - 1) - withC) + (notC - glen)) + ((N - 1) - glen)); best = Math.min(best,need); }out.println(best); } static boolean findPath( List<Integer>[] g, int u1, int[] matching, boolean[] vis){ vis[u1] = true; for ( int v :g[u1]) { int u2 = matching[v]; if ( ((u2 == -1) || (!vis[u2] && findPath(g,u2,matching,vis)))) {matching[v] = u1; return true;} }return false;} public static int maxMatching( List<Integer>[] g, int n2){ int n1 = g.length;  int[] matching = new int[n2]; Arrays.fill(matching,-1); int matches = 0; for ( int u = 0;(u < n1);u++) {if ( findPath(g,u,matching,new boolean[n1])) ++matches; }return matches;} public static void main( String[] args){ new D().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();} }
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);  BObtainingTheString solver = new BObtainingTheString(); solver.solve(1,in,out); out.close(); } static class BObtainingTheString{ public void solve( int testNumber, FastScanner br, PrintWriter pw){ int n = br.nextInt();  String s = br.nextString();  String t = br.nextString();  char[] sarr = new char[n];  char[] tarr = new char[n];  int[] sAppear = new int[26];  int[] tAppear = new int[26]; for ( int i = 0;(i < s.length());i++) {sarr[i] = s.charAt(i); tarr[i] = t.charAt(i); sAppear[(s.charAt(i) - 'a')]++; tAppear[(t.charAt(i) - 'a')]++; }for ( int i = 0;(i < 26);i++) {if ( (sAppear[i] != tAppear[i])) {pw.println(-1); pw.close(); } } ArrayList<Integer> ans = new ArrayList<Integer>(); for ( int i = 0;(i < n);i++) { char curr = tarr[i]; for ( int j = (i + 1);(j < n);j++) {if ( (sarr[j] == curr)) {for ( int k = j;(k > i);k--) {ans.add(k); char temp = sarr[(k - 1)]; sarr[(k - 1)] = sarr[k]; sarr[k] = temp; }break;} }}pw.println(ans.size()); for ( int e :ans) {pw.print((e + " ")); }pw.close(); } } static class FastScanner{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private FastScanner.SpaceCharFilter filter ; public FastScanner( 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); } } }
1	public class Solution{ Scanner in ; PrintWriter out ; boolean isPrime( int x){ for ( int i = 2;((i * i) <= x);++i) {if ( ((x % i) == 0)) {return false;} }return true;} void solve()throws IOException { in = new Scanner(System.in); out = new PrintWriter(System.out); int N = in.nextInt();  int K = in.nextInt();  List<Integer> primes = new ArrayList<Integer>(); for ( int i = 2;(i <= N);++i) {if ( isPrime(i)) {primes.add(i); } } int c = 0; for ( int i = 2;(i <= N);++i) {if ( !isPrime(i)) continue; for ( int j = 0;((j + 1) < primes.size());++j) { int p1 = primes.get(j);  int p2 = primes.get((j + 1)); if ( (((p1 + p2) + 1) == i)) {++c; break;} }}if ( (c >= K)) out.println("YES"); else out.println("NO"); out.close(); } public static void main( String[] args)throws IOException { new Solution().solve(); } }
4	public class 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());} long nextLong(){ return Long.parseLong(next());} } static FastReader s = new FastReader(); static PrintWriter out = new PrintWriter(System.out); static private int[] rai( int n){ int[] arr = new int[n]; for ( int i = 0;(i < n);i++) {arr[i] = s.nextInt(); }return arr;} static private int[][] rai( int n, int m){ int[][] arr = new int[n][m]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {arr[i][j] = s.nextInt(); }}return arr;} static private int ri(){ return s.nextInt();} static long gcd( long a, long b){ if ( (b == 0)) {return a;} return gcd(b,(a % b));} static int gcd( int a, int b){ if ( (b == 0)) {return a;} return gcd(b,(a % b));} static int MOD = 1000000007; public static void main( String[] args){ StringBuilder ans = new StringBuilder();  int t = ri(); while((t-- > 0)){ int n = ri();  int[] arr = rai(n);  List<Integer> list = new ArrayList<>(); for ( int i :arr) {if ( (i == 1)) {list.add(i); } else { int ind = (list.size() - 1); while(((list.size() > 0) && ((list.get(ind) + 1) != i))){list.remove((list.size() - 1)); ind = (list.size() - 1); }if ( (list.size() > 0)) {list.remove((list.size() - 1)); } list.add(i); }for ( int j = 0;(j < (list.size() - 1));j++) {ans.append(list.get(j)).append("."); }ans.append(list.get((list.size() - 1))).append("\n"); }}out.print(ans.toString()); out.flush(); } }
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 _G14{ public static void main( String[] args){ MyScanner sc = new MyScanner();  PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));  int t = 1; while((t-- > 0)){ int n = sc.nextInt(); mod = sc.nextLong(); long res = 0; initFac((n + 7)); long[] tpow = new long[(n + 7)];  long[][] combo = new long[(n + 6)][(n + 6)]; for ( int i = 0;(i <= n);i++) {for ( int j = 0;(j <= i);j++) {if ( ((j == 0) || (j == i))) combo[i][j] = 1; else combo[i][j] = ((combo[(i - 1)][(j - 1)] + combo[(i - 1)][j]) % mod); }}tpow[0] = 1; for ( int i = 1;(i <= (n + 6));i++) tpow[i] = ((tpow[(i - 1)] * 2) % mod); long[][] dp = new long[(n + 1)][(n + 1)]; for ( int i = 1;(i <= n);i++) dp[i][0] = tpow[(i - 1)]; for ( int i = 3;(i <= n);i++) {for ( int auto = 1;(auto <= (n / 2));auto++) {if ( !check(i,auto)) continue; long total = 0; for ( int j = (i - 2);(j >= 1);j--) {if ( !check(j,(auto - 1))) break; int len = ((i - j) - 1);  long ways = tpow[(len - 1)];  int picked = (j - (auto - 1));  long interleave = combo[(len + picked)][picked]; ways = ((ways * interleave) % mod); ways = ((ways * dp[j][(auto - 1)]) % mod); total = ((total + ways) % mod); }dp[i][auto] = total; if ( (i == n)) res = ((res + dp[i][auto]) % mod); }}res = ((res + dp[n][0]) % mod); out.println(res); }out.close(); } static boolean check( int n, int auto){ int rem = (n - auto);  int seg = (auto + 1); return (rem >= seg);} static long[] fac ; static long mod ; static void initFac( long n){ fac = new long[((int)n + 1)]; fac[0] = 1; for ( int i = 1;(i <= n);i++) {fac[i] = ((fac[(i - 1)] * i) % mod); }} static long pow( long b, long e){ long ans = 1; while((e > 0)){if ( ((e % 2) == 1)) ans = ((ans * b) % mod); e >>= 1; b = ((b * b) % mod); }return ans;} static long inv( long x){ return pow(x,(mod - 2));} 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());} long nextLong(){ return Long.parseLong(next());} } }
2	public class Test{ public static int digit( long number){ int i = 1;  long exp = 1; while((number > ((i * 9) * exp))){number -= ((i * 9) * exp); i++; exp *= 10; }return i;} public static int result( long number){ int digit = digit(number);  long exp = 1; for ( int i = 0;(i < (digit - 1));i++) {number -= (((i + 1) * 9) * exp); exp *= 10; } long b = (number / digit);  int c = (int)(number % digit); if ( (c > 0)) { String d = Long.toString((exp + b)); return (d.charAt((c - 1)) - '0');} else { String d = Long.toString(((exp + b) - 1)); return (d.charAt((d.length() - 1)) - '0');}} public static void main( String[] args){ Scanner input = new Scanner(System.in);  long k = input.nextLong(); System.out.println(result(k)); } }
4	public class Main{ void solve(){ int R = sc.nextInt();  int C = sc.nextInt();  int K = sc.nextInt();  int[] x = new int[K];  int[] y = new int[K]; for ( int i = 0;(i < K);i++) {x[i] = sc.nextInt(); y[i] = sc.nextInt(); } int best = -1;  int bestX = 0;  int bestY = 0; for ( int r = 1;(r <= R);r++) for ( int c = 1;(c <= C);c++) { int here = (R + C); for ( int i = 0;(i < K);i++) { int t = (abs((r - x[i])) + abs((c - y[i]))); here = min(here,t); }if ( (best < here)) {best = here; bestX = r; bestY = c; } }out.println(((bestX + " ") + bestY)); } void print( int[] a){ out.print(a[0]); for ( int i = 1;(i < a.length);i++) out.print((" " + a[i])); out.println(); } public static void main( String[] args)throws Exception { new Main().run(); } MyScanner sc = null; PrintWriter out = null; public void run()throws Exception { sc = new MyScanner(new FileInputStream(new File("input.txt"))); out = new PrintWriter(new File("output.txt")); for ( ;sc.hasNext();) {solve(); out.flush(); }out.close(); } class MyScanner{ String line ; BufferedReader reader ; StringTokenizer tokenizer ; public MyScanner( InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public void eat(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){try{line = reader.readLine(); if ( (line == null)) {tokenizer = null; return ;} tokenizer = new StringTokenizer(line); }catch (IOException e){ throw (new RuntimeException(e));} }} public String next(){ eat(); return tokenizer.nextToken();} public boolean hasNext(){ eat(); return ((tokenizer != null) && tokenizer.hasMoreElements());} public int nextInt(){ return Integer.parseInt(next());} } }
4	public class EdE{ static long[] mods = {1000000007,998244353,1000000009}; static long mod = mods[0]; public static MyScanner sc ; public static PrintWriter out ; static ArrayList<Integer> primes ; public static void main( String[] omkar)throws Exception { sc = new MyScanner(); out = new PrintWriter(System.out); int t = sc.nextInt(); primes = new ArrayList<>(); prime(3165); int[] freq = new int[10000001]; while((t-- > 0)){ int n = sc.nextInt();  int k = sc.nextInt();  int[] arr = readArrayInt(n); for ( int j = 0;(j < n);j++) {arr[j] = factorize(arr[j]); } int[][] left = new int[n][(k + 1)]; for ( int m = 0;(m <= k);m++) { int l = 0;  int count = 0; for ( int i = 0;(i < n);i++) {if ( (freq[arr[i]] > 0)) {count++; } freq[arr[i]]++; while((count > m)){freq[arr[l]]--; if ( (freq[arr[l]] > 0)) {count--; } l++; }left[i][m] = l; }while((l < n)){freq[arr[l]]--; l++; }} long[][] dp = new long[n][(k + 1)]; for ( int i = 0;(i < n);i++) {Arrays.fill(dp[i],Integer.MAX_VALUE); }for ( int i = 0;(i < n);i++) {for ( int j = 0;(j <= k);j++) {for ( int s = 0;(s <= j);s++) {if ( (left[i][s] == 0)) {dp[i][j] = 1; continue;} dp[i][j] = Math.min(dp[i][j],(dp[(left[i][s] - 1)][(j - s)] + 1)); }}}out.println(dp[(n - 1)][k]); }out.close(); } public static void prime( int n){ int[] isPrime = new int[(n + 1)]; Arrays.fill(isPrime,1); for ( long i = 2;(i <= n);i++) {if ( (isPrime[(int)i] == 1)) {for ( long j = (i * i);(j <= n);j += i) {isPrime[(int)j] = 0; }} }for ( int j = 3;(j <= n);j++) {if ( (isPrime[j] == 1)) {primes.add(j); } }} public static int factorize( long n){ long prod = 1;  int count = 0; while(((n % 2) == 0)){n >>= 1; count++; }if ( ((count > 0) && ((count % 2) == 1))) prod *= 2L; for ( long i :primes) {if ( ((i * i) > n)) break; count = 0; while(((n % i) == 0)){count++; n = (n / i); }if ( ((count > 0) && ((count % 2) == 1))) prod *= i; }if ( (n > 2)) prod *= n; return (int)prod;} 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 int[] readArrayInt( int n){ int[] array = new int[n]; for ( int j = 0;(j < n);j++) array[j] = sc.nextInt(); return array;} 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());} } }
4	public class Main{ public static void main( String[] args)throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringBuilder sb = new StringBuilder();  StringTokenizer st = new StringTokenizer(br.readLine()," "); n = pint(st.nextToken()); m = pint(st.nextToken()); k = pint(st.nextToken()); map = new int[n][m][4]; for ( int i = 0;(i < n);i++) {st = new StringTokenizer(br.readLine()," "); for ( int j = 0;(j < (m - 1));j++) { int temp = pint(st.nextToken()); map[i][j][3] = temp; map[i][(j + 1)][2] = temp; }}for ( int i = 0;(i < (n - 1));i++) {st = new StringTokenizer(br.readLine()," "); for ( int j = 0;(j < m);j++) { int temp = pint(st.nextToken()); map[i][j][1] = temp; map[(i + 1)][j][0] = temp; }}ans = new int[n][m][((k / 2) + 1)]; for ( int i = 0;(i < n);i++) {for ( int j = 0;(j < m);j++) {if ( ((k % 2) == 1)) {sb.append("-1 "); continue;} int min = rec(i,j,0,(k / 2)); sb.append((min * 2)).append(" "); }sb.append("\n"); }System.out.println(sb); } static int n ,m ,k ; static int[] dx = {-1,1,0,0}; static int[] dy = {0,0,-1,1}; static int[][][] map ; static int[][][] ans ; static int rec( int x, int y, int cost, int cnt){ if ( (cnt == 0)) {return 0;} if ( (ans[x][y][cnt] != 0)) return ans[x][y][cnt]; int temp = Integer.MAX_VALUE; for ( int i = 0;(i < 4);i++) { int tx = (x + dx[i]),ty = (y + dy[i]); if ( ((((tx < 0) || (tx >= n)) || (ty < 0)) || (ty >= m))) continue; if ( (map[x][y][i] != 0)) {temp = Math.min(temp,(rec(tx,ty,cost,(cnt - 1)) + map[x][y][i])); } }ans[x][y][cnt] = temp; return ans[x][y][cnt];} static int pint( String s){ return Integer.parseInt(s);} }
1	public class F{ static void solve()throws Exception { int n = scanInt();  long l[] = new long[n]; for ( int i = 0;(i < n);i++) {l[i] = scanLong(); } long e1 = 0,e2 = 0,ans = 0;  boolean water = false;  String types = scanString(); for ( int i = 0;(i < n);i++) { long li = l[i],cur ; switch(types.charAt(i)){ case 'G':cur = min(e1,li); e1 -= cur; li -= cur; e2 += (2 * cur); ans += (2 * cur); e2 += li; ans += (3 * li); break; case 'W':water = true; e1 += li; ans += (2 * li); break; case 'L':cur = min(e1,li); e1 -= cur; li -= cur; ans += (2 * cur); cur = min(e2,li); e2 -= cur; li -= cur; ans += (3 * cur); ans += ((water?4:6) * li); break; default :throw (new AssertionError()); } }out.print(ans); } static int scanInt()throws IOException { return parseInt(scanString());} static long scanLong()throws IOException { return parseLong(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); } } }
6	public class Task2{ public static void main( String[] args)throws IOException { new Task2().solve(); } int mod = 1000000007; PrintWriter out ; int n ; int m ; long base = (1L << 63); long P = 31; int[][] a ; void solve()throws IOException { Reader in = new Reader();  PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));  int n = in.nextInt();  double[][] a = new double[n][n]; for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) a[i][j] = in.nextDouble(); double[] dp = new double[(1 << n)]; dp[((1 << n) - 1)] = 1; for ( int mask = ((1 << n) - 1);(mask >= 0);mask--) { int k = Integer.bitCount(mask);  double p = (1.0 / ((k * (k - 1)) / 2.0)); for ( int i = 0;(i < n);i++) for ( int j = 0;(j < n);j++) if ( (((mask & (1 << i)) != 0) && ((mask & (1 << j)) != 0))) dp[(mask & (1 << j))] += ((p * dp[mask]) * a[i][j]); }for ( int i = 0;(i < n);i++) out.print((dp[(1 << i)] + " ")); out.flush(); out.close(); } long gcd( long a, long b){ if ( (b == 0)) return a; return gcd(b,(a % 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());} double nextDouble()throws NumberFormatException,IOException { return Double.valueOf(next());} } }
0	public class Solution implements Runnable{ private BufferedReader in ; private PrintWriter out ; private StringTokenizer st ; private Random rnd ; double Vend ; private double calcFirstSegment( double a, double Vmax, double Vend, double l){ double Vl = 0,Vr = Vmax; for ( int it = 0;(it < 256);it++) { double Vm = ((Vl + Vr) / 2.0);  double tFirst = (Vm / a);  double tSecond = 0; if ( (Vend < Vm)) tSecond = ((Vm - Vend) / a);  double firstPart = (((a * tFirst) * tFirst) / 2.0);  double secondPart = ((Vm * tSecond) - (((a * tSecond) * tSecond) / 2.0));  double res = (firstPart + secondPart); if ( (res < l)) Vl = Vm; else Vr = Vm; }this.Vend = Math.min(Vl,Vend); double res = 0.0; { double Vm = Vl;  double tFirst = (Vm / a);  double tSecond = 0; if ( (Vend < Vm)) tSecond = ((Vm - Vend) / a);  double firstPart = (((a * tFirst) * tFirst) / 2.0);  double secondPart = ((Vm * tSecond) - (((a * tSecond) * tSecond) / 2.0));  double remain = ((l - firstPart) - secondPart); res = ((tFirst + tSecond) + (remain / Vm)); }return res;} private double calcSecondPart( double a, double Vmax, double Vstart, double l){ double Vl = Vstart,Vr = Vmax; for ( int it = 0;(it < 256);it++) { double Vm = ((Vl + Vr) / 2.0);  double t = ((Vm - Vstart) / a);  double s = ((Vstart * t) + (((a * t) * t) / 2.0)); if ( (s < l)) Vl = Vm; else Vr = Vm; } double res = 0.0; { double Vm = ((Vl + Vr) / 2.0);  double t = ((Vm - Vstart) / a);  double s = ((Vstart * t) + (((a * t) * t) / 2.0));  double remain = (l - s); res = (t + (remain / Vmax)); }return res;} public void solve()throws IOException { double a = nextDouble(),v = nextDouble(),l = nextDouble(),d = nextDouble(),w = nextDouble();  double res = calcFirstSegment(a,v,w,d); res += calcSecondPart(a,v,Vend,(l - d)); out.println(res); } 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 double nextDouble()throws IOException { return Double.parseDouble(nextToken());} }
4	public class MainD{ static final StdIn in = new StdIn(); static final PrintWriter out = new PrintWriter(System.out); static final long M = ((long)1e9 + 7); static long[] fac ,faci ; public static void main( String[] args){ int n = in.nextInt(); fac = new long[(n + 1)]; faci = new long[(n + 1)]; fac[0] = faci[0] = 1; for ( int i = 1;(i <= n);++i) faci[i] = modI(fac[i] = ((fac[(i - 1)] * i) % M),M); List<List<Integer>> grps = new ArrayList<List<Integer>>(); for ( int i = 0;(i < n);++i) { int ai = in.nextInt(); for ( int j = 0;;++j) {if ( (j >= grps.size())) grps.add(new ArrayList<Integer>()); if ( ((grps.get(j).size() > 0) && !ps(((long)grps.get(j).get(0) * ai)))) continue; grps.get(j).add(ai); break;}} long[][] dp = new long[grps.size()][((n - grps.size()) + 1)]; dp[0][(grps.get(0).size() - 1)] = fac[grps.get(0).size()]; int ad = grps.get(0).size(); for ( int i = 1;(i < grps.size());++i) {for ( int j = 0;(j < dp[(i - 1)].length);++j) {if ( (dp[(i - 1)][j] == 0)) continue; for ( int k = 0;(k < grps.get(i).size());++k) for ( int l = Math.max(((((grps.get(i).size() + j) - k) - ad) - 1),0);(l <= Math.min((grps.get(i).size() - k),j));++l) dp[i][((j + k) - l)] = (((((((((fac[grps.get(i).size()] * nck(j,l)) % M) * nck(((ad + 1) - j),((grps.get(i).size() - k) - l))) % M) * nck((grps.get(i).size() - 1),k)) % M) * dp[(i - 1)][j]) + dp[i][((j + k) - l)]) % M); }ad += grps.get(i).size(); }out.println(dp[(grps.size() - 1)][0]); out.close(); } static long modI( long a, long m){ return (((a %= m) <= 1)?1:((((1 - (modI((m % a),a) * m)) / a) + m) % m));} static long nck( int n, int k){ return ((((fac[n] * faci[k]) % M) * faci[(n - k)]) % M);} static boolean ps( long x){ long lb = 1,rb = M; while((lb <= rb)){ long mb = ((lb + rb) / 2); if ( ((mb * mb) == x)) return true; if ( ((mb * mb) < x)) lb = (mb + 1); else rb = (mb - 1); }return false;} static class StdIn{ 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 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 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 G2PlaylistForPolycarpHardVersion{ Modular mod = new Modular((1e9 + 7)); public void solve( int testNumber, FastInput in, FastOutput out){ int n = in.readInt();  int m = in.readInt();  int[][] musics = new int[n][2];  int[] cnts = new int[4]; for ( int i = 0;(i < n);i++) {musics[i][0] = in.readInt(); musics[i][1] = in.readInt(); cnts[musics[i][1]]++; } int c1 = cnts[1];  int c2 = cnts[2];  int c3 = cnts[3];  int[][][][] comp = new int[(c1 + 1)][(c2 + 1)][(c3 + 1)][4]; for ( int i = 0;(i <= c1);i++) {for ( int j = 0;(j <= c2);j++) {for ( int k = 0;(k <= c3);k++) {for ( int t = 0;(t < 4);t++) {if ( (((i == 0) && (j == 0)) && (k == 0))) {comp[i][j][k][t] = 1; continue;} if ( ((i > 0) && (t != 1))) {comp[i][j][k][t] = mod.plus(comp[i][j][k][t],mod.mul(comp[(i - 1)][j][k][1],i)); } if ( ((j > 0) && (t != 2))) {comp[i][j][k][t] = mod.plus(comp[i][j][k][t],mod.mul(comp[i][(j - 1)][k][2],j)); } if ( ((k > 0) && (t != 3))) {comp[i][j][k][t] = mod.plus(comp[i][j][k][t],mod.mul(comp[i][j][(k - 1)][3],k)); } }}}} int[][][][] last = new int[(c1 + 1)][(c2 + 1)][(c3 + 1)][(m + 1)];  int[][][][] next = new int[(c1 + 1)][(c2 + 1)][(c3 + 1)][(m + 1)]; last[0][0][0][0] = 1; int t1 = 0;  int t2 = 0;  int t3 = 0; for ( int[] music :musics) { int m1 = music[1];  int m0 = music[0]; if ( (m1 == 1)) {t1++; } else if ( (m1 == 2)) {t2++; } else {t3++; }for ( int i = 0;(i <= t1);i++) {for ( int j = 0;(j <= t2);j++) {for ( int k = 0;(k <= t3);k++) {for ( int t = 0;(t <= m);t++) {next[i][j][k][t] = last[i][j][k][t]; if ( (t < m0)) {continue;} if ( ((m1 == 1) && (i > 0))) {next[i][j][k][t] = mod.plus(next[i][j][k][t],last[(i - 1)][j][k][(t - m0)]); } else if ( ((m1 == 2) && (j > 0))) {next[i][j][k][t] = mod.plus(next[i][j][k][t],last[i][(j - 1)][k][(t - m0)]); } else if ( ((m1 == 3) && (k > 0))) {next[i][j][k][t] = mod.plus(next[i][j][k][t],last[i][j][(k - 1)][(t - m0)]); } }}}} int[][][][] tmp = last; last = next; next = tmp; } int ans = 0; for ( int i = 0;(i <= c1);i++) {for ( int j = 0;(j <= c2);j++) {for ( int k = 0;(k <= c3);k++) {ans = mod.plus(ans,mod.mul(last[i][j][k][m],comp[i][j][k][0])); }}}out.println(ans); } } static class Modular{ int m ; public Modular( int m){ this.m = m; } public Modular( long m){ this.m = (int)m; if ( (this.m != m)) {throw (new IllegalArgumentException());} } public Modular( double m){ this.m = (int)m; if ( (this.m != m)) {throw (new IllegalArgumentException());} } public int valueOf( int x){ x %= m; if ( (x < 0)) {x += m; } return x;} public int valueOf( long x){ x %= m; if ( (x < 0)) {x += m; } return (int)x;} public int mul( int x, int y){ return valueOf(((long)x * y));} public int plus( int x, int y){ return valueOf((x + y));} public String toString(){ return ("mod " + m);} } 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();} } 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;} } }
4	public class OnTheBench{ public static void main( String[] args){ setupCombo(301); FastScanner sc = new FastScanner();  PrintWriter out = new PrintWriter(System.out);  int N = sc.nextInt();  long[] a = sc.nextLongs(N);  boolean[] vis = new boolean[N];  int[] groups = new int[(N + 1)];  int G = 0; for ( int i = 0;(i < N);i++) {if ( !vis[i]) {vis[i] = true; int elems = 1; for ( int j = (i + 1);(j < N);j++) { long prod = (a[i] * a[j]);  long root = (long)Math.sqrt(prod); if ( (!vis[j] && (prod == (root * root)))) {vis[j] = true; elems++; } }groups[++G] = elems; } } long[][] dp = new long[(G + 1)][(N + 1)]; dp[0][0] = 1; int total = 0; for ( int prefix = 1;(prefix <= G);prefix++) { int amt = groups[prefix]; for ( int prevBad = 0;(prevBad <= max(0,(total - 1)));prevBad++) {for ( int fixed = 0;(fixed <= min(prevBad,amt));fixed++) {for ( int slots = max(1,fixed);(slots <= min(amt,(total + 1)));slots++) { int introduced = (amt - slots);  long ways = mult(choose[prevBad][fixed],choose[((total + 1) - prevBad)][(slots - fixed)],choose[(amt - 1)][(slots - 1)],fact[amt],dp[(prefix - 1)][prevBad]);  int currBad = ((prevBad + introduced) - fixed); dp[prefix][currBad] = ((dp[prefix][currBad] + ways) % mod); }}}total += amt; }out.println(dp[G][0]); out.close(); } static long mod = ((long)1e9 + 7); static long[][] choose ; static long[] fact ; static long mult( long... multiplicands){ long ans = 1; for ( long v :multiplicands) {ans = ((ans * v) % mod); }return ans;} static void setupCombo( int MAX){ choose = new long[(MAX + 1)][(MAX + 1)]; fact = new long[(MAX + 1)]; choose[0][0] = 1; fact[0] = 1; for ( int i = 1;(i <= MAX);i++) {fact[i] = (((long)i * fact[(i - 1)]) % mod); choose[i][0] = 1; for ( int j = 1;(j < i);j++) {choose[i][j] = ((choose[(i - 1)][(j - 1)] + choose[(i - 1)][j]) % mod); }choose[i][i] = 1; }} 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[] nextLongs( int N){ long[] res = new long[N]; for ( int i = 0;(i < N);i++) {res[i] = 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)));} } }
0	public class Main{ public static void main( String[] args){ new TaskA().solve(); } } class TaskA extends Base{ public static void solve(){ long l = in.nextLong();  long r = in.nextLong(); if ( ((r - l) < 2)) {System.out.println(-1); return ;} if ( ((l % 2) == 0)) {System.out.println(((((l + " ") + (l + 1)) + " ") + (l + 2))); return ;} if ( ((r - l) > 2)) {System.out.println((((((l + 1) + " ") + (l + 2)) + " ") + (l + 3))); return ;} System.out.println(-1); } } 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){ e.printStackTrace(); } }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
1	public class ProblemB3{ Map<Integer,List<int[]>> dest ; private ProblemB3()throws IOException{ BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));  String h = rd.readLine();  String[] q = h.split("\\s+");  int a = Integer.parseInt(q[1]);  int b = Integer.parseInt(q[2]); h = rd.readLine(); q = h.split(" "); int n = q.length;  int[] p = new int[n]; for ( int i = 0;(i < n);i++) {p[i] = Integer.parseInt(q[i]); } Set<Integer> pset = new HashSet<>(); for ( int x :p) {pset.add(x); }dest = new HashMap<>(); boolean res = true; for ( int x :p) { boolean aOk = pset.contains((a - x));  boolean bOk = pset.contains((b - x)); if ( (!aOk && !bOk)) {res = false; break;} else {if ( aOk) {addEdgeAndBack(x,(a - x),0); } if ( bOk) {addEdgeAndBack(x,(b - x),1); } }} Set<Integer> aSet = new HashSet<>(); if ( (res && (a != b))) {for ( int x :p) { List<int[]> e = getEdges(x); if ( (e.size() == 1)) { int[] edge = e.get(0);  boolean odd = true;  int curA = edge[1];  int prev = x; while(true){ int cur = edge[0]; if ( ((curA == 0) && odd)) {aSet.add(prev); aSet.add(cur); } e = getEdges(cur); if ( (e.size() == 1)) {if ( (!odd && (e.get(0)[0] != cur))) {res = false; } break;} int other = ((e.get(0)[0] == prev)?1:0); edge = e.get(other); if ( (edge[1] == curA)) {res = false; break;} curA = (1 - curA); prev = cur; odd = !odd; }if ( !res) {break;} } }} out((res?"YES":"NO")); if ( res) { StringBuilder buf = new StringBuilder(); for ( int i = 0;(i < n);i++) {if ( (i > 0)) {buf.append(' '); } buf.append((aSet.contains(p[i])?'0':'1')); }out(buf); } } private void addEdgeAndBack( int from, int to, int u){ addEdge(from,to,u); addEdge(to,from,u); } private void addEdge( int from, int to, int u){ List<int[]> edges = getEdges(from); for ( int[] edge :edges) {if ( (edge[0] == to)) {return ;} }edges.add(new int[]{to,u}); } private List<int[]> getEdges( int from){ List<int[]> ds = dest.get(from); if ( (ds == null)) {ds = new ArrayList<>(); dest.put(from,ds); } return ds;} static private void out( Object x){ System.out.println(x); } public static void main( String[] args)throws IOException { new ProblemB3(); } }
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();} }
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());} } }
2	public class Probram3{ public static int get( long n){ int sum = 0; while((n != 0)){sum += (n % 10); n = (n / 10); }return sum;} public static void main( String[] args){ Scanner scanner = new Scanner(System.in);  long n = scanner.nextLong();  long s = scanner.nextLong();  long l = 1;  long r = Long.MAX_VALUE;  long index = 0; while((l <= r)){ long mid = ((l + r) / 2); if ( ((mid - get(mid)) >= s)) {index = mid; r = (mid - 1); } else {l = (mid + 1); }}System.out.println(Math.max(0,((n - index) + 1))); } }
1	public class Main{ static private void solve( InputReader in, OutputWriter out){ int n = in.nextInt();  List<List<Integer>> g = new ArrayList<>((n + 1)); for ( int i = 0;(i < (n + 1));i++) {g.add(new LinkedList<>()); } int degree1 = 0,degree2 = 0,root = 0; for ( int i = 0;(i < (n - 1));i++) { int a = in.nextInt();  int b = in.nextInt(); g.get(a).add(b); g.get(b).add(a); if ( (g.get(a).size() > degree1)) {if ( (a == root)) {degree1 = g.get(a).size(); } else {degree2 = degree1; degree1 = g.get(a).size(); root = a; }} else if ( (g.get(a).size() > degree2)) {degree2 = g.get(a).size(); } if ( (g.get(b).size() > degree1)) {if ( (b == root)) {degree1 = g.get(b).size(); } else {degree2 = degree1; degree1 = g.get(b).size(); root = b; }} else if ( (g.get(b).size() > degree2)) {degree2 = g.get(b).size(); } }if ( (degree2 > 2)) {out.print("No"); } else {out.println("Yes"); List<Integer> leaves = new LinkedList<>(); for ( int i = 1;(i <= n);i++) {if ( (i != root)) {if ( (g.get(i).size() == 1)) {leaves.add(i); } } }out.println(leaves.size()); for ( int i :leaves) {out.println(((root + " ") + i)); }}} 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(); } static private 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(); } } } static private 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(); } } } }
1	public class CF1082D{ public static void main( String[] args)throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  int n = Integer.parseInt(br.readLine());  StringTokenizer st = new StringTokenizer(br.readLine());  int[] aa = new int[n];  int[] i1 = new int[n];  int[] i2 = new int[n];  int n1 = 0,n2 = 0,m2 = 0; for ( int i = 0;(i < n);i++) { int a = Integer.parseInt(st.nextToken()); aa[i] = a; if ( (a == 1)) i1[n1++] = i; else {i2[n2++] = i; m2 += a; }}if ( (m2 < (((n2 - 1) * 2) + n1))) {System.out.println("NO"); return ;} int m = ((n2 - 1) + n1);  int d = ((n2 - 1) + Math.min(n1,2));  PrintWriter pw = new PrintWriter(System.out); pw.println(("YES " + d)); pw.println(m); for ( int i = 0;((i + 1) < n2);i++) {pw.println((((i2[i] + 1) + " ") + (i2[(i + 1)] + 1))); aa[i2[i]]--; aa[i2[(i + 1)]]--; }if ( (n1 > 0)) {while(((n2 > 0) && (aa[i2[(n2 - 1)]] == 0)))n2--; pw.println((((i2[(n2 - 1)] + 1) + " ") + (i1[(n1 - 1)] + 1))); aa[i2[(n2 - 1)]]--; n1--; } for ( int i = 0,j = 0;(j < n1);j++) {while((aa[i2[i]] == 0))i++; pw.println((((i2[i] + 1) + " ") + (i1[j] + 1))); aa[i2[i]]--; }pw.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);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ long l = in.nextLong();  long r = in.nextLong();  boolean[][] answer = new boolean[2][100];  int cur = 0; while((r > 0)){answer[0][cur] = ((r % 2) != 0); ++cur; r >>= 1; }cur = 0; while((l > 0)){answer[1][cur] = ((l % 2) != 0); ++cur; l >>= 1; } int old = -1; for ( int i = 63;(i >= 0);--i) {if ( (answer[0][i] && !answer[1][i])) {old = i; break;} }if ( (old == -1)) {out.println(0); return ;} long a = 1; for ( int i = 0;(i < old);++i) {a <<= 1; a += 1; }out.println(a); } } class InputReader{ static private BufferedReader bufferedReader ; static private StringTokenizer stringTokenizer ; public InputReader( InputStream inputStream){ bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); stringTokenizer = null; } public String next(){ while(((stringTokenizer == null) || !stringTokenizer.hasMoreTokens())){try{stringTokenizer = new StringTokenizer(bufferedReader.readLine()); }catch (IOException e){ e.printStackTrace(); } }return stringTokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
5	public class Solution implements Runnable{ public void solve()throws Exception { int n = sc.nextInt();  int a[] = new int[n];  int s = 0; for ( int i = 0;(i < n);++i) {a[i] = sc.nextInt(); s += a[i]; }Arrays.sort(a); int s2 = 0; for ( int i = (n - 1);(i >= 0);--i) {s2 += a[i]; if ( (s2 > (s - s2))) {out.println((n - i)); break;} }} static String filename = ""; static boolean fromFile = false; BufferedReader in ; PrintWriter out ; FastScanner sc ; public static void main( String[] args){ new Thread(null,new Solution(),"",(1 << 25)).start(); } void init()throws Exception { if ( fromFile) {in = new BufferedReader(new FileReader((filename + ".in"))); out = new PrintWriter(new FileWriter((filename + ".out"))); } else {in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); }sc = new FastScanner(in); } } 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());} }
3	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]); } int inv = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (A[i] > A[j])) {inv++; } }} StringBuilder sb = new StringBuilder("");  int m = Integer.parseInt(br.readLine()); for ( int i = 0;(i < m);i++) {s = br.readLine().split(" "); int li = Integer.parseInt(s[0]);  int ri = Integer.parseInt(s[1]);  int tot = ((ri - li) + 1); inv = (inv + ((tot * (tot - 1)) / 2)); if ( ((inv % 2) == 0)) {sb.append("even\n"); } else {sb.append("odd\n"); }}System.out.print(sb); } }
3	public class Main{ long MOD = 1000000007; InputReader in ; BufferedReader br ; PrintWriter out ; public static void main( String[] args)throws java.lang.Exception { Main solver = new Main(); solver.in = new InputReader(System.in); solver.br = new BufferedReader(new InputStreamReader(System.in)); solver.out = new PrintWriter(System.out); solver.solve(); solver.out.flush(); solver.out.close(); } int[] A ; int N ; public void solve(){ int tc = 1; for ( int cas = 1;(cas <= tc);cas++) {N = in.readInt(); A = new int[N]; for ( int i = 0;(i < A.length);i++) { String str = in.readString(); if ( str.equals("f")) A[i] = 1; } long[][] dp = new long[(N + 1)][(N + 1)]; for ( int i = 0;(i < N);i++) {if ( (i == 0)) {dp[i][0] = 1; } else if ( (A[(i - 1)] != 1)) {dp[i][N] = dp[(i - 1)][N]; for ( int j = (N - 1);(j >= 0);j--) {dp[i][j] = ((dp[(i - 1)][j] + dp[i][(j + 1)]) % MOD); }} else {for ( int j = 1;(j <= N);j++) {dp[i][j] = (dp[(i - 1)][(j - 1)] % MOD); }}} long res = 0; for ( int i = 0;(i <= N);i++) {res = ((res + dp[(N - 1)][i]) % MOD); }out.println(res); }} } 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 void readInt( int[] A){ for ( int i = 0;(i < A.length);i++) A[i] = readInt(); } 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 void readLong( long[] A){ for ( int i = 0;(i < A.length);i++) A[i] = readLong(); } 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); } }
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);  int N = Integer.parseInt(kek.readLine());  double[][] lake = new double[N][N]; for ( int i = 0;(i < N);i++) { String[] input = kek.readLine().split(" "); for ( int j = 0;(j < N);j++) {lake[i][j] = Double.parseDouble(input[j]); }} int pow = (int)Math.pow(2,N);  double[] res = new double[pow]; res[(pow - 1)] = 1.0; for ( int i = (pow - 1);(i >= 0);i--) { int ones = Integer.bitCount(i);  int possibleCombos = ((ones * (ones - 1)) / 2); for ( int j = 0;(j < N);j++) {if ( (((i >> j) % 2) == 0)) {continue;} for ( int k = (j + 1);(k < N);k++) {if ( (((i >> k) % 2) == 0)) {continue;} res[(i ^ (1 << k))] += ((res[i] * lake[j][k]) / possibleCombos); res[(i ^ (1 << j))] += ((res[i] * lake[k][j]) / possibleCombos); }}}for ( int i = 0;(i < N);i++) {outkek.print((res[(1 << i)] + " ")); }kek.close(); outkek.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 ans = 0; while(((a > 0) && (b > 0))){if ( (a < b)) { long t = a; a = b; b = t; } ans += (a / b); a %= b; }out.print(ans); } } 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 (Exception e){ throw (new RuntimeException(e));} }return tokenizer.nextToken();} public long nextLong(){ return Long.parseLong(next());} }
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[] h = new int[3000]; for ( int i = 0;(i < n);i++) h[i] = in.nextInt(); int l = 0,r = 1000000000,m = 0;  int ansl = 0,ansr = 0; while((l <= r)){m = ((l + r) / 2); int ca = 0; for ( int i = 0;(i < n);i++) if ( (h[i] > m)) ca++; if ( (ca == a)) ansl = m; if ( (ca <= a)) r = (m - 1); else l = (m + 1); }l = 0; r = 1000000000; while((l <= r)){m = ((l + r) / 2); int ca = 0; for ( int i = 0;(i < n);i++) if ( (h[i] > m)) ca++; if ( (ca == a)) ansr = m; if ( (ca < a)) r = (m - 1); else l = (m + 1); }if ( ((ansl == 0) || (ansr == 0))) System.out.print(0); else System.out.print(((ansr - ansl) + 1)); } }