import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { try ( Scanner sc = new Scanner ( System . in ) ) { new Main ( ) . solve ( sc ) ; } } void solve ( Scanner sc ) { char [ ] n = sc . next ( ) . toCharArray ( ) ; boolean f = false ; for ( int i = 1 ; i < n . length ; i ++ ) { if ( n [ i ] != '9' ) { f = true ; break ; } } if ( f ) { int ans = Integer . parseInt ( String . valueOf ( n [ 0 ] ) ) - 1 + 9 * ( n . length - 1 ) ; System . out . println ( ans ) ; } else { int ans = Integer . parseInt ( String . valueOf ( n [ 0 ] ) ) + 9 * ( n . length - 1 ) ; System . out . println ( ans ) ; } } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ADigitSum2 solver = new ADigitSum2 ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ADigitSum2 { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { String n = in . string ( ) ; int ans = 0 ; boolean filled = true ; for ( int i = 1 ; i < n . length ( ) ; i ++ ) { if ( n . charAt ( i ) != '9' ) { filled = false ; } ans += 9 ; } ans += Integer . parseInt ( n . substring ( 0 , 1 ) ) ; if ( ! filled ) { ans -= 1 ; } out . println ( ans ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } } }

public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] args ) { String n = scanner . next ( ) ; System . out . println ( n . charAt ( 0 ) - 49 + ( n . length ( ) - 1 ) * 9 + ( n . substring ( 1 ) . matches ( "9 * " ) ? 1 : 0 ) ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String N = sc . next ( ) ; int [ ] arr = new int [ N . length ( ) ] ; int max = 0 ; for ( int i = 0 ; i < N . length ( ) ; i ++ ) { arr [ i ] = N . charAt ( i ) - '0' ; max += arr [ i ] ; } for ( int i = 0 ; i < arr . length && arr [ i ] != 0 ; i ++ ) { int tmp = 0 ; for ( int j = 0 ; j < arr . length ; j ++ ) { if ( i == j ) { tmp += arr [ j ] - 1 + ( arr . length - j - 1 ) * 9 ; break ; } else { tmp += arr [ j ] ; } } max = Math . max ( max , tmp ) ; } out . println ( max ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; int ans = solve ( N ) ; System . out . println ( ans ) ; } static int help ( long N ) { int ans = 0 ; while ( N > 0 ) { ans += N % 10 ; N = N / 10 ; } return ans ; } static int solve ( long N ) { if ( N < 10 ) return ( int ) N ; String s = String . valueOf ( N ) ; int len = s . length ( ) ; int ans = help ( N ) ; for ( int i = 2 ; i <= len ; i ++ ) { long temp = ( long ) Math . pow ( 10 , i - 1 ) ; long cur = N / temp - 1 ; ans = Math . max ( ans , help ( cur ) + 9 * ( i - 1 ) ) ; } return ans ; } }

N = list ( input ( ) ) NEW_LINE ans1 , ans2 = 0 , 0 NEW_LINE for i in range ( len ( N ) ) : NEW_LINE INDENT if ( i == 0 ) : ans1 += int ( N [ i ] ) - 1 NEW_LINE else : ans1 += 9 NEW_LINE ans2 += int ( N [ i ] ) NEW_LINE DEDENT ans = max ( ans1 , ans2 ) NEW_LINE print ( ans ) NEW_LINE

N = input ( ) NEW_LINE flag = True NEW_LINE if N [ 0 ] == '1' : NEW_LINE INDENT for i in range ( 1 , len ( N ) ) : NEW_LINE INDENT if N [ i ] != '9' : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if not flag : NEW_LINE INDENT print ( 9 * ( len ( N ) - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 1 + 9 * ( len ( N ) - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( 1 , len ( N ) ) : NEW_LINE INDENT if N [ i ] != '9' : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT if not flag : NEW_LINE INDENT print ( 9 * ( len ( N ) - 1 ) + int ( N [ 0 ] ) - 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 9 * ( len ( N ) - 1 ) + int ( N [ 0 ] ) ) NEW_LINE DEDENT DEDENT

import numpy as np NEW_LINE n = int ( input ( ) ) NEW_LINE t = int ( np . log10 ( n ) + 1 ) NEW_LINE s = ( n + 1 ) // ( 10 ** ( t - 1 ) ) NEW_LINE print ( 9 * ( t - 1 ) + s - 1 ) NEW_LINE

s = input ( ) ; print ( max ( int ( s [ 0 ] ) - 1 + 9 * ( len ( s ) - 1 ) , sum ( map ( int , list ( s ) ) ) ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE bN = N NEW_LINE while bN : NEW_LINE INDENT ans += bN % 10 NEW_LINE bN //= 10 NEW_LINE DEDENT for i in range ( 17 , 0 , - 1 ) : NEW_LINE INDENT p = N // ( 10 ** i ) NEW_LINE if p == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT tmp = 0 NEW_LINE rem = p - 1 NEW_LINE while rem : NEW_LINE INDENT tmp += rem % 10 NEW_LINE rem //= 10 NEW_LINE DEDENT tmp += 9 * i NEW_LINE if tmp > ans : NEW_LINE INDENT ans = tmp NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE


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

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int [ ] valuees = new int [ 3 ] ; for ( int i = 0 ; i < 3 ; i ++ ) { valuees [ i ] = Integer . parseInt ( tokenizer . nextToken ( ) ) ; } Arrays . sort ( valuees ) ; int k = Integer . parseInt ( input . readLine ( ) ) ; for ( int i = 0 ; i < k ; i ++ ) { valuees [ 2 ] *= 2 ; } System . out . println ( valuees [ 0 ] + valuees [ 1 ] + valuees [ 2 ] ) ; } }

import static java . lang . System . * ; import java . util . * ; public 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 ( ) , k = sc . nextInt ( ) ; int total = a + b + c ; int max = max ( a , b , c ) ; int pow = ( int ) Math . pow ( 2 , k ) ; out . println ( ( total - max ) + max * pow ) ; } static int max ( int ... ar ) { Arrays . sort ( ar ) ; return ar [ ar . length - 1 ] ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int C = Integer . parseInt ( sc . next ( ) ) ; int K = Integer . parseInt ( sc . next ( ) ) ; int [ ] hako = { A , B , C } ; Arrays . sort ( hako ) ; int max = hako [ 2 ] ; for ( int i = 0 ; i < K ; i ++ ) { max = max * 2 ; } max = max + hako [ 0 ] + hako [ 1 ] ; System . out . print ( max ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int [ ] arr = new int [ 3 ] ; arr [ 0 ] = reader . nextInt ( ) ; arr [ 1 ] = reader . nextInt ( ) ; arr [ 2 ] = reader . nextInt ( ) ; int K = reader . nextInt ( ) ; int ans = 0 ; Arrays . sort ( arr ) ; for ( int i = 0 ; i < K ; i ++ ) { arr [ 2 ] *= 2 ; } for ( int i = 0 ; i < 3 ; i ++ ) { ans += arr [ i ] ; } System . out . print ( ans ) ; reader . close ( ) ; } }

abc_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE ans = 0 NEW_LINE for i in range ( k ) : NEW_LINE INDENT abc_list [ abc_list . index ( max ( abc_list ) ) ] = max ( abc_list ) * 2 NEW_LINE DEDENT print ( sum ( abc_list ) ) NEW_LINE

from collections import Counter NEW_LINE from functools import reduce NEW_LINE import fractions NEW_LINE import math NEW_LINE import statistics NEW_LINE import sys NEW_LINE import time NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE INF = 10 ** 18 NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def MI ( ) : return map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def IS ( ) : return input ( ) NEW_LINE def P ( x ) : return print ( x ) NEW_LINE def C ( x ) : return Counter ( x ) NEW_LINE def GCD_LIST ( numbers ) : NEW_LINE INDENT return reduce ( fractions . gcd , numbers ) NEW_LINE DEDENT def LCM_LIST ( numbers ) : NEW_LINE INDENT return reduce ( LCM , numbers ) NEW_LINE DEDENT def LCM ( m , n ) : NEW_LINE INDENT return ( m * n // fractions . gcd ( m , n ) ) NEW_LINE DEDENT li = LI ( ) NEW_LINE k = II ( ) NEW_LINE ans = [ ] NEW_LINE def calc ( a , b , c , count ) : NEW_LINE INDENT if count == k : NEW_LINE INDENT val = a + b + c NEW_LINE ans . append ( val ) NEW_LINE count -= 1 NEW_LINE return NEW_LINE DEDENT count += 1 NEW_LINE calc ( a * 2 , b , c , count ) NEW_LINE calc ( a , b * 2 , c , count ) NEW_LINE calc ( a , b , c * 2 , count ) NEW_LINE DEDENT calc ( li [ 0 ] , li [ 1 ] , li [ 2 ] , 0 ) NEW_LINE print ( max ( ans ) ) NEW_LINE NEW_LINE

A = [ int ( j ) for j in input ( ) . split ( ) ] NEW_LINE K = int ( input ( ) ) NEW_LINE A . sort ( ) NEW_LINE print ( A [ 2 ] * ( ( 2 ** K ) - 1 ) + sum ( A ) ) NEW_LINE

N = sorted ( list ( map ( int , input ( ) . split ( ) ) ) , reverse = True ) NEW_LINE print ( N [ 0 ] * 2 ** int ( input ( ) ) + N [ 1 ] + N [ 2 ] ) NEW_LINE

A , B , C = map ( int , input ( ) . split ( ) ) NEW_LINE K = int ( input ( ) ) NEW_LINE arr = [ A , B , C ] NEW_LINE for _ in range ( K ) : NEW_LINE INDENT arr1 = 2 * arr [ 0 ] + arr [ 1 ] + arr [ 2 ] NEW_LINE arr2 = arr [ 0 ] + 2 * arr [ 1 ] + arr [ 2 ] NEW_LINE arr3 = arr [ 0 ] + arr [ 1 ] + 2 * arr [ 2 ] NEW_LINE tmp = [ arr1 , arr2 , arr3 ] NEW_LINE idx = tmp . index ( max ( tmp ) ) NEW_LINE arr [ idx ] *= 2 NEW_LINE DEDENT print ( sum ( arr ) ) NEW_LINE


import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Deque ; import java . util . List ; import java . util . Scanner ; class Main { private static int bitcount ( long n ) { int res = 0 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) ++ res ; n /= 2 ; } return res ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long N = scan . nextLong ( ) ; int maxbit = - 1 ; long n = N ; while ( n > 0 ) { n /= 2 ; ++ maxbit ; } Deque < Integer > first = new ArrayDeque < > ( ) ; List < Integer > second = new ArrayList < > ( ) ; for ( int i = maxbit ; i > 0 ; -- i ) { first . addLast ( i ) ; second . add ( i ) ; } Deque < Integer > useNumber = new ArrayDeque < > ( ) ; for ( int i = bitcount ( N ) - 1 ; i > 0 ; -- i ) { useNumber . addLast ( maxbit + i ) ; first . addFirst ( maxbit + i ) ; } for ( int i = maxbit - 1 ; i >= 0 ; -- i ) { if ( ( ( N >> i ) & 1 ) == 1 ) { int inn = useNumber . removeFirst ( ) ; second . add ( second . indexOf ( i + 1 ) + 1 , inn ) ; } } List < Integer > ans = new ArrayList < > ( ) ; ans . add ( 100 ) ; while ( ! first . isEmpty ( ) ) { ans . add ( first . removeFirst ( ) ) ; } for ( int i : second ) ans . add ( i ) ; ans . add ( 100 ) ; System . out . println ( ans . size ( ) ) ; for ( int i : ans ) System . out . print ( i + " ▁ " ) ; System . out . println ( ) ; } }

import java . util . ArrayDeque ; import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; ++ N ; ArrayDeque < Integer > deque = new ArrayDeque < > ( ) ; int curVal = 1 ; ArrayList < Integer > lis = new ArrayList < > ( ) ; while ( N > 0 ) { if ( N % 2 == 0 ) { lis . add ( 0 ) ; } else { lis . add ( 1 ) ; } N /= 2 ; } for ( int i = lis . size ( ) - 2 ; i >= 0 ; -- i ) { deque . addLast ( curVal ) ; if ( lis . get ( i ) == 1 ) { ++ curVal ; deque . addFirst ( curVal ) ; } ++ curVal ; } -- curVal ; System . out . println ( curVal * 2 ) ; for ( int i = 0 ; i < curVal ; ++ i ) { System . out . print ( deque . pollFirst ( ) + " ▁ " ) ; } for ( int i = 1 ; i <= curVal ; ++ i ) { System . out . print ( i + ( i == curVal ? " \n " : " ▁ " ) ) ; } } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

import java . util . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long n = sc . nextLong ( ) ; ArrayList < Integer > res = new ArrayList < Integer > ( ) ; int k ; for ( k = 40 ; k >= 0 ; k -- ) { if ( n >= ( 1L << k ) - 1 ) break ; } for ( int i = 1 ; i <= k ; i ++ ) res . add ( i ) ; n -= ( 1L << k ) - 1 ; for ( int i = k - 1 ; i >= 0 ; i -- ) { if ( n < ( 1L << i ) ) continue ; k ++ ; res . add ( i , k ) ; n -= 1L << i ; } System . out . println ( 2 * res . size ( ) ) ; for ( int x : res ) System . out . print ( x + " ▁ " ) ; for ( int i = 1 ; i <= res . size ( ) ; i ++ ) System . out . print ( i + " ▁ " ) ; System . out . println ( ) ; } }

