Harryxun/stf_run huggingface dataset:
from collections import Counter
import math
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
n=int(input())
L=[]
for j in range(2,n+1):
    I=j
    s=0
    R=int(I)
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
c=Counter(L)
c=[0 for i in range(100)]
for i,j in c.most_common():
  c[j]+=1
 
s=0
s+=sum(c[4:])*(sum(c[4:])-1)*sum(c[2:]-2)//2
s+=sum(c[14:])*(sum(c[4:])-1)
s+=sum(c[24:])*(sum(c[2:])-1)
s+=sum(c[74:])
print(s)

### FIXED CODE ###

from collections import Counter
import math
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
n=int(input())
L=[]
for j in range(2,n+1):
    I=j
    s=0
    R=int(I)
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
C=Counter(L)
c=[0 for i in range(100)]
for i,j in C.most_common():
  c[j]+=1
 
s=0
s+=sum(c[4:])*(sum(c[4:])-1)*(sum(c[2:])-2)//2
s+=sum(c[14:])*(sum(c[4:])-1)
s+=sum(c[24:])*(sum(c[2:])-1)
s+=sum(c[74:])
print(s)
n=int(input());A = list(map(int,input().split(' ')))
x = [0]*10001
for a in A:
    if a != 0:
        x[a-1]+=1;x[a]+=1;x[a+1]+=1
    else:
        x[a]+=1;x[a+1]+=1
print(max(x))

### FIXED CODE ###

n=int(input());A = list(map(int,input().split(' ')))
x = [0]*100001
for a in A:
    if a != 0:
        x[a-1]+=1;x[a]+=1;x[a+1]+=1
    else:
        x[a]+=1;x[a+1]+=1
print(max(x))
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

MOD = 10**9 + 7
INF = 10**20
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd
from math import gcd

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    ans += (s[i] != s[n-i])
print(ans)

### FIXED CODE ###


MOD = 10**9 + 7
INF = 10**20
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    ans += (s[i] != s[n-i-1])
print(ans)
N = int(input())

prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

a = 0
_count = []
ans = 0

for g in range(len(prime_number)):
	if prime_number[g] > N:
		break
	for i in range(1, 100):
		a += N//prime_number[g]**i
		if  prime_number[g]**i > N:
			_count.append(a)
			a=0
			break

if _count[0] >= 74:
	ans+=1

c_24 = []
c_14 = []
c_4 = []
c_2 = []
for n in range(len(_count)):
	if _count[n]>=24:
		c_24.append(_count[n])
	if _count[n]>=14:
		c_14.append(_count[n])
	if _count[n]>=4:
		c_4.append(_count[n])
	if _count[n]>=2:
		c_2.append(_count[n])

ans += len(c_14)*(len(c_4)-1)
ans += len(c_24)*(len(c_2)-1)
ans += (len(c_4)-1)*len(c_4)*(len(c_2)-2)/2

print(int(max(ans,0)))

### FIXED CODE ###

N = int(input())

prime_number = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

a = 0
_count = []
ans = 0

for g in range(len(prime_number)):
	if prime_number[g] > N:
		break
	for i in range(1, 100):
		a += N//prime_number[g]**i
		if  prime_number[g]**i > N:
			_count.append(a)
			a=0
			break

if N!=1:
	if _count[0] >= 74:
		ans+=1

c_24 = []
c_14 = []
c_4 = []
c_2 = []
for n in range(len(_count)):
	if _count[n]>=24:
		c_24.append(_count[n])
	if _count[n]>=14:
		c_14.append(_count[n])
	if _count[n]>=4:
		c_4.append(_count[n])
	if _count[n]>=2:
		c_2.append(_count[n])

ans += len(c_14)*(len(c_4)-1)
ans += len(c_24)*(len(c_2)-1)
ans += (len(c_4)-1)*len(c_4)*(len(c_2)-2)/2

print(int(max(ans,0)))
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()


# [ok, ng) - Maximum
# (ng, ok] - Minimum
# ok が 最終的な答え
ok = N
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    n = mid
    dp = set()
    dp.add(0)
    ans = set(x for x in range(max(0, K - A[n] + 1), K))
    for i in range(N):
        a = A[i]
        if i == n or a >= K:
            continue
        for j in range(K - a - 1, -1, -1):
            if j in dp:
                if j + a in ans:
                    rst = True
                    break
                else:
                    dp.add(j + a)
        else:
            rst = False
    if rst:
        ok = mid
    else:
        ng = mid
