import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class A45 { public static void main ( String [ ] args ) throws IOException { BufferedReader inp = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int size = Integer . parseInt ( inp . readLine ( ) ) ; String [ ] s1 = inp . readLine ( ) . split ( " ▁ " ) ; long [ ] given = new long [ size ] ; long totalSum = 0 ; for ( int i = 0 ; i < size ; i ++ ) { given [ i ] = Integer . parseInt ( s1 [ i ] ) ; totalSum += given [ i ] ; } long each = totalSum / size ; long [ ] diff = new long [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { diff [ i ] = given [ i ] - each ; } long sum = Math . abs ( diff [ 0 ] ) ; long carry = diff [ 0 ] ; for ( int i = 1 ; i < size ; i ++ ) { sum += Math . abs ( diff [ i ] + carry ) ; carry = carry + diff [ i ] ; } System . out . println ( sum ) ; } }

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) )   k = sum ( arr ) // nmoves = 0   for i in range ( n - 1 ) : arr [ i + 1 ] += arr [ i ] - k moves += abs ( k - arr [ i ] ) print ( moves ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   need = sum ( a ) // n   ans = 0   from math import *   for i in range ( n - 1 ) : if ( a [ i ] <= need ) : a [ i + 1 ] -= need - a [ i ] else : a [ i + 1 ] += a [ i ] - need ans += abs ( a [ i ] - need )   print ( ans ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   t = 0 for i in range ( n ) : t += a [ i ]   t = t // ncnt = 0   for i in range ( n ) : if a [ i ] > t : a [ i + 1 ] += abs ( a [ i ] - t ) cnt += ( abs ( a [ i ] - t ) )   elif a [ i ] < t : a [ i + 1 ] -= abs ( a [ i ] - t ) cnt += ( abs ( a [ i ] - t ) )   print ( cnt ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) + [ 0 ] s = sum ( a ) // nd = 0 for i in range ( n ) : if a [ i ] > s : a [ i + 1 ] += abs ( a [ i ] - s ) else : a [ i + 1 ] -= abs ( a [ i ] - s ) d += abs ( a [ i ] - s ) print ( d ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class Matches { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( in . readLine ( ) ) ; String [ ] temp = in . readLine ( ) . split ( " ▁ " ) ; long c = 0 ; long [ ] pp = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int u = Integer . parseInt ( temp [ i ] ) ; c += u ; pp [ i ] = u ; } long h = c / n ; long y = 0 ; for ( int i = 0 ; i < pp . length - 1 ; i ++ ) { long u = pp [ i ] - h ; if ( u > 0 ) { pp [ i ] -= u ; pp [ i + 1 ] += u ; y += u ; } else if ( u < 0 ) { pp [ i + 1 ] = pp [ i + 1 ] - ( h - pp [ i ] ) ; y += ( h - pp [ i ] ) ; pp [ i ] = h ; } } System . out . println ( y ) ; } }


import java . io . * ; import java . util . * ; public class Balancer { static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ;   public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ;


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

def func ( a , b , prev ) : if a == 0 : if b == 0 : if prev == 0 : return 0 else : return - 1 else : return - 1   if a == 1 : if b == 0 : if prev == 0 or prev == 1 : return 1 - prev else : return - 1 elif b == 1 : if prev == 1 : return 1 else : return - 1 else : return - 1   if a == 2 : if b == 0 : if prev == 0 or prev == 2 : return 2 - prev else : return - 1 elif b == 2 : if prev == 2 : return 2 else : return - 1 else : return - 1   if a == 3 : if b == 0 : return 3 - prev elif b == 1 : if prev == 1 or prev == 3 : return 4 - prev else : return - 1 elif b == 2 : if prev == 2 or prev == 3 : return 5 - prev else : return - 1 else : if prev == 3 : return 3 else : return - 1     n = input ( ) arr = input ( ) brr = input ( ) arr = list ( arr . split ( " ▁ " ) ) brr = list ( brr . split ( " ▁ " ) )   n = int ( n ) for i in range ( n - 1 ) : arr [ i ] = int ( arr [ i ] ) brr [ i ] = int ( brr [ i ] )   for i in range ( 4 ) : a = arr [ 0 ] b = brr [ 0 ] t = list ( ) prev = i t . append ( prev ) pos = 1   for j in range ( 1 , n ) : prev = func ( a , b , prev ) t . append ( prev ) if prev == - 1 : pos = 0 break   if j == n - 1 : break a = arr [ j ] b = brr [ j ]   if pos == 1 : print ( " YES " ) for x in t : print ( x , end = " ▁ " ) exit ( )   print ( " NO " ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( 4 ) : c = [ - 1 ] * n c [ 0 ] = i for j in range ( n - 1 ) : if c [ j ] == - 1 : break for k in range ( 4 ) : if ( ( c [ j ] | k ) == a [ j ] and ( c [ j ] & k ) == b [ j ] ) : c [ j + 1 ] = k if - 1 not in c : print ( " YES " ) print ( * c ) exit ( 0 ) print ( " NO " ) NEW_LINE


import java . io . * ; import java . util . * ;   public class Task {   public static void main ( String [ ] args ) throws IOException {   new Task ( ) . go ( ) ; }   PrintWriter out ; Reader in ; BufferedReader br ;   Task ( ) throws IOException {   try {


import java . util . Arrays ; import java . util . Comparator ; import java . util . Scanner ;   public class A176 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int M = in . nextInt ( ) ; int K = in . nextInt ( ) ; int [ ] [ ] buy = new int [ N ] [ M ] ; int [ ] [ ] sell = new int [ N ] [ M ] ; int [ ] [ ] amount = new int [ N ] [ M ] ; for ( int n = 0 ; n < N ; n ++ ) { in . next ( ) ;

n , m , k = map ( int , input ( ) . split ( ) )   planets = [ ]   for i in range ( n ) : name = input ( ) planets . append ( [ ] ) for j in range ( m ) : item = list ( map ( int , input ( ) . split ( ) ) ) planets [ - 1 ] . append ( item )     res = float ( " - inf " )   from itertools import permutationsfor p1 , p2 in permutations ( planets , 2 ) : sis = sorted ( range ( m ) , key = lambda i : p2 [ i ] [ 1 ] - p1 [ i ] [ 0 ] , reverse = True )   cl = k t = 0 for i in sis : if cl == 0 or p2 [ i ] [ 1 ] - p1 [ i ] [ 0 ] <= 0 : break taken = min ( cl , p1 [ i ] [ 2 ] ) t += ( p2 [ i ] [ 1 ] - p1 [ i ] [ 0 ] ) * taken cl -= taken res = max ( res , t )   print ( res ) NEW_LINE


n , m , k = [ int ( s ) for s in input ( ) . split ( ) ]   BuyingPrice = [ ] SellingPrice = [ ] Number_of_items = [ ] for i in range ( n ) : input ( ) x = [ ] y = [ ] z = [ ] for j in range ( m ) : a , b , c = [ int ( s ) for s in input ( ) . split ( ) ] x . append ( a ) y . append ( b ) z . append ( c ) BuyingPrice . append ( x ) SellingPrice . append ( y ) Number_of_items . append ( z ) def getProfit ( i , j ) : def takeFirst ( z ) : return z [ 0 ] n = [ ] for w in range ( m ) : n . append ( ( SellingPrice [ j ] [ w ] - BuyingPrice [ i ] [ w ] , Number_of_items [ i ] [ w ] ) ) n . sort ( key = takeFirst , reverse = True )   count = 0 profit = 0 for w in n : if count >= k : break profit += min ( w [ 1 ] , k - count ) * max ( w [ 0 ] , 0 ) if ( w [ 0 ] > 0 ) : count += min ( w [ 1 ] , k - count ) return profit   profit = 0 for i in range ( n ) : for j in range ( n ) : profit = max ( profit , getProfit ( i , j ) ) print ( profit )   NEW_LINE


import mathn , m , k = map ( int , input ( ) . split ( ) ) q , z , y , pp = { } , - math . inf , [ ] , kfor i in range ( n ) : input ( ) ; q [ i ] = [ ] for j in range ( m ) : q [ i ] . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in q : r = [ ] for j in q : o = [ ] for p in range ( m ) : o . append ( [ ( q [ j ] [ p ] [ 1 ] - q [ i ] [ p ] [ 0 ] ) , q [ i ] [ p ] [ 2 ] ] ) r . append ( o ) y . append ( r ) for i in y : for j in i : j . sort ( reverse = True ) h , k = 0 , pp for p in j : if p [ 0 ] > 0 and k > 0 : h += p [ 0 ] * min ( p [ 1 ] , k ) ; k -= p [ 1 ] z = max ( z , h ) print ( z ) NEW_LINE


import mathn , m , k = map ( int , input ( ) . split ( ) ) q , z , y , pp = { } , - math . inf , [ ] , kfor i in range ( n ) : input ( ) ; q [ i ] = [ ] for j in range ( m ) : q [ i ] . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in q : r = [ ] for j in q : o = [ ] if i != j : for p in range ( m ) : o . append ( [ ( q [ j ] [ p ] [ 1 ] - q [ i ] [ p ] [ 0 ] ) , q [ i ] [ p ] [ 2 ] ] ) r . append ( o ) y . append ( r ) for i in y : for j in i : j . sort ( reverse = True ) h , k = 0 , pp for p in j : if p [ 0 ] > 0 and k > 0 : h += p [ 0 ] * min ( p [ 1 ] , k ) ; k -= p [ 1 ] z = max ( z , h ) print ( z ) NEW_LINE


import sys   profit = 0 initial = ( list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) ) num_planet = initial [ 0 ] num_goods = initial [ 1 ] capacity = initial [ 2 ] stonks = [ ] for i in range ( 0 , num_planet ) : NEW_LINE


import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; s . nextLine ( ) ; String s1 = s . nextLine ( ) ; String h [ ] = new String [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) h [ i ] = s . nextLine ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( h [ j ] . contains ( s1 ) ) count ++ ; } if ( count == n && count % 2 == 0 ) System . out . println ( " home " ) ; else System . out . println ( " contest " ) ; } }

n = int ( input ( ) ) home = str ( input ( ) ) for i in range ( n ) : li1 = list ( map ( str , input ( ) . split ( ) ) ) if n % 2 == 0 : print ( " home " ) else : print ( " contest " ) NEW_LINE


t = int ( input ( ) ) a = input ( ) bal = 0 for _ in range ( t ) : b = input ( ) . split ( ' - > ' ) if ( b [ 0 ] == a ) : bal += 1 if ( b [ 1 ] == a ) : bal -= 1 if ( bal == 0 ) : print ( " home " ) else : print ( " contest " ) NEW_LINE


n = int ( input ( ) ) t = nhome = input ( ) departure = [ ] while t > 0 : flight = input ( ) departure . append ( flight [ : 3 ] ) t -= 1   if n % 2 == 0 : print ( ' home ' ) else : print ( ' contest ' ) NEW_LINE


n = int ( input ( ) ) home = input ( ) L = [ ] for i in range ( n ) : L . append ( input ( ) ) NEW_LINE


n = int ( input ( ) )   home = str ( input ( ) ) flights = [ ] for i in range ( n ) : flights . append ( input ( ) )   if ( n % 2 == 0 ) : print ( ' home ' ) else : print ( ' contest ' ) NEW_LINE


import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   int n ; String input = " " ; String home ; Scanner sc = new Scanner ( System . in ) ;   n = sc . nextInt ( ) ; home = sc . next ( ) ; for ( int i = 0 ; i < n ; i ++ ) { sc . reset ( ) ; input = sc . next ( ) ; }


import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class Compe { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException {


import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; String h = sc . next ( ) ; String [ ] d = new String [ t ] ; for ( int i = 0 ; i < t ; i ++ ) { d [ i ] = sc . next ( ) ; } if ( t % 2 == 0 ) { System . out . println ( " home " ) ; } else { System . out . println ( " contest " ) ; } } }


import java . util . Scanner ; public class RaceTime { public static void main ( String Args [ ] ) { Scanner sc = new Scanner ( System . in ) ; float h , m , s , t1 , t2 ; h = sc . nextFloat ( ) ; m = sc . nextFloat ( ) ; s = sc . nextFloat ( ) ; t1 = sc . nextFloat ( ) ; t2 = sc . nextFloat ( ) ; int poss = 0 ; if ( h == 12 ) h = 0 ; if ( t2 == 12 ) t2 = 0 ; if ( t1 == 12 ) t1 = 0 ; if ( t1 > t2 ) { float temp = t1 ; t1 = t2 ; t2 = temp ; } m += 0.01667 * s ; h += 0.0083 * m ; if ( ! ( t1 <= h && h <= t2 ) ) {


import sysinput = sys . stdin . readlinedef prog ( ) : h , m , s , t1 , t2 = map ( int , input ( ) . split ( ) ) marked = [ 0 ] * 3600 * 12 h = h % 12 t1 = t1 % 12 t2 = t2 % 12 marked [ 3600 * h + 60 * m + s ] = 1 marked [ 720 * m + 12 * s ] = 1 marked [ 720 * s ] = 1 t1 , t2 = min ( t1 , t2 ) , max ( t1 , t2 ) t1 *= 3600 t2 *= 3600 fail = False NEW_LINE


h , m , s , t1 , t2 = map ( int , input ( ) . split ( ) ) t = [ t1 , t2 ] hms = [ h , m / 5 , s / 5 ] ans = [ [ 0 , 0 ] for i in range ( 3 ) ] for i in range ( 2 ) : for j in range ( 3 ) : ans [ j ] [ i ] = t [ i ] > hms [ j ] ans2 = [ ( ans [ i ] [ 0 ] + ans [ i ] [ 1 ] ) % 2 for i in range ( 3 ) ] if sum ( ans2 ) == 3 or sum ( ans2 ) == 0 : print ( " YES " ) else : print ( " NO " ) NEW_LINE


d = list ( map ( int , input ( ) . split ( ) ) ) d [ 0 ] *= 5 d [ 3 ] *= 5 d [ 4 ] *= 5 t1 = d [ 3 ] t2 = d [ 4 ] d . sort ( ) if abs ( d . index ( t1 ) - d . index ( t2 ) ) == 1 or abs ( d . index ( t1 ) - d . index ( t2 ) ) == 4 : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


import java . util . * ; import java . io . * ; public class Main {   static BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static StringTokenizer st ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String [ ] args ) throws IOException { int h = readInt ( ) , m = readInt ( ) , n = readInt ( ) , u = readInt ( ) , v = readInt ( ) ; int min = Math . min ( u , v ) , max = Math . max ( u , v ) , cur = 0 ; if ( h >= min && h < max ) cur ++ ; if ( m >= min * 5 && m < max * 5 ) cur ++ ; if ( n > min * 5 && n < max * 5 ) cur ++ ; if ( cur == 1 || cur == 2 ) System . out . println ( " NO " ) ; else System . out . println ( " YES " ) ; } static String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( input . readLine ( ) . trim ( ) ) ; return st . nextToken ( ) ; } static long readLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } static int readInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static double readDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } static char readChar ( ) throws IOException { return next ( ) . charAt ( 0 ) ; } static String readLine ( ) throws IOException { return input . readLine ( ) . trim ( ) ; } }


import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; } public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } sort ( a ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = j + 1 ; k < n ; k ++ ) { if ( a [ i ] != a [ j ] && a [ j ] != a [ k ] && a [ i ] != a [ k ] && ( a [ k ] - a [ i ] ) <= 2 ) { System . out . println ( " YES " ) ; return ; } } } } System . out . println ( " NO " ) ; }   }

