import java . util . Scanner ;   public class B1153 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int R = in . nextInt ( ) ; int C = in . nextInt ( ) ; int H = in . nextInt ( ) ; int [ ] Rheight = new int [ R ] ; int [ ] Cheight = new int [ C ] ; for ( int c = 0 ; c < C ; c ++ ) { Cheight [ c ] = in . nextInt ( ) ; } for ( int r = 0 ; r < R ; r ++ ) { Rheight [ r ] = in . nextInt ( ) ; } StringBuilder answer = new StringBuilder ( ) ; for ( int r = 0 ; r < R ; r ++ ) { for ( int c = 0 ; c < C ; c ++ ) { int a = in . nextInt ( ) ; int h = ( a == 0 ) ? 0 : Math . min ( Rheight [ r ] , Cheight [ c ] ) ; answer . append ( h ) . append ( ' ▁ ' ) ; } answer . append ( ' \n ' ) ; } System . out . print ( answer ) ; }   }

import java . io . IOException ; import java . io . InputStreamReader ; import java . util . TreeSet ; import java . util . Scanner ; import java . util . Collections ; import java . util . HashSet ; import java . util . Arrays ; import java . lang . Math ; import java . io . BufferedReader ;   public class lottery { public static void main ( String [ ] args ) throws IOException { Scanner scan = new Scanner ( System . in ) ; int len = scan . nextInt ( ) ; int width = scan . nextInt ( ) ; int height = scan . nextInt ( ) ; int [ ] front = new int [ width ] ; int [ ] left = new int [ len ] ; int [ ] [ ] top = new int [ len ] [ width ] ; for ( int i = 0 ; i < width ; i ++ ) { front [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < len ; i ++ ) { left [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < len ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { top [ i ] [ j ] = scan . nextInt ( ) ; } } int [ ] [ ] ans = new int [ len ] [ width ] ; for ( int i = 0 ; i < len ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { if ( top [ i ] [ j ] == 1 ) { ans [ i ] [ j ] = Math . min ( front [ j ] , left [ i ] ) ; } } } for ( int i = 0 ; i < len ; i ++ ) { for ( int j = 0 ; j < width ; j ++ ) { System . out . print ( ans [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; } } }

import java . io . * ; import java . util . * ; import java . lang . * ;   public class c1 { public static MyScanner scan ; public static PrintWriter out ; public static void main ( String [ ] args ) { scan = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ;   int t = 1 ;

n , m , h = list ( map ( int , input ( ) . split ( ) ) )     a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) c = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ]   for i in range ( n ) : for j in range ( m ) : if c [ i ] [ j ] == 1 : c [ i ] [ j ] = min ( a [ j ] , b [ i ] ) 	   for i in range ( n ) : print ( * c [ i ] ) NEW_LINE

n , m , h = list ( map ( int , input ( ) . split ( ) ) ) a_m = list ( map ( int , input ( ) . split ( ) ) ) b_n = list ( map ( int , input ( ) . split ( ) ) ) a_b = [ ] h = [ ] for i in range ( n ) : h . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for j in range ( m ) : if ( h [ i ] [ j ] > 0 ) : if ( a_m [ j ] >= b_n [ i ] ) : h [ i ] [ j ] = b_n [ i ] else : h [ i ] [ j ] = a_m [ j ] a_b . append ( [ a_m [ j ] , b_n [ i ] , i , j ] )   for i in range ( n ) : h [ i ] = list ( map ( str , h [ i ] ) ) print ( " ▁ " . join ( h [ i ] ) )     NEW_LINE

n , m , h = list ( map ( int , input ( ) . split ( ) ) ) a_m = list ( map ( int , input ( ) . split ( ) ) ) b_n = list ( map ( int , input ( ) . split ( ) ) ) a_b = [ ] h = [ ] for i in range ( n ) : h . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for j in range ( m ) : if ( h [ i ] [ j ] > 0 ) : if ( a_m [ j ] >= b_n [ i ] ) : h [ i ] [ j ] = b_n [ i ] else : h [ i ] [ j ] = a_m [ j ] h [ i ] = list ( map ( str , h [ i ] ) ) print ( " ▁ " . join ( h [ i ] ) )     NEW_LINE


import java . io . * ; import java . util . * ;   public class A implements Runnable { public static void main ( String [ ] args ) { new Thread ( null , new A ( ) , " _ cf " , 1 << 28 ) . start ( ) ; }   public void run ( ) { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; System . err . println ( " Go ! " ) ;   int n = fs . nextInt ( ) ; long k = fs . nextLong ( ) ; long [ ] a = new long [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) a [ i ] = fs . nextLong ( ) ; BIT value = new BIT ( n + 1 ) ; BIT alive = new BIT ( n + 1 ) ; for ( int i = 1 ; i <= n ; i ++ ) { long sub = ( n - i ) * a [ i ] ; sub *= alive . sum ( i - 1 ) ; long add = value . sum ( i - 1 ) ; long di = add - sub ;

import java . io . * ; import java . util . StringTokenizer ;   public class _314A implements Runnable { private BufferedReader in ; private StringTokenizer tok ;   private Object solve ( ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; for ( long i = 2 , j = 2 , n = nextInt ( ) , k = nextInt ( ) , a = nextInt ( ) , m = 0 , l = n ; i <= n ; i ++ ) { long s = ( j - 2 ) * a , c = nextInt ( ) ; if ( m + s < k + ( j - 1 ) * ( l - j ) * c ) { sb . append ( i ) . append ( ' \n ' ) ; l -- ; } else { a = c ; m += s ; j ++ ; } } return sb ; }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; } long d1 = 0 ; for ( int i = 0 , i2 = 0 ; i < n ; i ++ ) { long d2 = ( long ) i2 * ( n - i - 1 ) * a [ i ] ; if ( d1 - d2 < k ) { out . println ( i + 1 ) ; } else { d1 += i2 * a [ i ] ; i2 ++ ; } } }   }   static class InputReader { private StringTokenizer tokenizer ; private BufferedReader reader ;   public InputReader ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; }   private void fillTokenizer ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } }   public String next ( ) { fillTokenizer ( ) ; return tokenizer . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }

from sys import stdin , stdoutnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) for _ in range ( 1 ) : NEW_LINE

f = lambda : map ( int , input ( ) . split ( ) ) n , k = f ( ) s = j = 0 for i , q in enumerate ( f ( ) , 1 ) : if s - j * ( n - i ) * q < k : print ( i ) else : s += q * j j += 1 NEW_LINE

f = lambda : map ( int , input ( ) . split ( ) ) n , k = f ( ) j = 0 for i , q in enumerate ( f ( ) , 1 ) : if j * ( i - n ) * q < k : print ( i ) else : k -= q * j j += 1 NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) arr = map ( int , input ( ) . split ( ) ) s , j , all_res = 0 , 0 , [ ] for i , q in enumerate ( arr , 1 ) : if s - j * ( n - i ) * q < k : all_res . append ( str ( i ) ) else : s += q * j j += 1 print ( ' \n ' . join ( all_res ) ) NEW_LINE

from sys import stdin , stdoutnmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) def fn ( a ) : print ( ' a ' , a ) n = len ( a ) pos1 = [ 0 ] for i in range ( 1 , n ) : pos1 += [ pos1 [ - 1 ] + a [ i ] * i ] print ( ' pos1' , pos1 ) neg = [ ] for i in range ( n ) : neg += [ i * ( n - i - 1 ) * a [ i ] ] print ( ' neg ' , neg ) d = [ ] for i in range ( 1 , n + 1 ) : sm = 0 for j in range ( 1 , i ) : sm += a [ j - 1 ] * ( j - 1 ) - ( n - i ) * a [ i - 1 ] d += [ sm ] print ( ' d ' , d ) ; print ( ' = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = ' ) p = - 1 for i in range ( 1 , n ) : if pos1 [ i - 1 ] - neg [ i ] < k : p = i break if p == - 1 : return a . pop ( p ) fn ( a ) for _ in range ( 1 ) : NEW_LINE


import java . util . Scanner ; import java . util . Arrays ;   public class Polikarp { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   int n = input . nextInt ( ) ;   int [ ] array = new int [ n ] ; int [ ] arr = new int [ n ] ; long sum = 0 ;   for ( int i = 0 ; i < n ; i ++ ) {   arr [ i ] = input . nextInt ( ) ; }   for ( int b = 0 ; b < n ; b ++ ) { sum = arr [ b ] + sum ; }   for ( int h = 0 ; h < n ; h ++ ) { array [ h ] = input . nextInt ( ) ; }   Arrays . sort ( array ) ;   if ( array [ n - 2 ] + array [ n - 1 ] >= sum ) { System . out . println ( " YES " ) ; }   else { System . out . println ( " NO " ) ; } } }

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

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

import java . util . * ; import static java . lang . Math . max ; import static java . lang . Math . min ;   public class Test { public static void main ( String [ ] args ) {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ;   for ( int i = 0 ; i < n ; i ++ ) a [ i ] = input . nextInt ( ) ;   for ( int i = 0 ; i < n ; i ++ ) b [ i ] = input . nextInt ( ) ;   long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; }   int first = max ( b [ 0 ] , b [ 1 ] ) , second = min ( b [ 0 ] , b [ 1 ] ) ; for ( int i = 2 ; i < n ; i ++ ) { if ( b [ i ] > first ) { second = first ; first = b [ i ] ; } else if ( b [ i ] > second ) { second = b [ i ] ; } } System . out . println ( first + second >= sum ? " YES " : " NO " ) ; } }

n = int ( input ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) B = list ( map ( int , input ( ) . split ( ) ) )   space = [ ] for i in range ( n ) : space . append ( B [ i ] ) NEW_LINE

def canFill ( cola_volumes , can_capacities ) : total_volume = sum ( cola_volumes ) can_capacities . sort ( ) if total_volume <= can_capacities [ - 1 ] + can_capacities [ - 2 ] : return " YES " return " NO "   no_of_cans = int ( input ( ) ) cola_volumes = list ( map ( int , input ( ) . split ( ) ) ) can_capacities = list ( map ( int , input ( ) . split ( ) ) ) print ( canFill ( cola_volumes , can_capacities ) ) NEW_LINE

import itertoolsimport bisectimport mathfrom collections import * import osimport sysfrom io import BytesIO , IOBase   ii = lambda : int ( input ( ) ) lmii = lambda : list ( map ( int , input ( ) . split ( ) ) ) slmii = lambda : sorted ( map ( int , input ( ) . split ( ) ) ) li = lambda : list ( input ( ) ) mii = lambda : map ( int , input ( ) . split ( ) ) msi = lambda : map ( str , input ( ) . split ( ) )     def main ( ) : NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE

try : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) ) z = [ ] b . sort ( ) r = sum ( a ) if ( b [ len ( b ) - 1 ] + b [ len ( b ) - 2 ] ) >= r : print ( " YES " ) else : print ( " NO " ) except : pass NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . StringTokenizer ;   public class Main { static ArrayList < Integer > adjList [ ] ; static double ans [ ] ; static int cnt [ ] ;   public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; adjList = new ArrayList [ n ] ; for ( int i = 0 ; i < n ; i ++ ) adjList [ i ] = new ArrayList < > ( ) ; for ( int i = 1 ; i < n ; i ++ ) adjList [ sc . nextInt ( ) - 1 ] . add ( i ) ; cnt = new int [ n ] ; preprocess ( 0 ) ; ans = new double [ n ] ; dfs ( 0 , 0 ) ; for ( double x : ans ) out . print ( x + " ▁ " ) ; out . flush ( ) ; out . close ( ) ; }   static void dfs ( int u , int p ) { if ( u == 0 ) ans [ u ] = 1 ; else ans [ u ] = ans [ p ] + 0.5 * ( 1 + cnt [ p ] - cnt [ u ] ) ; for ( int v : adjList [ u ] ) dfs ( v , u ) ; }   static void preprocess ( int u ) { cnt [ u ] = 1 ; for ( int v : adjList [ u ] ) { preprocess ( v ) ; cnt [ u ] += cnt [ v ] ; } }   static class Scanner { BufferedReader br ; StringTokenizer st ;   Scanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; }   int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } } }

