import java . io . * ; import java . util . * ;   public class Main { static BufferedReader br ; static StringTokenizer st ;   static String nextToken ( ) { try { while ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; }   static int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; }   static char nextChar ( ) throws IOException { return ( char ) br . read ( ) ; }   private static long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; }   private static String nextString ( ) throws IOException { return br . readLine ( ) ; }   public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;

import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastScanner in = new FastScanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . run ( in , out ) ; out . close ( ) ; }   public static long mod = 17352642619633L ;   void run ( FastScanner in , PrintWriter out ) {   int N = in . nextInt ( ) ; TreeSet < int [ ] > ts = new TreeSet < > ( ( a , b ) -> { return a [ 0 ] == b [ 0 ] ? a [ 1 ] - b [ 1 ] : a [ 0 ] - b [ 0 ] ; } ) ; int sum = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int [ ] r = new int [ 2 ] ; r [ 0 ] = in . nextInt ( ) ; r [ 1 ] = i ; ts . add ( r ) ;   sum += r [ 0 ] ; }   List < List < Integer > > ans = new ArrayList < > ( ) ; for ( int i = 0 ; i < 10000 && ts . first ( ) [ 0 ] != ts . last ( ) [ 0 ] ; i ++ ) {   int diff = sum - N * ts . first ( ) [ 0 ] ;   int numPick = diff % 2 == 0 ? 2 : 3 ; numPick = Math . min ( numPick , N ) ;

n = ( int ( input ( ) ) ) R = list ( map ( int , input ( ) . split ( ) ) ) Time = 0 ; check = FalseOutput = [ ] while ( check == False ) : pos_max = [ ] ; pos_sec = [ ] ; Max_sec = - 1 ; Max_num = 0 ; Max = - 1 ; Min = 999999999 ; Time += 1 ; string = ' ' for i in range ( len ( R ) - 1 , - 1 , - 1 ) : if ( R [ i ] < Min ) : Min = R [ i ] if ( R [ i ] > Max ) : Max_sec = Max ; Max = R [ i ] ; pos_sec = pos_max ; pos_max = [ ] ; pos_max . append ( i ) ; Max_num = 1 elif ( R [ i ] == Max ) : Max_num += 1 ; pos_max . append ( i ) elif ( R [ i ] > Max_sec ) : Max_sec = R [ i ] pos_sec = [ ] pos_sec . append ( i ) NEW_LINE

n = int ( input ( ) )   L = list ( map ( int , input ( ) . split ( ) ) )   ans = 0   M = [ ]   while max ( L ) != min ( L ) :   ans += 1   k = max ( L )   if L . count ( k ) == 3 :   s = ' '   for i in range ( len ( L ) ) :   if L [ i ] == k :   s += '1'   L [ i ] -= 1   else :   s += '0'   M . append ( s )           else :               max_1 = 0   max_2 = 1   if L [ max_1 ] < L [ max_2 ] :   max_1 , max_2 = max_2 , max_1   for i in range ( 2 , n ) :   if L [ i ] > L [ max_1 ] :   max_2 , max_1 = max_1 , i   elif L [ i ] > L [ max_2 ] :   max_2 = i   s = ' '   for i in range ( n ) :   if i == max_1 or i == max_2 :   s += '1'   else :   s += '0'   M . append ( s )   L [ max_1 ] -= 1   if L [ max_1 ] < 0 :   L [ max_1 ] = 0   L [ max_2 ] -= 1   if L [ max_2 ] < 0 :   L [ max_2 ] = 0   print ( max ( L ) )   print ( ans )   for i in M :   print ( i )       NEW_LINE


import java . math . BigInteger ; import java . util . Scanner ;   public class A185 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long N = in . nextLong ( ) ; BigInteger bigN = BigInteger . valueOf ( N ) ; BigInteger two = BigInteger . valueOf ( 2 ) ; BigInteger mod = BigInteger . valueOf ( 1000000007 ) ; BigInteger power = two . modPow ( bigN , mod ) ; long result = power . add ( BigInteger . ONE ) . multiply ( power ) . divide ( two ) . mod ( mod ) . longValue ( ) ; System . out . println ( result ) ; }   }

n = int ( input ( ) ) m = pow ( 10 , 9 ) + 7 if n == 0 : print ( 1 ) else : print ( ( pow ( 2 , 2 * n - 1 , m ) + pow ( 2 , n - 1 , m ) ) % m ) NEW_LINE

z = 1000000007 def f ( a , m ) : p = 1 while m : if m % 2 : p = ( p * a ) % z m -= 1 else : m //= 2 a = ( a * a ) % z return pn = int ( input ( ) ) x = f ( 2 , n ) print ( ( x * ( x + 1 ) // 2 ) % z ) NEW_LINE


