Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#import sys

#input = sys.stdin.readline
import math
#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True


def main():
#    h,w,a,b = map(int, input().split())
    x,y = map(int,input().split())
    a=max(x,y)
    b=min(x,y)

    t=a//2
    if b<t:
       ans=0
    elif (b-t)%3==0 and a%2==0:
       aa=a//2
       bb=(b-t)//3*2
       aa-=(b-t)//3
       ans=1
       for i in range(bb):
           ans*=aa+bb-i
       ans=ans//(math.factorial(bb))
    elif (b-t+1)%3==0 and a%2!=0:
       aa=a//2
       bb=(b-t)//3*2+1
       aa -= (b - t) // 3
       ans=1
       for i in range(bb):
           ans *= aa +bb- i
       ans=ans//(math.factorial(bb))
    else:
        ans=0


#    print(ans)
    print(ans%(10**9+7))
if __name__ == "__main__":
    main()

### FIXED CODE ###

#import sys

#input = sys.stdin.readline
import math
import itertools
#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def main():
#    h,w,a,b = map(int, input().split())
    x,y = map(int,input().split())
    a=max(x,y)
    b=min(x,y)

    t=a//2
    if b<t:
       ans=0
    elif (b-t)%3==0 and a%2==0:
       aa=a//2
       bb=(b-t)//3*2
       aa-=(b-t)//3
       ans=1
       ans=cmb(aa+bb,bb)

    elif (b-t+1)%3==0 and a%2!=0:
       aa=a//2
       bb=(b-t)//3*2+1
       aa -= (b - t) // 3
       ans=1
       ans=cmb(aa+bb,bb)

    else:
        ans=0


#    print(ans)
    print(ans%(10**9+7))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
a=list(map(int,input().split()))
a.sort()
dp = [True for _ in range(a[n-1])]
for val in set(a):
    temp=2
    while val*temp<=a[n-1]:
        dp[val*temp-1]=False
        temp+=1
ans = 0
for val in a:
    if dp[val-1] and a.count(val)==1:
        ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
dp=[True]*a[-1]
def hantei(i):
    ans = True
    if i!=n-1:
        if a[i]==a[i+1]: ans = False
    if i!=0:
        if a[i]==a[i-1]: ans=False
    return ans
for val in set(a):
    for i in range(2*val,a[-1]+1,val): dp[i-1]=False
ans=0
for i in range(n):
    if dp[a[i]-1] and hantei(i)==1: ans+=1
print(ans)
### BUGGY CODE ###

