Harryxun/stf_run huggingface dataset:
N, K = raw_input().split()
D = raw_input().split()
candi = [str(i) for i in xrange(10)]
for d in D:
    candi.remove(d)

def decide(i):
    if i >= len(N):
        return ''
    for c in candi:
        if N[i] == c:
            return c + decide(i + 1)
        elif N[i] < c:
            return c + candi[0] * (len(N) - i - 1)

if candi[-1] * len(N) >= N:
    print decide(0)
else:
    print (candi[0] if candi[0] != '0' else candi[1]) + candi[0] * len(N)



### FIXED CODE ###

A, B, C = map(int, raw_input().split())

if [A, B, C].count(5) == 2 and [A, B, C].count(7) == 1:
    print 'YES'
else:
    print 'NO'
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
score = a.pop(0)
score += a.pop(0)
if n%2==1:
  score += sum(a[:(n-3)//2])*2
else:
  score += sum(a[:(n-3)//2])*2 + a[(n-3)//2]
print(score)  

### FIXED CODE ###

n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
score = a.pop(0)
if n%2==1:
  score += sum(a[:(n-1)//2-1])*2 + a[(n-1)//2-1]
else:
  score += sum(a[:(n-1)//2])*2
print(score)
# -*- coding: utf-8 -*-

A = int(input())
B = int(input())

[print(A+B) if A+B < 10 else print('error')]

### FIXED CODE ###

# -*- coding: utf-8 -*-

A, B = map(int, input().split())

[print(A+B) if A+B < 10 else print('error')]
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
max = min(n, 2 * 10 ** 5)

fac1 = [n] * max
fac2 = [1] * max
for i in range(2, max):
    fac1[i] = fac1[i - 1] * (n - i + 1) % mod
    fac2[i] = fac2[i - 1] * i % mod
c = fac1[a] * pow(fac2[a], mod - 2, mod) % mod
d = fac1[b] * pow(fac2[b], mod - 2, mod) % mod

print((pow(2, n, mod) - c - d - 1) % mod)


### FIXED CODE ###

n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
max = min(n, 2 * 10 ** 5)

fac1 = [n] * (max + 1)
fac2 = [1] * (max + 1)
for i in range(2, max + 1):
    fac1[i] = fac1[i - 1] * (n - i + 1) % mod
    fac2[i] = fac2[i - 1] * i % mod
c = fac1[a] * pow(fac2[a], mod - 2, mod) % mod
d = fac1[b] * pow(fac2[b], mod - 2, mod) % mod

print((pow(2, n, mod) - c - d - 1) % mod)
N, K = map(int, input().split())
H = list(map(int, input().split()))

ans = 0
for i in range(N):
    if H[i] >= K:
        ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
if N%2:
    print(((N+1)//2)/N)
else:
    print(0.5)
n,m=map(int,input().split())
l=[]
for i in range(n):
    l1=list(map(input().split()))
    l1=l1[::-1]
    l.append(l1)
l=sorted(l)
s=0
for i in range(n):
    s+=l[i][0]*l[i][1]
for i in range(n):
    if m-l[i][1]>=0:
        s-=l[i][0]*l[i][1]
        m-=l[i][1]
    else:
        s-=l[i][0]*m
print(s)


### FIXED CODE ###

b=True
while b:
  n,m=map(int,input().split())
  if n==0 and m==0:
    b=False
    exit
  else:
    l=[]
    for i in range(n):
      l1=list(map(int,input().split()))
      l1=l1[::-1]
      l.append(l1)
    l=sorted(l)
    l=l[::-1]
    s=0
    for i in range(n):
      s+=l[i][0]*l[i][1]
    for i in range(n):
      if m-l[i][1]>=0:
          s-=l[i][0]*l[i][1]
          m-=l[i][1]
      else:
          s-=l[i][0]*m
          break
    print(s)
n=input()
l=range(1,n)
m=0
while any(i%2==0 for i in l):
       l=[i/2 for i in l]
       m+=1
print(2**m)

### FIXED CODE ###

N=int(input())
c=0
n=range(1,N)
while any(i%2==0 for i in n):
          N=int(N/2)
          n=range(1,N+1)
          c+=1
print(2**c)
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, K = LI()
S = str(input())
S = S + "2"
d1 = []
d0 = []
k = S[0]
if k=="0":
    d1.append(0)
cou = int(1)
for i in range(N):
    if S[i]!=S[i+1]:
        if S[i]=="0":
            d0.append(cou)
        if S[i]=="1":
            d1.append(cou)
        cou = int(1)
    else:
        cou +=1

#print(d1)
#print(d0)

ansC = []
t = 2*K+1
newN = len(d1)
if len(d1)==1 or d0==[] or K>=N//2+1:
    ansC.append(N)

if newN!=len(d0):
    d0.append(0)
    d0.append(0)
sumd1 = [0]*(newN+t+5)
sumd0 = [0]*(newN+t+5)
for i in range(newN):
    sumd1[i+1] = d1[i]
    sumd0[i+1] = d0[i]
for i in range(newN+1):
    sumd1[i+1] += sumd1[i]
    sumd0[i+1] += sumd0[i]

#for i in range(max(newN-K+1,K)):
if ansC==[] and (newN - K + 1)>=1:
    for i in range(max(newN-K+1,K)):
        ans = (sumd1[i + K + 1] - sumd1[i]) + (sumd0[i + K] - sumd0[i])
        ansC.append(ans)

print(max(ansC))
#print(ansC)
#print(sumd1)
#print(sumd0)

### FIXED CODE ###

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(0)

N, K = LI()
S = str(input())
S = S + "2"
d1 = []
d0 = []
k = S[0]
if k=="0":
    d1.append(0)
cou = int(1)
for i in range(N):
    if S[i]!=S[i+1]:
        if S[i]=="0":
            d0.append(cou)
        if S[i]=="1":
            d1.append(cou)
        cou = int(1)
    else:
        cou +=1

#print(d1)
#print(d0)

ansC = []
t = 2*K+1
newN = len(d1)
if len(d1)==1 or d0==[] or K>=N//2+1:
    ansC.append(N)

if newN!=len(d0):
    d0.append(0)
    d0.append(0)
sumd1 = [0]*(newN+t+5)
sumd0 = [0]*(newN+t+5)
for i in range(newN):
    sumd1[i+1] = d1[i]
    sumd0[i+1] = d0[i]
for i in range(newN+1):
    sumd1[i+1] += sumd1[i]
    sumd0[i+1] += sumd0[i]

#for i in range(max(newN-K+1,K)):
if ansC==[] and (newN - K + 1)>=1:
    for i in range(newN - K + 1):
        ans = (sumd1[i + K + 1] - sumd1[i]) + (sumd0[i + K] - sumd0[i])
        ansC.append(ans)
else:
    ansC.append(N)
print(max(ansC))
#!/usr/bin/env python3
#ABC48 C

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

b = a.copy()
if a[0] > x:
    b[0] = x
for i in range(n-1):
    if b[i] + b[i+1] > x:
        b[i+1] -= (b[i]+b[i+1] - x)
        if b[i+1] < 0:
            b[i] -= abs(b[i+1])
            b[i+1] += abs(b[i+1])
ans = 0
for i in range(n):
    ans += abs(b[i] - a[i])
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC48 C

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

b = a.copy()
if a[0] > x:
    b[0] = x
for i in range(n-1):
    if b[i] + b[i+1] > x:
        b[i+1] -= (b[i]+b[i+1] - x)
        if b[i+1] < 0:
            b[i] -= abs(b[i+1])
            b[i+1] += abs(b[i+1])
ans = 0
for i in range(n):
    ans += abs(b[i] - a[i])
print(ans)
from collections import deque

dis_x = [1, 0, -1, 0]
dis_y = [0, 1, 0, -1]

goal_h, goal_w = map(int, input().split())

s = []
for _ in range(goal_h):
    line = input()
    s.append(list("#{}#".format(line)))

s = [list("#" * (goal_w + 2))] + s + [list("#" * (goal_w + 2))]

dist = [ [0] * (goal_w + 2) for _ in range(goal_w+2)]

que = deque([(1, 1)])

while que:
    h, w = que.popleft()

    for i in range(4):
        dx, dy = dis_x[i], dis_y[i]
        if s[h+dy][w+dx] == '.' and  dist[h+dy][w+dx] == 0:
            dist[h+dy][w+dx] = dist[h][w]+1
            que.append((h+dy, w+dx))

opt = dist[goal_h][goal_w]

not_wall_count = sum(l.count('.') for l in s)

if dist[goal_h][goal_w] == 0:
    print(-1)
else:
    print(not_wall_count - opt - 1)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
S = [input() for i in range(H)]
C = sum(s.count('.') for s in S)

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
que = deque([(0, 0, 0)])
used = {(0, 0)}

res = None
while que:
    s, t, cost = que.popleft()
    if s == H-1 and t == W-1:
        res = cost
        break
    for di, dj in dd:
        ni = s + di; nj = t + dj
        if (not 0 <= ni < H) or (not 0 <= nj < W) or S[ni][nj] == '#' or (ni, nj) in used:
            continue
        used.add((ni, nj))
        que.append((ni, nj, cost + 1))
if res:
    print(C - 1 - res)
else:
    print(-1)
a, b = map(int, input().spli())
if b % a == 0:
    print(a + b)
else:
    print(b-a)

### FIXED CODE ###

a, b = map(int, input().split())
if a == b:
    print(a + b)
elif b % a == 0:
    print(a + b) 
else:
    print(b-a)
n,T=map(int,input().split())
c,t=[int(input().split()) for i in range(n)]
k=[]
if all(t)>T:
    print('TLE')
else:
    for i in range(n):
        if t[i]<=T:
            k.append(c[j])
    print(min(k))

### FIXED CODE ###

n,T=map(int,input().split())
m=1001
for i in range(n):
    c,t=map(int,input().split())
    if t<=T:
        m=min(m,c)
if m==1001:
    print('TLE')
else:
    print(m)
# -*- coding: utf-8 -*-

# Input
s = [input() for i in range(2)]
N = int(s[0])
As = sorted(list(s[1].split()))

# Proccess
for i in range(N):
	if As[i] == As[i+1]:
		Anser = "No"
		break
	else:
		Anser = "Yes"
		
# Output							
print(Anser)

### FIXED CODE ###

# C - Distinct or Not
N = int(input())
A = list(map(int, input().split()))

M = len(set(A))

if N == M:
    print("YES")
else:
    print("NO")
n=input()
s=int(n.split())
a=s[0]
b=s[1]
S=a*b
L=(2*a)+(2*b)
print(S' 'L)


### FIXED CODE ###

#cording; UTF-8
a,b=[int(x) for x in input().split()]

S = a*b
L = 2*(a+b)
print(S,L)
from collections import defaultdict

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

cnt = defaultdict(int)
for i, (xi, yi) in enumerate(xy):
    for xj, yj in xy[i + 1:]:
        cnt[(xi - xj, yi - yj)] += 1
ans = n - max(cnt.values())
print(ans)


### FIXED CODE ###

from collections import defaultdict

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

cnt = defaultdict(int)
for xi, yi in xy:
    for xj, yj in xy:
        cnt[(xi - xj, yi - yj)] += 1
cnt[(0, 0)] = 0
ans = n - max(cnt.values())
print(ans)
ll=list()
for i in range(3):
    a=input()
    b=a.split()
    ll.append(int(b[0]),int(b[1]))
c1=ll.count(1)
c2=ll.count(2)
c3=ll.count(3)
c4=ll.count(4)
if c1>2 or c2>2 or c3>2 or c4>2:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

ll=list()
for i in range(3):
    a=input()
    b=a.split()
    ll.append(int(b[0]))
    ll.append(int(b[1]))
c1=ll.count(1)
c2=ll.count(2)
c3=ll.count(3)
c4=ll.count(4)
if c1>2 or c2>2 or c3>2 or c4>2:
    print("NO")
else:
    print("YES")
class sort:
    def __init__(self, num):
        self.num = num
 
    def insert(self, lst):
        print(*lst)
        for i in range(1,self.num):
            j = i - 1
            while (j >= 0) * (lst[j] > lst[i]):
                j -= 1
            lst[j+1:i+1] = lst[i] , *lst[j+1:i]
            print(*lst)

sort(int(input())).insert(list(map(int,input().split())))

### FIXED CODE ###

n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
    li = lst[i]
    j = i-1
    while j >= 0 and lst[j] > li:
        lst[j:j+2] = lst[j+1], lst[j]
        j -= 1
    print(*lst)
A, B, C = map(int, input())

if (A = B and B = C) or (A != B and B != C and C != A):
    print("No")

else:
    print("Yes")

### FIXED CODE ###

A, B, C = map(int, input().split())

if (A == B and B == C) or (A != B and B != C and C != A):
    print("No")

else:
    print("Yes")
import heapq
import collections
import math
import sys
N =  int(input())
input = sys.stdin.readline

nums = list(map(int,input().split(" ")))
keta = [0] * 61
# ある桁の1の出現回数
# keta[k] → 2**k の桁
jijou = [1]
MOD = 10 ** 9 + 7
for i in range(60):
    temp = jijou[i] * 2
    temp%= MOD
    jijou.append(temp)

for num in nums:
    s = format(num,"b")
    l = math.floor(math.log2(num)) + 1

    for i in range(0,l):
        keta[i] += int(s[l - i - 1 ])
ans = 0
for j,num in  enumerate(nums[:-1]):
    s = format(num, "b")
    l = math.floor(math.log2(num)) + 1
    for i in range(0,61): #i →  2 ** i 乗 桁目に対応
        if l <= i:
            ans += (keta[i] * jijou[i]) % MOD
        else:
            if s[l - i - 1 ] == "0":
                ans += (keta[i] * jijou[i]) % MOD
            else:
#              (N - j + 1) - (keta[i] + 1 ) → 0が経っているところの個数
                ans += (( (N - j + 1) - (keta[i] + 1)  ) * ( jijou[i]) ) % MOD
                keta[i] -= 1
        ans %= MOD
    ans %= MOD


print(ans)

### FIXED CODE ###


import heapq
import collections
import math
import sys
N =  int(input())
input = sys.stdin.readline
# num = a << b →  a  * (2 ** b)
# 1 << i → i桁目のマスク
# mask = 1 << i
# num = a << b
# num & mask


#
nums = list(map(int,input().split(" ")))
keta = [0] * 62
# ある桁の1の出現回数
# keta[k] → 2**k の桁
jijou = []
MOD = 10 ** 9 + 7


for num in nums:
    s = format(num,"b")
    l = len(s)

    for i in range(0,l):
        if s[l - i - 1 ] == "1":
            keta[i] += 1

ans = 0
temp = 1
for i in range(62):

    ans += ( keta[i] * (N - keta[i])) * temp
    ans %= MOD
    temp *= 2
    temp %= MOD
print(ans)
import bisect
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab[1])
    if ab[1] == n:
        G.append(ab[0])
        
ans = 'IMPOSSIBLE'
if len(G) != 0:
    for s in S:
        idx = bisect.bisect_left(G, s)
        if s == G[idx]:
            ans = 'POSSIBLE'
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
S = set()
G = set()

for i in range(m):
    s, g = map(int, input().split())
    if s == 1:
        G.add(g)
    if g == n:
        S.add(s)

if len(S&G) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
a,b,c,d,e,k= map(int, input().split())




if e-a > k:
    print(":(")
else:
    print("Yay!")

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())



if e-a > k:
    print(":(")
else:
    print("Yay!")
n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
s,c = zip(*sc)

arr = [0 for i in range(n)]

for i in range(m):
    if arr[s[i]-1] != 0 and arr[s[i]-1] != c[i]:
        print(-1)
        exit()
    if n != 0 and s[i]-1 == 0 and c[i] == 0:
        print(-1)
        exit()
    else:
        arr[s[i]-1] = c[i]

ans = 0
if n == 1 and arr[0] == 0:
    print(0)
    exit()

if arr[0] == 0:
    arr[0] = 1

print("".join(map(str,arr)))

### FIXED CODE ###

n,m = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(m)]
if m > 0:
    s,c = zip(*sc)

arr = [0 for i in range(n)]

for i in range(m):
    if arr[s[i]-1] != 0 and arr[s[i]-1] != c[i]:
        print(-1)
        exit()
    if n != 1 and s[i]-1 == 0 and c[i] == 0:
        print(-1)
        exit()
    else:
        arr[s[i]-1] = c[i]

if n == 1 and arr[0] == 0:
    print(0)
    exit()

if arr[0] == 0:
    arr[0] = 1

print("".join(map(str,arr)))
import sympy as sy
N=int(input())
def yakusuu(x):
    tmplist=list(sy.factorint(x).values())
    a=1
    for i in tmplist:
        a*=i+1
    return a
counter=0
for i in range(1,N+1,2):
    if yakusuu(i)==8:
        counter+=1
print(counter)

### FIXED CODE ###

import math

N = int(input())


# def yakusuu(x):
#     tmplist=list(sy.factorint(x).values())
#     a=1
#     for i in tmplist:
#         a*=i+1
#     return a
def make_prime_list_2(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0  # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]


def search_divisor_num_1(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num


counter = 0
for i in range(1, N + 1, 2):
    if search_divisor_num_1(i) == 8:
        counter += 1
print(counter)
N = int(input())
A = list(int(input()) for i in range(N))
ans = A[0]
for i in range(N):
    stor = A.pop(i)
    for n in range(N-1):
        if ans < A[i]:
            ans = A[i]
    A.append(stor)
    print(ans)
    ans = A[0]

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B= sorted(A)

for i in range(N):
    if A[i] == B[N-1]:
        ans = B[N-2]
        print(ans)
    else:
        print(B[N-1])
n, c = map(int, input().split())

x = [0 for _ in range(n + 2)]
v = [0 for _ in range(n + 1)]
for i in range(n):
    x[i + 1], v[i + 1] = map(int, input().split())

x[n + 1] = c

left = [0 for _ in range(n + 1)]
right = [0 for _ in range(n + 1)]
left_rev = [0 for _ in range(n + 1)]
right_rev = [0 for _ in range(n + 1)]

for i in range(1, n + 1):
    left[i] = left[i - 1] + v[i] - (x[i] - x[i - 1])
    left_rev[i] = left[i] - x[i]
    right[i] = right[i - 1] + v[n - i + 1] - (x[n - i + 2] - x[n - i + 1])
    right_rev[i] = right[i] - (c - x[n - i + 1])

result = 0
for i in range(1, n + 1):
    temp = max( (left[i] + max(right_rev[:n - i + 1])) , (right[i] + max(left_rev[:n - i + 1])) )
    if temp > result:
        result = temp

print(result)

### FIXED CODE ###

s = list(input())

print(700 + s.count('o') * 100)
s = input()
fre = [0] * 27
for ch in s:
  fre[ord(ch)] += 1
  if fre[ord(ch)] > 1:
    print("no")
    exit()
print("yes")

### FIXED CODE ###

from sys import *

s = stdin.readline()
fre = [0] * 200
for ch in s:
	fre[ord(ch)] += 1
	if fre[ord(ch)] > 1:
		print("no")
		exit()
print("yes")
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+a[y-1]-c
    if minimum > tmp:
        minimum = tmp

a.sort()
b.sort()

tmpind = b[0]
for i in a:
    if i + tmpind > minimum:
        break
    for ind, j in enumerate(b):
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
            tmpind = ind
            break

print(minimum)

### FIXED CODE ###

A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
minimum = a[0]+b[0]

for k in range(M):
    x,y,c = map(int,input().split())
    tmp = a[x-1]+b[y-1]-c
    if minimum > tmp:
        minimum = tmp

a.sort()
b.sort()

for i in a:
    if i + b[0] > minimum:
        break
    for j in b:
        tmp = i + j
        if minimum > tmp:
            minimum = tmp
        else:
            break

print(minimum)
s = input()

print(char(ord(s) + 1)


### FIXED CODE ###

s = input()

print(chr(ord(s) + 1))
import sys
sys.setrecursionlimit(100000000)

N, A, B, C, D = map(int, input().split())
s = list(input())

A -= 1
B -= 1
C -= 1
D -= 1

for i in len(s):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#':
            print("No")
            exit()




def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans

ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)
 
N, A, B, C, D = map(int, input().split())
s = list(input())
 
A -= 1
B -= 1
C -= 1
D -= 1
 
for i in range(len(s)):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#' and max(C, D) < i and i <= C:
            print("No")
            exit()
 
if D < C:
    tmp = 0
    for i in range(len(s)):
        if i == len(s) - 2 or i == len(s) - 1:
            continue
        else:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and B <= i + 1 <= D:
                tmp = 1
    if tmp != 1:
        print("No")
        exit()
 
 
 
def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans
 
ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")
A,B= list(map(int, input().split()))

if(A>=9 or b>=9):
    print(":(")
else:
    print("Yay!")

### FIXED CODE ###


A,B= list(map(int, input().split()))

if(A>=9 or B>=9):
    print(":(")
else:
    print("Yay!")
A, B, C, D, E, F = map(int, input().split())


ws = set()
ss = set()
for a in range(0, F+1, A*100):
    for b in range(0, F-a+1, B*100):
        if a + b == 0:
            continue
        ws.add(a + b)

for c in range(0, F+1, C):
    for d in range(0, F-c+1, D):
        ss.add(c + d)

mx = 0
ans = None
for w in ws:
    for s in ss:
        x = s * 100 / w
        if w + s <= F and x <= E and mx < x:
            mx = x
            ans = [s + w, s]

print(*ans)


### FIXED CODE ###

A, B, C, D, E, F = map(int, input().split())
W = set()
for a in range(0, F+1, 100*A):
    for b in range(0, F+1, 100*B):
        W.add(a+b)
S = set()
for c in range(0, F+1, C):
    for d in range(0, F+1, D):
        S.add(c+d)

rate = -1
for w in W:
    for s in S:
        if 0 < w + s <= F and s * 100 <= E * w:
            if s / (s + w) > rate:
                rate = s / (s + w)
                ans = w + s, s
print(ans[0], ans[1])
import numpy as np

N = int(input())
A_array = np.array(map(int, input().split()))

a_array = 1/A_array
print(np.sum(a_array))

### FIXED CODE ###

import numpy as np

N = int(input())
A_array = np.array([int(x) for x in input().split()])

a_array = np.sum(1/A_array)
print(1/a_array)
k, a, b = map(int, input().split())
k = max(0, k - a)
if k > 0 and a <= b:
  print(-1)
else:
  print((k // (a - b) + int(k % (a - b) != 0)) * 2 + 1)

### FIXED CODE ###

k, a, b = map(int, input().split())
k = max(0, k - a)
if k > 0 and a <= b:
  print(-1)
elif a == b:
  print(1)
else:
  print((k // (a - b) + int(k % (a - b) != 0)) * 2 + 1)
n = int(input())
D = list(map(int,input().split()))
daburi = 0
for i in range(n):
    for j in range(n):
        if i != j and D[i] == D[j]
            daburi += 1
print(n - daburi)


### FIXED CODE ###

n = int(input())
D = list(input() for i in range(n))
D = set(map(int,D))
print(len(D))
N = int(input())
A = sorted(list(map(int, input().split())))

for i in range N-1:
	A[i+1] = (A[i] + A[i+1])/2

 print(A[N-1])

### FIXED CODE ###

n = int(input())
v = sorted(list(map(int, input().split())))

for i in range(n - 1):
    v[i + 1] = (v[i] + v[i + 1]) / 2

print(v[n - 1])
a,b = map(int, input().split())
if a < 6:
    print(0)
    return
elif a < 14:
    print(int(b / 2))
	return
else:
    print(b)

### FIXED CODE ###

a,b = map(int, input().split())
if a >= 13:
    print(b)
    exit()
elif a >= 6:
    print(int(b / 2))
    exit()
else:
    print(0)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))+[10**10]
b = list(map(int, input().split()))+[10**10]



def dfs(ai, bi, time, finished=False):
    if finished:
        return ai+bi

    if time >= a[ai]:
        ret1 = dfs(ai+1, bi, time-a[ai])
    else:
        ret1 = dfs(ai, bi, time, finished=True)

    
    if time >= b[bi]:
        ret2 = dfs(ai, bi+1, time-b[bi])
    else:
        ret2 = dfs(ai, bi, time, finished=True)

    return max(ret1, ret2)

print(dfs(0, 0, k))

### FIXED CODE ###

from bisect import bisect_right
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

for i in range(m):
    b[i+1] += b[i]


def f(time, r):
    ret = bisect_right(r, time) - 1
    return ret


def fa(time):
    return f(time, a)


def fb(time):
    return f(time, b)

ans = 0

for i, ai in enumerate(a):
    k -= ai
    if k < 0:
        break
    ans = max(ans, i + fb(k))

print(ans)