import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Compressing { public static class pair { double dist ; int pop ; public pair ( double dist , int pop ) { this . dist = dist ; this . pop = pop ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int pop = sc . nextInt ( ) ; pair [ ] ar = new pair [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; double dist = Math . sqrt ( x * x + y * y ) ; ar [ i ] = new pair ( dist , c ) ; } Arrays . sort ( ar , ( a , b ) -> Double . compare ( a . dist , b . dist ) ) ; int i = 0 ; while ( pop < 1000000 && i < n ) { pop += ar [ i ] . pop ;

import java . util . * ;   public class Main {   public static double distance ( double x , double y ) { return Math . sqrt ( ( x * x ) + ( y * y ) ) ; }   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; long s = input . nextLong ( ) ; double a [ ] [ ] = new double [ n ] [ 2 ] ; TreeMap < Double , Long > map = new TreeMap < > ( ) ; long sum = s ; for ( int i = 0 ; i < n ; i ++ ) { double x = input . nextDouble ( ) ; double y = input . nextDouble ( ) ; long people = input . nextLong ( ) ; double key = distance ( x , y ) ; map . put ( key , map . getOrDefault ( key , 0L ) + people ) ; sum += people ; } if ( sum < 1000000 ) { System . out . println ( " - 1" ) ; } else { for ( Map . Entry < Double , Long > entry : map . entrySet ( ) ) { Long value = entry . getValue ( ) ; s += value ; if ( s >= 1000000 ) { System . out . println ( entry . getKey ( ) ) ; return ; } } }   }   }

import java . lang . * ; import java . util . * ; import java . io . * ;   public class Codeforces {   public void solve ( ) throws IOException { FastScanner fs = new FastScanner ( ) ; StringBuilder print = new StringBuilder ( ) ; int n = fs . nextInt ( ) , pop = fs . nextInt ( ) ; Places [ ] places = new Places [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int x = fs . nextInt ( ) , y = fs . nextInt ( ) , p = fs . nextInt ( ) ; float d = x * x + y * y ; places [ i ] = new Places ( d , p ) ; } Arrays . sort ( places , ( o1 , o2 ) -> { if ( o1 . r != o2 . r ) return ( int ) ( o1 . r - o2 . r ) ; else return o2 . pop - o1 . pop ; } ) ; for ( int i = 0 ; i < n ; i ++ ) { pop += places [ i ] . pop ; if ( pop >= 1000000 ) { System . out . printf ( " % .6f % n " , Math . sqrt ( places [ i ] . r ) ) ; return ; } } System . out . println ( " - 1" ) ; } class Places { float r ; int pop ; Places ( float r , int pop ) { this . r = r ; this . pop = pop ; } } public static void main ( String [ ] args ) throws IOException { try { new Codeforces ( ) . solve ( ) ; } catch ( Exception e ) {

n , p = map ( int , input ( ) . split ( ) ) dic = { } for i in range ( n ) : x , y , t = map ( int , input ( ) . split ( ) ) dist = ( ( x ** 2 ) + ( y ** 2 ) ) ** .5 if dist in dic . keys ( ) : dic [ dist ] = dic [ dist ] + t else : dic [ dist ] = tfor j in sorted ( dic ) : p = p + dic [ j ] if p >= 1000000 : print ( j ) breakelse : print ( - 1 ) NEW_LINE

from sys import stdin , stdoutfrom math import sqrtnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) sq = lambda x , y : ( x * x + y * y ) mega = 10 ** 6 def fn ( rad ) : sm = init for a , b , pop in l1 : if sq ( a , b ) <= rad : sm += pop if sm >= mega : return True return Falsefor _ in range ( 1 ) : NEW_LINE

from math import sqrt as rfrom collections import defaultdict as dq   n , s = map ( int , input ( ) . split ( ) )   left = 1000000 - s   d = dq ( int ) for i in range ( n ) : x , y , k = map ( int , input ( ) . split ( ) ) d [ x , y ] = k   minm = float ( ' inf ' ) f = 0 for k1 , v1 in d . items ( ) : xc = abs ( k1 [ 0 ] ) yc = abs ( k1 [ 1 ] ) total = 0 rad = round ( r ( xc ** 2 + ( yc ** 2 ) ) , 7 ) for k2 , v2 in d . items ( ) : if round ( r ( k2 [ 0 ] ** 2 + ( k2 [ 1 ] ** 2 ) ) , 7 ) <= rad : total += v2 if total >= left : if rad < minm : minm = rad f = 1   print ( minm if f == 1 else - 1 ) NEW_LINE

import mathn , s = map ( int , input ( ) . split ( ) ) dist = [ ] for _ in range ( n ) : x , y , k = map ( int , input ( ) . split ( ) ) dist . append ( [ math . sqrt ( x * x + y * y ) , k ] ) left = 1000000 - sdist . sort ( key = lambda x : x [ 0 ] ) ans = 0 i = - 1 while ans < left : i += 1 if i == n : break ans = ans + dist [ i ] [ 1 ] if i >= 0 and i < n : print ( dist [ i ] [ 0 ] ) else : print ( " - 1" ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . Arrays ; import java . io . BufferedWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . Writer ; import java . io . OutputStreamWriter ; import java . util . NoSuchElementException ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { new Thread ( null , new TaskA ( ) , " qqq " , 256 * 1024 * 1024 ) . start ( ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . NoSuchElementException ; import java . util . StringTokenizer ;   public class CodeforceSol11a { static FastScanner in ; static PrintWriter out ; public static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( 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 ( ) ) ; } }   public static void main ( String [ ] args ) {

import sys   class Node : def __init__ ( self , d ) : global nodes self . ch = { } self . a = [ [ ] , [ ] ] self . d = d nodes += [ self ]   nodes = [ ] pairs = [ ] res = 0   N = int ( sys . stdin . readline ( ) ) _input = sys . stdin . readlines ( ) _input = [ s [ : - 1 ] for s in _input ] A = [ _input [ : N ] , _input [ N : ] ] T = Node ( 0 )   for i , l in enumerate ( A ) : for j , s in enumerate ( l ) : t = T for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : t . ch [ v ] = Node ( t . d + 1 ) t = t . ch [ v ] t . a [ i ] += [ j + 1 ]   for n in reversed ( nodes ) : for i in n . ch : n . a [ 0 ] += n . ch [ i ] . a [ 0 ] n . a [ 1 ] += n . ch [ i ] . a [ 1 ] k = min ( len ( n . a [ 0 ] ) , len ( n . a [ 1 ] ) ) for i in range ( k ) : pairs += [ str ( n . a [ 0 ] [ - 1 ] ) + ' ▁ ' + str ( n . a [ 1 ] [ - 1 ] ) ] n . a [ 0 ] . pop ( ) n . a [ 1 ] . pop ( ) res += n . d   print ( res ) print ( ' \n ' . join ( pairs ) ) NEW_LINE

import sys   SIGMA = 26   nodes = [ ] pairs = [ ] res = 0   class Node : def __init__ ( self ) : self . ch = { } self . a = [ ] self . b = [ ] self . d = 0   def add ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : t . ch [ v ] = Node ( ) t . ch [ v ] . d = t . d + 1 nodes . append ( t . ch [ v ] ) t = t . ch [ v ] t . a . append ( i )   def inc ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : break t = t . ch [ v ] t . b . append ( i )   def solve ( self ) : global pairs global res for i in range ( SIGMA ) : if i in self . ch : self . a . extend ( self . ch [ i ] . a ) self . b . extend ( self . ch [ i ] . b ) k = min ( len ( self . a ) , len ( self . b ) ) for i in range ( k ) : pairs . append ( str ( self . a [ - 1 ] ) + ' ▁ ' + str ( self . b [ - 1 ] ) ) self . a . pop ( ) self . b . pop ( ) res += self . d return res   sys . setrecursionlimit ( 2000000 ) _input = sys . stdin . readlines ( ) _input = [ s [ : - 1 ] for s in _input ] N = int ( _input [ 0 ] ) A = _input [ 1 : N + 1 ] B = _input [ N + 1 : ] T = Node ( ) nodes . append ( T ) for i , s in enumerate ( A ) : T . add ( s , i + 1 ) for i , s in enumerate ( B ) : T . inc ( s , i + 1 ) for n in reversed ( nodes ) : n . solve ( ) print ( res ) print ( ' \n ' . join ( pairs ) ) NEW_LINE

import sys   SIGMA = 26   nodes = [ ] pairs = [ ] res = 0   class Node : def __init__ ( self ) : self . ch = { } self . a = [ ] self . b = [ ] self . d = 0   def add ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : t . ch [ v ] = Node ( ) t . ch [ v ] . d = t . d + 1 nodes . append ( t . ch [ v ] ) t = t . ch [ v ] t . a . append ( i )   def inc ( self , s , i ) : t = self for c in s : v = ord ( c ) - ord ( ' a ' ) if not v in t . ch : break t = t . ch [ v ] t . b . append ( i )   def solve ( self ) : global pairs global res for i in range ( SIGMA ) : if i in self . ch : self . a . extend ( self . ch [ i ] . a ) self . b . extend ( self . ch [ i ] . b ) k = min ( len ( self . a ) , len ( self . b ) ) for i in range ( k ) : pairs . append ( str ( self . a [ - 1 ] ) + ' ▁ ' + str ( self . b [ - 1 ] ) ) self . a . pop ( ) self . b . pop ( ) res += self . d return res   _input = sys . stdin . readlines ( ) _input = [ s [ : - 1 ] for s in _input ] N = int ( _input [ 0 ] ) A = _input [ 1 : N + 1 ] B = _input [ N + 1 : ] T = Node ( ) nodes . append ( T ) for i , s in enumerate ( A ) : T . add ( s , i + 1 ) for i , s in enumerate ( B ) : T . inc ( s , i + 1 ) for n in reversed ( nodes ) : n . solve ( ) print ( res ) print ( ' \n ' . join ( pairs ) ) NEW_LINE


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

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . * ; public class cdfmu2b { static void merge ( int arr [ ] , int l , int m , int r ) { int n1 = m - l + 1 ; int n2 = r - m ; int L [ ] = new int [ n1 ] ; int R [ ] = new int [ n2 ] ; for ( int i = 0 ; i < n1 ; ++ i ) L [ i ] = arr [ l + i ] ; for ( int j = 0 ; j < n2 ; ++ j ) R [ j ] = arr [ m + 1 + j ] ; int i = 0 , j = 0 ; int k = l ; while ( i < n1 && j < n2 ) { if ( L [ i ] <= R [ j ] ) { arr [ k ] = L [ i ] ; i ++ ; } else { arr [ k ] = R [ j ] ; j ++ ; } k ++ ; } while ( i < n1 ) { arr [ k ] = L [ i ] ; i ++ ; k ++ ; } while ( j < n2 ) { arr [ k ] = R [ j ] ; j ++ ; k ++ ; } } static void sort ( int arr [ ] , int l , int r ) { if ( l < r ) { int m = ( l + r ) / 2 ; sort ( arr , l , m ) ; sort ( arr , m + 1 , r ) ; merge ( arr , l , m , r ) ; } } public static int lowerBound ( int [ ] array , int length , int value ) { int low = 0 ; int high = length ; while ( low < high ) { final int mid = ( low + high ) / 2 ;

from collections import defaultdictb , q , l , m = map ( int , input ( ) . split ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] d = defaultdict ( bool ) for i in arr : d [ i ] = Trueif ( b == 0 ) : if ( d [ b ] ) : print ( 0 ) else : print ( " inf " ) elif ( q == 0 ) : if ( abs ( b ) > l ) : print ( 0 ) else : ans = 0 if ( not d [ b ] ) : ans += 1 if ( d [ 0 ] ) : print ( ans ) else : print ( " inf " )   elif ( q == 1 ) : if ( abs ( b ) > l ) : print ( 0 ) else : if ( d [ b ] ) : print ( 0 ) else : print ( " inf " ) elif ( q == - 1 ) : if ( abs ( b ) > l ) : print ( 0 ) else : if ( d [ b ] and d [ - b ] ) : print ( 0 ) else : print ( " inf " ) else : possible = [ ] curr = b while ( abs ( curr ) <= l ) : if ( not d [ curr ] ) : possible . append ( curr ) curr *= q print ( len ( possible ) ) NEW_LINE

b1 , q , l , m = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) if abs ( b1 ) > l : print ( 0 ) elif b1 == 0 : if b1 in a : print ( 0 ) else : print ( ' inf ' ) elif q == 1 : if b1 in a : print ( 0 ) else : print ( ' inf ' ) elif q == - 1 : if b1 in a and - b1 in a : print ( 0 ) else : print ( ' inf ' ) elif q == 0 : if 0 not in a : print ( ' inf ' ) elif b1 in a : print ( 0 ) else : print ( 1 ) else : ans = 0 while abs ( b1 ) <= l : if b1 not in a : ans = ans + 1 b1 = b1 * q print ( ans ) NEW_LINE

a , b , c , d = map ( int , input ( ) . split ( ) ) l = set ( list ( map ( int , input ( ) . split ( ) ) ) ) if ( abs ( a ) > c ) : print ( 0 ) exit ( 0 ) if ( a == 0 ) : if 0 in l : print ( 0 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) if ( b == 1 ) : if a in l : print ( 0 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) if ( b == - 1 ) : if ( - a in l ) and ( a in l ) : print ( 0 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) if ( b == 0 ) : if 0 in l : if a in l : print ( 0 ) exit ( 0 ) else : print ( 1 ) exit ( 0 ) else : print ( " inf " ) exit ( 0 ) ans = 0 while ( abs ( a ) <= c ) : if ( a not in l ) : ans += 1 a = a * bprint ( ans ) NEW_LINE

b , q , L , m = map ( int , input ( ) . split ( ) ) p = list ( map ( int , input ( ) . split ( ) ) )   def solve ( b , q , L , m , p ) : if q == 1 : if b in p : return 0 elif abs ( b ) <= L : return ' inf ' else : return 0 if q == - 1 : if ( b not in p or - b not in p ) and abs ( b ) <= L : return ' inf ' else : return 0 if q == 0 : if 0 not in p and abs ( b ) <= L : return ' inf ' elif b in p or not abs ( b ) <= L : return 0 else : return 1 if b == 0 : if 0 not in p : return ' inf ' else : return 0 s = 0 while abs ( b ) <= L : if b not in p : s += 1 b = b * q return s   print ( solve ( b , q , L , m , p ) ) NEW_LINE


import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; import java . lang . Math ; public class Account { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int m = sc . nextInt ( ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ;   int pictures = input . nextInt ( ) ; int painters = input . nextInt ( ) ; int a [ ] [ ] = new int [ pictures + 1 ] [ painters + 1 ] ; for ( int i = 1 ; i <= pictures ; i ++ ) { for ( int j = 1 ; j <= painters ; j ++ ) { a [ i ] [ j ] = Math . max ( a [ i ] [ j - 1 ] , a [ i - 1 ] [ j ] ) + input . nextInt ( ) ; } } for ( int i = 1 ; i <= pictures ; i ++ ) { System . out . print ( a [ i ] [ painters ] + " ▁ " ) ; } System . out . println ( " " ) ; }   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 . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class Task416B { public static void main ( String [ ] args ) throws IOException { Task416B task = new Task416B ( ) ; task . resolve ( ) ; }   private void resolve ( ) throws IOException { BufferedReader bufferedReader = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   String [ ] strings = bufferedReader . readLine ( ) . split ( " ▁ " ) ; int pictureCount = Integer . parseInt ( strings [ 0 ] ) ; int artistCount = Integer . parseInt ( strings [ 1 ] ) ;   int [ ] [ ] drawTime = new int [ pictureCount ] [ artistCount ] ; for ( int i = 0 ; i < pictureCount ; i ++ ) { strings = bufferedReader . readLine ( ) . split ( " ▁ " ) ; for ( int j = 0 ; j < artistCount ; j ++ ) { drawTime [ i ] [ j ] = Integer . parseInt ( strings [ j ] ) ; } }   int [ ] [ ] endTime = new int [ pictureCount ] [ artistCount ] ; endTime [ 0 ] [ 0 ] = drawTime [ 0 ] [ 0 ] ; for ( int i = 1 ; i < artistCount ; i ++ ) { endTime [ 0 ] [ i ] = drawTime [ 0 ] [ i ] + endTime [ 0 ] [ i - 1 ] ; }   for ( int i = 1 ; i < pictureCount ; i ++ ) { endTime [ i ] [ 0 ] = drawTime [ i ] [ 0 ] + endTime [ i - 1 ] [ 0 ] ; }   for ( int i = 1 ; i < pictureCount ; i ++ ) { for ( int j = 1 ; j < artistCount ; j ++ ) { endTime [ i ] [ j ] = Math . max ( endTime [ i - 1 ] [ j ] , endTime [ i ] [ j - 1 ] ) + drawTime [ i ] [ j ] ; } }   for ( int i = 0 ; i < pictureCount ; i ++ ) { System . out . print ( endTime [ i ] [ artistCount - 1 ] + " ▁ " ) ; } } }

m , n = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( m ) : k = list ( map ( int , input ( ) . split ( ) ) ) l . append ( k ) p = [ 0 ] * 6 for i in range ( m ) : for j in range ( 1 , n + 1 ) : p [ j ] = max ( p [ j ] , p [ j - 1 ] ) p [ j ] += l [ i ] [ j - 1 ] print ( p [ n ] , end = ' ▁ ' ) NEW_LINE

from itertools import accumulatem , n = map ( int , input ( ) . split ( ) ) t = [ ] for i in range ( m ) : arr = list ( map ( int , input ( ) . split ( ) ) ) t . append ( arr ) d = [ 0 ] * mfor i in range ( n ) : d [ 0 ] += t [ 0 ] [ i ] for j in range ( 1 , m ) : d [ j ] = max ( d [ j - 1 ] , d [ j ] ) + t [ j ] [ i ] print ( * d ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) x = [ ] for i in range ( n ) : x . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 1 , m ) : x [ 0 ] [ i ] += x [ 0 ] [ i - 1 ] for i in range ( 1 , n ) : for j in range ( m ) : if j == 0 : x [ i ] [ j ] += x [ i - 1 ] [ j ] else : x [ i ] [ j ] += max ( x [ i - 1 ] [ j ] , x [ i ] [ j - 1 ] ) for i in x : print ( i [ - 1 ] , end = " ▁ " ) NEW_LINE

import sysimport mathdef fn ( n , m , a ) : if n == 1 : t1 = 0 for i in range ( m ) : t1 = t1 + a [ i ] [ 0 ] print ( t1 , end = ' ▁ ' ) return 0 t = [ 0 ] * n t [ 0 ] = a [ 0 ] [ 0 ] for i in range ( 1 , n ) : t [ i ] = a [ 0 ] [ i ] + t [ i - 1 ] print ( t [ n - 1 ] , end = ' ▁ ' ) for i in range ( 1 , m ) : t [ 0 ] = t [ 0 ] + a [ i ] [ 0 ] for j in range ( n - 1 ) : if t [ j + 1 ] < t [ j ] : t [ j + 1 ] = a [ i ] [ j + 1 ] + t [ j ] else : t [ j + 1 ] = t [ j + 1 ] + a [ i ] [ j + 1 ] print ( t [ n - 1 ] , end = ' ▁ ' ) if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( int , input . split ( ) ) ) n = ( data [ 1 ] ) m = data [ 0 ] a = [ [ 0 ] * n for i in range ( m ) ] l = data [ 2 : ] k = 0 for i in range ( m ) : for j in range ( n ) : a [ i ] [ j ] = l [ k ] k = k + 1 ( fn ( n , m , a ) ) NEW_LINE

m , n = map ( int , input ( ) . split ( ) ) t = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( m ) ] cnt = [ [ 0 ] * n for i in range ( m ) ] for i in range ( m ) : for j in range ( n ) : if i == j == 0 : cnt [ i ] [ j ] = t [ i ] [ j ] elif i == 0 : cnt [ i ] [ j ] = cnt [ i ] [ j - 1 ] + t [ i ] [ j ] elif j == 0 : cnt [ i ] [ j ] = cnt [ i - 1 ] [ j ] + t [ i ] [ j ] else : cnt [ i ] [ j ] = max ( cnt [ i - 1 ] [ j ] , cnt [ i ] [ j - 1 ] ) + t [ i ] [ j ] ans = [ ] for i in range ( m ) : ans . append ( cnt [ i ] [ n - 1 ] ) print ( * ans ) NEW_LINE


import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) {   Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; String newstr = s . replaceAll ( " a " , " " ) ;   int removedcharlength = s . length ( ) - newstr . length ( ) ; int midindex = newstr . length ( ) / 2 ; if ( newstr . substring ( 0 , midindex ) . equals ( newstr . substring ( midindex ) ) ) { String strz = s . substring ( 0 , midindex + removedcharlength ) . replaceAll ( " a " , " " ) ;   if ( s . substring ( midindex + removedcharlength ) . equals ( strz ) ) System . out . println ( s . substring ( 0 , midindex + removedcharlength ) ) ; else System . out . println ( " : ( " ) ; } else System . out . println ( " : ( " ) ;   }   }

import java . util . * ; public class file { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; String str = scn . nextLine ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( char c : str . toCharArray ( ) ) { if ( c != ' a ' ) { sb . append ( c ) ; } } if ( sb . length ( ) % 2 == 0 ) { if ( sb . substring ( 0 , sb . length ( ) / 2 ) . equals ( sb . substring ( sb . length ( ) / 2 , sb . length ( ) ) ) ) { if ( str . substring ( str . length ( ) - sb . length ( ) / 2 , str . length ( ) ) . equals ( sb . substring ( 0 , sb . length ( ) / 2 ) ) ) { System . out . println ( str . substring ( 0 , str . length ( ) - sb . length ( ) / 2 ) ) ; } else { System . out . println ( " : ( " ) ; } } else { System . out . println ( " : ( " ) ; } } else { System . out . println ( " : ( " ) ; } } }

import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String t = in . next ( ) ; String s = t . substring ( 0 , ( int ) ( t . length ( ) + t . chars ( ) . filter ( c -> c == ' a ' ) . count ( ) ) / 2 ) ; System . out . println ( t . equals ( s + s . replaceAll ( " a " , " " ) ) ? s : " : ( " ) ; } }

def check ( t , n ) : flag = True if n % 2 != 0 : return False mid = n // 2 i = 0 while i < n // 2 : if t [ i ] != t [ mid ] : flag = False break i += 1 mid += 1 return flagif __name__ == ' _ _ main _ _ ' : t = input ( ) n = len ( t ) S = set ( t ) if len ( S ) == 1 and ' a ' in S : print ( t ) elif t . count ( ' a ' ) == 0 : if n % 2 == 1 : print ( ' : ( ' ) else : if not check ( t , n ) : print ( ' : ( ' ) else : print ( t [ : n // 2 ] ) else : s = ' ' for i in range ( n ) : if t [ i ] != ' a ' : s += t [ i ] if check ( s , len ( s ) ) : s = s [ len ( s ) // 2 : ] if t [ n - len ( s ) : ] == s : print ( t [ : n - len ( s ) ] ) else : print ( ' : ( ' ) else : print ( ' : ( ' ) NEW_LINE

t = input ( ) c = 0 n = len ( t ) s = ' ' a = ' : ( ' for i in range ( n ) : if i - c == n - i : if s == t [ i : ] : a = t [ : i ] break if t [ i ] == ' a ' : c += 1 if t [ i ] != ' a ' : s += t [ i ] if c == n : print ( t ) else : print ( a ) NEW_LINE

T = input ( ) Tp = ' '   for i in T : Tp += ( i , ' ' ) [ i == ' a ' ]   l = len ( Tp ) k = len ( T )   if l % 2 == 1 : print ( ' : ( ' ) exit ( 0 )   for i , j in zip ( range ( 1 + l // 2 ) , range ( l // 2 , l ) ) : if not Tp [ i ] == Tp [ j ] : print ( ' : ( ' ) exit ( 0 )   for i in range ( k - l // 2 , k ) : if T [ i ] == ' a ' : print ( ' : ( ' ) exit ( 0 )   for i in range ( k - l // 2 ) : print ( T [ i ] , end = ' ' ) NEW_LINE

def check ( arr , s ) : if len ( arr ) != len ( s ) : return False n = len ( arr ) for i in range ( n ) : if arr [ i ] != s [ i ] : return False return Trues = input ( ) n = len ( s ) cta = s . count ( ' a ' ) ans = " : ( " new = 0 if cta == n : ans = selif cta == 0 : if n % 2 == 0 and s [ : n // 2 ] == s [ n // 2 : ] : ans = s [ : n // 2 ] else : ind = 0 rem = [ ] for i in range ( n ) : if s [ i ] == ' a ' : ind = i for i in range ( ind ) : if s [ i ] != ' a ' : rem . append ( s [ i ] ) new += 1 for i in range ( ind + 1 , n ) : rem_len = n - i if rem_len == new : if check ( rem , s [ i : ] ) : ans = s [ : i ] break else : rem . append ( s [ i ] ) new += 1 print ( ans ) NEW_LINE


import java . util . Scanner ;   public class Nineteen {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s ; s = scanner . nextLine ( ) ; System . out . println ( enumerate ( s ) ) ; }   public static int enumerate ( String source ) { byte [ ] counter = new byte [ ] { - 1 , 0 , 0 , 0 } ; for ( char ch : source . toCharArray ( ) ) { switch ( ch ) { case ' n ' : counter [ 0 ] ++ ; break ; case ' i ' : counter [ 1 ] ++ ; break ; case ' e ' : counter [ 2 ] ++ ; break ; case ' t ' : counter [ 3 ] ++ ; break ; } }   counter [ 0 ] /= 2 ; counter [ 2 ] /= 3 ; int min1 = Math . min ( counter [ 0 ] , counter [ 1 ] ) ; int min2 = Math . min ( counter [ 2 ] , counter [ 3 ] ) ; int min = Math . min ( min1 , min2 ) ; return min ; } }

import java . math . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ;   int n = 0 ; int t = 0 ; int i = 0 ; int e = 0 ; for ( int x = 0 ; x < s . length ( ) ; x ++ ) { if ( s . charAt ( x ) == ' n ' ) n ++ ; if ( s . charAt ( x ) == ' t ' ) t ++ ; if ( s . charAt ( x ) == ' i ' ) i ++ ; if ( s . charAt ( x ) == ' e ' ) e ++ ; } n = ( n - 1 ) / 2 ; e = e / 3 ; int c = Math . min ( n , t ) ; int d = Math . min ( e , i ) ; int z = Math . min ( c , d ) ; System . out . println ( z ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class Game { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   String str = input . nextLine ( ) ; int [ ] freq = new int [ 4 ] ; Arrays . fill ( freq , 0 ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { switch ( str . charAt ( i ) ) { case ' n ' : freq [ 0 ] ++ ; break ;   case ' i ' : freq [ 1 ] ++ ; break ;   case ' e ' : freq [ 2 ] ++ ; break ;   case ' t ' : freq [ 3 ] ++ ; break ;   default : break ; } } if ( freq [ 0 ] < 3 || freq [ 1 ] < 1 || freq [ 2 ] < 3 || freq [ 3 ] < 1 ) { System . out . println ( 0 ) ; return ; }   int ans = 0 ; if ( freq [ 0 ] >= 3 && freq [ 1 ] >= 1 && freq [ 2 ] >= 3 && freq [ 3 ] >= 1 ) { freq [ 0 ] -- ; } while ( ( freq [ 0 ] >= 2 && ( freq [ 0 ] % 3 <= 2 ) ) && freq [ 1 ] >= 1 && freq [ 2 ] >= 3 && freq [ 3 ] >= 1 ) { freq [ 0 ] -= 2 ; freq [ 1 ] -- ; freq [ 2 ] -= 3 ; freq [ 3 ] -- ; ans ++ ; } System . out . println ( ans ) ;   } }

import java . util . Arrays ; import java . util . Scanner ; import java . util . Stack ;   public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   while ( sc . hasNext ( ) ) { String source = sc . nextLine ( ) ; int n = 0 ; int e = 0 ; int i = 0 ; int t = 0 ; for ( int j = 0 ; j < source . length ( ) ; j ++ ) { if ( source . charAt ( j ) == ' n ' ) { n ++ ; } if ( source . charAt ( j ) == ' e ' ) { e ++ ; } if ( source . charAt ( j ) == ' t ' ) { t ++ ; } if ( source . charAt ( j ) == ' i ' ) { i ++ ; }   } n = ( n - 1 ) / 2 ; e /= 3 ; int min1 = Math . min ( n , e ) ; int min2 = Math . min ( i , t ) ; int min = Math . min ( min1 , min2 ) ; System . out . println ( min ) ; }   } }

a = str ( input ( ) ) import collectionscnt = collections . Counter ( a ) ans = min ( { ( cnt [ ' n ' ] - 1 ) // 2 , cnt [ ' e ' ] // 3 , cnt [ ' i ' ] , cnt [ ' t ' ] } ) if ans < 1 : print ( 0 ) else : print ( ans ) NEW_LINE

str = input ( ) ans = { ' n ' : 0 , ' i ' : 0 , ' e ' : 0 , ' t ' : 0 } for i in str : if i in ans : ans [ i ] += 1 ans [ ' n ' ] -= 1 ans [ ' n ' ] //= 2 ans [ ' e ' ] //= 3 ans = min ( ans . values ( ) ) print ( ans if ans > 0 else 0 ) NEW_LINE

a = input ( ) b = a . count ( ' n ' ) c = a . count ( ' i ' ) d = a . count ( ' e ' ) e = a . count ( ' t ' )   if b > 4 : print ( min ( ( b - 1 ) // 2 , c , d // 3 , e ) ) elif b == 3 or b == 4 : print ( min ( 1 , c , d // 3 , e ) ) else : print ( 0 ) NEW_LINE

st = input ( ) nn = st . count ( ' n ' ) ne = st . count ( ' e ' ) ni = st . count ( ' i ' ) nt = st . count ( ' t ' )   ans = min ( ( nn - 1 ) // 2 , ne // 3 , ni , nt ) print ( max ( ans , 0 ) ) NEW_LINE

word = input ( ) n = word . count ( ' n ' ) i = word . count ( ' i ' ) e = word . count ( ' e ' ) t = word . count ( ' t ' )   if ( n < 3 ) : print ( 0 ) else : print ( min ( ( n - 1 ) // 2 , i , e // 3 , t ) ) NEW_LINE


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

import java . util . * ;   public class Solve {   static Scanner scan = new Scanner ( System . in ) ;   public static void solve ( int n , int a , int b ) {   System . out . println ( Math . min ( ( n - a ) , ( b + 1 ) ) ) ; }   public static void main ( String [ ] args ) {   int n = scan . nextInt ( ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ;   solve ( n , a , b ) ; } }

import java . util . * ;     import java . io . * ; import java . lang . * ; import java . math . BigInteger ;   public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int front = 0 ; int end = n ; int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { front ++ ; end -- ; if ( front > a && end <= b ) { ans ++ ;

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

n , a , b = map ( int , input ( ) . split ( ) ) ans = 0 while n - a - 1 > b : a += 1 print ( n - a ) NEW_LINE

def main ( ) : n , a , b = map ( int , input ( ) . split ( ) ) print ( n - max ( a + 1 , n - b ) + 1 ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

n , a , b = map ( int , input ( ) . split ( ) ) itog = 0 for i in range ( 1 , n + 1 ) : if i - 1 >= a and n - i <= b : itog += 1 print ( itog ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;

import java . util . * ; public class Problem1307b { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; if ( x % a [ i ] == 0 ) { ans = Math . min ( ans , x / a [ i ] ) ; } else if ( a [ i ] > x ) { ans = Math . min ( ans , x / a [ i ] + 2 ) ; } else { ans = Math . min ( ans , x / a [ i ] + 1 ) ; } } System . out . println ( ans ) ; } } }

import java . util . * ; import java . io . * ; import java . math . * ;     public class B {   private static long INF = 2000000000000000000L , M = 1000000007 , MM = 998244353 ; private static int N = 0 ;   public static void process ( ) throws IOException {   int n = sc . nextInt ( ) , m = sc . nextInt ( ) ; int arr [ ] = sc . readArray ( n ) ; int max = 0 ; for ( int e : arr ) { if ( e == m ) { System . out . println ( 1 ) ; return ; } max = max ( e , max ) ; } int cc = ceil ( m , max ) ; if ( cc < 2 ) System . out . println ( 2 ) ; else System . out . println ( cc ) ;   }

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

from math import ceil , sqrt , gcd , factorialfrom collections import defaultdict as ddd = dd ( lambda : 0 ) from sys import stdininput = stdin . readline def mp ( ) : return map ( int , input ( ) . split ( ) ) def it ( ) : return int ( input ( ) ) for _ in range ( it ( ) ) : a , b = mp ( ) s = list ( mp ( ) ) if b in s : print ( 1 ) else : print ( max ( 2 , ceil ( b / max ( s ) ) ) ) NEW_LINE

import mathfor _ in " ▁ " * int ( input ( ) ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) mx = max ( a ) print ( 1 if x in a else 2 if mx > x else math . ceil ( x / mx ) ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( )   start = int ( x / a [ - 1 ] ) * a [ - 1 ] ans = int ( x / a [ - 1 ] ) diff = x - start temp = ans for i in a : if i > diff and start != 0 : ans += 1 break elif i == diff : ans += 1 break if temp == ans : ans += 2 if x % a [ - 1 ] == 0 : ans = int ( x / a [ - 1 ] ) print ( ans ) NEW_LINE

import mathfor _ in range ( int ( input ( ) ) ) : n , x = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) a . sort ( ) if x in a : print ( 1 ) elif 2 * a [ - 1 ] > x : print ( 2 ) else : res = float ( ' inf ' ) for i in range ( n - 1 , - 1 , - 1 ) : if x % a [ i ] == 0 : res = min ( x // a [ i ] , res ) else : res = min ( math . ceil ( x / a [ i ] ) , res ) print ( res ) NEW_LINE


import java . io . * ; import java . util . * ;   public class C335A { static PrintWriter out = new PrintWriter ( ( System . out ) ) ; static Kioken sc = new Kioken ( ) ;   public static void main ( String args [ ] ) throws IOException { int t = 1 ;

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 ) ) ;

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

import java . io . * ; import java . util . * ; import java . lang . * ;   public class B {   public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int n = in . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] inva = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) - 1 ; inva [ a [ i ] ] = i ; } int curr = 1 ; int ans = 1 ; for ( int i = 1 ; i < n ; i ++ ) { if ( inva [ i ] < inva [ i - 1 ] ) curr = 1 ; else curr ++ ;

n = int ( input ( ) ) p = list ( map ( int , input ( ) . split ( ) ) )   dp = [ 0 ] * ( n + 1 ) for x in p : dp [ x ] = 1 + dp [ x - 1 ]   res = n - max ( dp ) print ( res ) NEW_LINE

n = int ( input ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) l = [ 0 ] * ( n + 1 ) for c in arr : l [ c ] = l [ c - 1 ] + 1 print ( n - max ( l ) ) NEW_LINE

n = int ( input ( ) ) l = [ int ( x ) for x in input ( ) . split ( ) ] b = [ 0 ] * ( n + 1 ) for i in l : b [ i ] = b [ i - 1 ] + 1 print ( n - max ( b ) )     NEW_LINE

import math , sys , bisect , heapq , osfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulatefrom functools import lru_cache NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ;   public class Big_VOVA { 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 ( ) ; int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = in . nextInt ( ) ; } Arrays . sort ( arr ) ; int gcd = arr [ n - 1 ] ; for ( int i = n - 2 ; i >= 0 ; i -- ) { int max = Integer . MIN_VALUE ; int ind = i ; for ( int j = i ; j >= 0 ; j -- ) { int val = gcd ( gcd , arr [ j ] ) ; if ( max < val ) { max = val ; ind = j ; } }

import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ;   public class B1407 {   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 ( ) ; List < Integer > rest = new ArrayList < > ( ) ; for ( int n = 0 ; n < N ; n ++ ) { rest . add ( in . nextInt ( ) ) ; } StringBuilder output = new StringBuilder ( ) ; int gcd = 0 ; int nextGCD ; int nextNumber = 0 ; while ( ! rest . isEmpty ( ) ) { nextGCD = 0 ; for ( int a : rest ) { int candGCD = gcd ( a , gcd ) ; if ( candGCD > nextGCD ) { nextGCD = candGCD ; nextNumber = a ; } } gcd = nextGCD ; output . append ( nextNumber ) . append ( ' ▁ ' ) ; rest . remove ( ( Integer ) nextNumber ) ; } System . out . println ( output ) ; } }   static int gcd ( int a , int b ) { return ( b == 0 ) ? a : gcd ( b , a % b ) ; }   }

from math import gcdfor NEW_LINE _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ ] NEW_LINE visited = [ 0 ] * n NEW_LINE maxi = max ( l ) NEW_LINE id = l . index ( maxi ) NEW_LINE visited [ id ] = 1 NEW_LINE ans . append ( maxi ) NEW_LINE k = 0 NEW_LINE hcf = - 1 NEW_LINE while k < n - 2 : for NEW_LINE i in range ( n ) : NEW_LINE if visited [ i ] == 0 : curr_hcf = gcd ( l [ i ] , maxi ) NEW_LINE if curr_hcf > hcf : curr_id = i NEW_LINE hcf = curr_hcf NEW_LINE ans . append ( l [ curr_id ] ) NEW_LINE visited [ curr_id ] = 1 NEW_LINE maxi = hcf NEW_LINE k += 1 NEW_LINE hcf = - 1 NEW_LINE for i in range ( n ) : if NEW_LINE visited [ i ] == 0 : ans . append ( l [ i ] ) NEW_LINE print ( * ans ) NEW_LINE

ll = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE t = lambda : int ( input ( ) ) NEW_LINE ss = lambda : input ( ) NEW_LINE from math import log10 , log2 , ceil , factorial as f , gcd NEW_LINE

for i in range ( int ( input ( ) ) ) : from math import gcd NEW_LINE n = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE arr . sort ( ) NEW_LINE li = [ ] NEW_LINE li . append ( arr . pop ( ) ) NEW_LINE hcf = li [ - 1 ] NEW_LINE while ( len ( arr ) > 0 ) : m , q = 0 , 0 NEW_LINE for x in arr : if NEW_LINE m < gcd ( hcf , x ) : m = gcd ( hcf , x ) NEW_LINE q = x NEW_LINE li += [ q ] NEW_LINE arr . remove ( q ) NEW_LINE hcf = m NEW_LINE print ( * li ) NEW_LINE

from math import gcdfor NEW_LINE _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ ] NEW_LINE visited = [ 0 ] * n NEW_LINE maxi = 0 NEW_LINE for i in range ( n ) : hcf = 0 NEW_LINE for j in range ( n ) : if NEW_LINE visited [ j ] == 0 and gcd ( maxi , l [ j ] ) > hcf : max_id = j NEW_LINE hcf = gcd ( maxi , l [ j ] ) NEW_LINE ans . append ( l [ max_id ] ) NEW_LINE visited [ max_id ] = 1 NEW_LINE maxi = hcf NEW_LINE


import java . util . Scanner ;   public class B38 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int rookX = s . charAt ( 0 ) - ' a ' ; int rookY = s . charAt ( 1 ) - '1' ; s = in . next ( ) ; int knightX = s . charAt ( 0 ) - ' a ' ; int knightY = s . charAt ( 1 ) - '1' ; int [ ] [ ] moves = new int [ ] [ ] { { 1 , 2 } , { - 1 , 2 } , { 1 , - 2 } , { - 1 , - 2 } , { 2 , 1 } , { - 2 , 1 } , { 2 , - 1 } , { - 2 , - 1 } } ; int answer = 0 ; for ( int x = 0 ; x < 8 ; x ++ ) { if ( x == rookX ) continue ; for ( int y = 0 ; y < 8 ; y ++ ) { if ( y == rookY ) continue ; if ( x == knightX && y == knightY ) continue ; boolean ok = true ; for ( int [ ] move : moves ) { int beatX = x + move [ 0 ] ; int beatY = y + move [ 1 ] ; if ( ( beatX == rookX && beatY == rookY ) || ( beatX == knightX && beatY == knightY ) ) { ok = false ; break ; } } if ( ok ) { answer ++ ; } } } System . out . println ( answer ) ; }   }

import java . util . * ; import java . math . * ; import java . text . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String rook = sc . next ( ) ; String knight = sc . next ( ) ; int r = knight . charAt ( 0 ) - ' a ' + 1 ; int c = knight . charAt ( 1 ) - '0' ; boolean m [ ] [ ] = new boolean [ 9 ] [ 9 ] ; int r1 = rook . charAt ( 0 ) - ' a ' + 1 ; int c1 = rook . charAt ( 1 ) - '0' ; for ( int i = 1 ; i <= 8 ; i ++ ) m [ r1 ] [ i ] = true ; for ( int i = 1 ; i <= 8 ; i ++ ) m [ i ] [ c1 ] = true ; int dx [ ] = { 2 , 2 , - 2 , - 2 , 1 , 1 , - 1 , - 1 } ; int dy [ ] = { - 1 , 1 , - 1 , 1 , 2 , - 2 , 2 , - 2 } ; int ans = 0 ; int x = 0 , y = 0 ; m [ r ] [ c ] = true ; for ( int i = 0 ; i < 8 ; i ++ ) { x = r + dx [ i ] ; y = c + dy [ i ] ; if ( x < 1 || y < 1 || x > 8 || y > 8 ) continue ; m [ x ] [ y ] = true ; } for ( int i = 1 ; i <= 8 ; i ++ ) { for ( int j = 1 ; j <= 8 ; j ++ ) { if ( ! m [ i ] [ j ] ) { boolean place = true ; for ( int k = 0 ; k < 8 ; k ++ ) { x = i + dx [ k ] ; y = j + dy [ k ] ; if ( x == r1 && y == c1 ) place = false ; } if ( place ) ans ++ ; } } } System . out . println ( ans ) ; } }

import java . util . Scanner ;   public class Chess { static void moveKnight ( boolean [ ] visited , int knight ) { for ( int i = - 1 ; i < 3 ; i += 2 ) {

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

first = input ( ) second = input ( ) s = " abcdefjh " ans = 0 for i in " abcdefgh " : for j in range ( 1 , 9 ) : move = i + str ( j )   if move != first and move != second : if not i in first and not str ( j ) in first : NEW_LINE

n = 9 chs = [ [ 0 for i in range ( 0 , n ) ] for j in range ( 0 , n ) ] a = input ( ) b = input ( ) lx = ord ( a [ 0 ] ) - 96 ly = int ( a [ 1 ] ) hx = ord ( b [ 0 ] ) - 96 hy = int ( b [ 1 ] ) chs [ hy ] [ hx ] = chs [ ly ] [ lx ] = 1 for i in range ( 1 , n ) : for j in range ( 1 , n ) : if ( ly == i or lx == j ) or ( ( abs ( i - ly ) == 1 and abs ( j - lx ) == 2 ) or ( abs ( i - ly ) == 2 and abs ( j - lx ) == 1 ) ) : chs [ i ] [ j ] = 1 if ( abs ( hy - i ) == 1 and abs ( hx - j ) == 2 ) or ( abs ( hy - i ) == 2 and abs ( hx - j ) == 1 ) : chs [ i ] [ j ] = 1 ans = 0 for i in range ( 1 , n ) : for j in range ( 1 , n ) : if chs [ i ] [ j ] == 0 : ans += 1 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 ( ) ; int n = input . nextInt ( ) ; String s = input . next ( ) ; int left = 0 ; int right = n - 1 ; int zero = 0 ; int one = 0 ; long ans = 0 ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == '0' ) zero ++ ; else one ++ ; if ( one - zero == 0 ) { ans = Math . max ( ans , i + 1 ) ; } else if ( map . containsKey ( one - zero ) ) { ans = Math . max ( ans , i - map . get ( one - zero ) ) ; } else map . put ( one - zero , i ) ; } System . out . println ( ans ) ; }   static class FastScanner {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ;   String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }

import java . util . ArrayList ; import java . util . Scanner ;   public class BalancedSubstring {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; String s = scanner . nextLine ( ) ; scanner . close ( ) ; int output = solveProblem ( n , s ) ; System . out . println ( output ) ; } private static int solveProblem ( int n , String s ) { int ones = 0 ; int zeroes = 0 ; int [ ] nums = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { char c = s . charAt ( i ) ;

import java . util . * ;   public class BalancedSubstrings { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   int n = input . nextInt ( ) ; input . nextLine ( ) ; String s = input . nextLine ( ) ;   input . close ( ) ;   int [ ] pre = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { if ( s . charAt ( i - 1 ) == '0' ) { pre [ i ] = pre [ i - 1 ] + 1 ; } else { pre [ i ] = pre [ i - 1 ] - 1 ; } }   int [ ] mp = new int [ 2 * n + 1 ] ; mp [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( pre [ i ] < 0 ) { if ( mp [ n + pre [ i ] ] == 0 ) { mp [ n + pre [ i ] ] = i ; } } else if ( pre [ i ] > 0 ) { if ( mp [ pre [ i ] ] == 0 ) { mp [ pre [ i ] ] = i ; } } }   int ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( pre [ i ] < 0 ) { ans = Math . max ( ans , i - mp [ n + pre [ i ] ] ) ; } else { ans = Math . max ( ans , i - mp [ pre [ i ] ] ) ; } }   System . out . println ( ans ) ; } }

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

n = int ( input ( ) ) s = input ( ) o = [ 0 ] * nz = [ 0 ] * nfor i in range ( n ) : if i == 0 : if s [ i ] == '1' : o [ i ] = 1 else : z [ i ] = 1 else : if s [ i ] == '1' : o [ i ] = o [ i - 1 ] + 1 z [ i ] = z [ i - 1 ] else : z [ i ] = z [ i - 1 ] + 1 o [ i ] = o [ i - 1 ] d = [ ] for i in range ( n ) : d . append ( o [ i ] - z [ i ] )   dd = { } dd . setdefault ( 0 , - 1 ) for i in range ( n ) : if d [ i ] not in dd . keys ( ) : dd . setdefault ( d [ i ] , i ) NEW_LINE

input ( ) instring = input ( ) balance = [ 0 ]   num0 = 0 num1 = 0   for c in instring : if c == "0" : num0 += 1 else : num1 += 1   balance . append ( num0 - num1 )   d = { }   for i in range ( len ( balance ) ) : if balance [ i ] not in d : d [ balance [ i ] ] = i   ans = 0 NEW_LINE

from collections import defaultdictimport sysinput = sys . stdin . readline   n = int ( input ( ) ) s = input ( ) m = defaultdict ( lambda : - 1 ) m [ 0 ] = 0 ans = 0 sum = 0   for i in range ( 1 , n + 1 ) : sum += ( 1 if s [ i - 1 ] == '1' else - 1 ) if ( sum == 0 ) : ans = i elif ( m [ sum ] != - 1 ) : ans = max ( ans , i - m [ sum ] ) else : m [ sum ] = i print ( ans ) NEW_LINE


import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int k = in . nextInt ( ) % 10 ; int r = in . nextInt ( ) ; int res = 1 ; int s = k ; while ( s % 10 != 0 && s % 10 != r ) { s = k * ++ res ; } System . out . println ( res ) ; }   }

import java . util . Scanner ;   public class A732 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int k = scanner . nextInt ( ) , r = scanner . nextInt ( ) ;   for ( int i = 1 ; ; i ++ ) { if ( i * k % 10 == 0 || i * k % 10 == r ) { System . out . println ( i ) ; break ; } } } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; int total = 1 ; int total_temp = 0 ;   while ( true ) { total_temp = total * k ; if ( total_temp % 10 == 0 || total_temp % 10 == r ) { break ; } else { total ++ ; } }   System . out . println ( total ) ; } }

import java . util . Scanner ; import java . util . StringTokenizer ;   public class BuyAShovel { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String line = scanner . nextLine ( ) ;   StringTokenizer stringTokenizer = new StringTokenizer ( line ) ;   int k = Integer . parseInt ( stringTokenizer . nextToken ( ) ) ; int r = Integer . parseInt ( stringTokenizer . nextToken ( ) ) ;   for ( int i = 1 ; i < 100000 ; i ++ ) { int result = ( k * i ) % 10 ;   if ( result == 0 || result == r ) { System . out . println ( i ) ; return ; }   }   } }

price , coin = map ( int , input ( ) . split ( ) ) i = 1 while ( price * i ) % 10 != 0 and ( price * i - coin ) % 10 != 0 : i += 1 print ( i ) NEW_LINE

k , r = map ( int , input ( ) . split ( " ▁ " ) ) i , m = 1 , kwhile m % 10 != r and m % 10 != 0 : i += 1 m = k * iprint ( i ) NEW_LINE

a , b = ( int ( i ) for i in input ( ) . split ( ) ) k = 1 c = awhile a % 10 != 0 and a % 10 != b : k += 1 a = c * kprint ( k ) NEW_LINE

[ shovel_price , rest ] = input ( ) . split ( ' ▁ ' ) x = 1 while True : if ( ( x * int ( shovel_price ) ) % 10 == 0 ) or ( ( x * int ( shovel_price ) % 10 == int ( rest ) ) ) : print ( x ) exit ( ) else : x += 1 NEW_LINE

x , y = map ( int , input ( ) . split ( ) ) n = 0 b = Truewhile b : n += 1 if ( n * x - y ) % 10 == 0 or n * x % 10 == 0 : b = Falseprint ( n ) NEW_LINE


import javax . print . attribute . standard . PrinterMessageFromOperator ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ;

import java . util . * ;   public class CodeForces22B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( ( i + j ) % 2 == 0 ) { System . out . print ( " W " ) ; } else { System . out . print ( " B " ) ; } } System . out . println ( ) ; } } }

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 ( ) { int n = ni ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { for ( int j = 0 ; j < n ; j ++ ) { if ( j % 2 == 0 ) sb . append ( ' W ' ) ; else sb . append ( ' B ' ) ; } } else { for ( int j = 0 ; j < n ; j ++ ) { if ( j % 2 == 0 ) sb . append ( " B " ) ; else sb . append ( " W " ) ; } } sb . append ( " \n " ) ; } pl ( sb ) ; } public static void main ( String [ ] args ) { Main g = new Main ( ) ; g . out = new PrintWriter ( System . out ) ; g . sc = new FastReader ( ) ; int t = 1 ;

n = int ( input ( ) ) for i in range ( n ) : if i % 2 == 0 : if n % 2 == 1 : print ( " WB " * ( ( n // 2 ) - 1 ) + " WBW " ) else : print ( " WB " * ( n // 2 ) ) else : if n % 2 == 1 : print ( " BW " * ( ( n // 2 ) - 1 ) + " BWB " ) else : print ( " BW " * ( n // 2 ) ) NEW_LINE


import java . util . Collections ;   import java . util . * ; import java . lang . * ; import java . io . * ; import java . util . Arrays ;   public class CodeChef { public static void solve ( String sr ) { if ( sr . length ( ) % 2 != 0 ) { System . out . println ( " - 1" ) ; return ; } int [ ] arr = new int [ 4 ] ; for ( int i = 0 ; i < sr . length ( ) ; i ++ ) { if ( sr . charAt ( i ) == ' L ' ) arr [ 0 ] ++ ; else if ( sr . charAt ( i ) == ' R ' ) arr [ 1 ] ++ ; else if ( sr . charAt ( i ) == ' U ' ) arr [ 2 ] ++ ; else if ( sr . charAt ( i ) == ' D ' ) arr [ 3 ] ++ ; } int count = 0 ; int diff1 = Math . abs ( arr [ 0 ] - arr [ 1 ] ) ; int diff2 = Math . abs ( arr [ 2 ] - arr [ 3 ] ) ; count = Math . min ( diff1 , diff2 ) + Math . abs ( diff1 - diff2 ) / 2 ; System . out . println ( count ) ;   }   public static void main ( String args [ ] ) throws Exception { StringBuilder sb = new StringBuilder ( ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   String sr = br . readLine ( ) ; solve ( sr ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class MemoryAndTrident { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) { FastReader sc = new FastReader ( ) ; String s = sc . next ( ) ; int left = 0 ; int right = 0 ; int up = 0 ; int down = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' L ' ) { left ++ ; } else if ( s . charAt ( i ) == ' R ' ) { right ++ ; } else if ( s . charAt ( i ) == ' D ' ) { down ++ ; } else { up ++ ; } } if ( s . length ( ) % 2 == 1 ) { System . out . println ( " - 1" ) ; } else { int max1 = Math . max ( left , right ) ; int min1 = Math . min ( left , right ) ; int max2 = Math . max ( up , down ) ; int min2 = Math . min ( up , down ) ; int ans1 = max1 + max2 ; int ans2 = min1 + min2 ; System . out . println ( ( ans1 - ans2 ) / 2 ) ; } } }

import java . text . DecimalFormat ; import java . util . stream . LongStream ; import java . util . stream . IntStream ; import java . io . * ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ;

import java . util . * ; import java . io . * ; public class B712 { static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; static StringTokenizer st ; public static void main ( String [ ] args ) throws IOException { String s = next ( ) ; int up = 0 ; int right = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' U ' ) { up ++ ; } else if ( s . charAt ( i ) == ' D ' ) { up -- ; } else if ( s . charAt ( i ) == ' L ' ) { right -- ; } else { right ++ ; } } up = Math . abs ( up ) ; right = Math . abs ( right ) ; if ( ( up + right ) % 2 == 0 ) { pr . println ( ( up + right ) / 2 ) ; } else { pr . println ( - 1 ) ; } pr . close ( ) ; } static String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . 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 readCharacter ( ) throws IOException { return next ( ) . charAt ( 0 ) ; } static String readLine ( ) throws IOException { return br . readLine ( ) . trim ( ) ; } }

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

import sys , mathsys . setrecursionlimit ( 10 ** 8 ) ''' def ▁ fun ( ) : ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 16 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ for ▁ j ▁ in ▁ range ( 4 ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ i & (1 < < j ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( j , end = ' ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ) import ▁ binarytreefrom ▁ collections ▁ import ▁ dequebst ▁ = ▁ binarytree . tree ( height = 4 , is _ perfect = True ) print ( bst ) def ▁ s ( bst ) : ▁ ▁ ▁ ▁ if ▁ bst : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ bst . left , bst . right ▁ = ▁ bst . right , bst . left ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . right ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s ( bst . left ) s ( bst ) print ( bst ) ''' s = input ( ) x , y = 0 , 0 for i in s : if i == ' L ' : x -= 1 elif i == ' R ' : x += 1 elif i == ' U ' : y += 1 elif i == ' D ' : y -= 1 print ( - 1 if len ( s ) % 2 != 0 else ( abs ( x ) + abs ( y ) ) // 2 ) NEW_LINE

s = input ( ) if len ( s ) % 2 == 1 : print ( - 1 ) else : l = s . count ( ' L ' ) r = s . count ( ' R ' ) u = s . count ( ' U ' ) d = s . count ( ' D ' )   NEW_LINE


import java . util . * ; import java . io . * ; public class parakh { public static void swap ( char a [ ] , int i , int j ) { char c = a [ j ] ; a [ j ] = a [ i ] ; a [ i ] = c ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;

import java . io . * ; import java . util . * ;   public class Main { static final int N = 15 ; static String str1 , str2 ; static Character [ ] arr = new Character [ N ] ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   public static void main ( String [ ] args ) throws IOException {

import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { FastScanner input = new FastScanner ( ) ; String question = input . next ( ) ; String ans = input . next ( ) ; if ( question . equals ( "0" ) && question . equals ( ans ) ) { System . out . println ( " OK " ) ; return ; } char a [ ] = question . toCharArray ( ) ; Arrays . sort ( a ) ; if ( a [ 0 ] == '0' ) { for ( int i = 0 ; i < question . length ( ) ; i ++ ) { if ( a [ i ] >= '1' && a [ i ] <= '9' ) { char temp = a [ i ] ; a [ i ] = '0' ; a [ 0 ] = temp ; break ; } } } String newQ = new String ( a ) ; if ( newQ . equals ( ans ) ) { System . out . println ( " OK " ) ; } else { System . out . println ( " WRONG _ ANSWER " ) ; } }   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 ( ) ) ; } }   }

num = input ( ) given = input ( )   num = " " . join ( sorted ( num ) )   idx = - 1 for i in range ( len ( num ) ) : if int ( num [ i ] ) > 0 : idx = i break   if idx == - 1 : solution = "0" else : solution = num [ idx ] + num [ : idx ] + num [ idx + 1 : ]   print ( " WRONG _ ANSWER " if solution != given else " OK " ) NEW_LINE

n = sorted ( list ( input ( ) ) )   NEW_LINE

a = list ( input ( ) ) b = list ( input ( ) )   if a . count ( '0' ) == len ( a ) : if ( b . count ( '0' ) == len ( b ) ) : if len ( a ) == len ( b ) : print ( " OK " ) else : print ( " WRONG _ ANSWER " ) else : print ( " WRONG _ ANSWER " )   else :     a . sort ( ) x = a . count ( '0' ) a = [ a [ x ] ] + [ '0' ] * x + a [ x + 1 : ] print ( " OK " if a == b else " WRONG _ ANSWER " )   NEW_LINE


import java . util . * ; import java . io . * ;   public class a implements Runnable {   static List < Integer > [ ] al ; static int [ ] c ;   static boolean check ( int u , int color , int p ) { for ( int v : al [ u ] ) { if ( v == p ) continue ; if ( color != - 1 && c [ v ] != color ) return false ; if ( ! check ( v , c [ v ] , u ) ) return false ; } return true ;   } public void run ( ) {   try {   FastScanner sc = new FastScanner ( ) ; int n = sc . nextInt ( ) ; al = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) al [ i ] = new ArrayList < > ( ) ;   int start = - 1 , end = - 1 ; int [ ] [ ] edge = new int [ n ] [ 2 ] ;   for ( int i = 1 ; i < n ; i ++ ) { int u = sc . nextInt ( ) ; int v = sc . nextInt ( ) ; al [ u ] . add ( v ) ; al [ v ] . add ( u ) ; edge [ i - 1 ] [ 0 ] = u ; edge [ i - 1 ] [ 1 ] = v ; }   c = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) c [ i ] = sc . nextInt ( ) ;   for ( int i = 0 ; i < n ; i ++ ) { if ( c [ edge [ i ] [ 0 ] ] != c [ edge [ i ] [ 1 ] ] ) { start = edge [ i ] [ 0 ] ; end = edge [ i ] [ 1 ] ; break ; } }

import java . io . * ; import java . math . BigDecimal ; import java . math . BigInteger ; import java . math . RoundingMode ; import java . util . * ; import java . util . concurrent . LinkedBlockingDeque ;   import java . util . ArrayList ; import java . util . HashMap ; import java . util . LinkedList ;

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

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

import collectionsimport sys     def read_ints ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . strip ( ) . split ( ) ]     def main ( ) : N = read_ints ( ) [ 0 ] edges = [ ] vx_to_neighbor_colors = collections . defaultdict ( set ) for _ in range ( N - 1 ) : u , v = read_ints ( ) u -= 1 v -= 1 edges . append ( ( u , v ) ) colors = read_ints ( )   vx_to_cnt = collections . Counter ( ) e_cnt = 0 for e in edges : if colors [ e [ 0 ] ] == colors [ e [ 1 ] ] : continue vx_to_cnt [ e [ 0 ] ] += 1 vx_to_cnt [ e [ 1 ] ] += 1 e_cnt += 1   if e_cnt == 0 : return 1 NEW_LINE

import math , sys , bisect , heapq , osfrom collections import defaultdict , Counter , dequefrom itertools import groupby , accumulatefrom functools import lru_cache NEW_LINE


import java . util . * ;   public class CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char p = ' a ' ; int c = 1 ; StringBuilder h = new StringBuilder ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( c > 2 ) { if ( p == ' a ' ) p = ' b ' ; else p = ' a ' ; c = 1 ; } h . append ( p ) ;

import java . sql . SQLOutput ; import java . util . * ;   public class Example { static int [ ] dp ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; char a [ ] = new char [ n ] ; int m = 97 ; int i = 0 ; while ( i < n ) { a [ i ] = ( char ) ( m ) ; i ++ ; if ( i == n ) break ; a [ i ] = ( char ) ( m ) ; i ++ ; if ( i == n ) break ; a [ i ] = ( char ) ( m + 1 ) ; i ++ ; if ( i == n ) break ; a [ i ] = ( char ) ( m + 1 ) ; i ++ ; }

import java . util . Scanner ;   public class _0692three_palindrome {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = " " ; while ( s . length ( ) < n ) { s += s + " aabb " ; } System . out . println ( s . substring ( 0 , n ) ) ; }   }

length = int ( input ( ) ) st = " a " string_len = 1 while True : st = st + " bbaabbaabbaabbaabbaabb " st = st + " aabbaabbaabbaabbaabbaa " string_len += 44 if ( string_len > length ) : break print ( st [ : length ] ) NEW_LINE

from __future__ import division , print_functionfrom collections import * from math import * from itertools import * import osimport sysfrom io import BytesIO , IOBaseimport math NEW_LINE

from __future__ import division , print_functionfrom collections import * from math import * from itertools import * from time import timeimport osimport sysfrom io import BytesIO , IOBase if sys . version_info [ 0 ] < 3 : from __builtin__ import xrange as range from future_builtins import ascii , filter , hex , map , oct , zip ''' Notes : ''' def main ( ) : n = int ( input ( ) ) s = ' aabb ' if n <= 4 : print ( s [ : n ] ) return if n % 2 == 0 : if n % 4 == 0 : dummy = n // 4 print ( s * dummy ) else : dummy = ( n - 2 ) // 4 print ( s * dummy + ' aa ' ) else : dummy = n - 1 if dummy % 2 == 0 : if dummy % 4 == 0 : dummy2 = dummy // 4 print ( s * dummy2 + ' a ' ) else : dummy2 = ( dummy - 2 ) // 4 print ( s * dummy2 + ' aab ' )                   NEW_LINE

n = int ( input ( ) )   v = [ ' a ' , [ ' aa ' , ' bb ' ] , ' aab ' , ' aabb ' ] if n == 1 : print ( ' a ' ) elif n == 2 : print ( ' ab ' ) elif n == 3 : print ( ' aab ' ) elif n == 4 : print ( ' aabb ' ) else : s = ' aabb ' while len ( s ) < n : s += s   print ( s [ : n ] ) NEW_LINE


import java . io . * ; import java . util . * ; public class isolatedVertices { public static void main ( String [ ] args ) throws IOException { BufferedReader f = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( f . readLine ( ) ) ; long n = Long . parseLong ( st . nextToken ( ) ) ; long m = Long . parseLong ( st . nextToken ( ) ) ; System . out . print ( Math . max ( 0 , n - 2L * m ) + " ▁ " ) ; int max = ( int ) Math . ceil ( 0.5 + Math . pow ( 1L + 8L * m , 0.5 ) * 0.5 ) ; if ( m == 0 ) max = 0 ; System . out . println ( Math . max ( n - max , 0 ) ) ; } }

import java . lang . * ; import java . util . * ; import java . util . stream . Collectors ; import java . io . * ;   public class Fridge {   static Set < Integer > set ; static long tmin ; static int [ ] ar ; static boolean [ ] visited ; public static void dfs ( HashMap [ ] adj , int u , long curcost ) { if ( set . contains ( u ) || curcost > tmin ) { if ( curcost < tmin ) { tmin = curcost ; } return ; } visited [ u ] = true ;

import java . util . Arrays ; import java . util . Scanner ;   public class VasyaAndIsolatedVertices { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long [ ] nm = Arrays . stream ( scanner . nextLine ( ) . split ( " ▁ " ) ) . mapToLong ( Long :: parseLong ) . toArray ( ) ; if ( nm [ 1 ] == 0 ) { System . out . println ( nm [ 0 ] + " ▁ " + nm [ 0 ] ) ; return ; } long [ ] sums = new long [ ( int ) nm [ 0 ] + 2 ] ; for ( int i = 2 ; i <= nm [ 0 ] ; i ++ ) { sums [ i ] = ( long ) i * ( ( long ) i - 1 ) / 2 ; } long min = nm [ 0 ] / 2 >= nm [ 1 ] ? nm [ 0 ] - 2 * nm [ 1 ] : 0 ; int t = Math . abs ( Arrays . binarySearch ( sums , nm [ 1 ] ) ) ; if ( sums [ t ] != nm [ 1 ] ) t -- ; long max = nm [ 0 ] - t ; System . out . println ( min + " ▁ " + max ) ; } }

n , m = list ( map ( int , input ( ) . split ( ) ) )   def bin_search ( m ) : o = m + 1 l = 0 while o != l : k = ( o + l ) // 2 if k * ( k - 1 ) >= 2 * m : o = k else : l = k + 1 return o   print ( max ( n - 2 * m , 0 ) , n - bin_search ( m ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) print ( max ( 0 , n - 2 * m ) , end = " ▁ " ) k = 0 while k * ( k - 1 ) // 2 < m : k += 1 print ( n - k ) NEW_LINE

from sys import stdinimport pprint   input_string = list ( map ( int , stdin . readline ( ) . split ( ) ) )   n = input_string [ 0 ] m = input_string [ 1 ]   i = 0   while ( i * ( i - 1 ) ) < m * 2 :   i += 1   NEW_LINE

n , m = map ( int , input ( ) . split ( ) )   ans = 0 u = [ ] s = m   if m > 0 : for j in range ( n ) : if s >= j : s -= j else : if s > 0 : mas = n - ( j + 1 ) break else : mas = n - j break   if m == 0 : mas = nelif m == n * ( n - 1 ) // 2 : mas = 0             print ( max ( 0 , n - ( m * 2 ) ) , mas ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) if m == 0 : ans1 = ans2 = nelse : ans1 = max ( 0 , ( n - 2 * m ) ) i = 1 while m > 0 : m -= i i += 1 ans2 = n - iprint ( ans1 , ans2 ) NEW_LINE


l = input ( ) . split ( ) n = int ( l [ 0 ] ) m = int ( l [ 1 ] ) vs = [ ] for i in range ( n ) : vs . append ( int ( input ( ) ) ) vs . append ( 10 * * 9 ) vs . sort ( ) hs = [ ] for i in range ( m ) : l = input ( ) . split ( ) if ( int ( l [ 0 ] ) == 1 ) : hs . append ( int ( l [ 1 ] ) ) hs . sort ( ) j = 0 mina = 10 * * 9   for i in range ( n + 1 ) : if ( j < len ( hs ) ) : while ( hs [ j ] < vs [ i ] ) : j += 1 if ( j == len ( hs ) ) : break if ( i + len ( hs ) - j < mina ) : mina = i + len ( hs ) - j   print ( mina )

# include < bits / stdc ++ . h > # define ll long long # define F first # define S second # define pb push_back # define P push # define fast ios :: sync_with_stdio ( NULL ) ; cin . tie ( 0 ) ; cout . tie ( 0 ) ; using namespace std ; ll n , i , j , k , x , y , z , l , r , mid , q , ans , mod = 998244353 , t , m ; ll a [ 200005 ] , b [ 200005 ] ; vector < ll > v [ 200005 ] ; string s ; char ch ; int main ( ) { fast ans = 1e9 ; cin >> n >> m ; for ( i = 0 ; i < n ; i ++ ) cin >> a [ i ] ; for ( i = 1 ; i <= m ; i ++ ) { cin >> x >> z >> y ; if ( x != 1 ) { m -- ; i -- ; continue ; } b [ i ] = z ; } sort ( a , a + n ) ; sort ( b + 1 , b + m + 1 , greater < ll > ( ) ) ; j = m ; for ( i = 0 ; i < n ; i ++ ) { while ( j && b [ j ] < a [ i ] ) j -- ; ans = min ( ans , i + j ) ; } while ( j && b [ j ] < 1e9 ) j -- ; ans = min ( ans , j + n ) ; cout << ans ; }

if __name__ == ' _ _ main _ _ ' : n , m = map ( int , input ( ) . split ( ) ) NEW_LINE

l = input ( ) . split ( ) n = int ( l [ 0 ] ) m = int ( l [ 1 ] ) vs = [ ] for i in range ( n ) : vs . append ( int ( input ( ) ) ) vs . append ( 10 ** 9 ) vs . sort ( ) hs = [ ] for i in range ( m ) : l = input ( ) . split ( ) if ( int ( l [ 0 ] ) == 1 ) : hs . append ( int ( l [ 1 ] ) ) hs . sort ( ) j = 0 mina = 10 ** 9   for i in range ( n + 1 ) : if ( j < len ( hs ) ) : while ( hs [ j ] < vs [ i ] ) : j += 1 if ( j == len ( hs ) ) : break if ( i + len ( hs ) - j < mina ) : mina = i + len ( hs ) - j   print ( mina ) NEW_LINE

import sysinput = sys . stdin . readline   def bs ( num ) : low = 0 high = len ( rows ) - 1 while low < high : mid = ( low + high ) // 2 if rows [ mid ] >= num : high = mid - 1 else : low = mid + 1 if rows [ low ] < num : return len ( rows ) - ( low + 1 ) else : return len ( rows ) - low   n , m = map ( int , input ( ) . split ( ) ) if n == 0 and m == 0 : print ( 0 ) exit ( 0 ) col = [ ] rows = [ ] for i in range ( n ) : col . append ( int ( input ( ) ) ) col . append ( 10 ** 9 ) for i in range ( m ) : temp = list ( map ( int , input ( ) . split ( ) ) ) if temp [ 0 ] == 1 : rows . append ( temp [ 1 ] ) col . sort ( ) rows . sort ( ) ans = 10 ** 9 if len ( rows ) == 0 : print ( 0 ) exit ( 0 ) for i in range ( n + 1 ) : count1 = bs ( col [ i ] ) ans = min ( ans , count1 + i ) print ( ans )       NEW_LINE


import java . util . Scanner ;    public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sum1 = 0 , sum2 = 0 , sum3 = 0 ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int v , i , j ; int t = 0 ; int cnt = 1 ; for ( i = 0 ; i < n ; i ++ ) { v = sc . nextInt ( ) ; a [ i ] = v ; sum1 += a [ i ] ; } for ( i = 1 ; i < n ; i ++ ) { for ( j = 1 ; j < n ; j ++ ) { if ( a [ j ] > a [ j - 1 ] ) { t = a [ j - 1 ] ; a [ j - 1 ] = a [ j ] ; a [ j ] = t ; } } } for ( i = 0 ; i < n ; i ++ ) { sum2 += a [ i ] ; sum3 = sum1 - sum2 ; if ( sum2 <= sum3 ) { cnt ++ ; } } System . out . println ( cnt ) ; }   }

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

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

import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ;

import java . util . Arrays ; import java . util . Scanner ;   public class JavaApplication1 {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] arr = new int [ n ] ; int total = 0 ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = input . nextInt ( ) ; total += arr [ i ] ; } Arrays . sort ( arr ) ; int sumOfCoins = 0 ; int numOfCoins = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { sumOfCoins += arr [ i ] ; numOfCoins ++ ; if ( sumOfCoins > ( total / 2 ) ) break ; } System . out . println ( numOfCoins ) ; input . close ( ) ; } }