def main():
    from itertools import product
    H, W, K = map(int, input().split())
    G = [list(map(int, list(input()))) for _ in range(H)]

    ans = float('inf')
    for pattern in product([0, 1], repeat=H-1):
        tmp_ans = 0
        div = [0] + [i for i, p in enumerate(pattern, start=1) if p == 1] + [100]
        grids = []
        for i in range(len(div) - 1):
            grids.append(G[div[i]: div[i + 1]])

        rows = []
        for grid in grids:
            row = []
            for w in range(W):
                v = 0
                for h in range(len(grid)):
                    v += grid[h][w]
                row.append(v)
            rows.append(row)

        w = 0
        counts = [0] * len(rows)
        while w < W:
            for i, row in enumerate(rows):
                counts[i] += row[w]

            if [c for c in counts if c > K]:
                tmp_ans += 1
                counts = [0] * len(rows)
            else:
                w += 1

        tmp_ans += len(div) - 2
        ans = min(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    from itertools import product
    H, W, K = map(int, input().split())
    G = [list(map(int, list(input()))) for _ in range(H)]

    ans = float('inf')
    for pattern in product([0, 1], repeat=H - 1):
        tmp_ans = 0
        div = [0] + [i for i, p in enumerate(pattern, start=1) if p == 1] + [100]
        grids = []
        for i in range(len(div) - 1):
            grids.append(G[div[i]: div[i + 1]])

        rows = []
        for grid in grids:
            row = []
            for w in range(W):
                v = 0
                for h in range(len(grid)):
                    v += grid[h][w]
                row.append(v)
            rows.append(row)

        w = 0
        d = set()
        df = False
        counts = [0] * len(rows)
        while w < W:
            for i, row in enumerate(rows):
                counts[i] += row[w]

            if [c for c in counts if c > K]:
                if w in d:
                    df = True
                    break
                d.add(w)
                tmp_ans += 1
                counts = [0] * len(rows)
            else:
                w += 1

            if df:
                break
        
        if not df:
            tmp_ans += len(div) - 2
            ans = min(ans, tmp_ans)

    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys

input = sys.stdin.readline

N, M, K = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
B = [int(s) for s in input().split()]

A_time = [0] + [sum(A[0:i+1]) for i in range(len(A))]
B_time = [0] + [sum(B[0:i+1]) for i in range(len(B))]

ans = 0
for i, a_time in enumerate(A_time):
    for j, b_time in enumerate(B_time):
        read_time = a_time + b_time
        if read_time <= K:
            if ans <= i + j:
                ans = i + j
        else:
            break

print(ans)

### FIXED CODE ###

import sys

N, M, K = [int(s) for s in sys.stdin.readline().split()]
n = 0
A = [0]
for s in sys.stdin.readline().split():
    n = n + int(s)
    A.append(n)

n = 0
B = [0]
for s in sys.stdin.readline().split():
    n = n + int(s)
    B.append(n)

ans = 0
for i in range(N + 1):
    if A[i] > K:
        break
    for j in range(M, -1, -1):
        if A[i] + B[j] <= K:
            ans = max(ans, i + j)
            M = j
            break

print(ans)
### BUGGY CODE ###

from collections import deque
# 全部ゼロ始まり
n, x, y = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(n-1):
    G[i].append(i+1)
for i in range(1, n):
    G[i].append(i-1)
x -= 1
y -= 1
G[x].append(y)
G[y].append(x)

# iとjの最短距離を返す
def bfs(i, j):
    i -= 1
    j -= 1
    q = deque()
    seen = [False] * n
    dist = [-1] * n

    q.append(i)
    seen[i] = True
    dist[i] = 0
    while len(q) > 0:
        now_v = q.popleft()
        for new_v in G[now_v]:
            if seen[new_v] is True:
                continue
            q.append(new_v)
            seen[new_v] = True
            dist[new_v] = dist[now_v] + 1
            if new_v == j:
                return dist[j]

cnt = [0] * (n-1)
for i in range(n-1):
    for j in range(i+1, n):
        cnt[bfs(i, j)-1] += 1

for ans in cnt:
    print(ans)

### FIXED CODE ###

n, x, y = map(int, input().split())
x -= 1
y -= 1
cnt = [0] * n
for i in range(n-1):
    for j in range(i+1, n):
        direct = j - i
        detour = abs(x-i) + abs(y-j) + 1
        d = min(direct, detour)
        cnt[d] += 1
for k in range(1, n):
    print(cnt[k])
### BUGGY CODE ###

K = int(input())

A = [0]
A[0] = 7%K
ans = 1
while 1==1:
    if A[ans-1]==0:
        break
        
    A.append((A[ans-1]*10+A[0])%K)
    ans += 1
    
    if A[ans-1] == A[0] and A[0] != 0:
        ans = -1
        break
        
print(ans)

### FIXED CODE ###

K = int(input())

A = [0]*1000001
A[0] = 7%K
ans = -1

for i in range(1,1000001):
    A[i] = (A[i-1]*10+7)%K

for i in range(1000001):
    if A[i]==0:
        ans = i+1
        break
        
print(ans)
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
game = {}

for i in range(1, n+1):
    game[i] = deque((map(int, input().split())))

count = 0
final = n*(n-1)//2
done = []

finish = [0] * (n + 1)
for me in range(1, n + 1):
    if finish[me] == 1 or game[me] == deque([]):
        continue

    you = game[me][0]
    if finish[you] == 1:
        continue
    else:
        if game[you][0] == me:
            done.append(you)
            done.append(me)
            finish[game[you].popleft()] = 1
            finish[game[me].popleft()] = 1
            possible = True
            count += 1
        else:
            continue

for day in range(2, 1000000):
    finish = [0]*(n+1)
    possible = False
    new_done = []
    for me in done:
        if finish[me] == 1 or game[me] == deque([]):
            continue

        you = game[me][0]
        if finish[you] == 1:
            continue
        else:
            if game[you][0] == me:
                finish[game[you].popleft()] = 1
                finish[game[me].popleft()] = 1
                new_done.append(me)
                new_done.append(you)
                possible = True
                count += 1
            else:
                continue
    done = new_done
    if not possible:
        print(-1)
        exit()

    if count == final:
        print(day)
        exit()

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline

n = int(input())
game = {}

for i in range(1, n+1):
    game[i] = deque((map(int, input().split())))

count = 0
final = n*(n-1)//2
done = []

finish = [0] * (n + 1)
for me in range(1, n + 1):
    if finish[me] == 1 or game[me] == deque([]):
        continue

    you = game[me][0]
    if finish[you] == 1:
        continue
    else:
        if game[you][0] == me:
            done.append(you)
            done.append(me)
            finish[game[you].popleft()] = 1
            finish[game[me].popleft()] = 1
            possible = True
            count += 1
        else:
            continue

for day in range(2, 1000000):
    finish = [0]*(n+1)
    possible = False
    new_done = []
    for me in done:
        if finish[me] == 1 or game[me] == deque([]):
            continue

        you = game[me][0]
        if finish[you] == 1:
            continue
        else:
            if game[you][0] == me:
                finish[game[you].popleft()] = 1
                finish[game[me].popleft()] = 1
                new_done.append(me)
                new_done.append(you)
                possible = True
                count += 1
            else:
                continue
    done = new_done
    if not possible:
        print(-1)
        exit()

    if count == final:
        print(day)
        exit()
### BUGGY CODE ###

import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()
# L = np.array(_L)
#C = np.zeros(N + 1)

def test(a,b,c):
    if a<b+c and b<c+a and c<a+b:
        return True
    return False

count = 0
for pair in itertools.combinations(L, 3):
    # print(pair)
    if test(*pair):
        count += 1
print(count)

### FIXED CODE ###

import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
L = LI()
# L = np.array(_L)
#C = np.zeros(N + 1)

# def test(a,b,c):
#     if a<b+c and b<c+a and c<a+b:
#         return True
#     return False

# count = 0
# for pair in itertools.combinations(L, 3):
#     # print(pair)
#     if test(*pair):
#         count += 1
# print(count)

# for i in range(N):
#     for j in range(i+1,N):

from numba import njit
 
@njit
def f(A):
  count = 0
  for i in range(N):
    for j in range(i + 1, N):
      for k in range(j + 1, N):
        count += (A[k] < A[i] + A[j])
  return count
 
A = np.array(L)
A.sort()
print(f(A))
### BUGGY CODE ###

K = int(input())
S = 7
i = 1
if (1 <= K) and (K <= (10 ** 6)):
    while True:
        if int(S) % K != 0:
            S = S * 10 + 7
            i += 1
        else:
            print(i)
            break

        if i > K:
            print('-1')
            break

### FIXED CODE ###

K = int(input())
if K % 2 == 0:
    print(-1)
elif K % 5 == 0:
    print(-1)
else:
    S = 7
    for i in range(K+1):
        if S % K == 0:
            print(i+1)
            break
        else:
            S = S % K
            S = S * 10 + 7
    else:
        print(-1)
### BUGGY CODE ###

from collections import Counter

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

cou = Counter(A) 

A = list(set(A))
A.sort()

C = [A[0]]
for i in range(1, len(A)):
    Flag = True
    for c in C:
        if A[i] % c == 0:
            Flag = False
            break
    if Flag == True:
        C.append(A[i])

ans = 0
for i in C:
    if cou[i] == 1:
        ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter

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

cnt = Counter(A) 

A = list(set(A))
A.sort()


C = [0]*(10**6+1)
ans = 0

for a in A:
    if C[a] == 0:
        i = 1
        while True:
            if a*i > 10**6:
                break
            C[a*i] = 1
            i += 1
        if cnt[a] == 1:
            ans += 1

print(ans)
### BUGGY CODE ###

N = int(input())
s = [input().split() for i in range(N)]
for i in range(N):
    s[i] = list(s[i][0])
    s[i].sort()
    s[i] = ''.join(map(str, s[i]))
s.sort()
count = 0
for i in range(N):
    for j in range(i+1,N):
        if s[i] == s[j]:
            count += 1
        else:
            break
print(count)

### FIXED CODE ###

N = int(input())
s = [input().split() for i in range(N)]
for i in range(N):
    s[i] = list(s[i][0])
    s[i].sort()
    s[i] = ''.join(map(str, s[i]))
s.sort()
count = 0
ren = 0
for i in range(N-1):
    if s[i] == s[i+1]:
        count += 1+ren
        ren += 1
    else:
        ren = 0
print(count)
### BUGGY CODE ###

import math

n = int(input())
c = 0

for i in range(1, n):
    m = math.sqrt(i)
    for j in range(1, int(m)+1):
        if i%j == 0:
            c += 2
    if m.is_integer():
        c -= 1

print(c)

### FIXED CODE ###

n = int(input())
c = 0

for i in range(1, n):
    c += (n-1) // i

print(c)
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
res = 1
flag0 = False
if 0 in a_list:
  flag0 = True

for i in range(n):
  res = a_list[i]*res
  if res > 1000000000000000000 and flag0==False:
    res = -1
    break

print(res)

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort(reverse=True)
res = 1
flag0 = False
if 0 in a_list:
  res = 0
else:
  for i in range(n):
    res = a_list[i]*res
    if res > 1000000000000000000:
      res = -1
      break

print(res)
### BUGGY CODE ###

def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    ans = 0
    while len(s) != 0:
        cnt = s.count(s[0])
        tmp = s[0]
        for i in range(cnt):
            s.remove(tmp)
        if cnt == 1:
            continue
        ans += (cnt * (cnt - 1)) / 2
    print(int(ans))

if __name__ == "__main__":
    main()

### FIXED CODE ###

import collections
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    s = collections.Counter(s)
    ans = 0
    for i in s.values():
        ans += (i*(i-1))//2
    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

x, y, z, k = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = list(map(int, input().split(' ')))
ab = []
for i in a:
    for j in b:
        ab.append(i+j)
ab.sort(reverse = True)
abc = []
k_1 = min([len(ab), k])
for i in ab:
    for j in c:
        abc.append(i+j)
abc.sort(reverse = True)
for i in range(k):
    print(abc[i])

### FIXED CODE ###

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

a, b, c = (sorted(map(int, sys.stdin.readline().split()), reverse=True) for _ in range(3))

abc = {(0,0,0)}

stu = [[-a[0]-b[0]-c[0], 0,0,0]]
heapq.heapify(stu)
result = []
while k > 0:
    out_p, n, m, l = heapq.heappop(stu)
    if n+1<x and not((n+1,m,l) in abc):
        abc.add((n+1,m,l))
        heapq.heappush(stu, [-a[n+1]-b[m]-c[l], n+1, m, l])
    if m+1<y and not((n,m+1,l) in abc):
        abc.add((n,m+1,l))
        heapq.heappush(stu, [-a[n]-b[m+1]-c[l], n, m+1, l])
    if l+1<z and not((n,m,l+1) in abc):
        abc.add((n,m,l+1))
        heapq.heappush(stu, [-a[n]-b[m]-c[l+1], n, m, l+1])
    result.append(-out_p)
    k -= 1
result.sort(reverse=True)
for i in result:
    print(i)
### BUGGY CODE ###

X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))

