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 . Arrays ; 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 ( ) ; for ( int i = S . length ( ) - 2 ; i >= 0 ; i -= 2 ) { if ( S . substring ( 0 , i / 2 ) . equals ( ( S . substring ( i / 2 , i ) ) ) ) { out . println ( i ) ; break ; } } } } 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 char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { StringBuilder sb = new StringBuilder ( sc . next ( ) ) ; while ( true ) { sb . delete ( sb . length ( ) - 1 , sb . length ( ) ) ; if ( isGumozi ( sb . toString ( ) ) ) { System . out . println ( sb . length ( ) ) ; return ; } } } static boolean isGumozi ( String s ) { if ( s . length ( ) % 2 != 0 ) return false ; if ( s . substring ( 0 , s . length ( ) / 2 ) . equals ( s . substring ( s . length ( ) / 2 , s . length ( ) ) ) ) { return true ; } return false ; } }

import java . util . Arrays ; import java . util . List ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; Scanner sc = new Scanner ( System . in ) ; main . solve ( sc ) ; sc . close ( ) ; } void solve ( Scanner sc ) { String S = sc . next ( ) ; String ms = " " ; int len = S . length ( ) ; int ans = 0 ; if ( len % 2 == 0 ) { ms = S . substring ( 0 , len - 2 ) ; } else { ms = S . substring ( 0 , len - 1 ) ; } if ( ms . length ( ) == 2 ) { System . out . println ( "2" ) ; return ; } for ( int i = ms . length ( ) ; i > 1 ; i -= 2 ) { if ( ms . substring ( 0 , i / 2 ) . equals ( ms . substring ( i / 2 , i ) ) ) { ans = i ; break ; } } System . out . println ( ans ) ; } }

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 ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; for ( int i = s . length ( ) / 2 - 1 ; i > 0 ; i -- ) { if ( s . substring ( 0 , i ) . equals ( s . substring ( i , i * 2 ) ) ) { out . println ( i * 2 ) ; return ; } } } } 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 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 . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String word = input . readLine ( ) ; int largest = 0 ; for ( int i = word . length ( ) - 1 ; i > 1 ; i -- ) { if ( i % 2 == 0 ) { int midle = i / 2 ; boolean state = true ; for ( int j = 0 ; j < i / 2 ; j ++ , midle ++ ) { if ( word . charAt ( j ) != word . charAt ( midle ) ) { state = false ; break ; } } if ( state ) largest = Math . max ( largest , i ) ; } } System . out . println ( largest ) ; } }

