Harryxun/stf_run huggingface dataset:
import numpy as np
import math


N, K = list(map(int, input().split()))
tmp = list(map(int, input().split()))
# tmp = input().split()
# lamps = np.array(tmp, dtype=np.int64)
# init = lamps
# for i in range(K):
#     act = np.zeros((N, N),dtype=np.int64)
#     for i in range(N):
#         # if init[i] == 0:
#         #     continue
#         # d = math.floor(init[i] + 0.5)
#         dmin = i - int(init[i])
#         dmax = i + int(init[i])
#         if dmin < 0:
#             dmin = 0
#         if dmax > N-1:
#             dmax = N-1
#         act[i][dmin:dmax+1] = 1
#         act[i][i] = 0
#     s = np.sum(act, axis=0)
#     init = s + np.ones(N, dtype=np.int64)
# result = init.astype("int64")
# ans = list(map(str,result.tolist()))
# print(" ".join(ans))
print("3 3 4 4 3")

### FIXED CODE ###

name = str(input())
nickname = name[:3]

print(nickname)
N = int(input().split())
A = list(map(int,input().split()))
M = 1000
S = 0
for i in range(N-1):
  M+=S*A[i]
  S = 0
  if A[i+1]>=A[i]:
    tmp=M//A[i]
    M = tmp*A[i]
    S+=tmp
M+=S*A[i]
S = 0
print(M)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
M = 1000
S = 0
for i in range(N-1):
  M+=S*A[i]
  S = 0
  if A[i+1]>=A[i]:
    tmp=M//A[i]
    M -= tmp*A[i]
    S+=tmp
M+=S*A[-1]
S = 0
print(M)
s = list(input())
N = len(s)
for i in range(N-1):
  if s[i]=s[N-1-i] and s[i]=s[(N-1)/2-1-i] and s[(N+3)/2-1+i]=s[N-1-i]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

s = list(input())
n = (len(s)+1)//2
if s[:n-1] == s[len(s):n-1:-1] == s[n-2::-1]:
  print("Yes")
else:
  print("No")
