import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; System . out . println ( "100 ▁ 100" ) ; boolean ans [ ] [ ] = new boolean [ 100 ] [ 100 ] ; for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { if ( i < 50 ) { ans [ i ] [ j ] = true ; } else { ans [ i ] [ j ] = false ; } } } for ( int i = 0 ; i < B - 1 ; i ++ ) { ans [ 2 * ( i / 50 ) ] [ 2 * ( i % 50 ) ] = false ; } for ( int i = 0 ; i < A - 1 ; i ++ ) { ans [ 2 * ( i / 50 ) + 51 ] [ 2 * ( i % 50 ) ] = true ; } for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { if ( ans [ i ] [ j ] ) { System . out . print ( ' . ' ) ; } else { System . out . print ( ' # ' ) ; } } System . out . println ( ) ; } } }

import java . util . * ; public class Main { public void main ( Scanner sc ) { int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; char data [ ] [ ] = new char [ 100 ] [ 100 ] ; for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { data [ i ] [ j ] = ( i / 50 == 0 ? ' # ' : ' . ' ) ; } } for ( int i = 0 ; i < a - 1 ; i ++ ) { data [ 2 * ( i / 50 ) ] [ 2 * ( i % 50 ) ] = ' . ' ; } for ( int i = 0 ; i < b - 1 ; i ++ ) { data [ 2 * ( i / 50 ) + 51 ] [ 2 * ( i % 50 ) ] = ' # ' ; } System . out . println ( "100 ▁ 100" ) ; for ( int i = 0 ; i < 100 ; i ++ ) { System . out . println ( new String ( data [ i ] ) ) ; } } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; new Main ( ) . main ( sc ) ; sc . close ( ) ; } }

import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . io . PrintStream ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; DGridComponents solver = new DGridComponents ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class DGridComponents { public void solve ( int testNumber , Scanner in , PrintWriter out ) { int a = in . nextInt ( ) - 1 , b = in . nextInt ( ) - 1 ; System . out . println ( "100 ▁ 100" ) ; for ( int y = 0 ; y < 49 ; y ++ ) { for ( int x = 0 ; x < 100 ; x ++ ) { if ( b > 0 && x % 2 == 0 && y % 2 == 0 ) { System . out . print ( ' # ' ) ; b -- ; } else { System . out . print ( ' . ' ) ; } } System . out . println ( ) ; } for ( int i = 0 ; i < 100 ; i ++ ) { System . out . print ( ' . ' ) ; } System . out . println ( ) ; for ( int i = 0 ; i < 100 ; i ++ ) { System . out . print ( ' # ' ) ; } System . out . println ( ) ; for ( int y = 51 ; y < 100 ; y ++ ) { for ( int x = 0 ; x < 100 ; x ++ ) { if ( a > 0 && x % 2 == 0 && y % 2 == 0 ) { System . out . print ( ' . ' ) ; a -- ; } else { System . out . print ( ' # ' ) ; } } System . out . println ( ) ; } } } }

import java . util . * ; class Main { static Scanner s = new Scanner ( System . in ) ; static char [ ] [ ] f = new char [ 40 ] [ 99 ] ; public static void main ( String [ ] $ ) { for ( int i = 0 ; i < 20 ; ++ i ) Arrays . fill ( f [ i ] , ' # ' ) ; for ( int i = 20 ; i < 40 ; ++ i ) Arrays . fill ( f [ i ] , ' . ' ) ; f ( 0 , ' . ' ) ; f ( 21 , ' # ' ) ; System . out . println ( "40 ▁ 99" ) ; Arrays . stream ( f ) . forEach ( System . out :: println ) ; } static void f ( int b , char c ) { int a = s . nextInt ( ) - 1 ; for ( int i = 0 ; i < a ; ++ i ) f [ i / 50 * 2 + b ] [ i % 50 * 2 ] = c ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner in = new Scanner ( System . in ) ; int numWhite = in . nextInt ( ) ; int numBlack = in . nextInt ( ) ; char WHITE = ' . ' ; char BLACK = ' # ' ; char [ ] [ ] map = new char [ 100 ] [ 100 ] ; for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { map [ i ] [ j ] = j <= 49 ? WHITE : BLACK ; } } int count = 1 ; for ( int i = 0 ; i < 100 ; i += 2 ) { for ( int j = 0 ; j <= 49 && count < numBlack ; j += 2 ) { map [ i ] [ j ] = BLACK ; count ++ ; } } count = 1 ; for ( int i = 0 ; i < 100 ; i += 2 ) { for ( int j = 51 ; j < 100 && count < numWhite ; j += 2 ) { map [ i ] [ j ] = WHITE ; count ++ ; } } System . out . println ( "100 ▁ 100" ) ; for ( int i = 0 ; i < 100 ; i ++ ) { for ( int j = 0 ; j < 100 ; j ++ ) { System . out . printf ( " % c " , map [ i ] [ j ] ) ; } System . out . println ( ) ; } } }

a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE g1 = [ [ " # " for i in range ( 100 ) ] for i in range ( 20 ) ] NEW_LINE g2 = [ [ " . " for i in range ( 100 ) ] for i in range ( 20 ) ] NEW_LINE a , b = a - 1 , b - 1 NEW_LINE j = 0 NEW_LINE while a != 0 : NEW_LINE INDENT for i in range ( 0 , 100 , 2 ) : NEW_LINE INDENT g1 [ j ] [ i ] = " . " NEW_LINE a -= 1 NEW_LINE if a == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT j += 2 NEW_LINE DEDENT j = 1 NEW_LINE while b != 0 : NEW_LINE INDENT for i in range ( 0 , 100 , 2 ) : NEW_LINE INDENT g2 [ j ] [ i ] = " # " NEW_LINE b -= 1 NEW_LINE if b == 0 : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT j += 2 NEW_LINE DEDENT g1 . extend ( g2 ) NEW_LINE print ( 40 , 100 ) NEW_LINE for ele in g1 : NEW_LINE INDENT print ( " " . join ( ele ) ) NEW_LINE DEDENT

def inpl ( ) : return [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE A , B = inpl ( ) NEW_LINE def nextin ( nwin ) : NEW_LINE INDENT nx , ny = nwin NEW_LINE if nx != 98 : NEW_LINE INDENT return ( nx + 2 , ny ) NEW_LINE DEDENT else : NEW_LINE INDENT return ( 0 , ny + 2 ) NEW_LINE DEDENT DEDENT Wh = [ [ ' # ' for _ in range ( 100 ) ] for _ in range ( 50 ) ] NEW_LINE nowin = [ 0 , 0 ] NEW_LINE for _ in range ( A - 1 ) : NEW_LINE INDENT ix , iy = nowin NEW_LINE Wh [ iy ] [ ix ] = ' . ' NEW_LINE nowin = nextin ( nowin ) NEW_LINE DEDENT Bl = [ [ ' . ' for _ in range ( 100 ) ] for _ in range ( 50 ) ] NEW_LINE nowin = [ 0 , 1 ] NEW_LINE for _ in range ( B - 1 ) : NEW_LINE INDENT ix , iy = nowin NEW_LINE Bl [ iy ] [ ix ] = ' # ' NEW_LINE nowin = nextin ( nowin ) NEW_LINE DEDENT print ( '100' , '100' ) NEW_LINE for i in range ( 50 ) : NEW_LINE INDENT print ( ' ' . join ( Wh [ i ] ) ) NEW_LINE DEDENT for j in range ( 50 ) : NEW_LINE INDENT print ( ' ' . join ( Bl [ j ] ) ) NEW_LINE DEDENT

A , B = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE print ( 100 , 100 ) NEW_LINE x1 = ' ' . join ( [ ' . ' ] * 100 ) NEW_LINE y1 = ' ' . join ( [ ' # ' ] * 100 ) NEW_LINE for i in range ( 25 ) : NEW_LINE INDENT x = [ ' . ' ] * 100 NEW_LINE for j in range ( 50 ) : NEW_LINE INDENT if B > 1 : NEW_LINE INDENT x [ 2 * j ] = ' # ' NEW_LINE B -= 1 NEW_LINE DEDENT DEDENT print ( ' ' . join ( x ) ) NEW_LINE print ( x1 ) NEW_LINE DEDENT for i in range ( 25 ) : NEW_LINE INDENT print ( y1 ) NEW_LINE y = [ ' # ' ] * 100 NEW_LINE for j in range ( 50 ) : NEW_LINE INDENT if A > 1 : NEW_LINE INDENT y [ 2 * j ] = ' . ' NEW_LINE A -= 1 NEW_LINE DEDENT DEDENT print ( ' ' . join ( y ) ) NEW_LINE DEDENT

import string NEW_LINE import re NEW_LINE import datetime NEW_LINE import calendar NEW_LINE import collections NEW_LINE import heapq NEW_LINE import bisect NEW_LINE import array NEW_LINE import numpy as np NEW_LINE a , b = map ( int , input ( ) . split ( ) ) NEW_LINE ans = np . empty ( ( 100 , 100 ) , dtype = int ) NEW_LINE x , y = ans . shape NEW_LINE for i in range ( x ) : NEW_LINE INDENT for j in range ( y ) : NEW_LINE INDENT if j == 0 : NEW_LINE INDENT ans [ i , j ] = 1 NEW_LINE DEDENT elif j == y - 1 : NEW_LINE INDENT ans [ i , j ] = 0 NEW_LINE DEDENT elif ( i % 4 ) == 0 or ( i % 4 ) == 1 : NEW_LINE INDENT ans [ i , j ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT ans [ i , j ] = 0 NEW_LINE DEDENT DEDENT DEDENT def cut_b ( ) : NEW_LINE INDENT itr = 1 NEW_LINE for i in range ( 2 , x , 4 ) : NEW_LINE INDENT for j in range ( 2 , y // 2 , 2 ) : NEW_LINE INDENT yield itr NEW_LINE ans [ i , j ] = ans [ i + 1 , j ] = 1 NEW_LINE itr += 1 NEW_LINE DEDENT DEDENT DEDENT def cut_w ( ) : NEW_LINE INDENT itr = 1 NEW_LINE for i in range ( 0 , x , 4 ) : NEW_LINE INDENT for j in range ( - 3 , - y // 2 , - 2 ) : NEW_LINE INDENT yield itr NEW_LINE ans [ i , j ] = ans [ i + 1 , j ] = 0 NEW_LINE itr += 1 NEW_LINE DEDENT DEDENT DEDENT for i in cut_b ( ) : NEW_LINE INDENT if i == a : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT for i in cut_w ( ) : NEW_LINE INDENT if i == b : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT print ( 100 , 100 ) NEW_LINE for i in range ( x ) : NEW_LINE INDENT for j in range ( y ) : NEW_LINE INDENT if ans [ i , j ] == 0 : NEW_LINE INDENT print ( ' . ' , end = " " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' # ' , end = " " ) NEW_LINE DEDENT DEDENT print ( ) NEW_LINE DEDENT

a , b = map ( int , input ( ) . split ( ) ) NEW_LINE grid = [ ] NEW_LINE for i in range ( 50 ) : NEW_LINE INDENT whiteline = [ " . " for k in range ( 100 ) ] NEW_LINE grid . append ( whiteline ) NEW_LINE DEDENT for i in range ( 50 ) : NEW_LINE INDENT blackline = [ " # " for k in range ( 100 ) ] NEW_LINE grid . append ( blackline ) NEW_LINE DEDENT b += - 1 NEW_LINE check = 1 NEW_LINE x = 1 NEW_LINE y = 1 NEW_LINE while b > 0 : NEW_LINE INDENT grid [ y ] [ x ] = " # " NEW_LINE b += - 1 NEW_LINE if x + 2 < 50 : NEW_LINE INDENT x += 2 NEW_LINE DEDENT else : NEW_LINE INDENT check = check * ( - 1 ) NEW_LINE if check == 1 : NEW_LINE INDENT x = 2 NEW_LINE DEDENT else : NEW_LINE INDENT x = 1 NEW_LINE DEDENT y += 2 NEW_LINE DEDENT DEDENT a += - 1 NEW_LINE check = 1 NEW_LINE x = 1 NEW_LINE y = 55 NEW_LINE while a > 0 : NEW_LINE INDENT grid [ y ] [ x ] = " . " NEW_LINE a += - 1 NEW_LINE if x + 2 < 50 : NEW_LINE INDENT x += 2 NEW_LINE DEDENT else : NEW_LINE INDENT check = check * ( - 1 ) NEW_LINE if check == 1 : NEW_LINE INDENT x = 2 NEW_LINE DEDENT else : NEW_LINE INDENT x = 1 NEW_LINE DEDENT y += 2 NEW_LINE DEDENT DEDENT print ( 100 , 100 ) NEW_LINE for i in range ( 100 ) : NEW_LINE INDENT for k in range ( 100 ) : NEW_LINE INDENT if k != 99 : NEW_LINE INDENT print ( grid [ i ] [ k ] , end = " " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( grid [ i ] [ k ] ) NEW_LINE DEDENT DEDENT DEDENT


import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long [ ] t = new long [ n ] ; long r = 0 ; long p1 = 0 ; long p2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { long v = sc . nextLong ( ) ; t [ i ] = v ; } Arrays . sort ( t ) ; double ans1 = 0 ; long ans2 = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( i <= a - 1 ) { ans1 += t [ n - 1 - i ] ; } if ( r == t [ n - 1 - i ] ) { p1 ++ ; } else { if ( i <= a - 1 ) { r = t [ n - 1 - i ] ; p1 = 1 ; } else { break ; } } if ( i == a - 1 ) { p2 = p1 ; } } if ( p2 != a ) { if ( ( ( ans1 - r * p2 ) / ( a - p2 ) ) == r ) { for ( long i = p2 ; i <= Math . min ( b - a + p2 , p1 ) ; i ++ ) { ans2 += c ( p1 , i ) ; } } else { ans2 += c ( p1 , p2 ) ; } } else { for ( long i = p2 ; i <= Math . min ( b - a + p2 , p1 ) ; i ++ ) { ans2 += c ( p1 , i ) ; } } System . out . println ( ans1 / a ) ; System . out . println ( ans2 ) ; } public static long c ( long o , long l ) { long ans = 1 ; for ( long i = 1 ; i <= l ; i ++ ) { ans *= o - i + 1 ; ans /= i ; } return ans ; } }

import java . util . * ; import java . util . Map . * ; public class Main { static int MAX = 50 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long [ ] [ ] c = comb ( n ) ; List < Long > v = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) { v . add ( sc . nextLong ( ) ) ; } Collections . sort ( v , Comparator . reverseOrder ( ) ) ; long sum = 0 ; for ( int i = 0 ; i < a ; i ++ ) { sum += v . get ( i ) ; } double ave = ( double ) sum / a ; int aInCnt = 0 ; int aCnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( v . get ( i ) . equals ( v . get ( a - 1 ) ) ) { aCnt ++ ; if ( i < a ) { aInCnt ++ ; } } } long ans = 0 ; if ( v . get ( 0 ) . equals ( v . get ( a - 1 ) ) ) { for ( int i = a ; i <= b ; i ++ ) { ans += c [ aCnt ] [ i ] ; } } else { ans += c [ aCnt ] [ aInCnt ] ; } System . out . println ( String . format ( " % .6f " , ave ) ) ; System . out . println ( ans ) ; } public static long [ ] [ ] comb ( long n ) { long [ ] [ ] c = new long [ MAX + 1 ] [ MAX + 1 ] ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( j == 0 || i == j ) { c [ i ] [ j ] = 1L ; continue ; } c [ i ] [ j ] = c [ i - 1 ] [ j - 1 ] + c [ i - 1 ] [ j ] ; } } return c ; } }

