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(); } }
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(); } }
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());} }
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); }
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 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);} }
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); } } }
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(); } }
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(); } }
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(); } } }
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); } } }
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)); } }
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;} }
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(); } } }
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 ; }
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(); } } }
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)); } }
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());} } }
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(); } }
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); }
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(); } }
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); } }
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(); } }
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(); } }
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(); } }
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));} } }
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); } }
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(); } }
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;} }
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));} }
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 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(); } } }
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); } }
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++];} }
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(); } } }
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))); }} }
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))); }}} }
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); } }
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"); }} }
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{ 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)); } }
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());} }
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());} }
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 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(); } }
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)); } }
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)); } }
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;} } }
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 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());} } }
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 ;} }
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); } }}} }
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); } }
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(); } }
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);} }
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){ 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());} }
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 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);} }
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); } }
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)); } }
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)); } }
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"); }} }
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); } }
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 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); }}} }
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(); } }
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 + " ")); } }
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(); } }
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(); } }
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;} } }
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"); }}} }
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"); } }
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(); } }
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;} } }
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 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)); }}} }
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); } }
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(); } }
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());} } }
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"); } }
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());} } }
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 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());} }
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); } }
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(); } } }
0	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  Scanner in = new Scanner(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } } class TaskD{ public void solve( int testNumber, Scanner in, PrintWriter out){ String[] str = in.nextLine().split(" ");  int a = Integer.parseInt(str[0]);  int v = Integer.parseInt(str[1]); str = in.nextLine().split(" "); int l = Integer.parseInt(str[0]);  int d = Integer.parseInt(str[1]);  int w = Integer.parseInt(str[2]);  double minTime = 0.; if ( (w >= v)) {minTime = getTimeAfterSign(0,v,l,a); out.format(Locale.US,"%.6f",minTime); return ;} double whenGetSpeedWPath = ((w * w) / (2. * a)); if ( (whenGetSpeedWPath >= d)) { double time = Math.sqrt(((2.0 * d) / a)); minTime = (time + getTimeAfterSign((a * time),v,(l - d),a)); } else { double stopPath = (((v * v) - (w * w)) / (2. * a));  double vMaxPath = ((v * v) / (2. * a)); if ( ((stopPath + vMaxPath) > d)) { double topSpeed = Math.sqrt(((((2. * a) * d) + (w * w)) / 2)); minTime = ((((2. * topSpeed) - w) / a) + getTimeAfterSign(w,v,(l - d),a)); } else { double stopTime = ((v - w) / (a + 0.));  double getMaxTime = (v / (a + 0.));  double maxTime = ((d - (stopPath + vMaxPath)) / v); minTime = (((stopTime + getMaxTime) + maxTime) + getTimeAfterSign(w,v,(l - d),a)); }}out.format(Locale.US,"%.6f",minTime); } double getTimeAfterSign( double startSpeed, double maxSpeed, double path, int a){ double maxSpeedTime = ((maxSpeed - startSpeed) / a);  double maxSpeedPath = ((startSpeed * maxSpeedTime) + (((a * maxSpeedTime) * maxSpeedTime) / 2)); if ( (maxSpeedPath > path)) {return ((-startSpeed + Math.sqrt(((startSpeed * startSpeed) + ((2 * a) * path)))) / a);} else {return (maxSpeedTime + ((path - maxSpeedPath) / maxSpeed));}} }
5	public class 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;} }
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); } }
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;} } }
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());} }
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());} } }
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());} } }
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(); } }
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();} } }
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();} }
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());} } }
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 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());} } }
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;} } }
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(); } }
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); }}} }
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))); }
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); } }
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")); } }
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(); } }
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); } } }
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;} }
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());} } }
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")); }} }
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{ 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(); } }
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();} }
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(); } } }
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 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 + " ")); } } }
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)); } }
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);} }
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); }} }
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());} } }
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();} } }
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 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)); } }
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());} } }
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 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;} } }
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());} } }
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(); } }
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(); } }
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(); } }
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); } }} }
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); }} }
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(); } }
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;} } }
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); }} }
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))); }}} }
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();} }
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;} } }
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(); } }
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); } } }
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))); }} }
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); } } }
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(); } }
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); } }
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(); }} }
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());} } }
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)));} }
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());} }
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));} }
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); } }
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)); } }
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(); } }
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 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); } } }
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)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); } }
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));} } }
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] + " ")); }} }
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;} } }
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();} } }
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); } }
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();} }
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();} }
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); }}}} }
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{ 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());} } }
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(); } }
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 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 "); } }
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)); } }
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());} }
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 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{ 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(); } }
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());} } }
4	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskC solver = new TaskC(); solver.solve(1,in,out); out.close(); } static class TaskC{ public void solve( int testNumber, InputReader in, OutputWriter out){ int tests = in.nextInt(); for ( int t = 0;(t < tests);t++) { int numLines = in.nextInt();  int stackIdx = -1;  int[] stack = new int[10000];  String prev = ""; for ( int x = 0;(x < numLines);x++) { int depth = 0;  int next = in.nextInt();  boolean found = false; for ( int i = stackIdx;(i >= 0);i--) {if ( (next == (stack[i] + 1))) {depth = i; found = true; break;} }if ( (found == true)) {stackIdx = depth; stack[depth] = next; for ( int i = 0;(i <= depth);i++) {if ( (i != 0)) {out.print("."); } out.print(stack[i]); }out.println(); } else if ( (next == 1)) {stackIdx++; stack[stackIdx] = 1; for ( int i = 0;(i <= stackIdx);i++) {if ( (i != 0)) {out.print("."); } out.print(stack[i]); }out.println(); } else {stackIdx = 0; stack[0] = next; out.println(next); }}}} } static class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) {writer.print(' '); } writer.print(objects[i]); }} public void println(){ writer.println(); } public void close(){ writer.close(); } public void print( int i){ writer.print(i); } public void println( int i){ writer.println(i); } } static class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private InputReader.SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c)){c = read(); } int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } }
6	public class Main 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(); } } }
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(); } }
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());} } }
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"); }}}} }
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;} }
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(); } }
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(); } }
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;} } }
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());} } }
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());} } }
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"); }}} }
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 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); } } }
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); } }
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)); } }
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);} }
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(); } }
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"); }} }
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());} }
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());} } }
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);} } }
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());} } }
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(); } }
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(); } }
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 + " ")); }} }
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(); } }
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)); } }
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); } }
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(); } }
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 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());} } }
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());} } }
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(); } }
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); } }
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());} } }
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); } } }
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"); } }
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));} } }
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(); } }
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))); } }
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;} }
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());} }
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(); } }
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))); } } }
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"); } }
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(); } }
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"); } }
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))); }} }
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; } } }
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;} }
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();} } }
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(); } }
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)); } }
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)); } }
3	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskD solver = new TaskD(); solver.solve(1,in,out); out.close(); } @SuppressWarnings("Duplicates") static class TaskD{ public void solve( int testNumber, InputReader in, PrintWriter out){ int n = in.nextInt();  int[] a = in.nextIntArray(n);  int m = in.nextInt();  int count = 0; for ( int i = 0;(i < n);i++) {for ( int j = (i + 1);(j < n);j++) {if ( (a[i] > a[j])) count = ((count + 1) % 2); }} StringBuilder res = new StringBuilder();  int l ,r ; while((m-- > 0)){l = (in.nextInt() - 1); r = (in.nextInt() - 1); count = (count ^ (((((r - l) + 1) * (r - l)) / 2) % 2)); res.append(((count == 1)?"odd":"even")).append('\n'); }out.print(res); } } static class InputReader{ private final BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream in){ reader = new BufferedReader(new InputStreamReader(in)); } public int[] nextIntArray( int size){ int[] array = new int[size]; for ( int i = 0;(i < size);++i) {array[i] = nextInt(); }return array;} public int nextInt(){ return Integer.parseInt(next());} public String next(){ while(((tokenizer == null) || !tokenizer.hasMoreTokens())){tokenizer = new StringTokenizer(readLine()); }return tokenizer.nextToken();} public String readLine(){ String line ; try{line = reader.readLine(); }catch (IOException e){ throw (new RuntimeException(e));} return line;} } }
5	public class 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(); } }
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"); } }
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))); }}}} }
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)); }} }
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();} } }
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 ; } }
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); } } }
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(); } }
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());} }
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());} } }
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));} } }
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"); } }
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());} } }
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(); } }
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(); } }
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(); } }
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();} } }
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"); }} }
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)));} } }
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();} } }
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 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(); } }
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")); } }
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());} }
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());} } }
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(); } }
4	public class Main{ public static void main( String[] args)throws IOException { Scanner sc = new Scanner(System.in);  PrintWriter out = new PrintWriter(System.out);  int t = sc.nextInt(); while((t-- > 0)){ int n = sc.nextInt();  ArrayList<Integer> al[] = new ArrayList[(n + 1)]; for ( int i = 0;(i <= n);i++) al[i] = new ArrayList<>(); al[0].add(1); int y ; y = sc.nextInt(); boolean flag = true; for ( int i = 1;(i <= (n - 1));i++) { int x = sc.nextInt();  int idx = (al[(i - 1)].size() - 1); if ( (x != 1)) {while(flag){ int ans = (x - 1); if ( (al[(i - 1)].get(idx) == ans)) {idx--; break;} idx--; }} for ( int j = 0;(j <= idx);j++) {al[i].add(al[(i - 1)].get(j)); }al[i].add(x); }for ( int i = 0;(i <= (n - 1));i++) {out.print(al[i].get(0)); for ( int j = 1;(j <= (al[i].size() - 1));j++) {out.print(("." + al[i].get(j))); }out.println(); }}out.flush(); out.close(); } }
5	public class Solution{ 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(); } }
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());} }
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 ; }
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")); }} }
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(); } }
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();} }
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 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());} }
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());} } }
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));} }
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); }} }
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;} }
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))); }} }
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 Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ public void solve( int testNumber, InputReader in, OutputWriter out){ int n = in.nextInt();  int k = in.nextInt();  int[] a = in.nextIntArray(n); if ( (k == 1)) {out.println("1 1"); return ;} int left = -1,right = -1;  Counter<Integer> counter = new Counter<Integer>(); while(true){right++; if ( (right == n)) {out.println("-1 -1"); return ;} counter.add(a[right]); if ( (counter.size() >= k)) break; }while(true){left++; if ( (counter.get(a[left]) == 1)) break; counter.add(a[left],-1); }out.printLine((left + 1),(right + 1)); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[(1 << 16)]; private int curChar ; private int numChars ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int nextInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c & 15); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public static boolean isSpaceChar( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int[] nextIntArray( int count){ int[] result = new int[count]; for ( int i = 0;(i < count);i++) {result[i] = nextInt(); }return result;} } class OutputWriter{ private PrintWriter writer ; public OutputWriter( OutputStream stream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(stream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object obj){ writer.print(obj); } public void println(){ writer.println(); } public void println( String x){ writer.println(x); } public void print( char c){ writer.print(c); } public void close(){ writer.close(); } public void printItems( Object... items){ for ( int i = 0;(i < items.length);i++) {if ( (i != 0)) {print(' '); } print(items[i]); }} public void printLine( Object... items){ printItems(items); println(); } }
5	public class 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); } }
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(); } }
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();} }
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());} }
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());} } }
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(); } }
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());} }
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))); } }
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){ } } }
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(); } }
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(); } }
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"); } }
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); } }
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 ; }
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());} } }
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());} } }
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;} }
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 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); } }
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();} } }
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);} }
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());} } }
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();} } }
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"); } }
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 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); } }
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)); } }
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));} } }
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;} }
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); } }
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;} }
1	public class Main{ public static void main( String[] args){ Scanner entrada = new Scanner(System.in);  int Primos[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997};  boolean sw = true;  int Indices[] = new int[Primos.length];  int cantidad = 0; for ( int i = 0;((i < (Primos.length - 1)) && sw);i++) { int suma = ((Primos[i] + Primos[(i + 1)]) + 1);  int posicion = Arrays.binarySearch(Primos,suma); if ( (posicion > -1)) Indices[posicion] = 1; }while(entrada.hasNextInt()){ int N = entrada.nextInt();  int K = entrada.nextInt();  int contador = 0; for ( int i = 0;((Primos[i] <= N) && (i < (Primos.length - 1)));i++) contador += Indices[i]; if ( (contador >= K)) System.out.println("YES"); else System.out.println("NO"); }} }
1	public class B{ 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); } } }
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")); }} }
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); } }
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))); }} }
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());} } }
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(); } }
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));} }
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(); } }
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;} }
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"); } }
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(); } }
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();} }
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(); } }
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;} }
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));} }
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();} }
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)); }} }
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)))); }}} }
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);} }
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;}}} }
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); } }
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 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);} }
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 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);} }
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); } }
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());} }
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); } } }
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());} }
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() + " ")); } }
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 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(); } } }
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); } }
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;} }
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 "); } }
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 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"); } }
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());} }
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 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(); } }
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))); } }
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());} } }
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); } } }
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); } }
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"); } }
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 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); } }
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());} } }
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(); } }
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);} }
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); } } }
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;} } }
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(); } }
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);} }
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); }}} }
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(); } }
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;} } }
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()); }} }
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 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 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; } }
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); } }
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());} }
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)); } }
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());} } }
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());} } }
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(); } }
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 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(); } }
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(); } }
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)));} }
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 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;} }}}} }
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; } } }
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(); } }
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;} }
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"); }} }
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());} }
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());} } }
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;} } }
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(); } }
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 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); } } }
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(); } }
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)); } }
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);} }
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();} }
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());} }
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)); } }
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();} }
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 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; } } }
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; } } }
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(); } }
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());} } }
0	public class problemA{ public static long GCD( long number1, long number2){ if ( (number2 == 0)) {return number1;} return GCD(number2,(number1 % number2));} public static void main( String[] args)throws NumberFormatException,IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  StringTokenizer st = new StringTokenizer(br.readLine());  long b = Long.parseLong(st.nextToken());  long c = Long.parseLong(st.nextToken()); if ( (((c - b) < 2) || (((c - b) == 2) && (GCD(c,b) == 1)))) {System.out.println("-1"); } else {if ( ((b % 2) == 0)) {System.out.println(((((b + " ") + (b + 1)) + " ") + (b + 2))); } else System.out.println((((((b + 1) + " ") + (b + 2)) + " ") + (b + 3))); }} }
5	public class 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());} }
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"); }} }
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); }
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}; }
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"); }} }
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 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));} } }
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(); } } }
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 ;}}} }
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 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); } }
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)]); } }
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); } }
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 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());} } }
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(); } }
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 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 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;} }
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){ } } } }
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());} }
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());} } }
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(); } }
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;} }
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(); } }
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(); } }
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 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); } } }
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); } }
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());} }
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() + " ")); } }
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 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(); } }
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 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(); } }
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;} }
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(); } } }
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))); } }
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 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); }} }
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());} }
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(); } }
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();} } }
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); } }
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());} }
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();} }
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"); }} }
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());} } }
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));} }
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] + " ")); }} }
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(); } } }
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); } }
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(); } }
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(); } }
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] + " ")); }} }
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(); } }
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 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 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;} }
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); } }
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])); } }} }
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); }} }
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))); } }
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"); } }
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;} }
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))); } }
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))); } }
0	public class A{ FastScanner in ; PrintWriter out ; public void run(){ try{in = new FastScanner(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); }catch (IOException e){ e.printStackTrace(); } } public void solve()throws IOException { long l = new Long(in.next());  long r = new Long(in.next()); if ( (((r - l) < 2) || (((r - l) == 2) && ((l % 2) != 0)))) {out.println("-1"); } else {if ( ((l % 2) != 0)) {l++; } out.println(l); out.println((l + 1)); out.println((l + 2)); }} class FastScanner{ BufferedReader br ; StringTokenizer st ; FastScanner( InputStreamReader in){ br = new BufferedReader(in); } String next(){ while(((st == null) || !st.hasMoreTokens())){try{st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } }return st.nextToken();} } public static void main( String[] arg){ A o = new A(); o.run(); } }
0	public class 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());} }
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)); } } }
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 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); } }
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;} } }
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); } }
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;} } }
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;  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); } } }
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());} }
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 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;} } }
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);} } }
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(){ } }
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")); } }
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")); }} }
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(); } }
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)); } }
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))); }} }
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;} }
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;} }
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;} }
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();  }} }
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 + " ")); }} }
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);} }
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"); }}} }
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))); }}}} }
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; } }
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))); }}} }
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();} }
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(); } }
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); } }
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;} } }
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();} } }
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)));} }
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(); } }
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"); } }
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);} }
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 ;}} }} }
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(); } }
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 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(); } }
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;} } }
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); }}} }
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); } }
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);} }
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(); } }
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();} } }
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)))); } }
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();} }
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(); } }
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); } }
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); } } }
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))); }}} }
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();} } }
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);} }
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); } }
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());} }
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"); }}} }
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();} }
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(); } }
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){ 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"); } }
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))); }}} }
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"); }} }
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(); } }
5	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  InputReader in = new InputReader(inputStream);  OutputWriter out = new OutputWriter(outputStream);  TaskA solver = new TaskA(); solver.solve(1,in,out); out.close(); } } class TaskA{ public void solve( int testNumber, InputReader in, OutputWriter out){ int count = in.readInt();  int[] array = IOUtils.readIntArray(in,count);  int[] sorted = array.clone(); ArrayUtils.sort(sorted,IntComparator.DEFAULT); int differs = 0; for ( int i = 0;(i < count);i++) {if ( (array[i] != sorted[i])) differs++; }if ( (differs <= 2)) out.printLine("YES"); else out.printLine("NO"); } } class InputReader{ private InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public InputReader( InputStream stream){ this.stream = stream; } public int read(){ if ( (numChars == -1)) throw (new InputMismatchException()); if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) return -1; } return buf[curChar++];} public int readInt(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) throw (new InputMismatchException()); res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) return filter.isSpaceChar(c); return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } } class OutputWriter{ private final PrintWriter writer ; public OutputWriter( OutputStream outputStream){ writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter( Writer writer){ this.writer = new PrintWriter(writer); } public void print( Object... objects){ for ( int i = 0;(i < objects.length);i++) {if ( (i != 0)) writer.print(' '); writer.print(objects[i]); }} public void printLine( Object... objects){ print(objects); writer.println(); } public void close(){ writer.close(); } } interface IntComparator{ public static final IntComparator DEFAULT = new IntComparator(){public int compare( int first, int second){ if ( (first < second)) return -1; if ( (first > second)) return 1; return 0;} }; public int compare( int first, int second); }
1	public class 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))); }} }
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 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(); } }
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));} }
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{ } }
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); } }
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());} }
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 ;} }} }
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(); } }
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"); } }
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));} }
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)); } }
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"); } }
1	public class Main{ public static void main( String[] args){ InputStream inputStream = System.in;  OutputStream outputStream = System.out;  FastReader in = new FastReader(inputStream);  PrintWriter out = new PrintWriter(outputStream);  TaskB solver = new TaskB(); solver.solve(1,in,out); out.close(); } } class TaskB{ int val[] ; int p[] ; int aneigh[] ,bneight[] ,deg[] ; Deque<Integer> mycycle ; boolean loops = false; public void solve( int testNumber, FastReader in, PrintWriter out){ int n = in.ni(); val = new int[n]; int a = in.ni();  int b = in.ni();  Map<Integer,Integer> set = new TreeMap<Integer,Integer>(); p = in.iArr(n); for ( int i = 0;(i < n);i++) {set.put(p[i],i); }aneigh = new int[n]; bneight = new int[n]; deg = new int[n]; for ( int i = 0;(i < n);i++) {aneigh[i] = val[i] = bneight[i] = -1; deg[i] = 0; } Queue<Integer> queue = new ArrayDeque<Integer>(); for ( int i = 0;(i < n);i++) { Integer x1 = set.get((a - p[i]));  Integer x2 = set.get((b - p[i])); if ( (x1 != null)) {aneigh[i] = x1; deg[i]++; } if ( ((x2 != null) && (a != b))) {bneight[i] = x2; deg[i]++; } if ( (deg[i] == 1)) {queue.add(i); } }while(!queue.isEmpty()){ int idx = queue.remove(); if ( (deg[idx] != 1)) {continue;} int aa = aneigh[idx];  int bb = bneight[idx]; if ( (aa != -1)) {val[idx] = val[aa] = 0; deg[aa]--; deg[idx]--; aneigh[aa] = -1; aneigh[idx] = -1; if ( (deg[aa] == 1)) { int zz = bneight[aa]; bneight[zz] = -1; deg[zz]--; if ( (deg[zz] == 1)) queue.add(zz); } } else {val[idx] = val[bb] = 1; deg[bb]--; deg[idx]--; bneight[idx] = bneight[bb] = -1; if ( (deg[bb] == 1)) { int zz = aneigh[bb]; aneigh[zz] = -1; deg[zz]--; if ( (deg[zz] == 1)) queue.add(zz); } }}for ( int i = 0;(i < n);i++) {if ( ((val[i] == -1) && cantBePaired(i))) {out.println("NO"); return ;} }for ( int i = 0;(i < n);i++) {if ( (val[i] == -1)) {mycycle = new ArrayDeque<Integer>(); loops = false; cycle(i); if ( (loops || ((mycycle.size() % 2) == 0))) {doEvenCycle(); continue;} out.println("NO"); return ;} }out.println("YES"); for ( int i = 0;(i < n);i++) {out.print((val[i] + " ")); }out.println(); } private boolean cantBePaired( int i){ int aa = aneigh[i];  int bb = bneight[i]; if ( ((aa != -1) && (val[aa] == -1))) {return false;} if ( ((bb != -1) && (val[bb] == -1))) {return false;} return true;} private void doEvenCycle(){ for ( int x :mycycle) {val[x] = 0; }} private void cycle( int i){ boolean aa = false;  int prev = i; mycycle.addLast(i); System.out.println(i); int j = aneigh[i]; while((j != i)){if ( (j == prev)) {loops = true; break;} mycycle.addLast(j); System.out.println(j); prev = j; j = (aa?aneigh[j]:bneight[j]); aa = !aa; }if ( loops) {j = bneight[i]; prev = i; aa = true; while((prev != j)){mycycle.addFirst(j); prev = j; j = (aa?aneigh[j]:bneight[j]); aa = !aa; }} System.out.println("XXX"); } } class FastReader{ public InputStream stream ; private byte[] buf = new byte[1024]; private int curChar ; private int numChars ; private SpaceCharFilter filter ; public FastReader( InputStream stream){ this.stream = stream; } public FastReader(){ } public int read(){ if ( (numChars == -1)) {throw (new InputMismatchException());} if ( (curChar >= numChars)) {curChar = 0; try{numChars = stream.read(buf); }catch (IOException e){ throw (new InputMismatchException());} if ( (numChars <= 0)) {return -1;} } return buf[curChar++];} public int ni(){ int c = read(); while(isSpaceChar(c))c = read(); int sgn = 1; if ( (c == '-')) {sgn = -1; c = read(); } int res = 0; do {if ( ((c < '0') || (c > '9'))) {throw (new InputMismatchException());} res *= 10; res += (c - '0'); c = read(); }while(!isSpaceChar(c));return (res * sgn);} public boolean isSpaceChar( int c){ if ( (filter != null)) {return filter.isSpaceChar(c);} return isWhitespace(c);} public static boolean isWhitespace( int c){ return (((((c == ' ') || (c == '\n')) || (c == '\r')) || (c == '\t')) || (c == -1));} public int[] iArr( int n){ int a[] = new int[n]; for ( int i = 0;(i < n);i++) {a[i] = ni(); }return a;} public interface SpaceCharFilter{ public boolean isSpaceChar( int ch); } }
0	public class 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(); } } }
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(); } }
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);} } }
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); } }
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());} }
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 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))); } }
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); } } }
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 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;} } }
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 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;} } }
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)); } }
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;} }
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 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));} }
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); }
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();} } }
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 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"); } }
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;} }
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(); } }
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();} } }
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)); } }
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); } }
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); } }
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); } }
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); } }
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"); }} }
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); } } }
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)); } }
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(); } }
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(); } } }
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"); }}} }
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 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());} } }
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 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));} }
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);} }
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());} } }
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;  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(); } }
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));}} }
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(); } }
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;} } }
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 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(); }} }
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(); } }
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());} }
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); } }
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; } }
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); } }
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 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());} }
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(); } }
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();} }
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); } }
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 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)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); } }
1	public class Beta17PA{ boolean[] isPrime = new boolean[1001]; int[] prime = new int[200]; public static void main( String[] args){ new Beta17PA().solve(); } public void solve(){ Scanner scan = new Scanner(System.in);  int n ,k ; n = scan.nextInt(); k = scan.nextInt(); init(); int m = 0; for ( int i = 2;(i <= n);i++) {if ( check(i)) m++; }if ( (m >= k)) System.out.println("YES"); else System.out.println("NO"); } private boolean check( int n){ if ( ((n < 6) || !isPrime[n])) return false; int d = (n - 1); for ( int i = 0;((i < 199) && ((prime[i] + prime[(i + 1)]) <= d));i++) {if ( ((prime[i] + prime[(i + 1)]) == d)) return true; }return false;} private void init(){ Arrays.fill(isPrime,true); isPrime[0] = isPrime[1] = false; for ( int i = 2;(i < 1001);i++) {if ( !isPrime[i]) continue; for ( int j = (i + i);(j < 1001);j += i) {isPrime[j] = false; }} int count = 0; for ( int i = 2;(i < 1001);i++) {if ( isPrime[i]) prime[count++] = i; }} }
3	public class 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 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());} }