Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python

A = [input() for i in range(5)]
min = 9
for a in A:
    if int(a[-1]) <= min and int(a[-1]) != 0:
        min = int(a[-1])
        min_dish = a
sum = int(min_dish)
A.remove(min_dish)
for a in A:
    if a[-1] == '0':
        sum += int(a)
    else:
        sum += int(a) + int(10) - int(a[-1])
print(int(sum))

### FIXED CODE ###

#!/usr/bin/env python

A = [input() for i in range(5)]
m = 9
flag = True
for a in A:
    if int(a[-1]) == 0:
        pass
    elif int(a[-1]) <= m:
        flag = False
        m = int(a[-1])
        min_dish = a
B = [int(i) for i in A]
if flag:
    min_dish = str(min(B))
sum = int(min_dish)
A.remove(min_dish)
for a in A:
    if int(a[-1]) == 0:
        sum += int(a)
    else:
        sum += int(a) + int(10) - int(a[-1])
print(int(sum))
import numpy as np

def ForbiddenList():

    NumA = list(map(int,input().split()))

    NumB = list(map(int,input().split()))

    result = list(range(min(NumB)-1, max(NumB)+1, 1))

    for data in NumB:
        result.remove(data)

    idx = np.abs(np.asarray(result) - NumA[0]).argmin()

    print(result[idx])

if __name__ == '__main__':
    ForbiddenList()

### FIXED CODE ###

import numpy as np

def ForbiddenList():

    NumA = list(map(int,input().split()))

    NumB = list(map(int,input().split()))

    if len(NumB) != 0:
        result = list(range(min(NumB)-1, max(NumB)+2, 1))

        for data in NumB:
            result.remove(data)

        idx = np.abs(np.asarray(result) - NumA[0]).argmin()

        print(result[idx])

    else:
        print(NumA[0])
    

if __name__ == '__main__':
    ForbiddenList()
n = int(input())
s = str(input()).split()
alpha_lst = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split()

tmp = [alpha_lst[(alpha_lst.index(i)+n)%26] for i in s]

print(''.join(tmp))

### FIXED CODE ###

n = int(input())
s = [i for i in str(input())]
alpha_lst = [i for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']

tmp = [alpha_lst[(int(alpha_lst.index(i))+n)%26] for i in s]
#tmp = [alpha_lst.index(i) for i in s]
print(''.join(tmp))
n,a=open(0);for i in range(int(n)):print(a.count(str(i+1)))

### FIXED CODE ###

n,*l=map(int,open(0).read().split());a=[0]*n
for i in l:a[i-1]+=1
print(*a)
N = [int(i) for i in input().split]
A = [int(i) for i in input().split]
if all([i%2==1 for i in A]):
    print('APPROVED')
else:
    even = [i for i in A if i%2==0]
    even = [0 if i%3==0 or i%5==0 else 1 for i in even]
    if max(even)==1:
        print('DENIED')
    else:
        print('APPROVED')

### FIXED CODE ###

N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if all([i%2==1 for i in A]):
    print('APPROVED')
else:
    even = [i for i in A if i%2==0]
    even = [0 if i%3==0 or i%5==0 else 1 for i in even]
    if max(even)==1:
        print('DENIED')
    else:
        print('APPROVED')
a = map(int, input().split())
X, Y = a[0], a[1]
print(X + int(Y // 2))

### FIXED CODE ###

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

print(X + Y // 2)
A = input()
B = input()
for i in range(len(A)):
　　if(A == B):
　　　　print("Yes")
　　　　exit()
　　A = (A+A[0])[1:]
print("No")


### FIXED CODE ###

A = input()
B = input()
for i in range(len(A)):
    if A == B:
        print("Yes")
        exit()
    A = (A+A[0])[1:]
print("No")
X = int(input())
a = 0
while True:
    c  = (X -a**5)**0.2
    b = int(c)
    if c - b < 0.01:
        print(a,-b)
        break
    a += 1

### FIXED CODE ###

X = int(input())
a = 0
while True:
    a5 = a**5
    d  = X-a5
    if d >= 0:
        c  = d**0.2
        b1 = int(c)
        b2 = b1+1
        if a5 + b1**5 == X:
            print(a,-b1)
            break
        if a5 + b2**5 == X:
            print(a,-b2)
            break
    else:
        c = ((-d)**0.2)
        b1 = int(c)
        b2 = b1+1
        if a5 - b1**5 == X:
            print(a,b1)
            break
        if a5 - b2**5 == X:
            print(a,b2)
            break
    a += 1
term = int(input())
sum = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        sum += i
print(sum)

### FIXED CODE ###

N = int(input())
sum=0
for i in range(1, N+1):
    if i%3!=0 and i%5!=0:
        sum += i
print(sum)
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(0, n+1, 2):
    if a[i]%2:
        count += 1
print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
print(sum([i % 2 == 1 for i in a[::2]]))
n=int(input())
blue=[]
for i in range(n):
    blue.append(input())
m=int(input())
red=[]
for i in range(m):
    red.append(input())
max=0
for i in blue:
    b=blue.count(i)
    r=red.count(i)
    max=max(b-r,max)
print(max)

### FIXED CODE ###

n=int(input())
blue=[]
for i in range(n):
    blue.append(input())
m=int(input())
red=[]
for i in range(m):
    red.append(input())
max=0
for i in blue:
    b=blue.count(i)
    r=red.count(i)
    if b-r>max:max=b-r
print(max)
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
k = 0
f
for i in range(n):
  k += a[i]
  if k >= a//2:
    f = i
    break
print(2*k - s)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = sum(a)
k = 0
f = 0
for i in range(n):
  k += a[i]
  if k >= s//2:
    f = i
    break
k = max(k, s - k)
k2 = k - a[f]
k2 = max(k2, s - k2)
print(min(2*k - s, 2*k2 - s))
from decimal import *

getcontext().prec = 20
a,b,c = map(int,input().split())
a = int(Decimal(a))
b = int(Decimal(b))
c = int(Decimal(c))
if a*b < 1/4 * (c-a-b)**2:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k-1])
x,n,*a=map(int,open(0).read().split())
b=[1]*101
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)

### FIXED CODE ###

x,n,*a=map(int,open(0).read().split())
b=[1]*103
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)
A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(len(S)):
        if i == A:
            if S[i] == "-":
                continue
            else:
                print("No")
                exit()
        else:
            if S[i] in C:
                continue
            else:
                print("No")
                exit()
    print("Yes")