import java . util . ArrayList ; import java . util . Scanner ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { long N = sc . nextLong ( ) ; ArrayList < Integer > first = new ArrayList < > ( ) ; ArrayList < Integer > second = new ArrayList < > ( ) ; for ( int i = 1 ; ( 1L << i ) - 1 <= N ; i ++ ) { first . add ( i ) ; second . add ( i ) ; } N -= ( 1L << first . size ( ) ) - 1 ; while ( N > 0 ) { int a = first . size ( ) + 1 ; first . add ( a ) ; for ( int i = 0 ; ; i ++ ) { if ( ( 1L << ( i + 1 ) ) > N ) { second . add ( i , a ) ; N -= ( 1L << ( i ) ) ; break ; } } } System . out . println ( first . size ( ) * 2 ) ; for ( int i = 0 ; i < first . size ( ) ; i ++ ) { System . out . print ( first . get ( i ) + " ▁ " ) ; } for ( int i = 0 ; i < first . size ( ) ; i ++ ) { System . out . print ( second . get ( i ) + ( i == first . size ( ) - 1 ? " \n " : " ▁ " ) ) ; } } }

import java . io . * ; import java . util . * ; public class Main { BufferedReader br ; PrintWriter out ; StringTokenizer st ; boolean eof ; void go ( ArrayDeque < Integer > q , long x ) { if ( x == 1 ) { return ; } if ( x % 2 == 0 ) { go ( q , x / 2 ) ; q . addLast ( q . size ( ) + 1 ) ; } else { go ( q , x - 1 ) ; q . addFirst ( q . size ( ) + 1 ) ; } } void solve ( ) throws IOException { long x = nextLong ( ) + 1 ; ArrayDeque < Integer > q = new ArrayDeque < > ( ) ; go ( q , x ) ; List < Integer > ans = new ArrayList < > ( ) ; for ( int i = 1 ; i <= q . size ( ) ; i ++ ) { ans . add ( i ) ; } ans . addAll ( q ) ; out . println ( ans . size ( ) ) ; for ( int xx : ans ) { out . print ( xx + " ▁ " ) ; } out . println ( ) ; } Main ( ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; solve ( ) ; out . close ( ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) ; } String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { eof = true ; return null ; } } return st . nextToken ( ) ; } String nextString ( ) { try { return br . readLine ( ) ; } catch ( IOException e ) { eof = true ; return null ; } } int nextInt ( ) throws IOException { return Integer . parseInt ( nextToken ( ) ) ; } long nextLong ( ) throws IOException { return Long . parseLong ( nextToken ( ) ) ; } double nextDouble ( ) throws IOException { return Double . parseDouble ( nextToken ( ) ) ; } }

n = int ( input ( ) ) + 1 NEW_LINE k = 50 NEW_LINE while ~ n >> k & 1 : NEW_LINE INDENT k -= 1 NEW_LINE DEDENT k -= 1 NEW_LINE a = [ ] NEW_LINE b = [ ] NEW_LINE now = 1 NEW_LINE while k >= 0 : NEW_LINE INDENT a = a + [ now ] NEW_LINE b = b + [ now ] NEW_LINE now += 1 NEW_LINE if n >> k & 1 : NEW_LINE INDENT a = a + [ now ] NEW_LINE b = [ now ] + b NEW_LINE now += 1 NEW_LINE DEDENT k -= 1 NEW_LINE DEDENT print ( len ( a + b ) ) NEW_LINE print ( * ( a + b ) ) NEW_LINE

def ncr ( n , r ) : NEW_LINE INDENT r = min ( n - r , r ) NEW_LINE up = 1 NEW_LINE down = 1 NEW_LINE for i in range ( r ) : NEW_LINE INDENT up *= ( n - i ) NEW_LINE down *= ( i + 1 ) NEW_LINE DEDENT return up // down NEW_LINE DEDENT def seq ( x ) : NEW_LINE INDENT s = 0 NEW_LINE for i in range ( 1 , x ) : NEW_LINE INDENT j = i * 2 NEW_LINE if j > x : NEW_LINE INDENT break NEW_LINE DEDENT s += ncr ( x , j ) NEW_LINE DEDENT return s NEW_LINE DEDENT def ins ( total , p ) : NEW_LINE INDENT s = 0 NEW_LINE for i in range ( p + 1 ) : NEW_LINE INDENT s += ncr ( p , i ) * ncr ( total - p , i ) NEW_LINE DEDENT return s NEW_LINE DEDENT ans = [ ] NEW_LINE N = int ( input ( ) ) NEW_LINE k = 1 NEW_LINE for i in range ( 41 , 0 , - 1 ) : NEW_LINE INDENT x = seq ( i ) NEW_LINE if N >= x : NEW_LINE INDENT for j in range ( i ) : NEW_LINE INDENT ans . append ( k ) NEW_LINE DEDENT N -= x NEW_LINE k += 1 NEW_LINE break NEW_LINE DEDENT DEDENT size = len ( ans ) NEW_LINE s = size // 2 NEW_LINE while N > 90 : NEW_LINE INDENT m = 0 NEW_LINE t = 0 NEW_LINE for i in range ( s + 1 ) : NEW_LINE INDENT tmp = ins ( size , i ) NEW_LINE if tmp > N : NEW_LINE INDENT break NEW_LINE DEDENT if tmp > t : NEW_LINE INDENT t = tmp NEW_LINE m = i NEW_LINE DEDENT DEDENT N -= t NEW_LINE ans . insert ( m , k ) NEW_LINE ans . append ( k ) NEW_LINE k += 1 NEW_LINE DEDENT while N > 0 : NEW_LINE INDENT for i in range ( 41 , 0 , - 1 ) : NEW_LINE INDENT x = seq ( i ) NEW_LINE if N >= x : NEW_LINE INDENT for j in range ( i ) : NEW_LINE INDENT ans . append ( k ) NEW_LINE DEDENT N -= x NEW_LINE k += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT print ( len ( ans ) ) NEW_LINE print ( " ▁ " . join ( [ str ( x ) for x in ans ] ) ) NEW_LINE

def f ( n ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT return [ ] NEW_LINE DEDENT if n % 2 == 0 : NEW_LINE INDENT r = f ( n // 2 ) NEW_LINE k = len ( r ) NEW_LINE return r + [ k + 1 ] NEW_LINE DEDENT if n % 2 == 1 : NEW_LINE INDENT r = f ( n - 1 ) NEW_LINE k = len ( r ) NEW_LINE return [ k + 1 ] + r NEW_LINE DEDENT DEDENT n = int ( input ( ) ) NEW_LINE r = f ( n + 1 ) NEW_LINE k = len ( r ) NEW_LINE res = r + list ( range ( 1 , k + 1 ) ) NEW_LINE print ( len ( res ) ) NEW_LINE for x in res : NEW_LINE INDENT print ( x , end = ' ▁ ' ) NEW_LINE DEDENT print ( ) NEW_LINE

fact = [ 1 ] NEW_LINE for i in range ( 1 , 101 ) : NEW_LINE INDENT fact . append ( fact [ - 1 ] * i ) NEW_LINE DEDENT def C ( a , b ) : NEW_LINE INDENT return fact [ a ] // ( fact [ b ] * fact [ a - b ] ) NEW_LINE DEDENT def sC ( a , b ) : NEW_LINE INDENT ret = 0 NEW_LINE for i in range ( min ( b , a - b ) + 1 ) : NEW_LINE INDENT ret += C ( b , i ) * C ( a - b , i ) NEW_LINE DEDENT return ret NEW_LINE DEDENT def calc ( n , k ) : NEW_LINE INDENT if n <= 0 : NEW_LINE INDENT return [ ] NEW_LINE DEDENT i = 0 NEW_LINE while ( 1 << ( i + 1 ) ) - 1 <= n : NEW_LINE INDENT i += 1 NEW_LINE DEDENT ret = [ str ( k ) ] * ( i + 1 ) NEW_LINE rem = n - ( ( 1 << i ) - 1 ) NEW_LINE kk = k + 1 NEW_LINE i += 1 NEW_LINE j = i // 2 NEW_LINE while j > 0 : NEW_LINE INDENT while True : NEW_LINE INDENT tmp = sC ( i , j ) NEW_LINE if tmp <= rem : NEW_LINE INDENT ret . insert ( j , str ( kk ) ) NEW_LINE ret . append ( str ( kk ) ) NEW_LINE kk += 1 NEW_LINE rem -= tmp NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT j -= 1 NEW_LINE DEDENT return ret + calc ( rem , kk ) NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE X = calc ( N , 1 ) NEW_LINE print ( len ( X ) ) NEW_LINE print ( " ▁ " . join ( X ) ) NEW_LINE

n = int ( input ( ) ) NEW_LINE x = [ ] NEW_LINE y = [ ] NEW_LINE k = 1 NEW_LINE for c in bin ( n + 1 ) [ 2 : ] [ 1 : ] : NEW_LINE INDENT x += [ k ] NEW_LINE y += [ k ] NEW_LINE k += 1 NEW_LINE if int ( c ) : NEW_LINE INDENT x = [ k ] + x NEW_LINE y += [ k ] NEW_LINE k += 1 NEW_LINE DEDENT DEDENT print ( len ( x + y ) ) NEW_LINE print ( * ( x + y ) ) NEW_LINE


import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] l = new int [ n ] ; int min = Integer . MAX_VALUE ; for ( int i = 0 ; i < n ; i ++ ) { l [ i ] = sc . nextInt ( ) ; min = Math . min ( min , l [ i ] ) ; } int gcd = 0 ; for ( int i = 0 ; i < n ; i ++ ) { gcd = gcd ( gcd , l [ i ] - min ) ; } System . out . println ( pow ( 2 , min + ( gcd + 1 ) / 2 ) ) ; } private static final int MOD = 1_000_000_007 ; private static int gcd ( int n , int m ) { if ( m == 0 ) { return n ; } else { return gcd ( m , n % m ) ; } } private static long pow ( int a , long n ) { long loop = n ; long ret = 1 ; long x = a ; while ( loop > 0 ) { if ( loop % 2 == 1 ) { ret = ret * x % MOD ; } x = x * x % MOD ; loop /= 2 ; } return ret ; } }