a=p[:]
a.extend(q)
a.extend(r)
a.sort()
a.reverse()
red=0
green=0
sum=0
for i in range(X+Y):
  if(a[i] in p):
    red+=1
  elif(a[i] in q):
    green+=1
    
if(red<=X and green<=Y):
  c=a[:(X+Y)]
  d=0
  for i in range(X+Y):
    d+=a[i]
  print(d)
elif(red>X):
  p.sort()
  p.reverse()
  for i in range(X):
    sum+=p[i]
  b=q[:]
  b.extend(r)
  b.sort()
  b.reverse()
  for i in range(Y):
    sum+=b[i]
  print(sum)
elif(green>Y):
  e=0
  q.sort()
  q.reverse()
  for i in range(Y):
    e+=q[i]
  sum+=e
  b=p[:]
  b.extend(r)
  b.sort()
  b.reverse()
  for i in range(X):
    sum+=b[i]
  print(sum)

### FIXED CODE ###

X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
q.sort()
p.reverse()
q.reverse()
p=p[:X]
q=q[:Y]
 
a=p[:]
a.extend(q)
a.extend(r)
a.sort()
a.reverse()
sum=0
for i in range(X+Y):
  sum+=a[i]
print(sum)
### BUGGY CODE ###

def kaiten(parts):
    parts = reversed(parts)
    parts = ''.join(parts)
    parts = parts.replace('L', 'Z')
    parts = parts.replace('R', 'L')
    parts = parts.replace('Z', 'R')
    return list(parts)

