import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { final static int ICE_TEA_COUNT = 4 ; final static double SHORT_TEA = 0.25 ; public static void main ( String [ ] args ) throws Exception { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] input = br . readLine ( ) . split ( " ▁ " ) ; String input2 = br . readLine ( ) ; long [ ] iceTeaList = new long [ 4 ] ; for ( int i = 0 ; i < ICE_TEA_COUNT ; i ++ ) { iceTeaList [ i ] = Integer . parseInt ( input [ i ] ) ; } int max = Integer . parseInt ( input2 ) ; long [ ] resultTea = new long [ 4 ] ; int multiple = 2 ; long beforeResult = 1 ; boolean continueFlag = false ; int point = 0 ; resultTea [ 0 ] = ( long ) ( max / SHORT_TEA ) ; for ( int i = 0 ; i < ICE_TEA_COUNT - 1 ; i ++ ) { if ( beforeResult == 0 ) { continueFlag = true ; } else if ( iceTeaList [ i + point ] * multiple > iceTeaList [ i + 1 ] ) { resultTea [ i + 1 ] = resultTea [ i + point ] / multiple ; resultTea [ i + point ] = resultTea [ i + point ] % multiple ; continueFlag = false ; point = 0 ; multiple = 2 ; } if ( continueFlag ) { point -= 1 ; multiple *= 2 ; if ( i + point >= 0 ) { beforeResult = ( long ) resultTea [ i + point ] ; i -= 1 ; } else { beforeResult = 1 ; } continue ; } beforeResult = resultTea [ i + 1 ] ; } System . out . println ( resultTea [ 0 ] * iceTeaList [ 0 ] + resultTea [ 1 ] * iceTeaList [ 1 ] + resultTea [ 2 ] * iceTeaList [ 2 ] + resultTea [ 3 ] * iceTeaList [ 3 ] ) ; } }


Q , H , S , D = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE efficient_num , efficient_cost = 0 , 8 * Q NEW_LINE if ( efficient_cost > 4 * H ) : efficient_num , efficient_cost = 1 , 4 * H NEW_LINE if ( efficient_cost > 2 * S ) : efficient_num , efficient_cost = 2 , 2 * S NEW_LINE if ( efficient_cost > D ) : efficient_num , efficient_cost = 3 , D NEW_LINE min_cost = 0 NEW_LINE if ( N % 2 == 0 ) : NEW_LINE INDENT if ( efficient_num == 0 ) : min_cost = int ( N / 0.25 ) * Q NEW_LINE elif ( efficient_num == 1 ) : min_cost = int ( N / 0.50 ) * H NEW_LINE elif ( efficient_num == 2 ) : min_cost = N * S NEW_LINE elif ( efficient_num == 3 ) : min_cost = ( N // 2 ) * D NEW_LINE DEDENT else : NEW_LINE INDENT N = 2 * ( N // 2 ) NEW_LINE if ( efficient_num == 0 ) : min_cost = int ( N / 0.25 ) * Q NEW_LINE elif ( efficient_num == 1 ) : min_cost = int ( N / 0.50 ) * H NEW_LINE elif ( efficient_num == 2 ) : min_cost = N * S NEW_LINE elif ( efficient_num == 3 ) : min_cost = ( N // 2 ) * D NEW_LINE efficient_num , efficient_cost = 0 , 8 * Q NEW_LINE if ( efficient_cost > 4 * H ) : efficient_num , efficient_cost = 1 , 4 * H NEW_LINE if ( efficient_cost > 2 * S ) : efficient_num , efficient_cost = 2 , 2 * S NEW_LINE if ( efficient_num == 0 ) : min_cost += int ( 1 / 0.25 ) * Q NEW_LINE elif ( efficient_num == 1 ) : min_cost += int ( 1 / 0.50 ) * H NEW_LINE elif ( efficient_num == 2 ) : min_cost += 1 * S NEW_LINE DEDENT print ( min_cost ) NEW_LINE


import itertools NEW_LINE import collections NEW_LINE import bisect NEW_LINE import sys NEW_LINE input = sys . stdin . readline NEW_LINE def main ( ) : NEW_LINE INDENT Q , H , S , D = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE half = min ( Q * 2 , H ) NEW_LINE one = min ( half * 2 , S ) NEW_LINE two = min ( one * 2 , D ) NEW_LINE print ( two * ( N // 2 ) + one * ( N % 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import math as ma NEW_LINE l = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE N *= 4 NEW_LINE dp = [ 0 for i in range ( 9 ) ] NEW_LINE for i in range ( 1 , 9 ) : NEW_LINE INDENT dp [ i ] = min ( [ dp [ i - 2 ** j ] + l [ j ] for j in range ( min ( 4 , int ( ma . log2 ( i ) + 1 ) ) ) ] ) NEW_LINE DEDENT ans = float ( ' inf ' ) NEW_LINE for i in range ( 1 , 9 ) : NEW_LINE INDENT ans = min ( ans , N // i * dp [ i ] + dp [ N - N // i * i ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE


q , h , s , d = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE a = [ q * 8 , h * 4 , s * 2 , d ] NEW_LINE min_s = min ( a [ : 3 ] ) // 2 NEW_LINE min_d = min ( a ) NEW_LINE b , c = divmod ( n , 2 ) NEW_LINE print ( b * min_d + c * min_s ) NEW_LINE


public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int q = scanner . nextInt ( ) ; int h = scanner . nextInt ( ) ; int s = scanner . nextInt ( ) ; int d = scanner . nextInt ( ) ; int n = scanner . nextInt ( ) ; long min1 = Math . min ( q * 4L , Math . min ( h * 2L , s ) ) ; long min2 = Math . min ( min1 * 2L , d ) ; System . out . println ( n / 2 * min2 + ( n & 1 ) * min1 ) ; } }

q , h , s , d , n = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; m = min ( 4 * q , 2 * h , s ) ; print ( n // 2 * min ( d , 2 * m ) + n % 2 * m ) NEW_LINE


import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int one = min ( nextInt ( ) * 4 , nextInt ( ) * 2 , nextInt ( ) ) ; int two = nextInt ( ) ; int n = nextInt ( ) ; if ( one * 2 <= two ) { System . out . println ( ( long ) one * n ) ; } else { System . out . println ( ( long ) n / 2 * two + ( long ) n % 2 * one ) ; } } static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( 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 " ; } }


import java . util . Scanner ; import java . util . Set ; import java . util . stream . Collectors ; public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int h = s . nextInt ( ) ; int w = s . nextInt ( ) ; s . nextLine ( ) ; int n = s . nextInt ( ) ; int [ ] arr = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arr [ i ] = s . nextInt ( ) ; } int x = 0 , y = 0 ; int turn = 0 ; int [ ] [ ] move = { { 1 , 0 } , { - 1 , 0 } } ; int [ ] [ ] d = new int [ h ] [ w ] ; for ( int i = 0 ; i < n ; i ++ ) { while ( arr [ i ] != 0 ) { arr [ i ] -- ; d [ x ] [ y ] = i + 1 ; x += move [ turn % 2 ] [ 0 ] ; y += move [ turn % 2 ] [ 1 ] ; if ( x < 0 || y < 0 || x == h || y == w ) { turn ++ ; y ++ ; x += move [ turn % 2 ] [ 0 ] ; y += move [ turn % 2 ] [ 1 ] ; } } } for ( int i = 0 ; i < h ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { if ( j == 0 ) System . out . print ( d [ i ] [ j ] ) ; else System . out . print ( " ▁ " + d [ i ] [ j ] ) ; } System . out . println ( ) ; } } }

height , wide = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE anslist = [ ] NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i , j in enumerate ( a ) : NEW_LINE INDENT for l in range ( j ) : NEW_LINE INDENT anslist . append ( i + 1 ) NEW_LINE DEDENT DEDENT for k in range ( height ) : NEW_LINE INDENT t = anslist [ k * wide : ( k + 1 ) * wide ] NEW_LINE if k % 2 == 1 : NEW_LINE INDENT t . reverse ( ) NEW_LINE DEDENT print ( ' ▁ ' . join ( map ( str , t ) ) ) NEW_LINE DEDENT


