import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int inv [ ] = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { inv [ sc . nextInt ( ) - 1 ] = i ; } for ( int i = 0 ; i < N ; i ++ ) { if ( i > 0 ) System . out . print ( " ▁ " ) ; System . out . print ( N * ( i + 1 ) ) ; } System . out . println ( " " ) ; for ( int i = 0 ; i < N ; i ++ ) { if ( i > 0 ) System . out . print ( " ▁ " ) ; System . out . print ( N * ( N - i ) + inv [ i ] ) ; } System . out . println ( " " ) ; } }

import java . io . * ; import java . util . * ; public class Main { private static boolean debug = false ; private static boolean elapsed = false ; private void solve ( Scanner sc , PrintWriter out ) { int N = sc . nextInt ( ) ; int [ ] p = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { p [ i ] = sc . nextInt ( ) - 1 ; } int [ ] r = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { r [ p [ i ] ] = i + 1 ; } int [ ] a = new int [ N ] ; int [ ] b = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { a [ i ] = N * ( i + 1 ) ; b [ i ] = N * ( N - i - 1 ) + r [ i ] ; } for ( int i = 0 ; i < N ; ++ i ) { if ( i > 0 ) { out . print ( " ▁ " ) ; } out . print ( a [ i ] ) ; } out . println ( ) ; for ( int i = 0 ; i < N ; ++ i ) { if ( i > 0 ) { out . print ( " ▁ " ) ; } out . print ( b [ i ] ) ; } out . println ( ) ; } public static void main ( String [ ] args ) { long S = System . currentTimeMillis ( ) ; Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( sc , out ) ; out . flush ( ) ; long G = System . currentTimeMillis ( ) ; if ( elapsed ) { System . err . println ( ( G - S ) + " ms " ) ; } } }

import java . util . * ; class Main { public static void main ( String args [ ] ) { try ( Scanner sc = new Scanner ( System . in ) ) { int N = sc . nextInt ( ) ; long [ ] A = new long [ N ] ; long [ ] B = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = i * 10001L + 1 ; B [ N - i - 1 ] = i * 10001L + 1 ; } for ( int i = 0 ; i < N ; i ++ ) { int p = sc . nextInt ( ) ; p -- ; A [ p ] += i / 2 ; B [ p ] += i - i / 2 ; } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( A [ i ] ) ; if ( i == N - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " ▁ " ) ; } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( B [ i ] ) ; if ( i == N - 1 ) { System . out . print ( " \n " ) ; } else { System . out . print ( " ▁ " ) ; } } } } }

import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; int [ ] B = new int [ N ] ; int [ ] p = new int [ N ] ; int [ ] q = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { p [ i ] = sc . nextInt ( ) ; q [ p [ i ] - 1 ] = i + 1 ; } A [ 0 ] = q [ 0 ] ; B [ 0 ] = 0 ; for ( int i = 1 ; i < N ; i ++ ) { if ( q [ i - 1 ] < q [ i ] ) { B [ i ] = B [ i - 1 ] - 1 ; A [ i ] = q [ i ] - B [ i ] ; } else { A [ i ] = A [ i - 1 ] + 1 ; B [ i ] = q [ i ] - A [ i ] ; } } for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( A [ i ] + " ▁ " ) ; } System . out . println ( ) ; for ( int i = 0 ; i < N ; i ++ ) { System . out . print ( ( B [ i ] + 1000000000 ) + " ▁ " ) ; } } }

import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; int a [ ] = new int [ n ] ; int b [ ] = new int [ n ] ; int p [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { p [ sc . nextInt ( ) - 1 ] = i + 1 ; a [ i ] = i * n + 1 ; } b [ n - 1 ] = 1 ; for ( int i = n - 2 ; i >= 0 ; i -- ) { b [ i ] = b [ i + 1 ] + n + p [ i ] - p [ i + 1 ] ; } System . out . println ( Arrays . toString ( a ) . replaceAll ( " [ ^ 0-9 ▁ ] " , " " ) ) ; System . out . println ( Arrays . toString ( b ) . replaceAll ( " [ ^ 0-9 ▁ ] " , " " ) ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }

N = int ( input ( ) ) NEW_LINE p = list ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) NEW_LINE r = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT r [ p [ i ] ] = i + 1 NEW_LINE DEDENT A = [ 30000 * i for i in range ( 1 , N + 1 ) ] NEW_LINE B = [ 30000 * ( N - i ) + r [ i - 1 ] for i in range ( 1 , N + 1 ) ] NEW_LINE print ( * A ) NEW_LINE print ( * B ) NEW_LINE

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE from itertools import accumulate NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE P = LI ( ) NEW_LINE T = [ 1 ] * N NEW_LINE for i , p in enumerate ( P ) : NEW_LINE INDENT T [ p - 1 ] += i NEW_LINE DEDENT A = list ( accumulate ( T ) ) NEW_LINE B = list ( accumulate ( T [ : : - 1 ] ) ) [ : : - 1 ] NEW_LINE print ( * A ) NEW_LINE print ( * B ) NEW_LINE return 0 NEW_LINE DEDENT main ( ) NEW_LINE

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE P = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE A = [ N * i + 1 for i in range ( 1 , N + 1 ) ] NEW_LINE B = list ( reversed ( A ) ) NEW_LINE for i , p in enumerate ( P ) : NEW_LINE INDENT A [ p - 1 ] -= N - i NEW_LINE DEDENT print ( * A ) NEW_LINE print ( * B ) NEW_LINE

n = int ( input ( ) ) NEW_LINE p = [ int ( m ) for m in input ( ) . split ( ) ] NEW_LINE a = [ i * n + ( i - 1 ) for i in range ( 1 , n + 1 ) ] NEW_LINE b = [ i * n + ( i - 1 ) for i in range ( n , 0 , - 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a [ p [ i ] - 1 ] += i + 1 NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( a [ i ] , " " , end = " " ) NEW_LINE DEDENT print ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT print ( b [ i ] , " " , end = " " ) NEW_LINE DEDENT

N = int ( input ( ) ) NEW_LINE P = [ int ( _ ) - 1 for _ in input ( ) . split ( ) ] NEW_LINE Q = sorted ( [ ( P [ i ] , i ) for i in range ( N ) ] ) NEW_LINE A = [ 1 ] NEW_LINE B = [ 10 ** 9 ] NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT d = Q [ i ] [ 1 ] - Q [ i - 1 ] [ 1 ] NEW_LINE if d > 0 : NEW_LINE INDENT A += [ A [ - 1 ] + d + 1 ] NEW_LINE B += [ B [ - 1 ] - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT A += [ A [ - 1 ] + 1 ] NEW_LINE B += [ B [ - 1 ] + d - 1 ] NEW_LINE DEDENT DEDENT print ( * A , sep = " ▁ " ) NEW_LINE print ( * B , sep = " ▁ " ) NEW_LINE


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x == 1 || x == 2 * N - 1 ) { out . println ( " No " ) ; out . flush ( ) ; return ; } out . println ( " Yes " ) ; if ( N == 2 ) { for ( int i = 1 , n = 2 * N ; i < n ; ++ i ) { out . println ( i ) ; } } else { if ( x > N ) { for ( int i = N ; i < N * 2 ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } out . println ( x ) ; for ( int i = 1 ; i < N ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } } else { for ( int i = N + 1 ; i < N * 2 ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } out . println ( x ) ; for ( int i = 1 ; i < N + 1 ; ++ i ) { if ( i != x ) { out . println ( i ) ; } } } } out . flush ( ) ; } }

import java . lang . reflect . Array ; import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int x = Integer . parseInt ( st . nextToken ( ) ) ; if ( x == 1 || x == 2 * n - 1 ) { System . out . print ( " No " ) ; return ; } System . out . println ( " Yes " ) ; StringBuilder sb = new StringBuilder ( ) ; int array [ ] = new int [ 2 * n ] ; array [ n ] = x ; for ( int i = n - 1 ; i >= 1 ; i -- ) array [ i ] = array [ i + 1 ] - 1 ; for ( int i = n + 1 ; i < array . length ; i ++ ) array [ i ] = array [ i - 1 ] + 1 ; for ( int i = 1 ; i < array . length ; i ++ ) { if ( array [ i ] <= 0 ) array [ i ] += 2 * n - 1 ; if ( array [ i ] > 2 * n - 1 ) array [ i ] -= 2 * n - 1 ; } for ( int i = 1 ; i < 2 * n ; i ++ ) { sb . append ( array [ i ] ) ; sb . append ( ' \n ' ) ; } System . out . print ( sb ) ; } }

import java . util . * ; import java . io . * ; public class Main { public static int [ ] solve ( int N , int x ) { int [ ] ans = new int [ 2 * N - 1 ] ; if ( N == 2 ) { return new int [ ] { 1 , 2 , 3 } ; } if ( x == 2 ) { ans [ N - 2 ] = 2 * N - 1 ; ans [ N - 1 ] = 2 ; ans [ N ] = 1 ; ans [ N + 1 ] = 2 * N - 2 ; int elm = 3 ; for ( int index = 0 ; index < 2 * N - 1 ; index ++ ) { if ( ans [ index ] == 0 ) { ans [ index ] = elm ; elm ++ ; } } } else { ans [ N - 2 ] = 1 ; ans [ N - 1 ] = x ; ans [ N ] = 2 * N - 1 ; ans [ N + 1 ] = 2 ; int elm = 3 ; for ( int index = 0 ; index < 2 * N - 1 ; index ++ ) { if ( elm == x ) elm ++ ; if ( ans [ index ] == 0 ) { ans [ index ] = elm ; elm ++ ; } } } return ans ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x == 1 || x == 2 * N - 1 ) { System . out . println ( " No " ) ; return ; } else { System . out . println ( " Yes " ) ; } int [ ] ans = solve ( N , x ) ; for ( int i = 0 ; i < ans . length ; i ++ ) System . out . println ( ans [ i ] ) ; } }

import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) * 2 - 1 , x = sc . nextInt ( ) ; if ( x == 1 || x == n ) { System . out . println ( " No " ) ; return ; } System . out . println ( " Yes " ) ; int [ ] ans = new int [ n ] ; ans [ n / 2 ] = x ; ans [ n / 2 - 1 ] = x + 1 ; ans [ n / 2 + 1 ] = x - 1 ; int idx = 1 ; for ( int i = 0 ; i < n ; i ++ ) { if ( idx == x - 1 ) { idx += 3 ; } if ( i == n / 2 - 1 ) { i += 2 ; continue ; } ans [ i ] = idx ++ ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( ans [ i ] ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }

import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int x = scanner . nextInt ( ) ; print ( x , n ) ; } public static void print ( int x , int n ) { int max = n * 2 - 1 ; if ( x == 1 || x == max ) { System . out . println ( " No " ) ; return ; } System . out . println ( " Yes " ) ; String sep = System . lineSeparator ( ) ; String ans = IntStream . range ( x + n - 1 , x + n + max - 1 ) . mapToObj ( e -> ( e % max + 1 ) + sep ) . collect ( StringBuilder :: new , StringBuilder :: append , StringBuilder :: append ) . toString ( ) ; System . out . println ( ans ) ; } }

