import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Restoring_IPv6 { public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int i , j , a , b , n , c , l , sum ; String [ ] s_array = new String [ 8 ] ; String ss , s1 , s2 , s_tem = "0000" ; StringBuilder s ;   s_array [ 0 ] = s_tem ; for ( i = 1 ; i < 8 ; i ++ ) { s_array [ i ] = s_array [ i - 1 ] + " : " + s_tem ; }    n = in . nextInt ( ) ;   while ( n -- > 0 ) { String [ ] s_main = new String [ 8 ] ; s1 = " " ; sum = 0 ; ss = in . nextLine ( ) ; s = new StringBuilder ( ss ) ; l = s . length ( ) ;   if ( ! ss . contains ( " : " ) ) { ss += " : " ; ss += s_array [ 7 ] ; s1 = ss ; } else if ( ss . contains ( " : : " ) ) {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class _250B implements Runnable { private BufferedReader in ;   private Object solve ( ) throws IOException { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 , n = nextInt ( ) ; i < n ; i ++ ) { String [ ] s = nextToken ( ) . split ( " : " , - 1 ) ; int k = 0 , m = s . length - 1 ; if ( s [ k ] . isEmpty ( ) ) { k ++ ; } if ( s [ m ] . isEmpty ( ) ) { m -- ; } for ( int j = k ; j <= m ; j ++ ) { if ( s [ j ] . isEmpty ( ) ) { for ( int l = 1 , lim = 8 - m + k ; l <= lim ; l ++ ) { sb . append ( "0000" ) ; if ( l < lim ) { sb . append ( ' : ' ) ; } } } else { for ( int l = s [ j ] . length ( ) ; l < 4 ; l ++ ) { sb . append ( '0' ) ; } sb . append ( s [ j ] ) ; } if ( j < m ) { sb . append ( ' : ' ) ; } } sb . append ( ' \n ' ) ; } return sb ; }

for kk in range ( int ( input ( ) ) ) : str = input ( ) print ( ' : ' . join ( i . zfill ( 4 ) for i in str . replace ( ' : : ' , ' : ' * ( 9 - str . count ( ' : ' ) ) ) . split ( ' : ' ) ) )       NEW_LINE

n = eval ( input ( ) ) for i in range ( n ) : ans = ' ' k = ' ' s = input ( ) . split ( ' : ' ) c = 0 m = 0 for g in range ( len ( s ) ) : if s [ g ] != ' ' : c += 1 if c == 8 : for j in range ( c ) : s [ j ] = ( 4 - len ( s [ j ] ) ) * '0' + s [ j ] ans += s [ j ] + ' : ' else : k = ( 8 - c ) * '0000 : ' for j in range ( len ( s ) ) : if s [ j ] == ' ' : ans += k k = ' ' m = 1 else : s [ j ] = ( 4 - len ( s [ j ] ) ) * '0' + s [ j ] ans += s [ j ] + ' : ' ans += k ans = ans [ : - 1 ] print ( ans ) NEW_LINE

def f ( s ) : res = [ ] sp = s . split ( " : " ) if not sp [ 0 ] : sp [ 0 ] = "0" if not sp [ - 1 ] : sp [ - 1 ] = "0" for b in sp : if b : res . append ( " { :0 > 4 } " . format ( b ) ) if not b : res . extend ( ( "0000" for i in range ( 8 - len ( sp ) + 1 ) ) ) return ( " : " . join ( res ) ) t = int ( input ( ) ) for i in range ( t ) : ip = input ( ) print ( f ( ip ) ) NEW_LINE


import java . math . BigInteger ; import java . util . * ; import static java . lang . Math . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String n = in . next ( ) ; String m = in . next ( ) ; int base = max ( n . chars ( ) . max ( ) . getAsInt ( ) , m . chars ( ) . max ( ) . getAsInt ( ) ) - '0' + 1 ; System . out . println ( new BigInteger ( n , base ) . add ( new BigInteger ( m , base ) ) . toString ( base ) . length ( ) ) ; } }

import java . util . * ; import static java . lang . Math . * ;   public class Main { static int largest ( int x ) { int ret = 0 ; while ( x > 0 ) { ret = max ( ret , x % 10 ) ; x /= 10 ; } return ret ; }   static int tobase ( int x , int base ) { int ret = 0 , p = 1 ; while ( x > 0 ) { ret += ( x % 10 ) * p ; p *= base ; x /= 10 ; } return ret ; }   static int digitsNum ( int x , int base ) { int ret = 0 ; while ( x > 0 ) { ret ++ ; x /= base ; } return ret ; }   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; int base = max ( largest ( n ) , largest ( m ) ) + 1 ; int x = tobase ( n , base ) + tobase ( m , base ) ;   System . out . println ( digitsNum ( x , base ) ) ; } }

import java . io . BufferedInputStream ; import java . math . BigInteger ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( new BufferedInputStream ( System . in ) ) ; int a = cin . nextInt ( ) ; int b = cin . nextInt ( ) ; int n = a , m = b ; int maxx = 0 ; while ( a != 0 ) { maxx = Math . max ( maxx , a % 10 ) ; a /= 10 ; } while ( b != 0 ) { maxx = Math . max ( maxx , b % 10 ) ; b /= 10 ; }

import java . util . * ; import java . lang . * ;   public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String a = scan . next ( ) ; String b = scan . next ( ) ; int max = 0 ; for ( char c : ( a + b ) . toCharArray ( ) ) { max = Math . max ( c - '0' , max ) ; } int len = Integer . toString ( Integer . parseInt ( a , max + 1 ) + Integer . parseInt ( b , max + 1 ) , max + 1 ) . length ( ) ; System . out . println ( len ) ; } }

a , b = input ( ) . split ( ) d = '0' y , z = len ( a ) , len ( b ) for i in range ( y ) : d = max ( d , a [ i ] ) for i in range ( z ) : d = max ( d , b [ i ] ) d = int ( d ) + 1 c = 0 for i in range ( y ) : c += int ( a [ y - 1 - i ] ) * ( d ** i ) for i in range ( z ) : c += int ( b [ z - 1 - i ] ) * ( d ** i ) e = 0 while c > 0 : e += 1 c //= dprint ( e ) NEW_LINE

def basechange ( n , base ) : new_number = [ ] q = n while ( q >= base ) : new_number . append ( q % base ) q = q // base new_number . append ( q ) return new_number   def to_base_10 ( n , base ) : string_n = str ( n ) total = 0 for i , number in enumerate ( string_n [ : : - 1 ] ) : total += ( base ** i ) * int ( number ) return total     number1 , number2 = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) max_n = max ( max ( str ( number1 ) ) , max ( str ( number2 ) ) ) NEW_LINE

def any2dec ( num_original , base_original ) : num_original = str ( num_original ) base_original = int ( base_original ) dic = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' , ' G ' , ' H ' , ' I ' , ' J ' , ' K ' , ' L ' , ' M ' , ' N ' , ' O ' , ' P ' , ' Q ' , ' R ' , ' S ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' , ' Z ' ] dec = 0 dec_temp = list ( num_original ) dec_temp . reverse ( ) for x , i in enumerate ( dec_temp ) : dec += dic . index ( i ) * base_original ** ( x ) return str ( dec )     def dec2any ( dec , base_final ) : base_final = int ( base_final ) dec = int ( dec ) dic = [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ' A ' , ' B ' , ' C ' , ' D ' , ' E ' , ' F ' , ' G ' , ' H ' , ' I ' , ' J ' , ' K ' , ' L ' , ' M ' , ' N ' , ' O ' , ' P ' , ' Q ' , ' R ' , ' S ' , ' T ' , ' U ' , ' V ' , ' W ' , ' X ' , ' Y ' , ' Z ' ] numero_final_temp = [ ] numero_final = ' ' while True : temp_numero_final = dec % base_final numero_final_temp . append ( temp_numero_final ) if int ( dec / base_final ) == 0 : break dec = int ( dec / base_final ) numero_final_temp . reverse ( ) for i in numero_final_temp : numero_final += dic [ i ] return numero_final   def main ( ) : v = input ( ) . split ( ) a = [ int ( i ) for i in list ( v [ 0 ] ) ] b = [ int ( i ) for i in list ( v [ 1 ] ) ] base = max ( max ( a ) , max ( b ) ) + 1 va = any2dec ( v [ 0 ] , base ) vb = any2dec ( v [ 1 ] , base ) ans = int ( va ) + int ( vb ) print ( len ( dec2any ( ans , base ) ) )   main ( ) NEW_LINE

def map2 ( r , b ) : d = dict ( zip ( [ i for i in range ( 0 , 16 ) ] , list ( "0123456789ABCDEF " ) ) ) return ( d [ r ] )   def xb ( x , b ) : x = list ( map ( int , list ( str ( x ) ) ) ) [ : : - 1 ] ans = 0 for i , d in enumerate ( x ) : ans += d * b ** i return ans   def xb2 ( x , b ) : xinbase = str ( ) while x > 0 : remainder = x % b x = x // b xinbase += map2 ( remainder , b ) return ( xinbase [ : : - 1 ] ) def encontrarbase ( a , b ) : return max ( list ( map ( int , list ( str ( a ) + str ( b ) ) ) ) ) a , b = list ( map ( int , input ( ) . split ( ) ) ) base = encontrarbase ( a , b ) + 1 x = xb2 ( xb ( a , base ) + xb ( b , base ) , base )     print ( len ( x ) ) NEW_LINE


import java . util . Scanner ; public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int tc = sc . nextInt ( ) ; while ( tc -- > 0 ) { long ha = sc . nextInt ( ) ; long hb = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = sc . nextInt ( ) ; } long x , max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { x = ( b [ i ] + ha - 1 ) / ha ; hb -= x * a [ i ] ; max = Math . max ( max , a [ i ] ) ; } if ( hb + max > 0 ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } sc . close ( ) ; } }

import java . util . * ; import java . io . * ; public class HelloWorld { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int t = input . nextInt ( ) ; for ( int j = 0 ; j < t ; j ++ ) { long x = input . nextLong ( ) ; long y = input . nextLong ( ) ; int n = input . nextInt ( ) ; long [ ] a = new long [ n ] ; long [ ] b = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextLong ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = input . nextLong ( ) ; } int i = 0 ; long max = 0 ; while ( i < n ) { long times = ( b [ i ] + x - 1 ) / x ; y -= times * a [ i ] ; max = Math . max ( max , a [ i ] ) ; i ++ ; } System . out . println ( y + max > 0 ? " YES " : " NO " ) ; } } }

import java . util . Scanner ;   public class B1480 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int T = in . nextInt ( ) ; for ( int t = 0 ; t < T ; t ++ ) { int AH = in . nextInt ( ) ; long DH = in . nextInt ( ) ; int N = in . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] D = new int [ N ] ; for ( int n = 0 ; n < N ; n ++ ) { A [ n ] = in . nextInt ( ) ; } for ( int n = 0 ; n < N ; n ++ ) { D [ n ] = in . nextInt ( ) ; } int max = 0 ; for ( int n = 0 ; n < N ; n ++ ) { long attacks = ( D [ n ] + AH - 1 ) / AH ; DH -= attacks * A [ n ] ; max = Math . max ( max , A [ n ] ) ; } DH += max ; System . out . println ( DH > 0 ? " YES " : " NO " ) ; } }   }

import java . util . * ; import java . lang . * ; import java . io . * ;     public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int a , b , c ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; int p [ ] = new int [ c ] ; int q [ ] = new int [ c ] ; A z [ ] = new A [ c ] ; for ( int i = 0 ; i < c ; i ++ ) { p [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < c ; i ++ ) { q [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < c ; i ++ ) { A y = new A ( p [ i ] , q [ i ] ) ; z [ i ] = y ; } Arrays . sort ( z , new nc ( ) ) ; boolean flag = true ; for ( int i = 0 ; i < c ; i ++ ) { int hm = z [ i ] . b ; int am = z [ i ] . a ; int r = hm / a ; if ( hm % a != 0 ) r ++ ; int s = b / am ; if ( b % am != 0 ) s ++ ; if ( s < r || b < 0 ) { flag = false ; break ; } else { b -= ( r * am ) ; } } if ( flag ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } } }    class A { int a , b ; A ( int a , int b ) { this . a = a ; this . b = b ; } }   class nc implements Comparator < A > { public int compare ( A s1 , A s2 ) { if ( s1 . a == s2 . a ) return 0 ; else if ( s1 . a > s2 . a ) return 1 ; else return - 1 ; }   }

