import java . util . Scanner ;   public class _0684MiddleoftheContest {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String [ ] strf = sc . nextLine ( ) . trim ( ) . split ( " : " ) ; String [ ] stre = sc . nextLine ( ) . trim ( ) . split ( " : " ) ;   int hrf = Integer . valueOf ( strf [ 0 ] ) ; int mmf = Integer . valueOf ( strf [ 1 ] ) ; int hre = Integer . valueOf ( stre [ 0 ] ) ; int mme = Integer . valueOf ( stre [ 1 ] ) ; int t1 = hrf * 60 + mmf ; int t2 = hre * 60 + mme ; int t3 = ( t1 + t2 ) / 2 ; hrf = ( t3 ) / 60 ; mmf = ( t3 % 60 ) ; if ( ( hrf + " " ) . length ( ) == 1 ) { System . out . print ( "0" + hrf ) ; } else { System . out . print ( hrf ) ; } System . out . print ( " : " ) ; if ( ( mmf + " " ) . length ( ) == 1 ) { System . out . print ( "0" + mmf ) ; } else { System . out . print ( mmf ) ;   }   }   }

start = input ( ) . split ( ' : ' ) end = input ( ) . split ( ' : ' ) start_min = int ( start [ 0 ] ) * 60 + int ( start [ 1 ] ) end_min = int ( end [ 0 ] ) * 60 + int ( end [ 1 ] ) diff = ( end_min - start_min ) // 2 print ( ' { :0 > 2 } ' . format ( str ( ( start_min + diff ) // 60 ) ) + ' : ' + ' { :0 > 2 } ' . format ( str ( ( start_min + diff ) % 60 ) ) ) NEW_LINE

start_time = input ( ) end_time = input ( ) start_time = start_time . split ( ' : ' ) end_time = end_time . split ( ' : ' ) start_hours = int ( start_time [ 0 ] ) start_minutes = int ( start_time [ 1 ] ) end_hours = int ( end_time [ 0 ] ) end_minutes = int ( end_time [ 1 ] ) start_hours *= 60 end_hours *= 60 start_hours += start_minutesend_hours += end_minutesx = end_hours - start_hoursx = x / 2 y = start_hours + xz = y % 60 w = y // 60 if z < 10 and w < 10 : print ( ( '0 { } :0 { } ' ) . format ( int ( w ) , int ( z ) ) ) elif w < 10 : print ( ( '0 { } : { } ' ) . format ( int ( w ) , int ( z ) ) ) elif z < 10 : print ( ( ' { } : 0 { } ' ) . format ( int ( w ) , int ( z ) ) ) else : print ( ( ' { } : { } ' ) . format ( int ( w ) , int ( z ) ) ) NEW_LINE


import java . lang . reflect . Array ; import java . text . DecimalFormat ; import java . util . * ; import java . io . * ;   public class Equal {    static class pair implements Comparable < pair > { int x ; int y ;   public pair ( int u , int v ) { this . x = u ; this . y = v ; }   @ Override public int compareTo ( pair o ) { if ( y == o . y ) return 0 ; if ( y < o . y ) return 1 ; return - 1 ; } }   static double dis ( pair a , pair b ) { return Math . sqrt ( ( ( a . x - b . x ) * ( a . x - b . x ) ) + ( ( a . y - b . y ) * ( a . y - b . y ) ) ) ; }   static int c ; static int d ; static int e ;   static void extendedEuclid ( int a , int b ) { if ( b == 0 ) { c = 1 ; d = 0 ; e = a ; return ; } extendedEuclid ( b , a % b ) ; int x1 = d ; int y1 = c - ( a / b ) * d ; c = x1 ; d = y1 ; } static int [ ] rank ; static int [ ] p ; static int sets ; static int findSet ( int i ) { return ( p [ i ] == i ) ? i : ( p [ i ] = findSet ( p [ i ] ) ) ; } static boolean isSameSet ( int i , int j ) { return findSet ( i ) == findSet ( j ) ; } static void unionSet ( int i , int j ) { if ( ! isSameSet ( i , j ) ) { sets -- ; int x = findSet ( i ) ; int y = findSet ( j ) ; if ( rank [ x ] > rank [ y ] ) p [ y ] = x ; else { p [ x ] = y ; if ( rank [ x ] == rank [ y ] ) rank [ y ] ++ ; } } } static class SegmentTree {

import java . util . * ; public class HelpKingdomOfFarFarAway2 { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) , ans = " " ; boolean flag = true ; if ( s . charAt ( 0 ) == ' - ' ) { s = s . substring ( 1 ) ; flag = false ; } int i ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' . ' ) break ; } for ( int k = 1 , j = i - 1 ; j >= 0 ; j -- , k ++ ) { ans = s . charAt ( j ) + ans ; if ( k % 3 == 0 && j != 0 ) { ans = ' , ' + ans ; k = - 3 ; } } ans += ' . ' ; if ( i + 1 < s . length ( ) ) ans += s . charAt ( i + 1 ) ; else ans += '0' ; if ( i + 2 < s . length ( ) ) ans += s . charAt ( i + 2 ) ; else ans += '0' ; ans = ' $ ' + ans ; if ( ! flag ) ans = ' ( ' + ans + ' ) ' ; System . out . println ( ans ) ; } }

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

import java . io . * ; import java . util . * ;   public class HelpKingdom_102B { public static void main ( String [ ] args ) throws IOException { FastReader fr = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new OutputStreamWriter ( System . out ) ) ; String s = fr . nextLine ( ) ;   boolean neg = s . indexOf ( " - " ) != - 1 ;   int point = s . indexOf ( " . " ) ;   StringBuilder sb = new StringBuilder ( ) ; if ( point == - 1 ) { if ( neg ) sb . append ( " ( $ " ) ; else sb . append ( " $ " ) ; StringBuilder bulk = new StringBuilder ( ) ; if ( neg ) { bulk . append ( s . substring ( 1 ) ) ; } else { bulk . append ( s ) ; } int add = ( bulk . length ( ) / 3 ) ; int pos = bulk . length ( ) % 3 ; int added = 0 ;

s = input ( ) start = 1 if s [ 0 ] == " - " else 0 answer = " "   float_start = len ( s ) if s . count ( " . " ) == 0 else s . index ( " . " ) answer = ( "0" + ( "0" if float_start == len ( s ) else s [ float_start + 1 ] ) if float_start + 2 >= len ( s ) else s [ float_start + 1 : float_start + 3 ] [ : : - 1 ] ) + " . "   current = 0 for i in range ( float_start - 1 , start - 1 , - 1 ) : answer += s [ i ] current += 1 if current == 3 and i != start : answer += " , " current = 0   answer = ( answer + " $ " ) [ : : - 1 ] print ( answer if start == 0 else " ( " + answer + " ) " ) NEW_LINE

s = input ( ) dot = 0 if " . " in s : dot = s . index ( " . " ) else : dot = len ( s ) a = s [ 0 : dot ] NEW_LINE

s = input ( ) start = 1 if s [ 0 ] == " - " else 0 answer = " "   float_start = 0 try : float_start = s . index ( " . " ) except : float_start = len ( s )   if float_start == len ( s ) : answer += "00 . " else : answer += s [ float_start + 1 : float_start + 3 ] [ : : - 1 ] + " . "   if float_start + 2 >= len ( s ) : answer = "0" + answer [ 0 ] + " . "   current = 0 for i in range ( float_start - 1 , start - 1 , - 1 ) : current += 1 answer += s [ i ] if current == 3 and i != start : answer += " , " current = 0 answer += " $ "   if start == 1 : print ( f " ( { answer [ : : -1 ] } ) " ) else : print ( answer [ : : - 1 ] ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int [ ] value = new int [ n ] ; for ( int i = 0 ; i < value . length ; i ++ ) { value [ i ] = in . nextInt ( ) ; } int l = 0 , r = n - 1 ; int s = 0 , d = 0 ; boolean p = true ; while ( l <= r ) { if ( value [ l ] >= value [ r ] ) { if ( p ) s += value [ l ] ; else d += value [ l ] ; l ++ ; } else if ( value [ r ] > value [ l ] ) { if ( p ) s += value [ r ] ; else d += value [ r ] ; r -- ; } if ( p ) p = false ; else p = true ; } System . out . println ( s + " ▁ " + d ) ; } }

import java . util . Scanner ; import java . util . Arrays ; import java . util . * ; import java . math . * ; import java . io . * ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int cards = s . nextInt ( ) ; int a [ ] = new int [ cards ] ; int end = cards - 1 ; int start = 0 ; int se = 0 ; int d = 0 ; boolean f = true ; for ( int i = 0 ; i < cards ; i ++ ) { a [ i ] = s . nextInt ( ) ; } for ( int i = 0 ; i < cards ; i ++ ) { if ( f == true ) { if ( a [ start ] > a [ end ] ) { se += a [ start ] ; start ++ ;   } else { se += a [ end ] ; end -- ; } f = false ; } else {   if ( a [ start ] > a [ end ] ) { d += a [ start ] ; start ++ ;   } else { d += a [ end ] ; end -- ; } f = true ; }   } System . out . print ( se + " ▁ " + d ) ; }   }

import java . util . * ; public class GFG { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = 1 ;   while ( t -- > 0 )   { int sp = 0 , dp = 0 ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int first = 0 ; int last = a . length - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ last ] > a [ first ] ) { if ( i % 2 == 0 ) sp = sp + a [ last ] ; else dp = dp + a [ last ] ; last -- ; } else { if ( i % 2 == 0 ) sp = sp + a [ first ] ; else dp = dp + a [ first ] ; first ++ ; } } System . out . println ( sp + " ▁ " + dp ) ; } } }

import java . util . ArrayList ; import java . util . Collections ; import java . util . HashSet ; import java . util . Scanner ;   public class Main {   public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; ArrayList < Integer > list = new ArrayList ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( scanner . nextInt ( ) ) ; } int l = 0 , r = 0 ; for ( int t = 0 , i = 0 , j = n - 1 ; i <= j ; t ++ ) { if ( t % 2 == 0 ) { if ( list . get ( i ) > list . get ( j ) ) { l += list . get ( i ) ; i ++ ; } else { l += list . get ( j ) ; j -- ; } } else { if ( list . get ( i ) > list . get ( j ) ) { r += list . get ( i ) ; i ++ ; } else { r += list . get ( j ) ; j -- ; } } } System . out . println ( l + " ▁ " + r ) ; } }

import java . util . * ; import java . io . * ; import java . lang . * ; public class Code { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } int i = 0 ; int j = arr . length - 1 ; boolean flag = true ; int s = 0 ; int d = 0 ; while ( i <= j ) { if ( flag == true ) { if ( arr [ i ] > arr [ j ] ) { s = s + arr [ i ] ; flag = false ; i ++ ; } else { s = s + arr [ j ] ; flag = false ; j -- ; } } else { if ( arr [ i ] > arr [ j ] ) { d = d + arr [ i ] ; flag = true ; i ++ ; } else { d = d + arr [ j ] ; flag = true ; j -- ; } } } System . out . println ( s + " ▁ " + d ) ; } }

from collections import deque   n = int ( input ( ) ) a = [ int ( i ) for i in input ( ) . split ( ) ] b = [ 0 , 0 ] x , y = 0 , n - 1 for i in range ( n ) : if a [ x ] > a [ y ] : b [ i % 2 ] += a [ x ] x += 1 else : b [ i % 2 ] += a [ y ] y -= 1 print ( * b , sep = ' ▁ ' ) NEW_LINE

n = int ( input ( ) ) a = [ int ( x ) for x in input ( ) . split ( ) ] ans = [ 0 , 0 ] k = 0 i = 0j = n - 1 while ( n > 0 ) : if ( a [ i ] > a [ j ] ) : ans [ k ] += a [ i ] i += 1 else : ans [ k ] += a [ j ] j -= 1 n -= 1 if ( k == 0 ) : k = 1 else : k = 0   print ( " { } ▁ { } " . format ( ans [ 0 ] , ans [ 1 ] ) ) NEW_LINE

n = int ( input ( ) ) a = tuple ( map ( int , input ( ) . split ( ) ) ) i , j = 0 , n - 1 x = y = 0 c = 1 while i <= j : if a [ i ] >= a [ j ] : if c : x += a [ i ] else : y += a [ i ] i += 1 else : if c : x += a [ j ] else : y += a [ j ] j -= 1 c = not c and 1 print ( x , y ) NEW_LINE

n = int ( input ( ) ) l = input ( ) . split ( ) p = [ ] for x in l : p . append ( int ( x ) ) i = 0j = len ( p ) - 1 note = 0 ser = [ ] dim = [ ] while i <= j : if p [ i ] <= p [ j ] and note == 0 : ser . append ( p [ j ] ) j = j - 1 note = 1 elif p [ i ] > p [ j ] and note == 0 : ser . append ( p [ i ] ) i = i + 1 note = 1 elif p [ i ] <= p [ j ] and note == 1 : dim . append ( p [ j ] ) j = j - 1 note = 0 elif p [ i ] > p [ j ] and note == 1 : dim . append ( p [ i ] ) i = i + 1 note = 0 NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ;   import java . util . * ; public class Main { static long find ( long n ) { if ( n == 1 ) return 1 ; long ans = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { ans *= 2 ; } return ans + find ( n - 1 ) ; } public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; StringBuilder ans = new StringBuilder ( ) ; String temp = " abcd " ; for ( int i = 0 ; i < n ; i ++ ) { ans . append ( temp . charAt ( i % 4 ) ) ; } System . out . println ( ans ) ;   out . flush ( ) ; }

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ;    @ SuppressWarnings ( " unused " ) public class A { public static Scanner scan = new Scanner ( System . in ) ; static char [ ] c = { ' a ' , ' b ' , ' c ' , ' d ' } ; public static void solve ( ) { int n = scan . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { System . out . print ( c [ i % 4 ] ) ; } } public static void main ( String [ ] args ) { solve ( ) ; scan . close ( ) ; }   }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; String s = " abcd " ; for ( int i = 0 ; i < n / 4 ; i ++ ) System . out . print ( s ) ; System . out . print ( s . substring ( 0 , n % 4 ) ) ; } }