import java . util . ArrayList ; import java . util . List ; import java . util . Locale ; import java . util . Scanner ;

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . List ; import java . util . Scanner ; import java . util . ArrayList ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class TaskA { private int [ ] sub ; private List < List < Integer > > adj ; private int [ ] height ;   public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; adj = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { adj . add ( new ArrayList < > ( ) ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int u = in . nextInt ( ) ; adj . get ( u - 1 ) . add ( i + 1 ) ; } sub = new int [ n ] ; height = new int [ n ] ; dfs ( 0 , - 1 ) ; for ( int i = 0 ; i < n ; i ++ ) { double ans = ( n - sub [ i ] - height [ i ] ) / 2.0 + height [ i ] + 1 ; out . print ( ans + " ▁ " ) ; } }   private void dfs ( int u , int p ) { sub [ u ] += 1 ; height [ u ] = ( p == - 1 ) ? 0 : height [ p ] + 1 ; for ( int v : adj . get ( u ) ) { dfs ( v , u ) ; sub [ u ] += sub [ v ] ; } }   } }

import java . io . * ; import java . util . * ;   public class icpc { public static void main ( String [ ] args ) throws IOException { Reader in = new Reader ( ) ;

class tree_node ( ) : def __init__ ( self ) : self . children = [ ] self . parent = None self . time = 0 self . downstream = 0   def addChild ( self , node ) : self . children . append ( node )   num_cities = int ( input ( ) )   if num_cities > 1 : other_cities = [ int ( x ) for x in input ( ) . split ( " ▁ " ) ] else : other_cities = [ ]   root = tree_node ( )   cities = [ root ]   for parent_city in other_cities : node = tree_node ( ) cities . append ( node ) parent = cities [ parent_city - 1 ] node . parent = parent parent . addChild ( node )   def calculate_downstream ( node ) : children = node . children if len ( children ) == 0 : return 1 return sum ( c . downstream for c in children ) + 1   def set_all_downstreams ( cities ) : for node in cities [ : : - 1 ] : node . downstream = calculate_downstream ( node )   def expected_starting_time ( node ) : parent = node . parent if parent == None : return 1.0 other_ds = parent . downstream - node . downstream - 1   return parent . time + other_ds / 2 + 1   def set_starting_times ( cities ) : for c in cities : c . time = expected_starting_time ( c )   set_all_downstreams ( cities ) set_starting_times ( cities )   for c in cities : print ( c . time ) NEW_LINE

n = int ( input ( ) ) pos , tree , ans , sz = list ( map ( int , input ( ) . split ( ) ) ) if n > 1 else [ ] , [ ] , [ ] , [ ] for i in range ( n ) : tree . append ( [ ] ) ans . append ( 0.0 ) sz . append ( 0 )   for i in range ( n - 1 ) : tree [ pos [ i ] - 1 ] . append ( i + 1 )   for i in range ( n ) [ : : - 1 ] : sz [ i ] = 1 for to in tree [ i ] : sz [ i ] += sz [ to ]   for i in range ( n ) : for to in tree [ i ] : ans [ to ] = ans [ i ] + 1 + ( sz [ i ] - 1 - sz [ to ] ) * 0.5   st = lambda i : str ( i + 1 ) print ( ' ▁ ' . join ( list ( map ( st , ans ) ) ) )       NEW_LINE

n = int ( input ( ) ) if n == 1 : print ( 1 ) exit ( 0 ) l = list ( map ( int , input ( ) . split ( ) ) ) w = [ [ ] for i in range ( n ) ] sz = [ 1 ] * nfor i in range ( n - 1 ) : w [ l [ i ] - 1 ] . append ( i + 1 ) for i in range ( n - 1 , - 1 , - 1 ) : for j in range ( len ( w [ i ] ) ) : sz [ i ] += sz [ w [ i ] [ j ] ] ans = [ 0 ] * nfor i in range ( n ) : for j in range ( len ( w [ i ] ) ) : ans [ w [ i ] [ j ] ] = ans [ i ] + 1 + ( sz [ i ] - 1 - sz [ w [ i ] [ j ] ] ) / 2 for i in range ( n ) : print ( ans [ i ] + 1 , end = " ▁ " ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Practice { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( ( t -- ) > 0 ) { PriorityQueue < Integer > heap = new PriorityQueue < Integer > ( Collections . reverseOrder ( ) ) ; String str = ( br . readLine ( ) ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == '1' ) { int curr = 0 ; while ( i < str . length ( ) && str . charAt ( i ) == '1' ) { i ++ ; curr ++ ; } heap . add ( curr ) ; } } int ans = 0 ; while ( ! heap . isEmpty ( ) ) { ans += heap . remove ( ) ; if ( heap . size ( ) > 0 ) { heap . remove ( ) ; } } System . out . println ( ans ) ; } } }

import java . util . * ; public class Test { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; while ( t -- > 0 ) { char [ ] s = input . next ( ) . toCharArray ( ) ; LinkedList < Integer > list = new LinkedList < > ( ) ; for ( int i = 0 ; i < s . length ; i ++ ) { int counter = 0 ; while ( i <= s . length - 1 && s [ i ] == '1' ) { counter ++ ; i ++ ; } if ( counter > 0 ) list . add ( counter ) ; } Collections . sort ( list , new Reverse ( ) ) ; int result = 0 ; for ( int i = 0 ; i < list . size ( ) ; i += 2 ) { result += list . get ( i ) ; } System . out . println ( result ) ; } } static class Reverse implements Comparator < Integer > { @ Override public int compare ( Integer a , Integer b ) { if ( a < b ) return 1 ; else if ( a > b ) return - 1 ; return 0 ; } } }

import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class SubstringRemovalGame { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int num = scan . nextInt ( ) ; ArrayList < String > cases = new ArrayList ( ) ; ArrayList < String > ones = new ArrayList ( ) ; ArrayList < Integer > score = new ArrayList ( ) ; int alice = 0 ; int gameCounter = 0 ; String one = " " ; for ( int i = 0 ; i < num ; i ++ ) cases . add ( scan . next ( ) ) ; for ( int i = 0 ; i < num ; i ++ ) { for ( int j = 0 ; j < cases . get ( i ) . length ( ) ; j ++ ) { if ( cases . get ( i ) . charAt ( j ) == '1' ) { one = one . concat ( "1" ) ; if ( ! one . equals ( " " ) && j == cases . get ( i ) . length ( ) - 1 ) ones . add ( one ) ; } else { if ( ! one . equals ( " " ) ) ones . add ( one ) ; one = " " ; } } while ( ! ones . isEmpty ( ) ) { if ( gameCounter % 2 == 0 ) { alice += Collections . max ( ones ) . length ( ) ; } gameCounter ++ ; ones . remove ( ones . indexOf ( ( Collections . max ( ones ) ) ) ) ; } score . add ( alice ) ; alice = 0 ; ones . clear ( ) ; one = " " ; gameCounter = 0 ; } for ( int i = 0 ; i < score . size ( ) ; i ++ ) System . out . println ( score . get ( i ) ) ; } }

for i in range ( int ( input ( ) ) ) : NEW_LINE INDENT s = input ( ) NEW_LINE a = sorted ( [ len ( i ) for i in s . split ( '0' ) ] , reverse = True ) NEW_LINE s = 0 NEW_LINE for i in range ( 0 , len ( a ) , 2 ) : NEW_LINE INDENT s += a [ i ] NEW_LINE DEDENT print ( s ) NEW_LINE DEDENT

t = int ( input ( ) ) NEW_LINE for i in range ( t ) : NEW_LINE INDENT s = input ( ) NEW_LINE l = list ( s ) NEW_LINE c = 0 NEW_LINE s = 0 NEW_LINE new = [ ] NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if l [ i ] == "1" : NEW_LINE INDENT c += 1 NEW_LINE if i == len ( l ) - 1 : NEW_LINE INDENT new . append ( c ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT new . append ( c ) NEW_LINE c = 0 NEW_LINE DEDENT DEDENT new . sort ( reverse = True ) NEW_LINE for i in range ( 0 , len ( new ) , 2 ) : NEW_LINE INDENT s += new [ i ] NEW_LINE DEDENT print ( s ) NEW_LINE DEDENT

for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT ans = 0 NEW_LINE S = input ( ) NEW_LINE l = sorted ( S . split ( "0" ) , reverse = True ) NEW_LINE for i in range ( len ( l ) ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT ans += len ( l [ i ] ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT

t = int ( input ( ) ) NEW_LINE for _ in range ( t ) : NEW_LINE INDENT s = input ( ) NEW_LINE q = " " NEW_LINE ali = [ ] NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if ( s [ i ] != "1" ) : NEW_LINE INDENT if ( len ( q ) != 0 ) : NEW_LINE INDENT ali . append ( int ( q ) ) NEW_LINE DEDENT q = " " NEW_LINE DEDENT else : NEW_LINE INDENT q += "1" NEW_LINE DEDENT DEDENT if ( len ( q ) != 0 ) : NEW_LINE INDENT ali . append ( int ( q ) ) NEW_LINE DEDENT ali = sorted ( ali , reverse = True ) NEW_LINE ans = 0 NEW_LINE for i in range ( 0 , len ( ali ) , 2 ) : NEW_LINE INDENT q = str ( ali [ i ] ) NEW_LINE ans += len ( q ) NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT

testcases = int ( input ( ) ) NEW_LINE for i in range ( testcases ) : NEW_LINE INDENT sequence = input ( ) NEW_LINE sequence = sequence . split ( '0' ) NEW_LINE sequence = [ len ( item ) for item in sequence if len ( item ) > 0 ] NEW_LINE sequence . sort ( reverse = True ) NEW_LINE print ( sum ( sequence [ : : 2 ] ) ) NEW_LINE DEDENT


import java . util . Scanner ; public class B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , q = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; while ( q -- > 0 ) { int l = sc . nextInt ( ) , r = sc . nextInt ( ) ; int ans = k + a [ r - 1 ] - a [ l - 1 ] - 2 * ( r - l ) - 1 ; System . out . println ( ans ) ; } sc . close ( ) ; } }

import java . util . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; while ( q -- > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int out = 0 ; out = k + arr [ b - 1 ] - arr [ a - 1 ] - 2 * ( b - a ) - 1 ; System . out . println ( out ) ; } } }

import java . util . * ; import java . math . * ; public class ReplaceAndKeepSorted { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = sc . nextInt ( ) ; while ( q -- > 0 ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int out = 0 ; out = k + arr [ b - 1 ] - arr [ a - 1 ] - 2 * ( b - a ) - 1 ; System . out . println ( out ) ; } } }

import java . util . Scanner ; public class p1485B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , q = sc . nextInt ( ) , k = sc . nextInt ( ) , a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; while ( q -- > 0 ) { int l = sc . nextInt ( ) - 1 , r = sc . nextInt ( ) - 1 ; System . out . println ( ( a [ r ] - a [ l ] + 1 - ( r - l + 1 ) ) * 2 + k - a [ r ] + a [ l ] - 1 ) ; } } }

R = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE n , q , k = R ( ) NEW_LINE a = 0 , * R ( ) NEW_LINE for _ in [ 0 ] * q : l , r = R ( ) ; print ( a [ r ] - a [ l ] + ( l - r ) * 2 + k - 1 ) NEW_LINE

n , q , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( q ) : NEW_LINE INDENT l , r = map ( int , input ( ) . split ( ) ) NEW_LINE print ( a [ r - 1 ] - a [ l - 1 ] + ( l - r ) * 2 + k - 1 ) NEW_LINE DEDENT

n , q , k = map ( int , input ( ) . split ( ) ) ; NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for Q in range ( q ) : l , r = map ( int , input ( ) . split ( ) ) ; print ( a [ r - 1 ] - a [ l - 1 ] + ( l - r ) * 2 + k - 1 ) NEW_LINE

