import java . io . BufferedWriter ; import java . io . IOException ; import java . io . OutputStreamWriter ; import java . util . ArrayList ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ;   public class PrincessesAndPrinces { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int test = scanner . nextInt ( ) ; try ( BufferedWriter output = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) { outerLoop : while ( test -- > 0 ) { int n = scanner . nextInt ( ) ; boolean [ ] isReserved = new boolean [ n + 1 ] ; List < Integer > single = new ArrayList < > ( ) ; HashSet < Integer > singleP = new HashSet < > ( ) ; List < List < Integer > > priority = new ArrayList < > ( n + 1 ) ; priority . add ( new ArrayList < > ( ) ) ; for ( int i = 1 ; i <= n ; i ++ ) { singleP . add ( i ) ; int k = scanner . nextInt ( ) ; List < Integer > t = new ArrayList < > ( k ) ; for ( int j = 1 ; j <= k ; j ++ ) { int temp = scanner . nextInt ( ) ; t . add ( temp ) ; } priority . add ( t ) ; } for ( int i = 1 ; i <= n ; i ++ ) { boolean flag = false ; for ( int j : priority . get ( i ) ) { if ( ! isReserved [ j ] ) { isReserved [ j ] = true ; flag = true ; singleP . remove ( j ) ; break ; } } if ( ! flag ) { single . add ( i ) ; } } if ( single . size ( ) == 0 ) { output . write ( " OPTIMAL \n " ) ; } else { for ( int i : single ) { for ( int j : singleP ) { if ( ! priority . get ( i ) . contains ( j ) ) { output . write ( " IMPROVE \n " ) ; output . write ( i + " ▁ " + j + " \n " ) ; continue outerLoop ; } } } output . write ( " OPTIMAL \n " ) ; } } output . flush ( ) ; } catch ( IOException e ) { } } }

import java . math . * ; import java . util . * ; public class PrincessAndPrince { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; while ( runs -- > 0 ) { int size = sc . nextInt ( ) ; boolean optimal = true ; int [ ] arr = new int [ size + 1 ] ; int out = 0 ; boolean add = false ; int [ ] dex = new int [ 2 ] ; for ( int i = 1 ; i < size + 1 ; i ++ ) { arr [ i ] = 1 ; } for ( int i = 0 ; i < size ; i ++ ) { int len = sc . nextInt ( ) ; boolean fill = false ; for ( int j = 0 ; j < len ; j ++ ) { int num = sc . nextInt ( ) ; if ( ! fill ) { if ( arr [ num ] == 1 ) { out ++ ; arr [ num ] -- ; fill = true ; } } } if ( ! fill && add == false ) { dex [ 0 ] = i + 1 ; add = true ; } } if ( add ) { for ( int j = 1 ; j < size + 1 ; j ++ ) { if ( arr [ j ] == 1 ) { arr [ j ] = 0 ; out ++ ; optimal = false ; dex [ 1 ] = j ; break ; } } } if ( optimal ) System . out . println ( " OPTIMAL " ) ; else { System . out . println ( " IMPROVE " ) ; System . out . println ( dex [ 0 ] + " ▁ " + dex [ 1 ] ) ; } } } }

import java . io . IOException ; import java . util . * ; import java . util . Arrays ; import java . util . Scanner ;   public class Bit_year { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; while ( T -- > 0 ) { int n = sc . nextInt ( ) ; LinkedList < Integer > [ ] adj = new LinkedList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) adj [ i ] = new LinkedList ( ) ; Set < Integer > prince = new HashSet < Integer > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { int s = sc . nextInt ( ) ; while ( s -- > 0 ) { adj [ i ] . add ( sc . nextInt ( ) ) ; } Collections . sort ( adj [ i ] ) ; prince . add ( i ) ; } boolean [ ] visited = new boolean [ n + 1 ] ; boolean [ ] visitedD = new boolean [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { Iterator itr = adj [ i ] . listIterator ( ) ; while ( itr . hasNext ( ) ) { int m = ( int ) itr . next ( ) ; if ( ! visited [ m ] ) { visited [ m ] = true ; prince . remove ( m ) ; visitedD [ i ] = true ; break ; } } }

import java . util . * ; import java . io . * ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . * ; import java . io . FileInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; import java . math . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;    public class Sol { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; boolean [ ] matched = new boolean [ n + 1 ] ; int extra = 0 ; int [ ] array = new int [ n + 1 ] ; int pair = 0 ; boolean [ ] daughter = new boolean [ n + 1 ] ; int boy = - 1 ; int girl = - 1 ; int left = 0 ; int index = - 1 ; for ( int i = 1 ; i <= n ; i ++ ) { int k = sc . nextInt ( ) ; boolean found = false ; while ( k > 0 ) { int prince = sc . nextInt ( ) ; if ( matched [ prince ] == false && daughter [ i ] == false ) { matched [ prince ] = true ; daughter [ i ] = true ; pair ++ ; array [ prince ] = - 1 ; found = true ; k -- ; continue ; } k -- ; }   if ( found == false ) { left ++ ; index = i ; } } int b = - 1 ; if ( left > 0 ) { for ( int i = 1 ; i <= n ; i ++ ) { if ( array [ i ] == 0 ) { b = i ; break ; } } } if ( left > 0 && b != - 1 ) { System . out . println ( " IMPROVE " ) ; System . out . println ( index + " ▁ " + b ) ; } else { System . out . println ( " OPTIMAL " ) ; } } } }

def calc ( optionsList ) : unusedDaughter = None usedKingdoms = [ False ] * ( len ( optionsList ) + 5 ) for daughterIdx , options in enumerate ( optionsList ) : kingdomFound = False for option in options : if not usedKingdoms [ option ] : usedKingdoms [ option ] = True kingdomFound = True break if not kingdomFound : unusedDaughter = daughterIdx toImprove = None if unusedDaughter is not None : for idx in range ( 1 , len ( optionsList ) + 1 ) : if not usedKingdoms [ idx ] : toImprove = " { } ▁ { } " . format ( unusedDaughter + 1 , idx ) break   NEW_LINE

import sys   def answer ( n , g ) : NEW_LINE

def calc ( optionsList ) : unusedDaughter = None usedKingdoms = [ False ] * ( len ( optionsList ) + 5 ) for daughterIdx , options in enumerate ( optionsList ) : kingdomFound = False for option in options : if not usedKingdoms [ option ] : usedKingdoms [ option ] = True kingdomFound = True break if not kingdomFound : unusedDaughter = daughterIdx toImprove = None if unusedDaughter is not None : for idx in range ( 1 , len ( optionsList ) + 1 ) : if not usedKingdoms [ idx ] and idx not in optionsList [ unusedDaughter ] : toImprove = " { } ▁ { } " . format ( unusedDaughter + 1 , idx ) break   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 ) ; Main m = new Main ( ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { m . run ( in , out ) ; }   out . close ( ) ; }   public static long mod = 17352642619633L ;   static char [ ] cat = " abacaba " . toCharArray ( ) ; static int [ ] kmp ( char [ ] ca ) { int [ ] kmp = new int [ ca . length ] ; int N = ca . length ; for ( int i = 1 ; i < N ; i ++ ) { int p = kmp [ i - 1 ] ; while ( p > 0 && ca [ p ] != ca [ i ] ) { p = kmp [ p - 1 ] ; } if ( ca [ p ] == ca [ i ] ) p ++ ; kmp [ i ] = p ; } return kmp ; } static int [ ] kmp = kmp ( cat ) ;    void run ( FastScanner in , PrintWriter out ) {   int N = in . nextInt ( ) ; char [ ] ca = in . next ( ) . toCharArray ( ) ;

def count ( s , want ) : ans = 0 for i in range ( n ) : if s [ i : i + 7 ] == want : ans += 1 return ansfor _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) s = input ( ) want = ' abacaba ' f = 0 for i in range ( n - 6 ) : flag = 0 for j in range ( 7 ) : if s [ i + j ] != want [ j ] and s [ i + j ] != " ? " : flag = 1 if flag == 1 : continue ss = " " . join ( s [ : i ] + want + s [ i + 7 : ] ) if count ( ss , want ) == 1 : ss = ss . replace ( " ? " , ' z ' ) print ( " Yes " ) print ( ss ) f = 1 break if f == 0 : print ( " No " ) NEW_LINE

''' import ▁ sysdef ▁ get _ ints ( ) : ▁ return ▁ map ( int , ▁ sys . stdin . readline ( ) . strip ( ) . split ( ) )  def ▁ sort _ list ( list1 , ▁ list2 ) : ▁ ▁ ▁ ▁ zipped _ pairs ▁ = ▁ zip ( list2 , ▁ list1 )   ▁ ▁ ▁ ▁ z ▁ = ▁ [ x ▁ for ▁ _ , ▁ x ▁ in ▁ sorted ( zipped _ pairs ) ]   ▁ ▁ ▁ ▁ return ▁ z ''' def coun ( s ) : c = 0 x = " abacaba " for i in range ( n - len ( x ) + 1 ) : if " " . join ( s [ i : i + len ( x ) ] ) == x : c += 1 return c   for ad in range ( int ( input ( ) ) ) : n = int ( input ( ) ) s = list ( input ( ) ) c = coun ( s ) NEW_LINE

import sysfrom math import sqrtinput = lambda : sys . stdin . readline ( ) . rstrip ( " \n " ) lm = lambda : list ( map ( int , input ( ) . split ( ) ) )   for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = [ ] [ a . append ( i ) for i in input ( ) ] ck = [ ' a ' , ' b ' , ' a ' , ' c ' , ' a ' , ' b ' , ' a ' ] NEW_LINE

from sys import stdin , stdoutstdin . readlinedef mp ( ) : return list ( map ( int , stdin . readline ( ) . strip ( ) . split ( ) ) ) def it ( ) : return int ( stdin . readline ( ) . strip ( ) ) from collections import defaultdict as dd , Counter as C , dequefrom math import ceil , gcd   def check ( pat , txt ) : M = len ( pat ) N = len ( txt ) res = 0 for i in range ( N - M + 1 ) : j = 0 while j < M : if ( txt [ i + j ] != pat [ j ] ) : break j += 1 if ( j == M ) : res += 1 j = 0 return res for _ in range ( it ( ) ) : n = it ( ) s = input ( ) l = ' abacaba ' k = check ( l , s ) NEW_LINE


import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Random ; import java . util . StringTokenizer ;   public class Main { private static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ;   public static void main ( String [ ] args ) throws FileNotFoundException {

import java . util . Arrays ; import java . util . Scanner ;   public class practice { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < m ; i ++ ) { int from = input . nextInt ( ) - 1 ; int to = input . nextInt ( ) - 1 ; int value = input . nextInt ( ) ; arr [ from ] += value ; arr [ to ] -= value ; } Arrays . sort ( arr ) ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] > 0 ) break ; total += arr [ i ] ; } System . out . println ( Math . abs ( total ) ) ; }   }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . HashMap ; import java . util . Map ; import java . util . StringTokenizer ;    public class Main {   public static void main ( String [ ] args ) throws IOException {   BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer stk = new StringTokenizer ( in . readLine ( ) ) ;   int n = Integer . parseInt ( stk . nextToken ( ) ) ; int m = Integer . parseInt ( stk . nextToken ( ) ) ;   int arr [ ] = new int [ n + 1 ] ; Arrays . fill ( arr , 0 ) ; for ( int i = 0 ; i < m ; i ++ ) { stk = new StringTokenizer ( in . readLine ( ) ) ; int a = Integer . parseInt ( stk . nextToken ( ) ) ; int b = Integer . parseInt ( stk . nextToken ( ) ) ; int c = Integer . parseInt ( stk . nextToken ( ) ) ; arr [ a ] += c ; arr [ b ] -= c ; } long ans = 0 ; for ( int i = 0 ; i < n + 1 ; i ++ ) { if ( arr [ i ] > 0 ) ans += arr [ i ] ; } System . out . println ( ans ) ; } }