import java . io . * ; import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; long [ ] nums = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { nums [ i ] = sc . nextLong ( ) ; } Arrays . sort ( nums ) ; double sum = 0 ; int [ ] occurs = new int [ a ] ; long count = 0 ; for ( int i = n - 1 ; i >= n - a ; i -- ) { sum += nums [ i ] ; } sum /= a ; boolean flag = true ; int index = - 1 ; if ( nums [ n - 1 ] != nums [ n - a ] ) { int counts = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( nums [ i ] == nums [ n - a ] ) { if ( flag ) { index = i + 1 ; flag = false ; } counts ++ ; } } count = combinations ( counts , a - ( n - index ) ) ; } else { int l = 0 ; for ( int i = n - 1 ; i >= 0 ; i -- ) { if ( nums [ i ] == nums [ n - 1 ] ) { l ++ ; } } for ( int i = a ; i <= b ; i ++ ) { if ( nums [ n - 1 ] == nums [ n - i ] ) { count += combinations ( l , i ) ; } } } System . out . println ( sum ) ; System . out . println ( count ) ; } private static long combinations ( int n , int k ) { long ans = 1 ; for ( int i = 1 ; i <= k ; i ++ ) { ans *= n - k + i ; ans /= i ; } return ans ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int N = sc . nextInt ( ) ; int A = sc . nextInt ( ) ; int B = sc . nextInt ( ) ; long [ ] [ ] nCr = new long [ N + 1 ] [ N + 1 ] ; nCr [ 0 ] [ 0 ] = 0 ; for ( int row = 1 ; row <= N ; row ++ ) { nCr [ row ] [ 0 ] = 1 ; for ( int col = 1 ; col <= row - 1 ; col ++ ) { nCr [ row ] [ col ] = nCr [ row - 1 ] [ col - 1 ] + nCr [ row - 1 ] [ col ] ; } nCr [ row ] [ row ] = 1 ; } long [ ] v = new long [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { v [ i ] = sc . nextLong ( ) ; } Arrays . sort ( v ) ; long sum1 = 0 ; for ( int i = N - 1 ; i >= N - A ; i -- ) { sum1 += v [ i ] ; } double ans1 = sum1 / ( ( double ) A ) ; int cnt1 = 0 ; int cnt2 = 0 ; for ( int i = N - 1 ; i >= 0 ; i -- ) { if ( v [ i ] > v [ N - A ] ) cnt1 ++ ; if ( v [ i ] == v [ N - A ] ) cnt2 ++ ; } long ans2 = 0 ; if ( v [ N - A ] < v [ N - 1 ] ) { ans2 = nCr [ cnt2 ] [ A - cnt1 ] ; } else { for ( int i = A ; i <= Math . min ( B , cnt2 ) ; i ++ ) { ans2 += nCr [ cnt2 ] [ i ] ; } } System . out . println ( ans1 ) ; System . out . println ( ans2 ) ; } }

import java . math . * ; import java . util . * ; class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { int n = s . nextInt ( ) , a = s . nextInt ( ) , b = s . nextInt ( ) ; long [ ] v = new long [ n ] ; Arrays . setAll ( v , i -> s . nextLong ( ) ) ; Arrays . sort ( v ) ; long sum = 0 ; int use = 0 , count = 0 ; for ( int i = n - a ; i < n ; ++ i ) { if ( v [ n - a ] == v [ i ] ) { ++ use ; ++ count ; } sum += v [ i ] ; } System . out . println ( BigDecimal . valueOf ( sum * 1.0 / a ) . toPlainString ( ) ) ; for ( int i = 0 ; i < n - a ; ++ i ) if ( v [ n - a ] == v [ i ] ) ++ count ; System . err . println ( count + " ▁ " + use ) ; if ( v [ n - a ] == v [ n - 1 ] ) { long r = 0 ; for ( int i = 0 , e = Math . min ( b - a , count - use ) ; i <= e ; ++ i ) r += comb ( count , use + i ) ; System . out . println ( r ) ; } else { System . out . println ( comb ( count , use ) ) ; } } static long comb ( int count , int use ) { long r = 1 ; for ( int i = use + 1 ; i <= count ; ++ i ) { r *= i ; r /= i - use ; } return r ; } }

d = { } NEW_LINE def nCr ( n , r ) : NEW_LINE INDENT if n < r : NEW_LINE INDENT return 0 NEW_LINE DEDENT if n == r or r == 0 : NEW_LINE INDENT return 1 NEW_LINE DEDENT if ( n , r ) in d : NEW_LINE INDENT return d [ ( n , r ) ] NEW_LINE DEDENT d [ ( n , r ) ] = nCr ( n - 1 , r ) + nCr ( n - 1 , r - 1 ) NEW_LINE return d [ ( n , r ) ] NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE v = sorted ( ( int ( s ) for s in input ( ) . split ( ) ) , reverse = True ) NEW_LINE print ( sum ( v [ : a ] ) / a ) NEW_LINE x = v . count ( v [ a - 1 ] ) NEW_LINE print ( nCr ( x , v [ : a ] . count ( v [ a - 1 ] ) ) if v [ 0 ] > v [ a - 1 ] else sum ( nCr ( x , i ) for i in range ( a , b + 1 ) ) ) NEW_LINE DEDENT

def comb ( n , r ) : NEW_LINE INDENT r = min ( r , n - r ) NEW_LINE result = 1 NEW_LINE for i in range ( n - r + 1 , n + 1 ) : NEW_LINE INDENT result *= i NEW_LINE DEDENT for i in range ( 1 , r + 1 ) : NEW_LINE INDENT result //= i NEW_LINE DEDENT return result NEW_LINE DEDENT N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE V = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE V . sort ( reverse = True ) NEW_LINE ave = sum ( V [ : A ] ) / A NEW_LINE pat = 0 NEW_LINE note = 0 NEW_LINE cnt = 0 NEW_LINE for v in V : NEW_LINE INDENT if v > V [ A - 1 ] : NEW_LINE INDENT note += 1 NEW_LINE DEDENT elif v == V [ A - 1 ] : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT elif v < V [ A - 1 ] : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if V [ 0 ] == V [ A - 1 ] : NEW_LINE INDENT for i in range ( A - note , B + 1 - note ) : NEW_LINE INDENT if i > cnt : NEW_LINE INDENT break NEW_LINE DEDENT pat += comb ( cnt , i ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT pat = comb ( cnt , A - note ) NEW_LINE DEDENT print ( ave ) NEW_LINE print ( pat ) NEW_LINE

