import java . util . Scanner ;   public class Problem33 {   public static void main ( String [ ] args ) {

import java . util . * ;   public class Solution {    public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int testCases = in . nextInt ( ) ; in . nextLine ( ) ; for ( int i = 0 ; i < testCases ; i ++ ) { int len = in . nextInt ( ) ; in . nextLine ( ) ; String red = in . nextLine ( ) ; String blue = in . nextLine ( ) ; int rp = 0 , bp = 0 ; for ( int j = 0 ; j < len ; j ++ ) { int r = ( int ) ( red . charAt ( j ) ) - 48 ; int b = ( int ) ( blue . charAt ( j ) ) - 48 ; if ( r > b ) rp ++ ; else if ( r < b ) bp ++ ; } if ( rp > bp ) { System . out . println ( " RED " ) ; } else if ( rp == bp ) { System . out . println ( " EQUAL " ) ; } else { System . out . println ( " BLUE " ) ; } } } }

import java . util . * ; public class redcards { public static void main ( String [ ] args ) { int t , n , i , s1 , s2 ; char r [ ] ; char b [ ] ;   Scanner sc = new Scanner ( System . in ) ;   t = sc . nextInt ( ) ;   while ( t -- > 0 ) { n = sc . nextInt ( ) ;   r = sc . next ( ) . toCharArray ( ) ; b = sc . next ( ) . toCharArray ( ) ;   s1 = 0 ; s2 = 0 ;   for ( i = 0 ; i < n ; i ++ ) { if ( r [ i ] > b [ i ] ) { s1 ++ ; } else if ( r [ i ] < b [ i ] ) { s2 ++ ; } } if ( s1 > s2 ) System . out . println ( " RED " ) ; if ( s1 < s2 ) System . out . println ( " BLUE " ) ; if ( s1 == s2 ) System . out . println ( " EQUAL " ) ; }   }   }

import java . io . * ; import java . util . * ; public class Main { static BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; public static void main ( String [ ] args ) throws Exception { int t = Integer . parseInt ( in . readLine ( ) ) ; while ( t -- != 0 ) { int len = Integer . parseInt ( in . readLine ( ) ) ; String s1 = in . readLine ( ) ; String s2 = in . readLine ( ) ; if ( s1 . equals ( s2 ) ) out . println ( " EQUAL " ) ; else deal ( s1 , s2 ) ; } out . flush ( ) ; } static void deal ( String s1 , String s2 ) { int n1 = 0 , n2 = 0 ; for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) { if ( s1 . charAt ( i ) > s2 . charAt ( i ) ) n1 ++ ; if ( s1 . charAt ( i ) < s2 . charAt ( i ) ) n2 ++ ; } if ( n1 > n2 ) out . println ( " RED " ) ; else if ( n1 < n2 ) out . println ( " BLUE " ) ; else out . println ( " EQUAL " ) ; } }

import java . util . Scanner ; public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; String a = sc . next ( ) ; String b = sc . next ( ) ; int p = 0 , q = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a . charAt ( i ) > b . charAt ( i ) ) p ++ ; else if ( b . charAt ( i ) > a . charAt ( i ) ) q ++ ; } if ( p > q ) System . out . println ( " RED " ) ; else if ( q > p ) System . out . println ( " BLUE " ) ; elseSystem . out . println ( " EQUAL " ) ; } }   }

t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : n = int ( input ( ) ) NEW_LINE red_digits_str = input ( ) NEW_LINE blue_digits_str = input ( ) NEW_LINE greater_red_digit_count = 0 NEW_LINE greater_blue_digit_count = 0 NEW_LINE for digit_i in range ( n ) : r_digit = int ( red_digits_str [ digit_i ] ) NEW_LINE b_digit = int ( blue_digits_str [ digit_i ] ) NEW_LINE if r_digit > b_digit : NEW_LINE INDENT greater_red_digit_count += 1 elif b_digit > r_digit : NEW_LINE greater_blue_digit_count += 1 NEW_LINE DEDENT if greater_red_digit_count > greater_blue_digit_count : NEW_LINE INDENT print ( ' RED ' ) elif greater_blue_digit_count > greater_red_digit_count : NEW_LINE print ( ' BLUE ' ) else : NEW_LINE print ( ' EQUAL ' ) NEW_LINE DEDENT

import sys   NEW_LINE def main ( ) : inp = sys . stdin . read ( ) . strip ( ) . split ( ) NEW_LINE out = [ ] NEW_LINE for i in range ( 2 , len ( inp ) , 3 ) : s = sum ( ( - 1 ) ** ( x < y ) for x , y in zip ( inp [ i ] , inp [ i + 1 ] ) if x != y ) NEW_LINE out . append ( s and ( ' BLUE ' , ' RED ' ) [ s > 0 ] or ' EQUAL ' ) NEW_LINE return out NEW_LINE print ( * main ( ) , sep = ' \n ' ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = input ( ) NEW_LINE c = input ( ) NEW_LINE r = b = 0 NEW_LINE for i in range ( n ) : if NEW_LINE a [ i ] == c [ i ] : NEW_LINE continue elif a [ i ] > c [ i ] : r += 1 else : b += 1 NEW_LINE if r > b : NEW_LINE INDENT print ( " RED " ) elif b > r : NEW_LINE print ( " BLUE " ) else : NEW_LINE print ( " EQUAL " ) NEW_LINE DEDENT

def rec ( n , z , l , x , y ) : if NEW_LINE n > z : NEW_LINE return l elif n == z : l . append ( n ) NEW_LINE return l else : if n not in l : l . append ( n ) NEW_LINE rec ( n * x , z , l , x , y ) NEW_LINE rec ( n * y , z , l , x , y )     NEW_LINE def gcd ( x , y ) : if NEW_LINE x < y : x , y = y , x NEW_LINE if y == 0 : return x NEW_LINE return gcd ( y , x % y )     NEW_LINE def lcm ( x , y ) : if NEW_LINE x < y : x , y = y , x NEW_LINE gcd_ = gcd ( x , y ) NEW_LINE return x * y // gcd_     NEW_LINE def main_func ( ) : output_list = [ ] NEW_LINE t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n = int ( input ( ) ) NEW_LINE r = input ( ) NEW_LINE b = input ( ) NEW_LINE count_r = 0 NEW_LINE ountb = 0 NEW_LINE for i in range ( len ( r ) ) : if NEW_LINE int ( r [ i ] ) > int ( b [ i ] ) : count_r += 1 NEW_LINE if int ( r [ i ] ) < int ( b [ i ] ) : NEW_LINE INDENT ountb += 1 else : NEW_LINE ountb += 1 NEW_LINE DEDENT count_r += 1 NEW_LINE if count_r > ountb : NEW_LINE INDENT output_list . append ( " RED " ) elif count_r < ountb : NEW_LINE output_list . append ( " BLUE " ) else : NEW_LINE output_list . append ( " EQUAL " ) NEW_LINE DEDENT return " \n " . join ( output_list )     print ( main_func ( ) )       NEW_LINE


import java . util . * ; import java . io . * ; import static java . lang . Math . * ;   public class PracticeProblem { public static FastReader in = new FastReader ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ;   public static void main ( String [ ] args ) { solve ( ) ; out . close ( ) ; }   public static void solve ( ) { int n = in . nextInt ( ) ; double [ ] arr = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextDouble ( ) ;   Arrays . sort ( arr ) ;   if ( arr [ n - 1 ] == 1 ) { out . println ( 1. ) ; return ; }   double p = 1 - arr [ n - 1 ] ; double s = arr [ n - 1 ] / ( 1 - arr [ n - 1 ] ) ;   for ( int i = n - 2 ; i >= 0 ; i -- ) { if ( s > 1 ) break ; p *= 1 - arr [ i ] ; s += arr [ i ] / ( 1 - arr [ i ] ) ; }   out . println ( p * s ) ;   }   public static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . io . * ; import java . util . * ; public class Abc { public static void main ( String [ ] args ) throws Exception { FastReader sc = new FastReader ( ) ; int n = sc . nextInt ( ) ; double p [ ] = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ i ] = sc . nextDouble ( ) ; if ( p [ i ] == 1 ) { System . out . println ( 1 ) ; return ; } } Arrays . sort ( p ) ; double max = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { double pr = 1 ; double sum = 0 ; for ( int j = i ; j < n ; j ++ ) { pr *= ( 1D - p [ j ] ) ; } for ( int j = i ; j < n ; j ++ ) { sum += ( pr / ( 1 - p [ j ] ) ) * ( p [ j ] ) ; } max = Math . max ( max , sum ) ; } System . out . println ( max ) ; } 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 ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . Arrays ; import java . util . Scanner ;   public class _26_Andrey_and_Problem {   public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; double [ ] arr = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = scn . nextDouble ( ) ;   } Arrays . sort ( arr ) ; double res = 1 ; double add = 0 ; double max = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { double b = arr [ i ] ; res = res * ( ( double ) 1 - b ) ; if ( ! ( arr [ i ] < 1.0 ) ) { max = 1.0 ; break ; } double bs = arr [ i ] / ( 1 - arr [ i ] ) ; add = add + bs ; if ( res * ( add ) > max ) { max = res * add ; } } System . out . printf ( " % .10f \n " , max ) ; } }

import bisectn = int ( input ( ) ) ls = list ( map ( float , input ( ) . split ( ) ) ) ls . sort ( ) mx = ls [ - 1 ] idx = bisect . bisect_left ( ls , 0.5 ) if idx < n and ls [ idx ] < 0.5 : idx += 1   res = 0 st = 0 while ( st < idx - 1 ) : temp = 0 for i in range ( st , idx ) : t = 1 for j in range ( st , idx ) : if i != j : t = t * ( 1 - ls [ j ] ) temp += t * ls [ i ] res = max ( res , temp ) st += 1 res = max ( res , mx ) print ( " % .12f " % res ) NEW_LINE

n = int ( input ( ) ) from itertools import combinations   a = sorted ( list ( map ( float , input ( ) . split ( ) ) ) , reverse = True ) NEW_LINE