n = int ( input ( ) ) for i in range ( n ) : if i % 4 == 0 : print ( " a " , end = " " ) elif i % 4 == 1 : print ( " b " , end = " " ) elif i % 4 == 2 : print ( " c " , end = " " ) elif i % 4 == 3 : print ( " d " , end = " " ) NEW_LINE

n = int ( input ( ) ) s = " abcd " * ( 4 * n ) print ( s [ : n ] ) NEW_LINE

import sys   def input ( ) : return sys . stdin . readline ( ) . strip ( ) def iinput ( ) : return int ( input ( ) ) def rinput ( ) : return map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) def get_list ( ) : return list ( map ( int , sys . stdin . readline ( ) . strip ( ) . split ( ) ) )       n = iinput ( ) s = [ ] for i in range ( n ) : if ( i == 0 or i % 4 == 0 ) : s . append ( ' a ' ) elif ( i == 1 or ( i - 1 ) % 4 == 0 ) : s . append ( ' b ' ) elif ( i == 2 or ( i - 2 ) % 4 == 0 ) : s . append ( ' c ' ) elif ( i == 3 or ( i - 3 ) % 4 == 0 ) : s . append ( ' d ' )   print ( " " . join ( s ) ) NEW_LINE

n = int ( input ( ) ) s = " abcd " for i in range ( n // 4 ) : print ( s , end = " " ) print ( s [ : n % 4 ] , end = " " ) NEW_LINE

n = int ( input ( ) )   x = ' abcdefghijklmnopqrstuvwxyz '     u = [ 0 ] * ( n )   s = 0 for j in range ( n ) : if u [ j ] == 0 : while j < n : u [ j ] = x [ s ] j += 4 s = ( s + 1 ) % 26     print ( ' ' . join ( u ) ) NEW_LINE


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

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

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

import java . util . Scanner ;   public class Taymyr { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; int z = scanner . nextInt ( ) ;   int intersection = 0 ; for ( int i = n ; i <= z ; i = i + n ) { for ( int j = m ; j <= z ; j = j + m ) { if ( i == j ) { intersection ++ ; } } }   System . out . println ( intersection ) ; }    }

def rec ( n , z , l , x , y ) : if n > z : return l elif n == z : l . append ( n ) return l else : if n not in l : l . append ( n ) rec ( n * x , z , l , x , y ) rec ( n * y , z , l , x , y )     def gcd ( x , y ) : if x < y : x , y = y , x if y == 0 : return x return gcd ( y , x % y )     def lcm ( x , y ) : if x < y : x , y = y , x gcd_ = gcd ( x , y ) return x * y // gcd_     def main_func ( ) : x , y , z = [ int ( i ) for i in input ( ) . split ( " ▁ " ) ] count = 0 for i in range ( 1 , z + 1 ) : if not i % x and not i % y : count += 1   return count   print ( main_func ( ) )       NEW_LINE

import math     if __name__ == ' _ _ main _ _ ' : n , m , z = map ( int , input ( ) . split ( ) ) print ( z // ( n * m // math . gcd ( n , m ) ) ) NEW_LINE

import sysfrom math import gcd   def main ( ) : n , m , z = map ( int , sys . stdin . read ( ) . strip ( ) . split ( ) ) return z // ( n * m // gcd ( n , m ) ) print ( main ( ) ) NEW_LINE

import mathn , m , z = map ( int , input ( ) . split ( ) ) print ( z // ( ( n * m ) // math . gcd ( n , m ) ) ) NEW_LINE

n , m , z = map ( int , input ( ) . split ( ) ) c = 0 for i in range ( m , z + 1 , m ) : if i % n == 0 : c += 1 print ( c ) NEW_LINE


import java . io . * ;   public class Main { static String str ; static BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; static BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;   public static void main ( String [ ] args ) throws IOException { str = br . readLine ( ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 , j ; i < str . length ( ) ; ++ i ) { if ( str . charAt ( i ) == ' / ' ) { j = i ; while ( j < str . length ( ) && str . charAt ( j ) == ' / ' ) { ++ j ; } sb . append ( str . charAt ( i ) ) ; i = j - 1 ; } else { sb . append ( str . charAt ( i ) ) ; } } int k = sb . length ( ) - 1 ; bw . write ( sb . length ( ) > 1 && sb . charAt ( k ) == ' / ' ? sb . substring ( 0 , k ) : sb . toString ( ) ) ; bw . close ( ) ; } }

import java . util . Scanner ; public class BerOS { public static void main ( String [ ] args ) { Scanner mm = new Scanner ( System . in ) ; String s = mm . next ( ) ; String res = " " ; boolean ok = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != ' / ' ) { ok = true ; res += s . charAt ( i ) ; } else { if ( ok ) { res += " / " ; } ok = false ; } } if ( res . charAt ( res . length ( ) - 1 ) == ' / ' && res . length ( ) > 1 ) { res = res . substring ( 0 , res . length ( ) - 1 ) ; } System . out . println ( res ) ; } }

import java . util . Scanner ; public class Code19 { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; String s = in . next ( ) ; String res = " " ; boolean ok = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) != ' / ' ) { ok = true ; res += s . charAt ( i ) ; } else { if ( ok ) { res += " / " ; } ok = false ; } } if ( res . charAt ( res . length ( ) - 1 ) == ' / ' && res . length ( ) > 1 ) { res = res . substring ( 0 , res . length ( ) - 1 ) ; } System . out . println ( res ) ; } }

import java . io . File ; import java . io . FileNotFoundException ; import java . io . PrintWriter ; import java . util . Arrays ; import java . util . Scanner ; import java . util . Stack ; public class test { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; String output = " " ; boolean open = false , f = false ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . charAt ( i ) == ' / ' ) { open = true ; } else { if ( open ) { open = false ; output += ' / ' ; } f = true ; output += str . charAt ( i ) ; } } if ( open && ! f ) output += ' / ' ; System . out . println ( output ) ; } }

linha = input ( ) . split ( ' / ' ) ans = [ ]   for i in range ( len ( linha ) ) : if len ( linha [ i ] ) > 0 : ans . append ( linha [ i ] ) print ( ' / ' + ' / ' . join ( ans ) ) NEW_LINE

path = list ( filter ( lambda x : len ( x ) != 0 , input ( ) . split ( ' / ' ) ) ) print ( ' / ' + ' / ' . join ( path ) ) NEW_LINE

s = input ( ) . strip ( ) x = [ 1 ]   for i in s :   if i != ' / ' : x . append ( i ) else : if x [ - 1 ] != i : x . append ( i ) if x [ - 1 ] == ' / ' and len ( x ) > 2 : print ( ' ' . join ( x [ 1 : len ( x ) - 1 ] ) ) else : print ( ' ' . join ( x [ 1 : ] ) ) NEW_LINE

d = [ x for x in input ( ) . split ( ' / ' ) if x ] print ( ' / ' + ' / ' . join ( d ) ) NEW_LINE

print ( ' / ' + ' / ' . join ( filter ( lambda x : len ( x ) , input ( ) . split ( ' / ' ) ) ) ) NEW_LINE


import java . util . * ; import java . io . * ;   public class Accordion { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( System . out ) ;   int t = 1 ;   while ( t -- > 0 ) {   char a [ ] = br . readLine ( ) . trim ( ) . toCharArray ( ) ; int n = a . length ;   int i = 0 ; for ( ; i < n ; i ++ ) { if ( a [ i ] == ' [ ' ) break ; } int j = i + 1 ; for ( ; j < n ; j ++ ) { if ( a [ j ] == ' : ' ) break ; } int k = n - 1 ; for ( ; k >= 0 ; k -- ) { if ( a [ k ] == ' ] ' ) break ; } int l = k - 1 ; for ( ; l >= 0 ; l -- ) { if ( a [ l ] == ' : ' ) break ; }    if ( j < l ) { int count = 0 ; for ( int p = j + 1 ; p < l ; p ++ ) { if ( a [ p ] == ' | ' ) count ++ ; } pw . println ( count + 4 ) ; } else { pw . println ( - 1 ) ; } } pw . flush ( ) ; }   }

import java . io . IOException ; import java . io . InputStream ; import java . util . InputMismatchException ; public class BEducation58 {   public static void main ( String [ ] args ) { FastScanner in = new FastScanner ( System . in ) ; String g = in . next ( ) ; int ans = ans ( g ) ; System . out . println ( ans ) ; } public static int ans ( String g ) { int index0 = g . indexOf ( ' [ ' ) ; int index1 = g . lastIndexOf ( ' ] ' ) ; if ( index0 == - 1 || index1 == - 1 || index0 > index1 ) { return - 1 ; } int index2 = g . indexOf ( ' : ' , index0 ) ; int index3 = - 1 ; for ( int i = index1 ; i >= 0 ; i -- ) { if ( g . charAt ( i ) == ' : ' ) { index3 = i ; break ; } } if ( index2 == - 1 || index3 == - 1 || index2 >= index3 ) { return - 1 ; }

import java . util . Scanner ; public class Accordion {   public static void main ( String [ ] args ) { Scanner obj = new Scanner ( System . in ) ; String s = obj . next ( ) ; int c1 = 0 , c2 = 0 , c3 = 0 , c4 = 0 , c5 = 0 ; int idx = s . lastIndexOf ( ' [ ' ) ; int idx2 = s . lastIndexOf ( ' ] ' ) ; int k = 0 ;   for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ' [ ' ) { c1 = 1 ; continue ; } if ( s . charAt ( i ) == ' : ' && c1 > c2 ) { c2 ++ ; k = i ; continue ; } } int g = 0 ; for ( int i = s . length ( ) - 1 ; i > k ; i -- ) { if ( s . charAt ( i ) == ' ] ' ) { c4 ++ ; continue ; } if ( c4 > c5 && s . charAt ( i ) == ' : ' ) { c5 = 1 ; g = i ; break ; }   } for ( int i = k + 1 ; i < g ; i ++ ) { if ( s . charAt ( i ) == ' | ' ) c3 ++ ; } if ( c1 == 0 || c2 == 0 || c4 == 0 || c5 == 0 ) { System . out . println ( " - 1" ) ; } else System . out . println ( 4 + c3 ) ;   }   }

s = input ( ) ans = 0 i , j = 0 , len ( s ) - 1 while i < j and s [ i ] != ' [ ' : i += 1 while j > i and s [ j ] != " ] " : j -= 1 if i > j : print ( - 1 ) else : ans += 2 i += 1 j -= 1 while i < j and s [ i ] != ' : ' : i += 1 while j > i and s [ j ] != " : " : j -= 1 if i >= j : print ( - 1 ) else : ans += 2 i += 1 j -= 1 while i <= j : if s [ i ] == " | " : ans += 1 i += 1 print ( ans )   NEW_LINE

r = list ( " [ : : ] " )   s = str ( input ( ) ) r = [ " [ " , " : " ] left = - 1 for i in range ( 0 , len ( s ) - 2 ) : if s [ i ] == r [ 0 ] : del ( r [ 0 ] ) if r == [ ] : left = i breakif left != - 1 : r = [ " ] " , " : " ] right = - 1 for i in range ( len ( s ) - 1 , left , - 1 ) : if s [ i ] == r [ 0 ] : del ( r [ 0 ] ) if r == [ ] : right = i break if right != - 1 : bb = 0 for i in range ( left + 1 , right ) : if s [ i ] == " | " : bb += 1 print ( 4 + bb ) else : print ( - 1 ) else : print ( - 1 ) NEW_LINE

import sys , string , heapq   arr = list ( sys . stdin . readline ( ) . rstrip ( ) ) n = len ( arr ) left = 0 right = 2 * nwhile left < right : mid = ( left + right ) // 2 res = { ' [ ' : 9876543210 , ' : ' : [ 9876543210 , - 1 ] , ' ] ' : - 1 } can = False for i in range ( n ) : if arr [ i ] == ' [ ' : res [ arr [ i ] ] = min ( res [ arr [ i ] ] , i ) elif arr [ i ] == ' ] ' : res [ arr [ i ] ] = max ( res [ arr [ i ] ] , i ) if res [ ' [ ' ] != 9876543210 and res [ ' ] ' ] != - 1 : for i in range ( n ) : if arr [ i ] == ' : ' : if res [ ' [ ' ] < i < res [ ' ] ' ] : res [ ' : ' ] [ 0 ] = min ( res [ ' : ' ] [ 0 ] , i ) res [ ' : ' ] [ 1 ] = max ( res [ ' : ' ] [ 1 ] , i ) if res [ ' : ' ] [ 0 ] != res [ ' : ' ] [ 1 ] : if res [ ' : ' ] [ 0 ] != 9876543210 and res [ ' : ' ] [ 1 ] != - 1 : cnt = 0 for i in range ( n ) : if arr [ i ] == ' | ' and res [ ' : ' ] [ 0 ] < i < res [ ' : ' ] [ 1 ] : cnt += 1 if cnt >= mid - 4 : can = True if can : left = mid + 1 else : right = midprint ( right - 1 ) NEW_LINE

