import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; StringBuffer sb = new StringBuffer ( ) ; int N = sc . nextInt ( ) ; String [ ] dict = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String s = sc . next ( ) ; sb = new StringBuffer ( s ) ; sb . reverse ( ) ; dict [ i ] = sb . toString ( ) ; } Arrays . sort ( dict ) ; for ( int i = 0 ; i < N ; i ++ ) { sb = new StringBuffer ( dict [ i ] ) ; pl ( sb . reverse ( ) . toString ( ) ) ; } } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }


def io_generator ( ) : NEW_LINE INDENT return input ( ) NEW_LINE DEDENT def main ( io ) : NEW_LINE INDENT n = int ( io ( ) ) NEW_LINE ll = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT ll . append ( io ( ) ) NEW_LINE DEDENT ll2 = [ l [ : : - 1 ] for l in ll ] NEW_LINE ll2 . sort ( ) NEW_LINE for l in ll2 : NEW_LINE INDENT print ( l [ : : - 1 ] ) NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT io = lambda : io_generator ( ) NEW_LINE main ( io ) NEW_LINE DEDENT


N = int ( input ( ) ) NEW_LINE for item in sorted ( [ input ( ) [ : : - 1 ] for _ in range ( N ) ] ) : NEW_LINE INDENT print ( item [ : : - 1 ] ) NEW_LINE DEDENT


n = int ( input ( ) ) NEW_LINE def f ( x ) : NEW_LINE INDENT y = " " NEW_LINE for i in range ( len ( x ) - 1 , - 1 , - 1 ) : NEW_LINE INDENT y = y + x [ i ] NEW_LINE DEDENT return y NEW_LINE DEDENT s = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT d = list ( input ( ) ) NEW_LINE s . append ( f ( d ) ) NEW_LINE DEDENT s . sort ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT ass = list ( s [ i ] ) NEW_LINE print ( f ( ass ) ) NEW_LINE DEDENT


def main ( ) : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE ss = [ input ( ) . rstrip ( ) for _ in range ( N ) ] NEW_LINE print ( " \n " . join ( sorted ( ss , key = ( lambda x : x [ : : - 1 ] ) ) ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . ArrayList ; import java . util . Collections ; import java . util . Comparator ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; Map < String , String > s_i = new HashMap < String , String > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String tmp = sc . next ( ) ; s_i . put ( new StringBuffer ( tmp ) . reverse ( ) . toString ( ) , tmp ) ; } List < Entry < String , String > > entries = new ArrayList < Entry < String , String > > ( s_i . entrySet ( ) ) ; Collections . sort ( entries , new Comparator < Entry < String , String > > ( ) { @ Override public int compare ( Entry < String , String > o1 , Entry < String , String > o2 ) { return o1 . getKey ( ) . compareTo ( o2 . getKey ( ) ) ; } } ) ; for ( Entry < String , String > e : entries ) { System . out . println ( e . getValue ( ) ) ; } } }

n = int ( input ( ) ) NEW_LINE l = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT l . append ( input ( ) [ : : - 1 ] ) NEW_LINE DEDENT l . sort ( ) NEW_LINE for i in l : NEW_LINE INDENT print ( i [ : : - 1 ] ) NEW_LINE DEDENT


import java . util . * ; public class Main { private static int n ; private static ArrayList < String > arrayList = new ArrayList < > ( ) ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; n = scan . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( scan . next ( ) ) ; sb . reverse ( ) ; arrayList . add ( sb . toString ( ) ) ; } } public static void main ( String args [ ] ) { input ( ) ; Collections . sort ( arrayList ) ; for ( int i = 0 ; i < n ; i ++ ) { StringBuffer sb = new StringBuffer ( ) ; sb . append ( arrayList . get ( i ) ) ; sb . reverse ( ) ; System . out . println ( sb . toString ( ) ) ; } } }


import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; Point [ ] p = new Point [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; p [ i ] = new Point ( x , y ) ; } long ans = Long . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { for ( int k = 0 ; k < n ; k ++ ) { for ( int l = 0 ; l < n ; l ++ ) { int count = 0 ; for ( int u = 0 ; u < n ; u ++ ) { if ( p [ u ] . x <= p [ i ] . x && p [ u ] . x >= p [ j ] . x && p [ u ] . y <= p [ k ] . y && p [ u ] . y >= p [ l ] . y ) { count ++ ; } } if ( count >= t ) { ans = Math . min ( ans , ( p [ i ] . x - p [ j ] . x ) * ( p [ k ] . y - p [ l ] . y ) ) ; } } } } } System . out . println ( ans ) ; } static class Point { long x ; long y ; public Point ( long x , long y ) { this . x = x ; this . y = y ; } } }

n , k = map ( int , input ( ) . split ( ) ) NEW_LINE XY = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE XY . sort ( ) NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( i + 1 , n ) : NEW_LINE INDENT x = XY [ j ] [ 0 ] - XY [ i ] [ 0 ] NEW_LINE T = sorted ( Z [ 1 ] for Z in XY [ i : j + 1 ] ) NEW_LINE for u , v in zip ( T , T [ k - 1 : ] ) : NEW_LINE INDENT ans = min ( ans , x * ( v - u ) ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


def axis_parallel_rectangle ( N : int , K : int , xy : list ) -> int : NEW_LINE INDENT sorted_x = sorted ( v [ 0 ] for v in xy ) NEW_LINE sorted_y = sorted ( v [ 1 ] for v in xy ) NEW_LINE XY = [ ( sorted_x . index ( v [ 0 ] ) , sorted_y . index ( v [ 1 ] ) ) for v in xy ] NEW_LINE S = [ [ 0 ] * ( N + 1 ) for _ in range ( N + 1 ) ] NEW_LINE for x , y in XY : NEW_LINE INDENT S [ x + 1 ] [ y + 1 ] = 1 NEW_LINE DEDENT for x in range ( N + 1 ) : NEW_LINE INDENT for y in range ( N ) : NEW_LINE INDENT S [ x ] [ y + 1 ] += S [ x ] [ y ] NEW_LINE DEDENT DEDENT for y in range ( N + 1 ) : NEW_LINE INDENT for x in range ( N ) : NEW_LINE INDENT S [ x + 1 ] [ y ] += S [ x ] [ y ] NEW_LINE DEDENT DEDENT min_area = float ( ' inf ' ) NEW_LINE for x1 in range ( N ) : NEW_LINE INDENT for x2 in range ( x1 + 1 , N ) : NEW_LINE INDENT for y1 in range ( N ) : NEW_LINE INDENT for y2 in range ( y1 + 1 , N ) : NEW_LINE INDENT count = S [ x2 + 1 ] [ y2 + 1 ] - S [ x2 + 1 ] [ y1 ] - S [ x1 ] [ y2 + 1 ] + S [ x1 ] [ y1 ] NEW_LINE if count < K : NEW_LINE INDENT continue NEW_LINE DEDENT xmin , xmax = sorted_x [ x1 ] , sorted_x [ x2 ] NEW_LINE ymin , ymax = sorted_y [ y1 ] , sorted_y [ y2 ] NEW_LINE min_area = min ( min_area , ( xmax - xmin ) * ( ymax - ymin ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return min_area NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 0 NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE xy = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE ans = axis_parallel_rectangle ( N , K , xy ) NEW_LINE print ( ans ) NEW_LINE DEDENT


from itertools import combinations NEW_LINE n , k = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE xy = [ [ int ( item ) for item in input ( ) . split ( ) ] for _ in range ( n ) ] NEW_LINE xsort = sorted ( xy , key = lambda x : x [ 0 ] ) NEW_LINE ysort = sorted ( xy , key = lambda x : x [ 1 ] ) NEW_LINE l = [ i for i in range ( n ) ] NEW_LINE cum = [ [ 0 for _ in range ( n + 1 ) ] for _ in range ( n + 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT cum [ i + 1 ] [ j + 1 ] = cum [ i + 1 ] [ j ] + cum [ i ] [ j + 1 ] - cum [ i ] [ j ] + ( [ xsort [ i ] [ 0 ] , ysort [ j ] [ 1 ] ] in xy ) NEW_LINE DEDENT DEDENT def count_points_in_rec ( x0 , x1 , y0 , y1 ) : NEW_LINE INDENT point = cum [ x1 + 1 ] [ y1 + 1 ] - cum [ x0 ] [ y1 + 1 ] - cum [ x1 + 1 ] [ y0 ] + cum [ x0 ] [ y0 ] NEW_LINE return point NEW_LINE DEDENT ans = 5 * 10 ** 18 NEW_LINE comb = [ ] NEW_LINE for a , b in combinations ( l , 2 ) : NEW_LINE INDENT if b - a >= k - 1 : NEW_LINE INDENT comb . append ( [ a , b ] ) NEW_LINE DEDENT DEDENT for a , b in comb : NEW_LINE INDENT for c , d in comb : NEW_LINE INDENT if count_points_in_rec ( a , b , c , d ) == k : NEW_LINE INDENT ans = min ( ans , ( xsort [ b ] [ 0 ] - xsort [ a ] [ 0 ] ) * ( ysort [ d ] [ 1 ] - ysort [ c ] [ 1 ] ) ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


from bisect import bisect_left NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ ] ; Y = [ ] ; info = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y = map ( int , input ( ) . split ( ) ) NEW_LINE X . append ( x ) ; Y . append ( y ) ; info . append ( [ x , y ] ) NEW_LINE DEDENT X . sort ( ) ; Y . sort ( ) NEW_LINE acc = [ [ 0 ] * ( N + 1 ) for i in range ( N + 1 ) ] NEW_LINE for x , y in info : NEW_LINE INDENT j = bisect_left ( X , x ) NEW_LINE i = bisect_left ( Y , y ) NEW_LINE acc [ i + 1 ] [ j + 1 ] += 1 NEW_LINE DEDENT for i in range ( N + 1 ) : NEW_LINE INDENT for j in range ( 1 , N ) : NEW_LINE INDENT acc [ i ] [ j + 1 ] += acc [ i ] [ j ] NEW_LINE DEDENT DEDENT for j in range ( N + 1 ) : NEW_LINE INDENT for i in range ( 1 , N ) : NEW_LINE INDENT acc [ i + 1 ] [ j ] += acc [ i ] [ j ] NEW_LINE DEDENT DEDENT ans = float ( ' inf ' ) NEW_LINE for t in range ( N - 1 ) : NEW_LINE INDENT for b in range ( t + 1 , N ) : NEW_LINE INDENT for l in range ( N - 1 ) : NEW_LINE INDENT for r in range ( l + 1 , N ) : NEW_LINE INDENT num = acc [ b + 1 ] [ r + 1 ] - acc [ b + 1 ] [ l ] - acc [ t ] [ r + 1 ] + acc [ t ] [ l ] NEW_LINE if num < K : continue NEW_LINE S = ( Y [ b ] - Y [ t ] ) * ( X [ r ] - X [ l ] ) NEW_LINE if S < ans : NEW_LINE INDENT ans = S NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE def debug ( ) : NEW_LINE INDENT for line in acc : NEW_LINE INDENT print ( line ) NEW_LINE DEDENT DEDENT


def solve ( N , K , XYs ) : NEW_LINE INDENT ans = 10 ** 19 + 1 NEW_LINE XYs . sort ( key = lambda x : x [ 0 ] ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j in range ( i + K - 1 , N ) : NEW_LINE INDENT narrowedXY = XYs [ i : j + 1 ] NEW_LINE narrowedXY . sort ( key = lambda x : x [ 1 ] ) NEW_LINE for y1 in range ( len ( narrowedXY ) ) : NEW_LINE INDENT for y2 in range ( y1 + K , len ( narrowedXY ) + 1 ) : NEW_LINE INDENT min_x = XYs [ i ] [ 0 ] NEW_LINE max_x = XYs [ j ] [ 0 ] NEW_LINE ys = [ xy [ 1 ] for xy in narrowedXY [ y1 : y2 ] ] NEW_LINE max_y = max ( ys ) NEW_LINE min_y = min ( ys ) NEW_LINE ans = min ( ans , abs ( max_x - min_x ) * abs ( max_y - min_y ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return ans NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N , K = tuple ( map ( int , input ( ) . split ( " ▁ " ) ) ) NEW_LINE XYs = [ tuple ( map ( int , input ( ) . split ( " ▁ " ) ) ) for _ in range ( N ) ] NEW_LINE print ( solve ( N , K , XYs ) ) NEW_LINE DEDENT


import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int k = in . nextInt ( ) ; List < int [ ] > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int [ ] tmp = { in . nextInt ( ) , in . nextInt ( ) } ; list . add ( tmp ) ; } list . sort ( ( x1 , x2 ) -> x1 [ 0 ] - x2 [ 0 ] ) ; long ans = Long . MAX_VALUE ; for ( int i = 0 ; i < n - k + 1 ; i ++ ) { for ( int j = i + k - 1 ; j < n ; j ++ ) { int [ ] y = new int [ j - i + 1 ] ; for ( int l = 0 ; l < j - i + 1 ; l ++ ) { y [ l ] = list . get ( l + i ) [ 1 ] ; } Arrays . sort ( y ) ; int yWidthMin = y [ k - 1 ] - y [ 0 ] ; for ( int l = 1 ; l + k - 1 < j - i + 1 ; l ++ ) { yWidthMin = Math . min ( yWidthMin , y [ l + k - 1 ] - y [ l ] ) ; } int xWidth = list . get ( j ) [ 0 ] - list . get ( i ) [ 0 ] ; ans = Math . min ( ans , ( long ) xWidth * yWidthMin ) ; } } System . out . println ( ans ) ; in . close ( ) ; } }


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 ( ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; } long ans = 2000000000 ; ans *= ans ; for ( int i = 0 ; i < N ; i ++ ) { long x1 = x [ i ] ; for ( int j = 0 ; j < N ; j ++ ) { long x2 = x [ j ] ; for ( int k = 0 ; k < N ; k ++ ) { long y1 = y [ k ] ; for ( int l = 0 ; l < N ; l ++ ) { long y2 = y [ l ] ; if ( x1 < x2 && y1 < y2 ) { int num = 0 ; for ( int m = 0 ; m < N ; m ++ ) { if ( x1 <= x [ m ] && x [ m ] <= x2 && y1 <= y [ m ] && y [ m ] <= y2 ) { num ++ ; } if ( num >= K ) { ans = Math . min ( ans , ( x2 - x1 ) * ( y2 - y1 ) ) ; } } } } } } } System . out . println ( ans ) ; } }


import java . util . * ; class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = s . nextInt ( ) , k = s . nextInt ( ) ; int [ ] x = new int [ n ] , y = new int [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { x [ i ] = s . nextInt ( ) ; y [ i ] = s . nextInt ( ) ; } long res = Long . MAX_VALUE ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = i + 1 ; j < n ; ++ j ) { long l = Math . min ( x [ i ] , x [ j ] ) ; long r = Math . max ( x [ i ] , x [ j ] ) ; for ( int p = 0 ; p < n ; ++ p ) { for ( int q = p + 1 ; q < n ; ++ q ) { long t = Math . min ( y [ p ] , y [ q ] ) ; long b = Math . max ( y [ p ] , y [ q ] ) ; int c = 0 ; for ( int o = 0 ; o < n ; ++ o ) { if ( l <= x [ o ] && x [ o ] <= r && t <= y [ o ] && y [ o ] <= b ) { ++ c ; } } if ( c >= k ) res = Math . min ( res , ( r - l ) * ( b - t ) ) ; } } } } System . out . println ( res ) ; } }