from statistics import mean , median , variance , stdev NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE import math NEW_LINE import fractions NEW_LINE import itertools NEW_LINE import copy NEW_LINE from operator import itemgetter NEW_LINE def j ( q ) : NEW_LINE INDENT if q == 1 : print ( " YES " ) NEW_LINE else : print ( " NO " ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT def ct ( x , y ) : NEW_LINE INDENT if ( x > y ) : print ( " + " ) NEW_LINE elif ( x < y ) : print ( " - " ) NEW_LINE else : print ( " ? " ) NEW_LINE DEDENT def ip ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT h , w = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE n = ip ( ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE horz = 1 NEW_LINE vert = 1 NEW_LINE x = 0 NEW_LINE y = 0 NEW_LINE ans = [ [ 0 for i in range ( w ) ] for i in range ( h ) ] NEW_LINE pos = 0 NEW_LINE for i in range ( h * w ) : NEW_LINE INDENT ans [ y ] [ x ] = pos + 1 NEW_LINE a [ pos ] -= 1 NEW_LINE if a [ pos ] == 0 : NEW_LINE INDENT pos += 1 NEW_LINE DEDENT if y == h - 1 and vert == 1 : NEW_LINE INDENT x += 1 NEW_LINE vert = - 1 NEW_LINE DEDENT elif y == 0 and vert == - 1 : NEW_LINE INDENT x += 1 NEW_LINE vert = 1 NEW_LINE DEDENT else : y += vert NEW_LINE DEDENT for i in range ( h ) : NEW_LINE INDENT for k in range ( w ) : NEW_LINE INDENT if k + 1 != w : print ( ans [ i ] [ k ] , " " , end = " " ) NEW_LINE else : print ( ans [ i ] [ k ] , end = " " ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT


import numpy as np NEW_LINE h , w = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE mat = np . zeros ( ( h , w ) , dtype = int ) NEW_LINE st = 0 NEW_LINE for i in range ( len ( a ) ) : NEW_LINE INDENT for idx in range ( st , st + a [ i ] ) : NEW_LINE INDENT mat [ idx // w ] [ idx % w ] = i + 1 NEW_LINE DEDENT st += a [ i ] NEW_LINE DEDENT for i in range ( 1 , h , 2 ) : NEW_LINE INDENT mat [ i ] = mat [ i ] [ : : - 1 ] NEW_LINE DEDENT for i in range ( h ) : NEW_LINE INDENT for j in range ( w ) : NEW_LINE INDENT print ( mat [ i ] [ j ] , end = " ▁ " ) NEW_LINE DEDENT print ( " " ) NEW_LINE DEDENT


import sys , collections NEW_LINE def solve ( ) : NEW_LINE INDENT H , W = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ [ " " for _ in range ( W ) ] for _ in range ( H ) ] NEW_LINE h , w = 0 , 0 NEW_LINE for i , v in enumerate ( L ) : NEW_LINE INDENT while v != 0 : NEW_LINE INDENT if h % 2 == 0 : NEW_LINE INDENT ans [ h ] [ w ] = str ( i + 1 ) NEW_LINE v -= 1 NEW_LINE if w == W - 1 : NEW_LINE INDENT h += 1 NEW_LINE DEDENT else : NEW_LINE INDENT w += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans [ h ] [ w ] = str ( i + 1 ) NEW_LINE v -= 1 NEW_LINE if w == 0 : NEW_LINE INDENT h += 1 NEW_LINE DEDENT else : NEW_LINE INDENT w -= 1 NEW_LINE DEDENT DEDENT DEDENT DEDENT for v in ans : NEW_LINE INDENT print ( " ▁ " . join ( v ) ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE


H , W = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE C = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( A [ i ] ) : NEW_LINE INDENT C . append ( i + 1 ) NEW_LINE DEDENT DEDENT ans = [ [ 0 ] * W for i in range ( H ) ] NEW_LINE for i in range ( H * W ) : NEW_LINE INDENT y = i // W NEW_LINE if y % 2 == 0 : NEW_LINE INDENT x = i % W NEW_LINE DEDENT else : NEW_LINE INDENT x = W - 1 - i % W NEW_LINE DEDENT ans [ y ] [ x ] = C [ i ] NEW_LINE DEDENT for i in range ( H ) : NEW_LINE INDENT ans [ i ] = [ str ( a ) for a in ans [ i ] ] NEW_LINE print ( " ▁ " . join ( ans [ i ] ) ) NEW_LINE DEDENT


import java . util . * ; public class Main { public void main ( Scanner sc ) { int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int p = 0 ; String all [ ] = new String [ h * w ] ; for ( int i = 1 ; i <= n ; i ++ ) { int a = sc . nextInt ( ) ; for ( int j = 0 ; j < a ; j ++ ) { all [ p ++ ] = " " + i ; } } p = 0 ; for ( int i = 0 ; i < h ; i ++ ) { String c [ ] = new String [ w ] ; if ( i % 2 == 0 ) { for ( int j = 0 ; j < w ; j ++ ) { c [ j ] = all [ p ++ ] ; } } else { for ( int j = w - 1 ; j >= 0 ; j -- ) { c [ j ] = all [ p ++ ] ; } } System . out . println ( String . join ( " ▁ " , c ) ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }


import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { static long ans = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) , W = sc . nextInt ( ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; int [ ] [ ] ans = new int [ H ] [ W ] ; int row = 0 , col = 0 ; int flag = 1 ; for ( int i = 0 ; i < n ; i ++ ) { int cnt = a [ i ] ; for ( int j = 0 ; j < cnt ; j ++ ) { if ( col == - 1 || col == W ) { col = col == - 1 ? 0 : W - 1 ; row ++ ; flag = flag * ( - 1 ) ; } ans [ row ] [ col ] = i + 1 ; col += flag ; } } for ( int i = 0 ; i < H ; i ++ ) { for ( int j = 0 ; j < W - 1 ; j ++ ) { System . out . print ( Integer . toString ( ans [ i ] [ j ] ) + " ▁ " ) ; } System . out . println ( ans [ i ] [ W - 1 ] ) ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int H = sc . nextInt ( ) ; int W = sc . nextInt ( ) ; int N = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; } System . out . println ( solve ( H , W , N , A ) ) ; } private static String solve ( int H , int W , int N , int [ ] A ) { List < Integer > numbers = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int n = i + 1 ; int a = A [ i ] ; for ( int j = 0 ; j < a ; j ++ ) { numbers . add ( n ) ; } } StringJoiner j = new StringJoiner ( " \n " ) ; for ( int h = 0 ; h < H ; h ++ ) { int start = h * W ; int end = h * W + W ; List < Integer > line = new ArrayList < > ( numbers . subList ( start , end ) ) ; if ( h % 2 == 1 ) { Collections . reverse ( line ) ; } StringJoiner j2 = new StringJoiner ( " ▁ " ) ; line . forEach ( i -> j2 . add ( i . toString ( ) ) ) ; j . add ( j2 . toString ( ) ) ; } return j . toString ( ) ; } }


import java . util . * ; public class Main { static int H , W , N ; static int [ ] [ ] ans ; static void snake ( int n , int x ) { int h = n / W ; int w = n % W ; if ( h % 2 == 1 ) w = W - w - 1 ; ans [ h ] [ w ] = x + 1 ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; H = sc . nextInt ( ) ; W = sc . nextInt ( ) ; N = sc . nextInt ( ) ; ArrayList < Integer > nums = new ArrayList < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int a = sc . nextInt ( ) ; for ( int j = 0 ; j < a ; j ++ ) nums . add ( i ) ; } ans = new int [ H ] [ W ] ; for ( int n = 0 ; n < nums . size ( ) ; n ++ ) { snake ( n , nums . get ( n ) ) ; } for ( int i = 0 ; i < H ; i ++ ) { System . out . print ( ans [ i ] [ 0 ] ) ; for ( int j = 1 ; j < W ; j ++ ) System . out . print ( " ▁ " + ans [ i ] [ j ] ) ; System . out . print ( ' \n ' ) ; } } }


import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int Q = scan . nextInt ( ) ; while ( Q -- > 0 ) { long A = scan . nextLong ( ) ; long B = scan . nextLong ( ) ; long k = ( A + B ) / ( Math . min ( A , B ) + 1 ) ; if ( k <= 1 ) { int C = scan . nextInt ( ) - 1 ; int D = scan . nextInt ( ) - 1 ; String even = ( A >= B ? " A " : " B " ) ; String odd = ( A >= B ? " B " : " A " ) ; String ans = " " ; for ( int i = C ; i <= D ; ++ i ) { if ( i % 2 == 0 ) ans += even ; else ans += odd ; } System . out . println ( ans ) ; continue ; } long n = ( k * A - B ) / ( k * k - 1 ) ; long m = ( k * B - A ) / ( k * k - 1 ) ; long a = A - n * k - m ; long b = B - m * k - n ; int C = scan . nextInt ( ) - 1 ; int D = scan . nextInt ( ) - 1 ; String ans = " " ; for ( int i = C ; i <= D ; ++ i ) { if ( i < n * ( k + 1 ) ) { if ( ( i + 1 ) % ( k + 1 ) == 0 ) ans += " B " ; else ans += " A " ; } else if ( i >= n * ( k + 1 ) + a + b ) { long index = i - ( n * ( k + 1 ) ) - a - b ; if ( index % ( k + 1 ) == 0 ) ans += " A " ; else ans += " B " ; } else { long index = i - n * ( k + 1 ) ; if ( index < a ) ans += " A " ; else ans += " B " ; } } System . out . println ( ans ) ; } } }

import math NEW_LINE Q = int ( input ( ) ) NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE K = math . ceil ( max ( A , B ) / ( min ( A , B ) + 1 ) ) NEW_LINE lo , hi = 0 , A + 1 NEW_LINE while hi - lo > 1 : NEW_LINE INDENT mid = ( lo + hi ) // 2 NEW_LINE rA , rB = A - mid , B - max ( 0 , ( mid - 1 ) // K ) NEW_LINE if ( rA + 1 ) * K < rB : NEW_LINE INDENT hi = mid NEW_LINE DEDENT else : NEW_LINE INDENT lo = mid NEW_LINE DEDENT DEDENT f = ' ' NEW_LINE for i in range ( C - 1 , D ) : NEW_LINE INDENT na = lo NEW_LINE nb = max ( 0 , ( na - 1 ) // K ) NEW_LINE if i < nb * ( K + 1 ) : NEW_LINE INDENT f += ( ' A ' , ' B ' ) [ i % ( K + 1 ) == K ] NEW_LINE DEDENT elif i < na + nb : NEW_LINE INDENT f += ' A ' NEW_LINE DEDENT else : NEW_LINE INDENT j = A + B - i - 1 NEW_LINE nb = B - nb NEW_LINE na = max ( 0 , ( nb - 1 ) // K ) NEW_LINE if j < na * ( K + 1 ) : NEW_LINE INDENT f += ( ' B ' , ' A ' ) [ j % ( K + 1 ) == K ] NEW_LINE DEDENT else : NEW_LINE INDENT f += ' B ' NEW_LINE DEDENT DEDENT DEDENT print ( f ) NEW_LINE DEDENT


import math NEW_LINE Q = int ( input ( ) ) NEW_LINE num = lambda x : ( x , max ( 0 , ( x - 1 ) // K ) ) NEW_LINE sub = lambda xs , ys : [ x - y for ( x , y ) in zip ( xs , ys ) ] NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE K = math . ceil ( max ( A , B ) / ( min ( A , B ) + 1 ) ) NEW_LINE l , r = 0 , A + 1 NEW_LINE while r - l > 1 : NEW_LINE INDENT m = ( l + r ) // 2 NEW_LINE rA , rB = sub ( ( A , B ) , num ( m ) ) NEW_LINE l , r = ( ( m , r ) , ( l , m ) ) [ ( rA + 1 ) * K < rB ] NEW_LINE DEDENT f = ' ' NEW_LINE for i in range ( C - 1 , D ) : NEW_LINE INDENT na , nb = num ( l ) NEW_LINE if i < na + nb : NEW_LINE INDENT f += ( ' A ' , ' B ' ) [ i % ( K + 1 ) == K ] if i < nb * ( K + 1 ) else ' A ' NEW_LINE DEDENT else : NEW_LINE INDENT nb , na = num ( B - nb ) NEW_LINE j = A + B - i - 1 NEW_LINE f += ( ' B ' , ' A ' ) [ j % ( K + 1 ) == K ] if j < na * ( K + 1 ) else ' B ' NEW_LINE DEDENT DEDENT print ( f ) NEW_LINE DEDENT


import math NEW_LINE Q = int ( input ( ) ) NEW_LINE for _ in range ( Q ) : NEW_LINE INDENT A , B , C , D = map ( int , input ( ) . split ( ) ) NEW_LINE K = math . ceil ( max ( A , B ) / ( min ( A , B ) + 1 ) ) NEW_LINE lo , hi = 0 , A + 1 NEW_LINE while hi - lo > 1 : NEW_LINE INDENT mid = ( lo + hi ) // 2 NEW_LINE rA , rB = A - mid , B - max ( 0 , ( mid - 1 ) // K ) NEW_LINE if ( rA + 1 ) * K < rB : NEW_LINE INDENT hi = mid NEW_LINE DEDENT else : NEW_LINE INDENT lo = mid NEW_LINE DEDENT DEDENT f = ' ' NEW_LINE for i in range ( C - 1 , D ) : NEW_LINE INDENT na = lo NEW_LINE nb = max ( 0 , ( na - 1 ) // K ) NEW_LINE if i < nb * ( K + 1 ) : NEW_LINE INDENT f += ( ' A ' , ' B ' ) [ i % ( K + 1 ) == K ] NEW_LINE DEDENT elif i < na + nb : f += ' A ' NEW_LINE else : NEW_LINE INDENT j = A + B - i - 1 NEW_LINE nb = B - nb NEW_LINE na = max ( 0 , ( nb - 1 ) // K ) NEW_LINE if j < na * ( K + 1 ) : f += ( ' B ' , ' A ' ) [ j % ( K + 1 ) == K ] NEW_LINE else : f += ' B ' NEW_LINE DEDENT DEDENT print ( f ) NEW_LINE DEDENT


import java . util . Scanner ; class Main { static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } public static void main ( String [ ] $ ) { long l = gInt ( ) , x = gInt ( ) , y = gInt ( ) , s = gInt ( ) , d = gInt ( ) ; long sl = y + x , sr = y - x ; long dl = d > s ? d - s : d + l - s ; long dr = l - dl ; double tl = dl * 1.0 / sl ; double tr = sr <= 0 ? 1145141919 : dr * 1.0 / sr ; System . out . println ( Math . min ( tl , tr ) ) ; } }

l , x , y , s , d = map ( int , input ( ) . split ( ) ) NEW_LINE if d >= s : NEW_LINE INDENT if y != x : a = ( s + l - d ) / ( y - x ) NEW_LINE b = ( d - s ) / ( x + y ) NEW_LINE DEDENT else : NEW_LINE INDENT if y != x : a = ( s - d ) / ( y - x ) NEW_LINE b = ( d - s + l ) / ( y + x ) NEW_LINE DEDENT if y <= x : print ( b ) NEW_LINE else : print ( min ( a , b ) ) NEW_LINE


def a_moving_walkway ( L , X , Y , S , D ) : NEW_LINE INDENT distance_start_to_goal = D - S if S <= D else D + ( L - S ) NEW_LINE if X < Y : NEW_LINE INDENT ans = min ( distance_start_to_goal / ( X + Y ) , ( L - distance_start_to_goal ) / ( Y - X ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = distance_start_to_goal / ( X + Y ) NEW_LINE DEDENT ans = round ( ans , 9 ) NEW_LINE return ans NEW_LINE DEDENT L , X , Y , S , D = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( a_moving_walkway ( L , X , Y , S , D ) ) NEW_LINE


l , x , y , s , d = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE if s <= d : NEW_LINE INDENT ans = ( d - s ) / ( x + y ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( d - s + l ) / ( x + y ) NEW_LINE DEDENT if x < y : NEW_LINE INDENT if s >= d : NEW_LINE INDENT ans = min ( ans , ( s - d ) / ( y - x ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( ans , ( l - d + s ) / ( y - x ) ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


def main ( ) : NEW_LINE INDENT l , x , y , s , d = map ( int , input ( ) . split ( ) ) NEW_LINE if s == d : NEW_LINE INDENT print ( 0 ) NEW_LINE return NEW_LINE DEDENT ds = [ d - l , d ] if s < d else [ d , d + l ] NEW_LINE res = ( ds [ 1 ] - s ) / ( x + y ) NEW_LINE if x < y : NEW_LINE INDENT res = min ( res , ( s - ds [ 0 ] ) / ( y - x ) ) NEW_LINE DEDENT print ( res ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE L , X , Y , S , D = map ( int , input ( ) . split ( ) ) NEW_LINE if S >= D : NEW_LINE INDENT distL = S - D NEW_LINE distR = L - distL NEW_LINE velR = X + Y NEW_LINE velL = Y - X NEW_LINE if velL <= 0 : NEW_LINE INDENT ans = distR / velR NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( distR / velR , distL / velL ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT distR = D - S NEW_LINE distL = L - distR NEW_LINE velR = X + Y NEW_LINE velL = Y - X NEW_LINE if velL <= 0 : NEW_LINE INDENT ans = distR / velR NEW_LINE DEDENT else : NEW_LINE INDENT ans = min ( distR / velR , distL / velL ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . * ; import java . io . * ; import java . awt . geom . * ; import java . math . * ; public class Main { static final Scanner in = new Scanner ( System . in ) ; static final PrintWriter out = new PrintWriter ( System . out , false ) ; static boolean debug = false ; static void solve ( ) { double l = in . nextInt ( ) ; double x = in . nextInt ( ) ; double y = in . nextInt ( ) ; double s = in . nextInt ( ) ; double d = in . nextInt ( ) ; if ( s < d ) { if ( x < y ) { out . printf ( " % .10f \n " , Math . min ( ( d - s ) / ( x + y ) , ( l - ( d - s ) ) / ( y - x ) ) ) ; } else { out . printf ( " % .10f \n " , ( d - s ) / ( x + y ) ) ; } } else if ( s > d ) { if ( x < y ) { out . printf ( " % .10f \n " , Math . min ( ( l - ( s - d ) ) / ( x + y ) , ( s - d ) / ( y - x ) ) ) ; } else { out . printf ( " % .10f \n " , ( l - ( s - d ) ) / ( x + y ) ) ; } } else { out . println ( "0" ) ; } } public static void main ( String [ ] args ) { debug = args . length > 0 ; long start = System . nanoTime ( ) ; solve ( ) ; out . flush ( ) ; long end = System . nanoTime ( ) ; dump ( ( end - start ) / 1000000 + " ▁ ms " ) ; in . close ( ) ; out . close ( ) ; } static void dump ( Object ... o ) { if ( debug ) System . err . println ( Arrays . deepToString ( o ) ) ; } }


import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; double l = sc . nextDouble ( ) ; double x = sc . nextDouble ( ) ; double y = sc . nextDouble ( ) ; double s = sc . nextDouble ( ) ; double d = sc . nextDouble ( ) ; double ans = 0 ; if ( s > d ) { if ( y > x ) ans = Math . min ( ( l - s + d ) / ( x + y ) , ( s - d ) / ( y - x ) ) ; else ans = ( l - s + d ) / ( x + y ) ; } else { if ( y > x ) ans = Math . min ( ( d - s ) / ( x + y ) , ( s + l - d ) / ( y - x ) ) ; else ans = ( d - s ) / ( x + y ) ; } System . out . println ( ans ) ; } }


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 L = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int Y = sc . nextInt ( ) ; int S = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; double ans ; if ( S >= D ) { double t1 = ( double ) ( S - D ) / ( double ) ( Y - X ) ; double t2 = ( double ) ( L - ( S - D ) ) / ( double ) ( Y + X ) ; if ( t1 < 0 ) ans = t2 ; else ans = min ( t1 , t2 ) ; } else { double t1 = ( double ) ( D - S ) / ( double ) ( Y + X ) ; double t2 = ( double ) ( L - ( D - S ) ) / ( double ) ( Y - X ) ; if ( t2 < 0 ) ans = t1 ; else ans = min ( t1 , t2 ) ; } if ( S == D ) ans = 0 ; out . println ( ans ) ; } }


import java . util . * ; public class Main { static int count = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double l = sc . nextInt ( ) ; double x = sc . nextInt ( ) ; double y = sc . nextInt ( ) ; double s = sc . nextInt ( ) ; double d = sc . nextInt ( ) ; double ans = 0 ; if ( x >= y ) { double val = d - s ; if ( val < 0 ) { val += l ; } ans = val / ( x + y ) ; } else { double val1 = s - d ; if ( val1 < 0 ) { val1 += l ; } double ans1 = val1 / ( y - x ) ; double val2 = d - s ; if ( val2 < 0 ) { val2 += l ; } double ans2 = val2 / ( y + x ) ; ans = Math . min ( ans1 , ans2 ) ; } System . out . println ( ans ) ; } }


import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scn = new Scanner ( System . in ) ; int N = scn . nextInt ( ) ; long K = scn . nextLong ( ) ; Pair [ ] P = new Pair [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { P [ i ] = new Pair ( scn . nextLong ( ) , scn . nextLong ( ) ) ; } Arrays . sort ( P ) ; long ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { K -= P [ i ] . getB ( ) ; if ( K <= 0 ) { ans = P [ i ] . getA ( ) ; break ; } } System . out . println ( ans ) ; } } class Pair implements Comparable < Pair > { long a ; long b ; Pair ( long a , long b ) { this . a = a ; this . b = b ; } @ Override public int compareTo ( Pair o ) { if ( this . getA ( ) > o . getA ( ) ) return 1 ; if ( this . getA ( ) < o . getA ( ) ) return - 1 ; return 0 ; } long getA ( ) { return this . a ; } long getB ( ) { return this . b ; } }

import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE A . append ( ( a , b ) ) NEW_LINE DEDENT A = sorted ( A , key = lambda x : x [ 0 ] ) NEW_LINE cnt = 0 NEW_LINE for x in A : NEW_LINE INDENT cnt += x [ 1 ] NEW_LINE if cnt >= K : NEW_LINE INDENT return x [ 0 ] NEW_LINE DEDENT DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( main ( ) ) NEW_LINE DEDENT


import numpy as np NEW_LINE N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE ab = np . array ( [ [ int ( i ) for i in input ( ) . split ( ) ] for _ in range ( N ) ] ) NEW_LINE idx_ab = np . argsort ( ab [ : , 0 ] ) NEW_LINE ab = ab [ idx_ab , : ] NEW_LINE k_sum = 0 NEW_LINE for record in ab : NEW_LINE INDENT a = record [ 0 ] NEW_LINE b = record [ 1 ] NEW_LINE k_sum += b NEW_LINE if k_sum >= K : NEW_LINE INDENT print ( a ) NEW_LINE break NEW_LINE DEDENT DEDENT


from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT N , K = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE dict = { } NEW_LINE ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT s1 , s2 = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE if s1 not in dict : NEW_LINE INDENT dict [ s1 ] = s2 NEW_LINE DEDENT else : NEW_LINE INDENT dict [ s1 ] += s2 NEW_LINE DEDENT DEDENT index = 0 NEW_LINE for k , v in sorted ( dict . items ( ) ) : NEW_LINE INDENT index += v NEW_LINE if ( index >= K ) : NEW_LINE INDENT ans = k NEW_LINE break NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


ab = [ 0 ] * ( 10 ** 5 + 1 ) NEW_LINE lis = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE for i in range ( lis [ 0 ] ) : NEW_LINE INDENT t = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ab [ t [ 0 ] ] += t [ 1 ] NEW_LINE DEDENT ans = 0 NEW_LINE i = 1 NEW_LINE count = 0 NEW_LINE while count < lis [ 1 ] : NEW_LINE INDENT count += ab [ i ] NEW_LINE ans = i NEW_LINE i += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE


import sys NEW_LINE fastinput = sys . stdin . readline NEW_LINE N , K = map ( int , fastinput ( ) . split ( ) ) NEW_LINE data = [ [ int ( j ) for j in fastinput ( ) . split ( ) ] for k in range ( N ) ] NEW_LINE ab = sorted ( data , key = lambda x : x [ 0 ] ) NEW_LINE number = 0 NEW_LINE for a , b in ab : NEW_LINE INDENT number += b NEW_LINE if number >= K : NEW_LINE INDENT print ( a ) NEW_LINE break NEW_LINE DEDENT DEDENT


import java . net . StandardSocketOptions ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; import java . util . TreeSet ; import org . omg . Messaging . SyncScopeHelper ; import org . omg . PortableInterceptor . SYSTEM_EXCEPTION ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_300 ( ) . doIt ( ) ; } class Test_300 { void doIt ( ) { int N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long A [ ] = new long [ 100002 ] ; for ( int i = 0 ; i < N ; i ++ ) { int a = sc . nextInt ( ) ; long b = sc . nextLong ( ) ; A [ a ] = A [ a ] + b ; } long cnt = 0 ; for ( int i = 0 ; i < 100002 ; i ++ ) { cnt = cnt + A [ i ] ; if ( cnt >= K ) { System . out . println ( i ) ; break ; } } } } }


import java . util . TreeMap ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = scanner . nextInt ( ) ; long k = scanner . nextLong ( ) ; IntStream . range ( 0 , n ) . boxed ( ) . collect ( Collectors . toMap ( i -> scanner . nextInt ( ) , i -> scanner . nextLong ( ) , Long :: sum , TreeMap :: new ) ) . entrySet ( ) . stream ( ) . reduce ( k , ( rem , entry ) -> { if ( rem != null && ( rem -= entry . getValue ( ) ) <= 0 ) { System . out . println ( entry . getKey ( ) ) ; return null ; } return rem ; } , Long :: sum ) ; } }


import java . util . ArrayList ; import java . util . List ; import java . util . Scanner ; import java . util . Collections ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; int [ ] a = new int [ n ] ; int [ ] b = new int [ n ] ; List < Pair > pairs = new ArrayList < Pair > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; b [ i ] = sc . nextInt ( ) ; pairs . add ( new Pair ( a [ i ] , b [ i ] ) ) ; } Collections . sort ( pairs ) ; long cnt = 0 ; sc . close ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int value = pairs . get ( i ) . value ; cnt += value ; if ( cnt >= k ) { System . out . println ( pairs . get ( i ) . key ) ; return ; } } } } class Pair implements Comparable { int key ; int value ; Pair ( int key , int value ) { this . key = key ; this . value = value ; } @ Override public int compareTo ( Object other ) { Pair otherPair = ( Pair ) other ; if ( this . key == otherPair . key ) return this . value - this . value ; return this . key - otherPair . key ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .


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 ( ) ; long K = sc . nextLong ( ) ; Map < Integer , Long > map = new TreeMap < > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { int a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; if ( map . containsKey ( a ) ) { b += map . get ( a ) ; } map . put ( a , b ) ; } for ( Map . Entry entry : map . entrySet ( ) ) { K -= ( long ) entry . getValue ( ) ; if ( K <= 0 ) { out . print ( entry . getKey ( ) ) ; return ; } } } }


