import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int [ ] [ ] ar = new int [ C ] [ 100001 ] ; for ( int i = 0 ; i < n ; i ++ ) { int s = sc . nextInt ( ) - 1 ; int t = sc . nextInt ( ) - 1 ; int c = sc . nextInt ( ) - 1 ; for ( int j = s ; j <= t ; j ++ ) { ar [ c ] [ j ] = 1 ; } } int ans = 0 ; for ( int i = 1 ; i < 100001 ; i ++ ) { int max = 0 ; for ( int j = 0 ; j < C ; j ++ ) { max += ar [ j ] [ i ] ; } ans = Math . max ( ans , max ) ; } System . out . println ( ans ) ; } }

import java . util . * ; public class Main { static int modP = 1000000007 ; static long inf = 1 << 61 ; static int n , c ; static int [ ] S , T , C ; public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; n = in . nextInt ( ) ; c = in . nextInt ( ) ; S = new int [ n ] ; T = new int [ n ] ; C = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { S [ i ] = in . nextInt ( ) ; T [ i ] = in . nextInt ( ) ; C [ i ] = in . nextInt ( ) ; } int [ ] memo = new int [ 200005 ] ; int [ ] counts = new int [ 200005 ] ; for ( int j = 1 ; j <= c ; j ++ ) { Arrays . fill ( memo , 0 ) ; for ( int i = 0 ; i < n ; i ++ ) { if ( j == C [ i ] ) { int si = S [ i ] ; int ti = T [ i ] ; memo [ 2 * si - 1 ] ++ ; memo [ 2 * ti ] -- ; } } for ( int i = 1 ; i < 200005 ; i ++ ) { memo [ i ] += memo [ i - 1 ] ; } for ( int i = 0 ; i < 200005 ; i ++ ) { if ( memo [ i ] > 0 ) { counts [ i ] ++ ; } } } int ans = Arrays . stream ( counts ) . max ( ) . getAsInt ( ) ; print ( ans ) ; } static void print ( String s ) { System . out . println ( s ) ; } static void print ( int i ) { System . out . println ( i ) ; } static void print ( long i ) { System . out . println ( i ) ; } static void print ( float i ) { System . out . println ( i ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; final int nMax = 100000 ; LinkedList < int [ ] > [ ] dic = new LinkedList [ C + 1 ] ; for ( int i = 0 ; i <= C ; i ++ ) dic [ i ] = new LinkedList < > ( ) ; for ( int i = 1 ; i <= N ; i ++ ) { int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; dic [ c ] . add ( new int [ ] { s , t } ) ; } int [ ] res = new int [ nMax + 5 ] ; for ( int i = 1 ; i <= C ; i ++ ) { if ( dic [ i ] . size ( ) == 0 ) continue ; int [ ] cur = new int [ nMax + 5 ] ; while ( dic [ i ] . size ( ) > 0 ) { int [ ] temp = dic [ i ] . remove ( ) ; cur [ temp [ 0 ] ] ++ ; cur [ temp [ 1 ] + 1 ] -- ; } for ( int j = 1 ; j < nMax + 5 ; j ++ ) cur [ j ] = cur [ j - 1 ] + cur [ j ] ; for ( int j = 1 ; j < nMax + 5 ; j ++ ) { if ( cur [ j ] > 0 ) res [ j ] ++ ; } } int ans = 0 ; for ( int j = 1 ; j < nMax + 5 ; j ++ ) ans = Math . max ( ans , res [ j ] ) ; System . out . println ( ans ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int TIME = 100001 ; int [ ] [ ] acc = new int [ TIME ] [ C + 1 ] ; for ( int i = 0 ; i < N ; i ++ ) { int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; acc [ s ] [ c ] += 1 ; acc [ t ] [ c ] -= 1 ; } for ( int t = 1 ; t < TIME ; t ++ ) { for ( int c = 1 ; c <= C ; c ++ ) { acc [ t ] [ c ] = acc [ t ] [ c ] + acc [ t - 1 ] [ c ] ; } } for ( int t = 1 ; t < TIME ; t ++ ) { for ( int c = 1 ; c <= C ; c ++ ) { if ( acc [ t ] [ c ] > 0 && acc [ t - 1 ] [ c ] != acc [ t ] [ c ] ) { acc [ t - 1 ] [ c ] += acc [ t ] [ c ] ; } } } int needMaxCnt = 0 ; for ( int t = 1 ; t < TIME ; t ++ ) { int tmpMaxCnt = 0 ; for ( int c = 1 ; c <= C ; c ++ ) { tmpMaxCnt += acc [ t ] [ c ] ; } needMaxCnt = Math . max ( needMaxCnt , tmpMaxCnt ) ; } out . println ( needMaxCnt ) ; } }

import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int n = in . nextInt ( ) ; int C = in . nextInt ( ) ; Map < Integer , List < int [ ] > > map = new HashMap < > ( ) ; for ( int i = 1 ; i <= C ; i ++ ) { List < int [ ] > list = new ArrayList < > ( ) ; map . put ( i , list ) ; } for ( int i = 0 ; i < n ; i ++ ) { int [ ] tmp = { in . nextInt ( ) , in . nextInt ( ) } ; int c = in . nextInt ( ) ; map . get ( c ) . add ( tmp ) ; } int [ ] time = new int [ 100002 ] ; for ( int i = 1 ; i <= C ; i ++ ) { List < int [ ] > list = map . get ( i ) ; list . sort ( ( st1 , st2 ) -> st1 [ 0 ] - st2 [ 0 ] ) ; int last = 0 ; for ( int [ ] st : list ) { if ( last == st [ 0 ] ) { time [ last + 1 ] ++ ; time [ st [ 1 ] + 1 ] -- ; last = st [ 1 ] ; } else { time [ st [ 0 ] ] ++ ; time [ st [ 1 ] + 1 ] -- ; last = st [ 1 ] ; } } } for ( int i = 1 ; i <= 100001 ; i ++ ) { time [ i ] += time [ i - 1 ] ; } int max = 0 ; for ( int i = 1 ; i <= 100001 ; i ++ ) { max = Math . max ( max , time [ i ] ) ; } System . out . println ( max ) ; in . close ( ) ; } }

n , c = map ( int , input ( ) . split ( ) ) NEW_LINE stc = [ list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE stc . sort ( ) NEW_LINE R = [ [ stc [ 0 ] [ 1 ] , stc [ 0 ] [ 2 ] ] ] NEW_LINE for s , t , c in stc [ 1 : ] : NEW_LINE INDENT for i in range ( len ( R ) ) : NEW_LINE INDENT tr , cr = R [ i ] [ 0 ] , R [ i ] [ 1 ] NEW_LINE if c == cr and tr <= s : NEW_LINE INDENT R [ i ] = [ t , c ] NEW_LINE break NEW_LINE DEDENT if c != cr and tr < s : NEW_LINE INDENT R [ i ] = [ t , c ] NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT R . append ( [ t , c ] ) NEW_LINE DEDENT DEDENT print ( len ( R ) ) NEW_LINE

from numpy import cumsum NEW_LINE n , c = [ int ( item ) for item in input ( ) . split ( ) ] NEW_LINE stc = [ [ int ( item ) for item in input ( ) . split ( ) ] for _ in range ( n ) ] NEW_LINE stc . sort ( key = lambda x : ( x [ 2 ] , x [ 0 ] ) ) NEW_LINE timeline = [ 0 ] * ( 10 ** 5 + 1 ) NEW_LINE prev_c = - 1 NEW_LINE for s , t , c in stc : NEW_LINE INDENT if prev_c != c : NEW_LINE INDENT prev_t = - 100 NEW_LINE DEDENT if prev_t != s : NEW_LINE INDENT timeline [ s - 1 ] += 1 NEW_LINE timeline [ t ] += - 1 NEW_LINE DEDENT else : NEW_LINE INDENT timeline [ s ] += 1 NEW_LINE timeline [ t ] += - 1 NEW_LINE DEDENT prev_t = t NEW_LINE prev_c = c NEW_LINE DEDENT print ( max ( cumsum ( timeline ) ) ) NEW_LINE

def recording ( N : int , C : int , info : list ) -> int : NEW_LINE INDENT _ , max_time , _ = max ( info , key = lambda x : x [ 1 ] ) NEW_LINE max_time = 2 * max_time NEW_LINE recorders = [ [ 0 ] * C for _ in range ( max_time + 1 ) ] NEW_LINE for s , t , ch in info : NEW_LINE INDENT recorders [ 2 * s - 1 ] [ ch - 1 ] += 1 NEW_LINE recorders [ 2 * t ] [ ch - 1 ] -= 1 NEW_LINE DEDENT for t in range ( max_time ) : NEW_LINE INDENT for ch in range ( C ) : NEW_LINE INDENT recorders [ t + 1 ] [ ch ] += recorders [ t ] [ ch ] NEW_LINE DEDENT DEDENT return max ( sum ( used > 0 for used in recorders [ t ] ) for t in range ( max_time + 1 ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 0 NEW_LINE N , C = map ( int , input ( ) . split ( ) ) NEW_LINE info = [ tuple ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE ans = recording ( N , C , info ) NEW_LINE print ( ans ) NEW_LINE DEDENT

import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N , C = map ( int , input ( ) . split ( ) ) NEW_LINE dic = [ [ ] for _ in range ( C + 1 ) ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT s , t , c = input ( ) . split ( ) NEW_LINE dic [ int ( c ) ] . append ( [ int ( s ) , int ( t ) ] ) NEW_LINE DEDENT for c in range ( C + 1 ) : NEW_LINE INDENT l = len ( dic [ c ] ) NEW_LINE if l == 1 : NEW_LINE INDENT continue NEW_LINE DEDENT dic [ c ] = sorted ( dic [ c ] ) NEW_LINE i = 0 NEW_LINE while i < l - 1 : NEW_LINE INDENT if i < l - 1 and dic [ c ] [ i ] [ 1 ] == dic [ c ] [ i + 1 ] [ 0 ] : NEW_LINE INDENT dic [ c ] [ i + 1 ] [ 0 ] += 1 NEW_LINE DEDENT else : NEW_LINE INDENT i += 1 NEW_LINE DEDENT DEDENT DEDENT f = [ 0 for _ in range ( 100002 ) ] NEW_LINE for c in range ( C + 1 ) : NEW_LINE INDENT for t in dic [ c ] : NEW_LINE INDENT f [ t [ 0 ] ] += 1 NEW_LINE f [ t [ 1 ] + 1 ] -= 1 NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for i in range ( 1 , 100001 ) : NEW_LINE INDENT f [ i ] += f [ i - 1 ] NEW_LINE if ans < f [ i ] : NEW_LINE INDENT ans = f [ i ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

ri = lambda : int ( input ( ) ) NEW_LINE rl = lambda : list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE rr = lambda N : [ ri ( ) for _ in range ( N ) ] NEW_LINE YN = lambda b : print ( ' YES ' ) if b else print ( ' NO ' ) NEW_LINE yn = lambda b : print ( ' Yes ' ) if b else print ( ' No ' ) NEW_LINE OE = lambda x : print ( ' Odd ' ) if x % 2 else print ( ' Even ' ) NEW_LINE INF = 10 ** 18 NEW_LINE N , C = rl ( ) NEW_LINE stc = [ rl ( ) for _ in range ( N ) ] NEW_LINE stc . sort ( key = lambda x : ( x [ 2 ] , x [ 0 ] ) ) NEW_LINE nstc = [ ] NEW_LINE for s , t , c in stc : NEW_LINE INDENT if len ( nstc ) != 0 and nstc [ - 1 ] [ 2 ] == c and nstc [ - 1 ] [ 1 ] == s : NEW_LINE INDENT nstc [ - 1 ] [ 1 ] = t NEW_LINE DEDENT else : NEW_LINE INDENT nstc . append ( [ s , t , c ] ) NEW_LINE DEDENT DEDENT n = len ( nstc ) NEW_LINE TT = [ 0 ] * ( 2 * 10 ** 5 + 5 ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT TT [ 2 * nstc [ i ] [ 0 ] - 1 ] += 1 NEW_LINE TT [ 2 * nstc [ i ] [ 1 ] ] -= 1 NEW_LINE DEDENT for i in range ( 1 , len ( TT ) ) : NEW_LINE INDENT TT [ i ] += TT [ i - 1 ] NEW_LINE DEDENT print ( max ( TT ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . print ( Math . max ( c / a , c / b ) ) ; } }

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 a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; out . println ( c / Math . min ( a , b ) ) ; } } 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 a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int c = sc . nextInt ( ) ; System . out . println ( c / Math . min ( a , b ) ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

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

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int A = in . nextInt ( ) ; int B = in . nextInt ( ) ; int C = in . nextInt ( ) ; out . println ( A < B ? C / A : C / B ) ; } } 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 ( ) ) ; } } }