print(ok)


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()


    # [ok, ng) - Maximum
    # (ng, ok] - Minimum
    # ok が 最終的な答え
    ok = N
    ng = -1
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        n = mid
        dp = [0] * (K + 1)
        dp[0] = 1
        for i in range(N):
            a = A[i]
            if i == n or a >= K:
                continue
            for j in range(K, -1, -1):
                dp[min(K, j + a)] |= dp[j]
        rst = any(dp[k] for k in range(max(0, K - A[n]), K))
        if rst:
            ok = mid
        else:
            ng = mid
    print(ok)


main()
#unionfind木_

def find(k):#要素k
    if par[k] == k:
        return par[k]
    else:
        par[k] = find(par[k])
        return par[k]

def union(i, j):
    i = find(i)
    j = find(j)
    if i==j: return False
    else:
        if rank[i] == rank[j]:#ランクが同じ場合
            par[j] = par[i]
            rank[i] += 1
        if rank[j] > rank[i]:
            i, j = j, i
            par[i] = par[j]
        else:
            par[i] = par[j]

n, m= map(int, input().split())
par = list(range(n))#初めは自分自身が親
rank = [1]*n

for i in range(m):
    a, b = map(lambda x:int(x)-1, input().split())
    union(a, b)

ans = [0]*n
for i in range(n):
    ans[find(ini_list[i])]+=1
print(max(ans))

### FIXED CODE ###

#unionfind木_集合の管理_同じ集合の数を数える場合：
#parには集合の数と親の名前を同時にメモ化する（根なら-size, 子なら親）
def find(k):#要素k
    if par[k] < 0:#初期はparがすべて負の値
        return k
    else:
        par[k] = find(par[k])
        return par[k]

def unite(i, j):
    i = find(i)
    j = find(j)
    if i==j:#すでに同じ集合
        return False
    else:
        #sizeが大きい方がi
        if i > j:#sizeはマイナス管理なので、i>jの時jの方がサイズが大きい
            i, j = j, i
        par[i] += par[j] #親は負の値で大きくなる
        par[j] = i
        return True

def size(x):
    return -par[find(x)]

n, m= map(int, input().split())
par = [-1]*n#初めは自分自身が親

for i in range(m):
    a, b = map(lambda x:int(x)-1, input().split())
    unite(a, b)

ans = 0
for i in range(n):
    ans = max(ans, -par[i])
print(ans)
import sys,math,collections,itertools
input = sys.stdin.readline

H,W= list(map(int,input().split()))
a = [ list(map(int,input().split())) for _ in range(H)]
operation = []

#-奇数だったら右へずらしていく。偶数ならなにもしない-#
cnt = 0
for ih in range(H):
    for iw in range(W-1):
        if a[ih][iw]%2 == 0:
            continue
        else:
            a[ih][iw] -= 1
            a[ih][iw+1] += 1
            cnt += 1
            operation.append([ih+1,iw+1,ih+1,iw+2])
#-最右端を上から下まで-#
for ih in range(H-1):
    if a[ih][iw]%2 == 0:
        continue
    else:
        a[ih][W] -= 1
        a[ih][W+1] += 1
        cnt += 1
        operation.append([ih+1,W+1,ih+2,W+1])
print(cnt)
for ope in operation:
    print(*ope)


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

H,W= list(map(int,input().split()))
a = [ list(map(int,input().split())) for _ in range(H)]
operation = []

#-奇数だったら右へずらしていく。偶数ならなにもしない-#
cnt = 0
for ih in range(H):
    for iw in range(W-1):
        if a[ih][iw]%2 == 0:
            continue
        else:
            a[ih][iw] -= 1
            a[ih][iw+1] += 1
            cnt += 1
            operation.append([ih+1,iw+1,ih+1,iw+2])
#-最右端を上から下まで-#
for ih in range(H-1):
    if a[ih][W-1]%2 == 0:
        continue
    else:
        a[ih][W-1] -= 1
        a[ih+1][W-1] += 1
        cnt += 1
        operation.append([ih+1,W,ih+2,W])
print(cnt)
for ope in operation:
    print(*ope)
N = map(int, input().split())

if abs(N[2]-N[0]) <= N[3]:
	print(“Yes”)
elif abs(N[1]-N[0])+abs(N[2]-N[1]) <= 2*N[3]:
	print(“Yes”)
else:
	print(“No”)

### FIXED CODE ###

a,b,c,d = map(int, input().split())

if abs(c-a) <= d:
	print('Yes')
elif abs(b-a) <= d and abs(c-b) <= d:
	print('Yes')