import mathsa = lambda : input ( ) sb = lambda : int ( input ( ) ) sc = lambda : input ( ) . split ( ) sd = lambda : list ( map ( int , input ( ) . split ( ) ) ) se = lambda : float ( input ( ) ) sf = lambda : list ( input ( ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ;    public class Another {   public static void main ( String [ ] args ) throws IOException { FastReader in = new FastReader ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; long m = in . nextLong ( ) ; long R = in . nextLong ( ) ; pw . printf ( " % .12f \n " , ( 2 + 2. * ( m - 1 ) * m * ( m + 1 ) / 3 / m / m - 2 * ( 2 - Math . sqrt ( 2 ) ) + ( 2 - Math . sqrt ( 2 ) ) * ( 2 * m + 2 * ( m - 1 ) ) / m / m ) * R ) ; pw . flush ( ) ; pw . close ( ) ; } static class FastReader { StringTokenizer st ; BufferedReader br ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } public String next ( ) throws IOException { if ( st == null || ! st . hasMoreTokens ( ) ) { st = new StringTokenizer ( br . readLine ( ) ) ; } return st . nextToken ( ) ; } public boolean hasNext ( ) throws IOException { if ( st != null && st . hasMoreTokens ( ) ) { return true ; } String s = br . readLine ( ) ; if ( s == null || s . isEmpty ( ) ) { return false ; } st = new StringTokenizer ( s ) ; return true ; } public int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) throws IOException { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) throws IOException { return br . readLine ( ) ; } } }