resolve()

### FIXED CODE ###

def resolve():
    A, B = map(int, input().split())
    S = input()
    C = "1234567890"
    for i in range(A):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    if S[A] != "-":
        print("No")
        exit()
    for i in range(A+1, len(S)):
        if S[i] in C:
            continue
        else:
            print("No")
            exit()
    print("Yes")
resolve()
def kaijou(n):
	res=1
	for i in xrange(1,x+1):
		res*=i
	return res

def comb(a,b):
	if(a<b or b<0):return 0
	if(b==0):return 1
	return kaijou(a)/kaijou(b)/kaijou(a-b)

a,b,c=map(int,raw_input().split())
c-=a*b
print comb(c+a-1,c)

### FIXED CODE ###

def kaijou(n):
	res=1
	for i in xrange(1,n+1):
		res*=i
	return res

def comb(a,b):
	if(a<b or b<0):return 0
	if(b==0):return 1
	return kaijou(a)/kaijou(b)/kaijou(a-b)

a,b,c=map(int,raw_input().split())
c-=a*b
print comb(c+a-1,c)
while True:
      x=input().split()
      a=int(x[0])
      op=x[1]
      b=int(x[2])
      if op =="+":
        print(a+b)
      elif op=="-":
          print(a-b)
      elif op=="*":
          print(a*b)
      elif op=="/":
          print(a/b)
      else:
         break


### FIXED CODE ###

while True:
    x=input().split(" ")
    a=int(x[0])
    op=x[1]
    b=int(x[2])
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "?":
        break
import math  # fractions

n = int(input())
a = list(map(int, input().split()))
ans = 0

l_gcd = [0]
for i in range(n):
    l_gcd.append(math.gcd(l_gcd[-1], a[i]))
# print(l_gcd)

r_gcd = [0]
for i in range(n):
    r_gcd.append(math.gcd(r_gcd[-1], a[-(i+1)]))
r_gcd.reverse()
# print(r_gcd)

for i in range(n):
    ans = max(ans, math.gcd(l_gcd[i], r_gcd[i+1]))
print(ans)

### FIXED CODE ###

import fractions

n = int(input())
a = list(map(int, input().split()))
ans = 0

l_gcd = [0]
for i in range(n):
    l_gcd.append(fractions.gcd(l_gcd[-1], a[i]))
# print(l_gcd)

