import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class B_Maria_Breaks_the_Self_isolation {   static int testCases , n ; static Scanner scanner = new Scanner ( ) ; static void merge ( long a [ ] , int left , int right , int mid ) { int n1 = mid - left + 1 , n2 = right - mid ; long L [ ] = new long [ n1 ] ; long R [ ] = new long [ n2 ] ; for ( int i = 0 ; i < n1 ; i ++ ) { L [ i ] = a [ left + i ] ; } for ( int i = 0 ; i < n2 ; i ++ ) { R [ i ] = a [ mid + 1 + i ] ; } int i = 0 , j = 0 , k = left ; while ( i < n1 && j < n2 ) { if ( L [ i ] <= R [ j ] ) { a [ k ] = L [ i ] ; i ++ ; } else { a [ k ] = R [ j ] ; j ++ ; } k ++ ; } while ( i < n1 ) { a [ k ] = L [ i ] ; k ++ ; i ++ ; } while ( j < n2 ) { a [ k ] = R [ j ] ; j ++ ; k ++ ; } } static void mergeSort ( long a [ ] , int left , int right ) { if ( left >= right ) { return ; } int mid = ( left + right ) / 2 ; mergeSort ( a , left , mid ) ; mergeSort ( a , mid + 1 , right ) ; merge ( a , left , right , mid ) ; } static void solve ( ) throws IOException { n = scanner . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextLong ( ) ; } mergeSort ( a , 0 , a . length - 1 ) ;

import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ;   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 {   FastScanner input = new FastScanner ( ) ; int tc = input . nextInt ( ) ; work : while ( tc -- > 0 ) { int n = input . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } sort ( a ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( a [ i ] <= ( i + 1 ) ) { System . out . println ( i + 2 ) ; continue work ; } } System . out . println ( "1" ) ; }   }   static class FastScanner {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ;   String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }

import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . stream . Collectors ; public class test { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tests = sc . nextInt ( ) ; for ( int t = 0 ; t < tests ; t ++ ) { int n = sc . nextInt ( ) ; int [ ] tab = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { tab [ i ] = sc . nextInt ( ) ; } Arrays . sort ( tab ) ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( tab [ i ] <= i + 1 ) { count = i + 1 ; } } System . out . println ( count + 1 ) ; } } }

import java . util . * ;   public class Practise {   static int [ ] [ ] dp ;   static long sum = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) {   int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ;   } Arrays . sort ( arr ) ; int incourt = n ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( incourt >= arr [ i ] ) { break ; } else incourt -- ;   } System . out . println ( incourt + 1 ) ;

from collections import defaultdict   t = int ( input ( ) )   while t != 0 : balance = 0 seen = 1 a = defaultdict ( int ) n = int ( input ( ) ) for i in map ( int , input ( ) . split ( ) ) : a [ i ] += 1 a = dict ( sorted ( a . items ( ) , key = lambda x : x [ 0 ] ) ) for key , value in a . items ( ) : if balance + value + seen - 1 >= key : seen += ( balance + value ) balance = 0 else : balance += value print ( seen ) t -= 1 NEW_LINE

t = int ( input ( ) ) for i in range ( t ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) s = 1 arr . sort ( ) NEW_LINE

t = int ( input ( ) ) for a in range ( t ) : n = int ( input ( ) ) bt = list ( map ( int , input ( ) . split ( ) ) ) bt . sort ( ) NEW_LINE

import matht = int ( input ( ) ) for i in range ( t ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) ans = n + 1 k = n - 1 for j in range ( n ) : if ( a [ k ] < ans ) : break ans = ans - 1 k = k - 1 print ( ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ;   public class FarewellParty { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; String [ ] input = br . readLine ( ) . split ( " ▁ " ) ; int [ ] peopleWearingSame = new int [ n ] ; int [ ] freq = new int [ n + 1 ] ; int [ ] answer = new int [ n ] ; int counter = 1 ; for ( int i = 0 ; i < n ; i ++ ) { peopleWearingSame [ i ] = n - Integer . parseInt ( input [ i ] ) ; freq [ peopleWearingSame [ i ] ] ++ ; if ( peopleWearingSame [ i ] == 1 ) { answer [ i ] = counter ; counter ++ ; } } for ( int i = 2 ; i <= n ; i ++ ) { if ( freq [ i ] % i != 0 ) { System . out . println ( " Impossible " ) ; System . exit ( 0 ) ; } else { if ( freq [ i ] != 0 ) { int counter2 = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( peopleWearingSame [ j ] == i ) { counter2 ++ ; answer [ j ] = counter ; if ( counter2 == i ) { counter ++ ; counter2 = 0 ; } } } } } } System . out . println ( " Possible " ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( answer [ i ] + " ▁ " ) ; } System . out . println ( ) ; } }

import java . io . * ; import java . util . * ;   public class FarewellParty {   public static void main ( String [ ] args ) { FastScanner in = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; int a [ ] = in . readArray ( n ) ; int b [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) b [ i ] = n - a [ i ] ; int vis [ ] = new int [ n ] ; int ans [ ] = new int [ n ] ; int k = 1 ; boolean verdict = true ; for ( int i = 0 ; i < n ; i ++ ) { int cnt = 0 ; if ( vis [ i ] != 1 ) { for ( int j = i ; j < n ; j ++ ) { if ( b [ j ] == b [ i ] && vis [ j ] != 1 ) { cnt ++ ; ans [ j ] = k ; vis [ j ] = 1 ;

import java . util . * ; import java . lang . Math ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] hats = new int [ n ] ; int [ ] [ ] myArr = new int [ 3 ] [ n ] ; int available = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int temp = scan . nextInt ( ) ; myArr [ 0 ] [ temp ] ++ ; hats [ i ] = temp ; } for ( int i = 0 ; i < n ; i ++ ) { if ( myArr [ 0 ] [ i ] % ( n - i ) != 0 ) { System . out . println ( " Impossible " ) ; return ; } } for ( int i = 0 ; i < n ; i ++ ) { int hatNum = hats [ i ] ; if ( myArr [ 2 ] [ hatNum ] == 0 ) { myArr [ 1 ] [ hatNum ] = available ++ ; } hats [ i ] = myArr [ 1 ] [ hatNum ] ; myArr [ 2 ] [ hatNum ] ++ ; myArr [ 2 ] [ hatNum ] %= n - hatNum ; } if ( available > n + 1 ) { System . out . println ( " Impossible " ) ; } System . out . println ( " Possible " ) ; for ( int x : hats ) System . out . print ( x + " ▁ " ) ; } }

from collections import defaultdictn = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( list ) for j in range ( n ) : d [ a [ j ] ] . append ( j ) f = 0 m = 1 for v in d : p = n - v if len ( d [ v ] ) % p != 0 : f = 1 break else : while d [ v ] != [ ] : for j in range ( p ) : q = d [ v ] . pop ( ) a [ q ] = m m = m + 1 if f == 0 : print ( ' Possible ' ) print ( ' ▁ ' . join ( map ( str , a ) ) ) else : print ( ' Impossible ' ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   c = 1 res = [ ] d = { } v = { } ok = Truefor item in a : if d . get ( item , 0 ) == 0 : d [ item ] = n - item - 1 v [ item ] = c c += 1 else : d [ item ] -= 1 res . append ( v [ item ] )   for k , v in d . items ( ) : if v != 0 : ok = False breakif ok : print ( ' Possible ' ) print ( ' ▁ ' . join ( map ( str , res ) ) ) else : print ( ' Impossible ' )     NEW_LINE

n = int ( input ( ) ) k = 0 d = { } i = 0 for x in map ( int , input ( ) . split ( ) ) : d . setdefault ( n - x , [ ] ) . append ( i ) ; i += 1 b = [ 0 ] * ng = 0 for x in d : l = d [ x ] ; g += 1 ; j = 0 if len ( l ) % x : print ( ' Impossible ' ) ; break for i in l : if j == x : j = 0 ; g += 1 b [ i ] = g ; j += 1 else : print ( ' Possible ' , * b ) NEW_LINE


import java . util . * ;   public class Maximal_Continuous_Rest { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long [ ] arr = new long [ ( int ) ( 2 * n ) ] ; List < Long > l = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; }

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 n = fs . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; int len = 0 ; int curr = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int b = fs . nextInt ( ) ; a . add ( b ) ; if ( b == 0 ) { len = Math . max ( len , curr ) ; curr = 0 ; } else { curr ++ ; } } for ( int b : a ) { if ( b == 0 ) { len = Math . max ( len , curr ) ; curr = 0 ; } else { curr ++ ; } } System . out . println ( len ) ; } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . util . Scanner ;   public class Apple {   public static void main ( String args [ ] ) {   try {   Scanner sc = new Scanner ( System . in ) ;   int T = sc . nextInt ( ) ; System . out . println ( ) ;   while ( T > 0 ) {   int A [ ] = new int [ T ] ;   for ( int i = 0 ; i < T ; i ++ ) {   A [ i ] = sc . nextInt ( ) ;   }   int B [ ] = new int [ 2 * T ] ;   for ( int i = 0 ; i < T ; i ++ ) {   B [ i ] = A [ i ] ;   }   for ( int i = T ; i < 2 * T ; i ++ ) {   B [ i ] = A [ i - T ] ;   }   int count = 0 ; int result = 0 ;   for ( int i = 0 ; i < 2 * T ; i ++ ) {   if ( B [ i ] == 0 ) { count = 0 ; } else {   count ++ ; result = Math . max ( result , count ) ; } }   System . out . println ( result ) ;   T -- ; }   } catch (   Exception e ) { return ;   } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashMap ; import java . util . Map ; import java . util . StringTokenizer ;   public class B_Maximal_Continuous_Rest {   static Scanner scanner = new Scanner ( ) ; static long n ; static Map < Long , Long > map = new HashMap < > ( ) ; public static void main ( String [ ] args ) throws IOException { n = scanner . nextLong ( ) ; long index = 1 ; while ( index <= n ) { map . put ( index , scanner . nextLong ( ) ) ; index ++ ; }

import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int a = 0 , b = 0 , temp = 0 , c = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) a ++ ; else break ; } for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] == 1 ) b ++ ; else break ; } for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 1 ) c ++ ; else c = 0 ; temp = Math . max ( temp , c ) ; } System . out . println ( Math . max ( temp , a + b ) ) ; } }

from itertools import groupbyn = int ( input ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) B = A * 2 g = groupby ( B ) ans = max ( len ( list ( v ) ) if k == 1 else 0 for k , v in g ) print ( ans ) NEW_LINE

n = int ( input ( ) ) hours = [ int ( i ) for i in input ( ) . split ( ) ] hours += hourscounter = 0 max_rest = 0 for hour in hours : if hour == 1 : counter += 1 if counter > max_rest : max_rest = counter else : counter = 0 print ( max_rest ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) ans = 0 consecutive = 0 for i in range ( n ) : if a [ i ] == 1 : consecutive += 1 else : consecutive = 0 ans = max ( ans , consecutive ) L = 0 for i in range ( n ) : if a [ i ] == 1 : L += 1 else : breakR = 0 for i in range ( n - 1 , - 1 , - 1 ) : if a [ i ] == 1 : R += 1 else : breakprint ( max ( ans , min ( n , L + R ) ) ) NEW_LINE

n = int ( input ( ) ) a = list ( input ( ) . split ( ) ) b = a * 2 bb = ' ' . join ( b ) c = bb . split ( '0' ) ans = 0 for i in c : ans = max ( ans , len ( i ) ) print ( ans ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) p = [ ] ; c = 0 for i in range ( len ( a ) ) : a . append ( a [ i ] ) i = 0 while i < len ( a ) : if a [ i ] == 1 : c += 1 else : p . append ( c ) c = 0 i += 1 print ( max ( p ) ) NEW_LINE


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

