import java . util . * ; import java . io . * ; public class A { public static void main ( String args [ ] ) { FastScanner in = new FastScanner ( ) ; int n = in . nextInt ( ) ; int a [ ] = in . nextArray ( n ) ; HashMap < Integer , Integer > hmap = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { hmap . put ( a [ i ] , i ) ; } int max = 0 ; int ans = 0 ; for ( int key : hmap . keySet ( ) ) { if ( n - hmap . get ( key ) > max ) { max = n - hmap . get ( key ) ; ans = key ; } } System . out . println ( ans ) ; }

import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; Integer [ ] visit = new Integer [ n ] ; Set < Integer > cafes = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; ++ i ) { visit [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; if ( ! cafes . contains ( visit [ i ] ) ) cafes . add ( visit [ i ] ) ; } Map < Integer , Integer > last = new HashMap < Integer , Integer > ( ) ; for ( int i = n - 1 ; i >= 0 ; -- i ) { Integer v = last . getOrDefault ( visit [ i ] , null ) ; if ( v == null ) last . put ( visit [ i ] , n - i ) ; } Integer winner = null ; int winnerScore = 0 ; for ( Integer i : cafes ) { int score = last . get ( i ) ; if ( winner == null || winnerScore < score ) { winner = i ; winnerScore = score ; } } System . out . println ( winner ) ; } }

import java . util . * ; public class A { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; HashMap < Integer , Integer > hm = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; hm . put ( a [ i ] , i + 1 ) ; } int min = Integer . MAX_VALUE ; int ans = 0 ; for ( Map . Entry < Integer , Integer > entry : hm . entrySet ( ) ) { int x = entry . getKey ( ) ; int y = entry . getValue ( ) ; if ( y < min ) { min = y ; ans = x ; } } System . out . println ( ans ) ; } }

import java . io . * ; import java . util . * ; public class VsRohan { static Reader sc = new Reader ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; public static void main ( String args [ ] ) throws IOException { int t = sc . nextInt ( ) ; int arr [ ] = new int [ 200001 ] ; Arrays . fill ( arr , ( int ) 1e9 ) ; for ( int i = 0 ; i < t ; ++ i ) { int a = sc . nextInt ( ) ; arr [ a ] = i ; } int min = ( int ) 1e9 , ans = 0 ; ; for ( int i = 0 ; i < arr . length ; ++ i ) { if ( arr [ i ] < min ) { min = arr [ i ] ; ans = i ; } } out . println ( ans ) ; out . close ( ) ; }   static class Reader { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; public String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return br . readLine ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; } public boolean hasNext ( ) { String next = null ; try { next = br . readLine ( ) ; } catch ( Exception e ) { } if ( next == null ) { return false ; } st = new StringTokenizer ( next ) ; return true ; } } }

n = int ( input ( ) ) r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = r ( )   x = set ( arr ) arr = arr [ : : - 1 ] y = set ( ) for i in arr : y . add ( i ) if len ( y ) == len ( x ) : print ( i ) break NEW_LINE

m = input ( ) a = list ( map ( int , input ( ) . split ( ) ) ) a . reverse ( ) dic = { } ; i = 0 for m in a : if m not in dic : dic [ m ] = i i += 1 print ( max ( dic , key = dic . get ) ) NEW_LINE

import sys , mathsys . setrecursionlimit ( 10 ** 8 ) ''' def ▁ fun ( ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 16 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( 4 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ i & (1 < < j ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( j , end = ' ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ) import ▁ binarytreefrom ▁ collections ▁ import ▁ dequebst ▁ = ▁ binarytree . tree ( height = 4 , is _ perfect = True ) print ( bst ) def ▁ s ( bst ) : ▁ ▁ ▁ ▁ if ▁ bst : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ bst . left , bst . right ▁ = ▁ bst . right , bst . left ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . right ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . left ) s ( bst ) print ( bst ) ''' t = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr = arr [ : : - 1 ] se = set ( arr ) l = len ( se ) se1 = set ( ) for i in arr : if ( i in se and i not in se1 ) : se1 . add ( i ) if l == 1 : print ( i ) l -= 1 NEW_LINE

import sys , mathsys . setrecursionlimit ( 10 ** 8 ) ''' def ▁ fun ( ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 16 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( 4 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ i & (1 < < j ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( j , end = ' ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ) import ▁ binarytreefrom ▁ collections ▁ import ▁ dequebst ▁ = ▁ binarytree . tree ( height = 4 , is _ perfect = True ) print ( bst ) def ▁ s ( bst ) : ▁ ▁ ▁ ▁ if ▁ bst : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ bst . left , bst . right ▁ = ▁ bst . right , bst . left ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . right ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . left ) s ( bst ) print ( bst ) ''' t = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr = arr [ : : - 1 ] d = { i : 0 for i in set ( arr ) } l = len ( d ) for i in arr : if d [ i ] == 0 : d [ i ] += 1 if l == 1 : print ( i ) l -= 1 else : d [ i ] += 1 NEW_LINE


import java . io . IOException ; import java . util . * ; public class Petya2 { public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; String x = input . next ( ) ; Stack < Character > stk = new Stack < > ( ) ; for ( int i = x . length ( ) - 1 ; i >= 0 ; i -- ) { if ( ! stk . empty ( ) && stk . peek ( ) == x . charAt ( i ) ) { stk . pop ( ) ; } else stk . push ( x . charAt ( i ) ) ; } int size = stk . size ( ) ; StringBuffer ans = new StringBuffer ( " " ) ; for ( int i = 0 ; i < size ; i ++ ) ans . append ( stk . pop ( ) ) ; System . out . println ( ans ) ; } }

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

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

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Stack ;   public class CF { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String s = br . readLine ( ) ; Stack < Character > stk = new Stack < Character > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( stk . empty ( ) ) { stk . push ( s . charAt ( i ) ) ; } else { if ( stk . peek ( ) != s . charAt ( i ) ) stk . push ( s . charAt ( i ) ) ; else stk . pop ( ) ; } } StringBuilder sb = new StringBuilder ( ) ; while ( ! stk . empty ( ) ) sb . append ( stk . pop ( ) ) ;   System . out . println ( sb . reverse ( ) . toString ( ) ) ; } }

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 {   public static void main ( String [ ] args ) throws IOException { FastScanner input = new FastScanner ( ) ; String s = input . next ( ) ; int len = s . length ( ) ; StringBuilder ans = new StringBuilder ( ) ; for ( int i = 0 ; i < len ; i ++ ) { if ( ans . length ( ) > 0 && ans . charAt ( ans . length ( ) - 1 ) == s . charAt ( i ) ) { ans . deleteCharAt ( ans . length ( ) - 1 ) ; } else { ans . append ( s . charAt ( i ) ) ; } } System . out . println ( ans ) ; }   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 ( ) ) ; } }   }

from collections import deque   charlist = list ( input ( ) ) NEW_LINE n = len ( charlist ) NEW_LINE string = deque ( charlist [ n - 1 ] ) NEW_LINE charlist . pop ( ) NEW_LINE n = len ( charlist ) NEW_LINE for i in reversed ( range ( 0 , n ) ) : if NEW_LINE INDENT ( len ( string ) == 0 ) : string . append ( charlist [ i ] ) elif ( string [ - 1 ] == charlist [ i ] ) : charlist . pop ( ) NEW_LINE DEDENT string . pop ( ) else : string . append ( charlist [ i ] )   print ( " " . join ( string ) [ : : - 1 ] )                         NEW_LINE

s = input ( )   i = 0 NEW_LINE t = [ ] NEW_LINE while i < len ( s ) : j = i NEW_LINE while j + 1 < len ( s ) and s [ j + 1 ] == s [ i ] : j += 1 NEW_LINE if ( j - i + 1 ) % 2 == 1 : if NEW_LINE t and t [ - 1 ] == s [ i ] : t . pop ( ) else : t . append ( s [ i ] ) NEW_LINE i = j + 1   print ( ' ' . join ( t ) ) NEW_LINE

s = input ( )   length = len ( s ) NEW_LINE ans = [ ] NEW_LINE ans . append ( s [ 0 ] )   for i in range ( 1 , length ) : length1 = len ( ans ) NEW_LINE


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

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . util . TreeMap ; import java . util . TreeSet ;    public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; Integer a [ ] = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } if ( n == 1 ) { System . out . println ( "2" ) ; return ; } Arrays . sort ( a ) ; int min = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] >= min ) { min ++ ; } } System . out . println ( min ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class MexArray { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   int n = scan . nextInt ( ) ; Integer [ ] a = new Integer [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) a [ i ] = scan . nextInt ( ) ;   Arrays . sort ( a ) ;   int mex = n + 1 ; int pp = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < i + 1 - pp ) { mex -- ; pp ++ ; } }   System . out . println ( mex ) ; } }

n = int ( input ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] k = 1 a . sort ( ) for i in range ( n ) : if a [ i ] >= k : k += 1 print ( k ) NEW_LINE

x = int ( input ( ) )   arr = list ( map ( int , input ( ) . split ( ) ) ) [ : x ] arr . sort ( )   cur = 1 for i in arr : if i >= cur : cur += 1 else : i += 1 print ( cur ) NEW_LINE

n = int ( input ( ) ) w = list ( map ( int , input ( ) . split ( ) ) ) w . sort ( ) ans = 1 for i in w : ans += i >= ansprint ( ans ) NEW_LINE

n = int ( input ( ) ) a = sorted ( [ 0 ] + [ int ( x ) for x in input ( ) . split ( ) ] ) for i in range ( 1 , n + 1 ) : if a [ i ] != a [ i - 1 ] : a [ i ] = a [ i - 1 ] + 1 print ( a [ - 1 ] + 1 ) NEW_LINE