import sys NEW_LINE from fractions import gcd NEW_LINE from functools import reduce NEW_LINE N = int ( input ( ) ) NEW_LINE a = sorted ( map ( int , sys . stdin ) ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE if N == 1 : NEW_LINE INDENT print ( pow ( 2 , a [ 0 ] , mod ) ) NEW_LINE exit ( ) NEW_LINE DEDENT gcd = reduce ( gcd , [ n - a [ 0 ] for n in a ] ) NEW_LINE print ( pow ( 2 , a [ 0 ] + ( gcd + 1 ) // 2 , mod ) % mod ) NEW_LINE

N = int ( input ( ) ) NEW_LINE L = [ ] NEW_LINE for _ in range ( N ) : NEW_LINE INDENT L . append ( int ( input ( ) ) ) NEW_LINE DEDENT L . sort ( ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE if N == 1 : NEW_LINE INDENT print ( pow ( 2 , L [ 0 ] , mod ) ) NEW_LINE exit ( ) NEW_LINE DEDENT def gcd ( m , n ) : NEW_LINE INDENT x = max ( m , n ) NEW_LINE y = min ( m , n ) NEW_LINE if y == 0 : NEW_LINE INDENT return x NEW_LINE DEDENT else : NEW_LINE INDENT return gcd ( y , x % y ) NEW_LINE DEDENT DEDENT M = [ ] NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT M . append ( L [ i + 1 ] - L [ i ] ) NEW_LINE DEDENT g = M [ 0 ] NEW_LINE for i in range ( 1 , N - 1 ) : NEW_LINE INDENT g = gcd ( g , M [ i ] ) NEW_LINE DEDENT print ( pow ( 2 , L [ 0 ] + ( g + 1 ) // 2 , mod ) ) NEW_LINE

MOD = 10 ** 9 + 7 NEW_LINE N = int ( input ( ) ) NEW_LINE L = sorted ( set ( [ int ( input ( ) ) for i in range ( N ) ] ) ) NEW_LINE N = len ( L ) NEW_LINE def gcd ( m , n ) : NEW_LINE INDENT r = m % n NEW_LINE return gcd ( n , r ) if r else n NEW_LINE DEDENT if N == 1 : NEW_LINE INDENT x = 0 NEW_LINE DEDENT else : NEW_LINE INDENT x = L [ 1 ] - L [ 0 ] NEW_LINE for i in range ( 2 , N ) : NEW_LINE INDENT x = gcd ( x , L [ i ] - L [ 0 ] ) NEW_LINE DEDENT DEDENT print ( pow ( 2 , L [ 0 ] + ( x + 1 ) // 2 , MOD ) ) NEW_LINE


import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; for ( int i = 99 ; i > 0 ; i -- ) { if ( s . contains ( String . valueOf ( i ) ) ) { System . out . println ( i ) ; break ; } } } }

import java . util . * ; import java . util . regex . Pattern ; import java . util . regex . Matcher ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String S = sc . next ( ) ; String chk [ ] = S . split ( " " ) ; int cnt = 0 ; StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < S . length ( ) ; i ++ ) { String chker = chk [ i ] ; String regex = " [ 0-9 ] + " ; Pattern p = Pattern . compile ( regex ) ; Matcher m = p . matcher ( chker ) ; if ( m . find ( ) ) { cnt ++ ; buf . append ( chker ) ; } else if ( cnt >= 1 ) { continue ; } } System . out . println ( buf ) ; } }

import java . util . * ; public class Main { static int count = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] arr = sc . next ( ) . toCharArray ( ) ; int a1 = - 1 ; int a2 = - 1 ; for ( char c : arr ) { if ( c >= '0' && c <= '9' ) { if ( a1 == - 1 ) { a1 = c - '0' ; } else { a2 = c - '0' ; } } } int ans ; if ( a2 == - 1 ) { ans = a1 ; } else { ans = a1 * 10 + a2 ; } System . out . println ( ans ) ; } }

import java . util . * ; class Main { void solve ( ) { Scanner in = new Scanner ( System . in ) ; System . out . println ( in . nextLine ( ) . replaceAll ( " [ a - z ] | [ A - Z ] " , " " ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } }

public class Main { public static void main ( String [ ] $ ) { System . out . println ( new java . util . Scanner ( System . in ) . next ( ) . replaceAll ( " \\ D " , " " ) ) ; } }

S = str ( input ( ) ) NEW_LINE list = [ ] NEW_LINE for i in range ( len ( S ) ) : NEW_LINE INDENT if ord ( S [ i ] ) >= 48 and ord ( S [ i ] ) <= 57 : NEW_LINE INDENT list . append ( S [ i ] ) NEW_LINE DEDENT DEDENT if list [ 0 ] == "0" : NEW_LINE INDENT list . pop ( 0 ) NEW_LINE DEDENT ans = " " NEW_LINE for i in range ( len ( list ) ) : NEW_LINE INDENT ans += list [ i ] NEW_LINE DEDENT print ( ans ) NEW_LINE

import re NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE s = input ( ) NEW_LINE pat = r ' ( \d ) + ' NEW_LINE res = re . search ( pat , s ) NEW_LINE if res : NEW_LINE INDENT print ( res . group ( ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " err " ) NEW_LINE DEDENT

import re NEW_LINE print ( re . sub ( ' \D ' , " " , input ( ) ) ) NEW_LINE

def a_nth_class ( S ) : NEW_LINE INDENT for i in range ( len ( S ) ) : NEW_LINE INDENT if S [ i : i + 2 ] . isdigit ( ) : NEW_LINE INDENT return S [ i : i + 2 ] NEW_LINE DEDENT elif S [ i ] . isdigit ( ) : NEW_LINE INDENT return S [ i ] NEW_LINE DEDENT DEDENT return None NEW_LINE DEDENT S = input ( ) NEW_LINE print ( a_nth_class ( S ) ) NEW_LINE

s = input ( ) NEW_LINE alph = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz " NEW_LINE for i in alph : NEW_LINE INDENT s = s . replace ( i , " " ) NEW_LINE DEDENT print ( s ) NEW_LINE


import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( s . nextInt ( ) / 2 >= s . nextInt ( ) ? " YES " : " NO " ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int point = 1 ; if ( k <= point && n >= point ) { System . out . println ( " YES " ) ; return ; } n -- ; if ( k <= point && n >= point ) { System . out . println ( " YES " ) ; return ; } while ( n > 0 ) { n -- ; point ++ ; if ( k <= point && n >= point ) { System . out . println ( " YES " ) ; return ; } } System . out . println ( " NO " ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) , k = sc . nextInt ( ) ; out . println ( n / 2 < k ? " NO " : " YES " ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextInt ( ) ; long K = sc . nextLong ( ) ; System . out . println ( ( K <= Math . ceil ( ( float ) ( N - 1 ) / 2 ) ) ? " YES " : " NO " ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; if ( N / 2 >= K ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; } } }

n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE if n // 2 >= k : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT

n , k = map ( int , open ( 0 ) ) ; print ( ' YNEOS ' [ n < k * 2 : : 2 ] ) NEW_LINE

n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE tmp = 0 NEW_LINE for i in range ( 10 ** 5 ) : NEW_LINE INDENT n = n - 2 NEW_LINE tmp += 1 NEW_LINE if n < 0 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE break NEW_LINE DEDENT if tmp == k : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE break NEW_LINE DEDENT DEDENT

print ( " NO " if int ( input ( ) ) // 2 < int ( input ( ) ) else " YES " ) NEW_LINE

def main ( ) : NEW_LINE INDENT n = int ( input ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE if n >= 2 * k : 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


import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long total = 1 ; for ( long i = 2 ; i <= ( int ) Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) { total = total + i ; long j = N / i ; if ( j != i ) { total = total + j ; } if ( total > N ) { break ; } } } if ( total == 1 ) { System . out . println ( " Deficient " ) ; } else if ( total == N ) { System . out . println ( " Perfect " ) ; } else if ( total < N ) { System . out . println ( " Deficient " ) ; } else { System . out . println ( " Abundant " ) ; } } }

import java . util . * ; class Main { static long sum ( long n ) { long ret = 1 ; for ( long i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == Math . sqrt ( n ) ) { ret += i ; } else { ret += i ; ret += n / i ; } } } return ret ; } static void solve ( long n ) { if ( n == 1 ) System . out . println ( " Deficient " ) ; else if ( sum ( n ) == n ) System . out . println ( " Perfect " ) ; else if ( sum ( n ) < n ) System . out . println ( " Deficient " ) ; else System . out . println ( " Abundant " ) ; } public static void main ( String args [ ] ) { Scanner cin = new Scanner ( System . in ) ; long n = cin . nextLong ( ) ; solve ( n ) ; } }

import java . util . * ; public class Main { private static long N ; public static void input ( ) { Scanner scan = new Scanner ( System . in ) ; N = scan . nextLong ( ) ; } public static void main ( String args [ ] ) { input ( ) ; long sum = 1 ; for ( long i = 2 ; i <= Math . sqrt ( N ) ; i ++ ) { if ( N % i == 0 ) sum += i + N / i ; } if ( N % Math . sqrt ( N ) == 0 ) sum -= Math . sqrt ( N ) ; if ( sum == N ) System . out . println ( " Perfect " ) ; else if ( sum > N ) System . out . println ( " Abundant " ) ; else System . out . println ( " Deficient " ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long M = ( long ) Math . floor ( Math . sqrt ( N ) ) ; if ( N == 1 ) { System . out . println ( " Deficient " ) ; return ; } long ans = 1l ; for ( long i = 2l ; i <= M ; i ++ ) { if ( N % i == 0 ) { if ( i != N / i ) { ans += N / i ; } ans += i ; } } if ( ans == N ) { System . out . println ( " Perfect " ) ; } else if ( ans < N ) { System . out . println ( " Deficient " ) ; } else if ( ans > N ) { System . out . println ( " Abundant " ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long n = Long . parseLong ( sc . next ( ) ) ; sc . close ( ) ; long num = 1 ; for ( long i = 2 ; i <= Math . sqrt ( n ) ; i ++ ) { if ( n % i == 0 ) { if ( i == Math . sqrt ( n ) ) num += i ; else num += i + n / i ; } } System . out . println ( n == 1 ? " Deficient " : num == n ? " Perfect " : num > n ? " Abundant " : " Deficient " ) ; } }

n = int ( input ( ) ) NEW_LINE ans = 1 NEW_LINE if n == 1 : NEW_LINE INDENT print ( " Deficient " ) NEW_LINE quit ( ) NEW_LINE DEDENT i = 2 NEW_LINE ans_l = [ " Deficient " , " Perfect " , " Abundant " ] NEW_LINE while i ** 2 <= n : NEW_LINE INDENT if n % i == 0 : NEW_LINE INDENT ans += i NEW_LINE if n // i != i : NEW_LINE INDENT ans += n // i NEW_LINE DEDENT DEDENT i += 1 NEW_LINE DEDENT key = ( ans - n ) // max ( 1 , abs ( ans - n ) ) + 1 NEW_LINE print ( ans_l [ key ] ) NEW_LINE

def b_perfect_number ( N ) : NEW_LINE INDENT def divisor_list ( n ) : NEW_LINE INDENT ret = [ ] NEW_LINE for k in range ( 1 , int ( n ** 0.5 ) + 1 ) : NEW_LINE INDENT if n % k == 0 : NEW_LINE INDENT ret . append ( k ) NEW_LINE if k != n // k : NEW_LINE INDENT ret . append ( n // k ) NEW_LINE DEDENT DEDENT DEDENT ret . sort ( ) NEW_LINE return ret NEW_LINE DEDENT div_list = divisor_list ( N ) NEW_LINE div_sum = sum ( div_list ) NEW_LINE if div_sum == 2 * N : NEW_LINE INDENT ans = ' Perfect ' NEW_LINE DEDENT elif div_sum < 2 * N : NEW_LINE INDENT ans = ' Deficient ' NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' Abundant ' NEW_LINE DEDENT return ans NEW_LINE DEDENT N = int ( input ( ) ) NEW_LINE print ( b_perfect_number ( N ) ) NEW_LINE

import math NEW_LINE N = int ( input ( ) ) NEW_LINE ans = ( - 1 ) * N NEW_LINE square_root = int ( math . sqrt ( N ) ) NEW_LINE if square_root ** 2 == N : NEW_LINE INDENT end = square_root NEW_LINE ans -= square_root NEW_LINE DEDENT else : NEW_LINE INDENT end = square_root + 1 NEW_LINE DEDENT for i in range ( 1 , end ) : NEW_LINE INDENT if N % i == 0 : NEW_LINE INDENT ans += ( N // i + i ) NEW_LINE DEDENT DEDENT print ( ' Perfect ' if ans == N else ' Abundant ' if ans > N else ' Deficient ' ) NEW_LINE

from math import sqrt NEW_LINE n = int ( input ( ) ) NEW_LINE nums = set ( ) NEW_LINE d_nums = set ( ) NEW_LINE for i in range ( 1 , int ( sqrt ( n ) ) + 1 ) : NEW_LINE INDENT if n % i == 0 and i != n : NEW_LINE INDENT nums . add ( i ) NEW_LINE DEDENT DEDENT for num in nums : NEW_LINE INDENT p , q = divmod ( n , num ) NEW_LINE if q == 0 and p != n : NEW_LINE INDENT d_nums . add ( p ) NEW_LINE DEDENT DEDENT m_nums = nums | d_nums NEW_LINE t = sum ( m_nums ) NEW_LINE if t == n : NEW_LINE INDENT print ( ' Perfect ' ) NEW_LINE DEDENT elif t > n : NEW_LINE INDENT print ( ' Abundant ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' Deficient ' ) NEW_LINE DEDENT

from collections import defaultdict as dd NEW_LINE from functools import reduce NEW_LINE def calc ( x ) : NEW_LINE INDENT a , b = x NEW_LINE v = 0 NEW_LINE for i in range ( b + 1 ) : NEW_LINE INDENT v += a ** i NEW_LINE DEDENT return v NEW_LINE DEDENT def factorization ( n ) : NEW_LINE INDENT d = dd ( int ) NEW_LINE for i in range ( 2 , 1 + int ( n ** 0.5 ) ) : NEW_LINE INDENT while n % i == 0 : NEW_LINE INDENT d [ i ] += 1 NEW_LINE n //= i NEW_LINE DEDENT DEDENT if n > 1 : d [ n ] += 1 NEW_LINE return d NEW_LINE DEDENT n = int ( input ( ) ) NEW_LINE if n == 1 : NEW_LINE INDENT print ( " Deficient " ) NEW_LINE DEDENT else : NEW_LINE INDENT d = factorization ( n ) NEW_LINE result = reduce ( lambda x , y : x * y , map ( calc , d . items ( ) ) ) - n NEW_LINE print ( " Perfect " if n == result else " Abundant " if result > n else " Deficient " ) NEW_LINE DEDENT


import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int n = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int m = Integer . parseInt ( tokenizer . nextToken ( ) ) ; char [ ] [ ] nBoard = new char [ n ] [ ] ; char [ ] [ ] mBoard = new char [ m ] [ ] ; for ( int i = 0 ; i < n ; i ++ ) { nBoard [ i ] = input . readLine ( ) . toCharArray ( ) ; } for ( int i = 0 ; i < m ; i ++ ) { mBoard [ i ] = input . readLine ( ) . toCharArray ( ) ; } boolean state = false ; TH : for ( int i = 0 ; i < ( n - m ) + 1 ; i ++ ) { for ( int j = 0 ; j < ( n - m ) + 1 ; j ++ ) { boolean state2 = true ; MT : for ( int k = 0 ; k < m ; k ++ ) { for ( int l = 0 ; l < m ; l ++ ) { if ( nBoard [ i + k ] [ j + l ] != mBoard [ k ] [ l ] ) { state2 = false ; break MT ; } } } if ( state2 ) { state = true ; break TH ; } } } System . out . println ( state ? " Yes " : " No " ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] srgs ) { Scanner scan = new Scanner ( System . in ) ; int a = scan . nextInt ( ) ; int b = scan . nextInt ( ) ; String strA [ ] = new String [ a ] ; String strB [ ] = new String [ b ] ; for ( int i = 0 ; i != a ; i ++ ) { strA [ i ] = scan . next ( ) ; } for ( int i = 0 ; i != b ; i ++ ) { strB [ i ] = scan . next ( ) ; } int fig = 0 ; loop : for ( int i = 0 ; i != a - b + 1 ; i ++ ) { for ( int k = 0 ; k != a - b + 1 ; k ++ ) { if ( strA [ i ] . substring ( k , k + b ) . equals ( strB [ 0 ] ) ) { for ( int j = 1 ; j != b + 1 ; j ++ ) { if ( j == b ) { fig = 1 ; break loop ; } if ( strA [ i + j ] . substring ( k , k + b ) . equals ( strB [ j ] ) ) { } else { break ; } } } } } System . out . println ( fig == 1 ? " Yes " : " No " ) ; } }

import java . util . Scanner ; public class Main { private static int m ; private static String [ ] [ ] a ; private static String [ ] [ ] b ; private static boolean matched ( int posx , int posy ) { for ( int i = 0 ; i < m ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( ! a [ posx + i ] [ posy + j ] . equals ( b [ i ] [ j ] ) ) { return false ; } } } return true ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; m = sc . nextInt ( ) ; a = new String [ n ] [ n ] ; b = new String [ m ] [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { String [ ] sa = sc . next ( ) . split ( " " ) ; for ( int j = 0 ; j < n ; j ++ ) { a [ i ] [ j ] = sa [ j ] ; } } for ( int i = 0 ; i < m ; i ++ ) { String [ ] sb = sc . next ( ) . split ( " " ) ; for ( int j = 0 ; j < m ; j ++ ) { b [ i ] [ j ] = sb [ j ] ; } } for ( int i = 0 ; i < n - m + 1 ; i ++ ) { for ( int j = 0 ; j < n - m + 1 ; j ++ ) { if ( matched ( i , j ) ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } }

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 ( ) , m = sc . nextInt ( ) ; String [ ] a = new String [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = sc . next ( ) ; } String [ ] b = new String [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { b [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < n - m + 1 ; i ++ ) { for ( int j = 0 ; j < n - m + 1 ; j ++ ) { boolean ans = true ; for ( int k = 0 ; k < m ; k ++ ) { for ( int l = 0 ; l < m ; l ++ ) { if ( a [ i + k ] . charAt ( j + l ) != b [ k ] . charAt ( l ) ) { ans = false ; } } } if ( ans ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } void run ( ) { Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) , M = Integer . parseInt ( sc . next ( ) ) ; String [ ] A = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { A [ i ] = sc . next ( ) ; } String [ ] B = new String [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { B [ i ] = sc . next ( ) ; } for ( int i = 0 ; i + M <= N ; i ++ ) { for ( int j = 0 ; j + M <= N ; j ++ ) { boolean yes = true ; for ( int k = 0 ; k < M ; k ++ ) { yes = yes && ( A [ i + k ] . substring ( j , j + M ) . equals ( B [ k ] ) ) ; } if ( yes ) { System . out . println ( " Yes " ) ; return ; } } } System . out . println ( " No " ) ; } }

n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a_list = [ input ( ) for _ in range ( n ) ] NEW_LINE b_list = [ input ( ) for _ in range ( m ) ] NEW_LINE for i in range ( n - m + 1 ) : NEW_LINE INDENT for j in range ( n - m + 1 ) : NEW_LINE INDENT f = True NEW_LINE for k in range ( m ) : NEW_LINE INDENT for l in range ( m ) : NEW_LINE INDENT if a_list [ i + k ] [ j + l ] != b_list [ k ] [ l ] : NEW_LINE INDENT f = False NEW_LINE break NEW_LINE DEDENT DEDENT if not f : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if f : NEW_LINE INDENT print ( " Yes " ) NEW_LINE exit ( ) NEW_LINE DEDENT DEDENT DEDENT print ( " No " ) NEW_LINE

def do_match ( A : list , B : list , offsets : tuple , size_B : int ) -> bool : NEW_LINE INDENT oh , ow = offsets NEW_LINE for h in range ( size_B ) : NEW_LINE INDENT for w in range ( size_B ) : NEW_LINE INDENT if A [ oh + h ] [ ow + w ] != B [ h ] [ w ] : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT DEDENT return True NEW_LINE DEDENT def template_matching ( N : int , M : int , A : list , B : list ) -> bool : NEW_LINE INDENT for offset_h in range ( N - M + 1 ) : NEW_LINE INDENT for offset_w in range ( N - M + 1 ) : NEW_LINE INDENT if do_match ( A , B , ( offset_h , offset_w ) , M ) : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT DEDENT return False NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 0 NEW_LINE M = 0 NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ input ( ) for _ in range ( N ) ] NEW_LINE B = [ input ( ) for _ in range ( M ) ] NEW_LINE yes = template_matching ( N , M , A , B ) NEW_LINE print ( ' Yes ' if yes else ' No ' ) NEW_LINE DEDENT

import numpy as np NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A . append ( list ( input ( ) ) ) NEW_LINE DEDENT B = [ ] NEW_LINE for i in range ( M ) : NEW_LINE INDENT B . append ( list ( input ( ) ) ) NEW_LINE DEDENT A = np . array ( A ) NEW_LINE B = np . array ( B ) NEW_LINE flag = False NEW_LINE for i in range ( N - M + 1 ) : NEW_LINE INDENT for j in range ( N - M + 1 ) : NEW_LINE INDENT if np . all ( A [ i : i + M , j : j + M ] == B ) : NEW_LINE INDENT flag = True NEW_LINE DEDENT DEDENT DEDENT if flag : NEW_LINE INDENT print ( ' Yes ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' No ' ) NEW_LINE DEDENT

N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A , B = [ ] , [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A . append ( input ( ) ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT B . append ( input ( ) ) NEW_LINE DEDENT ans = " " NEW_LINE for i in range ( N - M + 1 ) : NEW_LINE INDENT if B [ 0 ] in A [ i ] : NEW_LINE INDENT ans += " T " NEW_LINE y = A [ i ] . find ( B [ 0 ] ) NEW_LINE for j in range ( 1 , M ) : NEW_LINE INDENT if A [ i + j ] [ y : y + M ] == B [ j ] : NEW_LINE INDENT ans += " T " NEW_LINE DEDENT else : NEW_LINE INDENT ans += " F " NEW_LINE DEDENT DEDENT DEDENT DEDENT if " T " * M in ans : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT

from functools import reduce NEW_LINE import math NEW_LINE def main ( ) : NEW_LINE INDENT N , M = ( int ( _ ) for _ in input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE B = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A . append ( list ( _ for _ in input ( ) ) ) NEW_LINE DEDENT for i in range ( M ) : NEW_LINE INDENT B . append ( list ( _ for _ in input ( ) ) ) NEW_LINE DEDENT for i in range ( N - M + 1 ) : NEW_LINE INDENT for j in range ( N - M + 1 ) : NEW_LINE INDENT flag = True NEW_LINE for k in range ( M ) : NEW_LINE INDENT for l in range ( M ) : NEW_LINE INDENT if A [ i + k ] [ j + l ] != B [ k ] [ l ] : NEW_LINE INDENT flag = False NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT if ( flag ) : NEW_LINE INDENT ans = ' Yes ' NEW_LINE print ( ans ) NEW_LINE exit ( ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = ' No ' NEW_LINE DEDENT DEDENT DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextInt ( ) ; long a = sc . nextInt ( ) ; long b = sc . nextInt ( ) ; System . out . println ( ( x - a ) % b ) ; } }

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 x = in . nextInt ( ) ; int a = in . nextInt ( ) ; int b = in . nextInt ( ) ; out . println ( ( x - a ) % b ) ; } 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 . 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 ; public class Main { Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { new Main ( ) ; } public Main ( ) { new Test_100 ( ) . doIt ( ) ; } class Test_100 { void doIt ( ) { int X = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; int ans = ( X - A ) % B ; System . out . println ( ans ) ; } } }

import java . io . * ; import java . util . Scanner ; import java . lang . Math ; import java . util . Arrays ; import java . util . List ; import java . util . stream . Collectors ; class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int X = scanner . nextInt ( ) ; int A = scanner . nextInt ( ) ; int B = scanner . nextInt ( ) ; System . out . println ( X - A - ( X - A ) / B * B ) ; scanner . close ( ) ; } }

import java . util . * ; import java . io . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int a = Integer . parseInt ( sc . next ( ) ) ; int b = Integer . parseInt ( sc . next ( ) ) ; int c = Integer . parseInt ( sc . next ( ) ) ; a = a - b ; for ( ; ; ) { a -= c ; if ( a < c ) { break ; } } System . out . println ( a ) ; } }

x = int ( input ( ) ) NEW_LINE a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE print ( ( x - a ) % b ) NEW_LINE

x , a , b = map ( int , open ( 0 ) ) ; print ( ( x - a ) % b ) NEW_LINE

a = int ( input ( ) ) NEW_LINE b = int ( input ( ) ) NEW_LINE c = int ( input ( ) ) NEW_LINE print ( ( a - b ) % c ) NEW_LINE

X = int ( input ( ) ) NEW_LINE A = int ( input ( ) ) NEW_LINE B = int ( input ( ) ) NEW_LINE tmp = X - A NEW_LINE tmp = tmp - B * ( tmp // B ) NEW_LINE print ( tmp ) NEW_LINE

X , A , B = map ( int , [ input ( ) for i in range ( 3 ) ] ) NEW_LINE print ( ( X - A ) % B ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; int [ ] l = new int [ d ] ; int [ ] r = new int [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { l [ i ] = sc . nextInt ( ) ; r [ i ] = sc . nextInt ( ) ; } int [ ] s = new int [ k ] ; int [ ] t = new int [ k ] ; int [ ] now = new int [ k ] ; for ( int i = 0 ; i < k ; i ++ ) { s [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; now [ i ] = s [ i ] ; } sc . close ( ) ; int [ ] ans = new int [ k ] ; for ( int i = 0 ; i < d ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( ans [ j ] != 0 ) { continue ; } if ( l [ i ] <= now [ j ] && now [ j ] <= r [ i ] ) { if ( now [ j ] < t [ j ] ) { if ( t [ j ] <= r [ i ] ) { now [ j ] = t [ j ] ; ans [ j ] = i + 1 ; } else { now [ j ] = r [ i ] ; } } else { if ( t [ j ] >= l [ i ] ) { now [ j ] = t [ j ] ; ans [ j ] = i + 1 ; } else { now [ j ] = l [ i ] ; } } } } } for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ans [ i ] ) ; } } }

public class Main { private static java . util . Scanner scanner = new java . util . Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = scanner . nextInt ( ) , d = scanner . nextInt ( ) , k = scanner . nextInt ( ) ; int [ ] l = new int [ d ] , r = new int [ d ] , s = new int [ k ] , t = new int [ k ] , a = new int [ k ] ; boolean [ ] b = new boolean [ k ] ; for ( int i = 0 ; i < d ; i ++ ) { l [ i ] = scanner . nextInt ( ) ; r [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < k ; i ++ ) b [ i ] = ( s [ i ] = scanner . nextInt ( ) ) < ( t [ i ] = scanner . nextInt ( ) ) ; for ( int i = 0 ; i < d ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( l [ i ] <= s [ j ] && s [ j ] <= r [ i ] ) { s [ j ] = b [ j ] ? Math . max ( s [ j ] , r [ i ] ) : Math . min ( s [ j ] , l [ i ] ) ; if ( ( b [ j ] ? s [ j ] >= t [ j ] : s [ j ] <= t [ j ] ) && a [ j ] == 0 ) a [ j ] = i + 1 ; } } } java . util . Arrays . stream ( a ) . forEach ( System . out :: println ) ; } }

import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int D = scanner . nextInt ( ) ; int K = scanner . nextInt ( ) ; int [ ] L = new int [ D + 1 ] ; int [ ] R = new int [ D + 1 ] ; int [ ] S = new int [ K ] ; int [ ] T = new int [ K ] ; for ( int i = 1 ; i <= D ; i ++ ) { L [ i ] = scanner . nextInt ( ) ; R [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < K ; i ++ ) { S [ i ] = scanner . nextInt ( ) ; T [ i ] = scanner . nextInt ( ) ; } for ( int i = 0 ; i < K ; i ++ ) { int now = S [ i ] ; int day = 0 ; for ( int j = 1 ; j <= D ; j ++ ) { day ++ ; if ( S [ i ] < T [ i ] ) { if ( L [ j ] <= now && now <= R [ j ] ) { now = R [ j ] ; if ( now >= T [ i ] ) { System . out . println ( day ) ; break ; } } } else { if ( L [ j ] <= now && now <= R [ j ] ) { now = L [ j ] ; if ( now <= T [ i ] ) { System . out . println ( day ) ; break ; } } } } } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int d = sc . nextInt ( ) ; int k = sc . nextInt ( ) ; Area [ ] areas = new Area [ d ] ; for ( int i = 0 ; i < d ; i ++ ) { areas [ i ] = new Area ( sc . nextInt ( ) , sc . nextInt ( ) ) ; } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < k ; i ++ ) { int s = sc . nextInt ( ) ; int t = sc . nextInt ( ) ; int now = s ; boolean up = t > s ; for ( int j = 0 ; j < d ; j ++ ) { if ( areas [ j ] . left <= now && areas [ j ] . right >= now ) { if ( areas [ j ] . left <= t && areas [ j ] . right >= t ) { sb . append ( j + 1 ) . append ( " \n " ) ; break ; } if ( up ) { if ( now < areas [ j ] . right ) { now = areas [ j ] . right ; } } else { if ( now > areas [ j ] . left ) { now = areas [ j ] . left ; } } } } } System . out . print ( sb ) ; } static class Area { int left ; int right ; public Area ( int left , int right ) { this . left = left ; this . right = right ; } } }

import java . util . * ; import java . lang . * ; public class Main { static int n ; static int d ; static int k ; static int [ ] l ; static int [ ] r ; static int [ ] s ; static int [ ] t ; public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; d = sc . nextInt ( ) ; k = sc . nextInt ( ) ; l = new int [ d ] ; r = new int [ d ] ; s = new int [ k ] ; t = new int [ k ] ; int [ ] ans = new int [ k ] ; for ( int i = 0 ; i < d ; i ++ ) { l [ i ] = sc . nextInt ( ) ; r [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < k ; i ++ ) { s [ i ] = sc . nextInt ( ) ; t [ i ] = sc . nextInt ( ) ; } for ( int i = 0 ; i < d ; i ++ ) { for ( int j = 0 ; j < k ; j ++ ) { if ( l [ i ] <= s [ j ] && s [ j ] <= r [ i ] && s [ j ] != t [ j ] ) { if ( t [ j ] < s [ j ] && t [ j ] < l [ i ] ) { s [ j ] = l [ i ] ; } else if ( ( t [ j ] < s [ j ] && l [ i ] <= t [ j ] ) || ( s [ j ] < t [ j ] && t [ j ] <= r [ i ] ) ) { s [ j ] = t [ j ] ; ans [ j ] = i + 1 ; } else if ( s [ j ] < t [ j ] && r [ i ] < t [ j ] ) { s [ j ] = r [ i ] ; } } } } for ( int i = 0 ; i < k ; i ++ ) { System . out . println ( ans [ i ] ) ; } } }

n , d , k = map ( int , input ( ) . split ( ) ) NEW_LINE rst = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( d ) ] NEW_LINE dd = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( k ) ] NEW_LINE for dpt , dst in dd : NEW_LINE INDENT min_cur , max_cur = dpt , dpt NEW_LINE for i , ( s , e ) in enumerate ( rst ) : NEW_LINE INDENT if not ( min_cur <= s <= max_cur or min_cur <= e <= max_cur or s <= min_cur <= e or s <= max_cur <= e ) : NEW_LINE INDENT continue NEW_LINE DEDENT else : NEW_LINE INDENT if min_cur > s : NEW_LINE INDENT min_cur = s NEW_LINE DEDENT if max_cur < e : NEW_LINE INDENT max_cur = e NEW_LINE DEDENT if min_cur <= dst <= max_cur : NEW_LINE INDENT print ( i + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT

def ethnic_large_movement ( N : int , D : int , K : int , LR : list , ST : list ) -> list : NEW_LINE INDENT ret = [ 0 ] * K NEW_LINE defined = 0 NEW_LINE for d , ( l , r ) in enumerate ( LR ) : NEW_LINE INDENT for k , ( s , t ) in enumerate ( ST ) : NEW_LINE INDENT if ret [ k ] > 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if s < t : NEW_LINE INDENT if r < s or s < l : NEW_LINE INDENT continue NEW_LINE DEDENT if r < t : NEW_LINE INDENT ST [ k ] = ( r , t ) NEW_LINE DEDENT else : NEW_LINE INDENT ST [ k ] = ( t , t ) NEW_LINE ret [ k ] = d + 1 NEW_LINE defined += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if r < s or s < l : NEW_LINE INDENT continue NEW_LINE DEDENT if t < l : NEW_LINE INDENT ST [ k ] = ( l , t ) NEW_LINE DEDENT else : NEW_LINE INDENT ST [ k ] = ( t , t ) NEW_LINE ret [ k ] = d + 1 NEW_LINE defined += 1 NEW_LINE DEDENT DEDENT DEDENT if defined == K : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT return ret NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT D = 0 NEW_LINE K = 0 NEW_LINE N , D , K = map ( int , input ( ) . split ( ) ) NEW_LINE LR = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( D ) ] NEW_LINE ST = [ tuple ( int ( s ) for s in input ( ) . split ( ) ) for _ in range ( K ) ] NEW_LINE ans = ethnic_large_movement ( N , D , K , LR , ST ) NEW_LINE for a in ans : NEW_LINE INDENT print ( a ) NEW_LINE DEDENT DEDENT

N , D , K = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE LR = [ ] NEW_LINE for i in range ( D ) : NEW_LINE INDENT LR . append ( list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) ) NEW_LINE DEDENT tribePosition = [ 0 for i in range ( K ) ] NEW_LINE destination = [ 0 for i in range ( K ) ] NEW_LINE direction = [ 0 for i in range ( K ) ] NEW_LINE for i in range ( K ) : NEW_LINE INDENT tribePosition [ i ] , destination [ i ] = list ( map ( int , input ( ) . rstrip ( ) . split ( ) ) ) NEW_LINE if tribePosition [ i ] - destination [ i ] > 0 : NEW_LINE INDENT direction [ i ] = 0 NEW_LINE DEDENT elif tribePosition [ i ] - destination [ i ] < 0 : NEW_LINE INDENT direction [ i ] = 1 NEW_LINE DEDENT DEDENT ans_days = [ 0 for i in range ( K ) ] NEW_LINE for i in range ( D ) : NEW_LINE INDENT for j in range ( K ) : NEW_LINE INDENT if ans_days [ j ] == 0 : NEW_LINE INDENT if LR [ i ] [ 0 ] <= tribePosition [ j ] <= LR [ i ] [ 1 ] : NEW_LINE INDENT if LR [ i ] [ 0 ] <= destination [ j ] <= LR [ i ] [ 1 ] : NEW_LINE INDENT ans_days [ j ] = i + 1 NEW_LINE DEDENT elif direction [ j ] : NEW_LINE INDENT tribePosition [ j ] = LR [ i ] [ 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT tribePosition [ j ] = LR [ i ] [ 0 ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT for i in range ( K ) : NEW_LINE INDENT print ( ans_days [ i ] ) NEW_LINE DEDENT

n , d , k = map ( int , input ( ) . split ( ) ) NEW_LINE move = [ ] NEW_LINE for i in range ( d ) : NEW_LINE INDENT x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE move . append ( x ) NEW_LINE DEDENT for i in range ( k ) : NEW_LINE INDENT s , t = map ( int , input ( ) . split ( ) ) NEW_LINE start = s NEW_LINE end = s NEW_LINE if s < t : NEW_LINE INDENT for j in range ( len ( move ) ) : NEW_LINE INDENT if move [ j ] [ 0 ] <= start : NEW_LINE INDENT end = max ( end , move [ j ] [ 1 ] ) NEW_LINE start = end NEW_LINE DEDENT if end >= t : NEW_LINE INDENT print ( j + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for j in range ( len ( move ) ) : NEW_LINE INDENT if move [ j ] [ 1 ] >= start : NEW_LINE INDENT end = min ( end , move [ j ] [ 0 ] ) NEW_LINE start = end NEW_LINE DEDENT if end <= t : NEW_LINE INDENT print ( j + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT DEDENT

import sys , itertools NEW_LINE input = sys . stdin . readline NEW_LINE N , D , K = map ( int , input ( ) . split ( ) ) NEW_LINE info1 = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( D ) ] NEW_LINE info2 = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( K ) ] NEW_LINE for s , t in info2 : NEW_LINE INDENT now = s NEW_LINE day = 0 NEW_LINE for l , r in info1 : NEW_LINE INDENT day += 1 NEW_LINE if l <= now <= r : NEW_LINE INDENT if l <= t <= r : NEW_LINE INDENT print ( day ) NEW_LINE break NEW_LINE DEDENT elif t < l : NEW_LINE INDENT now = l NEW_LINE DEDENT elif r < t : NEW_LINE INDENT now = r NEW_LINE DEDENT DEDENT DEDENT DEDENT


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 ( ) ; sc . close ( ) ; if ( n == 0 ) { System . out . println ( 0 ) ; return ; } int [ ] rem = new int [ 40 ] ; for ( int i = 0 ; i < rem . length ; i ++ ) { rem [ i ] = n % - 2 ; n /= - 2 ; if ( rem [ i ] == - 1 ) { n ++ ; rem [ i ] = 1 ; } } int i = rem . length - 1 ; for ( ; i >= 0 ; i -- ) { if ( rem [ i ] == 1 ) { break ; } } for ( ; i >= 0 ; i -- ) { System . out . print ( rem [ i ] ) ; } System . out . println ( ) ; } }

import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; StringBuilder sb = new StringBuilder ( ) ; if ( n == 0 ) { System . out . println ( 0 ) ; return ; } while ( n != 0 ) { if ( n % - 2 == 0 ) { sb . append ( "0" ) ; n /= - 2 ; } else { sb . append ( "1" ) ; if ( n < 0 ) { n /= - 2 ; n ++ ; } else { n /= - 2 ; } } } String xx = sb . reverse ( ) . toString ( ) ; System . out . println ( xx ) ; } } class Pair implements Comparable { int from ; int end ; int num ; int bango ; @ Override public int compareTo ( Object other ) { Pair otherpair = ( Pair ) other ; return from - otherpair . from ; } }

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 ) ; ABC105_C solver = new ABC105_C ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ABC105_C { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long n = in . nextLong ( ) ; StringBuffer sb = new StringBuffer ( ) ; while ( true ) { if ( n % 2 != 0 ) { sb . append ( 1 ) ; n -- ; } else { sb . append ( 0 ) ; } if ( n == 0 ) { break ; } else { n /= - 2 ; } } out . print ( sb . reverse ( ) . toString ( ) ) ; } } }