n , q , k = map ( int , input ( ) . split ( ) ) ; NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for _ in ' . ' * q : l , r = map ( int , input ( ) . split ( ) ) ; print ( a [ r - 1 ] - a [ l - 1 ] + ( l - r ) * 2 + k - 1 ) NEW_LINE


import java . util . * ;    public class Practise {

import java . util . Scanner ;   public class Tetris { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , m = in . nextInt ( ) , i , a [ ] = new int [ n ] , o = 1000 ; for ( i = 0 ; i < m ; i ++ ) a [ in . nextInt ( ) - 1 ] ++ ;   in . close ( ) ; for ( i = 0 ; i < n ; i ++ ) o = Math . min ( o , a [ i ] ) ; System . out . println ( o ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ;   public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ATetris solver = new ATetris ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class ATetris { int n ; int m ;   public void readInput ( Scanner sc ) { n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; }   public void solve ( int testNumber , Scanner sc , PrintWriter pw ) { int q = 1 ; while ( q -- > 0 ) { readInput ( sc ) ; int [ ] count = new int [ n ] ; for ( int i = 0 ; i < m ; i ++ ) count [ sc . nextInt ( ) - 1 ] ++ ; int min = Integer . MAX_VALUE ; for ( int x : count ) min = Math . min ( min , x ) ; pw . println ( min ) ; } }   }   static class Scanner { StringTokenizer st ; BufferedReader br ;   public Scanner ( InputStream s ) { br = new BufferedReader ( new InputStreamReader ( s ) ) ; }   public String next ( ) { try { while ( st == null || ! st . hasMoreTokens ( ) ) st = new StringTokenizer ( br . readLine ( ) ) ; return st . nextToken ( ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   } }

import sysinput = sys . stdin . readlinefrom collections import defaultdict as dcfrom collections import Counterfrom bisect import bisect_right , bisect_leftimport mathfrom operator import itemgetterfrom heapq import heapify , heappop , heappushfrom queue import PriorityQueue as pqn , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) x = dc ( int ) c = 0 p = 0 NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) count = [ 0 ] * na = list ( map ( int , input ( ) . split ( ) ) ) for i in range ( m ) : count [ a [ i ] - 1 ] += 1 print ( min ( count ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) A = list ( map ( int , input ( ) . split ( ) ) ) L = [ 0 ] * nfor i in range ( m ) : L [ A [ i ] - 1 ] += 1 print ( min ( L ) ) NEW_LINE

if __name__ == " _ _ main _ _ " : dic = { } n , m = map ( int , input ( ) . split ( ) ) li = list ( map ( int , input ( ) . split ( ) ) ) c = 0 for i in range ( n ) : dic . setdefault ( i + 1 , 0 ) for i in li : if 0 not in dic . values ( ) : c = c + 1 for j in range ( 1 , n + 1 ) : dic [ j ] = dic [ j ] - 1   dic [ i ] = dic [ i ] + 1 if 0 not in dic . values ( ) : c = c + 1 print ( c ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : n , m = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) d = dict ( ) if len ( set ( l ) ) < n : print ( 0 ) else : for i in range ( m ) : d . setdefault ( l [ i ] , 0 ) d [ l [ i ] ] += 1 min1 = 999999999 for i in d . values ( ) : if i < min1 : min1 = i print ( min1 ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int n = sc . nextInt ( ) ; int s = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int mid = n / 2 ; Long cost = 0L ; if ( arr [ mid ] < s ) { cost += s - arr [ mid ] ; for ( int i = mid + 1 ; i < n ; i ++ ) { if ( arr [ i ] < s ) { cost += s - arr [ i ] ; } } } else if ( arr [ mid ] > s ) { cost += arr [ mid ] - s ; for ( int i = mid - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] > s ) { cost += arr [ i ] - s ; } } } else { cost = 0L ; }   System . out . println ( cost ) ;   } }   }

import javax . print . DocFlavor ; import java . io . * ; import java . net . Inet4Address ; import java . sql . ClientInfoStatus ; import java . util . * ;

