import java . util . HashMap ; import java . util . Scanner ; public class Main { static int a ; static int [ ] w ; static HashMap < Integer , Integer > left = new HashMap < Integer , Integer > ( ) ; static HashMap < Integer , Integer > right = new HashMap < Integer , Integer > ( ) ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; w = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { w [ i ] = sc . nextInt ( ) ; } a = N / 2 ; int ans = 0 ; pack ( 0 , a , left , 0 ) ; pack ( a , N , right , 0 ) ; for ( int c : left . keySet ( ) ) { if ( right . containsKey ( X - c ) ) { ans += left . get ( c ) * right . get ( X - c ) ; } } System . out . println ( ans ) ; } static void pack ( int s , int g , HashMap < Integer , Integer > map , int W ) { if ( s == g ) { if ( map . containsKey ( W ) ) { map . put ( W , map . get ( W ) + 1 ) ; } else { map . put ( W , 1 ) ; } } else { pack ( s + 1 , g , map , W ) ; pack ( s + 1 , g , map , W + w [ s ] ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; long x = sc . nextLong ( ) ; int [ ] a = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) a [ i ] = sc . nextInt ( ) ; Arrays . sort ( a ) ; HashMap < Long , Long > map1 = new HashMap < > ( ) ; HashMap < Long , Long > map2 = new HashMap < > ( ) ; int zen = n / 2 ; int c = 1 ; for ( int i = 0 ; i < zen ; i ++ ) c *= 2 ; for ( int i = 0 ; i < c ; i ++ ) { int d = i ; long v = 0 ; for ( int j = 0 ; j < zen ; j ++ ) { if ( d % 2 == 0 ) v += a [ j ] ; d /= 2 ; } if ( map1 . containsKey ( v ) ) map1 . put ( v , map1 . get ( v ) + 1 ) ; else map1 . put ( v , 1L ) ; } c = 1 ; for ( int i = zen ; i < n ; i ++ ) c *= 2 ; for ( int i = 0 ; i < c ; i ++ ) { int d = i ; long v = 0 ; for ( int j = zen ; j < n ; j ++ ) { if ( d % 2 == 0 ) v += a [ j ] ; d /= 2 ; } if ( map2 . containsKey ( v ) ) map2 . put ( v , map2 . get ( v ) + 1 ) ; else map2 . put ( v , 1L ) ; } long res = 0 ; Set < Long > set = map1 . keySet ( ) ; for ( long lo : set ) { if ( map2 . containsKey ( x - lo ) ) { res += map1 . get ( lo ) * map2 . get ( x - lo ) ; } } System . out . println ( res ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; int n = scan . nextInt ( ) ; long x = scan . nextInt ( ) ; long [ ] w = new long [ n ] ; for ( int i = 0 ; i < n ; ++ i ) w [ i ] = scan . nextInt ( ) ; int m = n / 2 ; long [ ] f = new long [ 1 << m ] ; long [ ] s = new long [ 1 << n - m ] ; for ( int i = 0 ; i < 1 << m ; ++ i ) for ( int j = 0 ; j < m ; ++ j ) if ( ( i & 1 << j ) != 0 ) f [ i ] += w [ j ] ; for ( int i = 0 ; i < 1 << n - m ; ++ i ) for ( int j = 0 ; j < n - m ; ++ j ) if ( ( i & 1 << j ) != 0 ) s [ i ] += w [ m + j ] ; Map < Long , Integer > hs = new HashMap < Long , Integer > ( ) ; for ( long ss : s ) if ( ! hs . containsKey ( ss ) ) hs . put ( ss , 1 ) ; else hs . put ( ss , hs . get ( ss ) + 1 ) ; long total = 0 ; for ( long ff : f ) if ( hs . containsKey ( x - ff ) ) total += hs . get ( x - ff ) ; System . out . println ( total ) ; } }

import java . util . * ; import java . io . * ; import static java . lang . System . in ; public class Main { static long R , B , x , y ; public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int X = sc . nextInt ( ) ; int [ ] w = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) w [ i ] = sc . nextInt ( ) ; long ans = help ( w , X ) ; System . out . println ( ans ) ; } static long help ( int [ ] w , int X ) { int n = w . length ; if ( n == 1 ) { return w [ 0 ] == X ? 1 : 0 ; } int ans = 0 ; int p = n / 2 ; HashMap < Integer , Integer > dic = getDic ( Arrays . copyOfRange ( w , p , n ) ) ; int [ ] first = Arrays . copyOfRange ( w , 0 , p ) ; for ( int i = 0 ; i < ( 1 << p ) ; i ++ ) { int cur = getSum ( first , i ) ; ans += dic . getOrDefault ( X - cur , 0 ) ; } return ans ; } static HashMap < Integer , Integer > getDic ( int [ ] a ) { int q = a . length ; HashMap < Integer , Integer > ans = new HashMap < > ( ) ; for ( int i = 0 ; i < ( 1 << q ) ; i ++ ) { int cur = getSum ( a , i ) ; int val = ans . getOrDefault ( cur , 0 ) + 1 ; ans . put ( cur , val ) ; } return ans ; } static int getSum ( int [ ] a , int mask ) { int sum = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { if ( ( mask & ( 1 << i ) ) > 0 ) sum += a [ i ] ; } return sum ; } }

from bisect import bisect , bisect_left NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE N , X = inpl ( ) NEW_LINE W = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE A = N // 2 NEW_LINE B = N - A NEW_LINE C = [ ] NEW_LINE D = [ ] NEW_LINE for i in range ( 2 ** A ) : NEW_LINE INDENT C . append ( sum ( [ W [ a ] * ( i >> a & 1 ) for a in range ( A ) ] ) ) NEW_LINE DEDENT for j in range ( 2 ** B ) : NEW_LINE INDENT D . append ( sum ( [ W [ b + A ] * ( j >> b & 1 ) for b in range ( B ) ] ) ) NEW_LINE DEDENT ans = 0 NEW_LINE C = sorted ( C ) NEW_LINE D = sorted ( D ) NEW_LINE for c in C [ : bisect ( C , X ) ] : NEW_LINE INDENT ans += bisect ( D , X - c ) - bisect_left ( D , X - c ) NEW_LINE DEDENT print ( ans ) NEW_LINE