import java . util . Scanner ; class Main { public static int ketasu ( int n ) { if ( n >= 0 ) { int ketasu = 1 ; long jougen = 1 ; long base = 1 ; for ( int i = 0 ; n > jougen ; i ++ ) { ketasu = ketasu + 2 ; base *= 4 ; jougen += base ; } return ketasu ; } else { int ketasu = 0 ; long jougen = 0 ; long base = - 2 ; for ( int i = 0 ; n < jougen ; i ++ ) { ketasu = ketasu + 2 ; jougen += base ; base *= 4 ; } return ketasu ; } } public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int n = scanner . nextInt ( ) ; scanner . close ( ) ; int ketasu = ketasu ( n ) ; char [ ] ans = new char [ ketasu ] ; for ( int index = ketasu - 1 ; index >= 0 ; index -- ) { if ( n % 2 == 0 ) { ans [ index ] = '0' ; n /= - 2 ; } else { ans [ index ] = '1' ; n = n - 1 ; n /= - 2 ; } } System . out . println ( String . valueOf ( ans ) ) ; } }

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 ( ) ; List < Integer > tmp = new ArrayList ( ) ; if ( N == 0 ) { tmp . add ( 0 ) ; } else { int base = - 2 ; while ( N != 1 ) { int mod = N % base ; switch ( mod ) { case - 1 : tmp . add ( 1 ) ; N = N / base + 1 ; break ; default : tmp . add ( mod ) ; N = N / base ; } } tmp . add ( N ) ; Collections . reverse ( tmp ) ; } String ans = " " ; for ( int i = 0 ; i < tmp . size ( ) ; i ++ ) { ans += Integer . toString ( tmp . get ( i ) ) ; } out . println ( ans ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

N = int ( input ( ) ) NEW_LINE a = ' ' NEW_LINE n = 0 NEW_LINE while N != 0 : NEW_LINE INDENT b = '0' if N % ( 2 ** ( n + 1 ) ) == 0 else '1' NEW_LINE a += b NEW_LINE N -= ( ( - 2 ) ** n ) * int ( b ) NEW_LINE n += 1 NEW_LINE DEDENT print ( a [ : : - 1 ] if a else 0 ) NEW_LINE

import sys NEW_LINE import itertools NEW_LINE import collections NEW_LINE import functools NEW_LINE import math NEW_LINE from queue import Queue NEW_LINE INF = float ( " inf " ) NEW_LINE def solve ( N : int ) : NEW_LINE INDENT ans = [ ] NEW_LINE kari = 0 NEW_LINE p = 1 NEW_LINE for i in range ( 40 ) : NEW_LINE INDENT c = N & 1 NEW_LINE if c == ( ( kari >> i ) & 1 ) : NEW_LINE INDENT ans . append ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( 1 ) NEW_LINE kari += p NEW_LINE DEDENT N >>= 1 NEW_LINE p *= - 2 NEW_LINE DEDENT if 1 in ans : NEW_LINE INDENT i = ans [ : : - 1 ] . index ( 1 ) NEW_LINE print ( * ans [ : : - 1 ] [ i : ] , sep = " " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT 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 solve ( N ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import sys NEW_LINE def solve ( N : int ) : NEW_LINE INDENT if N == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE return NEW_LINE DEDENT result = " " NEW_LINE div = 2 NEW_LINE while N != 0 : NEW_LINE INDENT divided = N % div NEW_LINE N -= divided NEW_LINE if divided != 0 : NEW_LINE INDENT result = "1" + result NEW_LINE DEDENT else : NEW_LINE INDENT result = "0" + result NEW_LINE DEDENT div *= - 2 NEW_LINE DEDENT print ( result ) 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 solve ( N ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

N = int ( input ( ) ) NEW_LINE if N == 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = " " NEW_LINE x = 0 NEW_LINE keta = 0 NEW_LINE while x != N : NEW_LINE INDENT if ( N - x ) % 2 ** ( keta + 1 ) == 0 : NEW_LINE INDENT ans = "0" + ans NEW_LINE DEDENT else : NEW_LINE INDENT ans = "1" + ans NEW_LINE x += ( - 2 ) ** keta NEW_LINE DEDENT keta += 1 NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT

N = int ( input ( ) ) NEW_LINE ans = [ ] NEW_LINE while ( 1 ) : NEW_LINE INDENT if ( N == 1 ) : NEW_LINE INDENT ans . append ( '1' ) NEW_LINE break NEW_LINE DEDENT elif ( N == 0 ) : NEW_LINE INDENT ans . append ( '0' ) NEW_LINE break NEW_LINE DEDENT if ( N % ( - 2 ) == - 1 ) : NEW_LINE INDENT ans . append ( '1' ) NEW_LINE N = N // ( - 2 ) + 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( '0' ) NEW_LINE N = N // ( - 2 ) NEW_LINE DEDENT DEDENT ans . reverse ( ) NEW_LINE ans_str = ' ' . join ( ans ) NEW_LINE print ( ans_str ) NEW_LINE


import java . util . Scanner ; public class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = s . nextInt ( ) , sum = 0 ; for ( ; n > 0 ; n -- ) { sum += Math . max ( 0 , 80 - s . nextInt ( ) ) ; } System . out . println ( sum ) ; } }

import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int n = sc . nextInt ( ) ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { ans += max ( 80 - sc . nextInt ( ) , 0 ) ; } out . println ( ans ) ; } }