import java . util . * ; public class TL { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; boolean flag = true ;   int [ ] correct = new int [ n ] ;   int max = Integer . MIN_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { correct [ i ] = sc . nextInt ( ) ; if ( correct [ i ] > max ) { max = correct [ i ] ; } }   for ( int i = 0 ; i < n ; i ++ ) { if ( correct [ i ] * 2 <= max ) { break ; } if ( i == n - 1 ) { flag = false ; } }   int min = Integer . MAX_VALUE ; if ( flag == false ) { for ( int i = 0 ; i < n ; i ++ ) { if ( correct [ i ] * 2 > max ) { if ( correct [ i ] * 2 < min ) min = correct [ i ] * 2 ; } } }   if ( flag == false ) { max = min ; flag = true ; }   for ( int i = 0 ; i < m ; i ++ ) { if ( sc . nextInt ( ) <= max ) { flag = false ; break ; } } sc . close ( ) ;

import java . util . Scanner ; import java . util . Arrays ; public class Tl { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int correct = sc . nextInt ( ) ; int wrong = sc . nextInt ( ) ;   int arr1 [ ] = new int [ correct ] ; int arr2 [ ] = new int [ wrong ] ;   for ( int i = 0 ; i < correct ; i ++ ) { arr1 [ i ] = sc . nextInt ( ) ;   } for ( int i = 0 ; i < wrong ; i ++ ) { arr2 [ i ] = sc . nextInt ( ) ; }   Arrays . sort ( arr1 ) ; Arrays . sort ( arr2 ) ;

import java . util . Scanner ; import java . util . Arrays ; public class Solution { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int arr1 [ ] = new int [ n ] ; int arr2 [ ] = new int [ m ] ; for ( int i1 = 0 ; i1 < n ; i1 ++ ) { arr1 [ i1 ] = sc . nextInt ( ) ; } for ( int i2 = 0 ; i2 < m ; i2 ++ ) { arr2 [ i2 ] = sc . nextInt ( ) ; } Arrays . sort ( arr1 ) ; Arrays . sort ( arr2 ) ; if ( arr1 [ n - 1 ] < arr2 [ 0 ] ) { if ( arr1 [ 0 ] <= ( arr1 [ n - 1 ] / 2 ) ) { System . out . println ( arr1 [ n - 1 ] ) ; } else { if ( ( 2 * arr1 [ 0 ] < arr2 [ 0 ] ) ) { System . out . println ( 2 * arr1 [ 0 ] ) ; } else { System . out . println ( " - 1" ) ; } } } else { System . out . println ( " - 1" ) ; } } }

import java . util . Scanner ;   public class A350 { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; int minCorrect = 100 ; int maxCorrect = 0 ; int wrong = 100 ; for ( int i = 0 ; i < n ; i ++ ) { int a = s . nextInt ( ) ; if ( a < minCorrect ) { minCorrect = a ; } if ( a > maxCorrect ) { maxCorrect = a ; } } for ( int i = 0 ; i < m ; i ++ ) { int a = s . nextInt ( ) ; if ( a < wrong ) { wrong = a ; } } int correct = Math . max ( minCorrect * 2 , maxCorrect ) ; int answer ; if ( correct >= wrong ) { answer = - 1 ; } else { answer = correct ; } System . out . println ( answer ) ; } }