n = int ( input ( ) ) pr = list ( map ( float , input ( ) . split ( ) ) ) pr . sort ( reverse = True ) pr . insert ( 0 , 0 )   mx = 0 for k in range ( 1 , len ( pr ) ) : cur = 0 for j in range ( 1 , k + 1 ) : jth = 1 for i in range ( 1 , j ) : jth *= ( 1 - pr [ i ] ) jth *= pr [ j ] for i in range ( j + 1 , k + 1 ) : jth *= ( 1 - pr [ i ] ) cur += jth mx = max ( mx , cur ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;   public class Practice   { static FastReader sc = new FastReader ( ) ; static int mod = ( int ) Math . pow ( 10 , 9 ) + 7 ; static int dp [ ] [ ] ; ; public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ;

import java . io . * ; import java . lang . * ; import java . util . * ;   public class B877 { public static void main ( String [ ] args ) throws IOException { StringTokenizer st ; BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( f . readLine ( ) ) ; String curr = st . nextToken ( ) ; int op = 0 ; int n = curr . length ( ) ; int [ ] psums = new int [ n + 1 ] ; int [ ] psums1 = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( curr . charAt ( i ) == ' a ' ) { psums [ i + 1 ] = psums [ i ] + 1 ; psums1 [ i + 1 ] = psums1 [ i ] ; } else { psums1 [ i + 1 ] = psums1 [ i ] + 1 ; psums [ i + 1 ] = psums [ i ] ; } } f . close ( ) ; for ( int i = 0 ; i < n + 1 ; i ++ ) { for ( int x = i ; x < n + 1 ; x ++ ) { int p1 = psums [ i ] ; int p2 = psums1 [ x ] - psums1 [ i ] ; int p3 = psums [ n ] - psums [ x ] ; op = Math . max ( p1 + p2 + p3 , op ) ; } }    System . out . println ( op ) ; }   }

s = input ( )   dp = [ 0 , 0 , 0 ]   for i in s : if i == " a " : dp [ 2 ] = max ( dp ) + 1 dp [ 0 ] += 1 else : dp [ 1 ] = max ( dp [ 0 ] , dp [ 1 ] ) + 1 print ( max ( dp ) ) NEW_LINE

s = input ( ) a , ab , aba = 0 , 0 , 0 for i in s : if i == ' a ' : a += 1 aba = max ( ab , aba ) + 1 else : ab = max ( a , ab ) + 1 print ( max ( aba , ab , a ) ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . FileNotFoundException ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . FileReader ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Reader in = new Reader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskA { public void solve ( int testNumber , Reader in , PrintWriter out ) {   long x = in . nextLong ( ) ; long y = in . nextLong ( ) ; long m = in . nextLong ( ) ; if ( x >= m || y >= m ) { out . println ( 0 ) ; out . flush ( ) ; return ; } if ( x >= 0 && y >= 0 && m < Math . min ( x , y ) ) { out . println ( - 1 ) ; out . flush ( ) ; return ; } if ( x <= 0 && y <= 0 && m > Math . max ( x , y ) ) { out . println ( - 1 ) ; out . flush ( ) ; return ; } if ( m < 0 ) { m = - m ; x = - x ; y = - y ; } long c = 0 ; while ( x < m && y < m ) {   if ( x > y ) { long z = x ; x = y ; y = z ; }

x , y , m = map ( int , input ( ) . split ( ) ) x , y = min ( x , y ) , max ( x , y ) if y >= m : s = 0 elif x + y <= x : s = - 1 else : s = ( y - x + y - 1 ) // y x += y * s while max ( x , y ) < m : if x < y : x += y else : y += x s += 1 print ( s ) NEW_LINE

from sys import stdin , stdoutfrom math import ceilnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) def fn ( a , b ) : op = 0 while max ( a , b ) < m : a1 = max ( a , b ) + min ( a , b ) b1 = max ( a , b ) a , b = a1 , b1 op += 1 return opfor _ in range ( 1 ) : NEW_LINE

import osimport sysfrom io import BytesIO , IOBaseimport mathimport itertoolsimport bisectimport heapq NEW_LINE


import java . util . * ; import java . io . * ; import java . lang . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ;   for ( int i = 0 ; i < t ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; System . out . println ( Math . max ( ( a + b ) , ( c + d ) ) ) ; } }

import java . util . Scanner ;   public class B1445 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; int D = in . nextInt ( ) ; int answer = Math . max ( A + B , C + D ) ; System . out . println ( answer ) ; } }   }

import java . util . * ; public class HelloWorld {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; System . out . println ( Math . max ( ( a + b ) , ( c + d ) ) ) ; } } }