def occurrences(string, sub):
    count = start = 0
    while True:
        start = string.find(sub, start) + 1
        if start > 0:
            count += 1
        else:
            return count

n, k = map(int, input().split())
s = input()

for _ in range(k):
    l = s.find('LR')
    r = s.find('RL', l)
    l2 = s.find('RL')
    r2 = s.find('LR', l2)
    _s = list(s)
    if 0 <= l and l < r:
        p = _s[l+1:r+1]
        _s[l+1:r+1] = kaiten(p)
    elif 0 <= l2 and l2 < r2:
        p = _s[l2+1:r2+1]
        _s[l2+1:r2+1] = kaiten(p)
    elif 0 <= l:
        p = _s[l+1:]
        _s[l+1:] = kaiten(p)
    elif 0 <= r:
        p = _s[:r+1]
        _s[:r+1] = kaiten(p)
    elif 0 <= l2:
        p = _s[l2+1:]
        _s[l2+1:] = kaiten(p)
    elif 0 <= r2:
        p = _s[:r2+1]
        _s[:r2+1] = kaiten(p)
    s = ''.join(_s)

score = occurrences(s, 'LL') + occurrences(s, 'RR')
print(score)


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
h = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        h += 1
print(min(h + 2 * k, n - 1))
### BUGGY CODE ###

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