n = input ( ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( reverse = True ) count = 0 ans = sum ( l ) for i in range ( len ( l ) ) : count += l [ i ] if ( count > ans / 2 ) : print ( i + 1 ) break NEW_LINE

ReadStr = lambda : input ( ) ReadList = lambda : list ( map ( int , input ( ) . split ( ) ) ) ReadInt = lambda : int ( input ( ) ) ReadMultipleValues = lambda : map ( int , input ( ) . split ( ) )   n = ReadInt ( ) coins = sorted ( ReadList ( ) ) [ : : - 1 ] s = 0 count = 0 for i in range ( n ) : if sum ( coins [ i : ] ) < s : break else : s += coins [ i ] count += 1 print ( count ) NEW_LINE

import math   def solve ( ) : n = int ( input ( ) ) array = [ int ( i ) for i in input ( ) . split ( ) ] sum1 , sum2 = 0 , 0   for i in array : sum1 += i   i , count = n - 1 , n array . sort ( reverse = True )   while sum1 > sum2 : sum1 -= array [ i ] sum2 += array [ i ] i -= 1 count -= 1   return count + 1       print ( solve ( ) ) NEW_LINE

import sysinput = sys . stdin . readline   def solve ( n , arr ) : tot = 0 count = 0 arr = sorted ( arr ) [ : : - 1 ] for i in range ( len ( arr ) ) : tot += arr [ i ] count = len ( arr [ : i ] ) if tot > sum ( arr [ i + 1 : ] ) : print ( count + 1 ) return           NEW_LINE


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

import java . util . * ; public class Marks { public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ;   int [ ] [ ] arr = new int [ n ] [ m ] ;   int [ ] store = new int [ m ] ; int count = 0 ;   for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ;   for ( int j = 0 ; j < m ; j ++ ) { arr [ i ] [ j ] = s . charAt ( j ) - '0' ; if ( s . charAt ( j ) - '0' > store [ j ] ) { store [ j ] = s . charAt ( j ) - '0' ; } } } sc . close ( ) ;   for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( arr [ i ] [ j ] == store [ j ] ) { count ++ ; break ; } } }   System . out . println ( count ) ; } }