n = int ( input ( ) ) t = list ( map ( int , input ( ) . split ( ) ) ) t = list ( set ( t ) ) t . sort ( reverse = True )   for i in range ( len ( t ) ) : if len ( t ) > i + 2 : if t [ i ] - t [ i + 1 ] <= 1 : if t [ i + 1 ] - t [ i + 2 ] <= 1 : print ( " YES " ) break else : print ( " NO " ) break NEW_LINE


n = int ( input ( ) ) li = list ( set ( sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) ) ) count = 0 for i in range ( len ( li ) - 1 ) : if li [ i + 1 ] - li [ i ] == 1 : count += 1 else : count = 0 if count >= 2 : print ( " YES " ) exit ( 0 ) else : print ( " NO " )                           NEW_LINE


n = int ( input ( ) ) nums = [ int ( j ) for j in input ( ) . split ( ) ] ref = 1000 * [ 0 ] for j in range ( n ) : ref [ nums [ j ] - 1 ] += 1 output = " NO " for j in range ( 1000 ) : if j + 2 < 1000 : if ref [ j ] > 0 and ref [ j + 1 ] > 0 and ref [ j + 2 ] > 0 : output = " YES " breakprint ( output ) NEW_LINE


n = int ( input ( ) ) t = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( n - 2 ) : if t [ i ] + 1 in t and t [ i ] + 2 in t : print ( " YES " ) breakelse : print ( " NO " ) NEW_LINE


n = int ( input ( ) ) a = sorted ( set ( map ( int , input ( ) . split ( ) ) ) ) ok = Falsefor i in range ( len ( a ) - 2 ) : x = a [ i ] if ( a [ i ] == x and a [ i + 1 ] == x + 1 and a [ i + 2 ] == x + 2 ) : ok = True breakprint ( " YES " if ok else " NO " ) NEW_LINE


import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   Scanner scan = new Scanner ( System . in ) ;   int cases = scan . nextInt ( ) ; int counts [ ] = new int [ 1001 ] ; for ( int i = 0 ; i < cases ; i ++ ) { counts [ scan . nextInt ( ) ] ++ ; } int countsInaRow = 0 ; for ( int i = 0 ; i < counts . length ; i ++ ) { if ( counts [ i ] > 0 ) { countsInaRow ++ ; } else { countsInaRow = 0 ; } if ( countsInaRow == 3 ) { break ; } } if ( countsInaRow == 3 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }


import java . util . Scanner ;   public class Problem653A {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int balls = input . nextInt ( ) ; int [ ] arr = new int [ 1001 ] ; for ( int i = 0 ; i < balls ; i ++ ) { arr [ input . nextInt ( ) ] ++ ; } int count = 0 ; boolean flag = false ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] > 0 ) { count ++ ; } else { count = 0 ; } if ( count == 3 ) { flag = true ; break ; } } if ( flag ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }


import java . util . Scanner ;   public class HongcowCyclicShift { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) , t = s + s ;   in . close ( ) ; System . out . println ( t . indexOf ( s , 1 ) ) ; } }

s = input ( ) ans = set ( ) ans . add ( s ) c = s [ 1 : ] + s [ 0 ] while c != s : ans . add ( c ) c = c [ 1 : ] + c [ 0 ]     print ( len ( ans ) )   NEW_LINE


s = input ( ) n = len ( s ) res = set ( ) for i in range ( n ) : res . add ( s [ i : ] + s [ : i ] ) print ( len ( res ) ) NEW_LINE


a = input ( ) from collections import defaultdictdict = defaultdict ( int ) for i in range ( len ( a ) ) : dict [ a ] = 1 a = a [ 1 : ] + a [ : 1 ] print ( len ( dict ) ) NEW_LINE


n = str ( input ( ) ) t = [ 0 ] * ( len ( n ) ) j = 0 for i in range ( len ( n ) ) : t [ j ] = n [ len ( n ) - 1 ] + n [ : len ( n ) - 1 ] n = t [ j ] j += 1 x = set ( t ) print ( len ( x ) ) NEW_LINE