n = int ( input ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) ; ar = sorted ( ar ) ele = 1 for i in range ( n ) : if ar [ i ] >= ele : ele += 1 print ( ele ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . io . BufferedWriter ; import java . io . Writer ; import java . io . OutputStreamWriter ; import java . util . InputMismatchException ; import java . util . Random ; import java . io . IOException ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; OutputWriter out = new OutputWriter ( outputStream ) ; Task1039B solver = new Task1039B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class Task1039B { private InputReader in ; private OutputWriter out ; private long n ; private long l ; private long r ; private int k ;   public void solve ( int testNumber , InputReader in , OutputWriter out ) { this . in = in ; this . out = out ; n = in . nextLong ( ) ; k = in . nextInt ( ) ; l = 1 ; r = n ; while ( true ) { while ( r - l >= 48 ) { getInterval ( ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Random ; import java . util . StringTokenizer ;   public class _507B {   public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; long n = fs . nextLong ( ) , k = fs . nextLong ( ) ; long min = 1 , max = n ; Random r = new Random ( ) ; while ( true ) { if ( max - min > 100 ) { long mid = ( max + min ) / 2 ; System . out . println ( min + " ▁ " + mid ) ; System . out . flush ( ) ; String input = fs . next ( ) ; if ( input . equals ( " Yes " ) ) { max = mid ; } else { min = mid + 1 ; } } else { long toPick = r . nextInt ( ( int ) ( max - min + 1 ) ) + min ; System . out . println ( toPick + " ▁ " + toPick ) ; System . out . flush ( ) ; String input = fs . next ( ) ; if ( input . equals ( " Yes " ) ) { return ; } else {

import sys   input = sys . stdin . readline   from random import randint   def solve ( ) : n , k = map ( int , input ( ) . split ( ) ) l = 1 r = n while True : c = ( l + r ) // 2 w1 = min ( c + k , n ) - max ( l - k , 1 ) w2 = min ( r + k , n ) - max ( c + 1 - k , 1 ) if max ( w1 , w2 ) + 1 >= r - l + 1 : pos = randint ( l , r ) print ( pos , pos ) sys . stdout . flush ( ) if input ( ) . strip ( ) == ' Yes ' : break else : print ( l , c ) sys . stdout . flush ( ) if input ( ) . strip ( ) == ' Yes ' : if l == c : break r = c else : l = c + 1 l = max ( l - k , 1 ) r = min ( r + k , n )   solve ( ) NEW_LINE

n , k = map ( int , raw_input ( ) . split ( ) ) i_from = 1 i_to = nq_limit = 4500 - 100 NEW_LINE


import java . util . Scanner ;   public class FindTheBone {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] h = new int [ n + 1 ] ; for ( int i = 0 ; i < m ; i ++ ) h [ sc . nextInt ( ) ] ++ ; int i = 0 , pos = 1 , u , v ; while ( i < k ) { i ++ ; u = sc . nextInt ( ) ; v = sc . nextInt ( ) ; if ( h [ pos ] > 0 ) continue ; if ( u != pos && v != pos ) continue ; pos = pos != u ? u : v ; } System . out . println ( pos ) ; sc . close ( ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import static java . util . Arrays . sort ; import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) {   FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int k = input . nextInt ( ) ; TreeSet < Integer > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < m ; i ++ ) { set . add ( input . nextInt ( ) ) ; } int start = 1 ; for ( int i = 0 ; i < k ; i ++ ) { int u = input . nextInt ( ) ; int v = input . nextInt ( ) ; if ( set . contains ( start ) ) { System . out . println ( start ) ; return ; } if ( start == u ) { start = v ; } else if ( start == v ) { start = u ; } } System . out . println ( start ) ; }   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 . * ; import java . io . * ; import java . lang . * ;    public class Forces {   public static PrintWriter cout ; public static void main ( String ... arg ) throws IOException {

import java . io . * ; import java . util . * ; public class Asd { static PrintWriter w = new PrintWriter ( System . out ) ; static FastScanner s = new FastScanner ( ) ; static HashSet < Long > list = new HashSet < > ( ) ; public static void main ( String [ ] args ) {

n , m , k = map ( int , input ( ) . split ( ) ) holes = set ( map ( int , input ( ) . split ( ) ) ) p = 1 f = Truefor _ in range ( k ) : u , v = map ( int , input ( ) . split ( ) ) if not f : continue else : if p in holes : f = False break elif u == p : p = v elif v == p : p = uprint ( p ) NEW_LINE

import sys     def read ( func = int ) : return func ( sys . stdin . readline ( ) . strip ( ) )   def readList ( func = int ) : return list ( map ( func , sys . stdin . readline ( ) . strip ( ) . split ( ) ) )     n , m , k = readList ( ) H = set ( readList ( ) ) position = 1 locked = position in Hfor _ in range ( k ) : u , v = readList ( ) if u == position : if not locked : position = v   elif v == position : if not locked : position = u   locked = position in H     print ( position )   NEW_LINE

n , m , k = map ( int , input ( ) . split ( ) ) h = { int ( x ) for x in input ( ) . split ( ) } x = 1 for _ in range ( k ) : if x in h : break u , v = map ( int , input ( ) . split ( ) ) if u == x : x = v elif v == x : x = uprint ( x ) NEW_LINE

nmk = input ( ) . split ( )   n = int ( nmk [ 0 ] ) NEW_LINE


import javax . print . DocFlavor ; import javax . swing . * ; import java . awt . image . BandedSampleModel ; import java . util . * ;   public class Example { static long [ ] [ ] dp ;

import java . util . * ;   public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long [ ] ar = new long [ ( int ) ( n + 1 ) ] ; for ( int i = 1 ; i <= n ; i ++ ) { ar [ i ] = sc . nextLong ( ) ; } long y = 0 ; for ( long j = k ; j >= 0 ; j -- ) { long g = ( 1 + 8 * j ) ;

import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ;   public class Letter {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int count = 0 , ans = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { count += ( i + 1 ) ; if ( count >= k ) { ans = a [ i - ( count - k ) ] ; break ; } } System . out . println ( ans ) ; sc . close ( ) ; } }

n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 1 , n + 1 ) : if k > i : k -= i else : breakprint ( a [ k - 1 ] ) NEW_LINE

n , k = map ( int , input ( ) . split ( ' ▁ ' ) ) arr = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) )   l = len ( arr )   def ans ( ) : greater = 0 prev = 0 for i in range ( l ) : greater = ( .5 * ( ( i + 1 ) ** 2 ) ) + ( .5 * ( i + 1 ) ) if greater >= k : dif = int ( k - prev ) return arr [ dif - 1 ] prev = greaterprint ( ans ( ) ) NEW_LINE

import sysinput = sys . stdin . readline   n , k = [ int ( i ) for i in input ( ) . split ( ) ] a = [ int ( i ) for i in input ( ) . split ( ) ] count = 1 while k - count > 0 : k -= count count += 1 print ( a [ k - 1 ] ) NEW_LINE

import sysinput = sys . stdin . readline   n , k = [ int ( i ) for i in input ( ) . split ( ) ] a = [ int ( i ) for i in input ( ) . split ( ) ] count = 1 while k > count : k -= count count += 1 print ( a [ k - 1 ] ) NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args )

from ctypes import c_int32   def gcd ( a , b ) :   if b == 0 :   return a   return gcd ( b , a % b )             def normalize_rational ( num , den ) :   NEW_LINE

from ctypes import c_int32def gcd ( a , b ) : if b == 0 : return a return gcd ( b , a % b ) def normalize_rational ( num , den ) : NEW_LINE


import java . io . * ; import java . util . * ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static FastReader sc = new FastReader ( ) ; static long mod = ( long ) ( 1e9 + 7 ) ; static List < Integer > tre [ ] ; public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; int t = 1 ;

import java . util . * ; import java . io . * ; import java . math . * ;   public class Main {   final static int mod = 1000000007 ; static FastReader sc ; static PrintWriter out ; static boolean test_case_input = false ;   public static void solution ( ) throws IOException {

import java . io . * ; import java . util . * ;   public class KIndustrialCities { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   String [ ] nk = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( nk [ 0 ] ) ; int k = Integer . parseInt ( nk [ 1 ] ) ;   ArrayList < Integer > [ ] adj = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i < ( n + 1 ) ; i ++ ) { adj [ i ] = new ArrayList < Integer > ( ) ; } adj [ 1 ] . add ( 0 ) ; for ( int l = 0 ; l < ( n - 1 ) ; l ++ ) {

import heapqimport sys   input = sys . stdin . readline     n , k = map ( int , input ( ) . split ( ) ) adj = [ [ ] for _ in range ( n ) ] for _ in range ( n - 1 ) : u , v = map ( int , input ( ) . split ( ) ) u -= 1 v -= 1 adj [ u ] . append ( v ) adj [ v ] . append ( u ) size = [ 1 ] * n   s = [ ] s . append ( ( 0 , - 1 , True ) ) while s : u , p , open = s . pop ( ) if open : s . append ( ( u , p , False ) ) for v in adj [ u ] : if v != p : s . append ( ( v , u , True ) ) else : for v in adj [ u ] : if v != p : size [ u ] += size [ v ]   q = [ ] heapq . heappush ( q , ( - ( size [ 0 ] - 1 ) , 0 , - 1 , 0 ) ) res = 0 for _ in range ( n - k ) : if not q : break d , u , p , a = heapq . heappop ( q ) res += - d for v in adj [ u ] : if v != p : a2 = a + 1 heapq . heappush ( q , ( - ( size [ v ] - a2 - 1 ) , v , u , a2 ) ) print ( res ) NEW_LINE

from sys import stdininput = stdin . readline   def dfs ( ) : size = [ 0 ] * n parent = [ 0 ] * n depth = [ 0 ] * n marked = [ False ] * n stack = [ 0 ] while stack : node = stack [ - 1 ] if marked [ node ] : stack . pop ( ) if node != 0 : size [ parent [ node ] ] += size [ node ] + 1 continue marked [ node ] = True for neighbor in tree [ node ] : if neighbor == parent [ node ] : continue parent [ neighbor ] = node depth [ neighbor ] = depth [ node ] + 1 stack . append ( neighbor ) return ( depth , size )   n , k = [ int ( x ) for x in input ( ) . split ( ) ] tree = [ [ ] for _ in range ( n ) ] for i in range ( n - 1 ) : u , v = [ int ( x ) for x in input ( ) . split ( ) ] tree [ u - 1 ] . append ( v - 1 ) tree [ v - 1 ] . append ( u - 1 ) depth , size = dfs ( ) ans = sum ( sorted ( [ depth [ i ] - size [ i ] for i in range ( n ) ] ) [ - k : ] ) print ( ans ) NEW_LINE

''' from ▁ heapq ▁ import ▁ * t = int ( input ( ) ) for ▁ i ▁ in ▁ range ( t ) : ▁ ▁ ▁ ▁ n = int ( input ( ) ) ▁ ▁ ▁ ▁ arr = [ 0 ▁ for ▁ i ▁ in ▁ range ( n ) ] ▁ ▁ ▁ ▁ heap = [ ] ▁ ▁ ▁ ▁ heappush ( heap , [ n , 1 ] ) ▁ ▁ ▁ ▁ while ▁ heap : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ pop = heappop ( heap ) ''' import sys , threadingsys . setrecursionlimit ( 300000 ) threading . stack_size ( 10 ** 8 ) def solve ( ) : n , k = map ( int , input ( ) . split ( ) ) n1 = [ n , k ] adj = { } depths = { } cities = [ ] subtrees = { } nums = { } for i in range ( n - 1 ) : a , b = map ( int , input ( ) . split ( ) ) if a not in adj : adj [ a ] = [ ] if b not in adj : adj [ b ] = [ ] adj [ a ] . append ( b ) adj [ b ] . append ( a ) v = set ( ) def dfs ( node , depth ) : v . add ( node ) depths [ node ] = depth subtrees [ node ] = 0 for child in adj . get ( node , [ ] ) : if child not in v : NEW_LINE

import sysimport threadingfrom collections import defaultdict   n , k = list ( map ( int , input ( ) . split ( ) ) ) adj = defaultdict ( list ) for _ in range ( n - 1 ) : a , b = list ( map ( int , input ( ) . split ( ) ) ) adj [ a ] . append ( b ) adj [ b ] . append ( a ) li = [ ]     def fun ( node , par , ht ) : size = 1 for ch in adj [ node ] : if ch != par : size += fun ( ch , node , ht + 1 ) li . append ( ht - size ) return size   def main ( ) : fun ( 1 , - 1 , 1 ) li . sort ( reverse = True ) print ( sum ( li [ : k ] ) ) if __name__ == " _ _ main _ _ " : sys . setrecursionlimit ( 10 ** 6 ) threading . stack_size ( 10 ** 8 ) t = threading . Thread ( target = main ) t . start ( ) t . join ( ) NEW_LINE


import java . util . Scanner ; public class Main { static Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n , d , e ; int ans = Integer . MAX_VALUE ; n = in . nextInt ( ) ; d = in . nextInt ( ) ; e = in . nextInt ( ) ; int num ; for ( int i = 0 ; i <= ( n / ( e * 5 ) ) ; i ++ ) { num = ( n - e * 5 * i ) % d ; ans = Math . min ( ans , num ) ; } System . out . println ( ans ) ; } }

import java . io . * ; import java . util . Scanner ; public class Main {

import java . util . Scanner ;   public class A1214 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int D = in . nextInt ( ) ; int E = 5 * in . nextInt ( ) ; int min = N ; for ( int e = 0 ; e <= N ; e += E ) { min = Math . min ( min , ( N - e ) % D ) ; } System . out . println ( min ) ; }   }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int eumin = 5 * e , rel = n ; for ( int i = 0 ; i * d <= n ; i ++ ) {

n , d , e = int ( input ( ) ) , int ( input ( ) ) , int ( input ( ) ) * 5   minn = nfor i in range ( d ) : for j in range ( e ) : if i + j != 0 : k = n % ( d * i + e * j ) % d % e if minn > k : minn = kprint ( minn ) NEW_LINE

n = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) ans = n % dwhile n >= 5 * e : n -= ( 5 * e ) ans = min ( ans , n % d ) print ( ans )   NEW_LINE

rub = int ( input ( ) ) dolls = int ( input ( ) ) eur = int ( input ( ) )   dollars = [ ] euros = [ ] for i in [ 1 , 2 , 5 , 10 , 20 , 50 , 100 ] : dollars . append ( dolls * i ) for j in [ 5 , 10 , 20 , 50 , 100 , 200 ] : euros . append ( eur * j )   res = float ( ' inf ' )   for i in range ( 0 , rub + 1 , euros [ 0 ] ) : res = min ( res , ( rub - i ) % dollars [ 0 ] )   print ( rub if res == float ( ' inf ' ) else res ) NEW_LINE

n = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) i = 0 ans = nwhile ( i * e * 5 <= n ) : ans = min ( ans , ( n - i * e * 5 ) % d ) i += 1 print ( ans ) NEW_LINE


import java . io . * ; import java . util . * ; import java . util . ArrayList ; public class CodeForce { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringBuilder sb = new StringBuilder ( ) ; static int next ( String [ ] sr , int ind ) { if ( sr [ ind ] . equals ( " S " ) || sr [ ind ] . equals ( " F " ) ) return 1000 ; return Integer . parseInt ( sr [ ind ] ) ; } public static void main ( String [ ] args ) throws IOException { int m = Integer . parseInt ( br . readLine ( ) ) ; int [ ] [ ] gf = new int [ 5 ] [ 5 ] ; for ( int i = 0 ; i < m ; i ++ ) { String [ ] sr = br . readLine ( ) . split ( " ▁ " ) ; int a = next ( sr , 0 ) ; int b = next ( sr , 1 ) ; gf [ a - 1 ] [ b - 1 ] = 1 ; gf [ b - 1 ] [ a - 1 ] = 1 ; } for ( int i = 0 ; i < 5 ; i ++ ) for ( int j = 0 ; j != i && j < 5 ; j ++ ) for ( int k = 0 ; k != i & k != j && k < 5 ; k ++ ) { if ( gf [ i ] [ j ] == 1 && gf [ j ] [ k ] == 1 && gf [ i ] [ k ] == 1 ) { System . out . println ( " WIN " ) ; return ; } else if ( gf [ i ] [ j ] == 0 && gf [ i ] [ k ] == 0 && gf [ j ] [ k ] == 0 ) { System . out . println ( " WIN " ) ; return ; } } System . out . println ( " FAIL " ) ; } }

m = int ( input ( ) ) NEW_LINE n = { } NEW_LINE n [ 1 ] = 0 NEW_LINE n [ 2 ] = 0 NEW_LINE n [ 3 ] = 0 NEW_LINE n [ 4 ] = 0 NEW_LINE n [ 5 ] = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE n [ a ] += 1 NEW_LINE n [ b ] += 1 NEW_LINE DEDENT if ( n [ 1 ] == n [ 2 ] == n [ 3 ] == n [ 4 ] == n [ 5 ] and n [ 1 ] == 2 ) : NEW_LINE INDENT print ( " FAIL " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " WIN " ) NEW_LINE DEDENT

import sys NEW_LINE from array import array NEW_LINE def input ( ) : NEW_LINE INDENT return sys . stdin . buffer . readline ( ) . decode ( ' utf - 8' ) NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE matrix = [ [ 0 ] * 5 for _ in range ( 5 ) ] NEW_LINE for u , v in ( map ( int , input ( ) . split ( ) ) for _ in range ( n ) ) : NEW_LINE INDENT matrix [ u - 1 ] [ v - 1 ] = matrix [ v - 1 ] [ u - 1 ] = 1 NEW_LINE DEDENT for i in range ( 5 ) : NEW_LINE INDENT if sum ( matrix [ i ] [ j ] for j in range ( 5 ) if i != j ) != 2 : NEW_LINE INDENT print ( ' WIN ' ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( ' FAIL ' ) NEW_LINE

from collections import Counter NEW_LINE n = int ( input ( ) ) NEW_LINE l = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE l . append ( x ) NEW_LINE l . append ( y ) NEW_LINE DEDENT d = Counter ( l ) NEW_LINE s1 = list ( d . values ( ) ) NEW_LINE f = True NEW_LINE if ( len ( list ( d . keys ( ) ) ) <= 4 ) : NEW_LINE INDENT print ( ' WIN ' ) NEW_LINE exit ( ) NEW_LINE DEDENT for p in s1 : NEW_LINE INDENT if ( p == 1 ) : NEW_LINE INDENT print ( ' WIN ' ) NEW_LINE f = False NEW_LINE break NEW_LINE DEDENT elif ( p >= 3 ) : NEW_LINE INDENT print ( ' WIN ' ) NEW_LINE f = False NEW_LINE break NEW_LINE DEDENT DEDENT if ( f ) : NEW_LINE INDENT print ( ' FAIL ' ) NEW_LINE DEDENT

def createMatrix ( rowCount , colCount , dataList ) : NEW_LINE INDENT mat = [ ] NEW_LINE for i in range ( rowCount ) : NEW_LINE INDENT rowList = [ ] NEW_LINE for j in range ( colCount ) : NEW_LINE INDENT rowList . append ( dataList [ rowCount * i + j ] ) NEW_LINE DEDENT mat . append ( rowList ) NEW_LINE DEDENT return mat NEW_LINE DEDENT def check_range ( friends_mat ) : NEW_LINE INDENT for i in range ( 2 , 5 ) : NEW_LINE INDENT for j in range ( 0 , i ) : NEW_LINE INDENT for k in range ( 0 , j ) : NEW_LINE INDENT if ( friends_mat [ i ] [ j ] == 1 and friends_mat [ i ] [ k ] == 1 and friends_mat [ k ] [ j ] == 1 ) or ( friends_mat [ i ] [ j ] == 0 and friends_mat [ i ] [ k ] == 0 and friends_mat [ k ] [ j ] == 0 ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT DEDENT return False NEW_LINE DEDENT alpha = [ 0 ] * 25 NEW_LINE friends_relations = createMatrix ( 5 , 5 , alpha ) NEW_LINE n = int ( input ( ) ) NEW_LINE while n : NEW_LINE INDENT A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE row = A [ 0 ] NEW_LINE col = A [ 1 ] NEW_LINE friends_relations [ row - 1 ] [ col - 1 ] = 1 NEW_LINE friends_relations [ col - 1 ] [ row - 1 ] = 1 NEW_LINE n -= 1 NEW_LINE DEDENT if check_range ( friends_relations ) : NEW_LINE INDENT print ( " WIN " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " FAIL " ) NEW_LINE DEDENT

m = int ( input ( ) ) NEW_LINE n = { } NEW_LINE n [ 5 ] = 0 NEW_LINE n [ 4 ] = 0 NEW_LINE n [ 3 ] = 0 NEW_LINE n [ 2 ] = 0 NEW_LINE n [ 1 ] = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT g = input ( ) . split ( ) NEW_LINE n [ int ( g [ 0 ] ) ] += 1 NEW_LINE n [ int ( g [ 1 ] ) ] += 1 NEW_LINE DEDENT if n [ 1 ] == n [ 2 ] == n [ 3 ] == n [ 4 ] == n [ 5 ] == 2 : NEW_LINE INDENT print ( ' FAIL ' ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( ' WIN ' ) NEW_LINE


import java . util . * ; public class saitama_hotel {   public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int s = in . nextInt ( ) ; int a [ ] = new int [ s + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; a [ x ] = Math . max ( a [ x ] , y ) ; } int ans = 0 ; while ( s > 0 ) { if ( a [ s ] - ans >= 0 ) ans = ans + a [ s ] - ans ; s -- ;   ans ++ ; } System . out . println ( ans ) ; } }

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 ( double a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; double temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int s = input . nextInt ( ) ; long total = s ; for ( int i = 1 ; i <= n ; i ++ ) { total = Math . max ( total , input . nextInt ( ) + input . nextInt ( ) ) ; } System . out . println ( total ) ; }   }

import java . util . Scanner ;   public class SaitamaFuckedUp { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   int n = scan . nextInt ( ) ; int s = scan . nextInt ( ) ; int [ ] [ ] floor = new int [ n ] [ 2 ] ; int t = 0 ;   for ( int i = 0 ; i < n ; i ++ ) { floor [ i ] [ 0 ] = scan . nextInt ( ) ; floor [ i ] [ 1 ] = scan . nextInt ( ) ; }   for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { if ( floor [ i ] [ 0 ] < floor [ j ] [ 0 ] ) { int x = floor [ i ] [ 0 ] ; floor [ i ] [ 0 ] = floor [ j ] [ 0 ] ; floor [ j ] [ 0 ] = x ;   x = floor [ i ] [ 1 ] ; floor [ i ] [ 1 ] = floor [ j ] [ 1 ] ; floor [ j ] [ 1 ] = x ; } } t += s - floor [ i ] [ 0 ] ; s = floor [ i ] [ 0 ] ; if ( floor [ i ] [ 1 ] > t ) { t = floor [ i ] [ 1 ] ; } } System . out . println ( t + s ) ; } }

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

n , s = map ( int , input ( ) . split ( ) ) ans = sfor _ in range ( n ) : f , t = map ( int , input ( ) . split ( ) ) ans = max ( ans , f + t ) print ( ans ) NEW_LINE

n , s = map ( int , input ( ) . split ( ) ) for i in range ( n ) : t , f = map ( int , input ( ) . split ( ) ) s = max ( s , t + f ) print ( s )       NEW_LINE

n , top = map ( int , input ( ) . split ( ) )   r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = [ r ( ) for _ in range ( n ) ]   arr . sort ( reverse = True , key = lambda x : x [ 0 ] ) arr . append ( [ 0 , 0 ] ) c = 0   NEW_LINE

n , s = map ( int , input ( ) . split ( ) )   ft = [ ] for _ in range ( n ) : f , t = map ( int , input ( ) . split ( ) ) ft . append ( [ f , t ] ) ft . sort ( reverse = True ) prevf , ans = s , 0 for f , t in ft : ans += prevf - f if ans < t : ans = t prevf = fans += ft [ - 1 ] [ 0 ] print ( ans ) NEW_LINE


import java . io . * ; import java . util . * ; public class Asd { static PrintWriter w = new PrintWriter ( System . out ) ; static FastScanner s = new FastScanner ( ) ;   public static void main ( String [ ] args ) {

n , f = map ( int , input ( ) . split ( ) ) gain = [ ] sold = 0 for i in range ( n ) : k , l = map ( int , input ( ) . split ( ) ) sold += min ( l , k ) if l == 0 or k == 0 or l < k : gain . append ( 0 ) else : if 2 * k > l : gain . append ( l - k ) else : gain . append ( k )   gain = sorted ( gain , reverse = True ) for i in range ( f ) : sold += gain [ i ] print ( sold ) NEW_LINE

planDays , chosenDays = map ( int , input ( ) . split ( ) ) total = [ ] t = 0 for i in range ( planDays ) : products , clients = map ( int , input ( ) . split ( ) )   NEW_LINE

numOfDays , sellOffDays = map ( int , input ( ) . split ( ) ) totalProductsSold = 0 l = [ ] for i in range ( numOfDays ) : numOfProduct , numOfClients = map ( int , input ( ) . split ( ) ) totalProductsSold += min ( numOfProduct , numOfClients ) l . append ( min ( 2 * numOfProduct , numOfClients ) - min ( numOfProduct , numOfClients ) ) l . sort ( ) print ( totalProductsSold + sum ( l [ numOfDays - sellOffDays : ] ) ) NEW_LINE

def solve ( n , f , kls ) : base = sum ( min ( k , l ) for k , l in kls ) plus = sorted ( [ min ( 2 * k , l ) - min ( k , l ) for k , l in kls ] ) [ : : - 1 ] res = base + sum ( plus [ : f ] ) print ( res )   def main ( ) : n , f = map ( int , input ( ) . split ( ) ) kls = [ ] for _ in range ( n ) : k , l = map ( int , input ( ) . split ( ) ) kls . append ( ( k , l ) ) solve ( n , f , kls )   if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE


import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . math . RoundingMode ; import java . util . * ; import java . util . concurrent . LinkedBlockingDeque ;    public class scratch_25 {

from sys import stdin , stdoutfor _ in range ( int ( stdin . readline ( ) ) ) : NEW_LINE

import sysinput = lambda : sys . stdin . readline ( ) . rstrip ( ) t = int ( input ( ) ) for _ in range ( t ) : s , t = input ( ) . split ( ) s = list ( s ) ss = sorted ( s ) t = list ( t ) for i in range ( len ( s ) ) : if s [ i ] == ss [ i ] : continue for j in range ( len ( s ) - 1 , - 1 , - 1 ) : if s [ j ] == ss [ i ] : s [ i ] , s [ j ] = s [ j ] , s [ i ] break break for i , j in zip ( s , t ) : if i < j : print ( ' ' . join ( s ) ) break elif i > j : print ( ' - - - ' ) break else : if len ( s ) < len ( t ) : print ( ' ' . join ( s ) ) else : print ( ' - - - ' ) NEW_LINE

for i in range ( int ( input ( ) ) ) : a , b = map ( list , input ( ) . split ( ) ) ind = - 1 for i in range ( len ( a ) ) : if a [ i ] != ' A ' : m = a [ i ] flag = False ind = i for g in range ( i + 1 , len ( a ) ) : if flag : if a [ g ] <= m : m = a [ g ] ind = g else : if a [ g ] < m : flag = True m = a [ g ] ind = g if flag : a [ i ] , a [ ind ] = a [ ind ] , a [ i ] break a = " " . join ( a ) b = " " . join ( b ) if a < b : print ( a ) else :     print ( ' - - - ' ) NEW_LINE

for i in range ( int ( input ( ) ) ) : a , b = map ( list , input ( ) . split ( ) ) minAtSuffix = [ 0 ] * ( len ( a ) - 1 ) minAtSuffixPos = [ 0 ] * ( len ( a ) - 1 ) minAtSuffix [ - 1 ] = a [ - 1 ] minAtSuffixPos [ - 1 ] = len ( a ) - 1   for i in range ( len ( a ) - 3 , - 1 , - 1 ) :   if a [ i + 1 ] < minAtSuffix [ i + 1 ] :   minAtSuffix [ i ] = a [ i + 1 ] minAtSuffixPos [ i ] = i + 1 else :   minAtSuffix [ i ] = minAtSuffix [ i + 1 ] minAtSuffixPos [ i ] = minAtSuffixPos [ i + 1 ]   for i in range ( len ( a ) - 1 ) : if minAtSuffix [ i ] < a [ i ] : a [ i ] , a [ minAtSuffixPos [ i ] ] = a [ minAtSuffixPos [ i ] ] , a [ i ] break a = " " . join ( a ) b = " " . join ( b ) if a >= b : print ( ' - - - ' ) else : print ( a ) NEW_LINE


n = int ( input ( ) ) k = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) )    def t_s ( j , u ) : while ( u - j ) > 1e-6 : f = ( u - j ) / 3 x2 = t_p ( j + f ) x3 = t_p ( u - f ) if x2 < x3 : u = j + 2 * f else : j = j + f return t_p ( ( j + u ) / 2 )    def t_p ( p ) : return max ( abs ( p - k [ i ] ) / s [ i ] for i in range ( n ) )    r = 0 t = 1e10f or p in k : r = max ( p , r ) t = min ( p , t ) print ( t_s ( t , r ) )

import java . util . * ; import java . io . * ;   public class CF780B2 { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; static int [ ] [ ] arr ; static int n ; static final double PRECISION = 1e-8 ;   public static void main ( String [ ] args ) throws IOException { n = Integer . parseInt ( br . readLine ( ) ) ; arr = new int [ n ] [ 2 ] ; String [ ] stringArr = br . readLine ( ) . split ( " ▁ " ) ; int largest = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int curr = Integer . parseInt ( stringArr [ i ] ) ; arr [ i ] [ 0 ] = curr ; largest = Math . max ( largest , curr ) ; }   stringArr = br . readLine ( ) . split ( " ▁ " ) ; for ( int i = 0 ; i < n ; i ++ ) { int curr = Integer . parseInt ( stringArr [ i ] ) ; arr [ i ] [ 1 ] = curr ; }

import java . io . * ; import java . util . * ; import java . lang . * ; import java . math . * ; import java . text . DecimalFormat ; import java . lang . reflect . Array ; import java . io . BufferedOutputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigDecimal ; public class Codeforces { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ;

from math import isclosen = int ( input ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) v = list ( map ( int , input ( ) . split ( ) ) ) xx = list ( ( x [ i ] , v [ i ] ) for i in range ( n ) ) xx . sort ( ) l , h = xx [ 0 ] [ 0 ] , xx [ - 1 ] [ 0 ] m = ( h + l ) / 2 while not isclose ( l , h ) : m = ( h + l ) / 2 t = abs ( m - xx [ 0 ] [ 0 ] ) / xx [ 0 ] [ 1 ] a , b = True , t for i in range ( 1 , n ) : t2 = abs ( m - xx [ i ] [ 0 ] ) / xx [ i ] [ 1 ] if not isclose ( t , t2 ) : s = False if t2 > b : b = t2 a = bool ( xx [ i ] [ 0 ] < m ) if a : h = m else : l = mprint ( max ( abs ( m - xx [ i ] [ 0 ] ) / xx [ i ] [ 1 ] for i in range ( n ) ) ) NEW_LINE

n = int ( input ( ) ) k = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) )     def t_s ( j , u ) : while ( u - j ) > 1e-6 : f = ( u - j ) / 3 x2 = t_p ( j + f ) x3 = t_p ( u - f ) if x2 < x3 : u = j + 2 * f else : j = j + f return t_p ( ( j + u ) / 2 )     def t_p ( p ) : return max ( abs ( p - k [ i ] ) / s [ i ] for i in range ( n ) )     r = 0 t = 1e10 for p in k : r = max ( p , r ) t = min ( p , t ) print ( t_s ( t , r ) ) NEW_LINE


import java . util . Scanner ;   public class OstapGrasshopper {   public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; final int N = s . nextInt ( ) ; final int K = s . nextInt ( ) ; s . nextLine ( ) ; char [ ] box = s . nextLine ( ) . toCharArray ( ) ;   int G = 0 ; for ( int i = 0 ; i < box . length ; i ++ ) { if ( box [ i ] == ' G ' ) { G = i ; break ; } }   boolean found = false ; int g = G ; while ( g >= 0 ) { if ( box [ g ] == ' T ' ) { found = true ; break ; } if ( box [ g ] == ' # ' ) { break ; } g -= K ; } g = G ; while ( g < N && ! found ) { if ( box [ g ] == ' T ' ) { found = true ; break ; } if ( box [ g ] == ' # ' ) { break ; } g += K ; }   if ( found ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } }   }

import java . util . Scanner ; import java . lang . StringBuilder ; public class OstapGrasshopper { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cells = sc . nextInt ( ) ; int jumps = sc . nextInt ( ) ; sc . nextLine ( ) ; String path = sc . nextLine ( ) ;   int g = path . indexOf ( " G " ) ; int t = path . indexOf ( " T " ) ; if ( t < g ) { StringBuilder sb = new StringBuilder ( path ) ; sb . reverse ( ) ; path = sb . toString ( ) ; g = path . indexOf ( " G " ) ; t = path . indexOf ( " T " ) ; }   int pos = g + jumps ; boolean found = false ; while ( pos < cells && ! found && pos <= t ) { if ( path . charAt ( pos ) == ' # ' ) { System . out . println ( " NO " ) ; found = true ; } else if ( path . charAt ( pos ) == ' T ' ) { System . out . println ( " YES " ) ; found = true ; } pos += jumps ; } if ( ! found ) { System . out . println ( " NO " ) ; } } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; sc . nextLine ( ) ; String str = sc . nextLine ( ) ; int a = str . indexOf ( ' G ' ) ; int b = str . indexOf ( ' T ' ) ; if ( a < b ) { for ( int i = a ; i <= b ; i = i + k ) { if ( str . charAt ( i ) == ' # ' ) { System . out . println ( " NO " ) ; System . exit ( 0 ) ; } else if ( str . charAt ( i ) == ' T ' ) { System . out . println ( " YES " ) ; System . exit ( 0 ) ; } } System . out . println ( " NO " ) ; } else { for ( int i = a ; i >= b ; i = i - k ) { if ( str . charAt ( i ) == ' # ' ) { System . out . println ( " NO " ) ; System . exit ( 0 ) ; } else if ( str . charAt ( i ) == ' T ' ) { System . out . println ( " YES " ) ; System . exit ( 0 ) ; } } System . out . println ( " NO " ) ; } } }

import java . util . Scanner ; import java . util . StringTokenizer ;   public class Ostap {    public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ;   StringTokenizer stringTokenizer = new StringTokenizer ( line ) ; int n = Integer . parseInt ( stringTokenizer . nextToken ( ) ) ; int k = Integer . parseInt ( stringTokenizer . nextToken ( ) ) ;   String route = scanner . nextLine ( ) . trim ( ) ;   int gPos = - 1 , iPos = - 1 ; for ( int i = 0 ; i < route . length ( ) ; i ++ ) { if ( route . charAt ( i ) == ' G ' ) { gPos = i ; } else if ( route . charAt ( i ) == ' T ' ) { iPos = i ; } }   if ( gPos > iPos ) { for ( int i = gPos - k ; i >= 0 ; i = i - k ) { if ( route . charAt ( i ) == ' T ' ) { System . out . println ( " YES " ) ; return ; } else if ( route . charAt ( i ) == ' # ' ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " NO " ) ; } else { for ( int i = gPos + k ; i < n ; i = i + k ) { if ( route . charAt ( i ) == ' T ' ) { System . out . println ( " YES " ) ; return ; } else if ( route . charAt ( i ) == ' # ' ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " NO " ) ; } }    }

n , k = map ( int , input ( ) . split ( ) ) s = input ( ) g , t , l = s . index ( ' G ' ) , s . index ( ' T ' ) , len ( s ) if t >= g : while g < l : g += k if g >= l : print ( ' NO ' ) break if s [ g ] == ' # ' : print ( ' NO ' ) break if s [ g ] == ' T ' : print ( ' YES ' ) breakelse : while g >= 0 : g -= k if g < 0 : print ( ' NO ' ) break if s [ g ] == ' # ' : print ( ' NO ' ) break if s [ g ] == ' T ' : print ( ' YES ' ) break NEW_LINE

k = int ( input ( ) . split ( ) [ 1 ] ) s = input ( ) . strip ( " . # " ) print ( " NO " if ( len ( s ) - 1 ) % k or " # " in s [ 0 : len ( s ) : k ] else " YES " ) NEW_LINE

import math   n , k = map ( int , input ( ) . split ( ) ) cells = input ( )   def findPath ( n , k , cells ) : line = [ ] grasshoper_pos = None target_pos = None counter = 0 for char in cells : line . append ( char ) if char == " G " : grasshoper_pos = counter elif char == " T " : target_pos = counter counter += 1   if abs ( target_pos - grasshoper_pos ) % k == 0 : if target_pos > grasshoper_pos : for x in range ( grasshoper_pos , target_pos , k ) : if line [ x ] == " # " : return " NO " else : for x in reversed ( range ( grasshoper_pos , target_pos , - k ) ) : if line [ x ] == " # " : return " NO " return " YES " else : return " NO "   print ( findPath ( n , k , cells ) ) NEW_LINE


import java . util . Scanner ;   public class FancyFence { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int t = scan . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { int n = scan . nextInt ( ) ; if ( 360 % ( 180 - n ) == 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } scan . close ( ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class CF270A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { double n = 360.0 / ( 180 - Integer . parseInt ( br . readLine ( ) ) ) ; System . out . println ( ( ( n == Math . floor ( n ) ) && ! Double . isInfinite ( n ) ) ? " YES " : " NO " ) ; }   } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class CF270A { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { int a = Integer . parseInt ( br . readLine ( ) ) ; double n = 360.0 / ( 180 - a ) ; System . out . println ( ( ( n == Math . floor ( n ) ) && ! Double . isInfinite ( n ) ) ? " YES " : " NO " ) ; }   } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ;   double x = in . nextDouble ( ) ; double m , conter = 0 ; for ( int i = 0 ; i < x ; i ++ ) { m = in . nextDouble ( ) ;   if ( 360 % ( 180 - m ) == 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } }

import java . util . Scanner ;   public class n270A { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int a ; for ( int i = 0 ; i < n ; i ++ ) { a = scanner . nextInt ( ) ; if ( 360 % ( 180 - a ) == 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } }

n = int ( input ( ) ) for i in range ( n ) : a = int ( input ( ) ) x = 360 / ( 180 - a ) if x == int ( x ) : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

for i in range ( int ( input ( ) ) ) : n = 360 / ( 180 - int ( input ( ) ) ) print ( " YES " if int ( n ) == n else " NO " ) NEW_LINE

for i in range ( int ( input ( ) ) ) : y = int ( input ( ) ) if 360 % ( 180 - y ) == 0 : print ( " YES " ) else : print ( " NO " ) NEW_LINE

t = int ( input ( ) ) for j in range ( t ) : flag = 0 a = int ( input ( ) ) if 360 % ( 180 - a ) == 0 : print ( ' YES ' ) else : print ( ' NO ' )                       NEW_LINE

import mathvalidangles = set ( ) i = 3 while ( angle : = ( 180 * ( i - 2 ) ) / i ) <= 179 : if math . floor ( angle ) == angle : validangles . add ( angle ) i += 1     n = int ( input ( ) ) for i in range ( n ) : a = int ( input ( ) ) if a in validangles : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


import java . util . * ; public class Practice { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int s = in . nextInt ( ) - 1 ; int f = in . nextInt ( ) - 1 ; int at = s ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) p [ i ] = in . nextInt ( ) - 1 ; int ans = 0 ; while ( at != f && ans <= n + 1 ) { at = p [ at ] ; ans ++ ; } System . out . println ( ans > n ? - 1 : ans ) ; } }

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

import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int [ ] p = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } if ( s == t ) { System . out . println ( "0" ) ; return ; } int count = 0 , strt = s ; while ( s != t ) { s = p [ s ] ; count ++ ; if ( s == strt ) { System . out . println ( " - 1" ) ; return ; } else if ( s == t ) { System . out . println ( count ) ; } } } }

import java . util . * ; public class FindMarble { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ;   int [ ] arr2 = new int [ n ] ; s = s - 1 ; t = t - 1 ; for ( int i = 0 ; i < n ; i ++ ) { arr2 [ i ] = arr [ i ] - 1 ; }   if ( s == t ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; }   int temp = s ; int i = 0 ; while ( i < n ) { temp = arr2 [ temp ] ;   if ( temp == s ) { System . out . println ( - 1 ) ; System . exit ( 0 ) ; } i ++ ; if ( temp == t ) { System . out . println ( i ) ; break ; } } if ( temp != t ) System . out . println ( - 1 ) ;     } }

n , m , t = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) brr = [ 0 ] * nf = mcount = 1 if ( m == t ) : print ( 0 ) else : while ( brr [ f - 1 ] != 1 and arr [ f - 1 ] != t ) : brr [ f - 1 ] = 1 f = arr [ f - 1 ] count += 1 if ( arr [ f - 1 ] == t ) : print ( count ) else : print ( - 1 ) NEW_LINE

n , i , f = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) if i == f : print ( 0 ) else : if l [ i - 1 ] == i or l [ f - 1 ] == f : print ( - 1 ) else : x = i flag = 0 flag2 = 0 c = 1 while True : if l [ x - 1 ] == f : flag = 1 break elif l [ x - 1 ] == i : flag2 = 1 break NEW_LINE

n , s , t = map ( int , input ( ) . split ( ) ) P = list ( map ( int , input ( ) . split ( ) ) ) operations = 0 L = list ( range ( 1 , n + 1 ) ) for i in range ( n ) : if s == t : print ( i ) exit ( ) s = P [ s - 1 ] print ( - 1 )         NEW_LINE

n , s , t = map ( int , input ( ) . split ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) if ( s == t ) : print ( '0' ) else : pos = s k = 0 f = 0 for i in range ( 0 , n ) : if ( pos == t ) : f = 1 break pos = x [ pos - 1 ] k = k + 1 if ( pos > n ) : pos = pos % n if ( f == 1 ) : print ( k ) else : print ( ' - 1' ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) { int N = in . nextInt ( ) ; int [ ] a = new int [ 2 * N ] ; for ( int i = 0 ; i < 2 * N ; i ++ ) { a [ i ] = in . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ N ] > a [ N - 1 ] ) { out . println ( " YES " ) ; } else { out . println ( " NO " ) ; }   }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; st = null ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . util . Arrays ; import java . util . Scanner ;    public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ 2 * n ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } Arrays . sort ( a ) ; if ( a [ n - 1 ] < a [ n ] ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

def solve ( ) : n = int ( input ( ) ) a = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] a . sort ( ) if a [ n - 1 ] == a [ n ] : return " NO " else : return " YES "   print ( solve ( ) ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a = sorted ( a ) if a [ n - 1 ] == a [ n ] : print ( ' NO ' ) else : print ( ' YES ' ) NEW_LINE

n = int ( input ( ) ) players = list ( map ( int , input ( ) . split ( ) ) ) players . sort ( ) if players [ n ] > players [ n - 1 ] : print ( " YES " ) else : print ( " NO " ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) wins = 1 j = ( 2 * n ) - 1 if l [ n - 1 ] != l [ n ] : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


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

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 _p000854A { static public void main ( final String [ ] args ) throws IOException { p000854A . _main ( args ) ; }

import java . util . Scanner ; public class giuhiuhi { public static boolean mn ( int a , int b ) { while ( a != b ) { if ( a > b ) { a = a - b ; } else { b = b - a ; } } return a == 1 ; }   public static void main ( String [ ] args ) {

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int num = 0 ; int deno = 0 ; int n = input . nextInt ( ) ; for ( int i = 1 ; i < 1000 ; i ++ ) { for ( int j = 2 ; j < 1000 ; j ++ ) { if ( i < j && checkCoPrime ( i , j ) == 1 && i + j == n ) { int newNum = i ; int newDeno = j ; if ( newNum > num || newDeno > deno ) { num = newNum ; deno = newDeno ; } } } } System . out . println ( num + " ▁ " + deno ) ; } public static int checkCoPrime ( int a , int b ) {   if ( a == 0 || b == 0 ) return 0 ; if ( a == b ) return a ; if ( a > b ) return checkCoPrime ( a - b , b ) ; return checkCoPrime ( a , b - a ) ; }   }

import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean flag = false ; int res1 = 0 ; int res2 = 0 ; for ( int i = 2 ; i <= n / 2 ; i ++ ) { if ( factors ( i , n - i ) ) { flag = true ; res1 = i ; res2 = n - i ; } } if ( ! flag ) pw . println ( 1 + " ▁ " + ( n - 1 ) ) ; else pw . println ( res1 + " ▁ " + res2 ) ;

import sys   def main ( ) : n = int ( sys . stdin . read ( ) . strip ( ) ) t = n // 2 if n % 2 : return t , t + 1 return t - 1 - t % 2 , t + 1 + t % 2 print ( * main ( ) ) NEW_LINE

import sysimport mathinput = sys . stdin . readline   n = int ( input ( ) ) a = n // 2 b = n - awhile math . gcd ( a , b ) > 1 : a -= 1 b += 1 print ( a , b ) NEW_LINE

""" s ▁ = ▁ input ( ) i ▁ = ▁ 0c ▁ = ▁ 0while ▁ True : ▁ ▁ ▁ ▁ if ▁ i ▁ = = ▁ len ( s ) -1 ▁ or ▁ len ( s ) ▁ = = ▁ 0 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ break ▁ ▁ ▁ ▁ if ▁ i ▁ < ▁ len ( s ) -1 ▁ and ▁ s [ i ] ▁ = = ▁ s [ i + 1 ] : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ c ▁ = ▁ c + 1 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ▁ = ▁ s [ : i ] + s [ i + 2 : ] ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ i ▁ = ▁ 0 ▁ ▁ ▁ ▁ else : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ i ▁ = ▁ i + 1print ( " Yes " ▁ if ▁ c % 2 ! = 0 ▁ else ▁ " No " ) """ from math import gcdn = int ( input ( ) ) m = 1 / ( n - 1 ) a = 1 b = n - 1 for i in range ( 1 , n ) : if gcd ( i , n - i ) == 1 and i < n - i and i / ( n - i ) > m : m = i / ( n - i ) a = i b = n - iprint ( a , b ) NEW_LINE

import mathn = int ( input ( ) ) a , b = 1 , n - 1 for i in range ( 1 , n ) : for j in range ( i + 1 , n ) : if i + j == n and math . gcd ( i , j ) == 1 : if i * b > j * a : a , b = i , jprint ( a , b ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Main {   public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter so = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int t = 1 ; while ( t -- > 0 ) { int k = in . nextInt ( ) ; int d = in . nextInt ( ) ; if ( k > 1 && d == 0 ) so . println ( " No ▁ solution " ) ; else { so . print ( d ) ; for ( int i = 0 ; i < k - 1 ; i ++ ) so . print ( "0" ) ; } } so . flush ( ) ; }   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   int [ ] readIntArray ( int n ) { int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; }   long [ ] readLongArray ( int n ) { long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextLong ( ) ; return a ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . util . StringTokenizer ; public class Main { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( newInputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static int solve ( int n ) { int sum = 0 ; while ( n > 0 ) { sum += n % 10 ; n /= 10 ; } return sum ; }   public static void main ( String [ ] args ) { FastReader fs = new FastReader ( ) ; int n = fs . nextInt ( ) ; int k = fs . nextInt ( ) ;

import java . util . Scanner ;   public class digitalroots { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int k = sc . nextInt ( ) ; int d = sc . nextInt ( ) ;   if ( d == 0 && k == 1 ) System . out . println ( 0 ) ; else if ( d > 0 ) { System . out . print ( d ) ; for ( int i = 2 ; i <= k ; i ++ ) { System . out . print ( 0 ) ; } } else { System . out . println ( " No ▁ solution " ) ; } } }

import sysfrom functools import lru_cache , cmp_to_keyfrom heapq import merge , heapify , heappop , heappushfrom math import * from collections import defaultdict as dd , deque , Counter as Cfrom itertools import combinations as comb , permutations as permfrom bisect import bisect_left as bl , bisect_right as br , bisect , insortfrom time import perf_counterfrom fractions import Fractionimport copyfrom copy import deepcopyimport timestarttime = time . time ( ) mod = int ( pow ( 10 , 9 ) + 7 ) mod2 = 998244353   def data ( ) : return sys . stdin . readline ( ) . strip ( ) def out ( * var , end = " \n " ) : sys . stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) def L ( ) : return list ( sp ( ) ) def sl ( ) : return list ( ssp ( ) ) def sp ( ) : return map ( int , data ( ) . split ( ) ) def ssp ( ) : return map ( str , data ( ) . split ( ) ) def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] def l2d ( n , m , val = 0 ) : return [ l1d ( n , val ) for j in range ( m ) ] try : NEW_LINE

k , d = map ( int , input ( ) . split ( ) ) if k != 1 and d == 0 : print ( " No ▁ solution " ) else : number = "0" * ( k ) number = number . replace ( '0' , str ( d ) , 1 ) print ( ( number ) ) NEW_LINE

k , d = map ( int , input ( ) . split ( ) ) if d == 0 and k > 1 : print ( " No ▁ solution " ) else : x = str ( d ) + "0" * ( k - 1 ) print ( x ) NEW_LINE

A = input ( ) . split ( ) d = int ( A [ 1 ] ) k = int ( A [ 0 ] )   if d == 0 : if k == 1 : print ( 0 ) else : print ( " No ▁ solution " )   else : x = d * ( 10 ** ( k - 1 ) ) print ( x ) NEW_LINE

k , d = map ( int , input ( ) . split ( ) ) ; if ( k > 1 and d == 0 ) : print ( " No ▁ solution " ) else : print ( str ( d ) + "0" * ( k - 1 ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   public class dpa01 { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }    public static void main ( String [ ] args ) { FastReader In = new FastReader ( ) ; int n = In . nextInt ( ) ; PriorityQueue < Integer > pq = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; int l = In . nextInt ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { pq . add ( In . nextInt ( ) ) ; } int cont = l ; while ( l <= pq . peek ( ) ) { l ++ ; pq . add ( pq . poll ( ) - 1 ) ; } System . out . println ( l - cont ) ; }    }

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 > { } ; public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int n = nxtInt ( ) ; PriorityQueue < Integer > q = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; int lmk = nxtInt ( ) ; for ( int i = 1 ; i < n ; i ++ ) q . add ( nxtInt ( ) ) ; int cnt = 0 ; while ( lmk <= q . peek ( ) ) { lmk ++ ; int tmp = q . poll ( ) ; tmp -- ; q . add ( tmp ) ; cnt ++ ; } pr . println ( cnt ) ; 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 . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ;   public class bearAndElections { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int [ ] arr = new int [ n - 1 ] ; for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int count = 0 ; while ( arr [ arr . length - 1 ] >= a ) { arr [ arr . length - 1 ] -- ; a ++ ; count ++ ; Arrays . sort ( arr ) ; } System . out . println ( count ) ; } }

import java . util . * ; public class p574A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PriorityQueue < Integer > pq = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; int n = sc . nextInt ( ) , x = sc . nextInt ( ) , c = 0 ; while ( n -- > 1 ) pq . add ( sc . nextInt ( ) ) ; while ( x <= pq . peek ( ) ) { pq . add ( pq . poll ( ) - 1 ) ; x ++ ; c ++ ; } System . out . println ( c ) ; } }

input ( ) c = [ int ( x ) for x in input ( ) . split ( ) ] l = c . pop ( 0 ) c . sort ( reverse = True ) ans = 0 while l <= c [ 0 ] : ans += 1 l += 1 c [ 0 ] -= 1 c . sort ( reverse = True ) print ( ans )   NEW_LINE

n = int ( input ( ) )   b , * l = map ( int , input ( ) . split ( ) )   l = sorted ( l )   ''' u ▁ need ▁ to ▁ sort ▁ at ▁ every ▁ step ▁ then ▁ only ▁ you ▁ wil ▁ get ▁ the ▁ minimum ▁ steps  '''       ans = 0   while b <= l [ - 1 ] :   l [ - 1 ] -= 1   b += 1   ans += 1 l = sorted ( l )           print ( ans )   NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) mx = max ( a ) for i in range ( a [ 0 ] , mx + 2 ) : need = i - a [ 0 ] changes = sum ( [ x - i + 1 for x in a [ 1 : ] if x >= i ] ) if changes <= need : print ( need ) exit ( 0 ) NEW_LINE


import java . util . Scanner ;   public class A638 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int A = in . nextInt ( ) ; int answer ; if ( A % 2 == 0 ) { answer = ( ( N + 2 ) - A ) / 2 ; } else { answer = ( A + 1 ) / 2 ; } System . out . println ( answer ) ; }   }