def func ( n , m , x , y ) : t = max ( x ) a = min ( x ) * 2 t = max ( t , a ) for i in y : if i <= t : return - 1 return t   n , m = map ( int , input ( ) . split ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) y = list ( map ( int , input ( ) . split ( ) ) ) print ( func ( x , m , x , y ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) cor = list ( map ( int , input ( ) . split ( ) ) ) wro = list ( map ( int , input ( ) . split ( ) ) ) maxx = max ( cor ) minn = min ( wro ) extra = min ( cor ) if maxx >= minn : print ( - 1 ) exit ( ) while True : if ( extra * 2 ) <= maxx : print ( maxx ) exit ( ) maxx += 1 if maxx >= minn : print ( - 1 ) exit ( )                         NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) l1 = list ( map ( int , input ( ) . split ( ) ) ) l2 = list ( map ( int , input ( ) . split ( ) ) ) x = min ( l1 ) y = max ( l1 ) res = max ( 2 * x , y ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) c = list ( map ( int , input ( ) . split ( ) ) ) w = list ( map ( int , input ( ) . split ( ) ) ) a = min ( c ) tl = 2 * afor i in range ( len ( c ) ) : if tl >= c [ i ] : pass else : tl = c [ i ] for i in range ( len ( w ) ) : if tl < w [ i ] : pass else : print ( - 1 ) exit ( ) print ( tl ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) right = list ( map ( int , input ( ) . split ( ) ) ) wrong = list ( map ( int , input ( ) . split ( ) ) ) ans = max ( 2 * min ( right ) , max ( right ) ) print ( - 1 ) if min ( wrong ) <= ans else print ( ans ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Solution { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int n = sc . nextInt ( ) ;   int [ ] pattern = new int [ n ] ; String [ ] text = new String [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) pattern [ i ] = sc . nextInt ( ) ;   for ( int i = 0 ; i < n ; i ++ ) text [ i ] = sc . nextLine ( ) ;   int f = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String curr = text [ i ] ;

import java . util . Scanner ;   public class Verse_Pattern { static Scanner scanner = new Scanner ( System . in ) ; static int n ; static boolean valid ( String s , int n ) { int count = 0 ;

import java . io . * ; import java . util . * ;   public class Main { static BufferedReader br ; static StringTokenizer st ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static class AL < T > extends ArrayList < T > { } ; public static class HM < T , Integer > extends HashMap < T , T > { } ; public static class HS < T > extends HashSet < T > { } ; static final List < Character > lst = Arrays . asList ( ' a ' , ' e ' , ' i ' , ' o ' , ' u ' , ' y ' ) ; public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int n = nxtInt ( ) , a [ ] = new int [ n ] ; st = new StringTokenizer ( br . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nxtInt ( ) ; HashSet < Character > vowel = new HashSet < > ( lst ) ; boolean flg = true ; for ( int i = 0 ; i < n ; i ++ ) { char [ ] s = nxtLn ( ) . toCharArray ( ) ; int v = 0 ; for ( int j = 0 ; j < s . length ; j ++ ) if ( vowel . contains ( s [ j ] ) ) v ++ ; if ( v != a [ i ] ) { flg = false ; break ; } } pr . print ( flg ? " YES " : " NO " ) ; pr . flush ( ) ; pr . close ( ) ; } static int nxtInt ( ) { return Integer . parseInt ( nxt ( ) ) ; } static long nxtLong ( ) { return Long . parseLong ( nxt ( ) ) ; } static double nxtDoub ( ) { return Double . parseDouble ( nxt ( ) ) ; } static String nxt ( ) { return st . nextToken ( ) ; } static String nxtLn ( ) throws IOException { return br . readLine ( ) ; } }

import java . io . * ; import java . util . * ;    public class Main {   public static void main ( String args [ ] ) {   Read input = new Read ( ) ; int n = input . nextInt ( ) , num [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) num [ i ] = input . nextInt ( ) ;   boolean ok = true ;   for ( int i = 0 ; i < n ; i ++ ) { String lin = input . line ( ) ; int cur = 0 ; for ( int j = 0 ; j < lin . length ( ) ; j ++ ) { char x = lin . charAt ( j ) ; if ( x == ' a ' || x == ' e ' || x == ' i ' || x == ' o ' || x == ' u ' || x == ' y ' ) cur ++ ; }   if ( cur != num [ i ] ) { ok = false ; break ; } }   if ( ok ) System . out . print ( " YES " ) ; else System . out . print ( " NO " ) ;   }   private static class Read { BufferedReader br ; StringTokenizer tk ;   public Read ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( tk == null || ! tk . hasMoreElements ( ) ) { try { tk = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return tk . nextToken ( ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } String line ( ) { String ans = " " ; try { ans = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return ans ; }   }     }

import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . BigInteger ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; boolean x = false ; String temp = br . readLine ( ) ; String a [ ] = temp . split ( " ▁ " ) ; for ( int j = 0 ; j < n ; j ++ ) { String s = br . readLine ( ) ;

if __name__ == ' _ _ main _ _ ' : cin = input n = int ( cin ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] d = { ' a ' : 0 , ' e ' : 0 , ' i ' : 0 , ' o ' : 0 , ' u ' : 0 , ' y ' : 0 }   for i in range ( n ) : for c in cin ( ) : if c in d . keys ( ) : d [ c ] += 1 if sum ( d . values ( ) ) != a [ i ] : print ( " NO " ) break d = d . fromkeys ( d , 0 ) else : print ( " YES " ) NEW_LINE

n = int ( input ( ) )     t = list ( map ( int , input ( ) . split ( ) ) ) x = ' aeiouy ' r = 0 for j in range ( n ) :   f = input ( ) p = 0 for i in f : if i in x : p += 1 NEW_LINE

vow = set ( [ ' a ' , ' e ' , ' i ' , ' o ' , ' u ' , ' y ' ] ) def f ( x ) : q = 0 for y in x : q += int ( y in vow ) return qn = int ( input ( ) ) p = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] fl = 1 for i in range ( n ) : s = [ f ( x ) for x in input ( ) . split ( ' ▁ ' ) ] if ( sum ( s ) != p [ i ] ) : fl = 0 print ( " YES " if ( fl ) else ( " NO " ) ) NEW_LINE

''' import ▁ syssys . stdin = open ( " input . txt " , " r " ) sys . stdout = open ( " output . txt " , " w " ) '''   n = int ( input ( ) ) p = [ int ( i ) for i in input ( ) . split ( ) ] flag = Truefor i in range ( n ) : s = input ( ) if ( s . count ( ' a ' ) + s . count ( ' e ' ) + s . count ( ' i ' ) + s . count ( ' o ' ) + s . count ( ' u ' ) + s . count ( ' y ' ) ) != p [ i ] and flag : flag = Falseif flag : print ( " YES " ) else : print ( " NO " ) NEW_LINE

def solve ( ) : n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) : s = input ( ) tot = 0 tot += s . count ( ' a ' ) tot += s . count ( ' e ' ) tot += s . count ( ' i ' ) tot += s . count ( ' o ' ) tot += s . count ( ' u ' ) tot += s . count ( ' y ' ) if tot != p [ i ] : print ( ' NO ' ) return print ( ' YES ' ) solve ( ) NEW_LINE


import java . util . * ;   public class SuffixStructure_B { public static boolean automaton ( String s , String t ) { boolean check = true ; int temp = 0 ; for ( char c : t . toCharArray ( ) ) { boolean found = false ; for ( int i = temp ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == c ) { found = true ; temp = i + 1 ; break ; } } if ( found == false ) { return false ; } } return true ; } public static boolean isAnagram ( String s , String t ) { int arr [ ] = new int [ 26 ] ; for ( char c : s . toCharArray ( ) ) { int x = ( int ) c - 97 ; arr [ x ] ++ ; } for ( char c : t . toCharArray ( ) ) { int x = ( int ) c - 97 ; arr [ x ] -- ; } boolean check = true ; for ( int i = 0 ; i < 26 ; i ++ ) { if ( arr [ i ] != 0 ) { check = false ; break ; } } return check ; } public static boolean containsDifferent ( String s , String t ) { int arr [ ] = new int [ 26 ] ; for ( char c : s . toCharArray ( ) ) {

import java . util . * ;   public class run {   public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String w = s . next ( ) ; String r = s . next ( ) ; cf_448B ( w , r ) ; } static void cf_448B ( String s , String t ) { int [ ] arr = new int [ 26 ] ; int [ ] arr1 = new int [ 26 ] ;   for ( int i = 0 ; i < s . length ( ) ; i ++ ) { arr [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int j = 0 ; j < t . length ( ) ; j ++ ) { arr1 [ t . charAt ( j ) - ' a ' ] ++ ; } for ( int i = 0 ; i < t . length ( ) ; i ++ ) { if ( arr [ t . charAt ( i ) - ' a ' ] < arr1 [ t . charAt ( i ) - ' a ' ] ) { System . out . println ( " need ▁ tree " ) ; return ; } } for ( int i = 0 ; ( i + t . length ( ) ) <= s . length ( ) ; i ++ ) { if ( ( s . substring ( i , i + t . length ( ) ) ) . equals ( t ) ) { System . out . println ( " automaton " ) ; return ; } } int p1 = 0 ; int p2 = 0 ; while ( p1 < s . length ( ) && p2 < t . length ( ) ) { if ( s . charAt ( p1 ) == t . charAt ( p2 ) ) { p2 ++ ; } p1 ++ ; } if ( p2 == t . length ( ) ) { System . out . println ( " automaton " ) ; return ; } if ( s . length ( ) == t . length ( ) ) { System . out . println ( " array " ) ; return ; } System . out . println ( " both " ) ; } }

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 ; static boolean readFile = false ;

s = input ( ) t = input ( ) def issubstring ( a , b ) : cnt = 0 for i in b : if i in a : a = list ( a ) a . remove ( i ) p = " " for i in a : p += i a = p cnt += 1 if cnt == len ( b ) : return True else : return False   NEW_LINE

def issubset ( a , b ) : i = 0 for c in a : if i < len ( b ) and c == b [ i ] : i += 1 return i == len ( b )   x = input ( ) y = input ( ) sx , sy = sorted ( x ) , sorted ( y ) if sx == sy : print ( " array " ) elif issubset ( x , y ) : print ( " automaton " ) elif issubset ( sx , sy ) : print ( " both " ) else : print ( " need ▁ tree " ) NEW_LINE

import sys     def ints_input ( ) : return [ int ( i ) for i in sys . stdin . readline ( ) . strip ( " \n " ) . split ( " ▁ " ) ]     def print_list ( arr ) : sys . stdout . writelines ( str ( x ) + " ▁ " for x in arr ) sys . stdout . write ( " \n " )     def fast_input ( type = str ) : return type ( sys . stdin . readline ( ) . strip ( " \n " ) )     s = fast_input ( ) t = fast_input ( )   fs = { } ft = { }     for i in s : if i in fs : fs [ i ] += 1 else : fs [ i ] = 1   for i in t : if i in ft : ft [ i ] += 1 else : ft [ i ] = 1   NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ; public class Euler { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; long a = in . nextLong ( ) ; long b = in . nextLong ( ) ; long [ ] x = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) x [ i ] = in . nextLong ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long mod = ( x [ i ] * a ) % b ; long ans = mod / a ; System . out . print ( ans + " ▁ " ) ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskB { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int N = in . nextInt ( ) ; int A = in . nextInt ( ) , B = in . nextInt ( ) ; int nums [ ] = CPUtils . readIntArray ( N , in ) ; int answer [ ] = new int [ N ] ;   for ( int i = 0 ; i < N ; i ++ ) { int ai = ( int ) ( ( ( long ) nums [ i ] * A ) % B ) ; answer [ i ] = ai / A ; } CPUtils . printIntArray ( answer , out ) ;   }   }   static class CPUtils { public static int [ ] readIntArray ( int size , Scanner in ) { int [ ] array = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { array [ i ] = in . nextInt ( ) ; } return array ; }   public static void printIntArray ( int [ ] array , PrintWriter out ) { StringBuilder stringBuilder = new StringBuilder ( ) ; for ( int i = 0 ; i < array . length ; i ++ ) { stringBuilder . append ( array [ i ] + " ▁ " ) ; } out . print ( stringBuilder . toString ( ) ) ; }   } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskB { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int N = in . nextInt ( ) ; double A = in . nextInt ( ) , B = in . nextInt ( ) ; int nums [ ] = CPUtils . readIntArray ( N , in ) ; int answer [ ] = new int [ N ] ;   for ( int i = 0 ; i < N ; i ++ ) { int ai = ( int ) ( ( nums [ i ] * ( A * 1L ) ) % B ) ; answer [ i ] = ( int ) ( ai / A ) ; } CPUtils . printIntArray ( answer , out ) ;   }   }   static class CPUtils { public static int [ ] readIntArray ( int size , Scanner in ) { int [ ] array = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { array [ i ] = in . nextInt ( ) ; } return array ; }   public static void printIntArray ( int [ ] array , PrintWriter out ) { StringBuilder stringBuilder = new StringBuilder ( ) ; for ( int i = 0 ; i < array . length ; i ++ ) { stringBuilder . append ( array [ i ] + " ▁ " ) ; } out . print ( stringBuilder . toString ( ) ) ; }   } }

n , a , b = map ( int , input ( ) . split ( ) ) lis = list ( map ( int , input ( ) . split ( ) ) ) for i in lis : x = ( i * a ) % b print ( int ( x / a ) , end = ' ▁ ' ) NEW_LINE

n , a , b = map ( int , input ( ) . split ( ) ) x = [ int ( i ) for i in input ( ) . split ( ) ]   def find_index ( n ) : l = 0 ; r = n while l < r : mid = ( l + r ) // 2 if ( mid * a ) // b == ( r * a ) // b : r = mid else : l = mid + 1 return r   for i in range ( n ) : print ( x [ i ] - find_index ( x [ i ] ) , end = " ▁ " )   print ( ) NEW_LINE

import mathn , a , b = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) for e in l : z = ( e * a ) // b s = e - math . ceil ( z * b / a ) print ( s , end = " ▁ " ) print ( ) NEW_LINE

n , a , b = map ( int , input ( ) . split ( ) ) lis = list ( map ( int , input ( ) . split ( ) ) ) for i in lis : x = ( i * a ) % b print ( int ( x / a ) )   NEW_LINE


import javax . annotation . processing . SupportedSourceVersion ; import java . io . * ; import java . util . * ; import java . util . regex . Matcher ;   public class Main {   public static void main ( String [ ] args ) throws IOException { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( new FileReader ( " input . txt " ) ) ;

import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class A {   public static void main ( String [ ] args ) throws IOException {   Scanner sc = new Scanner ( " input . txt " ) ; PrintWriter out = new PrintWriter ( new FileWriter ( " output . txt " ) ) ;

import sys sys . stdin = open ( ' input . txt ' ) sys . stdout = open ( ' output . txt ' , ' w ' ) [ row_num , col_num , query_num ] = list ( map ( int , input ( ) . split ( ) ) ) rows = [ ] for r in range ( row_num + 1 ) : rows . append ( ( col_num + 1 ) * [ None ] ) location = { } for query_index in range ( query_num ) : tokens = input ( ) . split ( ) id = tokens . pop ( ) integers = list ( map ( int , tokens ) ) if integers [ 0 ] == - 1 : if id in location : r , c = location [ id ] del location [ id ] rows [ r ] [ c ] = None print ( " % d ▁ % d " % ( r , c ) ) else : print ( " - 1 ▁ - 1" ) else : r , c = integers [ 1 : 3 ] while rows [ r ] [ c ] : c += 1 if c > col_num : c = 1 r += 1 if r > row_num : break if r <= row_num : location [ id ] = [ r , c ] rows [ r ] [ c ] = id NEW_LINE

import sysdef add ( x , y , id_t , shelves , track ) : element = ( ( x - 1 ) % n ) * m + y - 1 ; if shelves [ element ] : element += 1 NEW_LINE

f1 = open ( " input . txt " , " r " ) f2 = open ( " output . txt " , " w " ) n , m , k = map ( int , f1 . readline ( ) . split ( ) ) a = [ 0 ] * n * mb = { } for i in range ( k ) : s = f1 . readline ( ) . split ( ) if s [ 0 ] == " + 1" : y , x , nm = int ( s [ 1 ] ) - 1 , int ( s [ 2 ] ) - 1 , s [ 3 ] ind = y * m + x while ind < n * m : if a [ ind ] == 0 : a [ ind ] = 1 b [ nm ] = ind break else : ind += 1 else : if s [ 1 ] in b : ind = b [ s [ 1 ] ] f2 . write ( str ( ind // m + 1 ) + " ▁ " + str ( ind % m + 1 ) + " \n " ) a [ ind ] = 0 del ( b [ s [ 1 ] ] ) else : f2 . write ( " - 1 ▁ - 1 \n " ) f1 . close ( ) f2 . close ( ) NEW_LINE


import java . io . * ; import java . util . * ;   public class B_Koala_and_Lights { public static void main ( String [ ] args ) throws Exception { int n = in . readInt ( ) ; char [ ] init = in . readLine ( ) . toCharArray ( ) ; int [ ] time = new int [ 1000 ] ; int [ ] [ ] bulb = new int [ n ] [ ] ; int ans = 0 , mxt = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { bulb [ i ] = in . readA ( ) ; boolean state = init [ i ] == '1' ? true : false ; for ( int t = 0 ; t < time . length ; t ++ ) { if ( t >= bulb [ i ] [ 1 ] && ( t - bulb [ i ] [ 1 ] ) % bulb [ i ] [ 0 ] == 0 ) state = ! state ; if ( state ) time [ t ] ++ ; if ( time [ t ] > ans ) { mxt = t ; ans = time [ t ] ; } } }

import java . io . * ; import java . util . * ; public class Solution { public static void main ( String [ ] args ) throws Exception { FastReader fr = new FastReader ( ) ; int n = fr . nextInt ( ) ; String lights = fr . next ( ) ; char ch [ ] = lights . toCharArray ( ) ; int maxons = Integer . MIN_VALUE ; int period [ ] = new int [ n ] ; int glow [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { period [ i ] = fr . nextInt ( ) ; glow [ i ] = fr . nextInt ( ) ; } for ( int i = 1 ; i <= 1000 ; i ++ ) { int ons = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ch [ j ] == '1' ) ons ++ ; if ( i == glow [ j ] ) { if ( ch [ j ] == '1' ) ch [ j ] = '0' ; else ch [ j ] = '1' ; glow [ j ] += period [ j ] ; } }

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

n = int ( input ( ) ) s = input ( ) lights = [ 0 for i in range ( 500 ) ] for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) if s [ i ] == '1' : counter = 0 off = 1 for j in range ( b ) : lights [ j ] += 1 counter = b + a NEW_LINE

from collections import *     n = int ( input ( ) ) s = input ( ) d = defaultdict ( int )   for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) dd = defaultdict ( int ) if s [ i ] == "1" : f = 0 ind = 0 ai = 0 for j in range ( 1000 ) : if f == 0 : for k in range ( ind + 1 , b + ( ai * a ) + 1 ) : d [ k ] += 1 dd [ k ] += 1 f = 1 ind = b + ( ai * a ) ai += 1 else : f = 0 ind = b + ( ai * a ) ai += 1 else : f = 1 ind = 0 ai = 0 for j in range ( 1000 ) : if f == 0 : for k in range ( ind + 1 , b + ( ai * a ) + 1 ) : d [ k ] += 1 dd [ k ] += 1 f = 1 ind = b + ( ai * a ) ai += 1 else : f = 0 ind = b + ( ai * a ) ai += 1 print ( max ( d . values ( ) ) ) NEW_LINE

n = int ( input ( ) ) s = input ( ) ss = ' ▁ ' . join ( s ) ss = ss . split ( ) ab = [ ] ans = 0 test = Falseloop = Trueii = 0 for i in range ( n ) : l = list ( map ( int , input ( ) . split ( ) ) ) ab . append ( l ) times = [ ] for i in range ( n ) : times . append ( ab [ i ] [ 1 ] ) for i in range ( 1000 ) : for j in range ( n ) : if times [ j ] == ii : times [ j ] += ab [ j ] [ 0 ] ss [ j ] = str ( ( int ( ss [ j ] ) + 1 ) % 2 ) ans = max ( ss . count ( '1' ) , ans ) ii += 1 print ( ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class D {   public static void main ( String [ ] args ) throws IOException {   Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ;   int n = sc . nextInt ( ) , m = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) a [ i ] = sc . nextInt ( ) ; if ( n % 2 == 0 ) out . println ( 0 ) ; else { int b = a [ 0 ] ; for ( int i = 2 ; i < n ; i += 2 ) b = Math . min ( a [ i ] , b ) ; out . println ( Math . min ( b , 1l * m / ( ( n + 1 ) / 2 ) * k ) ) ; } out . close ( ) ; }   static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; }   public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; }   public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; }   public String nextLine ( ) throws IOException { return br . readLine ( ) ; }   public boolean ready ( ) throws IOException { return br . ready ( ) ; }    } }

import java . util . * ; import java . io . * ; import java . lang . * ; public class Main {   static class FastReader {   BufferedReader br ;   StringTokenizer st ;   public FastReader ( ) throws IOException {   br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   }   public FastReader ( String s ) throws IOException {   br = new BufferedReader ( new FileReader ( new File ( s ) ) ) ;   }   String next ( ) {   while ( st == null || ! st . hasMoreElements ( ) ) {   try {   st = new StringTokenizer ( br . readLine ( ) ) ;   }   catch ( Exception e ) {   e . printStackTrace ( ) ;   }                     }   return st . nextToken ( ) ;   }   String nextLine ( ) {   String str = " " ;   try {   str = br . readLine ( ) ;   }   catch ( Exception e ) {   e . printStackTrace ( ) ;   }   return str ;   }   int nextInt ( ) {   return Integer . parseInt ( next ( ) ) ;   }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ;   }   double nextDouble ( ) {   return Double . parseDouble ( next ( ) ) ;   }   } public static void main ( String [ ] args ) throws IOException { FastReader in = new FastReader ( ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int k = in . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = in . nextInt ( ) ; if ( n % 2 == 0 ) System . out . println ( 0 ) ; else { int b = a [ 0 ] ; for ( int i = 2 ; i < n ; i += 2 ) b = Math . min ( a [ i ] , b ) ; System . out . println ( Math . min ( b , 1L * m / ( ( n + 1 ) / 2 ) * k ) ) ; } } }

from sys import stdin   n , m , k = [ int ( x ) for x in stdin . readline ( ) . split ( ) ]   d = [ int ( x ) for x in stdin . readline ( ) . split ( ) ] NEW_LINE splitD = [ x for x in d [ : : 2 ] ]   if n == 1 : print ( min ( d [ 0 ] , k * m ) )   elif n == 2 : print ( 0 ) elif d [ 0 ] == 0 or d [ - 1 ] == 0 : print ( 0 ) elif n % 2 == 0 : print ( 0 ) else : if m >= n // 2 + 1 : times = m // ( n // 2 + 1 ) NEW_LINE print ( min ( times * k , min ( splitD ) ) ) else : print ( 0 ) NEW_LINE


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

import java . util . * ; public class bovine { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int t , n , area ; area = 0 ;   t = sc . nextInt ( ) ;   while ( t -- > 0 ) { n = sc . nextInt ( ) ;   int a [ ] = new int [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; }   HashSet < Integer > al = new HashSet < Integer > ( ) ;   for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { area = a [ j ] - a [ i ] ; al . add ( area ) ; } } System . out . println ( al . size ( ) ) ; }   }   }

import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ;   public class A1466 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int [ ] X = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { X [ n ] = in . nextInt ( ) ; } Set < Integer > set = new HashSet < > ( ) ; for ( int from = 0 ; from < N ; from ++ ) { for ( int to = from + 1 ; to < N ; to ++ ) { int area = X [ to ] - X [ from ] ;

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { HashSet < Long > h = new HashSet < > ( ) ; int n = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { h . add ( Math . abs ( a [ j ] - a [ i ] ) ) ; } } System . out . println ( h . size ( ) ) ; } } }

import java . util . * ;   public class A1466 {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int t = scanner . nextInt ( ) , i , j , k , count ; for ( int f = 0 ; f < t ; f ++ ) { int n = scanner . nextInt ( ) ; k = 0 ; count = 0 ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n * n ] ; for ( i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } for ( i = 0 ; i < n ; i ++ ) { for ( j = i + 1 ; j < n ; j ++ ) { b [ k ] = a [ j ] - a [ i ] ; k ++ ; } }   for ( i = 0 ; i < k ; i ++ ) { if ( b [ i ] != - 1 ) { count ++ ; for ( j = i + 1 ; j < k ; j ++ ) { if ( b [ i ] == b [ j ] ) { b [ j ] = - 1 ; } } } } System . out . println ( count ) ; } } }

n = int ( input ( ) ) NEW_LINE for i in range ( n ) : a = int ( input ( ) ) NEW_LINE s = [ int ( i ) for i in input ( ) . split ( ' ▁ ' ) ] NEW_LINE count = { } NEW_LINE for j in range ( a ) : for NEW_LINE k in range ( j + 1 , a ) : compute = s [ k ] - s [ j ] NEW_LINE if compute not in count : count [ compute ] = 1 NEW_LINE print ( len ( count ) ) NEW_LINE

t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l1 = [ ] NEW_LINE for i in l : for NEW_LINE j in l : NEW_LINE if ( i != j ) : l1 . append ( abs ( i - j ) ) NEW_LINE s = len ( set ( l1 ) ) NEW_LINE print ( s ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a = [ ] NEW_LINE for i in l : a . append ( i / 2 ) NEW_LINE s = set ( ) NEW_LINE for i in range ( n - 1 ) : for NEW_LINE j in range ( i + 1 , n ) : s . add ( a [ j ] - a [ i ] ) NEW_LINE print ( len ( s ) ) NEW_LINE


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

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

import java . io . BufferedReader ; import java . io . InputStreamReader ;   public class cf1430A {   public static void main ( String [ ] args ) throws Exception {   BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   int testCases = Integer . parseInt ( in . readLine ( ) ) ;   for ( int i = 0 ; i < testCases ; i ++ ) {   int windowsCount = Integer . parseInt ( in . readLine ( ) ) ; for ( int k = 0 ; k < windowsCount ; k ++ ) { for ( int l = 0 ; l < windowsCount ; l ++ ) { for ( int m = 0 ; m < windowsCount ; m ++ ) { if ( k * 3 + l * 5 + m * 7 == windowsCount ) { System . out . println ( k + " ▁ " + l + " ▁ " + m ) ; k = windowsCount ; l = windowsCount ; m = windowsCount ; } else if ( k == windowsCount - 1 && m == windowsCount - 1 && l == windowsCount - 1 && ! ( k * 3 + l * 5 + m * 7 == windowsCount ) ) { System . out . println ( " - 1" ) ; } } } } } } }

import java . util . Scanner ;   public class A1430 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int three = 0 ; int five = 0 ; int seven = 0 ; if ( N % 3 == 2 ) { N -= 5 ; five ++ ; } else if ( N % 3 == 1 ) { N -= 7 ; seven ++ ; } if ( N < 0 ) { System . out . println ( " - 1" ) ; } else { three = N / 3 ; System . out . println ( three + " ▁ " + five + " ▁ " + seven ) ; } } }   }

for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE if n in [ 1 , 2 , 4 ] : print ( - 1 ) NEW_LINE continue NEW_LINE x = y = z = 0 NEW_LINE z = n // 7 NEW_LINE left = [ [ 0 , 0 , 0 ] , [ 1 , 1 , - 1 ] , [ 3 , 0 , - 1 ] , [ 1 , 0 , 0 ] , [ 2 , 1 , - 1 ] , [ 0 , 1 , 0 ] , [ 2 , 0 , 0 ] ] NEW_LINE x += left [ n % 7 ] [ 0 ] NEW_LINE y += left [ n % 7 ] [ 1 ] NEW_LINE z += left [ n % 7 ] [ 2 ] NEW_LINE print ( x , y , z ) NEW_LINE

import sysinput = sys . stdin . readline   for _ in range ( int ( input ( ) ) ) : NEW_LINE

for i in range ( int ( input ( ) ) ) : num = int ( input ( ) ) NEW_LINE if num % 3 != 0 and num < 5 : NEW_LINE INDENT print ( - 1 ) elif num % 3 == 0 : NEW_LINE print ( num // 3 , 0 , 0 ) elif num % 5 == 0 : NEW_LINE print ( 0 , num // 5 , 0 ) elif num % 7 == 0 : NEW_LINE print ( 0 , 0 , num // 7 ) else : NEW_LINE remain = num % 5 NEW_LINE DEDENT while True : if NEW_LINE remain % 3 == 0 : print ( remain // 3 , num // 5 , 0 ) NEW_LINE break elif remain % 7 == 0 : print ( 0 , num // 5 , remain // 7 ) NEW_LINE break NEW_LINE num1 = 5 * ( ( num // 5 ) - 1 ) NEW_LINE remain = num - num1 NEW_LINE num = num1 NEW_LINE

t = int ( input ( ) ) NEW_LINE for a in range ( t ) : x , y , z = - 1 , - 1 , - 1 NEW_LINE n = int ( input ( ) ) NEW_LINE for i in range ( n // 7 + 1 ) : for NEW_LINE j in range ( n // 5 + 1 ) : NEW_LINE

cases = int ( input ( ) ) NEW_LINE while cases : cases -= 1 NEW_LINE num = int ( input ( ) )   if num in [ 1 , 2 , 4 ] : print ( - 1 ) NEW_LINE continue   if num % 3 == 0 : NEW_LINE INDENT print ( num // 3 , 0 , 0 ) elif num % 5 == 0 : NEW_LINE print ( 0 , num // 5 , 0 ) elif num % 7 == 0 : NEW_LINE print ( 0 , 0 , num // 7 ) else : NEW_LINE thr = 0 NEW_LINE DEDENT while num % 3 != 0 and num > 0 : num -= 3 NEW_LINE thr += 1 NEW_LINE if num % 5 == 0 : print ( thr , num // 5 , 0 ) NEW_LINE break NEW_LINE if num % 7 == 0 : print ( thr , 0 , num // 7 ) NEW_LINE break   NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class CF103B { static class UndirectedGraph { ArrayList < Integer > [ ] adjList ; int n ;   UndirectedGraph ( int n ) { this . n = n ; adjList = new ArrayList [ n ] ; Arrays . setAll ( adjList , i -> new ArrayList < Integer > ( ) ) ; }   void addEdge ( int v , int u ) { adjList [ v ] . add ( u ) ; adjList [ u ] . add ( v ) ; }   int cyclesCnt ( ) { int [ ] visited = new int [ n ] ; int cnt = dfs ( 0 , - 1 , visited ) ; for ( int i = 0 ; i < n ; i ++ ) if ( visited [ i ] == 0 )

import java . util . Scanner ;   public class Main { static Scanner sc = new Scanner ( System . in ) ; static int n = sc . nextInt ( ) ; static int m = sc . nextInt ( ) ; static int f [ ] = new int [ n + 1 ] ;

import java . io . IOException ; import java . util . * ; import java . util . Arrays ; import java . util . Scanner ;   public class Bit_year { static List < Integer > [ ] adj ; static boolean [ ] visited ; static int cyclenumber ;

def find ( node ) : while p [ node ] != node : p [ node ] = p [ p [ node ] ] node = p [ node ] return nodedef union ( n1 , n2 ) : a1 = find ( n1 ) a2 = find ( n2 )   if a1 != a2 : p [ a1 ] = a2     n , m = map ( int , input ( ) . split ( ) ) p = [ i for i in range ( n + 1 ) ] cnt = 0 for _ in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) if find ( a ) == find ( b ) : cnt += 1 union ( a , b )   cnt2 = 0 for i in range ( 1 , n + 1 ) : if p [ i ] == i : cnt2 += 1 if cnt == 1 and cnt2 == 1 : print ( ' FHTAGN ! ' ) else : print ( " NO " ) NEW_LINE

import io , osinput = io . BytesIO ( os . read ( 0 , os . fstat ( 0 ) . st_size ) ) . readline from collections import defaultdict n , m = map ( int , input ( ) . split ( ) ) adj = defaultdict ( list ) for i in range ( m ) : x , y = map ( int , input ( ) . split ( ) ) adj [ x ] . append ( y ) adj [ y ] . append ( x ) ok = Falsecmps = [ ] v = [ 0 ] * ( n + 1 ) for i in range ( 1 , 1 + n ) : if not v [ i ] : q = [ i ] cmp = [ ] while q : e = q . pop ( ) if not v [ e ] : cmp . append ( e ) v [ e ] = 1 for j in adj [ e ] : if not v [ j ] : q . append ( j ) cmps . append ( cmp ) for i in cmps : if len ( i ) > 2 : s = 0 for j in i : s += len ( adj [ j ] ) s //= 2 if s == len ( i ) : ok = True print ( " FHTAGN ! " if ok and len ( cmps ) == 1 else " NO " ) NEW_LINE

import io , osinput = io . BytesIO ( os . read ( 0 , os . fstat ( 0 ) . st_size ) ) . readlinefrom collections import defaultdict   n , m = map ( int , input ( ) . split ( ) ) adj = defaultdict ( list )   for i in range ( m ) : x , y = map ( int , input ( ) . split ( ) ) adj [ x ] . append ( y ) adj [ y ] . append ( x ) cmps = 0 v = [ 0 ] * ( n + 1 )   for i in range ( 1 , 1 + n ) : if not v [ i ] : q = [ i ] while q : e = q . pop ( ) v [ e ] = 1 for j in adj [ e ] : if not v [ j ] : q . append ( j ) cmps += 1 print ( " FHTAGN ! " if n == m and cmps == 1 else " NO " ) NEW_LINE

import osimport sysfrom io import BytesIO , IOBaseBUFSIZE = 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 java . util . HashSet ; import java . util . Scanner ;   public class problem60 {   public static void main ( String [ ] args ) {

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 , b ; b = input . nextInt ( ) ; n = input . nextInt ( ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int value = input . nextInt ( ) % b ; if ( map . containsKey ( value ) ) { System . out . println ( i + 1 ) ; return ; } else { map . put ( value , 1 ) ; } } System . out . println ( " - 1" ) ; }   }

import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Collection ; import java . util . List ; import java . util . Scanner ; import java . util . function . Function ; import java . util . stream . Collectors ; public class _p000447A { static public void main ( final String [ ] args ) throws IOException { p000447A . _main ( args ) ; }

import java . util . Scanner ;   public class DZYHash { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int p = in . nextInt ( ) , n = in . nextInt ( ) , a [ ] = new int [ p ] , i , o = - 1 ;   for ( i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; a [ x % p ] ++ ; if ( a [ x % p ] > 1 ) { o = i + 1 ; break ; } } in . close ( ) ; System . out . println ( o ) ; } }

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int p = input . nextInt ( ) ; int n = input . nextInt ( ) ; boolean [ ] freq = new boolean [ 301 ] ; int result = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { int num = input . nextInt ( ) ; int h = num % p ; if ( freq [ h ] ) { result = i + 1 ; break ; } freq [ h ] = true ; } System . out . println ( result ) ; }   }

a , b = map ( int , input ( ) . split ( ) ) ans = 0 seen = set ( ) while b : b -= 1   num = int ( input ( ) ) ans += 1 rem = num % a   if rem in seen : print ( ans ) exit ( ) else : seen . add ( rem )   print ( - 1 )         NEW_LINE

from collections import Counter n , k = map ( int , input ( ) . split ( ) ) c = Counter ( ) ans = - 1 for i in range ( 1 , k + 1 ) : x = int ( input ( ) ) c [ x % n ] += 1 if ans == - 1 and c [ x % n ] > 1 : ans = i print ( ans ) NEW_LINE

def solve ( arr , p ) : d = { } for i in range ( len ( arr ) ) : res = arr [ i ] % p if not d . get ( res ) : d [ res ] = 1 else : return i + 1 return - 1 def main ( ) : p , n = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) arr = [ ] for _ in range ( n ) : i = int ( input ( ) ) arr . append ( i ) print ( solve ( arr , p ) ) main ( ) NEW_LINE

p , n = map ( int , input ( ) . split ( ) )   lst = [ - 1 ] * p   res = - 1 for i in range ( n ) : x = int ( input ( ) ) if 0 <= ( x % p ) <= p - 1 : if lst [ x % p ] == - 1 : lst [ x % p ] = x elif lst [ x % p ] != - 1 : res = i break     print ( res if res < 0 else res + 1 ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) x = [ ] t = [ - 1 ] * mj = 0 c = Falsefor i in range ( m ) : x += list ( map ( int , input ( ) . split ( ) ) ) for k in range ( m ) : t [ j ] = x [ k ] % n j += 1 for l in range ( m ) : for y in range ( 0 , l ) : if l != y : if t [ l ] == t [ y ] : c = True print ( l + 1 ) exit ( ) if c == False : print ( - 1 ) NEW_LINE


import java . util . * ;   public class Main { public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; String arr [ ] [ ] = new String [ n ] [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . next ( ) . split ( " " ) ; } String standard1 = arr [ 0 ] [ 0 ] ; String standard2 = arr [ 0 ] [ 1 ] ; if ( standard1 . equals ( standard2 ) ) { System . out . println ( " NO " ) ; return ; }   int wide = n / 2 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! ( arr [ i ] [ i ] . equals ( standard1 ) & arr [ i ] [ n - i - 1 ] . equals ( standard1 ) ) ) { System . out . println ( " NO " ) ; return ; } for ( int j = 0 ; j < n ; j ++ ) { if ( j != i & j != n - i - 1 ) { if ( ! arr [ i ] [ j ] . equals ( standard2 ) ) { System . out . println ( " NO " ) ; return ; } } } } System . out . println ( " YES " ) ;   } }

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