import sys NEW_LINE from collections import Counter NEW_LINE try : NEW_LINE INDENT from scipy . special import comb NEW_LINE DEDENT except ImportError : NEW_LINE INDENT from scipy . misc import comb NEW_LINE DEDENT def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE V = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE V = sorted ( V , key = lambda x : - x ) NEW_LINE m_ave = sum ( V [ : A ] ) / A NEW_LINE b = A NEW_LINE while b < B : NEW_LINE INDENT if V [ 0 ] == V [ b ] : NEW_LINE INDENT b += 1 NEW_LINE DEDENT else : NEW_LINE INDENT break NEW_LINE DEDENT DEDENT if A == b : NEW_LINE INDENT ans = 1 NEW_LINE c = Counter ( V [ : A ] ) NEW_LINE d = Counter ( V ) NEW_LINE for key in c . keys ( ) : NEW_LINE INDENT n = d [ key ] NEW_LINE r = c [ key ] NEW_LINE ans *= comb ( n , r , exact = True ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT d = Counter ( V ) NEW_LINE key = V [ 0 ] NEW_LINE n = d [ key ] NEW_LINE ans = 0 NEW_LINE for r in range ( A , b + 1 ) : NEW_LINE INDENT ans += comb ( n , r , exact = True ) NEW_LINE DEDENT DEDENT print ( m_ave ) NEW_LINE print ( ans ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

import math NEW_LINE N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE V = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE V . sort ( ) NEW_LINE V . reverse ( ) NEW_LINE cur = 0 NEW_LINE selectlist = [ ] NEW_LINE for i in range ( A , B + 1 ) : NEW_LINE INDENT S = 0 NEW_LINE for j in range ( i ) : NEW_LINE INDENT S += V [ j ] NEW_LINE DEDENT S = S / i NEW_LINE if cur < S : NEW_LINE INDENT cur = S NEW_LINE selectlist = [ i ] NEW_LINE DEDENT elif cur == S : NEW_LINE INDENT selectlist . append ( i ) NEW_LINE DEDENT DEDENT ans = 0 NEW_LINE for p in range ( len ( selectlist ) ) : NEW_LINE INDENT nowselect = 1 NEW_LINE s = 0 NEW_LINE K = [ ] NEW_LINE for i in range ( selectlist [ p ] ) : NEW_LINE INDENT K . append ( V [ i ] ) NEW_LINE DEDENT P = list ( set ( K ) ) NEW_LINE P . sort ( ) NEW_LINE P . reverse ( ) NEW_LINE for j in range ( len ( P ) ) : NEW_LINE INDENT cnt = V . count ( P [ j ] ) NEW_LINE s += cnt NEW_LINE if s >= selectlist [ p ] : NEW_LINE INDENT res = K . count ( P [ j ] ) NEW_LINE nowselect *= math . factorial ( cnt ) // ( math . factorial ( res ) * math . factorial ( cnt - res ) ) NEW_LINE ans += nowselect NEW_LINE DEDENT else : NEW_LINE INDENT nowselect *= cnt NEW_LINE DEDENT DEDENT DEDENT print ( cur ) NEW_LINE print ( ans ) NEW_LINE

import itertools NEW_LINE import sys NEW_LINE import math NEW_LINE from functools import lru_cache NEW_LINE from queue import Queue NEW_LINE from operator import mul NEW_LINE from functools import reduce NEW_LINE nCr = { } NEW_LINE def cmb ( n , r ) : NEW_LINE INDENT if r == 0 or r == n : return 1 NEW_LINE if r == 1 : return n NEW_LINE if ( n , r ) in nCr : return nCr [ ( n , r ) ] NEW_LINE nCr [ ( n , r ) ] = cmb ( n - 1 , r ) + cmb ( n - 1 , r - 1 ) NEW_LINE return nCr [ ( n , r ) ] NEW_LINE DEDENT n , a , b = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE value = list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE value = list ( reversed ( sorted ( value ) ) ) NEW_LINE takai = 0 NEW_LINE avg = 0 NEW_LINE for i in range ( a ) : NEW_LINE INDENT if value [ i ] > value [ a ] : NEW_LINE INDENT takai += 1 NEW_LINE DEDENT avg += value [ i ] NEW_LINE DEDENT avg /= a NEW_LINE print ( avg ) NEW_LINE cc = value . count ( value [ a ] ) NEW_LINE if value [ 0 ] == value [ a ] : NEW_LINE INDENT sum = 0 NEW_LINE for i in range ( a , min ( cc , b ) + 1 ) : NEW_LINE INDENT sum += cmb ( cc , i ) NEW_LINE DEDENT print ( sum ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( cmb ( cc , a - takai ) ) NEW_LINE NEW_LINE DEDENT


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; String a [ ] = new String [ h ] ; for ( int i = 0 ; i < h ; i ++ ) { a [ i ] = sc . next ( ) ; } for ( int i = 0 ; i < w + 2 ; i ++ ) { System . out . print ( " # " ) ; } System . out . println ( " " ) ; for ( int i = 0 ; i < h ; i ++ ) { System . out . println ( " # " + a [ i ] + " # " ) ; } for ( int i = 0 ; i < w + 2 ; i ++ ) { System . out . print ( " # " ) ; } System . out . println ( " " ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStream ; import java . io . InputStreamReader ; import java . io . OutputStream ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; InputReader in = new InputReader ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; Task solver = new Task ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class Task { public void solve ( int testNumber , InputReader in , PrintWriter out ) { int H = in . nextInt ( ) ; int W = in . nextInt ( ) ; String [ ] array = new String [ H ] ; for ( int i = 0 ; i < array . length ; i ++ ) { array [ i ] = " # " + in . next ( ) + " # " ; } String repeated = new String ( new char [ W + 2 ] ) . replace ( " \0" , " # " ) ; out . println ( repeated ) ; for ( int i = 0 ; i < array . length ; i ++ ) { out . println ( array [ i ] ) ; } out . println ( repeated ) ; } } static class InputReader { public BufferedReader reader ; public StringTokenizer tokenizer ; public InputReader ( InputStream stream ) { reader = new BufferedReader ( new InputStreamReader ( stream ) , 32768 ) ; tokenizer = null ; } public String next ( ) { while ( tokenizer == null || ! tokenizer . hasMoreTokens ( ) ) { try { tokenizer = new StringTokenizer ( reader . readLine ( ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } } return tokenizer . nextToken ( ) ; } public char nextChar ( ) { return next ( ) . charAt ( 0 ) ; } public int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } public double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } } }

import java . io . IOException ; import java . util . ArrayList ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws IOException { Scanner sc = new Scanner ( System . in ) ; int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; char a [ ] [ ] = new char [ 102 ] [ 102 ] ; String str = " " ; for ( int i = 0 ; i < h + 2 ; i ++ ) { if ( i != 0 && i != h + 1 ) { str = sc . next ( ) ; } for ( int j = 0 ; j < w + 2 ; j ++ ) { if ( i == 0 || i == h + 1 || j == 0 || j == w + 1 ) a [ i ] [ j ] = ' # ' ; else a [ i ] [ j ] = str . charAt ( j - 1 ) ; } } for ( int i = 0 ; i < h + 2 ; i ++ ) { for ( int j = 0 ; j < w + 2 ; j ++ ) { System . out . print ( a [ i ] [ j ] ) ; if ( j == w + 1 ) System . out . println ( ) ; } } } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; StringTokenizer tokenizer = new StringTokenizer ( input . readLine ( ) ) ; int x = Integer . parseInt ( tokenizer . nextToken ( ) ) ; int y = Integer . parseInt ( tokenizer . nextToken ( ) ) ; StringBuilder firstAndLast = new StringBuilder ( ) ; for ( int i = 0 ; i < y + 2 ; i ++ ) { firstAndLast . append ( ' # ' ) ; } StringBuilder out = new StringBuilder ( ) ; out . append ( firstAndLast ) . append ( ' \n ' ) ; for ( int i = 0 ; i < x ; i ++ ) { out . append ( ' # ' ) . append ( input . readLine ( ) ) . append ( ' # ' ) . append ( ' \n ' ) ; } out . append ( firstAndLast ) . append ( ' \n ' ) ; System . out . print ( out ) ; } }

import java . util . * ; class Main { static Scanner sc = new Scanner ( System . in ) ; static int mod = 1000000007 ; public static void main ( String [ ] args ) { int h = sc . nextInt ( ) ; int w = sc . nextInt ( ) ; String [ ] ar = new String [ h ] ; for ( int i = 0 ; i < h ; i ++ ) { ar [ i ] = " # " + sc . next ( ) + " # " ; } for ( int i = 0 ; i < w + 2 ; i ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; for ( int i = 0 ; i < h ; i ++ ) { System . out . println ( ar [ i ] ) ; } for ( int i = 0 ; i < w + 2 ; i ++ ) { System . out . print ( " # " ) ; } System . out . println ( ) ; } }

H , W = map ( int , input ( ) . split ( ) ) NEW_LINE print ( " # " * ( W + 2 ) ) NEW_LINE for i in range ( 0 , H ) : NEW_LINE INDENT print ( " # " + input ( ) + " # " ) NEW_LINE DEDENT print ( " # " * ( W + 2 ) ) NEW_LINE

import sys NEW_LINE ns = lambda : sys . stdin . readline ( ) . rstrip ( ) NEW_LINE ni = lambda : int ( ns ( ) ) NEW_LINE nm = lambda : map ( int , sys . stdin . readline ( ) . split ( ) ) NEW_LINE nl = lambda : list ( nm ( ) ) NEW_LINE h , w = nm ( ) NEW_LINE a = [ [ ' # ' ] + list ( map ( str , sys . stdin . readline ( ) . split ( ) ) ) + [ ' # ' ] for _ in range ( h ) ] NEW_LINE a . insert ( 0 , [ ' # ' for _ in range ( w + 2 ) ] ) NEW_LINE a . append ( [ ' # ' for _ in range ( w + 2 ) ] ) NEW_LINE for i in range ( h + 2 ) : NEW_LINE INDENT print ( ' ' . join ( a [ i ] ) ) NEW_LINE DEDENT

H , W = map ( int , input ( ) . split ( ) ) NEW_LINE joubu = [ " # " for i in range ( W + 2 ) ] NEW_LINE print ( " " . join ( joubu ) ) NEW_LINE for i in range ( H ) : NEW_LINE INDENT S = input ( ) NEW_LINE print ( " # " + S + " # " ) NEW_LINE DEDENT print ( " " . join ( joubu ) ) NEW_LINE

h , w = map ( int , input ( ) . split ( ) ) NEW_LINE ans = [ [ " # " for i in range ( w + 2 ) ] for i in range ( h + 2 ) ] NEW_LINE a = [ input ( ) for i in range ( h ) ] NEW_LINE for i in range ( h ) : NEW_LINE INDENT for j in range ( w ) : NEW_LINE INDENT ans [ i + 1 ] [ j + 1 ] = a [ i ] [ j ] NEW_LINE DEDENT DEDENT for i in range ( h + 2 ) : NEW_LINE INDENT for j in range ( w + 2 ) : NEW_LINE INDENT print ( ans [ i ] [ j ] , end = " " ) NEW_LINE DEDENT print ( ) NEW_LINE DEDENT

import sys NEW_LINE def main ( ) : NEW_LINE INDENT input = sys . stdin . readline NEW_LINE H , W = map ( int , input ( ) . split ( ) ) NEW_LINE ud = ' # ' * ( W + 2 ) NEW_LINE print ( ud ) NEW_LINE for _ in range ( H ) : NEW_LINE INDENT a = input ( ) . strip ( ) NEW_LINE print ( ' # ' + a + ' # ' ) NEW_LINE DEDENT print ( ud ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT


import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { final Scanner sc = new Scanner ( System . in ) ; char [ ] s = sc . next ( ) . toCharArray ( ) ; int count = 1 ; char now = s [ 0 ] ; String ans = " " ; for ( int i = 1 ; i < s . length ; i ++ ) { if ( now == s [ i ] ) { count ++ ; } else { ans += now + " " + count ; now = s [ i ] ; count = 1 ; } } ans += now + " " + count ; System . out . println ( 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 ( ) ; int count = 1 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i - 1 ) ) { count ++ ; } else { out . print ( ( char ) ( s . charAt ( i - 1 ) ) ) ; out . print ( count ) ; count = 1 ; } } out . print ( s . charAt ( s . length ( ) - 1 ) ) ; out . println ( count ) ; } } 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 . * ; import java . util . regex . Matcher ; import java . util . regex . Pattern ; class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; String s = sc . next ( ) ; Pattern p = Pattern . compile ( " ( . ) \\ 1 { 0 , } " ) ; Matcher m = p . matcher ( s ) ; while ( m . find ( ) ) { System . out . print ( m . group ( 0 ) . charAt ( 0 ) ) ; System . out . print ( m . group ( 0 ) . length ( ) ) ; } System . out . println ( ) ; } }

import java . util . Scanner ; import java . util . Arrays ; public class Main { public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . next ( ) + " ▁ " ; String t = " " ; int count = 0 ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { count ++ ; if ( s . charAt ( i ) != s . charAt ( i - 1 ) ) { t += String . valueOf ( s . charAt ( i - 1 ) ) ; t += String . valueOf ( count ) ; count = 0 ; } } System . out . println ( t ) ; } }

import java . util . * ; class Main { public static void main ( String [ ] args ) { new Main ( ) . main ( ) ; } public void main ( ) { Scanner scanner = new Scanner ( System . in ) ; String s = scanner . nextLine ( ) ; int i = 0 ; StringBuilder builder = new StringBuilder ( ) ; while ( i < s . length ( ) ) { char ch = s . charAt ( i ) ; int count = this . countChar ( s . substring ( i , s . length ( ) ) , ch ) ; builder . append ( String . format ( " % c % d " , ch , count ) ) ; i += count ; } System . out . println ( builder . toString ( ) ) ; } private int countChar ( String s , char ch ) { int count = 0 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == ch ) { count ++ ; } else { break ; } } return count ; } }

s = list ( input ( ) ) NEW_LINE s . append ( " ▁ " ) NEW_LINE i = 0 NEW_LINE am = 1 NEW_LINE while i < len ( s ) - 1 : NEW_LINE INDENT if s [ i ] == s [ i + 1 ] : NEW_LINE INDENT am += 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( s [ i ] + str ( am ) , end = " " ) NEW_LINE am = 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT print ( ) NEW_LINE

hoge = input ( ) NEW_LINE mae = " ▁ " NEW_LINE kazu = 0 NEW_LINE flag = 0 NEW_LINE for i in range ( len ( hoge ) ) : NEW_LINE INDENT moji = hoge [ i ] NEW_LINE if ( moji == mae ) : NEW_LINE INDENT kazu += 1 NEW_LINE DEDENT else : NEW_LINE INDENT if ( flag == 0 ) : NEW_LINE INDENT flag = 1 NEW_LINE DEDENT else : NEW_LINE INDENT print ( kazu , end = " " ) NEW_LINE DEDENT print ( moji , end = " " ) NEW_LINE kazu = 1 NEW_LINE DEDENT mae = hoge [ i ] NEW_LINE DEDENT print ( kazu , end = " " ) NEW_LINE print ( " " ) NEW_LINE

s = input ( ) NEW_LINE pre = " " NEW_LINE cnt = 0 NEW_LINE res = " " NEW_LINE for x in s : NEW_LINE INDENT if x != pre : NEW_LINE INDENT if pre != " " : NEW_LINE INDENT res += pre + str ( cnt ) NEW_LINE DEDENT pre = x NEW_LINE cnt = 1 NEW_LINE DEDENT else : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT res += pre + str ( cnt ) NEW_LINE print ( res ) NEW_LINE

Ss = [ i for i in input ( ) ] NEW_LINE chars = [ ] NEW_LINE char = [ Ss [ 0 ] ] NEW_LINE for s in range ( 1 , len ( Ss ) ) : NEW_LINE INDENT if Ss [ s ] in char : NEW_LINE INDENT char . append ( Ss [ s ] ) NEW_LINE DEDENT else : NEW_LINE INDENT chars . append ( char ) NEW_LINE char = [ Ss [ s ] ] NEW_LINE DEDENT DEDENT chars . append ( char ) NEW_LINE ans = [ char [ 0 ] + str ( len ( char ) ) for char in chars ] NEW_LINE print ( " " . join ( ans ) ) NEW_LINE

def solve ( ) : NEW_LINE INDENT s = input ( ) NEW_LINE n = len ( s ) NEW_LINE ans = " " NEW_LINE ct = 1 NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT if ans == " " : NEW_LINE INDENT ans += s [ i ] NEW_LINE ct = 1 NEW_LINE DEDENT elif ans [ - 1 ] == s [ i ] : NEW_LINE INDENT ct += 1 NEW_LINE DEDENT elif ans [ - 1 ] != s [ i ] : NEW_LINE INDENT ans += str ( ct ) NEW_LINE ans += s [ i ] NEW_LINE ct = 1 NEW_LINE DEDENT DEDENT ans += str ( ct ) NEW_LINE print ( ans ) NEW_LINE DEDENT solve ( ) NEW_LINE


import java . math . BigInteger ; import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; final int N = sc . nextInt ( ) ; int a = sc . nextInt ( ) - 1 ; BigInteger k = new BigInteger ( sc . next ( ) ) ; int [ ] b = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) b [ i ] = sc . nextInt ( ) - 1 ; sc . close ( ) ; int count = 1 ; int current = b [ a ] ; int [ ] dpCount = new int [ N ] ; int [ ] dpPos = new int [ N + 1 ] ; while ( dpCount [ current ] == 0 ) { dpCount [ current ] = count ; dpPos [ count ] = current ; current = b [ current ] ; count ++ ; } int startRoop = dpCount [ current ] ; BigInteger rk = k . subtract ( BigInteger . valueOf ( startRoop ) ) ; int ans = 0 ; if ( rk . max ( BigInteger . ZERO ) . equals ( BigInteger . ZERO ) ) { ans = dpPos [ k . intValue ( ) ] ; } else { ans = dpPos [ startRoop + rk . mod ( BigInteger . valueOf ( count - startRoop ) ) . intValue ( ) ] ; } System . out . println ( ans + 1 ) ; } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long N = sc . nextLong ( ) ; long a = sc . nextLong ( ) ; String k = sc . next ( ) ; long [ ] b = new long [ ( int ) N ] ; for ( int i = 0 ; i < N ; i ++ ) { b [ i ] = sc . nextLong ( ) ; } ArrayList < Long > f = new ArrayList < Long > ( ) ; f . add ( a ) ; long presence = a ; long s = 0 ; long g = 1 ; for ( int i = 0 ; i < N ; i ++ ) { presence = b [ ( int ) presence - 1 ] ; if ( f . contains ( presence ) ) { for ( int j = 0 ; j < N ; j ++ ) { if ( f . get ( j ) == presence ) { s = ( long ) j ; g = ( long ) ( i + 1 ) - s ; break ; } } break ; } else { f . add ( presence ) ; } } long ans = 0 ; if ( k . length ( ) <= 6 ) { int step = Integer . parseInt ( k ) ; int p = ( int ) a ; for ( int i = 0 ; i < step ; i ++ ) { p = ( int ) b [ p - 1 ] ; } ans = p ; } else { long r = 0 ; if ( k . length ( ) <= 18 ) { r = ( Long . parseLong ( k ) ) % g ; } else { for ( int i = 0 ; i < k . length ( ) ; i ++ ) { long d = Long . parseLong ( String . valueOf ( k . charAt ( i ) ) ) ; r = ( 10 * r + d ) % g ; } } while ( r < s ) { r += g ; } ans = f . get ( ( int ) r ) ; } System . out . println ( ans ) ; } }