import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; long [ ] a = new long [ K ] ; for ( int i = 0 ; i < K ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } sc . close ( ) ; long max = 2 ; long min = 2 ; for ( int i = K - 1 ; i >= 0 ; i -- ) { min = ( ( min - 1 ) / a [ i ] + 1 ) * a [ i ] ; max = ( ( max ) / a [ i ] ) * a [ i ] + a [ i ] - 1 ; if ( min > max ) { System . out . println ( - 1 ) ; return ; } } System . out . println ( min + " ▁ " + max ) ; } }

import math NEW_LINE K = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) [ : : - 1 ] NEW_LINE mi = 2 NEW_LINE ma = 2 NEW_LINE res = 0 NEW_LINE for i in range ( K ) : NEW_LINE INDENT if ( mi % A [ i ] ) and ( ma % A [ i ] ) and ( ( mi // A [ i ] ) == ( ma // A [ i ] ) ) : NEW_LINE INDENT res = - 1 NEW_LINE break NEW_LINE DEDENT mi = math . ceil ( mi / A [ i ] ) * A [ i ] NEW_LINE ma = math . floor ( ma / A [ i ] ) * A [ i ] + A [ i ] - 1 NEW_LINE DEDENT if res == - 1 : NEW_LINE INDENT print ( res ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( mi , ma ) NEW_LINE DEDENT


import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE k = ni ( ) NEW_LINE a = list ( li ( ) ) NEW_LINE if a [ - 1 ] != 2 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT lower = 2 NEW_LINE upper = 3 NEW_LINE exist = True NEW_LINE for ai in a [ - 2 : : - 1 ] : NEW_LINE INDENT if lower % ai > 0 and upper % ai > 0 and lower // ai == upper // ai : NEW_LINE INDENT exist = False NEW_LINE print ( - 1 ) NEW_LINE break NEW_LINE DEDENT lower = - ( - lower // ai ) * ai NEW_LINE upper = ( upper // ai ) * ai + ( ai - 1 ) NEW_LINE DEDENT if exist : NEW_LINE INDENT print ( lower , upper ) NEW_LINE DEDENT DEDENT


from functools import reduce NEW_LINE from math import floor , ceil NEW_LINE K = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE R = reduce ( lambda acc , a : ( acc if acc [ 0 ] > acc [ 1 ] else ( a * ceil ( acc [ 0 ] / a ) , a * ( floor ( acc [ 1 ] / a ) + 1 ) - 1 ) ) , reversed ( A ) , ( 2 , 2 ) ) NEW_LINE ans = - 1 if R [ 0 ] > R [ 1 ] else ' ▁ ' . join ( map ( str , R ) ) NEW_LINE print ( ans ) NEW_LINE


def ceil ( a , b ) : NEW_LINE INDENT return - ( ( - a ) // b ) NEW_LINE DEDENT def floor ( a , b ) : NEW_LINE INDENT return a // b NEW_LINE DEDENT K = int ( input ( ) ) NEW_LINE A = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE L = [ 0 for i in range ( K + 1 ) ] NEW_LINE R = [ 0 for i in range ( K + 1 ) ] NEW_LINE L [ K ] = 2 NEW_LINE R [ K ] = 2 NEW_LINE for i in range ( 1 , K + 1 ) [ : : - 1 ] : NEW_LINE INDENT L [ i - 1 ] = ceil ( L [ i ] , A [ i - 1 ] ) * A [ i - 1 ] NEW_LINE R [ i - 1 ] = floor ( R [ i ] , A [ i - 1 ] ) * A [ i - 1 ] + A [ i - 1 ] - 1 NEW_LINE DEDENT if L [ 0 ] <= R [ 0 ] : NEW_LINE INDENT print ( L [ 0 ] , R [ 0 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT


k = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def g ( n , a , k ) : NEW_LINE INDENT for i in range ( k ) : NEW_LINE INDENT n = n - ( n % a [ i ] ) NEW_LINE DEDENT return n NEW_LINE DEDENT s = 0 NEW_LINE t = 2 + k * max ( a ) NEW_LINE while t - s > 1 : NEW_LINE INDENT m = ( s + t ) // 2 NEW_LINE if g ( m , a , k ) > 2 : NEW_LINE INDENT t = m NEW_LINE DEDENT else : NEW_LINE INDENT s = m NEW_LINE DEDENT DEDENT p = 0 NEW_LINE q = 2 + k * max ( a ) NEW_LINE while q - p > 1 : NEW_LINE INDENT m = ( p + q ) // 2 NEW_LINE if g ( m , a , k ) >= 2 : NEW_LINE INDENT q = m NEW_LINE DEDENT else : NEW_LINE INDENT p = m NEW_LINE DEDENT DEDENT c = 1 NEW_LINE if g ( s , a , k ) == 2 : NEW_LINE INDENT res = s NEW_LINE DEDENT elif g ( t , a , k ) == 2 : NEW_LINE INDENT res = t NEW_LINE DEDENT else : NEW_LINE INDENT c = - 1 NEW_LINE DEDENT if g ( q , a , k ) == 2 : NEW_LINE INDENT res2 = q NEW_LINE DEDENT elif g ( p , a , k ) == 2 : NEW_LINE INDENT res2 = p NEW_LINE DEDENT else : NEW_LINE INDENT c = - 1 NEW_LINE DEDENT if c == 1 : NEW_LINE INDENT print ( res2 , res ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT


import java . io . FileNotFoundException ; import java . util . Arrays ; import java . util . Scanner ; class Main { public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; long [ ] A = new long [ K ] ; for ( int i = 0 ; i < K ; ++ i ) { A [ i ] = sc . nextLong ( ) ; } long max = 2 ; long min = 2 ; for ( int i = K - 1 ; i >= 0 ; -- i ) { if ( max < A [ i ] ) { System . out . println ( - 1 ) ; return ; } max = max / A [ i ] * A [ i ] ; min = ( min + A [ i ] - 1 ) / A [ i ] * A [ i ] ; max += A [ i ] - 1 ; if ( max < min ) { System . out . println ( - 1 ) ; return ; } } System . out . println ( min + " ▁ " + max ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } public static void main ( String [ ] args ) throws FileNotFoundException { new Main ( ) . run ( ) ; } }


import java . util . * ; public class Main { public void main ( Scanner sc ) { int k = sc . nextInt ( ) ; long a [ ] = new long [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { a [ k - i - 1 ] = sc . nextInt ( ) ; } if ( a [ 0 ] != 2 ) { System . out . println ( - 1 ) ; return ; } long min = 2 ; long max = 2 ; for ( int i = 0 ; i < k - 1 ; i ++ ) { min = a [ i + 1 ] * ( ( min + a [ i + 1 ] - 1 ) / a [ i + 1 ] ) ; max = a [ i + 1 ] * ( ( max + a [ i ] - 1 ) / a [ i + 1 ] ) ; long minA = a [ i + 1 ] * ( ( min + a [ i + 1 ] - 1 ) / a [ i + 1 ] ) ; if ( minA > max ) { System . out . println ( - 1 ) ; return ; } } max += a [ k - 1 ] - 1 ; System . out . println ( min + " ▁ " + max ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }


import java . util . * ; public class Main { private void doit ( ) { Scanner sc = new Scanner ( System . in ) ; while ( sc . hasNext ( ) ) { int n = sc . nextInt ( ) ; int [ ] data = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { data [ i ] = sc . nextInt ( ) ; } long min = 2 ; long max = 2 ; boolean flg = true ; for ( int i = n - 1 ; i >= 0 ; i -- ) { int now = data [ i ] ; long tempmin = now * ( min / now + ( min % now == 0 ? 0 : 1 ) ) ; long tempmax = now * ( max / now + 1 ) - 1 ; if ( ! ( min <= tempmin / now * now && tempmin / now * now <= max ) ) { flg = false ; break ; } if ( ! ( min <= tempmax / now * now && tempmax / now * now <= max ) ) { flg = false ; break ; } min = tempmin ; max = tempmax ; } if ( flg ) { System . out . println ( min + " ▁ " + max ) ; } else { System . out . println ( - 1 ) ; } } } private void debug ( Object ... o ) { System . out . println ( " debug ▁ = ▁ " + Arrays . deepToString ( o ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . doit ( ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int [ ] a = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long max = 2 ; long min = 2 ; for ( int i = k - 1 ; i >= 0 ; i -- ) { max = ( long ) Math . floor ( ( double ) max / a [ i ] ) * a [ i ] + a [ i ] - 1 ; min = ( long ) Math . ceil ( ( double ) min / a [ i ] ) * a [ i ] ; } if ( max < min ) { System . out . println ( - 1 ) ; } else { System . out . println ( min + " ▁ " + max ) ; } } }


import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; long [ ] map = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { map [ i ] = sc . nextLong ( ) ; } Arrays . sort ( map ) ; int index = Arrays . binarySearch ( map , K ) ; if ( index >= 0 ) { System . out . println ( " POSSIBLE " ) ; return ; } if ( ~ index >= N ) { System . out . println ( " IMPOSSIBLE " ) ; return ; } for ( int i = 0 ; i < ( N - 1 ) ; i ++ ) { long A = map [ i ] ; if ( Arrays . binarySearch ( map , A + 1 ) >= 0 || Arrays . binarySearch ( map , A - 1 ) >= 0 ) { System . out . println ( " POSSIBLE " ) ; return ; } if ( Arrays . binarySearch ( map , A + A + 1 ) >= 0 || Arrays . binarySearch ( map , A - A - 1 ) >= 0 ) { System . out . println ( " POSSIBLE " ) ; return ; } if ( A > K && Arrays . binarySearch ( map , A - K ) >= 0 ) { System . out . println ( " POSSIBLE " ) ; return ; } } System . out . println ( " IMPOSSIBLE " ) ; } }

from functools import reduce NEW_LINE from fractions import gcd NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = sorted ( map ( int , input ( ) . split ( ) ) ) NEW_LINE M = reduce ( gcd , A ) NEW_LINE if K <= A [ - 1 ] and K % M == 0 : print ( " POSSIBLE " ) NEW_LINE else : print ( " IMPOSSIBLE " ) NEW_LINE


def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : return a NEW_LINE return gcd ( b , a % b ) NEW_LINE DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE g = a [ 0 ] NEW_LINE for aa in a : NEW_LINE INDENT g = gcd ( g , aa ) NEW_LINE DEDENT d = ( max ( a ) - K ) NEW_LINE if d >= 0 : NEW_LINE INDENT if d % g == 0 : NEW_LINE INDENT print ( ' POSSIBLE ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' IMPOSSIBLE ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' IMPOSSIBLE ' ) NEW_LINE DEDENT


from functools import reduce NEW_LINE def gcd ( a , b ) : NEW_LINE INDENT if b == 0 : NEW_LINE INDENT return a NEW_LINE DEDENT return gcd ( b , a % b ) NEW_LINE DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE lst_A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE max_A = max ( lst_A ) NEW_LINE gcd_A = reduce ( gcd , lst_A ) NEW_LINE ans = " IMPOSSIBLE " NEW_LINE if K % gcd_A == 0 and K <= max_A : NEW_LINE INDENT ans = " POSSIBLE " NEW_LINE DEDENT print ( ans ) NEW_LINE


import fractions as fr NEW_LINE from functools import reduce NEW_LINE def gcd ( a ) : NEW_LINE INDENT return reduce ( fr . gcd , a ) NEW_LINE DEDENT n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE g = gcd ( a ) NEW_LINE print ( " POSSIBLE " if ( k in a ) or ( max ( a ) >= k and ( g == 1 or k % g == 0 ) ) else " IMPOSSIBLE " ) NEW_LINE


def gcd ( x , y ) : NEW_LINE INDENT if y == 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( y , x % y ) NEW_LINE DEDENT DEDENT N , K = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE G = A [ 0 ] NEW_LINE for a in A : NEW_LINE INDENT G = gcd ( a , G ) NEW_LINE DEDENT print ( ' POSSIBLE ' if K % G == 0 and K <= max ( A ) else ' IMPOSSIBLE ' ) NEW_LINE


import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; String ans = " IMPOSSIBLE " ; int div = sc . nextInt ( ) ; int max = div ; if ( div == K ) ans = " POSSIBLE " ; for ( int i = 1 ; i < n ; i ++ ) { int cur = sc . nextInt ( ) ; if ( cur == K ) { ans = " POSSIBLE " ; break ; } div = gcd ( div , cur ) ; max = Math . max ( max , cur ) ; } if ( max > K && ( max - K ) % div == 0 ) ans = " POSSIBLE " ; System . out . println ( ans ) ; } static int gcd ( int a , int b ) { if ( a < b ) { int med = b ; b = a ; a = med ; } while ( a % b != 0 ) { int s = a ; a = b ; b = s % a ; } return b ; } }


import java . util . * ; public class Main { int [ ] a ; int cost ; int N ; int [ ] dp ; int INF = Integer . MAX_VALUE ; public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] A = new int [ N ] ; int M = 0 ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . nextInt ( ) ; M = Math . max ( M , A [ i ] ) ; } long g = A [ 0 ] ; for ( int i = 1 ; i < N ; i ++ ) { g = gcd ( g , A [ i ] ) ; } if ( K % g == 0 && K <= M ) { System . out . println ( " POSSIBLE " ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } long gcd ( long n , long m ) { if ( n < m ) { return gcd ( m , n ) ; } if ( m == 0 ) { return n ; } return gcd ( m , n % m ) ; } }


import java . util . * ; 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 ( ) , k = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int m = a ; int g = a ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int b = sc . nextInt ( ) ; m = max ( m , b ) ; g = gcd ( a , b ) ; a = b ; } if ( k <= m && k % g == 0 ) out . println ( " POSSIBLE " ) ; else out . println ( " IMPOSSIBLE " ) ; } static int gcd ( int a , int b ) { if ( b == 0 ) return a ; return gcd ( b , a % b ) ; } }


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 K = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int GCD = getGCD ( a ) ; Boolean B = false ; for ( int i = 0 ; i < N ; i ++ ) { if ( a [ i ] >= K && ( a [ i ] - K ) % GCD == 0 ) { B = true ; } } if ( B ) { System . out . println ( " POSSIBLE " ) ; } else { System . out . println ( " IMPOSSIBLE " ) ; } } static int getGCD ( int a , int b ) { if ( a < b ) { int c = a ; a = b ; b = c ; } if ( a % b == 0 ) { return b ; } else { return getGCD ( b , a % b ) ; } } static int getGCD ( int [ ] a ) { int gcd = a [ 0 ] ; int l = a . length ; for ( int i = 1 ; i < l ; i ++ ) { gcd = getGCD ( gcd , a [ i ] ) ; } return gcd ; } }