A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE if A <= B : NEW_LINE INDENT print ( C // A ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( C // B ) NEW_LINE DEDENT

def manju ( A : int , B : int , C : int ) -> int : NEW_LINE INDENT max_num = 0 NEW_LINE for numA in range ( C // A + 1 ) : NEW_LINE INDENT numB = ( C - A * numA ) // B NEW_LINE if numB < 0 : NEW_LINE INDENT break NEW_LINE DEDENT max_num = max ( max_num , numA + numB ) NEW_LINE DEDENT return max_num NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE ans = manju ( A , B , C ) NEW_LINE print ( ans ) NEW_LINE DEDENT

A , B , C = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE a = min ( A , B ) NEW_LINE print ( int ( C / a ) ) NEW_LINE

A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE D = A NEW_LINE count = 0 NEW_LINE if B < A : NEW_LINE INDENT A = B NEW_LINE B = D NEW_LINE DEDENT while True : NEW_LINE INDENT if C >= A : NEW_LINE INDENT C = C - A NEW_LINE count += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( count ) NEW_LINE

a , b , c = map ( int , input ( ) . split ( ) ) ; print ( c // min ( a , b ) ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; int d = scan . nextInt ( ) ; int e = scan . nextInt ( ) ; int [ ] num = new int [ 5 ] ; num [ 0 ] = a ; num [ 1 ] = b ; num [ 2 ] = c ; num [ 3 ] = d ; num [ 4 ] = e ; Arrays . sort ( num ) ; int ans = num [ 1 ] + num [ 2 ] + num [ 4 ] ; int ans2 = num [ 4 ] + num [ 3 ] + num [ 0 ] ; System . out . println ( Math . max ( ans2 , 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 int maxInt = Integer . MAX_VALUE ; static int minInt = Integer . MIN_VALUE ; public static void main ( String [ ] args ) { int [ ] ar = nextIntArray ( 5 ) ; ArrayList < Integer > list = new ArrayList < > ( ) ; for ( int i = 0 ; i < ( Math . pow ( 2 , 5 ) ) ; i ++ ) { if ( Integer . bitCount ( i ) != 3 ) continue ; int tempSum = 0 ; for ( int j = 0 ; j < 5 ; j ++ ) { if ( ( 1 & i >> j ) == 1 ) { tempSum += ar [ j ] ; } } list . add ( tempSum ) ; } Collections . sort ( list ) ; out . println ( list . get ( list . size ( ) - 3 ) ) ; } }

import java . util . Comparator ; import java . util . stream . Stream ; public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int a = scanner . nextInt ( ) , b = scanner . nextInt ( ) , c = scanner . nextInt ( ) , d = scanner . nextInt ( ) , e = scanner . nextInt ( ) ; Stream . of ( a + b + c , a + b + d , a + b + e , a + c + d , a + c + e , a + d + e , b + c + d , b + c + e , b + d + e , c + d + e ) . distinct ( ) . sorted ( Comparator . reverseOrder ( ) ) . skip ( 2 ) . findFirst ( ) . ifPresent ( System . out :: println ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; int D = sc . nextInt ( ) ; int E = sc . nextInt ( ) ; out . println ( Math . max ( A + D + E , B + C + E ) ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] po = new int [ 5 ] ; for ( int i = 0 ; i < 5 ; i ++ ) po [ i ] = sc . nextInt ( ) ; int ans [ ] = new int [ ] { po [ 0 ] + po [ 1 ] + po [ 2 ] , po [ 0 ] + po [ 1 ] + po [ 3 ] , po [ 0 ] + po [ 1 ] + po [ 4 ] , po [ 0 ] + po [ 2 ] + po [ 3 ] , po [ 0 ] + po [ 2 ] + po [ 4 ] , po [ 0 ] + po [ 3 ] + po [ 4 ] , po [ 1 ] + po [ 2 ] + po [ 3 ] , po [ 1 ] + po [ 2 ] + po [ 4 ] , po [ 1 ] + po [ 3 ] + po [ 4 ] , po [ 2 ] + po [ 3 ] + po [ 4 ] } ; Arrays . sort ( ans ) ; System . out . println ( ans [ 7 ] ) ; } }

import itertools NEW_LINE l = list ( map ( int , ( input ( ) . split ( ) ) ) ) NEW_LINE sm = [ ] NEW_LINE for p in itertools . combinations ( l , 3 ) : NEW_LINE INDENT sm . append ( sum ( p ) ) NEW_LINE DEDENT sm . sort ( reverse = True ) NEW_LINE print ( sm [ 2 ] ) NEW_LINE

ABCDE = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE total_list = [ ] NEW_LINE for i in ABCDE : NEW_LINE INDENT for j in ABCDE : NEW_LINE INDENT if i == j : NEW_LINE INDENT continue NEW_LINE DEDENT for k in ABCDE : NEW_LINE INDENT if j == k or i == k : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT total = i + j + k NEW_LINE if not total in total_list : NEW_LINE INDENT total_list . append ( total ) NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT total_list . sort ( ) NEW_LINE print ( total_list [ - 3 ] ) NEW_LINE

from itertools import permutations NEW_LINE a = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ans = [ ] NEW_LINE for x in permutations ( [ 0 , 0 , 1 , 1 , 1 ] ) : NEW_LINE INDENT sum = 0 NEW_LINE for i , y in enumerate ( x ) : NEW_LINE INDENT if y == 1 : NEW_LINE INDENT sum += a [ i ] NEW_LINE DEDENT DEDENT ans . append ( sum ) NEW_LINE DEDENT b = list ( set ( ans ) ) NEW_LINE b . sort ( ) NEW_LINE print ( b [ - 3 ] ) NEW_LINE

num = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE ans = [ ] NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT for j in range ( i + 1 , 4 ) : NEW_LINE INDENT for k in range ( j + 1 , 5 ) : NEW_LINE INDENT ans . append ( num [ i ] + num [ j ] + num [ k ] ) NEW_LINE DEDENT DEDENT DEDENT ans = sorted ( list ( set ( ans ) ) ) NEW_LINE print ( ans [ - 3 ] ) NEW_LINE

a , b , c , d , e = map ( int , input ( ) . split ( ) ) NEW_LINE s = a + b + c + d + e NEW_LINE l = [ a , b , c , d , e ] NEW_LINE l1 = [ ] NEW_LINE for i in range ( 4 ) : NEW_LINE INDENT for j in range ( i + 1 , 5 ) : NEW_LINE INDENT l1 . append ( s - l [ i ] - l [ j ] ) NEW_LINE DEDENT DEDENT l1 = sorted ( l1 ) NEW_LINE print ( l1 [ - 3 ] ) NEW_LINE


import java . util . Scanner ; public class Main { static int r , c , k , n ; static int [ ] rc , cc ; public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; r = sc . nextInt ( ) ; c = sc . nextInt ( ) ; k = sc . nextInt ( ) ; n = sc . nextInt ( ) ; rc = new int [ n ] ; cc = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { rc [ i ] = sc . nextInt ( ) - 1 ; cc [ i ] = sc . nextInt ( ) - 1 ; } long ans = solve ( ) ; System . out . println ( ans ) ; } static long solve ( ) { int [ ] candyInR = new int [ r + 1 ] ; int [ ] candyInC = new int [ c + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { candyInR [ rc [ i ] ] ++ ; candyInC [ cc [ i ] ] ++ ; } int [ ] countR = new int [ n + 1 ] ; int [ ] countC = new int [ n + 1 ] ; for ( int i = 0 ; i < r ; i ++ ) countR [ candyInR [ i ] ] ++ ; for ( int i = 0 ; i < c ; i ++ ) countC [ candyInC [ i ] ] ++ ; long ans = 0 ; for ( int i = 0 ; i <= k ; i ++ ) ans += countR [ i ] * countC [ k - i ] ; for ( int i = 0 ; i < n ; i ++ ) { int sum = candyInR [ rc [ i ] ] + candyInC [ cc [ i ] ] ; if ( sum == k ) ans -- ; if ( sum == k + 1 ) ans ++ ; } return ans ; } }

public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int r = scanner . nextInt ( ) , c = scanner . nextInt ( ) , k = scanner . nextInt ( ) , n = scanner . nextInt ( ) ; int [ ] ra = new int [ n ] , ca = new int [ n ] , rSum = new int [ r ] , cSum = new int [ c ] ; for ( int i = 0 ; i < n ; i ++ ) { rSum [ ra [ i ] = scanner . nextInt ( ) - 1 ] ++ ; cSum [ ca [ i ] = scanner . nextInt ( ) - 1 ] ++ ; } long [ ] rb = new long [ n + 1 ] , cb = new long [ n + 1 ] ; for ( int i : rSum ) rb [ i ] ++ ; for ( int i : cSum ) cb [ i ] ++ ; System . out . println ( java . util . stream . IntStream . rangeClosed ( 0 , k ) . mapToLong ( i -> rb [ i ] * cb [ k - i ] ) . sum ( ) + java . util . stream . IntStream . range ( 0 , n ) . map ( i -> rSum [ ra [ i ] ] + cSum [ ca [ i ] ] - k ) . map ( i -> ( i == 0 ? - 1 : i == 1 ? 1 : 0 ) ) . sum ( ) ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String [ ] rck = scanner . nextLine ( ) . split ( " ▁ " , 3 ) ; int R = Integer . parseInt ( rck [ 0 ] ) ; int C = Integer . parseInt ( rck [ 1 ] ) ; int K = Integer . parseInt ( rck [ 2 ] ) ; int N = Integer . parseInt ( scanner . nextLine ( ) ) ; int [ ] countPerR = new int [ R + 1 ] ; int [ ] countPerC = new int [ C + 1 ] ; int [ ] Rs = new int [ N ] ; int [ ] Cs = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { String [ ] rc = scanner . nextLine ( ) . split ( " ▁ " , 2 ) ; int r = Integer . parseInt ( rc [ 0 ] ) ; int c = Integer . parseInt ( rc [ 1 ] ) ; countPerR [ r ] ++ ; countPerC [ c ] ++ ; Rs [ i ] = r ; Cs [ i ] = c ; } long [ ] rPerCount = new long [ N + 1 ] ; for ( int i = 1 ; i <= R ; i ++ ) { rPerCount [ countPerR [ i ] ] ++ ; } long [ ] cPerCount = new long [ N + 1 ] ; for ( int i = 1 ; i <= C ; i ++ ) { cPerCount [ countPerC [ i ] ] ++ ; } long result = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { result += rPerCount [ i ] * cPerCount [ K - i ] ; } for ( int i = 0 ; i < N ; i ++ ) { int r = Rs [ i ] ; int c = Cs [ i ] ; long count = countPerR [ r ] + countPerC [ c ] ; if ( count == K ) { result -- ; } else if ( count == K + 1 ) { result ++ ; } } System . out . println ( result ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int R = scan . nextInt ( ) ; int C = scan . nextInt ( ) ; int K = scan . nextInt ( ) ; int N = scan . nextInt ( ) ; int [ ] [ ] p = new int [ N ] [ 2 ] ; int [ ] row = new int [ R + 1 ] ; int [ ] col = new int [ C + 1 ] ; Arrays . fill ( row , 0 ) ; Arrays . fill ( col , 0 ) ; for ( int i = 0 ; i < N ; i ++ ) { int r = scan . nextInt ( ) ; int c = scan . nextInt ( ) ; p [ i ] [ 0 ] = r ; p [ i ] [ 1 ] = c ; row [ r ] ++ ; col [ c ] ++ ; } scan . close ( ) ; int [ ] row1 = new int [ 100000 + 1 ] ; int [ ] col1 = new int [ 100000 + 1 ] ; Arrays . fill ( row1 , 0 ) ; Arrays . fill ( col1 , 0 ) ; for ( int i = 1 ; i <= R ; i ++ ) { row1 [ row [ i ] ] ++ ; } for ( int i = 1 ; i <= C ; i ++ ) { col1 [ col [ i ] ] ++ ; } long cnt = 0 ; for ( int i = 0 ; i <= K ; i ++ ) { cnt += row1 [ i ] * col1 [ K - i ] ; } for ( int i = 0 ; i < N ; i ++ ) { if ( row [ p [ i ] [ 0 ] ] + col [ p [ i ] [ 1 ] ] == K ) { cnt -- ; } else if ( row [ p [ i ] [ 0 ] ] + col [ p [ i ] [ 1 ] ] == K + 1 ) { cnt ++ ; } } System . out . println ( cnt ) ; } }

import java . util . ArrayList ; import java . util . HashMap ; import java . util . List ; import java . util . Map ; import java . util . Scanner ; class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int r = s . nextInt ( ) , c = s . nextInt ( ) , k = s . nextInt ( ) ; int [ ] cx = new int [ r ] , cy = new int [ c ] , ccx = new int [ k + 1 ] , ccy = new int [ k + 1 ] ; Map < Integer , List < Integer > > p = new HashMap < > ( ) ; for ( int n = s . nextInt ( ) ; n > 0 ; -- n ) { int X = s . nextInt ( ) - 1 , Y = s . nextInt ( ) - 1 ; p . computeIfAbsent ( X , ( i ) -> new ArrayList < > ( ) ) . add ( Y ) ; cx [ X ] ++ ; cy [ Y ] ++ ; } for ( int X : cx ) if ( X < k + 1 ) ccx [ X ] ++ ; for ( int Y : cy ) if ( Y < k + 1 ) ccy [ Y ] ++ ; long res = 0 ; for ( int x = 0 ; x < r ; ++ x ) { int need = k - cx [ x ] ; if ( need < 0 ) continue ; int CY = ccy [ need ] ; if ( p . containsKey ( x ) ) { for ( int y : p . get ( x ) ) { if ( cy [ y ] - 1 == need ) ++ res ; if ( cy [ y ] == need ) -- CY ; } } res += CY ; } System . out . println ( res ) ; } }