r_gcd = [0]
for i in range(n):
    r_gcd.append(fractions.gcd(r_gcd[-1], a[-(i+1)]))
r_gcd.reverse()
# print(r_gcd)

for i in range(n):
    ans = max(ans, fractions.gcd(l_gcd[i], r_gcd[i+1]))
print(ans)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if a < b :
    if b < c :
        if c < d:
            if d < e:
                if e < k:
                    ab = b-a
                    ac = c-a
                    ad = d-a
                    ae = e-a
                    bc = c-b
                    bd = d-b
                    be = e-b
                    cd = d-c
                    ce = e-c
                    de = e-d

                    lista = [ab,ac,ad,ae,bc,bd,be,cd,ce,de]
                    x = max(lista)

if x <= 15:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

antenas = []
k = 0
for i in range(6):
    if i == 5:
        k = int(input())
    else:
        antenas.append(int(input()))
antenas.sort()
dist = antenas[-1] - antenas[0]
if dist > k:
    print(":(")
else:
    print("Yay!")
r = int(input())
g = int(input())
pri

### FIXED CODE ###

r = int(input())
g = int(input())
print(2*g-r)
dataset = []
while True:
    try:
        dataset.append(input())
    except EOFError:
        break

for item in dataset:
    a, b, c, d, e, f = [int(i) for i in item.split()]
    e = e * (a/d)
    f = f * (a/d)

    y = (c - f)/(b-e)
    x = (c - b*y) / a 

    print("{:.3f} {:.3f}".format(x, y))

### FIXED CODE ###

import sys
dataset = sys.stdin.readlines()

for item in dataset:
    a, b, c, d, e, f = list(map(int, item.split()))

    y = (c * d - f * a)/(b * d - e * a)
    x = (c * e - b * f) / (a * e - b * d)
    if x == 0:
        x = 0
    print("{:.3f} {:.3f}".format(x, y))
def decoder(str_int):
    s_=''
    for a in str_int:
        s_ = s_+(alpbet[a])
    return s_

def encoder(s):
    return [alpbet.index(a) for a in s]

s = raw_input()
K = input()

alpbet = 'abcdefghijklmnopqrstuvwxyz'
encoder = lambda s: [alpbet.index(a) for a in s]
inc_count = K
str_int = encoder(s)
for i in range(len(str_int)):
    #末尾文字でない
    if i != len(str_int)-1:
        #b~zの間でかつデクリメントできる
        if str_int[i] > 0:
            #aになるまで必要なインクリメント回数
            cost = 26 - str_int[i]
            if inc_count > cost:
                inc_count -= cost
                str_int[i] = 0
    else:
        str_int[i] = (str_int[i] + inc_count) % 26
        
print decoder(str_int)

### FIXED CODE ###

s = raw_input()
s = s[:4]+" "+s[4:]
print s
N,K = map(int,input().split())

if N%K==0:
    print(0)
else:
    x = abs(N-K)
    for i in range(N/K):
        x = min(x,abs(x-K))
    print(x)    

### FIXED CODE ###

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

if N>=K:
    x = N%K
    print(min(x,abs(K-x)))
else:
    print(min(N,abs(K-N)))
H,W=(int(i) for i in input().split(' '))
a=[]
log=[]
n=0
for h in range(h):
  a.append([int(i) for i in input().split(' ')])
for h in range(H)[::2]:
  for w in range(W-1):
    if a[h][w]%2!=0:
      a[h][w]-=1
      a[h][w+1]+=1
      log.append([h+1,w+1,h+1,w+2])
      n+=1
  if h+1 != H:
    if a[h][W-1]%2!=0:
      a[h][W-1]-=1
      a[h+1][W-1]+=1
      log.append([h+1,W,h+2,W])
      n+=1
  else:
    break
  for w in range(1,W)[::-1]:
    if a[h+1][w]%2!=0:
      a[h+1][w]-=1
      a[h+1][w-1]+=1
      log.append([h+2,w+1,h+2,w])
      n+=1
  if h+2 != H:
    if a[h+1][0]%2!=0:
      a[h+1][0]-=1
      a[h+2][0]+=1
      log.append([1,h+2,1,h+3])
      n+=1
print(n)
for data in log:
  print(data.join(' '))
  
      

### FIXED CODE ###

H,W=(int(i) for i in input().split(' '))
a=[]
log=[]
n=0
for h in range(H):
  a.append([int(i) for i in input().split(' ')])