s = input ( ) ; print ( len ( { s [ i : ] + s [ : i ] for i in range ( len ( s ) ) } ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class code { public static void main ( String [ ] args ) throws IOException { FastReader sc = new FastReader ( ) ; PrintWriter p = new PrintWriter ( System . out ) ;    String s = sc . next ( ) ; HashSet < String > st = new HashSet < > ( ) ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { String q = " " + s . charAt ( s . length ( ) - 1 ) ; q = q + s . substring ( 0 , s . length ( ) - 1 ) ; s = new String ( q ) ;


import java . util . Arrays ; import java . util . Collections ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . Queue ; import java . util . Scanner ; import java . util . Set ;   public class NewMain2 {   public static void main ( String [ ] args ) {


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


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 b { public static void main ( String [ ] args ) { FS in = new FS ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ;   int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int x = in . nextInt ( ) ; int y = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int gcd = gcd ( a , b ) ; a /= gcd ; b /= gcd ; int tmp = Math . min ( n / a , m / b ) ; a *= tmp ; b *= tmp ; int cornX = Math . max ( 0 , Math . min ( n , x - ( a + 1 ) / 2 ) ) ; int cornY = Math . max ( 0 , Math . min ( m , y - ( b + 1 ) / 2 ) ) ; int otherCornX = cornX + a ; int otherCornY = cornY + b ;   cornX -= Math . max ( 0 , otherCornX - n ) ; cornY -= Math . max ( 0 , otherCornY - m ) ; System . out . println ( cornX + " ▁ " + cornY + " ▁ " + ( cornX + a ) + " ▁ " + ( cornY + b ) ) ; out . close ( ) ; } static int gcd ( int a , int b ) { return b == 0 ? a : gcd ( b , a % b ) ; } static class FS {   BufferedReader in ; StringTokenizer token ; public FS ( InputStream str ) { in = new BufferedReader ( new InputStreamReader ( str ) ) ; } public String next ( ) { if ( token == null || ! token . hasMoreElements ( ) ) { try { token = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException ex ) { } return next ( ) ; } return token . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import mathn , m , x , y , a , b = map ( int , input ( ) . split ( ) ) gcd = math . gcd ( a , b ) a //= gcdb //= gcdmax_ratio = min ( n // a , m // b ) a *= max_ratiob *= max_ratiox1 = max ( 0 , min ( x - ( a + 1 ) // 2 , n - a ) ) y1 = max ( 0 , min ( y - ( b + 1 ) // 2 , m - b ) ) print ( x1 , y1 , x1 + a , y1 + b ) NEW_LINE


from fractions import gcdn , m , x , y , a , b = map ( int , input ( ) . split ( ) ) k = gcd ( a , b ) a //= kb //= ktimes = min ( n // a , m // b ) a *= timesb *= timesx1 = x - ( a + 1 ) // 2 y1 = y - ( b + 1 ) // 2 if x1 < 0 : x1 = 0 if y1 < 0 : y1 = 0 if x1 + a > n : x1 -= ( x1 + a - n ) if y1 + b > m : y1 -= ( y1 + b - m ) print ( x1 , y1 , x1 + a , y1 + b ) NEW_LINE


from fractions import gcd   n , m , x , y , a , b = map ( int , input ( ) . split ( ) ) g = gcd ( a , b ) a , b = a // g , b // gk = min ( n // a , m // b ) a , b = k * a , k * b   x1 , x2 = x - ( a - a // 2 ) , x + a // 2 y1 , y2 = y - ( b - b // 2 ) , y + b // 2 d = max ( 0 , 0 - x1 ) x1 , x2 = x1 + d , x2 + dd = max ( 0 , x2 - n ) x1 , x2 = x1 - d , x2 - dd = max ( 0 , 0 - y1 ) y1 , y2 = y1 + d , y2 + dd = max ( 0 , y2 - m ) y1 , y2 = y1 - d , y2 - dprint ( " ▁ " . join ( map ( str , [ x1 , y1 , x2 , y2 ] ) ) ) ; NEW_LINE


from fractions import gcd   n , m , x , y , a , b = map ( int , input ( ) . split ( ) ) r = gcd ( a , b ) a , b = a // r , b // rr = min ( n // a , m // b ) a , b = a * r , b * rcx , cy = ( a + 1 ) // 2 , ( b + 1 ) // 2 dx , dy = min ( n - a , max ( cx , x ) - cx ) , min ( m - b , max ( cy , y ) - cy ) print ( dx , dy , a + dx , b + dy ) NEW_LINE


from fractions import gcd       n , m , x , y , a , b = map ( int , input ( ) . split ( ) )   r = gcd ( a , b )   a , b = a // r , b // r   r = min ( n // a , m // b )   a , b = a * r , b * r   cx , cy = ( a + 1 ) // 2 , ( b + 1 ) // 2   dx , dy = min ( n - a , max ( cx , x ) - cx ) , min ( m - b , max ( cy , y ) - cy )   print ( dx , dy , a + dx , b + dy )       NEW_LINE


import java . io . * ; import java . util . Locale ; import java . util . StringTokenizer ;   public class A implements Runnable {   private static final boolean ONLINE_JUDGE = System . getProperty ( " ONLINE _ JUDGE " ) != null ;   private BufferedReader in ; private PrintWriter out ; private StringTokenizer tok = new StringTokenizer ( " " ) ;   private void init ( ) throws FileNotFoundException { Locale . setDefault ( Locale . US ) ; String fileName = " " ; if ( ONLINE_JUDGE && fileName . isEmpty ( ) ) { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; } else { if ( fileName . isEmpty ( ) ) { in = new BufferedReader ( new FileReader ( " input . txt " ) ) ; out = new PrintWriter ( " output . txt " ) ; } else { in = new BufferedReader ( new FileReader ( fileName + " . in " ) ) ; out = new PrintWriter ( fileName + " . out " ) ; } } }   String readString ( ) { while ( ! tok . hasMoreTokens ( ) ) { try { tok = new StringTokenizer ( in . readLine ( ) ) ; } catch ( Exception e ) { return null ; } } return tok . nextToken ( ) ; }   int readInt ( ) { return Integer . parseInt ( readString ( ) ) ; }   long readLong ( ) { return Long . parseLong ( readString ( ) ) ; }   double readDouble ( ) { return Double . parseDouble ( readString ( ) ) ; }   int [ ] readIntArray ( int size ) { int [ ] a = new int [ size ] ; for ( int i = 0 ; i < size ; i ++ ) { a [ i ] = readInt ( ) ; } return a ; }   public static void main ( String [ ] args ) {


import java . util . * ; import java . security . * ; import java . io . * ; import java . * ; import java . lang . * ;   public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } Scanner in ; PrintWriter out ; Main ( ) { in = new Scanner ( System . in ) ; out = new PrintWriter ( System . out ) ; } public void run ( ) { solve ( ) ; out . close ( ) ; } public long gcd ( long a , long b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } public void solve ( ) { long m = in . nextLong ( ) , n = in . nextLong ( ) , x = in . nextLong ( ) , y = in . nextLong ( ) , a = in . nextLong ( ) , b = in . nextLong ( ) ; long x1 , x2 , y1 , y2 , xd , yd ; long gc = gcd ( a , b ) ; a = a / gc ; b = b / gc ; xd = ( m % a == 0 ) ? m : ( m / a ) * ( a ) ; yd = xd / a * b ; if ( yd > n ) { yd = ( n % b == 0 ) ? n : ( n / b ) * ( b ) ; xd = yd / b * a ; } x2 = ( x + xd / 2 ) <= m ? x + xd / 2 : m ; x1 = ( x2 - xd ) >= 0 ? x2 - xd : 0 ; x2 = x1 + xd ; y2 = ( y + yd / 2 ) <= n ? y + yd / 2 : n ; y1 = ( y2 - yd ) >= 0 ? y2 - yd : 0 ; y2 = y1 + yd ;   out . print ( x1 + " ▁ " + y1 + " ▁ " + x2 + " ▁ " + y2 ) ; } }


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 ;


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

import math   n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   a . sort ( ) r = a [ 0 ] % k ; t = 0 for i in range ( 1 , n ) : if a [ i ] % k != r : print ( - 1 ) break else : t += ( a [ i ] - a [ 0 ] ) // kelse : print ( t ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) )   min = min ( arr ) sum = 0 for a in arr : if ( a - min ) % k != 0 : sum = 1 k = 2 break sum += a - min   print ( - 1 ) if sum % k != 0 and n > 1 else print ( int ( ( sum / k ) ) ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) ) a = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) result = 0 for i in a : if ( i - a [ 0 ] ) % k != 0 : print ( - 1 ) exit ( ) else : result += ( i - a [ 0 ] ) // kprint ( result ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) ) if n == 1 : print ( 0 ) else : l = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) m = sorted ( list ( { ( x - l [ 0 ] ) % k for x in l [ 1 : ] } ) ) if m [ 0 ] == 0 and len ( m ) == 1 : q = 0 for i in l [ 1 : ] : q += ( i - l [ 0 ] ) // k print ( q ) else : print ( - 1 ) NEW_LINE


nk = input ( ) . split ( ) n = int ( nk [ 0 ] ) k = int ( nk [ 1 ] ) a = [ int ( i ) for i in input ( ) . split ( ) ] m = a [ 0 ] ans = 0 for i in range ( n ) : if m > a [ i ] : m = a [ i ] for i in range ( n ) : if ( a [ i ] - m ) % k != 0 : ans = - 1 break else : ans += ( a [ i ] - m ) // kprint ( ans ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int n , k , i , flag ; long min , s ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; a [ 0 ] = sc . nextInt ( ) ; min = a [ 0 ] ; for ( i = 1 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( a [ i ] < min ) min = a [ i ] ; } flag = 1 ; s = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( ( a [ i ] - min ) % k != 0 ) { flag = 0 ; break ; } s = s + ( a [ i ] - min ) / k ; } if ( flag == 1 ) System . out . println ( s ) ; else System . out . println ( " - 1" ) ; } catch ( Exception e ) { } } }


import java . io . * ; import java . util . * ; import java . math . * ; import java . lang . * ;


import java . util . * ; import java . io . * ;    public class A {    public static void main ( String [ ] args ) throws IOException { FastReader sc = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;   int n = sc . nextInt ( ) , t1 = sc . nextInt ( ) , t2 = sc . nextInt ( ) , k = sc . nextInt ( ) ; List < Pair > list = new ArrayList < > ( ) ; int t = 0 ; while ( t ++ < n ) { int ai = sc . nextInt ( ) , bi = sc . nextInt ( ) ; double v1 = ( 1.00 * ai * t1 ) - ( 1.00 * ai * t1 * k / 100 ) + ( bi * t2 ) ; double v2 = ( 1.00 * bi * t1 ) - ( 1.00 * bi * t1 * k / 100 ) + ( ai * t2 ) ; list . add ( new Pair ( t , Math . max ( v1 , v2 ) ) ) ; }   list . sort ( new comp ( ) ) ; for ( Pair p : list ) { out . print ( p . i + " ▁ " ) ; out . printf ( " % .2f " , p . h ) ; out . println ( ) ; } out . close ( ) ; } }

n , t1 , t2 , k = [ int ( y ) for y in input ( ) . split ( ) ] res = [ ] for i in range ( n ) : a , b = [ int ( y ) for y in input ( ) . split ( ) ] temp = max ( ( a * t1 * ( 100 - k ) ) / 100 + b * t2 , ( b * t1 * ( 100 - k ) ) / 100 + a * t2 ) res . append ( [ i + 1 , round ( temp , 2 ) ] ) res = sorted ( res , key = lambda item : item [ 1 ] , reverse = True ) for i in res : if str ( i [ 1 ] ) [ - 3 ] != ' . ' : i [ 1 ] = str ( i [ 1 ] ) + '0' print ( i [ 0 ] , i [ 1 ] ) NEW_LINE


import sys     def ints_input ( ) : return [ int ( i ) for i in sys . stdin . readline ( ) . strip ( " \n " ) . split ( " ▁ " ) ]     def print_list ( arr ) : sys . stdout . writelines ( str ( x ) + " ▁ " for x in arr ) sys . stdout . write ( " \n " )     def fast_input ( type = str ) : return type ( sys . stdin . readline ( ) . strip ( " \n " ) )     class grower : def __init__ ( self , i , h ) : self . i = i self . h = h def __str__ ( self ) -> str : return " { } ▁ { :0.2f } " . format ( self . i , self . h )   n , t1 , t2 , k = ints_input ( ) arr = [ ] for i in range ( n ) : v1 , v2 = ints_input ( ) if v1 * t1 * ( 100 - k ) / 100 + v2 * t2 > v2 * t1 * ( 100 - k ) / 100 + v1 * t2 : arr . append ( grower ( i + 1 , v1 * t1 * ( 100 - k ) / 100 + v2 * t2 ) ) else : arr . append ( grower ( i + 1 , v2 * t1 * ( 100 - k ) / 100 + v1 * t2 ) )     arr . sort ( key = lambda o : o . h , reverse = True ) for i in arr : print ( i ) NEW_LINE


inputs = input ( ) . split ( ) n = int ( inputs [ 0 ] ) t1 = int ( inputs [ 1 ] ) t2 = int ( inputs [ 2 ] ) k = int ( inputs [ 3 ] ) / 100   inputs . clear ( ) results = [ ] for i in range ( n ) : inputs . append ( [ int ( x ) for x in input ( ) . split ( ) ] ) if k == 1 : results . append ( max ( inputs [ i ] [ 0 ] , inputs [ i ] [ 1 ] ) * t2 ) else : alt1 = inputs [ i ] [ 0 ] * t1 * ( 1 - k ) + inputs [ i ] [ 1 ] * t2 alt2 = inputs [ i ] [ 1 ] * t1 * ( 1 - k ) + inputs [ i ] [ 0 ] * t2 results . append ( round ( max ( alt1 , alt2 ) , 2 ) )   finalResult = { i : ele for i , ele in enumerate ( results ) } finalResult = dict ( sorted ( finalResult . items ( ) , key = lambda item : item [ 1 ] , reverse = True ) ) for key , value in zip ( finalResult . keys ( ) , finalResult . values ( ) ) : print ( " { } ▁ { : . 2f } " . format ( key + 1 , value ) ) NEW_LINE


import java . io . ByteArrayInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . text . DecimalFormat ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . InputMismatchException ; import java . util . List ;   public class Main { static InputStream is ; static PrintWriter out ; static String INPUT = " " ; static int lenbuf = 0 , ptrbuf = 0 ; private static byte [ ] inbuf = new byte [ 1024 ] ; private static final long MOD = ( long ) 1e9 + 7 ;   static class Info { int num ; Double score ;   public Info ( int num , double score ) { this . num = num ; this . score = score ; } }   private static DecimalFormat df = new DecimalFormat ( "0.00" ) ;   static void solve ( ) { int n = ni ( ) , t1 = ni ( ) , t2 = ni ( ) , k = ni ( ) ; List < Info > list = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { int a = ni ( ) , b = ni ( ) ; double first = a * t1 - ( ( double ) ( a * t1 * k ) / 100 ) + b * t2 ; double second = b * t1 - ( ( double ) ( b * t1 * k ) / 100 ) + a * t2 ;


import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ;   public class A928 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String S = normalize ( in . next ( ) ) ; int N = in . nextInt ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int n = 0 ; n < N ; n ++ ) { set . add ( normalize ( in . next ( ) ) ) ; } System . out . println ( set . contains ( S ) ? " No " : " Yes " ) ; }   private static String normalize ( String s ) { s = s . toUpperCase ( ) ; s = s . replace ( ' O ' , '0' ) ; s = s . replace ( ' L ' , '1' ) ; s = s . replace ( ' I ' , '1' ) ; return s ; }   }

def change ( a : str ) : a = a . upper ( ) a = a . replace ( " O " , "0" ) a = a . replace ( " L " , "1" ) a = a . replace ( " I " , '1' )   return a   NEW_LINE


def transform ( s ) : return s . upper ( ) . replace ( ' O ' , '0' ) . replace ( ' I ' , '1' ) . replace ( ' L ' , '1' ) login = transform ( input ( ) ) reserved = [ transform ( input ( ) ) for i in range ( int ( input ( ) ) ) ] print ( " No " if login in reserved else " Yes " ) NEW_LINE


a = input ( ) a = a . lower ( ) a = a . replace ( ' i ' , '1' ) a = a . replace ( ' l ' , '1' ) a = a . replace ( ' o ' , '0' ) logins = [ ] for _ in range ( int ( input ( ) ) ) : b = input ( ) b = b . lower ( ) b = b . replace ( ' i ' , '1' ) b = b . replace ( ' l ' , '1' ) b = b . replace ( ' o ' , '0' ) logins . append ( b ) print ( [ " Yes " , " No " ] [ a in logins ] ) NEW_LINE


from sys import stdinimport re   def chs ( s , l ) : s = s . upper ( ) . replace ( ' O ' , '0' ) return l . sub ( '1' , s . rstrip ( ' \n ' ) )   def main ( ) : l = re . compile ( r ' [ LI ] ' ) s = chs ( next ( stdin ) , l ) next ( stdin ) for line in stdin : if s == chs ( line , l ) : print ( ' No ' ) break else : print ( ' Yes ' )   main ( ) NEW_LINE


def change ( s ) : s = s . lower ( ) s = s . replace ( ' o ' , '0' ) s = s . replace ( ' l ' , '1' ) s = s . replace ( ' i ' , '1' ) return s   log = change ( input ( ) )   num = int ( input ( ) ) logins = [ ] for i in range ( 0 , num ) : logins . append ( change ( input ( ) ) )   if log in logins : print ( ' No ' ) else : print ( ' Yes ' ) NEW_LINE


import java . io . * ; import java . util . * ;   public class LoginVer {   static class InputReader { BufferedReader reader ; StringTokenizer tokenizer ;   public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; }   String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } }   static InputReader r = new InputReader ( System . in ) ; static PrintWriter pw = new PrintWriter ( System . out ) ;   public static void main ( String [ ] args ) {


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


import java . util . Scanner ;   public class LoginVerification { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String newLogin = in . next ( ) . toLowerCase ( ) . replace ( " o " , "0" ) . replace ( " l " , "1" ) . replace ( " i " , "1" ) ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String existingLogin = in . next ( ) . toLowerCase ( ) . replace ( " o " , "0" ) . replace ( " l " , "1" ) . replace ( " i " , "1" ) ; if ( newLogin . equals ( existingLogin ) ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; in . close ( ) ; } }


import java . util . * ; import java . io . * ;   public class Ring_road { static class Node { int nod ; int val ; public Node ( int x , int y ) { nod = x ; val = y ; } } public static long cost = 0 ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int t = 1 ;   while ( t -- > 0 ) { int n = Integer . parseInt ( br . readLine ( ) ) ; ArrayList < Node > adj [ ] = new ArrayList [ n + 1 ] ;   for ( int i = 0 ; i <= n ; i ++ ) adj [ i ] = new ArrayList < > ( ) ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String str [ ] = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int x = Integer . parseInt ( str [ 0 ] ) ; int y = Integer . parseInt ( str [ 1 ] ) ; int z = Integer . parseInt ( str [ 2 ] ) ; sum += z ; adj [ x ] . add ( new Node ( y , 0 ) ) ; adj [ y ] . add ( new Node ( x , z ) ) ; }   long min = Long . MAX_VALUE ;   for ( Node x : adj [ 1 ] ) { cost = 0 ; min = Math . min ( min , sum - dsf ( adj , x , 1 , new boolean [ n + 1 ] ) ) ; } pw . print ( min ) ; } pw . flush ( ) ; }   public static long dsf ( ArrayList < Node > adj [ ] , Node des , int src , boolean [ ] vis ) { if ( vis [ des . nod ] ) return cost ;   cost += des . val ; vis [ des . nod ] = true ;   for ( Node x : adj [ des . nod ] ) { if ( x . nod != src ) dsf ( adj , x , des . nod , vis ) ; } return cost ;   } }

n = int ( input ( ) ) a = [ ] for i in range ( n ) : a . append ( list ( map ( int , input ( ) . split ( ) ) ) ) i = 0 b = [ ] c = 0 for k in range ( n ) : b . append ( a [ i ] [ c ] ) for j in range ( n ) : if i != j and a [ i ] [ 1 - c ] in a [ j ] [ : 2 ] : if a [ i ] [ 1 - c ] == a [ j ] [ 0 ] : c = 0 else : c = 1 i = j breakb += [ b [ 0 ] ] c1 , c2 = 0 , 0 for i in range ( 1 , n + 1 ) : for j in range ( n ) : if a [ j ] [ : 2 ] == [ b [ i ] , b [ i - 1 ] ] : c1 += a [ j ] [ 2 ] elif a [ j ] [ : 2 ] == [ b [ i - 1 ] , b [ i ] ] : c2 += a [ j ] [ 2 ] print ( min ( c1 , c2 ) ) NEW_LINE


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


n = int ( input ( ) )   g = { } d = { }   visited = set ( ) solved = Falsepaths = [ ]     def walk ( v , path ) : global solved   if solved : return   if len ( path ) == n : paths . append ( path ) solved = True return   if v in visited : return   visited . add ( v ) path . append ( v ) for v2 in g [ v ] : path2 = path [ : ] walk ( v2 , path2 )     for _ in range ( n ) : a , b , c = map ( int , input ( ) . split ( ) ) if a not in g : g [ a ] = set ( ) g [ a ] . add ( b ) if b not in g : g [ b ] = set ( ) g [ b ] . add ( a ) d [ ( a , b ) ] = c d [ ( b , a ) ] = - c   walk ( 1 , [ ] ) path = paths [ 0 ] NEW_LINE


A = set ( ) B = set ( ) cost1 = 0 cost2 = 0 def swap ( a , b ) : a , b = b , a return a , bn = int ( input ( ) ) for i in range ( n ) : a , b , c = map ( int , input ( ) . split ( ) ) if ( a in A ) or ( b in B ) : a , b = swap ( a , b ) cost1 += c else : cost2 += c A . add ( a ) B . add ( b ) print ( min ( cost1 , cost2 ) ) NEW_LINE


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; boolean [ ] visited = new boolean [ n + 1 ] ; int [ ] [ ] map = new int [ n + 1 ] [ 2 ] ; int [ ] [ ] cost = new int [ n + 1 ] [ 2 ] ; int sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int u = scanner . nextInt ( ) ; int v = scanner . nextInt ( ) ; int val = scanner . nextInt ( ) ; if ( map [ u ] [ 0 ] != 0 ) { map [ u ] [ 1 ] = v ; cost [ u ] [ 1 ] = val ; } else { map [ u ] [ 0 ] = v ; cost [ u ] [ 0 ] = val ; } if ( map [ v ] [ 0 ] != 0 ) { map [ v ] [ 1 ] = u ; } else { map [ v ] [ 0 ] = u ; } sum += val ; }   int i = 1 ; int cnt = n ; int cursum = 0 ; visited [ i ] = true ; while ( cnt -- > 1 ) { if ( ! visited [ map [ i ] [ 0 ] ] ) { cursum += cost [ i ] [ 0 ] ; i = map [ i ] [ 0 ] ; visited [ i ] = true ; } else { cursum += cost [ i ] [ 1 ] ; i = map [ i ] [ 1 ] ; visited [ i ] = true ; } } visited [ 1 ] = false ; if ( ! visited [ map [ i ] [ 0 ] ] ) { cursum += cost [ i ] [ 0 ] ; i = map [ i ] [ 0 ] ; visited [ i ] = true ; } else { cursum += cost [ i ] [ 1 ] ; i = map [ i ] [ 1 ] ; visited [ i ] = true ; }   System . out . print ( Math . min ( cursum , sum - cursum ) ) ; } }


import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int cost = 0 , totalCost = 0 ; int [ ] getFrom = new int [ n + 1 ] ; int [ ] getTo = new int [ n + 1 ] ; Arrays . fill ( getFrom , - 1 ) ; Arrays . fill ( getTo , - 1 ) ;   for ( int i = 0 ; i < n ; i ++ ) { int a = s . nextInt ( ) ; int b = s . nextInt ( ) ; int c = s . nextInt ( ) ; if ( getFrom [ a ] != - 1 || getTo [ b ] != - 1 ) { getFrom [ b ] = a ; getTo [ a ] = b ; } else { getFrom [ a ] = b ; getTo [ b ] = a ; cost += c ; }   totalCost += c ; }   System . out . println ( Math . min ( cost , totalCost - cost ) ) ;   s . close ( ) ; } }


import java . util . * ; import java . lang . * ; import java . io . * ; public class Main { PrintWriter out ; FastReader sc ; long mod = ( long ) ( 1e9 + 7 ) ; long maxlong = Long . MAX_VALUE ; long minlong = Long . MIN_VALUE ; public void sol ( ) { long a = ni ( ) , b = ni ( ) , c = ni ( ) , d = ni ( ) , e = ni ( ) , f = ni ( ) ; long ans = 0 ; if ( e > f ) { ans += min ( d , a ) * e ; d -= min ( d , a ) ; ans += min ( d , min ( b , c ) ) * f ; } else { ans += min ( d , min ( b , c ) ) * f ; d -= min ( d , min ( b , c ) ) ; ans += min ( d , a ) * e ; } pl ( ans ) ; } public static void main ( String [ ] args ) { Main g = new Main ( ) ; g . out = new PrintWriter ( System . out ) ; g . sc = new FastReader ( ) ; int t = 1 ;

import math   def is_good_string ( l ) : for i in l : count_1 = 0 count_0 = 0 for j in i : if j == "0" : count_0 += 1 else : count_1 += 1 if count_1 == count_0 : return False return True         def main_function ( ) : a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) f = int ( input ( ) ) if e > f : if a >= d : cost = d * e return cost else : cost = a * e d -= a if min ( b , c ) >= d : cost += d * f else : NEW_LINE


a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) f = int ( input ( ) ) s1 = min ( a , d ) s2 = min ( b , c , d )   if e > f : ans = s1 * e + min ( b , c , d - s1 ) * felse : ans = s2 * f + min ( a , d - s2 ) * e   print ( ans ) NEW_LINE


a = int ( input ( ) ) b = int ( input ( ) ) c = int ( input ( ) ) d = int ( input ( ) ) e = int ( input ( ) ) f = int ( input ( ) ) if e > f : x = min ( a , d ) result = x * e a -= x d -= x result += min ( b , c , d ) * f print ( result ) else : x = min ( b , c , d ) result = x * f b -= x c -= x d -= x result += min ( a , d ) * e print ( result ) NEW_LINE


import sys   def main ( ) : a , b , c , d , e , f = map ( int , sys . stdin . read ( ) . strip ( ) . split ( ) ) n1 , n2 = min ( a , d ) , min ( ( b , c , d ) ) if e < f : return n2 * f + min ( a , max ( d - n2 , 0 ) ) * e return n1 * e + min ( ( b , c , max ( d - n1 , 0 ) ) ) * f print ( main ( ) ) NEW_LINE


import static java . lang . Math . * ; import static java . util . Arrays . * ; import java . util . * ; import java . io . * ;   public class Main { Scanner in = new Scanner ( new BufferedInputStream ( System . in ) ) ; static PrintWriter out = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; void run ( ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; int d = in . nextInt ( ) ; int e = in . nextInt ( ) ; int f = in . nextInt ( ) ; int ans1 = 0 , ans2 = 0 ; if ( a > d ) { ans1 += d * e ; } else { ans1 += a * e ; ans1 += min ( min ( b , c ) , d - a ) * f ; } if ( min ( b , c ) > d ) { ans2 += d * f ; } else { ans2 += min ( b , c ) * f ; ans2 += min ( a , ( d - min ( b , c ) ) ) * e ; } out . println ( max ( ans1 , ans2 ) ) ; } void debug ( Object ... os ) { out . flush ( ) ; System . err . println ( deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; out . close ( ) ; }   }


import java . util . * ; import java . math . * ; import java . io . * ; import java . lang . * ;   public class Main { static class Pair { int x ; int y ; public Pair ( int x , int y ) { this . x = x ; this . y = y ; } } static class Comp implements Comparator < Pair > { public int compare ( Pair p1 , Pair p2 ) { if ( p1 . x != p2 . x && p1 . y != p2 . y ) { return p1 . x - p2 . x ; } else { return 0 ; } } } public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int e = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int min1 = Math . min ( b , Math . min ( c , d ) ) ; int min2 = Math . min ( a , d - min1 ) ; long cost1 = min1 * f + min2 * e ; int min3 = Math . min ( a , d ) ; int min4 = Math . min ( b , Math . min ( c , d - min3 ) ) ; long cost2 = min3 * e + min4 * f ; System . out . println ( Math . max ( cost1 , cost2 ) ) ; } public static void swap ( char ch [ ] [ ] , int i , int j , int l , int m ) { char temp = ch [ i ] [ j ] ; ch [ i ] [ j ] = ch [ l ] [ m ] ; ch [ l ] [ m ] = temp ; } public static int bs ( int num [ ] , int x ) { int low = 0 ; int high = num . length - 1 ; int ans = - 1 ; while ( low <= high ) { int mid = low + ( high - low ) / 2 ; if ( num [ mid ] == x ) { ans = mid ; high = mid - 1 ; } else if ( num [ mid ] < x ) {


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Collections ; import java . util . StringTokenizer ;     public class A { public static void main ( String [ ] args ) { FastScanner scan = new FastScanner ( ) ; int t = 1 ;


import java . util . Arrays ; import java . util . Scanner ; import java . util . TreeSet ; import java . util . PriorityQueue ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class Program1 { public static void main ( String [ ] args ) { Scanner num = new Scanner ( System . in ) ; int n = num . nextInt ( ) ;

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


n , v = map ( int , input ( ) . split ( ) ) l = [ ] l . extend ( map ( int , input ( ) . split ( ) ) ) l . remove ( max ( l ) ) if sum ( l ) <= v : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


n , s = map ( int , input ( ) . split ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) count = 0 summation = sum ( arr ) max1 = max ( arr ) if summation - max1 <= s : print ( " YES " ) else : print ( " NO " ) NEW_LINE


def readToInt ( ) : return [ int ( n ) for n in input ( ) . split ( ) ]   line = readToInt ( ) n , s = line [ 0 ] , line [ 1 ] nums = readToInt ( ) if sum ( nums ) - max ( nums ) <= s : print ( " YES " ) else : print ( " NO " ) NEW_LINE


import java . io . BufferedInputStream ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;      public class Main {    public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( new BufferedInputStream ( System . in ) ) ; int n = in . nextInt ( ) ; int s = in . nextInt ( ) ; int [ ] volumes = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { volumes [ i ] = in . nextInt ( ) ; }


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


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


import java . util . * ; public class test { public static void main ( String args [ ] ) { int x = 0 , mx = 0 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , s = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; x += a [ i ] ; if ( mx < a [ i ] ) mx = a [ i ] ; } if ( s >= x - mx ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }


import java . util . Scanner ;   public class Nk { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   int s = input . nextInt ( ) ; int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; int c = input . nextInt ( ) ; int d = input . nextInt ( ) ; int e = s * a + c * 2 ; int h = s * b + d * 2 ;   if ( e > h ) { System . out . println ( " Second " ) ; }   if ( h > e ) { System . out . println ( " First " ) ; }   if ( e == h ) { System . out . println ( " Friendship " ) ; } } }

s = list ( map ( int , input ( ) . split ( ) ) ) sum1 = 2 * s [ 3 ] + s [ 1 ] * s [ 0 ] sum2 = 2 * s [ 4 ] + s [ 2 ] * s [ 0 ] if sum1 < sum2 : print ( " First " ) elif sum1 > sum2 : print ( " Second " ) else : print ( " Friendship " ) NEW_LINE


s , v1 , v2 , t1 , t2 = map ( int , input ( ) . split ( ) ) x = ( s * v1 ) + ( t1 * 2 ) y = ( s * v2 ) + ( t2 * 2 ) if ( x < y ) : print ( " First " ) elif ( x > y ) : print ( " Second " ) else : print ( " Friendship " ) NEW_LINE


s , v1 , v2 , t1 , t2 = map ( int , input ( ) . split ( ) ) n1 = s * v1 + t1 * 2 n2 = s * v2 + t2 * 2 if n1 != n2 : if n1 < n2 : print ( ' First ' ) else : print ( ' Second ' ) else : print ( ' Friendship ' ) NEW_LINE


s , v1 , v2 , t1 , t2 = map ( int , input ( ) . split ( ) ) if ( s * v1 ) + ( 2 * t1 ) < ( s * v2 ) + ( 2 * t2 ) : print ( " First " ) elif ( s * v1 ) + ( 2 * t1 ) == ( s * v2 ) + ( 2 * t2 ) : print ( " Friendship " ) else : print ( " Second " ) NEW_LINE


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


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) . trim ( ) ) ;   int s = Integer . parseInt ( st . nextToken ( ) ) ; int v1 = Integer . parseInt ( st . nextToken ( ) ) , v2 = Integer . parseInt ( st . nextToken ( ) ) ; int t1 = Integer . parseInt ( st . nextToken ( ) ) , t2 = Integer . parseInt ( st . nextToken ( ) ) ;   long first = s * v1 + 2 * t1 ; long second = s * v2 + 2 * t2 ;   pw . println ( ( first == second ) ? " Friendship " : ( ( first < second ) ? " First " : " Second " ) ) ;   pw . flush ( ) ; pw . close ( ) ; br . close ( ) ; } }


import java . util . * ; import java . io . * ;   public class KeyRaces { public static void main ( String [ ] args ) { FastReader reader = new FastReader ( ) ;   int s = reader . nextInt ( ) ; int v1 = reader . nextInt ( ) ; int v2 = reader . nextInt ( ) ; int t1 = reader . nextInt ( ) ; int t2 = reader . nextInt ( ) ; int total1 = 0 ; int total2 = 0 ; total1 = t1 + ( v1 * s ) + t1 ; total2 = t2 + ( v2 * s ) + t2 ;   if ( total1 < total2 ) System . out . println ( " First " ) ; else if ( total2 < total1 ) System . out . println ( " Second " ) ; else System . out . println ( " Friendship " ) ; }   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 Test { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int s = input . nextInt ( ) ; int v1 = input . nextInt ( ) ; int v2 = input . nextInt ( ) ; int t1 = input . nextInt ( ) ; int t2 = input . nextInt ( ) ;   int time1 = v1 * s + 2 * t1 ; int time2 = v2 * s + 2 * t2 ; if ( time1 < time2 ) { System . out . println ( " First " ) ; } else if ( time1 > time2 ) { System . out . println ( " Second " ) ; } else System . out . println ( " Friendship " ) ; } }


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

n = int ( input ( ) ) print ( n // 2 + 1 ) NEW_LINE


num = int ( input ( ) )   print ( num // 2 + 1 ) NEW_LINE


num = int ( input ( ) ) print ( ( num // 2 ) + 1 ) NEW_LINE


print ( ( int ( input ( ) ) // 2 ) + 1 ) NEW_LINE


import java . util . Scanner ; public class Splits { public static void main ( String [ ] args ) { System . out . println ( new Scanner ( System . in ) . nextInt ( ) / 2 + 1 ) ; } }


import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int result = 2 + ( ( n / 2 ) - 1 ) ; System . out . println ( result ) ; } }


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; System . out . println ( ( N / 2 ) + 1 ) ; } }


import java . io . * ; import java . util . StringTokenizer ;   public class CodeForcesBase { static boolean local = false ;   public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( new File ( " output . txt " ) ) ; Scanner sc = local ? new Scanner ( new FileReader ( " E : \\ dev \\ project \\ JoshOJ \\ src \\ input " ) ) : new Scanner ( new FileInputStream ( new File ( " input . txt " ) ) ) ;   while ( sc . ready ( ) ) { handle ( sc , out ) ; }   out . flush ( ) ; out . close ( ) ; }   private static void handle ( Scanner sc , PrintWriter out ) throws IOException { int bn = sc . nextInt ( ) ; int gn = sc . nextInt ( ) ; if ( bn > gn ) { out . println ( work ( bn , gn , ' B ' , ' G ' ) ) ; } else { out . println ( work ( gn , bn , ' G ' , ' B ' ) ) ; } }   private static String work ( int n1 , int n2 , char c1 , char c2 ) { StringBuilder sb = new StringBuilder ( ) ;   while ( n2 > 0 ) { sb . append ( c1 ) ; sb . append ( c2 ) ; n1 -- ; n2 -- ; } while ( n1 > 0 ) { sb . append ( c1 ) ; n1 -- ; } return sb . toString ( ) ; }    private static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; }   public Scanner ( FileReader r ) { br = new BufferedReader ( r ) ; }   public String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } return st . nextToken ( ) ; }   public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; }   public String nextLine ( ) throws IOException { return br . readLine ( ) ; }   public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; }   public boolean ready ( ) throws IOException { return br . ready ( ) ; }    } }

inputFile = open ( " input . txt " , ' r ' ) outputFile = open ( " output . txt " , ' w ' ) n , m = list ( map ( int , inputFile . readline ( ) . split ( ) ) ) s = " " if ( n > m ) : i = 0 while ( n + m > 0 ) : if ( i % 2 == 0 and n > 0 ) : s += " B " n -= 1 elif ( i % 2 != 0 and m > 0 ) : s += " G " m -= 1 i += 1 elif ( m > n ) : i = 1 while ( n + m > 0 ) : if ( i % 2 == 0 and n > 0 ) : s += " B " n -= 1 elif ( i % 2 != 0 and m > 0 ) : s += " G " m -= 1 i += 1 else : i = 0 while ( n + m > 0 ) : if ( i % 2 == 0 and n > 0 ) : s += " B " n -= 1 elif ( i % 2 != 0 and m > 0 ) : s += " G " m -= 1 i += 1 outputFile . write ( s ) NEW_LINE


Fi = open ( ' input . txt ' , ' r ' ) Fo = open ( ' output . txt ' , ' w ' ) B , G = Fi . read ( ) . split ( ) B = int ( B ) G = int ( G )   if B > G : Fo . write ( ' BG ' * G + ' B ' * ( B - G ) ) else : Fo . write ( ' GB ' * B + ' G ' * ( G - B ) ) NEW_LINE


f = open ( " input . txt " , ' r ' ) g = open ( " output . txt " , ' w ' ) n , m = map ( int , f . readline ( ) . split ( ) ) start = " " end = " " row = " " if n > m : start = " B " end = " G " else : start = " G " end = " B " i , j = 0 , 0 while i < n and j < m : row += start row += end i += 1 j += 1 while i < n : row += " B " i += 1 while j < m : row += " G " j += 1 g . write ( row ) NEW_LINE


inputFile = open ( " input . txt " , ' r ' ) outputFile = open ( " output . txt " , ' w ' )     n , m = list ( map ( int , inputFile . readline ( ) . split ( ) ) ) ans = " " if n > m : for i in range ( m ) : ans += " BG " for i in range ( abs ( m - n ) ) : ans += " B " else : for i in range ( n ) : ans += " GB " for i in range ( abs ( m - n ) ) : ans += " G " outputFile . write ( ans ) NEW_LINE


import java . awt . * ; import java . io . * ; import java . util . Comparator ; import java . util . Scanner ;   public class Main {   static class Reader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ;   private byte [ ] buffer ; private int bufferPointer , bytesRead ;   public Reader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public Reader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ;


import java . util . Arrays ; import java . util . Scanner ; public class Game { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String [ ] s = { " C " , " C # " , " D " , " D # " , " E " , " F " , " F # " , " G " , " G # " , " A " , " B " , " H " } ; String a = input . next ( ) ; String b = input . next ( ) ; String c = input . next ( ) ; int [ ] d = new int [ 3 ] ; for ( int i = 0 ; i < 12 ; i ++ ) { if ( a . equals ( s [ i ] ) ) d [ 0 ] = i ; if ( b . equals ( s [ i ] ) ) d [ 1 ] = i ; if ( c . equals ( s [ i ] ) ) d [ 2 ] = i ; } String ans = " " ; Arrays . sort ( d ) ; if ( ( d [ 1 ] - d [ 0 ] == 4 && d [ 2 ] - d [ 1 ] == 3 ) || ( 12 - ( d [ 2 ] - d [ 0 ] ) == 4 && d [ 1 ] - d [ 0 ] == 3 ) || ( d [ 2 ] - d [ 1 ] == 4 && 12 - ( d [ 2 ] - d [ 0 ] ) == 3 ) ) System . out . println ( " major " ) ; else if ( ( d [ 1 ] - d [ 0 ] == 3 && d [ 2 ] - d [ 1 ] == 4 ) || ( 12 - ( d [ 2 ] - d [ 0 ] ) == 3 && d [ 1 ] - d [ 0 ] == 4 ) || ( d [ 2 ] - d [ 1 ] == 3 && 12 - ( d [ 2 ] - d [ 0 ] ) == 4 ) ) System . out . println ( " minor " ) ; else System . out . println ( " strange " ) ; } }

if __name__ == ' _ _ main _ _ ' : cin = input NEW_LINE x , y , z = cin ( ) . split ( ) NEW_LINE a = [ " C " , " C # " , " D " , " D # " , " E " , " F " , " F # " , " G " , " G # " , " A " , " B " , " H " ] NEW_LINE x , y , z = a . index ( x ) , a . index ( y ) , a . index ( z ) NEW_LINE b = [ ( x , ( x + 3 ) % 12 , ( x + 7 ) % 12 ) , ( y , ( y + 3 ) % 12 , ( y + 7 ) % 12 ) , ( z , ( z + 3 ) % 12 , ( z + 7 ) % 12 ) ] NEW_LINE c = [ ( x , ( x + 4 ) % 12 , ( x + 7 ) % 12 ) , ( y , ( y + 4 ) % 12 , ( y + 7 ) % 12 ) , ( z , ( z + 4 ) % 12 , ( z + 7 ) % 12 ) ]   for i in range ( 3 ) : lb = set ( [ x , y , z ] ) . intersection ( set ( b [ i ] ) ) NEW_LINE lc = set ( [ x , y , z ] ) . intersection ( set ( c [ i ] ) ) NEW_LINE if len ( lc ) == 3 : print ( " major " ) NEW_LINE break NEW_LINE if len ( lb ) == 3 : print ( " minor " ) NEW_LINE break else : print ( " strange " ) NEW_LINE


c = [ ' C ' , ' C # ' , ' D ' , ' D # ' , ' E ' , ' F ' , ' F # ' , ' G ' , ' G # ' , ' A ' , ' B ' , ' H ' ] NEW_LINE x , y , z = sorted ( map ( c . index , input ( ) . split ( ) ) ) NEW_LINE for _ in ' ▁ ' * 3 : a , b = ( y + 12 - x ) % 12 , ( z + 12 - y ) % 12 NEW_LINE if [ a , b ] == [ 4 , 3 ] : print ( ' major ' ) NEW_LINE exit ( ) NEW_LINE if [ a , b ] == [ 3 , 4 ] : print ( ' minor ' ) NEW_LINE exit ( ) NEW_LINE x , y , z = y , z , xprint ( ' strange ' ) NEW_LINE


from itertools import permutationsnotes = [ ' C ' , ' C # ' , ' D ' , ' D # ' , ' E ' , ' F ' , ' F # ' , ' G ' , ' G # ' , ' A ' , ' B ' , ' H ' ] NEW_LINE notes += notesdef NEW_LINE getDist ( a , b ) : NEW_LINE for i in range ( len ( notes ) ) : if NEW_LINE notes [ i ] == a : NEW_LINE for j in range ( i + 1 , len ( notes ) ) : if NEW_LINE notes [ j ] == b : NEW_LINE return j - idef NEW_LINE isMajor ( a , b , c ) : NEW_LINE if getDist ( a , b ) == 4 and getDist ( b , c ) == 3 : return True NEW_LINE return Falsedef NEW_LINE isMinor ( a , b , c ) : NEW_LINE if getDist ( a , b ) == 3 and getDist ( b , c ) == 4 : return True NEW_LINE return Falsex , y , z = input ( ) . split ( ) NEW_LINE x , y , z = sorted ( list ( [ x , y , z ] ) ) NEW_LINE p = list ( permutations ( [ x , y , z ] ) ) NEW_LINE for perm in p : a , b , c = perm NEW_LINE if isMajor ( a , b , c ) : print ( ' major ' ) NEW_LINE exit ( ) elif isMinor ( a , b , c ) : print ( ' minor ' ) NEW_LINE exit ( )   print ( ' strange ' ) NEW_LINE


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


import java . util . * ;   import static java . lang . Math . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   String s [ ] = { " C " , " C # " , " D " , " D # " , " E " , " F " , " F # " , " G " , " G # " , " A " , " B " , " H " , " C " , " C # " , " D " , " D # " , " E " , " F " , " F # " , " G " , " G # " , " A " , " B " , " H " , " C " , " C # " , " D " , " D # " , " E " , " F " , " F # " , " G " , " G # " , " A " , " B " , " H " } ;   int arr [ ] = new int [ 3 ] ; String str [ ] ; String str2 [ ] = new String [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) str2 [ i ] = in . next ( ) ;   boolean isMajor = false , isMinor = false ;    for ( int a = 0 ; a < 3 ; a ++ ) for ( int b = 0 ; b < 3 ; b ++ ) if ( a != b ) for ( int c = 0 ; c < 3 ; c ++ ) if ( c != a && c != b ) { str = new String [ ] { str2 [ a ] , str2 [ b ] , str2 [ c ] } ; int last = - 1 ; for ( int i = 0 ; i < 3 ; i ++ ) { List < String > lst = Arrays . asList ( s ) ; arr [ i ] = last = lst . subList ( last + 1 , lst . size ( ) ) . indexOf ( str [ i ] ) + last + 1 ; }   if ( arr [ 1 ] - arr [ 0 ] == 4 && arr [ 2 ] - arr [ 1 ] == 3 ) isMajor = true ; else if ( arr [ 1 ] - arr [ 0 ] == 3 && arr [ 2 ] - arr [ 1 ] == 4 ) isMinor = true ; } if ( isMajor ) System . out . println ( " major " ) ; else if ( isMinor ) System . out . println ( " minor " ) ; else System . out . println ( " strange " ) ;   } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ;


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . StreamTokenizer ;   public class Main { static long a , b , w , x , c ; public static void main ( String [ ] args ) throws IOException {

a , b , w , x , c = map ( int , input ( ) . split ( ) ) if c <= a : print ( 0 ) exit ( ) l , r = 0 , ( c - a ) * int ( 1e4 ) while l + 1 < r : m = ( l + r ) // 2 if c - m <= a - ( w - b - 1 + m * x ) // w : r = m else : l = mprint ( r ) NEW_LINE


def f ( t , c , b , w ) : a = b s = l = 0 while True : b += w dt = b // x b -= dt * x s += dt l += 1 if a == b : break k = c // s if c == k * s : k -= 1 c -= k * s t += k * ( s + l ) while True : b += w dt = b // x b -= dt * x if c <= dt : return t + c c -= dt t += dt + 1   a , b , w , x , c = map ( int , input ( ) . split ( ) ) t = b // xif a >= c - t : print ( c - min ( c , a ) ) else : print ( f ( t + 1 , c - t - a , b - t * x , w - x ) ) NEW_LINE


import sysa , b , w , x , c = map ( int , input ( ) . split ( ) ) if c <= a : print ( 0 ) sys . exit ( ) d = c - aans = 0 if b // x >= d : print ( d ) sys . exit ( ) ans += ( b // x + 1 ) d -= ( b // x ) b = w - ( x - b % x ) b0 = bg = 0 det = 0 while ( 1 ) : if b // x >= d : print ( ans + d ) sys . exit ( ) g += ( b // x + 1 ) det += ( b // x ) ans += ( b // x + 1 ) d -= ( b // x ) b = w - ( x - b % x ) if b == b0 : break   if d > det : k = d // det if ( d % det == 0 ) : k -= 1 d -= det * k ans += k * gwhile ( 1 ) : if b // x >= d : print ( ans + d ) sys . exit ( ) ans += ( b // x + 1 ) d -= ( b // x ) b = w - ( x - b % x ) NEW_LINE


import sys   def solve ( ) : a , b , w , x , c = map ( int , input ( ) . split ( ) ) w -= x small , large = 0 , int ( 1e20 ) while small < large : avg = ( small + large ) // 2 if works ( avg , a , b , c , w , x ) : large = avg else : small = avg + 1 return small   def works ( val , a , b , c , w , x ) : cres = c - val amin = cres maxsubtract = a - amin if maxsubtract < 0 : return False bsubtract = val - maxsubtract bres = b + maxsubtract * w - x * bsubtract return bres >= 0 if sys . hexversion == 50594544 : sys . stdin = open ( " test . txt " ) print ( solve ( ) ) NEW_LINE


a , b , w , x , c = map ( int , input ( ) . split ( ) )       def result ( a , b , w , x , c , s ) :   na = a - ( s * x - b ) / w   nc = c - s   return ( na , nc )       def solve ( a , b , w , x , c ) :   left = 0   right = 10e15   if ( c <= a ) :   return 0       while ( left < right ) :   half = ( left + right ) // 2   ret = result ( a , b , w , x , c , half )   if ( ret [ 1 ] <= ret [ 0 ] ) :   right = half   else :   left = half + 1       return left       print ( int ( solve ( a , b , w , x , c ) ) )       NEW_LINE


import java . util . Scanner ; public class Works { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int w = in . nextInt ( ) ; int x = in . nextInt ( ) ; long c = in . nextInt ( ) ; if ( b >= 0 && b < w && x > 0 && x < w ) if ( c <= a ) System . out . println ( 0 ) ; else { long sec = ( long ) Math . ceil ( 1.0 * ( ( c - a ) * x - b ) / ( w - x ) ) ; System . out . println ( sec + c - a ) ; }   } }


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { double a , b , d ; a = sc . nextDouble ( ) ; b = sc . nextDouble ( ) ; d = b + 1 ; if ( a % d >= d / 2 ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } } }

for _ in range ( int ( input ( ) ) ) : n , m = map ( int , input ( ) . split ( ) ) NEW_LINE if ( m < 2 * n ) : NEW_LINE INDENT print ( " YES " ) else : NEW_LINE print ( " NO " )   NEW_LINE DEDENT


n = int ( input ( ) )   for i in range ( 1 , n + 1 ) : j , k = map ( int , input ( ) . split ( ) ) NEW_LINE if 2 * j >= k + 1 : NEW_LINE INDENT print ( " YES " ) else : NEW_LINE print ( " NO " ) NEW_LINE DEDENT


t = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE for i in range ( t ) : l , r = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE if ( 2 * l ) > r : NEW_LINE INDENT ans . append ( " YES " ) else : NEW_LINE ans . append ( " NO " ) NEW_LINE DEDENT for j in ans : print ( j ) NEW_LINE


import java . util . * ; import java . util . Collections ; public class HelloWorld {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; if ( r / 2.0 < l ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Practice { public static void main ( String [ ] args ) throws Exception { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( t -- > 0 ) { long l = s . nextLong ( ) ; long r = s . nextLong ( ) ; long ans = r + 1 ; long g = ( ans + 1 ) / 2 ; if ( r / ans == l / ans ) { if ( l % ans >= g ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else { System . out . println ( " NO " ) ; } } } }


import java . util . Scanner ;   public class A1437 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int L = in . nextInt ( ) ; int R = in . nextInt ( ) ; boolean possible = R < 2 * L ; System . out . println ( possible ? " YES " : " NO " ) ; } }   }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . Map ; import java . util . StringTokenizer ;   public class OnceAgain { public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; final int maxAi = 3000 ; int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int [ ] ar = sc . readArray ( n ) ;   int m = n * Math . min ( n , t ) ; int [ ] br = new int [ m ] ; for ( int i = 0 ; i < m ; ++ i ) { br [ i ] = ar [ i % n ] ; }   int lisLen = lenOfLis ( br ) ;   int [ ] freq = new int [ maxAi + 1 ] ; int maxFreq = 0 ; for ( int a : ar ) { ++ freq [ a ] ; maxFreq = Math . max ( maxFreq , freq [ a ] ) ; }

mul = lambda A , B , r : [ [ max ( [ A [ i ] [ k ] + B [ k ] [ j ] for k in r if A [ i ] [ k ] and B [ k ] [ j ] ] , default = 0 ) for j in r ] for i in r ]   def binpower ( A , n , e ) : r = range ( n ) B = A NEW_LINE


f = lambda : map ( int , input ( ) . split ( ) ) n , m = f ( ) t = list ( f ( ) ) s = [ 0 ] * 301 d = s [ : ] for i in t : d [ i ] += 1 for i in t * min ( m , 2 * n ) : s [ i ] = max ( s [ : i + 1 ] ) + 1 print ( max ( s ) + max ( ( m - n * 2 ) * max ( d ) , 0 ) ) NEW_LINE


f = lambda : map ( int , input ( ) . split ( ) )   n , m = f ( )   t = list ( f ( ) )   s = [ 0 ] * 301   d = s [ : ]   for i in t : d [ i ] += 1   for i in t * min ( m , 2 * n ) : s [ i ] = max ( s [ : i + 1 ] ) + 1   print ( max ( s ) + max ( ( m - n * 2 ) * max ( d ) , 0 ) )         NEW_LINE


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Solution { public static void main ( String [ ] args ) throws java . lang . Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter out = new PrintWriter ( System . out ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int t = Integer . parseInt ( st . nextToken ( ) ) ; int [ ] bit = new int [ 301 ] ; int [ ] count = new int [ 301 ] ; int max = 0 ; st = new StringTokenizer ( br . readLine ( ) ) ; int [ ] in = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { in [ i ] = Integer . parseInt ( st . nextToken ( ) ) ; count [ in [ i ] ] ++ ; max = Math . max ( max , count [ in [ i ] ] ) ; } int blocks = Math . min ( 10000 / n , t ) ; int [ ] a = new int [ n * blocks ] ; for ( int i = 0 ; i < n * blocks ; i ++ ) a [ i ] = in [ i % n ] ; int ans = 0 ; for ( int val : a ) ans = Math . max ( binaryIndexedTree ( bit , val ) , ans ) ; out . println ( ans + max * ( t - blocks ) ) ; out . close ( ) ; } public static int binaryIndexedTree ( int [ ] bit , int val ) { int res = 0 ; int value = val ; while ( val > 0 ) { res = Math . max ( bit [ val ] , res ) ; val -= ( - val ) & val ; } res ++ ; val = value ;   while ( val < bit . length ) { bit [ val ] = Math . max ( bit [ val ] , res ) ; val += ( - val ) & val ; } return res ; } }


# include < bits / stdc ++ . h > # define pb push_back # define int long longusing namespace std ; const int siz = 1e6 + 5 ; int t , n , T , m , x , pos , a [ siz ] , mx , cnt [ siz ] , dp [ siz ] ; int32_t main ( ) { ios_base :: sync_with_stdio ( 0 ) ; cin . tie ( 0 ) ;   cin >> n >> T ; for ( int i = 1 ; i <= n ; i ++ ) { cin >> a [ i ] ; cnt [ a [ i ] ] ++ ; mx = max ( mx , cnt [ a [ i ] ] ) ; } int ans = 0 ; int l = n ; while ( -- T && l < 10000 ) { for ( int i = 1 ; i <= n ; i ++ ) a [ ++ l ] = a [ i ] ; } for ( int i = 1 ; i <= l ; i ++ ) { dp [ i ] ++ ; for ( int j = 1 ; j < i ; j ++ ) if ( a [ i ] >= a [ j ] ) dp [ i ] = max ( dp [ i ] , 1 + dp [ j ] ) ; ans = max ( ans , dp [ i ] ) ; } cout << ans + mx * T << endl ; }


import java . util . ArrayList ; import java . util . Scanner ;   public class F {   public static void main ( String [ ] args ) { Scanner fs = new Scanner ( System . in ) ; int n = fs . nextInt ( ) , a = fs . nextInt ( ) , b = fs . nextInt ( ) ; int orig = a + b ; char [ ] line = fs . next ( ) . toCharArray ( ) ; ArrayList < Integer > sizes = new ArrayList < > ( ) ; int size = 0 ; for ( char c : line ) { if ( c == ' * ' ) { sizes . add ( size ) ; size = 0 ; } else { size ++ ; } } sizes . add ( size ) ; for ( int i : sizes ) { int big = ( i + 1 ) / 2 , small = i - big ; int bigger = Math . max ( a , b ) , smaller = Math . min ( a , b ) ; b = Math . max ( 0 , bigger - big ) ; a = Math . max ( 0 , smaller - small ) ; } System . out . println ( orig - a - b ) ; }   }

def solve ( n , a , b , seq ) : empty = 0 ans = 0 for index in range ( n ) : if seq [ index ] == ' . ' : empty += 1 else : half = empty // 2 half2 = empty - half if a > b : if a >= half2 : a -= half2 ans += half2 else : ans += a a = 0 if b >= half : b -= half ans += half else : ans += b b = 0 else : if b >= half2 : b -= half2 ans += half2 else : ans += b b = 0 if a >= half : a -= half ans += half else : ans += a a = 0 empty = 0 if a == 0 and b == 0 : break if ( a > 0 or b > 0 ) and empty > 0 : half = empty // 2 half2 = empty - half if a > b : if a >= half2 : a -= half2 ans += half2 else : ans += a a = 0 if b >= half : b -= half ans += half else : ans += b b = 0 else : if b >= half2 : b -= half2 ans += half2 else : ans += b b = 0 if a >= half : a -= half ans += half else : ans += a a = 0 return ans n , a , b = list ( map ( int , input ( ) . split ( ) ) ) seq = list ( input ( ) ) print ( solve ( n , a , b , seq ) ) NEW_LINE


n , a , b = map ( int , input ( ) . split ( ) ) aa = abb = bs = [ " * " ] + list ( input ( ) ) cnt = 0 for i in range ( 1 , n + 1 ) : if a == 0 and b == 0 : break elif s [ i ] == " . " and s [ i - 1 ] == " * " : if b > a : b -= 1 s [ i ] = " B " else : a -= 1 s [ i ] = " A " elif s [ i ] == " . " and s [ i - 1 ] != " * " : if s [ i - 1 ] == " B " : if a : a -= 1 s [ i ] = " A " else : s [ i ] = " * " elif s [ i - 1 ] == " A " : if b : b -= 1 s [ i ] = " B " else : s [ i ] = " * " n = len ( s ) for i in range ( n ) : if s [ i ] == " A " or s [ i ] == " B " : cnt += 1 print ( cnt ) NEW_LINE


n , a , b = map ( int , input ( ) . split ( ) ) s = a + bfor x in map ( len , input ( ) . split ( ' * ' ) ) : if a > b : a , b = b , a a -= min ( a , ( x // 2 ) ) b -= min ( b , ( x - x // 2 ) ) print ( s - a - b ) ; NEW_LINE


n , a , b = map ( int , input ( ) . split ( ) ) str = input ( ) ;   ans = 0 if a < b : c = a a = b b = c   tim = 1 for i in range ( n ) : if str [ i ] == ' * ' : if a < b : c = a a = b b = c tim = 1 else : if tim % 2 == 1 : if a > 0 : ans += 1 a -= 1 else : if b > 0 : ans += 1 b -= 1   tim += 1   print ( ans ) NEW_LINE


n , a , b = map ( int , input ( ) . split ( ) ) t = a + bfor x in map ( len , input ( ) . split ( ' * ' ) ) : if a < b : a , b = b , a b -= min ( b , x // 2 ) ; a -= min ( a , x - x // 2 ) print ( t - a - b ) NEW_LINE


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


import java . io . * ; import java . util . * ;      public class Main { public static void main ( String args [ ] ) { Scanner in ; PrintStream out ; try { in = new Scanner ( new FileInputStream ( " java . in " ) ) ; out = new PrintStream ( " java . out " ) ; } catch ( FileNotFoundException e ) { in = new Scanner ( new BufferedInputStream ( System . in ) ) ; out = System . out ; } int n , a , b ; n = in . nextInt ( ) ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; String s = in . next ( ) ; int ans = 0 , pre = - 1 ; for ( int i = 0 ; i < n && ( a > 0 || b > 0 ) ; i ++ ) { if ( s . charAt ( i ) != ' * ' ) { if ( pre != - 1 ) { if ( pre == 0 ) { if ( b > 0 ) { b -- ; ans ++ ; pre = 1 ; } else { pre = - 1 ; } } else { if ( a > 0 ) { a -- ; ans ++ ; pre = 0 ; } else { pre = - 1 ; } } } else { if ( a > b ) { pre = 0 ; a -- ; ans ++ ; } else { pre = 1 ; b -- ; ans ++ ; } } } else pre = - 1 ; } out . println ( ans ) ; } static class MyCom implements Comparator < Integer > { public int compare ( Integer i1 , Integer i2 ) { return i1 - i2 ; } } }


import java . util . Scanner ;   public class B1417 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int N = in . nextInt ( ) ; int sum = in . nextInt ( ) ; boolean even = ( sum % 2 == 0 ) ; int half = sum / 2 ; boolean halfToZero = true ; StringBuilder output = new StringBuilder ( ) ; for ( int n = 0 ; n < N ; n ++ ) { int a = in . nextInt ( ) ; int color ; if ( a > sum ) { color = 0 ; } else { if ( even && a == half ) { color = halfToZero ? 0 : 1 ; halfToZero = ! halfToZero ; } else { color = ( a <= half ) ? 0 : 1 ; } } output . append ( color ) . append ( ' ▁ ' ) ; } System . out . println ( output ) ; } }   }

import sys , functools , collections , bisect , math , NEW_LINE INDENT heapqinput = sys . stdin . readline NEW_LINE DEDENT


t = int ( input ( ) ) NEW_LINE for i in range ( t ) : n , T = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE flag = 0 NEW_LINE for i in range ( n ) : if NEW_LINE a [ i ] == T / 2 : NEW_LINE if flag == 0 : a [ i ] = 0 NEW_LINE flag = 1 else : a [ i ] = 1 NEW_LINE flag = 0 elif a [ i ] < T / 2 : a [ i ] = 0 else : a [ i ] = 1 NEW_LINE print ( * a ) NEW_LINE


import matht = int ( input ( ) ) NEW_LINE for _ in range ( t ) : n , t = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE r = t / 2 NEW_LINE ans = [ ] NEW_LINE m = 1 NEW_LINE for i in range ( 0 , n ) : if NEW_LINE a [ i ] < r : ans . append ( 1 ) elif a [ i ] > r : ans . append ( 0 ) else : ans . append ( m ) NEW_LINE m = 1 if m == 0 else 0 NEW_LINE print ( * ans ) NEW_LINE


for _ in range ( int ( input ( ) ) ) : n , t = map ( int , input ( ) . split ( ) ) NEW_LINE li = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE tmp = 0 NEW_LINE for i in range ( n ) : if NEW_LINE li [ i ] < t / 2 : li [ i ] = 0 elif li [ i ] > t / 2 : li [ i ] = 1 else : li [ i ] = tmp % 2 NEW_LINE tmp += 1 NEW_LINE print ( * li ) NEW_LINE


import java . util . Scanner ;   public class B {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; for ( int i = 0 ; i < t ; ++ i ) { int n = sc . nextInt ( ) ; int T = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] ans = new int [ n ] ; int eqCount = 0 ; for ( int j = 0 ; j < n ; ++ j ) { a [ j ] = sc . nextInt ( ) ;   if ( T % 2 == 0 && a [ j ] == T / 2 ) { if ( eqCount % 2 == 0 ) { ans [ j ] = 0 ; } else { ans [ j ] = 1 ; } eqCount ++ ; } else if ( a [ j ] <= T / 2 ) { ans [ j ] = 0 ; } else if ( a [ j ] >= T / 2 ) { ans [ j ] = 1 ; } } StringBuilder sb = new StringBuilder ( ) ; for ( int j = 0 ; j < n ; ++ j ) { if ( j > 0 ) { sb . append ( ' ▁ ' ) ; } sb . append ( ans [ j ] ) ; } System . out . println ( sb . toString ( ) ) ; }   } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Two_Arr1 { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int t = in . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; while ( t -- > 0 ) { int n = in . nextInt ( ) ; long k = in . nextLong ( ) ; int currmid = 0 ; int r = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long x = in . nextLong ( ) ; if ( ( k % 2 == 0 ) && x == k / 2 ) { r = ( currmid ++ ) % 2 ; } else if ( 2 * x < k ) { r = 0 ; } else { r = 1 ; } sb . append ( r + " ▁ " ) ; }   sb . append ( " \n " ) ;   } System . out . println ( sb ) ; } }


import java . math . BigInteger ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . Scanner ; import java . util . Vector ; import javafx . util . Pair ;   public class NewClass {   static int n11 = 100000 ; static boolean a11 [ ] = new boolean [ n11 + 1 ] ; static Vector < Long > v11 = new Vector ( ) ;   static long gcd ( long a , long b ) { if ( b == 0 ) { return a ; } return gcd ( b , a % b ) ; }   static void seive ( ) {


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 ( ) ; String s = input . next ( ) ; int left [ ] = new int [ 3 ] ; int right [ ] = new int [ 3 ] ; int first = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { left [ i ] = s . charAt ( i ) - '0' ; first += left [ i ] ; } int last = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { right [ i ] = s . charAt ( i + 3 ) - '0' ; last += right [ i ] ; } if ( first == last ) { System . out . println ( "0" ) ; return ; } int add [ ] = new int [ 6 ] ; if ( first > last ) { for ( int i = 0 ; i < 3 ; i ++ ) { add [ i ] = left [ i ] ; } for ( int i = 0 ; i < 3 ; i ++ ) { add [ i + 3 ] = 9 - right [ i ] ; }

def solve ( ) : s = input ( ) x = [ int ( z ) for z in s ] y , z = x [ : 3 ] , x [ 3 : ]   if sum ( y ) < sum ( z ) : y , z = z , y   a = sum ( y ) - sum ( z )   b = [ y [ - 1 ] , y [ - 2 ] , y [ - 3 ] , 9 - z [ 0 ] , 9 - z [ 1 ] , 9 - z [ 2 ] ] b . sort ( )   c = 0 cnt = 0 while c < a : c += b . pop ( ) cnt += 1   return cnt   print ( solve ( ) ) NEW_LINE


s = input ( ) mas = [ ] for i in range ( 6 ) : mas += [ int ( s [ i ] ) ] a , b = mas [ 0 : 3 ] , mas [ 3 : 6 ] if ( sum ( a ) < sum ( b ) ) : a , b = b , adelta = sum ( a ) - sum ( b ) a = sorted ( a , reverse = True ) b . sort ( ) ans , sum , l1 , l2 = 0 , 0 , 0 , 0   while ( sum < delta ) : if ( a [ l1 ] > 9 - b [ l2 ] ) : sum += a [ l1 ] l1 += 1 else : sum += 9 - b [ l2 ] l2 += 1 ans += 1   print ( ans ) NEW_LINE


import sysinput = sys . stdin . readlinedef print ( val ) : sys . stdout . write ( str ( val ) + ' \n ' ) def prog ( ) : s = input ( ) . strip ( ) min_change = 6 for i in range ( 10 ** 6 ) : new = '0' * ( 6 - len ( str ( i ) ) ) + str ( i ) first = 0 second = 0 for j in range ( 3 ) : first += int ( new [ j ] ) for j in range ( 3 , 6 ) : second += int ( new [ j ] ) if first == second : change = 0 for j in range ( 6 ) : change += s [ j ] != new [ j ] min_change = min ( min_change , change ) print ( min_change ) prog ( ) NEW_LINE


import sysfrom itertools import product   n = list ( map ( int , input ( ) ) )   ans = 6 for a in product ( range ( 10 ) , repeat = 6 ) : if a [ 0 ] + a [ 1 ] + a [ 2 ] == a [ 3 ] + a [ 4 ] + a [ 5 ] : x = sum ( 0 if n [ i ] == a [ i ] else 1 for i in range ( 6 ) ) ans = min ( ans , x )   print ( ans ) NEW_LINE


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 ( ) ; String s = input . next ( ) ; int a [ ] = new int [ 6 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { a [ i ] = s . charAt ( i ) - '0' ; } int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i <= 999999 ; i ++ ) { int temp [ ] = new int [ 6 ] ; String s1 = ( String . format ( " % 06d " , i ) ) ; for ( int j = 0 ; j < 6 ; j ++ ) { temp [ j ] = s1 . charAt ( j ) - '0' ; } if ( temp [ 0 ] + temp [ 1 ] + temp [ 2 ] != temp [ 3 ] + temp [ 4 ] + temp [ 5 ] ) { continue ; } int count = 0 ; for ( int j = 0 ; j < 6 ; j ++ ) { if ( temp [ j ] != a [ j ] ) { count ++ ; } } ans = Math . min ( ans , count ) ; } 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 . util . * ; import java . io . * ; import java . math . BigInteger ; public class lp1 { static PrintWriter out = new PrintWriter ( System . out ) ; static int [ ] p ; static int find ( int x ) { if ( x == p [ x ] ) return x ; return p [ x ] = find ( p [ x ] ) ; } static void union ( int x , int y ) { int rx = find ( x ) , ry = find ( y ) ; if ( rx == ry ) return ; p [ rx ] = ry ; } static void solve ( ) {

def bfs ( node , target ) :   visited [ node ] = 1 queue = [ node ]   while queue :   a = queue . pop ( 0 )   for j in adj [ a ] : if visited [ j ] == 0 : queue . append ( j ) visited [ j ] = 1 if j == target : return 1 return 0   import sys   input = sys . stdin . readline     n = int ( input ( ) )   t = list ( map ( int , input ( ) . split ( ) ) )   s = list ( map ( int , input ( ) . split ( ) ) )       adj = [ set ( ) for i in range ( n + 1 ) ]     for j in range ( 1 , n + 1 ) :   u = s [ j - 1 ]   a = ( j - u ) b = j + u   if 1 <= a <= n : adj [ j ] . add ( a ) adj [ a ] . add ( j )   if 1 <= b <= n : adj [ j ] . add ( b ) adj [ b ] . add ( j )     h = 0 for i in range ( n ) :   visited = [ 0 ] * ( n + 1 )   if i + 1 == t [ i ] : continue else : a = bfs ( i + 1 , t [ i ] )     if a == 0 : print ( ' NO ' ) h += 1 break   if h == 0 : print ( ' YES ' )     NEW_LINE


n = int ( input ( ) ) l = list ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) f = list ( map ( int , input ( ) . split ( ) ) )   class UnionFind : def __init__ ( self , n ) : self . parent = list ( range ( n ) )   def find ( self , a ) : acopy = a while a != self . parent [ a ] : a = self . parent [ a ] while acopy != a : self . parent [ acopy ] , acopy = a , self . parent [ acopy ] return a   def union ( self , a , b ) : self . parent [ self . find ( b ) ] = self . find ( a )   UF = UnionFind ( n ) for i in range ( n ) : if 0 <= i - f [ i ] : UF . union ( i , i - f [ i ] ) if i + f [ i ] < n : UF . union ( i , i + f [ i ] )   works = True   for i in range ( n ) : if UF . find ( i ) == UF . find ( l [ i ] ) : pass else : works = False break   if works : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE


n = int ( input ( ) ) per = list ( map ( int , input ( ) . split ( ) ) ) d = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) p = [ i for i in range ( n + 1 ) ] def find ( node ) : while p [ node ] != node : p [ node ] = p [ p [ node ] ] node = p [ node ] return node   def union ( n1 , n2 ) : p1 = find ( n1 ) p2 = find ( n2 )   if p1 != p2 : p [ p1 ] = p2   for i in range ( 1 , n + 1 ) : if i - d [ i ] > 0 and i - d [ i ] <= n : union ( i , i - d [ i ] ) if i + d [ i ] > 0 and i + d [ i ] <= n : union ( i , i + d [ i ] ) for i in range ( n ) : pa = find ( per [ i ] ) pa1 = find ( i + 1 ) if pa != pa1 : print ( " NO " ) ; breakelse : print ( " YES " ) NEW_LINE


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


import java . util . * ; import java . io . * ; import java . math . BigInteger ; public class lp1 { static PrintWriter out = new PrintWriter ( System . out ) ; static int [ ] p ; static int find ( int x ) {   if ( x == p [ x ] ) return x ; return p [ x ] = find ( p [ x ] ) ; } static void union ( int x , int y ) { int rx = find ( x ) , ry = find ( y ) ; if ( rx == ry ) return ; p [ rx ] = ry ; } static void solve ( ) { int n = ni ( ) ; p = new int [ n ] ; int a [ ] = ai ( n ) ; int f [ ] = ai ( n ) ; for ( int i = 0 ; i < n ; i ++ ) p [ i ] = i ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( i + f [ i ] ) < n ) union ( i , i + f [ i ] ) ; if ( ( i - f [ i ] ) >= 0 ) union ( i , i - f [ i ] ) ; } String f1 = " YES " ; for ( int i = 0 ; i < n ; i ++ ) if ( find ( i ) != find ( a [ i ] - 1 ) ) { f1 = " NO " ; break ; } pn ( f1 ) ; out . flush ( ) ; } public static void main ( String [ ] args ) throws Exception {   solve ( ) ;   } static int [ ] ai ( int n )


import java . util . Arrays ; import java . util . HashSet ; import java . util . Scanner ;   public class PainttheNumbers {   public static void main ( String args [ ] ) {   Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scan . nextInt ( ) ; } Arrays . sort ( a ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { if ( a [ j ] % a [ i ] == 0 ) { a [ j ] = a [ i ] ; } } } HashSet < Integer > ar = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { ar . add ( a [ i ] ) ; } System . out . println ( ar . size ( ) ) ; }   }

n = int ( input ( ) ) num2 = [ ] num = list ( map ( int , input ( ) . split ( ) ) ) num . sort ( ) count = 0   while len ( num ) != 0 : minno = min ( num ) count += 1 num2 = [ num [ i ] for i in range ( len ( num ) ) if num [ i ] % minno != 0 ] num . clear ( ) num . extend ( num2 ) num2 . clear ( ) print ( count ) NEW_LINE


n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) cnt = 0 while len ( a ) > 0 : a = list ( filter ( lambda x : x % min ( a ) != 0 , a ) ) cnt += 1 print ( cnt ) NEW_LINE


n = int ( input ( ) ) x = list ( map ( int , input ( ) . split ( ) ) )   x . sort ( )     if n > 1 : for i in range ( n ) : if x [ i ] != - 1 : for j in range ( i + 1 , n ) : if x [ j ] % x [ i ] == 0 : x [ j ] = - 1 count = 0   for i in x : if i != - 1 : count = count + 1   print ( count ) NEW_LINE


n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) c = 0 q = [ ] while l : m = min ( l ) for i in list ( l ) : if i % m == 0 : c += 1 l . remove ( i ) q . append ( c ) c = 0 print ( len ( q ) )     NEW_LINE