import java . util . * ; public class Main { private static Scanner scanner = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { System . out . println ( java . util . stream . IntStream . range ( 0 , scanner . nextInt ( ) ) . map ( i -> scanner . nextInt ( ) ) . filter ( m -> m < 80 ) . map ( m -> 80 - m ) . sum ( ) ) ; } }

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

import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int sub = sc . nextInt ( ) ; int ten = 0 ; for ( int i = 0 ; i < sub ; i ++ ) { ten += Math . max ( 0 , 80 - sc . nextInt ( ) ) ; } System . out . println ( ten ) ; } }

N = int ( input ( ) ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE res = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT if L [ i ] >= 80 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT res += 80 - L [ i ] NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE

n , m = open ( 0 ) ; print ( sum ( max ( 0 , 80 - int ( i ) ) for i in m . split ( ) ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE m = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE sum = 0 NEW_LINE for i in m : NEW_LINE INDENT sum += max ( 0 , 80 - i ) NEW_LINE DEDENT print ( sum ) NEW_LINE

n = int ( input ( ) ) NEW_LINE m = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE sum_time = 0 NEW_LINE def time_for_test ( score ) : NEW_LINE INDENT gap = 80 - score NEW_LINE if gap <= 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return gap NEW_LINE DEDENT DEDENT for i in range ( n ) : NEW_LINE INDENT sum_time = sum_time + time_for_test ( m [ i ] ) NEW_LINE DEDENT print ( sum_time ) NEW_LINE

n , * t = map ( int , open ( 0 ) . read ( ) . split ( ) ) ; print ( sum ( ( 80 - i ) * ( i < 80 ) for i in t ) ) NEW_LINE


import java . util . * ; import java . awt . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; int ans1 = ( int ) 1e9 + 4 ; int ans2 = ( int ) 1e9 + 4 ; int ans3 = ( int ) 1e9 + 4 ; int ans4 = ( int ) 1e9 + 4 ; if ( - x <= - y ) ans1 = - y + x + 2 ; if ( - x <= y ) ans2 = y + x + 1 ; if ( x <= y ) ans3 = y - x ; if ( x <= - y ) ans4 = - y - x + 1 ; out . println ( min ( min ( ans1 , ans2 ) , min ( ans3 , ans4 ) ) ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; import java . io . IOException ; import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; LightScanner in = new LightScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; ASimpleCalculator solver = new ASimpleCalculator ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class ASimpleCalculator { public void solve ( int testNumber , LightScanner in , PrintWriter out ) { int x = in . ints ( ) , y = in . ints ( ) ; int ans = Integer . MAX_VALUE ; if ( x <= y ) { ans = Math . min ( ans , y - x ) ; } if ( x <= - y ) { ans = Math . min ( ans , 1 - x - y ) ; } if ( - x <= y ) { ans = Math . min ( ans , 1 + x + y ) ; } if ( - x <= - y ) { ans = Math . min ( ans , 2 - y + x ) ; } out . println ( ans ) ; } } static class LightScanner { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public LightScanner ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String string ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int ints ( ) { return Integer . parseInt ( string ( ) ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int x = sc . nextInt ( ) ; int y = sc . nextInt ( ) ; sc . close ( ) ; if ( x == y ) { System . out . println ( 0 ) ; } else if ( - x == y ) { System . out . println ( 1 ) ; } else if ( x < 0 && y < 0 ) { if ( Math . abs ( x ) <= Math . abs ( y ) ) { System . out . println ( 2 + Math . abs ( y - x ) ) ; } else { System . out . println ( Math . abs ( y - x ) ) ; } } else if ( x < 0 && y > 0 ) { if ( Math . abs ( x ) <= Math . abs ( y ) ) { System . out . println ( 1 + Math . abs ( y + x ) ) ; } else { System . out . println ( Math . abs ( y + x ) + 1 ) ; } } else if ( x > 0 && y < 0 ) { System . out . println ( 1 + Math . abs ( y + x ) ) ; } else if ( x > 0 && y > 0 ) { if ( Math . abs ( x ) <= Math . abs ( y ) ) { System . out . println ( Math . abs ( y - x ) ) ; } else { System . out . println ( 2 + Math . abs ( y - x ) ) ; } } if ( x == 0 && y == 0 ) { System . out . println ( 0 ) ; } else if ( x == 0 && y > 0 ) { System . out . println ( y ) ; } else if ( x == 0 && y < 0 ) { System . out . println ( - y + 1 ) ; } else if ( x > 0 && y == 0 ) { System . out . println ( x + 1 ) ; } else if ( x < 0 && y == 0 ) { System . out . println ( - x ) ; } } }

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

import java . util . * ; import java . lang . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long x = sc . nextLong ( ) ; long y = sc . nextLong ( ) ; long count = 10000000000L ; long tmp = y - x ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } tmp = y - x * - 1 + 1 ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } tmp = y * - 1 - x + 1 ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } tmp = y * - 1 - x * - 1 + 2 ; if ( tmp >= 0 ) { count = Math . min ( tmp , count ) ; } System . out . println ( count ) ; } }