import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int c = 1 ; int [ ] ans = new int [ n + 1 ] ; int i = 1 ; while ( c <= n ) { if ( d ( i ) ) { ans [ c ++ ] = i ; } i ++ ; } out . println ( ans [ n ] ) ; } static boolean d ( int i ) { String s = String . valueOf ( i ) ; HashSet < Character > k = new HashSet < > ( ) ; for ( int j = 0 ; j < s . length ( ) ; j ++ ) { k . add ( s . charAt ( j ) ) ; } return k . size ( ) == 1 ; } }

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE n = N // 9 + 1 if N % 9 != 0 else N // 9 NEW_LINE a = N % 9 if N % 9 != 0 else 9 NEW_LINE print ( str ( a ) * n ) NEW_LINE


def same ( i ) : NEW_LINE INDENT return len ( set ( c for c in str ( i ) ) ) == 1 NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE i = 0 NEW_LINE while n > 0 : NEW_LINE INDENT i += 1 NEW_LINE if same ( i ) : NEW_LINE INDENT n -= 1 NEW_LINE DEDENT DEDENT print ( i ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


N = int ( input ( ) ) NEW_LINE list = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] NEW_LINE for i in range ( 10 , 100 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 101 , 1000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 1001 , 10000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] and temp [ 2 ] == temp [ 3 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 10001 , 100000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] and temp [ 2 ] == temp [ 3 ] and temp [ 3 ] == temp [ 4 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT for i in range ( 100001 , 1000000 ) : NEW_LINE INDENT temp = str ( i ) NEW_LINE if temp [ 0 ] == temp [ 1 ] and temp [ 1 ] == temp [ 2 ] and temp [ 2 ] == temp [ 3 ] and temp [ 3 ] == temp [ 4 ] and temp [ 4 ] == temp [ 5 ] : NEW_LINE INDENT list . append ( i ) NEW_LINE DEDENT DEDENT print ( list [ N - 1 ] ) NEW_LINE


def a_repdigit ( N ) : NEW_LINE INDENT from itertools import repeat NEW_LINE count , digit = 1 , 0 NEW_LINE while True : NEW_LINE INDENT for k in range ( 1 , 10 ) : NEW_LINE INDENT if count == N : NEW_LINE INDENT return ' ' . join ( map ( str , repeat ( k , digit + 1 ) ) ) NEW_LINE DEDENT count += 1 NEW_LINE DEDENT digit += 1 NEW_LINE DEDENT return None NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE print ( a_repdigit ( N ) ) NEW_LINE


print ( sorted ( [ s * str ( i ) for i in range ( 1 , 10 ) for s in range ( 1 , 7 ) ] , key = lambda x : len ( x ) ) [ int ( input ( ) ) - 1 ] ) NEW_LINE


import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) , len , i , j = 0 , k ; sc . close ( ) ; String tmp ; for ( i = 1 ; j < N ; ++ i ) { tmp = Integer . toString ( i ) ; len = tmp . length ( ) ; for ( k = 1 ; k < len ; ++ k ) { if ( tmp . charAt ( k - 1 ) != tmp . charAt ( k ) ) break ; } if ( k == len ) ++ j ; } System . out . println ( i - 1 ) ; } }