for h in range(H)[::2]:
  for w in range(W-1):
    if a[h][w]%2!=0:
      a[h][w]-=1
      a[h][w+1]+=1
      log.append([h+1,w+1,h+1,w+2])
      n+=1
  if h+1 != H:
    if a[h][W-1]%2!=0:
      a[h][W-1]-=1
      a[h+1][W-1]+=1
      log.append([h+1,W,h+2,W])
      n+=1
  else:
    break
  for w in range(1,W)[::-1]:
    if a[h+1][w]%2!=0:
      a[h+1][w]-=1
      a[h+1][w-1]+=1
      log.append([h+2,w+1,h+2,w])
      n+=1
  if h+2 != H:
    if a[h+1][0]%2!=0:
      a[h+1][0]-=1
      a[h+2][0]+=1
      log.append([h+2,1,h+3,1])
      n+=1
print(n)
for data in log:
  print('{0[0]} {0[1]} {0[2]} {0[3]}'.format(data))
cooking_times = [int(input()) for i in range(5)]
fractional_times = []
result = 0

for time in cooking_times:
    if time % 10 == 0:
        result += time
    else:
        result += time - time % 10
        fractional_times.append(time % 10)

result += (len(fractional_times) - 1) * 10
result += min(fractional_times)

print(result)

### FIXED CODE ###

cooking_times = [int(input()) for i in range(5)]
fractional_times = []
result = 0

for time in cooking_times:
    if time % 10 == 0:
        result += time
    else:
        result += time - time % 10
        fractional_times.append(time % 10)

if fractional_times != []:
    result += (len(fractional_times) - 1) * 10
    result += min(fractional_times)

print(result)
from bisect import insort

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

for i in range(m):
    b,c = map(int,input().split())

    for j in range(b+1):        
        if a[j] < c:
            a.remove(a[j])
            insort(a,c)

sum = 0
for v in a:
    sum += v

print(sum)

### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

d = []

bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append([b,c])

bc = sorted(bc,key=lambda x:x[1],reverse=True)

for elm in bc:
    for i in range(elm[0]):
        d.append(elm[1])
        if len(d) >= n:
            break
    if len(d) >= n:
        break

d.sort()
d.reverse()

#print(a)
#print(d)

sum = 0
ln = len(d)
for i in range(n):
    if i < ln:
        if a[i] < d[i]:
            sum += d[i]
        else:
            sum += a[i]
    else:
        sum += a[i]

print(sum)
from scipy.special import comb

x, y = map(int, input().split())
mod = 10 * 9 + 7
m = (x * 2 - y) / 3
n = x - 2 * m
if (x + y) % 3:
    ans = 0
else:
    ans = comb(m + n, n, exact=True) % mod

print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline

MOD = 1000000007