import java . util . * ; public class Main { static long [ ] arrX ; static long [ ] arrY ; static int n ; static int k ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; k = sc . nextInt ( ) ; arrX = new long [ n ] ; arrY = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { arrX [ i ] = sc . nextLong ( ) ; arrY [ i ] = sc . nextLong ( ) ; } long min = Long . MAX_VALUE ; for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { for ( int k = 0 ; k < n - 1 ; k ++ ) { for ( int l = k + 1 ; l < n ; l ++ ) { long sqr = Math . abs ( arrX [ i ] - arrX [ j ] ) * Math . abs ( arrY [ k ] - arrY [ l ] ) ; if ( sqr > min ) { continue ; } if ( isOver ( Math . min ( arrX [ i ] , arrX [ j ] ) , Math . max ( arrX [ i ] , arrX [ j ] ) , Math . min ( arrY [ k ] , arrY [ l ] ) , Math . max ( arrY [ k ] , arrY [ l ] ) ) ) { min = sqr ; } } } } } System . out . println ( min ) ; } static boolean isOver ( long x1 , long x2 , long y1 , long y2 ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( arrX [ i ] >= x1 && arrX [ i ] <= x2 && arrY [ i ] >= y1 && arrY [ i ] <= y2 ) { count ++ ; } } return ( count >= k ) ; } }


import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; String s = sc . next ( ) ; int i = sc . nextInt ( ) ; System . out . println ( s . charAt ( i - 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 ; } } }

s = list ( input ( ) ) NEW_LINE i = int ( input ( ) ) NEW_LINE print ( s [ i - 1 ] ) NEW_LINE