import java . util . * ; import java . math . * ; import java . lang . * ; import javafx . util . Pair ;   public class gfg { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; String [ ] S = new String [ n ] ; int [ ] maxm = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { S [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { int max = 0 ; for ( int j = 0 ; j < n ; j ++ ) { char c = S [ j ] . charAt ( i ) ; String str = String . valueOf ( c ) ; int temp = Integer . parseInt ( str ) ; if ( temp > max ) max = temp ; } maxm [ i ] = max ; }

import java . util . Scanner ;   public class Experiment { static Scanner sc = new Scanner ( System . in ) ;   public static void main ( String args [ ] ) { int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; String [ ] arr = new String [ n ] ; int maxi [ ] = new int [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . next ( ) ; for ( int j = 0 ; j < m ; j ++ ) { maxi [ j ] = Math . max ( maxi [ j ] , arr [ i ] . charAt ( j ) ) ; } } int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( maxi [ j ] == arr [ i ] . charAt ( j ) ) { res ++ ; break ; } } } System . out . println ( res ) ;   } }

n , m = input ( ) . split ( " ▁ " ) gradebook = [ ] best = 0 successful_students = [ ]   for i in range ( int ( n ) ) : gradebook . append ( input ( ) )   for i in range ( int ( m ) ) : grades = [ ] NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) success = [ ] inp = [ ] lst = [ [ 0 for i in range ( n ) ] for j in range ( m ) ]   for _ in range ( n ) : inp . append ( input ( ) )   for i in range ( m ) : for j in range ( n ) : lst [ i ] [ j ] = inp [ j ] [ i ]   for j in lst : mx = max ( j ) for i in range ( n ) : if j [ i ] == mx : success . append ( i )   print ( len ( set ( success ) ) ) NEW_LINE