import java . math . BigInteger ; import java . util . Scanner ; public class Main { private static final BigInteger TWO = BigInteger . valueOf ( 2 ) ; public static void main ( String [ ] args ) { Scanner scanner = new Scanner ( System . in ) ; int N = scanner . nextInt ( ) ; int a = scanner . nextInt ( ) - 1 ; BigInteger k = scanner . nextBigInteger ( ) ; int [ ] b = new int [ N ] ; for ( int i = 0 ; i < N ; i ++ ) b [ i ] = scanner . nextInt ( ) - 1 ; int n = 0 ; int i1 = a ; int i2 = a ; do { i1 = b [ i1 ] ; i2 = b [ b [ i2 ] ] ; n ++ ; } while ( i1 != i2 ) ; int m = 0 ; int i3 = a ; while ( i1 != i3 ) { i1 = b [ i1 ] ; i3 = b [ i3 ] ; m ++ ; } int l ; if ( k . compareTo ( BigInteger . valueOf ( m ) ) < 0 ) { l = k . intValue ( ) ; } else { l = m + k . subtract ( BigInteger . valueOf ( m ) ) . mod ( BigInteger . valueOf ( n ) ) . intValue ( ) ; } while ( l > 0 ) { a = b [ a ] ; l -- ; } System . out . println ( a + 1 ) ; } }

n , a = ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE b = list ( int ( i ) for i in input ( ) . split ( ) ) NEW_LINE hist = [ ] NEW_LINE while a not in hist : NEW_LINE INDENT hist . append ( a ) NEW_LINE a = b [ a - 1 ] NEW_LINE DEDENT init = hist [ 0 : hist . index ( a ) ] NEW_LINE loop = hist [ hist . index ( a ) : ] NEW_LINE if k < len ( init ) : NEW_LINE INDENT print ( init [ k ] ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( loop [ ( k - len ( init ) ) % len ( loop ) ] ) NEW_LINE DEDENT

def mod ( k : int , c : int ) -> int : NEW_LINE INDENT ret = 0 NEW_LINE for n in str ( k ) : NEW_LINE INDENT ret = ( ret * 10 + int ( n ) ) % c NEW_LINE DEDENT return ret NEW_LINE DEDENT def strange_dict ( N : int , a : int , k : int , B : list ) -> int : NEW_LINE INDENT route = [ ] NEW_LINE idx = a - 1 NEW_LINE while idx not in route : NEW_LINE INDENT route . append ( idx ) NEW_LINE idx = B [ idx ] - 1 NEW_LINE DEDENT cycle_start = idx NEW_LINE if k < len ( route ) : NEW_LINE INDENT return route [ k ] + 1 NEW_LINE DEDENT T = route . index ( cycle_start ) NEW_LINE C = len ( route ) - T NEW_LINE return route [ ( k - T ) % C + T ] + 1 NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N , a = map ( int , input ( ) . split ( ) ) NEW_LINE k = int ( input ( ) ) NEW_LINE B = [ int ( s ) for s in input ( ) . split ( ) ] NEW_LINE ans = strange_dict ( N , a , k , B ) NEW_LINE print ( ans ) NEW_LINE DEDENT

import sys NEW_LINE stdin = sys . stdin NEW_LINE sys . setrecursionlimit ( 10 ** 5 ) NEW_LINE def li ( ) : return map ( int , stdin . readline ( ) . split ( ) ) NEW_LINE def li_ ( ) : return map ( lambda x : int ( x ) - 1 , stdin . readline ( ) . split ( ) ) NEW_LINE def lf ( ) : return map ( float , stdin . readline ( ) . split ( ) ) NEW_LINE def ls ( ) : return stdin . readline ( ) . split ( ) NEW_LINE def ns ( ) : return stdin . readline ( ) . rstrip ( ) NEW_LINE def lc ( ) : return list ( ns ( ) ) NEW_LINE def ni ( ) : return int ( stdin . readline ( ) ) NEW_LINE def nf ( ) : return float ( stdin . readline ( ) ) NEW_LINE n , a = li ( ) NEW_LINE k = ni ( ) NEW_LINE b = [ 0 ] + list ( li ( ) ) NEW_LINE searched = [ 0 ] * ( n + 1 ) NEW_LINE cur = a NEW_LINE order = [ ] NEW_LINE for _ in range ( 10 ** 5 + 1 ) : NEW_LINE INDENT cur = b [ cur ] NEW_LINE if searched [ cur ] : NEW_LINE INDENT lpst = order . index ( cur ) NEW_LINE header = order [ : lpst ] NEW_LINE loop = order [ lpst : ] NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT searched [ cur ] = 1 NEW_LINE order . append ( cur ) NEW_LINE DEDENT DEDENT if header : NEW_LINE INDENT if k <= len ( header ) : NEW_LINE INDENT print ( order [ k - 1 ] ) NEW_LINE DEDENT else : NEW_LINE INDENT k -= len ( header ) NEW_LINE print ( loop [ ( k - 1 ) % len ( loop ) ] ) NEW_LINE DEDENT DEDENT else : NEW_LINE INDENT print ( loop [ ( k - 1 ) % len ( loop ) ] ) NEW_LINE DEDENT

import bisect NEW_LINE import numpy as np NEW_LINE import sys NEW_LINE input = sys . stdin . readline NEW_LINE def IL ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def SL ( ) : return input ( ) . split ( ) NEW_LINE def I ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def S ( ) : return input ( ) NEW_LINE N , a = IL ( ) NEW_LINE k = I ( ) NEW_LINE bl = IL ( ) NEW_LINE dp = [ 0 , bl [ a - 1 ] ] NEW_LINE ans = - 1 NEW_LINE if k == 1 : NEW_LINE INDENT ans = 1 NEW_LINE DEDENT else : NEW_LINE INDENT for i in range ( 2 , N + 2 ) : NEW_LINE INDENT tmp = bl [ dp [ - 1 ] - 1 ] NEW_LINE if tmp in dp : NEW_LINE INDENT dp . append ( tmp ) NEW_LINE f = dp . index ( tmp ) NEW_LINE ans = f + ( k - i ) % ( i - f ) NEW_LINE break NEW_LINE DEDENT else : NEW_LINE INDENT dp . append ( tmp ) NEW_LINE DEDENT DEDENT DEDENT print ( dp [ ans ] ) NEW_LINE

N , a = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE a -= 1 NEW_LINE k = int ( input ( ) ) NEW_LINE b = [ int ( i ) - 1 for i in input ( ) . split ( ) ] NEW_LINE t = [ - 1 for i in range ( N ) ] NEW_LINE nowt = 0 NEW_LINE while t [ a ] == - 1 : NEW_LINE INDENT t [ a ] = nowt NEW_LINE a = b [ a ] NEW_LINE nowt += 1 NEW_LINE DEDENT loop = max ( t ) - t [ a ] + 1 NEW_LINE if k <= max ( t ) : NEW_LINE INDENT for i in range ( N ) : NEW_LINE INDENT if t [ i ] == k : NEW_LINE INDENT print ( i + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT else : NEW_LINE INDENT base = t [ a ] NEW_LINE for i in range ( N ) : NEW_LINE INDENT t [ i ] -= base NEW_LINE DEDENT k -= base NEW_LINE k %= loop NEW_LINE for i in range ( N ) : NEW_LINE INDENT if t [ i ] == k : NEW_LINE INDENT print ( i + 1 ) NEW_LINE break NEW_LINE DEDENT DEDENT DEDENT


import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { System . out . println ( ( sc . nextInt ( ) * 100 + sc . nextInt ( ) * 10 + sc . nextInt ( ) ) % 4 == 0 ? " YES " : " NO " ) ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; int r = reader . nextInt ( ) ; int g = reader . nextInt ( ) ; int b = reader . nextInt ( ) ; int num = r * 100 + g * 10 + b ; String ans = " NO " ; if ( num % 4 == 0 ) { ans = " YES " ; } reader . close ( ) ; System . out . print ( ans ) ; } }

import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = Integer . parseInt ( sc . next ( ) ) ; int A = Integer . parseInt ( sc . next ( ) ) ; int B = Integer . parseInt ( sc . next ( ) ) ; int cnt = N * 100 + A * 10 + B ; if ( cnt % 4 == 0 ) { out . println ( " YES " ) ; } else { out . println ( " NO " ) ; } out . flush ( ) ; } }

import java . util . Scanner ; public class Main { private static Scanner sc ; public static void main ( String [ ] args ) { sc = new Scanner ( System . in ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( sc . next ( ) ) . append ( sc . next ( ) ) . append ( sc . next ( ) ) ; int a = Integer . valueOf ( sb . toString ( ) ) ; if ( a % 4 == 0 ) { System . out . print ( " YES " ) ; } else { System . out . print ( " NO " ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int r = sc . nextInt ( ) ; int g = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; int num = r * 100 + g * 10 + b * 1 ; System . out . println ( ( num % 4 == 0 ) ? " YES " : " NO " ) ; } }

r , g , b = map ( int , input ( ) . split ( ) ) NEW_LINE print ( " YES " if ( 10 * g + b ) % 4 == 0 else " NO " ) NEW_LINE

print ( ' YNEOS ' [ not eval ( input ( ) . replace ( ' ▁ ' , ' ' ) + ' % 4 = = 0' ) : : 2 ] ) NEW_LINE

x , y , z = input ( ) . split ( ) NEW_LINE a = int ( x + y + z ) NEW_LINE if a % 4 == 0 : NEW_LINE INDENT print ( ' YES ' ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE DEDENT

work = input ( ) . split ( " ▁ " ) NEW_LINE r = int ( work [ 0 ] ) NEW_LINE b = int ( work [ 1 ] ) NEW_LINE g = int ( work [ 2 ] ) NEW_LINE num = r * 100 + b * 10 + g NEW_LINE if ( num % 4 == 0 ) : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT

print ( [ " NO " , " YES " ] [ int ( " " . join ( input ( ) . split ( ) ) ) % 4 == 0 ] ) NEW_LINE


import java . util . Scanner ; public class Main { private static double f ( double P , double x ) { return x + P / Math . pow ( 2 , x / 1.5 ) ; } public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; double P = sc . nextDouble ( ) ; double left = 0 ; double right = Long . MAX_VALUE ; for ( int i = 0 ; i < 200 ; i ++ ) { double x1 = ( left * 2 + right ) / 3 ; double x2 = ( left + right * 2 ) / 3 ; if ( f ( P , x1 ) > f ( P , x2 ) ) { left = x1 ; } else { right = x2 ; } } System . out . println ( f ( P , left ) ) ; } }

import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; double p = sc . nextDouble ( ) ; if ( p >= 1.5 / log ( 2 ) ) { out . println ( f ( 1.5 * log ( log ( 2 ) * p / 1.5 ) / log ( 2 ) , p ) ) ; } else { out . println ( p ) ; } } static double f ( double x , double p ) { return x + p / ( pow ( 2 , x / 1.5 ) ) ; } }

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

import java . util . * ; import java . io . * ; import java . awt . geom . * ; import java . math . * ; public class Main { static final Scanner in = new Scanner ( System . in ) ; static final PrintWriter out = new PrintWriter ( System . out , false ) ; static boolean debug = false ; static double f ( double x , double p ) { return x + p / Math . pow ( 2 , x * 2 / 3 ) ; } static void solve ( ) { double p = in . nextDouble ( ) ; double l = 0.0 , r = Integer . MAX_VALUE / 2 ; for ( int i = 0 ; i < 100 ; i ++ ) { double s = ( l * 2 + r ) / 3 ; double t = ( l + r * 2 ) / 3 ; if ( f ( s , p ) < f ( t , p ) ) { r = t ; } else { l = s ; } } out . printf ( " % .10f \n " , f ( ( l + r ) * 0.5 , p ) ) ; } public static void main ( String [ ] args ) { debug = args . length > 0 ; long start = System . nanoTime ( ) ; solve ( ) ; out . flush ( ) ; long end = System . nanoTime ( ) ; dump ( ( end - start ) / 1000000 + " ▁ ms " ) ; in . close ( ) ; out . close ( ) ; } static void dump ( Object ... o ) { if ( debug ) System . err . println ( Arrays . deepToString ( o ) ) ; } }

import java . util . * ; import java . util . function . * ; class Main { static Scanner s = new Scanner ( System . in ) ; public static void main ( String [ ] $ ) { double p = s . nextDouble ( ) ; DoubleUnaryOperator f = i -> i + p / Math . pow ( 2 , i / 1.5 ) ; System . out . println ( f . applyAsDouble ( goldenSelectionSearch ( 0 , p , 1e-9 , f ) ) ) ; } private static double goldenSelectionSearch ( double l , double r , double off , DoubleUnaryOperator f ) { final double g = ( 1 + Math . sqrt ( 5 ) ) / 2 ; double a = ( l * g + r ) / ( 1 + g ) , fa = f . applyAsDouble ( a ) ; double b = ( l + r * g ) / ( 1 + g ) , fb = f . applyAsDouble ( b ) ; while ( l + off < r ) { if ( fa <= fb ) { r = b ; b = a ; fb = fa ; a = ( l * g + r ) / ( 1 + g ) ; fa = f . applyAsDouble ( a ) ; } else { l = a ; a = b ; fa = fb ; b = ( l + r * g ) / ( 1 + g ) ; fb = f . applyAsDouble ( b ) ; } } return ( a + b ) / 2 ; } }

import sys NEW_LINE input = sys . stdin . readline NEW_LINE p = float ( input ( ) ) NEW_LINE def f ( x ) : NEW_LINE INDENT return x + p / 2 ** ( x / 1.5 ) NEW_LINE DEDENT high = 100 NEW_LINE low = 0 NEW_LINE while high - low > 0.000000001 : NEW_LINE INDENT mid_left = high / 3 + low * 2 / 3 NEW_LINE mid_right = high * 2 / 3 + low / 3 NEW_LINE if f ( mid_left ) >= f ( mid_right ) : NEW_LINE INDENT low = mid_left NEW_LINE DEDENT else : NEW_LINE INDENT high = mid_right NEW_LINE DEDENT DEDENT print ( f ( high ) ) NEW_LINE

from decimal import Decimal NEW_LINE from decimal import getcontext NEW_LINE getcontext ( ) . prec = 56 NEW_LINE def f ( x , P ) : NEW_LINE INDENT return Decimal ( x ) + P * Decimal ( 2 ** Decimal ( Decimal ( - 1 ) * Decimal ( x * Decimal ( 2 / 3 ) ) ) ) NEW_LINE DEDENT def solv ( P ) : NEW_LINE INDENT l = Decimal ( 0 ) NEW_LINE r = Decimal ( 100 ) NEW_LINE while True : NEW_LINE INDENT ml = Decimal ( l + ( r - l ) * Decimal ( 1 / 3 ) ) NEW_LINE mr = Decimal ( l + ( r - l ) * Decimal ( 2 / 3 ) ) NEW_LINE if ( mr - ml ) < 0.000000001 : NEW_LINE INDENT return f ( mr , P ) NEW_LINE DEDENT fml = f ( ml , P ) NEW_LINE fmr = f ( mr , P ) NEW_LINE if fml < fmr : NEW_LINE INDENT r = mr NEW_LINE DEDENT elif fml > fmr : NEW_LINE INDENT l = ml NEW_LINE DEDENT else : NEW_LINE INDENT l = ml NEW_LINE r = mr NEW_LINE DEDENT DEDENT DEDENT I = input ( ) . split ( " . " ) NEW_LINE I [ 1 ] = " . " + I [ 1 ] NEW_LINE P = Decimal ( I [ 0 ] ) + Decimal ( I [ 1 ] ) NEW_LINE print ( solv ( P ) ) NEW_LINE

p = float ( input ( ) ) NEW_LINE def func ( t ) : NEW_LINE INDENT return t + p / ( 2 ** ( t / 1.5 ) ) NEW_LINE DEDENT def TernarySearch ( f , xmin , xmax ) : NEW_LINE INDENT x0 = xmin NEW_LINE x3 = xmax NEW_LINE while x3 - x0 > 10 ** ( - 12 ) : NEW_LINE INDENT x1 = ( x0 * 2 + x3 ) / 3 NEW_LINE x2 = ( x0 + x3 * 2 ) / 3 NEW_LINE if f ( x1 ) < f ( x2 ) : NEW_LINE INDENT x3 = x2 NEW_LINE DEDENT else : NEW_LINE INDENT x0 = x1 NEW_LINE DEDENT DEDENT return x3 NEW_LINE DEDENT print ( func ( TernarySearch ( func , 0 , 100 ) ) ) NEW_LINE

from scipy . optimize import minimize NEW_LINE p = float ( input ( ) ) NEW_LINE t = lambda x : x + p / ( 2 ** ( x / 1.5 ) ) NEW_LINE c = ( { ' type ' : ' ineq ' , ' fun ' : lambda x : x } , { ' type ' : ' ineq ' , ' fun ' : t } ) NEW_LINE m = minimize ( t , x0 = 0 , tol = 0.1 ** 9 , constraints = c , method = " COBYLA " ) NEW_LINE print ( min ( p , m . fun ) ) NEW_LINE

import numpy as np NEW_LINE def main ( ) : NEW_LINE INDENT p = float ( input ( ) ) NEW_LINE b = get_b ( ) NEW_LINE x = max ( 0.0 , np . log ( - 1.0 / ( p * b ) ) / b ) NEW_LINE def f ( x ) : NEW_LINE INDENT return func ( p , x ) NEW_LINE DEDENT print ( f ( ternary_search ( f , 0 , p ) ) ) NEW_LINE DEDENT def ternary_search ( f , xmin , xmax ) : NEW_LINE INDENT assert xmin <= xmax NEW_LINE x0 = xmin NEW_LINE x3 = xmax NEW_LINE for i in range ( 200 ) : NEW_LINE INDENT x1 = ( x0 * 2 + x3 ) / 3.0 NEW_LINE x2 = ( x0 + x3 * 2 ) / 3.0 NEW_LINE if f ( x1 ) < f ( x2 ) : NEW_LINE INDENT x3 = x2 NEW_LINE DEDENT else : NEW_LINE INDENT x0 = x1 NEW_LINE DEDENT DEDENT return x3 NEW_LINE DEDENT def func ( p , x ) : NEW_LINE INDENT return p * 2.0 ** ( - x / 1.5 ) + x NEW_LINE DEDENT def get_b ( ) : NEW_LINE INDENT a = 2.0 ** ( - 1 / 1.5 ) NEW_LINE b = np . log ( a ) NEW_LINE return b NEW_LINE DEDENT main ( ) NEW_LINE


import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; Map < String , Integer > map = new HashMap < > ( ) ; int n = sc . nextInt ( ) ; for ( int i = 0 ; i < n ; i ++ ) { String str = sc . next ( ) ; if ( ! map . containsKey ( str ) ) { map . put ( str , 0 ) ; } map . put ( str , map . get ( str ) + 1 ) ; } int m = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { String str = sc . next ( ) ; if ( ! map . containsKey ( str ) ) { map . put ( str , 0 ) ; } map . put ( str , map . get ( str ) - 1 ) ; } int max = 0 ; for ( int i : map . values ( ) ) { max = max > i ? max : i ; } System . out . println ( max ) ; } }