def index ( s : str , idx : int ) -> str : NEW_LINE INDENT return s [ idx - 1 ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s = input ( ) NEW_LINE idx = int ( input ( ) ) NEW_LINE ans = index ( s , idx ) NEW_LINE print ( ans ) NEW_LINE DEDENT


s , i = open ( 0 ) ; print ( s [ int ( i ) - 1 ] ) NEW_LINE


print ( input ( ) [ int ( input ( ) ) - 1 ] ) NEW_LINE


S , I = input ( ) , int ( input ( ) ) NEW_LINE print ( S [ I - 1 ] ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String s = in . next ( ) ; int i = in . nextInt ( ) ; out . println ( s . charAt ( i - 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 ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; int i = sc . nextInt ( ) ; char ans = s . charAt ( i - 1 ) ; System . out . println ( ans ) ; } }


import java . util . * ; import java . util . stream . * ; import static java . lang . System . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int nextInt ( ) { return Integer . parseInt ( sc . next ( ) ) ; } static int [ ] nextIntArray ( int n ) { return IntStream . range ( 0 , n ) . map ( i -> nextInt ( ) ) . toArray ( ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } static int min ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ 0 ] ; } static String yesno ( boolean b ) { return b ? " Yes " : " No " ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { out . println ( sc . next ( ) . charAt ( nextInt ( ) - 1 ) ) ; } }


import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( sc . next ( ) . charAt ( sc . nextInt ( ) - 1 ) ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a , b , c ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; c = sc . nextInt ( ) ; if ( a + b >= c ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if A + B >= C : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT


l = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE print ( ' Yes ' if l [ 0 ] + l [ 1 ] >= l [ 2 ] else ' No ' ) NEW_LINE


A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE print ( [ " Yes " , " No " ] [ not ( C <= A + B ) ] ) NEW_LINE


a , b , c = map ( int , input ( ) . split ( ) ) NEW_LINE if ( a + b >= c ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT


a , b , c = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE print ( ' Yes ' if a + b >= c else ' No ' ) NEW_LINE


import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; if ( a + b >= c ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } sc . close ( ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int A = reader . nextInt ( ) ; int B = reader . nextInt ( ) ; int C = reader . nextInt ( ) ; String ans = " Yes " ; if ( A + B < C ) { ans = " No " ; } System . out . println ( ans ) ; reader . close ( ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; System . out . println ( sc . nextInt ( ) + sc . nextInt ( ) >= sc . nextInt ( ) ? " Yes " : " No " ) ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A , B , C ; A = sc . nextInt ( ) ; B = sc . nextInt ( ) ; C = sc . nextInt ( ) ; if ( A + B < C ) { System . out . println ( " No " ) ; } else { System . out . println ( " Yes " ) ; } sc . close ( ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String s1 = sc . next ( ) ; String s2 = sc . next ( ) ; ArrayList < Integer > d = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( s1 . charAt ( i ) == s2 . charAt ( i ) ) { d . add ( 1 ) ; } else { d . add ( 2 ) ; i ++ ; } } sc . close ( ) ; long mod = 1000000007 ; long ans ; if ( d . get ( 0 ) == 1 ) { ans = 3 ; } else { ans = 6 ; } for ( int i = 1 ; i < d . size ( ) ; i ++ ) { if ( d . get ( i ) == 1 ) { if ( d . get ( i - 1 ) == 1 ) { ans *= 2 ; } else { ans *= 1 ; } } else { if ( d . get ( i - 1 ) == 1 ) { ans *= 2 ; } else { ans *= 3 ; } } if ( ans > mod ) ans %= mod ; } System . out . println ( ans ) ; } }

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE N = int ( input ( ) ) NEW_LINE s = input ( ) NEW_LINE t = input ( ) NEW_LINE X = True NEW_LINE Y = False NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE if s [ 0 ] == t [ 0 ] : NEW_LINE INDENT i = 1 NEW_LINE ans = 3 NEW_LINE prev = X NEW_LINE DEDENT else : NEW_LINE INDENT i = 2 NEW_LINE ans = 6 NEW_LINE prev = Y NEW_LINE DEDENT while i < N : NEW_LINE INDENT if s [ i ] == t [ i ] : NEW_LINE INDENT if prev : NEW_LINE INDENT ans = ( ans * 2 ) % MOD NEW_LINE DEDENT else : NEW_LINE INDENT ans = ans % MOD NEW_LINE DEDENT i += 1 NEW_LINE prev = X NEW_LINE DEDENT else : NEW_LINE INDENT if prev : NEW_LINE INDENT ans = ( ans * 2 ) % MOD NEW_LINE DEDENT else : NEW_LINE INDENT ans = ( ans * 3 ) % MOD NEW_LINE DEDENT i += 2 NEW_LINE prev = Y NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


n = int ( input ( ) ) NEW_LINE list_s1 = list ( str ( input ( ) ) ) NEW_LINE ans = 1 NEW_LINE list_s1 . append ( " ! " ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT elif i == 1 : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT else : NEW_LINE INDENT if list_s1 [ i ] == list_s1 [ i - 1 ] : NEW_LINE INDENT ans *= 1 NEW_LINE DEDENT else : NEW_LINE INDENT if list_s1 [ i - 1 ] == list_s1 [ i - 2 ] : NEW_LINE INDENT if list_s1 [ i ] != list_s1 [ i + 1 ] : NEW_LINE INDENT ans *= 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans % ( 10 ** 9 + 7 ) ) NEW_LINE


import array NEW_LINE from bisect import * NEW_LINE from collections import * NEW_LINE import fractions NEW_LINE import heapq NEW_LINE from itertools import * NEW_LINE import math NEW_LINE import random NEW_LINE import re NEW_LINE import string NEW_LINE import sys NEW_LINE MOD = 1000000007 NEW_LINE N = int ( input ( ) ) NEW_LINE S1 = input ( ) NEW_LINE S2 = input ( ) NEW_LINE i = 0 NEW_LINE prev = None NEW_LINE ans = 1 NEW_LINE while i < N : NEW_LINE INDENT if S1 [ i ] == S2 [ i ] : NEW_LINE INDENT if prev is None : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT if prev == ' ver ' : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT if prev == ' hor ' : NEW_LINE INDENT pass NEW_LINE DEDENT prev = ' ver ' NEW_LINE i += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if prev is None : NEW_LINE INDENT ans *= 6 NEW_LINE DEDENT if prev == ' ver ' : NEW_LINE INDENT ans *= 2 NEW_LINE DEDENT if prev == ' hor ' : NEW_LINE INDENT ans *= 3 NEW_LINE DEDENT prev = ' hor ' NEW_LINE i += 2 NEW_LINE DEDENT ans %= MOD NEW_LINE DEDENT print ( ans ) NEW_LINE


from itertools import groupby as gb NEW_LINE N = int ( input ( ) ) NEW_LINE a , b = gb ( input ( ) ) , gb ( input ( ) ) NEW_LINE res = - 1 NEW_LINE for ( w , x ) , ( y , z ) in zip ( a , b ) : NEW_LINE INDENT if res == - 1 : NEW_LINE INDENT prev = w != y NEW_LINE res = 3 * ( 1 + prev ) NEW_LINE DEDENT elif prev : NEW_LINE INDENT prev = w != y NEW_LINE res *= 1 + prev * 2 NEW_LINE DEDENT else : NEW_LINE INDENT prev = w != y NEW_LINE res *= 2 NEW_LINE DEDENT DEDENT print ( res % ( 10 ** 9 + 7 ) ) NEW_LINE


n = int ( input ( ) ) NEW_LINE s1 = input ( ) NEW_LINE s2 = input ( ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE b = 0 NEW_LINE did = 0 NEW_LINE ans = 0 NEW_LINE if s1 [ 0 ] == s2 [ 0 ] : NEW_LINE INDENT b = 1 NEW_LINE ans += 3 NEW_LINE DEDENT else : NEW_LINE INDENT did = 1 NEW_LINE ans = 6 NEW_LINE DEDENT for i in range ( 1 , n ) : NEW_LINE INDENT if s1 [ i ] == s2 [ i ] : NEW_LINE INDENT if b : NEW_LINE INDENT ans = ans * 2 % mod NEW_LINE DEDENT b = 1 NEW_LINE DEDENT elif not did : NEW_LINE INDENT if b : NEW_LINE INDENT ans = ans * 2 % mod NEW_LINE DEDENT else : NEW_LINE INDENT ans = ans * 3 % mod NEW_LINE DEDENT did = 1 NEW_LINE b = 0 NEW_LINE DEDENT else : NEW_LINE INDENT did = 0 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


import java . util . ArrayList ; import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; import java . util . function . Consumer ; import java . util . stream . IntStream ; import static java . util . stream . Collectors . toList ; public class Main { private static final Scanner scanner = new Scanner ( System . in ) ; private static final Consumer < List < String > > consumer = solve ( ) ; public static void main ( String [ ] args ) { consumer . accept ( readInput ( ) ) ; } private static List < String > readInput ( ) { final List < String > lineList = new ArrayList < > ( ) ; while ( scanner . hasNextLine ( ) ) { lineList . add ( scanner . nextLine ( ) ) ; } return lineList ; } private static Consumer < List < String > > solve ( ) { return args -> { final char [ ] first = args . get ( 1 ) . toCharArray ( ) ; final char [ ] second = args . get ( 2 ) . toCharArray ( ) ; Long ans = 1L ; Boolean isPrevVertical = null ; Integer index = 0 ; while ( index < first . length ) { if ( first [ index ] == second [ index ] ) { if ( isPrevVertical == null ) { ans = ( ans * 3 ) % 1000000007 ; } else if ( isPrevVertical ) { ans = ( ans * 2 ) % 1000000007 ; } isPrevVertical = true ; index ++ ; } else { if ( isPrevVertical == null ) { ans = ( ans * 6 ) % 1000000007 ; } else if ( isPrevVertical ) { ans = ( ans * 2 ) % 1000000007 ; } else { ans = ( ans * 3 ) % 1000000007 ; } isPrevVertical = false ; index += 2 ; } } System . out . println ( ans ) ; } ; } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { int n ; char [ ] [ ] ss ; int MOD = 1000000007 ; public static void main ( String args [ ] ) { new Main ( ) . run ( ) ; } void run ( ) { FastReader sc = new FastReader ( ) ; n = sc . nextInt ( ) ; ss = new char [ 2 ] [ n ] ; for ( int i = 0 ; i < 2 ; i ++ ) { ss [ i ] = sc . next ( ) . toCharArray ( ) ; } solve ( ) ; } void solve ( ) { long num = 1 ; int prevBlock = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ss [ 0 ] [ i ] == ss [ 1 ] [ i ] ) { switch ( prevBlock ) { case 0 : num *= 3 ; break ; case 1 : num *= 2 ; break ; } num %= MOD ; prevBlock = 1 ; } else { switch ( prevBlock ) { case 0 : num *= 6 ; break ; case 1 : num *= 2 ; break ; case 2 : num *= 3 ; break ; } num %= MOD ; prevBlock = 2 ; i ++ ; } } System . out . println ( num ) ; } static class FastReader { BufferedReader br ; StringTokenizer st ; public FastReader ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; class Reader { static BufferedReader reader ; static StringTokenizer tokenizer ; static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; } static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } } public class Main { public static void main ( String [ ] args ) throws IOException { Reader . init ( System . in ) ; int n = Reader . nextInt ( ) ; String s1 = Reader . next ( ) ; String s2 = Reader . next ( ) ; if ( n == 1 ) { System . out . println ( 3 ) ; } else { String d ; int i = 1 ; long a = 1 ; if ( s1 . charAt ( 0 ) == s2 . charAt ( 0 ) ) { d = " single " ; a = 3 ; } else { d = " double " ; i = 2 ; a = 6 ; } while ( i < n ) { if ( s1 . charAt ( i ) != s2 . charAt ( i ) ) { if ( d . compareTo ( " single " ) == 0 ) { a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ; } else { a = ( ( a % 1000000007 ) * 3 ) % 1000000007 ; } i += 2 ; d = " double " ; } else { if ( d . compareTo ( " single " ) == 0 ) { a = ( ( a % 1000000007 ) * 2 ) % 1000000007 ; } d = " single " ; i ++ ; } } System . out . println ( a ) ; } } }


import java . util . * ; public class Main { private static final int MOD = 1_000_000_007 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; String S1 = sc . next ( ) ; String S2 = sc . next ( ) ; System . out . println ( solve ( N , S1 , S2 ) ) ; } private static int solve ( int N , String S1 , String S2 ) { long ans ; boolean prev_tate ; int i ; if ( S1 . charAt ( 0 ) == S2 . charAt ( 0 ) ) { prev_tate = true ; i = 1 ; ans = 3 ; } else { prev_tate = false ; i = 2 ; ans = 6 ; } while ( N > i ) { if ( S1 . charAt ( i ) == S2 . charAt ( i ) ) { if ( prev_tate ) { ans = ans * 2 % MOD ; } i ++ ; prev_tate = true ; } else { if ( prev_tate ) { ans = ans * 2 % MOD ; } else { ans = ans * 3 % MOD ; } i = i + 2 ; prev_tate = false ; } } return ( int ) ans ; } }


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; int [ ] cnt = new int [ N ] ; int min = N + 1 ; int max = 0 ; for ( int i = 0 ; i < N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; cnt [ a [ i ] ] += 1 ; min = Math . min ( min , a [ i ] ) ; max = Math . max ( max , a [ i ] ) ; } sc . close ( ) ; String POSSIBLE = " Possible " ; String IMPOSSIBLE = " Impossible " ; String ans = POSSIBLE ; if ( cnt [ min ] == 1 ) { if ( max == min * 2 ) { ans = POSSIBLE ; for ( int i = min + 1 ; i <= max ; i ++ ) { if ( cnt [ i ] < 2 ) { ans = IMPOSSIBLE ; break ; } } } else { ans = IMPOSSIBLE ; } } else if ( cnt [ min ] == 2 ) { if ( max == min * 2 - 1 ) { ans = POSSIBLE ; for ( int i = min + 1 ; i <= max ; i ++ ) { if ( cnt [ i ] < 2 ) { ans = IMPOSSIBLE ; break ; } } } else { ans = IMPOSSIBLE ; } } else { ans = IMPOSSIBLE ; } System . out . println ( ans ) ; } }

import sys NEW_LINE input = sys . stdin . readline NEW_LINE from math import ceil NEW_LINE input ( ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE maxA = max ( A ) NEW_LINE minA = min ( A ) NEW_LINE if minA != ceil ( maxA / 2 ) : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE DEDENT else : NEW_LINE INDENT if maxA % 2 : NEW_LINE INDENT for i in range ( minA , maxA + 1 ) : NEW_LINE INDENT if i == minA : NEW_LINE INDENT if A . count ( i ) != 2 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A . count ( i ) < 2 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ' Possible ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( minA , maxA + 1 ) : NEW_LINE INDENT if i == minA : NEW_LINE INDENT if A . count ( i ) != 1 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if A . count ( i ) < 2 : NEW_LINE INDENT print ( ' Impossible ' ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT print ( ' Possible ' ) NEW_LINE DEDENT DEDENT DEDENT


from collections import defaultdict NEW_LINE n = int ( input ( ) ) NEW_LINE xs = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def no ( ) : NEW_LINE INDENT print ( " Impossible " ) NEW_LINE quit ( 0 ) NEW_LINE DEDENT def yes ( ) : NEW_LINE INDENT print ( " Possible " ) NEW_LINE quit ( 0 ) NEW_LINE DEDENT cnts = defaultdict ( int ) NEW_LINE for x in xs : NEW_LINE INDENT cnts [ x ] += 1 NEW_LINE DEDENT d = max ( xs ) NEW_LINE delems = [ ] NEW_LINE for i in range ( d + 1 ) : NEW_LINE INDENT delems . append ( max ( i , d - i ) ) NEW_LINE DEDENT for delem in delems : NEW_LINE INDENT if cnts [ delem ] <= 0 : NEW_LINE INDENT no ( ) NEW_LINE DEDENT cnts [ delem ] -= 1 NEW_LINE DEDENT minx = min ( delems ) + 1 NEW_LINE for x , rem in cnts . items ( ) : NEW_LINE INDENT if rem > 0 : NEW_LINE INDENT if not minx <= x <= d : NEW_LINE INDENT no ( ) NEW_LINE DEDENT DEDENT DEDENT yes ( ) NEW_LINE


import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 10 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def f ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE a . sort ( ) NEW_LINE i = 1 NEW_LINE if n > 2 and a [ - 1 ] == 1 : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ - 1 ] != a [ - 2 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ - 1 ] % 2 == 1 : NEW_LINE INDENT if a [ - 1 ] // 2 + 1 != a [ 0 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ 0 ] != a [ 1 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if n > 2 and a [ 0 ] == a [ 2 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT i = 2 NEW_LINE DEDENT else : NEW_LINE INDENT if a [ - 1 ] // 2 != a [ 0 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if a [ 0 ] == a [ 1 ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT DEDENT c = 2 NEW_LINE t = a [ 0 ] NEW_LINE for j in range ( i , n ) : NEW_LINE INDENT if t != a [ j ] : NEW_LINE INDENT if c < 2 : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT if t + 1 != a [ j ] : NEW_LINE INDENT return ' Impossible ' NEW_LINE DEDENT c = 0 NEW_LINE t = a [ j ] NEW_LINE DEDENT c += 1 NEW_LINE DEDENT return ' Possible ' NEW_LINE DEDENT print ( f ( ) ) NEW_LINE


from collections import Counter NEW_LINE pos = " Possible " NEW_LINE imp = " Impossible " NEW_LINE def judge ( nums ) : NEW_LINE INDENT N = len ( nums ) NEW_LINE count = Counter ( nums ) NEW_LINE mx = max ( nums ) NEW_LINE if mx == 1 : NEW_LINE INDENT if N == 2 : NEW_LINE INDENT return pos NEW_LINE DEDENT else : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT elif mx == 2 : NEW_LINE INDENT if count [ 1 ] == 1 and count [ 2 ] >= 2 : NEW_LINE INDENT return pos NEW_LINE DEDENT else : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT mid = ( mx + 1 ) // 2 NEW_LINE for i in range ( 1 , mid ) : NEW_LINE INDENT if count [ i ] != 0 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT if mx % 2 == 1 : NEW_LINE INDENT if count [ mid ] != 2 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if count [ mid ] != 1 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT for i in range ( mid + 1 , mx + 1 ) : NEW_LINE INDENT if count [ i ] < 2 : NEW_LINE INDENT return imp NEW_LINE DEDENT DEDENT return pos NEW_LINE DEDENT DEDENT dummy = int ( input ( ) ) NEW_LINE nums = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( judge ( nums ) ) NEW_LINE def mk ( array ) : NEW_LINE INDENT ret = [ ] NEW_LINE n = 1 NEW_LINE for e in array : NEW_LINE INDENT ret += [ n ] * e NEW_LINE n += 1 NEW_LINE DEDENT print ( ret ) NEW_LINE return ret NEW_LINE DEDENT


n = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a . sort ( ) NEW_LINE m , s = a [ - 1 ] , a [ 0 ] NEW_LINE if m != a [ - 2 ] or ( m + 1 ) // 2 != s or ( m % 2 and s - a [ 1 ] ) or ( ( not m % 2 ) and s == a [ 1 ] ) or any ( a . count ( i ) < 2 for i in range ( s + 1 , m ) ) or ( n != 2 and s == a [ 1 ] == a [ 2 ] ) : print ( " Impossible " ) NEW_LINE else : print ( " Possible " ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n ] ; int [ ] pos = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { int tmp = sc . nextInt ( ) ; a [ i ] = tmp ; pos [ tmp - 1 ] = i ; } TreeSet < Integer > ts = new TreeSet < Integer > ( ) ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int h , l ; if ( ts . higher ( pos [ i ] ) == null ) { h = n ; } else { h = ts . higher ( pos [ i ] ) ; } if ( ts . lower ( pos [ i ] ) == null ) { l = - 1 ; } else { l = ts . lower ( pos [ i ] ) ; } ans += ( long ) ( pos [ i ] - l ) * ( long ) ( h - pos [ i ] ) * ( long ) ( i + 1 ) ; ts . add ( pos [ i ] ) ; } System . out . println ( ans ) ; } }

import sys NEW_LINE input = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE import heapq NEW_LINE n = int ( input ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE idx = { } NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT idx [ a ] = i NEW_LINE DEDENT hq = [ ] NEW_LINE right = [ n - 1 ] * n NEW_LINE for i in range ( n ) : NEW_LINE INDENT while hq and - hq [ 0 ] > A [ i ] : NEW_LINE INDENT h = - heapq . heappop ( hq ) NEW_LINE right [ idx [ h ] ] = i - 1 NEW_LINE DEDENT heapq . heappush ( hq , - A [ i ] ) NEW_LINE DEDENT hq = [ ] NEW_LINE left = [ 0 ] * n NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT while hq and - hq [ 0 ] > A [ i ] : NEW_LINE INDENT h = - heapq . heappop ( hq ) NEW_LINE left [ idx [ h ] ] = i + 1 NEW_LINE DEDENT heapq . heappush ( hq , - A [ i ] ) NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT ans += A [ i ] * ( i - left [ i ] + 1 ) * ( right [ i ] - i + 1 ) NEW_LINE DEDENT print ( ans ) NEW_LINE


N = int ( input ( ) ) NEW_LINE a = [ 0 ] + [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE par = [ 0 for i in range ( N + 1 ) ] NEW_LINE size = [ 0 for i in range ( N + 1 ) ] NEW_LINE def find ( x ) : NEW_LINE INDENT if ( par [ x ] == x ) : NEW_LINE INDENT return x NEW_LINE DEDENT par [ x ] = find ( par [ x ] ) NEW_LINE return par [ x ] NEW_LINE DEDENT def unite ( x , y ) : NEW_LINE INDENT x = find ( x ) NEW_LINE y = find ( y ) NEW_LINE res = size [ x ] * size [ y ] NEW_LINE size [ x ] += size [ y ] NEW_LINE par [ y ] = x NEW_LINE return res NEW_LINE DEDENT for i in range ( N + 1 ) : NEW_LINE INDENT par [ i ] = i NEW_LINE size [ i ] = 1 NEW_LINE DEDENT b = [ 0 for i in range ( N + 1 ) ] NEW_LINE for i in range ( N + 1 ) : NEW_LINE INDENT b [ a [ i ] ] = i NEW_LINE DEDENT ans = 0 NEW_LINE for j in range ( 1 , N + 1 ) [ : : - 1 ] : NEW_LINE INDENT i = b [ j ] NEW_LINE ans += a [ i ] NEW_LINE if i - 1 >= 1 and a [ i - 1 ] > a [ i ] : NEW_LINE INDENT ans += unite ( i - 1 , i ) * a [ i ] NEW_LINE DEDENT if i + 1 <= N and a [ i + 1 ] > a [ i ] : NEW_LINE INDENT ans += unite ( i + 1 , i ) * a [ i ] NEW_LINE DEDENT DEDENT print ( ans ) 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 collections import Counter NEW_LINE def main ( ) : NEW_LINE INDENT N = II ( ) NEW_LINE A = LI ( ) NEW_LINE idxs = [ 0 ] * ( N + 1 ) NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT idxs [ a ] = i NEW_LINE DEDENT ll = list ( range ( N + 1 ) ) NEW_LINE rr = list ( range ( N + 1 ) ) NEW_LINE ans = 0 NEW_LINE for a in range ( N , 0 , - 1 ) : NEW_LINE INDENT idx = idxs [ a ] NEW_LINE l , r = ll [ idx ] , rr [ idx ] NEW_LINE ans += ( idx - l + 1 ) * ( r - idx + 1 ) * a NEW_LINE ll [ r + 1 ] = l NEW_LINE rr [ l - 1 ] = r NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE


def getNums ( As ) : NEW_LINE INDENT nums = [ 0 ] * N NEW_LINE stack = [ ( - 1 , 0 ) ] NEW_LINE for iA , A in enumerate ( As ) : NEW_LINE INDENT while stack [ - 1 ] [ 1 ] > A : NEW_LINE INDENT stack . pop ( ) NEW_LINE DEDENT nums [ iA ] = iA - stack [ - 1 ] [ 0 ] NEW_LINE stack . append ( ( iA , A ) ) NEW_LINE DEDENT return nums NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE As = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE numLs = getNums ( As ) NEW_LINE numRs = getNums ( reversed ( As ) ) NEW_LINE print ( sum ( [ A * numL * numR for A , numL , numR in zip ( As , numLs , reversed ( numRs ) ) ] ) ) NEW_LINE


def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE N = int ( input ( ) ) NEW_LINE a = inpl ( ) NEW_LINE b = { a [ i ] : i for i in range ( N ) } NEW_LINE left = list ( range ( N + 2 ) ) NEW_LINE right = list ( range ( N + 2 ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( N , 0 , - 1 ) : NEW_LINE INDENT x = b [ i ] NEW_LINE ans += i * ( right [ x ] - x + 1 ) * ( x - left [ x ] + 1 ) NEW_LINE right [ left [ x ] - 1 ] = right [ x ] NEW_LINE left [ right [ x ] + 1 ] = left [ x ] NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { ArrayList < Integer > [ ] graph ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] a = new int [ n + 1 ] ; int [ ] pos = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; pos [ a [ i ] ] = i ; } TreeSet < Integer > ts = new TreeSet < > ( ) ; ts . add ( 0 ) ; ts . add ( n + 1 ) ; long ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int lo = ts . lower ( pos [ i ] ) ; int hi = ts . higher ( pos [ i ] ) ; ans += ( ( long ) ( pos [ i ] - lo ) ) * ( ( long ) ( hi - pos [ i ] ) ) * i ; ts . add ( pos [ i ] ) ; } System . out . println ( ans ) ; } }


import java . util . ArrayDeque ; import java . util . Scanner ; import java . util . stream . IntStream ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { a [ i ] = scan . nextInt ( ) ; } int [ ] leftl = new int [ N ] ; int [ ] rightl = new int [ N ] ; ArrayDeque < Integer > que = new ArrayDeque < > ( ) ; int index = 0 ; while ( index < N ) { while ( ! que . isEmpty ( ) && a [ que . peek ( ) ] > a [ index ] ) { int ind = que . poll ( ) ; rightl [ ind ] = index - ind - 1 ; } que . push ( index ++ ) ; } while ( ! que . isEmpty ( ) ) { int ind = que . poll ( ) ; rightl [ ind ] = N - ind - 1 ; } index = N - 1 ; while ( index >= 0 ) { while ( ! que . isEmpty ( ) && a [ que . peek ( ) ] > a [ index ] ) { int ind = que . poll ( ) ; leftl [ ind ] = ind - index - 1 ; } que . push ( index -- ) ; } while ( ! que . isEmpty ( ) ) { int ind = que . poll ( ) ; leftl [ ind ] = ind - index - 1 ; } long ans = 0 ; for ( int i = 0 ; i < N ; ++ i ) { ans += ( long ) a [ i ] * ( leftl [ i ] + 1 ) * ( rightl [ i ] + 1 ) ; } System . out . println ( ans ) ; } }