import java . util . * ; import java . math . BigInteger ; public class asd { static Scanner s = new Scanner ( System . in ) ; public static void main ( String args [ ] ) throws Exception { int t = 1 ; while ( t -- > 0 ) { solve ( ) ; } } public static void solve ( ) { int n = s . nextInt ( ) ; int y = s . nextInt ( ) ; long arr [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = s . nextLong ( ) ; Arrays . sort ( arr ) ; long med = arr [ n / 2 ] ; if ( med < y ) { long sum = ( long ) ( y - med ) ; arr [ n / 2 ] = y ; for ( int i = n / 2 + 1 ; i < n ; i ++ ) { if ( arr [ i ] < y ) { sum += ( y - arr [ i ] ) ; } else break ; } System . out . println ( sum ) ; } else { long sum = med - y ; arr [ n / 2 ] = y ; for ( int i = n / 2 - 1 ; i >= 0 ; i -- ) { if ( arr [ i ] > y ) { sum += ( arr [ i ] - y ) ; } else break ; } System . out . println ( sum ) ; } } }

a , b = map ( int , input ( ) . split ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) low = [ ] eq = [ ] high = [ ] flag = Truenum = int ( ( a - 1 ) / 2 ) for i in l : if i < b : low . append ( i ) elif i > b : high . append ( i ) else : if flag : eq . append ( i ) flag = False else : high . append ( i )     if len ( low ) == len ( high ) : print ( 0 ) elif len ( low ) > len ( high ) : k = b t = len ( low ) - num r = 0 n = - 1 for _ in range ( t ) : r += k - low [ n ] n -= 1 print ( r ) else : k = b t = len ( high ) - num r = 0 n = 0 for _ in range ( t ) : r += high [ n ] - k n += 1 print ( r ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) ar = sorted ( ar ) ; ans = 0 NEW_LINE

n , res = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) count = 0 s . sort ( )   for i in range ( n // 2 + 1 ) : if ( s [ i ] > res ) : count += s [ i ] - res   if ( s [ n - 1 - i ] < res ) : count += res - s [ n - 1 - i ]   print ( count ) NEW_LINE

n , s = map ( int , input ( ) . split ( ) ) l = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) cost = 0 boi0 = l [ : n // 2 ] boi1 = l [ n // 2 + 1 : ] for i in range ( n // 2 ) : if boi0 [ - 1 - i ] > s : cost += abs ( boi0 [ - 1 - i ] - s ) boi0 [ - 1 - i ] = s if boi1 [ i ] < s : cost += abs ( boi1 [ i ] - s ) boi1 [ i ] = scost += abs ( l [ n // 2 ] - s ) print ( cost ) NEW_LINE

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 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 . HashMap ; import java . util . List ; import java . util . Map ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Main implements Runnable { int n , m ; static boolean use_n_tests = true ; List < Integer > ls = generatePrimes ( 1000000 ) ;   void solve ( FastScanner in , PrintWriter out , int testNumber ) {

import java . io . * ; import java . util . * ; import java . util . Map . Entry ;   public class Main { static int [ ] lp ; static void sieveLinear ( int N ) { ArrayList < Integer > primes = new ArrayList < Integer > ( ) ; lp = new int [ N + 1 ] ;

import java . util . * ; import java . io . * ;   public class Main { public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; }   FastReader in = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int [ ] rec = new int [ 1000001 ] ; void run ( ) { for ( int i = 0 ; i < 1000001 ; i ++ ) { rec [ i ] = i ; } for ( int i = 2 ; i * i < 1000001 ; i ++ ) { if ( rec [ i ] != i ) continue ; for ( int j = i ; j * i < 1000001 ; j ++ ) { rec [ i * j ] = i ; } } for ( int q = ni ( ) ; q > 0 ; q -- ) { work ( ) ; } out . flush ( ) ; } long mod = 1000000007 ; long gcd ( long a , long b ) { return a == 0 ? b : gcd ( b % a , a ) ; }   void work ( ) { int n = ni ( ) ; int [ ] A = nia ( n ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; for ( int a : A ) { int v = 1 ; while ( rec [ a ] != 1 ) { int c = 0 ; int p = rec [ a ] ; while ( a % p == 0 ) { c ++ ; a /= p ; } if ( c % 2 == 1 ) { v *= p ; } } map . put ( v , map . getOrDefault ( v , 0 ) + 1 ) ; } int c1 = 0 , c2 = 0 ; for ( int key : map . keySet ( ) ) { int v = map . get ( key ) ; if ( v > c1 ) { c1 = v ; } if ( v % 2 == 0 || key == 1 ) { c2 += v ; } } for ( int t = ni ( ) ; t > 0 ; t -- ) { long w = nl ( ) ; if ( w == 0 ) { out . println ( c1 ) ; } else { out . println ( Math . max ( c1 , c2 ) ) ; } } }

import sysinput = sys . stdin . readlinefrom NEW_LINE collections NEW_LINE import *     NEW_LINE class Fast_factorize : def NEW_LINE __init__ ( self , n ) : self . p = [ - 1 ] * ( n + 1 ) NEW_LINE for i in range ( 2 , n + 1 ) : if NEW_LINE self . p [ i ] == - 1 : NEW_LINE for j in range ( i , n + 1 , i ) : if NEW_LINE self . p [ j ] == - 1 : self . p [ j ] = i NEW_LINE def factorize ( self , n ) : res = [ ] NEW_LINE while n > 1 : res . append ( self . p [ n ] ) NEW_LINE n //= self . p [ n ] NEW_LINE return res NEW_LINE ff = Fast_factorize ( 10 ** 6 )   for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE cnt = defaultdict ( int ) NEW_LINE for ai in a : fct = Counter ( ff . factorize ( ai ) ) NEW_LINE key = 1 NEW_LINE for p , c in fct . items ( ) : if NEW_LINE c % 2 == 1 : key *= p NEW_LINE cnt [ key ] += 1 NEW_LINE a , b = 0 , 0 NEW_LINE for k , v in cnt . items ( ) : a = max ( a , v ) NEW_LINE if k == 1 or v % 2 == 0 : b += v NEW_LINE q = int ( input ( ) ) NEW_LINE for _ in range ( q ) : w = int ( input ( ) ) NEW_LINE if w == 0 : NEW_LINE INDENT print ( a ) else : NEW_LINE print ( max ( a , b ) ) NEW_LINE DEDENT

from sys import stdin , stdoutfrom NEW_LINE collections NEW_LINE import defaultdictimport NEW_LINE mathimport NEW_LINE os , sys , __pypy__     NEW_LINE def get_prime ( n ) : n = int ( math . sqrt ( n ) ) NEW_LINE prime = [ 2 ] NEW_LINE for x in range ( 3 , n + 1 , 2 ) : is_prime = False NEW_LINE for p in prime : if NEW_LINE p > int ( math . sqrt ( x ) ) : is_prime = True NEW_LINE break NEW_LINE if x % p == 0 : break NEW_LINE if is_prime : prime . append ( x ) NEW_LINE return prime     NEW_LINE def main ( ) : t = int ( stdin . readline ( ) ) NEW_LINE ans = __pypy__ . builders . StringBuilder ( ) NEW_LINE prime = get_prime ( 1000000 ) NEW_LINE for _ in range ( t ) : n = int ( stdin . readline ( ) ) NEW_LINE arr = list ( map ( int , stdin . readline ( ) . split ( ) ) ) NEW_LINE gp = defaultdict ( int ) NEW_LINE mx = - 1 NEW_LINE for a in arr : x = a NEW_LINE uniq_p = [ ] NEW_LINE for p in prime : while NEW_LINE x % p == 0 : NEW_LINE if len ( uniq_p ) > 0 and uniq_p [ - 1 ] == p : NEW_LINE INDENT uniq_p . pop ( ) else : NEW_LINE uniq_p . append ( p ) NEW_LINE DEDENT x = int ( x / p ) NEW_LINE if p > x : break NEW_LINE if x != 1 : uniq_p . append ( x ) NEW_LINE key = 1 NEW_LINE for x in uniq_p : key *= x NEW_LINE gp [ key ] += 1 NEW_LINE mx = max ( mx , gp [ key ] ) NEW_LINE mx_2 = 0 NEW_LINE for k , v in gp . items ( ) : if NEW_LINE v % 2 == 0 or k == 1 : mx_2 += v NEW_LINE q = int ( stdin . readline ( ) ) NEW_LINE for _ in range ( q ) : qq = int ( stdin . readline ( ) ) NEW_LINE if qq == 0 : NEW_LINE INDENT ans . append ( " % d \n " % ( mx ) ) else : NEW_LINE ans . append ( " % d \n " % ( max ( mx , mx_2 ) ) ) NEW_LINE DEDENT os . write ( 1 , ans . build ( ) . encode ( ) )       main ( ) NEW_LINE

import sysfrom NEW_LINE os NEW_LINE import environfrom NEW_LINE collections NEW_LINE import defaultdict     if environ [ ' USERNAME ' ] == ' kissz ' : inp = open ( ' in0 . txt ' , ' r ' ) . readline NEW_LINE def debug ( * args ) : print ( * args , file = sys . stderr ) NEW_LINE else : inp = sys . stdin . readline NEW_LINE def debug ( * args ) : pass NEW_LINE   NEW_LINE


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Scanner ; import java . util . StringTokenizer ; import java . util . TreeSet ;    public class vk18 { public static void main ( String [ ] stp ) throws Exception { Scanner scan = new Scanner ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) , i ; Pair pair [ ] = new Pair [ n + 1 ] ; TreeSet < Integer > ts = new TreeSet < > ( ) ; for ( i = 1 ; i <= n ; i ++ ) { st = new StringTokenizer ( br . readLine ( ) ) ; pair [ i ] = new Pair ( Integer . parseInt ( st . nextToken ( ) ) , Integer . parseInt ( st . nextToken ( ) ) ) ; if ( pair [ i ] . d == 0 ) ts . add ( i ) ; } while ( ts . size ( ) != 1 ) { int index = ts . pollFirst ( ) ; int right = index ; while ( pair [ right ] . g != 0 ) { right = pair [ right ] . g ; } pair [ right ] . g = ts . first ( ) ; pair [ ts . first ( ) ] . d = right ; } for ( i = 1 ; i <= n ; i ++ ) pw . println ( pair [ i ] . d + " ▁ " + pair [ i ] . g ) ; pw . flush ( ) ; } static class Pair implements Comparable < Pair > { int d , g ; public Pair ( int d , int g ) { this . d = d ; this . g = g ; } public int compareTo ( Pair p ) { return - Integer . compare ( this . d , p . d ) ; } }    }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . HashSet ; import java . util . StringTokenizer ; public class A { void solve ( ) { int n ; n = readInt ( ) ; int [ ] left = new int [ n ] ; int [ ] right = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { left [ i ] = readInt ( ) - 1 ; right [ i ] = readInt ( ) - 1 ; }   boolean [ ] used = new boolean [ n ] ; int now = 0 ; while ( now < n ) { int l = now ; int r = now ; while ( l != - 1 ) { used [ l ] = true ; l = left [ l ] ; } while ( r != - 1 ) { used [ r ] = true ; if ( right [ r ] == - 1 ) break ; r = right [ r ] ; }   for ( ; now < n ; now ++ ) { if ( ! used [ now ] && left [ now ] == - 1 ) { left [ now ] = r ; right [ r ] = now ; break ; } } }   for ( int i = 0 ; i < n ; i ++ ) { out . println ( ( left [ i ] + 1 ) + " ▁ " + ( right [ i ] + 1 ) ) ; } } public static void main ( String [ ] args ) { new A ( ) . run ( ) ; }   private void run ( ) { try { init ( ) ; solve ( ) ; out . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; System . exit ( - 1 ) ; } }   private BufferedReader in ; private StringTokenizer tok = new StringTokenizer ( " " ) ;   private PrintWriter out ;   private void init ( ) { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ;

import java . util . * ; import java . io . * ; public class EdB {   public static void main ( String [ ] args ) throws Exception { int num = 998244353 ;

if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) arr = [ [ 0 , 0 ] ] for i in range ( n ) : arr . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) dl = [ [ 0 , 0 ] ] end = 0 for i in range ( n ) : dl . append ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in range ( 1 , n + 1 ) : if not dl [ i ] [ 0 ] : dl [ end ] [ 1 ] = i dl [ i ] [ 0 ] = end j = i while ( dl [ j ] [ 1 ] ) : NEW_LINE


import java . util . * ; public class Vanya { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int count , sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] <= f ) count = 1 ; else count = 2 ; sum += count ; } System . out . println ( sum ) ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner r = new Scanner ( System . in ) ; int n = r . nextInt ( ) ; int h = r . nextInt ( ) ; int result = 0 ;   for ( int i = 0 ; i < n ; i ++ ) {   result += ( r . nextInt ( ) > h ) ? 2 : 1 ; }   System . out . println ( result ) ;   r . close ( ) ; }   }

import java . util . Scanner ;   public class vanyaAndFence {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int h = sc . nextInt ( ) ; int res = n ; for ( int i = 1 ; i <= n ; i ++ ) { int hi = sc . nextInt ( ) ; if ( hi > h ) { res ++ ; } } System . out . println ( res ) ; }   }

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

n , h = list ( map ( int , input ( ) . split ( ) ) ) n1 = list ( map ( int , input ( ) . split ( ) ) ) count = 0 for i in n1 : if ( i > h ) : count += 2 else : count += 1 print ( count ) NEW_LINE

k = list ( map ( int , input ( ) . split ( ) ) ) l = list ( map ( int , input ( ) . split ( ) ) ) s = 0 for i in l : if ( i > k [ 1 ] ) : s = s + 2 else : s = s + 1 print ( s ) NEW_LINE

n , h = map ( int , input ( ) . split ( ) ) a = input ( ) . split ( ) sum = 0 for i in a : if int ( i ) > h : sum += 2 else : sum += 1 print ( sum ) NEW_LINE

h = int ( input ( ) . split ( ) [ 1 ] ) h_s = input ( ) . split ( ) print ( sum ( [ ( int ( int ( i ) > h ) + 1 ) for i in h_s ] ) ) NEW_LINE


import java . util . * ; public class LnUL { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; int i , j ; while ( t -- > 0 ) { int n = in . nextInt ( ) ; int a [ ] = new int [ n ] ; int l [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; for ( i = 0 ; i < n ; i ++ ) { a [ i ] = in . nextInt ( ) ; b [ i ] = a [ i ] ; } int c = 0 ; for ( i = 0 ; i < n ; i ++ ) { l [ i ] = in . nextInt ( ) ; if ( l [ i ] == 0 ) c ++ ; } int u [ ] = new int [ c ] ; int p = 0 ; for ( i = 0 ; i < n ; i ++ ) { if ( l [ i ] == 0 ) u [ p ++ ] = a [ i ] ; } Arrays . sort ( u ) ; for ( i = 0 ; i < n ; i ++ ) { if ( l [ i ] == 1 ) System . out . print ( a [ i ] + " ▁ " ) ; else System . out . print ( u [ -- c ] + " ▁ " ) ; } System . out . println ( ) ; } } }

import java . util . Scanner ; import java . util . ArrayList ; import java . util . Collections ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( t -- != 0 ) { int n = s . nextInt ( ) ; long arr [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextLong ( ) ; } ArrayList < Long > unlocked = new ArrayList < > ( ) ; ArrayList < Long > locked = new ArrayList < > ( ) ; int index [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int k = s . nextInt ( ) ; if ( k == 0 ) { unlocked . add ( arr [ i ] ) ; } else { locked . add ( arr [ i ] ) ; } index [ i ] = k ; } Collections . sort ( unlocked , Collections . reverseOrder ( ) ) ; long sum = 0 ; int i = 0 , j = 0 , k = 0 ; while ( k < n ) { if ( index [ k ] == 0 ) { System . out . print ( unlocked . get ( j ) + " ▁ " ) ; j ++ ; } else { System . out . print ( locked . get ( i ) + " ▁ " ) ; i ++ ; } k ++ ; } System . out . println ( ) ; } } }

for i in range ( int ( input ( ) ) ) : n = int ( input ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE new = [ ] NEW_LINE ref = [ ] NEW_LINE for j in range ( n ) : if NEW_LINE l [ j ] != 1 : new . append ( arr [ j ] ) else : ref . append ( ( arr [ j ] , j ) ) NEW_LINE new = sorted ( new ) [ : : - 1 ] NEW_LINE for x in ref : new . insert ( x [ 1 ] , x [ 0 ] ) NEW_LINE print ( * new ) NEW_LINE

t = int ( input ( ) ) NEW_LINE for i in range ( 0 , t ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( " ▁ " ) ) ) NEW_LINE l = [ ] NEW_LINE for i in range ( 0 , len ( a ) ) : if NEW_LINE b [ i ] == 0 : l . append ( a [ i ] ) NEW_LINE if not l : NEW_LINE INDENT print ( * a ) else : NEW_LINE j = 0 NEW_LINE DEDENT l . sort ( reverse = True ) NEW_LINE for i in range ( 0 , len ( a ) ) : if NEW_LINE b [ i ] == 0 : a [ i ] = l [ j ] NEW_LINE j += 1 NEW_LINE print ( * a ) NEW_LINE

t = int ( input ( ) ) NEW_LINE for q in range ( t ) : n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE m = [ ] NEW_LINE for i , j in enumerate ( b ) : if NEW_LINE j == 0 : m . append ( a [ i ] ) NEW_LINE m = sorted ( m ) [ : : - 1 ] NEW_LINE z = 0 NEW_LINE for i , j in enumerate ( b ) : if NEW_LINE j == 0 : a [ i ] = m [ z ] NEW_LINE z += 1 NEW_LINE for i in a : print ( i , end = ' ▁ ' ) NEW_LINE print ( ' ' ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   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 l = 0 , r = 0 , u = 0 , d = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' U ' ) u ++ ; else if ( s . charAt ( i ) == ' D ' ) d ++ ; else if ( s . charAt ( i ) == ' L ' ) l ++ ; else r ++ ; } long ans = Math . min ( l , r ) * 2 + Math . min ( u , d ) * 2 ; 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 . Scanner ; import java . util . Arrays ; public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { try { Scanner sc = new Scanner ( System . in ) ; int i , l , d , u , r ; int n = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; char c ; r = u = d = l = 0 ; for ( i = 0 ; i < n ; i ++ ) { c = s . charAt ( i ) ; if ( c == ' R ' ) r ++ ; else if ( c == ' D ' ) d ++ ; else if ( c == ' L ' ) l ++ ; else u ++ ; } r = 2 * ( int ) ( Math . min ( l , r ) ) + 2 * ( int ) ( Math . min ( u , d ) ) ; System . out . println ( r ) ; } catch ( Exception e ) { } } }

import java . util . * ;   public class Solve {   static Scanner scan = new Scanner ( System . in ) ;   public static void solve ( int n , String s ) { int ud = 0 , lr = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' L ' ) { lr -- ; } else if ( s . charAt ( i ) == ' R ' ) { lr ++ ; } else if ( s . charAt ( i ) == ' U ' ) { ud ++ ; } else { ud -- ; } } System . out . println ( n - ( Math . abs ( lr ) + Math . abs ( ud ) ) ) ; }   public static void main ( String [ ] args ) {   int n = scan . nextInt ( ) ; String s = scan . next ( ) ;   solve ( n , s ) ; } }

n = int ( input ( ) ) s = input ( ) cnt = { } for x in s : cnt [ x ] = cnt . get ( x , 0 ) + 1 ans = min ( cnt . get ( ' L ' , 0 ) , cnt . get ( ' R ' , 0 ) ) + min ( cnt . get ( ' U ' , 0 ) , cnt . get ( ' D ' , 0 ) ) print ( ans * 2 ) NEW_LINE