S = list ( input ( ) ) NEW_LINE l = len ( S ) NEW_LINE for i in range ( 1 , l // 2 ) : NEW_LINE INDENT if all ( [ S [ j ] == S [ j + i ] for j in range ( i ) ] ) : NEW_LINE INDENT ans = 2 * i NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

s = input ( ) NEW_LINE if len ( s ) % 2 == 1 : NEW_LINE INDENT s = s [ : len ( s ) - 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT s = s [ : len ( s ) - 2 ] NEW_LINE DEDENT x = int ( len ( s ) / 2 ) NEW_LINE if s [ : x ] == s [ x : ] : NEW_LINE INDENT print ( 2 * x ) NEW_LINE DEDENT else : NEW_LINE INDENT while s [ : x ] != s [ x : ] : NEW_LINE INDENT s = s [ : len ( s ) - 2 ] NEW_LINE x -= 1 NEW_LINE DEDENT print ( 2 * x ) NEW_LINE DEDENT

import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE s = ns ( ) NEW_LINE n = len ( s ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT s = s [ : - 1 ] NEW_LINE if len ( s ) % 2 == 0 : NEW_LINE INDENT m = len ( s ) // 2 NEW_LINE count = 0 NEW_LINE for j in range ( m ) : NEW_LINE INDENT if s [ j ] == s [ j + m ] : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if count == m : NEW_LINE INDENT print ( 2 * m ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT

S = list ( input ( ) ) NEW_LINE while ( True ) : NEW_LINE INDENT del S [ - 2 : ] NEW_LINE bunkatsu = int ( len ( S ) / 2 ) NEW_LINE if ( S [ : bunkatsu ] == S [ bunkatsu : ] ) : NEW_LINE INDENT print ( len ( S ) ) NEW_LINE break NEW_LINE DEDENT DEDENT

s = input ( ) NEW_LINE found = 0 NEW_LINE for i in range ( len ( s ) ) : NEW_LINE INDENT if i % 2 == 0 and i >= 2 : NEW_LINE INDENT t = s [ : i // 2 ] NEW_LINE t2 = s [ i // 2 : i ] NEW_LINE if t == t2 : NEW_LINE INDENT found = i NEW_LINE DEDENT DEDENT DEDENT print ( found ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] x = new int [ n ] ; int [ ] y = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = sc . nextInt ( ) ; y [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { double [ ] angle = new double [ n ] ; int p = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( j != i ) { angle [ p ++ ] = Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ; } } Arrays . sort ( angle , 0 , p ) ; angle [ p ++ ] = angle [ 0 ] + 2 * Math . PI ; double max = 0 ; for ( int j = 0 ; j + 1 < angle . length ; j ++ ) { max = Math . max ( max , angle [ j + 1 ] - angle [ j ] ) ; } max = Math . max ( max - Math . PI , 0.0 ) ; System . out . printf ( " % .15f \n " , max / ( 2 * Math . PI ) ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] x = new int [ n ] [ 2 ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] [ 0 ] = sc . nextInt ( ) ; x [ i ] [ 1 ] = sc . nextInt ( ) ; } sc . close ( ) ; if ( n == 2 ) { System . out . println ( 0.5 ) ; System . out . println ( 0.5 ) ; return ; } long [ ] num = new long [ n ] ; final int N = 3500000 ; double r = Math . pow ( 10 , 11 ) ; for ( int i = 0 ; i < N ; i ++ ) { double theta = 2.0d * Math . PI * ( double ) i / ( double ) N ; double mx = r * Math . cos ( theta ) ; double my = r * Math . sin ( theta ) ; double min = Math . pow ( 10 , 200 ) ; int minpos = 0 ; for ( int j = 0 ; j < n ; j ++ ) { double len = Math . pow ( ( double ) ( x [ j ] [ 0 ] ) - mx , 2 ) + Math . pow ( ( double ) ( x [ j ] [ 1 ] ) - my , 2 ) ; if ( len < min ) { min = len ; minpos = j ; } } num [ minpos ] ++ ; } for ( int i = 0 ; i < n ; i ++ ) { System . out . println ( ( double ) ( num [ i ] ) / ( double ) N ) ; } } }

import java . io . IOException ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; double [ ] x = new double [ n ] ; double [ ] y = new double [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { x [ i ] = sc . nextDouble ( ) ; y [ i ] = sc . nextDouble ( ) ; } for ( int i = 0 ; i < n ; ++ i ) { double [ ] deg = new double [ n - 1 ] ; int cnt = 0 ; for ( int j = 0 ; j < n ; ++ j ) { if ( i == j ) continue ; deg [ cnt ++ ] = ( Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ) ; } Arrays . sort ( deg ) ; double ans = 0 ; for ( int j = 0 ; j < n - 2 ; ++ j ) { ans = Math . max ( ans , deg [ ( j + 1 ) % ( n - 1 ) ] - deg [ j ] ) ; } ans = Math . max ( ans , Math . PI * 2 + deg [ 0 ] - deg [ n - 2 ] ) ; ans = ans - Math . PI ; if ( ans <= 0 ) System . out . println ( 0 ) ; else System . out . println ( String . format ( " % .20f " , ans / ( 2 * Math . PI ) ) ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

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 ) ; int n = sc . nextInt ( ) ; double x [ ] = new double [ n ] ; double y [ ] = new double [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = sc . nextDouble ( ) ; y [ i ] = sc . nextDouble ( ) ; } for ( int i = 0 ; i < n ; i ++ ) { ArrayList < Double > s = new ArrayList < > ( ) ; for ( int j = 0 ; j < n ; j ++ ) { if ( i != j ) { s . add ( Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ) ; } } Collections . sort ( s ) ; double max = 0 ; for ( int j = 0 ; j < n - 2 ; j ++ ) { max = Math . max ( s . get ( j + 1 ) - s . get ( j ) , max ) ; } max = Math . max ( max , 2 * Math . PI - ( s . get ( n - 2 ) - s . get ( 0 ) ) ) ; System . out . println ( Math . max ( ( max - Math . PI ) / 2 / Math . PI , 0 ) ) ; } } }

import java . util . Scanner ; import java . util . Comparator ; import java . util . Arrays ; import java . util . List ; import java . util . ArrayList ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int [ ] x = new int [ N ] ; int [ ] y = new int [ N ] ; for ( int i = 0 ; i < N ; ++ i ) { x [ i ] = scan . nextInt ( ) ; y [ i ] = scan . nextInt ( ) ; } for ( int i = 0 ; i < N ; ++ i ) { List < Double > thetas = new ArrayList < > ( ) ; for ( int j = 0 ; j < N ; ++ j ) { if ( i == j ) continue ; thetas . add ( Math . atan2 ( y [ j ] - y [ i ] , x [ j ] - x [ i ] ) ) ; } thetas . sort ( Comparator . naturalOrder ( ) ) ; thetas . add ( thetas . get ( 0 ) + 2 * Math . PI ) ; double ans = 0 ; for ( int k = 0 ; k < N - 1 ; ++ k ) ans = Math . max ( ans , thetas . get ( k + 1 ) - thetas . get ( k ) - Math . PI ) ; System . out . println ( ans / ( Math . PI * 2 ) ) ; } } }

import math ; q = 2 * math . pi NEW_LINE from cmath import phase as h NEW_LINE t = lambda x : h ( x ) + ( q if 0 > h ( x ) else 0 ) NEW_LINE n = int ( input ( ) ) NEW_LINE r = range ( n ) NEW_LINE c = [ complex ( input ( ) . replace ( ' ▁ - ' , ' - ' ) . replace ( ' ▁ ' , ' + ' ) + " j " ) for _ in r ] NEW_LINE for i in r : a = sorted ( [ t ( c [ j ] - c [ i ] ) / q for j in r if j != i ] ) ; d = [ a [ j ] - a [ j - 1 ] for j in r [ : - 1 ] ] ; d [ 0 ] += 1 ; print ( max ( max ( d ) - 1 / 2 , 0 ) ) NEW_LINE

from math import pi , atan2 NEW_LINE q = 2 * pi NEW_LINE def deg ( a , b ) : NEW_LINE INDENT d = b - a NEW_LINE t = atan2 ( d . real , d . imag ) NEW_LINE if t < 0 : t += q NEW_LINE return t NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE cs = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE cs += [ complex ( a , b ) ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT args = [ deg ( cs [ i ] , cs [ j ] ) / q for j in range ( n ) if j != i ] NEW_LINE args = sorted ( args ) NEW_LINE dif = [ args [ i ] - args [ i - 1 ] for i in range ( n - 1 ) ] NEW_LINE dif [ 0 ] += 1 NEW_LINE print ( max ( max ( dif ) - 1 / 2 , 0 ) ) NEW_LINE DEDENT

import math NEW_LINE from collections import defaultdict NEW_LINE n = int ( input ( ) ) NEW_LINE ps = [ tuple ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE def dist ( rad , p ) : NEW_LINE INDENT radtmp = 2 * math . pi * rad / maxcut NEW_LINE return - p [ 0 ] * math . cos ( radtmp ) - p [ 1 ] * math . sin ( radtmp ) NEW_LINE DEDENT def closest ( rad ) : NEW_LINE INDENT tmp = dist ( rad , ps [ 0 ] ) NEW_LINE itmp = 0 NEW_LINE for i , pp in enumerate ( ps ) : NEW_LINE INDENT tmp2 = dist ( rad , pp ) NEW_LINE if tmp2 < tmp : NEW_LINE INDENT itmp = i NEW_LINE tmp = tmp2 NEW_LINE DEDENT DEDENT return itmp NEW_LINE DEDENT maxcut = 2 ** 20 NEW_LINE binary = defaultdict ( int ) NEW_LINE binary [ 0 ] = closest ( 0 ) NEW_LINE binary [ maxcut ] = binary [ 0 ] NEW_LINE binary [ maxcut // 2 ] = closest ( maxcut // 2 ) NEW_LINE binary [ maxcut // 4 ] = closest ( maxcut // 4 ) NEW_LINE binary [ 3 * maxcut // 4 ] = closest ( 3 * maxcut // 4 ) NEW_LINE def fillbinary ( ll , rr ) : NEW_LINE INDENT if binary [ ll ] != binary [ rr ] and rr - ll != 1 : NEW_LINE INDENT mm = ( ll + rr ) // 2 NEW_LINE binary [ mm ] = closest ( mm ) NEW_LINE fillbinary ( ll , mm ) NEW_LINE fillbinary ( mm , rr ) NEW_LINE DEDENT DEDENT fillbinary ( 0 , maxcut // 4 ) NEW_LINE fillbinary ( maxcut // 4 , maxcut // 2 ) NEW_LINE fillbinary ( maxcut // 2 , 3 * maxcut // 4 ) NEW_LINE fillbinary ( 3 * maxcut // 4 , maxcut ) NEW_LINE binkeys = sorted ( binary . keys ( ) ) NEW_LINE ansli = [ 0 ] * n NEW_LINE beforekey = 0 NEW_LINE for i in binkeys : NEW_LINE INDENT ansli [ binary [ i ] ] += i - beforekey NEW_LINE beforekey = i NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT print ( ansli [ i ] / maxcut ) NEW_LINE DEDENT

def graham_scan ( vertices : list ) : NEW_LINE INDENT from math import atan2 NEW_LINE from operator import itemgetter NEW_LINE vertices . sort ( key = itemgetter ( 1 ) ) NEW_LINE base_x , base_y = vertices [ 0 ] [ : 2 ] NEW_LINE vertices = sorted ( vertices [ 1 : ] , key = lambda p : atan2 ( p [ 1 ] - base_y , p [ 0 ] - base_x ) ) + vertices [ : 1 ] NEW_LINE convex = vertices [ - 1 : ] + vertices [ : 1 ] NEW_LINE pop , append = convex . pop , convex . append NEW_LINE last_x , last_y = convex [ - 1 ] [ : 2 ] NEW_LINE for point , ( x , y , * _ ) in zip ( vertices [ 1 : ] , vertices [ 1 : ] ) : NEW_LINE INDENT while ( ( x - last_x ) * ( convex [ - 2 ] [ 1 ] - last_y ) - ( y - last_y ) * ( convex [ - 2 ] [ 0 ] - last_x ) < 0 ) : NEW_LINE INDENT pop ( ) NEW_LINE last_x , last_y = convex [ - 1 ] [ : 2 ] NEW_LINE DEDENT append ( point ) NEW_LINE last_x , last_y = point [ : 2 ] NEW_LINE DEDENT return convex [ : - 1 ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT from math import acos , sqrt , pi NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) + [ i ] for i in range ( N ) ] NEW_LINE result = [ 0 ] * N NEW_LINE convex_hull = graham_scan ( a ) * 2 NEW_LINE for ( x2 , y2 , _ ) , ( x1 , y1 , i ) , ( x3 , y3 , _ ) in zip ( convex_hull , convex_hull [ 1 : ] , convex_hull [ 2 : ] ) : NEW_LINE INDENT vec1_x , vec1_y = x2 - x1 , y2 - y1 NEW_LINE vec2_x , vec2_y = x3 - x1 , y3 - y1 NEW_LINE result [ i ] = pi - acos ( ( vec1_x * vec2_x + vec1_y * vec2_y ) / ( sqrt ( vec1_x ** 2 + vec1_y ** 2 ) * sqrt ( vec2_x ** 2 + vec2_y ** 2 ) ) ) NEW_LINE DEDENT total = sum ( result ) NEW_LINE for rad in result : NEW_LINE INDENT print ( rad / total ) NEW_LINE DEDENT DEDENT

from numpy import argmax NEW_LINE import numpy as np NEW_LINE from collections import defaultdict NEW_LINE def cross ( a , b ) : NEW_LINE INDENT return a [ 0 ] * b [ 1 ] - a [ 1 ] * b [ 0 ] NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE H = [ np . array ( [ int ( j ) for j in input ( ) . split ( ) ] ) for i in range ( n ) ] NEW_LINE if n == 1 : NEW_LINE INDENT print ( 1 ) NEW_LINE exit ( ) NEW_LINE DEDENT convex = [ min ( H , key = lambda x : x [ 1 ] ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT a = H [ 0 ] if ( H [ 0 ] != convex [ - 1 ] ) . any ( ) else H [ - 1 ] NEW_LINE for b in H : NEW_LINE INDENT ac = a - convex [ - 1 ] NEW_LINE bc = b - convex [ - 1 ] NEW_LINE cross_ = cross ( ac , bc ) NEW_LINE if cross_ < 0 or ( cross_ == 0 and np . linalg . norm ( ac ) < np . linalg . norm ( bc ) ) : NEW_LINE INDENT a = b NEW_LINE DEDENT DEDENT if ( a == convex [ 0 ] ) . all ( ) : NEW_LINE INDENT break NEW_LINE DEDENT convex . append ( a ) NEW_LINE DEDENT ans = defaultdict ( float ) NEW_LINE for c , a , b in zip ( [ convex [ - 1 ] ] + convex [ : - 1 ] , convex , convex [ 1 : ] + [ convex [ 0 ] ] ) : NEW_LINE INDENT ca = c - a NEW_LINE ba = b - a NEW_LINE i = np . inner ( ca , ba ) NEW_LINE n = np . linalg . norm ( ca ) * np . linalg . norm ( ba ) NEW_LINE ans [ tuple ( a ) ] = ( np . pi - np . arccos ( np . clip ( i / n , - 1 , 1 ) ) ) / ( 2 * np . pi ) NEW_LINE DEDENT for i in H : NEW_LINE INDENT print ( ans [ tuple ( i ) ] ) NEW_LINE DEDENT


import com . sun . org . apache . xalan . internal . xsltc . util . IntegerArray ; 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 ) ) ; reverse [ ] items = new reverse [ Integer . parseInt ( in . readLine ( ) ) ] ; for ( int i = 0 ; i < items . length ; ++ i ) { items [ i ] = new reverse ( in . readLine ( ) ) ; } Arrays . sort ( items ) ; for ( int i = 0 ; i < items . length ; ++ i ) { System . out . println ( items [ i ] ) ; } } static class reverse implements Comparable < reverse > { private String orig ; private String str ; public reverse ( String s ) { orig = s ; StringBuffer sb = new StringBuffer ( s ) ; str = sb . reverse ( ) . toString ( ) ; } @ Override public int compareTo ( reverse o ) { return str . compareTo ( o . str ) ; } @ Override public String toString ( ) { return orig ; } } } . / Main . java : 1 : warning : IntegerArray is internal proprietary API and may be removed in a future release import com . sun . org . apache . xalan . internal . xsltc . util . IntegerArray ; ^ 1 warning

import java . util . HashMap ; import java . util . Iterator ; import java . util . Map . Entry ; import java . util . PrimitiveIterator ; import java . util . Scanner ; class Main { public static void main ( String [ ] $ ) { int n = gInt ( ) ; HashMap < String , String > m = new HashMap < > ( ) ; for ( int i : rep ( n ) ) { String in = s . next ( ) ; String sb = new StringBuilder ( in ) . reverse ( ) . toString ( ) ; m . put ( in , sb ) ; } m . entrySet ( ) . stream ( ) . sorted ( Entry . comparingByValue ( ) ) . map ( Entry :: getKey ) . forEach ( System . out :: println ) ; } static Scanner s = new Scanner ( System . in ) ; static int gInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long gLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static Range rep ( int i ) { return new Range ( i ) ; } static Range rep ( int f , int t ) { return new Range ( f , t ) ; } static class Range implements Iterable < Integer > , PrimitiveIterator . OfInt { int from , to , c ; Range ( int from , int to ) { this . from = from ; this . to = to ; this . c = from ; } Range ( int n ) { this ( 0 , n - 1 ) ; } @ Override public Iterator < Integer > iterator ( ) { return this ; } @ Override public boolean hasNext ( ) { return c <= to ; } @ Override public int nextInt ( ) { return c ++ ; } } }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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