import java . util . * ; import java . lang . * ; import java . io . * ;   public class Codechef { public static void main ( String [ ] args ) throws java . lang . Exception { FastReader in = new FastReader ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; int t = 1 ; t = in . nextInt ( ) ; while ( t > 0 ) { -- t ; int A = in . nextInt ( ) ;

from math import ceil   for t in range ( int ( input ( ) ) ) : A , B , n = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE damage = 0 NEW_LINE for i in range ( n ) : damage = damage + ceil ( b [ i ] / A ) * a [ i ] NEW_LINE health = [ 0 ] * n NEW_LINE for i in range ( n ) : health [ i ] = B - damage + a [ i ] NEW_LINE if max ( health ) > 0 : NEW_LINE INDENT print ( ' YES ' ) else : NEW_LINE print ( ' NO ' ) NEW_LINE DEDENT

import sysinput = sys . stdin . readlinet = int ( input ( ) ) NEW_LINE for i in range ( t ) : a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE attack = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE health = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE li = [ ] NEW_LINE for j in range ( c ) : if NEW_LINE health [ j ] % a != 0 : li . append ( [ attack [ j ] , ( health [ j ] // a ) + 1 ] ) else : li . append ( [ attack [ j ] , ( health [ j ] // a ) ] ) NEW_LINE li . sort ( key = lambda x : x [ 0 ] ) NEW_LINE bl = False NEW_LINE for j in range ( c ) : b -= li [ j ] [ 1 ] * li [ j ] [ 0 ] NEW_LINE if b <= 0 : bl = True NEW_LINE if bl == True : if NEW_LINE b + li [ - 1 ] [ 0 ] > 0 : bl = False NEW_LINE if bl == False : NEW_LINE INDENT print ( " YES " ) else : NEW_LINE print ( " NO " ) NEW_LINE DEDENT

import mathfrom NEW_LINE sys NEW_LINE import stdininput = stdin . readlinefor NEW_LINE _ in range ( int ( input ( ) ) ) : A , B , n = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( n ) : fights = math . ceil ( b [ i ] / A ) NEW_LINE B -= a [ i ] * fights   B += max ( a ) NEW_LINE if B > 0 : NEW_LINE INDENT print ( " YES " ) else : NEW_LINE print ( " NO " ) NEW_LINE DEDENT

T_ON = 1 NEW_LINE DEBUG_ON = 0 NEW_LINE MOD = 998244353     NEW_LINE def solve ( ) : A , B , n = read_ints ( ) NEW_LINE X = read_ints ( ) NEW_LINE Y = read_ints ( ) NEW_LINE for x , y in zip ( X , Y ) : cnt = math . ceil ( y / A ) NEW_LINE B -= cnt * x NEW_LINE if B + max ( X ) > 0 : NEW_LINE INDENT YES ( ) else : NEW_LINE NO ( )     NEW_LINE DEDENT def main ( ) : T = read_int ( ) if T_ON else 1 NEW_LINE for i in range ( T ) : solve ( )     NEW_LINE def debug ( * xargs ) : if NEW_LINE DEBUG_ON : print ( * xargs )     from collections import * NEW_LINE import NEW_LINE INDENT math     NEW_LINE DEDENT


import java . util . Scanner ;   public class Three_Matrices { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] ar = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { ar [ i ] [ j ] = sc . nextInt ( ) ; } }   double [ ] [ ] arrA = new double [ n ] [ n ] ; double [ ] [ ] arrB = new double [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i ; j < n ; j ++ ) { arrA [ i ] [ j ] = ( 1.0 * ar [ i ] [ j ] + ar [ j ] [ i ] ) / 2 ; arrB [ i ] [ j ] = ar [ i ] [ j ] - arrA [ i ] [ j ] ; arrA [ j ] [ i ] = arrA [ i ] [ j ] ; arrB [ j ] [ i ] = 0.0 - arrB [ i ] [ j ] ; } }   for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( arrA [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; }   for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( arrB [ i ] [ j ] + " ▁ " ) ; } System . out . println ( ) ; }   } }

import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int [ ] [ ] w = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { w [ i ] [ j ] = scanner . nextInt ( ) ; } }

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

n = int ( input ( ) ) a = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ]   b = [ [ 0 for j in range ( n ) ] for i in range ( n ) ] c = [ [ 0 for j in range ( n ) ] for i in range ( n ) ]   for i in range ( n ) : for j in range ( i , n ) : if ( i == j ) : b [ i ] [ j ] = a [ i ] [ j ] / 1 else : x = ( a [ i ] [ j ] + a [ j ] [ i ] ) / 2 b [ i ] [ j ] = x b [ j ] [ i ] = x c [ i ] [ j ] = a [ i ] [ j ] - x c [ j ] [ i ] = a [ j ] [ i ] - xfor i in b : for j in i : print ( " { 0 : . 8f } " . format ( j ) , end = " ▁ " ) print ( ) for i in c : for j in i : print ( " { 0 : . 8f } " . format ( j ) , end = " ▁ " ) print ( ) NEW_LINE

'''   ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Online ▁ Python ▁ Compiler . ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ Code , ▁ Compile , ▁ Run ▁ and ▁ Debug ▁ python ▁ program ▁ online . Write ▁ your ▁ code ▁ in ▁ this ▁ editor ▁ and ▁ press ▁ " Run " ▁ button ▁ to ▁ execute ▁ it .   ''' n = int ( input ( ) ) matrix = [ ] for i in range ( n ) : listA = input ( ) . split ( ) for i in range ( 0 , len ( listA ) ) : listA [ i ] = int ( listA [ i ] ) matrix . append ( listA ) matAt = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] matBt = [ [ 0 for x in range ( n ) ] for y in range ( n ) ] for i in range ( n ) : for j in range ( n ) : matAt [ i ] [ j ] = matrix [ j ] [ i ] matAt [ i ] [ j ] = float ( matAt [ i ] [ j ] + matrix [ i ] [ j ] ) / 2 for i in range ( n ) : for j in range ( n ) : matBt [ i ] [ j ] = 0 - matrix [ j ] [ i ] matBt [ i ] [ j ] = float ( matBt [ i ] [ j ] + matrix [ i ] [ j ] ) / 2   for i in range ( n ) : print ( * matAt [ i ] ) for i in range ( n ) : print ( * matBt [ i ] )   NEW_LINE

n = int ( input ( ) ) arr = [ ] for i in range ( n ) : arr . append ( list ( map ( int , input ( ) . split ( ) ) ) ) a = [ ] b = [ ] for i in range ( n ) : a . append ( [ ] ) b . append ( [ ] ) for j in range ( n ) : a [ i ] . append ( ( arr [ i ] [ j ] + arr [ j ] [ i ] ) / 2 ) b [ i ] . append ( arr [ i ] [ j ] - a [ i ] [ j ] ) for i in range ( n ) : print ( * a [ i ] ) for i in range ( n ) : print ( * b [ i ] ) NEW_LINE

n = int ( input ( ) ) W = [ ] def print_matrix ( A ) : for i in A : for j in i : print ( j , end = ' ▁ ' ) print ( ) for i in range ( n ) : row_input = input ( ) row_list = row_input . split ( ) new_row_list = [ ] for j in row_list : new_row_list . append ( float ( j ) ) W . append ( new_row_list )   a = [ row [ : ] for row in W ] b = [ row [ : ] for row in W ]   for j in range ( n ) : for i in range ( n ) : if i == j : b [ j ] [ i ] = W [ j ] [ i ] - a [ j ] [ i ] continue a [ j ] [ i ] = ( W [ j ] [ i ] + W [ i ] [ j ] ) / 2.0 b [ j ] [ i ] = W [ j ] [ i ] - a [ j ] [ i ] NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { private static final int N = ( int ) 1e3 + 10 ; public static void main ( String [ ] args ) throws IOException { int t ; StreamTokenizer cin = new StreamTokenizer ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ;

import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { long a = sc . nextLong ( ) , b = sc . nextLong ( ) , c = sc . nextLong ( ) ; if ( b == 1 ) { if ( a == c ) System . out . println ( " - 1 ▁ - 1" ) ; else if ( a < c ) System . out . println ( "1 ▁ - 1" ) ; else System . out . println ( " - 1 ▁ 1" ) ; } else if ( a == c ) System . out . println ( " - 1 ▁ 2" ) ; else if ( a > c ) System . out . println ( " - 1 ▁ 1" ) ; else { if ( a * b > c ) System . out . println ( "1 ▁ " + b ) ; else System . out . println ( "1 ▁ - 1" ) ; } } } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int t = in . nextInt ( ) ; while ( t -- > 0 ) { long a = in . nextLong ( ) ; long b = in . nextLong ( ) ; long c = in . nextLong ( ) ; if ( a < c ) System . out . print ( "1 ▁ " ) ; else System . out . print ( " - 1 ▁ " ) ; if ( c < b * a ) System . out . print ( b ) ; else System . out . print ( " - 1" ) ; System . out . println ( ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int t = s . nextInt ( ) ; while ( t -- != 0 ) { long a = s . nextLong ( ) ; long b = s . nextLong ( ) ; long c = s . nextLong ( ) ; if ( c > a ) { System . out . print ( 1 + " ▁ " ) ; } else { System . out . print ( - 1 + " ▁ " ) ;   } if ( a * b > c ) { System . out . println ( b + " ▁ " ) ; } else { System . out . println ( - 1 + " ▁ " ) ; } } } }

import math as mt = int ( input ( ) ) for z in range ( t ) : a , b , c = list ( map ( int , input ( ) . split ( ) ) ) if c == a : print ( f ' -1 ▁ { b } ' ) elif c > a : print ( 1 , end = ' ▁ ' ) if a * b > c : print ( b ) else : print ( - 1 ) else : if a * b < c : print ( b , end = ' ▁ ' ) else : print ( - 1 , end = ' ▁ ' ) print ( 1 )   NEW_LINE

for tc in range ( int ( input ( ) ) ) : a , b , c = map ( int , input ( ) . split ( ) ) print ( 1 if a < c else - 1 , end = " ▁ " ) print ( b if c < a * b else - 1 ) NEW_LINE

cases = int ( input ( ) ) while cases : cases -= 1 a , b , c = map ( int , input ( ) . split ( ) )   if a >= c : ans1 = - 1 else : ans1 = 1 if a <= c // b : ans2 = - 1 else : ans2 = b   print ( ans1 , ans2 )     NEW_LINE

import mathtry : t = int ( input ( ) ) for i in range ( t ) : a , b , c = map ( int , input ( ) . split ( ) ) if ( c / b ) > a : print ( 1 , - 1 ) elif ( c / b ) < a : if b * a > c : if a < c : print ( 1 , b ) else : print ( - 1 , b ) else : print ( - 1 , b ) else : if b * a > c : print ( 1 , b ) else : print ( 1 , - 1 ) except : pass NEW_LINE

if __name__ == " _ _ main _ _ " : T = int ( input ( ) ) solution = 0 for t in range ( T ) : a , b , c = map ( int , input ( ) . split ( ) ) if b * a < c : print ( '1' , ' ▁ ' , ' - 1' ) elif b * a == c : print ( b - 1 , ' ▁ ' , ' - 1' ) else : NEW_LINE


import java . util . Scanner ; public class Test {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int [ ] arr = new int [ n ] ; int count = 0 ; int hired = 0 , crime = 0 ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] < 0 ) ++ crime ; if ( arr [ i ] > 0 ) hired += arr [ i ] ; if ( arr [ i ] < 0 && hired > 0 ) { -- hired ; -- crime ; } } System . out . println ( Math . abs ( crime ) ) ; } }