r , c , k = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE RC = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( n ) ] NEW_LINE R = [ 0 ] * r NEW_LINE C = [ 0 ] * c NEW_LINE for i in range ( n ) : NEW_LINE INDENT R [ RC [ i ] [ 0 ] - 1 ] += 1 NEW_LINE C [ RC [ i ] [ 1 ] - 1 ] += 1 NEW_LINE DEDENT R2 = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( r ) : NEW_LINE INDENT R2 [ R [ i ] ] += 1 NEW_LINE DEDENT C2 = [ 0 ] * ( n + 1 ) NEW_LINE for i in range ( c ) : NEW_LINE INDENT C2 [ C [ i ] ] += 1 NEW_LINE DEDENT cnt = 0 NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT j = k - i NEW_LINE cnt += R2 [ i ] * C2 [ j ] NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT if R [ RC [ i ] [ 0 ] - 1 ] + C [ RC [ i ] [ 1 ] - 1 ] == k : NEW_LINE INDENT cnt -= 1 NEW_LINE DEDENT if R [ RC [ i ] [ 0 ] - 1 ] + C [ RC [ i ] [ 1 ] - 1 ] == k + 1 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT print ( cnt ) NEW_LINE

import sys NEW_LINE import collections NEW_LINE import itertools NEW_LINE def parse_input ( input_lines ) : NEW_LINE INDENT return tuple ( map ( lambda sl : tuple ( map ( int , sl ) ) , map ( lambda s : s . strip ( ) . split ( ) , input_lines ) ) ) NEW_LINE DEDENT def main ( R , C , K , set_candies ) : NEW_LINE INDENT r_candies = [ 0 ] * R NEW_LINE c_candies = [ 0 ] * C NEW_LINE for i , ( r , c ) in enumerate ( set_candies ) : NEW_LINE INDENT r_candies [ r - 1 ] += 1 NEW_LINE c_candies [ c - 1 ] += 1 NEW_LINE DEDENT r_sums = collections . Counter ( r_candies ) NEW_LINE c_sums = collections . Counter ( c_candies ) NEW_LINE count = 0 NEW_LINE for i in range ( K + 1 ) : NEW_LINE INDENT count += r_sums [ i ] * c_sums [ K - i ] NEW_LINE DEDENT for r , c in set_candies : NEW_LINE INDENT got_candies = r_candies [ r - 1 ] + c_candies [ c - 1 ] NEW_LINE if got_candies == K : NEW_LINE INDENT count -= 1 NEW_LINE DEDENT if got_candies == K + 1 : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT return count NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT ( R , C , K ) , _ , * set_candies = parse_input ( sys . stdin . readlines ( ) ) NEW_LINE print ( main ( R , C , K , set_candies ) ) NEW_LINE DEDENT

from collections import Counter NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE R , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE N = int ( input ( ) ) NEW_LINE X = [ 0 ] * R NEW_LINE Y = [ 0 ] * C NEW_LINE pos = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b = map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) NEW_LINE X [ a ] += 1 NEW_LINE Y [ b ] += 1 NEW_LINE pos . append ( [ a , b ] ) NEW_LINE DEDENT Cx = Counter ( X ) NEW_LINE Cy = Counter ( Y ) NEW_LINE ans = 0 NEW_LINE for i in range ( 0 , K + 1 ) : NEW_LINE INDENT ans += Cx [ i ] * Cy [ K - i ] NEW_LINE DEDENT for x , y in pos : NEW_LINE INDENT if X [ x ] + Y [ y ] == K : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT elif X [ x ] + Y [ y ] == K + 1 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

import bisect NEW_LINE from collections import defaultdict NEW_LINE r , c , k = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE cnt_row = [ 0 for i in range ( r ) ] NEW_LINE cnt_col = [ 0 for i in range ( c ) ] NEW_LINE pos_ame = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT pos_row , pos_col = map ( int , input ( ) . split ( ) ) NEW_LINE cnt_row [ pos_row - 1 ] += 1 NEW_LINE cnt_col [ pos_col - 1 ] -= 1 NEW_LINE pos_ame . append ( [ pos_row - 1 , pos_col - 1 ] ) NEW_LINE DEDENT srtd_cnt_row = sorted ( cnt_row ) NEW_LINE srtd_cnt_col = sorted ( cnt_col ) NEW_LINE ans = 0 NEW_LINE left_r = 0 NEW_LINE left_c = bisect . bisect_right ( srtd_cnt_col , - ( k + 1 ) ) NEW_LINE for i in range ( k + 1 ) : NEW_LINE INDENT right_r = bisect . bisect_right ( srtd_cnt_row , i , left_r ) NEW_LINE right_c = bisect . bisect_right ( srtd_cnt_col , - k + i , left_c ) NEW_LINE ans = ans + ( right_r - left_r ) * ( right_c - left_c ) NEW_LINE left_r = right_r NEW_LINE left_c = right_c NEW_LINE DEDENT for i , j in pos_ame : NEW_LINE INDENT if cnt_row [ i ] - cnt_col [ j ] == k : NEW_LINE INDENT ans -= 1 NEW_LINE DEDENT elif cnt_row [ i ] - cnt_col [ j ] == k + 1 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

def main ( ) : NEW_LINE INDENT rows , cols , k = map ( int , input ( ) . split ( ) ) NEW_LINE n = int ( input ( ) ) NEW_LINE candies = [ ] NEW_LINE for _ in range ( n ) : NEW_LINE INDENT r , c = map ( int , input ( ) . split ( ) ) NEW_LINE candies . append ( ( r - 1 , c - 1 ) ) NEW_LINE DEDENT print ( solve ( rows , cols , k , candies ) ) NEW_LINE DEDENT def solve ( rows , cols , k , candies ) : NEW_LINE INDENT row_c = count ( ( c [ 0 ] for c in candies ) , rows ) NEW_LINE col_c = count ( ( c [ 1 ] for c in candies ) , cols ) NEW_LINE row_cc = count ( row_c . values ( ) , cols + 1 ) NEW_LINE col_cc = count ( col_c . values ( ) , rows + 1 ) NEW_LINE cnt = 0 NEW_LINE for i in range ( k + 1 ) : NEW_LINE INDENT cnt += row_cc . get ( i , 0 ) * col_cc . get ( k - i , 0 ) NEW_LINE DEDENT for r , c in candies : NEW_LINE INDENT x = row_c [ r ] + col_c [ c ] NEW_LINE if x == k : NEW_LINE INDENT cnt -= 1 NEW_LINE DEDENT elif x == k + 1 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT def count ( items , m ) : NEW_LINE INDENT cnt = dict ( ( i , 0 ) for i in range ( m ) ) NEW_LINE for v in items : NEW_LINE INDENT cnt [ v ] = cnt . get ( v , 0 ) + 1 NEW_LINE DEDENT return cnt NEW_LINE DEDENT main ( ) NEW_LINE


import java . util . * ; import java . util . stream . * ; public class Main { public static void main ( String [ ] $ ) { Scanner s = new Scanner ( System . in ) ; int n = s . nextInt ( ) ; long x = s . nextInt ( ) ; long [ ] [ ] a = new long [ n ] [ n ] ; Arrays . setAll ( a [ 0 ] , i -> s . nextLong ( ) ) ; for ( int j = 0 ; j < n ; ++ j ) { for ( int i = 1 ; i < n ; ++ i ) { a [ i ] [ j ] = Math . min ( a [ i - 1 ] [ j ] , a [ 0 ] [ ( j - i + n ) % n ] ) ; } } System . out . println ( IntStream . range ( 0 , n ) . mapToLong ( i -> i * x + Arrays . stream ( a [ i ] ) . sum ( ) ) . min ( ) . getAsLong ( ) ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . stream . LongStream ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; BColorfulSlimes solver = new BColorfulSlimes ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class BColorfulSlimes { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int n = in . nextInt ( ) ; long x = in . nextLong ( ) ; long [ ] [ ] a = new long [ n ] [ n ] ; a [ 0 ] = LongStream . range ( 0 , n ) . map ( z -> in . nextInt ( ) ) . toArray ( ) ; long ans = LongStream . of ( a [ 0 ] ) . sum ( ) ; for ( int k = 1 ; k < n ; k ++ ) { for ( int i = 0 ; i < n ; i ++ ) { a [ k ] [ i ] = Math . min ( a [ k - 1 ] [ ( i + n - 1 ) % n ] , a [ 0 ] [ i ] ) ; } ans = Math . min ( ans , LongStream . of ( a [ k ] ) . sum ( ) + k * x ) ; } out . println ( ans ) ; } } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { int n ; long x ; long [ ] as ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; x = sc . nextLong ( ) ; as = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { as [ i ] = sc . nextLong ( ) ; } long [ ] [ ] b = new long [ 2 ] [ n ] ; Arrays . fill ( b [ 0 ] , 1L << 50 ) ; int idx = 1 ; long ans = 1L << 50 ; for ( int k = 0 ; k < n ; k ++ ) { long sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { b [ idx ] [ i ] = Math . min ( b [ 1 - idx ] [ i ] , as [ ( i + n - k ) % n ] ) ; sum += b [ idx ] [ i ] ; } ans = Math . min ( ans , k * x + sum ) ; idx = 1 - idx ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }

import java . util . Scanner ; import java . util . Collections ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Queue ; import java . util . ArrayDeque ; import java . util . Deque ; import java . util . PriorityQueue ; import java . util . Set ; import java . util . HashMap ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int x = scanner . nextInt ( ) ; int INF = Integer . MAX_VALUE ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; } int [ ] b = new int [ n ] ; Arrays . fill ( b , INF ) ; long ans = Long . MAX_VALUE ; for ( int magic = 0 ; magic < n ; magic ++ ) { long s = ( long ) magic * x ; for ( int i = 0 ; i < n ; i ++ ) { b [ i ] = Math . min ( b [ i ] , a [ ( i + n - magic ) % n ] ) ; s += b [ i ] ; } ans = Math . min ( ans , s ) ; } System . out . println ( ans ) ; } }

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 ( ) ; long x = sc . nextLong ( ) ; long [ ] a = new long [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } long [ ] [ ] partmin = new long [ N + 1 ] [ N + 1 ] ; for ( int i = 1 ; i <= N ; i ++ ) { for ( int j = i ; j <= N + i - 1 ; j ++ ) { if ( i == j ) { partmin [ i ] [ j ] = a [ i ] ; } else { int k = ( j - 1 ) % N + 1 ; if ( k != 1 ) { partmin [ i ] [ k ] = Math . min ( partmin [ i ] [ k - 1 ] , a [ k ] ) ; } else { partmin [ i ] [ k ] = Math . min ( partmin [ i ] [ N ] , a [ 1 ] ) ; } } } } long min = 1000000000 ; min = min * min ; for ( long i = 0 ; i < N ; i ++ ) { long cost = i * x ; for ( int j = 1 ; j <= N ; j ++ ) { cost += partmin [ ( int ) ( N + j - i - 1 ) % N + 1 ] [ j ] ; } min = Math . min ( min , cost ) ; } System . out . println ( min ) ; } }