import java . util . Scanner ;   public class problem79 {   public static void main ( String [ ] args ) {

for t in range ( int ( input ( ) ) ) : a , b , c , d = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( max ( a + b , c + d ) ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE print ( max ( ( a + b ) , ( c + d ) ) ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : a , b , c , d = [ int ( j ) for j in input ( ) . split ( ) ] NEW_LINE e = a + b NEW_LINE f = c + d NEW_LINE if e > f : NEW_LINE INDENT print ( e ) else : NEW_LINE print ( f ) NEW_LINE DEDENT

for i in range ( int ( input ( ) ) ) : a = [ int ( j ) for j in input ( ) . split ( ) ] NEW_LINE print ( max ( a [ 0 ] + a [ 1 ] , a [ 2 ] + a [ 3 ] ) ) NEW_LINE


import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class Cat { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException { String str = sc . next ( ) ; if ( ! str . contains ( " Danil " ) && ! str . contains ( " Olya " ) && ! str . contains ( " Slava " ) && ! str . contains ( " Ann " ) && ! str . contains ( " Nikita " ) ) System . out . println ( " No " ) ; else { HashSet < String > hs = new HashSet < String > ( ) ; hs . add ( " Danil " ) ; hs . add ( " Olya " ) ; hs . add ( " Slava " ) ; hs . add ( " Ann " ) ; hs . add ( " Nikita " ) ; boolean flag = true ; int count = 0 ; for ( String i : hs ) { int index = 0 ; while ( true ) { index = str . indexOf ( i , index ) ; if ( index != - 1 ) { count ++ ; if ( count == 2 ) { System . out . println ( " No " ) ; flag = false ; break ; } index += i . length ( ) ; } else { break ; } } if ( ! flag ) break ; } if ( flag ) System . out . println ( " Yes " ) ; } }

import java . util . Scanner ;   public class AlexBrokenContest { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int c = 0 , i ; in . close ( ) ;   for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( i < s . length ( ) - 2 && s . substring ( i , i + 3 ) . equals ( " Ann " ) ) c ++ ; if ( i < s . length ( ) - 3 && s . substring ( i , i + 4 ) . equals ( " Olya " ) ) c ++ ; if ( i < s . length ( ) - 4 && s . substring ( i , i + 5 ) . equals ( " Danil " ) ) c ++ ; if ( i < s . length ( ) - 4 && s . substring ( i , i + 5 ) . equals ( " Slava " ) ) c ++ ; if ( i < s . length ( ) - 5 && s . substring ( i , i + 6 ) . equals ( " Nikita " ) ) c ++ ; } System . out . println ( c == 1 ? " YES " : " NO " ) ; } }

import sys   inp = sys . stdin . readlines ( ) ; ii = 0   out = [ ]   name = inp [ ii ] ii += 1   lst = [ ' Danil ' , ' Olya ' , ' Slava ' , ' Ann ' , ' Nikita ' ]   cnt = 0   for x in lst : cnt += name . count ( x )   if cnt == 1 : sys . stdout . write ( " YES " ) else : sys . stdout . write ( " NO " )     NEW_LINE

import re   str = ' Danil | Olya | Slava | Ann | Nikita ' if ( len ( re . findall ( str , input ( ) ) ) == 1 ) : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

s = input ( ) a = " Danil " b = " Olya " c = " Slava " d = " Ann " e = " Nikita " cnt = s . count ( a ) cnt += s . count ( b ) cnt += s . count ( c ) cnt += s . count ( d ) cnt += s . count ( e ) if cnt == 1 : print ( " YES " ) else : print ( " NO " ) NEW_LINE

def solve ( ) : m = 0 n , x = [ int ( j ) for j in input ( ) . split ( ) ] a = [ int ( мурк ) for мурк in input ( ) . split ( ) ] b = [ int ( k ) for k in input ( ) . split ( ) ] b . reverse ( ) for j in range ( n ) : if a [ j ] + b [ j ] <= x : m = m + 1 else : m = - 9999999999999999999 if m > 0 : print ( " YES " ) else : print ( " NO " ) def cmp ( key ) : return key [ 0 ] from math import floor , ceil NEW_LINE

s = str ( input ( ) ) l = [ ' Danil ' , ' Olya ' , ' Slava ' , ' Ann ' , ' Nikita ' ] c , c1 = 0 , 0 for i in l : if i in s : c = s . count ( i ) c1 += 1   if c == 1 and c1 == 1 : print ( " YES " ) else : print ( " NO " ) NEW_LINE


import java . util . * ; import java . util . Scanner ; import java . io . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ;   import javax . lang . model . util . ElementScanner6 ;   public class B592 { 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 ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String args [ ] ) { FastReader in = new FastReader ( ) ; int t = 1 ;

import java . io . * ; import java . math . * ; import java . util . * ;     public class Main {   private static int dx [ ] = { 1 , 0 , - 1 , 0 } ; private static int dy [ ] = { 0 , - 1 , 0 , 1 } ;   private static final long INF = Long . MAX_VALUE ; private static final int INT_INF = Integer . MAX_VALUE ; private static final long NEG_INF = Long . MIN_VALUE ; private static final int NEG_INT_INF = Integer . MIN_VALUE ; private static final double EPSILON = 1e-10 ;   private static final int MAX = 1000000007 ; private static final long MOD = 1000000007 ;   private static final int MAXN = 100007 ; private static final int MAXA = 100007 ; private static final int MAXLOG = 22 ;   public static void main ( String [ ] args ) throws IOException {   InputReader in = new InputReader ( System . in ) ;

import java . io . BufferedReader ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class monster {   public static void main ( String [ ] args ) {

n = int ( input ( ) ) print ( pow ( ( n - 2 ) , 2 ) ) NEW_LINE

n = int ( input ( ) ) print ( ( n - 2 ) * ( n - 2 ) ) NEW_LINE

n = int ( input ( ) ) if n == 3 : print ( 1 ) else : print ( ( n * ( n - 2 ) - ( n - 4 ) - n ) ) NEW_LINE

def STR ( ) : return list ( input ( ) ) def INT ( ) : return int ( input ( ) ) def MAP ( ) : return map ( int , input ( ) . split ( ) ) def MAP2 ( ) : return map ( float , input ( ) . split ( ) ) def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) def STRING ( ) : return input ( ) import stringimport sysfrom heapq import heappop , heappushfrom bisect import * from collections import deque , Counter , defaultdictfrom math import * from itertools import permutations , accumulatedx = [ - 1 , 1 , 0 , 0 ] dy = [ 0 , 0 , 1 , - 1 ] NEW_LINE


import java . math . BigDecimal ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String str = input . nextLine ( ) ; System . out . println ( new BigDecimal ( str ) . stripTrailingZeros ( ) . toPlainString ( ) + " " ) ; } }

import java . math . BigDecimal ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; BigDecimal a = input . nextBigDecimal ( ) ; long b = a . longValue ( ) ; if ( b == a . doubleValue ( ) ) System . out . println ( a . toBigInteger ( ) ) ; else System . out . println ( a . toPlainString ( ) ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import static java . util . Arrays . sort ; import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) {   FastScanner input = new FastScanner ( ) ;   String s = input . next ( ) ;   int point = s . indexOf ( " . " ) ;   int power = Integer . parseInt ( s . substring ( s . indexOf ( " e " ) + 1 ) ) ; s = s . substring ( 0 , s . indexOf ( " e " ) ) ;   point += power ; point ++ ; StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != ' . ' ) { if ( i == point ) { ans . append ( " . " ) ; } ans . append ( s . charAt ( i ) ) ; } }   point -= s . length ( ) ; while ( point -- > 0 ) { ans . append ( "0" ) ; }

from decimal import *   a = input ( ) b = Decimal ( a )   if ( int ( b ) == b ) : print ( " % d " % b ) else : print ( b ) NEW_LINE

from decimal import *   a = input ( ) b = Decimal ( a )   if ( round ( b ) == b ) : print ( " % d " % b ) else : print ( b ) NEW_LINE

s = input ( ) l , r = s . split ( ' e ' ) a , d = l . split ( ' . ' ) a = int ( a ) b = int ( r ) if int ( b ) : d = int ( str ( d ) [ - 1 : : - 1 ] ) for i in range ( b ) : a = a * 10 + d % 10 d //= 10 d = str ( d ) [ - 1 : : - 1 ] print ( a , end = ' ' ) if int ( d ) : print ( ' . ' , end = ' ' ) print ( d ) NEW_LINE


import java . util . Scanner ;   public class BuildContest { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , m = in . nextInt ( ) , a [ ] = new int [ n ] , i , j , z = n ;   for ( i = 0 ; i < m ; i ++ ) { int x = in . nextInt ( ) - 1 ; a [ x ] ++ ;   if ( a [ x ] == 1 ) z -- ; if ( z < 1 ) { for ( j = 0 ; j < n ; j ++ ) { a [ j ] -- ;   if ( a [ j ] < 1 ) z ++ ; } System . out . print ( 1 ) ; } else { System . out . print ( 0 ) ; } } in . close ( ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Map ; import java . util . Scanner ; import java . util . HashMap ;   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 ) ; BBuildAContest solver = new BBuildAContest ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class BBuildAContest { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int [ ] problemCounter = new int [ n ] ; Map < Integer , Integer > quantityCount = new HashMap < > ( ) ; int contests = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int p = in . nextInt ( ) - 1 ; problemCounter [ p ] ++ ; int curCount = problemCounter [ p ] ; quantityCount . put ( curCount , quantityCount . getOrDefault ( curCount , 0 ) + 1 ) ; if ( quantityCount . get ( contests + 1 ) == n ) { contests ++ ; out . print ( 1 ) ; } else { out . print ( 0 ) ; } } out . println ( ) ; }   } }

import java . io . * ; import java . util . * ;

from collections import defaultdict , deque , Counterfrom sys import stdin , stdoutfrom heapq import heappush , heappopimport mathimport ioimport osimport mathimport bisect   NEW_LINE

import collectionsn , m = map ( int , input ( ) . split ( ) ) d = collections . defaultdict ( set ) cnt = collections . defaultdict ( int ) for k in map ( int , input ( ) . split ( ) ) : cnt [ k ] += 1 d [ cnt [ k ] ] . add ( k ) if len ( d [ cnt [ k ] ] ) == n : print ( 1 , end = " " ) else : print ( 0 , end = " " ) NEW_LINE

def ints ( ) : return list ( map ( int , input ( ) . split ( ) ) ) n , le = ints ( ) l = ints ( ) d = [ 0 ] * nres = ' ' dis = 0 def chk ( n ) : global d global dis for i in range ( n ) : d [ i - 1 ] -= 1 if d [ i - 1 ] == 0 : dis -= 1 for i in range ( le ) : d [ l [ i ] - 1 ] += 1 if d [ l [ i ] - 1 ] == 1 : dis += 1 if dis == n : chk ( n ) print ( 1 , end = ' ' ) else : print ( 0 , end = ' ' )   NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) l1 = list ( map ( int , input ( ) . split ( ) ) )   freq = { } diff = 0 ans = " "   def update ( ) : global diff for i in range ( 1 , n + 1 ) : freq [ i ] -= 1 if ( freq [ i ] == 0 ) : diff -= 1 return     for i in range ( m ) : atual = l1 [ i ] if ( ( atual not in freq ) or freq [ atual ] == 0 ) : diff += 1 freq [ atual ] = 1 else : freq [ atual ] += 1   if ( diff == n ) : ans += "1" update ( ) else : ans += "0" print ( ans ) NEW_LINE


import java . util . * ; import java . io . * ; import java . lang . * ;    public class febchal { static int mod = 10000_00007 ;

import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; String row = input . next ( ) ; String col = input . next ( ) ; String ans = " " + row . charAt ( 0 ) + row . charAt ( row . length ( ) - 1 ) + col . charAt ( 0 ) + col . charAt ( col . length ( ) - 1 ) ;

import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . Stack ;   public class StronglyConnectedCity {   private static List < List < Integer > > adjList , adjList1 ; private static boolean [ ] vis ; private static Stack < Integer > stack ; private static int n , m ;   private static void dfs1 ( int u ) { vis [ u ] = true ; for ( int i : adjList . get ( u ) ) { if ( ! vis [ i ] ) dfs1 ( i ) ; } stack . add ( u ) ; }   private static void dfs2 ( int u ) { vis [ u ] = true ;

n , m = map ( int , input ( ) . split ( ) ) a = input ( ) b = input ( ) t = a [ 0 ] + b [ 0 ] + a [ - 1 ] + b [ - 1 ] if t == ' < v > ^ ' or t == ' > ^ < v ' : print ( " YES " ) else : print ( " NO " ) NEW_LINE

import math , sys , bisect , heapqfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulate NEW_LINE

import sys , os , ioimport math , bisect , operatorinf , mod = float ( ' inf ' ) , 10 ** 9 + 7 NEW_LINE


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { int n , k ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; Arrays . sort ( b ) ; int i = 0 , j = n - 1 , sum = 0 ; while ( k > 0 && b [ j ] > a [ i ] ) { sum += b [ j -- ] ; k -- ; i ++ ; } while ( i < n ) { sum += a [ i ++ ] ; } System . out . println ( sum ) ; t -- ; } } }

import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; import java . util . * ; public class B1353 { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int tc = sc . nextInt ( ) ; int n = 0 ; int x [ ] = new int [ 1000 ] ; int z = 0 ; int cap = 0 ; for ( int i = 0 ; i < tc ; i ++ ) { n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; int rr [ ] = new int [ n ] ; for ( int j = 0 ; j < n ; j ++ ) { arr [ j ] = sc . nextInt ( ) ; } for ( int y = 0 ; y < n ; y ++ ) { rr [ y ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; Arrays . sort ( rr ) ; int t = n - 1 ; for ( int b = 0 ; b < k ; b ++ ) { if ( rr [ t ] > arr [ b ] ) { arr [ b ] = rr [ t ] ; } t -- ; } int ans = 0 ; for ( int p = 0 ; p < n ; p ++ ) { ans = ans + arr [ p ] ; } x [ z ] = ans ; z ++ ;

import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int a = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int arra [ ] = new int [ a ] ; int arrb [ ] = new int [ a ] ; for ( int i = 0 ; i < a ; i ++ ) { arra [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < a ; i ++ ) { arrb [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arra ) ; Arrays . sort ( arrb ) ; int sum = 0 ; int pointb = a - 1 ; for ( int i = 0 ; i < a ; i ++ ) { if ( k > 0 & arra [ i ] < arrb [ pointb ] ) { k -- ; sum += arrb [ pointb ] ; pointb -- ; } else { sum += arra [ i ] ; } } System . out . println ( sum ) ; } } } ;

import java . util . * ; import java . io . * ; public class A { public static void main ( String ar [ ] ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { String nk [ ] = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; String str1 [ ] = br . readLine ( ) . split ( " ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = Integer . parseInt ( str1 [ i ] ) ; String str2 [ ] = br . readLine ( ) . split ( " ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) b [ i ] = Integer . parseInt ( str2 [ i ] ) ; System . out . println ( getMaxSum ( a , b , n , k ) ) ; } } public static int getMaxSum ( int a [ ] , int b [ ] , int n , int k ) { Arrays . sort ( a ) ; Arrays . sort ( b ) ; int count = 0 ; int curr = n - 1 ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < b [ curr ] && count < k ) { sum += b [ curr ] ; count ++ ; curr -- ; } else { sum += a [ i ] ; } } return sum ; } }

import java . util . * ;   public class TwoArraysAndSwap { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > l1 = new ArrayList < > ( ) ; List < Integer > l2 = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) l1 . add ( sc . nextInt ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) l2 . add ( sc . nextInt ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { int minIndex = l1 . indexOf ( Collections . min ( l1 ) ) ; int maxIndex = l2 . indexOf ( Collections . max ( l2 ) ) ; int min = l1 . get ( minIndex ) ; int max = Collections . max ( l2 ) ; if ( max > min ) { l1 . remove ( minIndex ) ; l1 . add ( max ) ; l2 . remove ( maxIndex ) ; } } int sum = 0 ; for ( int i = 0 ; i < l1 . size ( ) ; i ++ ) sum = sum + l1 . get ( i ) ; System . out . println ( sum ) ; } } }

if __name__ == ' _ _ main _ _ ' : t = int ( input ( ) ) while t > 0 : t -= 1 n , k = map ( int , input ( ) . split ( ) ) alist = input ( " " ) alist = [ int ( n ) for n in alist . split ( ) ] blist = input ( " " ) blist = [ int ( n ) for n in blist . split ( ) ] res = sum ( alist ) while k > 0 : k -= 1 alist . sort ( ) blist . sort ( ) if alist [ 0 ] < blist [ n - 1 ] : res += blist [ n - 1 ] - alist [ 0 ] tmp = alist [ 0 ] alist [ 0 ] = blist [ n - 1 ] blist [ n - 1 ] = tmp else : break print ( res )   NEW_LINE

test = int ( input ( ) ) while test > 0 : test -= 1 arr = [ int ( x ) for x in input ( ) . split ( ) ] n = arr [ 0 ] ; k = arr [ 1 ] a = [ int ( x ) for x in input ( ) . split ( ) ] b = [ int ( x ) for x in input ( ) . split ( ) ] a . sort ( ) ; b . sort ( ) a_index = 0 ; b_index = len ( b ) - 1 while a_index < n and b_index >= 0 and k > 0 : if a [ a_index ] < b [ b_index ] : NEW_LINE

for _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) x = min ( a ) ; y = max ( b ) xi = a . index ( x ) ; yi = b . index ( y ) if x >= y : print ( sum ( a ) ) else : i = 1 while ( x < y ) and ( i <= k ) : a [ xi ] , b [ yi ] = b [ yi ] , a [ xi ] x = min ( a ) y = max ( b ) xi = a . index ( x ) yi = b . index ( y ) i += 1 print ( sum ( a ) ) NEW_LINE

def main ( ) : t = int ( input ( ) ) for _ in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) b = sorted ( list ( map ( int , input ( ) . split ( ) ) ) , reverse = True ) for i in range ( k ) : if a [ i ] >= b [ i ] : break a [ i ] = b [ i ] print ( sum ( a ) )     if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

import heapqfor _ in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] b = [ int ( i ) for i in input ( ) . split ( ) ] heapq . heapify ( a ) heapq . heapify ( b ) c = heapq . nsmallest ( k , a ) d = heapq . nlargest ( k , b ) print ( sum ( a ) - sum ( c ) + sum ( heapq . nlargest ( k , c + d ) ) ) NEW_LINE


import java . util . * ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; while ( t -- > 0 ) {   int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int [ ] a = new int [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; }   for ( int i = 1 ; i < n ; i ++ ) { while ( a [ 0 ] < m && a [ i ] > 0 ) { a [ i ] -- ; a [ 0 ] ++ ; } if ( a [ 0 ] == m ) { break ; } } System . out . println ( a [ 0 ] ) ; } } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = Integer . parseInt ( scanner . nextLine ( ) ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; scanner . nextLine ( ) ; int sum = 0 ; String [ ] s = scanner . nextLine ( ) . split ( " ▁ " ) ; for ( int j = 0 ; j < n ; j ++ ) { sum += Integer . parseInt ( s [ j ] ) ; }   System . out . println ( sum >= m ? m : sum ) ;   }    } }

import java . util . * ; import java . io . * ; import java . math . * ;   public class Main   { static FastReader sc = new FastReader ( ) ; public static void main ( String [ ] args ) { StringBuffer sb = new StringBuffer ( " " ) ; int ttt = 1 ; ttt = i ( ) ; outer : while ( ttt -- > 0 ) { int n = i ( ) ; int k = i ( ) ; int A [ ] = input ( n ) ; int s = 0 ; for ( int i : A ) s += i ; System . out . println ( Math . min ( k , s ) ) ; }

import static java . lang . Integer . min ; import java . util . Scanner ;   public class Testing {   public static void main ( String [ ] args ) { Scanner x = new Scanner ( System . in ) ; short t = x . nextShort ( ) ; int [ ] finalanswer = new int [ t ] ; int counter = 0 ; for ( short i = 0 ; i < t ; i ++ ) { short n = x . nextShort ( ) ; int m = x . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( short j = 0 ; j < n ; j ++ ) a [ j ] = x . nextInt ( ) ; finalanswer [ counter ] = method1 ( a , m , n ) ; counter ++ ; } for ( int i = 0 ; i < t ; i ++ ) System . out . println ( finalanswer [ i ] ) ; } public static int method1 ( int [ ] a , int m , short n ) { int finalanswer ; int summation = 0 ; for ( short j = 0 ; j < n ; j ++ ) summation += a [ j ] ; finalanswer = min ( m , summation ) ; return finalanswer ; } }

t = int ( input ( ) ) for u in range ( t ) : n , m = map ( int , input ( ) . split ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] add = 0 for i in range ( 1 , n ) : add += a [ i ] print ( min ( m , a [ 0 ] + add ) ) NEW_LINE

t = int ( input ( ) )   for i in range ( t ) : n , m = tuple ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) )   s = sum ( a ) print ( min ( m , s ) )   NEW_LINE