import java . util . Scanner ;   public class kop { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int [ ] mas = new int [ n ] ; int sum = 0 ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int m = in . nextInt ( ) ; mas [ i ] = m ; } for ( int i = 0 ; i < n ; i ++ ) { if ( mas [ i ] > 0 ) { sum += mas [ i ] ; } else if ( mas [ i ] < 0 ) { if ( sum > 0 ) { sum -- ; } else { res ++ ; } }   } System . out . println ( res ) ; } }

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

import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ;   int n = in . nextInt ( ) ; int unrated = 0 ; int police = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; if ( x != - 1 ) { police += x ; continue ; } if ( police == 0 ) unrated ++ ; else police -- ;   } System . out . println ( unrated ) ;   }   }

import java . util . Scanner ;   public class PoliceRecruits { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int events = scanner . nextInt ( ) ; scanner . nextLine ( ) ;   int availableCops = 0 ;   int crimeUntreated = 0 ; for ( int i = 0 ; i < events ; i ++ ) { int s = scanner . nextInt ( ) ;   if ( s >= 1 ) { availableCops += s ;   }   if ( s == - 1 ) { if ( availableCops == 0 ) { crimeUntreated ++ ; } else { availableCops -- ; }   }   }   System . out . println ( crimeUntreated ) ; } }

current_popo = 0 untreated = 0 num_of_events = int ( input ( ) ) sequence = input ( ) . split ( ' ▁ ' )   for i in range ( sequence . __len__ ( ) ) : num = int ( sequence [ i ] ) if ( num > 0 ) : current_popo = current_popo + num if ( num < 0 ) : if ( current_popo == 0 ) : untreated = untreated + abs ( num ) else : current_popo = current_popo + num     print ( untreated )     NEW_LINE

x = int ( input ( ) ) n = list ( map ( int , input ( ) . split ( ) ) ) prest = 0 cop = 0 for i in range ( x ) : cop += n [ i ] if cop < 0 : prest += 1 cop = 0 print ( prest ) NEW_LINE

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

n = int ( input ( ) ) l = [ int ( x ) for x in input ( ) . split ( ) ] c , r = 0 , 0   for i in range ( n ) : if l [ i ] > 0 : c += l [ i ] elif l [ i ] < 0 : if l [ i ] + c < 0 : r += l [ i ] + c else : c = c + l [ i ]   print ( abs ( r ) ) NEW_LINE

n = int ( input ( ) ) l = [ int ( i ) for i in input ( ) . split ( ) ] x = 0 y = 0 for i in l : if i < 0 and x == 0 : y = y + 1 elif i < 0 and x > 0 : x = x + i else : x = x + iprint ( y ) NEW_LINE


import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int m = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ; int [ ] length = new int [ m ] ; int [ ] oil = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { length [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { oil [ i ] = scanner . nextInt ( ) ; }   int maxOil = 0 ; int costTime = 0 ; int oilLeft = 0 ; for ( int i = 0 ; i < m ; i ++ ) { maxOil = Math . max ( maxOil , oil [ i ] ) ; costTime += length [ i ] ; oilLeft = oilLeft + oil [ i ] - length [ i ] ; while ( oilLeft < 0 ) { oilLeft += maxOil ; costTime += k ; } } System . out . print ( costTime ) ; } }

import java . util . Arrays ; import java . util . Scanner ; import java . util . ArrayList ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = 25 ;

import java . util . * ; import java . io . * ;   public class Old_Peykan { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int t = 1 ;   while ( t -- > 0 ) { String str [ ] = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( str [ 0 ] ) ; int m = Integer . parseInt ( str [ 1 ] ) ;   str = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int d [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { d [ i ] = Integer . parseInt ( str [ i ] ) ; } str = br . readLine ( ) . trim ( ) . split ( " ▁ " ) ; int s [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { s [ i ] = Integer . parseInt ( str [ i ] ) ; }   int max [ ] = new int [ n ] ; max [ 0 ] = s [ 0 ] ; for ( int i = 1 ; i < n ; i ++ ) { max [ i ] = Math . max ( s [ i ] , max [ i - 1 ] ) ; }   long time = 0 ; long patrol = 0 ; for ( int i = 0 ; i < n ; i ++ ) { patrol += s [ i ] ;   if ( patrol < d [ i ] ) { int dif = ( int ) Math . abs ( patrol - d [ i ] ) ; int x = ( int ) Math . ceil ( dif * 1.0 / max [ i ] ) ; time += x * m ; patrol += x * max [ i ] ;   patrol -= d [ i ] ; time += d [ i ] ; } else { time += d [ i ] ; patrol -= d [ i ] ; }

m , k = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) cap = 0 dis = 0 ma = 0 time = 0 for i in range ( m ) : dis = d [ i ] cap += ( s [ i ] - d [ i ] ) time += d [ i ] ma = max ( ma , s [ i ] ) if cap < 0 : while cap < 0 : cap += ma time += kprint ( time ) NEW_LINE

from math import ceil   X = list ( map ( int , input ( ) . split ( ) ) ) Distance = list ( map ( int , input ( ) . split ( ) ) ) Fuel = list ( map ( int , input ( ) . split ( ) ) ) Tank , Time , Max = 0 , 0 , 0 for i in range ( X [ 0 ] ) : Tank += Fuel [ i ] Max = max ( Max , Fuel [ i ] ) Stay = max ( 0 , ceil ( ( Distance [ i ] - Tank ) / Max ) ) Time += Stay * X [ 1 ] + Distance [ i ] Tank += Stay * Max - Distance [ i ] print ( Time )   NEW_LINE

from math import ceiln , k = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) fuel = 0 stor = 0 time = 0   for i in range ( n ) : fuel += s [ i ] stor = max ( stor , s [ i ] ) if fuel >= d [ i ] : fuel -= d [ i ] time += d [ i ] else : yy = ceil ( ( d [ i ] - fuel ) / stor ) time += k * yy time += d [ i ] fuel += stor * yy fuel -= d [ i ] print ( time ) NEW_LINE

def main ( ) : import sys input = sys . stdin . readline m , k = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) s = list ( map ( int , input ( ) . split ( ) ) ) t = 0 f = 0 ma = 0 for i in range ( m ) : f += s [ i ] ma = max ( ma , s [ i ] ) while f < d [ i ] : f += ma t += k t += d [ i ] f -= d [ i ] print ( t ) return 0   main ( ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) d = list ( map ( int , input ( ) . split ( ) ) ) p = list ( map ( int , input ( ) . split ( ) ) ) t = 0 ; d1 = 0 ; i = 0 while i < a : if t + sum ( p [ i : : ] ) - sum ( d [ i : : ] ) < 0 : j = i ; pr = p [ i ] while j < a and pr >= p [ j ] : j += 1 k = ( - t - sum ( p [ i : j ] ) - 1 + sum ( d [ i : j ] ) + pr ) // pr d1 += b * k t = ( pr * k - ( - t - sum ( p [ i : j ] ) + sum ( d [ i : j ] ) ) ) % pr i = j else : i += 1 print ( sum ( d ) + d1 ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main {

import java . util . Scanner ;   public class BeautifulPermutation { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ; int k = scanner . nextInt ( ) ;   if ( n > k ) { StringBuilder ans = new StringBuilder ( ) ;   for ( int i = 0 ; i < n - k ; i ++ ) { if ( i == 0 ) { ans . append ( n - k ) . append ( " ▁ " ) ; } else ans . append ( i ) . append ( " ▁ " ) ; }   for ( int i = n - k ; i < n ; i ++ ) { ans . append ( i + 1 ) . append ( " ▁ " ) ; }   System . out . println ( ans ) ; } else { System . out . println ( - 1 ) ; } } }

import mathn , k = map ( int , input ( ) . strip ( ) . split ( ' ▁ ' ) ) NEW_LINE

v = map ( int , input ( ) . split ( ) ) n , k = v   r2 = [ ]   if k > n or ( n == 1 and k > 0 ) : print ( - 1 ) elif k == n : print ( - 1 ) else :               r2 . append ( n - k )   for d in range ( 1 , n - k ) : r2 . append ( d )             for e in range ( n - k + 1 , n + 1 ) : r2 . append ( e )   for v in r2 : print ( v , end = ' ▁ ' ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) if ( n == k ) : print ( " - 1" ) else : print ( n - k , end = " ▁ " ) r = 0 r = r + 1 j = 1 while ( r < n ) : if ( j == n - k ) : j = j + 1 print ( j , end = " ▁ " ) j = j + 1 else : print ( j , end = " ▁ " ) j = j + 1 r = r + 1 NEW_LINE

import mathdef main ( ) : n , k = map ( int , input ( ) . split ( ) ) if n == k or n == k - 1 : print ( " - 1" ) exit ( ) if n == k + 1 : for i in range ( n ) : print ( i + 1 , end = " ▁ " ) exit ( ) if n == k + 2 : print ( n , end = " ▁ " ) for i in range ( n - 2 ) : print ( i + 2 , end = " ▁ " ) print ( 1 ) exit ( ) l = [ ] for i in range ( k + 1 ) : l . append ( i + 1 ) for i in range ( k + 1 , n - 1 ) : l . append ( i + 2 ) if math . gcd ( 10000 , k + 2 ) > 1 : l . append ( 1 ) l [ 0 ] = k + 2 else : l . append ( k + 2 ) print ( * l ) if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

import sysimport mathdef gcd ( a , b ) : c = max ( a , b ) d = min ( a , b ) r = c % d if r == 0 : return d return gcd ( d , r ) def lcm ( a , b ) : def gcd_naive ( a , b ) : c = max ( a , b ) d = min ( a , b ) r = c % d if r == 0 : return d return gcd_naive ( d , r )   return int ( a * b / gcd_naive ( a , b ) )   def fn ( n , k ) : l = [ 0 ] * ( n ) if n <= k : print ( - 1 ) return 0 elif n == k + 1 : for i in range ( n ) : l [ i ] = i + 1 print ( * l ) return 0 else : for i in range ( 1 , k + 1 ) : l [ i ] = i + 1 l [ 0 ] = n for i in range ( n - 2 , k , - 1 ) : l [ i + 1 ] = i + 1 l [ k + 1 ] = 1 print ( * l ) if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( int , input . split ( ) ) ) n = data [ 0 ] k = data [ 1 ] ( fn ( n , k ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ;   public class Main {       public static void main ( String [ ] args ) throws IOException { FastScanner input = new FastScanner ( ) ;   String s = input . next ( ) ; int ans = 0 ; Stack < Character > st = new Stack < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( st . isEmpty ( ) ) st . add ( s . charAt ( i ) ) ; else { if ( st . peek ( ) == s . charAt ( i ) ) { st . add ( s . charAt ( i ) ) ; } else { ans ++ ; st . clear ( ) ; st . add ( s . charAt ( i ) ) ; } } if ( st . size ( ) == 5 ) { ans ++ ; st . clear ( ) ; } } if ( ! st . isEmpty ( ) ) ans ++ ; 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 ( ) ) ; }   int [ ] readArray ( int n ) { int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = nextInt ( ) ; } return a ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } }   }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; char ch = s . charAt ( 0 ) ; int c = 1 ; int ans = 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ch ) { if ( c < 5 ) c ++ ; else { ans += 1 ; c = 1 ; } } else { ans += 1 ; c = 1 ; ch = s . charAt ( i ) ; }

import java . util . Scanner ;   public class PostCardPhotos { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ;   String s = scan . nextLine ( ) ; int closet = 1 ; int count = 1 ; char prev = s . charAt ( 0 ) ;   for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( prev == s . charAt ( i ) ) { if ( count == 5 ) { count = 0 ; closet ++ ; } count ++ ; } else { count = 1 ; closet ++ ; if ( count == 5 ) { count = 0 ; } } prev = s . charAt ( i ) ; } System . out . println ( closet ) ; } }

import java . util . Scanner ;    public class PostcardsAndPhotos { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; String s = input . next ( ) ; int count = 1 ; char c = s . charAt ( 0 ) ; int temp = 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != c || temp == 5 ) { count ++ ; temp = 1 ; c = s . charAt ( i ) ; } else temp ++ ; } System . out . println ( count ) ; } }