import java . util . Arrays ; import java . util . LinkedList ; import java . util . Scanner ; public class Main { int n ; int [ ] a ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; a = new int [ n ] ; int [ ] r = new int [ n ] , l = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } LinkedList < Integer > stack = new LinkedList < > ( ) ; LinkedList < Integer > cnts = new LinkedList < > ( ) ; stack . add ( 0 ) ; int cnt = 1 ; for ( int i = 0 ; i < n ; i ++ ) { l [ i ] = 1 ; while ( stack . getLast ( ) > a [ i ] ) { stack . removeLast ( ) ; l [ i ] += cnts . removeLast ( ) ; } stack . addLast ( a [ i ] ) ; cnts . addLast ( l [ i ] ) ; } stack . clear ( ) ; stack . addLast ( 0 ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) { r [ i ] = 1 ; while ( stack . getLast ( ) > a [ i ] ) { stack . removeLast ( ) ; r [ i ] += cnts . removeLast ( ) ; } stack . addLast ( a [ i ] ) ; cnts . addLast ( r [ i ] ) ; } long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += 1L * a [ i ] * l [ i ] * r [ i ] ; } System . out . println ( ans ) ; } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }


import java . util . * ; public class Main { public void main ( Scanner sc ) { int n = sc . nextInt ( ) ; long a [ ] = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ sc . nextInt ( ) - 1 ] = i ; } TreeSet < Long > set = new TreeSet < > ( ) ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long num = a [ i ] ; Long l = set . lower ( num ) ; Long r = set . higher ( num ) ; l = ( l == null ? - 1 : l ) ; r = ( r == null ? n : r ) ; ans += ( i + 1 ) * ( num - l ) * ( r - num ) ; set . add ( num ) ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int prev = sc . nextInt ( ) ; int count = 1 ; int max = 1 ; boolean isDown = false ; for ( int i = 1 ; i < n ; i ++ ) { int h = sc . nextInt ( ) ; if ( isDown && prev < h ) { isDown = false ; count = 2 ; } else { count ++ ; if ( max < count ) { max = count ; } if ( prev > h ) { isDown = true ; } } prev = h ; } System . out . println ( max ) ; } }

N = int ( input ( ) ) NEW_LINE H = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE L = [ 1 ] * N NEW_LINE R = [ 1 ] * N NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT L [ i ] = L [ i - 1 ] * ( H [ i - 1 ] < H [ i ] ) + 1 NEW_LINE DEDENT for i in range ( N - 2 , - 1 , - 1 ) : NEW_LINE INDENT R [ i ] = R [ i + 1 ] * ( H [ i + 1 ] < H [ i ] ) + 1 NEW_LINE DEDENT ans = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT ans = max ( ans , L [ i ] + R [ i ] ) NEW_LINE DEDENT print ( ans - 1 ) NEW_LINE