def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE import numpy as np NEW_LINE N , x = inpl ( ) NEW_LINE a = np . array ( inpl ( ) ) NEW_LINE b = np . copy ( a ) NEW_LINE ans = float ( ' inf ' ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT c = np . roll ( a , i ) NEW_LINE b = np . minimum ( b , c ) NEW_LINE ans = min ( ans , sum ( b ) + i * x ) NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE input = sys . stdin . readline NEW_LINE n , x = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE T = A [ : ] NEW_LINE ans = sum ( T ) NEW_LINE for j in range ( 1 , n ) : NEW_LINE INDENT T = [ min ( T [ i ] , A [ i - j ] ) for i in range ( n ) ] NEW_LINE ans = min ( ans , sum ( T ) + x * j ) NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def 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 def main ( ) : NEW_LINE INDENT n , x = LI ( ) NEW_LINE A = LI ( ) NEW_LINE min_a , min_i = INF , - 1 NEW_LINE res = 0 NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT if a < min_a : NEW_LINE INDENT min_a = a NEW_LINE min_i = i NEW_LINE DEDENT res += a NEW_LINE DEDENT A = A [ min_i : ] + A [ : min_i ] NEW_LINE dp = [ INF ] + A NEW_LINE for k in range ( n - 1 ) : NEW_LINE INDENT tmp = 0 NEW_LINE for i in range ( n ) [ : : - 1 ] : NEW_LINE INDENT if dp [ i + 1 ] > dp [ i ] : NEW_LINE INDENT dp [ i + 1 ] = dp [ i ] NEW_LINE DEDENT tmp += dp [ i + 1 ] NEW_LINE DEDENT res = min ( res , tmp + ( k + 1 ) * x ) NEW_LINE DEDENT return res NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

N , x = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE A = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE ans = sum ( A ) NEW_LINE for k in range ( 1 , N + 1 ) : NEW_LINE INDENT A = [ min ( i , j ) for i , j in zip ( A , A [ 1 : ] + [ A [ 0 ] ] ) ] NEW_LINE ans = min ( ans , x * k + sum ( A ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE

N , x = map ( int , input ( ) . split ( ) ) NEW_LINE a_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ex_list = a_list . copy ( ) NEW_LINE ex_list . extend ( a_list ) NEW_LINE ans = float ( " inf " ) NEW_LINE cost_list = [ float ( " inf " ) for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT cost = 0 NEW_LINE for j in range ( N ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT cost += ex_list [ N + j ] NEW_LINE cost_list [ j ] = ex_list [ N + j ] NEW_LINE DEDENT else : NEW_LINE INDENT tmp = cost_list [ j ] NEW_LINE if tmp > ex_list [ N - i + j ] : NEW_LINE INDENT cost_list [ j ] = ex_list [ N - i + j ] NEW_LINE cost += ex_list [ N - i + j ] NEW_LINE DEDENT else : NEW_LINE INDENT cost += tmp NEW_LINE DEDENT DEDENT DEDENT cost += x * i NEW_LINE ans = min ( ans , cost ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . text . ParseException ; import java . text . SimpleDateFormat ; import java . util . Date ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . nextLine ( ) ; SimpleDateFormat sdf = new SimpleDateFormat ( " yyyy / MM / dd " ) ; Date date1 = null ; Date date2 = null ; try { date1 = sdf . parse ( S ) ; date2 = sdf . parse ( "2019/04/30" ) ; } catch ( ParseException e ) { e . printStackTrace ( ) ; } if ( date1 . compareTo ( date2 ) == - 1 || date1 . compareTo ( date2 ) == 0 ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } }

import java . io . PrintWriter ; import java . util . ArrayList ; import java . util . Collections ; import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner scan = new Scanner ( System . in ) ; String b = scan . next ( ) ; String ans = null ; if ( Integer . parseInt ( b . replaceAll ( " / " , " " ) ) > 20190430 ) { ans = " TBD " ; } else { ans = " Heisei " ; } PrintWriter out = new PrintWriter ( System . out ) ; out . println ( ans ) ; out . flush ( ) ; scan . close ( ) ; } }

import java . time . LocalDate ; import java . time . format . DateTimeFormatter ; import java . time . format . ResolverStyle ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String S = scanner . next ( ) ; scanner . close ( ) ; DateTimeFormatter formatter = DateTimeFormatter . ofPattern ( " yyyy / MM / dd " ) ; formatter . withResolverStyle ( ResolverStyle . LENIENT ) ; LocalDate tDate = LocalDate . parse ( "2019/04/30" , formatter ) ; LocalDate ldt = LocalDate . parse ( S , formatter ) ; if ( ldt . isEqual ( tDate ) || ldt . isBefore ( tDate ) ) { System . out . println ( " Heisei " ) ; } else { System . out . println ( " TBD " ) ; } } }

import java . text . ParseException ; import java . text . SimpleDateFormat ; import java . util . Calendar ; import java . util . Date ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws ParseException { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String h = " Heisei " ; String t = " TBD " ; Calendar c = Calendar . getInstance ( ) ; SimpleDateFormat f = new SimpleDateFormat ( " yyyy / MM / dd " ) ; Date d = f . parse ( "2019/05/01" ) ; if ( f . parse ( s ) . before ( d ) ) System . out . println ( h ) ; else System . out . println ( t ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskAtCoder119 solver = new TaskAtCoder119 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskAtCoder119 { public void solve ( int testNumber , Scanner in , PrintWriter out ) { if ( in . next ( ) . compareTo ( "2019/04/30" ) <= 0 ) out . println ( " Heisei " ) ; else out . println ( " TBD " ) ; } } }

s = int ( input ( ) . replace ( " / " , " " ) ) NEW_LINE print ( " Heisei " if s <= 20190430 else " TBD " ) NEW_LINE

i = input ( ) NEW_LINE x = [ s . strip ( ) for s in i . split ( ' / ' ) ] NEW_LINE if int ( x [ 0 ] ) < 2019 : NEW_LINE INDENT print ( ' Heisei ' ) NEW_LINE DEDENT elif int ( x [ 0 ] ) == 2019 : NEW_LINE INDENT if int ( x [ 1 ] ) < 5 : NEW_LINE INDENT print ( ' Heisei ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' TBD ' ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' TBD ' ) NEW_LINE DEDENT

print ( ' Heisei ' if input ( ) <= '2019/04/30' else ' TBD ' ) NEW_LINE

S = str ( input ( ) ) NEW_LINE def checker ( y , m , d ) : NEW_LINE INDENT if y < 2019 : return ' Heisei ' NEW_LINE if y > 2019 : return ' Heisei ' NEW_LINE if m in [ 1 , 2 , 3 , 4 ] : return ' Heisei ' NEW_LINE return ' TBD ' NEW_LINE DEDENT y , m , d = map ( int , S . split ( ' / ' ) ) NEW_LINE print ( checker ( y , m , d ) ) NEW_LINE

from datetime import datetime as dt NEW_LINE date = input ( ) NEW_LINE new_date = dt . strptime ( date , ' % Y / % m / % d ' ) NEW_LINE if new_date <= dt ( 2019 , 4 , 30 ) : NEW_LINE INDENT print ( ' Heisei ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' TBD ' ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int N = in . nextInt ( ) ; int K = in . nextInt ( ) ; String S = in . next ( ) ; HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; String [ ] s = new String [ N - K + 1 ] ; int [ ] arr = new int [ 26 ] ; for ( int i = 0 ; i <= N - K ; i ++ ) { if ( i == 0 ) { for ( int j = 0 ; j <= N ; j ++ ) { arr [ S . charAt ( i ) - ' a ' ] ++ ; } } else { arr [ S . charAt ( i - 1 ) - ' a ' ] -- ; arr [ S . charAt ( i + K - 1 ) - ' a ' ] ++ ; } s [ i ] = Arrays . toString ( arr ) ; if ( map . containsKey ( s [ i ] ) ) { map . put ( s [ i ] , Math . max ( map . get ( s [ i ] ) , i ) ) ; } else { map . put ( s [ i ] , i ) ; } } for ( int i = 0 ; i <= N - K ; i ++ ) { if ( map . get ( s [ i ] ) - i >= K ) { System . out . println ( " YES " ) ; return ; } } System . out . println ( " NO " ) ; } }

import java . util . * ; public class Main { private static int N ; private static int K ; private static String S ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextInt ( ) ; K = scan . nextInt ( ) ; S = scan . next ( ) ; } public static void main ( String args [ ] ) { input ( ) ; HashMap < String , Integer > map = new HashMap < String , Integer > ( ) ; String [ ] s = new String [ N - K + 1 ] ; int [ ] arr = new int [ 26 ] ; for ( int i = 0 ; i <= N - K ; i ++ ) { if ( i == 0 ) { for ( int j = 0 ; j < N ; j ++ ) arr [ S . charAt ( j ) - ' a ' ] ++ ; } else { arr [ S . charAt ( i - 1 ) - ' a ' ] -- ; arr [ S . charAt ( i + K - 1 ) - ' a ' ] ++ ; } s [ i ] = Arrays . toString ( arr ) ; if ( map . containsKey ( s [ i ] ) ) map . put ( s [ i ] , Math . max ( map . get ( s [ i ] ) , i ) ) ; else map . put ( s [ i ] , i ) ; } for ( int i = 0 ; i <= N - K ; i ++ ) { if ( map . get ( s [ i ] ) - i >= K ) { System . out . println ( " YES " ) ; return ; } } System . out . println ( " NO " ) ; } }

n , k = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE s = input ( ) NEW_LINE if n < k * 2 : print ( " NO " ) NEW_LINE else : NEW_LINE INDENT x , t = [ ] , [ 0 ] * 26 NEW_LINE for i in range ( k ) : t [ ord ( s [ i ] ) - 97 ] += 1 NEW_LINE x . append ( ( tuple ( t ) , k - 1 ) ) NEW_LINE for i in range ( k , n ) : NEW_LINE INDENT t [ ord ( s [ i - k ] ) - 97 ] -= 1 NEW_LINE t [ ord ( s [ i ] ) - 97 ] += 1 NEW_LINE x . append ( ( tuple ( t ) , i ) ) NEW_LINE DEDENT x , i , f = sorted ( x ) , 0 , 0 NEW_LINE while i < n - k : NEW_LINE INDENT for j in range ( i + 1 , n - k + 1 ) : NEW_LINE INDENT if x [ i ] [ 0 ] != x [ j ] [ 0 ] : NEW_LINE INDENT i = j NEW_LINE break NEW_LINE DEDENT elif x [ j ] [ 1 ] - x [ i ] [ 1 ] >= k : NEW_LINE INDENT f = 1 NEW_LINE break NEW_LINE DEDENT elif j == n - k : i = n - k NEW_LINE DEDENT if f : break NEW_LINE DEDENT if f : print ( " YES " ) NEW_LINE else : print ( " NO " ) NEW_LINE DEDENT

import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 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 I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n , k = LI ( ) NEW_LINE s = [ ord ( c ) - 97 for c in S ( ) ] NEW_LINE ts = [ 0 ] * 26 NEW_LINE d = collections . defaultdict ( int ) NEW_LINE for i in range ( k - 1 ) : NEW_LINE INDENT ts [ s [ i ] ] += 1 NEW_LINE DEDENT for i in range ( n - k + 1 ) : NEW_LINE INDENT if i > 0 : NEW_LINE INDENT ts [ s [ i - 1 ] ] -= 1 NEW_LINE DEDENT ts [ s [ i + k - 1 ] ] += 1 NEW_LINE t = tuple ( ts ) NEW_LINE if d [ t ] == 0 : NEW_LINE INDENT d [ t ] = i + 1 NEW_LINE DEDENT elif d [ t ] + k <= i + 1 : NEW_LINE INDENT return ' YES ' NEW_LINE DEDENT DEDENT return ' NO ' NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

def solve ( ) : NEW_LINE INDENT from collections import deque NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE S = [ 10 ** ( ( ord ( c ) - 97 ) * 5 ) for c in input ( ) ] NEW_LINE if N // 2 < K : NEW_LINE INDENT print ( " NO " ) NEW_LINE exit ( ) NEW_LINE DEDENT substring = set ( ) NEW_LINE dq = deque ( ) NEW_LINE add , append , popleft = substring . add , dq . append , dq . popleft NEW_LINE subtotal = sum ( S [ N - K : ] ) NEW_LINE append ( subtotal ) NEW_LINE for n1 , n2 in zip ( S [ N - K - 1 : N - 2 * K : - 1 ] , S [ : : - 1 ] ) : NEW_LINE INDENT subtotal += n1 - n2 NEW_LINE append ( subtotal ) NEW_LINE DEDENT for n1 , n2 in zip ( S [ N - 2 * K : : - 1 ] , S [ N - K : : - 1 ] ) : NEW_LINE INDENT add ( popleft ( ) ) NEW_LINE subtotal += n1 - n2 NEW_LINE if subtotal in substring : NEW_LINE INDENT print ( " YES " ) NEW_LINE exit ( ) NEW_LINE DEDENT append ( subtotal ) NEW_LINE DEDENT print ( " NO " ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT

from collections import defaultdict , Counter NEW_LINE from string import ascii_lowercase NEW_LINE N , K = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE S = input ( ) NEW_LINE counts = [ ] NEW_LINE tmp_counter = Counter ( S [ : K ] ) NEW_LINE def set_count ( tmp_counter , _index ) : NEW_LINE INDENT counts . append ( tuple ( tmp_counter [ s ] for s in ascii_lowercase ) + ( _index , ) ) NEW_LINE DEDENT set_count ( tmp_counter , 0 ) NEW_LINE for i in range ( N - K ) : NEW_LINE INDENT s_exclude = S [ i ] NEW_LINE s_add = S [ i + K ] NEW_LINE tmp_counter [ s_exclude ] -= 1 NEW_LINE tmp_counter [ s_add ] += 1 NEW_LINE set_count ( tmp_counter , i + 1 ) NEW_LINE DEDENT counts . sort ( ) NEW_LINE tmp_count = counts [ 0 ] NEW_LINE for count in ( counts [ 1 : ] ) : NEW_LINE INDENT if tmp_count [ : 26 ] == count [ : 26 ] : NEW_LINE INDENT if count [ 26 ] - tmp_count [ 26 ] >= K : NEW_LINE INDENT print ( " YES " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT tmp_count = count NEW_LINE DEDENT DEDENT print ( " NO " ) NEW_LINE

N , K = map ( int , input ( ) . strip ( ) . split ( ) ) NEW_LINE S = input ( ) . strip ( ) NEW_LINE def ctoi ( c ) : NEW_LINE INDENT return ord ( c ) - ord ( ' a ' ) NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT if K * 2 > N : return False NEW_LINE ctr = [ 0 for i in range ( 26 ) ] NEW_LINE hs = { } NEW_LINE for i in range ( N ) : NEW_LINE INDENT ctr [ ctoi ( S [ i ] ) ] += 1 NEW_LINE if i < K - 1 : continue NEW_LINE if i >= K : NEW_LINE INDENT ctr [ ctoi ( S [ i - K ] ) ] -= 1 NEW_LINE DEDENT h = tuple ( ctr ) NEW_LINE st = i - K + 1 NEW_LINE if h in hs : NEW_LINE INDENT if hs [ h ] + K <= st : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT hs [ h ] = st NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT if solve ( ) : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT


import java . math . BigDecimal ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int x1 = Integer . parseInt ( sc . next ( ) ) ; ArrayList < Integer > aaa = new ArrayList < Integer > ( ) ; String answer = null ; for ( int h = 0 ; h < x1 ; h ++ ) { aaa . add ( Integer . parseInt ( sc . next ( ) ) ) ; } Collections . sort ( aaa ) ; System . out . println ( aaa . get ( 0 ) ) ; System . out . flush ( ) ; sc . close ( ) ; } }

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 ( ) ; int ans = 100 ; for ( int i = 0 ; i < n ; i ++ ) { ans = Math . min ( ans , sc . nextInt ( ) ) ; } System . out . println ( ans ) ; } }

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