else:
	print('No')
pi = 3.141592653589
r = int(input())
c = pi*r**2
s = 2*pi*r
print("{0:.7f} {1:.7f}".format(c,s))

### FIXED CODE ###

pi = 3.141592653589
r = float(input())
c = pi*r**2
s = 2*pi*r
print('%.5f %.5f' % (c,s))
n = int(input())
s = list(input())
m = 0
c1, c2 = 0, 0
for i in range(n):
    if s[i] == ")":
        m += 1
        c2 = c1
    else:
        c1 += 1
j = 0
while True:
    if s[j] == "(":
        break
    j += 1
l = max((m - c2), j)
s1 = ["("] * l
for i in s:
    if i == "(":
        l += 1
    else:
        l -= 1
s2 = [")"] * l
s = s1 + s + s2
print("".join(s))

### FIXED CODE ###

n = int(input())
s = list(input())
m = 0
l = 0
for i in range(n):
    if s[i] == ")":
        m += 1
    else:
        m -= 1
    if l < m:
        l = m
s1 = ["("] * l
for i in s:
    if i == "(":
        l += 1
    else:
        l -= 1
s2 = [")"] * l
s = s1 + s + s2
print("".join(s))
r = int(input(""))
g = int(input(""))
b = int(input(""))
d = r*100 + g*10 + b
if d % 4 == 0:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

r, g, b = map(str, input().split())
ans = r + g + b
# print(ans)
ans_i = int(ans)
 
if ans_i % 4 == 0:
    print('YES')
else:
    print('NO')
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B = a,b=map(int,input().split())
print(lcm(A, B))

### FIXED CODE ###

import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
A, B =map(int,input().split())
print(lcm(A, B))
>|python|
# -*- coding: utf-8 -*-

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

sum = 0
for i in range(2):
    if A >= B :
        sum = sum + A
        A = A - 1
    else:
        sum = sum + B
        B = B - 1

print(sum)
||<

### FIXED CODE ###

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

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

sum = 0
for i in range(2):
    if a>=b :
        sum=sum+a
        a=a-1
    else:
        sum=sum+b
        b=b-1

print(sum)
S=list(input())
S.append(0)
count=0
people=0
x=[]
x.append(-1)
y=[]
z=[]
for i in range(10**5):
    if S[i]==0:
        All = i
        y.append(0)
        break
    if S[i]=='L':
        if S[i+1]=="R":
            x.append(i)
        if S[i+1]==0:
            x.append(i)
    if S[i]=="R":
        if S[i+1]=="L":
            y.append(i)