n , * h = map ( int , open ( 0 ) . readlines ( ) ) NEW_LINE m = 1 NEW_LINE for t in range ( n ) : NEW_LINE INDENT s , u = t - ( t > 0 ) , t + ( t < n - 1 ) NEW_LINE if h [ s ] < h [ t ] > h [ u ] or t < 1 or t > n - 2 : NEW_LINE INDENT while s and h [ s - 1 ] < h [ s ] : s -= 1 NEW_LINE while u < n - 1 and h [ u + 1 ] < h [ u ] : u += 1 NEW_LINE DEDENT m = max ( m , u - s + 1 ) NEW_LINE DEDENT print ( m ) NEW_LINE


N = int ( input ( ) ) NEW_LINE inputs = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE def process ( ) : NEW_LINE INDENT global right , ans NEW_LINE right += 1 NEW_LINE if right == N - 1 : NEW_LINE INDENT ans = max ( ans , right - left + 1 ) NEW_LINE print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT left = 0 NEW_LINE right = 0 NEW_LINE ans = 1 NEW_LINE while right < N - 1 : NEW_LINE INDENT while inputs [ right ] < inputs [ right + 1 ] : NEW_LINE INDENT process ( ) NEW_LINE DEDENT while inputs [ right ] > inputs [ right + 1 ] : NEW_LINE INDENT process ( ) NEW_LINE DEDENT ans = max ( ans , right - left + 1 ) NEW_LINE left = right NEW_LINE right += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE


N = int ( input ( ) ) NEW_LINE if N == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT L = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE L . append ( n ) NEW_LINE DEDENT ans = 0 NEW_LINE M = " N " NEW_LINE S = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT if M == " N " : NEW_LINE INDENT if L [ i ] > L [ i - 1 ] : NEW_LINE INDENT M = " U " NEW_LINE S = i - 1 NEW_LINE DEDENT DEDENT elif M == " U " : NEW_LINE INDENT if L [ i ] >= L [ i - 1 ] : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT M = " D " NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if L [ i ] <= L [ i - 1 ] : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT M = " U " NEW_LINE S = i - 1 NEW_LINE DEDENT DEDENT if ans < i - S + 1 : NEW_LINE INDENT ans = i - S + 1 NEW_LINE DEDENT DEDENT print ( min ( N , ans ) ) NEW_LINE DEDENT


S = int ( input ( ) ) NEW_LINE stu = [ ] NEW_LINE zyousyou = 1 NEW_LINE kakou = 0 NEW_LINE u = 1 NEW_LINE s = 1 NEW_LINE ans = 1 NEW_LINE for i in range ( S ) : NEW_LINE INDENT a = int ( input ( ) ) NEW_LINE if ( i > 0 ) : NEW_LINE INDENT u += 1 NEW_LINE if ( a > ba ) : NEW_LINE INDENT if ( kakou == 1 ) : NEW_LINE INDENT if ( ans < u - s ) : NEW_LINE INDENT ans = u - s NEW_LINE DEDENT s = i NEW_LINE kakou = 0 NEW_LINE zyousyou = 1 NEW_LINE DEDENT DEDENT elif ( a < ba ) : NEW_LINE INDENT if ( zyousyou == 1 ) : NEW_LINE INDENT kakou = 1 NEW_LINE zyousyou = 0 NEW_LINE DEDENT DEDENT DEDENT ba = a NEW_LINE DEDENT if ( ans < u - s + 1 ) : NEW_LINE INDENT ans = u - s + 1 NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int h [ ] = new int [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { h [ i ] = sc . nextInt ( ) ; } if ( N == 1 ) { System . out . println ( 1 ) ; return ; } int state = h [ 1 ] > h [ 0 ] ? 1 : - 1 ; int s = 1 ; int t = 1 ; int u = 1 ; int max = 0 ; for ( int i = 2 ; i <= N ; i ++ ) { if ( state > 0 ) { if ( h [ i ] > h [ i - 1 ] ) { t = i ; u = i ; } else { u = i ; state = - state ; } } else { if ( h [ i ] < h [ i - 1 ] ) { u = i ; } else { state = - state ; int size = u - s + 1 ; max = Math . max ( max , size ) ; s = i - 1 ; t = i - 1 ; } } } max = Math . max ( max , u - s + 1 ) ; System . out . println ( max ) ; } }


import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) , x = sc . nextInt ( ) ; if ( n / 2 < x ) { System . out . println ( n - x ) ; } else { System . out . println ( x - 1 ) ; } } }

n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if n / 2 >= x : NEW_LINE INDENT print ( x - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n - x ) NEW_LINE DEDENT


def red_red_red_red_blue ( n : int , x : int ) -> int : NEW_LINE INDENT return min ( x - 1 , n - x ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n , x = map ( int , input ( ) . split ( ) ) NEW_LINE ans = red_red_red_red_blue ( n , x ) NEW_LINE print ( ans ) NEW_LINE DEDENT


n , x = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE print ( min ( x - 1 , n - x ) ) NEW_LINE


n , x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE if x <= n / 2 : NEW_LINE INDENT print ( x - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( n - x ) NEW_LINE DEDENT


n , x = map ( int , input ( ) . split ( ) ) ; print ( n - x if x > n / 2 else x - 1 ) NEW_LINE


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 ( ) ; int x = in . nextInt ( ) ; out . println ( Math . min ( n - x , x - 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 ; } 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 n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; System . out . println ( Math . min ( x - 1 , n - x ) ) ; } 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 . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int n = in . nextInt ( ) ; int x = in . nextInt ( ) ; out . println ( n - x < x - 1 ? n - x : x - 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 ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( 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 String yesno ( boolean b ) { return b ? " Yes " : " No " ; } static int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int n = nextInt ( ) , x = nextInt ( ) ; out . println ( min ( x - 1 , n - x ) ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; String c = sc . next ( ) ; if ( C . equals ( c . toUpperCase ( ) ) ) { System . out . println ( " Yes " ) ; return ; } else { System . out . println ( " No " ) ; return ; } } }

a , b = input ( ) . split ( ) NEW_LINE print ( " No " if ord ( b ) - ord ( a ) != 32 else " Yes " ) NEW_LINE


def main ( ) : NEW_LINE INDENT C , c = input ( ) . split ( ) NEW_LINE if C . lower ( ) == c : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


a , _ , b = input ( ) ; print ( ' YNeos ' [ a . lower ( ) != b : : 2 ] ) NEW_LINE


import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE C , c = input ( ) . split ( ) NEW_LINE if ord ( C ) - ord ( ' A ' ) == ord ( c ) - ord ( ' a ' ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT


upL , loL = input ( ) . split ( ) NEW_LINE if loL . upper ( ) == upL : print ( ' Yes ' ) NEW_LINE else : print ( ' No ' ) NEW_LINE


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 ) { out . println ( in . next ( ) . charAt ( 0 ) + 32 == in . next ( ) . charAt ( 0 ) ? " Yes " : " No " ) ; } } 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 . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s = r . readLine ( ) ; String [ ] sl = s . split ( " [ \\ s ] + " ) ; String a = sl [ 0 ] ; String b = sl [ 1 ] ; System . out . println ( a . toLowerCase ( ) . equals ( b ) ? " Yes " : " No " ) ; } }


import java . util . * ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String C = sc . next ( ) ; String c = sc . next ( ) ; if ( c . toUpperCase ( ) . equals ( C ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }


import java . io . * ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] params = br . readLine ( ) . split ( " ▁ " ) ; String row = params [ 0 ] . toLowerCase ( ) ; if ( row . equals ( params [ 1 ] ) ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . text . ParseException ; import java . util . Arrays ; import java . util . IntSummaryStatistics ; public class Main { public static void main ( String [ ] args ) throws IOException , ParseException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int number = Integer . parseInt ( br . readLine ( ) ) ; int [ ] pointArray = new int [ number ] ; for ( int i = 0 ; i < number ; i ++ ) { pointArray [ i ] = Integer . parseInt ( br . readLine ( ) ) ; } IntSummaryStatistics iss = Arrays . stream ( pointArray ) . summaryStatistics ( ) ; long max = iss . getMax ( ) ; long sum = iss . getSum ( ) ; System . out . println ( sum ) ; System . out . println ( Math . max ( 0 , max - ( sum - max ) ) ) ; } }

n = int ( input ( ) ) NEW_LINE a = sorted ( [ int ( input ( ) ) for i in range ( n ) ] ) NEW_LINE print ( sum ( a ) ) NEW_LINE print ( max ( 0 , a [ - 1 ] - sum ( a [ : - 1 ] ) ) ) NEW_LINE


N = int ( input ( ) ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT d = int ( input ( ) ) NEW_LINE if ( i == 0 ) : NEW_LINE INDENT dmin = d NEW_LINE dmax = d NEW_LINE DEDENT else : NEW_LINE INDENT if ( dmin <= d and dmax >= d ) : NEW_LINE INDENT dmin = 0 NEW_LINE DEDENT else : NEW_LINE INDENT dmin = min ( abs ( dmin - d ) , abs ( dmax - d ) ) NEW_LINE DEDENT dmax += d NEW_LINE DEDENT DEDENT print ( dmax ) NEW_LINE print ( dmin ) NEW_LINE


n = int ( input ( ) ) NEW_LINE l = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT l . append ( int ( input ( ) ) ) NEW_LINE DEDENT print ( sum ( l ) ) NEW_LINE l . sort ( reverse = True ) NEW_LINE min_no = l [ 0 ] NEW_LINE for x in range ( 1 , len ( l ) ) : NEW_LINE INDENT min_no -= l [ x ] NEW_LINE DEDENT if min_no <= 0 : NEW_LINE INDENT min_no = 0 NEW_LINE DEDENT print ( min_no ) NEW_LINE


import numpy as np NEW_LINE import sys NEW_LINE n = int ( input ( ) ) NEW_LINE d = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE print ( sum ( d ) ) NEW_LINE if sum ( d ) - np . max ( d ) < np . max ( d ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT print ( sum ( d ) ) NEW_LINE DEDENT if 1 < n : NEW_LINE INDENT print ( - sum ( d ) + 2 * np . max ( d ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT


from sys import stdin NEW_LINE input = stdin . readline NEW_LINE n = int ( input ( ) ) NEW_LINE L = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT d = int ( input ( ) ) NEW_LINE L . append ( d ) NEW_LINE DEDENT ma = sum ( L ) NEW_LINE if 2 * max ( L ) > sum ( L ) : NEW_LINE INDENT mi = 2 * max ( L ) - sum ( L ) NEW_LINE DEDENT else : NEW_LINE INDENT mi = 0 NEW_LINE DEDENT print ( ma ) NEW_LINE print ( mi ) NEW_LINE


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


import java . io . * ; import java . util . * ; import java . math . * ; public class Main { static boolean debug = false ; static boolean debug2 = false ; public static void main ( String [ ] args ) throws java . io . IOException { debug = 1 <= args . length ; debug2 = 2 <= args . length ; BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; final int N = Integer . parseInt ( in . readLine ( ) ) ; int [ ] d = new int [ N ] ; int max = 0 ; for ( int i = 0 ; i < N ; ++ i ) { max += d [ i ] = Integer . parseInt ( in . readLine ( ) ) ; } int min = Integer . MAX_VALUE ; switch ( N ) { case 1 : min = max ; break ; case 2 : min = Math . abs ( d [ 1 ] - d [ 0 ] ) ; break ; default : for ( int i = 1 , a = d [ 0 ] ; i < N ; a += d [ i ++ ] ) { for ( int j = i + 1 ; j < N ; ++ j ) { int b = 0 ; for ( int n = i ; n < j ; ++ n ) { b += d [ n ] ; } int c = 0 ; for ( int n = j ; n < N ; ++ n ) { c += d [ n ] ; } int [ ] abc = new int [ ] { a , b , c } ; Arrays . sort ( abc ) ; if ( abc [ 0 ] + abc [ 1 ] < abc [ 2 ] ) { min = Math . min ( min , abc [ 2 ] - abc [ 1 ] - abc [ 0 ] ) ; } else { min = 0 ; } } } break ; } System . out . println ( max ) ; System . out . println ( min ) ; } }


import java . util . Arrays ; import java . util . IntSummaryStatistics ; import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) , in [ ] = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) in [ i ] = s . nextInt ( ) ; IntSummaryStatistics iss = Arrays . stream ( in ) . parallel ( ) . summaryStatistics ( ) ; long max = iss . getMax ( ) , sum = iss . getSum ( ) ; System . out . println ( sum ) ; System . out . println ( Math . max ( 0 , max - ( sum - max ) ) ) ; } }


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