import java . util . Scanner ;   public class B376 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int [ ] [ ] D = new int [ N ] [ N ] ; int M = in . nextInt ( ) ; for ( int m = 0 ; m < M ; m ++ ) { int from = in . nextInt ( ) - 1 ; int to = in . nextInt ( ) - 1 ; int amount = in . nextInt ( ) ; D [ from ] [ to ] = amount ; D [ to ] [ from ] = - amount ; } for ( int n = 0 ; n < N ; n ++ ) { int pos = 0 ; int neg = 0 ; while ( true ) { while ( pos < N && D [ pos ] [ n ] <= 0 ) pos ++ ; if ( pos == N ) break ; while ( neg < N && D [ neg ] [ n ] >= 0 ) neg ++ ; if ( neg == N ) break ; int transfer = Math . min ( D [ pos ] [ n ] , - D [ neg ] [ n ] ) ; D [ pos ] [ n ] -= transfer ; D [ n ] [ pos ] += transfer ; D [ neg ] [ n ] += transfer ; D [ n ] [ neg ] -= transfer ; D [ pos ] [ neg ] += transfer ; D [ neg ] [ pos ] -= transfer ; } } int answer = 0 ; for ( int from = 0 ; from < N ; from ++ ) { for ( int to = from + 1 ; to < N ; to ++ ) { answer += Math . abs ( D [ from ] [ to ] ) ; } } System . out . println ( answer ) ; }   }

n , m = map ( int , input ( ) . split ( ) ) arr = [ 0 ] * n for i in range ( m ) : a , b , c = map ( int , input ( ) . split ( ) ) a -= 1 b -= 1 arr [ b ] += c arr [ a ] -= c s = 0 for e in arr : if e < 0 : s += - e print ( s ) NEW_LINE

from sys import stdina , b = map ( int , stdin . readline ( ) . split ( ) ) ; z = [ 0 ] * afor _ in " ▁ " * b : u , v , w = map ( int , stdin . readline ( ) . split ( ) ) ; z [ u - 1 ] += w ; z [ v - 1 ] -= wprint ( sum ( max ( 0 , z [ i ] ) for i in range ( a ) ) ) NEW_LINE

from collections import defaultdict   n , m = map ( int , input ( ) . split ( ) ) s = defaultdict ( lambda : 0 ) for i in range ( m ) : a , b , c = map ( int , input ( ) . split ( ) ) s [ a ] -= c s [ b ] += c   print ( sum ( i for i in s . values ( ) if i > 0 ) ) NEW_LINE

from collections import defaultdictn , m = list ( map ( int , input ( ) . split ( ) ) ) friends_money = defaultdict ( int ) for friend in range ( 1 , n + 1 ) : friends_money [ friend ] for i in range ( m ) : f1 , f2 , money = list ( map ( int , input ( ) . split ( ) ) ) friends_money [ f1 ] = friends_money [ f1 ] - money friends_money [ f2 ] = friends_money [ f2 ] + money debt = 0 for money in friends_money . values ( ) : if money < 0 : debt = debt + abs ( money ) print ( debt ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) )   debts = [ 0 ] * ( n + 1 )     for i in range ( m ) : a , b , debt = map ( int , input ( ) . split ( ) ) debts [ a ] -= debt debts [ b ] += debt     total = 0 for i in range ( n ) : if debts [ i + 1 ] > 0 : total += debts [ i + 1 ]   print ( total ) NEW_LINE


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

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class BusesBetweenCities { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int tA = Integer . parseInt ( st . nextToken ( ) ) ;   st = new StringTokenizer ( br . readLine ( ) ) ; int b = Integer . parseInt ( st . nextToken ( ) ) ; int tB = Integer . parseInt ( st . nextToken ( ) ) ;   String timing = br . readLine ( ) ;   int hrs = Integer . parseInt ( timing . substring ( 0 , 2 ) ) ; int mins = Integer . parseInt ( timing . substring ( 3 ) ) ;   int simDeparture = hrs * 60 + mins ; int simArrival = simDeparture + tA ;   int counter = 0 ; for ( int i = 300 ; i < 1440 ; i += b ) { int busDeparture = i ; int busArrival = i + tB ;   if ( busDeparture >= simArrival || simDeparture >= busArrival ) continue ; counter ++ ; }   pw . println ( counter ) ; pw . flush ( ) ; pw . close ( ) ; } }

f1 , t1 = [ int ( i ) for i in input ( ) . split ( " ▁ " ) ] f2 , t2 = [ int ( i ) for i in input ( ) . split ( " ▁ " ) ] time = [ str ( i ) for i in input ( ) . split ( " ▁ " ) ] time = time [ 0 ]   th , tm = time . split ( " : " ) th = int ( th ) tm = int ( tm )   NEW_LINE

import sys   a , ta = map ( int , input ( ) . split ( ) ) b , tb = map ( int , input ( ) . split ( ) ) h , m = map ( int , input ( ) . split ( ' : ' ) ) s , t = h * 60 + m , min ( h * 60 + m + ta , 24 * 60 ) ans = 0   for x in range ( 5 * 60 , 24 * 60 , b ) : if s < x + tb and t > x : ans += 1   print ( ans ) NEW_LINE

import sys   input = sys . stdin . readline     def gcd ( a , b ) : if a == 0 : return b return gcd ( b % a , a )     def lcm ( a , b ) : return ( a * b ) / gcd ( a , b )   def main ( ) : a , ta = map ( int , input ( ) . split ( ) ) b , tb = map ( int , input ( ) . split ( ) ) hh , mm = map ( int , input ( ) . split ( ' : ' ) ) secs = hh * 60 + mm - ( 5 * 60 - 1 ) curr = 0 i = 0 ans = 0 x1 = hh * 60 + mm y1 = x1 + ta for x2 in range ( 5 * 60 , 24 * 60 , b ) : y2 = x2 + tb x = max ( x1 , x2 ) y = min ( y1 , y2 ) if ( x < y ) : ans += 1 print ( ans )           return   if __name__ == " _ _ main _ _ " : main ( )   NEW_LINE


import java . awt . * ; 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 ; import java . security . cert . TrustAnchor ;   public class A { public static PrintWriter out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; static long MOD = ( long ) ( 1e9 + 7 ) ;

import java . util . * ;   public class CodeForces1082B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; String s = input . next ( ) ; int cs = 0 , max = 0 , cg = 0 , res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' G ' ) { max ++ ; cg ++ ; } else { cs = cg ; cg = 0 ; } res = Math . max ( res , cs + cg + 1 ) ; } System . out . println ( Math . min ( res , max ) ) ; } }

n = int ( input ( ) )     t = input ( )       pre = [ ] suff = [ ]   if t [ 0 ] == ' G ' : pre . append ( 1 ) else : pre . append ( 0 )   if t [ - 1 ] == ' G ' : suff . append ( 1 ) else : suff . append ( 0 )             for i in range ( 1 , n ) : if t [ i ] == ' G ' : pre . append ( 1 + pre [ - 1 ] ) else : pre . append ( 0 )     u = n - 1 - i if t [ u ] == ' G ' : suff . append ( suff [ - 1 ] + 1 ) else : suff . append ( 0 )   suff = suff [ : : - 1 ]   g = t . count ( ' G ' )         ans = 0   for i in range ( n ) : if t [ i ] == ' S ' : if 0 < i < n - 1 : a = pre [ i - 1 ] + suff [ i + 1 ] elif i == 0 : a = suff [ i + 1 ] else : a = pre [ i - 1 ] NEW_LINE

import mathn = int ( input ( ) ) s = input ( ) l = [ 0 ] prev = " G " for i in range ( n ) : if ( s [ i ] == prev ) : l [ - 1 ] += 1 else : prev = s [ i ] l . append ( 1 ) ans = 0 h = s . count ( " G " ) for i in range ( 0 , len ( l ) , 2 ) : if ( l [ i ] != h ) : ans = max ( ans , l [ i ] + 1 ) else : ans = max ( ans , l [ i ] )   gg = [ ] for i in range ( 0 , len ( l ) - 2 , 2 ) : if ( l [ i + 1 ] == 1 ) : gg . append ( [ l [ i ] , l [ i + 2 ] ] )         for i in gg : if ( sum ( i ) != h ) : ans = max ( ans , sum ( i ) + 1 ) else : ans = max ( ans , sum ( i ) ) print ( ans ) NEW_LINE

n = int ( input ( ) ) s = input ( ) if s . count ( " G " ) == 0 : print ( 0 ) exit ( ) b = [ ] c = 1 s = s [ s . find ( " G " ) : ] n = len ( s ) for i in range ( 1 , n ) : if s [ i ] == s [ i - 1 ] : c += 1 else : b . append ( c ) c = 1 b . append ( c ) ans = 0 n = len ( b ) for i in range ( 0 , n , 2 ) : ans = max ( ans , b [ i ] ) g = ( len ( b ) - 1 ) // 2 + 1 if g > 1 : for i in range ( 0 , n , 2 ) : ans = max ( ans , b [ i ] + 1 ) for i in range ( 1 , n , 2 ) : if b [ i ] == 1 and i < n - 1 : if g > 2 : ans = max ( ans , b [ i - 1 ] + b [ i + 1 ] + 1 ) else : ans = max ( ans , b [ i - 1 ] + b [ i + 1 ] ) print ( ans ) NEW_LINE

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


import java . io . BufferedReader ; import java . io . * ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . * ; import java . math . * ; 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 ; } } public static void main ( String args [ ] ) throws Exception { FastReader sc = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int t = 1 ;

import java . lang . StringBuilder ; import java . io . BufferedReader ; import java . io . DataInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Deque ; import java . util . HashMap ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; import java . util . Stack ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String a = in . nextLine ( ) ; String z , v , m ; int x = a . indexOf ( " + " ) ; int y = a . indexOf ( " = " ) ; z = a . substring ( 0 , x ) ; v = a . substring ( x + 1 , y ) ; m = a . substring ( y + 1 , a . length ( ) ) ; if ( z . length ( ) + v . length ( ) == m . length ( ) ) { System . out . println ( a ) ; } else if ( z . length ( ) + 1 + v . length ( ) == m . length ( ) - 1 && m . length ( ) - 1 > 0 ) { a = ' | ' + a ; System . out . println ( a . substring ( 0 , a . length ( ) - 1 ) ) ; } else if ( z . length ( ) - 1 + v . length ( ) == m . length ( ) + 1 && z . length ( ) - 1 > 0 ) { a += ' | ' ; System . out . println ( a . substring ( 1 , a . length ( ) ) ) ; } else if ( z . length ( ) + v . length ( ) - 1 == m . length ( ) + 1 && v . length ( ) - 1 > 0 ) { v = v . substring ( 1 , v . length ( ) ) ; m += ' | ' ; System . out . println ( z + " + " + v + " = " + m ) ; } else System . out . println ( " Impossible " ) ;   } }