import java . util . HashMap ; import java . util . Map ; import java . util . Map . Entry ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner reader = new Scanner ( System . in ) ; Map < String , Integer [ ] > map = new HashMap < String , Integer [ ] > ( ) ; int N = reader . nextInt ( ) ; for ( int i = 0 ; i < N ; i ++ ) { String s = reader . next ( ) ; if ( map . containsKey ( s ) ) { map . get ( s ) [ 0 ] ++ ; } else { Integer [ ] arr = new Integer [ 2 ] ; arr [ 0 ] = 1 ; arr [ 1 ] = 0 ; map . put ( s , arr ) ; } } int M = reader . nextInt ( ) ; for ( int i = 0 ; i < M ; i ++ ) { String s = reader . next ( ) ; if ( map . containsKey ( s ) ) { map . get ( s ) [ 1 ] ++ ; } else { Integer [ ] arr = new Integer [ 2 ] ; arr [ 0 ] = 0 ; arr [ 1 ] = 1 ; map . put ( s , arr ) ; } } int ans = 0 ; for ( Entry < String , Integer [ ] > entry : map . entrySet ( ) ) { Integer [ ] arr = entry . getValue ( ) ; int gap = arr [ 0 ] - arr [ 1 ] ; ans = Math . max ( gap , ans ) ; } System . out . println ( ans ) ; reader . close ( ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; import java . util . HashMap ; public class Main { static final BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; public static void main ( String [ ] args ) throws Exception { HashMap < String , Integer > map = new HashMap < > ( ) ; int n = Integer . parseInt ( in . readLine ( ) ) ; for ( int i = 0 ; i < n ; i ++ ) { String key = in . readLine ( ) ; if ( map . containsKey ( key ) ) { map . put ( key , map . get ( key ) + 1 ) ; } else { map . put ( key , 1 ) ; } } int m = Integer . parseInt ( in . readLine ( ) ) ; for ( int i = 0 ; i < m ; i ++ ) { String key = in . readLine ( ) ; if ( map . containsKey ( key ) ) { map . put ( key , map . get ( key ) - 1 ) ; } else { map . put ( key , - 1 ) ; } } in . close ( ) ; int max = - 1 ; for ( int val : map . values ( ) ) { if ( max < val ) { max = val ; } } ; System . out . println ( max < 0 ? 0 : max ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { HashMap < String , Integer > map = new HashMap < > ( ) ; int n = sc . nextInt ( ) ; String s ; for ( int i = 0 ; i < n ; i ++ ) { s = sc . next ( ) ; map . put ( s , map . getOrDefault ( s , 0 ) ) ; map . put ( s , map . get ( s ) + 1 ) ; } int m = sc . nextInt ( ) ; for ( int i = 0 ; i < m ; i ++ ) { s = sc . next ( ) ; map . put ( s , map . getOrDefault ( s , 0 ) ) ; map . put ( s , map . get ( s ) - 1 ) ; } int max = 0 ; for ( Map . Entry < String , Integer > e : map . entrySet ( ) ) { max = Math . max ( max , e . getValue ( ) ) ; } out . println ( max ) ; } }

import java . io . PrintWriter ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; PrintWriter out = new PrintWriter ( System . out ) ; int N = Integer . parseInt ( sc . next ( ) ) ; String s [ ] = new String [ N ] ; for ( int i = 0 ; i < N ; i ++ ) { s [ i ] = sc . next ( ) ; } int M = Integer . parseInt ( sc . next ( ) ) ; String t [ ] = new String [ M ] ; for ( int i = 0 ; i < M ; i ++ ) { t [ i ] = sc . next ( ) ; } int ans = 0 ; for ( int i = 0 ; i < N ; i ++ ) { int cnt = 0 ; for ( int j = 0 ; j < N ; j ++ ) { if ( s [ i ] . equals ( s [ j ] ) ) { cnt ++ ; } } for ( int j = 0 ; j < M ; j ++ ) { if ( s [ i ] . equals ( t [ j ] ) ) { cnt -- ; } } if ( cnt > 0 && cnt > ans ) { ans = cnt ; } } out . println ( ans ) ; out . flush ( ) ; } }

import sys NEW_LINE from collections import Counter , defaultdict NEW_LINE INF = float ( ' inf ' ) NEW_LINE MOD = 10 ** 9 + 7 NEW_LINE def LI ( ) : return [ int ( x ) for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LI_ ( ) : return [ int ( x ) - 1 for x in sys . stdin . readline ( ) . split ( ) ] NEW_LINE def LS ( ) : return sys . stdin . readline ( ) . split ( ) NEW_LINE def II ( ) : return int ( sys . stdin . readline ( ) ) NEW_LINE def SI ( ) : return input ( ) NEW_LINE def main ( ) : NEW_LINE INDENT n = II ( ) NEW_LINE blue = defaultdict ( int ) NEW_LINE for _ in range ( n ) : NEW_LINE INDENT blue [ SI ( ) ] += 1 NEW_LINE DEDENT m = II ( ) NEW_LINE red = defaultdict ( int ) NEW_LINE for _ in range ( m ) : NEW_LINE INDENT red [ SI ( ) ] += 1 NEW_LINE DEDENT res = 0 NEW_LINE for key , v in blue . items ( ) : NEW_LINE INDENT res = max ( res , v - red [ key ] ) NEW_LINE DEDENT return res NEW_LINE DEDENT print ( main ( ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE s = [ input ( ) for _ in range ( N ) ] NEW_LINE M = int ( input ( ) ) NEW_LINE t = [ input ( ) for _ in range ( M ) ] NEW_LINE a = 0 NEW_LINE for i in s : NEW_LINE INDENT b = s . count ( i ) - t . count ( i ) NEW_LINE if a < b : NEW_LINE INDENT a = b NEW_LINE DEDENT DEDENT print ( a ) NEW_LINE

n , * s = open ( 0 ) ; print ( max ( 0 , * [ s . count ( i ) - s [ int ( n ) : ] . count ( i ) * 2 for i in s ] ) ) NEW_LINE

N = int ( input ( ) ) NEW_LINE blue = { } NEW_LINE for _ in range ( N ) : NEW_LINE INDENT s = input ( ) . rstrip ( ) NEW_LINE if blue . get ( s ) == None : NEW_LINE INDENT blue [ s ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT blue [ s ] += 1 NEW_LINE DEDENT DEDENT M = int ( input ( ) ) NEW_LINE red = { } NEW_LINE for _ in range ( M ) : NEW_LINE INDENT t = input ( ) . rstrip ( ) NEW_LINE if red . get ( t ) == None : NEW_LINE INDENT red [ t ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT red [ t ] += 1 NEW_LINE DEDENT DEDENT answer = 0 NEW_LINE for i , blue_elem in blue . items ( ) : NEW_LINE INDENT red_elem = red [ i ] if red . get ( i ) != None else 0 NEW_LINE answer = blue_elem - red_elem if answer < blue_elem - red_elem else answer NEW_LINE DEDENT print ( answer ) NEW_LINE

N = int ( input ( ) ) NEW_LINE input_Blue = [ input ( ) for i in range ( N ) ] NEW_LINE M = int ( input ( ) ) NEW_LINE input_Red = [ input ( ) for j in range ( M ) ] NEW_LINE dict_Blue = { } NEW_LINE for str_Blue in input_Blue : NEW_LINE INDENT dict_Blue [ str_Blue ] = dict_Blue . get ( str_Blue , 0 ) + 1 NEW_LINE DEDENT dict_Red = { } NEW_LINE for str_Red in input_Red : NEW_LINE INDENT dict_Red [ str_Red ] = dict_Red . get ( str_Red , 0 ) + 1 NEW_LINE DEDENT for Blue_Key in dict_Blue . keys ( ) : NEW_LINE INDENT if Blue_Key in dict_Red . keys ( ) : NEW_LINE INDENT dict_Blue [ Blue_Key ] = dict_Blue [ Blue_Key ] - dict_Red [ Blue_Key ] NEW_LINE DEDENT DEDENT if max ( dict_Blue . values ( ) ) < 0 : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( max ( dict_Blue . values ( ) ) ) NEW_LINE DEDENT


import java . util . Scanner ; public class Main { private static Scanner sc = new Scanner ( System . in ) ; public static void main ( String [ ] args ) { int n = sc . nextInt ( ) ; String s = sc . next ( ) ; int x = 0 ; int ans = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s . charAt ( i ) == ' I ' ) { x ++ ; } else if ( s . charAt ( i ) == ' D ' ) { x -- ; } ans = Math . max ( ans , x ) ; } System . out . println ( 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 ) { int N = in . nextInt ( ) ; String S = in . next ( ) ; int ans = 0 ; int tmp = 0 ; for ( int i = 0 ; i < N ; i ++ ) { if ( S . charAt ( i ) == ' I ' ) { tmp ++ ; } else if ( S . charAt ( i ) == ' D ' ) { tmp -- ; } ans = Math . max ( ans , tmp ) ; } out . println ( ans ) ; } } 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 . io . * ; import java . util . * ; public class Main { public static void main ( String [ ] args ) { MyScanner sc = new MyScanner ( ) ; int k = sc . nextInt ( ) ; String s = sc . next ( ) ; int ans = 0 ; int x = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( s . charAt ( i ) == ' I ' ) { x ++ ; } else { x -- ; } ans = Math . max ( x , ans ) ; } System . out . println ( ans ) ; } static int l_min ( int [ ] a ) { Arrays . sort ( a ) ; return a [ 0 ] ; } static int l_max ( int [ ] a ) { int l = a . length ; Arrays . sort ( a ) ; return a [ l - 1 ] ; } public static PrintWriter out ; public static class MyScanner { BufferedReader br ; StringTokenizer st ; public MyScanner ( ) { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; } String next ( ) { while ( st == null || ! st . hasMoreElements ( ) ) { try { st = new StringTokenizer ( br . readLine ( ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } return st . nextToken ( ) ; } int nextInt ( ) { return Integer . parseInt ( next ( ) ) ; } long nextLong ( ) { return Long . parseLong ( next ( ) ) ; } double nextDouble ( ) { return Double . parseDouble ( next ( ) ) ; } String nextLine ( ) { String str = " " ; try { str = br . readLine ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return str ; } } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { @ SuppressWarnings ( " resource " ) Scanner scan = new Scanner ( System . in ) ; int N = scan . nextInt ( ) ; String S = scan . next ( ) ; int x = 0 ; int max = 0 ; for ( char s : S . toCharArray ( ) ) { switch ( s ) { case ' I ' : x ++ ; if ( max < x ) { max = x ; } break ; case ' D ' : x -- ; } } System . out . println ( max ) ; } }

import java . io . BufferedReader ; import java . io . InputStreamReader ; public class Main { public static void main ( String [ ] args ) throws Exception { BufferedReader input = new BufferedReader ( new InputStreamReader ( System . in ) ) ; input . readLine ( ) ; String word = input . readLine ( ) ; int value = 0 ; int max = 0 ; for ( int i = 0 ; i < word . length ( ) ; i ++ ) { if ( word . charAt ( i ) == ' I ' ) { value ++ ; } else { value -- ; } max = Math . max ( max , value ) ; } System . out . println ( max ) ; } }

from functools import reduce NEW_LINE def main ( ) : NEW_LINE INDENT N = int ( input ( ) . rstrip ( ) ) NEW_LINE S = list ( _ for _ in input ( ) ) NEW_LINE x = 0 NEW_LINE max_x = 0 NEW_LINE for s in S : NEW_LINE INDENT if s == ' I ' : NEW_LINE INDENT x += 1 NEW_LINE DEDENT elif s == ' D ' : NEW_LINE INDENT x += - 1 NEW_LINE DEDENT max_x = max ( x , max_x ) NEW_LINE DEDENT print ( max_x ) NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT main ( ) NEW_LINE DEDENT

_ , t = open ( 0 ) ; a = b = 0 NEW_LINE for x in t : b += x > ' D ' or - 1 ; a = max ( a , b ) NEW_LINE print ( a ) NEW_LINE

x = 0 NEW_LINE N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE ans = [ ] NEW_LINE ans . append ( x ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if S [ i ] == " I " : NEW_LINE INDENT x += 1 NEW_LINE DEDENT else : NEW_LINE INDENT x -= 1 NEW_LINE DEDENT ans . append ( x ) NEW_LINE DEDENT print ( max ( ans ) ) NEW_LINE

n = int ( input ( ) ) NEW_LINE b = 0 NEW_LINE t = 0 NEW_LINE for c in input ( ) : NEW_LINE INDENT if c == ' I ' : NEW_LINE INDENT t += 1 NEW_LINE DEDENT else : NEW_LINE INDENT t -= 1 NEW_LINE DEDENT if t > b : NEW_LINE INDENT b = t NEW_LINE DEDENT DEDENT print ( b ) NEW_LINE

N = int ( input ( ) ) NEW_LINE S = input ( ) NEW_LINE res = 0 NEW_LINE tmp = 0 NEW_LINE for s in S : NEW_LINE INDENT if s == " I " : NEW_LINE INDENT tmp += 1 NEW_LINE DEDENT if s == " D " : NEW_LINE INDENT tmp -= 1 NEW_LINE DEDENT res = max ( tmp , res ) NEW_LINE DEDENT print ( res ) NEW_LINE


import static java . lang . Integer . parseInt ; import static java . lang . Long . parseLong ; import static java . lang . System . exit ; import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . io . PrintWriter ; import java . util . StringTokenizer ; public class Main { static void solve ( ) throws Exception { int n = scanInt ( ) , a = scanInt ( ) , b = scanInt ( ) ; if ( ( Integer . bitCount ( a ^ b ) & 1 ) == 0 ) { out . print ( " NO " ) ; } else { out . println ( " YES " ) ; go ( ( 1 << n ) - 1 , a , b ) ; } } static void go ( int mask , int a , int b ) { if ( ( mask & ( mask - 1 ) ) == 0 ) { out . print ( a + " ▁ " + b + " ▁ " ) ; } else { int c = Integer . lowestOneBit ( a ^ b ) ; int d = Integer . lowestOneBit ( mask ^ c ) ; go ( mask ^ c , a , a ^ d ) ; go ( mask ^ c , a ^ d ^ c , b ) ; } } static int scanInt ( ) throws IOException { return parseInt ( scanString ( ) ) ; } static long scanLong ( ) throws IOException { return parseLong ( scanString ( ) ) ; } static String scanString ( ) throws IOException { while ( tok == null || ! tok . hasMoreTokens ( ) ) { tok = new StringTokenizer ( in . readLine ( ) ) ; } return tok . nextToken ( ) ; } static BufferedReader in ; static PrintWriter out ; static StringTokenizer tok ; public static void main ( String [ ] args ) { try { in = new BufferedReader ( new InputStreamReader ( System . in ) ) ; out = new PrintWriter ( System . out ) ; solve ( ) ; in . close ( ) ; out . close ( ) ; } catch ( Throwable e ) { e . printStackTrace ( ) ; exit ( 1 ) ; } } }

import java . util . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int num = sc . nextInt ( ) ; int first = sc . nextInt ( ) ; int last = sc . nextInt ( ) ; boolean bit [ ] = new boolean [ num ] ; int index [ ] = new int [ num ] ; int sum = 0 ; for ( int i = 0 ; i < num ; i ++ ) { bit [ i ] = ( first & ( 1 << i ) ) != ( last & ( 1 << i ) ) ; sum += bit [ i ] ? 1 : 0 ; index [ bit [ i ] ? sum - 1 : num - ( i - sum ) - 1 ] = i ; } if ( sum % 2 == 0 ) { System . out . println ( " NO " ) ; } else { System . out . println ( " YES " ) ; int max = ( int ) Math . pow ( 2 , num ) ; int tmp = first ; int change [ ] = new int [ num ] ; System . out . print ( tmp + " ▁ " ) ; for ( int i = 1 ; i < max ; i ++ ) { int crtIndex = 0 ; for ( ; crtIndex < num ; crtIndex ++ ) { if ( ( i & ( 1 << crtIndex ) ) != 0 ) { break ; } } crtIndex = num - crtIndex - 1 ; if ( bit [ index [ crtIndex ] ] && crtIndex != 0 ) { if ( crtIndex % 2 == 0 ) { if ( change [ crtIndex ] < 2 ) { change [ crtIndex ] ++ ; crtIndex -- ; } } else { if ( change [ crtIndex ] < 1 ) { change [ crtIndex ] ++ ; crtIndex ++ ; } } } int crtDigit = 1 << index [ crtIndex ] ; tmp = ( tmp & crtDigit ) != 0 ? tmp - crtDigit : tmp + crtDigit ; System . out . print ( tmp + " ▁ " ) ; } } System . out . println ( ) ; } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; import java . util . StringTokenizer ; public class Main { BufferedReader in = new BufferedReader ( new InputStreamReader ( System . in ) , 1000000 ) ; StringTokenizer tok = new StringTokenizer ( " " ) ; StringBuilder out = new StringBuilder ( ) ; String next ( ) throws IOException { if ( ! tok . hasMoreTokens ( ) ) { tok = new StringTokenizer ( in . readLine ( ) ) ; } return tok . nextToken ( ) ; } int nextInt ( ) throws IOException { return Integer . parseInt ( next ( ) ) ; } int n = 0 ; int k = 0 ; void go ( int a , int b , int mask , char removed ) { if ( removed == k - 1 ) { out . append ( a + " ▁ " + b + " ▁ " ) ; } else { int k1 = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( ( mask & ( 1 << i ) ) == 0 && ( ( a ^ b ) & ( 1 << i ) ) > 0 ) { mask |= ( 1 << i ) ; removed ++ ; k1 = i ; break ; } } int a1 = 0 ; for ( int j = 0 ; j < k ; j ++ ) { if ( ( mask & ( 1 << j ) ) == 0 ) { a1 = a ^ ( 1 << j ) ; break ; } } go ( a , a1 , mask , removed ) ; go ( ( a1 ^ ( 1 << k1 ) ) , b , mask , removed ) ; } } void slave ( ) throws IOException { k = nextInt ( ) ; int A = nextInt ( ) ; int B = nextInt ( ) ; n = 1 << k ; if ( Integer . bitCount ( A ^ B ) % 2 == 0 ) { out . append ( " NO " ) ; } else { out . append ( " YES \n " ) ; go ( A , B , 0 , ( char ) 0 ) ; } System . out . print ( out ) ; } public static void main ( String [ ] args ) throws IOException { new Main ( ) . slave ( ) ; } }

import java . io . PrintWriter ; import java . util . Scanner ; public class Main { private static int [ ] path ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int n = sc . nextInt ( ) ; int a = sc . nextInt ( ) ; int b = sc . nextInt ( ) ; path = new int [ 1 << n ] ; if ( Integer . bitCount ( a ^ b ) % 2 != 0 ) { System . out . println ( " YES " ) ; } else { System . out . println ( " NO " ) ; return ; } path ( a , b , 0 , ( 1 << n ) - 1 ) ; PrintWriter pw = new PrintWriter ( System . out ) ; for ( int i = 0 ; i < path . length ; i ++ ) { pw . print ( path [ i ] + " ▁ " ) ; } pw . println ( ) ; pw . flush ( ) ; } private static void path ( int a , int b , int st , int mask ) { int diffBit = Integer . highestOneBit ( mask & ( a ^ b ) ) ; mask = mask ^ diffBit ; int size = Integer . bitCount ( mask ) ; if ( size == 0 ) { path [ st ] = a ; path [ st + 1 ] = b ; } else { int otherBit = Integer . highestOneBit ( mask ) ; path ( a , a ^ otherBit , st , mask ) ; path ( a ^ diffBit ^ otherBit , b , st + ( 1 << size ) , mask ) ; } } }

import java . util . ArrayList ; import java . util . Arrays ; import java . util . Scanner ; public class Main { int n , a , b ; ArrayList < Integer > ans ; void run ( ) { Scanner sc = new Scanner ( System . in ) ; n = sc . nextInt ( ) ; a = sc . nextInt ( ) ; b = sc . nextInt ( ) ; if ( Integer . bitCount ( a ^ b ) % 2 == 0 ) { System . out . println ( " NO " ) ; return ; } System . out . println ( " YES " ) ; ans = new ArrayList < > ( ) ; solve ( a , b , ( 1 << n ) - 1 ) ; boolean check = true ; for ( int i = 0 ; i < ( 1 << n ) - 1 ; i ++ ) { System . out . print ( ans . get ( i ) + " ▁ " ) ; } System . out . println ( b ) ; } void reverse ( int [ ] ar , int l , int r ) { int c = ( l + r ) / 2 - l ; for ( int i = 0 ; i < c ; i ++ ) { int tmp = ar [ l + i ] ; ar [ l + i ] = ar [ r - i ] ; ar [ r - i ] = tmp ; } } void solve ( int A , int B , int mask ) { if ( Integer . bitCount ( mask ) == 1 ) { ans . add ( A ) ; ans . add ( B ) ; return ; } int div = - 1 ; for ( int i = 0 ; i < n ; i ++ ) if ( ( ( ( A ^ B ) & mask ) & ( 1 << i ) ) > 0 ) { div = i ; } mask ^= 1 << div ; int c = mask & ( - mask ) ; int C = A ^ c ; solve ( A , C , mask ) ; solve ( C ^ ( 1 << div ) , B , mask ) ; } void debug ( Object ... os ) { System . err . println ( Arrays . deepToString ( os ) ) ; } public static void main ( String [ ] args ) { new Main ( ) . run ( ) ; } }

import sys NEW_LINE def revBit ( Ai ) : NEW_LINE INDENT return '1' if Ai == '0' else '0' NEW_LINE DEDENT def rec ( binA , binB ) : NEW_LINE INDENT if len ( binA ) == 1 : NEW_LINE INDENT return [ binA , binB ] NEW_LINE DEDENT for i , ( Ai , Bi ) in enumerate ( zip ( binA , binB ) ) : NEW_LINE INDENT if Ai != Bi : NEW_LINE INDENT x = i NEW_LINE Ax , Bx = Ai , Bi NEW_LINE break NEW_LINE DEDENT DEDENT binA2 = binA [ : x ] + binA [ x + 1 : ] NEW_LINE binB2 = binB [ : x ] + binB [ x + 1 : ] NEW_LINE binC = binA2 [ : - 1 ] + revBit ( binA2 [ - 1 ] ) NEW_LINE ptn1s = rec ( binA2 , binC ) NEW_LINE ptn2s = rec ( binC , binB2 ) NEW_LINE ptns = [ ] NEW_LINE for ptn1 in ptn1s : NEW_LINE INDENT ptns . append ( ptn1 [ : x ] + Ax + ptn1 [ x : ] ) NEW_LINE DEDENT for ptn2 in ptn2s : NEW_LINE INDENT ptns . append ( ptn2 [ : x ] + Bx + ptn2 [ x : ] ) NEW_LINE DEDENT return ptns NEW_LINE DEDENT N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE binA , binB = bin ( A ) [ 2 : ] . zfill ( N ) , bin ( B ) [ 2 : ] . zfill ( N ) NEW_LINE numDiff = sum ( [ Ai != Bi for Ai , Bi in zip ( binA , binB ) ] ) NEW_LINE if numDiff % 2 == 0 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT ptns = rec ( binA , binB ) NEW_LINE print ( ' YES ' ) NEW_LINE print ( ' ▁ ' . join ( [ str ( int ( ptn , 2 ) ) for ptn in ptns ] ) ) NEW_LINE

n , a , b = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE def f ( n , a , b ) : NEW_LINE INDENT if n == 1 : NEW_LINE INDENT return [ a , b ] NEW_LINE DEDENT mask = 1 << ( n - 1 ) NEW_LINE if a & mask == b & mask : NEW_LINE INDENT v1 = f ( n - 1 , a , b ) NEW_LINE v2 = f ( n - 1 , a ^ mask , v1 [ 1 ] ^ mask ) NEW_LINE ret = [ a ] NEW_LINE ret . extend ( v2 ) NEW_LINE ret . extend ( v1 [ 1 : ] ) NEW_LINE return ret NEW_LINE DEDENT else : NEW_LINE INDENT v1 = f ( n - 1 , a , a ^ 1 ) NEW_LINE v2 = f ( n - 1 , a ^ 1 ^ mask , b ) NEW_LINE v1 . extend ( v2 ) NEW_LINE return v1 NEW_LINE DEDENT DEDENT if bin ( a ^ b ) . count ( "1" ) % 2 == 0 : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " YES " ) NEW_LINE res = f ( n , a , b ) NEW_LINE for p in res : NEW_LINE INDENT print ( p , end = " ▁ " ) NEW_LINE DEDENT DEDENT

N , A , B = map ( int , input ( ) . split ( ) ) NEW_LINE if bin ( A ) . count ( "1" ) % 2 == bin ( B ) . count ( "1" ) % 2 : NEW_LINE INDENT print ( " No " ) NEW_LINE exit ( 0 ) NEW_LINE DEDENT print ( " Yes " ) NEW_LINE ans = [ ] NEW_LINE def solve ( c , A , B , S ) : NEW_LINE INDENT P = A ^ B NEW_LINE U = P & S NEW_LINE b = 1 NEW_LINE if c == 1 : NEW_LINE INDENT ans . append ( A ) NEW_LINE ans . append ( B ) NEW_LINE return NEW_LINE DEDENT for i in range ( N ) : NEW_LINE INDENT if U & b : NEW_LINE INDENT assert S & b > 0 , ( P , S , U , b ) NEW_LINE S0 = S ^ b NEW_LINE k = 1 NEW_LINE while not S0 & k : NEW_LINE INDENT k <<= 1 NEW_LINE DEDENT C = A ^ k NEW_LINE solve ( c - 1 , A , C , S0 ) NEW_LINE solve ( c - 1 , C ^ b , B , S0 ) NEW_LINE break NEW_LINE DEDENT b <<= 1 NEW_LINE DEDENT DEDENT solve ( N , A , B , 2 ** N - 1 ) NEW_LINE print ( * ans ) NEW_LINE

import sys NEW_LINE def sum_digits ( n , m ) : NEW_LINE INDENT r = 0 NEW_LINE while n : NEW_LINE INDENT r , n = r + n % m , n // m NEW_LINE DEDENT return r NEW_LINE DEDENT n , a , b = [ int ( i ) for i in input ( ) . split ( ) ] NEW_LINE c = a ^ b NEW_LINE if sum_digits ( c , 2 ) % 2 == 0 : NEW_LINE INDENT print ( ' NO ' ) NEW_LINE sys . exit ( ) NEW_LINE DEDENT def grey ( n ) : NEW_LINE INDENT if n == 1 : return [ 0 , 1 ] NEW_LINE a0 = grey ( n - 1 ) NEW_LINE a2 = [ ( 2 ** ( n - 2 ) ) ^ i ^ ( 2 ** ( n - 1 ) ) for i in grey ( n - 1 ) ] NEW_LINE return a0 + a2 NEW_LINE DEDENT def newgrey ( a , b , move ) : NEW_LINE INDENT if len ( move ) == 1 : NEW_LINE INDENT return [ a , b ] NEW_LINE DEDENT diff = 0 NEW_LINE for j in move : NEW_LINE INDENT if a & ( 2 ** j ) != b & ( 2 ** j ) : NEW_LINE INDENT diff = j NEW_LINE break NEW_LINE DEDENT DEDENT ac = a NEW_LINE bc = b NEW_LINE for j in move : NEW_LINE INDENT if j == diff : continue NEW_LINE ac = a ^ ( 2 ** j ) NEW_LINE bc = ac ^ ( 2 ** diff ) NEW_LINE if bc != b : break NEW_LINE DEDENT return newgrey ( a , ac , move - set ( { diff } ) ) + newgrey ( bc , b , move - set ( { diff } ) ) NEW_LINE DEDENT print ( ' YES ' ) NEW_LINE ans = newgrey ( a , b , set ( range ( n ) ) ) NEW_LINE print ( * ans ) NEW_LINE

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 6 ) NEW_LINE n , a , b = map ( int , input ( ) . split ( ) ) NEW_LINE def pop_count ( x ) : NEW_LINE INDENT res = 0 NEW_LINE for i in range ( 17 ) : NEW_LINE INDENT res += ( ( x >> i ) % 2 == 1 ) NEW_LINE DEDENT return res NEW_LINE DEDENT if ( pop_count ( a ^ b ) ) % 2 == 0 : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " YES " ) NEW_LINE def f ( m , x , y ) : NEW_LINE INDENT if m == 1 : NEW_LINE INDENT if x == 0 : NEW_LINE INDENT return [ 0 , 1 ] NEW_LINE DEDENT else : NEW_LINE INDENT return [ 1 , 0 ] NEW_LINE DEDENT DEDENT res = [ x ] NEW_LINE for i in range ( m ) : NEW_LINE INDENT if ( x >> i ) % 2 != ( y >> i ) % 2 : NEW_LINE INDENT diff = i NEW_LINE break NEW_LINE DEDENT DEDENT s = ( x % ( 2 ** diff ) ) + ( ( ( x // ( 2 ** ( diff + 1 ) ) ) * 2 ** ( diff + 1 ) ) >> 1 ) NEW_LINE t = ( y % ( 2 ** diff ) ) + ( ( ( y // ( 2 ** ( diff + 1 ) ) ) * 2 ** ( diff + 1 ) ) >> 1 ) NEW_LINE u = s ^ 1 NEW_LINE left = f ( m - 1 , s , u ) NEW_LINE right = f ( m - 1 , u , t ) NEW_LINE x_bit , y_bit = ( x >> diff ) % 2 , ( y >> diff ) % 2 NEW_LINE left = [ l % ( 2 ** diff ) + ( 2 ** diff * x_bit ) + ( ( ( l // ( 2 ** diff ) ) * 2 ** diff ) << 1 ) for l in left ] NEW_LINE right = [ r % ( 2 ** diff ) + ( 2 ** diff * y_bit ) + ( ( ( r // ( 2 ** diff ) ) * 2 ** diff ) << 1 ) for r in right ] NEW_LINE return left + right NEW_LINE DEDENT print ( * f ( n , a , b ) ) NEW_LINE DEDENT


import java . util . * ; public class Main { static int count = 0 ; public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; int k = sc . nextInt ( ) ; int prevA = 0 ; int a = 1 ; int prevB = 1 ; int b = 1 ; for ( int i = 2 ; i <= k ; i ++ ) { int ta = prevA + a ; int tb = prevB + b ; prevA = a ; a = ta ; prevB = b ; b = tb ; } System . out . println ( a + " ▁ " + b ) ; } }

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

import java . io . BufferedInputStream ; import java . io . IOException ; import java . io . InputStream ; public class Main { public static void main ( String [ ] args ) throws Exception { Scanner sc = new Scanner ( System . in ) ; int K = sc . nextInt ( ) ; long a = 1 ; long b = 1 ; for ( int i = 0 ; i < K ; i ++ ) { long tmp = a ; a += b ; b = tmp ; } System . out . println ( a + " ▁ " + b ) ; } public static class Scanner { private BufferedInputStream inputStream ; public Scanner ( InputStream in ) { inputStream = new BufferedInputStream ( in ) ; } public int nextInt ( ) throws IOException { int num = 0 ; int read = skip ( ) ; do { num = num * 10 + ( read - 0x30 ) ; } while ( ( read = inputStream . read ( ) ) > 0x20 ) ; return num ; } public int [ ] nextInt ( int n ) throws IOException { int [ ] array = new int [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { array [ i ] = nextInt ( ) ; } return array ; } public long nextLong ( ) throws IOException { long num = 0 ; int read = skip ( ) ; do { num = num * 10 + ( read - 0x30 ) ; } while ( ( read = inputStream . read ( ) ) > 0x20 ) ; return num ; } public long [ ] nextLong ( int n ) throws IOException { long [ ] array = new long [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { array [ i ] = nextLong ( ) ; } return array ; } public String next ( ) throws IOException { StringBuilder builder = new StringBuilder ( ) ; int read = skip ( ) ; do { builder . append ( ( char ) read ) ; } while ( ( read = inputStream . read ( ) ) > 0x20 ) ; return builder . toString ( ) ; } private int skip ( ) throws IOException { int read ; while ( ( read = inputStream . read ( ) ) <= 0x20 ) ; return read ; } } }

import java . io . BufferedReader ; import java . io . IOException ; import java . io . InputStreamReader ; class Main { static BufferedReader br ; static final double PHI = ( 1 + Math . sqrt ( 5 ) ) / 2 ; public static void main ( String [ ] args ) throws IOException { br = new BufferedReader ( new InputStreamReader ( System . in ) ) ; int k = Integer . parseInt ( br . readLine ( ) ) ; System . out . println ( ( int ) ( pow ( k ) / Math . sqrt ( 5 ) + 0.5 ) + " ▁ " + ( int ) ( PHI * pow ( k ) / Math . sqrt ( 5 ) + 0.5 ) ) ; } private static double pow ( int k ) { double d = 0.0 ; if ( k == 0 ) return 1 ; if ( k % 2 == 0 ) { d = pow ( k / 2 ) ; return d * d ; } d = pow ( k / 2 ) ; return PHI * d * d ; } }

import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) throws Exception { new Main ( ) . solve ( ) ; } void solve ( ) { Scanner sc = new Scanner ( System . in ) ; long k = sc . nextLong ( ) ; for ( long aa = 1 ; ; aa ++ ) { long a = aa ; long b = 0 ; for ( int i = 0 ; i < k ; i ++ ) { if ( a < b ) { long d = a ; a = b ; b = d ; } long nextA ; long nextB = a ; nextA = a + b ; a = nextA ; b = nextB ; } if ( 1000000000 > a || 1000000000 > b ) { System . out . println ( b + " ▁ " + a ) ; return ; } } } static int count = 0 ; long gcd ( long a , long b ) { if ( a > b ) { long d = a ; a = b ; b = d ; } if ( a == 0 ) return b ; else { count ++ ; return gcd ( a , b % a ) ; } } }

K = int ( input ( ) ) NEW_LINE f = [ 0 ] * 42 NEW_LINE f [ 0 ] = 1 NEW_LINE f [ 1 ] = 1 NEW_LINE for k in range ( 2 , 42 ) : NEW_LINE INDENT f [ k ] = f [ k - 1 ] + f [ k - 2 ] NEW_LINE DEDENT print ( f [ K + 1 ] , f [ K ] ) NEW_LINE

def mat_mul ( a , b ) : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( len ( a ) ) : NEW_LINE INDENT ans . append ( [ ] ) NEW_LINE for j in range ( len ( b [ 0 ] ) ) : NEW_LINE INDENT tmp = 0 NEW_LINE for k in range ( len ( a [ 0 ] ) ) : NEW_LINE INDENT tmp += a [ i ] [ k ] * b [ k ] [ j ] NEW_LINE DEDENT ans [ i ] . append ( tmp ) NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n = int ( input ( ) ) + 1 NEW_LINE x = [ [ 1 ] , [ 0 ] ] NEW_LINE y = [ [ 1 , 1 ] , [ 1 , 0 ] ] NEW_LINE while n > 0 : NEW_LINE INDENT if ( n & 1 ) > 0 : NEW_LINE INDENT x = mat_mul ( y , x ) NEW_LINE DEDENT n //= 2 NEW_LINE y = mat_mul ( y , y ) NEW_LINE DEDENT print ( " { } ▁ { } " . format ( x [ 0 ] [ 0 ] , x [ 1 ] [ 0 ] ) ) NEW_LINE

cache = { } NEW_LINE def fib ( n ) : NEW_LINE INDENT if cache . get ( n ) : NEW_LINE INDENT return cache [ n ] NEW_LINE DEDENT if n == 1 or n == 2 : NEW_LINE INDENT return 1 NEW_LINE DEDENT cache [ n - 1 ] = fib ( n - 1 ) NEW_LINE cache [ n - 2 ] = fib ( n - 2 ) NEW_LINE return cache [ n - 1 ] + cache [ n - 2 ] NEW_LINE DEDENT k = int ( input ( ) ) NEW_LINE print ( fib ( k + 2 ) , fib ( k + 1 ) ) NEW_LINE

from functools import lru_cache NEW_LINE @ lru_cache ( maxsize = None ) NEW_LINE def fib ( n ) : NEW_LINE INDENT if n < 2 : NEW_LINE INDENT return 1 NEW_LINE DEDENT return fib ( n - 1 ) + fib ( n - 2 ) NEW_LINE DEDENT K = int ( input ( ) ) NEW_LINE print ( fib ( K + 1 ) , fib ( K ) ) NEW_LINE

a = 0 NEW_LINE b = 1 NEW_LINE for i in range ( int ( input ( ) ) ) : a , b = b , a + b NEW_LINE print ( a , b ) NEW_LINE


import java . io . OutputStream ; import java . io . IOException ; import java . io . InputStream ; import java . io . PrintWriter ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { InputStream inputStream = System . in ; OutputStream outputStream = System . out ; Scanner in = new Scanner ( inputStream ) ; PrintWriter out = new PrintWriter ( outputStream ) ; D solver = new D ( ) ; solver . solve ( 1 , in , out ) ; out . close ( ) ; } static class D { public void solve ( int testNumber , Scanner in , PrintWriter out ) { long a = in . nextLong ( ) , b = in . nextLong ( ) ; out . println ( calc ( b ) - calc ( a - 1 ) ) ; } private long calc ( long n ) { char [ ] cs = Long . toString ( n ) . toCharArray ( ) ; boolean eight = false ; for ( int i = 0 ; i < cs . length ; i ++ ) { if ( ! eight && ( cs [ i ] == '4' || cs [ i ] == '9' ) ) { eight = true ; } else if ( eight ) { cs [ i ] = '8' ; } if ( cs [ i ] >= '9' ) { cs [ i ] -= 2 ; } else if ( cs [ i ] >= '4' ) { cs [ i ] -- ; } } long wo8 = Long . parseLong ( String . valueOf ( cs ) , 8 ) ; return n - wo8 ; } } }

import java . util . Arrays ; import java . util . Scanner ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; char [ ] a , b ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; a = String . valueOf ( A ) . toCharArray ( ) ; b = String . valueOf ( B + 1 ) . toCharArray ( ) ; System . out . println ( B - A + 1 - ( f ( b , 0 ) - f ( a , 0 ) ) ) ; } static long f ( char [ ] v , int idx ) { if ( idx == v . length ) return 0 ; long ret = 0 ; for ( int i = 0 ; i < v [ idx ] - '0' ; ++ i ) { if ( i == 4 || i == 9 ) continue ; ret += pow ( 8 , v . length - 1 - idx ) ; } if ( v [ idx ] - '0' != 4 && v [ idx ] - '0' != 9 ) ret += f ( v , idx + 1 ) ; return ret ; } static long pow ( long a , long n ) { long ret = 1 ; for ( ; n > 0 ; n >>= 1 , a = a * a ) { if ( n % 2 == 1 ) { ret = ret * a ; } } return ret ; } static void tr ( Object ... objects ) { System . out . println ( Arrays . deepToString ( objects ) ) ; } }

import java . util . * ; import static java . lang . System . * ; import static java . lang . Math . * ; public class Main { public static void main ( String [ ] $ ) { Scanner sc = new Scanner ( in ) ; long A = sc . nextLong ( ) - 1 ; long B = sc . nextLong ( ) ; int [ ] a = new int [ 19 ] ; int [ ] b = new int [ 19 ] ; for ( int i = 0 ; i < 19 ; i ++ ) { a [ 18 - i ] = ( int ) ( A % 10 ) ; b [ 18 - i ] = ( int ) ( B % 10 ) ; A /= 10 ; B /= 10 ; } out . println ( c ( b ) - c ( a ) ) ; } static long c ( int [ ] a ) { long [ ] [ ] [ ] dp = new long [ 20 ] [ 2 ] [ 2 ] ; dp [ 0 ] [ 0 ] [ 0 ] = 1 ; for ( int i = 0 ; i < 19 ; i ++ ) { for ( int j = 0 ; j < 2 ; j ++ ) { int x = j == 1 ? 9 : a [ i ] ; for ( int k = 0 ; k < 2 ; k ++ ) { for ( int l = 0 ; l <= x ; l ++ ) { dp [ i + 1 ] [ j == 1 || l < x ? 1 : 0 ] [ l == 4 || l == 9 ? 1 : k ] += dp [ i ] [ j ] [ k ] ; } } } } return dp [ 19 ] [ 0 ] [ 1 ] + dp [ 19 ] [ 1 ] [ 1 ] ; } }

import java . util . * ; class Main { static long f ( long a ) { int [ ] d = new int [ 19 ] ; long b = a ; for ( int i = 0 ; i < 19 ; ++ i ) { d [ 18 - i ] = ( int ) ( a % 10 ) ; a /= 10 ; } long [ ] dp = new long [ 20 ] ; boolean f = false ; for ( int i = 0 ; i < 19 ; ++ i ) { dp [ i + 1 ] = 8 * dp [ i ] ; for ( int k = d [ i ] + 1 ; k < 10 ; ++ k ) { if ( k != 4 && k != 9 && ! f ) dp [ i + 1 ] -- ; } if ( d [ i ] == 4 || d [ i ] == 9 ) f = true ; } return b + 1 - dp [ 19 ] ; } public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; long a = scan . nextLong ( ) ; long b = scan . nextLong ( ) ; System . out . println ( f ( b ) - f ( a - 1 ) ) ; } }

import java . util . * ; import static java . lang . System . * ; public class Main { public static void main ( String [ ] args ) { Scanner sc = new Scanner ( System . in ) ; long A = sc . nextLong ( ) ; long B = sc . nextLong ( ) ; long ANum = solver ( A - 1 ) ; long BNum = solver ( B ) ; out . println ( BNum - ANum ) ; } public static long solver ( long N ) { if ( N < 0 ) { return 0 ; } long ans = 0 ; while ( true ) { int first = Character . getNumericValue ( String . valueOf ( N ) . charAt ( 0 ) ) ; int k = String . valueOf ( N ) . length ( ) - 1 ; if ( k == 0 ) { for ( int i = 0 ; i <= first ; i ++ ) { if ( i == 4 || i == 9 ) { ans ++ ; } } break ; } else { long ansTmp = first * ( long ) Math . pow ( 10.0 , k ) ; for ( int i = 0 ; i < first ; i ++ ) { if ( i == 4 || i == 9 ) { continue ; } ansTmp -= ( long ) Math . pow ( 8 , k ) ; } ans += ansTmp ; } if ( k > 0 && ( first == 4 || first == 9 ) ) { ans += N - first * ( long ) Math . pow ( 10 , k ) + 1 ; break ; } else { N %= first * ( long ) Math . pow ( 10.0 , k ) ; } } return ans ; } }

whitedigits = [ 0 , 1 , 2 , 3 , 4 , 4 , 5 , 6 , 7 , 8 , 8 ] NEW_LINE def count ( n , whitedigits = [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ] ) : NEW_LINE INDENT n += 1 NEW_LINE c = 0 NEW_LINE d = 1 NEW_LINE while n > 0 : NEW_LINE INDENT digit = n % 10 NEW_LINE c *= whitedigits [ digit + 1 ] - whitedigits [ digit ] NEW_LINE c += whitedigits [ digit ] * d NEW_LINE d *= whitedigits [ 10 ] NEW_LINE n //= 10 NEW_LINE DEDENT return c NEW_LINE DEDENT A , B = map ( int , input ( ) . split ( ) ) NEW_LINE print ( ( B - count ( B , whitedigits ) ) - ( A - 1 - count ( A - 1 , whitedigits ) ) ) NEW_LINE

from itertools import product NEW_LINE a , b = input ( ) . split ( ) NEW_LINE def cnt ( c : str ) : NEW_LINE INDENT n = len ( c ) NEW_LINE dp = [ [ [ 0 ] * 2 for i in range ( 2 ) ] for j in range ( n + 1 ) ] NEW_LINE dp [ 0 ] [ 1 ] [ 0 ] = 1 NEW_LINE for i , j , k in product ( range ( n ) , range ( 2 ) , range ( 2 ) ) : NEW_LINE INDENT max_n = int ( c [ i ] ) if j else 9 NEW_LINE for n in range ( max_n + 1 ) : NEW_LINE INDENT dp [ i + 1 ] [ j and n == max_n ] [ k or n == 4 or n == 9 ] += dp [ i ] [ j ] [ k ] NEW_LINE DEDENT DEDENT res = 0 NEW_LINE for i in range ( 2 ) : NEW_LINE INDENT res += dp [ - 1 ] [ i ] [ 1 ] NEW_LINE DEDENT return res NEW_LINE DEDENT print ( cnt ( b ) - cnt ( str ( int ( a ) - 1 ) ) ) NEW_LINE

import copy NEW_LINE AB = input ( ) . split ( ) NEW_LINE Ans = [ 0 , 0 ] NEW_LINE AB [ 0 ] = str ( int ( AB [ 0 ] ) - 1 ) NEW_LINE for i in range ( 2 ) : NEW_LINE INDENT Dset = [ 2 , 2 , len ( AB [ i ] ) + 1 ] NEW_LINE D = 0 NEW_LINE for j in range ( 3 ) : NEW_LINE INDENT D = [ copy . deepcopy ( D ) for k in range ( Dset [ j ] ) ] NEW_LINE DEDENT D [ 0 ] [ 1 ] [ 0 ] = 1 NEW_LINE for j in range ( len ( AB [ i ] ) ) : NEW_LINE INDENT t = int ( AB [ i ] [ j ] ) NEW_LINE if t < 4 : a , b , c , d = ( t , 0 , 1 , 0 ) NEW_LINE elif t == 4 : a , b , c , d = ( 4 , 0 , 0 , 1 ) NEW_LINE elif t < 9 : a , b , c , d = ( t - 1 , 1 , 1 , 0 ) NEW_LINE else : a , b , c , d = ( 8 , 1 , 0 , 1 ) NEW_LINE D [ j + 1 ] [ 0 ] [ 0 ] = D [ j ] [ 0 ] [ 0 ] * 8 + D [ j ] [ 1 ] [ 0 ] * a NEW_LINE D [ j + 1 ] [ 0 ] [ 1 ] = D [ j ] [ 0 ] [ 0 ] * 2 + D [ j ] [ 0 ] [ 1 ] * 10 + D [ j ] [ 1 ] [ 0 ] * b + D [ j ] [ 1 ] [ 1 ] * t NEW_LINE D [ j + 1 ] [ 1 ] [ 0 ] = D [ j ] [ 1 ] [ 0 ] * c NEW_LINE D [ j + 1 ] [ 1 ] [ 1 ] = D [ j ] [ 1 ] [ 0 ] * d + D [ j ] [ 1 ] [ 1 ] NEW_LINE DEDENT Ans [ i ] = D [ - 1 ] [ 0 ] [ 1 ] + D [ - 1 ] [ 1 ] [ 1 ] NEW_LINE DEDENT print ( Ans [ 1 ] - Ans [ 0 ] ) NEW_LINE

import sys NEW_LINE sys . setrecursionlimit ( 10 ** 9 ) NEW_LINE input = sys . stdin . readline NEW_LINE OK = [ 0 , 1 , 2 , 3 , 5 , 6 , 7 , 8 ] NEW_LINE def cnt ( N ) : NEW_LINE INDENT L = len ( N ) NEW_LINE dp = [ [ 0 ] * 2 for _ in range ( L + 1 ) ] NEW_LINE N = " " . join ( list ( reversed ( [ c for c in N ] ) ) ) NEW_LINE dp [ 0 ] [ 1 ] = 1 NEW_LINE for dig in range ( L ) : NEW_LINE INDENT for less in range ( 2 ) : NEW_LINE INDENT for new in OK : NEW_LINE INDENT leq = new < int ( N [ dig ] ) or ( less == 1 and int ( N [ dig ] ) == new ) NEW_LINE dp [ dig + 1 ] [ leq ] += dp [ dig ] [ less ] NEW_LINE DEDENT DEDENT DEDENT return dp [ L ] [ 1 ] NEW_LINE DEDENT def solve ( ) : NEW_LINE INDENT A , B = input ( ) . split ( ) NEW_LINE noKinsi = cnt ( B ) - cnt ( str ( int ( A ) - 1 ) ) NEW_LINE ans = int ( B ) - int ( A ) - noKinsi + 1 NEW_LINE print ( ans ) NEW_LINE DEDENT solve ( ) NEW_LINE

from collections import defaultdict NEW_LINE import math NEW_LINE import bisect NEW_LINE import random NEW_LINE def LI ( ) : return list ( map ( int , input ( ) . split ( ) ) ) NEW_LINE def II ( ) : return int ( input ( ) ) NEW_LINE def LS ( ) : return input ( ) . split ( ) NEW_LINE def S ( ) : return input ( ) NEW_LINE def IIR ( n ) : return [ II ( ) for i in range ( n ) ] NEW_LINE def LIR ( n ) : return [ LI ( ) for i in range ( n ) ] NEW_LINE def SR ( n ) : return [ S ( ) for i in range ( n ) ] NEW_LINE mod = 1000000007 NEW_LINE a , b = LS ( ) NEW_LINE a = list ( map ( int , a ) ) NEW_LINE b = list ( map ( int , b ) ) NEW_LINE for i in range ( len ( b ) - len ( a ) ) : NEW_LINE INDENT a . insert ( 0 , 0 ) NEW_LINE DEDENT n = len ( b ) NEW_LINE dp = [ [ [ [ 0 for i in range ( 2 ) ] for j in range ( 2 ) ] for h in range ( 2 ) ] for k in range ( 20 ) ] NEW_LINE dp [ 0 ] [ 0 ] [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( n ) : NEW_LINE INDENT for j in range ( 2 ) : NEW_LINE INDENT for k in range ( 2 ) : NEW_LINE INDENT for h in range ( 2 ) : NEW_LINE INDENT x = 0 if j else a [ i ] NEW_LINE y = 9 if k else b [ i ] NEW_LINE for d in range ( x , y + 1 ) : NEW_LINE INDENT dp [ i + 1 ] [ j or d > a [ i ] ] [ k or d < b [ i ] ] [ h or d == 4 or d == 9 ] += dp [ i ] [ j ] [ k ] [ h ] NEW_LINE DEDENT DEDENT DEDENT DEDENT DEDENT ans = 0 NEW_LINE for j in range ( 2 ) : NEW_LINE INDENT for k in range ( 2 ) : NEW_LINE INDENT ans += dp [ n ] [ j ] [ k ] [ 1 ] NEW_LINE DEDENT DEDENT print ( ans ) NEW_LINE NEW_LINE