A = input ( ) . split ( ) n , m = int ( A [ 0 ] ) , int ( A [ 1 ] ) X = [ ] result = [ ] for i in range ( n ) : k = int ( input ( ) ) l = list ( map ( int , list ( str ( k ) ) ) ) X . append ( l )   for i in range ( m ) : k = [ ] for j in range ( n ) : k . append ( X [ j ] [ i ] ) l = max ( k ) for j in range ( n ) : if X [ j ] [ i ] == l : result . append ( j ) else : continueprint ( len ( set ( result ) ) )   NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) grades = [ ] for i in range ( n ) : grades . append ( input ( ) ) success = set ( ) for i in range ( m ) : maxiMark , maxStu = 0 , set ( ) for j in range ( n ) : if int ( grades [ j ] [ i ] ) > maxiMark : maxiMark = int ( grades [ j ] [ i ] ) maxStu = set ( ) maxStu . add ( j ) elif int ( grades [ j ] [ i ] ) == maxiMark : maxiMark = int ( grades [ j ] [ i ] ) maxStu . add ( j ) success |= maxStuprint ( len ( success ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) x = [ ] d = { } for i in range ( n ) : a = list ( input ( ) ) x . append ( a ) for i in x : for j , k in enumerate ( i ) : d [ j ] = 0 for i in x : for j , k in enumerate ( i ) : d [ j ] = max ( d [ j ] , int ( k ) ) c = 0 for i in x : for j , k in enumerate ( i ) : if int ( k ) == d [ j ] : c += 1 breakprint ( c ) NEW_LINE


import java . util . Scanner ;   public class QueriesOnStr { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; int m = in . nextInt ( ) ;   while ( m -- > 0 ) { int l = in . nextInt ( ) - 1 , r = in . nextInt ( ) - 1 , k = in . nextInt ( ) % ( r - l + 1 ) ; s = s . substring ( 0 , l ) + s . substring ( r - k + 1 , r + 1 ) + s . substring ( l , r - k + 1 ) + s . substring ( r + 1 ) ; } System . out . println ( s ) ; in . close ( ) ; } }