public class Main { public static void main ( String [ ] $ ) { int n = new java . util . Scanner ( System . in ) . nextInt ( ) - 1 ; System . out . println ( ( n % 9 + 1 ) * ( int ) ( 10 / 9d * Math . pow ( 10 , n / 9 ) ) ) ; } }


import java . util . Scanner ; import java . util . ArrayList ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int [ ] supportiveArray = { 1 , 11 , 111 , 1111 , 11111 , 111111 } ; int [ ] repdigitArray = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ; ArrayList < Integer > repdigitList = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < 6 ; i ++ ) { int support = supportiveArray [ i ] ; for ( int j = 0 ; j < 9 ; j ++ ) { int repdigit = repdigitArray [ j ] ; int repdigitPattern = support * repdigit ; repdigitList . add ( repdigitPattern ) ; } } System . out . println ( repdigitList . get ( N - 1 ) ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int j = sc . nextInt ( ) ; int num = ( j - 1 ) % 9 + 1 ; int time = ( j + 8 ) / 9 ; for ( int i = 0 ; i < time ; i ++ ) { System . out . print ( num ) ; } System . out . println ( ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextLong ( ) ; sc . close ( ) ; long count1 = 0 ; long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( i % 2 == 0 && sum <= 0 ) { count1 += 1 - sum ; sum = 1 ; } else if ( i % 2 == 1 && sum >= 0 ) { count1 += sum + 1 ; sum = - 1 ; } } sum = 0 ; long count2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { sum += a [ i ] ; if ( i % 2 == 1 && sum <= 0 ) { count2 += 1 - sum ; sum = 1 ; } else if ( i % 2 == 0 && sum >= 0 ) { count2 += sum + 1 ; sum = - 1 ; } } System . out . println ( Math . min ( count1 , count2 ) ) ; } }