n = int ( input ( ) )     d = { } for c in input ( ) : d . setdefault ( c , 0 ) d [ c ] += 1   ans = min ( d . get ( " L " , 0 ) , d . get ( " R " , 0 ) ) + min ( d . get ( " U " , 0 ) , d . get ( " D " , 0 ) ) print ( ans * 2 ) NEW_LINE

n = int ( input ( ) ) s = input ( ) a = s . count ( ' U ' ) b = s . count ( ' D ' ) c = s . count ( ' L ' ) d = s . count ( ' R ' )   print ( ( min ( a , b ) + min ( c , d ) ) * 2 ) NEW_LINE


import java . io . * ;   public class Main { static int t , n ; static StreamTokenizer st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   public static void main ( String [ ] args ) throws IOException { st . nextToken ( ) ; t = ( int ) st . nval ; int a , b , k ; while ( t -- > 0 ) { st . nextToken ( ) ; n = ( int ) st . nval ; k = 1 ; while ( n -- > 0 ) { st . nextToken ( ) ; a = ( int ) st . nval ; st . nextToken ( ) ; b = ( int ) st . nval ; if ( k < a ) { k = a ; } bw . write ( ( k > b ? 0 : k ++ ) + " ▁ " ) ; } bw . write ( " \n " ) ; } bw . close ( ) ; } }

import java . io . * ; import java . util . * ;   public class Main { static int t , n ; static PriorityQueue < Node > pq = new PriorityQueue < > ( ( o1 , o2 ) -> o1 . a == o2 . a ? o1 . id - o2 . id : o1 . a - o2 . a ) ; static StreamTokenizer st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   static class Node { int a , b , id ;   public Node ( int a , int b , int id ) { this . a = a ; this . b = b ; this . id = id ; } }   public static void main ( String [ ] args ) throws IOException { st . nextToken ( ) ; t = ( int ) st . nval ; int a , b , k ; while ( t -- > 0 ) { st . nextToken ( ) ; n = ( int ) st . nval ; k = 1 ; for ( int i = 0 ; i < n ; ++ i ) { st . nextToken ( ) ; a = ( int ) st . nval ; st . nextToken ( ) ; b = ( int ) st . nval ; pq . add ( new Node ( a , b , i ) ) ; } while ( ! pq . isEmpty ( ) ) { if ( k < pq . peek ( ) . a ) { k = pq . peek ( ) . a ; } bw . write ( ( k > pq . poll ( ) . b ? 0 : k ++ ) + " ▁ " ) ; } bw . write ( " \n " ) ; } bw . close ( ) ; } }

import java . io . * ; import java . util . * ;   public class Main { static int t , n ; static PriorityQueue < Node > pq = new PriorityQueue < > ( ( o1 , o2 ) -> o1 . a == o2 . a ? o1 . id - o2 . id : o1 . a - o2 . a ) ; static StreamTokenizer st = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   static class Node { int a , b , id ;   public Node ( int a , int b , int id ) { this . a = a ; this . b = b ; this . id = id ; } }   public static void main ( String [ ] args ) throws IOException { st . nextToken ( ) ; t = ( int ) st . nval ; int a , b , k ; while ( t -- > 0 ) { st . nextToken ( ) ; n = ( int ) st . nval ; k = 1 ; for ( int i = 0 ; i < n ; ++ i ) { st . nextToken ( ) ; a = ( int ) st . nval ; st . nextToken ( ) ; b = ( int ) st . nval ; pq . add ( new Node ( a , b , i ) ) ; } while ( ! pq . isEmpty ( ) ) { while ( k < pq . peek ( ) . a ) { ++ k ; } bw . write ( ( k > pq . poll ( ) . b ? 0 : k ++ ) + " ▁ " ) ; } bw . write ( " \n " ) ; } bw . close ( ) ; } }

import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class B920 {   static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) {   int tc = 1 ; tc = in . nextInt ( ) ; tcloop : while ( tc -- > 0 ) { int n = in . nextInt ( ) ; ArrayList < Integer > al = new ArrayList < > ( ) ; int left = 0 ; int last = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int l = in . nextInt ( ) ; int r = in . nextInt ( ) ; if ( last >= r ) {

t = int ( input ( ) ) for i in range ( t ) : n = int ( input ( ) ) tm = 1 x = 0 l1 = [ ] while ( x < n ) : l , r = input ( ) . split ( ) l = int ( l ) r = int ( r ) if ( l > tm ) : tm = l elif ( tm > r ) : l1 . append ( 0 ) x = x + 1 continue l1 . append ( tm ) tm = tm + 1 x = x + 1 c = 0 while ( c < n ) : print ( l1 [ c ] , end = " ▁ " ) c = c + 1 NEW_LINE

t = int ( input ( ) ) for test in range ( t ) : n = int ( input ( ) ) l = [ 0 ] * n r = [ 0 ] * n for i in range ( n ) : x , y = map ( int , input ( ) . split ( ) ) l [ i ] = x r [ i ] = y tek = l [ 0 ] for i in range ( n ) : if ( tek > r [ i ] ) : print ( 0 , end = " ▁ " ) if ( i != n - 1 ) : tek = max ( tek , l [ i + 1 ] ) continue print ( tek , end = " ▁ " ) tek += 1 if ( i != n - 1 ) : tek = max ( tek , l [ i + 1 ] ) print ( ) NEW_LINE

import collectionsa = int ( input ( ) ) for x in range ( a ) : b = int ( input ( ) ) s = { } d = { } j = 9999999999999 n = 0 h = [ 0 for y in range ( b ) ] for y in range ( b ) : e , f = map ( int , input ( ) . split ( ) ) j = min ( j , e ) if d . get ( e ) == None : d [ e ] = [ f ]   else : d [ e ] . append ( f )   if s . get ( e ) == None : s [ e ] = [ n ] else : s [ e ] . append ( n )   n += 1       od = collections . OrderedDict ( sorted ( d . items ( ) ) ) odm = collections . OrderedDict ( sorted ( s . items ( ) ) ) for y in odm : ll = 0 j = max ( j , y ) for z in od [ y ] : if z >= j : h [ ( ( odm [ y ] ) [ ll ] ) ] = j   j += 1   ll += 1   print ( * h ) NEW_LINE

import sys , math , itertoolsfrom collections import Counter , deque , defaultdictfrom bisect import bisect_left , bisect_right from heapq import heappop , heappush , heapify , nlargestfrom copy import deepcopymod = 10 ** 9 + 7 INF = float ( ' inf ' ) def inp ( ) : return int ( sys . stdin . readline ( ) ) def inpl ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) def inpl_1 ( ) : return list ( map ( lambda x : int ( x ) - 1 , sys . stdin . readline ( ) . split ( ) ) ) def inps ( ) : return sys . stdin . readline ( ) def inpsl ( x ) : tmp = sys . stdin . readline ( ) ; return list ( tmp [ : x ] ) def err ( x ) : print ( x ) ; exit ( )   for _ in range ( inp ( ) ) : n = inp ( ) data = [ ] for i in range ( n ) : l , r = inpl ( ) data . append ( ( l , r ) ) res = [ 0 ] * n idx = 0 q = deque ( ) for t in range ( 1 , 5010 ) : while idx < n : if data [ idx ] [ 0 ] <= t : q . append ( idx ) idx += 1 else : break while q : i = q . popleft ( ) if t <= data [ i ] [ 1 ] : res [ i ] = t break print ( * res ) NEW_LINE


import java . util . * ; public class file { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int b = scan . nextInt ( ) ; int g = scan . nextInt ( ) ; int n = scan . nextInt ( ) ; if ( n > ( b + g ) ) System . out . println ( "0" ) ; else if ( n == b + g ) System . out . println ( "1" ) ; else if ( n <= b && n <= g ) { System . out . println ( n + 1 ) ; } else if ( n > b && n > g ) { if ( b > g ) { System . out . println ( g - ( n - b ) + 1 ) ; } else { System . out . println ( b - ( n - g ) + 1 ) ; } } else if ( g <= b && g <= n ) System . out . println ( g + 1 ) ; else if ( b <= g && b <= n ) System . out . println ( b + 1 ) ; } }

import java . math . BigInteger ; import java . util . * ;    public class Main { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int boys , girls ; boys = input . nextInt ( ) ; girls = input . nextInt ( ) ; int n = input . nextInt ( ) ; int count = 0 ; int r = n ; for ( int b = 0 ; b <= n ; b ++ , r -- ) { if ( b <= boys && r <= girls ) count ++ ; } System . out . println ( count ) ; } }

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int boys = s . nextInt ( ) ; int girls = s . nextInt ( ) ; int n = s . nextInt ( ) ; int count = 0 , count1 = 0 , found = 0 ; int j = n ; if ( n % 2 == 0 && boys == n / 2 && girls == n / 2 ) found = 1 ; else { for ( int i = 0 ; i <= n ; i ++ ) { if ( i <= boys && j <= girls ) count ++ ; j -- ; } } int min = 0 ; if ( found == 1 ) min = 1 ; else min = count ; System . out . println ( min ) ; } }

import mathb = int ( input ( ) ) g = int ( input ( ) ) n = int ( input ( ) ) k = n + 1 if ( b > n ) : k -= 0 else : k -= ( n - b ) if ( g > n ) : k -= 0 else : k -= ( n - g ) print ( k ) NEW_LINE

b = int ( input ( ) ) g = int ( input ( ) ) n = int ( input ( ) ) ans = 0 for ib in range ( b + 1 ) : rg = n - ib if 0 <= rg <= g : ans += 1 print ( ans ) NEW_LINE

b = int ( input ( ) ) g = int ( input ( ) ) n = int ( input ( ) ) min_g = n - min ( b , n ) max_g = min ( g , n ) ans = max_g - min_g + 1 print ( ans ) NEW_LINE


import java . io . * ; import java . math . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastReader scan = new FastReader ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; Task solver = new Task ( ) ; ans = new StringBuilder ( ) ; int T = 1 ; for ( int tt = 0 ; tt < T ; tt ++ ) solver . solve ( tt , scan , out ) ; out . close ( ) ; }   static StringBuilder ans ;   static class Task { public void solve ( int testNumber , FastReader scan , PrintWriter out ) { int n = scan . nextInt ( ) ; if ( n == 0 ) { out . print ( 1 ) ; return ; } if ( n % 4 == 0 ) out . print ( 6 ) ; else if ( n % 4 == 3 ) out . print ( 2 ) ; else if ( n % 4 == 2 ) out . print ( 4 ) ; else out . print ( 8 ) ; } }   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public FastReader ( String s ) throws FileNotFoundException { br = new BufferedReader ( new FileReader ( new File ( s ) ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . * ; public class Arpa { public static void main ( String args [ ] ) { Scanner S = new Scanner ( System . in ) ; int n = S . nextInt ( ) ; if ( n == 0 ) System . out . println ( "1" ) ; else { int mod = n % 4 ; if ( mod == 1 ) System . out . println ( "8" ) ; else if ( mod == 2 ) System . out . println ( "4" ) ; else if ( mod == 3 ) System . out . println ( "2" ) ; else if ( mod == 0 ) System . out . println ( "6" ) ; } } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner inter = new Scanner ( System . in ) ; long n = inter . nextInt ( ) ; int reminder = ( int ) ( n % 4 ) ; int result = 0 ; switch ( reminder ) { case 0 : { result = 6 ; break ; } case 1 : { result = 8 ; break ; } case 2 : { result = 4 ; break ; } case 3 : { result = 2 ; break ; }   } if ( n != 0 ) System . out . println ( result ) ; else System . out . println ( 1 ) ; } }

import java . util . * ;   public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] ar = new long [ 11 ] ; ar [ 0 ] = 1 ;   long y = 8 ; for ( int i = 1 ; i <= 8 ; i ++ ) { long h = y % 10 ; ar [ i ] = h ; y *= 8 ; } if ( n == 0 ) { System . out . println ( 1 ) ; } else if ( n % 8 == 0 ) { System . out . println ( ar [ 8 ] ) ; } else { System . out . println ( ar [ n % 8 ] ) ; }

import java . util . * ; public class A { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int [ ] dig = { 6 , 8 , 4 , 2 } ; System . out . println ( ( n == 0 ) ? 1 : dig [ n % 4 ] ) ; input . close ( ) ; } }