import java . util . Scanner ;   public class HomeNumber { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n , a , result = 0 ; n = input . nextInt ( ) ; a = input . nextInt ( ) ; if ( n == a || a == 1 ) { result = 1 ; } else if ( a % 2 != 0 ) { result = a / 2 + 1 ; } else if ( a == n / 2 && a % 2 == 0 ) {   result = a / 2 + 1 ; } else { if ( a > n / 2 ) { result = ( n - a ) / 2 + 1 ; } else if ( a < n / 2 ) { result = ( n - a ) / 2 + 1 ; }   } System . out . println ( result ) ; } }

import java . io . * ; import java . util . * ; public class HomeNumbers { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; PrintWriter pr = new PrintWriter ( System . out ) ; int n = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int first , diff , numTerms ; if ( a % 2 == 1 ) { first = 1 ; diff = 2 ;   } else { first = n ; diff = - 2 ; } long sum = ( ( a - first ) / diff + 1 ) ; System . out . print ( sum ) ;   } }

import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . util . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;    public class Main1 {    public static void main ( String [ ] args ) {   try {    FastScanner in = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;   int n = in . nextInt ( ) ; int a = in . nextInt ( ) ;   if ( a % 2 != 0 ) { System . out . println ( ( a + 1 ) / 2 ) ; } else { int ct = a / 2 ; if ( n % 2 != 0 ) n -- ; System . out . println ( ( n / 2 ) - ct + 1 ) ;   }                         out . flush ( ) ; out . close ( ) ;    } catch ( Exception e ) { return ; }                      }    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 ( ) ) ; } }    }