n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE count1 = a [ 0 ] NEW_LINE count2 = a [ 0 ] NEW_LINE answer1 = 0 NEW_LINE answer2 = 0 NEW_LINE if a [ 0 ] <= 0 : NEW_LINE INDENT answer1 += ( 1 - a [ 0 ] ) NEW_LINE count1 = 1 NEW_LINE DEDENT if a [ 0 ] >= 0 : NEW_LINE INDENT answer2 += ( 1 + a [ 0 ] ) NEW_LINE count2 = - 1 NEW_LINE DEDENT for i in a [ 1 : ] : NEW_LINE INDENT if ( count1 > 0 and count1 + i < 0 ) or ( count1 < 0 and count1 + i > 0 ) : NEW_LINE INDENT count1 += i NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT answer1 += abs ( count1 + i ) + 1 NEW_LINE if count1 > 0 : NEW_LINE INDENT count1 = - 1 NEW_LINE DEDENT else : NEW_LINE INDENT count1 = 1 NEW_LINE DEDENT DEDENT DEDENT for i in a [ 1 : ] : NEW_LINE INDENT if ( count2 > 0 and count2 + i < 0 ) or ( count2 < 0 and count2 + i > 0 ) : NEW_LINE INDENT count2 += i NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT answer2 += abs ( count2 + i ) + 1 NEW_LINE if count2 > 0 : NEW_LINE INDENT count2 = - 1 NEW_LINE DEDENT else : NEW_LINE INDENT count2 = 1 NEW_LINE DEDENT DEDENT DEDENT print ( min ( answer1 , answer2 ) ) NEW_LINE


def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def count ( N , A , initSum ) : NEW_LINE INDENT sm = initSum NEW_LINE cnt = abs ( sm - A [ 0 ] ) NEW_LINE db ( cnt ) NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT nextSum = sm + A [ i + 1 ] NEW_LINE db ( ( sm , nextSum ) ) NEW_LINE if sm > 0 and nextSum >= 0 : NEW_LINE INDENT cnt += abs ( nextSum ) + 1 NEW_LINE sm = - 1 NEW_LINE DEDENT elif sm < 0 and nextSum <= 0 : NEW_LINE INDENT cnt += abs ( nextSum ) + 1 NEW_LINE sm = 1 NEW_LINE DEDENT else : NEW_LINE INDENT sm = nextSum NEW_LINE DEDENT db ( cnt ) NEW_LINE DEDENT return cnt NEW_LINE DEDENT def probC ( ) : NEW_LINE INDENT N = getInt ( ) NEW_LINE A = getIntList ( ) NEW_LINE db ( ( N , A ) ) NEW_LINE if A [ 0 ] != 0 : NEW_LINE INDENT initSum = A [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT initSum = 1 NEW_LINE DEDENT cnt1 = count ( N , A , initSum ) NEW_LINE db ( ( ' a [ 0 ] ▁ or ▁ + 1 : ▁ ' , cnt1 ) ) NEW_LINE if initSum > 0 : NEW_LINE INDENT cnt2 = count ( N , A , - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT cnt2 = count ( N , A , 1 ) NEW_LINE DEDENT db ( ( ' ? ? ? ? ▁ or ▁ - 1 : ▁ ' , cnt2 ) ) NEW_LINE return min ( cnt1 , cnt2 ) NEW_LINE DEDENT debug = False NEW_LINE print ( probC ( ) ) NEW_LINE


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 6 ) NEW_LINE _ = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def solve ( i , s , k , sign ) : NEW_LINE INDENT if i >= len ( A ) : NEW_LINE INDENT return k NEW_LINE DEDENT if sign * ( s + A [ i ] ) > 0 : NEW_LINE INDENT return solve ( i + 1 , s + A [ i ] , k , sign * - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT return solve ( i + 1 , sign , k + abs ( s + A [ i ] ) + 1 , sign * - 1 ) NEW_LINE DEDENT DEDENT print ( min ( solve ( 0 , 0 , 0 , 1 ) , solve ( 0 , 0 , 0 , - 1 ) ) ) NEW_LINE


N = int ( input ( ) ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Pnum = 0 NEW_LINE Psum = 0 NEW_LINE if L [ 0 ] >= 1 : NEW_LINE INDENT Pnum = L [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT Psum = 1 - L [ 0 ] NEW_LINE Pnum = 1 NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT if i % 2 == 1 : NEW_LINE INDENT if Pnum + L [ i ] <= - 1 : NEW_LINE INDENT Pnum = Pnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Psum += ( Pnum + L [ i ] + 1 ) NEW_LINE Pnum = - 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if Pnum + L [ i ] >= 1 : NEW_LINE INDENT Pnum = Pnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Psum += ( 1 - Pnum - L [ i ] ) NEW_LINE Pnum = 1 NEW_LINE DEDENT DEDENT DEDENT Mnum = 0 NEW_LINE Msum = 0 NEW_LINE if L [ 0 ] <= - 1 : NEW_LINE INDENT Mnum = L [ 0 ] NEW_LINE DEDENT else : NEW_LINE INDENT Msum = L [ 0 ] + 1 NEW_LINE Mnum = - 1 NEW_LINE DEDENT for i in range ( 1 , N ) : NEW_LINE INDENT if i % 2 == 0 : NEW_LINE INDENT if Mnum + L [ i ] <= - 1 : NEW_LINE INDENT Mnum = Mnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Msum += ( Mnum + L [ i ] + 1 ) NEW_LINE Mnum = - 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if Mnum + L [ i ] >= 1 : NEW_LINE INDENT Mnum = Mnum + L [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT Msum += ( 1 - Mnum - L [ i ] ) NEW_LINE Mnum = 1 NEW_LINE DEDENT DEDENT DEDENT print ( min ( Psum , Msum ) ) NEW_LINE


N = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ' ▁ ' ) ) ) NEW_LINE ans1 = 0 NEW_LINE ans2 = 0 NEW_LINE sum1 = 0 NEW_LINE sum2 = 0 NEW_LINE flag = True NEW_LINE for i in range ( len ( A ) ) : NEW_LINE INDENT sum1 = sum1 + A [ i ] NEW_LINE sum2 = sum2 + A [ i ] NEW_LINE flag = not ( flag ) NEW_LINE if flag : NEW_LINE INDENT if sum1 > 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans1 += abs ( 1 - sum1 ) NEW_LINE sum1 = 1 NEW_LINE DEDENT if sum2 < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans2 += abs ( - 1 - sum2 ) NEW_LINE sum2 = - 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if sum2 > 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans2 += abs ( 1 - sum2 ) NEW_LINE sum2 = 1 NEW_LINE DEDENT if sum1 < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans1 += abs ( - 1 - sum1 ) NEW_LINE sum1 = - 1 NEW_LINE DEDENT DEDENT DEDENT print ( min ( ans1 , ans2 ) ) NEW_LINE


import java . io . IOException ; import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . concurrent . SynchronousQueue ; class Main { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long [ ] a = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] = sc . nextLong ( ) ; } long [ ] sum = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { sum [ i ] = ( i > 0 ? sum [ i - 1 ] : 0 ) + a [ i ] ; } long ans = Long . MAX_VALUE / 16 ; int [ ] sign = { - 1 , 1 } ; for ( int f = 0 ; f <= 1 ; ++ f ) { long d = 0 ; long cnt = 0 ; for ( int i = 0 ; i < n ; ++ i ) { if ( sign [ ( i + f ) % 2 ] == sign ( sum [ i ] + d ) ) continue ; cnt += Math . abs ( sign [ ( i + f ) % 2 ] - ( sum [ i ] + d ) ) ; d += sign [ ( i + f ) % 2 ] - ( sum [ i ] + d ) ; } ans = Math . min ( ans , cnt ) ; } System . out . println ( ans ) ; } int sign ( long x ) { return Long . compare ( x , 0 ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }


import java . io . * ; import java . util . * ; public class Main { public static int n ; public static long [ ] nums ; public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; PrintWriter pw = new PrintWriter ( new BufferedWriter ( new OutputStreamWriter ( System . out ) ) ) ; n = Integer . parseInt ( br . readLine ( ) ) ; StringTokenizer st = new StringTokenizer ( br . readLine ( ) ) ; nums = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) nums [ i ] = Long . parseLong ( st . nextToken ( ) ) ; long sum = nums [ 0 ] ; if ( sum == 0 ) pw . println ( Math . min ( solve ( 1L , 1L ) , solve ( - 1L , 1L ) ) ) ; else if ( sum > 0 ) pw . println ( Math . min ( solve ( sum , 0L ) , solve ( - 1L , sum + 1L ) ) ) ; else if ( sum < 0 ) pw . println ( Math . min ( solve ( sum , 0L ) , solve ( 1L , - sum + 1L ) ) ) ; br . close ( ) ; pw . close ( ) ; System . exit ( 0 ) ; } public static long solve ( long sum , long ans ) { for ( int i = 1 ; i < n ; i ++ ) { long num = nums [ i ] ; if ( sum > 0 ) { sum += num ; if ( sum >= 0 ) { ans += sum + 1 ; sum = - 1 ; } } else if ( sum < 0 ) { sum += num ; if ( sum <= 0 ) { ans += - sum + 1 ; sum = 1 ; } } } return ans ; } }