print ( pow ( 8 , int ( input ( ) ) , 10 ) ) NEW_LINE

n = int ( input ( ) ) if n == 0 : print ( 1 ) else : s = n % 4 if s == 3 : print ( 2 ) elif s == 1 : print ( 8 ) elif s == 2 : print ( 4 ) else : print ( 6 ) NEW_LINE

n = int ( input ( ) ) print ( pow ( 8 , n , 10 ) ) NEW_LINE

n = int ( input ( ) ) ans = pow ( 1378 , n , 10 ) print ( ans ) NEW_LINE


import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int [ ] [ ] a = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] = in . nextInt ( ) ; } } for ( int [ ] ia : a ) { o : for ( int i = 0 ; i < n ; i ++ ) { if ( ia [ i ] != 1 ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { if ( a [ k ] [ i ] + ia [ j ] == ia [ i ] ) { continue o ; } } } System . out . println ( " No " ) ; in . close ( ) ; return ; } } } System . out . println ( " Yes " ) ; in . close ( ) ; } }

import java . util . * ;   public class P3 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a [ ] [ ] = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] = sc . nextInt ( ) ; } } if ( n == 1 ) { if ( a [ 0 ] [ 0 ] == 1 ) { System . out . println ( " YES " ) ; return ; } else { System . out . println ( " NO " ) ; return ; } } boolean mast = false ; int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( a [ i ] [ j ] != 1 ) { cnt = 0 ;

import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; int a [ ] [ ] = new int [ n ] [ n ] ; int one = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] = input . nextInt ( ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( a [ i ] [ j ] != 1 ) { boolean tf = check ( a , i , j , a [ i ] [ j ] ) ; if ( ! tf ) { System . out . println ( " NO " ) ; return ; } } } } System . out . println ( " YES " ) ; }   private static boolean check ( int [ ] [ ] a , int row , int col , int value ) { for ( int i = row ; i < row + 1 ; i ++ ) { for ( int j = 0 ; j < a . length ; j ++ ) { for ( int k = 0 ; k < a . length ; k ++ ) { for ( int l = col ; l < col + 1 ; l ++ ) { if ( a [ i ] [ j ] + a [ k ] [ l ] == value ) return true ; } } } } return false ; }   }

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

cases = int ( input ( ) ) n = casesmatrix = [ ] while cases : cases -= 1 row = list ( map ( int , input ( ) . split ( ) ) )   matrix . append ( row )     for i in range ( n ) : for j in range ( n ) : if matrix [ i ] [ j ] == 1 : continue broken = False for k in range ( n ) : for m in range ( n ) : if matrix [ i ] [ k ] + matrix [ m ] [ j ] == matrix [ i ] [ j ] : broken = True if not broken : print ( " No " ) exit ( ) print ( " Yes " ) NEW_LINE

n = int ( input ( ) ) a = [ ] for i in range ( n ) : b = [ int ( i ) for i in input ( ) . split ( ) ] a . append ( b ) can = Truefor i in range ( n ) : for j in range ( n ) : if a [ i ] [ j ] != 1 : for k in range ( n ) : if a [ i ] [ j ] - a [ k ] [ j ] in a [ i ] : break else : can = Falseif can : print ( " Yes " ) else : print ( " No " ) NEW_LINE

n = int ( input ( ) ) mat = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] c = [ ] for i in range ( n ) : c . append ( set ( ) ) for j in range ( n ) : c [ i ] . add ( mat [ j ] [ i ] ) ans = " YES " for i in range ( n ) : for j in range ( n ) : curr = mat [ i ] [ j ] if curr == 1 : continue for k in range ( n ) : if curr - mat [ i ] [ k ] in c [ j ] : break else : NEW_LINE

import itertoolsimport bisectimport mathfrom collections import * import osimport sysfrom io import BytesIO , IOBase   ii = lambda : int ( input ( ) ) lmii = lambda : list ( map ( int , input ( ) . split ( ) ) ) slmii = lambda : sorted ( map ( int , input ( ) . split ( ) ) ) li = lambda : list ( input ( ) ) mii = lambda : map ( int , input ( ) . split ( ) ) msi = lambda : map ( str , input ( ) . split ( ) )     def main ( ) : NEW_LINE


import java . util . * ; public class WatchingAMovie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ;   int sum = 0 ; int temp = 1 ;   for ( int i = 0 ; i < n ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ;   sum = sum + ( l - temp ) % x ; sum = sum + ( r - l ) + 1 ; temp = r + 1 ; } sc . close ( ) ;   System . out . println ( sum ) ;   } }

import java . util . Scanner ;   public class watchingaMovie { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int current = 1 ; int ans = 0 ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ;   while ( current + x <= a ) { current = current + x ;   } ans = ans + b - current + 1 ; current = b + 1 ; } System . out . println ( ans ) ;   } }

import java . io . * ;   public class _temp2 { public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] st = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( st [ 0 ] ) ; int x = Integer . parseInt ( st [ 1 ] ) ; int count = 0 ; int start = 1 ; for ( int i = 0 ; i < n ; i ++ ) { st = br . readLine ( ) . split ( " ▁ " ) ; int l = Integer . parseInt ( st [ 0 ] ) ; int r = Integer . parseInt ( st [ 1 ] ) ; int skip = ( l - start ) / x ; count += r - l + 1 ; count += ( l - start ) - skip * x ; start = r + 1 ;

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 x = sc . nextInt ( ) ; int a = 1 ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int s = sc . nextInt ( ) ; int f = sc . nextInt ( ) ; if ( x == 1 ) { res = res + f - s + 1 ; } else { while ( a + x <= s ) { a = a + x ; } res = res + f - a + 1 ; a = f + 1 ; }   } System . out . println ( res ) ;   } }

n = [ int ( x ) for x in input ( ) . split ( ) ] t = 1 inte = n [ 0 ] sk = n [ 1 ] counter = 0 for i in range ( inte ) : x = [ int ( x ) for x in input ( ) . split ( ) ] l = x [ 0 ] r = x [ 1 ] if ( l - t ) >= sk : for e in range ( l - t ) : t += sk if ( l - t ) < sk : counter += ( r + 1 ) - t t = r + 1 break elif ( l - t ) < sk : counter += ( r + 1 ) - t t = r + 1 print ( counter ) NEW_LINE

n , x = map ( int , input ( ) . split ( ) ) l = [ ] r = [ ] for i in range ( n ) : v , m = map ( int , input ( ) . split ( ) ) l . append ( v ) r . append ( m )   i = 0 now = 1 c = 0 while now <= r [ - 1 ] : if now > r [ i ] : i = i + 1 if now + x <= l [ i ] : now = now + x elif now + x > l [ i ] : c = c + r [ i ] - now + 1 now = r [ i ] + 1 print ( c ) NEW_LINE

n , x = map ( int , input ( ) . split ( ) ) ans = 0 prev = 0 for _ in range ( n ) : l , r = map ( int , input ( ) . split ( ) ) ans += r - l + 1 + ( l - prev - 1 ) % x prev = rprint ( ans ) NEW_LINE

def solution ( skip_amount , current_time ) : left , right = input ( ) . strip ( ) . split ( ) left = int ( left ) right = int ( right )   while current_time + skip_amount <= left : current_time += skip_amount   time_watched = right - current_time + 1 return time_watched , current_time + time_watched     n , x = input ( ) . strip ( ) . split ( ) n = int ( n ) x = int ( x ) current_time = 1 net = 0   for i in range ( n ) : time_watched , new_current_time = solution ( x , current_time ) net += time_watched current_time = new_current_time   print ( net ) NEW_LINE

n , x = map ( int , input ( ) . split ( ) )   r = lambda : list ( map ( int , input ( ) . split ( ) ) ) arr = [ r ( ) for _ in range ( n ) ]       t = 1 watch = 0 i = 0 while 1 : while t + x <= arr [ i ] [ 0 ] : t += x NEW_LINE


