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

import java . util . Scanner ;   public class B1032 {   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; char [ ] S = in . next ( ) . toCharArray ( ) ; int length = S . length ; int rows = ( length + 19 ) / 20 ; int inRow = length / rows ; int remainder = length % rows ; int colums = inRow + ( ( remainder == 0 ) ? 0 : 1 ) ; StringBuilder sb = new StringBuilder ( ) ; int pos = 0 ; for ( int row = 0 ; row < rows ; row ++ ) { for ( int i = 0 ; i < inRow ; i ++ ) { sb . append ( S [ pos ++ ] ) ; } if ( remainder != 0 ) { sb . append ( ( row < remainder ) ? S [ pos ++ ] : ' * ' ) ; } sb . append ( ' \n ' ) ; } System . out . println ( rows + " ▁ " + colums ) ; System . out . print ( sb ) ; }   }

# include < cstdio >   char s [ 110 ] ;   int main ( ) { scanf ( " % s " , s ) ; int len = 0 ; while ( ( s [ len ] >= ' a ' && s [ len ] <= ' z ' ) || ( s [ len ] >= ' A ' && s [ len ] <= ' Z ' ) ) ++ len ; int n = len / 20 , m = 20 , r = len % 20 ; if ( r == 0 ) { printf ( " % d ▁ % d \n " , n , 20 ) ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) putchar ( s [ i * m + j ] ) ; putchar ( ' \n ' ) ; } } else if ( n == 0 ) { printf ( " % d ▁ % d \n " , 1 , r ) ; for ( int i = 0 ; i < len ; ++ i ) putchar ( s [ i ] ) ; } else { m -= ( 20 - r ) / ( n + 1 ) ; r = ( 20 - r ) % ( n + 1 ) ; ++ n ; printf ( " % d ▁ % d \n " , n , m ) ; int index = 0 ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { if ( j == m - 1 && i > ( n - r ) - 1 ) putchar ( ' * ' ) ; else { putchar ( s [ index ] ) ; ++ index ; } } putchar ( ' \n ' ) ; } } }

from math import * name = input ( ) n = len ( name )   if n <= 20 : print ( 1 , n ) print ( name ) exit ( 0 )   rows = [ ]   rows_amount = 2 while n / rows_amount > 20 : rows_amount += 1     cutted = ceil ( n / rows_amount ) print ( rows_amount , cutted )   i = 0 start = 0 ostatok = n % rows_amount if n % rows_amount != 0 else rows_amountwhile i < rows_amount - ( rows_amount - ostatok ) : start = i * cutted rows . append ( name [ start : ( start + cutted ) ] ) i += 1   start += cuttedcutted -= 1 while i < rows_amount : rows . append ( name [ start : ( start + cutted ) ] ) rows [ - 1 ] += " * " i += 1 start += cutted     for j in rows : print ( j ) NEW_LINE