import java . util . Arrays ; import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) , k = s . nextInt ( ) , t [ ] = new int [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) t [ i + 1 ] = s . nextInt ( ) ; Arrays . parallelPrefix ( t , Integer :: sum ) ; for ( int i = 3 ; i <= n ; i ++ ) { if ( t [ i ] - t [ i - 3 ] < k ) { System . out . println ( i ) ; return ; } } System . out . println ( - 1 ) ; } }

n , k = map ( int , input ( ) . split ( ) ) NEW_LINE t = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT if t [ i - 2 ] + t [ i - 1 ] + t [ i ] < k : NEW_LINE INDENT print ( i + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT


n , k = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE res = False NEW_LINE time = [ int ( input ( ) ) , int ( input ( ) ) , int ( input ( ) ) ] NEW_LINE for i in range ( n - 3 ) : NEW_LINE INDENT if sum ( time ) < k and not res : NEW_LINE INDENT res = i + 3 NEW_LINE DEDENT time [ 0 ] , time [ 1 ] , time [ 2 ] = time [ 1 ] , time [ 2 ] , int ( input ( ) ) NEW_LINE DEDENT print ( res if res else - 1 ) NEW_LINE


def a_good_sleep ( N , K , T ) : NEW_LINE INDENT sleep_time = sum ( T [ : 3 ] ) NEW_LINE if sleep_time < K : NEW_LINE INDENT return 3 NEW_LINE DEDENT ans = - 1 NEW_LINE for day , t in enumerate ( T [ 3 : ] , 4 ) : NEW_LINE INDENT sleep_time -= T [ day - 3 - 1 ] NEW_LINE sleep_time += T [ day - 1 ] NEW_LINE if sleep_time < K : NEW_LINE INDENT ans = day NEW_LINE break NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT N , K = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE T = [ int ( input ( ) ) for _ in [ 0 ] * N ] NEW_LINE print ( a_good_sleep ( N , K , T ) ) NEW_LINE


n , k , * t = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; print ( ( [ i for i in range ( 3 , n ) if sum ( t [ i - 3 : i ] ) < k ] + [ - 1 ] ) [ 0 ] ) NEW_LINE


N , K = map ( int , input ( ) . split ( ) ) NEW_LINE L = [ ] NEW_LINE p = 0 NEW_LINE c = 0 NEW_LINE flag = True NEW_LINE for i in range ( N ) : NEW_LINE INDENT L . append ( int ( input ( ) ) ) NEW_LINE DEDENT for j in range ( N - 2 ) : NEW_LINE INDENT p = L [ j ] + L [ j + 1 ] + L [ j + 2 ] NEW_LINE if p < K : NEW_LINE INDENT flag = False NEW_LINE c = j + 3 NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT None NEW_LINE DEDENT DEDENT if flag : NEW_LINE INDENT print ( - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( c ) NEW_LINE DEDENT


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; int N = sc . nextInt ( ) ; int K = sc . nextInt ( ) ; int [ ] sleep = new int [ N + 1 ] ; sleep [ 0 ] = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { sleep [ i ] = sc . nextInt ( ) + sleep [ i - 1 ] ; } for ( int i = 3 ; i <= N ; i ++ ) { if ( sleep [ i ] - sleep [ i - 3 ] < K ) { pl ( i ) ; System . exit ( 0 ) ; } } pl ( - 1 ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }


import java . util . * ; import java . util . stream . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , k = scanner . nextInt ( ) , t [ ] = IntStream . range ( 0 , n ) . map ( i -> scanner . nextInt ( ) ) . toArray ( ) ; System . out . println ( IntStream . rangeClosed ( 3 , n ) . filter ( i -> t [ i - 3 ] + t [ i - 2 ] + t [ i - 1 ] < k ) . findFirst ( ) . orElse ( - 1 ) ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = Integer . parseInt ( sc . next ( ) ) ; int k = Integer . parseInt ( sc . next ( ) ) ; int temp0 = Integer . parseInt ( sc . next ( ) ) , temp1 = Integer . parseInt ( sc . next ( ) ) , temp2 = Integer . parseInt ( sc . next ( ) ) ; int sum = temp0 + temp1 + temp2 ; if ( sum < k ) { System . out . println ( 3 ) ; sc . close ( ) ; return ; } for ( int i = 4 ; i <= n ; i ++ ) { sum -= temp0 ; temp0 = temp1 ; temp1 = temp2 ; temp2 = Integer . parseInt ( sc . next ( ) ) ; sum += temp2 ; if ( sum < k ) { System . out . println ( i ) ; sc . close ( ) ; return ; } } System . out . println ( - 1 ) ; sc . close ( ) ; } }


import java . util . * ; import java . awt . * ; import java . awt . geom . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; int r = 0 ; int [ ] t = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { t [ i ] = sc . nextInt ( ) ; } for ( int i = 1 ; i <= n ; i ++ ) { r += t [ i ] ; if ( i < 3 ) continue ; if ( r < k ) { out . println ( i ) ; exit ( 0 ) ; } r -= t [ i - 2 ] ; } 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 k = sc . nextInt ( ) ; if ( k == 0 ) { System . out . print ( ( long ) n * n ) ; return ; } long sum = 0 ; for ( int i = k + 1 ; i <= n ; i ++ ) { sum += ( long ) ( n / i ) * ( i - k ) + Math . max ( n % i - k + 1 , 0 ) ; } System . out . print ( sum ) ; } }

N , K = map ( int , input ( ) . split ( ) ) NEW_LINE ans = 0 NEW_LINE for b in range ( 1 , N + 1 ) : NEW_LINE INDENT p = N // b NEW_LINE r = N % b NEW_LINE ans += max ( 0 , b - K ) * p + max ( 0 , r - K + 1 ) NEW_LINE if K == 0 : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


N , K = map ( int , input ( ) . split ( ) ) NEW_LINE Ans = 0 NEW_LINE if K == 0 : NEW_LINE INDENT print ( N ** 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT def Mods ( i , N , K ) : NEW_LINE INDENT lim = N // i NEW_LINE pattern = i - K NEW_LINE total = lim * pattern NEW_LINE if N - i * lim < K : NEW_LINE INDENT return total NEW_LINE DEDENT else : NEW_LINE INDENT extra = N - i * lim - K + 1 NEW_LINE return total + extra NEW_LINE DEDENT DEDENT for i in range ( K + 1 , N + 1 ) : NEW_LINE INDENT Ans += Mods ( i , N , K ) NEW_LINE DEDENT print ( Ans ) NEW_LINE DEDENT


N , K = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE ans = 0 NEW_LINE for mod in range ( K + 1 , N + 1 ) : NEW_LINE INDENT ans += ( mod - K ) * ( N // mod ) + max ( N % mod - max ( K - 1 , 0 ) , 0 ) NEW_LINE DEDENT print ( ans ) NEW_LINE


n , k = map ( int , input ( ) . split ( ) ) NEW_LINE a = ( n - k ) * ( n - k + 1 ) // 2 NEW_LINE for i in range ( k + 1 , n ) : NEW_LINE INDENT j = n // i * i NEW_LINE a += ( j // i - 1 ) * ( i - k ) + max ( n - j + 1 - max ( k , 1 ) , 0 ) NEW_LINE DEDENT print ( a ) NEW_LINE


N , K = map ( int , input ( ) . split ( ) ) NEW_LINE if K == 0 : print ( N ** 2 ) ; exit ( 0 ) NEW_LINE ans = ( N - K ) * ( N - K + 1 ) // 2 NEW_LINE for b in range ( K + 1 , N ) : NEW_LINE INDENT n = ( N - b + 1 ) // b NEW_LINE ans += ( n ) * ( b - K ) NEW_LINE if n * b + b - 1 != N : NEW_LINE INDENT if N % b >= K : NEW_LINE INDENT ans += N % b - K + 1 NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String [ ] tmpArray = br . readLine ( ) . split ( " ▁ " ) ; int n = Integer . parseInt ( tmpArray [ 0 ] ) ; int k = Integer . parseInt ( tmpArray [ 1 ] ) ; long result = 0 ; for ( int b = 1 ; b <= n ; b ++ ) { int p = n / b ; int r = n % b ; result += p * Math . max ( 0 , b - k ) + Math . max ( 0 , r - k + 1 ) ; } if ( k == 0 ) { result -= n ; } System . out . println ( result ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; int k = sc . nextInt ( ) ; sc . close ( ) ; if ( k == 0 ) { System . out . println ( n * n ) ; return ; } long ans = ( n - k + 1 ) * ( n - k ) / 2 ; for ( int i = k + 1 ; i < n ; i ++ ) { long tmp = ( ( n - i ) / i ) * ( i - k ) ; if ( n % i >= k ) { tmp += n % i - k + 1 ; } ans += tmp ; } System . out . println ( ans ) ; } }


import java . util . * ; import java . io . * ; import java . lang . * ; import java . math . * ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader bf = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer st = new StringTokenizer ( bf . readLine ( ) ) ; int n = Integer . parseInt ( st . nextToken ( ) ) ; int k = Integer . parseInt ( st . nextToken ( ) ) ; long ans = 0 ; for ( int b = 1 ; b <= n ; b ++ ) { if ( b <= k ) continue ; int remainders_per_b = b - 1 - k + 1 ; ans += 1L * n / b * remainders_per_b ; if ( n % b >= k ) ans += ( n % b ) - k + 1 ; if ( k == 0 ) ans -- ; } System . out . println ( ans ) ; } }


import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { solve ( ) ; } public static void solve ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; long count = 0 ; if ( k == 0 ) { count = ( long ) n * ( long ) n ; } else { for ( int i = 2 ; i <= n ; i ++ ) { if ( i > k ) { count += ( long ) Math . max ( 0 , n / i * ( i - k ) ) ; count += ( long ) Math . max ( 0 , ( n % i ) - k + 1 ) ; } } } System . out . println ( count ) ; } }


import java . util . Scanner ; import java . util . Arrays ; class Main { static int dp [ ] [ ] [ ] = new int [ 301 ] [ 301 ] [ 301 ] ; public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String S = scan . next ( ) ; int K = scan . nextInt ( ) ; int N = S . length ( ) ; for ( int i = 0 ; i < N ; ++ i ) for ( int k = 0 ; k <= K ; ++ k ) { dp [ i ] [ i + 1 ] [ k ] = 1 ; dp [ i ] [ i ] [ k ] = 0 ; } for ( int k = 0 ; k <= K ; ++ k ) { for ( int L = 2 ; L <= N ; ++ L ) { int i = 0 , j = L ; while ( j <= N ) { if ( k == 0 ) dp [ i ] [ j ] [ k ] = Math . max ( dp [ i + 1 ] [ j ] [ k ] , Math . max ( dp [ i ] [ j - 1 ] [ k ] , ( ( S . charAt ( i ) == S . charAt ( j - 1 ) ? dp [ i + 1 ] [ j - 1 ] [ k ] + 2 : dp [ i + 1 ] [ j - 1 ] [ k ] ) ) ) ) ; else dp [ i ] [ j ] [ k ] = Math . max ( dp [ i + 1 ] [ j ] [ k ] , Math . max ( dp [ i ] [ j - 1 ] [ k ] , Math . max ( dp [ i ] [ j ] [ k - 1 ] , ( ( S . charAt ( i ) == S . charAt ( j - 1 ) ? dp [ i + 1 ] [ j - 1 ] [ k ] + 2 : dp [ i + 1 ] [ j - 1 ] [ k - 1 ] + 2 ) ) ) ) ) ; ++ i ; ++ j ; } } } System . out . println ( dp [ 0 ] [ N ] [ K ] ) ; } }