n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) color = flag = 0 l . sort ( )   for each in l : flag = 0 if ( each != - 1 ) : for each_color in range ( 0 , n ) : ele = l [ each_color ] if ( ele != - 1 and ele % each == 0 ) : flag = 1 l [ each_color ] = - 1 if ( flag == 1 ) : color += 1 print ( color ) NEW_LINE


import java . io . * ; import java . util . * ; import javax . print . attribute . standard . Finishings ;   import java . math . * ;   public class PaintNumbers { static final Random random = new Random ( ) ; static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Reader sc = new Reader ( ) ;   public static void main ( String args [ ] ) throws IOException {


import java . util . Arrays ; import java . util . Scanner ; import java . util . ArrayList ;    public class PaintTheNumbers { static int findMin ( ArrayList < Integer > arr ) { int n = arr . size ( ) ; int min = arr . get ( 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr . get ( i ) < min ) { min = arr . get ( i ) ; } } return min ; } static int findNumOfPaint ( ArrayList < Integer > arr ) { int n = arr . size ( ) ; int color = 0 ; while ( arr . isEmpty ( ) == false ) { int x = findMin ( arr ) ; color ++ ; for ( int i = 0 ; i < arr . size ( ) ; ) { if ( arr . get ( i ) % x == 0 ) { arr . remove ( i ) ; } else { i ++ ; } } } return color ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < Integer > arr ; arr = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { arr . add ( sc . nextInt ( ) ) ; } int ans = findNumOfPaint ( arr ) ; System . out . println ( ans ) ; } }


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } Arrays . sort ( arr ) ; int count = 0 ; boolean visited [ ] = new boolean [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { if ( visited [ i ] == true ) { continue ; } count ++ ; for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ j ] % arr [ i ] == 0 ) { visited [ j ] = true ; } } if ( check ( visited ) ) { System . out . println ( count ) ; } } } public static boolean check ( boolean visited [ ] ) { for ( int i = 0 ; i < visited . length ; i ++ ) { if ( visited [ i ] == false ) { return false ; } } return true ; } }


import java . io . * ; import java . net . Inet4Address ; import java . util . * ;


n = int ( input ( ) ) print ( n % 2 ) NEW_LINE


n = int ( input ( ) ) print ( [ 1 , 0 ] [ n % 2 == 0 ] ) NEW_LINE


import java . util . Scanner ; public class Q { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; if ( a % 2 == 0 ) { System . out . println ( "0" ) ; } else { System . out . println ( "1" ) ; } } }