for i in range(a, b + 1):
    if i < a + k or i > b - k:
        print(i)

### FIXED CODE ###

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

s = set()
i = a
while i < b and i < a + k:
    s.add(i)
    i += 1

i = b
while i >= a and i > b - k:
    s.add(i)
    i -= 1

for x in sorted(s):
    print(x)
### BUGGY CODE ###

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A

def digits2int(c, L, MOD):
    base = 0
    for i in range(L):
        factor = (1 << i) % MOD
        f = (factor * c[i]) % MOD
        base = (base + f) % MOD
    return base


def solve(N, A, L=60, MOD=10**9+7):
    # j桁目のビットが1であるものの数を、累積和として記憶
    count_ones = [[0 for j in range(L+1)] for i in range(N+1)]
    for i in range(N):
        for j in range(L):
            count_ones[i+1][j] = count_ones[i][j] + ((A[i] >> j) & 1)
    # A[i] と A[j] (i<j) のxorをとる
    modsum = 0
    for i in range(N-1):
        c = [0 for j in range(L)]
        for j in range(L):
            if ((A[i] >> j) & 1) == 0:
                c[j] = count_ones[N][j] - count_ones[i+1][j]
            else:
                c[j] = (N-i-1) - (count_ones[N][j] - count_ones[i+1][j])
        modsum = (modsum + digits2int(c, L, MOD)) % MOD
    return modsum


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))