import java . io . BufferedInputStream ; import java . math . BigDecimal ; import java . math . RoundingMode ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner cin = new Scanner ( new BufferedInputStream ( System . in ) ) ; int m = cin . nextInt ( ) ; BigDecimal R = cin . nextBigDecimal ( ) ;   BigDecimal ans = BigDecimal . ZERO , TWO = BigDecimal . valueOf ( 2 ) , s2 = new BigDecimal ( Math . sqrt ( 2 ) ) ; for ( int i = 0 ; i != m ; ++ i ) { BigDecimal v = BigDecimal . ONE ; BigDecimal u = BigDecimal . valueOf ( i ) ; u = u . add ( BigDecimal . ONE ) ;   BigDecimal dis = BigDecimal . ZERO ; if ( u == v ) dis = R . multiply ( TWO ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Comparator ; import java . util . List ;   public class Main {   IIO io ;   Main ( IIO io ) { this . io = io ; }   public static void main ( String [ ] args ) throws IOException {

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . HashMap ; import java . util . HashSet ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Solution { public static void main ( String [ ] args ) throws IOException { FastScanner fs = new FastScanner ( ) ; PrintWriter out = new PrintWriter ( System . out ) ; int tt = 1 ; while ( tt -- > 0 ) { int m = fs . nextInt ( ) , r = fs . nextInt ( ) ; double dist = 0 ; double l = Math . sqrt ( 2 ) * r ; for ( int i = 1 ; i <= m ; i ++ ) { dist += 2 * r ; if ( i > 1 ) { dist += 2 * r + l ; dist += ( i - 2 ) * r + ( i - 2 ) * 2 * l + ( double ) ( i - 2 ) * ( i - 2 ) * r ; } if ( i < m ) { dist += 2 * r + l ; dist += ( m - i - 1 ) * r + ( m - i - 1 ) * 2 * l + ( double ) ( m - i - 1 ) * ( m - i - 1 ) * r ; } } double avg = dist / ( ( double ) m * m ) ; out . println ( avg ) ; } out . close ( ) ; } static final Random random = new Random ( ) ; static void ruffleSort ( int [ ] a ) { int n = a . length ;

m , r = map ( int , input ( ) . split ( ) )   answer = 0 from math import sqrt     def fef ( vev ) : if vev == 0 : return 0 if vev <= 1 : return 2 * r + sqrt ( 2 ) * r curr = 2 * r + sqrt ( 2 ) * r curr += ( vev - 1 ) * ( 2 * r + sqrt ( 2 ) * 2 * r )   curr += r * ( vev - 1 ) * ( vev - 2 ) return curr       for i in range ( m ) : answer += fef ( i ) answer += fef ( m - 1 - i ) answer += 2 * r   print ( answer / ( m ** 2 ) ) NEW_LINE


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

import com . sun . security . jgss . GSSUtil ; import org . w3c . dom . Node ;   import javax . print . DocFlavor ; import javax . swing . table . AbstractTableModel ; import java . io . * ; import java . util . * ; import java . util . concurrent . ConcurrentHashMap ; import java . util . concurrent . atomic . AtomicReferenceFieldUpdater ;

import java . util . ArrayList ; import java . util . Arrays ; import java . util . HashMap ; import java . util . LinkedHashMap ; import java . util . Map ; import java . util . Scanner ; import java . util . * ; import java . util . stream . Collectors ;   public class absolute { static List < Integer > primes ; static int total ; static void generatePrimes ( ) { boolean [ ] ar = new boolean [ total + 1 ] ; Arrays . fill ( ar , true ) ; ar [ 1 ] = true ; ar [ 2 ] = true ; for ( int i = 2 ; i <= Math . sqrt ( total ) ; i ++ ) { if ( ar [ i ] == true ) { for ( int j = i * i ; j <= total ; j += i ) ar [ j ] = false ; } } for ( int i = 2 ; i <= total ; i ++ ) if ( ar [ i ] ) primes . add ( i ) ; } public static void main ( String [ ] args ) {

n = int ( input ( ) ) list_a = input ( ) one_a = list_a . count ( "1" ) two_a = list_a . count ( "2" ) new_list = [ ] ps = 0 if two_a >= 1 : new_list . append ( 2 ) two_a -= 1 ps = 2 for i in range ( len ( new_list ) , n ) : if ( two_a > 0 and ps % 2 != 0 ) or one_a == 0 : ps += 2 two_a -= 1 new_list . append ( 2 ) if one_a == 0 : for i in range ( two_a ) : new_list . append ( 2 ) break elif ( one_a > 0 and ps % 2 == 0 ) or two_a == 0 : ps += 1 one_a -= 1 new_list . append ( 1 ) for i in range ( n - 1 ) : print ( new_list [ i ] , end = " ▁ " ) print ( new_list [ n - 1 ] ) NEW_LINE

N = int ( input ( ) ) one = input ( ) . count ( '1' ) two = N - oneif not one or not two : ans = [ 1 ] * one + [ 2 ] * twoelse : ans = [ 2 , 1 ] + [ 2 ] * ( two - 1 ) + [ 1 ] * ( one - 1 ) print ( * ans ) NEW_LINE

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) ones = l . count ( 1 ) twos = n - onesif ones >= 3 : print ( "1 ▁ 1 ▁ 1 ▁ " + "2 ▁ " * twos + "1 ▁ " * ( ones - 3 ) ) elif ones == 2 : if twos : print ( "2 ▁ 1 ▁ " + "2 ▁ " * ( twos - 1 ) + "1" ) else : print ( "1 ▁ 1" ) elif ones == 1 : if twos : print ( "2 ▁ 1 ▁ " + "2 ▁ " * ( twos - 1 ) ) else : print ( "1" ) else : print ( "2 ▁ " * twos ) NEW_LINE

from math import sqrtfrom collections import Counter   n = int ( input ( ) ) arr = [ int ( i ) for i in input ( ) . split ( ) ] c = Counter ( arr ) summa = sum ( arr ) sieve = [ True ] * ( summa + 1 )   if summa == 1 : print ( 1 ) exit ( )   if c [ 1 ] == 0 and c [ 2 ] : print ( '2 ▁ ' * c [ 2 ] ) exit ( ) elif c [ 2 ] == 0 and c [ 1 ] : print ( c [ 1 ] * '1 ▁ ' ) exit ( ) for i in range ( 2 , int ( sqrt ( summa ) ) + 1 ) : if sieve [ i ] : for j in range ( i ** 2 , summa + 1 , i ) : sieve [ j ] = False       s = 0   for i in range ( 2 , summa + 1 ) : ok = sieve [ i ] if ok : k = abs ( i - s ) if k // 2 : if c [ 2 ] > k // 2 : s += ( k // 2 ) * 2 c [ 2 ] -= k // 2 print ( ( k // 2 ) * '2 ▁ ' , end = ' ' ) k %= 2 elif c [ 2 ] : print ( c [ 2 ] * '2 ▁ ' , end = ' ' ) k -= c [ 2 ] * 2 s += c [ 2 ] * 2 c [ 2 ] = 0 if k : if c [ 1 ] > k : print ( '1 ▁ ' * k , end = ' ' ) s += k c [ 1 ] -= k elif c [ 1 ] : print ( c [ 1 ] * '1 ▁ ' , end = ' ' ) s += c [ 1 ] c [ 1 ] = 0   if c [ 1 ] or c [ 2 ] : print ( c [ 1 ] * '1 ▁ ' , end = ' ' ) print ( c [ 2 ] * '2 ▁ ' , end = ' ' ) NEW_LINE

import sysimport mathdef fn ( n , a ) : cnt = [ 0 ] * 2 for i in range ( n ) : cnt [ a [ i ] - 1 ] = cnt [ a [ i ] - 1 ] + 1 if cnt [ 0 ] == 0 or cnt [ 1 ] == 0 : for i in range ( n ) : print ( a [ i ] , end = ' ▁ ' ) return 0 if cnt [ 0 ] % 2 != 0 : print ( 2 , end = ' ▁ ' ) for i in range ( cnt [ 0 ] ) : print ( 1 , end = ' ▁ ' ) for i in range ( cnt [ 1 ] - 1 ) : print ( 2 , end = ' ▁ ' ) elif cnt [ 0 ] % 2 == 0 : print ( 2 , end = ' ▁ ' ) print ( 1 , end = ' ▁ ' ) for i in range ( cnt [ 1 ] - 1 ) : print ( 2 , end = ' ▁ ' ) for i in range ( cnt [ 0 ] - 1 ) : print ( 1 , end = ' ▁ ' ) if __name__ == ' _ _ main _ _ ' : input = sys . stdin . read ( ) data = list ( map ( int , input . split ( ) ) ) n = int ( data [ 0 ] ) a = data [ 1 : ] ( fn ( n , a ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ;    public class HelpFarmer { final static long INF = ( long ) 1e11 ; public static void main ( String [ ] args ) throws NumberFormatException , IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long n = Long . parseLong ( br . readLine ( ) ) ; long max = 0 , min = INF ; for ( long x = 1 ; x * x * x <= n ; x ++ ) { if ( n % x == 0 ) { for ( long y = x ; y * y <= n / x ; y ++ ) { if ( n % ( x * y ) == 0 ) { long z = ( n / ( x * y ) ) ; long a1 = x + 1 , b1 = y + 2 , c1 = z + 2 ; long cur = a1 * b1 * c1 - n ; if ( cur > max ) max = cur ; if ( cur < min ) min = cur ; long a2 = y + 1 , b2 = x + 2 , c2 = z + 2 ; long cur2 = a2 * b2 * c2 - n ; if ( cur2 > max ) max = cur2 ; if ( cur2 < min ) min = cur ; long a3 = z + 1 , b3 = x + 2 , c3 = y + 2 ; long cur3 = a3 * b3 * c3 - n ; if ( cur3 > max ) max = cur3 ; if ( cur3 < min ) min = cur ; } } } } System . out . println ( min + " ▁ " + max ) ; } }

n = int ( raw_input ( ) ) d = [ ] res = 10 * * 20 res1 = 0f or i in range ( 1 , int ( n * * 0.5 ) + 1 ) : if n % i == 0 : d . append ( i ) d . append ( n / i ) for i in range ( len ( d ) ) : for j in range ( len ( d ) ) : if n % ( d [ i ] * d [ j ] ) == 0 : res = min ( res , ( ( d [ i ] + 1 ) * ( d [ j ] + 2 ) * ( n / ( d [ i ] * d [ j ] ) + 2 ) ) - n ) res1 = max ( res1 , ( ( d [ i ] + 1 ) * ( d [ j ] + 2 ) * ( n / ( d [ i ] * d [ j ] ) + 2 ) ) - n ) print res , res1

from math import sqrtp , n = [ ] , int ( input ( ) ) def f ( x , y ) : return ( x + 2 ) * ( y + 2 ) + ( 2 * ( x + y + 2 ) * n ) // ( x * y ) for x in range ( 2 , int ( sqrt ( n ) ) + 1 ) : if n % x == 0 : p . append ( x ) p += [ n // x for x in reversed ( p ) ] p . append ( n ) u = v = f ( 1 , 1 ) for m in p : for x in range ( 1 , int ( sqrt ( m ) ) + 1 ) : if m % x == 0 : u = min ( u , f ( x , m // x ) ) print ( u , v ) NEW_LINE

n = int ( input ( ) ) u = v = 9 + 8 * nfor a in range ( 1 , int ( n ** ( 1 / 3 ) ) + 1 ) : if n % a : continue m = n // a for b in range ( a , int ( m ** 0.5 ) + 1 ) : if m % b : continue p = ( a + 1 ) * ( b + 2 ) * ( m // b + 2 ) - n if u > p : u = pprint ( u , v ) NEW_LINE


import java . util . * ; import java . math . * ; public class CommonPrefixes { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int runs = sc . nextInt ( ) ; boolean a = true ; while ( runs -- > 0 ) { int size = sc . nextInt ( ) ; int num = 0 ; char [ ] s = new char [ 200 ] ; Arrays . fill ( s , ' a ' ) ; System . out . println ( String . valueOf ( s ) ) ; for ( int i = 0 ; i < size ; i ++ ) { int temp = sc . nextInt ( ) ; if ( s [ temp ] == ' a ' ) s [ temp ] = ' b ' ; else s [ temp ] = ' a ' ; System . out . println ( String . valueOf ( s ) ) ; } } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . StringTokenizer ; import java . util . TreeMap ;   public class Main implements Runnable { int n , m , k ; static boolean use_n_tests = true ;

import java . util . * ; public class _1384A { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int t = sc . nextInt ( ) ; while ( t -- > 0 ) { int n = sc . nextInt ( ) ; char [ ] arr = new char [ 51 ] ; for ( int i = 0 ; i < 51 ; i ++ ) arr [ i ] = ' a ' ; System . out . println ( new String ( arr ) ) ; for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; arr [ x ] = ( arr [ x ] == ' a ' ) ? ' b ' : ' a ' ; System . out . println ( new String ( arr ) ) ; } } } }

import sys   def answer ( n , a ) : dir = 1 pword = [ ' a ' ] * 51 print ( ' ' . join ( pword ) ) for i in range ( n ) : if pword [ a [ i ] ] == ' a ' : pword [ a [ i ] ] = ' b ' else : pword [ a [ i ] ] = ' a ' print ( ' ' . join ( pword ) ) return   def main ( ) : t = int ( input ( ) ) while t : n = int ( sys . stdin . readline ( ) ) a = [ int ( i ) for i in sys . stdin . readline ( ) . split ( ) ] answer ( n , a )   t -= 1 returnmain ( ) NEW_LINE

t = int ( input ( ) ) for _ in range ( t ) : n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) s = [ ' a ' * 52 ] tmp = { ' a ' : ' b ' , ' b ' : ' a ' } for i in range ( n ) : p = s [ - 1 ] [ 0 : arr [ i ] ] + tmp [ s [ - 1 ] [ arr [ i ] ] ] * ( 52 - arr [ i ] ) s . append ( p ) for i in range ( n + 1 ) : print ( s [ i ] ) NEW_LINE

from sys import stdininput = stdin . readlinefrom heapq import heapify , heappush , heappop , heappushpopfrom collections import defaultdict as dd , deque as dq , Counter as Cfrom math import factorial as f , ceil , gcd , sqrt , logfrom bisect import bisect_left as bl , bisect_right as brfrom itertools import combinations as c , permutations as pfrom math import factorial as f , ceil , gcd , sqrt , logmp = lambda : map ( int , input ( ) . split ( ) ) it = lambda : int ( input ( ) ) ls = lambda : list ( input ( ) . strip ( ) ) mt = lambda r : [ list ( mp ( ) ) for _ in range ( r ) ] lcm = lambda a , b : ( a * b ) // gcd ( a , b ) def fibo_n ( n ) : return ( ( ( 1 + sqrt ( 5 ) ) / 2 ) ** n ) / sqrt ( 5 ) mod = 1000000007 for _ in range ( it ( ) ) : a = it ( ) b = list ( mp ( ) ) v = [ " a " ] * 200 print ( " " . join ( v ) ) for i in b : if v [ i ] == " a " : v [ i ] = " b " else : v [ i ] = " a " print ( " " . join ( v ) ) NEW_LINE


import java . io . * ; import java . util . Arrays ; import java . util . StringTokenizer ;

import java . io . BufferedReader ; import java . io . BufferedWriter ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . OutputStreamWriter ; import java . io . PrintWriter ; import java . util . StringTokenizer ;   public class temp4 { static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } static class Print { private final BufferedWriter bw ; public Print ( ) { bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ; } public void print ( String str ) throws IOException { bw . append ( str ) ; } public void println ( String str ) throws IOException { print ( str ) ; bw . append ( " \n " ) ; } public void close ( ) throws IOException { bw . close ( ) ; } } public static void main ( String [ ] args ) throws IOException { FastReader scn = new FastReader ( ) ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import static java . lang . Math . * ; import static java . lang . System . out ; import java . util . * ; import java . io . PrintStream ; import java . io . PrintWriter ; public class A { static final int N = ( int ) ( 1e5 + 100 ) ; static final int mod = 1000000007 ; static final long temp = 998244353 ; static final long MOD = 1000000007 ; static final long M = ( long ) 1e9 + 7 ; static class Pair implements Comparable < Pair > { int first , second ; public Pair ( int aa , int bb ) { first = aa ; second = bb ; } public int compareTo ( Pair o ) { return o . first - this . first ; } } static class Tuple implements Comparable < Tuple > { long first , second , third ; public Tuple ( long first , long second , long third ) { this . first = first ; this . second = second ; this . third = third ; } public int compareTo ( Tuple o ) { return ( int ) ( o . third - this . third ) ; } } public static class DSU { int [ ] parent ; int [ ] rank ;

from sys import stdin , stdoutinput = stdin . readline def main ( ) : n , k = map ( int , input ( ) . split ( ) ) ar = [ 1 ] * 5001 ai = list ( map ( int , input ( ) . split ( ) ) ) ans = [ 0 ] * n for i in range ( n ) : ans [ i ] = ar [ ai [ i ] ] ar [ ai [ i ] ] += 1 if ans [ i ] > k : print ( " NO " ) return temp = max ( ans ) if temp < k : ar = [ 0 ] * 5000 ar2 = [ ] for i in range ( n ) : if ar [ ans [ i ] - 1 ] : ar2 += [ i ] ar [ ans [ i ] - 1 ] = 1 z = 1 for j in range ( temp + 1 , k + 1 ) : ans [ ar2 [ z - 1 ] ] = j z += 1 print ( " YES " ) print ( * ans ) main ( )   NEW_LINE

n , k = [ * map ( int , input ( ) . split ( ) ) ] l = [ * map ( int , input ( ) . split ( ) ) ] d = { } for i in range ( n ) : if l [ i ] in d : d [ l [ i ] ] = d [ l [ i ] ] + 1 else : d [ l [ i ] ] = 1 if max ( d . values ( ) ) > k or k > n : print ( ' NO ' ) else : print ( ' YES ' ) li = [ ] for i in range ( n ) : li . append ( [ l [ i ] , i ] ) li . sort ( key = lambda x : x [ 0 ] ) la = [ ] for i in range ( n ) : la . append ( [ i % k + 1 , li [ i ] [ 1 ] ] ) la . sort ( key = lambda x : x [ 1 ] ) for i in range ( n ) : print ( la [ i ] [ 0 ] , end = ' ▁ ' ) NEW_LINE

from collections import Countern , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = Counter ( a ) if max ( d . values ( ) ) > k : print ( " NO " ) else : print ( " YES " ) b = sorted ( ( x , i ) for ( i , x ) in enumerate ( a ) ) count = 0 ans = [ 0 ] * n for x , i in b : count = count % k + 1 ans [ i ] = count print ( * ans ) NEW_LINE

from collections import defaultdictn , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( int ) for i in range ( n ) : d [ a [ i ] ] += 1 if d [ a [ i ] ] > k : print ( ' NO ' ) exit ( ) ''' m = max ( a )  for ▁ i ▁ in ▁ range ( 1 , m + 1 ) : ▁ ▁ ▁ ▁ if ▁ d [ i ] = = 0 : ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ print ( ' NO ' ) ▁ ▁ ▁ ▁ ▁ ▁ ▁ ▁ exit ( ) ''' ans = [ - 1 for i in range ( n ) ] d = defaultdict ( int ) for j in range ( n ) : y = a [ j ] d [ y ] += 1   t = [ ] for i in range ( n ) : t . append ( [ d [ a [ i ] ] , a [ i ] , i ] ) t . sort ( key = lambda x : x [ 1 ] , reverse = True ) t . sort ( key = lambda x : x [ 0 ] , reverse = True ) c = 0 for i in range ( n ) : c += 1 x = t [ i ] [ 2 ] ans [ x ] = c if c == k : c = 0   print ( ' YES ' ) print ( * ans ) NEW_LINE

from collections import defaultdictn , k = map ( int , input ( ) . split ( ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = defaultdict ( int ) for i in range ( n ) : d [ a [ i ] ] += 1 if d [ a [ i ] ] > k : print ( ' NO ' ) exit ( ) ans = [ - 1 for i in range ( n ) ] d = defaultdict ( int ) for j in range ( n ) : y = a [ j ] d [ y ] += 1   t = [ ] for i in range ( n ) : t . append ( [ d [ a [ i ] ] , a [ i ] , i ] ) t . sort ( key = lambda x : x [ 1 ] , reverse = True ) t . sort ( key = lambda x : x [ 0 ] , reverse = True ) c = 0 for i in range ( n ) : c += 1 x = t [ i ] [ 2 ] ans [ x ] = c if c == k : c = 0   print ( ' YES ' ) print ( * ans ) NEW_LINE


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

import java . util . * ; public class problem { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; String s = sc . next ( ) ; char [ ] a = new char [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = s . charAt ( i ) ; } int l , r ; char c1 , c2 ; for ( int i = 0 ; i < m ; i ++ ) { l = sc . nextInt ( ) ; r = sc . nextInt ( ) ; c1 = sc . next ( ) . charAt ( 0 ) ; c2 = sc . next ( ) . charAt ( 0 ) ; for ( int j = l - 1 ; j <= r - 1 ; j ++ ) { if ( a [ j ] == c1 ) { a [ j ] = c2 ; } } } for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( a [ j ] ) ; } } }

import java . util . * ; public class Solution { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; int m = s . nextInt ( ) ; s . nextLine ( ) ; String input = s . nextLine ( ) ; String result = " " , result1 = " " ; for ( int i = 0 ; i < m ; i ++ ) { int l = s . nextInt ( ) ; int r = s . nextInt ( ) ; l = l - 1 ; r = r - 1 ; result = " " ; char c1 = s . next ( ) . charAt ( 0 ) ; char c2 = s . next ( ) . charAt ( 0 ) ; for ( int y = 0 ; y < input . length ( ) ; y ++ ) { if ( y >= l && y <= r ) { if ( input . charAt ( y ) == c1 ) { result = result + c2 ; } else result = result + input . charAt ( y ) ; } else result = result + input . charAt ( y ) ; } input = result ; } System . out . println ( result ) ; } }

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

import java . util . Scanner ;   public class Singleton_Pattern { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; sc . nextLine ( ) ; String s = sc . nextLine ( ) ; StringBuilder string = new StringBuilder ( s ) ; for ( int i = 0 ; i < m ; i ++ ) { int l = sc . nextInt ( ) ; int r = sc . nextInt ( ) ; char c1 = sc . next ( ) . charAt ( 0 ) ; char c2 = sc . next ( ) . charAt ( 0 ) ; sc . nextLine ( ) ; Character c3 = Character . valueOf ( c1 ) ; Character c4 = Character . valueOf ( c2 ) ;    for ( int j = l - 1 ; j <= r - 1 ; j ++ ) { Character c5 = Character . valueOf ( string . charAt ( j ) ) ; boolean res = c3 . equals ( c5 ) ; if ( res == true ) string . setCharAt ( j , c2 ) ; }   } System . out . println ( string ) ;   } }

n , m = input ( ) . split ( ) n , m = int ( n ) , int ( m ) string = input ( ) iterator = [ ] for i in range ( m ) : l , r , c1 , c2 = input ( ) . split ( ) l , r = int ( l ) - 1 , int ( r ) - 1 iterator . append ( ( l , r , c1 , c2 ) ) for step in iterator : l , r , c1 , c2 = step [ 0 ] , step [ 1 ] , step [ 2 ] , step [ 3 ] for k in range ( l , r + 1 ) : if string [ k ] == c1 : string = string [ 0 : k ] + c2 + string [ k + 1 : len ( string ) ] print ( string ) NEW_LINE

string_length , test_case = map ( int , input ( ) . split ( ) ) st = list ( input ( ) )     for x in range ( test_case ) : start , end , frm , to = map ( str , input ( ) . split ( ) ) for y in range ( int ( start ) - 1 , int ( end ) ) : if st [ y ] == frm : st [ y ] = toprint ( " " . join ( st ) ) NEW_LINE

import sys   def main ( ) : inp = sys . stdin . read ( ) . strip ( ) . split ( ' \n ' ) s = inp [ 1 ] for i in inp [ 2 : ] : r , l , c , d = i . split ( ) r , l = int ( r ) - 1 , int ( l ) - 1 s = s [ : r ] + s [ r : l + 1 ] . replace ( c , d ) + s [ l + 1 : ] return s print ( main ( ) ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) str1 = input ( ) . lower ( ) for j in range ( m ) : l , r , c1 , c2 = input ( ) . split ( ) l , r = ( int ( l ) - 1 ) , int ( r ) l1 = [ i for i in str1 ] for p in range ( l , r ) : if l1 [ p ] == c1 : l1 [ p ] = c2 s = " " str1 = s . join ( l1 ) print ( str1 ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) s = list ( input ( ) ) for i in range ( m ) : a , b , c , d = map ( str , input ( ) . split ( ) ) a = int ( a ) b = int ( b ) if a == b : if s [ a - 1 ] == c : s [ a - 1 ] = d else : for j in range ( a - 1 , b ) : if s [ j ] == c : s [ j ] = dfor i in s : print ( i , end = ' ' ) NEW_LINE


import java . util . Scanner ; public class Word { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String ch = s . next ( ) ; String ch1 = " " ; String ch2 = " " ; boolean aux = true ; if ( Character . isLowerCase ( ch . charAt ( 0 ) ) ) { for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { if ( Character . isLowerCase ( ch . charAt ( i ) ) ) { aux = false ; break ; } } if ( aux == false ) { System . out . println ( ch ) ; } else { ch1 = ch1 + Character . toUpperCase ( ch . charAt ( 0 ) ) ; for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { ch1 = ch1 + Character . toLowerCase ( ch . charAt ( i ) ) ; } System . out . println ( ch1 ) ; } } else { for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { if ( Character . isLowerCase ( ch . charAt ( i ) ) ) { aux = false ; break ; } } if ( aux == false ) { System . out . println ( ch ) ; } else { ch2 = ch2 + Character . toLowerCase ( ch . charAt ( 0 ) ) ; for ( int i = 1 ; i < ch . length ( ) ; i ++ ) { ch2 = ch2 + Character . toLowerCase ( ch . charAt ( i ) ) ; } System . out . println ( ch2 ) ; } } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; String ch ; do { ch = s . next ( ) ; } while ( ( ch . length ( ) < 1 ) && ( ch . length ( ) > 100 ) ) ; if ( ch . equals ( ch . toUpperCase ( ) ) ) { System . out . println ( ch . toLowerCase ( ) ) ; } else if ( Character . isLowerCase ( ch . charAt ( 0 ) ) && ( ch . substring ( 1 ) ) . equals ( ( ch . substring ( 1 ) ) . toUpperCase ( ) ) ) { System . out . println ( Character . toUpperCase ( ch . charAt ( 0 ) ) + ( ch . substring ( 1 ) ) . toLowerCase ( ) ) ; } else { System . out . println ( ch ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ;   public class cAPS_lOCK { 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 ( ) ; boolean check = true ; char ch ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( Character . isLowerCase ( s . charAt ( i ) ) ) { check = false ; } } if ( check ) { for ( int j = 0 ; j < s . length ( ) ; j ++ ) { if ( Character . isLowerCase ( s . charAt ( j ) ) ) { ch = Character . toUpperCase ( s . charAt ( j ) ) ; } else { ch = Character . toLowerCase ( s . charAt ( j ) ) ; } System . out . print ( ch ) ; } } else { System . out . print ( s ) ; } } }

import java . util . Scanner ;   public class CapsLock { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; boolean flag = true ; if ( str . length ( ) == 1 ) { char ch [ ] = str . toCharArray ( ) ;

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

s = input ( ) x , up , low , st = len ( s ) , 0 , 0 , " " for i in range ( 1 , x ) : if ( ord ( s [ i ] ) > 90 ) : low += 1 else : up += 1 if ( up == ( len ( s ) - 1 ) or len ( s ) == 1 ) : st += s . swapcase ( ) print ( st ) else : print ( s ) NEW_LINE

def compute ( string ) :   if string . isupper ( ) or string [ 1 : ] . isupper ( ) or len ( string ) == 1 : answer = " " for character in string : if character . isupper ( ) : answer += character . lower ( ) else : answer += character . upper ( ) return answer else : return string   if __name__ == ' _ _ main _ _ ' : string = input ( ) print ( compute ( string ) ) NEW_LINE

s = input ( ) ans = sif len ( s ) == 1 or s [ 1 : ] . isupper ( ) : ans = ' ' for c in s : ans += ( c . upper ( ) if c . islower ( ) else c . lower ( ) )   print ( ans ) NEW_LINE

s = input ( ) ; print ( [ s , s . swapcase ( ) ] [ s [ 1 : ] == s [ 1 : ] . upper ( ) ] ) NEW_LINE

s = input ( ) x , up , low , st = len ( s ) , 0 , 0 , " " for i in range ( 1 , x ) : if ( ord ( s [ i ] ) > 90 ) : low += 1 else : up += 1 if ( up == ( len ( s ) - 1 ) or len ( s ) == 1 ) : st += s [ 0 ] . swapcase ( ) i = 1 for i in range ( x ) : if ( i > 0 ) : st += s [ i ] . swapcase ( ) print ( st ) else : print ( s ) NEW_LINE


import java . io . * ; import java . math . * ; import java . util . * ; import java . text . * ;   public class Main { private static FastIO sc ;   public static void main ( String [ ] args ) { sc = new FastIO ( System . in , System . out ) ; int n = sc . readInt ( ) , k = sc . readInt ( ) ; ArrayList < IntIntPair > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( IntIntPair . makePair ( sc . readInt ( ) , i + 1 ) ) ; } Collections . sort ( list ) ; List < Integer > indexes = new ArrayList < > ( ) ; for ( IntIntPair c : list ) { if ( c . first <= k ) { indexes . add ( c . second ) ; k -= c . first ; } } sc . println ( indexes . size ( ) ) ; for ( Integer c : indexes ) sc . printls ( c ) ; sc . close ( ) ; }   static void printPrecision ( double d ) { DecimalFormat ft = new DecimalFormat ( "0.00000000000" ) ;

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; int a [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = in . nextInt ( ) ; StringBuffer sb = new StringBuffer ( ) ; int c = 0 ; while ( k > 0 ) { int min = Integer . MAX_VALUE , p = - 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( a [ i ] < min ) { min = a [ i ] ; p = i ; } } k -= min ; if ( k >= 0 ) { c ++ ; a [ p ] = Integer . MAX_VALUE ; p = p + 1 ; sb . append ( p + " ▁ " ) ; } } System . out . println ( c ) ; System . out . println ( sb ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class AmrMusic { public static void main ( String [ ] args ) {   Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) , k = in . nextInt ( ) , i , a [ ] [ ] = new int [ n ] [ 2 ] , c = 0 , d = 0 ; String s = " " ;   for ( i = 0 ; i < n ; i ++ ) { a [ i ] [ 0 ] = in . nextInt ( ) ; a [ i ] [ 1 ] = i + 1 ; } in . close ( ) ; Arrays . sort ( a , ( x , y ) -> Integer . compare ( x [ 0 ] , y [ 0 ] ) ) ;   for ( i = 0 ; i < n ; i ++ ) { if ( c + a [ i ] [ 0 ] <= k ) { c += a [ i ] [ 0 ] ; d ++ ; s += a [ i ] [ 1 ] + " ▁ " ; } } System . out . println ( d + " \n " + s ) ; } }

import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . * ;   public class cp { static BufferedReader br ; static StringTokenizer st ;   public static void main ( String [ ] args ) throws IOException {   br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; List < Integer > answer = new ArrayList < Integer > ( ) ;

n , k = map ( int , input ( ) . split ( ) ) arr = sorted ( list ( zip ( range ( n ) , ( map ( int , input ( ) . split ( ) ) ) ) ) , key = lambda x : x [ 1 ] ) ans = [ ] i = 0 while k - arr [ i ] [ 1 ] >= 0 : k -= arr [ i ] [ 1 ] ans . append ( arr [ i ] [ 0 ] + 1 ) i += 1 if i == n : breakprint ( len ( ans ) ) print ( * ans ) NEW_LINE

import sysfrom os import pathif ( path . exists ( ' input . txt ' ) ) : sys . stdin = open ( " input . txt " , " r " ) sys . stdout = open ( " output . txt " , " w " )       n , k = [ int ( x ) for x in input ( ) . split ( ) ] a = [ int ( x ) for x in input ( ) . split ( ) ]   d = { } for i in range ( n ) : d [ i ] = a [ i ]   dict ( sorted ( d . items ( ) , key = lambda item : item [ 1 ] ) )   a . sort ( ) ; sum = 0 ; res = [ ] for i in a : sum += i if sum > k : break res . append ( i ) print ( len ( res ) ) ; for i in res : print ( list ( d . keys ( ) ) [ list ( d . values ( ) ) . index ( i ) ] + 1 , end = " ▁ " ) d [ ( list ( d . keys ( ) ) [ list ( d . values ( ) ) . index ( i ) ] ) ] = 0 NEW_LINE

n , k = list ( map ( int , input ( ) . split ( ) ) ) a = list ( map ( int , input ( ) . split ( ) ) ) d = { } ans = [ ]   for i in range ( len ( a ) ) : d [ i + 1 ] = a [ i ]   x = list ( d . values ( ) ) x . sort ( )   for i in x : k -= i if k >= 0 : ans . append ( list ( d . values ( ) ) . index ( i ) + 1 ) d [ list ( d . values ( ) ) . index ( i ) + 1 ] = 0 else : break 	 	   print ( len ( ans ) ) for i in ans : print ( i , end = ' ▁ ' ) NEW_LINE

from __future__ import division , print_functionfrom collections import * from math import * from itertools import * import osimport sysfrom io import BytesIO , IOBaseimport math   if sys . version_info [ 0 ] < 3 : from __builtin__ import xrange as range from future_builtins import ascii , filter , hex , map , oct , zip       def main ( ) : n , k = map ( int , input ( ) . split ( ) ) t = list ( map ( int , input ( ) . split ( ) ) ) arr = [ ] s = 0 while ( k >= 0 ) : try : k -= min ( t ) except : break if k < 0 : break arr . append ( t . index ( min ( t ) ) + 1 ) t . insert ( t . index ( min ( t ) ) + 1 , 123321 ) t . pop ( t . index ( min ( t ) ) ) s += 1 print ( s ) arr . sort ( ) arr = list ( map ( str , arr ) ) print ( " ▁ " . join ( arr ) )                     NEW_LINE


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

import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ;    public class A620 {   public static void main ( String args [ ] ) {   FastReader in = new FastReader ( ) ; PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; int tc = 1 ;

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 input = new Scanner ( System . in ) ; int x1 = input . nextInt ( ) ; int y1 = input . nextInt ( ) ; int x2 = input . nextInt ( ) ; int y2 = input . nextInt ( ) ; System . out . println ( Math . max ( Math . abs ( x1 - x2 ) , Math . abs ( y2 - y1 ) ) ) ; } }

import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long x1 , y1 , x2 , y2 , m , x3 , y3 ; x1 = in . nextLong ( ) ; y1 = in . nextLong ( ) ; x2 = in . nextLong ( ) ; y2 = in . nextLong ( ) ; x3 = Math . abs ( x2 - x1 ) ; y3 = Math . abs ( y2 - y1 ) ; if ( y3 >= x3 ) { m = y3 ; System . out . println ( m ) ; } else { m = x3 ; System . out . println ( m ) ; } } }

print ( max ( abs ( a - b ) for a , b in zip ( * [ map ( int , input ( ) . split ( ) ) for _ in ( 1 , 2 ) ] ) ) ) NEW_LINE

x , y = map ( int , input ( ) . split ( ) ) xx , yy = map ( int , input ( ) . split ( ) ) dx = abs ( xx - x ) dy = abs ( yy - y ) print ( max ( dx , dy ) ) NEW_LINE

x1 , y1 = map ( int , input ( ) . split ( ) ) x2 , y2 = map ( int , input ( ) . split ( ) ) print ( max ( abs ( x1 - x2 ) , abs ( y1 - y2 ) ) ) NEW_LINE

x , y = map ( int , input ( ) . split ( ' ▁ ' ) ) a , b = map ( int , input ( ) . split ( ' ▁ ' ) ) print ( max ( abs ( x - a ) , abs ( b - y ) ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . PriorityQueue ; import java . util . Random ; import java . util . StringTokenizer ;   public class Solution { static FastScanner fs = new FastScanner ( ) ; static PrintWriter out = new PrintWriter ( System . out ) ; static int n , d ; public static void main ( String [ ] args ) throws IOException {

import sys   def ask ( x ) : print ( ' ? ▁ % d ' % x ) sys . stdout . flush ( ) x = int ( input ( ) ) return x   n = int ( input ( ) ) t = n // 2 if t & 1 : print ( ' ! ▁ - 1' ) sys . stdout . flush ( ) sys . exit ( ) l = 1 r = nwhile l < r : mid = ( l + r ) >> 1 if ask ( mid ) >= ask ( ( mid + t - 1 ) % n + 1 ) : r = mid else : l = mid + 1 print ( ' ! ▁ % d ' % l ) sys . stdout . flush ( ) NEW_LINE

from sys import stdout       n = int ( input ( ) )   if n % 4 == 2 :   print ( " ! ▁ - 1" )   exit ( 0 )   print ( " ? " , 1 )   stdout . flush ( )   a = int ( input ( ) )   print ( " ? " , 1 + n // 2 )   stdout . flush ( )   b = int ( input ( ) )   if a == b :   print ( " ! " , 1 )   exit ( 0 )   l = 1   r = 1 + n // 2   while ( l != r ) :   mid = ( l + r ) // 2   print ( " ? " , mid )   stdout . flush ( )   c = int ( input ( ) )   print ( " ? " , mid + n // 2 )   stdout . flush ( )   d = int ( input ( ) )   if c == d :   print ( " ! " , mid )   exit ( 0 )   if a < b :   if c < d :   l = mid + 1   else :   r = mid   else :   if c > d :   l = mid + 1   else :   r = mid   print ( " ! " , l )       NEW_LINE

class Solver : def solve ( self ) : self . num_people = int ( input ( ) )   if self . num_people % 4 == 2 : return - 1   return self . find_zero_pair ( )   def find_zero_pair ( self ) : begin = 1 end = self . num_people // 2 + 1   begin_value = self . func ( begin ) if begin_value == 0 : return begin   while begin < end : mid = ( begin + end ) // 2 mid_value = self . func ( mid ) if mid_value == 0 : return mid elif begin_value * mid_value > 0 : begin = mid + 1 else : end = mid - 1   return begin   def func ( self , pos ) : opposite = ( pos - 1 + self . num_people // 2 ) % self . num_people + 1 return self . get_value ( pos ) - self . get_value ( opposite )   def get_value ( self , pos ) : print ( ' ? ▁ { } ' . format ( pos ) ) value = int ( input ( ) ) return value   solver = Solver ( ) pair = solver . solve ( ) print ( ' ! ▁ { } ' . format ( pair ) ) NEW_LINE


import java . util . * ; import java . util . stream . * ; public class Solution { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; List < String > rat = new ArrayList < > ( ) ; List < String > womanChild = new ArrayList < > ( ) ; List < String > man = new ArrayList < > ( ) ; String captain = " " ; int n = scan . nextInt ( ) ; scan . nextLine ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] info = scan . nextLine ( ) . split ( " ▁ " ) ; if ( info [ 1 ] . equals ( " rat " ) ) { rat . add ( info [ 0 ] ) ; } if ( info [ 1 ] . equals ( " woman " ) || info [ 1 ] . equals ( " child " ) ) { womanChild . add ( info [ 0 ] ) ; } if ( info [ 1 ] . equals ( " man " ) ) { man . add ( info [ 0 ] ) ; } if ( info [ 1 ] . equals ( " captain " ) ) { captain = info [ 0 ] ; } } for ( String elem : rat ) { System . out . println ( elem ) ; } for ( String elem : womanChild ) { System . out . println ( elem ) ; } for ( String elem : man ) { System . out . println ( elem ) ; } System . out . println ( captain ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ;   import static java . lang . Integer . lowestOneBit ; import static java . lang . Integer . parseInt ;   public class Example {   public static void main ( String [ ] args ) {    Scanner sc = new Scanner ( System . in ) ;   int n = sc . nextInt ( ) ; String sdsd = sc . nextLine ( ) ; String [ ] [ ] list = new String [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { String ss = sc . nextLine ( ) ; list [ i ] = ss . split ( " ▁ " ) ; } String s = " rat " ;   for ( int i = 0 ; i < n ; i ++ ) {   if ( list [ i ] [ 1 ] . equals ( s ) ) { System . out . println ( list [ i ] [ 0 ] ) ; }    } String ss = " child " ; for ( int i = 0 ; i < n ; i ++ ) { if ( list [ i ] [ 1 ] . equals ( ss ) || list [ i ] [ 1 ] . equals ( " woman " ) ) { System . out . println ( list [ i ] [ 0 ] ) ; } }    for ( int i = 0 ; i < n ; i ++ ) { if ( list [ i ] [ 1 ] . equals ( " man " ) ) { System . out . println ( list [ i ] [ 0 ] ) ; } } for ( int i = 0 ; i < n ; i ++ ) { if ( list [ i ] [ 1 ] . equals ( " captain " ) ) { System . out . println ( list [ i ] [ 0 ] ) ; } }   }   }

import java . util . * ;   public class CF102 { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < String > rat = new ArrayList < > ( ) ; List < String > womenc = new ArrayList < > ( ) ; List < String > men = new ArrayList < > ( ) ; List < String > capt = new ArrayList < > ( ) ; for ( int i = 1 ; i <= n ; i ++ ) { String name = sc . next ( ) ; String status = sc . next ( ) ; if ( status . equals ( " rat " ) ) { rat . add ( name ) ; } else if ( ( status . equals ( " woman " ) || status . equals ( " child " ) ) ) { womenc . add ( name ) ; } else if ( ( status . equals ( " man " ) ) ) { men . add ( name ) ; } else if ( ( status . equals ( " captain " ) ) ) { capt . add ( name ) ; } }   for ( String ss : rat ) { System . out . println ( ss ) ; } for ( String ss : womenc ) { System . out . println ( ss ) ; } for ( String ss : men ) { System . out . println ( ss ) ; } for ( String ss : capt ) { System . out . println ( ss ) ; }   } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . BufferedWriter ; import java . io . OutputStreamWriter ; import java . io . IOException ; import java . util . ArrayList ; import java . util . Collections ;   public class ObjectSortning_CF_63A { public static class Tripulant implements Comparable < Tripulant > { private String name ; private String type ; public Tripulant ( String name , String type ) { this . name = name ; this . type = type ; } public void setName ( String name ) { this . name = name ; } public void setType ( String type ) { this . type = type ; }   public void convertToNumbers ( Tripulant tripulant ) { if ( tripulant . type . equalsIgnoreCase ( " rat " ) ) { tripulant . setType ( "1" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " woman " ) ) { tripulant . setType ( "2" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " child " ) ) { tripulant . setType ( "2" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " man " ) ) { tripulant . setType ( "3" ) ; } else if ( tripulant . type . equalsIgnoreCase ( " captain " ) ) { tripulant . setType ( "4" ) ; } } @ Override public int compareTo ( Tripulant otherTripulant ) { int ret ; int num1 = Integer . parseInt ( type ) ; int num2 = Integer . parseInt ( otherTripulant . type ) ; if ( num1 < num2 ) { ret = - 1 ; } else if ( num1 > num2 ) { ret = 1 ; } else { ret = 0 ; } return ret ; } } public static void main ( String args [ ] ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; BufferedWriter bw = new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ;

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

prioridades = [ ] NEW_LINE tipos = [ ]   nombres = [ ]   n = int ( input ( ) ) NEW_LINE for i in range ( n ) : nombre , tipo = input ( ) . split ( ) NEW_LINE prioridad = 5 NEW_LINE if tipo == ' rat ' : NEW_LINE INDENT prioridad = 1 elif tipo == ' woman ' or tipo == ' child ' : NEW_LINE prioridad = 2 elif tipo == ' man ' : NEW_LINE prioridad = 3 else : NEW_LINE prioridad = 4 NEW_LINE DEDENT j = 0 NEW_LINE while j < len ( prioridades ) : if NEW_LINE prioridad < prioridades [ j ] : NEW_LINE break NEW_LINE j = j + 1 NEW_LINE prioridades . insert ( j , prioridad ) NEW_LINE nombres . insert ( j , nombre ) NEW_LINE for k in range ( n ) : print ( nombres [ k ] ) NEW_LINE

def solve ( arr , n ) : d = { ' rat ' : 0 , ' woman ' : 1 , ' child ' : 1 , ' man ' : 2 , ' captain ' : 3 } NEW_LINE for i in range ( 1 , n ) : j = i - 1 NEW_LINE key = arr [ i ] [ : ] NEW_LINE while j >= 0 and d [ arr [ j ] [ 1 ] ] > d [ key [ 1 ] ] : arr [ j + 1 ] = arr [ j ] NEW_LINE j -= 1 NEW_LINE arr [ j + 1 ] = key NEW_LINE for i in arr : print ( i [ 0 ] )                                 NEW_LINE def main ( ) : NEW_LINE

n = int ( input ( ) ) NEW_LINE rat = [ ] NEW_LINE men = [ ] NEW_LINE child = [ ] NEW_LINE captain = [ ] NEW_LINE for i in range ( n ) : a , b = input ( ) . split ( ) NEW_LINE if b == ' rat ' : NEW_LINE INDENT rat . append ( a ) elif b == ' child ' : NEW_LINE child . append ( a ) elif b == ' woman ' : NEW_LINE child . append ( a ) elif b == ' man ' : NEW_LINE men . append ( a ) else : NEW_LINE captain . append ( a ) NEW_LINE DEDENT ans = rat + child + men + captainfor NEW_LINE i in ans : print ( i ) NEW_LINE

n = int ( input ( ) ) NEW_LINE crew = [ ] NEW_LINE status = [ " rat " , [ " woman " , " child " ] , " man " , " captain " ] NEW_LINE leave_first = [ ]   for i in range ( n ) : crew . append ( input ( ) )   for i in range ( len ( status ) ) : for NEW_LINE j in range ( n ) : NEW_LINE if ( i == 1 ) : if NEW_LINE INDENT ( crew [ j ] . split ( " ▁ " ) [ 1 ] == status [ 1 ] [ 0 ] ) : leave_first . append ( crew [ j ] . split ( " ▁ " ) [ 0 ] ) elif ( crew [ j ] . split ( " ▁ " ) [ 1 ] == status [ 1 ] [ 1 ] ) : leave_first . append ( crew [ j ] . split ( " ▁ " ) [ 0 ] ) elif ( crew [ j ] . split ( " ▁ " ) [ 1 ] == status [ i ] ) : leave_first . append ( crew [ j ] . split ( " ▁ " ) [ 0 ] )   for i in leave_first : print ( i ) NEW_LINE DEDENT


import java . util . * ;   public class question { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; if ( s . length ( ) == 1 ) { System . out . println ( s ) ; System . exit ( 0 ) ; } StringBuilder ans = new StringBuilder ( ) ; int i = s . length ( ) - 1 , j = 0 ; if ( ( s . length ( ) & 1 ) == 0 ) { for ( int l = 0 ; l < s . length ( ) / 2 ; l ++ ) { if ( i == j ) { ans . append ( s . charAt ( i ) ) ; break ; } ans . append ( s . charAt ( i ) ) ; i -- ; ans . append ( s . charAt ( j ) ) ; j ++ ; } System . out . println ( ans . reverse ( ) ) ; } else { int mid = s . length ( ) / 2 ; int x = mid , y = mid ; System . out . print ( s . charAt ( mid ) ) ; for ( int l = 0 ; l < mid ; l ++ ) { x ++ ; System . out . print ( s . charAt ( x ) ) ; y -- ; System . out . print ( s . charAt ( y ) ) ; } }   } }

import java . lang . * ; import java . util . * ;   public class Main {   public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; StringBuilder t = new StringBuilder ( sc . nextLine ( ) ) ; int n = t . length ( ) ; StringBuilder sb = new StringBuilder ( " " ) ; while ( n != 0 ) { if ( n % 2 == 0 ) { sb . append ( t . charAt ( t . length ( ) - 1 ) ) ; t . deleteCharAt ( t . length ( ) - 1 ) ; } else { sb . append ( t . charAt ( 0 ) ) ; t . deleteCharAt ( 0 ) ; } n -- ;   } System . out . println ( sb . reverse ( ) ) ;   } }

import java . util . * ; public class P2 {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int len = s . length ( ) ; StringBuilder sb = new StringBuilder ( ) ; int p = 0 ; int m = len ; if ( ( s . length ( ) & 1 ) == 0 ) { while ( len > 0 ) { sb . append ( s . charAt ( m - p - 1 ) ) ; sb . append ( s . charAt ( p ) ) ; p ++ ; len -= 2 ; } sb . reverse ( ) ; System . out . println ( sb ) ; } else { while ( len > 0 ) { sb . append ( s . charAt ( p ) ) ; sb . append ( s . charAt ( m - p - 1 ) ) ; p ++ ; len -= 2 ; } sb . reverse ( ) ; sb . deleteCharAt ( 0 ) ; System . out . println ( sb ) ; }   } }

import sysfrom itertools import zip_longestfrom math import ceil   def main ( ) : s = sys . stdin . read ( ) . strip ( ) t = int ( ceil ( len ( s ) / 2 ) ) return ' ' . join ( i + j for i , j in zip_longest ( s [ : t ] [ : : - 1 ] , s [ t : ] , fillvalue = ' ' ) )   print ( main ( ) ) NEW_LINE

n = input ( ) if ( len ( n ) % 2 == 0 ) : c = n [ len ( n ) // 2 - 1 ] s = n [ : len ( n ) // 2 - 1 : ] s = s [ : : - 1 ] t = n [ len ( n ) // 2 : : ] x = min ( len ( s ) , len ( t ) ) for i in range ( x ) : c = c + t [ i ] + s [ i ] if ( x == len ( s ) ) : c = c + t [ - 1 ] else : c = c + s [ - 1 ] print ( c ) else : c = n [ len ( n ) // 2 ] s = n [ : len ( n ) // 2 : ] s = s [ : : - 1 ] t = n [ len ( n ) // 2 + 1 : : ] x = min ( len ( s ) , len ( t ) ) for i in range ( x ) : c = c + t [ i ] + s [ i ] print ( c ) NEW_LINE


import java . io . * ; import java . lang . * ; import java . util . * ; import java . util . concurrent . * ; import java . util . function . * ;   public class B { public static void main ( String [ ] args ) { int n = in . nextInt ( ) ; long [ ] a = in . nextLongs ( n ) ;

n = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) arr = [ 0 ] + arr + [ 0 ] suffmin = [ n + 1 ] * ( n + 2 ) premin = [ 0 ] * ( n + 1 ) st = [ n + 1 ] for i in range ( 1 , n + 1 ) : while arr [ i ] < arr [ st [ - 1 ] ] : suffmin [ st [ - 1 ] ] = i st . pop ( ) st += [ i ] st = [ 0 ] for i in range ( n , 0 , - 1 ) : while arr [ i ] < arr [ st [ - 1 ] ] : premin [ st [ - 1 ] ] = i st . pop ( ) st += [ i ] maxans = [ 0 ] * ( n + 2 ) for i in range ( 1 , n + 1 ) : if maxans [ suffmin [ i ] - premin [ i ] - 1 ] < arr [ i ] : maxans [ suffmin [ i ] - premin [ i ] - 1 ] = arr [ i ] m = arr [ 1 ] for i in range ( 1 , n + 1 ) : if arr [ i ] < m : m = arr [ i ] maxans [ n ] = mfor i in range ( n - 1 , 0 , - 1 ) : if maxans [ i + 1 ] > maxans [ i ] : maxans [ i ] = maxans [ i + 1 ]   print ( * maxans [ 1 : n + 1 ] ) NEW_LINE

n = int ( input ( ) ) ar = list ( map ( int , input ( ) . split ( ) ) ) prev_smaller = [ i + 1 for i in range ( n ) ] next_smaller = [ n + 1 ] * nstack = [ ] for index , value in enumerate ( ar ) : while stack and ar [ stack [ - 1 ] ] >= value : stack . pop ( ) if stack : prev_smaller [ index ] = stack [ - 1 ] + 1 else : prev_smaller [ index ] = 0 stack . append ( index ) NEW_LINE

numFeet = int ( input ( ) ) arr = list ( map ( int , input ( ) . split ( ) ) ) stack = [ ] r_arr = [ numFeet ] * ( numFeet + 1 ) l_arr = [ - 1 ] * ( numFeet + 1 ) ans = [ 0 ] * ( numFeet + 1 )   for i in range ( numFeet ) : while stack and arr [ stack [ - 1 ] ] >= arr [ i ] : stack . pop ( ) if stack : l_arr [ i ] = stack [ - 1 ] stack . append ( i ) NEW_LINE

n = int ( input ( ) ) maxn = n + 10 dpl , dpr , ans = [ 0 ] * maxn , [ n + 1 ] * maxn , [ 0 ] * maxna = [ 0 ] a . extend ( list ( map ( int , input ( ) . split ( ) ) ) ) a . append ( 0 )   for i in range ( 1 , n + 1 ) : tmp = i - 1 while ( a [ tmp ] >= a [ i ] ) : tmp = dpl [ tmp ] dpl [ i ] = tmp   for i in range ( n , 0 , - 1 ) : tmp = i + 1 while ( a [ tmp ] >= a [ i ] ) : tmp = dpr [ tmp ] dpr [ i ] = tmp ans [ dpr [ i ] - dpl [ i ] - 1 ] = max ( ans [ dpr [ i ] - dpl [ i ] - 1 ] , a [ i ] )   for i in range ( n , 0 , - 1 ) : ans [ i ] = max ( ans [ i + 1 ] , ans [ i ] )   print ( ' ▁ ' . join ( map ( str , ans [ 1 : n + 1 ] ) ) ) NEW_LINE


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

import java . util . * ; public class Main {   public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 0 ) ; return ; } int a = sc . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = sc . nextInt ( ) ; } Arrays . sort ( arr ) ; int min = Integer . MAX_VALUE ; min = Math . min ( min , Math . abs ( arr [ n - 2 ] - arr [ 0 ] ) + Math . min ( Math . abs ( a - arr [ 0 ] ) , Math . abs ( a - arr [ n - 2 ] ) ) ) ; min = Math . min ( min , Math . abs ( arr [ n - 1 ] - arr [ 1 ] ) + Math . min ( Math . abs ( a - arr [ 1 ] ) , Math . abs ( a - arr [ n - 1 ] ) ) ) ; System . out . println ( min ) ; } }

import java . util . Arrays ; import java . util . Scanner ;   public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n , a , temp = 2000000222 ; n = in . nextInt ( ) ; a = in . nextInt ( ) ; if ( n == 1 ) { System . out . println ( 0 ) ; return ; } int arr [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = in . nextInt ( ) ; Arrays . sort ( arr ) ; int temp2 ; temp = arr [ n - 2 ] - arr [ 0 ] + Math . min ( Math . abs ( arr [ 0 ] - a ) , Math . abs ( arr [ n - 2 ] - a ) ) ; temp2 = arr [ n - 1 ] - arr [ 1 ] + Math . min ( Math . abs ( arr [ 1 ] - a ) , Math . abs ( arr [ n - 1 ] - a ) ) ; System . out . println ( Math . min ( temp , temp2 ) ) ; } }

n , a = map ( int , input ( ) . split ( ) ) x = list ( map ( int , input ( ) . split ( ) ) ) x . sort ( ) print ( 0 if n == 1 else min ( abs ( a - x [ 1 ] ) + x [ n - 1 ] - x [ 1 ] , abs ( a - x [ n - 1 ] ) + x [ n - 1 ] - x [ 1 ] , abs ( a - x [ 0 ] ) + x [ n - 2 ] - x [ 0 ] , abs ( a - x [ n - 2 ] ) + x [ n - 2 ] - x [ 0 ] ) ) NEW_LINE

import osimport sysimport mathimport heapqfrom decimal import * from io import BytesIO , IOBasefrom collections import defaultdict , deque   def r ( ) : return int ( input ( ) ) def rm ( ) : return map ( int , input ( ) . split ( ) ) def rl ( ) : return list ( map ( int , input ( ) . split ( ) ) )   n , a = rm ( ) b = rl ( ) b . sort ( ) if n == 1 : print ( 0 ) elif n == 2 : print ( min ( abs ( a - b [ 0 ] ) , abs ( a - b [ 1 ] ) ) ) elif b [ 0 ] >= a : print ( abs ( a - b [ - 2 ] ) ) elif b [ - 1 ] <= a : print ( abs ( a - b [ 1 ] ) ) else : cal = 0 for i in b : if i <= a : cal += 1 else : break s = abs ( a - b [ 0 ] ) e = abs ( b [ - 1 ] - a ) if cal == 1 : es = abs ( b [ - 2 ] - a ) print ( min ( e , s + es + min ( s , es ) ) ) elif n - cal == 1 : se = abs ( a - b [ 1 ] ) print ( min ( s , e + se + min ( e , se ) ) ) else : es = abs ( b [ - 2 ] - a ) se = abs ( a - b [ 1 ] ) print ( min ( s + es + min ( s , es ) , e + se + min ( e , se ) ) ) NEW_LINE

n , a = map ( int , input ( ) . split ( ) ) x = [ * map ( int , input ( ) . split ( ) ) ] x . sort ( ) if ( n == 1 ) : print ( 0 ) exit ( 0 ) ind = 0 dist1 = min ( abs ( a - x [ n - 1 ] ) , abs ( a - x [ 1 ] ) ) + abs ( x [ n - 1 ] - x [ 1 ] ) dist2 = min ( abs ( a - x [ 0 ] ) , abs ( a - x [ n - 2 ] ) ) + abs ( x [ 0 ] - x [ n - 2 ] ) print ( min ( dist1 , dist2 ) )   NEW_LINE

n , a = map ( int , input ( ) . split ( ) ) l = [ int ( x ) for x in input ( ) . split ( ) ] if n == 1 : print ( 0 ) exit ( ) l . sort ( ) ans1 = l [ - 2 ] - l [ 0 ] + min ( abs ( a - l [ - 2 ] ) , abs ( a - l [ 0 ] ) ) ans2 = l [ - 1 ] - l [ 1 ] + min ( abs ( a - l [ - 1 ] ) , abs ( a - l [ 1 ] ) ) print ( min ( ans1 , ans2 ) ) NEW_LINE

import sysinput = sys . stdin . readline   n , m = map ( int , input ( ) . split ( ) )     t = list ( map ( int , input ( ) . split ( ) ) )       t . sort ( )     if n <= 1 : print ( 0 ) else :             ans = 9999999999999999 for j in range ( n ) :     if j + ( n - 2 ) < n : NEW_LINE


import java . util . * ; import java . io . * ;   public class Game_With_Stricks {   static class FastReader { BufferedReader br ; StringTokenizer st ;   public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; }   int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; }   long nextLong ( ) { return Long . parseLong ( next ( ) ) ; }   double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; }   String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; }   }   public static void shuffle ( int [ ] a ) { Random r = new Random ( ) ;   for ( int i = 0 ; i <= a . length - 2 ; i ++ ) { int j = i + r . nextInt ( a . length - i ) ;   swap ( a , i , j ) ; }   Arrays . sort ( a ) ; }   public static void swap ( int [ ] a , int i , int j ) { int temp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = temp ; }   public static void main ( String [ ] args ) {

import java . util . Scanner ; public class GameOfSticks { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int total = n * m ; int res = - 1 ; int inter = total ; while ( inter != 0 ) { res ++ ; n -- ; m -- ; inter = n * m ; } if ( res % 2 != 0 ) { System . out . println ( " Malvika " ) ; } else { System . out . println ( " Akshat " ) ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . PriorityQueue ;   public class Template { private static BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ;   static String readln ( ) throws IOException { return input . readLine ( ) ; }   public static void main ( String [ ] args ) throws IOException { solution ( ) ; }   public static void solution ( ) throws IOException {

import java . io . * ; import java . util . StringTokenizer ;   public class A451 { public static void main ( String [ ] args ) throws IOException { PrintWriter out = new PrintWriter ( System . out ) ; FastScanner fs = new FastScanner ( ) ; int N , M ; N = fs . nextInt ( ) ; M = fs . nextInt ( ) ; int mini = Math . min ( N , M ) ; if ( mini % 2 == 0 ) { out . println ( " Malvika " ) ; } else { out . println ( " Akshat " ) ; } out . close ( ) ; }   static class FastScanner { BufferedReader br ; StringTokenizer st ;   public FastScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; }   public FastScanner ( String filePath ) throws FileNotFoundException { try { br = new BufferedReader ( new FileReader ( filePath ) ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } }   String next ( ) throws IOException { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } } return st . nextToken ( ) ; }   String nextLine ( ) throws IOException { String str ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; throw e ; } return str ; }   int nextInt ( ) throws IOException { return Integer . parseInt ( this . next ( ) ) ; }   long nextLong ( ) throws IOException { return Long . parseLong ( this . next ( ) ) ; } } }

n , m = map ( int , input ( ) . split ( ) )   inters = n * m   moves = inters // max ( n , m )   if moves % 2 == 0 : print ( ' Malvika ' ) else : print ( ' Akshat ' ) NEW_LINE

k = 0 n = input ( ) a = list ( n . split ( ) ) if int ( a [ 0 ] ) > int ( a [ 1 ] ) : k = int ( a [ 1 ] ) elif int ( a [ 1 ] ) > int ( a [ 0 ] ) : k = int ( a [ 0 ] ) else : k = int ( a [ 0 ] ) if k % 2 == 0 : print ( " Malvika " ) else : print ( " Akshat " ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) points = 0 if n < m : points = nelse : points = mif ( points % 2 ) != 0 : print ( " Akshat " ) else : print ( " Malvika " ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) ) if min ( n , m ) % 2 == 0 : print ( ' Malvika ' ) else : print ( ' Akshat ' ) NEW_LINE

n , m = map ( int , input ( ) . split ( ) )   n = min ( n , m ) if n % 2 == 0 : print ( ' Malvika ' ) else : print ( ' Akshat ' ) NEW_LINE


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

import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class B817 {   static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; public static void main ( String args [ ] ) {   int tc = 1 ;

from math import combdef minp ( arr ) : arr = sorted ( arr ) st = arr [ : 3 ] ans = 1 for i in set ( st ) : ans *= comb ( arr . count ( i ) , st . count ( i ) ) return ans   a = input ( ) lst = list ( map ( int , input ( ) . strip ( ) . split ( ) ) ) print ( minp ( lst ) ) NEW_LINE

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) g = [ ] def combi ( n , r ) : p = 1 for i in range ( min ( r , n - r ) ) : p = p * ( n - i ) // ( i + 1 ) return p d = 1 if l [ 0 ] == l [ 1 ] == l [ 2 ] :   d = d * combi ( l . count ( l [ 0 ] ) , 3 ) elif l [ 0 ] != l [ 1 ] == l [ 2 ] : d = d * combi ( l . count ( l [ 2 ] ) , 2 ) * l . count ( l [ 0 ] ) elif l [ 0 ] == l [ 1 ] != l [ 2 ] : d = d * combi ( l . count ( l [ 0 ] ) , 2 ) * l . count ( l [ 2 ] ) elif l [ 0 ] != l [ 1 ] != l [ 2 ] : d = d * l . count ( l [ 0 ] ) * l . count ( l [ 1 ] ) * l . count ( l [ 2 ] ) print ( d ) NEW_LINE

import sysfrom collections import defaultdictinput = sys . stdin . readline   d , n = defaultdict ( int ) , int ( input ( ) ) s = sorted ( list ( map ( int , input ( ) . split ( ) ) ) ) for i in s : d [ i ] += 1 if s [ 2 ] != s [ 1 ] : print ( d [ s [ 2 ] ] ) elif s [ 2 ] == s [ 1 ] and s [ 1 ] != s [ 0 ] : print ( d [ s [ 2 ] ] * ( d [ s [ 2 ] ] - 1 ) // 2 ) else : print ( d [ s [ 0 ] ] * ( d [ s [ 0 ] ] - 1 ) * ( d [ s [ 0 ] ] - 2 ) // 6 ) NEW_LINE

num = int ( input ( ) ) arr = [ 0 ] * numarr = input ( ) . split ( ) for i in range ( num ) : arr [ i ] = int ( arr [ i ] ) arr . sort ( ) a = arr [ 0 ] b = arr [ 1 ] c = arr [ 2 ] ans = 1 ca = arr . count ( a ) cb = arr . count ( b ) cc = arr . count ( c ) if c != b and b != a : ans = ca * cb * ccelif b == c and b != a : ans = ca * ( cb * ( cb - 1 ) // 2 ) elif a == b and b != c : ans = ( ca * ( ca - 1 ) ) // 2 * ccelif a == b and b == c : ans = ( ca * ( ca - 1 ) * ( ca - 2 ) ) // 6 print ( ans ) NEW_LINE

n = int ( input ( ) ) l = list ( map ( int , input ( ) . split ( ) ) ) l . sort ( ) x , y , z = l . count ( l [ 0 ] ) , l . count ( l [ 1 ] ) , l . count ( l [ 2 ] ) if ( x > 2 ) : print ( x * ( x - 1 ) * ( x - 2 ) // 6 ) elif ( x == 1 and y >= 2 ) : print ( y * ( y - 1 ) // 2 ) else : print ( z ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; char [ ] [ ] c = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) c [ i ] = sc . next ( ) . toCharArray ( ) ; for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { if ( c [ i ] [ j ] == ' # ' && c [ i - 1 ] [ j ] == ' # ' && c [ i + 1 ] [ j ] == ' # ' && c [ i ] [ j + 1 ] == ' # ' && c [ i ] [ j - 1 ] == ' # ' ) { c [ i ] [ j ] = c [ i - 1 ] [ j ] = c [ i + 1 ] [ j ] = c [ i ] [ j - 1 ] = c [ i ] [ j + 1 ] = ' . ' ; } } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( c [ i ] [ j ] == ' # ' ) { System . out . println ( " NO " ) ; return ; } } } System . out . println ( " YES " ) ; } }

import java . util . * ;   public class ICPC {    public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; List < String > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { list . add ( sc . next ( ) ) ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { String s1 = list . get ( i ) ; String s2 = list . get ( i - 1 ) ; String s3 = list . get ( i + 1 ) ; char ch = list . get ( i ) . charAt ( j ) ; char ch1 = list . get ( i ) . charAt ( j + 1 ) ; char ch2 = list . get ( i ) . charAt ( j - 1 ) ; char ch3 = list . get ( i - 1 ) . charAt ( j ) ; char ch4 = list . get ( i + 1 ) . charAt ( j ) ;   if ( ch == ' # ' && ch1 == ' # ' && ch2 == ' # ' && ch3 == ' # ' && ch4 == ' # ' ) { String s11 = s1 . substring ( 0 , j - 1 ) + " . . . " + s1 . substring ( j + 2 ) ; list . set ( i , s11 ) ; String s12 = s2 . substring ( 0 , j ) + " . " + s2 . substring ( j + 1 ) ; list . set ( i - 1 , s12 ) ; String s13 = s3 . substring ( 0 , j ) + " . " + s3 . substring ( j + 1 ) ; list . set ( i + 1 , s13 ) ;

import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; char arr [ ] [ ] = new char [ n ] [ n ] ; int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String str = s . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = str . charAt ( j ) ; if ( arr [ i ] [ j ] == ' # ' ) { count ++ ; } } } if ( count % 5 > 0 ) { System . out . println ( " NO " ) ; return ; } for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int j = 1 ; j < n - 1 ; j ++ ) { if ( arr [ i ] [ j ] == ' # ' ) { if ( arr [ i - 1 ] [ j ] == ' # ' && arr [ i ] [ j + 1 ] == ' # ' && arr [ i + 1 ] [ j ] == ' # ' && arr [ i ] [ j - 1 ] == ' # ' ) { arr [ i ] [ j ] = ' . ' ; arr [ i - 1 ] [ j ] = ' . ' ; arr [ i ] [ j + 1 ] = ' . ' ; arr [ i ] [ j - 1 ] = ' . ' ; arr [ i + 1 ] [ j ] = ' . ' ; } }   } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( arr [ i ] [ j ] == ' # ' ) { System . out . println ( " NO " ) ; return ; } } } System . out . println ( " YES " ) ; } }

from itertools import chain   if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) tab = [ list ( c == ' # ' for c in input ( ) ) for _ in range ( n ) ] flag = { True } . issubset ( chain . from_iterable ( tab ) ) if ( flag ) : for i in range ( 1 , n - 1 ) : for j in range ( 1 , n - 1 ) : if tab [ i - 1 ] [ j ] and tab [ i ] [ j - 1 ] and tab [ i ] [ j ] and tab [ i ] [ j + 1 ] and tab [ i + 1 ] [ j ] : tab [ i - 1 ] [ j ] = False tab [ i ] [ j - 1 ] = False tab [ i ] [ j ] = False tab [ i ] [ j + 1 ] = False tab [ i + 1 ] [ j ] = False flag = { True } . issubset ( chain . from_iterable ( tab ) ) if ( flag ) : print ( ' NO ' ) else : print ( ' YES ' )   NEW_LINE

if __name__ == ' _ _ main _ _ ' : n = int ( input ( ) ) x = [ list ( input ( ) ) for i in range ( n ) ] y = [ [ ' . ' for j in range ( n ) ] for i in range ( n ) ]   error = False for i in range ( n ) : for j in range ( n ) : if x [ i ] [ j ] == ' . ' and y [ i ] [ j ] == ' . ' : continue elif x [ i ] [ j ] == ' . ' and y [ i ] [ j ] == ' # ' : error = True break elif x [ i ] [ j ] == ' # ' and y [ i ] [ j ] == ' . ' : if j == 0 or j == n - 1 or i > n - 3 or ( y [ i ] [ j ] == ' # ' or y [ i + 1 ] [ j - 1 ] == ' # ' or y [ i + 1 ] [ j ] == ' # ' or y [ i + 1 ] [ j + 1 ] == ' # ' or y [ i + 2 ] [ j ] == ' # ' ) : error = True break else : y [ i ] [ j ] = ' # ' y [ i + 1 ] [ j - 1 ] = ' # ' y [ i + 1 ] [ j ] = ' # ' y [ i + 1 ] [ j + 1 ] = ' # ' y [ i + 2 ] [ j ] = ' # '   if not error : print ( ' YES ' ) else : print ( ' NO ' ) NEW_LINE

def canDraw ( n , matrix ) : can = True for i in range ( n ) : for j in range ( n ) : if matrix [ i ] [ j ] == " # " : if matrix [ i + 1 ] [ j ] == " # " and matrix [ i + 2 ] [ j ] == " # " and matrix [ i + 1 ] [ j - 1 ] == " # " and matrix [ i + 1 ] [ j + 1 ] == " # " : matrix [ i ] [ j ] = " . " matrix [ i + 1 ] [ j ] = " . " matrix [ i + 2 ] [ j ] = " . " matrix [ i + 1 ] [ j - 1 ] = " . " matrix [ i + 1 ] [ j + 1 ] = " . " else : can = False break if not can : break return can         NEW_LINE


import java . util . * ; import java . util . Scanner ; import java . io . * ; import javax . lang . model . util . ElementScanner6 ; import static java . lang . System . out ; import java . util . Stack ; import java . util . Queue ; import java . util . LinkedList ;   public class B6 {   static int mod = ( int ) ( 1e9 + 7 ) ; static long MOD = ( long ) ( 1e9 + 7 ) ; static FastReader in = new FastReader ( ) ; static PrintWriter pr = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; static HashSet < Character > hs ; static int n , m ; static char ch [ ] [ ] ; public static void main ( String args [ ] ) {   int tc = 1 ;

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; import java . util . TreeSet ;   public class B6_Presidents_Office {   public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer stt = new StringTokenizer ( br . readLine ( ) ) ; int h = Integer . parseInt ( stt . nextToken ( ) ) ; int w = Integer . parseInt ( stt . nextToken ( ) ) ; char c = stt . nextToken ( ) . charAt ( 0 ) ; char [ ] [ ] arr = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { arr [ i ] = br . readLine ( ) . toCharArray ( ) ; } TreeSet < Character > set = new TreeSet < > ( ) ; for ( int i = 0 ; i < h ; ++ i ) { int index = String . valueOf ( arr [ i ] ) . indexOf ( c ) ; if ( index >= 0 ) { for ( int j = index ; j < w ; ++ j ) { if ( arr [ i ] [ j ] == c ) { if ( i > 0 ) { set . add ( arr [ i - 1 ] [ j ] ) ; } if ( i < h - 1 ) { set . add ( arr [ i + 1 ] [ j ] ) ; } if ( j > 0 ) { set . add ( arr [ i ] [ j - 1 ] ) ; } if ( j < w - 1 ) { set . add ( arr [ i ] [ j + 1 ] ) ; } } else { break ; } } } } set . remove ( ' . ' ) ; set . remove ( c ) ; System . out . println ( set . size ( ) ) ;    }   }

import java . io . BufferedInputStream ; import java . util . HashSet ; import java . util . Scanner ;   import javax . jws . WebParam . Mode ;   public class Main { public static char [ ] [ ] s ; static int n , m , sum ; static int [ ] a = new int [ 1000 ] ; static char c ; static int [ ] [ ] ans = { { 0 , 1 } , { 1 , 0 } , { - 1 , 0 } , { 0 , - 1 } } ; static int [ ] [ ] cnt ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( new BufferedInputStream ( System . in ) ) ; n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; c = sc . next ( ) . charAt ( 0 ) ; s = new char [ n ] [ m ] ; cnt = new int [ n ] [ m ] ; String string ; for ( int i = 0 ; i < n ; i ++ ) { string = sc . next ( ) ; for ( int j = 0 ; j <= string . length ( ) - 1 ; j ++ ) { s [ i ] [ j ] = string . charAt ( j ) ; } } sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( s [ i ] [ j ] == c ) { dfs ( i , j ) ; } } } System . out . println ( sum ) ; } private static void dfs ( int i , int j ) {

n , m , c = input ( ) . split ( ) lst = [ [ 1 ] * ( int ( m ) + 2 ) ] temp = [ ] for i in range ( int ( n ) ) : f = list ( input ( ) . strip ( ) ) f . insert ( 0 , 1 ) f . append ( 1 ) lst . append ( f ) lst . append ( [ 1 ] * ( int ( m ) + 2 ) ) for i in range ( 1 , int ( n ) + 1 ) : for j in range ( 1 , int ( m ) + 1 ) : if lst [ i ] [ j ] == c : temp . append ( lst [ i - 1 ] [ j ] ) temp . append ( lst [ i + 1 ] [ j ] ) temp . append ( lst [ i ] [ j + 1 ] ) temp . append ( lst [ i ] [ j - 1 ] ) temp = set ( temp ) st = " " for i in temp : st += str ( i ) st = st . replace ( "1" , " " ) st = st . replace ( " . " , " " ) st = st . replace ( c , " " ) print ( len ( st ) ) NEW_LINE

def indices ( n , m , room , c ) : res = [ ] for i in range ( n ) : for j in range ( m ) : if room [ i ] [ j ] == c : res . append ( ( i , j ) ) return res           def solve ( n , m , room , c ) : president_pos = indices ( n , m , room , c ) diputies = set ( ) for i , j in president_pos : if i > 0 and room [ i - 1 ] [ j ] not in c + ' . ' : diputies . add ( room [ i - 1 ] [ j ] ) if j > 0 and room [ i ] [ j - 1 ] not in c + ' . ' : diputies . add ( room [ i ] [ j - 1 ] ) if i < n - 1 and room [ i + 1 ] [ j ] not in c + ' . ' : diputies . add ( room [ i + 1 ] [ j ] ) if j < m - 1 and room [ i ] [ j + 1 ] not in c + ' . ' : diputies . add ( room [ i ] [ j + 1 ] ) print ( len ( diputies ) )           def main ( ) : n , m , c = input ( ) . split ( ) n , m = int ( n ) , int ( m ) room = [ ] for _ in range ( n ) : room . append ( input ( ) ) solve ( n , m , room , c )   if __name__ == ' _ _ main _ _ ' : main ( ) NEW_LINE

r = lambda : list ( map ( int , input ( ) . split ( ) ) ) a , b , x = input ( ) . split ( ) a = int ( a ) b = int ( b )   ans = set ( )   arr = [ input ( ) for _ in range ( a ) ]   for i in range ( a ) : for j in range ( b ) : if arr [ i ] [ j ] == x : if i > 0 : ans . add ( arr [ i - 1 ] [ j ] ) if i < a - 1 : ans . add ( arr [ i + 1 ] [ j ] ) if j > 0 : ans . add ( arr [ i ] [ j - 1 ] ) if j < b - 1 : ans . add ( arr [ i ] [ j + 1 ] )   try : ans . remove ( ' . ' ) except : passtry : ans . remove ( x ) except : passprint ( len ( ans ) )     NEW_LINE

n , m , c = input ( ) . split ( ) n = int ( n ) m = int ( m ) string = " . " * mfor i in range ( n ) : string = string + " . " + input ( ) + " . " string = string + ( " . " * m ) for i in range ( n * m ) : this = string [ i ] next = string [ i + 1 ] previous = string [ i - 1 ] res = [ ] for i in range ( len ( string ) ) : try : val = string [ i ] if val == c : next = string [ i + 1 ] if next != c and next != " . " : if next not in res : res . append ( next ) pre = string [ i - 1 ] if pre != c and pre != " . " : if pre not in res : res . append ( pre ) up = string [ i - ( m + 2 ) ] if up != c and up != " . " : if up not in res : res . append ( up ) down = string [ i + ( m + 2 ) ] if down != c and down != " . " : if down not in res : res . append ( down ) NEW_LINE