n , x = map ( int , input ( ) . split ( ) ) NEW_LINE ans = [ i for i in range ( 1 , 2 * n ) ] NEW_LINE if x == 1 or x == 2 * n - 1 : NEW_LINE INDENT print ( " No " ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( " Yes " ) NEW_LINE ans [ n - 1 ] , ans [ x - 1 ] = ans [ x - 1 ] , ans [ n - 1 ] NEW_LINE ans [ n - 2 ] , ans [ 0 ] = ans [ 0 ] , ans [ n - 2 ] NEW_LINE ans [ n ] , ans [ 2 * n - 2 ] = ans [ 2 * n - 2 ] , ans [ n ] NEW_LINE if n == 2 : NEW_LINE INDENT for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT exit ( ) NEW_LINE DEDENT if x < 2 * n - 2 : NEW_LINE INDENT ans [ n - 3 ] , ans [ 2 * n - 3 ] = ans [ 2 * n - 3 ] , ans [ n - 3 ] NEW_LINE DEDENT else : NEW_LINE INDENT ans [ n + 1 ] , ans [ 1 ] = ans [ 1 ] , ans [ n + 1 ] NEW_LINE DEDENT for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n , x = LI ( ) NEW_LINE if x == 1 or x == 2 * n - 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE return 0 NEW_LINE DEDENT print ( ' Yes ' ) NEW_LINE if n < 3 : NEW_LINE INDENT print ( * [ n for n in range ( 1 , 2 * n ) ] , sep = ' \n ' ) NEW_LINE return 1 NEW_LINE DEDENT tmp = [ x - 1 , x , x + 1 ] NEW_LINE remain = list ( set ( [ n for n in range ( 1 , 2 * n ) ] ) - set ( tmp ) ) NEW_LINE k = n - 2 NEW_LINE tmp = remain [ : k ] + tmp + remain [ k : ] NEW_LINE print ( * tmp , sep = ' \n ' ) NEW_LINE return 1 NEW_LINE DEDENT main ( ) NEW_LINE

n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if n == 2 and x == 2 : NEW_LINE INDENT print ( ' Yes ' , * [ 1 , 2 , 3 ] , sep = ' \n ' ) NEW_LINE exit ( ) NEW_LINE DEDENT a = [ [ ] for _ in range ( 2 * n - 1 ) ] NEW_LINE a [ n - 1 ] = x NEW_LINE f = [ 0 ] * 2 * n NEW_LINE f [ x ] = 1 NEW_LINE try : NEW_LINE INDENT if x > 2 * n - 3 : NEW_LINE INDENT a [ n - 3 ] = x - 2 NEW_LINE a [ n - 2 ] = x + 1 NEW_LINE a [ n ] = x - 1 NEW_LINE f [ x - 2 ] = f [ x - 1 ] = f [ x + 1 ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT a [ n - 3 ] = x + 2 NEW_LINE a [ n - 2 ] = x - 1 NEW_LINE a [ n ] = x + 1 NEW_LINE f [ x - 1 ] = f [ x + 1 ] = f [ x + 2 ] = 1 NEW_LINE DEDENT if f [ 0 ] : NEW_LINE INDENT 1 / 0 NEW_LINE DEDENT DEDENT except : NEW_LINE INDENT print ( ' No ' ) NEW_LINE exit ( ) NEW_LINE DEDENT i = 0 NEW_LINE for j , v in enumerate ( f [ 1 : ] , 1 ) : NEW_LINE INDENT if v : continue NEW_LINE while a [ i ] : i += 1 NEW_LINE a [ i ] = j NEW_LINE DEDENT print ( ' Yes ' , * a , sep = ' \n ' ) NEW_LINE

N , x = map ( int , input ( ) . split ( ) ) NEW_LINE if x == 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT elif x == 2 * N - 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE if N == 2 : NEW_LINE INDENT for i in range ( 1 , 4 ) : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if x != 2 * N - 2 : NEW_LINE INDENT L = [ ] NEW_LINE M = [ x + 2 , x - 1 , x , x + 1 ] NEW_LINE for i in range ( 1 , 2 * N ) : NEW_LINE INDENT if not i in M : NEW_LINE INDENT L . append ( i ) NEW_LINE DEDENT DEDENT for j in range ( N - 2 ) : NEW_LINE INDENT print ( L [ j ] ) NEW_LINE DEDENT for k in range ( 4 ) : NEW_LINE INDENT print ( M [ k ] ) NEW_LINE DEDENT for l in range ( N - 3 ) : NEW_LINE INDENT print ( L [ l + N - 2 ] ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT L = [ ] NEW_LINE M = [ x - 2 , x , x + 1 , x - 1 ] NEW_LINE for i in range ( 1 , 2 * N ) : NEW_LINE INDENT if not i in M : NEW_LINE INDENT L . append ( i ) NEW_LINE DEDENT DEDENT for j in range ( N - 2 ) : NEW_LINE INDENT print ( L [ j ] ) NEW_LINE DEDENT for k in range ( 4 ) : NEW_LINE INDENT print ( M [ k ] ) NEW_LINE DEDENT for l in range ( N - 3 ) : NEW_LINE INDENT print ( L [ l + N - 2 ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT

n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if x == 1 or x == ( 2 * n - 1 ) : NEW_LINE INDENT print ( " No " ) NEW_LINE exit ( ) NEW_LINE DEDENT print ( " Yes " ) NEW_LINE r = [ x - 1 , x , x + 1 ] NEW_LINE tmp = list ( range ( 1 , x - 1 ) ) + list ( range ( x + 2 , 2 * n ) ) NEW_LINE ans = tmp [ n - 2 : ] + r + tmp [ : n - 2 ] NEW_LINE for i in ans : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] R = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { R [ i ] = sc . nextInt ( ) ; } Arrays . sort ( R ) ; double ans = 0.0 ; for ( int i = N - K ; i < N ; i ++ ) { ans = ( ans + R [ i ] ) / 2.0 ; } out . println ( ans ) ; } }

import java . util . * ; class Main { public static int N ; public static int K ; public static ArrayList < Integer > ratelist = new ArrayList < Integer > ( ) ; public static double takahashirate = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; N = sc . nextInt ( ) ; K = sc . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { ratelist . add ( sc . nextInt ( ) ) ; } Collections . sort ( ratelist ) ; List < Integer > sbratelist = ratelist . subList ( N - K , N ) ; for ( int target : sbratelist ) { takahashirate = ( takahashirate + target ) / 2.0 ; } System . out . println ( takahashirate ) ; } }

import java . math . BigDecimal ; import java . math . RoundingMode ; import java . text . DecimalFormat ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Double > list = new ArrayList < Double > ( ) ; double trate = 0 ; for ( int c = 0 ; c < a ; c ++ ) { if ( sc . hasNextInt ( ) ) { list . add ( Double . parseDouble ( sc . next ( ) ) ) ; } } if ( a != b ) { Collections . sort ( list ) ; for ( int r = a - b ; r < a ; r ++ ) { trate = ( trate + list . get ( r ) ) / 2 ; } } else { Collections . sort ( list ) ; for ( int r = 0 ; r < b ; r ++ ) { trate = ( trate + list . get ( r ) ) / 2 ; } } new DecimalFormat ( "0.000000" ) . format ( trate ) ; BigDecimal bd_trate = new BigDecimal ( trate ) ; bd_trate . setScale ( 6 , RoundingMode . HALF_UP ) ; System . out . println ( bd_trate ) ; sc . close ( ) ; } }

import java . util . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , k = scanner . nextInt ( ) ; System . out . println ( java . util . stream . IntStream . range ( 0 , n ) . mapToDouble ( i -> scanner . nextDouble ( ) ) . sorted ( ) . skip ( n - k ) . reduce ( 0D , ( a , b ) -> ( a + b ) / 2 ) ) ; } }

import java . io . InputStream ; import java . io . PrintStream ; import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; List < Integer > r = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { r . add ( sc . nextInt ( ) ) ; } r . sort ( null ) ; double c = 0 ; for ( int i = n - k ; i < n ; i ++ ) { c = ( c + r . get ( i ) ) / 2 ; } out . println ( c ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }

n , k = map ( int , input ( ) . split ( ) ) NEW_LINE r = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE r . sort ( ) NEW_LINE del r [ : ( n - k ) ] NEW_LINE c = 0 NEW_LINE for i in r : NEW_LINE INDENT c = ( c + i ) / 2 NEW_LINE DEDENT print ( c ) NEW_LINE

N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE RList = sorted ( [ int ( i ) for i in input ( ) . split ( ) ] , reverse = True ) [ : K ] NEW_LINE ans = 0 NEW_LINE for i , r in enumerate ( RList [ : : - 1 ] ) : NEW_LINE INDENT ans = ( r + ans ) / 2 NEW_LINE DEDENT print ( ans ) NEW_LINE

N , K = map ( int , input ( ) . split ( ) ) NEW_LINE R = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def sort ( list1 ) : NEW_LINE INDENT return sorting ( list1 ) NEW_LINE DEDENT def sorting ( list1 ) : NEW_LINE INDENT if len ( list1 ) == 1 : NEW_LINE INDENT return list1 NEW_LINE DEDENT mid = len ( list1 ) // 2 NEW_LINE return merge ( sorting ( list1 [ : mid ] ) , sorting ( list1 [ mid : ] ) ) NEW_LINE DEDENT def merge ( list1 , list2 ) : NEW_LINE INDENT result = [ ] NEW_LINE i = 0 NEW_LINE j = 0 NEW_LINE m = len ( list1 ) NEW_LINE n = len ( list2 ) NEW_LINE while ( i + j < m + n ) : NEW_LINE INDENT if j == n or ( i < m and list1 [ i ] < list2 [ j ] ) : NEW_LINE INDENT result += [ list1 [ i ] ] NEW_LINE i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT result += [ list2 [ j ] ] NEW_LINE j += 1 NEW_LINE DEDENT DEDENT return result NEW_LINE DEDENT R = sort ( R ) NEW_LINE R [ : N - K ] = [ ] NEW_LINE C = 0 NEW_LINE for x in R : NEW_LINE INDENT if C < x : NEW_LINE INDENT C = ( C + x ) / 2 NEW_LINE DEDENT DEDENT print ( C ) NEW_LINE

Your_rate = 0 NEW_LINE N , K = ( int ( x ) for x in input ( ) . split ( ) ) NEW_LINE video_rate = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE video_rate . sort ( reverse = True ) NEW_LINE for i in range ( K - 1 , - 1 , - 1 ) : NEW_LINE INDENT Your_rate = ( Your_rate + video_rate [ i ] ) / 2 NEW_LINE DEDENT print ( Your_rate ) NEW_LINE