import java . util . Arrays ; 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 n = sc . nextInt ( ) ; long sumOfP = sc . nextLong ( ) ; long countP = 0 ; long sumOfM = sumOfP ; long countM = 0 ; if ( sumOfP <= 0 ) { countP = - sumOfP + 1 ; sumOfP = 1 ; } if ( sumOfM >= 0 ) { countM = sumOfM + 1 ; sumOfM = - 1 ; } for ( int i = 1 ; i < n ; i ++ ) { long a = sc . nextLong ( ) ; if ( sumOfP > 0 ) { if ( sumOfP + a >= 0 ) { countP += sumOfP + a + 1 ; sumOfP = - 1 ; } else { sumOfP += a ; } } else { if ( sumOfP + a <= 0 ) { countP += - ( sumOfP + a ) + 1 ; sumOfP = 1 ; } else { sumOfP += a ; } } if ( sumOfM > 0 ) { if ( sumOfM + a >= 0 ) { countM += sumOfM + a + 1 ; sumOfM = - 1 ; } else { sumOfM += a ; } } else { if ( sumOfM + a <= 0 ) { countM += - ( sumOfM + a ) + 1 ; sumOfM = 1 ; } else { sumOfM += a ; } } } System . out . println ( Math . min ( countP , countM ) ) ; } }


import java . util . Arrays ; import java . util . Scanner ; public class Main { static final Scanner s = new Scanner ( System . in ) ; static int n ; public static void main ( String [ ] __ ) { n = s . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = s . nextInt ( ) ; if ( a [ 0 ] != 0 ) { long r1 = solve ( Arrays . copyOf ( a , a . length ) ) ; long r2 = Math . abs ( a [ 0 ] ) + 1 ; a [ 0 ] = - a [ 0 ] / Math . abs ( a [ 0 ] ) ; r2 += solve ( Arrays . copyOf ( a , a . length ) ) ; System . out . println ( Math . min ( r1 , r2 ) ) ; } else { a [ 0 ] = 1 ; long r1 = 1 + solve ( Arrays . copyOf ( a , a . length ) ) ; a [ 0 ] = - 1 ; long r2 = 1 + solve ( Arrays . copyOf ( a , a . length ) ) ; System . out . println ( Math . min ( r1 , r2 ) ) ; } } private static final long solve ( long [ ] a ) { long sum [ ] = new long [ n ] ; sum [ 0 ] = a [ 0 ] ; long res = 0 ; for ( int i = 1 ; i < n ; i ++ ) { sum [ i ] = a [ i ] + sum [ i - 1 ] ; if ( sum [ i - 1 ] > 0 ) { long t = - sum [ i - 1 ] - 1 ; if ( a [ i ] > t ) { res += a [ i ] - t ; a [ i ] = t ; } } else { long t = - sum [ i - 1 ] + 1 ; if ( a [ i ] < t ) { res += t - a [ i ] ; a [ i ] = t ; } } sum [ i ] = a [ i ] + sum [ i - 1 ] ; } return res ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; int [ ] [ ] grid = new int [ w ] [ h ] ; int wCount = 0 ; for ( int i = 0 ; i < h ; i ++ ) { String s = sc . next ( ) ; for ( int j = 0 ; j < w ; j ++ ) { if ( s . charAt ( j ) == ' . ' ) { grid [ j ] [ i ] = - 1 ; wCount ++ ; } else { grid [ j ] [ i ] = Integer . MIN_VALUE ; } } } grid [ 0 ] [ 0 ] = 0 ; for ( int i = 0 ; i < wCount ; i ++ ) { for ( int j = 0 ; j < w ; j ++ ) { for ( int k = 0 ; k < h ; k ++ ) { if ( grid [ j ] [ k ] == i ) { if ( j != 0 ) { if ( grid [ j - 1 ] [ k ] == - 1 ) { grid [ j - 1 ] [ k ] = i + 1 ; } } if ( j != w - 1 ) { if ( grid [ j + 1 ] [ k ] == - 1 ) { grid [ j + 1 ] [ k ] = i + 1 ; } } if ( k != 0 ) { if ( grid [ j ] [ k - 1 ] == - 1 ) { grid [ j ] [ k - 1 ] = i + 1 ; } } if ( k != h - 1 ) { if ( grid [ j ] [ k + 1 ] == - 1 ) { grid [ j ] [ k + 1 ] = i + 1 ; } } } } } if ( grid [ w - 1 ] [ h - 1 ] != - 1 ) { System . out . println ( wCount - grid [ w - 1 ] [ h - 1 ] - 1 ) ; return ; } } System . out . println ( - 1 ) ; } }