import mathn = input ( ) def length ( s ) : res = [ ] counter = 1 for i in range ( 1 , len ( s ) ) : if s [ i - 1 ] == s [ i ] : counter += 1 else : res . append ( counter ) counter = 1 res . append ( counter ) return ressol = length ( n ) for i in range ( len ( sol ) ) : sol [ i ] = math . ceil ( sol [ i ] / 5 ) print ( sum ( sol ) )   NEW_LINE

st = input ( ) con = 1 ans = 1 pre = st [ 0 ] for i in range ( 1 , len ( st ) ) : if pre == st [ i ] and con < 5 : con += 1 else : con = 1 ans += 1 pre = st [ i ] print ( ans ) NEW_LINE

import sysfrom math import sqrt , log , log2 , ceil , log10 , gcd , floor , pow , sin , cos , tan , pi , inf , factorialfrom copy import copy , deepcopyfrom sys import exit , stdin , stdoutfrom collections import Counter , defaultdict , dequefrom itertools import permutationsimport heapqfrom bisect import bisect_left from bisect import bisect_right NEW_LINE

def solve ( s ) : tot = 1 count = 1 i = 1 while i < len ( s ) : if s [ i ] == s [ i - 1 ] : if count == 5 : count = 1 tot += 1 else : count += 1 else : count = 1 tot += 1 i += 1 return tot                   def main ( ) : s = input ( ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   public class ChatRecord { public static void main ( String [ ] args ) throws IOException { BufferedReader reader = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   int n = Integer . parseInt ( reader . readLine ( ) ) ;   for ( int i = 0 ; i < n ; i ++ ) { String chat = reader . readLine ( ) ;   if ( chat . startsWith ( " miao . " ) ) { if ( chat . endsWith ( " lala . " ) ) { System . out . println ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) ; } else System . out . println ( " Rainbow ' s " ) ; } else if ( chat . endsWith ( " lala . " ) ) { System . out . println ( " Freda ' s " ) ; } else System . out . println ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) ; } } }

import java . io . * ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) throws IOException { Scanner in = new Scanner ( System . in ) ; int n = Integer . parseInt ( in . nextLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String s = in . nextLine ( ) ; boolean f = s . endsWith ( " lala . " ) ; boolean r = s . startsWith ( " miao . " ) ; if ( f && ! r ) System . out . println ( " Freda ' s " ) ; else if ( r && ! f ) System . out . println ( " Rainbow ' s " ) ; else System . out . println ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) ; } }   }

import java . util . Scanner ; public class B { public static Scanner scan = new Scanner ( System . in ) ; public static void solve ( ) { int n = scan . nextInt ( ) ; scan . nextLine ( ) ; while ( n -- > 0 ) { String s = scan . nextLine ( ) ; if ( s . startsWith ( " miao . " ) && ! s . endsWith ( " lala . " ) ) { System . out . println ( " Rainbow ' s " ) ; } else if ( ! s . startsWith ( " miao . " ) && s . endsWith ( " lala . " ) ) { System . out . println ( " Freda ' s " ) ; } else { System . out . println ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) ; } } } public static void main ( String [ ] args ) { solve ( ) ; scan . close ( ) ; }   }

try : n = int ( input ( ) ) for i in range ( n ) : s = input ( ) if ( s . endswith ( " lala . " ) and s . startswith ( " miao . " ) ) or ( not s . endswith ( " lala . " ) and not s . startswith ( " miao . " ) ) : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) elif s . startswith ( " miao . " ) : print ( " Rainbow ' s " ) else : print ( " Freda ' s " ) except : pass NEW_LINE

for _ in range ( int ( input ( ) ) ) : s = input ( ) if len ( s ) < 5 : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) elif ' lala ' not in s and ' miao . ' not in s : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) elif s [ : 5 ] == ' miao . ' and s [ - 5 : ] == ' lala . ' : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) elif s [ : 5 ] == ' miao . ' : print ( " Rainbow ' s " ) elif s [ - 5 : ] == ' lala . ' : print ( " Freda ' s " ) else : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) NEW_LINE

for x in range ( int ( input ( ) ) ) : a = input ( ) b = len ( a ) - 5 print if " lala . " in a [ b : ] and " miao . " in a [ : 5 ] : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) elif " miao . " in a [ : 5 ] : print ( " Rainbow ' s " ) elif " lala . " in a [ b : ] : print ( " Freda ' s " ) else : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) NEW_LINE

t = int ( input ( ) ) while t > 0 : t -= 1 s = input ( ) if len ( s ) >= 5 : if s [ : 5 ] == " miao . " and s [ : : - 1 ] [ : 5 ] != " . alal " : print ( " Rainbow ' s " ) elif s [ : 5 ] != " miao . " and s [ : : - 1 ] [ : 5 ] == " . alal " : print ( " Freda ' s " ) else : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) else : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " ) NEW_LINE

def solve ( ) : s = input ( ) if ( s [ - 5 : ] == ' lala . ' and s [ : 5 ] != " miao . " ) : print ( " Freda ' s " ) elif ( s [ - 5 : ] != ' lala . ' and s [ : 5 ] == " miao . " ) : print ( " Rainbow ' s " ) else : print ( " OMG > . < ▁ I ▁ don ' t ▁ know ! " )     n = int ( input ( ) ) for _ in range ( n ) : solve ( ) NEW_LINE