def main():
    n = int(input())
    l = len(str(n))
    v = int(str(n)[0]) + 9 * (l - 1)
    if str(n)[1:] == '9' * (l - 1):
        print(ans)
    else:
        print(v-1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    l = len(str(n))
    v = int(str(n)[0]) + 9 * (l - 1)
    if str(n)[1:] == '9' * (l - 1):
        print(v)
    else:
        print(v-1)

if __name__ == '__main__':
    main()
mod=10**9+7
n=int(input())
l=list(map(int,input().split()))
ans=1
rgb=[0,0,0]
for i in range(n):
    for j in range(3):
        c=0
        if l[i]==rgb[j]:
            c+=1
    p=rbg.index(l[i])
    rgb[p]+=1
    ans*=c
    ans%=mod
print(ans)
    


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
ans=1
rgb=[0]*3
for i in range(n):
    f=0
    for j in range(3):
        if l[i]==rgb[j]:
            if f==0:
                rgb[j]+=1
            f+=1
    ans*=f
    ans%=mod
print(ans)
A = int(input())
B = int(input())
C = int(input())
X = int(input())
a = X//(500*A)
b = X//(100*B)
c = X//(50*C)
total = []
ans = 0
for l in range(a+1):
  d = 500*l
  total.append(d)
  for m in range(b+1):
    e = 100*m
    total.append(e)
    for n in range(c+1):
      f = 50*n
      total.append(f)
      if sum(total) ==X:
        ans += 1
print(ans)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            if 500*l+100*m+50*n ==X:
                ans += 1
print(ans)
n=int(input())
if a%2==0:
    a=n//2+1
else:
    a=n//2+2
def wa(k):
    kai=0
    while k>0:
        kai+=round(k%10)
        k=round((k-round(k%10))/10)
    return kai
ans=10000000000
for i in range(1,a+1):
    b=i
    c=n-i
    if ans>(wa(b)+wa(c)):
        ans=wa(b)+wa(c)
print(ans)

### FIXED CODE ###

n=int(input())
if n%2==0:
    a=n//2+1
else:
    a=n//2+2
def wa(k):
    kai=0
    while k>0:
        kai+=round(k%10)
        k=round((k-round(k%10))/10)
    return kai
ans=10000000000
for i in range(1,a+1):
    b=i
    c=n-i
    if ans>(wa(b)+wa(c)):
        ans=wa(b)+wa(c)
print(ans)
X=input()
if X>=400 and X<=599:
    print('8')
if X>=600 and X<=799:
    print('7')
if X>=800 and X<=999:
    print('6')
if X>=1000 and X<=1199:
    print('5')
if X>=1200 and X<=1399:
    print('4')
if X>=1400 and X<=1599:
    print('3')
if X>=1600 and X<=1799:
    print('2')
if X>=1800 and X<=1999:
    print('1')

### FIXED CODE ###

X=int(input())
if X>=400 and X<=599:
  print('8')
if X>=600 and X<=799:
  print('7')
if X>=800 and X<=999:
  print('6')
if X>=1000 and X<=1199:
  print('5')
if X>=1200 and X<=1399:
  print('4')
if X>=1400 and X<=1599:
  print('3')
if X>=1600 and X<=1799:
  print('2')
if X>=1800 and X<=1999:
  print('1')
#   AtCoder Beginner Contest 119
#   problem A: Still TBD

S = input() #-> yyyy/mm/dd

date = S.split('/')

year = int(date[0])
month = int(date[1])
day = int(date[2])

if month >= 5:
    print('TBD')
elif:
    print('Heisei')


### FIXED CODE ###

#   AtCoder Beginner Contest 119
#   problem A: Still TBD

S = input() #-> yyyy/mm/dd

date = S.split('/')

year = int(date[0])
month = int(date[1])
day = int(date[2])

if month >= 5:
    print('TBD')
else:
    print('Heisei')
n,m=map(int.input(),split())
if n == m :
    print("Yes")
else :
    print("No")

### FIXED CODE ###

n,m=map(int,input().split())
if n == m :
    print("Yes")
else :
    print("No")
N, Y = map(int, input().split())

def res(a, b, c, A, memo):
    if memo[a][b]:
        return None
    else:
        memo[a][b] = True
    if c < 0:
        return None
    if a+b+c == N:
        A.append([a, b, c])
        return None
    if a+b+c < N:
        return None
    res(a+1, b, c-10, A, memo)
    res(a, b+1, c-5, A, memo)
    return A

has_visit = [[False for i in range(Y//5000+2)] for j in range(Y//10000+2)]
A = res(0, 0, Y//1000, [], has_visit)
result = A[0] if A else [-1, -1, -1]
print(' '.join(map(str, result)))

### FIXED CODE ###

N, Y = map(int, input().split())

def main(Y):
    for i in range(Y//5000+1):
        b = i
        c = Y//1000 - 5*i
        if b//2 + b%2 + c <= N <= b + c:
            for j in range(b//2+1):
                if j + (b - 2*j) + c == N:
                    return (j, b - 2*j, c)
    return (-1, -1, -1)

result = main(Y)
print(' '.join(map(str, result)))
c=str()
print(c+1)

### FIXED CODE ###

c=str(input())
if c == 'a' :
    print("b")
elif c == 'b' :
    print("c")
elif c == 'c' :
    print("d")
elif c == 'd' :
    print("e")
elif c == 'e' :
    print ("f")
elif c == 'f' :
    print("g")
elif c == 'g' :
    print("h")
elif c == 'h' :
    print("i")
elif c == 'i' :
    print("j")
elif c == 'j' :
    print("k")
elif c == 'k' :
    print("l")
elif c == 'l' :
    print("m")
elif c == 'm' :
    print("n")
elif c == 'n' :
    print("o")
elif c == 'o' :
    print("p")
elif c == 'p' :
    print("q")
elif c == 'q' :
    print("r")
elif c == 'r' :
    print("s")
elif c == 's' :
    print("t")
elif c == 't' :
    print("u")
elif c == 'u' :
    print("v")
elif c == 'v' :
    print("w")
elif c == 'w' :
    print("x")
elif c == 'x' :
    print("y")
elif c == 'y' :
    print("z")
import sys
import math
input = sys.stdin.readline

n, m = [int(x) for x in input().rstrip().split()]
a = [int(x)//2 for x in input().rstrip().split()]
a = list(dict.fromkeys(a))

gcd = a[0]
product = 1
for x in a:
    gcd = math.gcd(gcd, x)
    product *= x

lcm = product // gcd

for x in a:
    if (lcm // x) % 2 == 0:
        print(0)
        sys.exit(0)

print((m // lcm + 1) // 2)


### FIXED CODE ###

import sys
import fractions
from functools import reduce
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = [int(x)//2 for x in input().strip().split()]
a = list(set(a))

def lcm_base(x, y): return x * y // fractions.gcd(x, y)
lcm = reduce(lcm_base, a, 1)


for x in a:
    if (lcm // x) % 2 == 0:
        print(0)
        break
else:
    print((m // lcm + 1) // 2)
N, M = [int(x) for x in input().split()]
A = [int(a) for a input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)

### FIXED CODE ###

N, M = [int(x) for x in input().split()]
A = [int(a) for a in input().split()]
tmp = N - sum(A)
if tmp >= 0:
    print(tmp)
else:
    print(-1)
n,a,b = map(int,input().split())
s = 'b'*a + 'r'*b
d = n//(a+b)
q = n % (a+b)

if q <= a:
  print(a*d+q)
else:
  print(a*d+a)



### FIXED CODE ###

n,a,b = map(int,input().split())

if a+b == 0:
  print(0)
  
else:  

  d = n//(a+b)
  q = n % (a+b)

  
  if q <= a:
    print(a*d+q)
  else:
    print(a*d+a)
m,k=map(int,input().split())
if 0<=k<2**m:
    if m==1 and k==1:
        print(-1)
    else:
        s=[i for i in range(2**m) if i!=k]
        print(*s,k,*s[::-1],k)
else:
    print(-1)

### FIXED CODE ###

m,k=map(int,input().split())
if 0<=k<2**m:
    if m==1:
        if k==1:print(-1)
        else:print(*[1,1,0,0])
    else:
        s=[str(i) for i in range(2**m) if i!=k]
        c=""
        for i in s:c+=i+" "
        c+=str(k)+" "
        for i in s[::-1]:c+=i+" "
        print(c+str(k))
else:
    print(-1)
import numpy as np
n = int(input())
p = list(map(int, input().split()))
count = 0
tof = True


for i in range(1, n+1):
    if p[i-1] <= np.min(p[:i]):
        count += 1

print(count)

### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
count = 0
m = [0] * n

memo = n
for i in range(n):
    if memo > p[i]:
        m[i] = p[i]
        memo = p[i]
    else:
        m[i] = memo

for i in range(1, n+1):
    if p[i-1] <= m[i-1]:
        count += 1

print(count)
import bisect
a=[]
def f(n,p):
    m=-1<<20
    x=bisect.bisect_left(a,n)
    if a[x]==n and x!=len(a):m=1
    if a[p]**2>n:return m
    if n%a[p]==0:m=f(n//a[p],p)+1
    return max(m,f(n,p+1))

for i in range(1,19):
    for j in range(1<<i):
        b=''
        for k in range(i):
            if (j//(1<<k))%2:b+='2'
            else:b+='8'
        a+=[int(b)]
a.sort()
n=int(input())
b=f(n,0)
if n==1 or b<0:b=-1
print(b)

### FIXED CODE ###

import bisect
import sys
sys.setrecursionlimit(10000)
a=[]
def f(a,bin,n):
    if bin>n:return
    if bin:a+=[bin]
    f(a,bin*10+2,n)
    f(a,bin*10+8,n)

def g(n,p):
    m=-1<<20
    x=bisect.bisect_left(a,n)
    if x!=len(a) and a[x]==n:m=1
    if a[p]**2>n:return m
    if n%a[p]==0:m=g(n//a[p],p)+1
    return max(m,g(n,p+1))

n=int(input())
if n&1:print(-1);exit()
f(a,0,n)
a=sorted(a)
b=g(n,0)
if b<0:b=-1
print(b)
S = input()
N = ["dream", "dreamer", "erase", "eraser"]
bool = True

while bool:
  if len(S) == 0:
    break
 
  bool = False
  for n in N:
    
    if S.endswith(n):
      L = S.rsplit(n,1)
      S = L[0]
      print(S)
      bool = True
      break
  

if bool:
  print("YES")
else:
  print("NO")
 

### FIXED CODE ###

S = input()
N = ["dream", "dreamer", "erase", "eraser"]
bool = True

while bool:
  if len(S) == 0:
    break
 
  bool = False
  for n in N:
    
    if S.endswith(n):
      L = S.rsplit(n,1)
      S = L[0]
      bool = True
      break
  

if bool:
  print("YES")
else:
  print("NO")
import numpy as np

def getInt():
  return map(int, input().split())

N, M, C = getInt()
B = list(getInt())
ans = 0
for i in range(N):
  A = list(getInt())
  if sum([a*b for (a,b) in (A,B)]) + C > 0:
    ans += 1
print(ans)
  

### FIXED CODE ###

H, W = map(int, input().split())
h, w = map(int, input().split())

res = (H-h)*(W-w)

print(res)
N = int(input())
An = [int(x) for x in input().split()]

L = [0,0]
for i in range(N):
    if i > 1:
        L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))

for k in range(N):
    Bn = [An[i] for i in range(N) if not i == k]
    Cn = [Bn.count(i) for i in range(N)]
    Dn = [Cn.count(i)*L[i] for i in range(N)] 
    
    print(sum(Dn))

### FIXED CODE ###

import collections as c

# 入力
N = int(input())
An = [int(x) for x in input().split()]
 
# 各数字の個数を求める
Cn = c.Counter(An)
 
# 全部の組み合わせ
s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))
x = input
print (x*x*x,"\n")


### FIXED CODE ###

x = input()
x = int(x)
print (x*x*x)
N,M = map(int,raw_input().split())

X = map(int,raw_input().split())

X.sort()
gap = []
for i in range(M-1):
    i = M-i-1
    gap.append(abs(X[i]-X[i-1]))

gap.sort()
gap.reverse()

gapsum = 0
counter = 0
if len(gap) > 0:
    while N-counter-1 > 0:
        gapsum += gap[counter]
        counter += 1


print abs(X[0]-X[-1])-gapsum

### FIXED CODE ###

N,M = map(int,raw_input().split())

X = map(int,raw_input().split())

X.sort()
gap = []
for i in range(M-1):
    i = M-i-1
    gap.append(abs(X[i]-X[i-1]))

gap.sort()
gap.reverse()

gapsum = 0
counter = 0
if len(gap) > 0:
    while N-counter-1 > 0 and counter < len(gap):
        gapsum += gap[counter]
        counter += 1

print abs(X[0]-X[-1])-gapsum
A, B, T = input().split()
return int((int(T)+0.5)//int(A)*int(B))


### FIXED CODE ###

a, b, t = map(int, input().split(' '))
print(int((t+0.5)//a*b))
n = int(input())
x = list(map(int,input().split()))
count = 1
if n >=2:
  for i in range(n-2):
    if min(x[0:i])>=x[i+1]:
      count+=1
print(count)

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
count = 1
m = x[0]

for i in range(1,n):
  if m >=x[i]:
    count+=1
    m = x[i]
  
print(count)
D = int(input())
C = list(map(int, input().split()))
S = [None] * D
for i in range(D):
    S[i] = list(map(int, input().split()))
lasts = [0] * 26
score = 0
for d in range(D):
    bs = 0
    ba = None
    for t in range(26):
        s = S[d][t]
        s -= sum(C[i] * (d+1-l) for i, l in enumerate(lasts) if i != t)
        if s > bs:
            bs = s
            ba = t
    score += bs
    lasts[ba] = d
    print(ba+1)

### FIXED CODE ###

D = int(input())
C = list(map(int, input().split()))
S = [None] * D
for i in range(D):
    S[i] = list(map(int, input().split()))
lasts = [0] * 26
score = 0
for d in range(D):
    bs = None
    ba = None
    for t in range(26):
        s = S[d][t]
        s -= sum(C[i] * (d+1-l) for i, l in enumerate(lasts) if i != t)
        if bs is None or s > bs:
            bs = s
            ba = t
    score += bs
    lasts[ba] = d
    print(ba+1)
a,b,c = map(int,input.split())
print(b*(c//a))

### FIXED CODE ###

a,b,c = map(int,input().split())
print(b*int(c/a))
import copy
import math
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
left, right = 0, max(a)
while (right - left) > 1:
    middle = (left + right) / 2
    if calc(middle, a):
        right = middle
    else:
        left = middle
print(math.ceil(middle))

def calc(x, aa):
    a = copy.deepcopy(aa)
    cnt = k
    while cnt > 0:
        for i in range(n):
            if (a[i] > x):
                cnt -= a[i] // x
                a[i] = x
            if cnt < 0:
                return False
        if cnt < 0:
            return False
        return True

### FIXED CODE ###

import copy
import math

def calc(x, aa):
    a = copy.deepcopy(aa)
    cnt = k
    while cnt > 0:
        for i in range(n):
            if (a[i] > x):
                cnt -= a[i] // x
                a[i] = x
            if cnt < 0:
                return False
        if cnt < 0:
            return False
        return True
    
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
left, right = 0, max(a)
if k == 0:
    print(right)
    exit()
    
while (right - left) > 1:
    middle = (left + right) / 2
    if calc(middle, a):
        right = middle
    else:
        left = middle        
for i in range(max(math.floor(left) - 10, 1), math.ceil(right) + 10):
    if calc(i, a):
        print(i)
        exit()
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a_str_list = input().split()

a_list = []

for item in a_str_list:
    a_list.append(int(item))

step = lcm_list(a_list)
start = lcm_list(a_list) // 2

if m - start < 0:
    print(0)
else:
    print(((m-start) // step)+1)


### FIXED CODE ###

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def two(val):
    ret = 0
    tmp = val
    while True:
        if tmp != 0 and tmp % 2 == 0:
            ret += 1
            tmp = tmp // 2
        else:
            break
    return ret


n, m = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = []

for item in a_list:
    b_list.append(item // 2)

cnt = -1

for item in b_list:
    ret = two(item)
    if cnt == -1:
        cnt = ret
    elif cnt != ret:
        print(0)
        exit()

val = b_list[0]

for item in b_list:
    val = lcm(item, val)

ret = m // val

tmp1 = ret // 2
tmp2 = ret % 2

print(tmp1 + tmp2)
n = int(input())
s = input()
t = input()
l = ""
for i in range(n):
    l += s[i]
    l += t[i]

print(l)


### FIXED CODE ###

n = int(input())
s = input().split()
l = ""
for i in range(n):
    l += s[0][i]
    l += s[1][i]

print(l)
n = int(input())
if(n%1000 == 0):
	print('0')
else:
	n_str = str(n)
    g = n_str[0]
    print((n+1)*1000-n)

### FIXED CODE ###

n = int(input())
for i in range(1000,10001,1000):
    if(i>=n):
        print(i-n)
        break
N, X = map(int, input().split())
L = list(map(int, input().split()))

D = [0]
for l in L:
  d = D[-1] + L
  if d <= X:
    D.append(d)
  else:
    break

print(len(D))

### FIXED CODE ###

N, X = map(int, input().split())
L = list(map(int, input().split()))

D = [0]
for l in L:
  d = D[-1] + l
  if d <= X:
    D.append(d)
  else:
    break

print(len(D))
print(int(input() ** 2)

### FIXED CODE ###

print(int(input()) ** 2)
st = input()
if st[0] == st[1] and st[0] == st[2] and st[0] == "R":
  print(3)
elif (st[0] == st[1] == "R") OR (st[1] == st[2] == "R"):
  print(2)
else:
  print(1)

### FIXED CODE ###

st = input()
if st[0] == st[1] and st[0] == st[2] and st[0] == "R":
  print(3)
elif (st[0] == st[1] and st[0] == "R") or (st[1] == st[2] and st[1] == "R"):
  print(2)
elif "R" in st:
  print(1)
else:
  print(0)
n, k = map(int, input().split())
MOD = 10**9+7
red_num = n - k
blue_num = k

def prepare(n, MOD):
    """
    nCr mod MOD
    n!/r!*(n-r)! → facts(n)*invs(r)*invs(n-r)
    :param n:
    :param MOD:
    :return:
    """
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    _invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs

for i in range(1, k+1):
    facts1, inves1 = prepare(red_num+1, MOD)
    facts2, inves2 = prepare(k-1, MOD)
    a = facts1[red_num+1]*inves1[i]*inves1[red_num+1-i]%MOD
    b = facts2[k-1]*inves2[i-1]*inves2[k-i]%MOD

    print(a*b%MOD)
    



### FIXED CODE ###

n, k = map(int, input().split())
MOD = 10**9+7
red_num = n - k
blue_num = k

def prepare(n, MOD):
    """
    nCr mod MOD
    n!/r!/(n-r)! → facts(n)*invs(r)*invs(n-r)
    :param n:
    :param MOD:
    :return:
    """
    facts = [1]*(n+1)
    for i in range(1, n+1):
        facts[i] = facts[i-1]*i%MOD
    invs = [1]*(n+1)
    _invs = [1]*(n+1)
    invs[n] = pow(facts[n], MOD-2, MOD)
    for i in range(0, n)[::-1]:
        invs[i] = invs[i+1] * (i+1) % MOD
    return facts, invs

for i in range(1, k+1):
    if red_num+1 < i:
        print(0)
        continue
    facts1, inves1 = prepare(red_num+1, MOD)
    facts2, inves2 = prepare(k-1, MOD)
    a = facts1[red_num+1]*inves1[i]*inves1[red_num+1-i]%MOD
    b = facts2[k-1]*inves2[i-1]*inves2[k-i]%MOD

    print(a*b%MOD)
import sys
import math
x, y = map(int, input().split())


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


w = (x + y) / 3
a = (- x + 2*y) // 3

if w.is_integer():
    w = int(w)
else:
    print(0)
    sys.exit()

ans = combinations_count(w, a) % (10**9 + 7)
print(ans)


### FIXED CODE ###

import sys
x, y = map(int, input().split())

if (x + y) % 3 != 0:
    print(0)
    sys.exit()

mod = 10**9 + 7
n = (x+y) // 3
a = min(
    (2 * x - y) // 3, (2 * y - x) // 3
)


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


N = max(x, y)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

ans = cmb(n, a, mod)
print(ans)
from  collections import deque
 
N, M, K =map(int, input().split())
A  = list(map(int, input().split()))
B  = list(map(int, input().split()))
 
A = deque(A)
B = deque(B)
 
def check(n, A_, B_):
  if len(A_) >= n and len(B_) >= n:
    if A_[n-1] > B_[n-1]:
      return 'B'
    elif A_[n-1] < B_[n-1]:
      return 'A'
    else:
      check(n+1, A_, B_)
  elif len(A_) < n and len(B_) <  n:
    return 'A'
  elif len(A_) < n:
    return 'B'
  else:
    return 'A'
  
#print(check(1, A, B))


ans = 0
while True:
  if A:
    a = A[0]
  else:
    a = 10**9+7
  if B:
    b = B[0]
  else:
    b = 10**9+7
  if min(a, b) > K:
    break
  elif len(A) == 0 and len(B) == 0:
    break
  else:
    j =check(1, A, B)
    if j ==  'A':
      K -= A.popleft()
      ans += 1
    else:
      K -= B.popleft()
      ans += 1
      
print(ans)

### FIXED CODE ###

from bisect import *
 
N, M, K =map(int, input().split())
A  = list(map(int, input().split()))
B  = list(map(int, input().split()))

A_= [0]
for a in A:
  A_.append(A_[-1] + a)
#print(A_)

b_sum = 0
ans = 0
b_cnt = 0

while True:
  if b_sum > K:
    break
  else:
    k = K - b_sum
    ans = max(bisect_right(A_, k)-1 + b_cnt, ans)
    #print(bisect_right(A_, k)-1 + b_cnt, ans,  b_cnt)
    if b_cnt == M:
      break
    b_sum += B[b_cnt]
    b_cnt += 1
    

print(ans)
if set(S) !== 2:
  print(No)

### FIXED CODE ###

S = input()

if len(set(S)) == 2:
  print('Yes')
else:
  print('No')
a,b,c = map(int, input().split())
if a+b>=c>=a:
  print(YES)
else
 print(NO)

### FIXED CODE ###

a,b,c = map(int, input().split())
if a+b>=c>=a:
  print("YES")
else:
 print("NO")
import sys
sys.setrecursionlimit(1000000000)

def answer():
    input = sys.stdin.readline
    M = int(input())

    part = ''
    for i in range(M):
        d, c = input().split()
        part += d * int(c)

    _round = 0
    while len(part) > 1:
        _round += 1
        # 和10以上を探索
        mt10 = 0
        for i in range(1, len(part)):
            s1 = part[-i]
            s2 = part[-i-1]
            if int(s1) + int(s2) >= 10:
                mt10 = - i - 1
                break

        if mt10 == 0:
            s1 = part[0]
            s2 = part[1]
            s3 = part[2:]
            part = str(int(s1) + int(s2)) + s3
        else:
            s1 = part[:mt10]
            s2 = part[mt10]
            s3 = part[mt10+1]
            s4 = ''
            if mt10 < -2:
                s4 = part[mt10+2:]
            part = s1 + str(int(s2)+int(s3)) + s4

    print(_round)


if __name__ == '__main__':
    answer()


### FIXED CODE ###

import sys

def answer():
    input = sys.stdin.readline
    M = int(input())

    Ds = [0] * M
    Cs = [0] * M
    total = 0

    for i in range(M):
        c, d = map(int, input().split())
        Cs[i] = c
        Ds[i] = d
        total += d * c

    digits = sum(Ds)

    ans = (digits-1) + (total-1) // 9

    print(ans)


if __name__ == '__main__':
    answer()
#!/usr/bin/env python

def func():
    n,m = [int(i) for i in input().split(" ")]
    dic = {}
    same = 0
    a = [0] * n

    for i in range(m):
        tmp = [int(i) for i in input().split(" ")]

        if tmp[0] not in dic.keys():
            dic[tmp[0]] = tmp[1]
        else:
            if dic[tmp[0]] != tmp[1]:
                print("No")
                return

    for key in dic.keys():
        a[key] = dic[key]

    if a[0] == 0:
        print("No")
        return
        
    for i in a:
        print(i, end = "")

    print("")

if __name__ == "__main__":
    func()

### FIXED CODE ###

#!/usr/bin/env python

n, m = input().split(" ")
n = int(n)
m = int(m)
s_len = []
c_len = []
dig = 10**(n-1)

for i in range(m):
    tmp = input().split(" ")
    s_len.append(int(tmp[0]))
    c_len.append(int(tmp[1]))

for i in range(0, dig*10):
    flag = False
    if len(str(i)) < n:
        continue
    for j,s in enumerate(s_len):
        if str(i)[s-1] != str(c_len[j]) and flag == False:
            flag = True
            break
    if flag==False:
        print(i)
        exit()

print("-1")