import java . io . * ; import java . util . * ;      public class Main { public static Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) , 640000 ) ) ; public static PrintWriter out = new PrintWriter ( System . out ) ;    public static void rotate ( char chrs [ ] , int startIndex , int endIndex , int shiftOffset ) { int length = ( endIndex - startIndex ) + 1 ; char aux [ ] = new char [ length ] ;   for ( int i = 0 ; i < aux . length ; ++ i ) aux [ i ] = chrs [ startIndex + i ] ;   for ( int i = 0 ; i < aux . length ; ++ i ) { int newLocalIndex = ( i + shiftOffset ) % length ; chrs [ newLocalIndex + startIndex ] = aux [ i ] ; }   }    public static void solve ( ) { String s = in . next ( ) ;    char chrs [ ] = s . toCharArray ( ) ;   int m = in . nextInt ( ) ; for ( int i = 0 ; i < m ; ++ i ) { int startIndex = in . nextInt ( ) - 1 ; int endIndex = in . nextInt ( ) - 1 ; int k = in . nextInt ( ) ;   int shiftSize = ( endIndex - startIndex ) + 1 ; int finalShiftOffset = k % shiftSize ;   rotate ( chrs , startIndex , endIndex , finalShiftOffset ) ;      } out . println ( new String ( chrs ) ) ; }   public static void main ( String args [ ] ) { solve ( ) ; out . close ( ) ; } }