import math , string , itertools , fractions , heapq , collections , re , array , bisect , sys , random , time , copy , functools NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE inf = 10 ** 20 NEW_LINE mod = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def F ( ) : return float ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT N , X = LI ( ) NEW_LINE W = sorted ( [ I ( ) for _ in range ( N ) ] , reverse = True ) NEW_LINE d = collections . defaultdict ( int ) NEW_LINE d [ 0 ] = 1 NEW_LINE for c in W [ N // 2 : ] : NEW_LINE INDENT t = collections . defaultdict ( int ) NEW_LINE for k , v in d . items ( ) : NEW_LINE INDENT if k + c > X : NEW_LINE INDENT continue NEW_LINE DEDENT t [ k + c ] += v NEW_LINE DEDENT for k , v in t . items ( ) : NEW_LINE INDENT d [ k ] += v NEW_LINE DEDENT DEDENT d2 = collections . defaultdict ( int ) NEW_LINE d2 [ 0 ] = 1 NEW_LINE for c in W [ : N // 2 ] : NEW_LINE INDENT t = collections . defaultdict ( int ) NEW_LINE for k , v in d2 . items ( ) : NEW_LINE INDENT if k + c > X : NEW_LINE INDENT continue NEW_LINE DEDENT t [ k + c ] += v NEW_LINE DEDENT for k , v in t . items ( ) : NEW_LINE INDENT d2 [ k ] += v NEW_LINE DEDENT DEDENT r = 0 NEW_LINE for k , v in d . items ( ) : NEW_LINE INDENT r += v * d2 [ X - k ] NEW_LINE DEDENT return r NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

def make ( n , r ) : NEW_LINE INDENT v = { 0 : 1 } NEW_LINE for _ in range ( n ) : NEW_LINE INDENT s = int ( input ( ) ) NEW_LINE w = dict ( v ) NEW_LINE for k , val in v . items ( ) : NEW_LINE INDENT w [ k + s ] = v . get ( k + s , 0 ) + val NEW_LINE DEDENT v = w NEW_LINE DEDENT return sorted ( v . items ( ) , reverse = r ) NEW_LINE DEDENT N , X = map ( int , input ( ) . split ( ) ) NEW_LINE S = make ( N // 2 , 0 ) NEW_LINE T = make ( N - N // 2 , 1 ) NEW_LINE ans = 0 NEW_LINE it = iter ( T ) NEW_LINE nn = ( None , None ) NEW_LINE t , w = next ( it , nn ) NEW_LINE for s , v in S : NEW_LINE INDENT while w and s + t > X : NEW_LINE INDENT t , w = next ( it , nn ) NEW_LINE DEDENT if w and s + t == X : NEW_LINE INDENT ans += v * w NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

from collections import defaultdict NEW_LINE import sys , heapq , bisect , math , itertools , string , queue , datetime NEW_LINE sys . setrecursionlimit ( 10 ** 8 ) NEW_LINE INF = float ( ' inf ' ) NEW_LINE mod = 10 ** 9 + 7 NEW_LINE eps = 10 ** - 7 NEW_LINE AtoZ = [ chr ( i ) for i in range ( 65 , 65 + 26 ) ] NEW_LINE atoz = [ chr ( i ) for i in range ( 97 , 97 + 26 ) ] NEW_LINE def inpl ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def inpl_s ( ) : return list ( input ( ) . split ( ) ) NEW_LINE N , X = inpl ( ) NEW_LINE ww = [ int ( input ( ) ) for i in range ( N ) ] NEW_LINE k = N // 2 NEW_LINE flags1 = itertools . product ( [ 0 , 1 ] , repeat = k ) NEW_LINE flags2 = itertools . product ( [ 0 , 1 ] , repeat = N - k ) NEW_LINE dd1 = defaultdict ( int ) NEW_LINE ed = [ ] NEW_LINE dd2 = defaultdict ( int ) NEW_LINE for flag in flags1 : NEW_LINE INDENT tmp = 0 NEW_LINE for i , fl in enumerate ( flag ) : NEW_LINE INDENT if fl : NEW_LINE INDENT tmp += ww [ i ] NEW_LINE DEDENT DEDENT if dd1 [ tmp ] == 0 : NEW_LINE INDENT ed . append ( tmp ) NEW_LINE DEDENT dd1 [ tmp ] += 1 NEW_LINE DEDENT for flag in flags2 : NEW_LINE INDENT tmp = 0 NEW_LINE for i , fl in enumerate ( flag ) : NEW_LINE INDENT if fl : NEW_LINE INDENT tmp += ww [ i + k ] NEW_LINE DEDENT DEDENT dd2 [ tmp ] += 1 NEW_LINE DEDENT ans = 0 NEW_LINE for e in ed : NEW_LINE INDENT ans += dd1 [ e ] * dd2 [ X - e ] NEW_LINE DEDENT print ( ans ) NEW_LINE

import sys NEW_LINE from collections import defaultdict , Counter NEW_LINE from itertools import product , groupby , count , permutations , combinations NEW_LINE from math import pi , sqrt , ceil , floor NEW_LINE from collections import deque NEW_LINE from bisect import bisect , bisect_left , bisect_right NEW_LINE from string import ascii_lowercase NEW_LINE INF = float ( " inf " ) NEW_LINE sys . setrecursionlimit ( 10 ** 7 ) NEW_LINE dy = [ 0 , - 1 , 0 , 1 ] NEW_LINE dx = [ 1 , 0 , - 1 , 0 ] NEW_LINE def inside ( y : int , x : int , H : int , W : int ) -> bool : return 0 <= y < H and 0 <= x < W NEW_LINE def main ( ) : NEW_LINE INDENT N , X = map ( int , input ( ) . split ( ) ) NEW_LINE w_list = [ int ( input ( ) ) for _ in range ( N ) ] NEW_LINE w_list1 , w_list2 = w_list [ : N // 2 ] , w_list [ N // 2 : ] NEW_LINE n = len ( w_list1 ) NEW_LINE s = [ ] NEW_LINE for b in range ( 2 ** n ) : NEW_LINE INDENT total = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if b & 1 << i : NEW_LINE INDENT total += w_list1 [ i ] NEW_LINE DEDENT DEDENT s . append ( total ) NEW_LINE DEDENT n = len ( w_list2 ) NEW_LINE d = defaultdict ( int ) NEW_LINE for b in range ( 2 ** n ) : NEW_LINE INDENT total = 0 NEW_LINE for i in range ( n ) : NEW_LINE INDENT if b & 1 << i : NEW_LINE INDENT total += w_list2 [ i ] NEW_LINE DEDENT DEDENT d [ total ] += 1 NEW_LINE DEDENT ans = 0 NEW_LINE for a in s : NEW_LINE INDENT if a > X : NEW_LINE INDENT continue NEW_LINE DEDENT ans += d [ X - a ] NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) * 2 ; long length [ ] = new long [ num ] ; for ( int i = 0 ; i < num ; i ++ ) { length [ i ] = sc . nextLong ( ) ; } Arrays . sort ( length ) ; long ans = 0 ; for ( int i = 0 ; i < num ; i += 2 ) { ans += length [ i ] ; } System . out . println ( 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 ( ) ; Integer [ ] L = new Integer [ 2 * N ] ; for ( int i = 0 ; i < 2 * N ; i ++ ) { L [ i ] = sc . nextInt ( ) ; } Arrays . sort ( L , Collections . reverseOrder ( ) ) ; int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { ans += Math . min ( L [ 2 * i ] , L [ 2 * i + 1 ] ) ; } out . println ( ans ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . lang . reflect . Array ; import java . util . Arrays ; import java . util . StringTokenizer ; public class Main { static BufferedReader reader ; static StringTokenizer tokenizer ; static void init ( InputStream input ) { reader = new BufferedReader ( new InputStreamReader ( input ) ) ; tokenizer = new StringTokenizer ( " " ) ; } static String next ( ) throws IOException { while ( ! tokenizer . hasMoreTokens ( ) ) { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } return tokenizer . nextToken ( ) ; } static int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } static double nextDouble ( ) throws IOException { return Double . parseDouble ( next ( ) ) ; } public static void main ( String [ ] args ) throws IOException { init ( System . in ) ; int n = nextInt ( ) ; int A [ ] = new int [ 2 * n ] ; for ( int i = 0 ; i < 2 * n ; i ++ ) { A [ i ] = nextInt ( ) ; } Arrays . sort ( A ) ; int sum = 0 ; for ( int i = 0 ; i < 2 * n ; i += 2 ) { if ( A [ i ] < A [ i + 1 ] ) { sum += A [ i ] ; } else { sum += A [ i + 1 ] ; } } System . out . println ( sum ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String line = sc . nextLine ( ) ; int N = Integer . parseInt ( line ) ; line = sc . nextLine ( ) ; String [ ] l1l2 = line . split ( " ▁ " ) ; List < Integer > kusi = new ArrayList < > ( ) ; for ( int i = 0 ; i < l1l2 . length ; i ++ ) { kusi . add ( Integer . parseInt ( l1l2 [ i ] ) ) ; } Collections . sort ( kusi ) ; calc ( kusi ) ; } public static void calc ( List < Integer > list ) { int total = 0 ; for ( int i = 0 ; i < list . size ( ) ; i = i + 2 ) { total += list . get ( i ) ; } System . out . println ( total ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int spitCount = Integer . valueOf ( scanner . nextLine ( ) ) * 2 ; int spits [ ] = new int [ spitCount ] ; for ( int i = 0 ; i < spitCount ; i ++ ) { spits [ i ] = scanner . nextInt ( ) ; } Arrays . sort ( spits ) ; int dishSum = 0 ; for ( int i = 0 ; i < spitCount ; i ++ ) { if ( i % 2 == 0 ) { dishSum += spits [ i ] ; } } System . out . println ( dishSum ) ; } }

import math NEW_LINE def getInt ( ) : return int ( input ( ) ) NEW_LINE def getIntList ( ) : return [ int ( x ) for x in input ( ) . split ( ) ] NEW_LINE def zeros ( n ) : return [ 0 ] * n NEW_LINE def zeros2 ( n , m ) : return [ zeros ( m ) for i in range ( n ) ] NEW_LINE class Debug ( ) : NEW_LINE INDENT def __init__ ( self ) : NEW_LINE INDENT self . debug = True NEW_LINE DEDENT def off ( self ) : NEW_LINE INDENT self . debug = False NEW_LINE DEDENT def dmp ( self , x , cmt = ' ' ) : NEW_LINE INDENT if self . debug : NEW_LINE INDENT if cmt != ' ' : NEW_LINE INDENT w = cmt + ' : ▁ ' + str ( x ) NEW_LINE DEDENT else : NEW_LINE INDENT w = str ( x ) NEW_LINE DEDENT print ( w ) NEW_LINE DEDENT return x NEW_LINE DEDENT DEDENT def prob ( ) : NEW_LINE INDENT d = Debug ( ) NEW_LINE d . off ( ) NEW_LINE N = getInt ( ) NEW_LINE d . dmp ( ( N ) , ' N ' ) NEW_LINE L = getIntList ( ) NEW_LINE d . dmp ( ( L ) , ' L ' ) NEW_LINE L . sort ( ) NEW_LINE count = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT count += min ( L [ i * 2 ] , L [ i * 2 + 1 ] ) NEW_LINE DEDENT return count NEW_LINE DEDENT ans = prob ( ) NEW_LINE print ( ans ) NEW_LINE

n , l = open ( 0 ) ; print ( sum ( sorted ( map ( int , l . split ( ) ) ) [ : : 2 ] ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE L = [ ] NEW_LINE for n in [ int ( i ) for i in input ( ) . split ( ) ] : NEW_LINE INDENT L . append ( n ) NEW_LINE DEDENT L . sort ( ) NEW_LINE SUM = 0 NEW_LINE for i in range ( N ) : NEW_LINE INDENT x = L . pop ( ) NEW_LINE y = L . pop ( ) NEW_LINE if x < y : NEW_LINE INDENT SUM = SUM + x NEW_LINE DEDENT elif x >= y : NEW_LINE INDENT SUM = SUM + y NEW_LINE DEDENT DEDENT print ( SUM ) NEW_LINE

N = input ( ) NEW_LINE L = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def quicksort ( array ) : NEW_LINE INDENT if len ( array ) < 2 : NEW_LINE INDENT return array NEW_LINE DEDENT else : NEW_LINE INDENT pivot = array [ 0 ] NEW_LINE less = [ i for i in array [ 1 : ] if i <= pivot ] NEW_LINE greater = [ i for i in array [ 1 : ] if i > pivot ] NEW_LINE return quicksort ( less ) + [ pivot ] + quicksort ( greater ) NEW_LINE DEDENT DEDENT guzai = 0 NEW_LINE for i in range ( int ( N ) ) : NEW_LINE INDENT guzai += int ( quicksort ( L ) [ int ( 2 * i ) ] ) NEW_LINE DEDENT print ( guzai ) NEW_LINE

import bisect NEW_LINE N = input ( ) NEW_LINE Ls = map ( int , input ( ) . split ( " ▁ " ) ) NEW_LINE Ls = sorted ( Ls ) NEW_LINE ans = sum ( [ L for i , L in enumerate ( Ls ) if i % 2 == 0 ] ) NEW_LINE print ( ans ) NEW_LINE


import java . util . * ; class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; char [ ] array = sc . nextLine ( ) . toCharArray ( ) ; try { for ( int i = array . length - 1 ; i >= 0 ; i -- ) { if ( i >= 6 ) { if ( array [ i - 6 ] == ' d ' && array [ i - 5 ] == ' r ' && array [ i - 4 ] == ' e ' && array [ i - 3 ] == ' a ' && array [ i - 2 ] == ' m ' && array [ i - 1 ] == ' e ' && array [ i ] == ' r ' ) { i -= 6 ; continue ; } } if ( i >= 5 ) { if ( array [ i - 5 ] == ' e ' && array [ i - 4 ] == ' r ' && array [ i - 3 ] == ' a ' && array [ i - 2 ] == ' s ' && array [ i - 1 ] == ' e ' && array [ i ] == ' r ' ) { i -= 5 ; continue ; } } if ( ( array [ i - 4 ] == ' d ' && array [ i - 3 ] == ' r ' && array [ i - 2 ] == ' e ' && array [ i - 1 ] == ' a ' && array [ i ] == ' m ' ) || ( array [ i - 4 ] == ' e ' && array [ i - 3 ] == ' r ' && array [ i - 2 ] == ' a ' && array [ i - 1 ] == ' s ' && array [ i ] == ' e ' ) ) { i -= 4 ; } else { System . out . println ( " NO " ) ; return ; } } } catch ( ArrayIndexOutOfBoundsException e ) { System . out . println ( " NO " ) ; return ; } System . out . println ( " YES " ) ; } }

import java . io . * ; import java . util . * ; public class Main { static class FastScanner { BufferedReader br ; StringTokenizer st ; public FastScanner ( ) { try { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } public String next ( ) { if ( st . hasMoreTokens ( ) ) return st . nextToken ( ) ; try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { String line = " " ; if ( st . hasMoreTokens ( ) ) line = st . nextToken ( ) ; else try { return br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } while ( st . hasMoreTokens ( ) ) line += " ▁ " + st . nextToken ( ) ; return line ; } } public static void main ( String [ ] args ) { FastScanner sc = new FastScanner ( ) ; PrintWriter pw = new PrintWriter ( System . out ) ; String s = sc . nextLine ( ) ; int k = s . length ( ) ; while ( k > 0 ) { if ( k >= 5 && s . substring ( k - 5 , k ) . equals ( " dream " ) ) { k -= 5 ; } else if ( k >= 7 && s . substring ( k - 7 , k ) . equals ( " dreamer " ) ) { k -= 7 ; } else if ( k >= 5 && s . substring ( k - 5 , k ) . equals ( " erase " ) ) { k -= 5 ; } else if ( k >= 6 && s . substring ( k - 6 , k ) . equals ( " eraser " ) ) { k -= 6 ; } else { pw . println ( " NO " ) ; pw . close ( ) ; return ; } } pw . println ( " YES " ) ; pw . close ( ) ; } }

import java . util . * ; import java . io . * ; public class Main { static boolean match ( String temp , int start , String str ) { if ( start + temp . length ( ) > str . length ( ) ) return false ; for ( int j = 0 ; j < temp . length ( ) ; j ++ ) { if ( temp . charAt ( j ) != str . charAt ( j + start ) ) return false ; } return true ; } public static void main ( String [ ] args ) throws Exception { String array [ ] = new String [ ] { " dreamer " , " dream " , " eraser " , " erase " } ; BufferedReader br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; String str = br . readLine ( ) ; int start = 0 ; int last = - 1 ; while ( start < str . length ( ) && start >= 0 ) { boolean flag = false ; for ( int j = 0 ; j < 4 ; j ++ ) { if ( match ( array [ j ] , start , str ) ) { start += array [ j ] . length ( ) ; flag = true ; last = j ; break ; } } if ( ! flag && last == 0 ) { start -= 2 ; last = - 1 ; } else if ( ! flag ) break ; } if ( start == str . length ( ) ) System . out . println ( " YES " ) ; else System . out . println ( " NO " ) ; } }

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 [ ] [ ] addeds = { " dream " . toCharArray ( ) , " dreamer " . toCharArray ( ) , " erase " . toCharArray ( ) , " eraser " . toCharArray ( ) } ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int endIndex = s . length ; while ( endIndex > 0 ) { boolean f = false ; for ( char [ ] added : addeds ) { if ( isMatch ( s , added , endIndex ) ) { endIndex -= added . length ; f = true ; break ; } } if ( f == false ) { System . out . println ( " NO " ) ; return ; } } System . out . println ( " YES " ) ; } boolean isMatch ( char [ ] s , char [ ] added , int endIndex ) { if ( endIndex - added . length < 0 ) { return false ; } for ( int i = 0 ; i < added . length ; i ++ ) { if ( added [ i ] != s [ endIndex - added . length + i ] ) { return false ; } } return true ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String inputText = sc . next ( ) ; char [ ] p1 = { ' m ' , ' a ' , ' e ' , ' r ' , ' d ' } ; char [ ] p2 = { ' r ' , ' e ' , ' m ' , ' a ' , ' e ' , ' r ' , ' d ' } ; char [ ] p3 = { ' e ' , ' s ' , ' a ' , ' r ' , ' e ' } ; char [ ] p4 = { ' r ' , ' e ' , ' s ' , ' a ' , ' r ' , ' e ' } ; char [ ] inputArray = inputText . toCharArray ( ) ; int wordIndex = 0 ; char [ ] targetArray = null ; for ( int i = inputArray . length - 1 ; i >= 0 ; i -- ) { if ( wordIndex == 0 ) { if ( inputArray [ i ] == ' m ' ) { targetArray = p1 ; } else if ( inputArray [ i ] == ' e ' ) { targetArray = p3 ; } else if ( inputArray [ i ] == ' r ' ) { if ( i - 2 > 0 ) { if ( inputArray [ i - 2 ] == ' m ' ) { targetArray = p2 ; } else if ( inputArray [ i - 2 ] == ' s ' ) { targetArray = p4 ; } else { System . out . println ( " NO " ) ; return ; } } else { System . out . println ( " NO " ) ; return ; } } else { System . out . println ( " NO " ) ; return ; } } else { if ( targetArray [ wordIndex ] != inputArray [ i ] ) { System . out . println ( " NO " ) ; return ; } } if ( wordIndex < targetArray . length - 1 ) { wordIndex ++ ; } else { wordIndex = 0 ; targetArray = null ; } } System . out . println ( " YES " ) ; } }

s = list ( input ( ) ) NEW_LINE c = 0 NEW_LINE while len ( s ) > 0 : NEW_LINE INDENT p = "1" NEW_LINE q = "1" NEW_LINE r = "1" NEW_LINE if len ( s ) < 5 : NEW_LINE INDENT break NEW_LINE DEDENT if len ( s ) <= 7 : NEW_LINE INDENT if len ( s ) == 5 : NEW_LINE INDENT if s == list ( " dream " ) or s == list ( " erase " ) : NEW_LINE INDENT c = 1 NEW_LINE break NEW_LINE DEDENT DEDENT elif len ( s ) == 6 : NEW_LINE INDENT if s == list ( " eraser " ) : NEW_LINE INDENT c = 1 NEW_LINE break NEW_LINE DEDENT DEDENT elif len ( s ) == 7 : NEW_LINE INDENT if s == list ( " dreamer " ) : NEW_LINE INDENT c = 1 NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT p = s [ len ( s ) - 5 : len ( s ) ] NEW_LINE q = s [ len ( s ) - 6 : len ( s ) ] NEW_LINE r = s [ len ( s ) - 7 : len ( s ) ] NEW_LINE if p == list ( " dream " ) or p == list ( " erase " ) : NEW_LINE INDENT del s [ len ( s ) - 5 : len ( s ) ] NEW_LINE DEDENT elif q == list ( " eraser " ) : NEW_LINE INDENT del s [ len ( s ) - 6 : len ( s ) ] NEW_LINE DEDENT elif r == list ( " dreamer " ) : NEW_LINE INDENT del s [ len ( s ) - 7 : len ( s ) ] NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT DEDENT print ( " YES " if c == 1 else " NO " ) NEW_LINE

from collections import deque NEW_LINE def solve ( s ) : NEW_LINE INDENT stack = deque ( ) NEW_LINE stack . append ( s ) NEW_LINE while len ( stack ) > 0 : NEW_LINE INDENT top = stack . pop ( ) NEW_LINE if top == ' ' : NEW_LINE INDENT return ' YES ' NEW_LINE DEDENT if top [ : 5 ] == ' dream ' : NEW_LINE INDENT if top [ 5 : 7 ] == ' er ' : NEW_LINE INDENT stack . append ( top [ 7 : ] ) NEW_LINE DEDENT stack . append ( top [ 5 : ] ) NEW_LINE DEDENT elif top [ : 5 ] == ' erase ' : NEW_LINE INDENT if len ( top ) > 5 and top [ 5 ] == ' r ' : NEW_LINE INDENT stack . append ( top [ 6 : ] ) NEW_LINE DEDENT else : NEW_LINE INDENT stack . append ( top [ 5 : ] ) NEW_LINE DEDENT DEDENT DEDENT return ' NO ' NEW_LINE DEDENT print ( solve ( input ( ) ) ) NEW_LINE

S = input ( ) NEW_LINE S = S [ : : - 1 ] NEW_LINE S = S . replace ( ' resare ' , ' ' ) NEW_LINE S = S . replace ( ' esare ' , ' ' ) NEW_LINE S = S . replace ( ' remaerd ' , ' ' ) NEW_LINE S = S . replace ( ' maerd ' , ' ' ) NEW_LINE if S : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT

def db ( x ) : NEW_LINE INDENT global debug NEW_LINE if debug : NEW_LINE INDENT print ( x ) NEW_LINE DEDENT DEDENT def gen ( tstr ) : NEW_LINE INDENT if len ( tstr ) <= len ( S ) : NEW_LINE INDENT for w in words : NEW_LINE INDENT yield tstr + w NEW_LINE for w2 in gen ( tstr + w ) : NEW_LINE INDENT yield w2 NEW_LINE DEDENT DEDENT DEDENT DEDENT def solve ( ) : NEW_LINE INDENT ans = False NEW_LINE for genstr in gen ( ' ' ) : NEW_LINE INDENT db ( genstr ) NEW_LINE if genstr == S : NEW_LINE INDENT ans = True NEW_LINE break NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT def solve2 ( ) : NEW_LINE INDENT stack = list ( words ) NEW_LINE while stack != [ ] : NEW_LINE INDENT str = stack . pop ( ) NEW_LINE db ( ( ' pop ' , str ) ) NEW_LINE if len ( str ) < len ( S ) : NEW_LINE INDENT for w in words : NEW_LINE INDENT stack . append ( str + w ) NEW_LINE DEDENT DEDENT elif len ( str ) == len ( S ) and str == S : NEW_LINE INDENT return True NEW_LINE DEDENT DEDENT return False NEW_LINE DEDENT def solve3 ( ) : NEW_LINE INDENT string = S + ' ▁ ' NEW_LINE n = len ( string ) NEW_LINE while n > 1 : NEW_LINE INDENT for w in words : NEW_LINE INDENT db ( ( string . rfind ( w , 0 , n ) , len ( w ) , n ) ) NEW_LINE if string . rfind ( w , 0 , n ) + len ( w ) + 1 == n : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT db ( ( n , w ) ) NEW_LINE n -= len ( w ) NEW_LINE DEDENT return True NEW_LINE DEDENT debug = False NEW_LINE words = ( ' dream ' , ' dreamer ' , ' erase ' , ' eraser ' ) NEW_LINE S = input ( ) NEW_LINE db ( S ) NEW_LINE if solve3 ( ) : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT

def YESNO ( ans , yes = " YES " , no = " NO " ) : NEW_LINE INDENT print ( [ no , yes ] [ ans ] ) NEW_LINE DEDENT II = lambda : int ( input ( ) ) NEW_LINE MI = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE MIL = lambda : list ( MI ( ) ) NEW_LINE MIS = lambda : input ( ) . split ( ) NEW_LINE def check ( s ) : NEW_LINE INDENT if s == " " : NEW_LINE INDENT return True NEW_LINE DEDENT if s [ : 5 ] in [ " dream " , " erase " ] : NEW_LINE INDENT return True NEW_LINE DEDENT return False NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT S = input ( ) NEW_LINE i = 0 NEW_LINE l = len ( S ) NEW_LINE while i < l : NEW_LINE INDENT if S [ i : i + 7 ] == " dreamer " and check ( S [ i + 7 : ] ) : NEW_LINE INDENT i += 7 NEW_LINE DEDENT elif S [ i : i + 6 ] == " eraser " and check ( S [ i + 6 : ] ) : NEW_LINE INDENT i += 6 NEW_LINE DEDENT elif check ( S [ i : ] ) : NEW_LINE INDENT i += 5 NEW_LINE DEDENT else : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT YESNO ( main ( ) ) NEW_LINE DEDENT


import java . util . * ; import java . awt . Point ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } public void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long H = scanner . nextLong ( ) ; long W = scanner . nextLong ( ) ; int N = scanner . nextInt ( ) ; Point [ ] point = new Point [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int row = scanner . nextInt ( ) ; int col = scanner . nextInt ( ) ; point [ i ] = new Point ( col , row ) ; } HashMap < Point , Integer > hashmap = new HashMap < Point , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int y = - 1 ; y < 2 ; y ++ ) { for ( int x = - 1 ; x < 2 ; x ++ ) { Point p = new Point ( point [ i ] . x + x , point [ i ] . y + y ) ; if ( hashmap . get ( p ) == null ) { hashmap . put ( p , 1 ) ; } else { hashmap . put ( p , hashmap . get ( p ) + 1 ) ; } } } } long [ ] counter = new long [ 10 ] ; for ( int i = 0 ; i < counter . length ; i ++ ) { counter [ i ] = 0 ; } long sum = ( H - 2 ) * ( W - 2 ) ; for ( HashMap . Entry < Point , Integer > map : hashmap . entrySet ( ) ) { if ( 1 < map . getKey ( ) . x && map . getKey ( ) . x < W && 1 < map . getKey ( ) . y && map . getKey ( ) . y < H ) { counter [ map . getValue ( ) ] ++ ; sum -- ; } } counter [ 0 ] = sum ; for ( int i = 0 ; i < counter . length ; i ++ ) { System . out . println ( counter [ i ] ) ; } } }