import java . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { try { Scanner sc = new Scanner ( System . in ) ; int n ; n = Integer . parseInt ( sc . next ( ) ) ; int [ ] t = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { t [ i ] = Integer . parseInt ( sc . next ( ) ) ; } Arrays . sort ( t ) ; System . out . println ( t [ 0 ] ) ; } catch ( Exception e ) { System . out . println ( " out " ) ; } } }

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

N = int ( input ( ) ) NEW_LINE all1 = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT all1 . append ( int ( input ( ) ) ) NEW_LINE DEDENT print ( min ( all1 ) ) NEW_LINE

_ , * t = map ( int , open ( 0 ) ) ; print ( min ( t ) ) NEW_LINE

n = int ( input ( ) ) NEW_LINE t = [ int ( input ( ) ) for i in range ( n ) ] NEW_LINE t = sorted ( t ) NEW_LINE print ( t [ 0 ] ) NEW_LINE

import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE e = [ [ int ( i ) for i in input ( ) . split ( ) ] for i in range ( N ) ] NEW_LINE e = np . array ( [ i [ 0 ] for i in e ] ) NEW_LINE print ( e [ e . argmin ( ) ] ) NEW_LINE

n = int ( input ( ) ) NEW_LINE ans = 100 NEW_LINE for i in range ( n ) : NEW_LINE INDENT temp = int ( input ( ) ) NEW_LINE ans = min ( ans , temp ) NEW_LINE DEDENT print ( ans ) NEW_LINE


import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long a = sc . nextLong ( ) ; long b = sc . nextLong ( ) ; long c = sc . nextLong ( ) ; long k = sc . nextLong ( ) ; if ( k % 2 == 0 ) { System . out . println ( a - b ) ; } else { System . out . println ( b - a ) ; } } }

import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; int c = in . nextInt ( ) ; long k = in . nextLong ( ) ; int x = k % 2 == 0 ? a - b : b - a ; out . println ( x ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( " End ▁ of ▁ Input " ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }

import java . util . * ; import java . awt . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; if ( K % 2 == 0 ) { System . out . println ( A - B ) ; } else { System . out . println ( B - A ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int C = sc . nextInt ( ) ; Long K = sc . nextLong ( ) ; int ans = 0 ; if ( K % 2 == 1 ) { ans = B - A ; } else { ans = A - B ; } System . out . println ( ans ) ; } }

import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int a = sc . nextInt ( ) , b = sc . nextInt ( ) , c = sc . nextInt ( ) ; long k = sc . nextLong ( ) ; System . out . println ( k % 2 == 1 ? b - a : a - b ) ; } }

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT a , b , c , k = LI ( ) NEW_LINE return b - a if k % 2 else a - b NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

A , B , C , K = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE if ( K % 2 ) : NEW_LINE INDENT print ( B - A ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( A - B ) NEW_LINE DEDENT

import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE a , b , c , k = li ( ) NEW_LINE if k % 2 : NEW_LINE INDENT print ( b - a ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( a - b ) NEW_LINE DEDENT

a , b , c , k = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( a - b ) * ( - 1 ) ** ( k ) ) NEW_LINE

import sys NEW_LINE input = sys . stdin . readline NEW_LINE A , B , C , K = map ( int , input ( ) . split ( ) ) NEW_LINE ans = ( - 1 ) ** K * ( A - B ) NEW_LINE print ( ans if abs ( ans ) <= 10 ** 18 else ' Unfair ' ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; int A = String . valueOf ( N ) . length ( ) ; int B = 10 ; int have = N ; int sum = 0 ; for ( int i = 0 ; i < ( A - 2 ) ; i ++ ) { B *= 10 ; } if ( N % B == 0 ) { sum = 10 ; System . out . println ( sum ) ; System . exit ( 0 ) ; } sum = N / B ; for ( ; ; ) { have = have - ( have / B ) * B ; B /= 10 ; if ( B == 0 ) { break ; } sum += have / B ; } System . out . println ( sum ) ; } }

import java . io . * ; import java . util . * ; public class Main { static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { try { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } public String next ( ) { if ( st . hasMoreTokens ( ) ) return st . nextToken ( ) ; try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return st . 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 ( ) { String line = " " ; if ( st . hasMoreTokens ( ) ) line = st . nextToken ( ) ; else try { return br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } while ( st . hasMoreTokens ( ) ) line += " ▁ " + st . nextToken ( ) ; return line ; } } static int mod = 1000000007 ; static long oo = Long . MAX_VALUE ; public static boolean pow10 ( int v ) { while ( v > 1 && v % 10 == 0 ) v /= 10 ; return v == 1 ; } public static int digSum ( int v ) { if ( v < 10 ) return v ; else return ( v % 10 ) + digSum ( v / 10 ) ; } public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; int n = sc . nextInt ( ) ; if ( pow10 ( n ) ) pw . println ( 10 ) ; else pw . println ( digSum ( n ) ) ; pw . close ( ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String [ ] n = sc . next ( ) . split ( " " ) ; int sum = Arrays . stream ( n ) . mapToInt ( Integer :: parseInt ) . sum ( ) ; System . out . println ( sum == 1 ? 10 : sum ) ; } }

import java . net . StandardSocketOptions ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Collections ; import java . util . PriorityQueue ; import java . util . Scanner ; import java . util . TreeSet ; import org . omg . Messaging . SyncScopeHelper ; import org . omg . PortableInterceptor . SYSTEM_EXCEPTION ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_200 ( ) . doIt ( ) ; } class Test_200 { void doIt ( ) { int Wa [ ] = new int [ 100001 ] ; Pa_10 ( Wa ) ; int ans = Integer . MAX_VALUE ; int N = sc . nextInt ( ) ; for ( int i = 1 ; i <= N / 2 ; i ++ ) { ans = Math . min ( ans , Wa [ N - i ] + Wa [ i ] ) ; } System . out . println ( ans ) ; } void Pa_10 ( int Wa [ ] ) { for ( int i = 0 ; i <= 100000 ; i ++ ) { Wa [ i ] = i % 10 ; Wa [ i ] = Wa [ i ] + ( ( i / 10 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 100 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 1000 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 10000 ) % 10 ) ; Wa [ i ] = Wa [ i ] + ( ( i / 100000 ) % 10 ) ; } } } }

import java . io . PrintStream ; import java . util . Scanner ; import java . util . stream . Stream ; public class Main { static void exec ( Scanner in , PrintStream out ) { String N = in . next ( ) ; if ( N . length ( ) == 1 ) { out . println ( N ) ; return ; } if ( N . substring ( 0 , 2 ) . equals ( "10" ) ) { int sum = 10 ; if ( N . length ( ) > 2 ) { sum += Stream . of ( N . substring ( 2 ) . split ( " " ) ) . mapToInt ( Integer :: valueOf ) . sum ( ) ; } out . println ( sum ) ; } else { int sum = Stream . of ( N . split ( " " ) ) . mapToInt ( Integer :: valueOf ) . sum ( ) ; out . println ( sum ) ; } } public static void main ( String [ ] args ) { exec ( new Scanner ( System . in ) , System . out ) ; } }