import java . util . Scanner ;   public class JavaApplication1 {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; String [ ] str = new String [ n ] ; boolean flag = true ; for ( int i = 0 ; i < n ; i ++ ) { str [ i ] = input . next ( ) ; } char diagonalLetter = str [ 0 ] . charAt ( 0 ) ; char secondLetter = str [ 0 ] . charAt ( 1 ) ; if ( diagonalLetter == secondLetter ) flag = false ; else { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j || j == n - i - 1 ) { if ( str [ i ] . charAt ( j ) != diagonalLetter ) { flag = false ; break ; } } else { if ( str [ i ] . charAt ( j ) != secondLetter ) { flag = false ; break ; } } } if ( ! flag ) break ; } } if ( flag ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; input . close ( ) ; } }

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

import java . util . Scanner ; public class A { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; String board [ ] = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { board [ i ] = in . next ( ) ; } boolean ok = true ; char l1 = board [ 0 ] . charAt ( 0 ) ; char l2 = board [ 0 ] . charAt ( 1 ) ; if ( l1 == l2 ) { ok = false ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i == j || i == ( n - j - 1 ) ) { if ( board [ i ] . charAt ( j ) != l1 ) { ok = false ; } } else { if ( board [ i ] . charAt ( j ) != l2 ) { ok = false ; } } } } System . out . println ( ok ? " YES " : " NO " ) ; } }