import java . io . * ; import java . util . * ;   import static java . lang . Integer . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { FastReader in = new FastReader ( System . in ) ; PrintWriter pw = new PrintWriter ( System . out ) ; HashMap < Integer , Integer > map = new HashMap < > ( ) ; int n = in . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = in . nextInt ( ) ; for ( int j = 2 ; j * j <= a ; j ++ ) { if ( a % j == 0 ) { int cnt = map . getOrDefault ( j , 0 ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ; import static java . util . Arrays . sort ; import javafx . util . Pair ;   public class Main {   public static void main ( String [ ] args ) {   FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int count [ ] = new int [ 100001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int value = input . nextInt ( ) ; count [ value ] ++ ; } int max = 1 ; for ( int i = 2 ; i < 100001 ; i ++ ) { int c = 0 ; for ( int j = i ; j <= 100000 ; j += i ) { c += count [ j ] ; } max = Math . max ( max , c ) ; } System . out . println ( max ) ;   }   static class FastScanner {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ;   String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }

import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ;   public class Main { static boolean [ ] prime ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; PrintWriter p = new PrintWriter ( System . out ) ; int n = in . nextInt ( ) ; int [ ] ara = new int [ 100001 ] ; Arrays . fill ( ara , 0 ) ; int ans = 1 ; for ( int i = 0 ; i < n ; i ++ ) { ara [ in . nextInt ( ) ] ++ ; }   for ( int i = 2 ; i < ara . length ; i ++ ) { for ( int j = i * 2 ; j < ara . length ; j += i ) { ara [ i ] += ara [ j ] ; } ans = Math . max ( ans , ara [ i ] ) ; }   p . println ( ans ) ; p . close ( ) ; }   }

res , N = 1 , int ( 1e5 + 16 ) n = int ( input ( ) ) M = { } for i in map ( int , input ( ) . split ( ) ) : M [ i ] = M . get ( i , 0 ) + 1 for i in range ( 2 , N ) : num = 0 for k in range ( i , N , i ) : num += M . get ( k , 0 ) res = max ( res , num ) print ( res ) NEW_LINE

n = int ( input ( ) ) ip = list ( map ( int , input ( ) . split ( ) ) ) m = max ( ip ) ; ans = 0 x = [ 0 ] * ( m + 1 ) ; p = [ ] p . append ( 1 ) for i in ip : x [ i ] += 1 for k in range ( 2 , m + 1 , 1 ) : l = k z = 0 while l <= m : z += x [ l ] l += k if ans < z : p . append ( z ) print ( max ( p ) ) NEW_LINE

from collections import defaultdictn = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) factors = defaultdict ( int ) for i in range ( n ) : root = int ( a [ i ] ** 0.5 ) for j in range ( 2 , root + 1 ) : if a [ i ] % j == 0 : factors [ j ] += 1 while a [ i ] % j == 0 : a [ i ] //= j if a [ i ] > 1 : factors [ a [ i ] ] += 1 ans = 1 for i in factors : ans = max ( ans , factors [ i ] ) print ( ans ) NEW_LINE

val = int ( '1' + '0' * 5 ) freequency = [ 0 ] * ( val + 1 ) n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) for x in range ( n ) : freequency [ l [ x ] ] += 1 ans = 1 for x in range ( 2 , val + 1 ) : count = 0 for y in range ( x , val + 1 , x ) : count += freequency [ y ] ans = max ( ans , count ) print ( ans ) NEW_LINE


import java . util . * ; public class DreamoonAndStairs { public static int minStair ( int n , int m ) { if ( n < m ) { return - 1 ; } int minSteps = n / 2 + n % 2 ; int nextMultiple = m ; int i = 2 ; while ( true ) { if ( minSteps > nextMultiple ) { nextMultiple = m * i ; } else { break ; } i ++ ; } return nextMultiple ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; System . out . println ( minStair ( n , m ) ) ; in . close ( ) ;   }   }

import java . util . Scanner ; public class cond {     public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; if ( m > n ) { System . out . println ( - 1 ) ; return ; } else if ( n % 2 == 0 ) { int k = n / 2 ; while ( k <= n ) { if ( k % m == 0 ) { System . out . println ( k ) ; return ; } k ++ ; } } else { int k = ( n / 2 ) + 1 ; while ( k <= n ) { if ( k % m == 0 ) { System . out . println ( k ) ; return ; } k ++ ; } } } }

import java . util . Scanner ;   public class _0604DreamoonandStairs {   static int DreamoonandStairs ( int n , int m ) { int val = n / 2 ; if ( n % 2 != 0 ) { val ++ ; } if ( val % m != 0 ) { val += m - ( val % m ) ; } return val ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; if ( n < m ) { System . out . println ( - 1 ) ; } else { System . out . println ( DreamoonandStairs ( n , m ) ) ; } }   }

n , m = map ( int , input ( ) . split ( ) ) count = 0 if ( n < m ) : print ( " - 1" ) else : if ( n % 2 == 0 ) : count = n // 2 else : count = n // 2 + 1 while ( count % m != 0 ) : count += 1 print ( count ) NEW_LINE

import mathdef solve ( n , m ) : start = n % 2 + n // 2 while start <= n : if start % m == 0 : return start start += 1 return - 1                   def main ( ) : NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) t = ( n // 2 ) + ( n % 2 ) print ( - 1 ) if n < m else print ( t + ( ( m - ( t % m ) ) % m ) ) NEW_LINE

import sys   n , m = map ( int , sys . stdin . readline ( ) . split ( ) )   num_twos = n // 2 ; num_steps = num_twos + n % 2   num_changed = 0   while ( num_steps % m != 0 ) and ( num_twos > 0 ) and ( num_changed < 30 ) : num_twos -= 1 num_steps += 1 num_changed += 1   if num_steps % m != 0 : print ( - 1 ) else : print ( num_steps ) NEW_LINE

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


a , b = map ( int , raw_input ( ) . split ( ) ) print ( ( pow ( 3 , a , b ) + b - 1 ) % b )

# include < iostream >   using namespace std ;   int n , m ;   int putere ( int x , int p ) ;   int main ( ) { int i ;   cin >> n >> m ; int rez = putere ( 3 , n ) ; rez -- ; if ( rez < 0 ) rez += m ; cout << rez << ' \n ' ; return 0 ; }   int putere ( int x , int p ) { int aux = 1 ;   while ( p ) { if ( p % 2 ) aux = ( 1l l * aux * x ) % m ; x = ( 1l l * x * x ) % m ; p /= 2 ; } return aux ; }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class FlyingSaucerSegments {   public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; long n = in . nextLong ( ) ; long mod = in . nextLong ( ) ; long ans = fastPow ( 3 , n , mod ) - 1 ; if ( ans == - 1 ) ans += mod ; out . println ( ans ) ; out . close ( ) ; }   static long fastPow ( long a , long b , long mod ) { if ( b == 0 ) return 1L ; long val = fastPow ( a , b / 2 , mod ) ; if ( b % 2 == 0 ) return val * val % mod ; else return val * val % mod * a % mod ; } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ;   public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; }   public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; }   public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } }    }

n = input ( ) . split ( ) n1 = int ( n [ 0 ] ) n2 = int ( n [ 1 ] ) F = pow ( 3 , n1 , n2 ) print ( ( F - 1 ) % n2 )     NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashSet ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Solution { static ArrayList < Integer > [ ] adjlist ; static int n ; static final int inf = ( int ) 1e9 ; static int ans = inf ; static int [ ] q ; public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { n = fs . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = fs . nextLong ( ) ;

import sysinput = sys . stdin . readlinefrom collections import deque   class Graph ( object ) : """ docstring ▁ for ▁ Graph """ def __init__ ( self , n , d ) : NEW_LINE

from sys import stdinfrom collections import deque     INT_MAX = float ( ' inf ' ) def shortest_cycle ( gr ) : NEW_LINE

def solve ( n , a ) : B = 60 bits = [ [ ] for i in range ( B ) ] for i in range ( n ) : for j in range ( B ) : if a [ i ] & ( 1 << j ) : bits [ j ] . append ( i )   adj = [ [ ] for i in range ( n ) ] for shared in bits : if len ( shared ) >= 3 : return 3 elif len ( shared ) == 2 : u , v = shared adj [ u ] . append ( v ) adj [ v ] . append ( u )   vis = [ False for u in range ( n ) ] dist = [ - 1 for u in range ( n ) ] def shortest_cycle ( n , adj , s ) : frontier = [ ( s , - 1 ) ] dist [ s ] = 0 ptr = 0   while ptr < len ( frontier ) : u , p = frontier [ ptr ] if not vis [ u ] : vis [ u ] = True for v in adj [ u ] : if vis [ v ] and v != p : ans = dist [ u ] + dist [ v ] + 1 for u , p in frontier : vis [ u ] = False dist [ u ] = - 1 return ans if dist [ v ] == - 1 : dist [ v ] = dist [ u ] + 1 frontier . append ( ( v , u ) ) ptr += 1   return 10 ** 18 NEW_LINE

import sysreadline = sys . stdin . readlinefrom collections import deque   N = int ( readline ( ) ) A = list ( map ( int , readline ( ) . split ( ) ) ) A = [ a for a in A if a ] limit = 32 table = [ 0 ] * limit   for a in A : for i in range ( limit ) : if a & ( 1 << i ) : table [ i ] += 1   if max ( table ) > 2 : print ( 3 )   else : INF = 10 ** 18 + 3 N = len ( A ) Edge = [ set ( ) for _ in range ( N ) ] for i in range ( N ) : for j in range ( i ) : if A [ i ] & A [ j ] : Edge [ i ] . add ( j ) Edge [ j ] . add ( i ) ans = INF for st in range ( N ) : for en in Edge [ st ] . copy ( ) : Edge [ st ] . remove ( en ) Edge [ en ] . remove ( st ) dist = [ INF ] * N dist [ st ] = 0 Q = deque ( [ st ] ) while Q : vn = Q . pop ( ) for vf in Edge [ vn ] : if dist [ vf ] == INF : dist [ vf ] = 1 + dist [ vn ] Q . appendleft ( vf ) ans = min ( ans , 1 + dist [ en ] ) Edge [ st ] . add ( en ) Edge [ en ] . add ( st ) if ans >= INF : ans = - 1 print ( ans ) NEW_LINE


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

import java . util . * ; import java . lang . * ; import java . io . * ; import java . math . * ;    public class file {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) {   FastScanner input = new FastScanner ( ) ;   String s = input . next ( ) ; int k = input . nextInt ( ) ; int count = 0 ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { if ( s . charAt ( i ) == '0' ) { count ++ ; } if ( count == k ) { System . out . println ( ( s . length ( ) - ( i ) ) - count ) ; return ; } } if ( count < k ) { System . out . println ( s . length ( ) - 1 ) ; }   }   static class FastScanner {   BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( " " ) ;   String next ( ) { while ( ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) {   return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) throws IOException { return br . readLine ( ) ; } }   }

n , k = [ x for x in input ( ) . split ( ) ] cnt = 0 k = int ( k ) l = len ( n ) for i in range ( l - 1 , - 1 , - 1 ) : if k <= 0 : break elif n [ i ] == '0' : k -= 1 else : cnt += 1 if k <= 0 : print ( cnt ) else : print ( l - 1 ) NEW_LINE

import sysimport mathfrom collections import OrderedDictdef input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def minput ( ) : return map ( int , input ( ) . split ( ) ) def listinput ( ) : return list ( map ( int , input ( ) . split ( ) ) ) n , k = map ( str , input ( ) . split ( ) ) if n == '0' : print ( '0' ) elif n . count ( '0' ) < int ( k ) : print ( len ( n ) - 1 ) else : for i in range ( 1 , len ( n ) ) : if n [ i ] == '0' and n [ i : ] . count ( '0' ) == int ( k ) : print ( len ( n [ i : ] ) - int ( k ) ) break NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) n = str ( n ) if ( len ( n ) <= k ) : print ( len ( n ) - 1 ) else : n = str ( n ) count = 0 ans = 0 for i in range ( len ( n ) - 1 , - 1 , - 1 ) : if ( n [ i ] == "0" ) : count = count + 1 if ( count == k ) : break else : ans = ans + 1 if ( count != k ) : print ( len ( n ) - 1 ) else : print ( ans ) NEW_LINE

""" ▁ Created ▁ by ▁ Henrikh ▁ Kantuni ▁ on ▁ 2/26/17 ▁ """   n , k = [ int ( x ) for x in input ( ) . split ( ) ] digits = list ( str ( n ) )   zero_count = digits . count ( '0' ) if zero_count < k : print ( len ( str ( n ) ) - 1 ) exit ( )   count = 0 i = len ( digits ) - 1   while int ( ' ' . join ( digits ) ) % 10 ** k > 0 : if digits [ i ] != '0' : del digits [ i ] count += 1 i -= 1   print ( count ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main { static long count = 0 ; public static void main ( String [ ] args ) {   FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; ArrayList < ArrayList < Integer > > a = new ArrayList < > ( n + 1 ) ; boolean visited [ ] = new boolean [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { a . add ( new ArrayList < > ( ) ) ; } for ( int i = 0 ; i < m ; i ++ ) { int x = input . nextInt ( ) ; int y = input . nextInt ( ) ; a . get ( x ) . add ( y ) ; a . get ( y ) . add ( x ) ; } long ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { if ( ! visited [ i ] ) { count = 0 ; dfs ( visited , a , i ) ; ans += ( count - 1 ) ; } }

import java . io . BufferedWriter ; import java . io . ByteArrayInputStream ; import java . io . FileInputStream ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . HashSet ; import java . util . InputMismatchException ; import java . util . LinkedList ; import java . util . List ; import java . util . Map ; import java . util . Queue ; import java . util . Set ;   public class Main { private static final long MOD = ( long ) 1e9 + 7 ; static InputStream is ; static PrintWriter out ; static String INPUT = " " ; static int lenbuf = 0 , ptrbuf = 0 ; private static byte [ ] inbuf = new byte [ 1024 ] ; static boolean readFile = false ;

import java . util . * ; import java . util . zip . CRC32 ;   public class Solution {   static Scanner scan = new Scanner ( System . in ) ;   static class DSU { int parent [ ] ; int groupSize [ ] ; public DSU ( int nodes ) { parent = new int [ nodes + 1 ] ; groupSize = new int [ nodes + 1 ] ; for ( int i = 0 ; i <= nodes ; i ++ ) { parent [ i ] = i ; groupSize [ i ] = 1 ; } }   public int findSuperParent ( int node ) { if ( parent [ node ] == node ) return node ; return parent [ node ] = findSuperParent ( parent [ node ] ) ; } public void mergeGroup ( int x , int y ) { int xSuperParent = findSuperParent ( x ) ; int ySuperParent = findSuperParent ( y ) ; if ( xSuperParent == ySuperParent ) return ; if ( groupSize [ xSuperParent ] > groupSize [ ySuperParent ] ) { parent [ ySuperParent ] = xSuperParent ; groupSize [ xSuperParent ] += groupSize [ ySuperParent ] ; } else { parent [ xSuperParent ] = ySuperParent ; groupSize [ ySuperParent ] += groupSize [ xSuperParent ] ; } }    public int getExpectedFriends ( int element ) { return groupSize [ findSuperParent ( element ) ] - 1 ; } }   public static void main ( String [ ] args ) {

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

import bisectimport collectionsimport copyimport functoolsimport heapqimport itertoolsimport mathimport randomimport reimport sysimport timeimport stringfrom typing import List NEW_LINE

from collections import defaultdictdef dfs ( node , graph , vis ) : global count vis [ node ] = True count += 1 for i in graph [ node ] : if not vis [ i ] : dfs ( i , graph , vis ) n , m = map ( int , input ( ) . split ( ) ) if m == 0 : print ( 1 ) else : graph = defaultdict ( list ) for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) graph [ a ] . append ( b ) graph [ b ] . append ( a ) vis = [ False ] * ( n + 1 ) ans = 0 ans = 0 for i in range ( 1 , n + 1 ) : global count count = 0 if not vis [ i ] : dfs ( i , graph , vis ) ans += 1 print ( pow ( 2 , n - ans ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) arr = [ x for x in range ( 0 , n + 1 ) ] d = 1 for i in range ( m ) : a , b = map ( int , input ( ) . split ( ) ) a , b = arr [ a ] , arr [ b ] while a != arr [ a ] : a = arr [ a ] while b != arr [ b ] : b = arr [ b ] if a != b : arr [ b ] = a d *= 2 print ( d ) NEW_LINE

def gf ( x ) : if fa [ x ] != x : fa [ x ] = gf ( fa [ x ] ) return fa [ x ]     n , m = map ( int , input ( ) . split ( ) ) fa = list ( range ( n + 1 ) ) for _ in range ( m ) : x , y = map ( int , input ( ) . split ( ) ) fa [ gf ( x ) ] = gf ( y ) ans = 2 ** nfor i in range ( 1 , n + 1 ) : if gf ( i ) == i : ans //= 2 print ( ans ) NEW_LINE


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

import java . io . * ;   import java . lang . * ;    import java . util . * ;   public class TestA { static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } }   public static void main ( String [ ] args ) {   try { System . setIn ( new FileInputStream ( " input . txt " ) ) ; System . setOut ( new PrintStream ( new FileOutputStream ( " output . txt " ) ) ) ; } catch ( Exception e ) { System . err . println ( " Error " ) ; }   FastReader objScanner = new FastReader ( ) ;  		  int arr [ ] [ ] = new int [ 6 ] [ 6 ] ;   int x = - 1 ; int y = - 1 ; for ( int i = 1 ; i <= 5 ; i ++ ) { for ( int j = 1 ; j <= 5 ; j ++ ) { arr [ i ] [ j ] = objScanner . nextInt ( ) ;   if ( arr [ i ] [ j ] == 1 ) { x = i ; y = j ; } } }   System . out . println ( Math . abs ( x - 3 ) + Math . abs ( y - 3 ) ) ; }   }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = 0 , b = 0 ; for ( int i = 0 ; i < 25 ; i ++ ) { if ( scan . nextInt ( ) == 1 ) { a = i % 5 ; b = i / 5 ; } } System . out . println ( Math . abs ( a - 2 ) + Math . abs ( b - 2 ) ) ; } }

import java . io . * ; import java . util . * ; import java . lang . * ; import java . util . Random ; public class Main { public static void main ( String [ ] args ) throws java . lang . Exception { Scanner scan = new Scanner ( System . in ) ; int repeat = 1 ; while ( repeat -- > 0 ) { int [ ] [ ] matrix = new int [ 5 ] [ 5 ] ; int count = 0 ; int row = 0 ; int col = 0 ; while ( count < 25 ) { int val = scan . nextInt ( ) ; if ( val == 1 ) { row = count / 5 ; col = count % 5 ; break ; } count ++ ; } int dist = Math . abs ( row - 2 ) + Math . abs ( col - 2 ) ; System . out . println ( dist ) ; } } }

import java . util . Scanner ;   public class BeautifulMatrix {   public static void main ( String [ ] args ) { matrix ( ) ;   } public static void matrix ( ) { Scanner s = new Scanner ( System . in ) ; int x = 0 , y = 0 ; int [ ] [ ] feld = new int [ 5 ] [ 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) { for ( int j = 0 ; j < 5 ; j ++ ) { feld [ i ] [ j ] = s . nextInt ( ) ; if ( feld [ i ] [ j ] == 1 ) { x = i ; y = j ; } } } int hor = x - 2 < 0 ? ( x - 2 ) * ( - 1 ) : x - 2 ; int vert = y - 2 < 0 ? ( y - 2 ) * ( - 1 ) : y - 2 ; System . out . print ( hor + vert ) ; }   }

matrix = [ ] for i in range ( 5 ) : row = list ( map ( int , input ( ) . split ( ) ) ) matrix . append ( row ) r = 0 c = 0 for i in range ( 5 ) : for j in range ( 5 ) : if matrix [ i ] [ j ] == 1 : if ( i != 2 ) : r = abs ( 2 - i ) if ( j != 2 ) : c = abs ( 2 - j )                                   print ( r + c ) NEW_LINE

for row in range ( 0 , 5 ) : row_matrix = [ int ( n ) for n in input ( ) . split ( ) ] if 1 in row_matrix : column_index = row_matrix . index ( 1 ) print ( abs ( column_index - 2 ) + abs ( row - 2 ) ) NEW_LINE

lst = [ ]   x = y = 0   for i in range ( 5 ) :   matrix = input ( ) . split ( )   lst . append ( matrix )   for j in range ( 0 , 5 ) :   if ( lst [ i ] [ j ] == "1" ) :   x = i - 2   y = j - 2   print ( abs ( x ) + abs ( y ) ) NEW_LINE

data = [ ] for i in range ( 5 ) : data . append ( list ( map ( int , input ( ) . split ( ) ) ) )   n , m = 0 , 0 for i in range ( 5 ) : for j in range ( 5 ) : if data [ i ] [ j ] == 1 : n , m = i , j   print ( abs ( 3 - ( n + 1 ) ) + abs ( 3 - ( m + 1 ) ) ) NEW_LINE


import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = true ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static int oo = ( int ) 2e9 ;

import java . util . * ; import java . io . * ;   public class Test { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; PriorityQueue < Integer > pq = new PriorityQueue < > ( Collections . reverseOrder ( ) ) ; if ( n <= 3 ) System . out . println ( " NO " ) ; else { System . out . println ( " YES " ) ; for ( int i = 1 ; i < n + 1 ; i ++ ) { pq . add ( i ) ; } int ct = 0 ; while ( ! pq . isEmpty ( ) ) { int a = pq . poll ( ) ; int b = pq . poll ( ) ; if ( a == 4 ) { System . out . println ( "4 ▁ * ▁ 3 ▁ = ▁ 12" ) ; System . out . println ( "12 ▁ * ▁ 2 ▁ = ▁ 24" ) ; System . out . println ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) ; break ; } if ( a == 5 ) { System . out . println ( "5 ▁ - ▁ 3 ▁ = ▁ 2" ) ; System . out . println ( "2 ▁ + ▁ 1 ▁ = ▁ 3" ) ; System . out . println ( "4 ▁ * ▁ 3 ▁ = ▁ 12" ) ; System . out . println ( "12 ▁ * ▁ 2 ▁ = ▁ 24" ) ; break ; } System . out . println ( a + " ▁ - ▁ " + b + " ▁ = ▁ 1" ) ; ct ++ ; } while ( ct -- > 0 ) { System . out . println ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) ; } } } }

n = int ( input ( ) ) if n < 4 : print ( " NO " ) else : print ( " YES " ) if n == 4 : print ( "4 ▁ * ▁ 3 ▁ = ▁ 12 \n 12 ▁ * ▁ 2 ▁ = ▁ 24 \n 24 ▁ * ▁ 1 ▁ = 24" ) elif n == 5 : print ( "5 ▁ * ▁ 4 ▁ = ▁ 20 \n 20 ▁ + ▁ 3 ▁ = ▁ 23 \n 23 ▁ + ▁ 2 ▁ = ▁ 25 \n 25 ▁ - ▁ 1 ▁ = ▁ 24" ) else : print ( "4 ▁ * ▁ 3 ▁ = ▁ 12 \n 12 ▁ * ▁ 2 ▁ = ▁ 24 \n " + str ( n ) + " ▁ - ▁ " + str ( n - 1 ) + " ▁ = ▁ 1 \n 1 ▁ - ▁ 1 ▁ = ▁ 0" ) for i in range ( 5 , n - 1 ) : print ( str ( i ) + " ▁ * ▁ 0 ▁ = ▁ 0" ) print ( "24 ▁ + ▁ 0 ▁ = ▁ 24" ) NEW_LINE

n = int ( input ( ) ) if n > 3 : print ( " YES " ) if n % 2 : for i in range ( 6 , n , 2 ) : print ( i + 1 , " ▁ - ▁ " , i , " ▁ = ▁ " , 1 ) print ( "5 ▁ - ▁ 1 ▁ = ▁ 4 \n 4 ▁ - ▁ 2 ▁ = ▁ 2" ) print ( "4 ▁ * ▁ 3 ▁ = ▁ 12 \n 12 ▁ * ▁ 2 ▁ = ▁ 24" ) else : print ( "4 ▁ * ▁ 3 ▁ = ▁ 12 \n 12 ▁ * ▁ 2 ▁ = ▁ 24" ) for i in range ( 5 , n , 2 ) : print ( i + 1 , " ▁ - ▁ " , i , " ▁ = ▁ " , 1 ) print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) for i in range ( ( n - 4 ) // 2 ) : print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) else : print ( " NO " ) NEW_LINE

n = int ( input ( ) ) if ( n <= 3 ) : print ( " NO " ) else : print ( " YES " ) if ( n % 2 == 0 ) : print ( "1 ▁ * ▁ 2 ▁ = ▁ 2" ) print ( "2 ▁ * ▁ 3 ▁ = ▁ 6" ) print ( "6 ▁ * ▁ 4 ▁ = ▁ 24" ) for i in range ( 5 , n , 2 ) : print ( str ( i + 1 ) + " ▁ - ▁ " + str ( i ) + " ▁ = ▁ 1" ) print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) else : print ( "5 ▁ + ▁ 1 ▁ = ▁ 6" ) print ( "6 ▁ * ▁ 4 ▁ = ▁ 24" ) print ( "3 ▁ - ▁ 2 ▁ = ▁ 1" ) print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) for i in range ( 6 , n , 2 ) : print ( str ( i + 1 ) + " ▁ - ▁ " + str ( i ) + " ▁ = ▁ 1" ) print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) NEW_LINE