from collections import deque NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE G = [ list ( input ( ) ) for i in range ( H ) ] NEW_LINE first_black = sum ( [ row . count ( ' # ' ) for row in G ] ) NEW_LINE que = deque ( [ ( 0 , 0 ) ] ) NEW_LINE dist = [ [ - 1 ] * W for i in range ( H ) ] NEW_LINE dist [ 0 ] [ 0 ] = 0 NEW_LINE direction = [ ( 0 , 1 ) , ( 0 , - 1 ) , ( 1 , 0 ) , ( - 1 , 0 ) ] NEW_LINE while que : NEW_LINE INDENT nh , nw = que . pop ( ) NEW_LINE for dh , dw in direction : NEW_LINE INDENT if not ( ( 0 <= nh + dh < H ) & ( 0 <= nw + dw < W ) ) : NEW_LINE INDENT continue NEW_LINE DEDENT if G [ nh + dh ] [ nw + dw ] == ' # ' : NEW_LINE INDENT continue NEW_LINE DEDENT if dist [ nh + dh ] [ nw + dw ] > 0 : NEW_LINE INDENT continue NEW_LINE DEDENT dist [ nh + dh ] [ nw + dw ] = dist [ nh ] [ nw ] + 1 NEW_LINE que . appendleft ( ( nh + dh , nw + dw ) ) NEW_LINE DEDENT DEDENT if dist [ - 1 ] [ - 1 ] != - 1 : NEW_LINE INDENT print ( H * W - dist [ - 1 ] [ - 1 ] - first_black - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT


import queue NEW_LINE h , w = [ int ( i ) for i in input ( ) . split ( " ▁ " ) ] NEW_LINE s = [ " " for i in range ( 0 , h ) ] NEW_LINE for i in range ( 0 , h ) : NEW_LINE INDENT s [ i ] = input ( ) NEW_LINE DEDENT b = [ [ False for j in range ( 0 , w ) ] for i in range ( 0 , h ) ] NEW_LINE c = 0 NEW_LINE for i in range ( 0 , h ) : NEW_LINE INDENT for j in range ( 0 , w ) : NEW_LINE INDENT if s [ i ] [ j ] == " . " : NEW_LINE INDENT c += 1 NEW_LINE DEDENT DEDENT DEDENT q = queue . Queue ( ) NEW_LINE q . put ( [ 0 , 0 , 0 ] ) NEW_LINE b [ 0 ] [ 0 ] = True NEW_LINE def addq ( i , j , d ) : NEW_LINE INDENT global b NEW_LINE global q NEW_LINE if 0 <= i and i < h and 0 <= j and j < w and not b [ i ] [ j ] and s [ i ] [ j ] == " . " : NEW_LINE INDENT b [ i ] [ j ] = True NEW_LINE q . put ( [ i , j , d ] ) NEW_LINE DEDENT DEDENT f = False NEW_LINE while not q . empty ( ) : NEW_LINE INDENT qi = q . get ( ) NEW_LINE if qi [ 0 ] == h - 1 and qi [ 1 ] == w - 1 : NEW_LINE INDENT f = True NEW_LINE print ( c - qi [ 2 ] - 1 ) NEW_LINE break NEW_LINE DEDENT i = qi [ 0 ] NEW_LINE j = qi [ 1 ] NEW_LINE addq ( i + 1 , j , qi [ 2 ] + 1 ) NEW_LINE addq ( i , j + 1 , qi [ 2 ] + 1 ) NEW_LINE addq ( i - 1 , j , qi [ 2 ] + 1 ) NEW_LINE addq ( i , j - 1 , qi [ 2 ] + 1 ) NEW_LINE DEDENT if not f : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT


from collections import deque , Counter NEW_LINE from functools import reduce NEW_LINE H , W = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE area_info = [ input ( ) for _ in range ( H ) ] NEW_LINE is_visit = [ [ False for _ in range ( W ) ] for _ in range ( H ) ] NEW_LINE next_search = deque ( [ [ 0 , 0 , 0 ] , ] ) NEW_LINE def get_shortest_step ( ) : NEW_LINE INDENT shortest_step = - 1 NEW_LINE while len ( next_search ) > 0 : NEW_LINE INDENT nowx , nowy , now_step = next_search . pop ( ) NEW_LINE if is_visit [ nowx ] [ nowy ] : NEW_LINE INDENT continue NEW_LINE DEDENT is_visit [ nowx ] [ nowy ] = True NEW_LINE for stepx , stepy in [ ( 1 , 0 ) , ( 0 , 1 ) , ( - 1 , 0 ) , ( 0 , - 1 ) ] : NEW_LINE INDENT nextx = nowx + stepx NEW_LINE nexty = nowy + stepy NEW_LINE if nextx == H - 1 and nexty == W - 1 : NEW_LINE INDENT shortest_step = now_step + 1 NEW_LINE return shortest_step NEW_LINE DEDENT if 0 <= nextx < H and 0 <= nexty < W : NEW_LINE INDENT if is_visit [ nextx ] [ nexty ] or area_info [ nextx ] [ nexty ] == " # " : NEW_LINE INDENT continue NEW_LINE DEDENT next_search . appendleft ( [ nextx , nexty , now_step + 1 ] ) NEW_LINE DEDENT DEDENT DEDENT return shortest_step NEW_LINE DEDENT shortest_step = get_shortest_step ( ) NEW_LINE c = Counter ( " " . join ( area_info ) ) NEW_LINE if shortest_step == - 1 : NEW_LINE INDENT print ( " - 1" ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( c [ ' . ' ] - shortest_step - 1 ) NEW_LINE DEDENT


h , w = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ [ " # " ] * ( w + 2 ) ] + [ [ " # " ] + list ( input ( ) ) + [ " # " ] for i in range ( h ) ] + [ [ " # " ] * ( w + 2 ) ] NEW_LINE p = [ [ 1 , 1 ] ] NEW_LINE d = 0 NEW_LINE for i in range ( 1 , h + 1 ) : NEW_LINE INDENT for j in range ( 1 , w + 1 ) : NEW_LINE INDENT if s [ i ] [ j ] == " . " : NEW_LINE INDENT d += 1 NEW_LINE DEDENT DEDENT DEDENT s [ 1 ] [ 1 ] = " # " NEW_LINE k = 0 NEW_LINE while [ h , w ] not in p : NEW_LINE INDENT k += 1 NEW_LINE g = [ ] NEW_LINE for i in range ( len ( p ) ) : NEW_LINE INDENT x , y = p [ i ] [ 0 ] , p [ i ] [ 1 ] NEW_LINE if s [ x - 1 ] [ y ] == " . " : NEW_LINE INDENT s [ x - 1 ] [ y ] = " Q " NEW_LINE g . append ( [ x - 1 , y ] ) NEW_LINE DEDENT if s [ x + 1 ] [ y ] == " . " : NEW_LINE INDENT s [ x + 1 ] [ y ] = " Q " NEW_LINE g . append ( [ x + 1 , y ] ) NEW_LINE DEDENT if s [ x ] [ y + 1 ] == " . " : NEW_LINE INDENT s [ x ] [ y + 1 ] = " Q " NEW_LINE g . append ( [ x , y + 1 ] ) NEW_LINE DEDENT if s [ x ] [ y - 1 ] == " . " : NEW_LINE INDENT s [ x ] [ y - 1 ] = " Q " NEW_LINE g . append ( [ x , y - 1 ] ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT p = g NEW_LINE if len ( p ) == 0 : NEW_LINE INDENT print ( - 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( d - k - 1 ) NEW_LINE DEDENT


from collections import deque NEW_LINE h , w = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE s = [ input ( ) for _ in range ( h ) ] NEW_LINE dist = [ [ - 1 ] * w for _ in range ( h ) ] NEW_LINE black = 0 NEW_LINE for line in s : NEW_LINE INDENT black += line . count ( " # " ) NEW_LINE DEDENT que = deque ( ) NEW_LINE que . append ( [ 0 , 0 ] ) NEW_LINE dist [ 0 ] [ 0 ] = 1 NEW_LINE while que : NEW_LINE INDENT x , y = que . popleft ( ) NEW_LINE for i , j in [ ( 1 , 0 ) , ( - 1 , 0 ) , ( 0 , 1 ) , ( 0 , - 1 ) ] : NEW_LINE INDENT nx = x + i NEW_LINE ny = y + j NEW_LINE if nx < 0 or nx >= h or ny < 0 or ny >= w : NEW_LINE INDENT continue NEW_LINE DEDENT if s [ nx ] [ ny ] == " # " : NEW_LINE INDENT continue NEW_LINE DEDENT if dist [ nx ] [ ny ] == - 1 : NEW_LINE INDENT dist [ nx ] [ ny ] = dist [ x ] [ y ] + 1 NEW_LINE que . append ( [ nx , ny ] ) NEW_LINE DEDENT DEDENT DEDENT if dist [ h - 1 ] [ w - 1 ] == - 1 : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( h * w - dist [ h - 1 ] [ w - 1 ] - black ) NEW_LINE DEDENT


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . IOException ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; long k = Arrays . stream ( br . readLine ( ) . split ( " " ) ) . distinct ( ) . count ( ) ; br . close ( ) ; if ( k == 1 ) { System . out . println ( " SAME " ) ; } else { System . out . println ( " DIFFERENT " ) ; } } }

N = input ( ) NEW_LINE nCnt = N . count ( N [ 0 ] ) NEW_LINE if nCnt == 4 : NEW_LINE INDENT print ( ' SAME ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' DIFFERENT ' ) NEW_LINE DEDENT


print ( " SAME " if len ( set ( input ( ) ) ) == 1 else " DIFFERENT " ) NEW_LINE


def password ( N : int ) -> bool : NEW_LINE INDENT s = set ( ( N // ( 10 ** i ) ) % 10 for i in range ( 4 ) ) NEW_LINE return len ( s ) == 1 NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE yes = password ( N ) NEW_LINE print ( ' SAME ' if yes else ' DIFFERENT ' ) NEW_LINE DEDENT


N = input ( ) NEW_LINE x = N [ 0 ] NEW_LINE flag = True NEW_LINE for i in N : NEW_LINE INDENT if ( i != x ) : NEW_LINE INDENT flag = False NEW_LINE DEDENT x = i NEW_LINE DEDENT if ( flag ) : NEW_LINE INDENT print ( ' SAME ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' DIFFERENT ' ) NEW_LINE DEDENT


n = input ( ) NEW_LINE print ( " DIFFERENT " if len ( set ( n ) ) != 1 else " SAME " ) NEW_LINE


import java . util . HashSet ; import java . util . Scanner ; import java . util . Set ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; Set < String > set = new HashSet < > ( ) ; for ( int i = 0 ; i < 4 ; i ++ ) { set . add ( s . substring ( i , i + 1 ) ) ; } System . out . println ( set . size ( ) == 1 ? " SAME " : " DIFFERENT " ) ; } }


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 ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String S = in . next ( ) ; String ans = " SAME " ; for ( int i = 1 ; i < S . length ( ) ; i ++ ) { if ( S . charAt ( i ) != S . charAt ( i - 1 ) ) { ans = " DIFFERENT " ; break ; } } out . println ( ans ) ; } } 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 . * ; 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 int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { String s = sc . next ( ) ; out . println ( s . charAt ( 0 ) == s . charAt ( 1 ) && s . charAt ( 1 ) == s . charAt ( 2 ) && s . charAt ( 2 ) == s . charAt ( 3 ) ? " SAME " : " DIFFERENT " ) ; } }


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; 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 ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; if ( s . charAt ( 0 ) == s . charAt ( 1 ) && s . charAt ( 0 ) == s . charAt ( 2 ) && s . charAt ( 0 ) == s . charAt ( 3 ) ) out . println ( " SAME " ) ; else out . println ( " DIFFERENT " ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }


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

import sys NEW_LINE n = int ( sys . stdin . readline ( ) . rstrip ( ) ) NEW_LINE div , mod = divmod ( n , 2 ) NEW_LINE ans = 0 NEW_LINE if mod : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT ans += div NEW_LINE print ( ans ) NEW_LINE if mod : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT for _ in range ( div ) : NEW_LINE INDENT print ( 2 ) NEW_LINE DEDENT


N = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE for x in [ 8 , 4 , 2 , 1 ] : NEW_LINE INDENT while N >= x and N != 0 : NEW_LINE INDENT N -= x NEW_LINE ans . append ( x ) NEW_LINE DEDENT DEDENT print ( len ( ans ) ) NEW_LINE for x in ans : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT


n = input ( ) NEW_LINE print ( n + " \n 1" * int ( n ) ) NEW_LINE


n = int ( input ( ) ) NEW_LINE for i in range ( 2 ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( 2 ) : NEW_LINE INDENT for l in range ( 2 ) : NEW_LINE INDENT if i * 8 + j * 4 + k * 2 + l * 1 == n : NEW_LINE INDENT print ( i + j + k + l ) NEW_LINE if i == 1 : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT if j == 1 : NEW_LINE INDENT print ( j ) NEW_LINE DEDENT if k == 1 : NEW_LINE INDENT print ( k ) NEW_LINE DEDENT if l == 1 : NEW_LINE INDENT print ( l ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT


N = int ( input ( ) ) NEW_LINE N1 = 1 NEW_LINE N2 = 2 NEW_LINE N3 = 4 NEW_LINE N4 = 8 NEW_LINE ansList = [ ] NEW_LINE if N >= N4 : NEW_LINE INDENT ansList . append ( N4 ) NEW_LINE N -= N4 NEW_LINE DEDENT elif N >= N3 : NEW_LINE INDENT ansList . append ( N3 ) NEW_LINE N -= N3 NEW_LINE DEDENT if N >= N2 : NEW_LINE INDENT ansList . append ( N2 ) NEW_LINE N -= N2 NEW_LINE DEDENT elif N >= N1 : NEW_LINE INDENT ansList . append ( N1 ) NEW_LINE N -= N1 NEW_LINE DEDENT print ( len ( ansList ) ) NEW_LINE for i in ansList : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT


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 . math . BigDecimal ; 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 N = in . nextInt ( ) ; out . println ( N ) ; for ( int i = 0 ; i < N ; i ++ ) { out . println ( 1 ) ; } } } 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 . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; 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 ) ; TaskA solver = new TaskA ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskA { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { int n = in . nextInt ( ) ; out . println ( n ) ; for ( int i = 0 ; i < n ; i ++ ) out . println ( 1 ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isSpaceChar ( int c ) { return c == ' ▁ ' || c == ' \n ' || c == ' \r ' || c == ' \t ' || c == - 1 ; } public int nextInt ( ) { int n = 0 ; int b = readByte ( ) ; while ( isSpaceChar ( b ) ) b = readByte ( ) ; boolean minus = ( b == ' - ' ) ; if ( minus ) b = readByte ( ) ; while ( b >= '0' && b <= '9' ) { n *= 10 ; n += b - '0' ; b = readByte ( ) ; } if ( ! isSpaceChar ( b ) ) throw new NumberFormatException ( ) ; return minus ? - n : n ; } } }


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int a = sc . nextInt ( ) ; System . out . println ( a ) ; for ( int i = 0 ; i < a ; i ++ ) { System . out . println ( "1" ) ; } } 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 . 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 int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int n = nextInt ( ) ; out . println ( n ) ; for ( int i = 0 ; i < n ; i ++ ) { out . println ( 1 ) ; } } }


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 ( " " ) ; } }

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 { 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 ( ) ; } }


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 ( ) ; } }

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 . 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 ( ) ; } }