import java . util . * ; class Point implements Comparable < Point > { int a , b ; Point ( int a , int b ) { this . a = a ; this . b = b ; } public int hashCode ( ) { return ( ( a & 0xFFFF0000 ) | ( b >> 16 ) ) ^ ( ( b & 0xFFFF0000 ) | ( a >> 16 ) ) ; } public boolean equals ( Object object ) { Point point = ( Point ) object ; return this . a == point . a && this . b == point . b ; } public int compareTo ( Point p ) { if ( this . a != p . a ) { return this . a - p . a ; } return this . b - p . b ; } } public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int h = s . nextInt ( ) ; int w = s . nextInt ( ) ; int n = s . nextInt ( ) ; HashMap < Point , Integer > map = new HashMap < Point , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = s . nextInt ( ) - 1 ; int b = s . nextInt ( ) - 1 ; for ( int da = Math . max ( 0 , a - 2 ) ; da <= Math . min ( h - 3 , a ) ; da ++ ) { for ( int db = Math . max ( 0 , b - 2 ) ; db <= Math . min ( w - 3 , b ) ; db ++ ) { Point p = new Point ( da , db ) ; if ( map . get ( p ) == null ) { map . put ( p , 1 ) ; } else { map . put ( p , map . get ( p ) + 1 ) ; } } } } long [ ] output = new long [ 10 ] ; output [ 0 ] = ( long ) ( h - 2 ) * ( long ) ( w - 2 ) ; for ( int value : map . values ( ) ) { output [ 0 ] -- ; output [ value ] ++ ; } for ( long value : output ) { System . out . println ( value ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long h = in . nextLong ( ) , w = in . nextLong ( ) ; int n = in . nextInt ( ) ; Map < Long , Integer > map = new HashMap < > ( ) ; int [ ] dx = { 0 , 0 , 1 , 1 , 1 , 0 , - 1 , - 1 , - 1 } ; int [ ] dy = { 0 , - 1 , - 1 , 0 , 1 , 1 , 1 , 0 , - 1 } ; for ( int i = 0 ; i < n ; i ++ ) { int a = in . nextInt ( ) - 1 , b = in . nextInt ( ) - 1 ; for ( int k = 0 ; k < 9 ; k ++ ) { int y = a + dy [ k ] , x = b + dx [ k ] ; if ( x < 1 || w - 1 <= x || y < 1 || h - 1 <= y ) { continue ; } long key = ( long ) y << 32 | x ; Integer val = map . get ( key ) ; map . put ( key , val == null ? 1 : val + 1 ) ; } } System . out . println ( ( h - 2 ) * ( w - 2 ) - map . size ( ) ) ; long [ ] cnt = new long [ 10 ] ; for ( long key : map . keySet ( ) ) { cnt [ map . get ( key ) ] ++ ; } for ( int i = 1 ; i < 10 ; i ++ ) { System . out . println ( cnt [ i ] ) ; } } }

import java . util . * ; class Point implements Comparable < Point > { int a , b ; Point ( int a , int b ) { this . a = a ; this . b = b ; } public int hashCode ( ) { return a ^ b ; } public boolean equals ( Object object ) { Point point = ( Point ) object ; return this . a == point . a && this . b == point . b ; } public int compareTo ( Point p ) { if ( this . a != p . a ) { return this . a - p . a ; } return this . b - p . b ; } } public class Main { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; int h = s . nextInt ( ) ; int w = s . nextInt ( ) ; int n = s . nextInt ( ) ; TreeMap < Point , Integer > map = new TreeMap < Point , Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int a = s . nextInt ( ) - 1 ; int b = s . nextInt ( ) - 1 ; for ( int da = Math . max ( 0 , a - 2 ) ; da <= Math . min ( h - 3 , a ) ; da ++ ) { for ( int db = Math . max ( 0 , b - 2 ) ; db <= Math . min ( w - 3 , b ) ; db ++ ) { Point p = new Point ( da , db ) ; if ( map . get ( p ) == null ) { map . put ( p , 1 ) ; } else { map . put ( p , map . get ( p ) + 1 ) ; } } } } long [ ] output = new long [ 10 ] ; output [ 0 ] = ( long ) ( h - 2 ) * ( long ) ( w - 2 ) ; for ( int value : map . values ( ) ) { output [ 0 ] -- ; output [ value ] ++ ; } for ( long value : output ) { System . out . println ( value ) ; } } }

import java . util . HashMap ; import java . util . Scanner ; import java . awt . Point ; public class Main { public static void main ( String [ ] args ) { new Main ( ) . solve ( ) ; } public void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long H = scanner . nextLong ( ) ; long W = scanner . nextLong ( ) ; int N = scanner . nextInt ( ) ; Point [ ] point = new Point [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { int row = scanner . nextInt ( ) ; int col = scanner . nextInt ( ) ; point [ i ] = new Point ( col , row ) ; } HashMap < Point , Integer > hashmap = new HashMap < Point , Integer > ( ) ; for ( int i = 0 ; i < N ; i ++ ) { for ( int y = - 1 ; y < 2 ; y ++ ) { for ( int x = - 1 ; x < 2 ; x ++ ) { Point p = new Point ( point [ i ] . x + x , point [ i ] . y + y ) ; if ( hashmap . get ( p ) == null ) { hashmap . put ( p , 1 ) ; } else { hashmap . put ( p , hashmap . get ( p ) + 1 ) ; } } } } long [ ] counter = new long [ 10 ] ; for ( int i = 0 ; i < counter . length ; i ++ ) { counter [ i ] = 0 ; } long sum = ( H - 2 ) * ( W - 2 ) ; for ( HashMap . Entry < Point , Integer > map : hashmap . entrySet ( ) ) { if ( 1 < map . getKey ( ) . x && map . getKey ( ) . x < W && 1 < map . getKey ( ) . y && map . getKey ( ) . y < H ) { counter [ map . getValue ( ) ] ++ ; sum -- ; } } counter [ 0 ] = sum ; for ( int i = 0 ; i < counter . length ; i ++ ) { System . out . println ( counter [ i ] ) ; } } }