import java . lang . StringBuilder ; import java . io . BufferedReader ; import java . io . DataInputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Deque ; import java . util . HashMap ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; import java . util . Stack ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String a = in . nextLine ( ) ; String z , v , m ; int x = a . indexOf ( " + " ) ; int y = a . indexOf ( " = " ) ; z = a . substring ( 0 , x ) ; v = a . substring ( x + 1 , y ) ; m = a . substring ( y + 1 , a . length ( ) ) ; if ( z . length ( ) + v . length ( ) == m . length ( ) ) { System . out . println ( a ) ; } else if ( z . length ( ) + 1 + v . length ( ) == m . length ( ) - 1 && m . length ( ) > 0 ) { a = ' | ' + a ; System . out . println ( a . substring ( 0 , a . length ( ) - 1 ) ) ; } else if ( z . length ( ) - 1 + v . length ( ) == m . length ( ) + 1 && z . length ( ) - 1 > 0 ) { a += ' | ' ; System . out . println ( a . substring ( 1 , a . length ( ) ) ) ; } else if ( z . length ( ) + v . length ( ) - 1 == m . length ( ) + 1 && v . length ( ) - 1 > 0 ) { v = v . substring ( 1 , v . length ( ) ) ; m += ' | ' ; System . out . println ( z + " + " + v + " = " + m ) ; } else System . out . println ( " Impossible " ) ;   } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . next ( ) ; char x = ' | ' , y = ' + ' , z = ' = ' ; long a = 0 , b = 0 , c = 0 , p = 0 , e = 0 ; int i ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == y ) { p ++ ; } else if ( s . charAt ( i ) == z ) { e ++ ; } else if ( s . charAt ( i ) == x && p == 0 && e == 0 ) { a ++ ; } else if ( s . charAt ( i ) == x && p > 0 && e == 0 ) { b ++ ; } else if ( s . charAt ( i ) == x && p > 0 && e > 0 ) { c ++ ; } } if ( a + b == c ) { System . out . println ( s ) ; } else if ( Math . abs ( ( a + b ) - c ) == 2 ) { if ( a + b > c ) { if ( a > b && a > 1 ) a -- ; else b -- ; c ++ ; } else { a ++ ; c -- ; } for ( i = 0 ; i < a ; i ++ ) System . out . print ( " | " ) ; System . out . print ( " + " ) ; for ( i = 0 ; i < b ; i ++ ) System . out . print ( " | " ) ; System . out . print ( " = " ) ; for ( i = 0 ; i < c ; i ++ ) System . out . print ( " | " ) ; System . out . print ( " \n " ) ; } else { System . out . println ( " Impossible " ) ; } } }

from collections import Counterimport stringimport mathimport sysdef array_int ( ) : return [ int ( i ) for i in sys . stdin . readline ( ) . split ( ) ] def vary ( number_of_variables ) : if number_of_variables == 1 : return int ( sys . stdin . readline ( ) ) if number_of_variables >= 2 : return map ( int , sys . stdin . readline ( ) . split ( ) ) def makedict ( var ) : return dict ( Counter ( var ) ) mod = 100000007 s = input ( ) x = y = n = 0 t = s . find ( ' + ' ) tt = s . find ( ' = ' ) x = s . count ( ' | ' , 0 , t ) y = s . count ( ' | ' , t + 1 , tt ) n = s . count ( ' | ' , tt + 1 , len ( s ) ) if x + y == n : print ( s ) elif x + 1 + y == n - 1 : print ( ' | ' * ( x + 1 ) + ' + ' + ' | ' * y + ' = ' + ' | ' * ( n - 1 ) ) elif x - 1 + y == n + 1 : if x != 1 : print ( ' | ' * ( x - 1 ) + ' + ' + ' | ' * y + ' = ' + ' | ' * ( n + 1 ) ) elif y > 1 : print ( ' | ' * ( x ) + ' + ' + ' | ' * ( y - 1 ) + ' = ' + ' | ' * ( n + 1 ) )   else : print ( ' Impossible ' ) else :   print ( ' Impossible ' )                                                                                NEW_LINE

s = input ( )   A = 0 B = 0 C = 0 i = 0 while ( s [ i ] != ' + ' ) : A += 1 i += 1 i += 1 while ( s [ i ] != ' = ' ) : B += 1 i += 1 C = len ( s ) - A - B - 2 sep = " | " if A + B != C and abs ( A + B - C ) != 2 : res = " Impossible " elif A + B == C : res = selif A + B == C + 2 and A != 1 : res = s [ 1 : ] + " | " elif A + B == C + 2 and A == 1 : res = " { } + { } = { } " . format ( sep * A , sep * ( B - 1 ) , sep * ( C + 1 ) ) elif A + B == C - 2 : res = " | " + s [ : - 1 ] print ( res ) NEW_LINE

str1 = input ( ) str = str1 . split ( ' = ' ) ans = str [ 0 ] . split ( ' + ' ) r = len ( ans [ 0 ] ) + len ( ans [ 1 ] ) if r - len ( str [ 1 ] ) != 0 and r - len ( str [ 1 ] ) != - 2 and r - len ( str [ 1 ] ) != 2 : print ( " Impossible " ) else : a = len ( ans [ 0 ] ) b = len ( ans [ 1 ] ) c = len ( str [ 1 ] ) if r - c == 2 : if a > 1 : a -= 1 else : b -= 1 c += 1 elif r - c == - 2 : a += 1 c -= 1 print ( a * ' | ' + ' + ' + b * ' | ' + ' = ' + c * ' | ' ) NEW_LINE


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Bouncing {   public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; long copy = n ; long bn = 0 ; while ( copy >= 10 ) { bn *= 10 ; bn += 9 ; copy /= 10 ;

import java . util . * ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; long n = input . nextLong ( ) ;   long a = ( long ) Math . pow ( 10 , ( long ) Math . log10 ( n ) ) - 1 ; long b = n - a ; int sum = 0 ;   while ( a > 0 ) { sum += a % 10 ; a /= 10 ; }   while ( b > 0 ) { sum += b % 10 ; b /= 10 ; } System . out . println ( sum ) ; } }

n = int ( input ( ) )     def sum_of_digits ( numer ) : numer = str ( numer ) summ = 0 for digit in numer : summ += int ( digit ) return summ     if n < 10 : print ( n ) else : len_num = len ( str ( n ) ) - 1 num_1 = int ( len_num * "9" ) num_2 = n - num_1 NEW_LINE

def countsum ( s ) : l = list ( map ( int , list ( s ) ) ) return sum ( l ) t = int ( input ( ) ) if ( t > 9 ) : u = '9' * ( len ( str ( t ) ) - 1 ) print ( countsum ( u ) + countsum ( str ( t - int ( u ) ) ) ) elif ( t <= 9 ) : print ( t ) NEW_LINE

def maxSum ( a , b ) : s1 = 0 s2 = 0 for i in a : s1 = s1 + int ( i ) for i in b : s2 = s2 + int ( i ) print ( s1 + s2 ) returntry : n = input ( ) a = str ( int ( n [ 0 ] ) - 1 ) for i in range ( len ( n ) - 1 ) : a = a + "9" b = str ( int ( n ) - int ( a ) ) maxSum ( a , b ) except : pass NEW_LINE

n = int ( input ( ) ) res = 0 carrier = 0 while n > 9 : target = ( n % 10 ) - carrier if target == 9 : res += 9 carrier = 0 elif target == - 1 : res += 9 carrier = 1 else : res += 10 + target carrier = 1 n //= 10   print ( res + n - carrier ) NEW_LINE

def ds ( n ) : s = str ( n ) k = 0 for i in s : k += int ( i ) return kn = int ( input ( ) ) k = len ( str ( n ) ) - 1 m = str ( n ) s = " " print ( s ) if m [ 0 ] == "1" : s = "9" * kelse : s = "1" + "9" * kif s == " " : s = "0" x = n - int ( s ) print ( ds ( x ) + ds ( int ( s ) ) )         NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Long n = sc . nextLong ( ) ; ArrayList < Long > p = new ArrayList < Long > ( ) ; Long i = 2L , c = 0L ; outer : while ( i * i <= n ) { if ( n % i == 0 ) while ( n % i == 0 ) { c ++ ; p . add ( i ) ; n /= i ; if ( c == 3 ) { System . out . printf ( " % d \n % d " , 1 , p . get ( 0 ) * p . get ( 1 ) ) ; return ; } } i ++ ; } if ( n >= 2 ) { p . add ( i ) ; c ++ ; } if ( c == 2 ) System . out . println ( 2 ) ; else { if ( c <= 1 ) System . out . printf ( " % d \n % d " , 1 , 0 ) ; else System . out . printf ( " % d \n % d " , 1 , p . get ( 0 ) * p . get ( 1 ) ) ; } } static class FastScanner { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ; String next ( ) { while ( ! st . hasMoreTokens ( ) ) try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = nextInt ( ) ; return a ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } } }

import java . io . * ; import java . util . ArrayList ;   public class Main { static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { long q = input . nextLong ( ) ; if ( q == 1 || isPrime ( q ) ) { pr . print ( "1 \n " + 0 ) ; pr . flush ( ) ; return ; } ArrayList list = new ArrayList ( ) ; for ( long i = 2 ; i * i <= q ; i ++ ) { while ( q % i == 0 ) { list . add ( i ) ; q /= i ; } if ( list . size ( ) >= 2 ) break ; } if ( q > 1 ) list . add ( q ) ; if ( list . size ( ) == 2 ) { pr . println ( 2 ) ; } else { pr . print ( "1 \n " + Long . valueOf ( String . valueOf ( list . get ( 0 ) ) ) * Long . valueOf ( String . valueOf ( list . get ( 1 ) ) ) ) ; } pr . flush ( ) ; } public static boolean isPrime ( long x ) { if ( x <= 3 ) { return x > 1 ; } for ( long i = 2 ; i * i <= x ; i ++ ) { if ( x % i == 0 ) { return false ; } } return true ; } static class input { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StreamTokenizer in = new StreamTokenizer ( br ) ; static String next ( ) throws IOException { return br . readLine ( ) ; } static int nextInt ( ) throws IOException { in . nextToken ( ) ; return ( int ) in . nval ; } static long nextLong ( ) throws IOException { in . nextToken ( ) ; return ( long ) in . nval ; } static double nextDouble ( ) throws IOException { in . nextToken ( ) ; return in . nval ; } } }

import java . util . Arrays ; import java . util . Scanner ;   public class Main {    public static void main ( String [ ] args ) {   long n ; Scanner in = new Scanner ( System . in ) ; n = in . nextLong ( ) ; int num = 0 ; long [ ] ns = new long [ 50 ] ; long temp = n ; for ( long i = 2 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { while ( n % i == 0 ) { ns [ num ] = i ; num ++ ; n /= i ; } if ( num >= 2 ) break ; } } if ( n != temp && n != 1 ) ns [ num ++ ] = n ; if ( num != 2 ) { System . out . println ( 1 ) ; System . out . println ( ns [ 1 ] * ns [ 0 ] ) ; } else System . out . println ( 2 ) ;   }     }

q = int ( input ( ) ) if q == 1 : print ( 1 ) print ( 0 ) else : ls = [ ] for i in range ( 2 , int ( q ** 0.5 ) + 1 ) : while q % i == 0 : ls . append ( i ) q = q // i if q > 1 : ls . append ( q ) if len ( ls ) > 2 : print ( 1 ) print ( ls [ 0 ] * ls [ 1 ] ) elif len ( ls ) == 2 : print ( 2 ) else : print ( 1 ) print ( 0 ) NEW_LINE

def factorize ( n ) : p = 2 r = [ ] while p * p <= n : while n % p == 0 : r . append ( p ) n //= p p += 1 if n > 1 : r . append ( n ) return r     q = int ( input ( ) ) f = factorize ( q ) if len ( f ) <= 1 : print ( 1 ) print ( 0 ) elif len ( f ) == 2 : print ( 2 ) else : print ( 1 ) print ( f [ 0 ] * f [ 1 ] ) NEW_LINE

def factorize ( q ) : factors = [ ] k = 2 while k * k <= q : while q % k == 0 : q //= k factors . append ( k ) k += 1 if q > 1 : factors . append ( q ) return factors     q = int ( input ( ) ) factors = factorize ( q ) if len ( factors ) <= 1 : print ( "1" ) print ( "0" ) elif len ( factors ) > 2 : print ( "1" ) print ( factors [ 0 ] * factors [ 1 ] ) else : print ( "2" ) NEW_LINE

import sysinput = sys . stdin . readlinedef read ( ) : return map ( int , input ( ) . split ( ) ) n = int ( input ( ) ) i = 2 ans , ans2 = 1 , 0 while i * i <= n : if n % i == 0 : ans += 1 ans2 = i n //= i break i += 1 while i * i <= n : if n % i == 0 : ans = 1 ans2 *= i n //= i break i += 1 if ans == 1 : print ( ans ) print ( ans2 ) else : print ( ans ) NEW_LINE