N = int ( input ( ) ) NEW_LINE def sum_digit ( n ) : NEW_LINE INDENT s = 0 NEW_LINE while n > 0 : NEW_LINE INDENT s += n % 10 NEW_LINE n //= 10 NEW_LINE DEDENT return s NEW_LINE DEDENT min_sum = 9 * 10 NEW_LINE for x in range ( 1 , N // 2 + 1 ) : NEW_LINE INDENT min_sum = min ( min_sum , sum_digit ( x ) + sum_digit ( N - x ) ) NEW_LINE DEDENT print ( min_sum ) NEW_LINE

NL = [ int ( x ) for x in str ( input ( ) ) ] NEW_LINE if NL [ 0 ] == 1 and sum ( NL ) == 1 : NEW_LINE INDENT print ( 10 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( sum ( NL ) ) NEW_LINE DEDENT

import math NEW_LINE n = int ( input ( ) ) NEW_LINE ns = list ( str ( n ) ) NEW_LINE if ( math . log10 ( n ) == float ( len ( ns ) - 1 ) ) : print ( 10 ) NEW_LINE else : print ( sum ( [ int ( ns [ i ] ) for i in range ( len ( ns ) ) ] ) ) NEW_LINE

import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE ans = np . Inf NEW_LINE for i in range ( 1 , int ( n / 2 + 1 ) ) : NEW_LINE INDENT a = str ( i ) NEW_LINE b = str ( n - i ) NEW_LINE an = 0 NEW_LINE for j in range ( len ( a ) ) : NEW_LINE INDENT an += int ( a [ j ] ) NEW_LINE DEDENT for k in range ( len ( b ) ) : NEW_LINE INDENT an += int ( b [ k ] ) NEW_LINE DEDENT if an < ans : NEW_LINE INDENT ans = an NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

N = int ( input ( ) ) NEW_LINE min_ = 100000 NEW_LINE for i in range ( 1 , N // 2 + 1 ) : NEW_LINE INDENT j = N - i NEW_LINE sum_i = 0 NEW_LINE sum_j = 0 NEW_LINE tmp_i = i NEW_LINE tmp_j = j NEW_LINE while tmp_i > 0 : NEW_LINE INDENT sum_i += tmp_i % 10 NEW_LINE tmp_i = tmp_i // 10 NEW_LINE DEDENT while tmp_j > 0 : NEW_LINE INDENT sum_j += tmp_j % 10 NEW_LINE tmp_j = tmp_j // 10 NEW_LINE DEDENT min_ = min ( min_ , sum_i + sum_j ) NEW_LINE DEDENT print ( min_ ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] X = new long [ N ] ; long [ ] Y = new long [ N ] ; long [ ] Z = new long [ N ] ; int [ ] sg = { 1 , - 1 } ; for ( int i = 0 ; i < N ; i ++ ) { X [ i ] = sc . nextLong ( ) ; Y [ i ] = sc . nextLong ( ) ; Z [ i ] = sc . nextLong ( ) ; } long ans = 0 ; long [ ] S = new long [ N ] ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { for ( int k = 0 ; k < 2 ; k ++ ) { long ans2 = 0 ; for ( int l = 0 ; l < N ; l ++ ) { S [ l ] = X [ l ] * sg [ i ] + Y [ l ] * sg [ j ] + Z [ l ] * sg [ k ] ; } Arrays . sort ( S ) ; for ( int l = N - 1 ; l > N - M - 1 ; l -- ) ans2 += S [ l ] ; ans = Math . max ( ans , ans2 ) ; } } } System . out . println ( ans ) ; } }

import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int [ ] a = { 1 , 1 , 1 , 1 , - 1 , - 1 , - 1 , - 1 } ; int [ ] b = { 1 , 1 , - 1 , - 1 , 1 , 1 , - 1 , - 1 } ; int [ ] c = { 1 , - 1 , 1 , - 1 , 1 , - 1 , 1 , - 1 } ; long kati = Long . MIN_VALUE ; long tmp = Long . MIN_VALUE ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ N ] ; long [ ] z = new long [ N ] ; long [ ] maxes = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; z [ i ] = sc . nextLong ( ) ; } for ( int i = 0 ; i < 8 ; i ++ ) { tmp = 0 ; for ( int j = 0 ; j < N ; j ++ ) { maxes [ j ] = x [ j ] * a [ i ] + y [ j ] * b [ i ] + z [ j ] * c [ i ] ; } Arrays . sort ( maxes ) ; for ( int k = 0 ; k < M ; k ++ ) { tmp += maxes [ N - 1 - k ] ; } kati = Math . max ( kati , tmp ) ; } System . out . println ( kati ) ; } }

import java . util . Scanner ; import java . util . Arrays ; import java . util . Comparator ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; Cake [ ] cake = new Cake [ n ] ; long ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long z = sc . nextLong ( ) ; cake [ i ] = new Cake ( x , y , z ) ; } int [ ] xyz = new int [ 3 ] ; for ( int i = 0 ; i < 8 ; i ++ ) { Arrays . fill ( xyz , 1 ) ; int ii = i ; long an = 0 ; int count = 0 ; while ( ii > 0 ) { if ( ( ii & 1 ) == 1 ) { xyz [ count ] *= - 1 ; } ii >>= 1 ; count ++ ; } for ( int j = 0 ; j < n ; j ++ ) { cake [ j ] . x1 = cake [ j ] . x * xyz [ 0 ] ; cake [ j ] . y1 = cake [ j ] . y * xyz [ 1 ] ; cake [ j ] . z1 = cake [ j ] . z * xyz [ 2 ] ; } Arrays . sort ( cake , Comparator . comparing ( Cake :: getSum ) . reversed ( ) ) ; for ( int k = 0 ; k < m ; k ++ ) { an += cake [ k ] . getSum ( ) ; } ans = Math . max ( ans , an ) ; } System . out . println ( ans ) ; } static class Cake { long x ; long y ; long z ; long x1 ; long y1 ; long z1 ; public Cake ( long x , long y , long z ) { this . x = x ; this . y = y ; this . z = z ; } public long getSum ( ) { return this . x1 + this . y1 + this . z1 ; } } }

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ N ] ; long [ ] z = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { x [ i ] = sc . nextLong ( ) ; y [ i ] = sc . nextLong ( ) ; z [ i ] = sc . nextLong ( ) ; } long ans = Long . MIN_VALUE ; for ( int i = 0 ; i < 1 << 3 ; i ++ ) { Long [ ] values = new Long [ N ] ; for ( int j = 0 ; j < N ; j ++ ) { values [ j ] = add ( x [ j ] , ( i >> 2 & 1 ) == 1 ) + add ( y [ j ] , ( i >> 1 & 1 ) == 1 ) + add ( z [ j ] , ( i >> 0 & 1 ) == 1 ) ; } Arrays . sort ( values , Collections . reverseOrder ( ) ) ; long ans_tmp = 0 ; for ( int j = 0 ; j < M ; j ++ ) { ans_tmp += values [ j ] ; } ans = Math . max ( ans , ans_tmp ) ; } out . println ( ans ) ; } public static long add ( long a , boolean isMaximumPlus ) { if ( isMaximumPlus ) { return a ; } return - a ; } }

import java . util . Comparator ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; long [ ] x = new long [ n ] ; long [ ] y = new long [ n ] ; long [ ] z = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) { x [ i ] = scanner . nextLong ( ) ; y [ i ] = scanner . nextLong ( ) ; z [ i ] = scanner . nextLong ( ) ; } int [ ] scale = { - 1 , 1 } ; long result = 0 ; for ( int a = 0 ; a < 2 ; ++ a ) { for ( int b = 0 ; b < 2 ; ++ b ) { for ( int c = 0 ; c < 2 ; ++ c ) { PriorityQueue < Long > sum = new PriorityQueue < > ( Comparator . reverseOrder ( ) ) ; long currentSum = 0 ; for ( int i = 0 ; i < n ; ++ i ) { long current = scale [ a ] * x [ i ] + scale [ b ] * y [ i ] + scale [ c ] * z [ i ] ; sum . add ( current ) ; } for ( int i = 0 ; i < m ; ++ i ) { currentSum += sum . poll ( ) ; } result = Math . max ( result , currentSum ) ; } } } System . out . println ( result ) ; } }