import sys NEW_LINE input = sys . stdin . readline NEW_LINE sys . setrecursionlimit ( 10000 ) NEW_LINE H , W , N = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE if N == 0 : NEW_LINE INDENT reslis = [ 0 ] * 10 NEW_LINE reslis [ 0 ] = ( H - 2 ) * ( W - 2 ) - sum ( reslis ) NEW_LINE DEDENT else : NEW_LINE INDENT L = [ ] NEW_LINE for k in range ( N ) : NEW_LINE INDENT a , b = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE for i in range ( 3 ) : NEW_LINE INDENT for j in range ( 3 ) : NEW_LINE INDENT if 1 <= a - 2 + i <= H - 2 and 1 <= b - 2 + j <= W - 2 : NEW_LINE INDENT L . append ( ( a - 2 + i , b - 2 + j ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT L . sort ( ) NEW_LINE temp = None NEW_LINE cc = 1 NEW_LINE reslis = [ 0 ] * 10 NEW_LINE for se in L : NEW_LINE INDENT if temp == se : NEW_LINE INDENT cc += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if temp == None : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT reslis [ cc ] += 1 NEW_LINE cc = 1 NEW_LINE DEDENT temp = se NEW_LINE DEDENT DEDENT reslis [ cc ] += 1 NEW_LINE reslis [ 0 ] = ( H - 2 ) * ( W - 2 ) - sum ( reslis ) NEW_LINE DEDENT for i in reslis : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT

f = lambda : map ( int , input ( ) . split ( ) ) NEW_LINE h , w , n = f ( ) NEW_LINE c = [ ( h - 2 ) * ( w - 2 ) ] + [ 0 ] * 9 NEW_LINE d = { } NEW_LINE while n : NEW_LINE INDENT n -= 1 ; x , y = f ( ) NEW_LINE for i in range ( 9 ) : a = x + i % 3 , y + i // 3 ; g = h >= a [ 0 ] > 2 < a [ 1 ] <= w ; t = d [ a ] = d . get ( a , 0 ) + g ; c [ t - g ] -= 1 ; c [ t ] += 1 NEW_LINE DEDENT print ( * c ) NEW_LINE

from collections import defaultdict NEW_LINE def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE HW = defaultdict ( lambda : 0 ) NEW_LINE direction = [ ( 0 , 0 ) , ( 1 , 1 ) , ( 1 , 0 ) , ( 1 , - 1 ) , ( 0 , - 1 ) , ( - 1 , - 1 ) , ( - 1 , 0 ) , ( - 1 , 1 ) , ( 0 , 1 ) ] NEW_LINE H , W , N = inpl ( ) NEW_LINE for _ in range ( N ) : NEW_LINE INDENT a , b = inpl ( ) NEW_LINE for dh , dw in direction : NEW_LINE INDENT if 2 <= a + dh <= H - 1 and 2 <= b + dw <= W - 1 : NEW_LINE INDENT HW [ ( a + dh , b + dw ) ] += 1 NEW_LINE DEDENT DEDENT DEDENT ans = [ 0 for i in range ( 10 ) ] NEW_LINE print ( ( H - 2 ) * ( W - 2 ) - len ( HW ) ) NEW_LINE for j in HW . values ( ) : NEW_LINE INDENT ans [ j ] += 1 NEW_LINE DEDENT for i in ans [ 1 : ] : NEW_LINE INDENT print ( i ) NEW_LINE DEDENT

from collections import defaultdict NEW_LINE h , w , n = map ( int , input ( ) . split ( ) ) NEW_LINE abd = defaultdict ( int ) NEW_LINE for _ in range ( n ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE abd [ ( a , b ) ] += 1 NEW_LINE abd [ ( a , b - 1 ) ] += 1 NEW_LINE abd [ ( a , b - 2 ) ] += 1 NEW_LINE abd [ ( a - 1 , b ) ] += 1 NEW_LINE abd [ ( a - 1 , b - 1 ) ] += 1 NEW_LINE abd [ ( a - 1 , b - 2 ) ] += 1 NEW_LINE abd [ ( a - 2 , b ) ] += 1 NEW_LINE abd [ ( a - 2 , b - 1 ) ] += 1 NEW_LINE abd [ ( a - 2 , b - 2 ) ] += 1 NEW_LINE DEDENT suma = [ 0 for _ in range ( 10 ) ] NEW_LINE for a , b in abd . keys ( ) : NEW_LINE INDENT if 0 < a < h - 1 and 0 < b < w - 1 : NEW_LINE INDENT suma [ abd [ ( a , b ) ] ] += 1 NEW_LINE DEDENT DEDENT suma [ 0 ] = ( h - 2 ) * ( w - 2 ) - sum ( suma ) NEW_LINE print ( * suma , sep = ' \n ' ) NEW_LINE

import sys , collections NEW_LINE def check_range ( y , x , H , W ) : NEW_LINE INDENT return 0 < x and x < W and 0 < y and y < H NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT H , W , N = map ( int , input ( ) . split ( ) ) NEW_LINE L = [ 0 for _ in range ( 10 ) ] NEW_LINE L [ 0 ] = ( H - 2 ) * ( W - 2 ) NEW_LINE NL = [ ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT y , x = map ( int , input ( ) . split ( ) ) NEW_LINE x -= 1 NEW_LINE y -= 1 NEW_LINE for i in range ( - 1 , 2 ) : NEW_LINE INDENT for j in range ( - 1 , 2 ) : NEW_LINE INDENT if check_range ( y + i , x + j , H - 1 , W - 1 ) : NEW_LINE INDENT NL . append ( ( y + i , x + j ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT NLD = collections . Counter ( NL ) NEW_LINE for v in NLD . values ( ) : NEW_LINE INDENT L [ v ] += 1 NEW_LINE L [ 0 ] -= 1 NEW_LINE DEDENT for v in L : NEW_LINE INDENT print ( v ) NEW_LINE DEDENT DEDENT solve ( ) NEW_LINE


import java . util . * ; class Main { static ArrayList < Integer > [ ] map ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int x = sc . nextInt ( ) ; if ( x == 1 ) { System . out . println ( n - 2 ) ; System . exit ( 0 ) ; } map = new ArrayList [ n + 1 ] ; for ( int i = 0 ; i <= n ; i ++ ) map [ i ] = new ArrayList < > ( ) ; for ( int i = 0 ; i < n - 1 ; i ++ ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; map [ a ] . add ( b ) ; map [ b ] . add ( a ) ; } long ans = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { int first = 1 , second = 0 ; for ( int w : map [ i ] ) { int [ ] cur = dfs ( w , i , x / 2 - 1 ) ; first += cur [ 0 ] ; second = Math . max ( second , cur [ 1 ] ) ; } if ( x % 2 == 1 ) first += second ; ans = Math . max ( ans , first ) ; } System . out . println ( n - ans ) ; } static int [ ] dfs ( int root , int from , int level ) { if ( level == 0 ) return new int [ ] { 1 , map [ root ] . size ( ) - 1 } ; int first = 1 , second = 0 ; for ( int w : map [ root ] ) { if ( w == from ) continue ; int [ ] cur = dfs ( w , root , level - 1 ) ; first += cur [ 0 ] ; second += cur [ 1 ] ; } return new int [ ] { first , second } ; } } Note : . / Main . java uses unchecked or unsafe operations . Note : Recompile with - Xlint : unchecked for details .

from collections import deque NEW_LINE n , k = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE b = [ [ int ( i ) - 1 for i in input ( ) . split ( ) ] for i in range ( n - 1 ) ] NEW_LINE x , d , ans , c = [ [ ] for i in range ( n ) ] , [ [ ] for i in range ( n ) ] , n , 0 NEW_LINE for i , j in b : NEW_LINE INDENT x [ i ] . append ( j ) NEW_LINE x [ j ] . append ( i ) NEW_LINE DEDENT def f ( s ) : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT q , v = deque ( ) , [ 1 ] * n NEW_LINE v [ i ] = 0 NEW_LINE for j in x [ i ] : NEW_LINE INDENT q . append ( ( j , 1 , j ) ) NEW_LINE d [ i ] . append ( j ) NEW_LINE v [ j ] = 0 NEW_LINE DEDENT while q : NEW_LINE INDENT p = q . pop ( ) NEW_LINE if p [ 1 ] < s : NEW_LINE INDENT for j in x [ p [ 0 ] ] : NEW_LINE INDENT if v [ j ] : NEW_LINE INDENT q . append ( ( j , p [ 1 ] + 1 , p [ 2 ] ) ) NEW_LINE d [ i ] . append ( p [ 2 ] ) NEW_LINE v [ j ] = 0 NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT DEDENT if k > n // 2 : NEW_LINE INDENT for i in x : c = max ( len ( i ) , c ) NEW_LINE DEDENT if n - c + 1 <= k : ans = 0 NEW_LINE elif k == 1 : ans = n - 2 NEW_LINE else : NEW_LINE INDENT f ( k // 2 ) NEW_LINE if k % 2 : NEW_LINE INDENT for i , j in b : ans = min ( ans , n - len ( d [ i ] ) - len ( d [ j ] ) + d [ i ] . count ( j ) + d [ j ] . count ( i ) - 2 ) NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( n ) : ans = min ( ans , n - len ( d [ i ] ) - 1 ) NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE

n , k = map ( int , input ( ) . split ( ) ) NEW_LINE import sys NEW_LINE sys . setrecursionlimit ( 2000 ) NEW_LINE l = [ [ ] for i in range ( n ) ] NEW_LINE e = [ ] NEW_LINE for i in range ( n - 1 ) : NEW_LINE INDENT a , b = map ( int , input ( ) . split ( ) ) NEW_LINE l [ a - 1 ] . append ( b - 1 ) NEW_LINE l [ b - 1 ] . append ( a - 1 ) NEW_LINE e . append ( [ a - 1 , b - 1 ] ) NEW_LINE DEDENT def first_search ( first , depth ) : NEW_LINE INDENT record = 0 NEW_LINE for i in l [ first ] : NEW_LINE INDENT temp = search ( first , i , depth - 1 ) NEW_LINE if record < temp : NEW_LINE INDENT record = temp NEW_LINE DEDENT DEDENT return record + 1 NEW_LINE DEDENT def search ( before , now , depth ) : NEW_LINE INDENT if depth <= 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans = 1 NEW_LINE for i in l [ now ] : NEW_LINE INDENT if before != i : NEW_LINE INDENT ans += search ( now , i , depth - 1 ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT DEDENT ret = 0 NEW_LINE if k % 2 == 0 : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT temp = search ( - 1 , i , k // 2 ) NEW_LINE if temp > ret : NEW_LINE INDENT ret = temp NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT for i in e : NEW_LINE INDENT temp = search ( i [ 0 ] , i [ 1 ] , k // 2 ) + search ( i [ 1 ] , i [ 0 ] , k // 2 ) NEW_LINE if temp > ret : NEW_LINE INDENT ret = temp NEW_LINE DEDENT DEDENT DEDENT print ( n - ret ) NEW_LINE

import sys NEW_LINE from collections import defaultdict , deque NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n , k = LI ( ) NEW_LINE G = defaultdict ( list ) NEW_LINE AB = [ LI_ ( ) for _ in range ( n - 1 ) ] NEW_LINE for a , b in AB : NEW_LINE INDENT G [ a ] . append ( b ) NEW_LINE G [ b ] . append ( a ) NEW_LINE DEDENT def DFS ( ss : list , t : int ) : NEW_LINE INDENT q = deque ( ) NEW_LINE for s in ss : NEW_LINE INDENT q . append ( ( s , 0 ) ) NEW_LINE DEDENT visited = [ 0 ] * n NEW_LINE visited [ ss [ 0 ] ] = visited [ ss [ - 1 ] ] = 1 NEW_LINE while q : NEW_LINE INDENT v , d = q . pop ( ) NEW_LINE if d >= t : NEW_LINE INDENT continue NEW_LINE DEDENT for to in G [ v ] : NEW_LINE INDENT if visited [ to ] : NEW_LINE INDENT continue NEW_LINE DEDENT visited [ to ] = 1 NEW_LINE q . append ( ( to , d + 1 ) ) NEW_LINE DEDENT DEDENT return n - sum ( visited ) NEW_LINE DEDENT res = INF NEW_LINE if k % 2 : NEW_LINE INDENT for a , b in AB : NEW_LINE INDENT res = min ( res , DFS ( [ a , b ] , ( k - 1 ) // 2 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT for i in range ( n ) : NEW_LINE INDENT res = min ( res , DFS ( [ i ] , k // 2 ) ) NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

import copy NEW_LINE N , K = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE G = [ [ ] for i in range ( N ) ] NEW_LINE E = [ ] NEW_LINE for i in range ( N - 1 ) : NEW_LINE INDENT A , B = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE E . append ( ( A - 1 , B - 1 ) ) NEW_LINE G [ A - 1 ] . append ( B - 1 ) NEW_LINE G [ B - 1 ] . append ( A - 1 ) NEW_LINE DEDENT def DFS ( u , n , G ) : NEW_LINE INDENT q = [ u ] NEW_LINE v = [ 0 ] * N NEW_LINE d = [ 0 ] * N NEW_LINE while q : NEW_LINE INDENT u1 = q . pop ( ) NEW_LINE v [ u1 ] = 1 NEW_LINE if d [ u1 ] < n : NEW_LINE INDENT for u2 in G [ u1 ] : NEW_LINE INDENT if not v [ u2 ] : NEW_LINE INDENT d [ u2 ] = d [ u1 ] + 1 NEW_LINE q . append ( u2 ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return sum ( v ) NEW_LINE DEDENT def DFS_E ( u , uu , n , G ) : NEW_LINE INDENT q = [ u , uu ] NEW_LINE v = [ 0 ] * N NEW_LINE d = [ 0 ] * N NEW_LINE while q : NEW_LINE INDENT u1 = q . pop ( ) NEW_LINE v [ u1 ] = 1 NEW_LINE if d [ u1 ] < n : NEW_LINE INDENT for u2 in G [ u1 ] : NEW_LINE INDENT if not v [ u2 ] and u2 != u : NEW_LINE INDENT d [ u2 ] = d [ u1 ] + 1 NEW_LINE q . append ( u2 ) NEW_LINE DEDENT DEDENT DEDENT DEDENT return sum ( v ) NEW_LINE DEDENT if K % 2 == 0 : NEW_LINE INDENT ans = 0 NEW_LINE for v in range ( N ) : NEW_LINE INDENT ans = max ( ans , DFS ( v , K // 2 , G ) ) NEW_LINE DEDENT print ( N - ans ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = 0 NEW_LINE for u , v in E : NEW_LINE INDENT ans = max ( ans , DFS_E ( u , v , ( K - 1 ) // 2 , G ) ) NEW_LINE DEDENT print ( N - ans ) NEW_LINE DEDENT

from collections import deque NEW_LINE N , K = map ( int , input ( ) . split ( ) ) NEW_LINE es = [ tuple ( map ( lambda x : int ( x ) - 1 , input ( ) . split ( ) ) ) for i in range ( N - 1 ) ] NEW_LINE tr = [ [ ] for i in range ( N ) ] NEW_LINE for i , ( a , b ) in enumerate ( es ) : NEW_LINE INDENT tr [ a ] . append ( ( b , i ) ) NEW_LINE tr [ b ] . append ( ( a , i ) ) NEW_LINE DEDENT def reachable_points ( root_v , cant_visit_v ) : NEW_LINE INDENT visited = [ 0 ] * N NEW_LINE visited [ root_v ] = visited [ cant_visit_v ] = 1 NEW_LINE q = deque ( [ ( root_v , 0 ) ] ) NEW_LINE ret = 0 NEW_LINE while q : NEW_LINE INDENT v , dep = q . popleft ( ) NEW_LINE if dep == K // 2 : break NEW_LINE for to , _ in tr [ v ] : NEW_LINE INDENT if visited [ to ] : continue NEW_LINE ret += 1 NEW_LINE q . append ( ( to , dep + 1 ) ) NEW_LINE visited [ to ] = 1 NEW_LINE DEDENT DEDENT return ret NEW_LINE DEDENT def reachable_edges ( root_e ) : NEW_LINE INDENT a , b = es [ root_e ] NEW_LINE return reachable_points ( a , b ) + reachable_points ( b , a ) NEW_LINE DEDENT if K % 2 : NEW_LINE INDENT ans = N NEW_LINE for center_e in range ( N - 1 ) : NEW_LINE INDENT ans = min ( ans , N - 2 - reachable_edges ( center_e ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT else : NEW_LINE INDENT ans = N NEW_LINE for center_v in range ( N ) : NEW_LINE INDENT ans = min ( ans , N - 1 - reachable_points ( center_v , center_v ) ) NEW_LINE DEDENT print ( ans ) NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { int INF = 100000000 ; Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int m = sc . nextInt ( ) ; int [ ] dp = new int [ n + 1 ] ; int [ ] a = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } int [ ] cost = { 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; Arrays . sort ( a ) ; Arrays . fill ( dp , - INF ) ; dp [ 0 ] = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( i - cost [ a [ j ] ] < 0 ) continue ; else dp [ i ] = Math . max ( dp [ i ] , dp [ i - cost [ a [ j ] ] ] + 1 ) ; } } StringBuilder ans = new StringBuilder ( ) ; while ( n != 0 ) { for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( cost [ a [ j ] ] > n ) continue ; if ( dp [ n - cost [ a [ j ] ] ] == dp [ n ] - 1 ) { ans . append ( a [ j ] ) ; n -= cost [ a [ j ] ] ; break ; } } } System . out . println ( ans ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; public class Main { static long t [ ] ; static long l [ ] ; static long h [ ] ; public static void main ( String [ ] args ) throws IOException { BufferedReader r = new BufferedReader ( new InputStreamReader ( System . in ) , 1 ) ; String s ; String sl [ ] ; int d [ ] = new int [ 10 ] ; int c [ ] = { 999999 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; for ( int i = 0 ; i <= 9 ; i ++ ) { d [ i ] = 999999 ; } s = r . readLine ( ) ; sl = s . split ( " ▁ " ) ; int n = Integer . parseInt ( sl [ 0 ] ) ; int m = Integer . parseInt ( sl [ 1 ] ) ; s = r . readLine ( ) ; sl = s . split ( " ▁ " ) ; for ( int i = 0 ; i < m ; i ++ ) { int v = Integer . parseInt ( sl [ i ] ) ; d [ v ] = c [ v ] ; } int dp [ ] = new int [ n + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { dp [ i ] = - 999999 ; for ( int j = 1 ; j <= 9 ; j ++ ) { if ( i - d [ j ] >= 0 && dp [ i - d [ j ] ] >= 0 ) { dp [ i ] = Math . max ( dp [ i ] , dp [ i - d [ j ] ] + 1 ) ; } } } int z = dp [ n ] ; int q = n ; while ( q > 0 ) { for ( int i = 9 ; 1 <= i ; i -- ) { if ( q - d [ i ] >= 0 && dp [ q - d [ i ] ] == dp [ q ] - 1 ) { System . out . print ( i ) ; q -= d [ i ] ; break ; } } } } }

import java . io . InputStream ; import java . io . PrintStream ; import java . util . HashMap ; import java . util . Map ; import java . util . Scanner ; public class Main { InputStream in = System . in ; PrintStream out = System . out ; int [ ] q = { 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; int [ ] a ; int compare ( String a , String b ) { if ( a == null ) { a = " " ; } if ( b == null ) { b = " " ; } int result = Integer . compare ( a . length ( ) , b . length ( ) ) ; if ( result == 0 ) { result = a . compareTo ( b ) ; } return result ; } String max ( String s1 , String s2 ) { if ( compare ( s1 , s2 ) > 0 ) { return s1 ; } else { return s2 ; } } Map < Integer , String > memo = new HashMap < > ( ) ; String dfs ( int n ) { if ( n == 0 ) { return " " ; } String x = memo . get ( n ) ; if ( x != null ) { return x ; } String ans = null ; for ( int i = 0 ; i < a . length ; i ++ ) { int newN = n - q [ a [ i ] ] ; if ( newN < 0 ) { continue ; } String tmp = dfs ( newN ) ; if ( tmp == null ) { continue ; } ans = max ( ans , a [ i ] + tmp ) ; } memo . put ( n , ans ) ; return ans ; } public void _main ( String [ ] args ) { Scanner sc = new Scanner ( in ) ; int N = sc . nextInt ( ) ; int M = sc . nextInt ( ) ; a = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { a [ i ] = sc . nextInt ( ) ; } out . println ( dfs ( N ) ) ; sc . close ( ) ; } public static void main ( String [ ] args ) { new Main ( ) . _main ( args ) ; } }

import java . util . Arrays ; import java . util . Scanner ; class Main { public static void reverse ( int [ ] A ) { for ( int i = 0 ; i < A . length / 2 ; i ++ ) { int tmp = A [ i ] ; A [ i ] = A [ A . length - i - 1 ] ; A [ A . length - i - 1 ] = tmp ; } } private static final int [ ] num = { 999999 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; private static final int INF = Integer . MAX_VALUE / 4 ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = Integer . parseInt ( scanner . next ( ) ) ; int M = Integer . parseInt ( scanner . next ( ) ) ; int [ ] A = new int [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { A [ i ] = Integer . parseInt ( scanner . next ( ) ) ; } Arrays . sort ( A ) ; reverse ( A ) ; int [ ] dp = new int [ 10010 ] ; Arrays . fill ( dp , - INF ) ; dp [ 0 ] = 0 ; for ( int i = 0 ; i <= N ; i ++ ) { for ( int j = 0 ; j < M ; j ++ ) { if ( i - num [ A [ j ] ] >= 0 ) { dp [ i ] = Math . max ( dp [ i ] , dp [ i - num [ A [ j ] ] ] + 1 ) ; } } } String ans = " " ; int goal = dp [ N ] ; for ( int k = 0 ; k < goal ; k ++ ) { for ( int i = 0 ; i < M ; i ++ ) { if ( N - num [ A [ i ] ] >= 0 && dp [ N ] != 0 && dp [ N - num [ A [ i ] ] ] == dp [ N ] - 1 ) { ans += A [ i ] ; N -= num [ A [ i ] ] ; break ; } } } System . out . println ( ans ) ; } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { private static final int [ ] NUMBER = { 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 } ; public static void main ( String [ ] args ) { try ( Scanner scanner = new Scanner ( System . in ) ) { int n = scanner . nextInt ( ) ; int m = scanner . nextInt ( ) ; scanner . nextLine ( ) ; int [ ] a = new int [ m ] ; int [ ] num = new int [ m ] ; for ( int i = 0 ; i < m ; i ++ ) { a [ i ] = scanner . nextInt ( ) ; num [ i ] = num ( a [ i ] ) ; } scanner . nextLine ( ) ; Arrays . sort ( a ) ; Arrays . sort ( num ) ; int digit = dp ( n , num ) ; int remain = n ; StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < digit ; i ++ ) { for ( int j = m - 1 ; j >= 0 ; j -- ) { if ( dp ( remain - num ( a [ j ] ) , num ) == dp ( remain , num ) - 1 ) { sb . append ( a [ j ] ) ; remain -= num ( a [ j ] ) ; break ; } } } System . out . println ( sb . toString ( ) ) ; } } private static int num ( int k ) { return NUMBER [ k ] ; } private static int dp ( int n , int [ ] num ) { if ( 0 == n ) { return 0 ; } int min = num [ 0 ] ; if ( n % min == 0 ) { return n / min ; } else { for ( int number : num ) { if ( n >= number ) { int next = dp ( n - number , num ) ; if ( next >= 0 ) { return next + 1 ; } } } } return - 1 ; } }

import sys NEW_LINE def solve ( N : int , M : int , A : " List [ int ] " ) : NEW_LINE INDENT costs = [ 10 ** 18 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] NEW_LINE cand = [ ( i , costs [ i ] ) for i in A ] NEW_LINE cand . sort ( reverse = True ) NEW_LINE digits = [ - 1 * 10 ** 16 for i in range ( N + 1 ) ] NEW_LINE digits [ 0 ] = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT r = - 1 * 10 ** 16 NEW_LINE for c in cand : NEW_LINE INDENT if i - c [ 1 ] >= 0 : NEW_LINE INDENT r = max ( r , digits [ i - c [ 1 ] ] + 1 ) NEW_LINE DEDENT DEDENT digits [ i ] = r NEW_LINE DEDENT digit = digits [ N ] NEW_LINE lastCost = N NEW_LINE result = 0 NEW_LINE for i in range ( digit ) : NEW_LINE INDENT for c in cand : NEW_LINE INDENT if lastCost - c [ 1 ] >= 0 and digits [ lastCost - c [ 1 ] ] == digits [ lastCost ] - 1 : NEW_LINE INDENT result = result * 10 + c [ 0 ] NEW_LINE lastCost = lastCost - c [ 1 ] NEW_LINE break NEW_LINE DEDENT DEDENT 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 M = int ( next ( tokens ) ) NEW_LINE A = [ int ( next ( tokens ) ) for _ in range ( M ) ] NEW_LINE solve ( N , M , A ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

N , M = map ( int , input ( ) . split ( ) ) NEW_LINE A = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def num ( k ) : NEW_LINE INDENT costs = [ 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] NEW_LINE return costs [ k - 1 ] NEW_LINE DEDENT inf = 1000 NEW_LINE dp = [ - inf for _ in range ( N + 1 ) ] NEW_LINE dp [ 0 ] = 0 NEW_LINE cost_list = [ num ( k ) for k in A ] NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT for cost in cost_list : NEW_LINE INDENT if i - cost < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT temp = dp [ i - cost ] + 1 NEW_LINE dp [ i ] = max ( dp [ i ] , temp ) NEW_LINE DEDENT DEDENT DEDENT ans = ' ' NEW_LINE many = N NEW_LINE for d in range ( dp [ N ] ) : NEW_LINE INDENT for k in sorted ( A , reverse = True ) : NEW_LINE INDENT if many - num ( k ) < 0 : NEW_LINE INDENT pass NEW_LINE DEDENT else : NEW_LINE INDENT if dp [ many - num ( k ) ] == dp [ many ] - 1 : NEW_LINE INDENT ans += str ( k ) NEW_LINE many -= num ( k ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT pass NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( int ( ans ) ) NEW_LINE

def solve ( string ) : NEW_LINE INDENT n , m , * a = map ( int , string . split ( ) ) NEW_LINE needs = { i + 1 : n for i , n in enumerate ( map ( int , "2 ▁ 5 ▁ 5 ▁ 4 ▁ 5 ▁ 6 ▁ 3 ▁ 7 ▁ 6" . split ( ) ) ) } NEW_LINE if 2 in a and 5 in a : NEW_LINE INDENT a . remove ( 2 ) NEW_LINE DEDENT if 3 in a and 5 in a : NEW_LINE INDENT a . remove ( 3 ) NEW_LINE DEDENT if 2 in a and 3 in a : NEW_LINE INDENT a . remove ( 2 ) NEW_LINE DEDENT if 6 in a and 9 in a : NEW_LINE INDENT a . remove ( 6 ) NEW_LINE DEDENT b = sorted ( a , key = lambda x : needs [ x ] ) NEW_LINE index = 0 NEW_LINE base = str ( b [ 0 ] ) * ( n // needs [ b [ 0 ] ] ) NEW_LINE n %= needs [ b [ 0 ] ] NEW_LINE while n > 0 : NEW_LINE INDENT use = [ _b for _b in b if needs [ _b ] <= needs [ b [ 0 ] ] + n ] NEW_LINE if len ( use ) == 1 : NEW_LINE INDENT base = base [ : - 1 ] NEW_LINE n += needs [ b [ 0 ] ] NEW_LINE DEDENT elif max ( use ) == b [ 0 ] : NEW_LINE INDENT tmp_n = use [ - 1 ] NEW_LINE tmp_c = n // ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) NEW_LINE base = base [ : - tmp_c ] + str ( tmp_n ) * tmp_c NEW_LINE n -= ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) * tmp_c NEW_LINE DEDENT else : NEW_LINE INDENT tmp_n = max ( use ) NEW_LINE tmp_c = n // ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) NEW_LINE base = base [ : index ] + str ( tmp_n ) * tmp_c + base [ index + tmp_c : ] NEW_LINE n -= ( needs [ tmp_n ] - needs [ b [ 0 ] ] ) * tmp_c NEW_LINE index += tmp_c NEW_LINE DEDENT DEDENT return base NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( ' \n ' . join ( [ input ( ) , input ( ) ] ) ) ) NEW_LINE DEDENT

import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nms = lambda : map ( str , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE n , m = nm ( ) NEW_LINE a = nl ( ) NEW_LINE lis = [ 0 , 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] NEW_LINE dp = [ - 1 for _ in range ( n + 1 ) ] NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in a : NEW_LINE INDENT if i - lis [ j ] >= 0 : NEW_LINE INDENT dp [ i ] = max ( dp [ i ] , dp [ i - lis [ j ] ] * 10 + j ) NEW_LINE DEDENT DEDENT DEDENT print ( dp [ n ] ) NEW_LINE

import sys NEW_LINE RESOURCE_DICT = dict ( [ ( k , v ) for k , v in zip ( range ( 1 , 10 ) , [ 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 ] ) ] ) NEW_LINE def get_input ( ) : NEW_LINE INDENT N , M = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE A = [ int ( _ ) for _ in input ( ) . split ( ) ] NEW_LINE return N , M , A NEW_LINE DEDENT def solve ( N , M , A ) : NEW_LINE INDENT sorted_A = sorted ( A ) [ : : - 1 ] NEW_LINE dp = fill_dp ( N , sorted_A ) NEW_LINE array = find_array ( dp , N , sorted_A ) NEW_LINE return " " . join ( map ( str , array ) ) NEW_LINE DEDENT def fill_dp ( N , A ) : NEW_LINE INDENT dp = [ - 100 * N for _ in range ( N + 1 ) ] NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , N + 1 ) : NEW_LINE INDENT fill ( A , dp , i , N ) NEW_LINE DEDENT return dp NEW_LINE DEDENT def fill ( A , dp , n , N ) : NEW_LINE INDENT cand = [ dp [ n - RESOURCE_DICT [ num ] ] + 1 for num in A if n - RESOURCE_DICT [ num ] >= 0 ] NEW_LINE dp [ n ] = max ( cand ) if len ( cand ) > 0 else - 100 * N NEW_LINE DEDENT def find_array ( dp , N , sorted_A ) : NEW_LINE INDENT array = [ ] NEW_LINE current_n = N NEW_LINE for _ in range ( dp [ N ] ) : NEW_LINE INDENT for number in sorted_A : NEW_LINE INDENT if current_n - RESOURCE_DICT [ number ] >= 0 and dp [ current_n - RESOURCE_DICT [ number ] ] == dp [ current_n ] - 1 : NEW_LINE INDENT array . append ( number ) NEW_LINE current_n -= RESOURCE_DICT [ number ] NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT return array NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N , M , A = get_input ( ) NEW_LINE ans = solve ( N , M , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT


import java . util . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; long n = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; out . println ( f ( x , n - x ) + n ) ; } static long f ( long a , long b ) { if ( a > b ) { long t = a ; a = b ; b = t ; } if ( b % a == 0 ) return ( b / a - 1 ) * 2 * a + a ; return 2 * a * ( b / a ) + f ( b % a , a ) ; } }

import java . util . * ; public class Main { public void main ( Scanner sc ) { long n = sc . nextLong ( ) ; long x = sc . nextLong ( ) ; long ans = n ; long a = n - x ; long b = x ; while ( b != 0 ) { long r = a / b ; long q = a % b ; ans += 2 * b * r ; if ( q == 0 ) { ans -= b ; } a = b ; b = q ; } System . out . println ( ans ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . UncheckedIOException ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { SC sc = new SC ( System . in ) ; long N = sc . nextLong ( ) ; long X = sc . nextLong ( ) ; long sum = 0 ; if ( X > N / 2 ) { X = N - X ; } long big = N - X ; long mini = X ; sum = N ; while ( true ) { if ( big % mini != 0 ) { sum += mini * 2 * ( big / mini ) ; long tmp = mini ; mini = big % mini ; big = tmp ; } else { sum += mini * ( ( big / mini ) * 2 - 1 ) ; break ; } } pl ( sum ) ; } static class SC { private BufferedReader reader = null ; private StringTokenizer tokenizer = null ; public SC ( InputStream in ) { reader = new BufferedReader ( new InputStreamReader ( in ) ) ; } public String next ( ) { if ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } return tokenizer . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } public String nextLine ( ) { try { return reader . readLine ( ) ; } catch ( IOException e ) { throw new UncheckedIOException ( e ) ; } } } public static void pl ( Object o ) { System . out . println ( o ) ; } public static void pl ( ) { System . out . println ( ) ; } public static void p ( Object o ) { System . out . print ( o ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long num = sc . nextLong ( ) ; long start = sc . nextLong ( ) ; System . out . println ( num + cal ( start , num - start ) ) ; } public static long cal ( long width , long height ) { if ( width * height == 0 ) { return - Math . max ( width , height ) ; } else if ( width == height ) { return width ; } else if ( width > height ) { return width / height * height * 2 + cal ( width % height , height ) ; } else { return height / width * width * 2 + cal ( width , height % width ) ; } } }

import java . util . Scanner ; public class Main { public long solve ( long N , long X ) { long longEdge = Math . max ( X , N - X ) ; long shortEdge = Math . min ( X , N - X ) ; long length = X + N - X ; long times = 1 ; while ( shortEdge > 0 ) { long num = longEdge / shortEdge ; long left = longEdge - ( shortEdge * num ) ; length += ( shortEdge * num * 2 ) ; longEdge = shortEdge ; shortEdge = left ; times ++ ; } length -= longEdge ; return length ; } public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; long N = in . nextLong ( ) ; long X = in . nextLong ( ) ; in . close ( ) ; Main main = new Main ( ) ; long result = main . solve ( N , X ) ; System . out . println ( result ) ; } }

import sys NEW_LINE stdin = sys . stdin NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE na = lambda : list ( map ( int , stdin . readline ( ) . split ( ) ) ) NEW_LINE nn = lambda : list ( stdin . readline ( ) . split ( ) ) NEW_LINE ns = lambda : stdin . readline ( ) . rstrip ( ) NEW_LINE n , x = na ( ) NEW_LINE def loop ( a , b ) : NEW_LINE INDENT h = max ( a , b ) NEW_LINE w = min ( a , b ) NEW_LINE if h % w == 0 : NEW_LINE INDENT return int ( ( 2 * h / w - 1 ) * w ) NEW_LINE DEDENT else : NEW_LINE INDENT m = h % w NEW_LINE q = h // w NEW_LINE return 2 * q * w + loop ( m , w ) NEW_LINE DEDENT DEDENT print ( loop ( x , n - x ) + n ) NEW_LINE

n , x = map ( int , input ( ) . split ( ) ) NEW_LINE if ( x > n // 2 and n % 2 == 0 ) or ( x > ( n + 1 ) // 2 and n % 2 == 1 ) : NEW_LINE INDENT x = n - x NEW_LINE DEDENT A = n - x NEW_LINE B = x NEW_LINE k = 0 NEW_LINE m = - 1 NEW_LINE ans = n NEW_LINE while m != 0 : NEW_LINE INDENT k = A // B NEW_LINE m = A % B NEW_LINE ans += B * k * 2 NEW_LINE if m == 0 : NEW_LINE INDENT ans -= B NEW_LINE DEDENT A = B NEW_LINE B = m NEW_LINE DEDENT print ( ans ) NEW_LINE

def main ( ) : NEW_LINE INDENT n , x = map ( int , input ( ) . split ( ) ) NEW_LINE a , b = n - x , x NEW_LINE if ( a < b ) : NEW_LINE INDENT a , b = b , a NEW_LINE DEDENT path_length = calc_path ( a , b , n ) NEW_LINE print ( path_length ) NEW_LINE DEDENT def calc_path ( a1 , b1 , c1 ) : NEW_LINE INDENT q , mod = divmod ( a1 , b1 ) NEW_LINE count = 0 NEW_LINE if mod == 0 : NEW_LINE INDENT c2 = c1 + 2 * b1 * q - b1 NEW_LINE return c2 NEW_LINE DEDENT else : NEW_LINE INDENT count = count + 1 NEW_LINE c2 = c1 + 2 * b1 * q NEW_LINE a2 = a1 - b1 * q NEW_LINE b2 = b1 NEW_LINE if ( a2 < b2 ) : NEW_LINE INDENT a2 , b2 = b2 , a2 NEW_LINE DEDENT return calc_path ( a2 , b2 , c2 ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import sys NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LF ( ) : return [ float ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n , x = LI ( ) NEW_LINE b , a = sorted ( [ x , n - x ] ) NEW_LINE ans = a + b NEW_LINE while b : NEW_LINE INDENT q , mod = divmod ( a , b ) NEW_LINE ans += ( 2 * q - ( not mod ) ) * b NEW_LINE a , b = b , mod NEW_LINE DEDENT return ans NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

def solve ( s , a , b ) : NEW_LINE INDENT if a % b == 0 : NEW_LINE INDENT return s + ( ( a // b ) * 2 - 1 ) * b NEW_LINE DEDENT if b % a == 0 : NEW_LINE INDENT return s + ( ( b // a ) * 2 - 1 ) * a NEW_LINE DEDENT elif a > b : NEW_LINE INDENT s += ( a // b ) * 2 * b NEW_LINE return solve ( s , a % b , b ) NEW_LINE DEDENT else : NEW_LINE INDENT s += ( b // a ) * 2 * a NEW_LINE return solve ( s , a , b % a ) NEW_LINE DEDENT DEDENT n , x = map ( int , input ( ) . split ( ) ) NEW_LINE print ( solve ( n , n - x , x ) ) NEW_LINE


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; scanner . close ( ) ; String formatted = " " ; if ( s . length ( ) == 1 ) { formatted = s . toUpperCase ( ) ; } else { formatted = s . substring ( 0 , 1 ) . toUpperCase ( ) + s . substring ( 1 , s . length ( ) ) . toLowerCase ( ) ; } System . out . println ( formatted ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . InputMismatchException ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; FastScanner in = new FastScanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; TaskB solver = new TaskB ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class TaskB { public void solve ( int testNumber , FastScanner in , PrintWriter out ) { String s = in . next ( ) ; out . print ( Character . toUpperCase ( s . charAt ( 0 ) ) ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { out . print ( Character . toLowerCase ( s . charAt ( i ) ) ) ; } out . println ( ) ; } } static class FastScanner { private InputStream in ; private byte [ ] buffer = new byte [ 1024 ] ; private int bufPointer ; private int bufLength ; public FastScanner ( InputStream in ) { this . in = in ; this . bufPointer = 0 ; this . bufLength = 0 ; } private int readByte ( ) { if ( bufPointer >= bufLength ) { if ( bufLength == - 1 ) throw new InputMismatchException ( ) ; bufPointer = 0 ; try { bufLength = in . read ( buffer ) ; } catch ( IOException e ) { throw new InputMismatchException ( ) ; } if ( bufLength <= 0 ) return - 1 ; } return buffer [ bufPointer ++ ] ; } private static boolean isPrintableChar ( int c ) { return c >= 33 && c <= 126 ; } public String next ( ) { StringBuilder sb = new StringBuilder ( ) ; int b = readByte ( ) ; while ( ! isPrintableChar ( b ) ) b = readByte ( ) ; while ( isPrintableChar ( b ) ) { sb . appendCodePoint ( b ) ; b = readByte ( ) ; } return sb . toString ( ) ; } } }

import java . util . * ; import java . lang . * ; import java . math . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; String cap = s . substring ( 0 , 1 ) . toUpperCase ( ) ; String other = s . substring ( 1 ) . toLowerCase ( ) ; System . out . println ( cap + other ) ; sc . close ( ) ; } private static long gcd ( Long m , long n ) { if ( m < n ) { return gcd ( n , m ) ; } if ( n == 0 ) { return m ; } return gcd ( n , m % n ) ; } private static long [ ] [ ] Combination_nCk ( long n , long k ) { n ++ ; k ++ ; long [ ] [ ] ans = new long [ ( int ) n ] [ ( int ) k ] ; for ( int i = 0 ; i < n ; i ++ ) { ans [ i ] [ 0 ] = 1 ; } for ( int i = 0 ; i < n - 1 ; i ++ ) { for ( int j = 0 ; j < k - 1 ; j ++ ) { if ( i < j ) { ans [ i ] [ j ] = 0 ; } else { ans [ i + 1 ] [ j + 1 ] = ans [ i ] [ j ] + ans [ i ] [ j + 1 ] ; } } } return ans ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { String S = in . next ( ) ; out . println ( S . toUpperCase ( ) . charAt ( 0 ) + S . substring ( 1 ) . toLowerCase ( ) ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { String S = sc . next ( ) ; System . out . println ( S . substring ( 0 , 1 ) . toUpperCase ( ) + S . substring ( 1 ) . toLowerCase ( ) ) ; } }

s = str ( input ( ) ) NEW_LINE print ( s . capitalize ( ) ) NEW_LINE

s = input ( ) NEW_LINE s = s . lower ( ) NEW_LINE if len ( s ) >= 2 : NEW_LINE INDENT print ( s [ 0 ] . upper ( ) + s [ 1 : ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( s [ 0 ] . upper ( ) ) NEW_LINE DEDENT

s = input ( ) NEW_LINE if len ( s ) == 1 : NEW_LINE INDENT print ( s . upper ( ) ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( s [ 0 ] . upper ( ) + s [ 1 : ] . lower ( ) ) NEW_LINE DEDENT

print ( input ( ) . capitalize ( ) ) NEW_LINE

s = list ( input ( ) ) NEW_LINE s [ 0 ] = s [ 0 ] . upper ( ) NEW_LINE for i in range ( 1 , len ( s ) ) : NEW_LINE INDENT s [ i ] = s [ i ] . lower ( ) NEW_LINE DEDENT print ( " " . join ( s ) ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; boolean b1 , b2 = false , b3 = true ; b1 = ( s . charAt ( 0 ) == ' A ' ) ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( i != 1 && i != s . length ( ) - 1 && c == ' C ' ) { if ( ! b2 ) { b2 = true ; } else { b1 = false ; } } else if ( Character . isUpperCase ( c ) ) { b3 = false ; } } if ( b1 && b2 && b3 ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } }

import java . io . IOException ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; System . out . println ( s . matches ( " A [ a - z ] + C [ a - z ] + " ) ? " AC " : " WA " ) ; sc . close ( ) ; } }

import java . util . Scanner ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int size = str . length ( ) ; if ( " A " . equals ( str . substring ( 0 , 1 ) ) ) { int num = 0 ; String str2 = str . substring ( 2 , size - 1 ) ; int size2 = str2 . length ( ) ; for ( int i = 0 ; i < size2 ; i ++ ) { String str4 = str2 . substring ( 0 , 1 ) ; if ( str4 . equals ( " C " ) ) { num = num + 1 ; } str2 = str2 . substring ( 1 ) ; } if ( num == 1 ) { str2 = str . substring ( 2 , size - 1 ) ; str2 = str2 . replace ( " C " , " c " ) ; str2 = str2 . concat ( str . substring ( str . length ( ) - 1 ) ) ; str2 = str . substring ( 1 , 2 ) . concat ( str2 ) ; String str3 = str2 . toLowerCase ( ) ; if ( str2 . equals ( str3 ) ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } else { System . out . println ( " WA " ) ; } } else { System . out . println ( " WA " ) ; } } }

import java . io . * ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { String str = ( new Scanner ( System . in ) ) . next ( ) ; String ans = str . matches ( " ^ A [ a - z ] + C [ a - z ] + $ " ) ? " AC " : " WA " ; System . out . println ( ans ) ; } }

import java . util . * ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; String str = sc . nextLine ( ) ; int L = str . length ( ) ; int cnt = 0 ; boolean check = true ; for ( int i = 0 ; i < L ; i ++ ) { if ( i == 0 ) { if ( str . charAt ( i ) != ' A ' ) { check = false ; } } else if ( 2 <= i && i <= L - 2 ) { if ( str . charAt ( i ) == ' C ' ) { cnt ++ ; } else if ( ' A ' <= str . charAt ( i ) && str . charAt ( i ) <= ' Z ' ) { check = false ; } } else { if ( ' A ' <= str . charAt ( i ) && str . charAt ( i ) <= ' Z ' ) check = false ; } } if ( cnt != 1 ) { check = false ; } if ( check ) { System . out . println ( " AC " ) ; } else { System . out . println ( " WA " ) ; } } }

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 s = IS ( ) NEW_LINE if s [ 0 ] == ' A ' and s [ 2 : len ( s ) - 1 ] . count ( ' C ' ) == 1 and ' ' . join ( [ s [ i ] for i in range ( 1 , len ( s ) ) if not i == s . index ( ' C ' ) ] ) . islower ( ) : NEW_LINE INDENT print ( ' AC ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' WA ' ) NEW_LINE DEDENT

s = input ( ) NEW_LINE a = " AC " NEW_LINE if s [ 0 ] != " A " : NEW_LINE INDENT a = " WA " NEW_LINE DEDENT cnt = 0 NEW_LINE for i in range ( 2 , len ( s ) - 1 ) : NEW_LINE INDENT if s [ i ] == " C " : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT if cnt != 1 : NEW_LINE INDENT a = " WA " NEW_LINE DEDENT for i in range ( 1 , len ( s ) ) : NEW_LINE INDENT if s [ i ] != " C " and ord ( s [ i ] ) < ord ( " a " ) : NEW_LINE INDENT a = " WA " NEW_LINE DEDENT DEDENT print ( a ) 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 ( S : str ) : NEW_LINE INDENT if S [ 0 ] != " A " : NEW_LINE INDENT print ( " WA " ) NEW_LINE return NEW_LINE DEDENT if S [ 2 : - 1 ] . count ( " C " ) != 1 : NEW_LINE INDENT print ( " WA " ) NEW_LINE return NEW_LINE DEDENT flag = False NEW_LINE for i , c in enumerate ( S ) : NEW_LINE INDENT if i == 0 : NEW_LINE INDENT continue NEW_LINE DEDENT if ord ( " a " ) <= ord ( c ) and ord ( c ) <= ord ( " z " ) : NEW_LINE INDENT continue NEW_LINE DEDENT elif 1 < i and i < len ( S ) - 1 and c == " C " and flag == False : NEW_LINE INDENT flag = True NEW_LINE continue NEW_LINE DEDENT else : NEW_LINE INDENT print ( " WA " ) NEW_LINE return NEW_LINE DEDENT DEDENT print ( " AC " ) 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 S = next ( tokens ) NEW_LINE solve ( S ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

S = [ i for i in input ( ) ] NEW_LINE count = 0 NEW_LINE if S . pop ( 0 ) == ' A ' : NEW_LINE INDENT count += 1 NEW_LINE DEDENT if S [ 1 : - 1 ] . count ( ' C ' ) == 1 : NEW_LINE INDENT count += 1 NEW_LINE S . remove ( ' C ' ) NEW_LINE if ' ' . join ( S ) . islower ( ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT print ( ' AC ' if count == 3 else ' WA ' ) NEW_LINE

S = input ( ) NEW_LINE if S [ 0 ] == ' A ' : NEW_LINE INDENT f1 = True NEW_LINE DEDENT else : NEW_LINE INDENT f1 = False NEW_LINE DEDENT C_cnt = 0 NEW_LINE for s in S [ 2 : - 1 ] : NEW_LINE INDENT if s == ' C ' : NEW_LINE INDENT C_cnt += 1 NEW_LINE DEDENT DEDENT if C_cnt == 1 : NEW_LINE INDENT f2 = True NEW_LINE DEDENT else : NEW_LINE INDENT f2 = False NEW_LINE DEDENT f3 = True NEW_LINE for s in S : NEW_LINE INDENT if s == ' A ' or s == ' C ' : NEW_LINE INDENT continue NEW_LINE DEDENT if s != s . lower ( ) : NEW_LINE INDENT f3 = False NEW_LINE break NEW_LINE DEDENT DEDENT if f1 and f2 and f3 : NEW_LINE INDENT print ( ' AC ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' WA ' ) NEW_LINE DEDENT


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

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

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int [ ] a = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) a [ i ] = sc . nextInt ( ) ; solver ( N , a ) ; } public static void solver ( int N , int [ ] a ) { int [ ] ans = new int [ N ] ; for ( int n = N - 1 ; n >= 0 ; n -- ) { if ( n == N - 1 ) { continue ; } else if ( n == N - 2 ) { ans [ n ] = Math . abs ( a [ n ] - a [ n + 1 ] ) ; } else if ( n == N - 3 ) { ans [ n ] = Math . abs ( a [ n ] - a [ n + 2 ] ) ; } else { ans [ n ] = Math . min ( Math . abs ( ans [ n + 1 ] + Math . abs ( a [ n ] - a [ n + 1 ] ) ) , Math . abs ( ans [ n + 2 ] + Math . abs ( a [ n ] - a [ n + 2 ] ) ) ) ; } } out . println ( ans [ 0 ] ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int [ ] values = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { values [ i ] = sc . nextInt ( ) ; } int [ ] cache = new int [ n ] ; Arrays . fill ( cache , - 1 ) ; System . out . println ( cost ( n - 1 , values , cache ) ) ; } private static int cost ( int i , int [ ] values , int [ ] cache ) { int ans = 0 ; if ( cache [ i ] != - 1 ) { return cache [ i ] ; } if ( i == 0 ) { ans = 0 ; } else if ( i == 1 ) { ans = Math . abs ( values [ 1 ] - values [ 0 ] ) ; } else { int a = cost ( i - 2 , values , cache ) + Math . abs ( values [ i ] - values [ i - 2 ] ) ; int b = cost ( i - 1 , values , cache ) + Math . abs ( values [ i ] - values [ i - 1 ] ) ; ans = Math . min ( a , b ) ; } if ( cache [ i ] == - 1 ) { cache [ i ] = ans ; } return ans ; } }

import java . util . Scanner ; public class Main { static int N ; public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; N = reader . nextInt ( ) ; int [ ] arr = new int [ N ] ; int [ ] gaps = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { arr [ i ] = reader . nextInt ( ) ; if ( i > 0 ) { int r = Math . abs ( arr [ i ] - arr [ i - 1 ] ) + gaps [ i - 1 ] ; if ( i > 1 ) { r = Math . min ( r , Math . abs ( arr [ i ] - arr [ i - 2 ] ) + gaps [ i - 2 ] ) ; } gaps [ i ] = r ; } } System . out . println ( gaps [ N - 1 ] ) ; reader . close ( ) ; } }

n , * a = map ( int , open ( 0 ) . read ( ) . split ( ) ) NEW_LINE dp = [ 0 for i in range ( n ) ] NEW_LINE dp [ 1 ] = abs ( a [ 0 ] - a [ 1 ] ) NEW_LINE for i in range ( 2 , n ) : NEW_LINE INDENT x = abs ( a [ i ] - a [ i - 2 ] ) + dp [ i - 2 ] NEW_LINE y = abs ( a [ i ] - a [ i - 1 ] ) + dp [ i - 1 ] NEW_LINE dp [ i ] = min ( x , y ) NEW_LINE DEDENT print ( dp [ - 1 ] ) NEW_LINE

if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT scaffold_count = int ( input ( ) ) NEW_LINE scaffold_list = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE jump_costs = [ 0 ] * scaffold_count NEW_LINE jump_costs [ 0 ] = 0 NEW_LINE jump_costs [ 1 ] = abs ( scaffold_list [ 0 ] - scaffold_list [ 1 ] ) NEW_LINE for i in range ( 2 , scaffold_count ) : NEW_LINE INDENT jump_costs [ i ] = min ( jump_costs [ i - 2 ] + abs ( scaffold_list [ i - 2 ] - scaffold_list [ i ] ) , jump_costs [ i - 1 ] + abs ( scaffold_list [ i - 1 ] - scaffold_list [ i ] ) ) NEW_LINE DEDENT print ( jump_costs [ scaffold_count - 1 ] ) NEW_LINE DEDENT

import sys NEW_LINE sys . setrecursionlimit ( 1000000 ) NEW_LINE N = int ( input ( ) ) NEW_LINE a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE dp = [ 0 ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE dp [ 1 ] = abs ( a [ 1 ] - a [ 0 ] ) NEW_LINE def dpdfs ( n ) : NEW_LINE INDENT if n == 0 : NEW_LINE INDENT return dp [ 0 ] NEW_LINE DEDENT elif n == 1 : NEW_LINE INDENT return dp [ 1 ] NEW_LINE DEDENT if dp [ n ] != 0 : NEW_LINE INDENT return dp [ n ] NEW_LINE DEDENT dp [ n ] = min ( dpdfs ( n - 1 ) + abs ( a [ n ] - a [ n - 1 ] ) , dpdfs ( n - 2 ) + abs ( a [ n ] - a [ n - 2 ] ) ) NEW_LINE return dp [ n ] NEW_LINE DEDENT dpdfs ( N - 1 ) NEW_LINE print ( dp [ - 1 ] ) NEW_LINE

_ , t = open ( 0 ) NEW_LINE b , * a = map ( int , t . split ( ) ) NEW_LINE c = b NEW_LINE e = f = 0 NEW_LINE for g in a : e , f , b , c = min ( abs ( b - g ) + e , abs ( c - g ) + f ) , e , g , b NEW_LINE print ( e ) NEW_LINE

def poll_poll_poll_poll_poll ( N : int , A : list ) -> int : NEW_LINE INDENT dp = [ float ( ' inf ' ) ] * N NEW_LINE dp [ 0 ] = 0 NEW_LINE for i in range ( 1 , N ) : NEW_LINE INDENT dp [ i ] = dp [ i - 1 ] + abs ( A [ i ] - A [ i - 1 ] ) NEW_LINE if i > 1 : NEW_LINE INDENT dp [ i ] = min ( dp [ i ] , dp [ i - 2 ] + abs ( A [ i ] - A [ i - 2 ] ) ) NEW_LINE DEDENT DEDENT return dp [ N - 1 ] NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = int ( input ( ) ) NEW_LINE A = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = poll_poll_poll_poll_poll ( N , A ) NEW_LINE print ( ans ) NEW_LINE DEDENT


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

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { int LOG = 40 ; void solve ( ) { long A = in . nextLong ( ) , B = in . nextLong ( ) ; long ans = xor ( B ) ^ xor ( A - 1 ) ; out . println ( ans ) ; } long xor ( long n ) { if ( n <= 0 ) return 0 ; long res = 0 ; for ( int i = 0 ; i < LOG ; i ++ ) { long period = 1L << ( i + 1 ) ; long zeros = period / 2 , ones = period / 2 ; long q = ( n + 1 ) / period , r = ( n + 1 ) % period ; long v = 0 ; if ( q % 2 == 1 && ones % 2 == 1 ) v ^= 1 ; if ( r > zeros && ( r - zeros ) % 2 == 1 ) v ^= 1 ; res |= v << i ; } return res ; } public static void main ( String [ ] args ) { in = new FastScanner ( new BufferedReader ( new InputStreamReader ( System . in ) ) ) ; out = new PrintWriter ( System . out ) ; new Main ( ) . solve ( ) ; out . close ( ) ; } static FastScanner in ; static PrintWriter out ; static class FastScanner { BufferedReader in ; StringTokenizer st ; public FastScanner ( BufferedReader in ) { this . in = in ; } public String nextToken ( ) { while ( st == null || ! st . hasMoreTokens ( ) ) { try { st = new StringTokenizer ( in . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } public int nextInt ( ) { return Integer . parseInt ( nextToken ( ) ) ; } public long nextLong ( ) { return Long . parseLong ( nextToken ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( nextToken ( ) ) ; } } }

import java . util . * ; import java . io . * ; import java . awt . * ; import java . awt . geom . Point2D ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { out . println ( f ( sc . nextLong ( ) - 1 ) ^ f ( sc . nextLong ( ) ) ) ; out . close ( ) ; } static long f ( long x ) { long c = x % 4 ; if ( c == 0 ) return x ; if ( c == 1 ) return 1 ; if ( c == 2 ) return 1 ^ x ; return 0 ; } static long power ( long x , long n ) { long mod = 1000000007 ; long ans = 1 ; while ( n > 0 ) { if ( ( n & 1 ) == 1 ) { ans = ( ans * x ) % mod ; } x = ( x * x ) % mod ; n >>= 1 ; } return ans ; } static PrintWriter out = new PrintWriter ( System . out ) ; static class sc { static Scanner s = new Scanner ( System . in ) ; static String next ( ) { return s . next ( ) ; } static int nextInt ( ) { return Integer . parseInt ( s . next ( ) ) ; } static long nextLong ( ) { return Long . parseLong ( s . next ( ) ) ; } static double nextDouble ( ) { return Double . parseDouble ( s . next ( ) ) ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Main main = new Main ( ) ; main . solve ( ) ; } private void solve ( ) { Scanner scanner = new Scanner ( System . in ) ; long A = scanner . nextLong ( ) ; long B = scanner . nextLong ( ) ; long answer = 0 ; long C = 0 ; if ( A % 2 == 0 ) { if ( B % 2 == 0 ) { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = B ; } else { answer = B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = 1 ; } else { answer = 0 ; } } } else { if ( B % 2 == 0 ) { C = ( B - A - 1 ) / 2 ; if ( C % 2 == 0 ) { answer = A ^ B ; } else { answer = A ^ B ^ 1 ; } } else { C = ( B - A ) / 2 ; if ( C % 2 == 0 ) { answer = A ; } else { answer = A ^ 1 ; } } } System . out . println ( answer ) ; } }

import java . util . * ; public class Main { public static class MyPair implements Comparable < MyPair > { int cost ; int supply ; public MyPair ( int cost , int supply ) { this . cost = cost ; this . supply = supply ; } @ Override public int compareTo ( MyPair other ) { return ( this . cost - other . cost ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; boolean AOdd = A % 2 == 1 ; boolean BOdd = B % 2 == 1 ; if ( A == B ) { System . out . println ( A ) ; } else if ( AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; if ( LSB == 1 ) { System . out . println ( A - 1 ) ; } else { System . out . println ( A ) ; } } else if ( AOdd && ! BOdd ) { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; long BToCompare = B + LSB ; long AToCompare = A ; long solution = 0 ; long multiplier = 1 ; while ( BToCompare > 0 ) { if ( AToCompare == 0 ) { solution += BToCompare % 2 * multiplier ; BToCompare /= 2 ; } else { if ( BToCompare % 2 != AToCompare % 2 ) { solution += multiplier ; } BToCompare /= 2 ; AToCompare /= 2 ; } multiplier *= 2 ; } System . out . println ( solution ) ; } else if ( ! AOdd && BOdd ) { long diff = B - A ; long LSB = ( diff + 1 ) / 2 % 2 ; System . out . println ( LSB ) ; } else { long diff = B - A ; long LSB = ( diff ) / 2 % 2 ; System . out . println ( B + LSB ) ; } } }

A , B = map ( int , input ( ) . split ( ) ) NEW_LINE A -= 1 NEW_LINE if A % 4 == 1 : NEW_LINE INDENT A = 1 NEW_LINE DEDENT elif A % 4 == 2 : NEW_LINE INDENT A += 1 NEW_LINE DEDENT elif A % 4 == 3 : NEW_LINE INDENT A = 0 NEW_LINE DEDENT if B % 4 == 1 : NEW_LINE INDENT B = 1 NEW_LINE DEDENT elif B % 4 == 2 : NEW_LINE INDENT B += 1 NEW_LINE DEDENT elif B % 4 == 3 : NEW_LINE INDENT B = 0 NEW_LINE DEDENT answer = A ^ B NEW_LINE print ( answer ) NEW_LINE

def solve ( string ) : NEW_LINE INDENT a , b = map ( int , string . split ( ) ) NEW_LINE if b == 0 : NEW_LINE INDENT return "0" NEW_LINE DEDENT bin_a = " { :040b } " . format ( a ) NEW_LINE bin_b = " { :040b } " . format ( b ) NEW_LINE aa = [ - 1 if _a == "0" else int ( bin_a [ i + 1 : ] or "0" , 2 ) for i , _a in enumerate ( bin_a ) ] NEW_LINE bb = [ - 1 if _b == "0" else int ( bin_b [ i + 1 : ] or "0" , 2 ) for i , _b in enumerate ( bin_b ) ] NEW_LINE index = 0 NEW_LINE while True : NEW_LINE INDENT if bb [ index ] != - 1 : NEW_LINE INDENT break NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans = [ ] NEW_LINE while index < 40 : NEW_LINE INDENT if aa [ index ] == bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( "0" ) NEW_LINE DEDENT elif aa [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 ) % 2 ) ) NEW_LINE DEDENT elif bb [ index ] == - 1 : NEW_LINE INDENT ans . append ( str ( aa [ index ] % 2 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans . append ( str ( ( bb [ index ] + 1 - aa [ index ] ) % 2 ) ) NEW_LINE DEDENT index += 1 NEW_LINE DEDENT ans [ - 1 ] = str ( ( b - a ) // 2 % 2 ) if a % 2 == b % 2 == 0 else str ( ( ( b - a ) // 2 + 1 ) % 2 ) NEW_LINE return str ( int ( " " . join ( ans ) , 2 ) ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT print ( solve ( input ( ) ) ) NEW_LINE DEDENT

import sys NEW_LINE INF = float ( " inf " ) NEW_LINE def f ( n ) : NEW_LINE INDENT if n % 2 == 0 : NEW_LINE INDENT if ( n // 2 ) % 2 == 0 : NEW_LINE INDENT return n NEW_LINE DEDENT else : NEW_LINE INDENT return 1 ^ n NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if ( ( n + 1 ) // 2 ) % 2 == 0 : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 1 NEW_LINE DEDENT DEDENT DEDENT def solve ( A : int , B : int ) : NEW_LINE INDENT print ( f ( B ) ^ f ( A - 1 ) ) 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 A = int ( next ( tokens ) ) NEW_LINE B = int ( next ( tokens ) ) NEW_LINE solve ( A , B ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import math NEW_LINE A , B = map ( int , input ( ) . split ( ) ) NEW_LINE ans = int ( 0 ) NEW_LINE if B == 0 : NEW_LINE INDENT ans = 0 NEW_LINE DEDENT else : NEW_LINE INDENT N = math . floor ( math . log2 ( B ) + 1 ) NEW_LINE A_mod = A % 4 NEW_LINE B_mod = B % 4 NEW_LINE if A_mod < 2 : NEW_LINE INDENT if B_mod == 1 or B_mod == 2 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod == 3 or B_mod == 0 : NEW_LINE INDENT ans += 1 NEW_LINE DEDENT DEDENT for i in range ( 2 , N + 1 ) : NEW_LINE INDENT A_mod = A % ( 2 ** i ) NEW_LINE B_mod = B % ( 2 ** i ) NEW_LINE if A_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT if B_mod >= 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( ( B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT if B_mod < 2 ** ( i - 1 ) : NEW_LINE INDENT ans += ( A_mod % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT else : NEW_LINE INDENT ans += ( ( A_mod + B_mod + 1 ) % 2 ) * ( 2 ** ( i - 1 ) ) NEW_LINE DEDENT DEDENT DEDENT DEDENT print ( ans ) NEW_LINE

def SI ( ) : return input ( ) NEW_LINE def II ( ) : return int ( SI ( ) ) NEW_LINE def STI ( ) : return SI ( ) . split ( ) NEW_LINE def ITI ( ) : return map ( int , STI ( ) ) NEW_LINE def SLI ( ) : return list ( SI ( ) ) NEW_LINE def ILI ( ) : return list ( ITI ( ) ) NEW_LINE A , B = ITI ( ) NEW_LINE def cum_xor ( n ) : NEW_LINE INDENT result = ( n + 1 ) // 2 % 2 NEW_LINE if ( n + 1 ) % 2 == 1 : result ^= n NEW_LINE return result NEW_LINE DEDENT print ( cum_xor ( A - 1 ) ^ cum_xor ( B ) ) NEW_LINE