import java . io . * ; import java . util . * ; public class p741a { static class Pair { public int a , b ; public Pair ( int a , int b ) { this . a = a ; this . b = b ; } } public static long hcf ( long a , long b ) { if ( a == 0 || b == 0 ) return a + b ; return hcf ( b , a % b ) ; } public static long lcm ( long a , long b ) { return ( a * b ) / hcf ( a , b ) ; } public static void main ( String [ ] args ) throws IOException { InputReader in = new InputReader ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) - 1 ; long rep [ ] = new long [ n ] ; Arrays . fill ( rep , - 1 ) ; long lc = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int v = i ; for ( int j = 0 ; j < n ; j ++ ) { v = arr [ v ] ; if ( v == i ) { long val = ( ( j + 1 ) % 2 != 0 ) ? ( j + 1 ) : ( j + 1 ) / ( int ) 2 ;

from math import gcdn = int ( input ( ) ) arr = map ( int , input ( ) . split ( ) ) arr = list ( map ( lambda x : x - 1 , arr ) )   res = 1f or i in range ( n ) : p , k = 0 , i for j in range ( n ) : k = arr [ k ] if k == i : p = j break if k != i : print ( - 1 ) exit ( ) p += 1 if p % 2 == 0 : p

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 ;

def gcd ( a , b ) : if b == 0 : return a return gcd ( b , a % b ) def lcm ( a , b ) : return a * b / gcd ( a , b ) def dfs ( sad , num , posjeceno ) : """ if ▁ sad = = a [ sad ] -1 ▁ and ▁ posjeceno ! = [ 0 ] * n : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ return ▁ ( -10 , ▁ [ ] ) """ posjeceno [ sad ] = 1 if posjeceno [ a [ sad ] - 1 ] == 1 : return ( num + 1 , posjeceno ) return dfs ( a [ sad ] - 1 , num + 1 , posjeceno )   def trazi ( oznaka ) : global memo if memo [ oznaka ] == [ ] : memo [ oznaka ] = dfs ( oznaka , 0 , [ 0 ] * n ) return memo [ oznaka ] n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = set ( ) brojac = nmemo = [ [ ] for e in range ( n ) ] while brojac > - 1 : brojac -= 1 if memo [ brojac ] == [ ] : trazi ( brojac ) """ if ▁ memo [ brojac ] [0 ] = = - 10 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ d = - 10 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ break """ l = memo [ brojac ] [ 1 ] for w in range ( n ) : if l [ w ] == 1 : if trazi ( w ) [ 1 ] != l : d = - 10 break if d == - 10 : break vrati , l = trazi ( brojac ) if vrati % 2 == 0 : d . add ( float ( vrati / 2 ) ) else : d . add ( float ( vrati ) ) if d == - 10 : print ( - 1 ) else : sol = 1 for r in d : sol = lcm ( sol , r ) print ( int ( sol ) ) NEW_LINE

from math import gcddef lcm ( a , b ) : return a * b // gcd ( a , b ) n = int ( input ( ) ) A = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) g = { } for i in range ( 1 , n + 1 ) : g [ A [ i ] ] = iif len ( g ) != n : print ( - 1 ) else : clc = 1 for i in g : x = g [ i ] cnt = 1 while x != i : x = g [ x ] cnt += 1 if cnt % 2 == 0 : cnt //= 2 clc = lcm ( clc , cnt ) print ( clc ) NEW_LINE

from math import gcdn = int ( input ( ) ) arr = map ( int , input ( ) . split ( ) ) arr = list ( map ( lambda x : x - 1 , arr ) )   res = 1 for i in range ( n ) : p , k = 0 , i for j in range ( n ) : k = arr [ k ] if k == i : p = j break if k != i : print ( - 1 ) exit ( ) p += 1 if p % 2 == 0 : p //= 2 res = res * p // gcd ( res , p ) print ( res ) NEW_LINE

def read_int ( ) : return int ( input ( ) )     def read_ints ( ) : return map ( int , input ( ) . split ( ' ▁ ' ) )     def gcd ( x , y ) : return x if y == 0 else gcd ( y , x % y )     n = read_int ( ) a = list ( read_ints ( ) ) vis = [ False for i in range ( n ) ] loop = 0 ok = Truefor i in range ( n ) : if vis [ i ] : continue current = i length = 0 while not vis [ current ] : vis [ current ] = True current = a [ current ] - 1 length += 1 if current != i : ok = False print ( - 1 ) break if length % 2 == 0 : length //= 2 if loop == 0 : loop = length else : loop = loop * length // gcd ( loop , length ) if ok : print ( loop ) NEW_LINE


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { try ( Scanner input = new Scanner ( System . in ) ) { String [ ] pointA = input . nextLine ( ) . split ( " ▁ " ) ; String [ ] pointB = input . nextLine ( ) . split ( " ▁ " ) ; String [ ] pointC = input . nextLine ( ) . split ( " ▁ " ) ; discoverWay ( pointA , pointB , pointC ) ; } }   private static void discoverWay ( String [ ] pointA , String [ ] pointB , String [ ] pointC ) { long xa = Long . parseLong ( pointA [ 0 ] ) ; long ya = Long . parseLong ( pointA [ 1 ] ) ; long xb = Long . parseLong ( pointB [ 0 ] ) ; long yb = Long . parseLong ( pointB [ 1 ] ) ; long xc = Long . parseLong ( pointC [ 0 ] ) ; long yc = Long . parseLong ( pointC [ 1 ] ) ; long [ ] BA = { ( long ) ( xa - xb ) , ( long ) ( ya - yb ) } ; long [ ] BC = { ( long ) ( xc - xb ) , ( long ) ( yc - yb ) } ; long BAx = BA [ 0 ] ; long BAy = BA [ 1 ] ;   long BCx = BC [ 0 ] ; long BCy = BC [ 1 ] ; long direction = ( long ) ( BAx * BCy ) - ( long ) ( BCx * BAy ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class WhereDoITurn {

import java . util . * ;   public class WhereDoITurn {   public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; Vec a = new Vec ( scan . nextLong ( ) , scan . nextLong ( ) ) ; Vec b = new Vec ( scan . nextLong ( ) , scan . nextLong ( ) ) ; Vec c = new Vec ( scan . nextLong ( ) , scan . nextLong ( ) ) ; Vec ab = b . sub ( a ) ; Vec bc = c . sub ( b ) ; long cp = ab . cprod ( bc ) ; if ( cp == 0 ) System . out . println ( " TOWARDS " ) ; else if ( cp > 0 ) System . out . println ( " LEFT " ) ; else System . out . println ( " RIGHT " ) ; } static class Vec { long x ; long y ; public Vec ( long x , long y ) { this . x = x ; this . y = y ; } public Vec sub ( Vec v ) { return new Vec ( x - v . x , y - v . y ) ; } public long cprod ( Vec v ) { return x * v . y - y * v . x ; } }   }

import sysinput = sys . stdin . readlinel = input ( ) . split ( ) xa = int ( l [ 0 ] ) ya = int ( l [ 1 ] ) l = input ( ) . split ( ) xb = int ( l [ 0 ] ) yb = int ( l [ 1 ] ) l = input ( ) . split ( ) xc = int ( l [ 0 ] ) yc = int ( l [ 1 ] ) num1 = ( xb - xa ) * ( xc - xb ) + ( yb - ya ) * ( yc - yb ) if ( num1 != 0 ) : print ( " TOWARDS " ) quit ( ) num1 = ( yc - yb ) num2 = xb - xaif ( num1 != 0 ) : if ( num1 * num2 > 0 ) : print ( ' LEFT ' ) else : print ( " RIGHT " ) else : num1 = ( xc - xb ) num2 = yb - ya if ( num1 != 0 ) : if ( num1 * num2 < 0 ) : print ( ' LEFT ' ) else : print ( " RIGHT " ) NEW_LINE

import math   a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) )   xab = b [ 0 ] - a [ 0 ] NEW_LINE

a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = list ( map ( int , input ( ) . split ( ) ) ) position = ( ( b [ 0 ] - a [ 0 ] ) * ( c [ 1 ] - a [ 1 ] ) - ( b [ 1 ] - a [ 1 ] ) * ( c [ 0 ] - a [ 0 ] ) ) if position < 0 : print ( " RIGHT " ) elif position == 0 : print ( " TOWARDS " ) else : print ( " LEFT " ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a , b , c , d , e , f , g ; a = sc . nextInt ( ) ; Vector < Integer > x = new Vector < Integer > ( ) ; g = 0 ; e = 0 ; f = 0 ; d = 0 ; for ( b = 0 ; b < a ; b ++ ) { c = sc . nextInt ( ) ; if ( c == 0 ) { x . add ( c ) ; } if ( c == 100 ) { x . add ( c ) ; } if ( c >= 1 && c <= 9 ) { if ( d == 0 ) { d ++ ; x . add ( c ) ; } } if ( c >= 10 && c <= 99 ) { if ( c % 10 == 0 ) { if ( e == 0 ) { e ++ ; x . add ( c ) ; } } else { if ( d == 0 && f == 0 && e == 0 ) { f ++ ; x . add ( c ) ; g = x . size ( ) ; } } } } if ( e >= 1 && f >= 1 ) { x . remove ( g - 1 ) ; f -- ; } else if ( d >= 1 && f >= 1 ) { x . remove ( g - 1 ) ; } System . out . println ( x . size ( ) ) ; for ( b = 0 ; b < x . size ( ) ; b ++ ) { System . out . print ( x . get ( b ) + " ▁ " ) ; } System . out . println ( ) ; } }

import java . io . * ; import java . util . * ;   public class Test { static BufferedReader reader ; static StringTokenizer tokenizer ; static PrintWriter writer ;   static int nextInt ( ) throws IOException { return Integer . parseInt ( nextToken ( ) ) ; }   static long nextLong ( ) throws IOException { return Long . parseLong ( nextToken ( ) ) ; }   static double nextDouble ( ) throws IOException { return Double . parseDouble ( nextToken ( ) ) ; }   static String nextToken ( ) throws IOException { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } static String nexts ( ) throws IOException { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; String s = " " ; while ( tokenizer . hasMoreTokens ( ) ) { s += tokenizer . nextElement ( ) + " ▁ " ; } return s ; }

import java . util . Scanner ;   public class StrangeAddition {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int sum = 0 ; int c = 0 ; String s = " " ; int checkSingle = - 1 ; int checkDouble = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == 0 || arr [ i ] == 100 ) { c ++ ; s = s + arr [ i ] + " ▁ " ; } else if ( arr [ i ] % 10 == 0 && checkDouble == - 1 ) { c ++ ; checkDouble = 0 ; s = s + arr [ i ] + " ▁ " ; } else if ( arr [ i ] / 10 == 0 && checkSingle == - 1 ) { c ++ ; checkSingle = 0 ; s = s + arr [ i ] + " ▁ " ; } } if ( checkDouble == - 1 && checkSingle == - 1 ) { for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] != 0 && arr [ i ] != 100 ) { c ++ ; s = s + arr [ i ] + " ▁ " ; break ; } } } if ( c == 0 ) { System . out . println ( 1 ) ; System . out . println ( arr [ 0 ] ) ; return ; } System . out . println ( c ) ; System . out . println ( s ) ; }   private static boolean add ( int a , int b ) { while ( a % 10 == 0 || b % 10 == 0 ) { if ( a == 0 || b == 0 ) return true ; a = a / 10 ; b = b / 10 ; } return false ; }   }

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) t = [ ] flag = 0 if ( 0 in arr ) : t . append ( 0 ) if ( 100 in arr ) : t . append ( 100 ) for i in range ( n ) : if ( arr [ i ] > 0 and arr [ i ] < 10 ) : t . append ( arr [ i ] ) flag = 1 breakfor i in range ( n ) : if ( arr [ i ] % 10 == 0 and arr [ i ] > 0 and arr [ i ] < 100 ) : t . append ( arr [ i ] ) flag = 1 breakif ( flag == 0 ) : for i in range ( n ) : if ( arr [ i ] > 10 and arr [ i ] < 100 ) : t . append ( arr [ i ] ) breakprint ( len ( t ) ) for i in range ( len ( t ) ) : print ( t [ i ] , end = " ▁ " ) NEW_LINE

k = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) r = 0 e = 0 l . sort ( ) q0 = 0 q1 = 0 q11 = 0 q10 = 0 q100 = 0 r1 = [ ] for i in range ( k ) : if ( l [ i ] == 0 ) : q0 = q0 + 1 elif ( l [ i ] > 0 and l [ i ] < 10 ) : q1 = q1 + 1 elif ( l [ i ] == 100 ) : q100 = q100 + 1 elif ( l [ i ] % 10 == 0 ) : q10 = q10 + 1 elif ( l [ i ] > 10 and l [ i ] % 10 != 0 ) : q11 = q11 + 1 if ( q0 > 0 ) : r1 . append ( 0 ) r = r + 1 if ( q100 > 0 ) : r1 . append ( 100 ) r = r + 1 temp = rif ( q10 > 0 ) : for i in range ( k ) : if ( l [ i ] > 9 and l [ i ] < 100 and l [ i ] % 10 == 0 ) : r = r + 1 e = 1 r1 . append ( l [ i ] ) breaktemp1 = rif ( q1 > 0 ) : for i in range ( k ) : if ( l [ i ] > 0 and l [ i ] < 10 ) : r = r + 1 r1 . append ( l [ i ] ) breakif ( r == 0 or ( temp1 == r and q11 > 0 and ( q0 > 0 or q100 > 0 ) and e == 0 ) ) : for i in range ( k ) : if ( l [ i ] > 10 and l [ i ] % 10 != 0 ) : r = r + 1 r1 . append ( l [ i ] ) breakprint ( r ) for i in range ( r ) : print ( r1 [ i ] , end = " ▁ " ) NEW_LINE

from collections import defaultdictn = int ( input ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] ans = [ ] d = defaultdict ( bool ) for i in arr : if ( i == 0 ) : ans . append ( i ) elif ( i % 100 == 0 and not d [ 100 ] ) : d [ 100 ] = True ans . append ( i ) elif ( i % 10 == 0 and not d [ 10 ] ) : d [ 10 ] = True ans . append ( i ) if ( d [ 10 ] ) : for i in arr : if ( '0' not in str ( i ) and len ( str ( i ) ) == 1 ) : ans . append ( i ) breakelse : for i in arr : if ( '0' not in str ( i ) ) : ans . append ( i ) breakprint ( len ( ans ) ) print ( * ans )   NEW_LINE

k = int ( input ( ) )   zlist2 = [ int ( d ) for d in input ( ) . split ( ) ] zlist2 . sort ( )   if k == 1 : print ( k ) print ( str ( zlist2 [ 0 ] ) ) exit ( )   res = [ ]   dicti = { } dicti [ 0 ] = Falsedicti [ 100 ] = Truedicti [ '0-10' ] = Falsedicti [ '10-100' ] = False   cnt = 0 for x in zlist2 : if x == 0 : res . append ( '0' ) elif x == 100 : res . append ( '100' ) if 0 < x < 10 and dicti [ '0-10' ] == False : cnt += 1 res . append ( str ( x ) ) dicti [ '0-10' ] = True if 9 < x < 100 and dicti [ '10-100' ] == False and x % 10 == 0 : cnt += 1 res . append ( str ( x ) ) dicti [ '10-100' ] = True   if cnt == 0 : for y in zlist2 : if 9 < y < 100 and y % 10 != 0 : res . append ( str ( y ) ) breakprint ( len ( res ) ) print ( ' ▁ ' . join ( res ) )   NEW_LINE


import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int n = in . nextInt ( ) ; int existed = 0 ; int max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; existed += x ; max = Math . max ( max , x ) ; } System . out . println ( n * max - existed ) ; }   }

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

import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Integer [ ] arr = new Integer [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . sort ( arr ) ; int max = Collections . max ( Arrays . asList ( arr ) ) ; int sum = 0 ; for ( int i = 0 ; i < n - 1 ; i ++ ) { sum += max - arr [ i ] ; } System . out . println ( sum ) ; } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < Integer > ar = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { ar . add ( sc . nextInt ( ) ) ; } int max = Collections . max ( ar ) ; int ans = 0 ; for ( int j = 0 ; j < n ; j ++ ) { ans = ans + max - ar . get ( j ) ; } System . out . println ( ans ) ; } }

a = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) k = max ( l ) l = sorted ( l ) p = 0 for i in range ( len ( l ) - 1 ) : p += ( k - l [ i ] ) print ( p ) NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) maxnum = max ( arr ) total = 0 for num in arr : total += ( abs ( maxnum - num ) ) print ( total ) NEW_LINE

from collections import Counterimport math   def solve ( ) : n = int ( input ( ) ) array = list ( map ( int , input ( ) . split ( ) ) ) count = 0 array . sort ( )   for i in range ( n - 1 ) : count += abs ( array [ i ] - array [ n - 1 ] )   return count   print ( solve ( ) ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) print ( n * max ( a ) - sum ( a ) ) NEW_LINE

peoples = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) count = 0 max_ = max ( arr ) for num in arr : count += max_ - numprint ( count ) NEW_LINE


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 ) ; BQueueAtTheSchool solver = new BQueueAtTheSchool ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class BQueueAtTheSchool { public void solve ( int testNumber , FastScanner fs , PrintWriter out ) { int n = fs . nextInt ( ) , t = fs . nextInt ( ) ; char [ ] q = fs . next ( ) . toCharArray ( ) ; for ( int tt = 0 ; tt < t ; tt ++ ) { for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( q [ i ] == ' B ' && q [ i + 1 ] == ' G ' ) { q [ i ] = ' G ' ; q [ i + 1 ] = ' B ' ; i ++ ; } } } String ans = new String ( q ) ; 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 ( ) ) ; }   } }

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

import java . io . * ; import java . util . Scanner ; public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; if ( System . getProperty ( " ONLINE _ JUDGE " ) == null ) { try { System . setOut ( new PrintStream ( new FileOutputStream ( " output . txt " ) ) ) ; sc = new Scanner ( new File ( " input . txt " ) ) ; } catch ( Exception e ) { } }

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int n = in . nextInt ( ) ; int t = in . nextInt ( ) ; in . nextLine ( ) ; String s = in . nextLine ( ) ;   char [ ] a = s . toCharArray ( ) ;   for ( int step = 0 ; step < t ; step ++ ) { for ( int i = 0 ; i < a . length - 1 ; i ++ ) { if ( a [ i ] == ' B ' && a [ i + 1 ] == ' G ' ) { a [ i ] = ' G ' ; a [ i + 1 ] = ' B ' ; i ++ ; } } }   System . out . println ( new String ( a ) ) ; } }

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

def ret ( inp ) : lst = inp . copy ( ) for i in range ( len ( inp ) ) : if inp [ i ] == ' G ' : j = i - 1 k = t if j >= 0 and inp [ j ] == ' B ' : lst [ j + 1 ] = ' B ' lst [ j ] = ' G ' return lstn , t = [ int ( x ) for x in input ( ) . split ( ) ] inp = input ( ) inp_lst = [ ] for c in inp : inp_lst . append ( c ) for c in range ( t ) : inp_lst = ret ( inp_lst )   lst_str = " " . join ( inp_lst ) print ( lst_str ) NEW_LINE

import sys   input = sys . stdin . readline   sys . setrecursionlimit ( 10 ** 5 + 1 )   n , t = map ( int , input ( ) . split ( ) ) s = list ( input ( ) )   for i in range ( t ) : j = 1 while j < n : if s [ j - 1 ] == " B " and s [ j ] == " G " : s [ j - 1 ] , s [ j ] = " G " , " B " j += 1 j += 1 print ( * s , sep = " " ) NEW_LINE

import copy   n , t = list ( map ( int , input ( ) . split ( ) ) ) queue = list ( input ( ) ) bqueue = [ ' N ' for i in range ( n ) ]   while t > 0 : t -= 1   bqueue [ 0 ] = queue [ 0 ]   for i in range ( n - 1 ) : if queue [ i ] == " B " and queue [ i + 1 ] == " G " : bqueue [ i ] = " G " bqueue [ i + 1 ] = " B " else : if bqueue [ i ] == ' N ' : bqueue [ i ] = queue [ i ] bqueue [ i + 1 ] = queue [ i + 1 ]   queue = copy . deepcopy ( bqueue ) bqueue = [ ' N ' for i in range ( n ) ]   print ( " " . join ( queue ) ) NEW_LINE