def comb_mod(n, r, mod):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fac.append(fac[-1] * i % mod)
            inv.append(-inv[mod % i] * (mod // i) % mod)
            finv.append((finv[-1] * inv[-1]) % mod)

        return int(fac[n] * finv[r] * finv[n - r] % mod)

x, y = map(int, input().split())
m = int((x * 2 - y) / 3)
n = int(x - 2 * m)

if (x + y) % 3 != 0:
    print(0)
else:
    print(comb_mod(n + m, n, MOD))
# -*- coding: utf-8 -*-
a = int(input())
b = int(input().split(""))
list(b)
count = []
for i in range(a):
  count[i] = 0
  while b[i] % 2 == 1:
    b[i] = b[i] / 2
    count[i] += 1
print(min(count))

### FIXED CODE ###

# -*- coding: utf-8 -*-
n = int(input())
a = list(map(int, input().split()))
count = []
for i in range(n):
    count.append(0)
    while a[i] % 2 == 0:
        a[i] = a[i] / 2
        count[i] += 1
print(min(count))
import math, cmath
 
def koch(v1, v2, n):
    if n == 0:
        return [v1, v2]
     
    rad60 = math.pi/3
    u1 = (v2 - v1)/3
    u2 = cmath.rect(abs(u1), cmath.phase(u1)+rad60)
    q1 = v1 + u1
    q2 = q1 + u2
    q3 = q1 + u1
    if n == 1:
        return [v1,q1,q2,q3,v2]
    else:
        x1 = koch(v1,q1,n-1)[:-1]
        x2 = koch(q1,q2,n-1)[:-1]
        x3 = koch(q2,q3,n-1)[:-1]
        x4 = koch(q3,v2,n-1)
        x = x1 + x2 + x3 + x4
    return x
 
n = int(raw_input())
v1 = complex(0,0)
v2 = complex(100,0)
 
for e in koch(p1,p2,n):
    print e.real,e.imag

### FIXED CODE ###

import math, cmath
 
def koch(v1, v2, n):
    if n == 0:
        return [v1, v2]
     
    rad60 = math.pi/3
    u1 = (v2 - v1)/3
    u2 = cmath.rect(abs(u1), cmath.phase(u1)+rad60)
    q1 = v1 + u1
    q2 = q1 + u2
    q3 = q1 + u1
    if n == 1:
        return [v1,q1,q2,q3,v2]
    else:
        x1 = koch(v1,q1,n-1)[:-1]
        x2 = koch(q1,q2,n-1)[:-1]
        x3 = koch(q2,q3,n-1)[:-1]
        x4 = koch(q3,v2,n-1)
        x = x1 + x2 + x3 + x4
    return x
 
n = int(raw_input())
v1 = complex(0,0)
v2 = complex(100,0)
 
for e in koch(v1,v2,n):
    print e.real,e.imag
import sys

sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

g=[[] for i in range(n)]
for i in range(m):
  v1,v2=map(int,input().split())
  v1-=1;v2-=1
  g[v1].append(v2)

dp=[-1]*n  
  
def dfs(i):
  temp=0
  for nv in g[i]:
    if dp(nv)!=-1:
      temp=max(temp, dp[nv])
    else:  
    	temp=max(temp,dfs(nv)+1)
    dp[i]=temp
  return temp  
    
res=0
for i in range(n):
  res=max(res,dfs(i))
print(res)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

g=[[] for i in range(n)]
for i in range(m):
  v1,v2=map(int,input().split())
  v1-=1;v2-=1
  g[v1].append(v2)

dp=[-1]*n  
  
def dfs(i):
  if dp[i]!=-1:
    return dp[i]
  temp=0
  for nv in g[i]:
    temp=max(temp,dfs(nv)+1)
  dp[i]=temp  
  return temp  
    
res=0
for i in range(n):
  res=max(res,dfs(i))
print(res)
a,b = map(int(input()).split())
print((a-1)*(b-1))


### FIXED CODE ###

a,b = map(int,input().split())
print((a-1)*(b-1))
# フェルマーの小定理
K = int(input())
S = input()

m = 1000000007

l = len(S)
result = 0

a = pow(26, K, m)
inv26 = pow(26, -1K, m)
b = 1
c = 1
d = 1
for i in range(K + 1):
    # result += pow(26, K - i, m) * mcomb(len(S) - 1 + i, i) * pow(25, i, m)
    result += a * (b * pow(c, -1, m)) * d
    result %= m
    a *= inv26
    a %= m
    b *= l + i
    b %= m
    c *= i + 1
    c %= m
    d *= 25
    d %= m
print(result)


### FIXED CODE ###

# フェルマーの小定理
K = int(input())
S = input()

m = 1000000007


def make_factorial_table(n):
    result = [0] * (n + 1)
    result[0] = 1
    for i in range(1, n + 1):
        result[i] = result[i - 1] * i % m
    return result


def mcomb(n, k):
    if n == 0 and k == 0:
        return 1
    if n < k or k < 0:
        return 0
    return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m


fac = make_factorial_table(len(S) + K)

result = 0
for i in range(K + 1):
    result += pow(26, i, m) * mcomb(len(S) - 1 + K - i, len(S) - 1) * pow(25, K - i, m)
    result %= m
print(result)
N=int(input())
sys.setrecursionlimit(1000000000)

ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
from functools import lru_cache
@lru_cache(maxsize=None)
def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
N=int(input())
ABC=[]
for _ in range(N):
    ABC.append(list(map(int,input().split())))
from functools import lru_cache
@lru_cache(maxsize=None)
def dynam(n):
    if n>1:
        a=max(dynam(n-1)[1]+ABC[n-1][0],
              dynam(n-1)[2]+ABC[n-1][0])
        b=max(dynam(n-1)[0]+ABC[n-1][1],
              dynam(n-1)[2]+ABC[n-1][1])
        c=max(dynam(n-1)[0]+ABC[n-1][2],
              dynam(n-1)[1]+ABC[n-1][2])
        return (a,b,c)
    return tuple(ABC[0])
print(max(dynam(N)))
ef binarySearch(S,t):
    if len(S) == 1:
        return S[0] == t
    m = len(S)//2
    if S[m] == t:
        return True
    if S[m] > t:
        return binarySearch(S[:m],t)
    if len(S) > 2:
        return binarySearch(S[m+1:],t)
    return False

if __name__=='__main__':
    n=int(input())
    S=list(map(int,input().split()))
    q=int(input())
    T=list(map(int,input().split()))
    cnt = 0
    for t in T: cnt += binarySearch(S,t)
    print(cnt)

### FIXED CODE ###

def binarySearch(A, key):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right) // 2
        if A[mid] == key:
            return mid
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return -1

if __name__=='__main__':
    n=int(input())
    S=list(map(int,input().split()))
    q=int(input())
    T=list(map(int,input().split()))
    cnt = 0
    print(sum(map(lambda t: binarySearch(S,t) >= 0, T)))
s = input()

if s[3] == s[4] and s[5] == s[6]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = list(input())

if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
# 初期入力
import sys
from collections import defaultdict
import numpy as np
input = sys.stdin.readline  #文字列では使わない
H,W,M = map(int, input().split())
bomb =np.zeros(H+1,W+1)
posision =defaultdict(int)

for i in range(M):
    h,w = map(int, input().split())
    bomb[h,:] +=1
    bomb[:,w] +=1
    posision[(h,w)] =1

index =np.unravel_index(np.argmax(bomb), bomb.shape)
bom_max =np.max(bomb)
ans =0
if posision[index] ==1:
    ans =bom_max -1
else:
    ans =bom_max
print(ans)


### FIXED CODE ###

import sys


H, W, M = map(int, input().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in sys.stdin.readlines()]
X = [0] * H  # X:各行の爆破対象の個数
Y = [0] * W  # Y:各列の爆破対象の個数
for h, w in bomb:
    X[h] += 1
    Y[w] += 1
maxX = max(X)
maxY = max(Y)

R = [h for h, x in enumerate(X) if x == maxX]  # R:爆破対象の数が最大となる行の番号
C = [w for w, y in enumerate(Y) if y == maxY]  # C:爆破対象の数が最大となる列の番号

bomb = set(bomb)
for r in R:
    for c in C:
        # (r, c)に爆破対象が存在しないとき, maxX + maxY が答えとなることが確定するため, 
        # 即座に探索を終了する.
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)
import sys
import math
A, B = map(int, input().split())
if A == B:
  print (A)
  sys.exit()