n , a = input ( ) . split ( ) n = int ( n ) a = int ( a ) if ( a % 2 == 0 ) : x = n - a x = x / 2 x = x + 1 else : x = a - 1 x = x / 2 x = x + 1 print ( int ( x ) ) NEW_LINE

def f ( l ) : n , a = l return ( a + 1 ) // 2 if a % 2 > 0 else ( n + 2 - a ) // 2 l = list ( map ( int , input ( ) . split ( ) ) ) print ( f ( l ) ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) a , b = [ ] , [ ] for x in range ( 1 , n + 1 ) : if x % 2 == 0 : a . append ( x ) else : b . append ( x ) a = a [ : : - 1 ] ans = 0 for x in range ( len ( a ) ) : ans += 1 if k == a [ x ] or k == b [ x ] : breakprint ( ans ) NEW_LINE

import sysn , a = map ( int , input ( ) . split ( ) ) up = [ i for i in range ( 1 , n , 2 ) ] down = [ i for i in range ( n , 1 , - 2 ) ] if a in up : print ( up . index ( a ) + 1 ) else : print ( down . index ( a ) + 1 ) NEW_LINE


import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ;

import java . util . * ;   public class ICPC { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ;   for ( int i = 1 ; i <= t ; i ++ ) { long n = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; long c = 0 ;

import java . util . * ; import java . io . * ; public class EdA { static long [ ] mods = { 1000000007 , 998244353 , 1000000009 } ; static long mod = mods [ 0 ] ; public static MyScanner sc ; public static PrintWriter out ; public static void main ( String [ ] omkar ) throws Exception {

import java . util . * ;   public class CodeForces1175A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; for ( int i = 0 ; i < t ; i ++ ) { long n = input . nextLong ( ) ; long k = input . nextLong ( ) ; long count = 0 ; while ( n >= 1 ) { if ( n >= k ) { count += n % k + 1 ; n /= k ; } else { count += n ; n = 0 ; } } System . out . println ( count ) ; } } }

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

cases = int ( input ( ) ) while cases : cases -= 1 n , k = map ( int , input ( ) . split ( ) )   ans = 0   while n : ans += n % k n //= k if n > 0 : ans += 1   print ( ans ) NEW_LINE

t = int ( input ( ) ) for i in range ( t ) : n , k = [ int ( x ) for x in input ( ) . split ( ) ] count = 0 while n != 0 : if n % k == 0 : n = n // k count = count + 1 else : count = count + n % k n = n - n % k print ( count ) NEW_LINE

t = int ( input ( ) ) for i in range ( t ) : n , k = [ int ( x ) for x in input ( ) . split ( ) ] ind = 0 while n != 0 : if n % k == 0 : n = n // k ind += 1 else : ind = ind + ( n % k ) n = n - ( n % k ) print ( ind ) NEW_LINE


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

t = int ( input ( ) ) NEW_LINE alco = " ABSINTH , ▁ BEER , ▁ BRANDY , ▁ CHAMPAGNE , ▁ GIN , ▁ RUM , ▁ SAKE , ▁ TEQUILA , ▁ VODKA , ▁ WHISKEY , ▁ WINE " . replace ( " , " , " " ) . split ( ) NEW_LINE check = 0 NEW_LINE for _ in range ( t ) : n = input ( ) NEW_LINE check += int ( n . isdigit ( ) and int ( n ) < 18 or n in alco ) NEW_LINE print ( check ) NEW_LINE

n = int ( input ( ) ) NEW_LINE d = [ ' ABSINTH ' , ' BEER ' , ' BRANDY ' , ' CHAMPAGNE ' , ' GIN ' , ' RUM ' , ' SAKE ' , ' TEQUILA ' , ' VODKA ' , ' WHISKEY ' , ' WINE ' ] NEW_LINE c = 0   for i in range ( n ) : a = input ( ) NEW_LINE if a . isnumeric ( ) and int ( a ) < 18 : NEW_LINE INDENT c += 1 else : NEW_LINE if NEW_LINE DEDENT not a . isnumeric ( ) : NEW_LINE if a in d : c += 1   print ( c ) NEW_LINE

ALCOHOLIC_DRINKS = [ " ABSINTH " , " BEER " , " BRANDY " , " CHAMPAGNE " , " GIN " , " RUM " , " SAKE " , " TEQUILA " , " VODKA " , " WHISKEY " , " WINE " ]   total_clients = int ( input ( ) )   clients_to_check = 0   for _ in range ( total_clients ) : data = input ( )     try : data = int ( data ) NEW_LINE if data < 18 : NEW_LINE INDENT clients_to_check += 1 else : NEW_LINE continue except ValueError : NEW_LINE DEDENT if data in ALCOHOLIC_DRINKS : NEW_LINE INDENT clients_to_check += 1 else : NEW_LINE continue   print ( clients_to_check ) NEW_LINE DEDENT

def isfloat ( st ) : try NEW_LINE INDENT : int ( st ) NEW_LINE DEDENT return True except ValueError : NEW_LINE return False     nct = 0 NEW_LINE ct = 0 NEW_LINE test = int ( input ( ) ) NEW_LINE drinks = [ " ABSINTH " , " BEER " , " BRANDY " , " CHAMPAGNE " , " GIN " , " RUM " , " SAKE " , " TEQUILA " , " VODKA " , " WHISKEY " , " WINE " ] NEW_LINE while nct < test : n = input ( ) NEW_LINE if isfloat ( n ) : if NEW_LINE int ( n ) < 18 : ct = ct + 1 else : for i in drinks : if NEW_LINE n == i : ct = ct + 1 NEW_LINE nct = nct + 1 NEW_LINE print ( ct ) NEW_LINE


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

import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; String s = in . next ( ) ; int a [ ] = new int [ 26 ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ s . charAt ( i ) - ' a ' ] ++ ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( a [ i ] > k ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; }   }

import java . util . Scanner ;   public class GenerousKefa { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) , i , a [ ] = new int [ 26 ] , m = 0 ; String s = in . next ( ) ; in . close ( ) ; for ( i = 0 ; i < n ; i ++ ) { a [ s . charAt ( i ) - 97 ] ++ ; m = Math . max ( m , a [ s . charAt ( i ) - 97 ] ) ; } System . out . println ( m <= k ? " YES " : " NO " ) ; } }