import java . math . * ; import java . util . * ; import java . io . * ;   public class B {   public static void main ( String [ ] args ) throws Exception { Scanner in = new Scanner ( System . in ) ; int test = 10 ; if ( test == 0 ) in = new Scanner ( new FileReader ( file ) ) ; String [ ] str = in . nextLine ( ) . split ( " ▁ " ) ;   int m = Integer . valueOf ( str [ 0 ] ) , n = Integer . valueOf ( str [ 1 ] ) ; String [ ] grid = new String [ m ] ; int [ ] start = new int [ m ] , end = new int [ m ] ; Arrays . fill ( start , - 1 ) ; for ( int i = 0 ; i < m ; i ++ ) { grid [ i ] = in . nextLine ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( grid [ i ] . charAt ( j ) == ' W ' ) { if ( start [ i ] == - 1 ) start [ i ] = j ; end [ i ] = j ; } } } while ( m > 0 && start [ m - 1 ] < 0 ) m -- ;

import java . io . * ; import java . util . * ; public class code implements Runnable {

def check ( line , clom ) : global rem global pos_first global pos_last while line <= n : for i in range ( 1 , m + 1 ) : if ls [ line ] [ i ] == ' W ' : if pos_first == 0 : pos_first = i rem = line pos_last = i if ' W ' in ls [ line ] : return True line += 1 return False   n , m = map ( int , input ( ) . split ( ) ) ls = [ [ 0 ] for j in range ( n + 1 ) ] for i in range ( 1 , n + 1 ) : ls [ i ] = ls [ i ] + list ( input ( ) ) ''' for ▁ i ▁ in ▁ range ( n + 1 ) : ▁ ▁ ▁ ▁ print ( ls [ i ] ) ''' drc = 1 ; ans = 0 ; line = 1 ; clom = 1 ; rem = 1 ; pos_first = 0 ; pos_last = 0 while check ( line , clom ) : ans += rem - line line = rem for i in range ( 1 , m + 1 ) : ls [ line ] [ i ] = ' G ' if line % 2 != 0 : ans += abs ( pos_first - clom ) ans += abs ( pos_first - pos_last ) clom = pos_last elif line % 2 == 0 : ans += abs ( pos_last - clom ) ans += abs ( pos_first - pos_last ) clom = pos_first pos_first = 0 pos_last = 0 print ( ans ) NEW_LINE

rc = input ( ) . split ( ) r = int ( rc [ 0 ] ) c = int ( rc [ 1 ] ) l = [ ] for i in range ( r ) : l . append ( [ i for i in input ( ) ] ) pos = [ 0 , 0 ] last = [ 0 , 0 ] count = 0 for i in range ( r - 1 ) : j = pos [ 1 ] while j >= 0 and j < c : if l [ i ] [ j ] == " W " : count += abs ( j - pos [ 1 ] ) pos [ 1 ] = j if i % 2 == 0 : j += 1 else : j -= 1 mark = 0 if i % 2 == 0 : for j in range ( pos [ 1 ] , c ) : if l [ i + 1 ] [ j ] == " W " : last = [ i + 1 , j ] mark = 1 if mark == 1 : count += abs ( last [ 1 ] - pos [ 1 ] ) + 1 pos = last else : count += 1 pos [ 0 ] += 1 else : for j in range ( pos [ 1 ] , - 1 , - 1 ) : if l [ i + 1 ] [ j ] == " W " : last = [ i + 1 , j ] mark = 1 if mark == 1 : count += abs ( last [ 1 ] - pos [ 1 ] ) + 1 pos = last else : count += 1 pos [ 0 ] += 1 if ( r - 1 ) % 2 != 0 : j = pos [ 1 ] for i in range ( j , - 1 , - 1 ) : if l [ r - 1 ] [ i ] == " W " : count += pos [ 1 ] - i pos [ 1 ] = ielse : j = pos [ 1 ] for i in range ( j + 1 , c ) : if l [ r - 1 ] [ i ] == " W " : count += i - pos [ 1 ] pos [ 1 ] = i   for i in range ( r - 1 , - 1 , - 1 ) : if " W " not in l [ i ] : count -= 1 else : break   print ( count if count > 0 else 0 ) NEW_LINE

n , m = list ( map ( int , input ( ) . split ( ) ) ) mat = [ ] for i in range ( n ) : x = input ( ) x = list ( x ) a , b = - 1 , - 1 for j in range ( m ) : if x [ j ] == ' W ' and a == - 1 : a = j b = j elif x [ j ] == ' W ' and a != - 1 : b = j mat . append ( [ a , b ] ) last = n - 1 r = 1 ans = 0 prev = 0 while last > 0 and mat [ last ] [ 0 ] == - 1 : last -= 1 ans = lastfor i in mat [ : last + 1 ] : if i [ 0 ] != - 1 : if r == 1 : ans += abs ( i [ 0 ] - prev ) + i [ 1 ] - i [ 0 ] prev = i [ 1 ] else : ans += abs ( i [ 1 ] - prev ) + i [ 1 ] - i [ 0 ] prev = i [ 0 ] r = r ^ 1 print ( ans ) NEW_LINE


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

import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long n = scanner . nextLong ( ) ; int k = scanner . nextInt ( ) ; long l = 0 ; while ( k -- != 0 ) { l = n % 10 ; if ( l == 0 ) { n = n / 10 ; } else { n = n - 1 ; } } System . out . println ( n ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int n = Integer . parseInt ( str . substring ( 0 , str . indexOf ( " ▁ " ) ) ) ; int k = Integer . parseInt ( str . substring ( str . indexOf ( " ▁ " ) + 1 , str . length ( ) ) ) ; for ( int i = 1 ; i <= k ; i ++ ) { if ( n % 10 != 0 ) { n = n - 1 ; } else { n = n / 10 ; } } System . out . println ( n ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; int t = sc . nextInt ( ) ; while ( t != 0 ) { if ( n % 10 == 0 ) n = n / 10 ; else n = n - 1 ; t -- ; } System . out . println ( n ) ; } }

import java . io . * ; import java . util . * ; public class AWrongSubstraction { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n , k ; n = input . nextInt ( ) ; k = input . nextInt ( ) ; for ( int i = 0 ; i < k ; i ++ ) { if ( n % 10 == 0 ) n = n / 10 ; else n -- ; } System . out . println ( n ) ; } }

n , k = input ( ) . split ( sep = ' ▁ ' ) n = int ( n ) k = int ( k ) kcont = 0   for i in range ( 0 , k ) : if n % 10 == 0 : n = n / 10 else : n = n - 1   print ( int ( n ) ) NEW_LINE

n , k = input ( ) . split ( ) n = int ( n ) k = int ( k ) for i in range ( k ) : if ( n % 10 == 0 ) : n = int ( n / 10 ) else : n = n - 1 print ( n ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) count = 1 while count <= b : if a % 10 != 0 : a -= 1 count += 1 if a % 10 == 0 and count <= b : a = a // 10 count += 1 print ( a )             NEW_LINE

nums = list ( map ( int , input ( ) . split ( ) ) )   n = nums [ 0 ] k = nums [ 1 ] for i in range ( k ) : if n % 10 == 0 : n = n / 10 else : n = n - 1   print ( int ( n ) ) NEW_LINE

a = list ( map ( int , input ( ) . split ( ) ) ) c = a [ 0 ] for i in range ( a [ 1 ] ) : if ( c % 10 == 0 ) : c = c / 10 else : c = c - 1 print ( int ( c ) ) NEW_LINE


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

import java . util . * ; import java . io . * ; import java . math . * ;   public class B { public static void main ( String hi [ ] ) throws Exception { BufferedReader infile = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( infile . readLine ( ) ) ; int N = Integer . parseInt ( st . nextToken ( ) ) ; HashMap < Integer , Integer > map = new HashMap < Integer , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { st = new StringTokenizer ( infile . readLine ( ) ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int x = Integer . parseInt ( st . nextToken ( ) ) ; map . put ( a , x ) ; } int M = Integer . parseInt ( infile . readLine ( ) ) ; for ( int i = 0 ; i < M ; i ++ ) { st = new StringTokenizer ( infile . readLine ( ) ) ; int a = Integer . parseInt ( st . nextToken ( ) ) ; int x = Integer . parseInt ( st . nextToken ( ) ) ; if ( ! map . containsKey ( a ) || map . get ( a ) < x ) map . put ( a , x ) ; } long res = 0L ; for ( int k : map . keySet ( ) ) res += map . get ( k ) ; System . out . println ( res ) ; } }

import java . util . * ;   public class Question981B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] arr = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { arr [ i ] [ j ] = sc . nextInt ( ) ; } } int m = sc . nextInt ( ) ; int [ ] [ ] arr1 = new int [ m ] [ 2 ] ; for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { arr1 [ i ] [ j ] = sc . nextInt ( ) ; } } Map < Integer , List < Integer > > map = new HashMap < > ( ) ; for ( int i = 0 ; i < arr . length ; i ++ ) { List < Integer > list = new ArrayList < > ( ) ; list . add ( arr [ i ] [ 1 ] ) ; map . put ( arr [ i ] [ 0 ] , list ) ; }   for ( int i = 0 ; i < arr1 . length ; i ++ ) { if ( map . containsKey ( arr1 [ i ] [ 0 ] ) ) { List < Integer > list = map . get ( arr1 [ i ] [ 0 ] ) ; list . add ( arr1 [ i ] [ 1 ] ) ; map . put ( arr1 [ i ] [ 0 ] , list ) ; } else { List < Integer > list = new ArrayList < > ( ) ; list . add ( arr1 [ i ] [ 1 ] ) ; map . put ( arr1 [ i ] [ 0 ] , list ) ; } }

import java . util . * ; public class Test { static int gcd ( int a , int b ) { if ( a == 0 ) return b ; return gcd ( b % a , a ) ; } static int lcm ( int a , int b ) { return ( a * b ) / gcd ( a , b ) ; }   static void solve ( int b , int g ) { } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Hashtable < Integer , Integer > ht = new Hashtable < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { ht . put ( sc . nextInt ( ) , sc . nextInt ( ) ) ; } int m = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; if ( ht . containsKey ( x ) ) { if ( ht . get ( x ) < y ) { ht . replace ( x , ht . get ( x ) , y ) ; } } else ht . put ( x , y ) ; } long sum = 0 ; for ( Map . Entry < Integer , Integer > e : ht . entrySet ( ) ) { sum += e . getValue ( ) ; } System . out . println ( sum ) ; } }

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

k = { } s = 0   for i in range ( int ( input ( ) ) ) : a , x = map ( int , input ( ) . split ( ) ) k [ a ] = x for j in range ( int ( input ( ) ) ) : b , y = map ( int , input ( ) . split ( ) ) if b in k : k [ b ] = max ( k [ b ] , y ) NEW_LINE

n = int ( input ( ) ) dicta = { } dictb = { } for i in range ( n ) : a , x = map ( int , input ( ) . split ( ) ) dicta [ a ] = xm = int ( input ( ) ) for i in range ( m ) : b , y = map ( int , input ( ) . split ( ) ) dictb [ b ] = yans = 0 for i in dicta . keys ( ) : if i in dictb . keys ( ) : ans += max ( dicta [ i ] , dictb [ i ] ) del dictb [ i ] else : ans += dicta [ i ] for i in dictb . values ( ) : ans += iprint ( ans ) NEW_LINE