for e in range ( int ( input ( ) ) ) : n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) first = l [ 0 ] l . sort ( ) if ( sum ( l ) >= m ) : print ( m ) else : print ( sum ( l ) ) NEW_LINE

t = int ( input ( ) ) for _ in range ( t ) : n , m = map ( int , input ( ) . split ( ) ) ali = list ( map ( int , input ( ) . split ( ) ) ) q = sum ( ali [ 1 : ] ) NEW_LINE


import java . util . Scanner ; public class A { static int val = 10000 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = " " ; int n = sc . nextInt ( ) ; for ( int i = 1 ; i <= val ; i ++ ) { s += i ; } System . out . println ( s . charAt ( n - 1 ) ) ;   } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Digit_Seq { 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 ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int k = in . nextInt ( ) ; long n = 1 ; int i = 0 ; String s = " " ; while ( s . length ( ) < k ) { s += n ; n ++ ; } System . out . println ( s . charAt ( k - 1 ) ) ; } }

import javax . swing . plaf . IconUIResource ; import javax . xml . crypto . dsig . spec . HMACParameterSpec ; import java . awt . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . List ;   import static java . lang . Math . * ; public class Main {   public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ;

import java . util . * ;   public class questionCF { public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 1 ; i <= n ; i ++ ) sb . append ( i ) ; System . out . println ( sb . charAt ( n - 1 ) ) ; } }

c = 1   x = int ( input ( ) ) string = " " while len ( string ) < x : string += str ( c ) c += 1   print ( string [ x - 1 ] ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : k = int ( input ( ) ) s = list ( range ( 1 , 10001 ) ) s = ' ' . join ( str ( c ) for c in s ) print ( s [ k - 1 ] ) NEW_LINE

k = int ( input ( ) ) lis = ' ' . join ( [ str ( i ) for i in range ( 1 , k + 1 ) ] ) print ( lis [ k - 1 ] ) NEW_LINE

n = int ( input ( ) ) s = " " i = 1 while len ( s ) < 10000 : s += str ( i ) i += 1   print ( s [ n - 1 ] ) NEW_LINE


import java . util . Scanner ;   public class Beautiful_Year {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; for ( int i = n + 1 ; ; i ++ ) { boolean check = true ; int arr [ ] = new int [ 10 ] ; int temp = i ; while ( temp > 0 ) { int ld = temp % 10 ; arr [ ld ] ++ ; temp = temp / 10 ; } for ( int j = 0 ; j < 10 ; j ++ ) { if ( arr [ j ] > 1 ) { check = false ; } } if ( check ) { System . out . println ( i ) ; break ; } } } }

import java . io . * ;   import java . lang . * ;    import java . util . * ;   public class TestA { 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 ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) {   try { System . setIn ( new FileInputStream ( " input . txt " ) ) ; System . setOut ( new PrintStream ( new FileOutputStream ( " output . txt " ) ) ) ; } catch ( Exception e ) { System . err . println ( " Error " ) ; }   FastReader objScanner = new FastReader ( ) ;   int n = objScanner . nextInt ( ) ;   int i = n + 1 ;   while ( true ) { if ( distinct ( i ) ) { System . out . println ( i ) ; break ; } i ++ ; }   }     static boolean distinct ( int n ) { String str = Integer . toString ( n ) ;   HashSet < Character > objSet = new HashSet < Character > ( ) ; int l = str . length ( ) ;   for ( int i = 0 ; i < l ; i ++ ) { objSet . add ( str . charAt ( i ) ) ; }   if ( objSet . size ( ) == l ) { return true ; } else { return false ; } } }

import java . util . Scanner ; public class year { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; while ( x > 0 ) { x = x + 1 ; int a = x % 10 ; int b = ( x / 10 ) % 10 ; int c = ( x / 100 ) % 10 ; int d = ( x / 1000 ) % 10 ; if ( a != b && a != c && a != d && b != c && b != d && c != d ) { break ; } else continue ; } System . out . println ( x ) ; } }

import java . util . * ; import java . lang . * ; import java . io . * ;   public class BeautifulYear271A { public static void main ( String [ ] args ) throws java . lang . Exception {

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . HashSet ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   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 ) ; ABeautifulYear solver = new ABeautifulYear ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class ABeautifulYear { public void solve ( int testNumber , FastScanner fs , PrintWriter out ) { int y = fs . nextInt ( ) , ans = y + 1 ; HashSet < Integer > dist = new HashSet < > ( ) ; for ( int i = y + 1 ; i <= 10000 ; i ++ ) { int t = i ; dist . clear ( ) ; boolean yes = true ; while ( t > 0 ) { int d = t % 10 ; if ( dist . contains ( d ) ) { yes = false ; break ; } dist . add ( d ) ; t /= 10 ; } if ( yes ) { out . println ( i ) ; break ; } } }   }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; }   public String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }

l = int ( input ( ) ) def split ( num ) : return list ( num ) for i in range ( l + 1 , 9013 ) : u = str ( i ) v = split ( u ) o = set ( v ) if len ( o ) == 4 : v = i breakprint ( v ) NEW_LINE

year = input ( ' ' ) while True : year = str ( int ( year ) + 1 ) nums = [ ] for y in year : if y not in nums : nums . append ( y ) if len ( nums ) == 4 : print ( year ) break NEW_LINE


import java . io . * ; import java . util . * ;   public class codeforces {   BufferedReader br ; StringTokenizer st ; public codeforces ( ) {

import java . util . Arrays ; import java . util . Scanner ;   public class SoldierBadges { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int c = 0 ; Arrays . sort ( a ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( a [ i ] == a [ j ] ) { ++ c ; a [ j ] ++ ; } } } System . out . println ( c ) ; } }

import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class pblm3 { static int sum ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ar = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) ar [ i ] = sc . nextInt ( ) ; Arrays . sort ( ar ) ; List < Integer > ll = new ArrayList < Integer > ( ) ; int i = 0 , val = 1 ; while ( val <= 3000 ) { while ( i < n && val < ar [ i ] ) ll . add ( val ++ ) ; val ++ ; i ++ ; } int sum = 0 ;

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) res = 0 a . sort ( ) for i in range ( n ) : if i > 0 and a [ i ] <= a [ i - 1 ] : res += a [ i - 1 ] + 1 - a [ i ] a [ i ] = a [ i - 1 ] + 1 print ( res ) NEW_LINE

import math , sysfrom collections import defaultdict , dequeimport bisect as bidef yes ( ) : print ( ' YES ' ) def no ( ) : print ( ' NO ' ) def I ( ) : return ( int ( sys . stdin . readline ( ) ) ) def In ( ) : return ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def Sn ( ) : return sys . stdin . readline ( ) . strip ( ) def Pr ( x ) : sys . stdout . write ( str ( x ) + ' \n ' ) NEW_LINE

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) s = sum ( l ) for i in range ( 1 , n ) : if l [ i ] <= l [ i - 1 ] : l [ i ] = l [ i - 1 ] + 1 print ( sum ( l ) - s ) NEW_LINE

from collections import defaultdictn = int ( input ( ) ) arr = tuple ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( int ) for i in arr : d [ i ] += 1 i = 0 ans = 0 while i <= n or d [ i - 1 ] != 0 : if d [ i ] : ans += d [ i ] - 1 d [ i + 1 ] += d [ i ] - 1 i += 1 print ( ans ) NEW_LINE


import java . io . * ; import java . util . * ; public class Lvl3Taser {   public static void main ( String [ ] args ) throws IOException {

n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = 0 ans = - 1f or i in range ( n - 1 ) : while c < n - 1 and a [ c + 1 ] - a [ i ] <= m : c += 1 if i < c - 1 : ans = max ( ans , ( a [ c ] - a [ i + 1 ] ) / ( a [ c ] - a [ i ] ) ) print ( ans )

n , m = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) c = 0 ans = - 1 for i in range ( n - 1 ) : while c < n - 1 and a [ c + 1 ] - a [ i ] <= m : c += 1 if i < c - 1 : ans = max ( ans , ( a [ c ] - a [ i + 1 ] ) / ( a [ c ] - a [ i ] ) ) print ( ans ) NEW_LINE

import sysinput = sys . stdin . readlinefrom bisect import *   n , U = map ( int , input ( ) . split ( ) ) E = list ( map ( int , input ( ) . split ( ) ) ) ans = - 1   for i in range ( n ) : j = i + 1 k = bisect_right ( E , E [ i ] + U ) - 1 if k - i >= 2 : ans = max ( ans , ( E [ k ] - E [ j ] ) / ( E [ k ] - E [ i ] ) )   print ( ans ) NEW_LINE

from bisect import bisect_left as bin , u = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) c = [ ] for i in range ( n - 1 ) : b = bi ( a , a [ i ] + u ) if b != n : if a [ b ] == a [ i ] + u : b = b + 1 b = a [ b - 1 ] if b - a [ i ] != 0 : c . append ( ( b - a [ i + 1 ] ) / ( b - a [ i ] ) ) if len ( c ) == 0 or max ( c ) == 0 : print ( - 1 ) else : print ( max ( c ) ) NEW_LINE

import mathimport sysfrom collections import dequefrom fractions import Fraction NEW_LINE