def solve ( arr , n ) : last_d = arr [ 0 ] [ 0 ] last = arr [ 0 ] [ 1 ] for i in range ( n ) : for j in range ( n ) : if i == j or i == n - j - 1 : if last_d != arr [ i ] [ j ] or last == arr [ i ] [ j ] : return ' NO ' else : if last != arr [ i ] [ j ] or arr [ i ] [ j ] == last_d : return ' NO ' return ' YES '             def main ( ) : NEW_LINE

n = int ( input ( ) ) x1 = input ( ) d = x1 [ 0 ] o = x1 [ 1 ] if d == o : print ( ' NO ' ) else : for i in range ( n - 1 ) : x = input ( ) x1 += x c = ' ' l = 1 rl = n for i in range ( 1 , n + 1 ) : if i == ( ( n // 2 ) + 1 ) : c += ( n // 2 ) * o + d + ( n // 2 ) * o l += 1 rl -= 1 continue for e in range ( 1 , n + 1 ) : if e == l or e == rl : c += d else : c += o l += 1 rl -= 1 if c == x1 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

diag = [ ] nond = [ ] t = int ( input ( ) ) for a in range ( t ) : s = input ( ) diag . append ( s [ 0 + a ] ) diag . append ( s [ t - 1 - a ] ) for b in s : nond . append ( b ) nond . remove ( s [ 0 + a ] ) if t - 1 - a != 0 + a : nond . remove ( s [ t - 1 - a ] ) if len ( diag ) == diag . count ( diag [ 0 ] ) and len ( nond ) == nond . count ( nond [ 0 ] ) and nond [ 0 ] != diag [ 0 ] : print ( " YES " ) else : print ( " NO " ) NEW_LINE

diag = [ ] nond = [ ] t = int ( input ( ) ) for a in range ( t ) : s = input ( ) for b in range ( len ( s ) ) : if b == 0 + a or b == t - 1 - a : diag . append ( s [ b ] ) else : nond . append ( s [ b ] ) if len ( diag ) == diag . count ( diag [ 0 ] ) and len ( nond ) == nond . count ( nond [ 0 ] ) and nond [ 0 ] != diag [ 0 ] : print ( " YES " ) else : print ( " NO " ) NEW_LINE


import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   String input = new Scanner ( System . in ) . nextLine ( ) ; String [ ] costs = input . split ( " [ a - z ] { 1,10 } " ) ;   double sum = 0 ; for ( String cost : costs ) { if ( cost . isEmpty ( ) ) continue ; if ( cost . matches ( " ( [1-9 ] [ 0-9 ] { 0,2 } | 0 ) ( \\ . [0-9 ] { 3 } ) * ( \\ . [0-9 ] { 2 } ) ? " ) ) { if ( cost . length ( ) > 3 && cost . charAt ( cost . length ( ) - 3 ) == ' . ' ) cost = cost . substring ( 0 , cost . length ( ) - 3 ) + " # " + cost . substring ( cost . length ( ) - 2 ) ; cost = cost . replace ( " . " , " " ) ; cost = cost . replace ( " # " , " . " ) ; sum += Double . parseDouble ( cost ) ; } else { System . out . println ( " Invalid ▁ Input " ) ; return ; } }   String output = Long . toString ( Math . round ( sum * 100 ) / 100 ) + " . " + String . format ( " % 02d " , ( Math . round ( sum * 100 ) % 100 ) ) ; while ( output . indexOf ( ' . ' ) > 3 ) output = output . substring ( 0 , output . indexOf ( ' . ' ) - 3 ) + " . " + output . substring ( output . indexOf ( ' . ' ) - 3 ) ; if ( output . endsWith ( " . 00" ) ) output = output . substring ( 0 , output . length ( ) - 3 ) ; System . out . println ( output ) ; } }