x = input ( ) . split ( ) q = input ( ) newq = " " ans = " " for thing in q : newq += thing + " ▁ " newq = newq . split ( ) ppl = int ( x [ 0 ] ) time = int ( x [ 1 ] ) for second in range ( time ) : counter = 0 while counter < len ( newq ) - 1 : if newq [ counter ] == " B " and newq [ counter + 1 ] == " G " : newq [ counter ] , newq [ counter + 1 ] = newq [ counter + 1 ] , newq [ counter ] counter += 1 counter += 1 for thing in newq : ans += thingprint ( ans ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . * ;     public class B {   private static long INF = 2000000000000000000L , M = 1000000007 , MM = 998244353 ; private static int N = 0 ;   public static void process ( ) throws IOException {   long n = sc . nextLong ( ) , g = sc . nextLong ( ) , b = sc . nextLong ( ) ; long req = n / 2 ; if ( n % 2 == 1 ) req ++ ; long l = 1 , r = Integer . MAX_VALUE ; long ans = 1 ; while ( l <= r ) { long mid = ( l + r ) / 2 ; if ( mid * g >= req ) { ans = mid ; r = mid - 1 ; } else { l = mid + 1 ; } } long res = b * ( ans - 1 ) ; res += ( ans - 1 ) * g ; req -= ( ( ans - 1 ) * g ) ; res += req ; long max = max ( res , n ) ; System . out . println ( max ) ;   }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class NationalProject { private static final FastReader in = new FastReader ( ) ; private static final PrintWriter pw = new PrintWriter ( System . out ) ;   public static void main ( String [ ] args ) { Solver sol = new Solver ( ) ; int tt = 1 ; for ( int qq = in . nextInt ( ) ; tt <= qq ; tt ++ ) sol . solve ( tt ) ; pw . close ( ) ; }   private static class Solver { public void solve ( int testCase ) { long n = Long . parseLong ( in . next ( ) ) , g = Long . parseLong ( in . next ( ) ) , b = Long . parseLong ( in . next ( ) ) ;

import java . io . BufferedInputStream ; import java . math . BigDecimal ; import java . util . Scanner ;    public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int n = 0 ; long half = 0 , gd = 0 , bd = 0 ; while ( n < N ) { long length = sc . nextLong ( ) ; long g = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long time = 0 ;   if ( length % 2 == 1 ) { half = length / 2 + 1 ; } else half = length / 2 ;   if ( half % g == 0 ) { time = ( half / g ) * ( b + g ) - b ; } else { time = ( half / g ) * ( b + g ) + half % g ; }   time = Math . max ( time , length ) ; System . out . println ( time ) ; n ++ ;    } } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; while ( t -- != 0 ) { long n = input . nextInt ( ) ; long g = input . nextInt ( ) ; long b = input . nextInt ( ) ; long half = ( n + 1 ) / 2 ; long ans = half / g * ( g + b ) ; if ( half % g == 0 ) { ans -= b ; } else { ans += half % g ; } System . out . println ( ( long ) Math . max ( ans , n ) ) ; } } }

import matht = int ( input ( ) ) anss = [ ] while t : n , a , b = map ( int , input ( ) . split ( ) ) ans = 0 if a >= b : ans = n else : m = math . ceil ( n / 2 ) if m % a == 0 : ans = m + ( ( m // a ) - 1 ) * b else : ans = m + ( m // a ) * b anss . append ( max ( ans , n ) ) t = t - 1 for i in anss : print ( i ) NEW_LINE

import mathfor _ in range ( int ( input ( ) ) ) : n , g , b = map ( int , input ( ) . split ( ) ) if ( n <= g ) : print ( n ) else :   total = g + b y = math . ceil ( n / 2 ) d = y // g ans = d * total work = y if ( y - d * g > 0 ) : ans = ans + y - d * g else : ans = ans - b print ( max ( ans , n ) ) NEW_LINE

from sys import stdin , stdoutinput = stdin . readline def main ( ) : q = int ( input ( ) ) for i in range ( q ) : n , g , b = map ( int , input ( ) . split ( ) ) num = ( n + 1 ) // 2 temp = ( num - 1 ) // g print ( max ( n , temp * ( g + b ) + num - temp * g ) ) main ( ) NEW_LINE

t = int ( input ( ) ) for i in range ( t ) : n , g , b = map ( int , input ( ) . split ( ) ) q = n // 2 + n % 2 ans = 0 if ( q % g == 0 ) : ans = q // g ans = ( ans * g ) + ( ( ans - 1 ) * b ) else : ans = q // g + 1 ans = ( ( ans - 1 ) * ( g + b ) ) + ( q % g ) print ( max ( n , ans ) ) NEW_LINE


# include < cstdio > # include < iostream > # include < string > # include < cstring > # include < algorithm > # include < queue > # include < cmath > # include < fstream > # include < stack > # include < set > using namespace std ; typedef long long LL ; const int maxn = 1e6 + 100 ; const int maxm = 1e6 + 100 ; const int INF = 1 << 30 ; struct Edge { int u , v , w , f , next ; } e [ maxm ] , tmp [ maxm ] ; int head [ maxn ] , tot = 1 ; void addEdge ( int u , int v , int f , int w ) { e [ ++ tot ] . u = u ; e [ tot ] . v = v ; e [ tot ] . f = f ; e [ tot ] . w = w ; e [ tot ] . next = head [ u ] ; head [ u ] = tot ;

import java . util . * ; import java . io . * ;   public class CFA { BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; private static final long MOD = 1000L * 1000L * 1000L + 7 ; private static final int [ ] dx = { 0 , - 1 , 0 , 1 } ; private static final int [ ] dy = { 1 , 0 , - 1 , 0 } ; private static final String yes = " Yes " ; private static final String no = " No " ;   void solve ( ) {

from sys import stdin , stdoutfrom NEW_LINE collections NEW_LINE import dequeimport NEW_LINE sys   graph = [ ] NEW_LINE n = 0 NEW_LINE current_graph = [ ] NEW_LINE pair_f = [ ] NEW_LINE pair_a = [ ] NEW_LINE dist = [ ]     NEW_LINE def dfs ( s ) : global pair_f NEW_LINE global pair_a NEW_LINE global dist   if s != 0 : for NEW_LINE a in current_graph [ s ] : NEW_LINE if dist [ pair_a [ a ] ] == ( dist [ s ] + 1 ) : if NEW_LINE dfs ( pair_a [ a ] ) : pair_a [ a ] = s NEW_LINE pair_f [ s ] = a NEW_LINE return True   dist [ s ] = 10 ** 4 + 1 NEW_LINE return False   return True     NEW_LINE def bfs ( ) : global dist NEW_LINE   q = deque ( ) NEW_LINE inf = 10 ** 4 + 1 NEW_LINE for f in range ( 1 , n + 1 ) : NEW_LINE

import osimport NEW_LINE sysfrom NEW_LINE io NEW_LINE import BytesIO , IOBase NEW_LINE


import java . util . * ;   public class Practise {   static int [ ] [ ] dp ;    public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; boolean tt = true ; if ( b == a ) { System . out . println ( 0 ) ; tt = false ; } if ( b > a ) { long temp = a ; a = b ; b = temp ; } int c = 0 ; while ( a % 8 == 0 && ( a / 8 ) >= b ) {   a = a / 8 ; c ++ ; if ( a == b ) { System . out . println ( c ) ; tt = false ; break ; } } if ( tt ) { while ( a % 4 == 0 && ( a / 4 ) >= b ) {   a = a / 4 ; c ++ ; if ( a == b ) { System . out . println ( c ) ; tt = false ; break ; } }   } if ( tt ) { while ( a % 2 == 0 && ( a / 2 ) >= b ) {   a = a / 2 ; c ++ ; if ( a == b ) { System . out . println ( c ) ; tt = false ; break ; } } } if ( tt ) System . out . println ( - 1 ) ;                       t -- ; }    } }

import java . util . Scanner ;   public class _0618JohnnyandAncientComputer {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int cases = sc . nextInt ( ) ; while ( cases > 0 ) { long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; if ( a < b ) { long temp = a ; a = b ; b = temp ; } long val = a / b ; if ( a == b ) { System . out . println ( 0 ) ; } else if ( val % 2 != 0 || a % b != 0 ) { System . out . println ( - 1 ) ; } else { int count = 0 ; a : { while ( val > 1 ) { if ( val % 8 == 0 ) { count ++ ; val = val / 8 ; } else if ( val % 4 == 0 ) { val = val / 4 ; count ++ ; } else if ( val % 2 == 0 ) { val = val / 2 ; count ++ ; } else { break a ; } } } if ( val == 1 ) { System . out . println ( count ) ; } else { System . out . println ( - 1 ) ; } } cases -- ; } }   }

import math     a = int ( input ( ) ) for i in range ( a ) : c , d = map ( int , input ( ) . split ( ) ) c , d = min ( c , d ) , max ( c , d ) num = 0 ; while ( c != d ) : if ( math . floor ( d / c ) == d // c and ( d // c ) % 8 == 0 ) : c *= 8 num += 1 elif ( math . floor ( d / c ) == d // c and d // c % 4 == 0 ) : c *= 4 num += 1 elif ( math . floor ( d / c ) == d // c and d // c % 2 == 0 ) : c *= 2 num += 1 else : num = - 1 break print ( num ) NEW_LINE

import sys   input = sys . stdin . buffer . readline   t = int ( input ( ) ) for _ in range ( t ) : a , b = map ( int , input ( ) . split ( ) ) a , b = max ( a , b ) , min ( a , b )   div , mod = divmod ( a , b ) if mod != 0 : print ( - 1 ) continue   count = 0   for factor in [ 8 , 4 , 2 ] : while div % factor == 0 : count += 1 div //= factor   print ( count if div == 1 else - 1 ) NEW_LINE

t = int ( input ( ) ) while t > 0 : digits = [ int ( i ) for i in input ( ) . split ( ) ] a = digits [ 0 ] b = digits [ 1 ] if a == b : print ( 0 ) else : if a < b : NEW_LINE

from sys import stdin , stdoutfrom math import floor , gcd , fabs , factorial , fmod , sqrt , inf , logfrom collections import defaultdict as dd , dequefrom heapq import merge , heapify , heappop , heappush , nsmallestfrom bisect import bisect_left as bl , bisect_right as br , bisect mod = pow ( 10 , 9 ) + 7 mod2 = 998244353 def inp ( ) : return stdin . readline ( ) . strip ( ) def iinp ( ) : return int ( inp ( ) ) def out ( var , end = " \n " ) : stdout . write ( str ( var ) + " \n " ) def outa ( * var , end = " \n " ) : stdout . write ( ' ▁ ' . join ( map ( str , var ) ) + end ) def lmp ( ) : return list ( mp ( ) ) def mp ( ) : return map ( int , inp ( ) . split ( ) ) def smp ( ) : return map ( str , inp ( ) . split ( ) ) def l1d ( n , val = 0 ) : return [ val for i in range ( n ) ] def l2d ( n , m , val = 0 ) : return [ l1d ( m , val ) for j in range ( n ) ] def remadd ( x , y ) : return 1 if x % y else 0 def ceil ( a , b ) : return ( a + b - 1 ) // b def isprime ( x ) : if x <= 1 : return False if x in ( 2 , 3 ) : return True if x % 2 == 0 : return False for i in range ( 3 , int ( sqrt ( x ) ) + 1 , 2 ) : if x % i == 0 : return False return True for _ in range ( int ( inp ( ) ) ) : a , b = mp ( ) if a == b : print ( 0 ) elif a < b : c = 0 while ( a < b ) : a *= 2 c += 1 print ( ceil ( c , 3 ) if a == b else - 1 ) else : c = 0 while ( a > b and a % 2 == 0 ) : a //= 2 c += 1 print ( ceil ( c , 3 ) if a == b else - 1 ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   import java . util . * ; import javafx . util . Pair ;   public class Main { static long mod = ( long ) ( 1e9 + 7 ) ; public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; String s = input . next ( ) ; long ans = 0 ; long temp = 0 ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == ' b ' ) { temp ++ ; } else { ans += temp ; temp *= 2 ; ans = ans % mod ; temp = temp % mod ; } } 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 ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }

import java . lang . reflect . Array ; import java . text . CollationElementIterator ; import java . util . * ; import java . util . Map . Entry ; import java . io . * ; import java . lang . Math . * ; import java . math . BigInteger ;   import static java . lang . Math . * ; import static java . lang . System . * ; import static java . util . Arrays . fill ; import static java . util . Arrays . spliterator ; public class ContestMain implements Runnable { private static Reader in = new Reader ( ) ; private static StringBuilder ans = new StringBuilder ( ) ; private static long MOD = ( long ) ( 1e9 + 7 ) ; private static final int N = ( int ) ( 2e5 + 7 ) ;

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

import math as mtimport sys , stringfrom collections import Counter , defaultdictinput = sys . stdin . readline MOD = 1000000007 PI = 3.14159265358979323 I = lambda : int ( input ( ) ) S = lambda : input ( ) M = lambda : map ( int , input ( ) . split ( ) ) Ms = lambda : map ( str , input ( ) . split ( ) ) ARR = lambda : list ( map ( int , input ( ) . split ( ) ) ) def solve ( ) : s = S ( ) ans , count_b = 0 , 0 for i in range ( len ( s ) - 1 , - 1 , - 1 ) : if s [ i ] == ' b ' : count_b += 1 else : ans += count_b ans %= MOD count_b *= 2 count_b %= MOD print ( ans )   tc = 1 NEW_LINE

import sys , os , iodef rs ( ) : return sys . stdin . readline ( ) . rstrip ( ) def ri ( ) : return int ( sys . stdin . readline ( ) ) def ria ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def ws ( s ) : sys . stdout . write ( s + ' \n ' ) def wi ( n ) : sys . stdout . write ( str ( n ) + ' \n ' ) def wia ( a ) : sys . stdout . write ( ' ▁ ' . join ( [ str ( x ) for x in a ] ) + ' \n ' ) import math , datetime , functools , itertools , operator , bisect , fractions , statisticsfrom collections import deque , defaultdict , OrderedDict , Counterfrom fractions import Fractionfrom decimal import Decimalfrom sys import stdoutfrom heapq import heappush , heappop , heapify , _heapify_max , _heappop_max , nsmallest , nlargest NEW_LINE

a = input ( ) mod = 1000000007 ans = 0 count_a = 0 for i in a : if i == ' a ' : count_a += 1 else : ans += ( pow ( 2 , count_a , mod ) - 1 ) % modprint ( ans % mod ) NEW_LINE

MOD = int ( 1e9 ) + 7   def solve ( ) : s = input ( ) r = c = 0 for i in range ( len ( s ) - 1 , - 1 , - 1 ) : if s [ i ] == ' b ' : c += 1 else : r += c c = ( c * 2 ) % MOD   return r % MOD   print ( solve ( ) ) NEW_LINE

s = input ( ) a = 0 m = 10 ** 9 + 7 t = 0 for i in range ( len ( s ) ) : if s [ ~ i ] == ' a ' : a = ( a + t ) % m t = ( t * 2 ) % m else : t += 1 print ( a )   NEW_LINE


import java . util . Scanner ;   public class Test10 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int dishCount = sc . nextInt ( ) ; int desk = sc . nextInt ( ) ; int dishR = sc . nextInt ( ) ;   double angle = 360.0 / ( dishCount * 2 ) ; double minR = dishR / Math . sin ( Math . toRadians ( angle ) ) + dishR ;   if ( dishCount == 1 ) { if ( desk >= dishR ) { System . out . println ( " YES " ) ; return ; } else { System . out . println ( " NO " ) ; return ; } } if ( dishCount == 2 ) { if ( 2 * dishR <= desk ) { System . out . println ( " YES " ) ; return ; } else { System . out . println ( " NO " ) ; return ; } }   if ( desk >= minR ) { System . out . println ( " YES " ) ; return ; } else { System . out . println ( " NO " ) ; return ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Main { private static class InputReader { private BufferedReader br = null ; private StringTokenizer tokenizer = null ;   public InputReader ( InputStream is ) { super ( ) ; this . br = new BufferedReader ( new InputStreamReader ( is ) ) ; }   public String nextLine ( ) { try { return br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw new RuntimeException ( e ) ; } }   public String next ( ) { for ( ; tokenizer == null || ! tokenizer . hasMoreTokens ( ) ; ) { tokenizer = new StringTokenizer ( nextLine ( ) ) ; } return tokenizer . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } }   public static void main ( String [ ] args ) { InputReader in = new InputReader ( System . in ) ;   int n = in . nextInt ( ) ; double R = in . nextDouble ( ) ; double r = in . nextDouble ( ) ; if ( n > 1 ) { if ( R >= r / Math . sin ( Math . toRadians ( 360.0 / n / 2 ) ) + r ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else { if ( R >= r || n <= 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } }

import java . util . Scanner ;   public class Test3 {   public static void main ( String [ ] args ) { int n ; double R , r ; double eps = 1e-10 ; double PI = Math . acos ( - 1 ) ; Scanner in = new Scanner ( System . in ) ; while ( in . hasNext ( ) ) { n = in . nextInt ( ) ; R = in . nextInt ( ) ; r = in . nextInt ( ) ; if ( n == 1 ) { if ( R >= r ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; continue ; } double tmp = Math . asin ( r / ( R - r ) ) ; if ( PI / tmp - n > - eps ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; }   } }

import java . util . Scanner ;   public class APeng { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; double n = in . nextInt ( ) ; double R = in . nextInt ( ) ; double r = in . nextInt ( ) ; if ( R < r ) { System . out . println ( " NO " ) ; return ; } double cos = Math . sqrt ( Math . pow ( R , 2 ) - 2 * R * r ) / ( R - r ) ; if ( Math . PI / Math . acos ( cos ) >= n || n == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

import java . util . Scanner ;   public class Solution20200410 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; double R = scanner . nextDouble ( ) ; double r = scanner . nextDouble ( ) ;   double angle = 360.0 / ( n * 2 ) ; double minR = r / Math . sin ( Math . toRadians ( angle ) ) + r ; if ( n == 1 ) { if ( R >= r ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else if ( n == 2 ) { if ( R >= r * 2 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else { if ( R >= minR ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } } }

import math [ n , R , r ] = [ int ( x ) for x in input ( ) . split ( ) ]   m = Noneif r > R : m = 0 elif 2 * r > R : m = 1 elif 2 * r == R : m = 2 else : sina = r / ( R - r ) vysek = math . asin ( sina ) m = math . pi / vysek   if n <= m + 0.000000001 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

import mathn , R , r = map ( int , input ( ) . split ( ) ) if r > R : print ( " NO " ) elif 2 * r > R and n == 1 : print ( " YES " ) elif 2 * r > R and n != 1 : print ( " NO " ) elif 2 * r <= R and n <= 2 : print ( " YES " ) else : d = math . asin ( r / ( R - r ) ) m = math . pi / d if abs ( round ( m ) - m ) < math . pow ( 10 , - 12 ) : m = round ( m ) else : m = math . floor ( m ) if m >= n : print ( " YES " ) else : print ( " NO " )   NEW_LINE

import math     def solve ( ) :   n , R , r = [ int ( x ) for x in input ( ) . split ( ' ▁ ' ) ] e = 10 ** ( - 7 )   if n == 1 : return r <= R elif n == 2 : return 2 * r <= R else : return r < ( R - r ) * math . sin ( math . pi / n ) + e     if solve ( ) : print ( " YES " ) else : print ( " NO " )   NEW_LINE


import java . util . Scanner ;   public class Main { private static final Scanner in = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; int k1 = in . nextInt ( ) ; int [ ] s1 = genNums ( k1 ) ; int k2 = in . nextInt ( ) ; int [ ] s2 = genNums ( k2 ) ;   int [ ] result1 = new int [ n ] ; int [ ] result2 = new int [ n ] ;   for ( int i = 0 ; i < k1 ; i ++ ) { result1 [ n - s1 [ i ] ] = 1 ; } for ( int i = 0 ; i < k2 ; i ++ ) { result2 [ n - s2 [ i ] ] = 1 ; } result2 [ 0 ] = - 1 ; result1 [ 0 ] = - 1 ;   boolean changed = true ; while ( changed ) { changed = false ; for ( int i = n - 1 ; i > 0 ; i -- ) {   changed = stateChanged ( n , k1 , s1 , result1 , result2 , changed , i ) ;   changed = stateChanged ( n , k2 , s2 , result2 , result1 , changed , i ) ; } }   printRound ( n , result1 ) ; System . out . println ( ) ; printRound ( n , result2 ) ; }

f = lambda : list ( map ( int , input ( ) . split ( ) ) ) [ 1 : ] n = int ( input ( ) ) s , p , q = [ ] , [ ] , [ ] for x in [ 0 , 1 ] : r = f ( ) s . append ( r ) t = [ len ( r ) ] * n t [ 0 ] = 0 p . append ( t ) q . append ( ( x , 0 ) ) while q : x , i = q . pop ( ) y = 1 - x for d in s [ y ] : j = ( i - d ) % n if p [ y ] [ j ] < 1 : continue p [ y ] [ j ] = - 1 for d in s [ x ] : k = ( j - d ) % n if p [ x ] [ k ] < 1 : continue p [ x ] [ k ] -= 1 if p [ x ] [ k ] == 0 : q . append ( ( x , k ) ) for x in [ 0 , 1 ] : print ( * [ [ ' Lose ' , ' Loop ' , ' Win ' ] [ min ( q , 1 ) ] for q in p [ x ] [ 1 : ] ] ) NEW_LINE

class T : h = ( ' Lose ' , ' Loop ' , ' Win ' ) def __init__ ( t ) : t . s = list ( map ( int , input ( ) . split ( ) ) ) [ 1 : ] t . p = [ len ( t . s ) ] * n t . p [ 0 ] = 0 def f ( t , i ) : for d in t . s : j = ( i - d ) % n if t . p [ j ] > 0 : yield j def g ( t ) : print ( * [ t . h [ min ( q , 1 ) ] for q in t . p [ 1 : ] ] ) n = int ( input ( ) ) r , m = T ( ) , T ( ) q = [ ( r , m , 0 ) , ( m , r , 0 ) ] while q : x , y , i = q . pop ( ) for j in y . f ( i ) : y . p [ j ] = - 1 for k in x . f ( j ) : x . p [ k ] -= 1 if not x . p [ k ] : q . append ( ( x , y , k ) ) r . g ( ) m . g ( ) NEW_LINE

RESULT = [ ' Lose ' , ' Loop ' , ' Win ' ]   class Player ( object ) : """ docstring ▁ for ▁ Player """ def __init__ ( self ) : super ( Player , self ) . __init__ ( ) self . a = list ( map ( int , input ( ) . split ( ) ) ) [ 1 : ] self . f = [ len ( self . a ) ] * n self . f [ 0 ] = 0   def prev ( self , i ) : for x in self . a : if self . f [ ( i - x ) % n ] > 0 : yield ( i - x ) % n   def print_result ( self ) : print ( * [ RESULT [ min ( x , 1 ) ] for x in self . f [ 1 : ] ] )   n = int ( input ( ) ) a , b = Player ( ) , Player ( ) q = [ ( a , b , 0 ) , ( b , a , 0 ) ] while q : x , y , i = q . pop ( ) for j in y . prev ( i ) : y . f [ j ] = - 1 for k in x . prev ( j ) : x . f [ k ] -= 1 if x . f [ k ] == 0 : q . append ( ( x , y , k ) )   a . print_result ( ) b . print_result ( ) NEW_LINE


import java . util . * ; import java . io . * ; public class A { static FastReader in = new FastReader ( ) ; static final Random random = new Random ( ) ; static long mod = 1000000007L ; public static void main ( String args [ ] ) throws IOException { int t = 1 ;

import java . util . ArrayList ; import java . util . Scanner ;   public class BottleOpener { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   int n = scan . nextInt ( ) ; int [ ] open = new int [ 1000 ] ; ArrayList < Integer > same = new ArrayList < > ( ) ;   for ( int i = 0 ; i < n ; i ++ ) { int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ;   if ( same . contains ( a ) ) { open [ b - 1 ] += 1000 ; open [ a - 1 ] -- ; }   if ( a == b ) { if ( ! same . contains ( b ) ) { same . add ( b ) ; if ( open [ a - 1 ] % 1000 > 0 ) { open [ a - 1 ] -= open [ a - 1 ] % 1000 ; } } } else open [ b - 1 ] += 1000 ;   open [ a - 1 ] ++ ; }   int countC = 0 ; for ( int i = 0 ; i < 1000 ; i ++ ) { if ( open [ i ] > 0 && open [ i ] < 1000 ) countC += open [ i ] ; } System . out . println ( countC ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   import static java . lang . Math . log ; import static java . lang . Math . min ;   public class First {   public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; int t ;

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ;   int arr1 [ ] = new int [ n ] ; int arr2 [ ] = new int [ n ] ;   int ans = n ;   for ( int i = 0 ; i < n ; i ++ ) {   arr1 [ i ] = sc . nextInt ( ) ; arr2 [ i ] = sc . nextInt ( ) ;   }   int b = - 5 ;   for ( int i = 0 ; i < n ; i ++ ) {   for ( int j = 0 ; j < n ; j ++ ) {   if ( arr1 [ i ] == arr2 [ j ] && i != j ) { ans -- ; break ; }   }   }   System . out . println ( ans ) ;   }   }

n = int ( input ( ) ) al = [ ] bl = [ ] for i in range ( n ) : a , b = [ int ( x ) for x in input ( ) . split ( ) ] al . append ( a ) bl . append ( b ) count = 0 for i , bot in enumerate ( al ) : if bot in bl [ : i ] + bl [ i + 1 : ] : count += 1   print ( n - count ) NEW_LINE

n = int ( input ( ) ) a = [ ] b = [ ] cnt = 0 carry = dict ( ) for i in range ( n ) : ai , bi = [ int ( x ) for x in input ( ) . split ( ) ] a . append ( ai ) b . append ( bi ) if bi in carry . keys ( ) : carry [ bi ] += 1 else : carry [ bi ] = 1 for i in range ( n ) : carry [ b [ i ] ] -= 1 if ( a [ i ] not in carry . keys ( ) or carry [ a [ i ] ] == 0 ) : cnt += 1 carry [ b [ i ] ] += 1 print ( cnt ) NEW_LINE

n = int ( input ( ) ) count = 0 a = [ ] b = [ ] for i in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) a . append ( x ) b . append ( y ) v = b . copy ( ) for i in range ( n ) : del v [ i ] if not a [ i ] in v : count += 1 v = b . copy ( ) print ( count ) NEW_LINE

n = int ( input ( ) ) nn = nnnn = nb = [ ] o = [ ] c = 0 while n > 0 : n -= 1 bt , ot = map ( int , input ( ) . split ( ) ) b . append ( bt ) o . append ( ot ) for i in range ( 0 , nnn ) : if b [ i ] == o [ i ] and o . count ( o [ i ] ) == 1 : nn += 1 o = set ( o ) for i in o : temp = b . count ( i ) nn -= temp   print ( nn ) NEW_LINE

from collections import defaultdictn = int ( input ( ) ) l = [ ] d = defaultdict ( int ) ans = 0 for i in range ( n ) : a , b = map ( int , input ( ) . split ( ) ) l . append ( [ a , b ] ) d [ b ] += 1 for i in range ( n ) : if l [ i ] [ 1 ] == l [ i ] [ 0 ] and d [ l [ i ] [ 1 ] ] == 1 or l [ i ] [ 0 ] not in d : ans += 1 print ( ans ) 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 ; } } public static void main ( String [ ] args ) throws Exception { FastReader sc = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;

import java . util . * ; import java . io . * ; import java . math . * ;   public class First { public static void process ( ) throws IOException { int n = ni ( ) ; int a [ ] = new int [ n + 1 ] ; int b [ ] = new int [ n + 1 ] ; HashMap < Integer , Long > map = new HashMap < Integer , Long > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = ni ( ) ; b [ i ] = i - a [ i ] ; } long ans = 1l ; for ( int i = 1 ; i <= n ; i ++ ) { if ( map . isEmpty ( ) || ! map . containsKey ( b [ i ] ) ) { long x = a [ i ] ; map . put ( b [ i ] , x ) ; ans = Math . max ( ans , x ) ; } else { long x = map . get ( b [ i ] ) ; x += a [ i ] ; ans = Math . max ( ans , x ) ; map . put ( b [ i ] , x ) ; } } pn ( ans ) ;     }     static AnotherReader sc ; static PrintWriter out ; public static void main ( String [ ] args ) throws IOException { out = new PrintWriter ( System . out ) ; sc = new AnotherReader ( ) ; boolean oj = true ;

import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Expedition { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] ar = new int [ n + 1 ] ; Map < Integer , Long > map = new HashMap < Integer , Long > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; int key = i - ar [ i ] ; if ( map . containsKey ( key ) ) { map . replace ( key , map . get ( key ) + ar [ i ] ) ; } else map . put ( key , ( long ) ar [ i ] ) ; } long max = 0 ; for ( Map . Entry < Integer , Long > entry : map . entrySet ( ) ) { max = Math . max ( max , entry . getValue ( ) ) ; } System . out . println ( ( long ) max ) ; } }

import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {   public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; HashMap < Long , Long > map = new HashMap < > ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextLong ( ) ; map . put ( i - a [ i ] , map . getOrDefault ( i - a [ i ] , 0L ) + a [ i ] ) ; } Long ans = Long . MIN_VALUE ; for ( Map . Entry < Long , Long > entry : map . entrySet ( ) ) { Long key = entry . getKey ( ) ; Long value = entry . getValue ( ) ; ans = Math . max ( ans , value ) ; } 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 ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) : arr [ i ] -= i arr [ i ] = [ arr [ i ] , i ] arr . sort ( ) ma = 0 s = arr [ 0 ] [ 0 ] + arr [ 0 ] [ 1 ] for i in range ( 1 , n ) : if ( arr [ i - 1 ] [ 0 ] != arr [ i ] [ 0 ] ) : ma = max ( s , ma ) s = arr [ i ] [ 0 ] + arr [ i ] [ 1 ] else : s += arr [ i ] [ 0 ] + arr [ i ] [ 1 ] ma = max ( ma , s ) print ( ma ) NEW_LINE

import sysn = int ( sys . stdin . readline ( ) ) l = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) )   val = [ 0 for i in range ( 800010 ) ] for i in range ( n ) : val [ ( i + 1 ) - l [ i ] + 400000 ] += l [ i ] print ( max ( val ) ) NEW_LINE

from math import * from sys import stdininput = stdin . readlinen , i = int ( input ( ) ) , 0 d = { } for x in list ( map ( int , input ( ) . split ( ) ) ) : d [ x - i ] = d . get ( x - i , 0 ) + x i += 1 print ( max ( d . values ( ) ) ) NEW_LINE

n = int ( input ( ) ) b = list ( map ( int , input ( ) . split ( ) ) ) l = [ [ ] for i in range ( 10 ** 6 ) ] d = [ b [ i ] - ( i + 1 ) for i in range ( n ) ] for i in range ( n ) : l [ d [ i ] ] . append ( b [ i ] ) ans = - 1 for i in range ( len ( l ) ) : if l [ i ] : ans = max ( ans , sum ( l [ i ] ) ) print ( ans ) NEW_LINE

import sysinput = sys . stdin . readline   n = int ( input ( ) ) b = [ int ( x ) for x in input ( ) . split ( ) ] c = [ 0 ] * ( 10 ** 6 ) for i in range ( n ) : c [ b [ i ] - i ] += b [ i ]   print ( max ( c ) ) NEW_LINE


import java . math . BigInteger ; import java . util . Scanner ;    public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; BigInteger b = BigInteger . valueOf ( sc . nextLong ( ) ) ; if ( b . mod ( BigInteger . valueOf ( 10 ) ) . compareTo ( ( BigInteger . valueOf ( 5 ) ) ) < 0 ) b = b . subtract ( b . mod ( BigInteger . valueOf ( 10 ) ) ) ; if ( b . mod ( BigInteger . valueOf ( 10 ) ) . compareTo ( ( BigInteger . valueOf ( 5 ) ) ) >= 0 ) b = b . add ( BigInteger . valueOf ( 10 ) . subtract ( b . mod ( BigInteger . valueOf ( 10 ) ) ) ) ; System . out . println ( b ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; System . out . println ( ( scan . nextLong ( ) + 5 ) / 10 * 10 ) ; } }

import java . util . * ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; System . out . println ( ( n % 10 < 5 ) ? n / 10 * 10 : ( n / 10 + 1 ) * 10 ) ; } }

import java . util . * ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int t = n % 10 ; System . out . println ( ( t >= 5 ) ? n + ( 10 - t ) : n - t ) ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; if ( num % 10 <= 5 ) num -= num % 10 ; else num += 10 - num % 10 ; System . out . println ( num ) ; } }

n = int ( input ( ) ) num_to_rem = n % 10 if num_to_rem >= 5 : print ( n - num_to_rem + 10 ) else : print ( n - num_to_rem ) NEW_LINE

n = input ( ) if n [ - 1 ] == '0' : print ( n ) elif n [ - 1 ] <= '5' : s = int ( n [ - 1 ] ) n = int ( n ) print ( n - s ) else : s = 10 - int ( n [ - 1 ] ) print ( int ( n ) + s )   NEW_LINE

try : n = int ( input ( ) ) if ( n % 10 < 6 ) : print ( n - n % 10 ) else : print ( n + ( 10 - n % 10 ) ) except : pass NEW_LINE

n = input ( ) num = int ( n ) x = list ( map ( int , n . strip ( ) ) ) y = list ( n . strip ( ) )     if len ( x ) == 1 and x != "5" : if x [ 0 ] > 5 : print ( 10 ) else : print ( 0 ) else : if int ( x [ - 1 ] ) < 5 : y [ - 1 ] = "0" print ( ' ' . join ( y ) )   else :   while ( n [ - 1 ] != "0" ) : num = num + 1 n = str ( num ) if n [ - 1 ] == "0" : print ( num ) NEW_LINE

n = int ( input ( ) ) if n % 10 == 0 : print ( n ) elif n % 10 <= 5 : print ( n - ( n % 10 ) ) else : print ( n + ( 10 - ( n % 10 ) ) ) NEW_LINE


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

import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static int oo = ( int ) 1e9 ;   public static void solve ( ) throws Exception { int n = f . ni ( ) ; int arr [ ] = new int [ n ] ;   for ( int i = 0 ; i < n ; ++ i ) arr [ i ] = f . ni ( ) ;   sort ( arr ) ; int ans = 0 ; for ( int i = 0 ; i + 1 < n ; i += 2 ) { ans += arr [ i + 1 ] - arr [ i ] ; } pn ( ans ) ; } public static void main ( String [ ] args ) throws Exception { if ( memory ) new Thread ( null , new Runnable ( ) { public void run ( ) { try { new Main ( ) . run ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( 1 ) ; } } } , " " , 1 << 28 ) . start ( ) ; else new Main ( ) . run ( ) ; } void run ( ) throws Exception { if ( System . getProperty ( " ONLINE _ JUDGE " ) == null ) { f = new FastScanner ( " " ) ; pw = new PrintWriter ( System . out ) ; } else { f = new FastScanner ( ) ; pw = new PrintWriter ( System . out ) ;

import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class temp4 { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static class Print { private final BufferedWriter bw ; public Print ( ) { bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; } public void print ( String str ) throws IOException { bw . append ( str ) ; } public void println ( String str ) throws IOException { print ( str ) ; bw . append ( " \n " ) ; } public void close ( ) throws IOException { bw . close ( ) ; } } public static void main ( String [ ] args ) throws IOException { FastReader scn = new FastReader ( ) ; Print pr = new Print ( ) ; int n = scn . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = scn . nextInt ( ) ; } Arrays . sort ( arr ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i += 2 ) { ans += arr [ i + 1 ] - arr [ i ] ; } System . out . println ( ans ) ; } }

import java . util . * ; import java . io . * ; public class B { public static void taskSolver ( FastReader sc ) { int n = sc . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int ans = 0 ; Arrays . sort ( arr ) ; for ( int i = 1 ; i <= n ; i += 2 ) { ans += Math . abs ( arr [ i ] - arr [ i - 1 ] ) ; } System . out . println ( ans ) ; } public static void main ( String args [ ] ) { FastReader sc = new FastReader ( ) ; taskSolver ( sc ) ; } public static long gcd ( long a , long b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . * ; public class MyClass { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; Arrays . sort ( arr ) ; long s = 0 ; for ( int i = 0 ; i < n ; i += 2 ) { s = s + arr [ i + 1 ] - arr [ i ] ; } System . out . println ( s ) ; } }

class Heap : def __init__ ( self , * data ) : self . arr = [ ] self . size = 0 if not data : return else : for item in data : self . insert ( item )   def __str__ ( self ) : return str ( self . arr )   def sift_up ( self , index ) : while index : parent = ( index - 1 ) // 2 if self . arr [ index ] < self . arr [ parent ] : self . arr [ index ] , self . arr [ parent ] = self . arr [ parent ] , self . arr [ index ] index = parent else : break   def sift_down ( self ) : if not self . size : return   index = 0 child_left = index * 2 + 1   while child_left < self . size : child_right = index * 2 + 2   if child_right >= self . size or self . arr [ child_left ] <= self . arr [ child_right ] : branch = child_left else : branch = child_right   if self . arr [ index ] < self . arr [ branch ] : return   self . arr [ index ] , self . arr [ branch ] = self . arr [ branch ] , self . arr [ index ] index = branch child_left = index * 2 + 1   def insert ( self , data ) : self . arr . append ( data ) self . size += 1 self . sift_up ( self . size - 1 )   def pop_min ( self ) : if not self . size : return self . arr [ 0 ] , self . arr [ - 1 ] = self . arr [ - 1 ] , self . arr [ 0 ] self . size -= 1 self . sift_down ( ) return self . arr . pop ( )     def heap_sort ( arr : list ) : heap = Heap ( * arr ) for i in range ( heap . size ) : arr [ i ] = heap . pop_min ( )     n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   heap_sort ( a )   ans = 0 for i in range ( 1 , len ( a ) , 2 ) : ans += a [ i ] - a [ i - 1 ]   print ( ans ) NEW_LINE

num = int ( input ( ) ) li = list ( map ( int , input ( ) . split ( ) ) ) li . sort ( ) a = 0 for i in range ( 0 , num , 2 ) : a += abs ( li [ i ] - li [ i + 1 ] ) print ( a ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) print ( sum ( a [ 1 : : 2 ] ) - sum ( a [ 0 : : 2 ] ) ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) c = 0 for i in range ( 1 , n , 2 ) : if a [ i - 1 ] != a [ i ] : c += ( a [ i ] - a [ i - 1 ] ) print ( c ) NEW_LINE