import collectionsa , b = map ( int , input ( ) . split ( ) ) s = input ( ) count = collections . Counter ( s ) . most_common ( 1 ) [ 0 ] [ 1 ]   if count > b : print ( " NO " ) else : print ( " YES " ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) s = list ( input ( ) ) l = [ ] d = [ ] for i in s : if i not in d : d . append ( i ) l . append ( s . count ( i ) ) c = 0 for j in l : if j > k : c = 1 if c == 1 : print ( " NO " ) else : print ( " YES " ) NEW_LINE

try : a , b = map ( int , input ( ) . split ( ) ) s = input ( ) alph = [ ] count = [ ] for i in range ( a ) : if s [ i ] in alph : continue else : alph . append ( s [ i ] ) count . append ( s . count ( s [ i ] ) ) if ( max ( count ) > b ) : print ( ' No ' ) else : print ( ' Yes ' ) except : pass NEW_LINE

def solve ( s , n , k ) : d = { } for c in s : if d . get ( c ) : d [ c ] += 1 else : d [ c ] = 1 for i in d : if d [ i ] > k : return ' NO ' return ' YES '                         def main ( ) : NEW_LINE

import string   a , b = map ( int , input ( ) . split ( ) ) s = input ( )   f = Truefor i in string . ascii_lowercase : if s . count ( i ) > b : f = False break     if f : print ( " YES " ) else : print ( " NO " ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class experiment { static int M = 1_000_000_007 ; static int INF = Integer . MAX_VALUE ; static final FastScanner fs = new FastScanner ( ) ;

import java . util . * ;    public class dummycodes {   public static class Pair { int x ; int y ; int z ; public Pair ( int x , int y , int z ) { this . x = x ; this . y = y ; this . z = z ; } } public static boolean Solve ( String s1 , String s2 ) { if ( s1 . length ( ) != s2 . length ( ) || s1 . equals ( s2 ) ) return false ; int i = 0 ; int j = s1 . length ( ) - 1 ; boolean flagi = false ; boolean flagj = false ; boolean flag = false ; while ( j > i ) { if ( s1 . charAt ( i ) == s2 . charAt ( i ) ) i ++ ; else { if ( flag ) return false ; flagi = true ; } if ( s1 . charAt ( j ) == s2 . charAt ( j ) ) j -- ; else { if ( flag ) return false ; flagj = true ; } if ( flagi && flagj ) { if ( s1 . charAt ( i ) == s2 . charAt ( j ) && s1 . charAt ( j ) == s2 . charAt ( i ) ) { flag = true ; i ++ ; j -- ; } else return false ; flagi = flagj = false ; } } return flag ; }   public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String s1 = sc . nextLine ( ) ; String s2 = sc . nextLine ( ) ; if ( Solve ( s1 , s2 ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ;    } }

import java . util . * ; import java . math . * ; public class ComparingStrings { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] first = sc . nextLine ( ) . toCharArray ( ) ; char [ ] second = sc . nextLine ( ) . toCharArray ( ) ; int [ ] letters = new int [ 26 ] ; Arrays . fill ( letters , 0 ) ; if ( first . length != second . length ) { System . out . println ( " NO " ) ; return ; } if ( first . length == 1 ) { if ( first [ 0 ] != second [ 0 ] ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; return ; } int count = 0 ; for ( int i = 0 ; i < first . length ; i ++ ) { if ( first [ i ] != second [ i ] ) count ++ ; letters [ ( int ) first [ i ] - 97 ] ++ ; letters [ ( int ) second [ i ] - 97 ] -- ; } for ( int i = 0 ; i < 26 ; i ++ ) { if ( letters [ i ] != 0 ) { System . out . println ( " NO " ) ; return ; } } if ( count == 2 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class A186 { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; char [ ] first = s . nextLine ( ) . toCharArray ( ) ; char [ ] second = s . nextLine ( ) . toCharArray ( ) ;   boolean match = true ; if ( first . length != second . length ) { match = false ; } else { int diff = 0 ; for ( int i = 0 ; i < first . length ; i ++ ) { if ( first [ i ] != second [ i ] ) { diff ++ ; } } if ( diff != 2 ) { match = false ; } else { Arrays . sort ( first ) ; Arrays . sort ( second ) ; match = Arrays . equals ( first , second ) ; } } System . out . println ( match == true ? " YES " : " NO " ) ;    } }

g1 = input ( ) g2 = input ( ) s1 = [ ] s2 = [ ] if len ( g1 ) != len ( g2 ) : print ( ' NO ' ) else : for i in range ( len ( g1 ) ) : if g1 [ i ] != g2 [ i ] : s1 . append ( g1 [ i ] ) s2 . append ( g2 [ i ] )   if len ( s1 ) != 2 or len ( s2 ) != 2 : print ( ' NO ' ) else : if s1 [ 0 ] == s2 [ 1 ] and s1 [ 1 ] == s2 [ 0 ] : print ( " YES " ) else : print ( " NO " ) NEW_LINE

first = input ( ) second = input ( ) flag = 0 counter = 0 if ( len ( first ) == len ( second ) and len ( first ) == 2 ) : if ( first [ 1 ] + first [ 0 ] == second ) : print ( " YES " ) else : print ( " NO " ) elif ( first != second and len ( first ) == len ( second ) and len ( first ) > 2 ) :   for i in range ( len ( first ) ) : if ( first [ i ] != second [ i ] ) : counter += 1   if ( counter == 1 ) : index_1 = flag elif ( counter == 2 ) : index_2 = flag first_swap = first [ 0 : index_1 ] + first [ index_2 ] + first [ index_1 + 1 : index_2 ] + first [ index_1 ] + first [ index_2 + 1 : ] if ( first_swap == second ) : print ( " YES " ) break else : print ( " NO " ) break flag += 1   if ( counter == 1 ) : print ( " NO " )   else : print ( " NO " ) NEW_LINE

g1 = input ( ) g2 = input ( )   l1 = [ ] l2 = [ ] ml = [ ] if len ( g1 ) != len ( g2 ) : print ( ' NO ' ) else : for i in range ( 0 , len ( g1 ) ) : if g1 [ i ] != g2 [ i ] : l1 . append ( g1 [ i ] ) l2 . append ( g2 [ i ] ) if g1 [ i ] not in ml : ml . append ( g1 [ i ] ) if g2 [ i ] not in ml : ml . append ( g2 [ i ] ) if l1 . sort ( ) == l2 . sort ( ) and len ( l1 ) > 1 and len ( l1 ) < 3 and len ( ml ) <= 2 : print ( ' YES ' ) elif g1 == g2 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

def solution ( ) : a = input ( ) b = input ( ) ca = [ 0 ] * 26 cb = [ 0 ] * 26   for i in a : ca [ ord ( i ) - ord ( ' a ' ) ] += 1 for i in b : cb [ ord ( i ) - ord ( ' a ' ) ] += 1   if ca != cb : print ( ' NO ' ) return strike = 0 n = len ( a ) for i in range ( n ) : if a [ i ] != b [ i ] : if strike < 2 : strike += 1 else : print ( ' NO ' ) return print ( ' YES ' )   return 	 	       solution ( ) NEW_LINE

a = input ( ) b = input ( ) coun = 0 leta = [ ] letb = [ ] n = len ( a ) if len ( a ) == len ( b ) : for i in range ( len ( a ) ) : if a [ i ] == b [ i ] : coun += 1 else : leta . append ( a [ i ] ) letb . append ( b [ i ] ) if coun >= n - 2 : leta . sort ( ) ; letb . sort ( ) if leta == letb : print ( " YES " ) else : print ( " NO " ) else : print ( " NO " ) else : print ( " NO " ) 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 str = sc . next ( ) ; int c = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( str . charAt ( i ) == str . charAt ( i + 1 ) ) { c ++ ; } } System . out . println ( c ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . HashSet ;   public class Demo { public static void main ( String args [ ] ) throws NumberFormatException , IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   int n = Integer . parseInt ( reader . readLine ( ) ) ; String str = reader . readLine ( ) ; int count = 0 ; for ( int i = 0 ; i < str . length ( ) - 1 ; i ++ ) { if ( str . charAt ( i ) == str . charAt ( i + 1 ) ) { count ++ ; } } System . out . println ( count ) ; } }

import java . io . * ; import java . util . * ;   public class Main {   static Main . MyScanner sc = new Main . MyScanner ( ) ; static PrintStream out = System . out ;   public static void main ( String [ ] args ) throws Exception {   int n = sc . nextInt ( ) , counter = 0 ; String input = sc . next ( ) ; for ( int i = 0 ; i < input . length ( ) - 1 ; i ++ ) { if ( input . charAt ( i ) == input . charAt ( i + 1 ) ) counter ++ ; } out . print ( counter ) ; out . close ( ) ; }   static private class MyScanner { BufferedReader br ; StringTokenizer st ;   public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public long mod ( long x ) {

import java . util . Scanner ;   public class StonesOnTable { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; scanner . nextLine ( ) ;   String s = scanner . nextLine ( ) ;   int res = 0 ; for ( int i = 1 ; i < s . length ( ) ; ) { char ch = s . charAt ( i ) ;   if ( ch == s . charAt ( i - 1 ) ) { res ++ ; s = s . substring ( 0 , i ) + s . substring ( i + 1 ) ;

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AStonesOnTheTable solver = new AStonesOnTheTable ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class AStonesOnTheTable { public void solve ( int testNumber , FastScanner fs , PrintWriter out ) { int n = fs . nextInt ( ) ; char [ ] c = fs . next ( ) . toCharArray ( ) ; int ans = 0 ; char p = c [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { if ( c [ i ] == p ) { ans ++ ; } else { p = c [ i ] ; } } out . println ( ans ) ; }   }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( InputStream inputStream ) { br = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; }   public String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }

n = int ( input ( ) ) s = input ( ) count = 0 for i in range ( len ( s ) - 1 ) : if s [ i ] == s [ i + 1 ] : count += 1 print ( count ) NEW_LINE

n = eval ( input ( ) ) s = input ( ) current = s [ 0 ] ans = 0 for i in s [ 1 : : ] : if i == current : ans += 1 current = iprint ( ans ) NEW_LINE

n = int ( input ( ) ) colors = list ( input ( ) )   count = 0 prev = ' '   for i in colors : if prev == i : count += 1   prev = i   print ( count ) NEW_LINE

n = int ( input ( ) )   s = input ( )   R = G = B = 0   for i in range ( 1 , n ) :   if ( s [ i - 1 ] == s [ i ] ) :   if ( s [ i ] == " R " ) :   R = R + 1   elif ( s [ i ] == " G " ) :   G = G + 1   else :   B = B + 1     print ( R + G + B ) NEW_LINE

n = int ( input ( ) ) s = input ( ) ans = 0 c = 0 n = len ( s ) for i in range ( n - 1 ) : NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   public class LiteratureLesson {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n ; int k ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; int reqtype = 0 ; for ( int i = 0 ; i < n ; i ++ ) { boolean bad = false ; String [ ] suffix = new String [ 4 ] ; for ( int l = 0 ; l < 4 ; l ++ ) { suffix [ l ] = " " ; String s = sc . next ( ) ; int vowels = 0 ; for ( int let = s . length ( ) - 1 ; let >= 0 ; let -- ) { char c = s . charAt ( let ) ; if ( c == ' a ' || c == ' e ' || c == ' i ' || c == ' o ' || c == ' u ' ) {

n , k = list ( map ( int , input ( ) . split ( ) ) ) l = [ ] for i in range ( 4 * n ) : l . append ( input ( ) ) poss = 0 lst = [ ] for i in l : c = 0 n = len ( i ) for j in range ( n - 1 , - 1 , - 1 ) : if ( i [ j ] == ' a ' or i [ j ] == ' e ' or i [ j ] == ' i ' or i [ j ] == ' o ' or i [ j ] == ' u ' ) : c += 1 else : continue if ( c == k ) : lst . append ( i [ j : ] ) break if ( c < k ) : poss = 1 ; break ; if ( poss == 1 ) : print ( " NO " ) else : n = len ( lst ) ch = [ ] ans = - 1 pos = 0 for i in range ( 0 , n , 4 ) : s1 = lst [ i ] s2 = lst [ i + 1 ] ; s3 = lst [ i + 2 ] ; s4 = lst [ i + 3 ] ; if ( s1 == s2 and s2 == s3 and s3 == s4 ) : ch . append ( [ 1 , 2 , 3 , 4 ] ) elif ( s1 != s2 ) : if ( s1 == s3 and s2 == s4 ) : ch . append ( [ 2 ] ) if ( ans != - 1 and ans != 2 ) : pos = 1 ; break ans = 2 elif ( s1 == s4 and s2 == s3 ) : ch . append ( [ 3 ] ) if ( ans != - 1 and ans != 3 ) : pos = 1 ; break ans = 3 else : pos = 1 ; break else : if ( s3 == s4 ) : ch . append ( [ 1 ] ) if ( ans != - 1 and ans != 1 ) : pos = 1 ; break ans = 1 else : pos = 1 ; break   if ( pos == 1 ) : print ( " NO " ) else : if ( ans == - 1 ) : print ( " aaaa " ) elif ( ans == 2 ) : print ( " abab " ) elif ( ans == 3 ) : print ( " abba " ) elif ( ans == 1 ) : print ( " aabb " ) NEW_LINE


import java . util . Scanner ;   public class A1408 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; StringBuilder output = new StringBuilder ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; int [ ] C = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { A [ n ] = in . nextInt ( ) ; } for ( int n = 0 ; n < N ; n ++ ) { B [ n ] = in . nextInt ( ) ; } for ( int n = 0 ; n < N ; n ++ ) { C [ n ] = in . nextInt ( ) ; } int [ ] P = new int [ N ] ; P [ 0 ] = A [ 0 ] ; for ( int n = 1 ; n < N - 1 ; n ++ ) { if ( P [ n - 1 ] == A [ n ] ) { P [ n ] = B [ n ] ; } else { P [ n ] = A [ n ] ; } } if ( P [ N - 2 ] != A [ N - 1 ] && P [ 0 ] != A [ N - 1 ] ) { P [ N - 1 ] = A [ N - 1 ] ; } else if ( P [ N - 2 ] != B [ N - 1 ] && P [ 0 ] != B [ N - 1 ] ) { P [ N - 1 ] = B [ N - 1 ] ; } else { P [ N - 1 ] = C [ N - 1 ] ; } for ( int p : P ) { output . append ( p ) . append ( ' ▁ ' ) ; } output . append ( ' \n ' ) ; } System . out . print ( output ) ; }   }

import systry : sys . stdin = open ( " input . txt " , " r " ) except FileNotFoundError : NEW_LINE pass   NEW_LINE def next_array ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE   NEW_LINE def prefix ( lst ) : assert len ( lst ) NEW_LINE pre = [ lst [ 0 ] ] NEW_LINE for i in range ( 1 , len ( lst ) ) : pre . append ( lst [ i ] + pre [ i - 1 ] ) NEW_LINE return pre   NEW_LINE def solve ( ) : l = int ( input ( ) ) NEW_LINE a = next_array ( ) NEW_LINE b = next_array ( ) NEW_LINE c = next_array ( ) NEW_LINE lst = [ a , b , c ] NEW_LINE out = [ ] NEW_LINE for i in range ( l ) : if NEW_LINE i == 0 : out . append ( lst [ 0 ] [ 0 ] ) elif i == l - 1 : NEW_LINE for j in range ( 3 ) : if NEW_LINE lst [ j ] [ i ] != out [ i - 1 ] and lst [ j ] [ i ] != out [ 0 ] : out . append ( lst [ j ] [ i ] ) NEW_LINE break elif i : NEW_LINE for j in range ( 3 ) : if NEW_LINE lst [ j ] [ i ] != out [ i - 1 ] : out . append ( lst [ j ] [ i ] ) NEW_LINE break NEW_LINE print ( " ▁ " . join ( str ( i ) for i in out ) ) NEW_LINE if __name__ == " _ _ main _ _ " : test_cases = True NEW_LINE if test_cases : for NEW_LINE i in range ( int ( input ( ) ) ) : solve ( ) else : solve ( ) NEW_LINE

t = int ( input ( ) ) NEW_LINE for z in range ( t ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE c = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l = [ a [ 0 ] ] NEW_LINE for i in range ( 1 , n ) : if NEW_LINE a [ i ] != l [ len ( l ) - 1 ] and a [ i ] != l [ 0 ] : l . append ( a [ i ] ) elif b [ i ] != l [ len ( l ) - 1 ] and b [ i ] != l [ 0 ] : l . append ( b [ i ] ) else : l . append ( c [ i ] ) NEW_LINE print ( * l ) NEW_LINE

cases = int ( input ( ) )   while cases : cases -= 1 NEW_LINE num = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE c = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ a [ 0 ] ] NEW_LINE for i in range ( 1 , num ) : if NEW_LINE a [ i ] != ans [ - 1 ] : ans . append ( a [ i ] ) else : ans . append ( b [ i ] )   if ans [ 0 ] == ans [ - 1 ] : if NEW_LINE ans [ - 2 ] != c [ - 1 ] : ans [ - 1 ] = c [ - 1 ] elif ans [ - 2 ] != b [ - 1 ] and ans [ 0 ] != b [ - 1 ] : ans [ - 1 ] = b [ - 1 ] else : ans [ - 1 ] = NEW_LINE a [ - 1 ]   print ( * ans )     NEW_LINE


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

import java . io . * ; import java . util . Arrays ; import java . util . stream . Stream ;   public class GreenhouseEffect { static int [ ] [ ] dp ; public static void main ( String [ ] args ) throws IOException { GreenhouseEffect obj = new GreenhouseEffect ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int [ ] arr = Stream . of ( br . readLine ( ) . split ( " ▁ " ) ) . mapToInt ( Integer :: parseInt ) . toArray ( ) ; int n = arr [ 0 ] ; int m = arr [ 1 ] ; dp = new int [ n ] [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { Arrays . fill ( dp [ i ] , - 1 ) ; } int [ ] val = new int [ n ] ;

import java . io . * ; import java . util . * ; public class Solution { public static void main ( String ag [ ] ) { Scanner sc = new Scanner ( System . in ) ; int i , j , k ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int type [ ] = new int [ N ] ; double location [ ] = new double [ N ] ; for ( i = 0 ; i < N ; i ++ ) { type [ i ] = sc . nextInt ( ) ; location [ i ] = sc . nextDouble ( ) ; } int dp [ ] = new int [ N ] ; Arrays . fill ( dp , 1 ) ; int max = 1 ; for ( i = 1 ; i < N ; i ++ ) { for ( j = 0 ; j < i ; j ++ ) { if ( dp [ j ] + 1 > dp [ i ] && type [ i ] >= type [ j ] ) { dp [ i ] = dp [ j ] + 1 ; } } max = Math . max ( max , dp [ i ] ) ; } System . out . println ( N - max ) ; } }

def f ( arr ) : arr = [ None ] + arr dp = [ 0 ] * ( len ( arr ) ) for i in range ( 1 , len ( arr ) ) : j = int ( arr [ i ] ) for k in range ( int ( j ) , 0 , - 1 ) : dp [ j ] = max ( dp [ j ] , 1 + dp [ k ] ) return len ( arr ) - max ( dp ) - 1 NEW_LINE

def lis ( arr ) : n = len ( arr ) NEW_LINE