for j in range(All):
    try:
        c=y[count+1]
    except IndexError:
        print(1)
    if j == y[count]:
        people=x[count+1]-x[count]
        if(people%2==0):
            z.append(people//2)
            z.append(people//2)
        else:
            if((y[count]-x[count])%2!=0):
                z.append(people//2+1)
                z.append(people//2)
            else:
                z.append(people//2)
                z.append(people//2+1)
    elif j-1==y[count]:
        count+=1
    else:
        z.append(0)
print(*z)

### FIXED CODE ###

S=list(input())
S.append(0)
count=0
people=0
x=[]
x.append(-1)
y=[]
z=[]
for i in range(10**5+1):
    if S[i]==0:
        All = i
        y.append(0)
        break
    if S[i]=='L':
        if S[i+1]=="R":
            x.append(i)
        if S[i+1]==0:
            x.append(i)
    if S[i]=="R":
        if S[i+1]=="L":
            y.append(i)
for j in range(All):
    if j == y[count]:
        people=x[count+1]-x[count]
        if(people%2==0):
            z.append(people//2)
            z.append(people//2)
        else:
            if((y[count]-x[count])%2!=0):
                z.append(people//2+1)
                z.append(people//2)
            else:
                z.append(people//2)
                z.append(people//2+1)
    elif j-1==y[count]:
        count+=1
    else:
        z.append(0)
print(*z)
def answer(in0, in1):
    even = {}
    odd = {}

    list = in1.split(" ")

    for i in range(len(list)):
        n = list[i]
        if i % 2 == 0:
            odd[n] = odd.get(n, 0) + 1
        else:
            even[n] = even.get(n, 0) + 1

    odd = sorted(
        [{'key': k, 'value': odd[k]} for k in odd],
        key=lambda x: (-x['value'], int(x['key'])))

    even = sorted(
        [{'key': k, 'value': even[k]} for k in even],
        key=lambda x: (-x['value'], int(x['key'])))

    oddMax = odd[0]
    evenMax = even[0]

    #print(odd)
    #print(even)

    # 奇数偶数ともにトップのキーが一緒
    if oddMax['key'] == evenMax['key']:
        # 文字列が全部同じだからどっちかを書き換えればOK
        if len(even) == 1 and len(odd) == 1:
            return int(int(in0) / 2)

        if oddMax['value'] > evenMax['value']:
            evenMax = even[1]
        else:
            oddMax = odd[1]

    oddCount = 0
    evenCount = 0

    for v in odd:
        if v['key'] != oddMax['key']:
            oddCount += v['value']

    for v in even:
        if v['key'] != evenMax['key']:
            evenCount += v['value']

    return oddCount + evenCount

print(answer(input(), input()))


### FIXED CODE ###

def answer(in0):

    result = ''

    for ch in str(in0):
        if ch == '9':
            result += '1'
        elif ch == '1':
            result += '9'

    return result


print(answer(input()))
n,m=map(int(input().split())
print((n-1)*(m-1))

### FIXED CODE ###

n,m=map(int,input().split())
print((n-1)*(m-1))
x = int(input())
for i in range(1,10):
  for  j in range(1,10):
    f = 0
    if(i*j==x):
      	f = 1
      	print("Yes")
      	break
  if(f==1):
 	break
if(f==0):
  print("No")

### FIXED CODE ###

x = int(input())
for i in range(1,10):
  for  j in range(1,10):
    f = 0
    if(i*j==x):
      	f = 1
      	print("Yes")
      	break
  if(f==1):
    break
  
if(f==0):
  print("No")
import numpy as np
input()
x = np.array(input().split(), dtype=np.int32)

ans = 0
while ( x % 2 == 0 ).all():
  	x //= 2
    ans += 1
print(ans)    

### FIXED CODE ###

import numpy as np
input()
x = np.array(input().split(),dtype=np.int32)

ans = 0
while (x%2==0).all():
  x //= 2
  ans += 1
print(ans)
N = int(input())
Carry = []
for i in range(5):
    Carry.append(int(input()))
min_num = min(Carry)
if N % min_num == 0:
    print((N//min(max_Carry)))
else:
    print((N//min(max_Carry))+5)

### FIXED CODE ###

N = int(input())
Carry = []
for i in range(5):
    Carry.append(int(input()))
min_num = min(Carry)
if N < min_num:
    print(5)
elif min_num == 1:
    print((N//min_num)+4)
elif N % min_num == 0:
    print((N//min_num))
else:
    print((N//min_num)+5)
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1 for i in range(n)]

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x]) # contraction
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.same(x, y):
            self.size[y] += self.size[x]
        self.par[x] = y

    def same(self, x, y):
        return self.find(x) ==  self.find(y)


n, m = map(int, input().split())
edge = []
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge.append((a, b))

uf = UnionFind(n)
ans = n * (n-1) // 2
anss = []
for i in reversed(range(m)):
    anss.append(ans)
    # print(uf.par)
    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])
    a, b = edge[i]
    if not uf.same(a, b):
        ans -= uf.size[uf.find(a)] * uf.size[uf.find(b)]
    # print(i, a, b)

    uf.unite(a, b)

for i in reversed(range(m)):
    print(anss[i])


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)


class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x]) # contraction
        return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if not self.same(x, y):
            self.size[y] += self.size[x]
        self.par[x] = y

    def same(self, x, y):
        return self.find(x) == self.find(y)


n, m = map(int, input().split())
edge = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]

uf = UnionFind(n)
ans = n * (n-1) // 2
anss = []
for i in reversed(range(m)):
    anss.append(ans)
    # print(uf.par)
    # print(uf.size, [uf.size[uf.find(i)] for i in range(n)])
    a, b = edge[i]
    if not uf.same(a, b):
        ans -= uf.size[uf.find(a)] * uf.size[uf.find(b)]
    # print(i, a, b)

    uf.unite(a, b)

for i in reversed(range(m)):
    print(anss[i])
from collections import defaultdict

vertice,edge = map(int,input().split(" "))
cost = [[0 if m == n else float("inf") for n in range(vertice)] for m in range(vertice)]
link = defaultdict(dict)
weight = defaultdict(dict)

for e in range(edge):
    i,j,w = map(int,input().split(""))
    link[i] = link.get(i,set()) | {j}
    weight[i].update({j:w})

vertice_cnt = 0
while 1:
    if vertice_cnt >= vertice:
        print("NEGATIVE CYCLE")
        break
    update = False
    for source in range(vertice)
        for k,value in link.items():
            for v in value:
                if cost[source][v] > cost[source][k] + weight[k][v]:
                    cost[source][v] = cost[source][k] + weight[k][v]
                    update = True
    if not update:
        for o in range(vertice):

            print(*([n if n != float("INF") else "INF" for n in cost[o]]))
        break
    vertice_cnt += 1

### FIXED CODE ###

vertices, edges = (int(n) for n in input().split(" "))
cost_dp = [[float("inf") if n != m else 0 for n in range(vertices)] for m in range(vertices)]
for e in range(edges):
    v1, v2, weight = (int(n) for n in input().split(" "))
    cost_dp[v1][v2] = weight
for neg in range(2):
    updated = 0
    for t in range(vertices):
        for i in range(vertices):
            for k in range(vertices):
                if cost_dp[i][k] > cost_dp[i][t] + cost_dp[t][k]:
                    updated = 1
                    cost_dp[i][k] = cost_dp[i][t] + cost_dp[t][k]
if neg == 1 and updated:
    print("NEGATIVE CYCLE")
else:
    for ve in range(vertices):
        ans = ["INF" if n == float("inf") else n for n in cost_dp[ve]]
        print(*ans)
import subprocess
import os
import time


import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

input = sys.stdin.readline


mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]


def find_n(x, y):
    moves = int((x+y)/3)
    for n in range(moves+1):
        if n + (moves-n)*2 == x and n*2 + (moves-n) == y:
            return n % mod, (moves-n) % mod


# def cmb(n, r):
#     return math.factorial(n) % mod // ((math.factorial(r) % mod) * (math.factorial(n-r) % mod))


def cmb(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n-r)

    return g1[n] * g2[r] * g2[n-r] % mod


def main():
    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)

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

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

    n, m = find_n(x, y)

    # n = int(((x*2 - y) // 3))
    # m = int(((y*2 - x) // 3))

    ans = cmb(n+m, n)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import subprocess
import os
import time


import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

input = sys.stdin.readline


mod = 10**9+7
N = 10**6
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]


# def find_n(x, y):
#     moves = int((x+y)/3)
#     for n in range(moves+1):
#         if n + (moves-n)*2 == x and n*2 + (moves-n) == y:
#             return n % mod, (moves-n) % mod


# def cmb(n, r):
#     return math.factorial(n) % mod // ((math.factorial(r) % mod) * (math.factorial(n-r) % mod))


def cmb(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n-r)

    return g1[n] * g2[r] * g2[n-r] % mod


def main():
    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)

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

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

    # n, m = find_n(x, y)

    n = int(((x*2 - y) // 3))
    m = int(((y*2 - x) // 3))

    ans = cmb(n+m, n)

    print(ans)


if __name__ == '__main__':
    main()
A, B, K = map(int, input().split())

A2=A-K
if A2<0:
    B2=B+A2
    A2=0
print(A2, B2)

### FIXED CODE ###

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


if A>=K:
    A2=A-K
    B2=B
elif A+B>=K:
    A2=0
    B2=A+B-K
else:
    A2=B2=0
print(A2, B2)
n = int(input())
count_ans = 0
for i in range(n//2 + 1):
  count_y = 0
  for j in range(i):
    if i%j == 0:
      count_y += 1
  if count_y == 8:
    count_ans += 1
print(count_ans)

### FIXED CODE ###

n = int(input())
count_ans = 0
for i in range(n//2 + 1 if n%2 ==1 else n//2):
  count_y = 0
  for j in range(2*i+2):
    if j > 0:
      if (2 * i + 1)%j == 0:
        count_y += 1
  if count_y == 8:
    count_ans += 1
print(count_ans)
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, K = il()
    A = il()
    B = il()
    aq, bq = 0, 0
    time, ret = 0, 0

    for _ in range(N+M):
        if aq < N and A[aq] < B[bq] and A[aq] + time <= K:
            time += A[aq]
            ret += 1
            aq += 1
        elif bq < M and B[bq] + time <= K:
            time += B[bq]
            ret += 1
            bq += 1
        else:
            break
    print(ret)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, K = il()
    A = list(itertools.accumulate([0] + il()))
    B = list(itertools.accumulate(([0] + il())))

    ret, m = 0, M
    for n in range(N+1):
        if A[n] > K:
            break

        while B[m] > K - A[n]:
            m -= 1
        ret = max(ret, n+m)
    print(ret)




if __name__ == '__main__':
    main()