import java . io . * ; import java . nio . file . Files ; import java . nio . file . Path ; import java . nio . file . Paths ; import java . nio . file . StandardCopyOption ; import java . util . * ; import java . util . function . Function ; import java . util . function . Predicate ; import java . util . stream . Collectors ; import java . util . stream . Stream ;   import static java . util . stream . Collectors . * ; import static java . util . stream . Collectors . counting ; import static java . util . stream . Collectors . groupingBy ; import static java . util . stream . Collectors . partitioningBy ;   public class Main { public static void main ( String [ ] args ) throws IOException { InputStream inputStream = System . in ;

import java . io . * ; import java . text . DecimalFormat ; import java . util . * ; import java . io . IOException ; import java . io . InputStream ; import java . util . stream . Collector ; import java . util . stream . Collectors ;   public class Main { public static void main ( String [ ] args ) {   File file = new File ( " in . txt " ) ; InputStream inputStream = null ;

import java . util . Locale ; import java . util . Scanner ;   public class Project { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] str = sc . next ( ) . replaceFirst ( " [ a - z ] + " , " " ) . split ( " [ a - z ] + " , - 1 ) ; int len = str . length ;   long gold = 0 ; long coins = 0 ;   for ( int i = 0 ; i < len ; i ++ ) { int lastPoint = str [ i ] . lastIndexOf ( ' . ' ) ;   if ( str [ i ] . substring ( lastPoint + 1 ) . length ( ) == 2 ) { gold += Integer . parseInt ( str [ i ] . substring ( 0 , lastPoint ) . replaceAll ( " \\ . " , " " ) ) ; coins += Integer . parseInt ( str [ i ] . substring ( lastPoint + 1 ) ) ; } else { gold += Integer . parseInt ( str [ i ] . replaceAll ( " \\ . " , " " ) ) ; }   }   gold += coins / 100 ; coins %= 100 ;   if ( gold == 0 ) { System . out . printf ( Locale . GERMAN , "0 . % 02d " , coins ) ; } else if ( coins == 0 ) { System . out . printf ( Locale . GERMAN , " % , d " , gold ) ; } else { System . out . printf ( Locale . GERMAN , " % , d . %02d " , gold , coins ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . DecimalFormat ; import java . util . Locale ;   public class Checksum { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = reader . readLine ( ) ; double checksum = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { int z = i ; if ( Character . isDigit ( s . charAt ( i ) ) ) { StringBuilder currentPrice = new StringBuilder ( ) ; for ( int j = z ; j < s . length ( ) ; j ++ ) { char currentSymbol = s . charAt ( j ) ; i = j ; if ( Character . isDigit ( currentSymbol ) || Character . toString ( currentSymbol ) . equals ( " . " ) ) { currentPrice . append ( Character . toString ( currentSymbol ) ) ; } else break ; } String [ ] k = currentPrice . toString ( ) . split ( " \\ . " ) ; currentPrice = new StringBuilder ( ) ; for ( int j = 0 ; j < k . length ; j ++ ) { if ( k . length > 1 && j + 1 == k . length && k [ j ] . length ( ) == 2 ) { currentPrice . append ( " . " ) . append ( k [ j ] ) ; } else currentPrice . append ( k [ j ] ) ; } checksum += Double . parseDouble ( currentPrice . toString ( ) ) ; } } s = String . format ( " % , . 2f " , checksum ) ; s = s . replaceAll ( " , " , " . " ) ; if ( s . substring ( s . length ( ) - 2 ) . equals ( "00" ) ) s = s . substring ( 0 , s . length ( ) - 3 ) ; System . out . println ( s ) ; } }

import reimport pdb   inputNumbers = re . findall ( r ' [0-9 . ] + ' , input ( ) )     def convToNumber ( inputString ) : inputString = inputString . split ( ' . ' ) penny = 0 if len ( inputString ) > 1 and len ( inputString [ - 1 ] ) == 2 : penny = inputString . pop ( - 1 ) return float ( f " { ' ' . join ( inputString ) } . { penny } " )     def convToString ( inputNumber ) : intNumber , penny = str ( inputNumber ) . split ( ' . ' ) output = ' ' for i , char in enumerate ( list ( intNumber [ : : - 1 ] ) ) : output += char if ( i + 1 ) % 3 == 0 : output += ' . ' while len ( penny ) < 2 : penny += '0' output = output [ : : - 1 ] if output [ 0 ] == ' . ' : output = output [ 1 : ]   if penny == '00' : return output else : return f ' { output } . { penny } '   a = round ( sum ( [ convToNumber ( i ) for i in inputNumbers ] ) , 2 ) print ( convToString ( a ) ) NEW_LINE

s = input ( )   R = str . replace   for i in range ( 97 , 123 ) : s = R ( s , chr ( i ) , ' ▁ ' )   b = a = 0   for x in s . split ( ) :   l = x . rfind ( ' . ' )   if l == - 1 or len ( x ) - 1 - l > 2 : a += int ( R ( x , ' . ' , ' ' ) )   else : a += int ( R ( x [ : l ] , ' . ' , ' ' ) ) ; b += int ( x [ l + 1 : ] )   a += b // 100   b = str ( b % 100 )   a = str ( a )   r = ' '   while a : r = a [ - 3 : ] + ' . ' + r ; a = a [ : - 3 ]   if b != '0' : r += '0' * ( 2 - len ( b ) ) + b   else : r = r [ : - 1 ]   print ( r )       NEW_LINE

s = input ( )   prices = [ ]   cur = " " for i in s : if i . isdigit ( ) or i == " . " : cur += i else : if cur != " " : prices += [ cur ] cur = " "   if cur != " " : prices += [ cur ]   total = 0   for price in prices : if price . rfind ( " . " ) == len ( price ) - 1 - 3 : price = price . replace ( " . " , " " ) total += round ( float ( price ) , 2 ) elif price . rfind ( " . " ) == len ( price ) - 1 - 2 : NEW_LINE

from math import truncs = input ( ) k = - 1 temp = ' ' q = 0 for i in s : if i . isdigit ( ) : temp += i elif i == ' . ' : if k != - 1 : temp = temp [ : k ] + temp [ k + 1 : ] temp += i k = len ( temp ) - 1 elif len ( temp ) : if k != - 1 and len ( temp ) - 1 - k != 2 : temp = temp [ : k ] + temp [ k + 1 : ] q += float ( temp ) k = - 1 temp = ' ' if len ( temp ) : if k != - 1 and len ( temp ) - 1 - k != 2 : temp = temp [ : k ] + temp [ k + 1 : ] q += float ( temp ) ex = Falsefor i in range ( 2 , 0 , - 1 ) : d = int ( q // 1000 ** i ) if not ex : if d > 0 : print ( d , ' . ' , sep = ' ' , end = ' ' ) ex = True else : print ( '0' * ( 3 - len ( str ( d ) ) ) + str ( d ) + ' . ' , end = ' ' ) q -= d * 1000 ** ir = str ( int ( trunc ( q ) ) ) if q == 0 : print ( '000' ) elif trunc ( q ) != q : if ex : print ( '0' * ( 3 - len ( r ) ) , " { : . 2f } " . format ( round ( q , 2 ) ) , sep = ' ' ) else : print ( " { : . 2f } " . format ( round ( q , 2 ) ) ) else : if ex : print ( '0' * ( 3 - len ( r ) ) , int ( q ) , sep = ' ' ) else : print ( int ( q ) ) NEW_LINE


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

import java . io . * ; import java . util . * ; public class r73b { public static void main ( String args [ ] ) { fastio in = new fastio ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int n = in . nextInt ( ) ; HashMap < String , Integer > countand = new HashMap < String , Integer > ( ) ; HashMap < String , Integer > countstar = new HashMap < String , Integer > ( ) ; countand . put ( " void " , 0 ) ; countstar . put ( " void " , 0 ) ; countand . put ( " errtype " , - 1 ) ; countstar . put ( " errtype " , - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class VasyaAndTypes { public static TreeMap < String , Integer > parameters = new TreeMap < > ( ) ; public static int process ( String A ) { int ampersands = 0 , l = A . length ( ) ; while ( A . charAt ( ampersands ) == ' & ' ) ampersands ++ ;   int asterisks = 0 ; while ( A . charAt ( l - 1 - asterisks ) == ' * ' ) asterisks ++ ;   String C = A . substring ( ampersands , l - asterisks ) ;   if ( C . equals ( " errtype " ) ) return - 1 ; else { if ( ! parameters . containsKey ( C ) ) return - 1 ; int Cx = parameters . get ( C ) ;   if ( Cx == - 1 ) return - 1 ;   asterisks += Cx ; if ( asterisks >= ampersands ) { return asterisks - ampersands ; } else { return - 1 ; } } } public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int n = Integer . parseInt ( br . readLine ( ) ) ;   StringTokenizer st ;     parameters . put ( " void " , 0 ) ;   for ( int i = 0 ; i < n ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ;   String command = st . nextToken ( ) ;   if ( command . equals ( " typedef " ) ) { String A = st . nextToken ( ) ; String B = st . nextToken ( ) ;   parameters . put ( B , process ( A ) ) ;   } else { String A = st . nextToken ( ) ;   int x = process ( A ) ; if ( x == - 1 ) pw . println ( " errtype " ) ; else { pw . print ( " void " ) ; for ( int j = 0 ; j < x ; j ++ ) pw . print ( " * " ) ; pw . println ( ) ; } } }   pw . flush ( ) ; pw . close ( ) ; } }

from collections import * NEW_LINE import sys , relines = [ i [ : - 1 ] for i in sys . stdin . readlines ( ) ] NEW_LINE n = int ( lines [ 0 ] ) NEW_LINE lines = lines [ 1 : ] NEW_LINE typeof = defaultdict ( lambda : ' errtype ' ) NEW_LINE typeof [ ' void ' ] = ' void ' NEW_LINE def simplify ( s ) : global typeof NEW_LINE l , r = s . count ( ' & ' ) , s . count ( ' * ' ) NEW_LINE result = typeof [ s [ l : len ( s ) - r ] ] NEW_LINE

class CodeforcesTask87BSolution : def NEW_LINE __init__ ( self ) : self . result = ' ' NEW_LINE self . n = 0 NEW_LINE self . expressions = [ ]   NEW_LINE def read_input ( self ) : self . n = int ( input ( ) ) NEW_LINE for x in range ( self . n ) : self . expressions . append ( input ( ) . split ( " ▁ " ) )   NEW_LINE def process_task ( self ) : result = [ ] NEW_LINE lang_dict = { " void " : 0 } NEW_LINE for expr in self . expressions : if NEW_LINE expr [ 0 ] == " typedef " : up = expr [ 1 ] . count ( " * " ) NEW_LINE down = expr [ 1 ] . count ( " & " ) NEW_LINE nm = expr [ 1 ] . replace ( " * " , " " ) . replace ( " & " , " " ) NEW_LINE if nm in lang_dict : if NEW_LINE lang_dict [ nm ] == - 1 : lang_dict [ expr [ 2 ] ] = - 1 else : lang_dict [ expr [ 2 ] ] = max ( - 1 , lang_dict [ nm ] + up - down ) else : lang_dict [ expr [ 2 ] ] = - 1 elif expr [ 0 ] == " typeof " : up = expr [ 1 ] . count ( " * " ) NEW_LINE down = expr [ 1 ] . count ( " & " ) NEW_LINE nm = expr [ 1 ] . replace ( " * " , " " ) . replace ( " & " , " " ) NEW_LINE if nm in lang_dict : balance = max ( lang_dict [ nm ] + up - down , - 1 ) NEW_LINE if balance == - 1 or lang_dict [ nm ] == - 1 : NEW_LINE INDENT result . append ( " errtype " ) else : NEW_LINE result . append ( " void " + " * " * balance ) else : result . append ( " errtype " ) NEW_LINE DEDENT self . result = " \n " . join ( result )   NEW_LINE def get_result ( self ) : return self . result NEW_LINE     if __name__ == " _ _ main _ _ " : Solution = CodeforcesTask87BSolution ( ) NEW_LINE Solution . read_input ( ) NEW_LINE Solution . process_task ( ) NEW_LINE print ( Solution . get_result ( ) ) NEW_LINE


import java . io . File ; import java . io . FileNotFoundException ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Iterator ; import java . util . Scanner ;   public class A { public static void main ( String [ ] args ) throws FileNotFoundException { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { long num = in . nextLong ( ) ; long res = 0 ; int turn = 0 ; while ( num > 0 ) { long amt = 0 ; if ( num % 4 == 0 && num > 8 ) amt = 1 ; else if ( num % 2 == 0 ) { amt = num / 2 ; } else { amt = 1 ; } num -= amt ; if ( turn == 0 ) res += amt ; turn = ( turn + 1 ) % 2 ; } System . out . println ( res ) ; } } }

import java . util . * ; public class ArenaOfGreed {   static HashMap < Long , Long > map = new HashMap < > ( ) ;   public static void main ( String [ ] args ) {

import java . io . * ; import java . util . * ; public class Solution { public static void main ( String [ ] args ) throws Exception { FastReader fr = new FastReader ( ) ; int t = fr . nextInt ( ) ; while ( t -- > 0 ) { long n = fr . nextLong ( ) ; boolean turn = true ; long val = 0 ; while ( n > 0 ) { if ( n % 4 == 0 && n > 8 ) { if ( turn ) val += 1 ; n -- ; } else if ( n % 2 == 0 ) { if ( turn ) val += n / 2 ; n = n / 2 ; } else { if ( turn ) val += 1 ; n -- ; } turn = ! turn ; } System . out . println ( val ) ; } } } class Pair { int x ; int y ; Pair ( int x , int y ) { this . x = x ; this . y = y ; } }      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 Ishu { static Scanner scan = new Scanner ( System . in ) ; static void tc ( ) { long n = scan . nextLong ( ) ; long a = 0l ; long b = 0l ; int ctr = 0 ; while ( n > 0 ) { if ( ctr % 2 == 0 ) { if ( n % 2 == 0 ) { if ( ( n / 2 ) % 2 == 0 && n > 4 ) { a += 1 ; -- n ; } else { a += n / 2 ; n /= 2 ; } } else { a += 1 ; -- n ; } } else { if ( n % 2 == 0 ) { if ( ( n / 2 ) % 2 == 0 && n > 4 ) { b += 1 ; -- n ; } else { b += n / 2 ; n /= 2 ; } } else { b += 1 ; -- n ; } } ++ ctr ;   } System . out . println ( a ) ; } public static void main ( String [ ] args ) { int t = 1 ; t = scan . nextInt ( ) ; while ( t -- > 0 ) tc ( ) ; } }

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

from sys import stdin , stdoutdef NEW_LINE main ( ) : NEW_LINE for _ in range ( int ( stdin . readline ( ) ) ) : n = int ( stdin . readline ( ) ) NEW_LINE ans = [ 0 , 0 ] NEW_LINE first , second = 1 , 0 NEW_LINE get = [ 0 , 1 , 1 , 2 , 3 ] NEW_LINE while n : if NEW_LINE n < 5 : temp = get [ n ] NEW_LINE if first : ans [ 0 ] += temp NEW_LINE first ^= 1 NEW_LINE ans [ 1 ] += n - temp else : ans [ 1 ] += temp NEW_LINE second ^= 1 NEW_LINE ans [ 0 ] += n - temp NEW_LINE break elif n % 2 == 1 or ( ( n // 2 ) % 2 == 0 ) : NEW_LINE if first : ans [ 0 ] += 1 NEW_LINE first ^= 1 NEW_LINE second = 1 else : ans [ 1 ] += 1 NEW_LINE second ^= 1 NEW_LINE first = 1 NEW_LINE n -= 1 else : if first : ans [ 0 ] += n // 2 NEW_LINE first ^= 1 NEW_LINE second = 1 else : ans [ 1 ] += n // 2 NEW_LINE second ^= 1 NEW_LINE first = 1 NEW_LINE n = n // 2 NEW_LINE stdout . write ( " % d \n " % ( ans [ 0 ] ) ) NEW_LINE main ( ) NEW_LINE


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

import java . util . Arrays ; import java . util . Scanner ; import java . lang . String ; import java . util . Random ;   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 n = sc . nextInt ( ) ; for ( int j = 0 ; j < n ; j += 2 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; System . out . print ( - b + " ▁ " + a + " ▁ " ) ; } System . out . println ( ) ; } } }

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

for t in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE i = 0 NEW_LINE j = n - 1 NEW_LINE result = [ 0 ] * n NEW_LINE while i < j : result [ i ] = - a [ j ] NEW_LINE result [ j ] = a [ i ] NEW_LINE i += 1 NEW_LINE j -= 1 NEW_LINE print ( " ▁ " . join ( str ( x ) for x in result ) ) NEW_LINE

def insertion_sort ( l ) : for NEW_LINE i in range ( len ( l ) ) : NEW_LINE for j in ( range ( i ) ) : k = i - j NEW_LINE if l [ k ] >= l [ k - 1 ] : NEW_LINE INDENT l [ k - 1 ] , l [ k ] = l [ k ] , l [ k - 1 ] else : NEW_LINE break NEW_LINE DEDENT return l       NEW_LINE def selection_sort ( l ) : for NEW_LINE i in range ( len ( l ) ) : min_ind = i NEW_LINE min_val = l [ i ] NEW_LINE for j in range ( i , len ( l ) ) : if NEW_LINE min_val > l [ j ] : min_val = l [ j ] NEW_LINE min_ind = j NEW_LINE l [ i ] , l [ min_ind ] = l [ min_ind ] , l [ i ] NEW_LINE return l     NEW_LINE def bubble_sort ( l ) : for NEW_LINE i in range ( len ( l ) - 1 ) : NEW_LINE for j in range ( len ( l ) - 1 - i ) : if NEW_LINE l [ j ] > l [ j + 1 ] : l [ j ] , l [ j + 1 ] = l [ j + 1 ] , l [ j ] NEW_LINE return l     NEW_LINE

t = int ( input ( ) ) NEW_LINE while ( t > 0 ) : n = int ( input ( ) ) NEW_LINE temp = input ( ) NEW_LINE ar = ( temp . split ( ) ) NEW_LINE for i in range ( 0 , n , 2 ) : print ( - 1 * ( int ( ar [ i + 1 ] ) ) , end = " ▁ " ) NEW_LINE print ( ( int ( ar [ i ] ) ) , end = " ▁ " ) NEW_LINE print ( " " ) NEW_LINE t -= 1 NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class Zad940B {   public static void main ( String [ ] args ) {

import java . io . * ; import java . util . * ; import java . util . ArrayList ;    public class CryOut {    public static void main ( String [ ] args ) { InputStream stream = System . in ; PrintWriter out = new PrintWriter ( System . out ) ; FastReader sc = new FastReader ( stream ) ;

import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;

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

import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class pblm3 { static int a ; static int b ; static int k ; static HashMap < Integer , Long > map ; public static long steps ( int n ) {

n = int ( input ( ) ) k = int ( input ( ) ) a = int ( input ( ) ) b = int ( input ( ) )   ans = 0   if k == 1 : ans += ( n ) * a - aelse : while n > 1 : if n % k > 0 : if n < k : ans += ( n % k ) * a - a ; n -= ( n % k ) else : ans += ( n % k ) * a ; n -= ( n % k ) else : ans += min ( ( n - ( n // k ) ) * a , b ) n = n // kprint ( ans )       NEW_LINE

n = int ( input ( ) ) k = int ( input ( ) ) A = int ( input ( ) ) B = int ( input ( ) ) c = 0 while ( n != 1 ) : if ( k == 1 or k > n ) : c += ( n - 1 ) * A break elif ( n % k != 0 ) : c += ( n % k ) * A n -= n % k else : c += min ( B , ( n - n // k ) * A ) n = n // kprint ( c ) NEW_LINE

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

n , k , a , b , s = int ( input ( ) ) , int ( input ( ) ) , int ( input ( ) ) , int ( input ( ) ) , 0 if ( k > 1 ) : while ( ( ( n // k ) * ( k - 1 ) * a ) > b ) : s += ( n % k ) * a + b n //= kprint ( int ( s + ( n - 1 ) * a ) ) NEW_LINE

import sysinput = sys . stdin . readlinen = int ( input ( ) ) k = int ( input ( ) ) a = int ( input ( ) ) b = int ( input ( ) ) ans = 0 if k == 1 : print ( ( n - 1 ) * a ) exit ( ) while n > 1 : if n < k : ans += ( n - 1 ) * a break if n % k != 0 : ans += ( n % k ) * a n -= ( n % k ) else : while n % k == 0 and n > 1 : temp = n // k if ( n - temp ) * a >= b : ans += b else : ans += ( ( n - temp ) * a ) n //= kprint ( ans ) NEW_LINE


import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] a = new char [ n ] ; int count = 0 , count1 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = s . charAt ( i ) ; if ( a [ i ] == '0' ) { count ++ ; } else { count1 ++ ; } } if ( count == count1 ) { System . out . println ( "2 ▁ " ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { System . out . print ( a [ i ] ) ; } System . out . print ( " ▁ " ) ; System . out . print ( a [ n - 1 ] ) ; } else if ( n == 1 ) { int j = 0 ; System . out . println ( "1 ▁ " ) ; System . out . print ( a [ j ] ) ; } else { System . out . println ( "1 ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( a [ i ] ) ; } } } }

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; s . nextLine ( ) ; String s1 = s . nextLine ( ) ; String result = " " ; int count = 0 , count1 = 0 , count2 = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( s1 . charAt ( j ) == '0' ) count ++ ; else count1 ++ ; } if ( count == count1 ) { int k = n / count ; System . out . println ( "2" ) ; System . out . print ( s1 . charAt ( 0 ) + " ▁ " ) ; for ( int j = 1 ; j < n ; j ++ ) { result = result + s1 . charAt ( j ) ; } System . out . print ( result ) ; } else { System . out . println ( "1" ) ; System . out . println ( s1 ) ; } } }

import java . util . * ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; String s = input . next ( ) ;   int z = 0 , o = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '0' ) z ++ ; else o ++ ; }   if ( z == o ) { System . out . println ( 2 ) ; System . out . println ( s . substring ( 0 , n - 1 ) + " ▁ " + s . substring ( n - 1 ) ) ; } else { System . out . println ( 1 ) ; System . out . println ( s ) ; } } }

import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class KeanuReaves { 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 {

import java . util . * ;   public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int ct = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '0' ) ct ++ ; else ct -- ; } if ( ct != 0 ) System . out . print ( "1 \n " + s ) ; else System . out . print ( "2 \n " + s . charAt ( 0 ) + " ▁ " + s . substring ( 1 , n ) ) ; } }

import math   def is_good_string ( s ) : count_1 = 0 count_0 = 0 for i in s : if i == "0" : count_0 += 1 else : count_1 += 1 if count_1 == count_0 : return False return True   def recur_search_for_good_str ( s , n , l ) : pass         def main_function ( ) : n = int ( input ( ) ) s = input ( ) if is_good_string ( s ) : return str ( 1 ) + " \n " + s else : return str ( 2 ) + " \n " + s [ 0 ] + " ▁ " + s [ 1 : ]               print ( main_function ( ) ) NEW_LINE

n = int ( input ( ) ) k = ( input ( ) ) x = k . count ( '0' ) y = k . count ( '1' ) if ( x == y ) : print ( 2 ) print ( k [ 0 ] , k [ 1 : ] ) else : print ( 1 ) print ( k ) NEW_LINE

num = int ( input ( ) ) s = input ( )   if s . count ( "0" ) != s . count ( "1" ) : print ( 1 ) print ( s ) else : print ( 2 ) print ( s [ 0 ] , s [ 1 : ] )     NEW_LINE

n = int ( input ( ) ) s = input ( ) bal = 0 for c in s : if c == '0' : bal = bal + 1 else : bal = bal - 1 if bal != 0 : print ( '1' + ' \n ' + s ) else : print ( '2' + " \n " + s [ 0 : - 1 ] + " ▁ " + s [ - 1 ] ) NEW_LINE

n = int ( input ( ) ) s = input ( ) bal = 0 for c in s : if c == '0' : bal += 1 else : bal -= 1 if bal != 0 : print ( '1' + ' \n ' + s ) else : print ( '2' + " \n " + s [ 0 : - 1 ] + " ▁ " + s [ - 1 ] ) NEW_LINE


import java . util . Scanner ;   public class zizo { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; for ( int a = 0 ; a < n ; a ++ ) { LOOP : for ( int b = 1 ; b < n ; b ++ ) { for ( int i = 0 ; i <= 4 ; i ++ ) { int x = a + b * i ; if ( x >= n ) { continue LOOP ; } if ( s [ x ] == ' . ' ) { continue LOOP ; } } System . out . println ( " yes " ) ; return ; } } System . out . println ( " no " ) ; } }

import java . io . * ; import java . util . * ;    public class Source { static class FastScanner { private BufferedReader br ; private StringTokenizer st ; public FastScanner ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException ignored ) { } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } }   public static void main ( String args [ ] ) { FastScanner scanner = new FastScanner ( System . in ) ; PrintWriter printer = new PrintWriter ( System . out ) ; int n = scanner . nextInt ( ) ; String s = scanner . next ( ) ; for ( int k = 1 ; k < n ; k ++ ) { for ( int i = 0 ; ; i ++ ) { if ( i + k * 4 >= n ) { break ; } boolean c1 = s . charAt ( i ) == ' * ' ; boolean c2 = s . charAt ( i + k ) == ' * ' ; boolean c3 = s . charAt ( i + k * 2 ) == ' * ' ; boolean c4 = s . charAt ( i + k * 3 ) == ' * ' ; boolean c5 = s . charAt ( i + k * 4 ) == ' * ' ; if ( c1 && c2 && c3 && c4 && c5 ) { printer . println ( " yes " ) ; printer . close ( ) ; return ; } } } printer . println ( " no " ) ; printer . close ( ) ; } }

import java . util . Scanner ;   public class Code {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; boolean t = true ; for ( int i = 0 ; i < s . length ( ) && t ; i ++ ) { if ( s . charAt ( i ) == ' * ' ) { for ( int j = 1 ; i + 4 * j < s . length ( ) ; j ++ ) { if ( s . charAt ( i + j ) == ' * ' && s . charAt ( i + 2 * j ) == ' * ' && s . charAt ( i + 3 * j ) == ' * ' && s . charAt ( i + 4 * j ) == ' * ' ) { System . out . println ( " yes " ) ; t = false ; break ; } } } } if ( t ) { System . out . println ( " no " ) ; } }   }

def king ( s ) : l = [ ] for i in range ( len ( s ) ) : if s [ i ] == ' * ' : l . append ( i ) if len ( l ) < 5 : print ( ' no ' ) else : k = ( max ( x for x in l ) - min ( x for x in l ) ) // 4 def space_eq ( s , j ) : ans = False for i in s : if ( i + j ) in s and ( i + 2 * j ) in s and ( i + 3 * j ) in s and ( i + 4 * j ) in s : ans = True break return ans ans = False for j in range ( 1 , k + 1 ) : if space_eq ( l , j ) == True : ans = True break if ans == True : print ( ' yes ' ) else : print ( ' no ' )   n = int ( input ( ) ) s = input ( ) assert len ( s ) == n , ' Incorrect ▁ Input ' king ( s ) NEW_LINE

n , s , r = int ( input ( ) ) , input ( ) , rangeprint ( [ ' no ' , ' yes ' ] [ any ( all ( s [ i + k * j ] == ' * ' for k in r ( 5 ) ) for i in r ( n - 4 ) for j in r ( 1 , ( n - i + 3 ) // 4 ) ) ] ) NEW_LINE

n , s , r = int ( input ( ) ) , input ( ) , rangeprint ( [ ' yes ' , ' no ' ] [ all ( ' . ' in s [ i : i + 5 * j : j ] for i in r ( n - 4 ) for j in r ( 1 , ( n - i + 3 ) // 4 ) ) ] ) NEW_LINE

a = int ( input ( ) ) k = input ( ) b = [ i for i in range ( a ) if k [ i ] == ' * ' ] for i in b : for j in range ( 1 , 101 ) : ok = 1 for x in range ( 1 , 5 ) : if i + j * x not in b : ok = 0 ; break if ok : exit ( print ( " yes " ) ) print ( " no " ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   public class Codeforces_1185A { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] places = { in . nextInt ( ) , in . nextInt ( ) , in . nextInt ( ) } ; int d = in . nextInt ( ) , c = 0 ; Arrays . sort ( places ) ; if ( places [ 1 ] - places [ 0 ] < d ) c = c + d - ( places [ 1 ] - places [ 0 ] ) ; if ( places [ 2 ] - places [ 1 ] < d ) c = c + d - ( places [ 2 ] - places [ 1 ] ) ; System . out . println ( c ) ; } }

import java . util . * ;   public class NewClass {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int [ ] arr = new int [ 4 ] ; for ( int i = 0 ; i < 4 ; i ++ ) { arr [ i ] = in . nextInt ( ) ; } int c = 0 ; int newArr [ ] = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { newArr [ i ] = arr [ i ] ; } Arrays . sort ( newArr ) ; int ab = Math . abs ( newArr [ 0 ] - newArr [ 1 ] ) - arr [ 3 ] ; int bc = Math . abs ( newArr [ 1 ] - newArr [ 2 ] ) - arr [ 3 ] ; int ac = Math . abs ( newArr [ 0 ] - newArr [ 2 ] ) - arr [ 3 ] ; while ( ab < 0 ) { ab ++ ; c ++ ; } while ( bc < 0 ) { bc ++ ; c ++ ; }   System . out . println ( c ) ; } }

import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = new int [ 4 ] ; for ( int i = 1 ; i <= 3 ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; int d = sc . nextInt ( ) ; int i = 1 , total = 0 ; if ( a [ i + 1 ] - a [ i ] < d ) { total = total + ( d - ( a [ i + 1 ] - a [ i ] ) ) ; } i ++ ; if ( a [ i + 1 ] - a [ i ] < d ) { total = total + ( d - ( a [ i + 1 ] - a [ i ] ) ) ; } System . out . println ( total ) ; } }

a , b , c , d = map ( int , input ( ) . split ( ) )   if ( a <= b and b <= c ) or ( c <= b and b <= a ) : mid = belif ( b <= c and c <= a ) or ( a <= c and c <= b ) : mid = celse : mid = a   subOne = abs ( mid - min ( ( a , b , c ) ) ) subTwo = abs ( max ( ( a , b , c ) ) - mid ) ans = 0 if subOne < d : ans += abs ( d - subOne ) else : ans += 0 if subTwo < d : ans += abs ( d - subTwo ) else : ans += 0 print ( ans ) NEW_LINE

a , b , c , d = map ( int , input ( ) . split ( ) ) a = sorted ( [ a , b , c ] ) print ( max ( 0 , d - ( a [ 1 ] - a [ 0 ] ) ) + max ( 0 , d - ( a [ 2 ] - a [ 1 ] ) ) ) NEW_LINE

a , b , c , d = list ( map ( int , input ( ) . split ( ) ) ) s = sorted ( [ a , b , c ] ) ab = s [ 1 ] - s [ 0 ] bc = s [ 2 ] - s [ 1 ] if ab < d : if bc < d : print ( ( d - s [ 1 ] + s [ 0 ] ) + ( d - s [ 2 ] + s [ 1 ] ) ) else : print ( d - s [ 1 ] + s [ 0 ] ) else : if bc < d : print ( d - s [ 2 ] + s [ 1 ] ) else : print ( 0 )   NEW_LINE

l = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) l , d = l [ : 3 ] , l [ 3 ] sec = 0 l . sort ( ) sec = max ( 0 , d - l [ 1 ] + l [ 0 ] ) + max ( 0 , d - l [ 2 ] + l [ 1 ] ) print ( sec ) NEW_LINE

a , b , c , d = map ( int , input ( ) . split ( ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Main {   public static int smallestIndex ( ArrayList < Integer > a , int start ) { int min = Integer . MAX_VALUE ; for ( int i = start ; i < a . size ( ) ; i ++ ) { min = Math . min ( min , a . get ( i ) ) ; } return a . indexOf ( min ) ;   }   public static void main ( String [ ] args ) throws IOException {   FastScanner input = new FastScanner ( ) ; int tc = input . nextInt ( ) ; while ( tc -- > 0 ) { int n = input . nextInt ( ) ; ArrayList < Integer > a = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int value = input . nextInt ( ) ; a . add ( value ) ;   } int start = 0 ;   while ( start < a . size ( ) ) { int i = smallestIndex ( a , start ) ; int small = a . get ( i ) ; if ( a . get ( i ) == a . get ( start ) ) { start ++ ; continue ; } a . remove ( a . get ( i ) ) ; a . add ( start , small ) ;

import java . io . * ; import java . util . * ; public class minimizethepermutation { public static void main ( String [ ] args ) throws IOException { BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( f . readLine ( ) ) ; int q = Integer . parseInt ( st . nextToken ( ) ) ; while ( q > 0 ) { q -- ; int n = Integer . parseInt ( f . readLine ( ) ) ; int [ ] arr = new int [ n ] ; st = new StringTokenizer ( f . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = Integer . parseInt ( st . nextToken ( ) ) - 1 ; } int index = 0 ; HashSet < Integer > usedOperations = new HashSet < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { index = 0 ; while ( arr [ index ] != i ) index ++ ; for ( int j = index ; j >= 1 && ! usedOperations . contains ( j ) ; j -- ) { if ( arr [ j ] < arr [ j - 1 ] ) { int temp = arr [ j ] ; arr [ j ] = arr [ j - 1 ] ; arr [ j - 1 ] = temp ; usedOperations . add ( j ) ; } } } for ( int i : arr ) System . out . print ( i + 1 + " ▁ " ) ; System . out . println ( ) ; } } }

T = int ( input ( ) ) for _ in range ( T ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) ; k = 0 for i in range ( 1 , n + 1 ) : idx = arr . index ( i ) if idx == k : k += 1 ; continue elif idx > k : for i in range ( idx , k , - 1 ) : arr [ i ] , arr [ i - 1 ] = arr [ i - 1 ] , arr [ i ] k = idx print ( * arr ) NEW_LINE

import sysinput = sys . stdin . readlinefor _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) visited = set ( ) for i in range ( 1 , n + 1 ) : ind = l . index ( i ) if ind >= i - 1 : while ind > i - 1 : if ( ind - 1 , ind ) in visited : break   if l [ ind - 1 ] < l [ ind ] : break   else : l [ ind - 1 ] , l [ ind ] = l [ ind ] , l [ ind - 1 ] visited . add ( ( ind - 1 , ind ) )   ind -= 1   NEW_LINE