n = int ( input ( ) ) if n < 4 : print ( " NO " ) elif n % 2 == 0 : print ( " YES " ) print ( "1 ▁ * ▁ 2 ▁ = ▁ 2" ) print ( "2 ▁ * ▁ 3 ▁ = ▁ 6" ) print ( "6 ▁ * ▁ 4 ▁ = ▁ 24" ) for i in range ( 5 , n + 1 , 2 ) : print ( i + 1 , " - " , i , " = " , 1 ) print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) else : print ( " YES " ) print ( "5 ▁ + ▁ 4 ▁ = ▁ 9" ) print ( "9 ▁ + ▁ 3 ▁ = ▁ 12" ) print ( "12 ▁ * ▁ 2 ▁ = ▁ 24" ) print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) for i in range ( 6 , n + 1 , 2 ) : print ( i + 1 , " - " , i , " = " , 1 ) print ( "24 ▁ * ▁ 1 ▁ = ▁ 24" ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . Scanner ;   public class Codeforces {   private static final Scanner sc = new Scanner ( System . in ) ; private static final BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; private static final long MOD = ( long ) ( 1e9 + 7 ) ; private static PrintWriter out = new PrintWriter ( System . out ) ;   public static void solve ( int T ) throws IOException { int n = sc . nextInt ( ) ; if ( n == 1 ) { System . out . println ( " O " ) ; return ; } if ( n == 2 ) { System . out . println ( " OO " ) ; return ; } int [ ] f = new int [ n + 5 ] ; int a = 0 ; int b = 1 ; f [ 0 ] = a ; f [ 1 ] = b ; for ( int i = 2 ; i <= n + 4 ; i ++ ) { int c = a + b ; f [ i ] = c ; a = b ; b = c ; }

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 ( ) ; int first = 0 , second = 1 ; int [ ] a = new int [ n + 1 ] ; int count = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int num = first + second ; if ( num > n ) { break ; } a [ i ] = num ; count ++ ; first = second ; second = num ; } for ( int i = 1 ; i <= n ; i ++ ) { int flag = 0 ; for ( int j = 1 ; j <= count ; j ++ ) { if ( i == a [ j ] ) { flag = 1 ; break ; } } if ( flag == 1 ) { System . out . print ( " O " ) ; } else { System . out . print ( " o " ) ; } } } }

import java . util . * ; import java . lang . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String result = " " ; int n = s . nextInt ( ) ; int a [ ] = new int [ 1000 ] ; int b [ ] = new int [ n + 1 ] ; if ( n == 1 ) { result = result + ' O ' ; System . out . println ( result ) ; } else { a [ 0 ] = 0 ; a [ 1 ] = 1 ; for ( int i = 2 ; i < 1000 ; i ++ ) { a [ i ] = a [ i - 1 ] + a [ i - 2 ] ; } for ( int j = 1 ; j <= n ; j ++ ) { boolean c = check ( a , j ) ; if ( c == false ) { result = result + ' o ' ; } else result = result + ' O ' ; } System . out . println ( result ) ; } } public static boolean check ( int a [ ] , int j ) { for ( int i = 0 ; i < a . length ; i ++ ) { if ( a [ i ] == j ) return true ; } return false ; } }

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

a , b = 1 , 1 k = int ( input ( ) ) n = 1 while n <= k : if n == b : print ( " O " , end = " " ) a , b = b , a + b else : print ( " o " , end = " " ) n = n + 1 NEW_LINE

import math   def isPerfectSquare ( x ) : s = int ( math . sqrt ( x ) ) return s * s == x   def isFibonacci ( n ) : return isPerfectSquare ( 5 * n * n + 4 ) or isPerfectSquare ( 5 * n * n - 4 )   n = int ( input ( ) ) for i in range ( 1 , n + 1 ) : if isFibonacci ( i ) : print ( " O " , end = " " ) else : print ( " o " , end = " " ) NEW_LINE

class eleven : def __init__ ( self , n ) : self . n = n self . printName ( self . n ) def printName ( self , n ) : list1 = [ 0 , 1 ] f0 = 0 f1 = 1 for x in range ( 0 , n ) : f2 = f0 + f1 list1 . append ( f2 ) f0 = f1 f1 = f2 for x in range ( 1 , n + 1 ) : if x in list1 : print ( ' O ' , end = " " ) else : print ( " o " , end = " " ) n = int ( input ( ) ) if ( 1 <= n and n <= 1000 ) : passelse : exit ( ) elevenObj = eleven ( n ) NEW_LINE

n = int ( input ( ) ) s = [ ' o ' ] * na = b = c = 1 while a <= n : s [ a - 1 ] = ' O ' c = a a = b b = a + cprint ( ' ' . join ( s ) ) NEW_LINE