### FIXED CODE ###

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A, L=60, MOD=10**9+7):
    modsum = 0
    for j in range(L):
        count_ones = sum([1 for a in A if (a >> j) & 1])
        # count_ones = sum([(A[i] >> j) & 1 for i in range(N)])
        count_zeros = N - count_ones
        # MODは一度にとる
        modsum +=  (1<<j) * count_zeros * count_ones
        modsum %= MOD
    return modsum


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

# C - Tsundoku
def get_total_time(n):
	totals = [0] * (n + 1)
	arr = input().split()
	
	for i in range(n):
		totals[i + 1] = totals[i] + int(arr[i])
	
	return totals


n, m, k = map(int, input().split())
a_sum = get_total_time(n)
b_sum = get_total_time(m)
ans = 0

for i in range(n + 1):
	if a_sum[i] > k:
		break
	else:
		for j in range(m + 1):
			if a_sum[i] + b_sum[j] > k:
				break
			else:
				ans = max(ans, i + j)

print(ans)

### FIXED CODE ###

# C - Tsundoku
def calc_cusum(n):
	cusum = [0] * (n + 1)
	arr = input().split()
	
	for i in range(n):
		cusum[i + 1] = cusum[i] + int(arr[i])
	
	return cusum


def identify_position(i, j):
  global a
  global b
  global k
  global m
  
  if a[i] + b[j] > k:
    while j > 0:
      j -= 1
      
      if a[i] + b[j] <= k:
        break
  else:
    while j < m and a[i] + b[j+1]<= k:
      j += 1
  
  return j


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

ans = 0
j = 0

for i in range(n + 1):
  j = identify_position(i, j) 
  
  #print(a[i])
  #print(b[j])
  #print(i + j)
  
  if a[i] + b[j] <= k:
    ans = max(ans, i+j)

print(ans)
### BUGGY CODE ###

import sys

n = int(sys.stdin.readline().strip())
S = [int(_) for _ in sys.stdin.readline().strip().split()]
q = int(sys.stdin.readline().strip())
T = [int(_) for _ in sys.stdin.readline().strip().split()]
cnt = 0


def binary_search(ary, target):

    if ary:
        ind = len(ary) // 2
        if target == ary[ind]:
            return True
        elif target < ary[ind]:
            return binary_search(ary[:ind], target)
        else:
            return binary_search(ary[ind + 1:], target)

    else:
        return False


for target in T:
    if binary_search(S, target):
        cnt += 1

if __name__ == '__main__':
    print(cnt)



### FIXED CODE ###

# def binary_search_original(ary, target):

#     if ary:
#         ind = len(ary) // 2
#         if target == ary[ind]:
#             return True
#         elif target < ary[ind]:
#             return binary_search(ary[:ind], target)
#         else:
#             return binary_search(ary[ind + 1:], target)

#     else:
#         return False


def binary_search(ary, target):

    left = 0
    right = len(ary)

    while left < right:
        mid = (left + right) // 2

        if ary[mid] == target:
            return True
        elif ary[mid] < target:
            left = mid + 1
        else:
            right = mid

    return False


if __name__ == '__main__':

    n = int(input())
    S = [int(_) for _ in input().split()]
    q = int(input())
    T = [int(_) for _ in input().split()]
    cnt = 0

    for target in T:
        if binary_search(S, target):
            cnt += 1

    print(cnt)