def solve ( s , k ) : NEW_LINE INDENT n = len ( s ) NEW_LINE if k >= n // 2 : NEW_LINE INDENT return n NEW_LINE DEDENT dpp = [ [ 1 ] * ( k + 1 ) , [ 0 ] * ( k + 1 ) ] NEW_LINE for r in range ( 1 , n ) : NEW_LINE INDENT dpc = [ [ 0 ] * ( k + 1 ) for _ in range ( r + 2 ) ] NEW_LINE dpc [ r ] = [ 1 ] * ( k + 1 ) NEW_LINE for l in range ( r - 1 , - 1 , - 1 ) : NEW_LINE INDENT dpl , dpl1 = dpc [ l ] , dpp [ l + 1 ] NEW_LINE if s [ l ] == s [ r ] : NEW_LINE INDENT dpc [ l ] = [ c + 2 for c in dpl1 ] NEW_LINE DEDENT else : NEW_LINE INDENT dppl , dpcl1 = dpp [ l ] , dpc [ l + 1 ] NEW_LINE dpl [ 0 ] = max ( dppl [ 0 ] , dpcl1 [ 0 ] ) NEW_LINE for p in range ( 1 , k + 1 ) : NEW_LINE INDENT dpl [ p ] = max ( dppl [ p ] , dpcl1 [ p ] , dpl1 [ p - 1 ] + 2 ) NEW_LINE DEDENT DEDENT DEDENT dpp = dpc NEW_LINE DEDENT return dpp [ 0 ] [ k ] NEW_LINE DEDENT print ( solve ( input ( ) , int ( input ( ) ) ) ) NEW_LINE


import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . * ; public class Main { public static void main ( String args [ ] ) throws IOException { Scanner sc = new Scanner ( System . in ) ; char s [ ] = sc . next ( ) . toCharArray ( ) ; int k = sc . nextInt ( ) ; int dp [ ] [ ] [ ] = new int [ s . length ] [ s . length ] [ k + 1 ] ; for ( int i = 0 ; i <= k ; i ++ ) { for ( int r = 0 ; r < s . length ; r ++ ) { for ( int l = r ; l >= 0 ; l -- ) { if ( l == r ) { dp [ l ] [ r ] [ i ] = 1 ; continue ; } if ( r == l + 1 ) { dp [ l ] [ r ] [ i ] = s [ l ] == s [ r ] || i > 0 ? 2 : 1 ; continue ; } if ( s [ l ] == s [ r ] ) { dp [ l ] [ r ] [ i ] = dp [ l + 1 ] [ r - 1 ] [ i ] + 2 ; } else { dp [ l ] [ r ] [ i ] = Math . max ( dp [ l + 1 ] [ r ] [ i ] , dp [ l ] [ r - 1 ] [ i ] ) ; } if ( i > 0 ) { dp [ l ] [ r ] [ i ] = Math . max ( dp [ l ] [ r ] [ i ] , dp [ l + 1 ] [ r - 1 ] [ i - 1 ] + 2 ) ; } } } } System . out . println ( dp [ 0 ] [ s . length - 1 ] [ k ] ) ; } }