from math import * name = input ( ) n = len ( name )   if n <= 20 : print ( 1 , n ) print ( name ) exit ( 0 )   rows = [ ]   rows_amount = 2 while n / rows_amount > 20 : rows_amount += 1     cutted = ceil ( n / rows_amount ) print ( rows_amount , cutted )   i = 0 start = 0 ostatok = n % rows_amount if n % rows_amount != 0 else rows_amountwhile i < rows_amount - ( rows_amount - ostatok ) : rows . append ( name [ start : ( start + cutted ) ] ) i += 1 start += cutted   cutted -= 1 while i < rows_amount : rows . append ( name [ start : ( start + cutted ) ] ) rows [ - 1 ] += " * " i += 1 start += cutted     for j in rows : print ( j ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Main { public static void main ( String [ ] args ) {   Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ;

import java . util . Scanner ;   public class Problem1155B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; int count = 0 ; int toRemove = n - 11 ; int vasya = toRemove / 2 ; int petya = toRemove / 2 ; for ( int i = 0 ; i < n - 10 ; i ++ ) { if ( s . charAt ( i ) == '8' ) { count ++ ; } } if ( count - ( petya ) > 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

import java . util . Scanner ;   public class GamewithelephoneNumbers {   public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; String s = scan . next ( ) ; int k = n - 11 ; k /= 2 ; int p = 0 ; for ( int i = 0 ; i <= n - 11 ; i ++ ) { if ( s . charAt ( i ) == '8' ) { ++ p ; } } if ( p > k ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } }   }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Game_Tele { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } public static void main ( String [ ] args ) { FastReader in = new FastReader ( ) ; int n = in . nextInt ( ) ; String s = in . nextLine ( ) ; int c = 0 ; for ( int i = 0 ; i <= ( n - 11 ) ; i ++ ) { if ( s . charAt ( i ) == '8' ) { c ++ ; } }

import java . util . * ; public class telephone { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int chancePetya = ( n - 11 ) / 2 ; int count8 = 0 ; int b = 0 ; for ( int i = 0 ; i <= n - 1 ; i ++ ) { if ( s . charAt ( i ) == '8' ) count8 ++ ; else b ++ ; if ( count8 > chancePetya ) break ; } if ( count8 <= chancePetya ) System . out . println ( " NO " ) ; else if ( b <= chancePetya ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

import sys , mathfrom collections import defaultdict , dequeinput = sys . stdin . readline       n = int ( input ( ) ) s = input ( ) . strip ( ) moves = n - 11 NEW_LINE

n = int ( input ( ) ) nn = neight = [ ] rest = [ ] s = list ( input ( ) ) for i in range ( n ) : if s [ i ] == "8" : eight . append ( i ) else : rest . append ( i ) lst = eight + rest [ : : - 1 ] i = 0 left = 1 right = 0 while n > 11 : n -= 1 if i == 0 : s [ lst [ - left ] ] = " " left += 1 i = 1 else : s [ lst [ right ] ] = " " right += 1 i = 0 ans = " " for i in range ( nn ) : ans += s [ i ] if ans [ 0 ] == "8" : print ( " YES " ) else : print ( " NO " ) NEW_LINE

n = int ( input ( ) ) s = input ( ) ; flag = True ; cnt = 0 for i in range ( 0 , n - 10 , 2 ) : NEW_LINE


import java . util . * ; import java . lang . * ; import java . io . * ;   public class Ideone { public static void main ( String [ ] args ) throws java . lang . Exception { long M = 1000000007 ; long res = 1 ; Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; for ( int i = 0 ; i < k - 1 ; i ++ ) res = ( res * k ) % M ; for ( int i = 0 ; i < n - k ; i ++ ) res = ( res * ( n - k ) ) % M ; System . out . println ( res ) ; } }

n , k = map ( int , input ( ) . split ( ' ▁ ' ) ) print ( k ** ( k - 1 ) * ( n - k ) ** ( n - k ) % int ( 1e9 + 7 ) ) NEW_LINE

mod = 10 ** 9 + 7 def power ( x , a ) : if ( a == 0 ) : return ( 1 ) z = power ( x , a // 2 ) z = ( z * z ) % mod if ( a % 2 ) : z = ( z * x ) % mod return ( z ) [ n , k ] = list ( map ( int , input ( ) . split ( ) ) ) print ( ( power ( n - k , n - k ) * power ( k , k - 1 ) ) % mod ) NEW_LINE

import sys , math , heapq , copyfrom collections import defaultdict , dequefrom bisect import bisect_left , bisect_rightfrom functools import cmp_to_keyfrom itertools import permutations , combinations , combinations_with_replacement NEW_LINE

import sysread = lambda : sys . stdin . readline ( ) . strip ( ) readi = lambda : map ( int , read ( ) . split ( ) ) from collections import *   n , k = readi ( ) mod = 10 ** 9 + 7 ans = 1   for i in range ( 1 , k ) : ans = ( ans * k ) % mod   for _ in range ( n - k ) : ans = ( ans * ( n - k ) ) % mod   print ( ans ) NEW_LINE

n , k = [ int ( x ) for x in input ( ) . split ( ) ] ans = ( ( n - k ) ** ( n - k ) ) * ( ( k ) ** ( k - 1 ) ) % ( 10 ** 9 + 7 ) print ( ans ) NEW_LINE


import java . io . DataInputStream ; import java . io . FileInputStream ; import java . io . IOException ;   public class EpicGame { public static void main ( String [ ] args ) throws IOException { FastReader reader = new FastReader ( ) ; int a = reader . nextInt ( ) ; int b = reader . nextInt ( ) ; int heap = reader . nextInt ( ) ;   int turn = 0 ; while ( true ) { int itemsToRemove ; if ( turn % 2 == 0 ) { itemsToRemove = gcd ( a , heap ) ; } else { itemsToRemove = gcd ( b , heap ) ; }   if ( heap > 0 ) { heap -= itemsToRemove ; turn ++ ; } else { System . out . println ( ( turn + 1 ) % 2 ) ; break ; } } }   private static int gcd ( int a , int b ) { if ( a == 0 ) { return b ; }   return gcd ( b % a , a ) ; }    static class FastReader { final private int BUFFER_SIZE = 1 << 16 ; private DataInputStream din ; private byte [ ] buffer ; private int bufferPointer , bytesRead ;   public FastReader ( ) { din = new DataInputStream ( System . in ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public FastReader ( String file_name ) throws IOException { din = new DataInputStream ( new FileInputStream ( file_name ) ) ; buffer = new byte [ BUFFER_SIZE ] ; bufferPointer = bytesRead = 0 ; }   public String readLine ( ) throws IOException { byte [ ] buf = new byte [ 64 ] ;

import java . util . Scanner ;   public class CodeForces { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; while ( n >= 0 ) { n = n - gcd ( a , n ) ; if ( n < 0 ) { System . out . println ( 1 ) ; break ; } n = n - gcd ( b , n ) ; if ( n < 0 ) { System . out . println ( 0 ) ; }   }   } private static int gcd ( int a , int b ) { if ( b == 0 ) return a ; else return gcd ( b , a % b ) ; } }

import java . util . Scanner ; public class question { static int gcd ( int a , int b ) { int dividend = a > b ? a : b ; int divisor = a < b ? a : b ; int rem = 1 ; if ( a == 0 || b == 0 ) return dividend ; while ( rem != 0 ) { rem = dividend % divisor ; dividend = divisor ; if ( rem == 0 ) break ; divisor = rem ; } return divisor ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; while ( true ) { if ( n == 0 ) { System . out . println ( 1 ) ; break ; } n = n - gcd ( a , n ) ;   if ( n == 0 ) { System . out . println ( 0 ) ; break ; } n = n - gcd ( b , n ) ; } } }

a , b , n = map ( int , input ( ) . split ( ) )   def gcd ( a , b ) : if b == 0 : return a else : return gcd ( b , a % b )   temp2 = True   while n > 0 : n -= gcd ( a , n ) if n <= 0 : temp2 = False break n -= gcd ( b , n ) 	   if temp2 != True : print ( 0 ) else : print ( 1 ) 	   NEW_LINE

import matha , b , n = map ( int , input ( ) . split ( ) ) i = 0 while math . gcd ( a , n ) <= n or math . gcd ( b , n ) <= n : if i % 2 == 0 : g = math . gcd ( a , n ) n = n - g else : g = math . gcd ( b , n ) n = n - g i = i + 1 if i % 2 == 1 : print ( 0 ) else : print ( 1 ) NEW_LINE

import matha , b , n = list ( map ( int , input ( ) . split ( ) ) ) c = 0 while n >= 0 :   if ( n != 0 ) : x = math . gcd ( a , n ) n = n - x c = 1 if ( n != 0 ) : y = math . gcd ( b , n ) n = n - y c = 2 if ( n == 0 ) : break   if ( c == 1 ) : print ( "0" ) else : print ( "1" )   NEW_LINE

import math * a , n = map ( int , input ( ) . split ( ) ) i = 0 while n >= 0 : n -= math . gcd ( a [ i ] , n ) i = 1 - iprint ( i ) NEW_LINE


import java . util . * ; public class FriendsPresents275B {   public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int cnt1 = s . nextInt ( ) ; int cnt2 = s . nextInt ( ) ; int x = s . nextInt ( ) ; int y = s . nextInt ( ) ; long l = 0 ; long r = ( long ) 1e10 ; long mid = 0l ; long ans = 0l ; while ( l <= r ) { mid = l + ( r - l ) / 2 ; long forone = mid - mid / x ; long fortwo = mid - mid / y ; long onlyone = mid / x + mid / y - mid / ( x * y ) ; long sub = mid - onlyone ; if ( forone >= cnt1 && fortwo >= cnt2 && forone + fortwo - sub >= cnt1 + cnt2 ) { ans = mid ; r = mid - 1 ; } else l = mid + 1 ; } System . out . println ( ans ) ; }   }

import java . util . * ; public class ProB { static long a , b , x , y , ans , l , r , mid ;   public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; a = in . nextInt ( ) ; b = in . nextInt ( ) ; x = in . nextInt ( ) ; y = in . nextInt ( ) ; l = 1 ; r = 10000000000l ; while ( l <= r ) { mid = ( l + r ) / 2 ; if ( mid - mid / x >= a && mid - mid / y >= b && mid - mid / x / y >= a + b ) { ans = mid ; r = mid - 1 ; } else l = mid + 1 ; } System . out . println ( ans ) ; } }

import java . awt . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   public class Main {   public static void main ( String agr [ ] ) throws Exception { FastReader sc = new FastReader ( ) ; long cnt1 = sc . nextInt ( ) , cnt2 = sc . nextInt ( ) , x = sc . nextInt ( ) , y = sc . nextInt ( ) ; long l = 1 , hi = ( long ) 1e12 ; long ans1 = - 1 ; while ( l <= hi ) { long mid = l + ( hi - l ) / 2 ; if ( cnt1 > ( mid - ( mid / x ) ) || cnt2 > ( mid - ( mid / y ) ) || ( mid - ( mid / ( x * y ) ) < cnt1 + cnt2 ) ) { l = mid + 1 ; } else { ans1 = mid ; hi = mid - 1 ; }

import mathu , v , x , y = map ( int , input ( ) . split ( ) ) z = x * y // math . gcd ( x , y ) def check ( ans ) : inter = ans - ans // x - ans // y + ans // z fx = ans // y - ans // z fy = ans // x - ans // z if fx + inter < u : return False if fy + inter < v : return False if fx + fy + inter < u + v : return False return Trueans = 0 for i in range ( 31 , - 1 , - 1 ) : if not check ( ans + 2 ** i ) : ans += 2 ** iprint ( ans + 1 ) NEW_LINE

def Solve ( n , m , sum ) : cnt = int ( sum / x / y ) if x == y : cnt = int ( sum / x ) n = max ( 0 , n - int ( sum / y ) + cnt ) m = max ( 0 , m - int ( sum / x ) + cnt ) if ( sum - int ( sum / x ) - int ( sum / y ) + cnt >= n + m ) : tmp = 0 else : tmp = m + n - ( sum - int ( sum / x ) - int ( sum / y ) + cnt ) NEW_LINE

c1 , c2 , x , y = map ( int , input ( ) . split ( ) )   def valid ( m ) : a = m - m // x b = m - m // y - max ( 0 , c1 - m // y + m // x // y ) return a >= c1 and b >= c2     l , r = 0 , ( 1 << 62 ) while l + 1 < r : m = l + r >> 1 if valid ( m ) : r = m else : l = mprint ( r ) NEW_LINE

c1 , c2 , x , y = map ( int , input ( ) . split ( ) ) def poss ( v ) : global c1 , c2 , x , y divbyx = v // x divbyy = v // y divbyxy = v // ( x * y ) cc1 = c2 - divbyx + divbyxy cc2 = c1 - divbyy + divbyxy cc1 = max ( cc1 , 0 ) cc2 = max ( cc2 , 0 ) remaining = v - divbyx - divbyy + divbyxy NEW_LINE

c1 , c2 , x , y = map ( int , input ( ) . split ( ) ) l = c1 + c2temp = lh = pow ( 10 , 10 ) while ( l < h ) : ans = ( l + h ) // 2 if ( c1 > ans - ans // x ) or ( c2 > ans - ans // y ) or ( temp > ans - ans // ( x * y ) ) : l = ans + 1 else : h = ansprint ( l ) NEW_LINE


import java . util . Scanner ;   public class A599 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int d1 = scanner . nextInt ( ) , d2 = scanner . nextInt ( ) , d3 = scanner . nextInt ( ) ;   int a [ ] = { ( 2 * d1 + 2 * d2 ) , ( 2 * d1 + 2 * d3 ) , ( 2 * d2 + 2 * d3 ) , ( d1 + d2 + d3 ) } ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < a . length ; i ++ ) {   if ( a [ i ] < min ) min = a [ i ] ;

import java . util . * ; import static java . lang . Math . min ; import static java . lang . Math . max ;   public class Test { public static void main ( String [ ] args ) throws Exception {   Scanner input = new Scanner ( System . in ) ; int d1 = input . nextInt ( ) ; int d2 = input . nextInt ( ) ; int d3 = input . nextInt ( ) ;   System . out . println ( min ( d1 , d2 ) + min ( d1 + d2 , d3 ) + min ( max ( d1 , d2 ) , d3 + min ( d1 , d2 ) ) ) ; } }

import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; long d1 = scanner . nextLong ( ) , d2 = scanner . nextLong ( ) , d3 = scanner . nextLong ( ) ; long path1 = 2 * d1 + 2 * d2 , path2 = 2 * d1 + 2 * d3 , path3 = 2 * d2 + 2 * d3 , path4 = d1 + d2 + d3 ; System . out . println ( Math . min ( Math . min ( path1 , path2 ) , Math . min ( path3 , path4 ) ) ) ; } }

import java . util . Scanner ;   public class Patrick { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int d1 = scanner . nextInt ( ) ; int d2 = scanner . nextInt ( ) ; int d3 = scanner . nextInt ( ) ;   int max = Math . max ( Math . max ( d1 , d2 ) , d3 ) ;   int i = d1 + d2 + d3 - max ;   if ( d1 + d2 + d3 < i * 2 ) { System . out . println ( d1 + d2 + d3 ) ; } else { System . out . println ( i * 2 ) ; } } }

a , b , c = map ( int , input ( ) . split ( ) ) x = a + b + cy = 2 * a + 2 * bz = 2 * a + 2 * cw = 2 * b + 2 * cprint ( min ( x , y , z , w ) ) NEW_LINE

a , b , c = map ( int , input ( ) . split ( ) ) print ( min ( 2 * ( a + b ) , 2 * ( a + c ) , 2 * ( b + c ) , a + b + c ) ) NEW_LINE


import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; StringBuilder s = new StringBuilder ( input . next ( ) + " ▁ " ) ; int i = 0 ; while ( i < s . length ( ) ) { StringBuilder newS = new StringBuilder ( s ) ; for ( char j = ' a ' ; j <= ' z ' ; j ++ ) { newS . insert ( i , j ) ; String send = newS . toString ( ) . trim ( ) ; boolean ch = check ( send ) ;

import java . util . Scanner ;   public class test02 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . nextLine ( ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { String temp = s . substring ( 0 , i ) ; String temp2 = s . substring ( i ) ; String la = " abcdefghijklmnopqrstuvwxyz " ;

import java . util . * ; import java . math . * ; import java . io . * ;   public class MakePalindrom {   public static void main ( String [ ] args ) throws Exception { Scanner pm = new Scanner ( System . in ) ; int [ ] hash = new int [ 26 ] ; String s = pm . next ( ) ; int k = s . length ( ) ; StringBuffer sb = new StringBuffer ( s ) ; if ( k == 1 ) { System . out . println ( sb . append ( sb ) ) ; return ; } for ( int i = 0 ; i < k ; i ++ ) { int po = ( int ) s . charAt ( i ) - 97 ; hash [ po ] ++ ;

s = input ( ) n = len ( s ) f = Falsefor i in range ( len ( s ) // 2 ) : if s [ i ] != s [ n - 1 - i ] : o = s [ : n - i ] + s [ i ] + s [ n - i : ] p = s [ : i ] + s [ n - i - 1 ] + s [ i : ] f = True   if o == o [ : : - 1 ] : print ( o ) elif p == p [ : : - 1 ] : print ( p ) else : print ( " NA " ) break     if not f : if n % 2 == 0 : print ( s [ : n // 2 ] + ' y ' + s [ n // 2 : ] ) else : x = s [ n // 2 ] print ( s [ : n // 2 ] + x + s [ n // 2 : ] ) NEW_LINE

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

s = input ( ) l = len ( s ) a = ' abcdefghijklmnopqrstuvwxyz ' for i in range ( len ( a ) ) : for j in range ( l + 1 ) : x = s [ : j ] + a [ i ] + s [ j : ] if x == x [ : : - 1 ] : print ( x ) exit ( ) else : print ( " NA " ) NEW_LINE


import java . util . Scanner ;   public class _0856ExercisingWalk {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { int left = sc . nextInt ( ) ; int right = sc . nextInt ( ) ; int down = sc . nextInt ( ) ; int up = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int x1 = sc . nextInt ( ) ; int y1 = sc . nextInt ( ) ; int x2 = sc . nextInt ( ) ; int y2 = sc . nextInt ( ) ; x += right - left ; y += up - down ; if ( left + right > 0 && x1 == x2 ) { System . out . println ( " NO " ) ; } else if ( up + down > 0 && y1 == y2 ) { System . out . println ( " NO " ) ; } else if ( x <= x2 && x >= x1 && y <= y2 && y >= y1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } t -- ; } }   }

import java . awt . * ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { static int countSubstrings ( String s ) { int n = s . length ( ) ; int dp [ ] [ ] = new int [ 1001 ] [ 1001 ] ; for ( int i = 0 ; i < n ; i ++ ) { dp [ i ] [ i ] = 1 ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { dp [ i ] [ i + 1 ] = 1 ; } } for ( int d = 2 ; d < n ; d ++ ) { int i = 0 , j = d ; while ( j < n ) { if ( s . charAt ( i ) == s . charAt ( j ) && dp [ i + 1 ] [ j - 1 ] == 1 ) { dp [ i ] [ j ] = 1 ; } else dp [ i ] [ j ] = 0 ; i ++ ; j ++ ; } } int count = 0 ; for ( int i = 0 ; i < 1001 ; i ++ ) { for ( int j = 0 ; j < 1001 ; j ++ ) { if ( dp [ i ] [ j ] == 1 ) count ++ ; } } return count ; } public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ;

import java . util . * ;    public class ExercisingWalk { public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ;   int test = input . nextInt ( ) ;    int a = 0 ; int b = 0 ; int c = 0 ; int d = 0 ; int x = 0 ; int y = 0 ; int x1 = 0 ; int y1 = 0 ; int x2 = 0 ; int y2 = 0 ; int sumV = 0 ; int sumH = 0 ; for ( int t = 0 ; t < test ; t ++ ) { a = input . nextInt ( ) ; b = input . nextInt ( ) ; c = input . nextInt ( ) ; d = input . nextInt ( ) ; x = input . nextInt ( ) ; y = input . nextInt ( ) ; x1 = input . nextInt ( ) ; y1 = input . nextInt ( ) ; x2 = input . nextInt ( ) ; y2 = input . nextInt ( ) ; String answer = " Yes " ;   sumV = d - c ; sumH = b - a ;   if ( x1 == x2 && a + b > 0 ) { answer = " No " ; } if ( y1 == y2 && c + d > 0 ) { answer = " No " ; } if ( sumV != 0 ) { if ( sumV > 0 ) { if ( y + sumV > y2 ) { answer = " No " ; } } else if ( sumV < 0 ) { if ( y + sumV < y1 ) { answer = " No " ; } } } if ( sumH != 0 ) { if ( sumH > 0 ) { if ( x + sumH > x2 ) { answer = " No " ; } } else if ( sumH < 0 ) { if ( x + sumH < x1 ) { answer = " No " ; } } }    System . out . println ( answer ) ;     } } }

def q1332a ( ) : num_cases = int ( input ( ) ) for _ in range ( num_cases ) : a , b , c , d = tuple ( [ int ( num ) for num in input ( ) . split ( ) ] ) x , y , x1 , y1 , x2 , y2 = tuple ( [ int ( num ) for num in input ( ) . split ( ) ] ) subproblem ( a , b , c , d , x , y , x1 , y1 , x2 , y2 )   def subproblem ( a , b , c , d , x , y , x1 , y1 , x2 , y2 ) : move_x = b - a NEW_LINE

for iii in range ( int ( input ( ) ) ) : a , b , c , d = map ( int , input ( ) . split ( ) ) x , y , x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) if ( x1 <= x - a + b <= x2 ) and ( y1 <= y - c + d <= y2 ) and ( x2 > x1 or a + b == 0 ) and ( y2 > y1 or c + d == 0 ) : print ( " YES " ) else : print ( " NO " ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : l , r , d , u = map ( int , input ( ) . split ( ) ) x , y , x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) x += r - l y += u - d   if l + r > 0 and x1 == x2 : print ( ' No ' ) elif u + d > 0 and y1 == y2 : print ( ' No ' ) elif x1 <= x <= x2 and y1 <= y <= y2 : print ( ' Yes ' ) else : print ( ' No ' ) NEW_LINE

import sysinput = sys . stdin . readlinefrom collections import defaultdict as dcfrom collections import Counterfrom bisect import bisect_right , bisect_leftimport mathfrom operator import itemgetterfrom heapq import heapify , heappop , heappushfrom queue import PriorityQueue as pqfor _ in range ( int ( input ( ) ) ) : a , b , c , d = map ( int , input ( ) . split ( ) ) x , y , x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) p , q = x , y if a >= b : p = p - ( a - b ) else : p = p + b - a if c >= d : q = q - ( c - d ) else : q = q + d - c f = 0 if ( b == 0 or ( b > 0 and x + 1 >= x1 and x + 1 <= x2 ) ) or ( a == 0 or ( a > 0 and x - 1 >= x1 and x - 1 <= x2 ) ) : if ( d == 0 or ( d > 0 and y + 1 >= y1 and y + 1 <= y2 ) ) or ( c == 0 or ( c > 0 and y - 1 >= y1 and y - 1 <= y2 ) ) : f = 1 if f == 1 and p >= x1 and p <= x2 and q >= y1 and q <= y2 : print ( " Yes " ) else : print ( " No " ) NEW_LINE

t = int ( input ( ) ) while t > 0 : a , b , c , d = map ( int , input ( ) . split ( ) ) x , y , x1 , y1 , x2 , y2 = map ( int , input ( ) . split ( ) ) x = x + ( b - a ) y = y + ( d - c ) if abs ( a + b ) > 0 and x1 == x2 : print ( " NO " ) elif abs ( c + d ) > 0 and y1 == y2 : print ( " NO " ) elif x1 <= x <= x2 and y1 <= y <= y2 : print ( " Yes " ) else : print ( " NO " ) NEW_LINE


import java . util . * ; import java . io . * ; import java . lang . Math ;    public class A { static int INF = - 2_000_000_000 ; static long MOD = 1_000_000_007 ; public static void main ( String args [ ] ) { FastScanner fs = new FastScanner ( ) ; int t = fs . nextInt ( ) ; for ( int test_case = 1 ; test_case <= t ; ++ test_case ) { long n = fs . nextInt ( ) , k = fs . nextInt ( ) ; if ( n % 2 != k % 2 || k > n || k * k > n ) { System . out . println ( " NO " ) ; } else {

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

import java . util . Scanner ;   public class _0838SumofOddIntegers {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; if ( k % 2 == 0 && n % 2 == 0 || k % 2 != 0 && n % 2 != 0 ) { if ( k * k <= n ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } else { System . out . println ( " NO " ) ; } t -- ; } }   }

import java . util . * ; import java . io . * ; import java . lang . Math ;    public class A { static int INF = - 2_000_000_000 ; static long MOD = 1_000_000_007 ; public static void main ( String args [ ] ) { FastScanner fs = new FastScanner ( ) ; int t = fs . nextInt ( ) ; for ( int test_case = 1 ; test_case <= t ; ++ test_case ) { long n = fs . nextInt ( ) , k = fs . nextInt ( ) ; if ( ! ( ( n & ( long ) 1 ) == ( k & ( long ) 1 ) ) || k > n || k * k > n ) { System . out . println ( " NO " ) ; } else {

import sysdef get_ints ( ) : return map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) for i in range ( int ( input ( ) ) ) : n , k = get_ints ( ) if ( k ** 2 > n ) or ( k % 2 != n % 2 ) : print ( " NO " ) else : print ( " yes " )   NEW_LINE

for i in range ( int ( input ( ) ) ) : n , k = map ( int , input ( ) . split ( ) ) if k % 2 == n % 2 and n >= k * k : print ( " YES " ) else : print ( " NO " ) NEW_LINE

t = int ( input ( ) ) for _ in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) s = ( 1 + ( 1 + 2 * ( k - 1 ) ) ) * k / 2 if s <= n : if k % 2 == 1 and n % 2 == 1 : print ( ' YES ' ) elif k % 2 == 0 and n % 2 == 0 : print ( ' YES ' ) else : print ( ' NO ' ) else : print ( " NO " ) NEW_LINE


import java . util . * ; public class B_Array_Walk { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int q = sc . nextInt ( ) ; while ( q -- > 0 ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int z = sc . nextInt ( ) ; int ar [ ] = new int [ n ] ; int i = 0 ; for ( i = 0 ; i < n ; i ++ ) { ar [ i ] = sc . nextInt ( ) ; } long ans = 0 ; for ( int t = 0 ; t <= z ; t ++ ) { int pos = k - 2 * t ; if ( pos < 0 ) continue ; long s = 0 ; long max = 0 ; for ( i = 0 ; i <= pos ; i ++ ) { if ( i != n - 1 ) { max = Math . max ( max , ( long ) ( ar [ i ] + ar [ i + 1 ] ) ) ; } s += ar [ i ] ; } s += ( t ) * max ; ans = Math . max ( ans , s ) ; } System . out . println ( ans ) ; } } }

import math , sys , bisect , heapq , os NEW_LINE from collections import defaultdict , Counter , deque NEW_LINE from itertools import groupby , accumulate NEW_LINE from functools import lru_cache NEW_LINE int1 = lambda x : int ( x ) - 1 NEW_LINE def input ( ) : return sys . stdin . readline ( ) . rstrip ( ' \n ' ) NEW_LINE aj = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def list3d ( a , b , c , d ) : return [ [ [ d ] * c for j in range ( b ) ] for i in range ( a ) ] NEW_LINE def Y ( c ) : print ( [ " NO " , " YES " ] [ c ] ) NEW_LINE def y ( c ) : print ( [ " no " , " yes " ] [ c ] ) NEW_LINE def Yy ( c ) : print ( [ " No " , " Yes " ] [ c ] ) NEW_LINE def solve ( ) : NEW_LINE INDENT for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT n , k , z = aj ( ) NEW_LINE A = aj ( ) NEW_LINE B = list ( accumulate ( A ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT if i <= k : NEW_LINE INDENT temp = B [ i ] NEW_LINE back = min ( z , math . ceil ( ( k - i ) / 2 ) ) NEW_LINE temp += back * A [ i - 1 ] NEW_LINE forw = max ( 0 , back - 1 ) NEW_LINE temp += forw * A [ i ] NEW_LINE rem = max ( 0 , k - i - forw - back ) NEW_LINE if back : NEW_LINE INDENT temp += B [ i + rem - 1 ] - B [ i - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT temp += B [ i + rem ] - B [ i ] NEW_LINE DEDENT ans = max ( ans , temp ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT DEDENT try : NEW_LINE INDENT sys . stdin = open ( ' input . txt ' , ' r ' ) NEW_LINE sys . stdout = open ( ' output . txt ' , ' w ' ) NEW_LINE DEDENT except : NEW_LINE INDENT pass NEW_LINE DEDENT solve ( ) NEW_LINE

import sys NEW_LINE for _ in range ( int ( sys . stdin . readline ( ) ) ) : NEW_LINE INDENT n , k , z = map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE a = [ int ( i ) for i in sys . stdin . readline ( ) . split ( ) ] NEW_LINE prefix_sums = [ a [ 0 ] ] NEW_LINE for a_i in a [ 1 : ] : NEW_LINE INDENT prefix_sums . append ( prefix_sums [ - 1 ] + a_i ) NEW_LINE DEDENT if z == 0 : NEW_LINE INDENT print ( sum ( a [ : k + 1 ] ) ) NEW_LINE DEDENT else : NEW_LINE INDENT max_score = a [ 0 ] NEW_LINE for ind in range ( 1 , n ) : NEW_LINE INDENT if k == 0 : NEW_LINE INDENT break NEW_LINE DEDENT local_max_score = prefix_sums [ ind ] NEW_LINE local_k = k - 1 NEW_LINE local_z = z NEW_LINE flag = 0 NEW_LINE while local_k != 0 and local_z != 0 : NEW_LINE INDENT if flag == 0 : NEW_LINE INDENT local_max_score += a [ ind - 1 ] NEW_LINE flag = 1 NEW_LINE local_z -= 1 NEW_LINE DEDENT else : NEW_LINE INDENT local_max_score += a [ ind ] NEW_LINE flag = 0 NEW_LINE DEDENT local_k -= 1 NEW_LINE DEDENT if local_k == local_z == 0 : NEW_LINE INDENT max_score = max ( max_score , local_max_score ) NEW_LINE DEDENT elif local_k == 0 : NEW_LINE INDENT max_score = max ( max_score , local_max_score ) NEW_LINE DEDENT elif local_z == 0 : NEW_LINE INDENT local_max_score += ( prefix_sums [ ind - 1 + local_k ] - prefix_sums [ ind - 1 ] ) NEW_LINE max_score = max ( max_score , local_max_score ) NEW_LINE DEDENT k -= 1 NEW_LINE DEDENT print ( max_score ) NEW_LINE DEDENT DEDENT

for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT n , k , z = map ( int , input ( ) . split ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE pref = [ 0 ] * n NEW_LINE pref [ 0 ] = arr [ 0 ] NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT pref [ i ] = pref [ i - 1 ] + arr [ i ] NEW_LINE DEDENT ans = pref [ k ] NEW_LINE for i in range ( 1 , k ) : NEW_LINE INDENT curr = 0 NEW_LINE neg = z NEW_LINE x = k - i NEW_LINE curr = pref [ i ] NEW_LINE j = i NEW_LINE f = - 1 NEW_LINE while neg and x : NEW_LINE INDENT if f == - 1 : NEW_LINE INDENT j -= 1 NEW_LINE curr += arr [ j ] NEW_LINE neg -= 1 NEW_LINE x -= 1 NEW_LINE f = 1 NEW_LINE DEDENT elif f == 1 : NEW_LINE INDENT j += 1 NEW_LINE curr += arr [ j ] NEW_LINE x -= 1 NEW_LINE f = - 1 NEW_LINE DEDENT DEDENT if x : NEW_LINE INDENT curr += ( pref [ j + x ] - pref [ j ] ) NEW_LINE DEDENT ans = max ( ans , curr ) NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT

t = int ( input ( ) ) NEW_LINE for test in range ( t ) : NEW_LINE INDENT n , k , z = map ( int , input ( ) . split ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE dp = [ [ [ 0 , 0 ] for i in range ( z + 1 ) ] for j in range ( n ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] = arr [ 0 ] NEW_LINE m = 0 NEW_LINE for j in range ( z + 1 ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT if i > 0 : NEW_LINE INDENT dp [ i ] [ j ] = [ arr [ i ] + dp [ i - 1 ] [ j ] [ 0 ] , dp [ i - 1 ] [ j ] [ 1 ] + 1 ] NEW_LINE DEDENT if i < n - 1 and j > 0 and dp [ i ] [ j - 1 ] [ 0 ] + arr [ i + 1 ] + arr [ i ] > dp [ i ] [ j ] [ 0 ] : NEW_LINE INDENT dp [ i ] [ j ] = [ dp [ i ] [ j - 1 ] [ 0 ] + arr [ i + 1 ] + arr [ i ] , dp [ i + 1 ] [ j - 1 ] [ 1 ] + 1 ] NEW_LINE DEDENT if dp [ i ] [ j ] [ 1 ] == k : NEW_LINE INDENT m = max ( m , dp [ i ] [ j ] [ 0 ] ) NEW_LINE DEDENT DEDENT DEDENT print ( m ) NEW_LINE DEDENT

for _ in range ( int ( input ( ) ) ) : NEW_LINE INDENT n , k , z = map ( int , input ( ) . split ( ) ) NEW_LINE arr = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE pairSum = [ [ i , i + 1 ] for i in range ( n - 1 ) ] NEW_LINE pairSum . sort ( key = lambda x : arr [ x [ 0 ] ] + arr [ x [ 1 ] ] ) NEW_LINE sumUptoK = sum ( arr [ : k + 1 ] ) NEW_LINE ans = sumUptoK NEW_LINE for leftMoves in range ( 1 , z + 1 ) : NEW_LINE INDENT if k < 2 : NEW_LINE INDENT break NEW_LINE DEDENT sumUptoK -= arr [ k ] + arr [ k - 1 ] NEW_LINE k -= 2 NEW_LINE temp = sumUptoK NEW_LINE while True : NEW_LINE INDENT if not pairSum : NEW_LINE INDENT break NEW_LINE DEDENT if pairSum [ - 1 ] [ 1 ] <= k + 1 : NEW_LINE INDENT ans = max ( ans , sumUptoK + ( arr [ pairSum [ - 1 ] [ 0 ] ] + arr [ pairSum [ - 1 ] [ 1 ] ] ) * leftMoves ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT pairSum . pop ( ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE DEDENT


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

import java . util . Scanner ;   public class _0849SequentialNim {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t > 0 ) { int n = sc . nextInt ( ) ; int k = 0 ; int hype = 0 ; boolean allone = true ; int [ ] arr = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { int temp = arr [ i ] ; if ( temp == 1 ) { k ++ ; } else { break ; } } System . out . println ( ( k == n ) ^ ! ( k % 2 == 0 ) ? " Second " : " First " ) ; t -- ; } }   }

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 ; FastI in = new FastI ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BSequentialNim solver = new BSequentialNim ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class BSequentialNim { public void solve ( int testNumber , FastI sc , PrintWriter out ) { int t = sc . nextInt ( ) ; while ( t > 0 ) { t -- ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int cnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == 1 ) { cnt ++ ; } else { break ; } } if ( cnt == n ) { if ( cnt % 2 == 0 ) { out . println ( " Second " ) ; } else { out . println ( " First " ) ; } } else { if ( cnt % 2 == 0 ) { out . println ( " First " ) ; } else { out . println ( " Second " ) ; } } } }   }   static class FastI { BufferedReader br ; StringTokenizer st ;   public FastI ( 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 . math . * ; import java . util . * ; import java . io . * ; public class gr13b {

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) + [ 0 ] ans , i = [ ' First ' , ' Second ' ] , 0 while ( a [ i ] == 1 ) : i += 1 if i == n : i += 1 print ( ans [ i % 2 ] ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) s = sum ( l ) if s == n and n % 2 : print ( " First " ) elif s == n and n % 2 == 0 : print ( " Second " ) else : w = 0 for i in l : if i == 1 : w = 1 - w else : break if w == 0 : print ( " First " ) else : print ( " Second " ) NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) c = 0 for i in range ( n ) : if ( l [ i ] == 1 ) : c += 1 else : break if ( c == n ) : if ( c % 2 == 0 ) : print ( " Second " ) else : print ( " First " ) elif ( c % 2 != 0 ) : print ( " Second " ) else : print ( " First " )                           NEW_LINE

for _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) arr = [ int ( x ) for x in input ( ) . split ( ) ] k = 0 while k < n and arr [ k ] == 1 : k += 1 if ( k % 2 == 1 ) : if n == k : print ( " First " ) else : print ( " Second " ) else : if n == k : print ( " Second " ) else : print ( " First " ) NEW_LINE


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

import java . util . * ; import java . io . * ;   public class Div2_310B { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] array = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) array [ i ] = sc . nextInt ( ) ; boolean flag = true ; for ( int i = 1 ; i < n ; i ++ ) if ( array [ i ] != array [ i - 1 ] + 1 ) { flag = false ; break ; } for ( int k = 0 ; k < n - 1 ; k ++ ) { array [ 0 ] = ( array [ 0 ] + 1 ) % n ; boolean f = true ; for ( int i = 1 ; i < n ; i ++ ) { if ( i % 2 == 1 ) { array [ i ] += n - 1 ; array [ i ] %= n ; } else { array [ i ] ++ ; array [ i ] %= n ; } } for ( int i = 1 ; i < n ; i ++ ) { if ( array [ i ] != array [ i - 1 ] + 1 ) { f = false ; break ; } } if ( f ) { flag = true ; break ; } } System . out . println ( flag ? " YES " : " NO " ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Scanner ;   public class Main {   static Scanner sc = new Scanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; public static void main ( String [ ] args ) { int [ ] atto = new int [ 1000 ] ; int cas = sc . nextInt ( ) ; int b = 0 ; int c = 0 ; for ( b = 0 ; b < cas ; b ++ ) { atto [ b ] = sc . nextInt ( ) ; } while ( atto [ 0 ] != 0 ) { for ( b = 0 ; b < cas ; b ++ ) { if ( b % 2 == 1 && atto [ b ] == 0 ) { atto [ b ] = cas - 1 ; } else if ( b % 2 == 1 ) { atto [ b ] -- ; } else if ( atto [ b ] == cas - 1 ) { atto [ b ] = 0 ; } else { atto [ b ] ++ ; } } } for ( b = 0 ; b < cas ; b ++ ) { if ( atto [ b ] == b ) { c = 1 ; } else { c = 0 ; break ; } } if ( c == 1 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " No " ) ; } } }

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) print ( ( ' Yes ' , ' No ' ) [ any ( [ ( a [ i ] - ( - 1 ) ** i * a [ 0 ] ) % n != i for i in range ( n ) ] ) ] ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) x = ( 0 - a [ 0 ] ) % nfor i in range ( 1 , n ) : if ( a [ i ] + x * ( - 1 ) ** i ) % n != i : print ( ' No ' ) exit ( 0 ) print ( ' Yes ' ) NEW_LINE

from sys import stdin     def real_puzzle ( n , active_teeth ) : while active_teeth [ 0 ] != 0 : for i in range ( n ) : if i % 2 == 0 : active_teeth [ i ] = ( active_teeth [ i ] + 1 ) % n else : active_teeth [ i ] = active_teeth [ i ] - 1 if active_teeth [ i ] != 0 else n - 1 for i in range ( n ) : if active_teeth [ i ] != i : return " No " return " Yes "     if __name__ == " _ _ main _ _ " : n = int ( stdin . readline ( ) ) active_teeth = [ int ( c ) for c in stdin . readline ( ) . split ( " ▁ " ) ] print ( real_puzzle ( n , active_teeth ) ) NEW_LINE


import java . io . * ; import java . lang . Math ; import java . util . * ;   public class Main {   public BufferedReader in ; public PrintStream out ;   public boolean log_enabled = false ; public boolean multiply_tests = true ;   public static boolean do_gen_test = false ; public void gen_test ( ) { } private class TestCase {   public Object solve ( ) { int n = readInt ( ) ; int [ ] a = readIntArray ( n ) ; int min = 1000000001 ; int max = - 1 ; int t , mp = 0 ; int i ; for ( i = 0 ; i < n - 1 ; i ++ ) { if ( ( a [ i ] > - 1 ) && ( a [ i + 1 ] == - 1 ) ) { if ( a [ i ] > max ) { max = a [ i ] ; } if ( a [ i ] < min ) { min = a [ i ] ; } } if ( ( a [ i ] > - 1 ) && ( a [ i + 1 ] > - 1 ) ) { t = Math . abs ( a [ i ] - a [ i + 1 ] ) ; if ( t > mp ) { mp = t ; } } } for ( i = 1 ; i < n ; i ++ ) { if ( ( a [ i ] > - 1 ) && ( a [ i - 1 ] == - 1 ) ) { if ( a [ i ] > max ) { max = a [ i ] ; } if ( a [ i ] < min ) { min = a [ i ] ; } } } if ( max == - 1 ) { return "0 ▁ 42" ; } int k = ( min + max ) / 2 ; int m = Math . max ( max - k , k - min ) ; if ( m < mp ) { m = mp ; } return strf ( " % d ▁ % d " , m , k ) ;

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 FileWriter fw ; static PrintWriter pw ; static double eps = ( double ) 1e-6 ; static long oo = Long . MAX_VALUE ;

def ceil ( a , b ) : return ( ( a + b - 1 ) // b ) def maximum_diff ( arr ) : ans = 0 for i in range ( 1 , len ( arr ) ) : ans = max ( ans , abs ( arr [ i ] - arr [ i - 1 ] ) ) return ansfor _ in range ( int ( input ( ) ) ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) arr = [ ] for i in range ( n ) : if a [ i ] != - 1 : left = max ( 0 , i - 1 ) right = min ( n - 1 , i + 1 ) if a [ left ] == - 1 or a [ right ] == - 1 : arr . append ( a [ i ] ) if len ( arr ) == 0 : print ( 0 , 0 ) else : k = ceil ( max ( arr ) + min ( arr ) , 2 ) for i in range ( n ) : if a [ i ] == - 1 : a [ i ] = k m = maximum_diff ( a ) print ( m , k ) NEW_LINE

def calc ( a , mx ) : l = 0 r = 10 ** 9 for i in range ( 1 , len ( a ) ) : if a [ i ] != - 1 and a [ i - 1 ] != - 1 : if abs ( a [ i ] - a [ i - 1 ] ) > mx : return None elif a [ i ] != - 1 : l = max ( l , a [ i ] - mx ) r = min ( r , a [ i ] + mx ) elif a [ i - 1 ] != - 1 : l = max ( l , a [ i - 1 ] - mx ) r = min ( r , a [ i - 1 ] + mx ) return l if l <= r else None     def solve ( a ) : if calc ( a , 0 ) is not None : return 0 , calc ( a , 0 ) low = 0 high = 1 while calc ( a , high ) is None : high *= 2 while low + 1 < high : mid = ( low + high ) // 2 if calc ( a , mid ) is None : low = mid else : high = mid return high , calc ( a , high )     tc = int ( input ( ) ) for _ in range ( tc ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) print ( * solve ( a ) ) NEW_LINE

import mathimport sys   t = int ( input ( ) )   for _ in range ( t ) : n = int ( input ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) e = 0 ; c = 0 ; r = [ ] mx = - 10 ; mn = 10 ** 10 for i in range ( n ) : if a [ i ] != - 1 : if i != 0 : if a [ i - 1 ] == - 1 : mn = min ( mn , a [ i ] ) mx = max ( mx , a [ i ] ) if i != n - 1 : if a [ i + 1 ] == - 1 : mn = min ( mn , a [ i ] ) mx = max ( mx , a [ i ] ) else : r . append ( i ) if len ( r ) == n : k = 0 else : k = ( mx + mn ) // 2 for i in range ( len ( r ) ) : a [ r [ i ] ] = k mx = - 2 for i in range ( n - 1 ) : mx = max ( mx , abs ( a [ i ] - a [ i + 1 ] ) ) print ( mx , k ) 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 ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AFunctionHeight solver = new AFunctionHeight ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; }   static class AFunctionHeight { public void solve ( int testNumber , InputReader in , PrintWriter out ) { long n = in . nextLong ( ) , k = in . nextLong ( ) ; out . println ( k / n + ( k % n == 0 ? 0 : 1 ) ) ; }   }   static class InputReader { private BufferedReader reader ; private StringTokenizer tokenizer ;   public InputReader ( InputStream inputStream ) { reader = new BufferedReader ( new InputStreamReader ( inputStream ) ) ; }   public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return tokenizer . nextToken ( ) ; }   public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   } }

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

import java . util . * ; import java . io . * ; import java . math . * ; public class Main {

import mathn , k = map ( int , input ( ) . split ( ) ) print ( ( k + n - 1 ) // n ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) print ( ( b + a - 1 ) // a ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) if k % n != 0 : print ( k // n + 1 ) else : print ( k // n ) NEW_LINE

from decimal import *   import math   n , k = map ( int , input ( ) . split ( ) ) print ( math . ceil ( Decimal ( k ) / Decimal ( n ) ) ) NEW_LINE


import java . util . Scanner ;   public class _0721NastyaIsPlayingComputerGames {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; System . out . println ( 3 * n + Math . min ( n - k , k - 1 ) ) ; }   }

import java . io . * ; import java . util . * ; import java . util . concurrent . ConcurrentHashMap ;

import javax . xml . crypto . dsig . spec . XSLTTransformParameterSpec ; import java . util . * ;   public class Example { static int [ ] dp ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int ans = 0 ; ans = ans + ( n + 1 ) ; ans = ans + n ; if ( k == 1 || k == n ) ans = ans + ( n - 1 ) ;   else { int a1 = Math . abs ( n - k ) ; int a2 = ( k - 1 ) ; int x = Math . min ( a1 , a2 ) ; ans += ( x * 2 ) ; ans = ans + Math . max ( a1 , a2 ) ;   } System . out . println ( ans ) ;      }    }

n , k = map ( int , input ( ) . split ( ) ) ans = min ( k - 1 , n - k ) + 3 * n print ( ans ) NEW_LINE

from sys import maxsize , stdout , stdin , stderrmod = int ( 1e9 + 7 ) def I ( ) : return int ( stdin . readline ( ) ) def lint ( ) : return [ int ( x ) for x in stdin . readline ( ) . split ( ) ] def S ( ) : return input ( ) . strip ( ) def grid ( r , c ) : return [ lint ( ) for i in range ( r ) ] from collections import defaultdictimport math   n , k = lint ( ) print ( 3 * n + min ( k - 1 , n - k ) ) NEW_LINE

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

n , k = map ( int , input ( ) . split ( ) ) ans = min ( k - 1 , n - k ) * 2 + max ( k - 1 , n - k ) + 2 * n + 1 print ( ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class Borze { static class RealScanner { 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 ( ) ) ; } }   public static void main ( String [ ] args ) { RealScanner sc = new RealScanner ( ) ; String s = sc . next ( ) ; String myS = " " ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' . ' ) { myS += '0' ; } try { if ( s . charAt ( i ) == ' - ' ) { if ( s . charAt ( i + 1 ) == ' . ' ) { myS += '1' ; i ++ ; } else if ( s . charAt ( i + 1 ) == ' - ' ) { myS += '2' ; i ++ ; } } } catch ( Exception e ) {   } } System . out . println ( myS ) ; } }

s = input ( ) res = ' ' i = 0 for j in range ( len ( s ) ) : if i >= len ( s ) : break if s [ i ] == ' . ' : res += '0' i += 1 continue elif s [ i ] == ' - ' and s [ i + 1 ] == ' . ' : res += '1' i += 2 continue elif s [ i ] == ' - ' and s [ i + 1 ] == ' - ' : res += '2' i += 2 continueprint ( res ) NEW_LINE

s = input ( ) res = " " i = 0 while i < len ( s ) : if s [ i ] == " . " : res = res + str ( 0 ) i += 1 elif i < len ( s ) - 1 : if s [ i ] == " - " and s [ i + 1 ] == " - " : res = res + str ( 2 ) i += 2 elif s [ i ] == " - " and s [ i + 1 ] == " . " : res = res + str ( 1 ) i += 2 print ( res ) NEW_LINE


import java . util . * ;   public class StackBracket { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; long sum = ( n - l ) ; long c = 1 ; for ( int i = 1 ; i <= l ; i ++ ) { sum += c ; c *= 2 ; }   long sum2 = 1 ; r = r - 1 ; int count = 1 ; long c2 = 2 ;   for ( int i = 1 ; i <= r ; i ++ ) { sum2 += c2 ; c2 *= 2 ; count ++ ; } sum2 += c2 / 2 * ( n - count ) ;    System . out . println ( sum + " ▁ " + sum2 ) ;      }   public static boolean strive ( String s ) { Stack < Character > stack = new Stack < > ( ) ; stack . push ( s . charAt ( 0 ) ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { char ch1 = s . charAt ( i ) ; if ( ch1 == ' ) ' ) { if ( ! stack . isEmpty ( ) && stack . peek ( ) == ' ( ' ) { stack . pop ( ) ; } else { return false ; } } else { stack . push ( ' ( ' ) ; } } return stack . size ( ) == 0 ; }   public static int getAns ( int [ ] ar , int bigger , int [ ] [ ] dp , int i , int j ) {   if ( i < 0 || j < 0 ) { return 0 ; }    if ( dp [ i ] [ j ] != - 1 ) { return dp [ i ] [ j ] ; } int ans1 = 0 , ans2 = 0 , ans3 = 0 ;   if ( ar [ i ] < bigger ) { ans1 = 1 + getAns ( ar , ar [ i ] , dp , i - 1 , j ) ;

import java . util . Scanner ;   public class Main { static Scanner input = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = input . nextInt ( ) ; int l = input . nextInt ( ) ; int r = input . nextInt ( ) ; int min = 0 ; int max = 0 ; int sum = 0 ; for ( int i = 1 ; i <= l ; i ++ ) { sum += quite ( i ) ; } min += sum + ( n - l ) ; System . out . print ( min + " ▁ " ) ; sum = 0 ; for ( int i = 1 ; i <= r ; i ++ ) { sum += quite ( i ) ; } max = sum + ( ( n - r ) * quite ( r ) ) ; System . out . println ( max ) ; } static int quite ( int n ) { int sum = 1 ; if ( n == 1 ) sum = 1 ; else for ( int i = 2 ; i <= n ; i ++ ) sum *= 2 ; return sum ; } }

import java . io . * ; import java . util . * ;   public class Solution { public static void main ( String [ ] args ) throws Exception { int [ ] nlr = in . readA ( ) ; int n = nlr [ 0 ] , l = nlr [ 1 ] , r = nlr [ 2 ] ;

import java . util . * ;    public class Practise {

length , min_bound , max_bound = map ( int , input ( ) . split ( ) )   array = [ 1 ] val = 1   for each in range ( 1 , min_bound ) : val = val * 2 array . append ( val ) for each in range ( 1 , length + 1 - min_bound ) : array . append ( 1 ) print ( sum ( array ) , end = " ▁ " )   array = [ 1 ] val = 1   for each in range ( 1 , max_bound ) : val = val * 2 array . append ( val )   for each in range ( 1 , length + 1 - max_bound ) : array . append ( val )     print ( sum ( array ) ) NEW_LINE

import sysdef 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 , l , r = minput ( ) mi = 2 ** l - 1 + n - lma = 2 ** r - 1 + 2 ** ( r - 1 ) * ( n - r ) print ( mi , ma ) NEW_LINE

def sumeve ( n ) : s = 1 cur = 1 for i in range ( n - 1 ) : cur *= 2 s += cur return s   n , l , r = map ( int , input ( ) . rstrip ( ) . split ( ) ) mi = sumeve ( l ) + n - lma = sumeve ( r ) + ( n - r ) * ( 2 ** ( r - 1 ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . FileNotFoundException ; import java . io . FileReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static boolean gsd ( long x , int y ) { for ( int i = 2 ; i <= Math . min ( y , x ) ; i ++ ) { if ( x % i == 0 && y % i == 0 ) return true ; } return false ; } public static int s ( long x ) { int sum = 0 ; do { sum += x % 10 ; x /= 10 ; } while ( x > 0 ) ; return sum ; } public static void main ( String [ ] args ) throws IOException , InterruptedException { PrintWriter pw = new PrintWriter ( System . out ) ; Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; int x = ( int ) Math . sqrt ( n ) ; int i = 0 ; boolean flag = false ;

import java . io . BufferedReader ; import java . io . File ; import java . io . FileWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . math . BigInteger ; import java . util . * ;   import javafx . util . Pair ;   public class Main { public static long sumOfdigit ( long n ) { long sum = 0 ; while ( n != 0 ) { sum += n % 10 ; n /= 10 ; } return sum ; }   public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; long n = input . nextLong ( ) ; for ( long i = 1 ; i <= 90 ; i ++ ) { long d = ( i * i ) + ( 4 * n ) ; long x1 = ( long ) Math . sqrt ( d ) ; if ( x1 * x1 == d ) { long x = ( - i + x1 ) / 2 ; long sumof = sumOfdigit ( x ) ; if ( sumof == i ) { System . out . println ( x ) ; return ; } x = ( - i - x1 ) / 2 ; sumof = sumOfdigit ( x ) ; if ( sumof == i ) { System . out . println ( x ) ; return ; } } } System . out . println ( " - 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 ( ) ; } }   }

import java . util . * ; import java . io . * ;   public class Mangos { public static long check ( long x ) { long sum = 0 ; while ( x != 0 ) { sum += ( x % 10 ) ; x = x / 10 ; } return sum ; } public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long n = Long . parseLong ( br . readLine ( ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ; double x = - 0.5 + ( Math . sqrt ( 1 + 4 * n ) / 2.0 ) ; double y = - 81.5 + ( Math . sqrt ( 26569 + 4 * n ) / 2 ) ; long z = ( long ) x ; long s = ( long ) y ; boolean f = true ; for ( long i = s ; i <= z ; i ++ ) { if ( i * i + check ( i ) * i == n ) { f = false ; pw . println ( i ) ; break ; } } if ( f ) pw . println ( - 1 ) ; pw . flush ( ) ; } }

from math import sqrtn = int ( input ( ) ) ans = 1000000000000000000 an = ansfor i in range ( 90 ) : d = i ** 2 + 4 * n rd = int ( sqrt ( d ) ) if ( rd ** 2 == d ) : x = - i + rd if ( x % 2 == 0 ) : x = x // 2 su = 0 xx = x while xx > 0 : su += xx % 10 xx = xx // 10 if ( su == i ) : ans = min ( ans , x ) if ( an == ans ) : print ( - 1 ) else : print ( ans ) NEW_LINE

def f ( x ) : ans = 0 while x > 0 : ans += x % 10 x //= 10 return ans     def f1 ( b , c ) : D = b ** 2 - 4 * c ans1 = ( - b + D ** 0.5 ) / 2 ans2 = ( - b - D ** 0.5 ) / 2 return [ ans1 , ans2 ]     n = int ( input ( ) ) ans = 10 ** 19 for i in range ( 1 , 99 ) : k = f1 ( i , - n ) k1 , k2 = k [ 0 ] , k [ 1 ] if k1 == int ( k1 ) and f ( k1 ) == i : ans = min ( ans , k1 ) if ans == 10 ** 19 or ans == 999959999 : print ( - 1 ) else : print ( int ( ans ) ) NEW_LINE

def f ( x ) : ans = 0 while x > 0 : ans += x % 10 x //= 10 return ans     def f1 ( b , c ) : D = b ** 2 - 4 * c ans1 = ( - b + D ** 0.5 ) / 2 ans2 = ( - b - D ** 0.5 ) / 2 return [ ans1 , ans2 ]     n = int ( input ( ) ) ans = 10 ** 19 for i in range ( 1 , 99 ) : k = f1 ( i , - n ) k1 , k2 = k [ 0 ] , k [ 1 ] if k1 == int ( k1 ) and f ( k1 ) == i : if int ( k1 ) ** 2 + i * int ( k1 ) - n == 0 : ans = min ( ans , int ( k1 ) ) if ans == 10 ** 19 : print ( - 1 ) else : print ( int ( ans ) ) NEW_LINE

from math import sqrt     def s ( x ) : x = int ( x ) x = abs ( x ) x = str ( x ) su = 0 for i in range ( len ( x ) ) : su += int ( x [ i ] ) return su     a = int ( input ( ) ) for i in range ( 1 , 91 ) : f = ( - i + sqrt ( i ** 2 + 4 * a ) ) / 2 if f == int ( f ) and s ( f ) == i and int ( f ) > 0 and ( int ( f ) ** 2 + s ( f ) * int ( f ) - a ) == 0 : print ( int ( f ) ) breakelse : print ( - 1 ) NEW_LINE

import math     def solve ( n ) :   x = int ( math . sqrt ( n ) )   while ( x * x + 81 * x >= n ) : if x * x + sum_digit ( x ) * x == n : return x x -= 1 return - 1     def sum_digit ( n ) :   str_n = str ( n ) digit_sum = 0 for i in str_n : digit_sum += int ( i )   return digit_sum     if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) )   result = solve ( n )   print ( result ) NEW_LINE


import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; int pred1 = 1 ; int pred2 = 1 ; int res = 0 ; int next = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i > 1 ) { pred2 = pred1 ; } if ( i > 0 ) { pred1 = next ; } next = scan . nextInt ( ) ; if ( next == 1 ) { res ++ ; if ( pred1 == 0 && pred2 == 1 && i > 1 ) { res ++ ; } }

import java . io . File ; import java . io . FileNotFoundException ; import java . io . IOException ; import java . io . PrintWriter ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; StringBuilder s = new StringBuilder ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = in . nextInt ( ) ; s . append ( x ) ; } int start = s . indexOf ( "1" ) ; int end = s . lastIndexOf ( "1" ) ; if ( start < 0 ) System . out . println ( "0" ) ; else { int total = end - start + 1 ; for ( int i = start + 1 ; i <= end ; i ++ ) { if ( s . charAt ( i ) == '1' ) { if ( i - start - 1 > 1 ) total -= ( i - start - 1 ) ; start = i ; } } System . out . println ( total ) ; } }   }

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

n = int ( input ( ) ) s = input ( )   s = s . lstrip ( "0 ▁ " ) s = s . rstrip ( " ▁ 0" ) s = s [ : : 2 ]     while '00' in s : x = s . replace ( '00' , ' * ' ) while x != s : s = x x = s . replace ( ' * 0' , ' * ' )           print ( len ( s ) - s . count ( ' * ' ) )       NEW_LINE

n = int ( input ( ) ) a = input ( ) . replace ( ' ▁ ' , ' ' ) a += '00' result = 0 start = 0 count = 0 count0 = 0 for i in range ( n + 2 ) : if a [ i ] == '1' : start = 1 count += 1 count0 = 0 if a [ i ] == '0' and start == 1 : count += 1 count0 += 1 if count0 == 2 : result += ( count - 2 ) count0 = 0 count = 0 start = 0 result += countprint ( result ) NEW_LINE

n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( 1 , n - 1 ) : if a [ i ] == 0 and a [ i - 1 ] == 1 and a [ i + 1 ] == 1 : a [ i ] = 1 print ( sum ( a ) ) NEW_LINE


import java . util . * ; import static java . lang . Integer . * ;   public class Main { public static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a , b , c ; int ans ; a = scanner . nextInt ( ) ; b = scanner . nextInt ( ) ; c = scanner . nextInt ( ) ; ans = ( a / 3 ) + ( b / 3 ) + ( c / 3 ) ; for ( int i = 0 ; i < min ( 3 , min ( a , min ( b , c ) ) ) ; i ++ ) { int nw = ( a - i ) / 3 + ( b - i ) / 3 + ( c - i ) / 3 + i ; ans = max ( ans , nw ) ; } System . out . println ( ans ) ; } }

import java . util . * ;   public class cf154 { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int r = sc . nextInt ( ) ; int g = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; int min = Math . min ( r , Math . min ( g , b ) ) ; ans += min ; ans += ( r - min ) / 3 ; ans += ( g - min ) / 3 ; ans += ( b - min ) / 3 ; int r1 = ( r - min ) % 3 ; int r2 = ( g - min ) % 3 ; int r3 = ( b - min ) % 3 ; boolean f1 = ( r1 == 2 ) ; boolean f2 = ( r2 == 2 ) ; boolean f3 = ( r3 == 2 ) ; if ( ( ( f1 && f2 ) || ( f2 && f3 ) || ( f1 && f3 ) ) && min > 0 ) { ans ++ ; } System . out . println ( ans ) ; } }

from sys import stdin , stdoutfrom collections import Counternmbr = lambda : int ( stdin . readline ( ) ) lst = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) def fn ( useda ) : ans = useda + ( a - useda ) // 3 cb = ( b - useda ) // 3 cc = ( c - useda ) // 3 return ans + cb + cc   for _ in range ( 1 ) : NEW_LINE

a , b , c = map ( int , input ( ) . split ( ) ) ans = 0 for i in range ( 3 ) : k = min ( i , a , b , c ) x , y , z = a - k , b - k , c - k ans = max ( ans , ( x // 3 ) + ( y // 3 ) + ( z // 3 ) + k )   print ( ans ) NEW_LINE

r , g , b = map ( int , input ( ) . split ( ) ) possible = [ 0 ] if min ( r , g , b ) >= 3 : possible . append ( 3 + ( r - 3 ) // 3 + ( g - 3 ) // 3 + ( b - 3 ) // 3 ) if min ( r , g , b ) >= 2 : possible . append ( 2 + ( r - 2 ) // 3 + ( g - 2 ) // 3 + ( b - 2 ) // 3 ) if min ( r , g , b ) >= 1 : possible . append ( 1 + ( r - 1 ) // 3 + ( g - 1 ) // 3 + ( b - 1 ) // 3 ) possible . append ( r // 3 + g // 3 + b // 3 ) print ( max ( possible ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner puttingvaluesinside = new Scanner ( System . in ) ; int j = puttingvaluesinside . nextInt ( ) ; int i = puttingvaluesinside . nextInt ( ) ; long sum = 0 ; while ( j <= i ) { char [ ] c = ( " " + j ) . toCharArray ( ) ; for ( int k = 0 ; k < c . length ; k ++ ) { switch ( c [ k ] ) { case '0' : { sum += 6 ; break ; } case '1' : { sum += 2 ; break ; } case '2' : { sum += 5 ; break ; } case '3' : { sum += 5 ; break ; } case '4' : { sum += 4 ; break ; } case '5' : { sum += 5 ; break ; } case '6' : { sum += 6 ; break ; } case '7' : { sum += 3 ; break ; } case '8' : { sum += 7 ; break ; } case '9' : { sum += 6 ; break ; } } } j ++ ; } System . out . println ( sum ) ; } }

import java . io . * ; import java . util . * ;   public class Main { public static void main ( String [ ] args ) throws IOException { int [ ] segments = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int ans = 0 ; for ( int i = a ; i <= b ; i ++ ) { String str = i + " " ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; } public static void main ( String [ ] args ) throws IOException { Scanner input = new Scanner ( System . in ) ; long value [ ] = { 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; int a = input . nextInt ( ) ; int b = input . nextInt ( ) ; long ans = 0 ; for ( int i = a ; i <= b ; i ++ ) { String s = i + " " ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { ans += ( value [ s . charAt ( j ) - '0' ] ) ; } } System . out . println ( ans ) ; }   }

arr = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] ans = 0 a , b = map ( int , input ( ) . split ( ) ) for i in range ( a , b + 1 ) : x = list ( str ( i ) ) for j in x : ans += arr [ int ( j ) ]   print ( ans ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) d = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] pas = 0 for i in range ( a , b + 1 ) : for k in ( str ( i ) ) : pas += d [ int ( k ) ] print ( pas ) NEW_LINE

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

a , b = map ( int , input ( ) . split ( ) ) arr = [ 6 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] seg = 0 for i in range ( a , b + 1 ) : while ( i > 0 ) : x = int ( i % 10 ) seg += arr [ x ] i = i // 10 print ( seg ) NEW_LINE

import sys , math   ''' def ▁ construct ( a , seg , low , high , pos ) : ▁ ▁ ▁ ▁ try : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ low ▁ = = ▁ high : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ seg [ pos ] ▁ = ▁ a [ low ] ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ mid ▁ = ▁ ( low + high ) / / 2 ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ construct ( a , seg , low , mid , 2 * pos + 1 ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ construct ( a , seg , mid , high , 2 * pos + 2 ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ seg [ pos ] ▁ = ▁ min ( seg [ 2 * pos + 1 ] , seg [ 2 * pos + 2 ] ) ▁ ▁ ▁ ▁ except : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ pass a ▁ = ▁ [ -1,2,4,0 ] c ▁ = ▁ 1while ▁ c < len ( a ) : ▁ ▁ ▁ ▁ c ▁ = ▁ 2 * cseg ▁ = ▁ [ 10000 ] * (2 * c - 1 ) print ( construct ( a , seg , 0,3,0 ) ) def ▁ matrix ( a , b ) : ▁ ▁ ▁ ▁ c ▁ = ▁ [ [ a [ 0 ] [ 0 ] * b [ 0 ] [ 0 ] + a [ 0 ] [ 1 ] * b [ 1 ] [ 0 ] , a [ 0 ] [ 0 ] * b [ 0 ] [ 1 ] + a [ 0 ] [ 1 ] * b [ 1 ] [ 1 ] ] , \ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ [ a [ 1 ] [ 0 ] * b [ 0 ] [ 0 ] + a [ 1 ] [ 1 ] * b [ 1 ] [ 0 ] , a [ 1 ] [ 0 ] * b [ 1 ] [ 0 ] + a [ 1 ] [ 1 ] * b [ 1 ] [ 1 ] ] ] ▁ ▁ ▁ ▁ return ▁ cdef ▁ power ( a , n ) : ▁ ▁ ▁ ▁ if ▁ n ▁ = = ▁ 0 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ return ▁ [ [1,1 ] , [1,0 ] ] ▁ ▁ ▁ ▁ else : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ if ▁ n % 2 ▁ = = ▁ 0 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ return ▁ matrix ( power ( a , n / /2 ) , power ( a , n / /2 ) ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ else : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ return ▁ matrix ( matrix ( a , a ) , power ( a , n - 1 ) ) a ▁ = ▁ [ [1,1 ] , [1,0 ] ] for ▁ i ▁ in ▁ range ( 10 ) : ▁ ▁ ▁ ▁ print ( power ( a , i ) ) a ▁ = ▁ [ [1,1 ] , [1,0 ] ] c ▁ = ▁ afor ▁ i ▁ in ▁ range ( 10 ) : ▁ ▁ ▁ ▁ c ▁ = ▁ matrix ( c , a ) ▁ ▁ ▁ ▁ print ( c ) t ▁ = ▁ int ( input ( ) ) for ▁ _ ▁ in ▁ range ( t ) : ▁ ▁ ▁ ▁ n , ▁ w ▁ = ▁ map ( int , input ( ) . split ( ) ) ▁ ▁ ▁ ▁ a ▁ = ▁ list ( map ( int , input ( ) . split ( ) ) ) ▁ ▁ ▁ ▁ a . sort ( ) ▁ ▁ ▁ ▁ x ▁ = ▁ 0 ▁ ▁ ▁ ▁ s ▁ = ▁ 0 ▁ ▁ ▁ ▁ while ▁ x < n ▁ and ▁ s + a [ x ] < = w : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ s + = a [ x ] ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ x + = 1 ▁ ▁ ▁ ▁ if ▁ x ▁ = = ▁ 0 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( -1 ) ▁ ▁ ▁ ▁ else : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( x ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( a [ 0 : x + 1 ] )   ''' def cal ( a , b ) : seg = { 0 : 6 , 1 : 2 , 2 : 5 , 3 : 5 , 4 : 4 , 5 : 5 , 6 : 6 , 7 : 3 , 8 : 7 , 9 : 6 } ans = 0 for i in range ( a , b + 1 ) : for c in str ( i ) : ans += seg [ int ( c ) ] return ansa , b = map ( int , input ( ) . split ( ) ) print ( cal ( a , b ) ) NEW_LINE


import java . util . Scanner ;   public class B978 { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) , a = 0 , res = 0 ; String file = scanner . next ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( file . charAt ( i ) == ' x ' ) { a ++ ; if ( a > 2 ) { res ++ ; } } else { a = 0 ; } } System . out . println ( res ) ; } }

import java . util . Scanner ;   public class CodeForces { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; String s = sc . next ( ) ; String s1 = " " ; int count = 0 ; for ( int i = 0 ; i < t ; i ++ ) { if ( count < 2 ) { s1 += s . charAt ( i ) ; if ( s . charAt ( i ) == ' x ' ) { count ++ ; } else { count = 0 ; } } else if ( s . charAt ( i ) != ' x ' ) { count = 0 ; s1 += s . charAt ( i ) ; } } System . out . println ( t - s1 . length ( ) ) ; } }

import java . util . * ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . valueOf ( scanner . nextLine ( ) ) ; String s = scanner . nextLine ( ) ; System . out . println ( s . length ( ) - s . replaceAll ( " xxx + " , " xx " ) . length ( ) ) ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s ; int x = 0 , n , flag ; n = scanner . nextInt ( ) ; s = scanner . next ( ) ; while ( s . contains ( " xxx " ) ) { s = s . replaceFirst ( " xxx " , " xx " ) ; x ++ ; } System . out . println ( x ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class FileExtention { public static void main ( String [ ] args ) { FastScanner fs = new FastScanner ( ) ; int T = 1 ; PrintWriter out = new PrintWriter ( System . out ) ; for ( int tt = 0 ; tt < T ; tt ++ ) { int n = fs . nextInt ( ) ; String s = fs . next ( ) ; s = s + " ▁ " ; int count = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' x ' ) { for ( int j = i + 1 ; j < s . length ( ) ; j ++ ) { if ( s . charAt ( j ) != ' x ' ) { count += ( j - i - 2 ) > 0 ? ( j - i - 2 ) : 0 ;

n = int ( input ( ) ) s = input ( ) count = 0 for i in range ( n ) : s1 = s [ i : i + 3 ] if ( s1 == ' xxx ' ) : count += 1 print ( count ) NEW_LINE

b , c = int ( input ( ) ) , input ( ) f = 0 m = 0 for i in range ( 0 , len ( c ) ) : if c [ i ] == " x " : f += 1 else : if f > 2 : m += f - 2 f = 0 if i + 1 == len ( c ) and f > 2 : m += f - 2 print ( m ) NEW_LINE

n = int ( input ( ) ) s = input ( ) ans = 0 for i in range ( n - 2 ) : if s [ i ] == ' x ' and s [ i + 1 ] == ' x ' and s [ i + 2 ] == ' x ' : ans += 1 print ( ans ) NEW_LINE

n = int ( input ( ) ) s = input ( ) c = 0 for i in range ( n - 2 ) : if s [ i ] == ' x ' and s [ i + 1 ] == ' x ' and s [ i + 2 ] == ' x ' : c += 1 print ( c ) NEW_LINE


import java . util . * ;   public final class Party { public static int maxDepth = 1 ;   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; ArrayList < Integer > [ ] adj = new ArrayList [ n ] ; int [ ] visited = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int superior = sc . nextInt ( ) - 1 ; if ( superior >= 0 ) { if ( adj [ superior ] == null ) { adj [ superior ] = new ArrayList < > ( ) ; }

import java . io . * ; import java . util . * ;   public class A115 { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   int n = Integer . parseInt ( br . readLine ( ) ) ;   ArrayList < Integer > [ ] adj = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i < ( n + 1 ) ; i ++ ) { adj [ i ] = new ArrayList < Integer > ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { int j = Integer . parseInt ( br . readLine ( ) ) ; if ( j != - 1 ) { adj [ j ] . add ( i + 1 ) ; } }   boolean [ ] visited = new boolean [ n + 1 ] ; int [ ] maxHeight = { 0 } ; for ( int i = 1 ; i < n + 1 ; i ++ ) { if ( ! visited [ i ] ) { findMaxHeight ( i , 1 , adj , visited , maxHeight ) ; } }   bw . write ( maxHeight [ 0 ] + " \n " ) ; bw . flush ( ) ; }   public static void findMaxHeight ( int node , int currentHeight , ArrayList < Integer > [ ] adj , boolean [ ] visited , int [ ] maxHeight ) { if ( currentHeight > maxHeight [ 0 ] ) { maxHeight [ 0 ] = currentHeight ; } visited [ node ] = true ; for ( int i = 0 ; i < adj [ node ] . size ( ) ; i ++ ) { findMaxHeight ( adj [ node ] . get ( i ) , currentHeight + 1 , adj , visited , maxHeight ) ; } } }

import java . util . * ; public class sol { static ArrayList < Integer > [ ] adj = new ArrayList [ 10000 ] ; static int ans = 0 ; static int max ( int x , int y ) { return x >= y ? x : y ; } static void dfs ( int u , int depth ) { for ( int v : adj [ u ] ) { dfs ( v , depth + 1 ) ; } ans = max ( ans , depth ) ; } public static void main ( String [ ] args ) { Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { adj [ i ] = new ArrayList < Integer > ( ) ; int x = input . nextInt ( ) ; if ( x != - 1 ) { adj [ i ] . add ( x ) ; } } for ( int i = 1 ; i <= n ; i ++ ) { dfs ( i , 1 ) ; } System . out . println ( ans ) ; } }

import java . util . Scanner ; public class CodeForces { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] p = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) p [ i ] = sc . nextInt ( ) ; int max = 0 ; int q = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int r = p [ i ] ; while ( r != - 1 ) { q ++ ; max = Math . max ( max , q ) ; r = p [ r - 1 ] ; } q = 0 ; } System . out . println ( max + 1 ) ; } }

def main ( ) : n = int ( input ( ) ) adj = [ [ ] for i in range ( n ) ] roots = list ( ) for i in range ( n ) : a = int ( input ( ) ) if ( a != - 1 ) : adj [ a - 1 ] . append ( i ) else : roots . append ( i )   def dfs ( s , e , depth = 0 ) : print ( s ) for child in adj [ s ] : if child != e : dfs ( child , s ) return depth   def dfs_iter ( s ) : visited = [ False for i in range ( n ) ] depth = [ 0 for i in range ( n ) ] NEW_LINE

def dfslen ( i , prev ) : global visited , d   visited [ i ] = 1 if len ( d [ i ] ) == 0 : return prev   ans = prev for item in d [ i ] : if visited [ item ] == 0 : ans = max ( ans , dfslen ( item , prev + 1 ) ) return ans     n = int ( input ( ) ) d = [ [ ] for _ in range ( n + 1 ) ] root = [ ] for i in range ( 1 , n + 1 ) : x = int ( input ( ) ) if x == - 1 : root . append ( i ) continue d [ x ] . append ( i ) NEW_LINE

n = int ( input ( ) )   children = [ set ( ) for _ in range ( n + 1 ) ] parent = [ None ] * ( n + 1 )   for i in range ( 1 , n + 1 ) : temp = int ( input ( ) ) if temp != - 1 : parent [ i ] = temp children [ temp ] . add ( i )   ans = 0 visited = set ( ) while True : leaves = set ( ) for i , children_set in enumerate ( children ) : if not children_set and i and i not in visited : leaves . add ( i ) if leaves : ans += 1 for leaf in leaves : visited . add ( leaf ) for cl in children : if leaf in cl : cl . remove ( leaf ) else : break   print ( ans ) NEW_LINE

n = int ( input ( ) ) a = [ ] for i in range ( n ) : x = int ( input ( ) ) a . append ( x ) maxcount = 1 for i in range ( n ) : if a [ i ] != - 1 : j = i count = 0 while j >= 0 : j = a [ j ] - 1 count += 1 maxcount = max ( count , maxcount ) print ( maxcount ) NEW_LINE


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

import java . io . File ; import java . util . Scanner ; import java . util . StringTokenizer ;   public class p006 { public static void main ( String args [ ] ) throws Exception { StringTokenizer stok = new StringTokenizer ( new Scanner ( System . in ) . useDelimiter ( " \\ A " ) . next ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; int n = Integer . parseInt ( stok . nextToken ( ) ) ; int k = Integer . parseInt ( stok . nextToken ( ) ) ; char [ ] s = stok . nextToken ( ) . toCharArray ( ) ; int [ ] a = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s [ i ] - 48 ; int r = 0 ; for ( int i = k ; i < n && r == 0 ; i ++ ) if ( a [ i ] > a [ i % k ] ) r = i ; else if ( a [ i ] < a [ i % k ] ) break ; while ( a [ r ] > a [ r % k ] ) { int c = 1 ; a [ r -- ] = 0 ; while ( c == 1 ) { if ( a [ r ] < 9 ) { a [ r ] ++ ; c = 0 ; } else a [ r -- ] = 0 ; } } System . out . println ( n ) ; for ( int i = 0 ; i < n ; i ++ ) sb . append ( a [ i % k ] ) ; System . out . println ( sb ) ; } }

import java . io . ByteArrayInputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; import java . io . * ; import java . math . * ; public class Main { InputStream is ; PrintWriter out ; String INPUT = " " ;

import java . util . * ;   public class Solution { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; char ans [ ] = new char [ n ] ; System . out . println ( n ) ; for ( int i = 0 ; i < k ; i ++ ) { for ( int j = i ; j < n ; j += k ) { ans [ j ] = s . charAt ( i ) ; } } boolean less = false ; int idx = - 1 ; char cc = ' ▁ ' ; for ( int i = 0 ; i < n ; i ++ ) { if ( ans [ i ] > s . charAt ( i ) ) break ; if ( ans [ i ] < s . charAt ( i ) ) { less = true ; idx = i ; break ; } } if ( ! less ) System . out . println ( ans ) ; else { int min_idx = - 1 ; for ( int i = 0 ; i < k ; i ++ ) { if ( s . charAt ( i ) != '9' ) min_idx = i ; } min_idx = Math . min ( idx , min_idx ) ; for ( int i = min_idx ; i < k ; i ++ ) { for ( int j = i ; j < n ; j += k ) { if ( i == min_idx ) ans [ j ] = ( char ) ( s . charAt ( i ) + 1 ) ; else ans [ j ] = '0' ; } } System . out . println ( ans ) ; } } }

n , k = [ int ( x ) for x in input ( ) . split ( ) ] a = [ int ( x ) for x in input ( ) ]   ans = a [ : k ] while len ( ans ) < n : ans . append ( ans [ len ( ans ) - k ] )   if ans < a : i = k - 1 while True : ans [ i ] += 1 if ans [ i ] == 10 : ans [ i ] = 0 i -= 1 else : break for i in range ( k , n ) : ans [ i ] = ans [ i - k ] print ( n ) print ( ' ' . join ( [ str ( x ) for x in ans ] ) ) NEW_LINE

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

n , k = map ( int , input ( ) . split ( ) ) s = input ( ) t = s [ : k ] ans = tfor i in range ( k , n ) : ans += ans [ i - k ] if ans >= s : print ( len ( ans ) ) print ( ans ) else : t = s [ : k ] t = str ( int ( t ) + 1 ) ans = t for i in range ( k , n ) : ans += ans [ i - k ] print ( len ( ans ) ) print ( ans ) NEW_LINE


import java . util . * ;   public class Test {   static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int t = Integer . parseInt ( sc . next ( ) ) ; while ( t -- > 0 ) solve ( ) ; }   static void solve ( ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ;   boolean [ ] arr = new boolean [ n + 1 ] ;   for ( int i = 0 ; i < n ; i ++ ) { arr [ sc . nextInt ( ) ] = true ; }   List < Integer > al = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) if ( arr [ i ] ) al . add ( i ) ;   if ( al . size ( ) > k ) { System . out . println ( - 1 ) ; return ; } while ( al . size ( ) < k ) { al . add ( 1 ) ; }   List < Integer > ans = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { ans . addAll ( al ) ; } System . out . println ( n * k ) ; for ( Integer i : ans ) System . out . print ( i + " ▁ " ) ; System . out . println ( ) ;   } }

import java . util . * ;   public class Test {   static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; int t = Integer . parseInt ( sc . next ( ) ) ; while ( t -- > 0 ) solve ( ) ; }   static void solve ( ) { int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ;   boolean [ ] arr = new boolean [ n + 1 ] ;   for ( int i = 0 ; i < n ; i ++ ) { arr [ sc . nextInt ( ) ] = true ; }   List < Integer > al = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) if ( arr [ i ] ) al . add ( i ) ;   if ( al . size ( ) > k ) { System . out . println ( - 1 ) ; return ; } while ( al . size ( ) < k ) { al . add ( 1 ) ; }   System . out . println ( n * k ) ; for ( int i = 1 ; i <= n ; i ++ ) for ( Integer j : al ) System . out . print ( j + " ▁ " ) ;   System . out . println ( ) ;   } }

def solve ( n , k , a ) : s = set ( a ) if len ( s ) > k : print ( - 1 ) return s = list ( s ) while len ( s ) != k : s . append ( 1 ) s . sort ( ) res = s * n print ( len ( res ) ) print ( * res )     for _ in range ( int ( input ( ) ) ) : n , k = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) solve ( n , k , a ) NEW_LINE

import sys   t = int ( sys . stdin . readline ( ) ) for _ in range ( t ) : n , k = map ( int , sys . stdin . readline ( ) . split ( ) ) l = list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) s = set ( l ) if len ( s ) > k : print ( - 1 ) else : q = list ( s ) cur = 1 while len ( q ) < k : while cur in s : cur += 1 q . append ( cur ) ans = [ ] i = 0 for i in range ( n ) : for j in q : if i < n and l [ i ] == j : ans . append ( str ( j ) ) i += 1 else : ans . append ( str ( j ) ) print ( len ( ans ) ) print ( " ▁ " . join ( ans ) ) NEW_LINE

from sys import stdin , stdoutinput = stdin . readline def main ( ) : t = int ( input ( ) ) for i in range ( t ) : NEW_LINE

t = int ( input ( ) )   for i in range ( t ) : n , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) s = set ( a ) ans = [ ] if len ( list ( s ) ) > k : print ( - 1 ) continue print ( k * n ) for j in range ( n ) : for un in s : ans . append ( un ) for l in range ( k - len ( list ( s ) ) ) : ans . append ( 1 ) print ( * ans ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ;   public class Tapes { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) , m = sc . nextInt ( ) , k = sc . nextInt ( ) ; sc . nextLine ( ) ; int [ ] diferencias = new int [ n - 1 ] ; int anterior = sc . nextInt ( ) ; for ( int i = 0 ; i < diferencias . length ; i ++ ) { int actual = sc . nextInt ( ) ; diferencias [ i ] = actual - anterior ; anterior = actual ; } sc . nextLine ( ) ; Arrays . sort ( diferencias ) ; long resultado = k ; for ( int i = 0 ; i < n - k ; i ++ ) resultado += diferencias [ i ] ; System . out . println ( resultado ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;   import java . util . * ; import javafx . util . Pair ;   public class Main { static void sort ( int a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; int temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; } Arrays . sort ( a ) ; } public static void main ( String args [ ] ) { FastScanner input = new FastScanner ( ) ; int n = input . nextInt ( ) ; int m = input . nextInt ( ) ; int k = input . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextInt ( ) ; } long size = a [ n - 1 ] - a [ 0 ] + 1 ;

n , m , k = list ( map ( int , input ( ) . split ( ) ) ) b = list ( map ( int , input ( ) . split ( ) ) )   c = [ ]   for i in range ( n - 1 ) : c . append ( b [ i + 1 ] - b [ i ] )   c . sort ( )   ret = 0   for i in range ( n - k ) : ret += c [ i ]   ret += k   print ( ret )   NEW_LINE

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

[ num_broken , length , max_pieces ] = [ int ( el ) for el in input ( ) . split ( ) ]   positions = input ( ) . split ( )   distances = [ ]   for i in range ( num_broken - 1 ) : diff = int ( positions [ i + 1 ] ) - int ( positions [ i ] ) - 1 distances . append ( diff ) distances . sort ( )   uncut_size = int ( positions [ - 1 ] ) - int ( positions [ 0 ] ) + 1   if max_pieces == 1 : print ( uncut_size ) else : print ( uncut_size - sum ( distances [ ( - max_pieces + 1 ) : ] ) )   NEW_LINE


import java . util . ArrayList ; import java . util . Scanner ;   public class SquarePainting { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ;   int n = scanner . nextInt ( ) ; long [ ] a = new long [ n ] ; int min = 0 ;   for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextLong ( ) ; if ( a [ min ] > a [ i ] ) min = i ; }   ArrayList < Integer > minimum = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] == a [ min ] ) { minimum . add ( i ) ; } }   if ( minimum . size ( ) == 1 ) { System . out . println ( n * a [ min ] + n - 1 ) ; } else { int max = n - minimum . get ( minimum . size ( ) - 1 ) + minimum . get ( 0 ) ; for ( int i = 0 ; i < minimum . size ( ) - 1 ; i ++ ) { int diff = minimum . get ( i + 1 ) - minimum . get ( i ) ;   if ( max < diff ) max = diff ; } System . out . println ( n * a [ min ] + max - 1 ) ; } } }

import com . sun . org . apache . bcel . internal . generic . AALOAD ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . math . BigInteger ; import java . util . * ; import java . util . stream . IntStream ; import javafx . util . Pair ;   public class Main {   static void sort ( double a [ ] ) { Random ran = new Random ( ) ; for ( int i = 0 ; i < a . length ; i ++ ) { int r = ran . nextInt ( a . length ) ; double temp = a [ r ] ; a [ r ] = a [ i ] ; a [ i ] = temp ; }   Arrays . sort ( a ) ; }   public static void main ( String [ ] args ) throws IOException {   Scanner input = new Scanner ( System . in ) ; int n = input . nextInt ( ) ; long a [ ] = new long [ n ] ; long ans = 0 ; long min = Long . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = input . nextLong ( ) ; if ( min > a [ i ] ) { min = a [ i ] ; } } long highestRun = 0 ; long run = 0 ; for ( int i = 0 ; i < n * 2 ; i ++ ) { if ( a [ i % n ] == min ) { highestRun = Math . max ( highestRun , run ) ; run = 0 ; } else { run ++ ; } } System . out . println ( min * n + highestRun ) ;   }   }

import java . io . * ; import java . math . BigInteger ; import java . util . * ;    @ SuppressWarnings ( " unused " ) public class B { public static FastScannerB scan = new FastScannerB ( ) ; public static PrintWriter out = new PrintWriter ( System . out ) ; public static void solve ( ) { int n = scan . nextInt ( ) ; int [ ] a = scan . readArray ( n ) ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { min = Math . min ( a [ i ] , min ) ; } int cnt = 0 ; long res = ( long ) n * min ; int max = 0 ; for ( int i = 0 ; i < 2 * n ; i ++ ) { if ( a [ i % n ] == min ) cnt = 0 ; else { cnt ++ ; max = Math . max ( max , cnt ) ; } } System . out . println ( max + res ) ; } public static void main ( String [ ] args ) { solve ( ) ; out . close ( ) ; }   } class FastScannerB { 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 ( ) ) ; } void sort ( long [ ] a ) { ArrayList < Long > l = new ArrayList < > ( ) ; for ( long i : a ) l . add ( i ) ; Collections . sort ( l ) ; for ( int i = 0 ; i < a . length ; i ++ ) a [ i ] = l . get ( i ) ; }   }

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

a , b = int ( input ( ) ) , list ( map ( int , input ( ) . split ( ) ) ) d , s , c , e = 0 , 0 , b . index ( min ( b ) ) , min ( b ) for i in range ( a ) : if b [ i ] == e : d = max ( d , s ) s = 0 else : s += 1 print ( e * a + max ( s + c , d ) ) NEW_LINE

n = int ( input ( ) ) litres = list ( map ( int , input ( ) . split ( ) ) ) mini = 10 ** 9 + 1 for i in range ( n ) : if mini >= litres [ i ] : mini = litres [ i ] last = ifor i in range ( n ) : if litres [ i ] == mini : first = i breaklitres += litres [ : first + 1 ] maxi = 0 prev = firstif first == last : print ( mini * n + n - 1 ) else : for i in range ( first + 1 , n + first + 1 ) : if litres [ i ] == mini : if maxi < i - prev : maxi = i - prev prev = i print ( mini * n + maxi - 1 ) NEW_LINE

n = int ( input ( ) ) a = list ( map ( int , input ( ) . strip ( ) . split ( " ▁ " ) ) )   p = min ( a ) lf = [ ] rf = [ ] c1 = 0 c2 = 0 kc = - 1 for i in range ( n ) : if i == 0 : if a [ i ] == p : lf . append ( i ) kc = 1 c1 += 1 else : lf . append ( - 1 ) c1 += 1 else : if a [ i ] == p and kc == - 1 : lf . append ( i ) kc = 1 c1 += 1 else : lf . append ( lf [ c1 - 1 ] ) c1 += 1 for i in range ( n - 1 , - 1 , - 1 ) : if i == n - 1 : if a [ i ] == p : rf . append ( i ) c2 += 1 else : rf . append ( - 1 ) c2 += 1 else : if a [ i ] == p : rf . append ( i ) c2 += 1 else : rf . append ( rf [ c2 - 1 ] ) c2 += 1 rf . reverse ( ) NEW_LINE

n = int ( input ( ) ) ; lis = list ( map ( int , input ( ) . split ( ) ) ) minpos = None ; minval = float ( ' inf ' ) ; maxdiff = float ( ' - inf ' ) ; difflis = list ( ) for i , j in enumerate ( lis ) : if j <= minval : minval = jfor i , j in enumerate ( lis ) : if j == minval : difflis . append ( i ) ; fp = difflis [ 0 ] if len ( difflis ) == 1 : ans = ( n - 1 ) * ( minval + 1 ) + minval ; print ( ans ) ; exit ( ) for i in range ( 1 , len ( difflis ) ) : cur = difflis [ i ] - difflis [ i - 1 ] - 1 ; maxdiff = max ( maxdiff , cur ) if len ( set ( lis ) ) == 1 : print ( minval * n ) ; exit ( ) diff = n - difflis [ len ( difflis ) - 1 ] + difflis [ 0 ] - 1 ; maxdiff = max ( maxdiff , diff ) ans = maxdiff * ( minval + 1 ) + ( n - maxdiff ) * minval ; print ( ans ) NEW_LINE


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

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

import java . util . * ; public class ApplemanAndEasyTask { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char [ ] [ ] arr = new char [ n ] [ n ] ; boolean flag = true ;   for ( int i = 0 ; i < n ; i ++ ) { String s = sc . next ( ) ;   for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = s . charAt ( j ) ; } } sc . close ( ) ;   for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { int counter = 0 ; if ( j + 1 < n && arr [ i ] [ j + 1 ] == ' o ' ) { counter ++ ; }   if ( j - 1 >= 0 && arr [ i ] [ j - 1 ] == ' o ' ) { counter ++ ; }   if ( i + 1 < n && arr [ i + 1 ] [ j ] == ' o ' ) { counter ++ ; } if ( i - 1 >= 0 && arr [ i - 1 ] [ j ] == ' o ' ) { counter ++ ; }   if ( counter != 0 ) { if ( counter % 2 != 0 ) { System . out . println ( " NO " ) ; flag = false ; break ; }   } } if ( flag == false ) break ;   } if ( flag ) System . out . println ( " YES " ) ;   } }

import java . util . Scanner ;   public class _0675ApplemanandEasyTask {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; sc . nextLine ( ) ; char [ ] [ ] arr = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String temp = sc . nextLine ( ) ; for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = temp . charAt ( j ) ; } } boolean flag = true ; for ( int i = 0 ; i < n ; i ++ ) { int count = 0 ; for ( int j = 0 ; j < n ; j ++ ) { count = 0 ; if ( i - 1 >= 0 && arr [ ( i - 1 ) ] [ j ] == ' o ' ) { count ++ ; } if ( i + 1 < n && arr [ i + 1 ] [ j ] == ' o ' ) { count ++ ; } if ( j + 1 < n && arr [ i ] [ j + 1 ] == ' o ' ) { count ++ ; } if ( j - 1 >= 0 && arr [ i ] [ j - 1 ] == ' o ' ) { count ++ ; } if ( count % 2 != 0 ) { flag = false ; break ; } } } if ( flag ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ;   } }   }

from __future__ import division , print_functionfrom collections import * from math import * from itertools import * from time import timeimport osimport sysfrom io import BytesIO , IOBase if sys . version_info [ 0 ] < 3 : from __builtin__ import xrange as range from future_builtins import ascii , filter , hex , map , oct , zip ''' Notes :   '''   def main ( ) : n = int ( input ( ) ) ar = [ ] for i in range ( n ) : ar . append ( input ( ) ) for i in range ( n ) : for j in range ( n ) : count = 0 if ( i - 1 ) >= 0 : if ar [ i - 1 ] [ j ] == ' o ' : count += 1 if ( i + 1 ) < n : if ar [ i + 1 ] [ j ] == ' o ' : count += 1 if ( j - 1 ) >= 0 : if ar [ i ] [ j - 1 ] == ' o ' : count += 1 if ( j + 1 ) < n : if ar [ i ] [ j + 1 ] == ' o ' : count += 1 if count % 2 == 0 : continue else : print ( " NO " ) return print ( " YES " ) 	 	     NEW_LINE

n = int ( input ( ) )   mat = [ input ( ) for _ in range ( n ) ]   status = True   for i in range ( n ) : for j in range ( n ) : count = 0 if i >= 1 and mat [ i - 1 ] [ j ] == ' o ' : count += 1 if j >= 1 and mat [ i ] [ j - 1 ] == ' o ' : count += 1 if i <= n - 2 and mat [ i + 1 ] [ j ] == ' o ' : count += 1 if j <= n - 2 and mat [ i ] [ j + 1 ] == ' o ' : count += 1 if count % 2 != 0 : status = False break if status : print ( " YES " ) else : print ( " NO " ) NEW_LINE