import java . io . * ; import java . util . * ;      public class Main { public static Scanner in = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) , 640000 ) ) ; public static PrintWriter out = new PrintWriter ( System . out ) ;    public static void rotate ( char chrs [ ] , int startIndex , int endIndex , int shiftOffset ) { int length = ( endIndex - startIndex ) + 1 ; char aux [ ] = new char [ length ] ; for ( int i = 0 ; i < aux . length ; ++ i ) aux [ i ] = chrs [ startIndex + i ] ; for ( int i = 0 ; i < aux . length ; ++ i ) { int newLocalIndex = ( i + shiftOffset ) % length ; chrs [ newLocalIndex + startIndex ] = aux [ i ] ; }   }    public static void solve ( ) { String s = in . next ( ) ;    char chrs [ ] = s . toCharArray ( ) ;   int m = in . nextInt ( ) ; for ( int i = 0 ; i < m ; ++ i ) { int startIndex = in . nextInt ( ) - 1 ; int endIndex = in . nextInt ( ) - 1 ; int k = in . nextInt ( ) ;   int shiftSize = ( endIndex - startIndex ) + 1 ; int finalShiftOffset = k % shiftSize ;   rotate ( chrs , startIndex , endIndex , finalShiftOffset ) ;      } System . out . println ( new String ( chrs ) ) ; }   public static void main ( String args [ ] ) { solve ( ) ; out . close ( ) ; } }

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