public class Main { static int dp [ ] [ ] [ ] ; static String s ; public static int solve ( int i , int j , int k ) { if ( dp [ i ] [ j ] [ k ] >= 0 ) return dp [ i ] [ j ] [ k ] ; else { int ans ; if ( i > j ) ans = 0 ; else if ( i == j ) ans = 1 ; else if ( s . charAt ( i ) == s . charAt ( j ) ) ans = solve ( i + 1 , j - 1 , k ) + 2 ; else { ans = solve ( i + 1 , j , k ) ; ans = Math . max ( ans , solve ( i , j - 1 , k ) ) ; if ( k > 0 ) ans = Math . max ( ans , solve ( i + 1 , j - 1 , k - 1 ) + 2 ) ; } dp [ i ] [ j ] [ k ] = ans ; return ans ; } } public static void main ( String [ ] args ) { java . util . Scanner scan = new java . util . Scanner ( System . in ) ; s = scan . next ( ) ; int t = scan . nextInt ( ) ; dp = new int [ s . length ( ) ] [ s . length ( ) ] [ t + 1 ] ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { for ( int j = 0 ; j < s . length ( ) ; j ++ ) { for ( int k = 0 ; k <= t ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; } } System . out . println ( solve ( 0 , s . length ( ) - 1 , t ) ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; int [ ] [ ] A = new int [ M ] [ 2 ] ; for ( int i = 0 ; i < M ; i ++ ) { A [ i ] [ 0 ] = sc . nextInt ( ) - 1 ; A [ i ] [ 1 ] = sc . nextInt ( ) - 1 ; } int [ ] [ ] B = new int [ N ] [ 2 ] ; for ( int i = 0 ; i < N ; i ++ ) { B [ i ] [ 0 ] = i ; B [ i ] [ 1 ] = 1 ; } long [ ] inconv = new long [ M + 1 ] ; inconv [ M ] = ( long ) N * ( N - 1 ) / 2 ; for ( int i = M - 1 ; i >= 0 ; i -- ) { int v1 = A [ i ] [ 0 ] ; int v2 = A [ i ] [ 1 ] ; int l1 = findRoot ( B , B [ v1 ] [ 0 ] ) ; int l2 = findRoot ( B , B [ v2 ] [ 0 ] ) ; inconv [ i ] = inconv [ i + 1 ] ; if ( l1 != l2 ) { int s1 = B [ l1 ] [ 1 ] ; int s2 = B [ l2 ] [ 1 ] ; inconv [ i ] -= s1 * s2 ; if ( s1 < s2 ) { int temp = l1 ; l1 = l2 ; l2 = temp ; } B [ l1 ] [ 1 ] += B [ l2 ] [ 1 ] ; B [ l2 ] [ 0 ] = l1 ; B [ l2 ] [ 1 ] = 0 ; } } for ( int i = 1 ; i < M + 1 ; i ++ ) { System . out . println ( inconv [ i ] ) ; } } static private int findRoot ( int [ ] [ ] leaders , int n ) { if ( leaders [ n ] [ 0 ] == n ) return n ; return findRoot ( leaders , leaders [ n ] [ 0 ] ) ; } }

class uf : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . table = [ - 1 ] * ( n + 1 ) NEW_LINE self . size = [ 1 ] * ( n + 1 ) NEW_LINE DEDENT def merge ( self , r1 , r2 ) : NEW_LINE INDENT self . table [ r1 ] = r2 NEW_LINE self . size [ r2 ] += self . size [ r1 ] NEW_LINE self . size [ r1 ] = 0 NEW_LINE DEDENT def find_root ( self , k ) : NEW_LINE INDENT path = [ ] NEW_LINE curr = k NEW_LINE while self . table [ curr ] != - 1 : NEW_LINE INDENT path . append ( curr ) NEW_LINE curr = self . table [ curr ] NEW_LINE DEDENT self . defrag ( curr , path ) NEW_LINE return curr , path NEW_LINE DEDENT def defrag ( self , r , p ) : NEW_LINE INDENT for i in p : NEW_LINE INDENT self . table [ i ] = r NEW_LINE DEDENT DEDENT DEDENT def solve ( string ) : NEW_LINE INDENT n , m , * ab = map ( int , string . split ( ) ) NEW_LINE ab = ab [ : : - 1 ] NEW_LINE ans = [ n * ( n - 1 ) // 2 ] NEW_LINE table = uf ( n ) NEW_LINE for _b , _a in zip ( ab [ : : 2 ] , ab [ 1 : : 2 ] ) : NEW_LINE INDENT r_a , _ = table . find_root ( _a ) NEW_LINE r_b , _ = table . find_root ( _b ) NEW_LINE if r_a == r_b : NEW_LINE INDENT ans . append ( ans [ - 1 ] ) NEW_LINE continue NEW_LINE DEDENT ans . append ( ans [ - 1 ] - table . size [ r_a ] * table . size [ r_b ] ) NEW_LINE table . merge ( r_a , r_b ) NEW_LINE DEDENT return " \n " . join ( [ str ( a ) for a in ans [ : - 1 ] [ : : - 1 ] ] ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( ' { } ▁ { } \n ' . format ( n , m ) + ' \n ' . join ( [ input ( ) for _ in range ( m ) ] ) ) ) NEW_LINE DEDENT


N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE bridge = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT bridge . append ( [ int ( i ) - 1 for i in input ( ) . split ( ) ] ) NEW_LINE DEDENT nod = [ [ i , [ i ] ] for i in range ( N ) ] NEW_LINE e = 0 NEW_LINE totale = int ( N * ( N - 1 ) / 2 ) NEW_LINE def joint ( a , b , e ) : NEW_LINE INDENT na = nod [ a ] [ 0 ] NEW_LINE nb = nod [ b ] [ 0 ] NEW_LINE if na == nb : NEW_LINE INDENT return e NEW_LINE DEDENT else : NEW_LINE INDENT e += len ( nod [ na ] [ 1 ] ) * len ( nod [ nb ] [ 1 ] ) NEW_LINE if na < nb : NEW_LINE INDENT nod [ na ] [ 1 ] . extend ( nod [ nb ] [ 1 ] ) NEW_LINE for i in nod [ nb ] [ 1 ] : NEW_LINE INDENT nod [ i ] [ 0 ] = na NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT nod [ nb ] [ 1 ] . extend ( nod [ na ] [ 1 ] ) NEW_LINE for i in nod [ na ] [ 1 ] : NEW_LINE INDENT nod [ i ] [ 0 ] = nb NEW_LINE DEDENT DEDENT return e NEW_LINE DEDENT DEDENT ans = [ ] NEW_LINE for i in range ( M - 1 , - 1 , - 1 ) : NEW_LINE INDENT ans . append ( totale - e ) NEW_LINE e = joint ( bridge [ i ] [ 0 ] , bridge [ i ] [ 1 ] , e ) NEW_LINE DEDENT for i in range ( M - 1 , - 1 , - 1 ) : NEW_LINE INDENT print ( ans [ i ] ) NEW_LINE DEDENT


import numpy as np NEW_LINE def solve ( n , m , a , b ) : NEW_LINE INDENT p = [ - 1 ] * ( n + 1 ) NEW_LINE u = [ 1 ] * ( n + 1 ) NEW_LINE def find ( x ) : NEW_LINE INDENT if p [ x ] == - 1 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return find ( p [ x ] ) NEW_LINE DEDENT DEDENT total = n * ( n - 1 ) // 2 NEW_LINE res = [ total ] NEW_LINE for i in range ( m - 1 , 0 , - 1 ) : NEW_LINE INDENT x , y = a [ i ] , b [ i ] NEW_LINE px = find ( x ) NEW_LINE py = find ( y ) NEW_LINE if px > py : NEW_LINE INDENT px , py = py , px NEW_LINE DEDENT if px != py : NEW_LINE INDENT n1 = u [ px ] NEW_LINE n2 = u [ py ] NEW_LINE p [ py ] = px NEW_LINE u [ px ] = n1 + n2 NEW_LINE total -= n1 * n2 NEW_LINE DEDENT res . append ( total ) NEW_LINE DEDENT return res [ : : - 1 ] NEW_LINE DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = np . zeros ( m , dtype = int ) NEW_LINE b = np . zeros ( m , dtype = int ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT a [ i ] , b [ i ] = map ( int , input ( ) . split ( ) ) NEW_LINE DEDENT print ( " \n " . join ( map ( str , solve ( n , m , a , b ) ) ) ) NEW_LINE


N , M = map ( int , input ( ) . split ( ) ) NEW_LINE AB = [ ] NEW_LINE for _ in range ( M ) : NEW_LINE INDENT A_i , B_i = map ( int , input ( ) . split ( ) ) NEW_LINE AB . append ( [ A_i , B_i ] ) NEW_LINE DEDENT class UnionFind ( ) : NEW_LINE INDENT def __init__ ( self , n ) : NEW_LINE INDENT self . parent = [ - 1 for _ in range ( n ) ] NEW_LINE DEDENT def root ( self , x ) : NEW_LINE INDENT if self . parent [ x ] < 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT self . parent [ x ] = self . root ( self . parent [ x ] ) NEW_LINE return self . parent [ x ] NEW_LINE DEDENT DEDENT def size ( self , x ) : NEW_LINE INDENT x = self . root ( x ) NEW_LINE return - 1 * self . parent [ x ] NEW_LINE DEDENT def union ( self , x , y ) : NEW_LINE INDENT x = self . root ( x ) NEW_LINE y = self . root ( y ) NEW_LINE if x == y : NEW_LINE INDENT return False NEW_LINE DEDENT x_size = self . size ( x ) NEW_LINE y_size = self . size ( y ) NEW_LINE if x_size < y_size : NEW_LINE INDENT x , y = y , x NEW_LINE DEDENT self . parent [ x ] += self . parent [ y ] NEW_LINE self . parent [ y ] = x NEW_LINE return True NEW_LINE DEDENT DEDENT max_inconvenience = N * ( N - 1 ) // 2 NEW_LINE ans = [ max_inconvenience ] NEW_LINE uf = UnionFind ( N ) NEW_LINE for bridge in reversed ( AB ) : NEW_LINE INDENT x = uf . root ( bridge [ 0 ] - 1 ) NEW_LINE y = uf . root ( bridge [ 1 ] - 1 ) NEW_LINE if x != y : NEW_LINE INDENT x_size = uf . size ( x ) NEW_LINE y_size = uf . size ( y ) NEW_LINE ans_tmp = max_inconvenience - x_size * y_size NEW_LINE max_inconvenience = ans_tmp NEW_LINE uf . union ( x , y ) NEW_LINE DEDENT else : NEW_LINE INDENT ans_tmp = max_inconvenience NEW_LINE DEDENT ans . append ( ans_tmp ) NEW_LINE DEDENT for a in reversed ( ans [ : - 1 ] ) : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT


N , M = map ( int , input ( ) . split ( ) ) NEW_LINE a_list = [ ] NEW_LINE b_list = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE a_list . append ( a ) NEW_LINE b_list . append ( b ) NEW_LINE DEDENT par = [ i for i in range ( N + 1 ) ] NEW_LINE rank = [ 0 ] * ( N + 1 ) NEW_LINE size = [ 1 ] * ( N + 1 ) NEW_LINE def find ( x ) : NEW_LINE INDENT if par [ x ] == x : NEW_LINE INDENT return par [ x ] NEW_LINE DEDENT else : NEW_LINE INDENT par [ x ] = find ( par [ x ] ) NEW_LINE return par [ x ] NEW_LINE DEDENT DEDENT def unite ( x , y ) : NEW_LINE INDENT x_par = find ( x ) NEW_LINE y_par = find ( y ) NEW_LINE if x_par == y_par : NEW_LINE INDENT return NEW_LINE DEDENT if rank [ x_par ] < rank [ y_par ] : NEW_LINE INDENT par [ x_par ] = y_par NEW_LINE size [ y_par ] += size [ x_par ] NEW_LINE DEDENT else : NEW_LINE INDENT par [ y_par ] = x_par NEW_LINE size [ x_par ] += size [ y_par ] NEW_LINE if rank [ x_par ] == rank [ y_par ] : NEW_LINE INDENT rank [ x_par ] += 1 NEW_LINE DEDENT DEDENT DEDENT def bool_func ( x , y ) : NEW_LINE INDENT if find ( x ) == find ( y ) : NEW_LINE INDENT return True NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT ans_list = [ ] NEW_LINE ans = int ( N * ( N - 1 ) / 2 ) NEW_LINE for i in range ( M ) : NEW_LINE INDENT ans_list . append ( ans ) NEW_LINE a = a_list [ M - 1 - i ] NEW_LINE b = b_list [ M - 1 - i ] NEW_LINE p = size [ find ( a ) ] NEW_LINE q = size [ find ( b ) ] NEW_LINE if bool_func ( a , b ) : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT ans -= p * q NEW_LINE unite ( a , b ) NEW_LINE DEDENT DEDENT for i in range ( M ) : NEW_LINE INDENT print ( ans_list [ M - 1 - i ] ) NEW_LINE DEDENT


import java . util . * ; import java . util . stream . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , m = scanner . nextInt ( ) , a [ ] = new int [ m ] , b [ ] = new int [ m ] , num [ ] = new int [ n + 1 ] ; long [ ] ans = new long [ m ] ; fa = IntStream . rangeClosed ( 0 , n ) . toArray ( ) ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; b [ i ] = scanner . nextInt ( ) ; } Arrays . fill ( num , 1 ) ; ans [ m - 1 ] = ( long ) n * ( n - 1 ) / 2 ; for ( int i = m - 1 ; i > 0 ; i -- ) { ans [ i - 1 ] = ans [ i ] ; if ( fd ( a [ i ] ) != fd ( b [ i ] ) ) { ans [ i - 1 ] -= num [ fa [ a [ i ] ] ] * num [ fa [ b [ i ] ] ] ; num [ fa [ b [ i ] ] ] += num [ fa [ a [ i ] ] ] ; fa [ fa [ a [ i ] ] ] = fa [ b [ i ] ] ; } } Arrays . stream ( ans ) . forEach ( System . out :: println ) ; } static int [ ] fa ; static int fd ( int a ) { return fa [ a ] == a ? a : ( fa [ a ] = fd ( fa [ a ] ) ) ; } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] a = new int [ m ] ; int [ ] b = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) - 1 ; b [ i ] = sc . nextInt ( ) - 1 ; } long [ ] answer = new long [ m ] ; answer [ m - 1 ] = ( long ) n * ( n - 1 ) / 2 ; UnionFind uf = new UnionFind ( n ) ; for ( int i = m - 1 ; i >= 1 ; i -- ) { answer [ i - 1 ] = answer [ i ] ; if ( uf . root ( a [ i ] ) != uf . root ( b [ i ] ) ) { answer [ i - 1 ] -= ( long ) uf . size ( a [ i ] ) * uf . size ( b [ i ] ) ; uf . connect ( a [ i ] , b [ i ] ) ; } } for ( int i = 0 ; i < m ; i ++ ) { System . out . println ( answer [ i ] ) ; } } } class UnionFind { private int [ ] parents ; UnionFind ( int n ) { parents = new int [ n ] ; Arrays . fill ( parents , - 1 ) ; } int size ( int node ) { return - parents [ root ( node ) ] ; } int root ( int node ) { if ( parents [ node ] < 0 ) return node ; else return parents [ node ] = root ( parents [ node ] ) ; } boolean connect ( int node1 , int node2 ) { int root1 = root ( node1 ) ; int root2 = root ( node2 ) ; if ( root1 == root2 ) return false ; else { if ( root1 < root2 ) { int temp = root1 ; root1 = root2 ; root2 = temp ; } parents [ root1 ] += parents [ root2 ] ; parents [ root2 ] = root1 ; return true ; } } }


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Amida amida = new Amida ( ) ; amida . startAmida ( ) ; amida . printHitLine ( ) ; } } class Amida { String [ ] [ ] amida ; int currentIndex ; int lineCount ; int rowCount ; public Amida ( ) { Scanner sc = new Scanner ( System . in ) ; this . lineCount = 2 * ( sc . nextInt ( ) ) - 1 ; this . rowCount = sc . nextInt ( ) ; this . amida = new String [ rowCount ] [ lineCount ] ; String [ ] tmpArr = new String [ rowCount + 1 ] ; for ( int i = rowCount ; i >= 0 ; i -- ) { tmpArr [ i ] = sc . nextLine ( ) ; } for ( int i = 0 ; i < rowCount ; i ++ ) { char [ ] charArr = tmpArr [ i ] . toCharArray ( ) ; for ( int j = 0 ; j < lineCount ; j ++ ) { this . amida [ i ] [ j ] = String . valueOf ( charArr [ j ] ) ; } } String currentPoint = sc . nextLine ( ) ; char [ ] currArr = currentPoint . toCharArray ( ) ; for ( int i = 0 ; i < currArr . length ; i ++ ) { if ( currArr [ i ] == " o " . toCharArray ( ) [ 0 ] ) { this . currentIndex = i ; } } } public void startAmida ( ) { for ( int i = 0 ; i < rowCount ; i ++ ) { if ( currentIndex < lineCount - 1 && amida [ i ] [ currentIndex + 1 ] . equalsIgnoreCase ( " - " ) ) { currentIndex += 2 ; } else if ( currentIndex > 0 && amida [ i ] [ currentIndex - 1 ] . equalsIgnoreCase ( " - " ) ) { currentIndex -= 2 ; } } } public void printHitLine ( ) { int ans = currentIndex / 2 + 1 ; System . out . println ( ans ) ; } }

n , l = map ( int , input ( ) . split ( ) ) NEW_LINE s = [ input ( ) for _ in range ( l ) ] NEW_LINE y = input ( ) NEW_LINE goal = 0 NEW_LINE while y [ goal ] != ' o ' : NEW_LINE INDENT goal += 2 NEW_LINE DEDENT goal //= 2 NEW_LINE for i in range ( n ) : NEW_LINE INDENT now = i NEW_LINE for ss in s : NEW_LINE INDENT if now != 0 and ss [ 2 * now - 1 ] == ' - ' : NEW_LINE INDENT now -= 1 NEW_LINE DEDENT elif now != n - 1 and ss [ 2 * now + 1 ] == ' - ' : NEW_LINE INDENT now += 1 NEW_LINE DEDENT DEDENT if now == goal : NEW_LINE INDENT print ( i + 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT


from sys import stdin NEW_LINE input = stdin . readline NEW_LINE n , l = map ( int , input ( ) . split ( ) ) NEW_LINE L = [ ] NEW_LINE for _ in range ( l + 1 ) : NEW_LINE INDENT L_ = list ( input ( ) ) NEW_LINE L . append ( L_ ) NEW_LINE DEDENT now = L [ l ] . index ( " o " ) NEW_LINE for i in range ( l - 1 , - 1 , - 1 ) : NEW_LINE INDENT if L [ i ] [ now - 1 ] == " - " : NEW_LINE INDENT now -= 2 NEW_LINE DEDENT elif L [ i ] [ now + 1 ] == " - " : NEW_LINE INDENT now += 2 NEW_LINE DEDENT DEDENT print ( now // 2 + 1 ) NEW_LINE


n , l = map ( int , input ( ) . split ( ) ) NEW_LINE line = [ ] NEW_LINE line . append ( " ▁ " ) NEW_LINE for i in range ( l + 1 ) : NEW_LINE INDENT line . append ( list ( input ( ) ) ) NEW_LINE DEDENT pos_ld = line [ l + 1 ] . index ( " o " ) NEW_LINE def route_amida ( line , length , width , n ) : NEW_LINE INDENT if width == 1 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT if length == 1 : NEW_LINE INDENT return int ( ( n + 2 ) / 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT if line [ length - 1 ] [ 1 ] == ' - ' : NEW_LINE INDENT n += 2 NEW_LINE DEDENT DEDENT elif n == 2 * width - 2 : NEW_LINE INDENT if line [ length - 1 ] [ 2 * width - 3 ] == ' - ' : NEW_LINE INDENT n -= 2 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if line [ length - 1 ] [ n + 1 ] == ' - ' : NEW_LINE INDENT n += 2 NEW_LINE DEDENT elif line [ length - 1 ] [ n - 1 ] == ' - ' : NEW_LINE INDENT n -= 2 NEW_LINE DEDENT DEDENT return route_amida ( line [ : length - 1 ] , ( length - 1 ) , width , n ) NEW_LINE DEDENT DEDENT DEDENT print ( route_amida ( line [ : l + 1 ] , l + 1 , n , pos_ld ) ) NEW_LINE