N , K = map ( int , input ( ) . split ( ) ) NEW_LINE R = input ( ) . split ( ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT for j in range ( i + 1 , N ) : NEW_LINE INDENT if int ( R [ i ] ) < int ( R [ j ] ) : NEW_LINE INDENT tmp = R [ i ] NEW_LINE R [ i ] = R [ j ] NEW_LINE R [ j ] = tmp NEW_LINE DEDENT DEDENT DEDENT R = R [ 0 : K ] NEW_LINE R . reverse ( ) NEW_LINE sum = 0 NEW_LINE for i in range ( K ) : NEW_LINE INDENT sum += int ( R [ i ] ) * 2 ** i NEW_LINE DEDENT sum /= 2 ** K NEW_LINE print ( sum ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ; ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int count = 0 ; for ( int i = 0 ; i < h ; i ++ ) { String row = sc . next ( ) ; for ( char c : row . toCharArray ( ) ) { if ( c == ' # ' ) { count ++ ; } } } System . out . println ( count == h + w - 1 ? " Possible " : " Impossible " ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . io . UncheckedIOException ; import java . util . stream . Stream ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; AShikAndStone solver = new AShikAndStone ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class AShikAndStone { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int h = in . ints ( ) , w = in . ints ( ) ; String [ ] a = in . string ( h ) ; int c = 0 ; for ( String row : a ) { for ( char column : row . toCharArray ( ) ) { if ( column == ' # ' ) { c ++ ; } } } if ( c == h + w - 1 ) { out . println ( " Possible " ) ; } else { out . println ( " Impossible " ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public String [ ] string ( int length ) { return IntStream . range ( 0 , length ) . mapToObj ( x -> string ( ) ) . toArray ( String [ ] :: new ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }

import java . io . InputStream ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . BufferedReader ; class MyScanner { InputStream stream ; public MyScanner ( ) { stream = System . in ; } public int nextInt ( ) { int ret = 0 ; try { while ( true ) { char readed = ( char ) stream . read ( ) ; if ( readed < '0' || readed > '9' ) { break ; } ret = ret * 10 + ( readed - '0' ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { return ret ; } } } class Main { public static void main ( String args [ ] ) { try { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; MyScanner sc = new MyScanner ( ) ; int h = sc . nextInt ( ) , w = sc . nextInt ( ) ; int sum = 0 ; for ( int i = 0 ; i < h ; ++ i ) { char [ ] a = br . readLine ( ) . toCharArray ( ) ; for ( int j = 0 ; j < w ; ++ j ) { if ( a [ j ] == ' # ' ) { ++ sum ; } } } if ( sum == h + w - 1 ) { System . out . println ( " Possible " ) ; } else { System . out . println ( " Impossible " ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } }

import java . util . * ; import java . awt . geom . Point2D ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; char [ ] [ ] f = new char [ h ] [ w ] ; for ( int i = 0 ; i < h ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < w ; j ++ ) { f [ i ] [ j ] = s . charAt ( j ) ; } } Point p = new Point ( 0 , 0 ) ; int [ ] dx = { - 1 , 0 , 1 , 0 } ; int [ ] dy = { 0 , - 1 , 0 , 1 } ; Deque < Point > stack = new ArrayDeque < > ( ) ; stack . addFirst ( p ) ; int k = 1 ; while ( stack . size ( ) > 0 ) { k ++ ; Point t = stack . pollFirst ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { int x = t . x + dx [ i ] , y = t . y + dy [ i ] ; if ( D ( h , w , x , y ) ) { if ( f [ y ] [ x ] == ' # ' ) { if ( i == 2 || i == 3 ) { stack . addFirst ( new Point ( x , y ) ) ; f [ t . y ] [ t . x ] = '0' ; } else { out . println ( " Impossible " ) ; exit ( 0 ) ; } } } } if ( stack . size ( ) > 1 ) { out . println ( " Impossible " ) ; exit ( 0 ) ; } } out . println ( " Possible " ) ; } static boolean D ( int h , int w , int x , int y ) { return 0 <= x && x < w && 0 <= y && y < h ; } }

import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int H = ni ( ) ; int W = ni ( ) ; char [ ] [ ] A = new char [ H ] [ W ] ; for ( int i = 0 ; i < H ; i ++ ) { A [ i ] = sc . next ( ) . toCharArray ( ) ; } for ( int x1 = 0 ; x1 < H ; x1 ++ ) for ( int y1 = 0 ; y1 < W ; y1 ++ ) { for ( int x2 = 0 ; x2 < H ; x2 ++ ) for ( int y2 = 0 ; y2 < W ; y2 ++ ) { if ( x1 < x2 && y2 < y1 && A [ x1 ] [ y1 ] == ' # ' && A [ x2 ] [ y2 ] == ' # ' ) { System . out . println ( " Impossible " ) ; return ; } } } System . out . println ( " Possible " ) ; } public static int ni ( ) { return Integer . parseInt ( sc . next ( ) ) ; } }

H , W = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE A_s = [ input ( ) for _ in range ( H ) ] NEW_LINE pos = [ 0 , 0 ] NEW_LINE num = 1 NEW_LINE while True : NEW_LINE INDENT if pos == [ H - 1 , W - 1 ] : NEW_LINE INDENT total = sum ( map ( lambda A : A . count ( " # " ) , A_s ) ) NEW_LINE ans = total == num NEW_LINE break NEW_LINE DEDENT h , w = pos NEW_LINE if h != H - 1 and A_s [ h + 1 ] [ w ] == " # " : NEW_LINE INDENT pos = [ h + 1 , w ] NEW_LINE num += 1 NEW_LINE continue NEW_LINE DEDENT if w != W - 1 and A_s [ h ] [ w + 1 ] == " # " : NEW_LINE INDENT pos = [ h , w + 1 ] NEW_LINE num += 1 NEW_LINE continue NEW_LINE DEDENT ans = False NEW_LINE break NEW_LINE DEDENT print ( " Possible " if ans else " Impossible " ) NEW_LINE

import re NEW_LINE pattern = re . compile ( ' ^ ( ? : \ . * ) ( # + ) ( ? : \ . * ) $ ' ) NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE board = [ input ( ) for i in range ( H ) ] NEW_LINE c = 0 NEW_LINE for row in board : NEW_LINE INDENT result = pattern . match ( row ) NEW_LINE if result == None or result . start ( 1 ) != c : NEW_LINE INDENT print ( " Impossible " ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT c = result . end ( 1 ) - 1 NEW_LINE DEDENT DEDENT print ( " Possible " ) NEW_LINE

h , w = map ( int , input ( ) . split ( ) ) ; c = 0 NEW_LINE for i in range ( h ) : NEW_LINE INDENT a = input ( ) NEW_LINE b = [ ] NEW_LINE for j in range ( w ) : b . append ( a [ j ] ) NEW_LINE c += b . count ( " # " ) NEW_LINE DEDENT print ( " Possible " if h + w - 1 == c else " Impossible " ) NEW_LINE

from collections import deque NEW_LINE h , w = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a = [ [ i for i in input ( ) ] for _ in range ( h ) ] NEW_LINE right_count = sum ( [ sum ( [ 1 for j in range ( w ) if a [ i ] [ j ] == " # " ] ) for i in range ( h ) ] ) NEW_LINE pattern = [ ( 1 , 0 ) , ( 0 , 1 ) ] NEW_LINE queue = deque ( [ ( 0 , 0 ) ] ) NEW_LINE def bfs ( ) : NEW_LINE INDENT cnt = 1 NEW_LINE while queue : NEW_LINE INDENT ( x , y ) = queue . popleft ( ) NEW_LINE if ( x , y ) == ( w - 1 , h - 1 ) : NEW_LINE INDENT return cnt NEW_LINE DEDENT around = False NEW_LINE for i , j in pattern : NEW_LINE INDENT if y + i < h and x + j < w : NEW_LINE INDENT if a [ y + i ] [ x + j ] == " # " : NEW_LINE INDENT queue . append ( ( x + j , y + i ) ) NEW_LINE around = True NEW_LINE cnt += 1 NEW_LINE DEDENT DEDENT DEDENT if around == False : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT print ( " Possible " if bfs ( ) == right_count else " Impossible " ) NEW_LINE

t = open ( 0 ) . read ( ) ; print ( ' I ▁ mPp ' [ t . count ( ' # ' ) < int ( t [ 0 ] ) + int ( t [ 2 ] ) : : 2 ] + ' ossible ' ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] t = new int [ n + 1 ] ; int [ ] x = new int [ n + 1 ] ; int [ ] y = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { int dt = t [ i ] - t [ i - 1 ] ; int dx = Math . abs ( x [ i ] - x [ i - 1 ] ) ; int dy = Math . abs ( y [ i ] - y [ i - 1 ] ) ; int time = dt - dx - dy ; if ( time < 0 || time % 2 == 1 ) { System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } }

import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? " Yes " : " No " ; } public static void main ( String [ ] args ) { int n = nextInt ( ) ; int x = 0 , y = 0 ; long tSum = 0 ; boolean F = true ; for ( int i = 0 ; i < n ; i ++ ) { long t = nextInt ( ) - tSum ; tSum += t ; int tempX = nextInt ( ) ; int tempY = nextInt ( ) ; if ( x == tempX && y == tempY ) { F = false ; break ; } int dist = calcManhatDistance ( x , y , tempX , tempY ) ; if ( dist > t || dist % 2 != t % 2 ) { F = false ; break ; } x = tempX ; y = tempY ; } System . out . println ( yesno ( F ) ) ; } static int calcManhatDistance ( int x1 , int y1 , int x2 , int y2 ) { int d = Math . abs ( x1 - x2 ) + Math . abs ( y1 - y2 ) ; return d ; } static double calcEuclidDistance ( double x1 , double y1 , double x2 , double y2 ) { double d = Math . sqrt ( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) ; return d ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskC solver = new TaskC ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskC { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; int lastX = 0 , lastY = 0 , lastT = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int t = in . nextInt ( ) , x = in . nextInt ( ) , y = in . nextInt ( ) ; int dist = Math . abs ( x - lastX ) + Math . abs ( y - lastY ) ; if ( dist > t - lastT || dist % 2 != ( t - lastT ) % 2 ) { out . println ( " No " ) ; return ; } lastX = x ; lastY = y ; lastT = t ; } out . println ( " Yes " ) ; } } static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( InputStream in ) { br = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { String line = null ; try { line = br . readLine ( ) ; } catch ( IOException e ) { } st = new StringTokenizer ( line ) ; } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . util . Scanner ; class C { public static void main ( String ... args ) { final Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; final int [ ] x = new int [ N + 1 ] ; final int [ ] y = new int [ N + 1 ] ; final int [ ] t = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { t [ i ] = sc . nextInt ( ) ; x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= N ; i ++ ) { final int dist = Math . abs ( x [ i ] - x [ i - 1 ] ) + Math . abs ( y [ i ] - y [ i - 1 ] ) ; if ( dist > t [ i ] - t [ i - 1 ] || ( dist - t [ i ] + t [ i - 1 ] ) % 2 != 0 ) { System . err . println ( dist + " ▁ " + i ) ; System . out . println ( " No " ) ; return ; } } System . out . println ( " Yes " ) ; } } public class Main { public static void main ( String ... args ) { C . main ( args ) ; } }

import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String stN = sc . nextLine ( ) ; int n = Integer . parseInt ( stN ) ; String line = null ; List < String > lines = null ; int t = 0 ; int x = 0 ; int y = 0 ; int nT = 0 ; int nX = 0 ; int nY = 0 ; int abs = 0 ; while ( sc . hasNext ( ) ) { line = sc . nextLine ( ) ; lines = Arrays . asList ( line . split ( " ▁ " ) ) ; nT = Integer . parseInt ( lines . get ( 0 ) ) ; nX = Integer . parseInt ( lines . get ( 1 ) ) ; nY = Integer . parseInt ( lines . get ( 2 ) ) ; abs = Math . abs ( nX - x ) + Math . abs ( nY - y ) ; if ( abs == ( nT - t ) ) { } else if ( abs < ( nT - t ) && ( ( nT - t ) - abs ) % 2 == 0 ) { } else { System . out . println ( " No " ) ; return ; } t = nT ; x = nX ; y = nY ; } System . out . println ( " Yes " ) ; } }

n = int ( input ( ) ) NEW_LINE s , a , b = 0 , 0 , 0 NEW_LINE f = True NEW_LINE for _ in [ 0 ] * n : NEW_LINE INDENT t , x , y = map ( int , input ( ) . split ( ) ) NEW_LINE p = t - s - ( abs ( x - a ) + abs ( y - b ) ) NEW_LINE if p % 2 == 1 or p < 0 : NEW_LINE INDENT f = False NEW_LINE DEDENT DEDENT print ( " Yes " if f else " No " ) NEW_LINE

import sys NEW_LINE def chk1 ( t , x , y ) : NEW_LINE INDENT return t % 2 == ( x + y ) % 2 NEW_LINE DEDENT def chk2 ( t , x , y ) : NEW_LINE INDENT return t >= abs ( x ) + abs ( y ) NEW_LINE DEDENT def chk ( t , x , y ) : NEW_LINE INDENT return chk1 ( t , x , y ) and chk2 ( t , x , y ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE T = [ 0 ] * ( N + 1 ) NEW_LINE X = [ 0 ] * ( N + 1 ) NEW_LINE Y = [ 0 ] * ( N + 1 ) NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT T [ i ] , X [ i ] , Y [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT for i in range ( 1 , N + 1 ) : NEW_LINE INDENT dt , dx , dy = T [ i ] - T [ i - 1 ] , X [ i ] - X [ i - 1 ] , Y [ i ] - Y [ i - 1 ] NEW_LINE if not chk ( dt , dx , dy ) : NEW_LINE INDENT print ( ' No ' ) NEW_LINE sys . exit ( 0 ) NEW_LINE DEDENT DEDENT print ( ' Yes ' ) NEW_LINE

N = int ( input ( ) ) NEW_LINE list = [ ] NEW_LINE list . append ( ( 0 , 0 , 0 ) ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT t , x , y = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE list . append ( ( t , x , y ) ) NEW_LINE DEDENT def isReachable ( t1 , x1 , y1 , t2 , x2 , y2 ) : NEW_LINE INDENT if ( t2 - t1 ) < abs ( x1 - x2 ) + abs ( y1 - y2 ) : NEW_LINE INDENT return False NEW_LINE DEDENT if ( ( t2 - t1 ) - ( abs ( x1 - x2 ) + abs ( y1 - y2 ) ) ) % 2 == 0 : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT ret = True NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT t1 , x1 , y1 = list [ i ] NEW_LINE t2 , x2 , y2 = list [ i + 1 ] NEW_LINE b = isReachable ( t1 , x1 , y1 , t2 , x2 , y2 ) NEW_LINE if b == False : NEW_LINE INDENT ret = False NEW_LINE break NEW_LINE DEDENT DEDENT if ret == True : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT

N = int ( input ( ) ) NEW_LINE txy = [ input ( ) for i in range ( N ) ] NEW_LINE now_pos = [ 0 , 0 ] NEW_LINE now_time = 0 NEW_LINE fail_flag = False NEW_LINE for i in range ( N ) : NEW_LINE INDENT t , x , y = map ( int , txy [ i ] . split ( ' ▁ ' ) ) NEW_LINE if ( x + y ) % 2 != t % 2 : NEW_LINE INDENT fail_flag = True NEW_LINE DEDENT distance = ( abs ( now_pos [ 0 ] - x ) + abs ( now_pos [ 1 ] - y ) ) NEW_LINE if distance > t - now_time : NEW_LINE INDENT fail_flag = True NEW_LINE DEDENT if fail_flag : NEW_LINE INDENT print ( ' No ' ) NEW_LINE exit ( ) NEW_LINE DEDENT now_pos = [ x , y ] NEW_LINE now_time = t NEW_LINE DEDENT print ( ' Yes ' ) NEW_LINE

N = int ( input ( ) ) NEW_LINE travel = [ [ 0 , 0 , 0 ] ] + [ list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) for i in range ( N ) ] NEW_LINE ans = ' Yes ' NEW_LINE for i in range ( N ) : NEW_LINE INDENT dt = travel [ i + 1 ] [ 0 ] - travel [ i ] [ 0 ] NEW_LINE dx = abs ( travel [ i + 1 ] [ 1 ] - travel [ i ] [ 1 ] ) NEW_LINE dy = abs ( travel [ i + 1 ] [ 2 ] - travel [ i ] [ 2 ] ) NEW_LINE if dx + dy <= dt and ( dx + dy ) % 2 == dt % 2 : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' No ' NEW_LINE break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; double max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { max = Math . max ( max , ( sc . nextDouble ( ) + sc . nextDouble ( ) + sc . nextDouble ( ) + sc . nextDouble ( ) ) + ( sc . nextDouble ( ) * 110 / ( double ) 900 ) ) ; } System . out . println ( max ) ; } }

import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int n = Integer . parseInt ( br . readLine ( ) ) ; double max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] arr = br . readLine ( ) . split ( " ▁ " , 5 ) ; double sum = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { int x = Integer . parseInt ( arr [ j ] ) ; if ( j < 4 ) { sum += x ; } else { sum += ( double ) x * ( 110.0 / 900.0 ) ; } } if ( max < sum ) { max = sum ; } } System . out . println ( max ) ; } }

import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; double ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { double score = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { double s = sc . nextDouble ( ) ; score += j != 4 ? s : s * 11 / 90 ; } ans = max ( score , ans ) ; } out . println ( ans ) ; } }