import java . util . * ; public class xt { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int max = n ; int min = 1 ; sc . nextLine ( ) ; for ( int i = 0 ; i < m ; i ++ ) { String s = sc . nextLine ( ) ;

[ n , m ] = map ( int , ( input ( ) . split ( ) ) ) NEW_LINE p1 = 0 NEW_LINE p2 = n + 1 NEW_LINE for j in range ( m ) : hint = input ( ) NEW_LINE ind_val = int ( hint . split ( ) [ - 1 ] ) NEW_LINE if hint [ 7 ] == ' r ' : if NEW_LINE p1 < ind_val : p1 = ind_val NEW_LINE if hint [ 7 ] == ' l ' : if NEW_LINE p2 > ind_val : p2 = ind_val   if p1 >= p2 - 1 : NEW_LINE INDENT print ( - 1 ) else : NEW_LINE print ( p2 - p1 - 1 ) NEW_LINE DEDENT

a , b = map ( int , input ( ) . split ( ) ) NEW_LINE z = [ 0 ] + [ 1 ] * afor NEW_LINE _ in " ▁ " * b : gh = input ( ) . split ( ) NEW_LINE if gh [ 2 ] == ' left ' : NEW_LINE INDENT z [ int ( gh [ - 1 ] ) : ] = [ 0 ] * ( a - int ( gh [ - 1 ] ) + 1 ) else : NEW_LINE z [ : int ( gh [ - 1 ] ) + 1 ] = [ 0 ] * ( int ( gh [ - 1 ] ) + 1 ) NEW_LINE DEDENT if z [ 1 : ] . count ( 1 ) : NEW_LINE INDENT print ( z [ 1 : ] . count ( 1 ) ) else : NEW_LINE print ( - 1 ) NEW_LINE DEDENT

n , m = map ( int , input ( ) . split ( ) ) NEW_LINE l = [ int ( i ) for i in range ( 1 , n + 1 ) ] NEW_LINE for i in range ( m ) : p = input ( ) . split ( ) NEW_LINE if p [ 2 ] == ' left ' : h = int ( p [ - 1 ] ) NEW_LINE if h not in l : if NEW_LINE min ( l ) > h : print ( - 1 ) ; NEW_LINE exit ( ) else : l = l [ : l . index ( h ) ] NEW_LINE if l == [ ] : NEW_LINE INDENT print ( - 1 ) ; exit ( ) else : NEW_LINE h = int ( p [ - 1 ] ) NEW_LINE DEDENT if h not in l : if NEW_LINE max ( l ) < h : print ( - 1 ) ; NEW_LINE exit ( ) else : l = l [ l . index ( h ) + 1 : ] NEW_LINE if l == [ ] : print ( - 1 ) ; exit ( ) NEW_LINE print ( len ( l ) ) NEW_LINE

v = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE n = v [ 0 ] NEW_LINE m = v [ 1 ]   r = 1 l = n   ans = True   for i in range ( m ) : hint = input ( ) . split ( ) NEW_LINE vt = int ( hint [ - 1 ] ) NEW_LINE if hint [ 2 ] == ' left ' : if NEW_LINE INDENT ( vt - 1 < l ) : l = vt - 1 else : if ( vt + 1 > r ) : r = vt + 1 NEW_LINE DEDENT if l < 0 or r > n : ans = False NEW_LINE if l - r < 0 : ans = False   if ans : NEW_LINE INDENT print ( l - r + 1 ) else : NEW_LINE print ( - 1 ) NEW_LINE DEDENT

n , m = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE l , h = 1 , nfor NEW_LINE i in range ( m ) : s = input ( ) . split ( ) NEW_LINE v = int ( s [ - 1 ] ) NEW_LINE d = s [ 2 ] NEW_LINE if d == ' left ' : NEW_LINE INDENT h = min ( h , v - 1 ) else : NEW_LINE l = max ( l , v + 1 ) NEW_LINE DEDENT output = h - l + 1 NEW_LINE if output <= 0 : NEW_LINE INDENT print ( - 1 ) else : NEW_LINE print ( output ) NEW_LINE DEDENT


import java . util . * ; import java . io . * ; import java . math . BigInteger ; import java . text . * ; public class Main { static long mod = 1000_000_007 ; static long mod1 = 998244353 ; static boolean fileIO = false ; static boolean memory = true ; static FastScanner f ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static FileWriter fw ; static long oo = Long . MAX_VALUE ;

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

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 dequeif __name__ == ' _ _ main _ _ ' : n , q = map ( int , input ( ) . split ( ' ▁ ' ) ) arr = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) dq = deque ( arr ) m = max ( arr ) lst = [ ] while dq [ 0 ] != m : a = dq . popleft ( ) b = dq . popleft ( ) lst . append ( [ a , b ] ) dq . append ( min ( a , b ) ) dq . appendleft ( max ( a , b ) ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : n , m = map ( int , input ( ) . split ( ' ▁ ' ) ) x = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) y = [ int ( input ( ) ) for x in range ( m ) ]   max_index = x . index ( max ( x ) ) r = [ ] for i in range ( max_index ) : r . append ( ' { 0 } ▁ { 1 } ' . format ( x [ 0 ] , x [ 1 ] ) )   if x [ 0 ] > x [ 1 ] : k = x . pop ( 1 ) x . append ( k ) else : k = x . pop ( 0 ) x . append ( k ) for i in y : if i - 1 < max_index : print ( r [ i - 1 ] ) else : k = i - max_index - 1 print ( ' { 0 } ▁ { 1 } ' . format ( x [ 0 ] , x [ 1 + k % ( n - 1 ) ] ) )   NEW_LINE


import java . util . * ;   public class Check2 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { if ( n % i == 0 ) { String s1 = s . substring ( 0 , i ) ; String s2 = s . substring ( i ) ; StringBuilder stringBuilder = new StringBuilder ( s1 ) ; s = stringBuilder . reverse ( ) + s2 ;

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

def divisors ( n ) : divs = [ ] i = 1 while n >= i ** 2 : if n % i == 0 : divs . append ( i ) if i ** 2 != n : divs . append ( n // i ) i = i + 1 divs . sort ( ) return divs     num = int ( input ( ) ) s = input ( ) divs = divisors ( num ) for i in divs : s = s [ : i ] [ : : - 1 ] + s [ i : ]   print ( s ) NEW_LINE

n = int ( input ( ) ) s = list ( input ( ) )       for i in range ( 2 , n ) : if n % i == 0 : s [ : i ] = s [ : i ] [ : : - 1 ] NEW_LINE

import sysinput = sys . stdin . readline   n = int ( input ( ) ) s = input ( ) for i in range ( 1 , n + 1 ) : if n % i == 0 : s = s [ : i ] [ : : - 1 ] + s [ i : ] print ( s ) NEW_LINE

import sysinput = sys . stdin . readline   n = int ( input ( ) ) s = input ( ) for i in range ( 1 , n + 1 ) : if n % i : continue s = s [ : i ] [ : : - 1 ] + s [ i : ] print ( s ) NEW_LINE


import java . util . * ; import java . lang . * ; import java . io . * ; import java . awt . Point ;

import java . util . * ; public class Main {   public static void main ( String [ ] args ) {   Scanner scn = new Scanner ( System . in ) ; int n = scn . nextInt ( ) ; String str = scn . next ( ) ; int [ ] r = new int [ 2 ] ; int [ ] b = new int [ 2 ] ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' r ' ) { r [ i % 2 ] ++ ; } else { b [ i % 2 ] ++ ; } } System . out . println ( Math . min ( Math . max ( r [ 0 ] , b [ 1 ] ) , Math . max ( r [ 1 ] , b [ 0 ] ) ) ) ;   } }

import java . util . * ; import java . io . * ; public class a {   public static void main ( final String [ ] args ) throws IOException { BufferInput sc = new BufferInput ( ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ;

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

import java . util . * ;   public class CodeForces719B { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; char [ ] arr = input . next ( ) . toCharArray ( ) ; int evenB = ( n + 1 ) / 2 , evenR = ( n + 1 ) / 2 ; int oddB = n / 2 , oddR = n / 2 ; for ( int i = 0 ; i < arr . length ; i ++ ) { if ( i % 2 == 0 ) { if ( arr [ i ] == ' r ' ) evenR -- ; else evenB -- ; } else { if ( arr [ i ] == ' r ' ) oddR -- ; else oddB -- ; } } System . out . println ( Math . min ( Math . max ( evenB , oddR ) , Math . max ( evenR , oddB ) ) ) ; } }

am = int ( input ( ) ) arr = list ( input ( ) ) for i in range ( am ) : if arr [ i ] == " r " : arr [ i ] = 1 else : arr [ i ] = 0 ans = 0 NEW_LINE

n = int ( input ( ) ) l = list ( input ( ) ) x1 , x2 , y1 , y2 = 0 , 0 , 0 , 0 for i in range ( n ) : if i % 2 == 0 : if l [ i ] == ' r ' : x1 += 1 else : x2 += 1 else : if l [ i ] == ' b ' : y1 += 1 else : y2 += 1 print ( min ( max ( x1 , y1 ) , max ( x2 , y2 ) ) ) NEW_LINE

import sysinput = sys . stdin . readlinefrom collections import defaultdictopp = { " r " : " b " , " b " : " r " } def func ( n , a , want , d ) : curr = defaultdict ( int ) ans = 0 for i in range ( n ) : if a [ i ] != want [ i ] : if curr [ d [ a [ i ] ] ] > 0 : curr [ d [ a [ i ] ] ] -= 1 else : curr [ a [ i ] ] += 1 ans += 1 return ansn = int ( input ( ) ) a = input ( ) want1 = " r " want2 = " b " for i in range ( 1 , n ) : want1 += opp [ want1 [ i - 1 ] ] want2 += opp [ want2 [ i - 1 ] ] ans = func ( n , a , want1 , opp ) ans = min ( ans , func ( n , a , want2 , opp ) ) print ( ans )   NEW_LINE


import java . util . * ;   public class B {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; if ( s . lastIndexOf ( ' @ ' ) == s . length ( ) - 1 || s . indexOf ( ' @ ' ) == 0 || ! s . contains ( " @ " ) ) { System . out . println ( " No ▁ solution " ) ; System . exit ( 0 ) ; } Vector < Integer > v = new Vector < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' @ ' ) { v . add ( i ) ; } } if ( v . size ( ) == 1 ) { System . out . println ( s ) ; } else { for ( int i = 1 ; i < v . size ( ) ; i ++ ) { if ( v . get ( i ) - v . get ( i - 1 ) <= 2 ) { System . out . println ( " No ▁ solution " ) ; System . exit ( 0 ) ; } } String result = " " ; Vector < String > vec = new Vector < > ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { result += s . charAt ( i ) ; if ( s . charAt ( i ) == ' @ ' ) { result += s . charAt ( i + 1 ) ; vec . add ( result ) ; result = " " ; i ++ ; } } String az = s . substring ( v . get ( v . size ( ) - 1 ) + 2 ) ; for ( int i = 0 ; i < vec . size ( ) - 1 ; i ++ ) { System . out . print ( vec . get ( i ) + " , " ) ; } System . out . print ( vec . get ( vec . size ( ) - 1 ) + " " + az ) ; } } }

import static java . lang . Double . parseDouble ; import static java . lang . Integer . max ; import static java . lang . Integer . min ; import static java . lang . Integer . parseInt ; import static java . lang . Long . parseLong ; import static java . lang . System . exit ; import static java . lang . System . setOut ;   import java . io . * ; import java . util . * ; import java . util . concurrent . ThreadLocalRandom ;   public class A {   static BufferedReader in ; static PrintWriter out ; static StringTokenizer tok ;   static void solve ( ) throws Exception { char [ ] s = next ( ) . toCharArray ( ) ; int n = s . length ; if ( s [ 0 ] == ' @ ' || s [ n - 1 ] == ' @ ' ) { out . print ( " No ▁ solution \n " ) ; return ; } List < Integer > ats = new ArrayList < > ( ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { if ( s [ i ] == ' @ ' ) { ats . add ( i ) ; } } int prev = - 10 ; for ( int x : ats ) { if ( x - prev <= 2 ) { out . print ( " No ▁ solution \n " ) ; return ; } prev = x ; } if ( ats . size ( ) == 0 ) { out . print ( " No ▁ solution \n " ) ; return ; }   for ( int i = 0 ; i < n ; i ++ ) { out . print ( s [ i ] ) ; if ( s [ i ] == ' @ ' ) { i ++ ; out . print ( s [ i ] ) ; out . print ( i < ats . get ( ats . size ( ) - 1 ) ? ' , ' : " " ) ; } } }

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

a = input ( ) . split ( ' @ ' ) n = len ( a ) b = [ ] if n >= 2 : for i in range ( n ) : if len ( a [ i ] ) > int ( i != 0 and i != n - 1 ) : if i != 0 and i != n - 1 : b . append ( a [ i - 1 ] [ min ( 1 , i - 1 ) : ] + ' @ ' + a [ i ] [ 0 ] ) elif i == n - 1 : b . append ( a [ i - 1 ] [ min ( 1 , i - 1 ) : ] + ' @ ' + a [ i ] ) else : print ( ' No ▁ solution ' ) break else : c = b [ 0 ] for i in range ( 1 , len ( b ) ) : c += ' , ' + b [ i ] print ( c ) else : print ( ' No ▁ solution ' ) NEW_LINE

s = input ( ) . split ( ' @ ' ) n = len ( s ) - 1 for i in range ( 1 , n ) : if len ( s [ i ] ) < 2 : s = False break s [ i ] = s [ i ] [ 0 ] + ' , ' + s [ i ] [ 1 : ] if n > 0 and s and s [ 0 ] and s [ n ] : print ( ' @ ' . join ( s ) ) else : print ( ' No ▁ solution ' ) NEW_LINE

from sys import stdouta = input ( ) c = list ( a . split ( ' @ ' ) ) while ' ' in c : c . remove ( ' ' ) if a . count ( ' @ ' ) == 0 : exit ( print ( ' No ▁ solution ' ) ) if a . count ( ' @ ' ) != len ( c ) - 1 : exit ( print ( ' No ▁ solution ' ) ) if any ( len ( i ) == 1 for i in c [ 1 : len ( c ) - 1 ] ) : exit ( print ( ' No ▁ solution ' ) ) stdout . write ( c [ 0 ] + ' @ ' ) for i in range ( 1 , len ( c ) - 1 ) : stdout . write ( c [ i ] [ : len ( c [ i ] ) // 2 ] + ' , ' + c [ i ] [ len ( c [ i ] ) // 2 : ] + ' @ ' ) stdout . write ( c [ - 1 ] ) NEW_LINE

def main ( ) : email = input ( ) if len ( email ) < 3 or email . count ( ' @ ' ) == 0 : print ( ' No ▁ solution ' ) return if len ( email ) == 3 : if email . count ( ' @ ' ) != 1 or email [ 1 ] != ' @ ' : print ( ' No ▁ solution ' ) return pos = [ ] for i in range ( 0 , len ( email ) ) : if ( email [ i ] == ' @ ' ) : pos . append ( i ) if i == 0 or i == len ( email ) - 1 : print ( ' No ▁ solution ' ) return elif len ( pos ) >= 2 : if ( pos [ - 1 ] - pos [ - 2 ] ) <= 2 : print ( ' No ▁ solution ' ) return   ans = [ ] temp = " " atual = 2 i = 0 while ( i < len ( email ) ) : temp += email [ i ] if email [ i ] == ' @ ' : temp += email [ i + 1 ] ans . append ( temp ) i += 1 temp = " " i += 1 ans . append ( temp ) if ( len ( ans ) >= 2 ) : if ( ans [ - 1 ] . count ( ' @ ' ) == 0 ) : ans [ - 2 ] += ans [ - 1 ] del ans [ - 1 ] print ( ' , ' . join ( ans ) ) main ( ) NEW_LINE


import java . io . * ; import java . util . * ;   public class A {   static PrintWriter out ; static class FIO { BufferedReader in ; StringTokenizer st = null ; FIO ( ) throws IOException { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; st = null ; } FIO ( String s ) throws IOException { in = new BufferedReader ( new FileReader ( s + " . in " ) ) ; out = new PrintWriter ( new FileWriter ( s + " . out " ) ) ; st = null ; } String next ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . 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 ( ) ) ; } } static FIO in ; public static void main ( String [ ] args ) throws IOException { in = new FIO ( ) ; int tc = in . nextInt ( ) ; while ( tc -- > 0 ) new solver ( ) ; out . close ( ) ; } static class solver { void p1 ( ) { out . println ( " WIN " ) ; } void p2 ( ) { out . println ( " LOSE " ) ; } solver ( ) { int N = in . nextInt ( ) ; long [ ] ar = new long [ N ] ; for ( int i = 0 ; i < N ; ++ i ) ar [ i ] = in . nextLong ( ) ; for ( int i = 31 ; i >= 0 ; -- i ) { int oc = 0 ; for ( long x : ar ) oc += ( ( x & ( 1 << i ) ) == 0 ? 0 : 1 ) ; if ( oc % 4 == 1 ) { p1 ( ) ; return ; } if ( oc % 4 == 3 ) { if ( ( N - oc ) % 2 == 1 ) p1 ( ) ; else p2 ( ) ; return ; } } out . println ( " DRAW " ) ; } }   }

# include < iostream > # include < algorithm > # include < string . h > # include < stdio . h > # include < math . h > # include < set > # include < map > # include < list > # include < vector > using namespace std ; typedef long long LL ; const int maxn = 1e5 + 3 ; int main ( ) { ios_base :: sync_with_stdio ( 0 ) , cin . tie ( 0 ) ;   int test ; cin >> test ; while ( test -- ) { int n ; cin >> n ;   int x = 0 ; vector < int > a ( n ) ; for ( auto & i : a ) { cin >> i ; x ^= i ; }   if ( x == 0 ) { cout << " DRAW \n " ; continue ; }   for ( int k = 30 ; k >= 0 ; -- k ) if ( x >> k & 1 )

import java . math . BigInteger ; import java . util . ArrayList ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int T = sc . nextInt ( ) ; while ( T -- > 0 ) { int n = sc . nextInt ( ) ; int v [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { v [ i ] = sc . nextInt ( ) ; } int ans = - 1 ; for ( int j = 30 ; j >= 0 ; j -- ) { int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ( v [ i ] & ( 1 << j ) ) > 0 ) cnt += 1 ; } if ( cnt % 2 == 0 ) { continue ; } int z = ( n - cnt ) % 2 ; cnt = ( cnt + 1 ) / 2 ; if ( cnt % 2 == 0 && z % 2 == 1 ) { ans = 1 ; break ; } else if ( cnt % 2 == 1 ) { ans = 1 ; break ; } ans = 0 ; break ; } String Ans = new String ( ) ; if ( ans == - 1 ) { Ans = " DRAW " ; } else if ( ans == 0 ) { Ans = " LOSE " ; } else { Ans = " WIN " ; } System . out . println ( Ans ) ; } } }

def solve ( ) : n = int ( input ( ) ) lst = list ( map ( int , input ( ) . split ( ) ) ) k = 1 while k < 10 ** 9 : k *= 2 num = 0 while k and num % 2 == 0 : num = 0 for i in lst : if i % ( k * 2 ) // k == 1 : num += 1 k //= 2 if k == 0 and num % 2 == 0 : print ( " DRAW " ) return 0 if ( num % 4 == 1 ) or ( n % 2 == 0 ) : print ( " WIN " ) else : print ( " LOSE " ) for i in range ( int ( input ( ) ) ) : solve ( ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) )   x = 0 for i in a : x ^= i if x == 0 : print ( " DRAW " ) continue if n % 2 == 0 : print ( " WIN " ) continue b = 0 while ( 1 << b ) <= x : b += 1 b -= 1 c = 0 for i in a : if ( 1 << b ) & i != 0 : c += 1 if ( ( c - 1 ) // 2 ) % 2 == 0 : print ( " WIN " ) else : print ( " LOSE " ) NEW_LINE

""" T = int ( input ( ) ) for ▁ _ ▁ in ▁ range ( 0 , T ) : ▁ ▁ ▁ ▁ n = int ( input ( ) ) ▁ ▁ ▁ ▁ a , b = map ( int , input ( ) . split ( ) ) ▁ ▁ ▁ ▁ s = input ( ) ▁ ▁ ▁ ▁ s = [ int ( x ) ▁ for ▁ x ▁ in ▁ input ( ) . split ( ) ] ▁ ▁ ▁ ▁ for ▁ i ▁ in ▁ range ( 0 , len ( s ) ) : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ a , b = map ( int , input ( ) . split ( ) ) """     T = int ( input ( ) ) for _ in range ( 0 , T ) : n = int ( input ( ) ) s = [ int ( x ) for x in input ( ) . split ( ) ] pos = [ 0 ] * 35 for i in range ( 0 , len ( s ) ) : tt = bin ( s [ i ] ) [ 2 : ] tt = '0' * ( 35 - len ( tt ) ) + tt for j in range ( 35 ) : pos [ j ] += int ( tt [ j ] )   ans = ' DRAW ' turn = 0 for i in range ( 0 , 35 ) : if ( pos [ i ] % 2 != 0 ) : if ( pos [ i ] % 4 == 3 and ( n - pos [ i ] ) % 2 == 0 ) : ans = ' LOSE ' else : ans = ' WIN '   break   print ( ans ) NEW_LINE

d = { 1 : ' WIN ' , 0 : ' LOSE ' , - 1 : ' DRAW ' }   def main ( ) : t = int ( input ( ) )   for _ in range ( t ) : n = int ( input ( ) ) a = map ( int , input ( ) . split ( ) )   f = [ 0 ] * 30   for x in a : for b in range ( 30 ) : if x >> b & 1 : f [ b ] += 1   ans = - 1 for x in reversed ( range ( 30 ) ) : if f [ x ] % 2 == 1 : ans = 0 if f [ x ] % 4 == 3 and ( n - f [ x ] ) % 2 == 0 else 1 break   print ( d [ ans ] )   main ( ) NEW_LINE


import java . util . * ; public class FedorAndNewGame { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , k = sc . nextInt ( ) ; int [ ] arr = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) arr [ i ] = sc . nextInt ( ) ; int mask = sc . nextInt ( ) ; int ans = 0 ; for ( int x : arr ) { int temp = x ^ mask ; int cnt = 0 ; for ( int i = 0 ; i < 21 ; i ++ ) { cnt += 1 & temp ; temp = temp >> 1 ; } if ( cnt <= k ) ans ++ ; } System . out . println ( ans ) ; }   }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] [ ] list = new int [ m + 1 ] [ n ] ; for ( int i = 0 ; i < m + 1 ; i ++ ) { int temp = sc . nextInt ( ) ; int count = 0 ; while ( true ) { if ( temp == 1 ) { list [ i ] [ count ] = temp ; break ; } else { list [ i ] [ count ] = temp % 2 ; temp = temp / 2 ; count ++ ; } } } int maxCnt = 0 ; for ( int i = 0 ; i < m ; i ++ ) { int curCnt = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( list [ i ] [ j ] == 1 && list [ m ] [ j ] == 0 ) || ( list [ i ] [ j ] == 0 && list [ m ] [ j ] == 1 ) ) { curCnt ++ ; } } if ( curCnt <= k ) { maxCnt ++ ; } } System . out . println ( maxCnt ) ; } }