n , m = map ( int , input ( ) . split ( ) ) NEW_LINE info = [ [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) for i in range ( n ) ] NEW_LINE ans = 0 NEW_LINE for oishi in range ( 2 ) : NEW_LINE INDENT for kirei in range ( 2 ) : NEW_LINE INDENT for ninki in range ( 2 ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT info [ i ] [ 0 ] = ( ( - 1 ) ** kirei ) * info [ i ] [ 1 ] + ( ( - 1 ) ** oishi ) * info [ i ] [ 2 ] + ( ( - 1 ) ** ninki ) * info [ i ] [ 3 ] NEW_LINE DEDENT info = sorted ( info , reverse = True ) NEW_LINE ans_kirei = 0 NEW_LINE ans_oishi = 0 NEW_LINE ans_ninki = 0 NEW_LINE for i in range ( m ) : NEW_LINE INDENT ans_kirei += ( ( - 1 ) ** kirei ) * info [ i ] [ 1 ] NEW_LINE ans_oishi += ( ( - 1 ) ** oishi ) * info [ i ] [ 2 ] NEW_LINE ans_ninki += ( ( - 1 ) ** ninki ) * info [ i ] [ 3 ] NEW_LINE DEDENT ans = max ( ans , ans_kirei + ans_oishi + ans_ninki ) NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE import itertools NEW_LINE def solve ( N : int , M : int , x : " List [ int ] " , y : " List [ int ] " , z : " List [ int ] " ) : NEW_LINE INDENT coef = [ 1 , - 1 ] NEW_LINE cand = itertools . product ( coef , repeat = 3 ) NEW_LINE sumMax = 0 NEW_LINE for can in cand : NEW_LINE INDENT combined = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT combined . append ( can [ 0 ] * x [ i ] + can [ 1 ] * y [ i ] + can [ 2 ] * z [ i ] ) NEW_LINE DEDENT combined . sort ( ) NEW_LINE s = sum ( combined [ : M ] ) NEW_LINE sumMax = max ( sumMax , abs ( s ) ) NEW_LINE DEDENT print ( sumMax ) NEW_LINE return NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT def iterate_tokens ( ) : NEW_LINE INDENT for line in sys . stdin : NEW_LINE INDENT for word in line . split ( ) : NEW_LINE INDENT yield word NEW_LINE DEDENT DEDENT DEDENT tokens = iterate_tokens ( ) NEW_LINE N = int ( next ( tokens ) ) NEW_LINE M = int ( next ( tokens ) ) NEW_LINE x = [ int ( ) ] * ( N ) NEW_LINE y = [ int ( ) ] * ( N ) NEW_LINE z = [ int ( ) ] * ( N ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT x [ i ] = int ( next ( tokens ) ) NEW_LINE y [ i ] = int ( next ( tokens ) ) NEW_LINE z [ i ] = int ( next ( tokens ) ) NEW_LINE DEDENT solve ( N , M , x , y , z ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import sys , re NEW_LINE from collections import deque , defaultdict , Counter NEW_LINE from math import ceil , sqrt , hypot , factorial , pi , sin , cos , radians NEW_LINE from itertools import permutations , combinations , product NEW_LINE from operator import itemgetter , mul NEW_LINE from copy import deepcopy NEW_LINE from string import ascii_lowercase , ascii_uppercase , digits NEW_LINE def input ( ) : return sys . stdin . readline ( ) . strip ( ) NEW_LINE def INT ( ) : return int ( input ( ) ) NEW_LINE def MAP ( ) : return map ( int , input ( ) . split ( ) ) NEW_LINE def LIST ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE N , M = MAP ( ) NEW_LINE xyz = [ LIST ( ) for _ in range ( N ) ] NEW_LINE ans = [ ] NEW_LINE for i in range ( 0 , 2 ) : NEW_LINE INDENT for j in range ( 0 , 2 ) : NEW_LINE INDENT for k in range ( 0 , 2 ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT k_x = 1 NEW_LINE DEDENT else : NEW_LINE INDENT k_x = - 1 NEW_LINE DEDENT if j == 0 : NEW_LINE INDENT k_y = 1 NEW_LINE DEDENT else : NEW_LINE INDENT k_y = - 1 NEW_LINE DEDENT if k == 0 : NEW_LINE INDENT k_z = 1 NEW_LINE DEDENT else : NEW_LINE INDENT k_z = - 1 NEW_LINE DEDENT tmp = [ x * k_x + y * k_y + z * k_z for x , y , z in xyz ] NEW_LINE tmp . sort ( reverse = True ) NEW_LINE ans . append ( sum ( tmp [ 0 : M ] ) ) NEW_LINE DEDENT DEDENT DEDENT print ( max ( ans ) ) NEW_LINE

def main ( ) : NEW_LINE INDENT N , M = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE t = [ [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] , [ ] ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT x , y , z = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE for j in range ( 8 ) : NEW_LINE INDENT xs = 1 if j % 2 == 0 else - 1 NEW_LINE ys = 1 if ( j // 2 ) % 2 == 0 else - 1 NEW_LINE zs = 1 if ( j // 4 ) % 2 == 0 else - 1 NEW_LINE t [ j ] . append ( xs * x + ys * y + zs * z ) NEW_LINE DEDENT DEDENT res = [ ] NEW_LINE for li in t : NEW_LINE INDENT li . sort ( reverse = True ) NEW_LINE res . append ( sum ( li [ : M ] ) ) NEW_LINE DEDENT print ( max ( res ) ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

from operator import mul NEW_LINE import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE N , M = tuple ( li ( ) ) NEW_LINE Cs = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT n = tuple ( li ( ) ) NEW_LINE Cs . append ( n ) NEW_LINE DEDENT state = [ 0 , 0 , 0 , 0 ] NEW_LINE maximum = 0 NEW_LINE trans = [ ] NEW_LINE for per in range ( 8 ) : NEW_LINE INDENT ops = [ 1 if ( per & 4 ) >> 2 else - 1 , 1 if ( per & 2 ) >> 1 else - 1 , 1 if per & 1 else - 1 ] NEW_LINE trans . clear ( ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT trans . append ( list ( map ( mul , Cs [ i ] , ops ) ) ) NEW_LINE DEDENT trans . sort ( key = lambda x : - sum ( x ) ) NEW_LINE maximum = max ( maximum , sum ( sum ( t ) for t in trans [ : M ] ) ) NEW_LINE DEDENT print ( maximum ) NEW_LINE


import java . util . Scanner ; public class Main { void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] [ ] b = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) for ( int j = 1 ; j <= n ; j ++ ) { b [ i ] [ j ] = sc . nextInt ( ) ; } for ( int c = 1 ; c <= n ; c ++ ) for ( int r = 1 ; r <= n ; r ++ ) { b [ c ] [ r ] += b [ c - 1 ] [ r ] + b [ c ] [ r - 1 ] - b [ c - 1 ] [ r - 1 ] ; } int [ ] mem = new int [ n * n + 1 ] ; for ( int c1 = 1 ; c1 <= n ; c1 ++ ) for ( int r1 = 1 ; r1 <= n ; r1 ++ ) { for ( int c2 = c1 ; c2 <= n ; c2 ++ ) for ( int r2 = r1 ; r2 <= n ; r2 ++ ) { mem [ ( c2 - c1 + 1 ) * ( r2 - r1 + 1 ) ] = Math . max ( mem [ ( c2 - c1 + 1 ) * ( r2 - r1 + 1 ) ] , b [ c2 ] [ r2 ] + b [ c1 - 1 ] [ r1 - 1 ] - b [ c2 ] [ r1 - 1 ] - b [ c1 - 1 ] [ r2 ] ) ; } } int q = sc . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int max = 0 ; for ( int j = sc . nextInt ( ) ; j > 0 ; j -- ) max = Math . max ( max , mem [ j ] ) ; System . out . println ( max ) ; } } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }

import java . util . * ; import java . util . stream . IntStream ; public class Main { static int n ; static int [ ] [ ] d ; static int [ ] [ ] cum ; static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; d = new int [ n ] [ n ] ; cum = new int [ n + 1 ] [ n + 1 ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { d [ i ] [ j ] = sc . nextInt ( ) ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { cum [ i + 1 ] [ j + 1 ] = cum [ i + 1 ] [ j ] + cum [ i ] [ j + 1 ] + d [ i ] [ j ] - cum [ i ] [ j ] ; } } int q = sc . nextInt ( ) ; for ( int i = 0 ; i < q ; i ++ ) { int p = sc . nextInt ( ) ; int best = 0 ; for ( int j = 0 ; j < p ; j ++ ) { int x = p - j ; int y = p / x ; y = Math . min ( y , n ) ; best = Math . max ( best , f ( x , y ) ) ; } System . out . println ( best ) ; } } static int f ( int x , int y ) { int best = 0 ; for ( int i = 0 ; i < n - x + 1 ; i ++ ) { for ( int j = 0 ; j < n - y + 1 ; j ++ ) { best = Math . max ( best , cum [ i + x ] [ j + y ] - cum [ i + x ] [ j ] - cum [ i ] [ j + y ] + cum [ i ] [ j ] ) ; } } return best ; } }

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE N = int ( input ( ) ) NEW_LINE grid = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT grid . append ( list ( map ( int , input ( ) . split ( ) ) ) ) NEW_LINE DEDENT S = [ [ 0 ] * ( N + 1 ) for _ in range ( N + 1 ) ] NEW_LINE Q = int ( input ( ) ) NEW_LINE query = [ int ( input ( ) ) for _ in range ( Q ) ] NEW_LINE def solve ( ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT S [ i + 1 ] [ j + 1 ] = S [ i ] [ j + 1 ] + S [ i + 1 ] [ j ] - S [ i ] [ j ] + grid [ i ] [ j ] NEW_LINE DEDENT DEDENT val = [ 0 ] * ( N * N + 1 ) NEW_LINE for x1 in range ( N ) : NEW_LINE INDENT for x2 in range ( x1 + 1 , N + 1 ) : NEW_LINE INDENT for y1 in range ( N ) : NEW_LINE INDENT for y2 in range ( y1 + 1 , N + 1 ) : NEW_LINE INDENT area = ( x2 - x1 ) * ( y2 - y1 ) NEW_LINE s = S [ x2 ] [ y2 ] - S [ x1 ] [ y2 ] - S [ x2 ] [ y1 ] + S [ x1 ] [ y1 ] NEW_LINE val [ area ] = max ( val [ area ] , s ) NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in range ( N ** 2 ) : NEW_LINE INDENT val [ i + 1 ] = max ( val [ i ] , val [ i + 1 ] ) NEW_LINE DEDENT for q in query : NEW_LINE INDENT print ( val [ q ] ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE

from collections import defaultdict NEW_LINE import math NEW_LINE def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def II ( ) : return int ( input ( ) ) NEW_LINE def LS ( ) : return input ( ) . split ( ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def IIR ( n ) : return [ II ( ) for i in range ( n ) ] NEW_LINE def LIR ( n ) : return [ LI ( ) for i in range ( n ) ] NEW_LINE def SR ( n ) : return [ S ( ) for i in range ( n ) ] NEW_LINE mod = 1000000007 NEW_LINE n = II ( ) NEW_LINE d = LIR ( n ) NEW_LINE q = II ( ) NEW_LINE p = IIR ( q ) NEW_LINE d . insert ( 0 , [ 0 for i in range ( n + 1 ) ] ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT d [ i + 1 ] . insert ( 0 , 0 ) NEW_LINE DEDENT for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT d [ i + 1 ] [ j + 1 ] += d [ i + 1 ] [ j ] + d [ i ] [ j + 1 ] - d [ i ] [ j ] NEW_LINE DEDENT DEDENT ans = [ 0 for i in range ( n ** 2 + 1 ) ] NEW_LINE for a in range ( n + 1 ) : NEW_LINE INDENT for b in range ( n + 1 ) : NEW_LINE INDENT for c in range ( a ) : NEW_LINE INDENT for e in range ( b ) : NEW_LINE INDENT ans [ ( a - c ) * ( b - e ) ] = max ( ans [ ( a - c ) * ( b - e ) ] , d [ a ] [ b ] - d [ c ] [ b ] - d [ a ] [ e ] + d [ c ] [ e ] ) NEW_LINE DEDENT DEDENT DEDENT DEDENT for i in p : NEW_LINE INDENT an = 0 NEW_LINE for a in range ( i + 1 ) : NEW_LINE INDENT an = max ( an , ans [ a ] ) NEW_LINE DEDENT print ( an ) NEW_LINE NEW_LINE DEDENT

import numpy as np NEW_LINE N = int ( input ( ) ) NEW_LINE D = np . zeros ( ( N + 1 , N + 1 ) , dtype = np . int ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT for j , value in enumerate ( map ( int , input ( ) . split ( ) ) ) : NEW_LINE INDENT D [ i + 1 , j + 1 ] = value NEW_LINE DEDENT DEDENT np . cumsum ( D [ 1 : , 1 : ] , axis = 0 , out = D [ 1 : , 1 : ] ) NEW_LINE np . cumsum ( D [ 1 : , 1 : ] , axis = 1 , out = D [ 1 : , 1 : ] ) NEW_LINE maxs = np . zeros ( ( N * N + 1 ) , dtype = D . dtype ) NEW_LINE for r in range ( 1 , N + 1 ) : NEW_LINE INDENT for c in range ( 1 , N + 1 ) : NEW_LINE INDENT maxs [ r * c ] = max ( maxs [ r * c ] , max ( D [ i + r , j + c ] - D [ i , j + c ] - D [ i + r , j ] + D [ i , j ] for i in range ( N - r + 1 ) for j in range ( N - c + 1 ) ) ) NEW_LINE DEDENT DEDENT for p in range ( 1 , N * N + 1 ) : NEW_LINE INDENT maxs [ p ] = max ( maxs [ p ] , maxs [ p - 1 ] ) NEW_LINE DEDENT Q = int ( input ( ) ) NEW_LINE for q in range ( Q ) : NEW_LINE INDENT P = int ( input ( ) ) NEW_LINE print ( maxs [ P ] ) NEW_LINE DEDENT

from itertools import accumulate NEW_LINE from operator import add NEW_LINE def getAccAss ( Ass ) : NEW_LINE INDENT accAss = [ [ 0 ] * ( len ( Ass [ 0 ] ) + 1 ) ] + [ [ 0 ] + As for As in Ass ] NEW_LINE accAss = [ accumulate ( accAs ) for accAs in accAss ] NEW_LINE accAss [ 0 ] = list ( accAss [ 0 ] ) NEW_LINE for x in range ( 1 , len ( accAss ) ) : NEW_LINE INDENT accAss [ x ] = list ( map ( add , accAss [ x ] , accAss [ x - 1 ] ) ) NEW_LINE DEDENT return accAss NEW_LINE DEDENT def getRangeSum2D ( accAss , xFr , xTo , yFr , yTo ) : NEW_LINE INDENT return accAss [ xTo + 1 ] [ yTo + 1 ] - accAss [ xTo + 1 ] [ yFr ] - accAss [ xFr ] [ yTo + 1 ] + accAss [ xFr ] [ yFr ] NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE Dss = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( N ) ] NEW_LINE Q = int ( input ( ) ) NEW_LINE Ps = [ int ( input ( ) ) for _ in range ( Q ) ] NEW_LINE accDss = getAccAss ( Dss ) NEW_LINE sumDs = [ 0 ] * ( N * N + 1 ) NEW_LINE for xFr in range ( N ) : NEW_LINE INDENT for xTo in range ( xFr , N ) : NEW_LINE INDENT for yFr in range ( N ) : NEW_LINE INDENT for yTo in range ( yFr , N ) : NEW_LINE INDENT area = ( xTo - xFr + 1 ) * ( yTo - yFr + 1 ) NEW_LINE sumD = getRangeSum2D ( accDss , xFr , xTo , yFr , yTo ) NEW_LINE if sumD > sumDs [ area ] : NEW_LINE INDENT sumDs [ area ] = sumD NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT sumDs = list ( accumulate ( sumDs , lambda x , y : x if x >= y else y ) ) NEW_LINE for P in Ps : NEW_LINE INDENT print ( sumDs [ P ] ) NEW_LINE DEDENT

n = int ( input ( ) ) NEW_LINE d = [ list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE q = int ( input ( ) ) NEW_LINE p = [ int ( input ( ) ) for _ in range ( q ) ] NEW_LINE darea = lambda i , j , ii , jj : r [ i ] [ j ] - r [ ii + 1 ] [ j ] - r [ i ] [ jj + 1 ] + r [ ii + 1 ] [ jj + 1 ] NEW_LINE r = [ [ 0 for _ in range ( n + 1 ) ] for __ in range ( n + 1 ) ] NEW_LINE for i in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT for j in range ( n - 1 , - 1 , - 1 ) : NEW_LINE INDENT r [ i ] [ j ] = d [ i ] [ j ] + r [ i + 1 ] [ j ] + r [ i ] [ j + 1 ] - r [ i + 1 ] [ j + 1 ] NEW_LINE DEDENT DEDENT dmax = [ 0 for _ in range ( n ** 2 + 1 ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( n ) : NEW_LINE INDENT for ii in range ( i , n ) : NEW_LINE INDENT for jj in range ( j , n ) : NEW_LINE INDENT num = ( ii - i + 1 ) * ( jj - j + 1 ) NEW_LINE d = darea ( i , j , ii , jj ) NEW_LINE if dmax [ num ] < d : NEW_LINE INDENT dmax [ num ] = d NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT m = 0 NEW_LINE for i in range ( n ** 2 + 1 ) : NEW_LINE INDENT if m > dmax [ i ] : NEW_LINE INDENT dmax [ i ] = m NEW_LINE DEDENT else : NEW_LINE INDENT m = dmax [ i ] NEW_LINE DEDENT DEDENT for pk in p : NEW_LINE INDENT print ( dmax [ pk ] ) NEW_LINE DEDENT


import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner s = new Scanner ( System . in ) ; int n = Integer . parseInt ( s . nextLine ( ) ) ; String prevWord = null ; String currWord = null ; Set < String > set = new HashSet < > ( ) ; boolean isValid = true ; for ( int i = 0 ; i < n ; i ++ ) { currWord = s . nextLine ( ) ; if ( set . contains ( currWord ) ) { isValid = false ; } set . add ( currWord ) ; if ( isValid && i != 0 ) { if ( prevWord . charAt ( prevWord . length ( ) - 1 ) != currWord . charAt ( 0 ) ) { isValid = false ; } } prevWord = currWord ; } System . out . println ( isValid ? " Yes " : " No " ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . ArrayList ; import java . util . List ; public class Main { public static void main ( String [ ] args ) throws IOException { BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int N = Integer . parseInt ( br . readLine ( ) ) ; List < String > sir = new ArrayList < String > ( ) ; boolean isCorrect = true ; String lastWord = " " ; for ( int n = 0 ; n < N ; n ++ ) { String word = br . readLine ( ) ; String [ ] chr = word . split ( " " ) ; if ( n == 0 ) lastWord = chr [ chr . length - 1 ] ; else { if ( ! lastWord . equals ( chr [ 0 ] ) ) { isCorrect = false ; break ; } else { if ( sir . contains ( word ) ) { isCorrect = false ; break ; } sir . add ( word ) ; lastWord = chr [ chr . length - 1 ] ; } } sir . add ( word ) ; } if ( isCorrect ) System . out . println ( " Yes " ) ; else System . out . println ( " No " ) ; } }

import java . util . Collections ; import java . util . HashSet ; import java . util . List ; import java . util . Scanner ; import java . util . Set ; import java . util . stream . Collectors ; import java . util . stream . IntStream ; public class Main { private static final String YES = " Yes " ; private static final String NO = " No " ; public static String process ( TestCase testCase ) { final int N = testCase . N ; final List < String > W = testCase . W ; final Set < String > announced = new HashSet < > ( Collections . singletonList ( W . get ( 0 ) ) ) ; return IntStream . range ( 1 , N ) . allMatch ( i -> { final String prev = W . get ( i - 1 ) ; final String curr = W . get ( i ) ; final boolean notAnnounced = ! announced . contains ( curr ) ; final boolean charSatisfied = curr . charAt ( 0 ) == prev . charAt ( prev . length ( ) - 1 ) ; announced . add ( curr ) ; return notAnnounced && charSatisfied ; } ) ? YES : NO ; } public static void main ( String [ ] args ) { TestCase testCase = readFromInput ( ) ; final String result = process ( testCase ) ; output ( result ) ; } private static TestCase readFromInput ( ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; final List < String > W = IntStream . range ( 0 , N ) . mapToObj ( i -> sc . next ( ) ) . collect ( Collectors . toList ( ) ) ; return new TestCase ( N , W ) ; } private static void output ( String result ) { System . out . println ( result ) ; } public static class TestCase { final int N ; final List < String > W ; public TestCase ( int N , List < String > W ) { this . N = N ; this . W = W ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Map < String , Integer > po = new HashMap < String , Integer > ( ) ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; boolean ppp = true ; sc . nextLine ( ) ; String g = sc . nextLine ( ) ; po . put ( g , 0 ) ; String nstr = g . substring ( g . length ( ) - 1 , g . length ( ) ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { String str = sc . nextLine ( ) ; if ( po . containsKey ( str ) ) { ppp = false ; break ; } else { if ( nstr . equals ( str . substring ( 0 , 1 ) ) ) { nstr = str . substring ( str . length ( ) - 1 , str . length ( ) ) ; po . put ( str , 0 ) ; } else { ppp = false ; break ; } } } System . out . println ( ( ppp ) ? " Yes " : " No " ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; String [ ] [ ] nArray = new String [ n ] [ ] ; for ( int i = 0 ; i < n ; i ++ ) { String num = sc . next ( ) ; nArray [ i ] = num . split ( " " ) ; } boolean judge = true ; out : for ( int i = 1 ; i < n ; i ++ ) { for ( int k = 0 ; k < i ; k ++ ) { if ( Arrays . equals ( nArray [ i ] , nArray [ k ] ) ) { judge = false ; break out ; } } } for ( int i = 0 ; i < n - 1 ; i ++ ) { if ( nArray [ i ] [ nArray [ i ] . length - 1 ] . equals ( nArray [ i + 1 ] [ 0 ] ) ) { } else { judge = false ; break ; } } if ( judge ) { System . out . println ( " Yes " ) ; } else { System . out . println ( " No " ) ; } } }

N = int ( input ( ) ) NEW_LINE W = [ input ( ) for i in range ( N ) ] NEW_LINE flag = True NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT if W [ i ] [ len ( W [ i ] ) - 1 ] != W [ i + 1 ] [ 0 ] : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if i != j : NEW_LINE INDENT if W [ i ] == W [ j ] : NEW_LINE INDENT flag = False NEW_LINE DEDENT DEDENT DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT

_ , * l = open ( 0 ) ; print ( ' YNeos ' [ any ( a [ - 2 ] != b [ 0 ] * l . count ( a ) for a , b in zip ( l , l [ 1 : ] ) ) : : 2 ] ) NEW_LINE

def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE said = set ( ) NEW_LINE first = input ( ) NEW_LINE said . add ( first ) NEW_LINE last = first [ - 1 ] NEW_LINE is_shiritori = True NEW_LINE for _ in range ( n - 1 ) : NEW_LINE INDENT word = input ( ) NEW_LINE if word in said or word [ 0 ] != last : NEW_LINE INDENT is_shiritori = False NEW_LINE DEDENT said . add ( word ) NEW_LINE last = word [ - 1 ] NEW_LINE DEDENT if is_shiritori : 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

from collections import Counter NEW_LINE N = int ( input ( ) ) NEW_LINE w_list = [ input ( ) for _ in range ( N ) ] NEW_LINE cnt = Counter ( w_list ) . most_common ( 1 ) [ 0 ] [ 1 ] NEW_LINE if cnt > 1 : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( 0 , N - 1 ) : NEW_LINE INDENT if w_list [ i ] [ - 1 ] != w_list [ i + 1 ] [ 0 ] : NEW_LINE INDENT print ( ' No ' ) NEW_LINE break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT DEDENT

N = int ( input ( ) ) NEW_LINE before = [ ] NEW_LINE answer = ' Yes ' NEW_LINE for i in range ( N ) : NEW_LINE INDENT s = input ( ) NEW_LINE if s in before : NEW_LINE INDENT answer = ' No ' NEW_LINE DEDENT if len ( before ) > 0 : NEW_LINE INDENT if before [ - 1 ] [ - 1 ] != s [ 0 ] : NEW_LINE INDENT answer = ' No ' NEW_LINE DEDENT DEDENT before . append ( s ) NEW_LINE DEDENT print ( answer ) NEW_LINE


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

import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { PrintWriter out = new PrintWriter ( System . out ) ; InputStreamScanner in = new InputStreamScanner ( System . in ) ; new Main ( ) . solve ( in , out ) ; out . flush ( ) ; } private void solve ( InputStreamScanner in , PrintWriter out ) { String s = in . next ( ) ; out . printf ( " % s % d % s \n " , s . charAt ( 0 ) , s . length ( ) - 2 , s . charAt ( s . length ( ) - 1 ) ) ; } static class InputStreamScanner { private InputStream in ; private byte [ ] buf = new byte [ 1024 ] ; private int len = 0 ; private int off = 0 ; InputStreamScanner ( InputStream in ) { this . in = in ; } String next ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( int b = skip ( ) ; ! isSpace ( b ) ; ) { sb . appendCodePoint ( b ) ; b = read ( ) ; } return sb . toString ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } char nextChar ( ) { return ( char ) skip ( ) ; } int skip ( ) { for ( int b ; ( b = read ( ) ) != - 1 ; ) { if ( ! isSpace ( b ) ) { return b ; } } return - 1 ; } private boolean isSpace ( int c ) { return c < 33 || c > 126 ; } private int read ( ) { if ( len == - 1 ) { throw new InputMismatchException ( " End ▁ of ▁ Input " ) ; } if ( off >= len ) { off = 0 ; try { len = in . read ( buf ) ; } catch ( IOException e ) { throw new InputMismatchException ( e . getMessage ( ) ) ; } if ( len <= 0 ) { return - 1 ; } } return buf [ off ++ ] ; } } }

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 ( ) ; System . out . println ( word . charAt ( 0 ) + String . valueOf ( word . length ( ) - 2 ) + word . charAt ( word . length ( ) - 1 ) ) ; } }

import java . util . Scanner ; public class Main { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; String str = sc . next ( ) ; int len = str . length ( ) ; int midLen = len - 2 ; System . out . print ( str . substring ( 0 , 1 ) + midLen + str . substring ( len - 1 , len ) ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; String s = scan . nextLine ( ) ; int size = s . length ( ) ; char a = s . charAt ( 0 ) ; char z = s . charAt ( size - 1 ) ; System . out . print ( a ) ; System . out . print ( size - 2 ) ; System . out . print ( z ) ; scan . close ( ) ; } }

s = input ( ) NEW_LINE print ( s [ 0 ] + str ( len ( s ) - 2 ) + s [ len ( s ) - 1 ] ) NEW_LINE

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 print ( s [ 0 ] + str ( len ( s ) - 2 ) + s [ - 1 ] ) NEW_LINE

S = input ( ) NEW_LINE S0 = S [ 0 ] NEW_LINE S1 = str ( len ( S ) - 2 ) NEW_LINE S2 = S [ - 1 ] NEW_LINE print ( S0 + S1 + S2 ) NEW_LINE

s1 , * s2 , s3 = map ( str , input ( ) ) NEW_LINE print ( s1 + str ( len ( s2 ) ) + s3 ) NEW_LINE

s = input ( ) NEW_LINE print ( " { } { } { } " . format ( s [ 0 ] , len ( s ) - 2 , s [ - 1 ] ) ) NEW_LINE