import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { double res = - 1145141919 ; for ( int n = s . nextInt ( ) ; n > 0 ; n -- ) { double sum = 0 ; for ( int j = 0 ; j < 4 ; j ++ ) sum += s . nextInt ( ) ; sum += s . nextInt ( ) * 110 / 900.0 ; res = Math . max ( res , sum ) ; } System . out . println ( res ) ; } }

import java . util . * ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; double max = 0 ; for ( int i = 0 ; i < N ; i ++ ) { double sum = 0 ; for ( int j = 0 ; j < 4 ; j ++ ) { sum += sc . nextInt ( ) ; } sum += ( 110 * sc . nextInt ( ) / 900.0 ) ; max = Math . max ( max , sum ) ; } System . out . println ( max ) ; } }

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for _ in range ( N ) : NEW_LINE INDENT * a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = max ( ans , sum ( a ) + b * 110 / 900 ) NEW_LINE DEDENT print ( ans ) NEW_LINE

m = 0 ; exec ( ' * a , = map ( int , input ( ) . split ( ) ) ; m = max ( m , sum ( a [ :4 ] , a [ 4 ] * 11/90 ) ) ; ' * int ( input ( ) ) ) ; print ( m ) NEW_LINE

N = int ( input ( ) ) NEW_LINE L = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE res = - 1 NEW_LINE for l in L : NEW_LINE INDENT tmp = 0 NEW_LINE for i in range ( 5 ) : NEW_LINE INDENT if i == 4 : NEW_LINE INDENT tmp += l [ i ] * 110 / 900 NEW_LINE DEDENT else : NEW_LINE INDENT tmp += l [ i ] NEW_LINE DEDENT DEDENT res = max ( res , tmp ) NEW_LINE DEDENT print ( res ) NEW_LINE

def ans ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE max_ = 0 NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b , c , d , e = map ( int , input ( ) . split ( ) ) NEW_LINE score = a + b + c + d + e * ( 110 / 900 ) NEW_LINE if ( score > max_ ) : NEW_LINE INDENT max_ = score NEW_LINE DEDENT DEDENT if ( max_ == int ( max_ ) ) : NEW_LINE INDENT print ( int ( max_ ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( max_ ) NEW_LINE DEDENT DEDENT ans ( ) NEW_LINE

N = int ( input ( ) ) NEW_LINE scores = [ ] NEW_LINE for idx in range ( 0 , N ) : NEW_LINE INDENT scores . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT sums = [ ] NEW_LINE for score in scores : NEW_LINE INDENT sum = score [ 0 ] + score [ 1 ] + score [ 2 ] + score [ 3 ] + score [ 4 ] * 11 / 90.0 NEW_LINE sums . append ( sum ) NEW_LINE DEDENT print ( max ( sums ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String l1 = sc . next ( ) ; String l2 = sc . next ( ) ; char temp1 ; char temp2 ; for ( int i = 0 ; i < l1 . length ( ) ; i ++ ) { temp1 = l1 . charAt ( i ) ; temp2 = l2 . charAt ( i ) ; if ( temp1 != temp2 ) { if ( temp1 == ' @ ' && ( temp2 == ' a ' || temp2 == ' t ' || temp2 == ' c ' || temp2 == ' o ' || temp2 == ' d ' || temp2 == ' e ' || temp2 == ' r ' ) ) { } else if ( temp2 == ' @ ' && ( temp1 == ' a ' || temp1 == ' t ' || temp1 == ' c ' || temp1 == ' o ' || temp1 == ' d ' || temp1 == ' e ' || temp1 == ' r ' ) ) { } else { System . out . println ( " You ▁ will ▁ lose " ) ; return ; } } } System . out . println ( " You ▁ can ▁ win " ) ; } }

import java . util . * ; class Main { public static boolean d ; public static int fun1 ( String s , String t ) { char [ ] charlist = { ' a ' , ' t ' , ' c ' , ' o ' , ' d ' , ' e ' , ' r ' } ; int i = s . length ( ) ; for ( int n = 0 ; n < i ; n ++ ) { d = false ; if ( s . charAt ( n ) != t . charAt ( n ) ) { if ( s . charAt ( n ) != ' @ ' && t . charAt ( n ) != ' @ ' ) { return 0 ; } else if ( s . charAt ( n ) == ' @ ' && t . charAt ( n ) != ' @ ' ) { for ( char target : charlist ) { if ( t . charAt ( n ) == target ) { d = true ; break ; } } if ( d == false ) { return 0 ; } } else if ( s . charAt ( n ) != ' @ ' && t . charAt ( n ) == ' @ ' ) { for ( char target : charlist ) { if ( s . charAt ( n ) == target ) { d = true ; break ; } } if ( d == false ) { return 0 ; } } } } return 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . nextLine ( ) ; String t = sc . nextLine ( ) ; int result = fun1 ( s , t ) ; if ( result == 0 ) { System . out . println ( " You ▁ will ▁ lose " ) ; } else { System . out . println ( " You ▁ can ▁ win " ) ; } } }

import java . util . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { char [ ] sArr = sc . next ( ) . toCharArray ( ) ; char [ ] tArr = sc . next ( ) . toCharArray ( ) ; Set < Character > chars = new HashSet < > ( Arrays . asList ( ' @ ' , ' a ' , ' t ' , ' c ' , ' o ' , ' d ' , ' e ' , ' r ' ) ) ; System . out . println ( isWinner ( chars , sArr , tArr ) ? " You ▁ can ▁ win " : " You ▁ will ▁ lose " ) ; } static boolean isWinner ( Set < Character > chars , char [ ] sArr , char [ ] tArr ) { for ( int i = 0 ; i < sArr . length ; i ++ ) { for ( int j = 0 ; j < tArr . length ; j ++ ) { if ( isValid ( chars , sArr [ i ] , tArr [ i ] ) ) { continue ; } else { return false ; } } } return true ; } static boolean isValid ( Set < Character > chars , char c1 , char c2 ) { return ( c1 == ' @ ' && chars . contains ( c2 ) ) || ( c2 == ' @ ' && chars . contains ( c1 ) ) || ( c1 == c2 ) ; } }

import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String a = sc . next ( ) ; String b = sc . next ( ) ; String c = null ; String [ ] list = new String [ a . length ( ) ] ; String [ ] list2 = new String [ a . length ( ) ] ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { list [ i ] = String . valueOf ( a . charAt ( i ) ) ; list2 [ i ] = String . valueOf ( b . charAt ( i ) ) ; } String atc = " [ a | t | c | o | d | e | r ] " ; boolean bl = false ; for ( int i = 0 ; i < a . length ( ) ; i ++ ) { if ( bl == true || i == 0 ) { if ( list [ i ] . equals ( list2 [ i ] ) ) { bl = true ; } else if ( list [ i ] . equals ( " @ " ) ) { bl = list2 [ i ] . matches ( atc ) ; } else if ( list2 [ i ] . equals ( " @ " ) ) { bl = list [ i ] . matches ( atc ) ; } else { bl = false ; } } else { break ; } } ; if ( bl == true ) { c = " You ▁ can ▁ win " ; } else { c = " You ▁ will ▁ lose " ; } System . out . println ( c ) ; System . out . flush ( ) ; sc . close ( ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; String t = scanner . nextLine ( ) ; scanner . close ( ) ; String [ ] toReplace = { " a " , " t " , " c " , " o " , " d " , " e " , " r " } ; boolean canWin = true ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( ! canWin ) { break ; } if ( s . charAt ( i ) == t . charAt ( i ) ) { canWin = true ; } else if ( s . charAt ( i ) == ' @ ' ) { canWin = containToReplace ( t . charAt ( i ) ) ; } else if ( t . charAt ( i ) == ' @ ' ) { canWin = containToReplace ( s . charAt ( i ) ) ; } else { canWin = false ; } } String msg = " " ; if ( canWin ) { msg = " You ▁ can ▁ win " ; } else { msg = " You ▁ will ▁ lose " ; } System . out . println ( msg ) ; } private static boolean containToReplace ( char c ) { char [ ] toReplace = { ' a ' , ' t ' , ' c ' , ' o ' , ' d ' , ' e ' , ' r ' } ; for ( int i = 0 ; i < toReplace . length ; i ++ ) { if ( c == toReplace [ i ] ) { return true ; } } return false ; } }