x , y = map ( int , input ( ) . split ( ) ) NEW_LINE if abs ( x ) == abs ( y ) : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT elif abs ( x ) < abs ( y ) : NEW_LINE INDENT if y > 0 : NEW_LINE INDENT if x >= 0 : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if x >= 0 : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( y ) - abs ( x ) + 2 ) NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT if x < 0 : NEW_LINE INDENT if y <= 0 : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) + 1 ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if y <= 0 : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) + 1 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( abs ( x ) - abs ( y ) + 2 ) NEW_LINE DEDENT DEDENT DEDENT

def solve ( ) : NEW_LINE INDENT x , y = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE ans = [ ] NEW_LINE if x <= y : NEW_LINE INDENT ans . append ( y - x ) NEW_LINE DEDENT if - x <= y : NEW_LINE INDENT ans . append ( y + x + 1 ) NEW_LINE DEDENT if x <= - y : NEW_LINE INDENT ans . append ( - y - x + 1 ) NEW_LINE DEDENT if - x <= - y : NEW_LINE INDENT ans . append ( x - y + 2 ) NEW_LINE DEDENT return ( min ( ans ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( ) ) NEW_LINE DEDENT

input_nums = [ int ( c ) for c in input ( ) . split ( " ▁ " ) ] NEW_LINE x = input_nums [ 0 ] NEW_LINE y = input_nums [ 1 ] NEW_LINE ad = 0 NEW_LINE if x > y : NEW_LINE INDENT ad = 2 NEW_LINE DEDENT if ( x < 0 and y > 0 ) or ( x >= 0 and y <= 0 ) : NEW_LINE INDENT ad = 1 NEW_LINE DEDENT if x == y : NEW_LINE INDENT ad = 0 NEW_LINE DEDENT x , y = abs ( x ) , abs ( y ) NEW_LINE print ( abs ( x - y ) + ad ) 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 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 x , y = LI ( ) NEW_LINE if abs ( x ) <= abs ( y ) : NEW_LINE INDENT cnt = abs ( y ) - abs ( x ) NEW_LINE if x >= 0 : NEW_LINE INDENT if y < 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if y >= 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += 2 NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT cnt = abs ( x ) - abs ( y ) NEW_LINE if x <= 0 : NEW_LINE INDENT if y > 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if y <= 0 : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += 2 NEW_LINE DEDENT DEDENT DEDENT return cnt NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

x , y = map ( int , input ( ) . split ( ) ) NEW_LINE cnt = float ( ' inf ' ) NEW_LINE for first , add_cnt_f in ( - 1 , 1 ) , ( 1 , 0 ) : NEW_LINE INDENT xx = x * first NEW_LINE for last , add_cnt_l in ( - 1 , 1 ) , ( 1 , 0 ) : NEW_LINE INDENT yy = y * last NEW_LINE if yy >= xx : NEW_LINE INDENT cnt = min ( cnt , add_cnt_f + add_cnt_l + yy - xx ) NEW_LINE DEDENT DEDENT DEDENT print ( cnt ) NEW_LINE


import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { long PRIME = 1000000007 ; Scanner sc = new Scanner ( System . in ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int M = Integer . parseInt ( sc . next ( ) ) ; long [ ] x = new long [ N ] ; long [ ] y = new long [ M ] ; for ( int i = 0 ; i < N ; i ++ ) x [ i ] = Long . parseLong ( sc . next ( ) ) ; for ( int j = 0 ; j < M ; j ++ ) y [ j ] = Long . parseLong ( sc . next ( ) ) ; Arrays . sort ( x ) ; Arrays . sort ( y ) ; long xans = 0 ; long yans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { xans = ( xans + ( i - ( N - 1 - i ) ) * x [ i ] ) % PRIME ; } for ( int j = 0 ; j < M ; j ++ ) { yans = ( yans + ( j - ( M - 1 - j ) ) * y [ j ] ) % PRIME ; } System . out . println ( ( xans * yans ) % PRIME ) ; sc . close ( ) ; } }

import java . io . * ; import java . util . * ; class Main { static final long MOD = 1000000007 ; static long f ( long [ ] a ) { int n = a . length ; long ans = 0 ; for ( int i = 0 ; i < n ; ++ i ) { a [ i ] %= MOD ; if ( a [ i ] < 0 ) a [ i ] += MOD ; long f = ( 2 * i - n + 1 + MOD ) % MOD ; ans = ( ans + f * a [ i ] ) % MOD ; } return ans ; } public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; out = new PrintWriter ( new BufferedOutputStream ( System . out ) ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; long [ ] x = new long [ n ] , y = new long [ m ] ; for ( int i = 0 ; i < n ; ++ i ) x [ i ] = sc . nextLong ( ) ; for ( int i = 0 ; i < m ; ++ i ) y [ i ] = sc . nextLong ( ) ; out . println ( f ( x ) * f ( y ) % MOD ) ; out . close ( ) ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . * ; import java . io . * ; import java . awt . geom . * ; import java . math . * ; public class Main { static final Scanner in = new Scanner ( System . in ) ; static final PrintWriter out = new PrintWriter ( System . out , false ) ; static boolean debug = false ; static final long MOD = 1_000_000_007 ; static void solve ( ) { int n = in . nextInt ( ) ; int m = in . nextInt ( ) ; long [ ] x = new long [ n ] ; long [ ] y = new long [ m ] ; long sumX = 0 , sumY = 0 ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = in . nextInt ( ) ; if ( i != 0 ) sumX = ( sumX + ( x [ i ] - x [ i - 1 ] ) * i % MOD * ( n - i ) % MOD ) % MOD ; } for ( int i = 0 ; i < m ; i ++ ) { y [ i ] = in . nextInt ( ) ; if ( i != 0 ) sumY = ( sumY + ( y [ i ] - y [ i - 1 ] ) * i % MOD * ( m - i ) % MOD ) % MOD ; } out . println ( sumX * sumY % MOD ) ; } public static void main ( String [ ] args ) { debug = args . length > 0 ; long start = System . nanoTime ( ) ; solve ( ) ; out . flush ( ) ; long end = System . nanoTime ( ) ; dump ( ( end - start ) / 1000000 + " ▁ ms " ) ; in . close ( ) ; out . close ( ) ; } static void dump ( Object ... o ) { if ( debug ) System . err . println ( Arrays . deepToString ( o ) ) ; } }

import java . util . * ; class Main { static int mod = 1000000007 ; static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = s . nextInt ( ) - 1 , m = s . nextInt ( ) - 1 ; long [ ] a = new long [ n ] , b = new long [ m ] ; f ( a ) ; f ( b ) ; System . err . println ( Arrays . toString ( a ) ) ; System . err . println ( Arrays . toString ( b ) ) ; long A = g ( n , a ) , B = g ( m , b ) ; System . out . println ( A * B % mod ) ; } static void f ( long [ ] a ) { long p = s . nextLong ( ) ; for ( int i = 0 ; i < a . length ; ++ i ) { long q = s . nextLong ( ) ; a [ i ] = q - p ; p = q ; } } static long g ( int n , long [ ] a ) { long A = 0 ; for ( int i = 0 ; i < n ; ++ i ) { long p = Math . min ( i , n - 1 - i ) ; A += ( ( p + 1 ) * p + ( n - p * 2 ) * ( p + 1 ) ) % mod * a [ i ] ; A %= mod ; } return A ; } }

import java . util . * ; public class Main { int ni ( ) { return cin . nextInt ( ) ; } long nl ( ) { return cin . nextLong ( ) ; } String line ( ) { return cin . nextLine ( ) ; } void println ( String str ) { System . out . println ( str ) ; } void print ( String str ) { System . out . print ( str ) ; } static final int MOD = 1000000007 ; Scanner cin = new Scanner ( System . in ) ; String output ; public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { input ( ) ; int res = solve ( ) ; output = res + " " ; println ( output ) ; } int n , m ; long [ ] x ; long [ ] y ; void input ( ) { n = ni ( ) ; m = ni ( ) ; x = new long [ n ] ; y = new long [ m ] ; for ( int i = 0 ; i < n ; i ++ ) { x [ i ] = nl ( ) ; } for ( int j = 0 ; j < m ; j ++ ) { y [ j ] = nl ( ) ; } } int solve ( ) { long xsum = 0 , ysum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { xsum += x [ i ] * i - x [ i ] * ( n - i - 1 ) ; xsum %= MOD ; } for ( int i = 0 ; i < m ; i ++ ) { ysum += y [ i ] * i - y [ i ] * ( m - i - 1 ) ; ysum %= MOD ; } return ( int ) ( ( xsum * ysum ) % MOD ) ; } }

import collections NEW_LINE mod = 1000000007 NEW_LINE def solve ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE x = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE y = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE X = int ( ) NEW_LINE for i in range ( 1 , n ) : NEW_LINE INDENT X += ( x [ i ] - x [ i - 1 ] ) * i * ( n - i ) NEW_LINE X %= mod NEW_LINE DEDENT Y = int ( ) NEW_LINE for i in range ( 1 , m ) : NEW_LINE INDENT Y += ( y [ i ] - y [ i - 1 ] ) * i * ( m - i ) NEW_LINE Y %= mod NEW_LINE DEDENT print ( ( X * Y ) % mod ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT solve ( ) NEW_LINE DEDENT

from operator import mul NEW_LINE n , m = map ( int , input ( ) . split ( ) ) NEW_LINE xs = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE ys = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE fX = sum ( map ( mul , xs , range ( - n + 1 , n + 1 , 2 ) ) ) % MOD NEW_LINE fY = sum ( map ( mul , ys , range ( - m + 1 , m + 1 , 2 ) ) ) % MOD NEW_LINE print ( ( fX * fY ) % MOD ) NEW_LINE

def getN ( ) : NEW_LINE INDENT return int ( input ( ) ) NEW_LINE DEDENT def getMN ( ) : NEW_LINE INDENT a = input ( ) . split ( ) NEW_LINE b = [ int ( i ) for i in a ] NEW_LINE return b [ 0 ] , b [ 1 ] NEW_LINE DEDENT def getlist ( ) : NEW_LINE INDENT a = input ( ) . split ( ) NEW_LINE b = [ int ( i ) for i in a ] NEW_LINE return b NEW_LINE DEDENT MOD = 1000000007 NEW_LINE n , m = getMN ( ) NEW_LINE anums = getlist ( ) NEW_LINE bnums = getlist ( ) NEW_LINE def calc_accum_width ( nums ) : NEW_LINE INDENT x_pos_acc = 0 NEW_LINE x_width_acc = 0 NEW_LINE for i , a in enumerate ( nums ) : NEW_LINE INDENT x_width_acc += a * i - x_pos_acc NEW_LINE x_pos_acc += a NEW_LINE DEDENT return x_width_acc NEW_LINE DEDENT x_acc = calc_accum_width ( anums ) NEW_LINE y_acc = calc_accum_width ( bnums ) NEW_LINE print ( x_acc * y_acc % MOD ) NEW_LINE

def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def make ( N ) : NEW_LINE INDENT if N % 2 : NEW_LINE INDENT L = [ N + ( N // 2 ) ** 2 - n ** 2 + 2 * n - 1 for n in range ( 1 , N // 2 + 2 ) ] NEW_LINE L = L [ 1 : : ] [ : : - 1 ] + L NEW_LINE return L NEW_LINE DEDENT else : NEW_LINE INDENT L = [ N + N * ( N - 2 ) // 4 - n ** 2 + n for n in range ( 1 , N // 2 + 1 ) ] NEW_LINE L = L [ : : - 1 ] + L NEW_LINE return L NEW_LINE DEDENT DEDENT N , M = inpl ( ) NEW_LINE X = inpl ( ) NEW_LINE Y = inpl ( ) NEW_LINE A = make ( N - 1 ) NEW_LINE B = make ( M - 1 ) NEW_LINE Sx = 0 NEW_LINE Sy = 0 NEW_LINE for i , a in enumerate ( A ) : NEW_LINE INDENT Sx += a * ( X [ i + 1 ] - X [ i ] ) NEW_LINE DEDENT for j , b in enumerate ( B ) : NEW_LINE INDENT Sy += b * ( Y [ j + 1 ] - Y [ j ] ) NEW_LINE DEDENT print ( ( Sx * Sy ) % ( 10 ** 9 + 7 ) ) NEW_LINE

mod = 10 ** 9 + 7 NEW_LINE def sum_subarrays ( A ) : NEW_LINE INDENT N = len ( A ) NEW_LINE S = [ 0 ] NEW_LINE for a in A : NEW_LINE INDENT S . append ( S [ - 1 ] + a ) NEW_LINE S [ - 1 ] %= mod NEW_LINE DEDENT return sum ( ( 2 * i - N - 1 ) * s % mod for i , s in enumerate ( S ) ) % mod NEW_LINE DEDENT N , M = map ( int , input ( ) . split ( ) ) NEW_LINE X = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE Y = [ 0 ] + list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE diff_X = [ X [ i + 1 ] - X [ i ] for i in range ( N ) ] NEW_LINE diff_Y = [ Y [ i + 1 ] - Y [ i ] for i in range ( M ) ] NEW_LINE print ( sum_subarrays ( diff_X ) * sum_subarrays ( diff_Y ) % mod ) NEW_LINE


import java . util . Arrays ; import java . util . Comparator ; import java . util . PriorityQueue ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } public void run ( ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] [ ] a = new int [ n ] [ m ] ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { a [ i ] [ j ] = sc . nextInt ( ) ; -- a [ i ] [ j ] ; } } boolean [ ] invalid = new boolean [ m ] ; int ans = Integer . MAX_VALUE ; for ( int t = 0 ; t < m ; ++ t ) { int [ ] cnt = new int [ m ] ; for ( int i = 0 ; i < n ; ++ i ) { for ( int j = 0 ; j < m ; ++ j ) { if ( invalid [ a [ i ] [ j ] ] ) continue ; ++ cnt [ a [ i ] [ j ] ] ; break ; } } int max = 0 ; for ( int i = 0 ; i < m ; ++ i ) { max = Math . max ( max , cnt [ i ] ) ; } ans = Math . min ( ans , max ) ; for ( int i = 0 ; i < m ; ++ i ) { if ( cnt [ i ] == max ) { invalid [ i ] = true ; break ; } } } System . out . println ( ans ) ; } void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; ArrayList [ ] a = new ArrayList [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { a [ i ] = new ArrayList < Integer > ( ) ; for ( int j = 0 ; j < m ; j ++ ) { a [ i ] . add ( sc . nextInt ( ) - 1 ) ; } } int min = n ; for ( int i = 0 ; i < m ; i ++ ) { int [ ] mnum = new int [ m ] ; for ( int j = 0 ; j < n ; j ++ ) { mnum [ ( int ) ( a [ j ] . get ( 0 ) ) ] ++ ; } int max = 0 , maxpos = 0 ; for ( int j = 0 ; j < m ; j ++ ) { if ( mnum [ j ] > max ) { max = mnum [ j ] ; maxpos = j ; } } if ( max < min ) min = max ; for ( int j = 0 ; j < n ; j ++ ) { a [ j ] . removeAll ( Arrays . asList ( new Integer [ ] { maxpos } ) ) ; } } System . out . println ( min ) ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT a = [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE A . append ( a ) NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT res = [ 0 for x in range ( M + 1 ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT res [ A [ i ] [ 0 ] ] += 1 NEW_LINE DEDENT ans = max ( res ) NEW_LINE jud = res . index ( ans ) NEW_LINE for j in range ( N ) : NEW_LINE INDENT A [ j ] . remove ( jud ) NEW_LINE DEDENT return ans NEW_LINE DEDENT minans = N NEW_LINE for i in range ( M ) : NEW_LINE INDENT minans = min ( solve ( ) , minans ) NEW_LINE DEDENT print ( minans ) NEW_LINE

from collections import Counter NEW_LINE N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = [ [ ] for _ in range ( N ) ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT A [ i ] = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE DEDENT V = [ 1 ] * ( M + 1 ) NEW_LINE ans = N NEW_LINE for _ in range ( M - 1 ) : NEW_LINE INDENT W = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT while True : NEW_LINE INDENT if V [ A [ i ] [ 0 ] ] == 1 : NEW_LINE INDENT W . append ( A [ i ] [ 0 ] ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT A [ i ] . pop ( 0 ) NEW_LINE DEDENT DEDENT DEDENT a , c = Counter ( W ) . most_common ( ) [ 0 ] NEW_LINE ans = min ( ans , c ) NEW_LINE V [ a ] = 0 NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys , math , copy NEW_LINE HUGE = 2147483647 NEW_LINE HUGEL = 9223372036854775807 NEW_LINE ABC = " abcdefghijklmnopqrstuvwxyz " NEW_LINE def each_attend ( anm , held ) : NEW_LINE INDENT n = len ( anm ) NEW_LINE m = len ( anm [ 0 ] ) NEW_LINE atte = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT aim = anm [ i ] NEW_LINE for k in aim : NEW_LINE INDENT if k in held : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT atte . append ( k ) NEW_LINE DEDENT return atte NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE anm = [ ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT aim = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE anm . append ( aim ) NEW_LINE DEDENT held = set ( range ( 1 , m + 1 ) ) NEW_LINE res = HUGE NEW_LINE while len ( held ) > 0 : NEW_LINE INDENT atte = each_attend ( anm , held ) NEW_LINE num_atte = { k : 0 for k in range ( 1 , m + 1 ) } NEW_LINE for k in atte : NEW_LINE INDENT num_atte [ k ] += 1 NEW_LINE DEDENT ma = max ( num_atte . values ( ) ) NEW_LINE res = min ( res , ma ) NEW_LINE popest_sports = set ( filter ( lambda k : num_atte [ k ] == ma , held ) ) NEW_LINE held -= popest_sports NEW_LINE DEDENT print ( res ) NEW_LINE DEDENT main ( ) NEW_LINE

def check ( mask ) : NEW_LINE INDENT for e in mask : NEW_LINE INDENT if e == 1 : return True NEW_LINE DEDENT return False NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT n , m = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE ia = [ list ( map ( int , input ( ) . split ( " ▁ " ) ) ) for _ in range ( n ) ] NEW_LINE a = [ [ 0 for _ in range ( m ) ] for _ in range ( n ) ] NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT a [ i ] [ ia [ i ] [ j ] - 1 ] = j NEW_LINE DEDENT DEDENT mask = [ 1 for _ in range ( m ) ] NEW_LINE res = 1000 NEW_LINE while check ( mask ) : NEW_LINE INDENT cnt = [ 0 for _ in range ( m ) ] NEW_LINE for alst in a : NEW_LINE INDENT mi = 3000 NEW_LINE pos = - 1 NEW_LINE for i in range ( m ) : NEW_LINE INDENT if alst [ i ] < mi and mask [ i ] == 1 : NEW_LINE INDENT pos = i NEW_LINE mi = alst [ i ] NEW_LINE DEDENT DEDENT cnt [ pos ] += 1 NEW_LINE DEDENT ma = max ( cnt ) NEW_LINE res = min ( res , ma ) NEW_LINE for i in range ( m ) : NEW_LINE INDENT if cnt [ i ] == ma : mask [ i ] = 0 NEW_LINE DEDENT DEDENT print ( res ) NEW_LINE DEDENT main ( ) NEW_LINE

import sys , collections NEW_LINE def input ( ) : NEW_LINE INDENT return sys . stdin . readline ( ) [ : - 1 ] NEW_LINE DEDENT n , m = map ( int , input ( ) . split ( ) ) NEW_LINE a = [ list ( map ( int , input ( ) . split ( ) ) ) for _ in range ( n ) ] NEW_LINE def calc ( s ) : NEW_LINE INDENT c = collections . Counter ( ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( m ) : NEW_LINE INDENT if a [ i ] [ j ] not in s : NEW_LINE INDENT c [ a [ i ] [ j ] ] += 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT tmp = [ - 1 , - 1 ] NEW_LINE for k , v in c . items ( ) : NEW_LINE INDENT if v > tmp [ 1 ] : NEW_LINE INDENT tmp = [ k , v ] NEW_LINE DEDENT DEDENT del c NEW_LINE return tmp NEW_LINE DEDENT ans , boycott = n , set ( ) NEW_LINE for _ in range ( m - 1 ) : NEW_LINE INDENT res = calc ( boycott ) NEW_LINE ans = min ( ans , res [ 1 ] ) NEW_LINE boycott . add ( res [ 0 ] ) NEW_LINE DEDENT print ( ans ) NEW_LINE