""" You ▁ are ▁ given ▁ a ▁ string ▁ s ▁ and ▁ should ▁ process ▁ m ▁ queries . ▁ Each ▁ query ▁ is ▁ described ▁ by ▁ two ▁ 1 - based ▁ indices ▁ li , ▁ ri ▁ and ▁ integer ▁ ki . ▁ It ▁ means ▁ that ▁ you ▁ should ▁ cyclically ▁ shift ▁ the ▁ substring ▁ s [ li . . . ▁ ri ] ▁ ki ▁ times . ▁ The ▁ queries ▁ should ▁ be ▁ processed ▁ one ▁ after ▁ another ▁ in ▁ the ▁ order ▁ they ▁ are ▁ given .  One ▁ operation ▁ of ▁ a ▁ cyclic ▁ shift ▁ ( rotation ) ▁ is ▁ equivalent ▁ to ▁ moving ▁ the ▁ last ▁ character ▁ to ▁ the ▁ position ▁ of ▁ the ▁ first ▁ character ▁ and ▁ shifting ▁ all ▁ other ▁ characters ▁ one ▁ position ▁ to ▁ the ▁ right .  For ▁ example , ▁ if ▁ the ▁ string ▁ s ▁ is ▁ abacaba ▁ and ▁ the ▁ query ▁ is ▁ l1  =  3 ,  r1  =  6 ,  k1  =  1 ▁ then ▁ the ▁ answer ▁ is ▁ abbacaa . ▁ If ▁ after ▁ that ▁ we ▁ would ▁ process ▁ the ▁ query ▁ l2  =  1 ,  r2  =  4 ,  k2  =  2 ▁ then ▁ we ▁ would ▁ get ▁ the ▁ string ▁ baabcaa . """ from itertools import chainss = input ( ) n = int ( input ( ) ) for x in range ( n ) : l , r , k = [ int ( y ) for y in input ( ) . split ( ) ] k %= ( r - l + 1 ) l -= 1 ss = ss [ : l ] + ss [ r - k : r ] + ss [ l : r - k ] + ss [ r : ] print ( ss ) NEW_LINE

""" a1 ▁ a2 ▁ a3 ▁ a4 ▁ a5 ▁ a6l ▁ = ▁ 2 , ▁ r ▁ = ▁ 5 , ▁ k ▁ = ▁ 1 ▁ - > ▁ a1 ▁ a2 ▁ a3 ▁ a4 ▁ a5 ▁ a6 """ def rotate_sub ( s , l , r , k ) : sub_size = r - ( l - 1 ) k = k % sub_size if k == 0 : return None rightmost = [ ] for i in range ( r - k , r ) : rightmost . append ( s [ i ] ) for i in range ( r - k - 1 , l - 2 , - 1 ) : s [ i + k ] = s [ i ] for i in range ( len ( rightmost ) ) : s [ l - 1 + i ] = rightmost [ i ]   if __name__ == ' _ _ main _ _ ' : s = list ( input ( ) ) m = int ( input ( ) ) while m : m -= 1 l , r , k = map ( int , input ( ) . split ( ) ) rotate_sub ( s , l , r , k ) print ( ' ' . join ( s ) ) NEW_LINE

s = input ( ) m = int ( input ( ) )   for _ in range ( m ) : l , r , k = map ( int , input ( ) . split ( ) ) l -= 1 r -= 1   k %= ( r - l + 1 )   t = s [ l : r + 1 ] t = t [ - k : ] + t [ : - k ]   s = s [ : l ] + t + s [ r + 1 : ]   print ( s ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : a = list ( input ( ) ) m = int ( input ( ) ) s = " "   while m > 0 : l , r , k = map ( int , input ( ) . split ( ) ) d = r - l + 1   for i in range ( d ) : if ( i + k ) % d == 0 : a = a [ : l - 1 ] + a [ i + l - 1 : r ] + a [ l - 1 : i + l - 1 ] + a [ r : ] break m -= 1 print ( " " . join ( a ) ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : a = list ( input ( ) ) m = int ( input ( ) ) s = " "   while m > 0 : l , r , k = map ( int , input ( ) . split ( ) ) k %= ( r - l + 1 ) a = a [ : l - 1 ] + a [ r - k : r ] + a [ l - 1 : r - k ] + a [ r : ] m -= 1 print ( " " . join ( a ) ) NEW_LINE


import java . util . * ;   public class Main { public static void main ( String [ ] args ) { int n , i ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; String s1 = " I ▁ love ▁ " ; String s2 = " I ▁ hate ▁ " ; int flag = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( i % 2 == 0 ) { System . out . print ( s2 ) ; } else { System . out . print ( s1 ) ; } if ( i != n - 1 ) System . out . print ( " that ▁ " ) ; } System . out . print ( " it " ) ; } }

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int n = in . nextInt ( ) ;   for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 == 0 ) System . out . print ( " I ▁ love ▁ " ) ; else System . out . print ( " I ▁ hate ▁ " ) ; if ( i == n ) System . out . print ( " it " ) ; else System . out . print ( " that ▁ " ) ; } } }

import java . util . * ; public class Hulk { public static void main ( String args [ ] ) { int n = 0 ; Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; String res = " " ; for ( int i = 1 ; i <= n ; i ++ ) { if ( i % 2 != 0 ) res = res + " I ▁ hate ▁ " ; else res = res + " I ▁ love ▁ " ; if ( i != n ) res = res + " that ▁ " ; } res = res + " it " ; System . out . println ( res ) ; } }

print ( * ( [ ' I ▁ hate ' , ' I ▁ love ' ] * 50 ) [ : int ( input ( ) ) ] , sep = ' ▁ that ▁ ' , end = ' ▁ it ' ) NEW_LINE

n = int ( input ( ) ) for i in range ( 1 , n ) : if i % 2 == 1 : print ( ' I ▁ hate ▁ that ' , end = ' ▁ ' ) else : print ( ' I ▁ love ▁ that ' , end = ' ▁ ' ) if n % 2 == 1 : print ( ' I ▁ hate ▁ it ' , end = ' ▁ ' ) else : print ( ' I ▁ love ▁ it ' , end = ' ▁ ' ) NEW_LINE

n = int ( input ( ) ) f = 1 s = " " for i in range ( n - 1 ) : if f == 1 : s += " I ▁ hate " f = 2 else : s += " I ▁ love " f = 1 s += " ▁ that ▁ " if f == 1 : s += " I ▁ hate ▁ it " else : s += " I ▁ love ▁ it " print ( s ) NEW_LINE


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

import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; long a = s . nextLong ( ) ; long b = s . nextLong ( ) ; if ( a == b ) { System . out . print ( ( 10 * a ) + " ▁ " + ( 10 * b + 1 ) ) ; return ; } if ( a + 1 == b ) { System . out . print ( ( 10 * a + 9 ) + " ▁ " + ( 10 * b ) ) ; return ; } if ( b == 1 && a == 9 ) { System . out . print ( 9 + " ▁ " + 10 ) ; return ; } System . out . print ( - 1 ) ; } }

import java . util . Scanner ;   public class ForgettingThings {   public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; if ( a == 9 && b == 1 ) { System . out . println ( 9 + " ▁ " + 10 ) ; } else if ( a == b ) { System . out . println ( a + "0 ▁ " + b + "1" ) ; } else if ( a + 1 == b ) { System . out . println ( a + " ▁ " + b ) ; } else { System . out . println ( " - 1" ) ; } }   }

da , db = map ( int , input ( ) . split ( ) ) if da - db == 8 : print ( da , db * 10 ) elif db - da > 1 : print ( - 1 ) elif db - da == 1 : print ( da , db ) elif da == db : print ( da * 10 + 1 , db * 10 + 2 ) else : print ( - 1 ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) )   if a == 9 and b == 1 : print ( 99 , 100 ) elif a == b : print ( 10 * a , 10 * a + 1 ) elif a + 1 == b : print ( 10 * a + 9 , 10 * b ) else : print ( - 1 ) NEW_LINE

na , nb = map ( int , input ( ) . split ( ) )   if na - nb == 8 : print ( 9 , 10 ) elif nb - na == 1 : print ( na * 10 + 9 , nb * 10 )   elif na == nb : print ( na * 10 , nb * 10 + 1 )   else : print ( - 1 )           NEW_LINE


import java . util . * ; public class contest13 { static Scanner scn = new Scanner ( System . in ) ; public static void main ( String [ ] args ) {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Codeforces {   private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ;   public static int [ ] LPS ( String p ) { int [ ] lps = new int [ p . length ( ) ] ;   int i = 1 ; int j = 0 ; while ( i < p . length ( ) ) { if ( p . charAt ( i ) == p . charAt ( j ) ) { lps [ i ] = j + 1 ; i ++ ; j ++ ; } else { if ( j == 0 ) { lps [ i ] = 0 ; i ++ ; } else { j = lps [ j - 1 ] ; } } } return lps ; }   public static void KMP ( String text , String pattern ) { int [ ] lps = LPS ( pattern ) ; int i = 0 ; int j = 0 ; ArrayList < Integer > matches = new ArrayList < > ( ) ; while ( i < text . length ( ) ) { if ( text . charAt ( i ) == pattern . charAt ( j ) ) { i ++ ; j ++ ; } else { if ( j != 0 ) { j = lps [ j - 1 ] ; } else { i ++ ; } } if ( j == pattern . length ( ) ) { matches . add ( i - j ) ; j = lps [ j - 1 ] ; } } for ( int x : matches ) { System . out . println ( " Match ▁ at ▁ : ▁ " + x ) ; } }   private static class SegmentTree { private long [ ] st ; private int size ; private int n ; private long [ ] a ; SegmentTree ( long [ ] a , int n ) { this . size = 4 * n ; this . n = n ; this . a = a ; st = new long [ size ] ;

import java . util . * ; import java . util . Arrays ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int L1 = - 1 , R1 = - 1 , L2 = - 1 , R2 = - 1 ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; String [ ] table = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { table [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( table [ i ] . charAt ( j ) == ' B ' ) { if ( L1 == - 1 ) { L2 = i ; L1 = i ; R2 = j ; R1 = j ; } else if ( i > L2 && j > R2 ) { L2 = i ; R2 = j ; } } } } System . out . println ( ( L1 + L2 + 2 ) / 2 + " ▁ " + ( R1 + R2 + 2 ) / 2 ) ; } }

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ;   public class Singleton_Pattern { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . nextLine ( ) ; int x = 0 ; int y = - 1 ; int count = 0 ; int startindex = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { String s = sc . nextLine ( ) ; if ( x == 1 ) continue ; if ( s . contains ( " B " ) ) { x = 1 ; if ( startindex == - 1 ) startindex = i ;   for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( j ) == ' B ' ) {

f = 1 r , n = map ( int , input ( ) . split ( ) ) for x in range ( r ) : s = input ( ) s1 = len ( s ) s2 = len ( s ) if f == 1 : for i in range ( len ( s ) ) : if s [ i ] == " B " and f == 1 : s1 = i   f = 0   p = x NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) matrix = [ ] for i in range ( n ) : row = list ( str ( input ( ) ) ) matrix . append ( row ) for j in range ( n ) : for k in range ( m ) : if ( matrix [ j ] [ k ] == " B " ) : c = j d = kfor p in reversed ( range ( n ) ) : for q in reversed ( range ( m ) ) : if ( matrix [ p ] [ q ] == " B " ) : f = p g = qr = int ( ( c + f ) / 2 ) s = int ( ( d + g ) / 2 ) print ( r + 1 , " ▁ " , s + 1 ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) )   matrix = [ ]   find_B_start = TrueB_col_start = B_row_start = B_side = 0   for i in range ( n ) : row = list ( str ( input ( ) ) ) for j in range ( m ) : if row [ j ] == ' B ' : if ( find_B_start ) : B_col_start = j + 1 B_row_start = i + 1 find_B_start = False B_side += 1 break   middle_x = B_col_start + ( B_side // 2 ) middle_y = B_row_start + ( B_side // 2 )   print ( middle_y , end = ' ▁ ' ) print ( middle_x )                                 NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) v = Falsefor i in range ( n ) : row = input ( ) if not v and ' B ' in row : s , e = row . find ( ' B ' ) , row . rfind ( ' B ' ) c = ( s + e ) // 2 r = i + c - s v = True print ( r + 1 , c + 1 ) NEW_LINE