print ( ' You ▁ can ▁ win ' * all ( s + t in ' @ a @ t @ c @ o @ d @ e @ r @ ' + s * 2 for s , t in zip ( * open ( 0 ) ) ) or ' You ▁ will ▁ lose ' ) NEW_LINE

S = list ( input ( ) ) NEW_LINE T = list ( input ( ) ) NEW_LINE pit = 0 NEW_LINE N = len ( S ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] != T [ i ] : NEW_LINE INDENT if S [ i ] == ' @ ' : NEW_LINE INDENT if T [ i ] == ' a ' or T [ i ] == ' t ' or T [ i ] == ' c ' or T [ i ] == ' o ' or T [ i ] == ' d ' or T [ i ] == ' e ' or T [ i ] == ' r ' or T [ i ] == ' @ ' : NEW_LINE INDENT pit = pit + 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' You ▁ will ▁ lose ' ) NEW_LINE break NEW_LINE DEDENT DEDENT elif T [ i ] == ' @ ' : NEW_LINE INDENT if S [ i ] == ' a ' or S [ i ] == ' t ' or S [ i ] == ' c ' or S [ i ] == ' o ' or S [ i ] == ' d ' or S [ i ] == ' e ' or S [ i ] == ' r ' or S [ i ] == ' @ ' : NEW_LINE INDENT pit = pit + 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' You ▁ will ▁ lose ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' You ▁ will ▁ lose ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT pit = pit + 1 NEW_LINE DEDENT DEDENT if pit == N : NEW_LINE INDENT print ( ' You ▁ can ▁ win ' ) NEW_LINE DEDENT