import java . io . * ; import java . util . * ;    public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = false ;   void solve ( FastScanner in , PrintWriter out , int testNumber ) { n = in . nextInt ( ) ; int [ ] a = in . nextArray ( n ) ; int q = in . nextInt ( ) ; int [ ] maxs = new int [ q + 1 ] ; int it = 0 ; Map < Integer , Integer > sett = new HashMap < > ( ) ; Map < Integer , Integer > sett_maxid = new HashMap < > ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int t = in . nextInt ( ) ; if ( t == 2 ) { int x = in . nextInt ( ) ; maxs [ it ++ ] = x ; } else { int id = in . nextInt ( ) ; int v = in . nextInt ( ) ; sett . put ( id , v ) ; sett_maxid . put ( id , it ) ; } } for ( int i = it - 2 ; i >= 0 ; i -- ) { maxs [ i ] = Math . max ( maxs [ i ] , maxs [ i + 1 ] ) ; } for ( int i = 0 ; i < n ; i ++ ) { if ( sett . containsKey ( i + 1 ) ) { int v = sett . get ( i + 1 ) ; int id = sett_maxid . get ( i + 1 ) ; if ( id != it ) { out . print ( Math . max ( v , maxs [ id ] ) + " ▁ " ) ; } else { out . print ( v + " ▁ " ) ; } } else { if ( it != 0 ) { out . print ( Math . max ( a [ i ] , maxs [ 0 ] ) + " ▁ " ) ; } else { out . print ( a [ i ] + " ▁ " ) ; } } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . UncheckedIOException ; import java . io . Closeable ; import java . io . Writer ; import java . io . OutputStreamWriter ;   public class water { public static void main ( String [ ] args ) {   InputStream inputStream = System . in ;

import java . io . BufferedReader ; import java . io . File ; import java . io . FileInputStream ; import java . io . FileNotFoundException ; import java . io . FileOutputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . BitSet ; import java . util . Calendar ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . HashSet ; import java . util . LinkedList ; import java . util . PriorityQueue ; import java . util . SortedSet ; import java . util . Stack ; import java . util . StringTokenizer ; import java . util . TreeMap ; import java . util . TreeSet ;   public class B_Round_576_Div1 { public static long MOD = 1000000007 ; static int [ ] [ ] dp ;   public static void main ( String [ ] args ) throws FileNotFoundException {

import java . io . * ; import java . util . * ; import java . math . BigInteger ; import java . lang . Object ;    public class Main { static class sort implements Comparator < int [ ] > { public int compare ( int [ ] a , int [ ] b ) {

from collections import deque , defaultdictfrom math import sqrt , ceil , factorial , floorimport sysimport copydef get_array ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) ) def get_ints ( ) : return map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) def input ( ) : return sys . stdin . readline ( ) . strip ( ) maxn = ( 10 ** 5 ) + 1     n = int ( input ( ) ) a = get_array ( ) q = int ( input ( ) ) mya = [ - 1 ] * nc = [ ] for i in range ( q ) : b = get_array ( ) if b [ 0 ] == 1 : mya [ b [ 1 ] - 1 ] = i c . append ( b )   myb = [ - 1 ] * ( len ( c ) ) for i in range ( len ( c ) - 1 , - 1 , - 1 ) : if c [ i ] [ 0 ] == 2 : myb [ i ] = max ( myb [ i ] , c [ i ] [ 1 ] ) if i + 1 <= len ( c ) - 1 : myb [ i ] = max ( myb [ i + 1 ] , myb [ i ] )   ans = [ ]   for i in range ( n ) : if mya [ i ] == - 1 : ans . append ( max ( a [ i ] , myb [ 0 ] ) ) else : ind = mya [ i ] my = c [ ind ] [ 2 ] ans . append ( max ( my , myb [ ind ] ) ) print ( * ans ) NEW_LINE

from sys import stdin , stdoutfrom math import gcd , sqrt , inffrom collections import dequeinput = stdin . readlineR = lambda : map ( int , input ( ) . split ( ) ) I = lambda : int ( input ( ) ) S = lambda : input ( ) . rstrip ( ' \n ' ) L = lambda : list ( R ( ) ) hg = lambda x , y : ( ( y + x - 1 ) // x ) * xpw = lambda x : 1 if x == 1 else 1 + pw ( x // 2 ) chk = lambda x : chk ( x // 2 ) if not x % 2 else True if x == 1 else FalseM = inf   n = I ( ) * a , = R ( ) cng = [ - 1 ] * nq = I ( ) op = [ 0 ] * ( q + 1 ) for i in range ( q ) : * p , = R ( ) if p [ 0 ] == 2 : op [ i ] = p [ 1 ] else : cng [ p [ 1 ] - 1 ] = i a [ p [ 1 ] - 1 ] = p [ 2 ] x = 0 for i in range ( q , - 1 , - 1 ) : x = max ( x , op [ i ] ) op [ i ] = xprint ( * [ max ( a [ i ] , op [ cng [ i ] + 1 ] ) for i in range ( n ) ] ) NEW_LINE

from sys import stdin , stdoutfor _ in range ( 1 ) : NEW_LINE

from heapq import * import sysdef get_ints ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) )   n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr_q = [ ] for i in range ( int ( input ( ) ) ) : arr_q . append ( list ( get_ints ( ) ) ) cur = 0 ans = [ - 1 ] * n   for i in arr_q [ : : - 1 ] : if i [ 0 ] == 2 : cur = max ( cur , i [ 1 ] ) else : if ans [ i [ 1 ] - 1 ] == - 1 : ans [ i [ 1 ] - 1 ] = max ( cur , i [ 2 ] )   for i in range ( n ) : if ans [ i ] == - 1 : ans [ i ] = max ( cur , arr [ i ] ) print ( * ans ) NEW_LINE


import java . util . * ;    public class Main {   public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int t = reader . nextInt ( ) ; while ( t -- != 0 ) { int n = reader . nextInt ( ) ; int cnt = 0 ; while ( n > 1 ) { if ( n % 6 != 0 && n % 2 == 0 ) { cnt = - 1 ; break ; } if ( n % 6 != 0 ) n *= 2 ; else n /= 6 ; cnt ++ ; } System . out . println ( cnt ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class CF1374B { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int t = Integer . parseInt ( br . readLine ( ) ) ; while ( t -- > 0 ) { int n = Integer . parseInt ( br . readLine ( ) ) ; if ( n == 1 ) { System . out . println ( 0 ) ; continue ; } if ( n % 3 != 0 ) { System . out . println ( - 1 ) ; continue ; } int ans = 0 ; while ( n != 1 ) { if ( n % 6 == 0 ) { n /= 6 ; ans ++ ; } else if ( n % 3 == 0 ) { n *= 2 ; ans ++ ; } else { ans = - 1 ; break ; } } System . out . println ( ans ) ;   } } }

import java . util . * ; public class f { public static void main ( String [ ] ta ) { Scanner sc = new Scanner ( System . in ) ; if ( sc . hasNext ( ) ) { int t = sc . nextInt ( ) ; while ( t -- > 0 ) { long n = sc . nextLong ( ) ; long count = 0 ; long count2 = 0 ; while ( n != 1 && count != - 1 ) { if ( n % 6 == 0 ) { n /= 6 ; if ( count2 == 1 ) count2 -- ; } else { n *= 2 ; count2 ++ ; }   count ++ ;   if ( count2 > 1 ) { count = - 1 ; } } System . out . println ( count ) ; } } } }

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; int n , count2 , count3 ; boolean flag ; for ( int i = 0 ; i < t ; i ++ ) { n = sc . nextInt ( ) ; flag = true ; count2 = 0 ; count3 = 0 ; while ( n != 1 ) { if ( n % 2 == 0 ) { count2 ++ ; n = n / 2 ; } else if ( n % 3 == 0 ) { count3 ++ ; n = n / 3 ; } else { flag = false ; System . out . println ( " - 1" ) ; break ; } } if ( flag ) { if ( count2 <= count3 ) { System . out . println ( 2 * count3 - count2 ) ; } else { System . out . println ( " - 1" ) ; } } } } }

def findMoves ( n ) : cnt2 = 0 cnt3 = 0 while ( n % 2 == 0 ) : n /= 2 cnt2 += 1 while ( n % 3 == 0 ) : n /= 3 ; cnt3 += 1 if ( n == 1 and cnt2 <= cnt3 ) : print ( 2 * cnt3 - cnt2 ) else : print ( - 1 )   tc = int ( input ( ) ) for _ in range ( 0 , tc ) : n = int ( input ( ) ) findMoves ( n ) NEW_LINE

t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) c2 = 0 c1 = 0 while ( n % 2 == 0 ) : n = n // 2 c2 += 1 while ( n % 3 == 0 ) : n = n // 3 c1 += 1 if ( n == 1 and c1 >= c2 ) : print ( ( c1 - c2 ) + c1 ) else : print ( - 1 ) NEW_LINE

t = int ( input ( ) ) output = [ ]   for _ in range ( 0 , t ) : n = int ( input ( ) ) count = 0   while True : if n == 1 : output . append ( count ) break elif n % 6 != 0 : if ( n * 2 ) % 6 != 0 : output . append ( - 1 ) break n = n * 2 / 6 count += 2 else : n /= 6 count += 1     for i in range ( 0 , t ) : print ( output [ i ] ) NEW_LINE

t = int ( input ( ) )   for i in range ( t ) : n = int ( input ( ) ) c2 , c3 = 0 , 0 while n % 2 == 0 : n /= 2 c2 += 1   while n % 3 == 0 : n /= 3 c3 += 1   if n == 1 and c2 <= c3 : print ( ( c3 - c2 ) + c3 ) else : print ( - 1 ) NEW_LINE

from sys import stdininput = stdin . readline   t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) ans = 0 while n % 3 == 0 : if n % 6 == 0 : n //= 6 else : n *= 2 ans += 1 if n == 1 : print ( ans ) else : print ( - 1 ) NEW_LINE


import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String x = sc . next ( ) ; x = x . toLowerCase ( ) ; int max = 1 ; int last = - 1 ; boolean first = true ; for ( int i = 0 ; i < x . length ( ) ; i ++ ) { if ( x . charAt ( i ) == ' a ' | x . charAt ( i ) == ' e ' | x . charAt ( i ) == ' i ' | x . charAt ( i ) == ' o ' | x . charAt ( i ) == ' u ' | x . charAt ( i ) == ' y ' ) { if ( first ) { first = false ; max = i + 1 ; last = i ; } else { max = Math . max ( i - last , max ) ; last = i ; } } } max = Math . max ( max , x . length ( ) - last ) ; System . out . println ( max ) ; } }

import java . util . * ; import java . lang . * ; import java . io . * ;   public class sample { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; s += " ▁ " ; char [ ] arr = s . toCharArray ( ) ; int max = 1 , prev = - 1 , index = - 1 ;   for ( int i = 0 ; i < arr . length ; i ++ ) { if ( arr [ i ] == ' A ' || arr [ i ] == ' ▁ ' || arr [ i ] == ' E ' || arr [ i ] == ' I ' || arr [ i ] == ' O ' || arr [ i ] == ' U ' || arr [ i ] == ' Y ' ) { index = i ; int diff = index - prev ; max = Math . max ( max , diff ) ; prev = index ; } }   System . out . println ( max ) ; }   }

import java . util . Scanner ;   public class CF4 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int max = Integer . MIN_VALUE ; int index = 0 ; str = ' A ' + str + ' A ' ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( isVowel ( str . charAt ( i ) ) ) { max = Math . max ( max , i - index ) ; index = i ; } }   System . out . println ( max ) ; sc . close ( ) ; }   static boolean isVowel ( char ch ) { return ch == ' A ' || ch == ' I ' || ch == ' O ' || ch == ' Y ' || ch == ' E ' || ch == ' U ' ; } }

import java . util . Scanner ; import java . util . Arrays ; public class Grasshopper { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) ; int n = s . length ( ) , f = 0 ; int [ ] a ; a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { char x = s . charAt ( i ) ; if ( ! ( x == ' A ' || x == ' E ' || x == ' Y ' || x == ' O ' || x == ' U ' || x == ' I ' ) ) a [ f ] ++ ; else f ++ ; } Arrays . sort ( a ) ; System . out . println ( a [ n - 1 ] + 1 ) ; scanner . close ( ) ; } }

import java . util . * ;   public class Solve {   static Scanner scan = new Scanner ( System . in ) ;   public static void solve ( String s ) {   int lastIndex = 0 , count = 0 , val = 0 ;   for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' A ' || s . charAt ( i ) == ' E ' || s . charAt ( i ) == ' I ' || s . charAt ( i ) == ' O ' || s . charAt ( i ) == ' U ' || s . charAt ( i ) == ' Y ' ) { val = ( i + 1 ) - lastIndex ; count = Math . max ( count , val ) ; lastIndex = ( i + 1 ) ; } } count = Math . max ( count , s . length ( ) - lastIndex + 1 ) ; System . out . println ( count ) ; }   public static void main ( String [ ] args ) {   String s = scan . next ( ) ; solve ( s ) ; } }

s = input ( ) s = ' A ' + s + ' A ' vo = " AEIOUY " pos = [ i + 1 for i , j in enumerate ( s ) if j in vo ]       pos = [ 0 ] + posarr = [ j - i for i , j in zip ( pos [ : - 1 ] , pos [ 1 : ] ) ] print ( max ( arr ) ) NEW_LINE

def jump ( phrase : str ) -> int : previous , maximum , phrase = - 1 , - 1 , ' A ' + phrase + ' A ' for index in range ( len ( phrase ) ) : if phrase [ index ] in set ( " AEIOUY " ) : maximum = max ( maximum , index - previous ) previous = index return maximum     def read_input ( filename : str = None ) -> None : from sys import stdin stdin = open ( filename ) if filename else stdin phrase = stdin . readline ( ) . strip ( ) print ( jump ( phrase ) )     def main ( ) : read_input ( )     if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

a = input ( ) b = list ( a ) v = [ ' A ' , ' E ' , ' I ' , ' O ' , ' U ' , ' Y ' ] m = 0 last = - 1 for i in range ( len ( b ) ) : if b [ i ] in v : m = max ( m , i - last ) last = iprint ( max ( m , len ( b ) - last ) ) NEW_LINE

a = input ( ) . upper ( ) + " ▁ " v = [ ' A ' , ' E ' , ' I ' , ' O ' , ' U ' , ' Y ' ] m = 0 c = 0 for i in range ( len ( a ) ) : c += 1 if ( a [ i ] in v or a [ i ] == " ▁ " ) : if ( c > m ) : m = c c = 0 print ( m ) NEW_LINE

s = [ x for x in input ( ) ] n = len ( s ) v = [ ' A ' , ' E ' , ' I ' , ' O ' , ' U ' , ' Y ' ] pos = [ - 1 ] for i in range ( len ( s ) ) : if ( v . count ( s [ i ] ) ) : pos . append ( i ) pos . append ( n ) d = [ ] for i in range ( 1 , len ( pos ) ) : d . append ( pos [ i ] - pos [ i - 1 ] ) print ( max ( d ) ) NEW_LINE


import java . util . Scanner ;   public class AgainTwentyFive { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String n = scanner . nextLine ( ) ; System . out . println ( 25 ) ;

import java . util . Scanner ;   public class A630 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long n = scanner . nextLong ( ) ;   System . out . println ( 25 ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long n = in . nextLong ( ) ; System . out . println ( 25 ) ; } }

import java . util . * ; public class Test { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String num = input . next ( ) ; System . out . println ( "25" ) ; } }

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; System . out . println ( "25" ) ; } }

def power ( base , exp ) : if exp < 0 : return 1 / power ( base , - exp ) ans = 1 while exp : if exp & 1 : ans *= base exp >>= 1 base *= base return ans def fn ( ) : r = 0 t = int ( input ( ) ) if t < 2 & t > 2 * ( power ( 10 , 18 ) ) : return 0 r = 25 print ( r )   fn ( ) NEW_LINE