import java . io . * ; import java . util . * ;      public class B {

from math import * from copy import * from string import * NEW_LINE

n , m , k = map ( int , input ( ) . split ( ) ) army = [ ] for i in range ( m ) : x = int ( input ( ) ) army . append ( x ) m = int ( input ( ) ) ans = 0     for i in army : uniq = bin ( m ^ i ) count = 0 for j in uniq : if j == '1' : count += 1 if count <= k : continue else : count = k + 1 break if count <= k : ans += 1 print ( ans )               NEW_LINE

def count ( y ) : s = 0 for i in y : if i == '1' : s += 1 return s         n , m , k = map ( int , input ( ) . split ( ) ) l = [ ] for i in range ( m + 1 ) : a = int ( input ( ) ) l . append ( a ) res = 0 f = l [ - 1 ]   for i in range ( m ) : x = l [ i ] y = bin ( f ^ x ) c = count ( y ) if c <= k : res += 1 print ( res )           NEW_LINE

n , m , k = map ( int , input ( ) . split ( ) ) army = [ ] for i in range ( m + 1 ) : army . append ( int ( input ( ) ) ) fed = army [ - 1 ] ans = 0 for i in range ( m ) : temp = bin ( fed ^ army [ i ] ) if temp . count ( "1" ) <= k : ans += 1 print ( ans ) NEW_LINE