flag1 = False NEW_LINE flag2 = False NEW_LINE s1 = input ( ) NEW_LINE s2 = input ( ) NEW_LINE win = " You ▁ can ▁ win " NEW_LINE lose = " You ▁ will ▁ lose " NEW_LINE for i in range ( len ( s1 ) ) : NEW_LINE INDENT if s1 [ i ] == " @ " : NEW_LINE INDENT if s2 [ i ] != " a " and s2 [ i ] != " t " and s2 [ i ] != " c " and s2 [ i ] != " o " and s2 [ i ] != " d " and s2 [ i ] != " e " and s2 [ i ] != " r " and s2 [ i ] != " @ " : NEW_LINE INDENT flag1 = True NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if s1 [ i ] != s2 [ i ] : NEW_LINE INDENT if s2 [ i ] != " @ " : NEW_LINE INDENT flag1 = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in range ( len ( s2 ) ) : NEW_LINE INDENT if s2 [ i ] == " @ " : NEW_LINE INDENT if s1 [ i ] != " a " and s1 [ i ] != " t " and s1 [ i ] != " c " and s1 [ i ] != " o " and s1 [ i ] != " d " and s1 [ i ] != " e " and s1 [ i ] != " r " and s1 [ i ] != " @ " : NEW_LINE INDENT flag2 = True NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if s1 [ i ] != s2 [ i ] : NEW_LINE INDENT if s1 [ i ] != " @ " : NEW_LINE INDENT flag2 = True NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT if flag1 or flag2 : NEW_LINE INDENT print ( lose ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( win ) NEW_LINE DEDENT

S = input ( ) NEW_LINE T = input ( ) NEW_LINE lll = [ " a " , " t " , " c " , " o " , " d " , " e " , " r " ] NEW_LINE if S == T : NEW_LINE INDENT print ( " You ▁ can ▁ win " ) NEW_LINE exit ( ) NEW_LINE DEDENT if " @ " not in S and " @ " not in T : NEW_LINE INDENT print ( " You ▁ will ▁ lose " ) NEW_LINE exit ( ) NEW_LINE DEDENT for i , w in enumerate ( S ) : NEW_LINE INDENT if " @ " == w : NEW_LINE INDENT r = T [ i ] NEW_LINE if r not in lll : NEW_LINE INDENT if " @ " == r : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( " You ▁ will ▁ lose " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if w == T [ i ] : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if T [ i ] == " @ " : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( " You ▁ will ▁ lose " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT for i , w in enumerate ( T ) : NEW_LINE INDENT if " @ " == w : NEW_LINE INDENT r = S [ i ] NEW_LINE if r not in lll : NEW_LINE INDENT if " @ " == r : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( " You ▁ will ▁ lose " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if w == S [ i ] : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if S [ i ] == " @ " : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( " You ▁ will ▁ lose " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( " You ▁ can ▁ win " ) NEW_LINE

s = list ( input ( ) ) NEW_LINE t = list ( input ( ) ) NEW_LINE x = list ( " atcorder @ " ) NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if s [ i ] == " @ " and t [ i ] in x : NEW_LINE INDENT continue NEW_LINE DEDENT elif t [ i ] == " @ " and s [ i ] in x : NEW_LINE INDENT continue NEW_LINE DEDENT elif s [ i ] == t [ i ] : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( " You ▁ will ▁ lose " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT print ( " You ▁ can ▁ win " ) NEW_LINE


import java . util . * ; import static java . lang . Integer . parseInt ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int question = sc . nextInt ( ) ; ArrayList < String > answers = new ArrayList < String > ( ) ; int scores [ ] = new int [ 4 ] ; answers . add ( sc . next ( ) ) ; for ( int i = 0 ; i < 4 ; i ++ ) { for ( int digit = 0 ; digit < question ; digit ++ ) if ( parseInt ( answers . get ( 0 ) . substring ( digit , digit + 1 ) ) == ( i + 1 ) ) { scores [ i ] = scores [ i ] + 1 ; } } int max = scores [ 0 ] ; int min = scores [ 1 ] ; for ( int i = 0 ; i < scores . length ; i ++ ) { int v = scores [ i ] ; if ( v > max ) { max = v ; } if ( v < min ) { min = v ; } } System . out . println ( max + " ▁ " + min ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int bias = 100 ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; if ( A == B ) { System . out . println ( 0 ) ; System . exit ( 0 ) ; } HashSet < Integer > fixed = new HashSet < > ( ) ; int [ ] dic = new int [ ] { 1 , 5 , 10 , - 1 , - 5 , - 10 } ; B = Math . abs ( B - A ) + bias ; int [ ] dist = new int [ 2 * bias + 1 ] ; Arrays . fill ( dist , Integer . MAX_VALUE ) ; dist [ bias ] = 0 ; myComparator mc = new myComparator ( ) ; PriorityQueue < int [ ] > pq = new PriorityQueue < > ( 10 , mc ) ; pq . add ( new int [ ] { bias , 0 } ) ; while ( ! fixed . contains ( B ) ) { int [ ] cur = pq . poll ( ) ; int now = cur [ 0 ] ; if ( fixed . contains ( now ) ) continue ; fixed . add ( now ) ; dist [ now ] = cur [ 1 ] ; for ( int w : dic ) { if ( ! fixed . contains ( now + w ) ) { if ( now + w > 2 * bias || now + w < 0 ) continue ; if ( dist [ now + w ] > dist [ now ] + 1 ) { dist [ now + w ] = dist [ now ] + 1 ; pq . add ( new int [ ] { now + w , dist [ now ] + 1 } ) ; } } } } int ans = dist [ B ] ; System . out . println ( ans ) ; } static class myComparator implements Comparator < int [ ] > { public int compare ( int [ ] a , int [ ] b ) { return a [ 1 ] - b [ 1 ] ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int count = 0 ; int dif = A - B ; while ( dif != 0 ) { if ( dif >= 8 ) { dif -= 10 ; } else if ( dif >= 4 ) { dif -= 5 ; } else if ( dif >= 1 ) { dif -- ; } else if ( dif <= - 8 ) { dif += 10 ; } else if ( dif <= - 4 ) { dif += 5 ; } else { dif ++ ; } count ++ ; } out . println ( count ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int a [ ] = new int [ 4 ] ; for ( int i = 0 ; i < n ; i ++ ) { switch ( s . charAt ( i ) ) { case ( '1' ) : a [ 0 ] ++ ; break ; case ( '2' ) : a [ 1 ] ++ ; break ; case ( '3' ) : a [ 2 ] ++ ; break ; case ( '4' ) : a [ 3 ] ++ ; break ; } } Arrays . sort ( a ) ; System . out . println ( a [ 3 ] + " ▁ " + a [ 0 ] ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 ; } } }

import java . util . * ; import java . io . * ; public class Main { public static int solve ( int A , int B ) { int ans = Integer . MAX_VALUE ; for ( int one = - 4 ; one <= 4 ; one ++ ) { for ( int five = - 1 ; five <= 1 ; five ++ ) { for ( int ten = - 10 ; ten <= 10 ; ten ++ ) { if ( A + one + 5 * five + 10 * ten == B ) ans = Math . min ( ans , Math . abs ( one ) + Math . abs ( five ) + Math . abs ( ten ) ) ; } } } return ans ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( solve ( A , B ) ) ; } }

n = int ( input ( ) ) NEW_LINE cs = input ( ) . strip ( ) NEW_LINE cd = { '1' : 0 , '2' : 0 , '3' : 0 , '4' : 0 } NEW_LINE for c in cs : NEW_LINE INDENT cd [ c ] += 1 NEW_LINE DEDENT print ( max ( v for v in cd . values ( ) ) , min ( v for v in cd . values ( ) ) ) NEW_LINE

a , b = map ( int , input ( ) . split ( ) ) NEW_LINE dis = abs ( b - a ) NEW_LINE ans1 = int ( dis / 10 ) NEW_LINE ex = dis % 10 NEW_LINE if ( ex == 1 or ex == 5 ) : NEW_LINE INDENT ans2 = 1 NEW_LINE DEDENT elif ( ex == 3 or ex == 7 or ex == 8 ) : NEW_LINE INDENT ans2 = 3 NEW_LINE DEDENT elif ( ex == 0 ) : NEW_LINE INDENT ans2 = 0 NEW_LINE DEDENT else : NEW_LINE INDENT ans2 = 2 NEW_LINE DEDENT print ( ans1 + ans2 ) NEW_LINE

from collections import defaultdict NEW_LINE from heapq import heappush , heappop NEW_LINE import sys NEW_LINE import math NEW_LINE import bisect NEW_LINE import itertools NEW_LINE def LI ( ) : return list ( map ( int , sys . stdin . readline ( ) . split ( ) ) ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def S ( ) : return list ( sys . stdin . readline ( ) ) NEW_LINE def IR ( n ) : return [ I ( ) for i in range ( n ) ] NEW_LINE def LIR ( n ) : return [ LI ( ) for i in range ( n ) ] NEW_LINE def SR ( n ) : return [ S ( ) for i in range ( n ) ] NEW_LINE def LSR ( n ) : return [ LS ( ) for i in range ( n ) ] NEW_LINE mod = 1000000007 NEW_LINE def A ( ) : NEW_LINE INDENT n = I ( ) NEW_LINE c = S ( ) NEW_LINE minans = float ( " INF " ) NEW_LINE maxans = 0 NEW_LINE for i in range ( 1 , 5 ) : NEW_LINE INDENT minans = min ( minans , c . count ( str ( i ) ) ) NEW_LINE maxans = max ( maxans , c . count ( str ( i ) ) ) NEW_LINE DEDENT print ( maxans , minans ) NEW_LINE DEDENT def B ( ) : NEW_LINE INDENT a , b = LI ( ) NEW_LINE ans = 0 NEW_LINE while a != b : NEW_LINE INDENT if a > b : NEW_LINE INDENT a = a ^ b NEW_LINE b = a ^ b NEW_LINE a = a ^ b NEW_LINE DEDENT ab = b - a NEW_LINE if ab >= 8 : NEW_LINE INDENT a += 10 NEW_LINE DEDENT elif ab >= 3 : NEW_LINE INDENT a += 5 NEW_LINE DEDENT else : NEW_LINE INDENT a += 1 NEW_LINE DEDENT ans += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT B ( ) NEW_LINE DEDENT

_ , c = open ( 0 ) ; print ( * sorted ( map ( c . count , '1234' ) ) [ : : - 3 ] ) NEW_LINE

import numpy as np NEW_LINE class Calculator : NEW_LINE INDENT def __init__ ( self , arr ) : NEW_LINE INDENT self . arr = arr NEW_LINE DEDENT def calc ( self ) : NEW_LINE INDENT self . min_num = 9999 NEW_LINE self . max_num = 0 NEW_LINE for i in range ( 1 , 5 ) : NEW_LINE INDENT self . sum = np . sum ( self . arr == i ) NEW_LINE self . min_num = min ( self . min_num , self . sum ) NEW_LINE self . max_num = max ( self . max_num , self . sum ) NEW_LINE DEDENT DEDENT def get_max ( self ) : NEW_LINE INDENT return self . max_num NEW_LINE DEDENT def get_min ( self ) : NEW_LINE INDENT return self . min_num NEW_LINE DEDENT DEDENT def main ( ) : NEW_LINE INDENT N , = map ( int , input ( ) . split ( ) ) NEW_LINE c = list ( map ( int , list ( input ( ) ) ) ) NEW_LINE arr = np . array ( c , dtype = int ) NEW_LINE calc = Calculator ( arr ) NEW_LINE calc . calc ( ) NEW_LINE print ( calc . get_max ( ) , calc . get_min ( ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . Scanner ; import java . util . ArrayList ; import java . util . List ; public class Main { static List < Edge > [ ] list ; static long [ ] dist ; static class Edge { int to ; long cost ; public Edge ( int to , long cost ) { this . to = to ; this . cost = cost ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; list = new ArrayList [ n ] ; dist = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { list [ i ] = new ArrayList < Edge > ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; long c = sc . nextLong ( ) ; list [ a ] . add ( new Edge ( b , c ) ) ; list [ b ] . add ( new Edge ( a , c ) ) ; } int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) - 1 ; dfs ( k , - 1 , 0 ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; System . out . println ( dist [ x ] + dist [ y ] ) ; } } static void dfs ( int place , int front , long cost ) { dist [ place ] = cost ; for ( Edge e : list [ place ] ) { if ( e . to != front ) { dfs ( e . to , place , cost + e . cost ) ; } } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import java . util . * ; public class Main { static ArrayList < Route > [ ] lists ; static long [ ] costs ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; lists = new ArrayList [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { lists [ i ] = new ArrayList < Route > ( ) ; } for ( int i = 1 ; i < n ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; lists [ a ] . add ( new Route ( b , c ) ) ; lists [ b ] . add ( new Route ( a , c ) ) ; } costs = new long [ n + 1 ] ; Arrays . fill ( costs , - 1 ) ; int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; setCost ( 0 , k ) ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; sb . append ( costs [ x ] + costs [ y ] ) . append ( " \n " ) ; } System . out . print ( sb ) ; } static void setCost ( long total , int idx ) { if ( costs [ idx ] == - 1 ) { costs [ idx ] = total ; for ( Route r : lists [ idx ] ) { setCost ( total + r . cost , r . point ) ; } } } static class Route { public int point ; public long cost ; public Route ( int point , long cost ) { this . point = point ; this . cost = cost ; } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { static List < Edge > [ ] list ; static long [ ] dist ; static class Edge { int to ; long cost ; public Edge ( int to , long cost ) { this . to = to ; this . cost = cost ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; list = new ArrayList [ n ] ; dist = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) list [ i ] = new ArrayList < Edge > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) - 1 ; int b = sc . nextInt ( ) - 1 ; long c = sc . nextLong ( ) ; list [ a ] . add ( new Edge ( b , c ) ) ; list [ b ] . add ( new Edge ( a , c ) ) ; } int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) - 1 ; dfs ( k , - 1 , 0 ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) - 1 ; int y = sc . nextInt ( ) - 1 ; System . out . println ( dist [ x ] + dist [ y ] ) ; } } static void dfs ( int v , int p , long d ) { dist [ v ] = d ; for ( Edge e : list [ v ] ) { if ( e . to != p ) { dfs ( e . to , v , d + e . cost ) ; } } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; Node [ ] nodes = new Node [ N ] ; for ( int i = 0 ; i < N ; i ++ ) nodes [ i ] = new Node ( i ) ; for ( int i = 0 ; i < N - 1 ; i ++ ) { int a = scanner . nextInt ( ) - 1 ; int b = scanner . nextInt ( ) - 1 ; int c = scanner . nextInt ( ) ; nodes [ a ] . edges . add ( new Edge ( nodes [ b ] , c ) ) ; nodes [ b ] . edges . add ( new Edge ( nodes [ a ] , c ) ) ; } int Q = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) - 1 ; dfs ( nodes [ K ] , 0 ) ; for ( int i = 0 ; i < Q ; i ++ ) { int x = scanner . nextInt ( ) - 1 ; int y = scanner . nextInt ( ) - 1 ; System . out . println ( nodes [ x ] . depth + nodes [ y ] . depth ) ; } } private static void dfs ( Node n , long depth ) { n . depth = depth ; n . visited = true ; for ( Edge e : n . edges ) { if ( ! e . to . visited ) dfs ( e . to , depth + e . dist ) ; } } static class Node { final int id ; boolean visited ; List < Edge > edges = new ArrayList < > ( ) ; long depth = 0 ; Node ( int id ) { this . id = id ; } } static class Edge { final Node to ; final int dist ; Edge ( Node to , int dist ) { this . to = to ; this . dist = dist ; } } }

import java . util . Scanner ; import java . util . ArrayList ; public class Main { static ArrayList < Edge > [ ] list ; static long [ ] dist ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; list = new ArrayList [ n + 1 ] ; dist = new long [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) { list [ i ] = new ArrayList < > ( ) ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long c = sc . nextLong ( ) ; list [ a ] . add ( new Edge ( b , c ) ) ; list [ b ] . add ( new Edge ( a , c ) ) ; } int q = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; dfs ( k , 0 , - 1 ) ; for ( int i = 0 ; i < q ; i ++ ) { int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; System . out . println ( dist [ x ] + dist [ y ] ) ; } } static void dfs ( int now , long cost , int front ) { dist [ now ] = cost ; for ( Edge i : list [ now ] ) { if ( i . to != front ) { dfs ( i . to , i . cost + cost , now ) ; } } } static class Edge { int to ; long cost ; public Edge ( int to , long cost ) { this . to = to ; this . cost = cost ; } } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import sys NEW_LINE from collections import deque NEW_LINE def dfs ( start , dest , pre , d ) : NEW_LINE INDENT if d [ start ] [ dest ] > 0 : NEW_LINE INDENT return d [ start ] [ dest ] NEW_LINE DEDENT for i in range ( len ( d ) ) : NEW_LINE INDENT if d [ start ] [ i ] > 0 and i != pre : NEW_LINE INDENT c = dfs ( i , dest , start , d ) NEW_LINE if c > 0 : NEW_LINE INDENT return d [ start ] [ i ] + dfs ( i , dest , start , d ) NEW_LINE DEDENT DEDENT DEDENT return 0 NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE d = [ [ ] for _ in range ( N ) ] NEW_LINE for _ in range ( N - 1 ) : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE a , b = a - 1 , b - 1 NEW_LINE d [ a ] . append ( ( b , c ) ) NEW_LINE d [ b ] . append ( ( a , c ) ) NEW_LINE DEDENT Q , K = map ( int , input ( ) . split ( ) ) NEW_LINE K -= 1 NEW_LINE k_dist = [ 0 for _ in range ( N ) ] NEW_LINE start = deque ( ) NEW_LINE start . append ( K ) NEW_LINE while len ( start ) > 0 : NEW_LINE INDENT s = start . popleft ( ) NEW_LINE for dest , cost in d [ s ] : NEW_LINE INDENT if k_dist [ dest ] > 0 : NEW_LINE INDENT continue NEW_LINE DEDENT k_dist [ dest ] = k_dist [ s ] + cost NEW_LINE start . append ( dest ) NEW_LINE DEDENT DEDENT for _ in range ( Q ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE x , y = x - 1 , y - 1 NEW_LINE print ( int ( k_dist [ x ] + k_dist [ y ] ) ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 6 ) NEW_LINE n = int ( input ( ) ) NEW_LINE inf = float ( " inf " ) NEW_LINE road = [ dict ( ) for _ in range ( n + 1 ) ] NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE road [ a ] [ b ] = c NEW_LINE road [ b ] [ a ] = c NEW_LINE DEDENT q , k = map ( int , input ( ) . split ( ) ) NEW_LINE dfs = [ inf ] * ( n + 1 ) NEW_LINE dfs [ k ] = 0 NEW_LINE def dodfs ( x ) : NEW_LINE INDENT for i in road [ x ] : NEW_LINE INDENT if dfs [ i ] == inf : NEW_LINE INDENT dfs [ i ] = dfs [ x ] + road [ x ] [ i ] NEW_LINE dodfs ( i ) NEW_LINE DEDENT DEDENT return NEW_LINE DEDENT dodfs ( k ) NEW_LINE for _ in range ( q ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE print ( dfs [ x ] + dfs [ y ] ) NEW_LINE DEDENT

import heapq NEW_LINE def dijkstra_heap ( s ) : NEW_LINE INDENT d = [ float ( " inf " ) ] * n NEW_LINE used = [ True ] * n NEW_LINE d [ s ] = 0 NEW_LINE used [ s ] = False NEW_LINE edgelist = [ ] NEW_LINE for e in edge [ s ] : NEW_LINE INDENT heapq . heappush ( edgelist , e ) NEW_LINE DEDENT while len ( edgelist ) : NEW_LINE INDENT minedge = heapq . heappop ( edgelist ) NEW_LINE if not used [ minedge [ 1 ] ] : NEW_LINE INDENT continue NEW_LINE DEDENT v = minedge [ 1 ] NEW_LINE d [ v ] = minedge [ 0 ] NEW_LINE used [ v ] = False NEW_LINE for e in edge [ v ] : NEW_LINE INDENT if used [ e [ 1 ] ] : NEW_LINE INDENT heapq . heappush ( edgelist , [ e [ 0 ] + d [ v ] , e [ 1 ] ] ) NEW_LINE DEDENT DEDENT DEDENT return d NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE edge = [ [ ] for i in range ( n ) ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT x , y , z = map ( int , input ( ) . split ( ) ) NEW_LINE edge [ x - 1 ] . append ( [ z , y - 1 ] ) NEW_LINE edge [ y - 1 ] . append ( [ z , x - 1 ] ) NEW_LINE DEDENT Q , K = map ( int , input ( ) . split ( ) ) NEW_LINE L = dijkstra_heap ( K - 1 ) NEW_LINE query = [ ] NEW_LINE for i in range ( Q ) : NEW_LINE INDENT query . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT for i in range ( Q ) : NEW_LINE INDENT print ( L [ query [ i ] [ 0 ] - 1 ] + L [ query [ i ] [ 1 ] - 1 ] ) NEW_LINE DEDENT

from queue import Queue NEW_LINE def distances ( tree : list , treeSize : int , root : int ) -> list : NEW_LINE INDENT dists = [ 0 ] * treeSize NEW_LINE q = Queue ( ) NEW_LINE q . put ( ( root , - 1 , 0 ) ) NEW_LINE while not q . empty ( ) : NEW_LINE INDENT v , prev , d2v = q . get ( ) NEW_LINE dists [ v ] = d2v NEW_LINE for u , dv2u in tree [ v ] : NEW_LINE INDENT if prev == u : NEW_LINE INDENT continue NEW_LINE DEDENT q . put ( ( u , v , d2v + dv2u ) ) NEW_LINE DEDENT DEDENT return dists NEW_LINE DEDENT def transit_tree_path ( N : int , edges : list , Q : int , K : int , queries : list ) -> list : NEW_LINE INDENT tree = [ [ ] for _ in range ( N ) ] NEW_LINE for u , v , c in edges : NEW_LINE INDENT tree [ u - 1 ] . append ( ( v - 1 , c ) ) NEW_LINE tree [ v - 1 ] . append ( ( u - 1 , c ) ) NEW_LINE DEDENT d = distances ( tree , N , K - 1 ) NEW_LINE return [ d [ x - 1 ] + d [ y - 1 ] for x , y in queries ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE edges = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N - 1 ) ] NEW_LINE Q = 0 NEW_LINE Q , K = map ( int , input ( ) . split ( ) ) NEW_LINE queries = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( Q ) ] NEW_LINE ans = transit_tree_path ( N , edges , Q , K , queries ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT

def solve ( N , ABCs , Q , K , XYs ) : NEW_LINE INDENT path = [ [ ] for _ in range ( N + 1 ) ] NEW_LINE for ( a , b , c ) in ABCs : NEW_LINE INDENT path [ a ] . append ( ( b , c ) ) NEW_LINE path [ b ] . append ( ( a , c ) ) NEW_LINE DEDENT dst = [ 0 for _ in range ( N + 1 ) ] NEW_LINE q = [ K ] NEW_LINE while len ( q ) : NEW_LINE INDENT index = q . pop ( ) NEW_LINE for n , w in path [ index ] : NEW_LINE INDENT if dst [ n ] == 0 : NEW_LINE INDENT dst [ n ] = dst [ index ] + w NEW_LINE q . append ( n ) NEW_LINE DEDENT DEDENT DEDENT ans = [ ] NEW_LINE for x , y in XYs : NEW_LINE INDENT ans . append ( str ( dst [ x ] + dst [ y ] ) ) NEW_LINE DEDENT return " \n " . join ( ans ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ABCs = [ tuple ( map ( int , input ( ) . split ( " ▁ " ) ) ) for _ in range ( N - 1 ) ] NEW_LINE Q , K = tuple ( map ( int , input ( ) . split ( " ▁ " ) ) ) NEW_LINE XYs = [ tuple ( map ( int , input ( ) . split ( " ▁ " ) ) ) for _ in range ( Q ) ] NEW_LINE print ( solve ( N , ABCs , Q , K , XYs ) ) NEW_LINE DEDENT


import java . util . ArrayDeque ; import java . util . Deque ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { Map < String , Deque < String > > deq = new HashMap < > ( ) ; String [ ] participants = new String [ ] { " a " , " b " , " c " } ; for ( int i = 0 ; i < 3 ; i ++ ) { String s = sc . next ( ) ; deq . put ( participants [ i ] , new ArrayDeque < > ( ) ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { deq . get ( participants [ i ] ) . addLast ( s . charAt ( j ) + " " ) ; } } String prev = participants [ 0 ] ; while ( true ) { if ( deq . get ( prev ) . size ( ) == 0 ) { System . out . println ( prev . toUpperCase ( ) ) ; return ; } prev = deq . get ( prev ) . pollFirst ( ) ; } } }

import java . util . Scanner ; class Main { static String a ; static String b ; static String c ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; a = sc . next ( ) ; b = sc . next ( ) ; c = sc . next ( ) ; char ac = a . charAt ( 0 ) ; int ans = 0 ; if ( ac == ' a ' ) { ans = DisCard ( 1 ) ; } else if ( ac == ' b ' ) { ans = DisCard ( 2 ) ; } else { ans = DisCard ( 3 ) ; } String answ = " " ; if ( ans == 1 ) { answ = " A " ; } else if ( ans == 2 ) { answ = " B " ; } else { answ = " C " ; } System . out . println ( answ ) ; sc . close ( ) ; } public static int DisCard ( int player ) { if ( player == 1 ) { if ( a . length ( ) == 0 ) { return 1 ; } else { char c = a . charAt ( 0 ) ; a = a . substring ( 1 ) ; if ( c == ' a ' ) { return DisCard ( 1 ) ; } else if ( c == ' b ' ) { return DisCard ( 2 ) ; } else { return DisCard ( 3 ) ; } } } else if ( player == 2 ) { if ( b . length ( ) == 0 ) { return 2 ; } else { char c = b . charAt ( 0 ) ; b = b . substring ( 1 ) ; if ( c == ' a ' ) { return DisCard ( 1 ) ; } else if ( c == ' b ' ) { return DisCard ( 2 ) ; } else { return DisCard ( 3 ) ; } } } else { if ( c . length ( ) == 0 ) { return 3 ; } else { char cha = c . charAt ( 0 ) ; c = c . substring ( 1 ) ; if ( cha == ' a ' ) { return DisCard ( 1 ) ; } else if ( cha == ' b ' ) { return DisCard ( 2 ) ; } else { return DisCard ( 3 ) ; } } } } }

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String s_a = sc . next ( ) ; String s_b = sc . next ( ) ; String s_c = sc . next ( ) ; int la = s_a . length ( ) ; int lb = s_b . length ( ) ; int lc = s_c . length ( ) ; int a = la ; int b = lb ; int c = lc ; char turn = ' a ' ; String ans = null ; boolean end = false ; while ( ! end ) { switch ( turn ) { case ( ' a ' ) : if ( a == 0 ) { end = true ; ans = " A " ; break ; } turn = s_a . charAt ( la - a ) ; a -- ; break ; case ( ' b ' ) : if ( b == 0 ) { end = true ; ans = " B " ; break ; } turn = s_b . charAt ( lb - b ) ; b -- ; break ; case ( ' c ' ) : if ( c == 0 ) { end = true ; ans = " C " ; break ; } turn = s_c . charAt ( lc - c ) ; c -- ; break ; } } System . out . println ( ans ) ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { 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 ; } } }

import java . util . Scanner ; public class Main { public static char abc_ans ( String str_a , String str_b , String str_c ) { char [ ] a = str_a . toCharArray ( ) ; char [ ] b = str_b . toCharArray ( ) ; char [ ] c = str_c . toCharArray ( ) ; int a_count = a . length ; int b_count = b . length ; int c_count = c . length ; int a_number = 0 ; int b_number = 0 ; int c_number = 0 ; char x = a [ a_number ] ; while ( true ) { switch ( x ) { case ' a ' : if ( a_number >= a . length ) { return ( ' A ' ) ; } x = a [ a_number ] ; a_number ++ ; break ; case ' b ' : if ( b_number >= b . length ) { return ( ' B ' ) ; } x = b [ b_number ] ; b_number ++ ; break ; case ' c ' : if ( c_number >= c . length ) { return ( ' C ' ) ; } x = c [ c_number ] ; c_number ++ ; break ; } } } public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String str_a = scan . next ( ) ; String str_b = scan . next ( ) ; String str_c = scan . next ( ) ; System . out . println ( abc_ans ( str_a , str_b , str_c ) ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] letters = new String [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { letters [ i ] = input . readLine ( ) ; } int current = 0 ; int [ ] positions = new int [ 3 ] ; while ( true ) { if ( positions [ current ] == letters [ current ] . length ( ) ) { System . out . println ( ( char ) ( current + ' A ' ) ) ; break ; } current = letters [ current ] . charAt ( positions [ current ] ++ ) - ' a ' ; } } }

S = { c : list ( input ( ) ) for c in " abc " } NEW_LINE s = " a " NEW_LINE while S [ s ] : NEW_LINE INDENT s = S [ s ] . pop ( 0 ) NEW_LINE DEDENT print ( s . upper ( ) ) NEW_LINE

hoa = list ( input ( ) ) NEW_LINE hob = list ( input ( ) ) NEW_LINE hoc = list ( input ( ) ) NEW_LINE f = " A " NEW_LINE while 1 : NEW_LINE INDENT if ( f == " A " and len ( hoa ) == 0 ) : NEW_LINE INDENT print ( f ) NEW_LINE break NEW_LINE DEDENT elif ( f == " B " and len ( hob ) == 0 ) : NEW_LINE INDENT print ( f ) NEW_LINE break NEW_LINE DEDENT elif ( f == " C " and len ( hoc ) == 0 ) : NEW_LINE INDENT print ( f ) NEW_LINE break NEW_LINE DEDENT elif ( f == " A " ) : NEW_LINE INDENT if ( hoa [ 0 ] == " a " ) : NEW_LINE INDENT f = " A " NEW_LINE hoa = hoa [ 1 : ] NEW_LINE DEDENT elif ( hoa [ 0 ] == " b " ) : NEW_LINE INDENT f = " B " NEW_LINE hoa = hoa [ 1 : ] NEW_LINE DEDENT elif ( hoa [ 0 ] == " c " ) : NEW_LINE INDENT f = " C " NEW_LINE hoa = hoa [ 1 : ] NEW_LINE DEDENT DEDENT elif ( f == " B " ) : NEW_LINE INDENT if ( hob [ 0 ] == " a " ) : NEW_LINE INDENT f = " A " NEW_LINE hob = hob [ 1 : ] NEW_LINE DEDENT elif ( hob [ 0 ] == " b " ) : NEW_LINE INDENT f = " B " NEW_LINE hob = hob [ 1 : ] NEW_LINE DEDENT elif ( hob [ 0 ] == " c " ) : NEW_LINE INDENT f = " C " NEW_LINE hob = hob [ 1 : ] NEW_LINE DEDENT DEDENT elif ( f == " C " ) : NEW_LINE INDENT if ( hoc [ 0 ] == " a " ) : NEW_LINE INDENT f = " A " NEW_LINE hoc = hoc [ 1 : ] NEW_LINE DEDENT elif ( hoc [ 0 ] == " b " ) : NEW_LINE INDENT f = " B " NEW_LINE hoc = hoc [ 1 : ] NEW_LINE DEDENT elif ( hoc [ 0 ] == " c " ) : NEW_LINE INDENT f = " C " NEW_LINE hoc = hoc [ 1 : ] NEW_LINE DEDENT DEDENT DEDENT

def str2turn ( c : str ) -> int : NEW_LINE INDENT if c . lower ( ) == ' a ' : NEW_LINE INDENT return 0 NEW_LINE DEDENT elif c . lower ( ) == ' b ' : NEW_LINE INDENT return 1 NEW_LINE DEDENT return 2 NEW_LINE DEDENT def turn2str ( t : int ) -> str : NEW_LINE INDENT if t == 0 : NEW_LINE INDENT return ' a ' NEW_LINE DEDENT elif t == 1 : NEW_LINE INDENT return ' b ' NEW_LINE DEDENT return ' c ' NEW_LINE DEDENT def card_game_for_three ( Sa : str , Sb : str , Sc : str ) -> str : NEW_LINE INDENT indexes = [ 0 , 0 , 0 ] NEW_LINE limits = [ len ( Sa ) , len ( Sb ) , len ( Sc ) ] NEW_LINE cards = [ Sa , Sb , Sc ] NEW_LINE turn = 0 NEW_LINE while indexes [ turn ] < limits [ turn ] : NEW_LINE INDENT next_turn = str2turn ( cards [ turn ] [ indexes [ turn ] ] ) NEW_LINE indexes [ turn ] += 1 NEW_LINE turn = next_turn NEW_LINE DEDENT return turn2str ( turn ) . upper ( ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT Sa = input ( ) NEW_LINE Sb = input ( ) NEW_LINE Sc = input ( ) NEW_LINE ans = card_game_for_three ( Sa , Sb , Sc ) NEW_LINE print ( ans ) NEW_LINE DEDENT

def selection ( X , A , B , C ) : NEW_LINE INDENT if X == ' a ' : NEW_LINE INDENT if len ( A ) == 0 : NEW_LINE INDENT print ( ' A ' ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT Y = A . pop ( 0 ) NEW_LINE DEDENT DEDENT if X == ' b ' : NEW_LINE INDENT if len ( B ) == 0 : NEW_LINE INDENT print ( ' B ' ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT Y = B . pop ( 0 ) NEW_LINE DEDENT DEDENT if X == ' c ' : NEW_LINE INDENT if len ( C ) == 0 : NEW_LINE INDENT print ( ' C ' ) NEW_LINE return NEW_LINE DEDENT else : NEW_LINE INDENT Y = C . pop ( 0 ) NEW_LINE DEDENT DEDENT selection ( Y , A , B , C ) NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT Sa = list ( input ( ) ) NEW_LINE Sb = list ( input ( ) ) NEW_LINE Sc = list ( input ( ) ) NEW_LINE selection ( ' a ' , Sa , Sb , Sc ) NEW_LINE DEDENT main ( ) NEW_LINE

import sys NEW_LINE p = [ " A " , " B " , " C " ] NEW_LINE p_dic = { " a " : 0 , " b " : 1 , " c " : 2 } NEW_LINE def card ( cards , player ) : NEW_LINE INDENT if len ( cards [ player ] ) == 0 : NEW_LINE INDENT print ( p [ player ] ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT x = cards [ player ] [ 0 ] NEW_LINE cards [ player ] = cards [ player ] [ 1 : ] NEW_LINE card ( cards , p_dic [ x ] ) NEW_LINE DEDENT DEDENT cards = [ input ( ) for i in range ( 3 ) ] NEW_LINE card ( cards , 0 ) NEW_LINE


import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int hako [ ] = new int [ a ] ; int cont = 0 ; int flag = 1 ; for ( int i = 0 ; i < a ; i ++ ) { hako [ i ] = sc . nextInt ( ) ; } while ( flag == 1 ) { for ( int i = 0 ; i < a ; i ++ ) { if ( hako [ i ] % 2 == 0 ) { hako [ i ] = hako [ i ] / 2 ; } else { flag = 0 ; } } if ( flag == 1 ) { cont ++ ; } } System . out . print ( cont ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int min = 0 ; int n = Integer . parseInt ( input . readLine ( ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int [ ] value = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { value [ i ] = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } boolean state = true ; while ( state ) { for ( int i = 0 ; i < n && state ; i ++ ) { if ( ( value [ i ] & 1 ) == 0 ) { value [ i ] /= 2 ; } else { state = false ; } } if ( state ) min ++ ; } System . out . println ( min ) ; } static int log ( int x , int base ) { return ( int ) ( Math . log ( x ) / Math . log ( base ) ) ; } }

import java . util . Scanner ; import java . util . stream . IntStream ; public class Main { public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int count = scanner . nextInt ( ) ; scanner . nextLine ( ) ; System . out . println ( IntStream . range ( 0 , count ) . map ( i -> devide2Count ( scanner . nextInt ( ) ) ) . min ( ) . getAsInt ( ) ) ; } } private static int devide2Count ( int number ) { int result = 0 ; while ( number % 2 == 0 ) { number = number / 2 ; result ++ ; } return result ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNextInt ( ) ) { int n = sc . nextInt ( ) ; int ans = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { int x = sc . nextInt ( ) ; int cnt = 0 ; while ( x % 2 == 0 ) { x /= 2 ; cnt ++ ; } ans = Math . min ( ans , cnt ) ; } System . out . println ( ans ) ; } } }

import java . util . Scanner ; class Main { public static void main ( String arg [ ] ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; sc . nextLine ( ) ; String S = sc . nextLine ( ) ; sc . close ( ) ; String [ ] s = S . split ( " ▁ " ) ; int [ ] n = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String tmp = s [ i ] ; n [ i ] = Integer . parseInt ( tmp ) ; } System . out . println ( calc ( n ) ) ; } public static int calc ( int n [ ] ) { int count = 0 ; while ( true ) { for ( int j = 0 ; j < n . length ; j ++ ) { if ( n [ j ] % 2 == 0 ) { n [ j ] /= 2 ; } else { return count ; } } count ++ ; } } }

a = int ( input ( ) ) NEW_LINE list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE flag = False NEW_LINE ans = 30 NEW_LINE for i in range ( 31 ) : NEW_LINE INDENT for j in list : NEW_LINE INDENT if j % ( 2 ** i ) != 0 : NEW_LINE INDENT if not ( flag ) : NEW_LINE INDENT flag = True NEW_LINE ans = i - 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE

import math NEW_LINE n = input ( ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = float ( " inf " ) NEW_LINE for i in a : NEW_LINE INDENT ans = min ( ans , len ( bin ( i ) ) - bin ( i ) . rfind ( "1" ) - 1 ) NEW_LINE DEDENT print ( round ( ans ) ) NEW_LINE

import sys NEW_LINE line1 , line2 = [ sys . stdin . readline ( ) for i in range ( 2 ) ] NEW_LINE components = [ int ( i ) for i in line2 . strip ( ) . split ( ) ] NEW_LINE count = 0 NEW_LINE while all ( [ i % 2 == 0 for i in components ] ) : NEW_LINE INDENT count += 1 NEW_LINE components = [ i // 2 for i in components ] NEW_LINE DEDENT else : NEW_LINE INDENT print ( count ) NEW_LINE DEDENT

num = int ( input ( ) ) NEW_LINE board = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE evener = 0 NEW_LINE ope = True NEW_LINE while True : NEW_LINE INDENT for i in range ( num ) : NEW_LINE INDENT if board [ i ] % 2 == 0 : NEW_LINE INDENT board [ i ] = board [ i ] / 2 NEW_LINE DEDENT else : NEW_LINE INDENT ope = False NEW_LINE break NEW_LINE DEDENT DEDENT if ope == True : NEW_LINE INDENT evener += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( evener ) NEW_LINE

input ( ) NEW_LINE numbers = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count = 0 NEW_LINE while ( True ) : NEW_LINE INDENT if sum ( list ( map ( lambda x : x % 2 , numbers ) ) ) == 0 : NEW_LINE INDENT numbers = list ( map ( lambda x : x / 2 , numbers ) ) NEW_LINE count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String input1 = sc . nextLine ( ) ; String input2 = sc . nextLine ( ) ; String input3 = sc . nextLine ( ) ; System . out . println ( input1 . substring ( 0 , 1 ) + input2 . substring ( 1 , 2 ) + input3 . substring ( 2 , 3 ) ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { for ( int i = 0 ; i < 3 ; i ++ ) { String S = in . next ( ) ; for ( int j = 0 ; j < 3 ; j ++ ) { if ( i == j ) { out . print ( S . charAt ( i ) ) ; } } } out . println ( ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String C1 = sc . next ( ) ; String C2 = sc . next ( ) ; String C3 = sc . next ( ) ; System . out . println ( " " + C1 . charAt ( 0 ) + C2 . charAt ( 1 ) + C3 . charAt ( 2 ) ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , Scanner in , PrintWriter out ) { StringBuffer sb = new StringBuffer ( ) ; for ( int i = 0 ; i < 3 ; i ++ ) { sb . append ( in . next ( ) . charAt ( i ) ) ; } out . print ( sb . toString ( ) ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String [ ] ary = new String [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { ary [ i ] = sc . next ( ) ; } System . out . println ( ary [ 0 ] . substring ( 0 , 1 ) + ary [ 1 ] . substring ( 1 , 2 ) + ary [ 2 ] . substring ( 2 , 3 ) ) ; } }

C1 = input ( ) NEW_LINE C2 = input ( ) NEW_LINE C3 = input ( ) NEW_LINE print ( C1 [ : 1 ] + C2 [ 1 : 2 ] + C3 [ 2 : ] ) NEW_LINE

s = [ input ( ) for _ in range ( 3 ) ] NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT print ( s [ i ] [ i ] , end = ' ' ) NEW_LINE DEDENT print ( ' ' ) NEW_LINE

print ( ' ' . join ( [ input ( ) [ i ] for i in range ( 3 ) ] ) ) NEW_LINE

A = input ( ) NEW_LINE B = input ( ) NEW_LINE C = input ( ) NEW_LINE print ( A [ 0 ] + B [ 1 ] + C [ - 1 ] ) NEW_LINE

n = 3 NEW_LINE C = [ None ] * 3 NEW_LINE for i in range ( n ) : NEW_LINE INDENT C [ i ] = input ( ) [ i ] NEW_LINE DEDENT print ( ' ' . join ( C ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws InterruptedException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] a = new String [ n ] ; String [ ] [ ] s = new String [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { s [ ( n - 1 ) - i ] [ j ] = a [ i ] . substring ( j , j + 1 ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { System . out . print ( s [ j ] [ i ] ) ; } System . out . print ( " \n " ) ; } sc . close ( ) ; } public static int gcd ( int a , int b ) { if ( a < b ) { int tmp = a ; a = b ; b = tmp ; } int r = - 1 ; while ( r != 0 ) { r = a % b ; a = b ; b = r ; } return a ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . IntStream ; import java . io . UncheckedIOException ; import java . util . stream . Stream ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; B solver = new B ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class B { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int n = in . ints ( ) ; String [ ] s = in . string ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { out . print ( s [ n - j - 1 ] . charAt ( i ) ) ; } out . println ( ) ; } } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public String [ ] string ( int length ) { return IntStream . range ( 0 , length ) . mapToObj ( x -> string ( ) ) . toArray ( String [ ] :: new ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }

import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; String [ ] S = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { S [ i ] = scanner . next ( ) ; } char [ ] [ ] s = new char [ N ] [ N ] ; char [ ] [ ] t = new char [ N ] [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { s [ i ] [ j ] = S [ i ] . charAt ( j ) ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { t [ j ] [ N - i - 1 ] = s [ i ] [ j ] ; } } for ( int i = 0 ; i < N ; i ++ ) { for ( int j = 0 ; j < N ; j ++ ) { System . out . print ( t [ i ] [ j ] ) ; } System . out . println ( ) ; } } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = Integer . parseInt ( scanner . nextLine ( ) ) ; char [ ] [ ] arr = new char [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { String line = scanner . nextLine ( ) ; for ( int j = 0 ; j < n ; j ++ ) { arr [ i ] [ j ] = line . charAt ( j ) ; } } for ( int j = 0 ; j < n ; j ++ ) { for ( int i = n - 1 ; i >= 0 ; i -- ) { System . out . print ( arr [ i ] [ j ] ) ; } System . out . print ( " \n " ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; char [ ] [ ] mass = new char [ n ] [ n ] ; for ( int i = n - 1 ; i >= 0 ; i -- ) { String s = sc . next ( ) ; for ( int j = 0 ; j < n ; j ++ ) { mass [ j ] [ i ] = s . charAt ( j ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( char c : mass [ i ] ) System . out . print ( c ) ; System . out . println ( ) ; } } }

n = int ( input ( ) ) NEW_LINE s = [ list ( input ( ) ) for _ in range ( n ) ] NEW_LINE a = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT tmp = [ ] NEW_LINE for j in range ( n ) : NEW_LINE INDENT tmp . append ( s [ n - j - 1 ] [ i ] ) NEW_LINE DEDENT a . append ( tmp ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( ' ' . join ( a [ i ] ) ) NEW_LINE DEDENT

def rotate ( N : int , S : list ) -> list : NEW_LINE INDENT res = [ ' ' for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT res [ i ] += S [ N - j - 1 ] [ i ] NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE S = [ input ( ) for _ in range ( N ) ] NEW_LINE ans = rotate ( N , S ) NEW_LINE print ( ' \n ' . join ( ans ) ) NEW_LINE DEDENT

_ , * t = open ( 0 ) NEW_LINE for x in zip ( * t ) : print ( * x [ : : - 1 ] , sep = ' ' ) NEW_LINE

import copy NEW_LINE n = int ( input ( ) ) NEW_LINE p = [ [ " a " ] * ( n ) ] * ( n ) NEW_LINE q = [ [ " a " ] * ( n ) ] * ( n ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT p [ i ] = list ( input ( ) ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT q [ i ] [ j ] = p [ n - 1 - j ] [ i ] NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT print ( p [ n - 1 - j ] [ i ] , end = " " ) NEW_LINE if j == n - 1 : NEW_LINE INDENT print ( " " ) NEW_LINE DEDENT DEDENT DEDENT

import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE s = np . array ( [ [ c for c in input ( ) ] for _ in range ( N ) ] ) NEW_LINE s = np . rot90 ( s , k = - 1 ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT print ( " " . join ( s [ i ] ) ) NEW_LINE DEDENT