def xor(a, b):
  r = ""
  for i in range(len(a)):
    if a[i] == "0" and b[i] == "0" or a[i] == "1" and b[i] == "1":
      r += "0"
    else:
      r += "1"
  return r

S = "0" * 40
def xorn(S, n):
  m = int(math.log2(n))
  b = n - 2 ** m
#  print (S[0:-m-1],1,S[-m-1:-1],m,b)
  S = S[0:-m-1] + "1" + S[-m-1:-1]
  if b == 0:
    return S
  return xorn(S, b)

print (int("0b" + xor(xorn(S, A-1), xorn(S, B)), 0))

### FIXED CODE ###

import sys
import math
A, B = map(int, input().split())

def nXor(n):
  if n % 2 == 0:
    if (n//2) % 2 == 0:
      return 0 ^ n
    else:
      return 1 ^ n
  else:
    if ((n+1)//2) % 2 == 0:
      return 0
    else:
      return 1
n = 0
for i in range(9):
  n = n^i
print (nXor(A-1) ^ nXor(B))
max_counter = 0

def check(limit, a, b, i, j, counter):
    global max_counter

    if len(a) > i:
        if limit - a[i] >= 0:

            check(limit - a[i], a, b, i + 1, j, counter + 1)

    if len(b) > j:
        if limit - b[j] >= 0:

            check(limit - b[j], a, b, i, j + 1, counter + 1)

    if counter > max_counter:
        max_counter = counter

    return

def main():
    global max_counter
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    check(k, a, b, 0, 0, 0)

    print(max_counter)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    a_sum = [0]
    b_sum = [0] 

    max_counter = 0

    j = m

    for i in range(n):
        a_sum.append(a_sum[i] + a[i])

    for i in range(m):
        b_sum.append(b_sum[i] + b[i])

    for i in range(n + 1):
        if a_sum[i] > k:
            break

        while k < a_sum[i] + b_sum[j]:
            j -= 1
        
        max_counter = max(max_counter, i + j)

    print(max_counter)

if __name__ == '__main__':
    main()