import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class temp4 { 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 ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static class Print { private final BufferedWriter bw ; public Print ( ) { bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; } public void print ( String str ) throws IOException { bw . append ( str ) ; } public void println ( String str ) throws IOException { print ( str ) ; bw . append ( " \n " ) ; } public void close ( ) throws IOException { bw . close ( ) ; } } public static void main ( String [ ] args ) throws IOException { FastReader scn = new FastReader ( ) ;

import java . util . * ; import java . lang . * ; import java . io . * ;   public class Ideone { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 1 + " ▁ " + 0 ) ; return ; } HashMap < Integer , Integer > set = getFactors ( n ) ; long ans = 1 ; int max = Integer . MIN_VALUE ; int min = Integer . MAX_VALUE ; for ( int num : set . keySet ( ) ) { ans *= num ; max = Math . max ( max , set . get ( num ) ) ; min = Math . min ( min , set . get ( num ) ) ; } if ( max == 1 ) { System . out . println ( n + " ▁ " + 0 ) ; return ; } int path = getPath ( max ) ; if ( noOfOnes ( max ) == 1 ) { if ( min == max ) {

from collections import defaultdicti = 2 n = int ( input ( ) ) dic = defaultdict ( lambda : 0 ) while n > 1 : if n % i == 0 : n //= i dic [ i ] += 1 else : i += 1 arr = list ( dic . values ( ) ) ln = len ( arr ) ans = [ 1 , 0 ] for el in dic . keys ( ) : ans [ 0 ] *= eltemp = 0 while True : onc = 0 for i in range ( ln ) : if arr [ i ] == 1 : onc += 1 if arr [ i ] % 2 == 1 : arr [ i ] += 1 temp += 1 arr [ i ] //= 2 if onc == ln : break ans [ 1 ] += 1 ans [ 1 ] += ( 1 if temp > ln and ans [ 1 ] > 0 else 0 ) print ( * ans )   NEW_LINE

import math   N = 10 ** 6 + 5 spf = [ - 1 ] * ( N + 1 ) for i in range ( N + 1 ) : spf [ i ] = ifor i in range ( 2 , int ( math . sqrt ( N ) ) + 1 ) : if spf [ i ] == i : for j in range ( i * 2 , N + 1 , i ) : if spf [ j ] == j : spf [ j ] = i   def factorize ( n ) : d = { } while n != 1 : p = spf [ n ] if p in d : d [ p ] += 1 else : d [ p ] = 1 n //= p return d   table = [ 0 ] * 31 table [ 0 ] = 1 for i in range ( 1 , 31 ) : table [ i ] = table [ i - 1 ] * 2   import bisectn = int ( input ( ) ) d = factorize ( n ) ans = 1 for k in d . keys ( ) : ans *= kcnt = 0 while True : cnt1 = 0 cnt_e = 0 max_v = 0 for k , v in d . items ( ) : if v == 1 : cnt1 += 1 if v % 2 == 0 : cnt_e += 1 max_v = max ( max_v , v ) if cnt1 == len ( d ) : break if cnt_e == len ( d ) : for k , v in d . items ( ) : d [ k ] = v // 2 cnt += 1 else : j = bisect . bisect_left ( table , max_v ) b = table [ j ] for k in d . keys ( ) : d [ k ] = b cnt += 1 print ( ans , cnt ) NEW_LINE

n = int ( input ( ) ) t = nn_ans = 1 i = 2 while i <= n : if n % i == 0 : n_ans *= i while n % i == 0 : n //= i i += 1   cnt = 0 tmp = n_answhile tmp % t != 0 : cnt += 1 tmp *= tmp   if tmp != t : cnt += 1 print ( n_ans , cnt )   NEW_LINE


import java . io . BufferedReader ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . io . * ; public class codeforces { static class Student { int x , y ; Student ( int x , int y ) { this . x = x ; this . y = y ;

# include < bits / stdc ++ . h > using namespace std ; int primes [ 100005 ] ; int s [ 100005 ] ; bool is [ 100005 ] ; void sieve ( ) { for ( int i = 2 ; i <= 100000 ; i ++ ) { if ( s [ i ] == 0 ) { s [ i ] = i ; for ( int j = i + i ; j <= 100000 ; j += i ) { if ( s [ j ] == 0 ) s [ j ] = i ; } } } return ; } int main ( ) { sieve ( ) ; int n , m ; cin >> n >> m ; while ( m -- ) { char f ; cin >> f ; if ( f == ' + ' ) { int a ; cin >> a ; if ( is [ a ] ) { cout << " Already ▁ on \n " ; } else { vector < int > pf ; int tmp = a ; bool t = false ; while ( tmp != 1 ) { if ( primes [ s [ tmp ] ] ) { cout << " Conflict ▁ with ▁ " << primes [ s [ tmp ] ] << ' \n ' ; t = true ; break ; } else { pf . push_back ( s [ tmp ] ) ; tmp /= s [ tmp ] ; } } if ( t ) continue ; for ( auto u : pf ) { primes [ u ] = a ; } is [ a ] = true ; cout << " Success \n " ; } } else { int a ; cin >> a ; if ( is [ a ] == false ) { cout << " Already ▁ off \n " ; } else { int tmp = a ; while ( tmp != 1 ) { primes [ s [ tmp ] ] = 0 ; tmp /= s [ tmp ] ; } is [ a ] = false ; cout << " Success \n " ; } } } return 0 ; }

import osimport sysfrom io import BytesIO , IOBase     BUFSIZE = 8192     class FastIO ( IOBase ) : newlines = 0   def __init__ ( self , file ) : self . _fd = file . fileno ( ) self . buffer = BytesIO ( ) self . writable = " x " in file . mode or " r " not in file . mode self . write = self . buffer . write if self . writable else None   def read ( self ) : while True : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) if not b : break ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines = 0 return self . buffer . read ( )   def readline ( self ) : while self . newlines == 0 : b = os . read ( self . _fd , max ( os . fstat ( self . _fd ) . st_size , BUFSIZE ) ) self . newlines = b . count ( b " \n " ) + ( not b ) ptr = self . buffer . tell ( ) self . buffer . seek ( 0 , 2 ) , self . buffer . write ( b ) , self . buffer . seek ( ptr ) self . newlines -= 1 return self . buffer . readline ( )   def flush ( self ) : if self . writable : os . write ( self . _fd , self . buffer . getvalue ( ) ) self . buffer . truncate ( 0 ) , self . buffer . seek ( 0 )     class IOWrapper ( IOBase ) : def __init__ ( self , file ) : self . buffer = FastIO ( file ) self . flush = self . buffer . flush self . writable = self . buffer . writable self . write = lambda s : self . buffer . write ( s . encode ( " ascii " ) ) self . read = lambda : self . buffer . read ( ) . decode ( " ascii " ) self . readline = lambda : self . buffer . readline ( ) . decode ( " ascii " )     sys . stdin , sys . stdout = IOWrapper ( sys . stdin ) , IOWrapper ( sys . stdout ) input = lambda : sys . stdin . readline ( ) . rstrip ( " \n " ) NEW_LINE

import random , math , sysfrom copy import deepcopy as dcfrom bisect import bisect_left , bisect_rightfrom collections import Counter   input = sys . stdin . readline     NEW_LINE

from sys import stdinimport mathn , k = map ( int , stdin . readline ( ) . rstrip ( ) . split ( " ▁ " ) )     a = [ [ ] for i in range ( n + 1 ) ] act = { } active = [ 0 ] * ( n + 1 )     for i in range ( 2 , n + 1 ) : if not a [ i ] : act [ i ] = 0 for j in range ( i , n + 1 , i ) : a [ j ] . append ( i )   storing = { } for _ in range ( k ) : s , v = stdin . readline ( ) . rstrip ( ) . split ( " ▁ " ) v = int ( v ) if s == " - " : if active [ v ] == 1 : print ( " Success " ) active [ v ] = 0 for i in list ( a [ v ] ) : act [ i ] = 0 else : print ( " Already ▁ off " ) else : if active [ v ] : print ( " Already ▁ on " ) else : test = 1 r = True for i in list ( a [ v ] ) : if act [ i ] : test = i r = False break if r : print ( " Success " ) active [ v ] = 1 for i in list ( a [ v ] ) [ : : - 1 ] : act [ i ] = v else : x = 0 print ( " Conflict ▁ with " , act [ test ] ) NEW_LINE


import java . io . IOException ; import java . util . * ; public class SagheerandCrossroads {   public static void main ( String [ ] args ) throws IOException {

import java . io . * ; import java . util . * ;   public class practice812a { public static void main ( String [ ] args ) throws Exception {

arr = [ ] for i in range ( 4 ) : arr . append ( input ( ) . split ( ) ) arr *= 3 flag = Truefor i in range ( 4 , 8 ) : if arr [ i ] [ 0 ] == '1' : if arr [ i - 1 ] [ 3 ] == '1' or arr [ i ] [ 3 ] == '1' : print ( ' YES ' ) flag = False break if arr [ i ] [ 1 ] == '1' : if arr [ i ] [ 3 ] == '1' or arr [ i + 2 ] [ 3 ] == '1' : print ( ' YES ' ) flag = False break if arr [ i ] [ 2 ] == '1' : if arr [ i ] [ 3 ] == '1' or arr [ i + 1 ] [ 3 ] == '1' : print ( ' YES ' ) flag = False breakif flag : print ( ' NO ' ) NEW_LINE

p = list ( map ( int , input ( ) . split ( ) ) ) q = list ( map ( int , input ( ) . split ( ) ) ) r = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) flag = 0 if p [ 3 ] == 1 : if p . count ( 1 ) > 1 or r [ 1 ] == 1 : flag = 1 NEW_LINE

p = list ( map ( int , input ( ) . split ( ) ) ) q = list ( map ( int , input ( ) . split ( ) ) ) r = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) flag = 0 if p [ 3 ] == 1 : if p . count ( 1 ) > 1 or r [ 1 ] == 1 or q [ 0 ] == 1 or s [ 2 ] == 1 : flag = 1 if q [ 3 ] == 1 : if q . count ( 1 ) > 1 or s [ 1 ] == 1 or r [ 0 ] == 1 or p [ 2 ] == 1 : flag = 1 if r [ 3 ] == 1 : if r . count ( 1 ) > 1 or p [ 1 ] == 1 or s [ 0 ] == 1 or q [ 2 ] == 1 : flag = 1 if s [ 3 ] == 1 : if s . count ( 1 ) > 1 or q [ 1 ] == 1 or p [ 0 ] == 1 or r [ 2 ] == 1 : flag = 1 if flag == 0 : print ( " NO " ) else : print ( " YES " )     NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   int N ; int Q ; List < Integer > [ ] adj ;   int [ ] centroids ; int [ ] sz ; int [ ] parent ; boolean [ ] visited ;   void run ( FastScanner in , PrintWriter out ) { N = in . nextInt ( ) ; Q = in . nextInt ( ) ;   adj = new List [ N + 1 ] ; centroids = new int [ N + 1 ] ; parent = new int [ N + 1 ] ; sz = new int [ N + 1 ] ;   for ( int i = 0 ; i < adj . length ; i ++ ) adj [ i ] = new ArrayList < > ( ) ;   for ( int i = 2 ; i <= N ; i ++ ) { int u = in . nextInt ( ) ; int v = i ; adj [ u ] . add ( v ) ; }   getsz ( 1 , - 1 ) ; dfsCentroid ( 1 ) ;   while ( Q -- > 0 ) { int t = in . nextInt ( ) ; out . println ( centroids [ t ] ) ; } }   void getsz ( int u , int p ) { sz [ u ] = 1 ; parent [ u ] = p ;   for ( int v : adj [ u ] ) { getsz ( v , u ) ; sz [ u ] += sz [ v ] ; } }    void dfsCentroid ( int u ) { if ( sz [ u ] == 1 ) { centroids [ u ] = u ; return ; }   int ptr = 0 ; for ( int v : adj [ u ] ) { dfsCentroid ( v ) ;

import operatorimport bisect   n , q = [ int ( s ) for s in input ( ) . split ( ) ]   ps = [ int ( s ) for s in input ( ) . split ( ) ]   childs = [ [ ] for _ in range ( n ) ]   for ( c , pa ) in enumerate ( ps ) : childs [ pa - 1 ] . append ( c + 1 ) toposort = [ ] this_level = [ 0 ] next_level = [ ] while len ( this_level ) > 0 : for this_n in this_level : toposort . append ( this_n ) for c in childs [ this_n ] : next_level . append ( c ) this_level = next_level next_level = [ ]   sz = [ 0 ] * npotentials = [ 0 ] * npotential_sz = [ 0 ] * npotential_lo = [ 0 ] * ncentr = [ 0 ] * n   for node in reversed ( toposort ) : if len ( childs [ node ] ) == 0 : centr [ node ] = node sz [ node ] = 1 else : s = 1 lg_c = - 1 lg_c_sz = 0 for c in childs [ node ] : s += sz [ c ] if sz [ c ] > lg_c_sz : lg_c_sz = sz [ c ] lg_c = c sz [ node ] = s if lg_c_sz <= sz [ node ] // 2 : centr [ node ] = node potentials [ node ] = [ node ] potential_sz [ node ] = [ sz [ node ] ] continue   potentials [ node ] = potentials [ lg_c ] potential_sz [ node ] = potential_sz [ lg_c ]   i = bisect . bisect_right ( potential_sz [ node ] , sz [ node ] // 2 , lo = potential_lo [ lg_c ] ) centr [ node ] = potentials [ node ] [ i ]   potentials [ node ] . append ( node ) potential_lo [ node ] = i potential_sz [ node ] . append ( sz [ node ] )   vs = [ int ( input ( ) ) - 1 for i in range ( q ) ] print ( ' \n ' . join ( [ str ( centr [ v ] + 1 ) for v in vs ] ) )         NEW_LINE


import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ;    public class file {

import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main implements Runnable { static int mod = 1000_000_007 ; static long lim = ( long ) 1e9 + 6 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static FastScanner f ; static int inf = 2000_000_000 ; static PrintWriter pw = new PrintWriter ( System . out ) ; static Scanner S = new Scanner ( System . in ) ; static long x0 ; static long y0 ; static long iinf = Long . MAX_VALUE ; static double eps = ( double ) 1e-6 ; public static void solve ( ) { long a = f . nl ( ) ; long b = f . nl ( ) ; boolean ok = true ; ok &= ( a - b ) == 1 && isPrime ( a + b ) ; pn ( ok ? " YES " : " NO " ) ; } public static void main ( String [ ] args ) throws IOException , InterruptedException { Thread thread = new Thread ( null , new Main ( ) , " F * uckit " , 1 << 28 ) ; thread . start ( ) ; thread . join ( ) ; } public void run ( ) { f = new FastScanner ( System . in ) ;

import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class a { static long [ ] count , count1 , count2 ; static int [ ] arr ; static char [ ] ch , ch1 ; static int [ ] darr , farr ; static Character [ ] [ ] mat , mat1 ; static long x , h ; static long maxl ; static double dec ; static String s ; static long minl ; static int mx = ( int ) 1e6 ; static long mod = 998244353l ;

import java . util . Scanner ; public class Tin { public static void main ( String [ ] args ) { Scanner tin = new Scanner ( System . in ) ; int t = tin . nextInt ( ) ; for ( int x = 0 ; x < t ; x ++ ) { boolean rhj = true ; long a = tin . nextLong ( ) ; long b = tin . nextLong ( ) ; long y = a + b ; for ( int z = 2 ; z <= Math . sqrt ( y ) ; z ++ ) { if ( y % z == 0 ) { rhj = false ; } } if ( rhj && a - b == 1 ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } } }

from math import sqrtfor _ in range ( int ( input ( ) ) ) : a , b = list ( map ( int , input ( ) . split ( ) ) ) if a - b != 1 : print ( " NO " ) else : c = a + b div = False for i in range ( 2 , int ( sqrt ( c ) ) + 2 ) : if c % i == 0 : div = True break if div : print ( " NO " ) else : print ( " YES " ) NEW_LINE

def isPrime ( x ) : i = int ( 2 ) if x == 2 : return True while ( i * i <= x ) : if x % i == 0 : return False i += 1 return True   for _ in range ( int ( input ( ) ) ) : a , b = map ( int , input ( ) . split ( ) ) if a - b == 1 and isPrime ( a + b ) : print ( " YES " ) else : print ( " NO " ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ; public class B { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int t = fs . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; while ( t -- > 0 ) { int n = fs . nextInt ( ) ; if ( ! a . contains ( n ) ) a . add ( n ) ; } int ans = - 1 ; if ( a . size ( ) < 4 ) { if ( a . size ( ) < 2 ) { ans = 0 ; } else if ( a . size ( ) == 2 ) { if ( ( a . get ( 1 ) - a . get ( 0 ) ) % 2 == 0 ) ans = Math . abs ( ( ( a . get ( 1 ) - a . get ( 0 ) ) / 2 ) ) ; else ans = Math . abs ( a . get ( 1 ) - a . get ( 0 ) ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; public class discounts {

import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int dp [ ] = new int [ 101 ] ; for ( int i = 0 ; i < n ; i ++ ) { dp [ s . nextInt ( ) ] ++ ; } int a = - 1 , b = - 1 , c = - 1 ; for ( int i = 0 ; i <= 100 ; i ++ ) { if ( dp [ i ] > 0 ) { if ( a == - 1 ) { a = i ; } else if ( b == - 1 ) { b = i ; } else if ( c == - 1 ) { c = i ; } else { System . out . println ( - 1 ) ; return ; } } } if ( b == - 1 && c == - 1 ) { System . out . println ( 0 ) ; return ; } if ( c == - 1 ) { if ( ( b - a ) % 2 == 0 ) { System . out . println ( ( b - a ) / 2 ) ; } else { System . out . println ( b - a ) ; } return ; } if ( 2 * b == a + c ) { System . out . println ( b - a ) ; } else { System . out . println ( - 1 ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import static java . lang . Math . * ; import static java . lang . System . out ; import java . util . * ; import java . io . PrintStream ; import java . io . PrintWriter ; public class A { static final int N = ( int ) ( 1e5 + 100 ) ; static final int mod = 1000000007 ; static final long temp = 998244353 ; static final long MOD = 1000000007 ; static final long M = ( long ) 1e9 + 7 ; static class Pair implements Comparable < Pair > { long first , second ; public Pair ( long aa , long bb ) { first = aa ; second = bb ; } public int compareTo ( Pair o ) { return ( int ) ( o . first - this . first ) ; } } static class Tuple implements Comparable < Tuple > { long first , second , third ; public Tuple ( long first , long second , long third ) { this . first = first ; this . second = second ; this . third = third ; } public int compareTo ( Tuple o ) { return ( int ) ( o . third - this . third ) ; } } public static class DSU { int [ ] parent ; int [ ] rank ;

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   ans = 1000   if n == 1 : print ( 0 ) exit ( ) if len ( set ( a ) ) == 1 : print ( 0 ) exit ( )   for s in range ( 101 ) : t = set ( ) for i in range ( n ) : x = abs ( s - a [ i ] ) if x == 0 : continue t . add ( x ) if len ( t ) == 1 : ans = min ( ans , list ( t ) [ 0 ] ) if ans == 1000 : print ( - 1 ) else : print ( ans ) NEW_LINE

def solve ( n , arr ) : unique_nums = sorted ( set ( arr ) )   if len ( unique_nums ) > 3 : return - 1   if len ( unique_nums ) == 2 : if ( unique_nums [ 1 ] - unique_nums [ 0 ] ) % 2 == 0 : return ( unique_nums [ 1 ] - unique_nums [ 0 ] ) // 2 return unique_nums [ 1 ] - unique_nums [ 0 ]   if len ( unique_nums ) == 1 : return 0 NEW_LINE

from sys import stdin , stdoutstdin . readlinedef mp ( ) : return list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) def it ( ) : return int ( stdin . readline ( ) . strip ( ) ) from math import ceilfrom collections import defaultdict as ddfrom collections import Counter as Cn = it ( ) l = sorted ( mp ( ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Squares_Seg { 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 ( Exception e ) {   e . printStackTrace ( ) ; }   } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return str ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } }   public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; long n = in . nextLong ( ) ; System . out . println ( Solve ( n ) ) ; } static long Solve ( long n ) { long l = 0 ; long r = n * 4L ; long ans = 0 ;   while ( l <= r ) { long mid = ( l + r ) / 2 ; if ( good ( mid , n ) ) { r = mid - 1 ; ans = mid ; } else { l = mid + 1 ; } } return ans ; } static boolean good ( long mid , long n ) { long x = mid / 2 ; long y = mid - mid / 2 ; return x * y >= n ; } }

import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class a { static int [ ] count , count1 , count2 ; static long [ ] arr ; static char [ ] ch , ch1 ; static int [ ] darr , farr ; static Character [ ] [ ] mat , mat1 ; static long x , h ; static long maxl ; static double dec ; static String s ; static long minl ; static int mx = ( int ) 1e6 ; static long mod = 998244353l ;

import java . io . * ; import java . util . * ; public class Main { static BufferedReader br ; static PrintWriter pr ; static int cin ( ) throws Exception { return Integer . valueOf ( br . readLine ( ) ) ; } static int [ ] split ( ) throws Exception { String [ ] cmd = br . readLine ( ) . split ( " ▁ " ) ; int [ ] ans = new int [ cmd . length ] ; for ( int i = 0 ; i < cmd . length ; i ++ ) { ans [ i ] = Integer . valueOf ( cmd [ i ] ) ; } return ans ; } static long [ ] splitL ( ) throws IOException { String [ ] cmd = br . readLine ( ) . split ( " ▁ " ) ; long [ ] ans = new long [ cmd . length ] ; for ( int i = 0 ; i < cmd . length ; i ++ ) { ans [ i ] = Long . valueOf ( cmd [ i ] ) ; } return ans ; } static int sum ( long n ) { int ans = 0 ; while ( n != 0 ) { ans = ans + ( int ) ( n % 10 ) ; n = n / 10 ; } return ans ; } static long gcd ( long x , long y ) { if ( x == 0 ) return y ; if ( y == 0 ) return x ; if ( x > y ) return gcd ( x % y , y ) ; else return gcd ( x , y % x ) ; } public static void main ( String [ ] args ) throws Exception {

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int sqrt = ( int ) ( Math . floor ( Math . sqrt ( n ) ) ) ; if ( n == sqrt * sqrt ) System . out . println ( 2 * sqrt ) ; else if ( n - ( sqrt * sqrt ) <= sqrt ) System . out . println ( 2 * sqrt + 1 ) ; else System . out . println ( 2 * sqrt + 2 ) ; } }

import math   n = int ( input ( ) )   res = [ ] sqrt = int ( math . sqrt ( n ) ) if sqrt * sqrt >= n : print ( sqrt * 2 ) elif ( sqrt + 1 ) * sqrt >= n : print ( sqrt * 2 + 1 ) elif ( sqrt + 1 ) * ( sqrt + 1 ) >= n : print ( sqrt * 2 + 2 ) NEW_LINE

n = int ( input ( ) ) i = int ( n ** 0.5 )   k = ( n + i - 1 ) // iprint ( i + k ) NEW_LINE

import mathn = int ( input ( ) ) nn = int ( math . sqrt ( n ) ) base = 2 * nnb2 = ( n - ( nn * nn ) ) b2 = math . ceil ( b2 / nn ) print ( base + b2 ) NEW_LINE

from math import ceil , sqrtn = int ( input ( ) ) if n == 1 : print ( 2 ) if n == 2 : print ( 3 ) elif n >= 3 : print ( ceil ( 2 * sqrt ( n ) ) ) NEW_LINE

import mathn = int ( input ( ) ) print ( math . ceil ( 2 * ( n ** 0.5 ) ) ) NEW_LINE


import java . util . Scanner ;   public class _0854TernarySequence {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { long sum = 0 ; int a [ ] = new int [ 3 ] ; int b [ ] = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < 3 ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } int min = 0 ; min = Math . min ( a [ 1 ] , b [ 0 ] ) ; a [ 1 ] -= min ; b [ 0 ] -= min ; min = Math . min ( a [ 0 ] , b [ 2 ] ) ; a [ 0 ] -= min ; b [ 2 ] -= min ; min = Math . min ( a [ 2 ] , b [ 1 ] ) ; a [ 2 ] -= min ; b [ 1 ] -= min ; sum += 2 * min ; sum -= 2 * Math . min ( a [ 1 ] , b [ 2 ] ) ; System . out . println ( sum ) ; t -- ; } }   }

import java . util . * ; public class nammekyahirakhahai { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; int i , j ; while ( t -- > 0 ) { int x1 = in . nextInt ( ) ; int y1 = in . nextInt ( ) ; int z1 = in . nextInt ( ) ; int x2 = in . nextInt ( ) ; int y2 = in . nextInt ( ) ; int z2 = in . nextInt ( ) ; int pos = 0 , neg = 0 ; pos = Math . min ( z1 , y2 ) ; z1 = z1 - pos ; y2 = y2 - pos ;

import java . util . * ; public class _1401B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) {   int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int z1 = sc . nextInt ( ) ;   int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; int z2 = sc . nextInt ( ) ;   int res = 0 , score = 0 ;   score = Math . min ( z1 , y2 ) ;

import java . io . * ; import java . math . BigInteger ; import java . util . * ; import java . util . StringTokenizer ;   public class Main1 {   public static void main ( String [ ] args ) throws IOException { FastReader fr = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int T = fr . nextInt ( ) ; for ( int aa = 0 ; aa < T ; aa ++ ) { int a = fr . nextInt ( ) , b = fr . nextInt ( ) , c = fr . nextInt ( ) , d = fr . nextInt ( ) , e = fr . nextInt ( ) , f = fr . nextInt ( ) ;

import java . util . Scanner ;   public class B1401 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int [ ] A = new int [ 3 ] ; int [ ] B = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { A [ i ] = in . nextInt ( ) ; } for ( int i = 0 ; i < 3 ; i ++ ) { B [ i ] = in . nextInt ( ) ; } int d = Math . min ( B [ 2 ] , A [ 0 ] ) ; B [ 2 ] -= d ; d = Math . min ( B [ 2 ] , A [ 2 ] ) ; B [ 2 ] -= d ; A [ 2 ] -= d ; int answer = 2 * ( Math . min ( A [ 2 ] , B [ 1 ] ) - B [ 2 ] ) ; System . out . println ( answer ) ; } }   }

for _ in range ( int ( input ( ) ) ) : x0 , x1 , x2 = map ( int , input ( ) . split ( ) ) y0 , y1 , y2 = map ( int , input ( ) . split ( ) ) res = 0 tmp = min ( x0 , y2 ) x0 -= tmp y2 -= tmp   tmp = min ( x1 , y0 ) x1 -= tmp y0 -= tmp   tmp = min ( x2 , y1 ) x2 -= tmp y1 -= tmp res += 2 * tmp   res -= 2 * min ( x1 , y2 ) print ( res ) NEW_LINE

t = int ( input ( ) )   ans = [ ]   while t : x1 , y1 , z1 = map ( int , input ( ) . split ( ) ) x2 , y2 , z3 = map ( int , input ( ) . split ( ) ) c = 0 abp = min ( z1 , y2 ) c = c + abp * 2 z3 = z3 - min ( z3 , x1 ) y1 = y1 - min ( x2 , y1 ) abn = min ( z3 , y1 ) c = c - abn * 2 ans . append ( c ) t = t - 1     for i in ans : print ( i ) NEW_LINE

cases = int ( input ( ) ) while cases : cases -= 1 zero , one , two = map ( int , input ( ) . split ( ) ) zero2 , one2 , two2 = map ( int , input ( ) . split ( ) )   ans = 0 two_mn = min ( two , one2 ) ans += ( two_mn * 2 )   one2 -= two_mn two -= two_mn   rem = two2 - ( two + zero )   ans -= max ( rem , 0 ) * 2   print ( ans )                 NEW_LINE

t = int ( input ( ) ) for i in range ( t ) : x1 , y1 , z1 = ( map ( int , input ( ) . split ( ) ) ) x2 , y2 , z2 = ( map ( int , input ( ) . split ( ) ) ) Sum = 0 sub = 0 if z1 <= y2 : Sum = 2 * z1 z1 = 0 else : Sum = 2 * y2 z1 = z1 - y2 if z1 + x1 <= z2 : z2 = z2 - ( z1 + x1 ) sub = 2 * z2 print ( Sum - sub ) NEW_LINE

for t in range ( int ( input ( ) ) ) : x1 , y1 , z1 = map ( int , input ( ) . split ( ) ) x2 , y2 , z2 = map ( int , input ( ) . split ( ) ) sm = 0 two1 = min ( z1 , y2 ) sm += ( 2 * two1 ) z1 -= two1 y2 -= two1 one0 = min ( y1 , x2 ) y1 -= one0 x2 -= one0 one1 = min ( y1 , y2 ) y1 -= one1 y2 -= one1 one2 = min ( z2 , y1 ) sm -= 2 * ( one2 ) z2 -= one2 y1 -= one2 print ( sm ) NEW_LINE


import mathimport sys   n = int ( raw_input ( ) ) mp = map ( int , raw_input ( ) . split ( ) )   cc = [ ] idx1 = - 1 idx2 = - 1   vsted = [ False ] * len ( mp ) all_even = True   for i in range ( 0 , len ( mp ) ) : if vsted [ i ] : continue   newc = [ ] x = i while not vsted [ x ] : vsted [ x ] = True newc . append ( x ) x = mp [ x ] - 1 if len ( newc ) == 1 : idx1 = len ( cc ) elif len ( newc ) == 2 : idx2 = len ( cc ) if len ( newc ) % 2 != 0 : all_even = False   cc . append ( newc ) if ( idx1 < 0 and idx2 < 0 ) or ( idx1 < 0 and not all_even ) : print " NO " sys . exit ( 0 )   print " YES " idx = 0 if idx1 < 0 : idx = idx2else : idx = idx1   for i in range ( 0 , len ( cc ) ) : if i == idx : continue for j in range ( 0 , len ( cc [ i ] ) ) : k = j % len ( cc [ idx ] ) print cc [ i ] [ j ] + 1 , cc [ idx ] [ k ] + 1   if idx == idx2 : print cc [ idx ] [ 0 ] + 1 , cc [ idx ] [ 1 ] + 1

# define _USE_MATH_DEFINES # define _CRT_SECURE_NO_DEPRECATE # include < iostream > # include < cstdio > # include < cstdlib > # include < vector > # include < sstream > # include < string > # include < map > # include < set > # include < algorithm > # include < cmath > # include < cstring > # include < queue > # include < time . h > using namespace std ; # define mp make_pair # define pb push_back # define all ( C ) ( C ) . begin ( ) , ( C ) . end ( ) # define sz ( C ) ( int ) ( C ) . size ( ) # define PRIME 123 # define PRIME1 31415 typedef long long int64 ; typedef unsigned long long uint64 ; typedef pair < int , int > pii ; typedef vector < int > vi ; typedef vector < vector < int > > vvi ;

# define _CRT_SECURE_NO_WARNINGS # include < cstdio > # include < iostream > # include < cstring > # include < string > # include < cmath > # include < algorithm > # include < vector > # include < set > # include < map > # include < queue > # include < cwctype > # include < functional > using namespace std ;   vector < vector < int > > group ; vector < pair < int , int > > ans ; int p [ 100005 ] ; bool f [ 100005 ] ; int n ;   void NO ( ) { printf ( " NO \n " ) ; exit ( 0 ) ; }   void YES ( ) { printf ( " YES \n " ) ; for ( int i = 0 ; i < ( int ) ans . size ( ) ; i ++ ) { printf ( " % d ▁ % d \n " , ans [ i ] . first + 1 , ans [ i ] . second + 1 ) ; } exit ( 0 ) ; }   int main ( ) {

import sysreadline = sys . stdin . readline   N = int ( readline ( ) ) P = list ( map ( lambda x : int ( x ) - 1 , readline ( ) . split ( ) ) )   PP = [ ] used = set ( ) for i in range ( N ) : if i not in used : res = [ ] while i not in used : used . add ( i ) res . append ( i ) i = P [ i ] PP . append ( res )   if any ( len ( p ) == 1 for p in PP ) : print ( ' YES ' ) for p in PP : if len ( p ) == 1 : break d = p [ 0 ] Ans = [ ] for i in range ( N ) : if i != d : Ans . append ( ' { } ▁ { } ' . format ( i + 1 , d + 1 ) ) print ( ' \n ' . join ( Ans ) ) elif not any ( len ( p ) == 2 for p in PP ) : print ( ' NO ' )   elif any ( len ( p ) & 1 for p in PP ) : print ( ' NO ' ) else : print ( ' YES ' ) dd = None for p in PP : if len ( p ) == 2 : dd = p PP . remove ( p ) break d1 , d2 = dd   Ans = [ ' { } ▁ { } ' . format ( d1 + 1 , d2 + 1 ) ] for p in PP : for i in range ( len ( p ) ) : if i & 1 : Ans . append ( ' { } ▁ { } ' . format ( d1 + 1 , p [ i ] + 1 ) ) else : Ans . append ( ' { } ▁ { } ' . format ( d2 + 1 , p [ i ] + 1 ) ) print ( ' \n ' . join ( Ans ) ) NEW_LINE

def read_data ( ) : n = int ( input ( ) ) ps = list ( map ( int , input ( ) . split ( ) ) ) return n , ps   def solve ( n , ps ) : ps = [ p - 1 for p in ps ] cycles = [ 0 ] * n roots = [ ] has_odd_cycle = False for i in range ( n ) : if cycles [ i ] > 0 : continue q = ps [ i ] cycle = 1 while q != i : cycle += 1 q = ps [ q ] if cycle & 1 : has_odd_cycle = True cycles [ i ] = cycle roots . append ( i ) q = ps [ i ] while q != i : cycles [ q ] = cycle q = ps [ q ] mincycle = min ( cycles ) if mincycle > 2 : return False , [ ] if mincycle == 1 : p = cycles . index ( 1 ) return True , [ ( p , i ) for i in range ( n ) if i != p ] if has_odd_cycle : return False , [ ] p = cycles . index ( 2 ) q = ps [ p ] edges = [ ( p , q ) ] for root in roots : if root == p or root == q : continue edges . append ( ( p , root ) ) r = ps [ root ] edges . append ( ( q , r ) ) r = ps [ r ] while r != root : edges . append ( ( p , r ) ) r = ps [ r ] edges . append ( ( q , r ) ) r = ps [ r ] return True , edges   n , ps = read_data ( ) is_possible , edges = solve ( n , ps ) if is_possible : print ( ' YES ' ) for a , b in edges : print ( a + 1 , b + 1 ) else : print ( ' NO ' ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static int mod = 1000000007 ;    int N ; List < Integer > [ ] adj ; long [ ] [ ] dp ; int [ ] c ; void run ( FastScanner in , PrintWriter out ) {   N = in . nextInt ( ) ; adj = new List [ N ] ; dp = new long [ N ] [ 2 ] ; c = new int [ N ] ; for ( int i = 0 ; i < adj . length ; i ++ ) adj [ i ] = new ArrayList < > ( ) ;   for ( int v = 1 ; v < N ; v ++ ) { int u = in . nextInt ( ) ; adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; }   for ( int i = 0 ; i < N ; i ++ ) c [ i ] = in . nextInt ( ) ;   go ( 0 , - 1 ) ; out . println ( dp [ 0 ] [ 1 ] ) ; }   void go ( int u , int p ) {

import java . io . * ; import java . util . * ; public class Solution { private static int [ ] a ; private static long [ ] [ ] dp ; private static final int mod = 1000000007 ; public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] from = new int [ n - 1 ] ; int [ ] to = new int [ n - 1 ] ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int u = Integer . parseInt ( st . nextToken ( ) ) ; from [ i ] = u ; to [ i ] = i + 1 ; } int [ ] [ ] g = construct ( n , from , to ) ;

import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static int mod = 1_000_000_007 ; long [ ] [ ] dp ; List < Integer > [ ] adj ; int [ ] x ; void run ( FastScanner in , PrintWriter out ) {   int n = in . nextInt ( ) ; adj = new List [ n ] ; for ( int i = 0 ; i < n ; i ++ ) adj [ i ] = new ArrayList < > ( ) ; for ( int v = 1 ; v < n ; v ++ ) { int u = in . nextInt ( ) ; adj [ u ] . add ( v ) ; adj [ v ] . add ( u ) ; } x = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) x [ i ] = in . nextInt ( ) ;

MOD = 10 ** 9 + 7     def topo_compute ( childrens , colors , parents ) : def f ( node , connected_to_black ) : if colors [ node ] == 1 and connected_to_black : return 0   children = childrens [ node ] if colors [ node ] == 1 or connected_to_black : ret = 1   for child in children : x = dp_conn [ child ] + dp_not_conn [ child ] x %= MOD   ret *= x ret %= MOD   return ret   s = 1 prefix_prod = [ ] for child in children : x = dp_conn [ child ] + dp_not_conn [ child ] x %= MOD s *= x s %= MOD prefix_prod . append ( s )   s = 1 suffix_prod = [ ] for child in reversed ( children ) : x = dp_conn [ child ] + dp_not_conn [ child ] x %= MOD s *= x s %= MOD suffix_prod . append ( s )   suffix_prod = list ( reversed ( suffix_prod ) )   ret = 0   for i in range ( len ( children ) ) : pre = prefix_prod [ i - 1 ] if i > 0 else 1 suf = suffix_prod [ i + 1 ] if i + 1 < len ( suffix_prod ) else 1   x = pre * suf x %= MOD   x *= dp_not_conn [ children [ i ] ] x %= MOD   ret += x ret %= MOD   return ret   NEW_LINE

mod = 10 ** 9 + 7 n = int ( input ( ) ) edges = list ( map ( int , input ( ) . split ( ) ) ) colored = list ( map ( int , input ( ) . split ( ) ) ) childs = [ [ ] for i in range ( n ) ]   for i in range ( 1 , n ) : childs [ edges [ i - 1 ] ] . append ( i )   dp = [ [ 0 , 0 ] for i in range ( n ) ]   for i in range ( n - 1 , - 1 , - 1 ) : prod = 1 for child in childs [ i ] : prod *= sum ( dp [ child ] ) if colored [ i ] : dp [ i ] = [ 0 , prod % mod ] else : sec = 0 for child in childs [ i ] : now = dp [ child ] [ 1 ] * prod // sum ( dp [ child ] ) sec += now dp [ i ] = [ prod % mod , sec % mod ]     print ( dp [ 0 ] [ 1 ] ) NEW_LINE


import java . io . BufferedWriter ; import java . io . ByteArrayInputStream ; import java . io . FileInputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . InputMismatchException ;   public class Main { private static final long MOD = ( long ) 1e9 + 7 ; static InputStream is ; static PrintWriter out ; static String INPUT = " " ; static int lenbuf = 0 , ptrbuf = 0 ; private static byte [ ] inbuf = new byte [ 1024 ] ; static boolean readFile = false ;

import java . util . Scanner ;   public class KidsMark { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; scanner . nextInt ( ) ; scanner . nextInt ( ) ; int sall = scanner . nextInt ( ) ; int sk = scanner . nextInt ( ) ;   int c = 0 ; int d = 0 ;   int a = sall - sk ; int b = n - k ; if ( b != 0 ) { c = a / b ; d = a % b ; } int e = sk / k ; int f = sk % k ;   StringBuilder ans = new StringBuilder ( ) ;   for ( int i = 0 ; i < b ; i ++ ) { int val = c ; if ( d > 0 ) { val ++ ; d -- ; }   ans . append ( val ) . append ( " ▁ " ) ; }   for ( int i = b ; i < n ; i ++ ) { int val = e ; if ( f > 0 ) { val ++ ; f -- ; }   ans . append ( val ) . append ( " ▁ " ) ; }   System . out . println ( ans ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Solution { private final static FastReader in = new FastReader ( ) ; private static final PrintWriter out = new PrintWriter ( System . out ) ;   public static void valeraAndContest ( int n , int k , int l , int r , int sa , int sk ) {   StringBuilder sb = new StringBuilder ( ) ; sa -= sk ; for ( int x = k ; x > 0 ; x -- ) { sb . append ( sk / x ) . append ( " ▁ " ) ; sk -= sk / x ; }   for ( int x = n - k ; x > 0 ; x -- ) { sb . append ( sa / x ) . append ( " ▁ " ) ; sa -= sa / x ; } out . println ( sb ) ;    }   public static void main ( String [ ] args ) { valeraAndContest ( in . nextInt ( ) , in . nextInt ( ) , in . nextInt ( ) , in . nextInt ( ) , in . nextInt ( ) , in . nextInt ( ) ) ; out . flush ( ) ;   }   private static final class FastReader { private static BufferedReader BF ; private static StringTokenizer ST ;   public FastReader ( ) { BF = new BufferedReader ( new InputStreamReader ( System . in ) ) ; ST = null ; }    public final String next ( ) { while ( ST == null || ! ST . hasMoreTokens ( ) ) { try { ST = new StringTokenizer ( BF . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return ST . nextToken ( ) ; }   final int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   }    }

import java . io . IOException ; import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) throws IOException {   Scanner in = new Scanner ( System . in ) ;   int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; int sa = in . nextInt ( ) ; int sk = in . nextInt ( ) ;   int [ ] ans = new int [ n ] ;   int dis = sk / k ; int rem = sk % k ; for ( int i = 0 ; i < k ; i ++ ) { ans [ i ] = dis ; if ( rem > 0 ) { ans [ i ] ++ ; rem -- ; } }   if ( n - k != 0 ) { dis = ( sa - sk ) / ( n - k ) ; rem = ( sa - sk ) % ( n - k ) ; }   for ( int i = k ; i < n ; i ++ ) { ans [ i ] = dis ; if ( rem > 0 ) { ans [ i ] ++ ; rem -- ; } }   for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( ans [ i ] + " ▁ " ) ; }

import java . util . Arrays ; import java . util . Scanner ;   public class ValeraContestV02 {   public static void main ( String [ ] args ) {

n , k , l , r , s , s1 = [ int ( i ) for i in input ( ) . split ( ) ] l2 = [ ] l1 = [ ] c = int ( s1 // k ) while ( len ( l1 ) < k ) : l1 . append ( c ) d = sum ( l1 ) if ( d == s1 ) : passelse : while ( d < s1 ) : for i in range ( 0 , len ( l1 ) ) : l1 [ i ] = l1 [ i ] + 1 d = d + 1 if ( d == s1 ) : break le = n - k while ( len ( l2 ) < le ) : l2 . append ( l ) e = sum ( l2 ) if ( e == ( s - s1 ) ) : passelse : while ( e < ( s - s1 ) ) : for i in range ( 0 , len ( l2 ) ) : l2 [ i ] = l2 [ i ] + 1 e = e + 1 if ( e == ( s - s1 ) ) : breakprint ( * ( l1 + l2 ) ) NEW_LINE

n , k , l , r , sa , sk = map ( int , input ( ) . split ( " ▁ " ) ) ans = [ sk // k ] * ( k - sk % k ) + [ sk // k + 1 ] * ( sk % k ) n -= kif n != 0 : sa -= sk ans1 = [ sa // n ] * ( n - sa % n ) + [ sa // n + 1 ] * ( sa % n ) ans += ans1ans = [ str ( i ) for i in ans ] print ( " ▁ " . join ( ans ) ) NEW_LINE

def main ( ) : n , k , l , r , s_all , s_k = map ( int , input ( ) . split ( ) ) ans = [ ] for i in range ( k ) : if i < s_k % k : ans . append ( s_k // k + 1 ) else : ans . append ( s_k // k ) s_r = s_all - s_k for i in range ( n - k ) : if i < s_r % ( n - k ) : ans . append ( s_r // ( n - k ) + 1 ) else : ans . append ( s_r // ( n - k ) ) print ( * ans )     if __name__ == " _ _ main _ _ " : main ( ) NEW_LINE

import mathn , k , l , r , sall , sk = map ( int , input ( ) . split ( ) ) osk , ok = sk , klst = [ ] while k : x = math . ceil ( sk / k ) lst . append ( x ) k -= 1 sk -= xv = n - oksall -= oskwhile v : x = math . ceil ( sall / v ) lst . append ( x ) v -= 1 sall -= xprint ( * lst ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Spotlights {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class CF0729B_Spotlights { static class Scanner { BufferedReader br ; StringTokenizer st ;   public Scanner ( ) { 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 ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static int solution ( int n , int m , boolean [ ] [ ] actors ) { int [ ] [ ] ans = new int [ n ] [ m ] ;

import java . io . * ; import java . util . StringTokenizer ; import java . util . * ; import java . lang . * ;   public class Spotlights { public static void main ( String [ ] args ) throws IOException {

import java . util . * ; import java . io . * ; import java . math . * ;   public class First { public static void process ( ) throws IOException { int n = ni ( ) ; int m = ni ( ) ; int a [ ] [ ] = new int [ n ] [ m ] ; int h [ ] [ ] = new int [ n ] [ m ] ; int v [ ] [ ] = new int [ n ] [ m ] ;   for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { a [ i ] [ j ] = ni ( ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( j == 0 ) { if ( a [ i ] [ j ] == 1 ) { h [ i ] [ j ] = 1 ; } else { h [ i ] [ j ] = 0 ; } } else { if ( a [ i ] [ j ] == 1 ) { h [ i ] [ j ] = h [ i ] [ j - 1 ] + 1 ; } else { h [ i ] [ j ] = h [ i ] [ j - 1 ] ; } } } } for ( int j = 0 ; j < m ; j ++ ) { for ( int i = 0 ; i < n ; i ++ ) { if ( i == 0 ) { if ( a [ i ] [ j ] == 1 ) { v [ i ] [ j ] = 1 ; } else { v [ i ] [ j ] = 0 ; } } else { if ( a [ i ] [ j ] == 1 ) { v [ i ] [ j ] = v [ i - 1 ] [ j ] + 1 ; } else { v [ i ] [ j ] = v [ i - 1 ] [ j ] ; } } } }

n , m = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( n ) : k = list ( map ( int , input ( ) . split ( ) ) ) l . append ( k ) ans = 0 for i in range ( n ) : for j in range ( m ) : if l [ i ] [ j ] == 1 : for k in range ( j , m ) : if l [ i ] [ k ] == 0 : ans = ans + 1 breakfor i in range ( n ) : for j in range ( m - 1 , - 1 , - 1 ) : if l [ i ] [ j ] == 1 : for k in range ( j - 1 , - 1 , - 1 ) : if l [ i ] [ k ] == 0 : ans = ans + 1 breakfor i in range ( m ) : for j in range ( n ) : if l [ j ] [ i ] == 1 : for k in range ( j + 1 , n ) : if l [ k ] [ i ] == 0 : ans = ans + 1 breakfor i in range ( m ) : for j in range ( n - 1 , - 1 , - 1 ) : if l [ j ] [ i ] == 1 : for k in range ( j - 1 , - 1 , - 1 ) : if l [ k ] [ i ] == 0 : ans = ans + 1 breakprint ( ans ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) s = [ input ( ) . split ( ) for g in range ( n ) ] ans = 0 for i in range ( n ) : cur = s [ i ] prev_1 = 0 prev_0 = 0 for j in cur : if j == '1' : ans += prev_0 prev_0 = 0 prev_1 = 1 else : ans += prev_1 prev_0 += 1 for i in range ( m ) : prev_1 = 0 prev_0 = 0 for t in range ( n ) : j = s [ t ] [ i ] if j == '1' : ans += prev_0 prev_0 = 0 prev_1 = 1 else : ans += prev_1 prev_0 += 1 print ( ans ) NEW_LINE