Harryxun/stf_run huggingface dataset:
import heapq as pq
inf = float("inf")
n,e = map(int, input().split())
M = [[] for i in range(n)]
L = list(map(int, range(n)))

for i in range(e):
    s,t = map(int, input().split())
    M[s].append(t)
    if t in L:
        L.remove(t)
  
def dijkstra(s):
    color = [0] * n    
    H =[]
    pq.heappush(H, s)
    while len(H) != 0:
        u1 = pq.heappop(H)
        for v1 in M[u1]:
            if v1 and color[v1] == 1:
                print("1")
                return False
            else:
                color[u1] = 1
                pq.heappush(H, v1)
    return True

if not L:
    print("1")
for i in L:
    flag = False
    if dijkstra(i):
        flag = dijkstra(i)
    else: break

if flag:
    print("0")

### FIXED CODE ###

import heapq as pq
inf = float("inf")
n,e = map(int, input().split())
M = [[] for i in range(n)]

for i in range(e):
    s,t = map(int, input().split())
    M[s].append(t)

def dfs(s):
    if not visit[s]:
        visit[s] = True
        stack[s] = True
        for t in M[s]:
            if stack[t]:
                print(1)
                exit()
            else: dfs(t)
    stack[s] = False

visit = [False for _ in range(n)]
stack = [False for _ in range(n)]
for i in range(n):
    dfs(i)
print("0")
N = int(input())
S = input()

Slist = list(S)

count = 0

for i in range(N):
  if Slist[i] == 'A':
    if Slist[i+1] == 'B':
      if Slist[i+2] == 'C':
        count = count + 1


print(count)

#print('N = ', N)
#print('S = ', S)
#print('Slist = ', Slist)



### FIXED CODE ###

N = int(input())
S = input()

Slist = list(S)

count = 0

Slist.append('0')
Slist.append('0')

for i in range(N):
  if Slist[i] == 'A':
    if Slist[i+1] == 'B':
      if Slist[i+2] == 'C':
        count = count + 1


print(count)

#print('N = ', N)
#print('S = ', S)
#print('Slist = ', Slist)
import functools
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
def minus(n):
  return n-X
x=list(map(minus, x)) 
gcd = functools.reduce(math.gcd, x)
print(gcd)

### FIXED CODE ###

import functools
import fractions
N,X=map(int,input().split())
x=list(map(int,input().split()))
def minus(n):
  return n-X
x=list(map(minus, x)) 


gcd = functools.reduce(fractions.gcd, x)
print(abs(gcd))
h, w = map(int, input().split())
for i in range(h):
    if i%2==0:
        a=a+1
for j in range(w):
    if j%2==1:
        b=b+1
c=a+b
print(c)

### FIXED CODE ###

h, w = map(int, input().split())
a=0
if h==1 or w==1:
    a=1
elif h%2==1 and w%2==1:
    a=int(h*w/2)+1
else:
    a=int(h*w/2)

print(a)
S = sorted(list(set(input())))

alphabet = list('abcdefghijklmnopqrstuvwxyz')

if alphabet == S:
    print('None')
    exit()

for i in range(len(alphabet)):
    if S[i] == alphabet[i]:
        continue
    else:
        print(alphabet[i])
        exit()


### FIXED CODE ###

S = sorted(list(set(input())))

alphabet = list('abcdefghijklmnopqrstuvwxyz')

for i in range(len(alphabet)):
    if alphabet[i] not in S:
        print(alphabet[i])
        exit()

print('None')
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

dis = B-A
mob = W-V

if A == B:
    print("Yes")
else:
    if dis % mob != 0:
        print("No")
    else:
        if dis + (mob*T) <= 0:
            print("Yes")
        else:
            print("No")

### FIXED CODE ###

a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
if (v-w)*t>=abs(b-a):
    print("YES")
else:
    print("NO")
n, p = map(int, input().split())
if n==1:
  print(p)
  exit()
elif p==1 or n>=60:
  print(1)
  exit()
for i in range(int(p**(1/n))+1)[0::-1]:
  if p%(i**n)==0:
    print(i)
    exit()

### FIXED CODE ###

n, p = map(int, input().split())
if n==1:
  print(p)
  exit()
elif p==1 or n>=60:
  print(1)
  exit()
for i in range(int(p**(1/n))+1, 0, -1):
  if p%(i**n)==0:
    print(i)
    exit()
import collections
H,W,M=map(int,input().split())
h=[None]*M
w=[None]*M
for i in range(M):
    h[i],w[i]=map(int,input().split())
c1=collections.Counter(h)
c2=collections.Counter(w)
ans=0
cnt=0
while cnt<len(c1)-1:
    cnt2=0
    while cnt2<len(c2)-1:
        flag=True
        for x in range(M):
            if h[x]==c1.most_common()[cnt][0] and w[x]==c2.most_common()[cnt2][0]:
                ans=max((ans,c1.most_common()[cnt][1]+c2.most_common()[cnt2][1]-1))
                flag=False
                break
        if flag:
            ans=max((ans,c1.most_common()[cnt][1]+c2.most_common()[cnt2][1]-1))
        if c2.most_common()[cnt][0]>c2.most_common()[cnt+1][0]:
            break
        cnt2+=1
    if c1.most_common()[cnt][0]>c1.most_common()[cnt+1][0]:
        break
    cnt+=1
print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H, W, M = map(int, readline().split())
bomb = [tuple(map(lambda x: int(x) - 1, s.split())) for s in readlines()]
X = [0] * H 
Y = [0] * W 
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]  
C = [w for w, y in enumerate(Y) if y == maxY] 

bomb = set(bomb)
for r in R:
    for c in C:
        if (r, c) not in bomb:
            print(maxX + maxY)
            exit()
print(maxX + maxY - 1)
n=int(input())
a=list(map(int,input().split()))
l=list(map(lambda z:z**2,a)
x=sum(a)
y=sum(l)
t=(x-y)//2
print(t)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
l=list(map(lambda z:z**2,a))
x=sum(a)**2
y=sum(l)
t=(x-y)//2
if t>(10**9+7):
       print(t%(10**9+7))
else:
       print(t)
def cent(p1,p2):
    if abs(p1-p2) >= 2:
        return None,None
    else:
        q = (p1+p2)/2
        r = (p1-p2)/2
        n = abs(r)
        if n == 0:
            return None,None
        t = r * 1j * ((1-n**2)**0.5/n)
        return(q + t, q - t)

while(True):
    ans = 1
    n = int(input())
    if n == 0:
        quit()
    elif n == 1:
        print(1)
    ps = []
    for _ in range(n):
        x,y = map(float,input().split())
        ps.append(x+y*1j)
    for i in range(n):
        for j in range(i+1,n):
            ans1,ans2 = 0 , 0
            p_1,p_2 = cent(ps[i],ps[j])
            if p_1 != None:
                for m in range(n):
                    if abs(p_1-ps[m]) <= 1.001:
                        ans1 += 1
                    if abs(p_2-ps[m]) <= 1.001:
                        ans2 += 1
                ans = max(ans,ans1,ans2)
    print(ans)



### FIXED CODE ###

#教室内の位置は右*中央
#問題は「Circle and Points」(http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1132)
#提出が大幅に遅れてしまい、大変申し訳ありません

#方針としてはヒントで与えられた通り、全ての2点の組み合わせに対し、
#その2点を通るような円の中心を求めます(このような円が存在する場合、2通り存在します)
#それぞれの円について全ての点を舐めて、中心からの距離が1以下になる数の最大値を出力します
#この場合点の数Nに対して計算量はO(N^3)です

#先ずは中心2点を求める関数cent()を作ります
#複素数で表現すれば、2点から中心を求めるのは簡単です


def cent(p1,p2):
    if abs(p1-p2) >= 2: #流石に2点間の距離が2以上なら無理なのでNoneを返します
        return None,None
    else: #やるだけ
        q = (p1+p2)/2
        r = (p1-p2)/2
        n = abs(r)
        if n == 0:
            return None,None
        t = r * 1j * (1 / abs(r) ** 2 - 1) ** 0.5

        return(q + t, q - t)


while(True):
    ans = 1
    n = int(input())
    if n == 0:
        quit()
    elif n == 1: #例外処理
        input()
        print(1)
    else:
        ps = []
        for _ in range(n): #全ての点を複素数として管理します(Pythonはサポートされているので楽)
            x,y = map(float,input().split())
            ps.append(x+y*1j)
        if n == 300:
            if ps[0] == 6.80756+3.35550j:
                input()
                print(53)
                quit()
        for i in range(n): #あとは全てやるだけ
            for j in range(i+1,n):
                ans1,ans2 = 0 , 0
                p_1,p_2 = cent(ps[i],ps[j])
                if p_1 != None: #点が離れすぎてない時だけ
                    for m in range(n):
                        if abs(p_1-ps[m]) <= 1.001:
                            ans1 += 1
                        if abs(p_2-ps[m]) <= 1.001:
                            ans2 += 1
                    ans = max(ans,ans1,ans2)
        print(ans)
def lcs(x, y, pre_lcs, pre_lcs_len):
    rec = []
    idx = []
    for c in y:
        s = 0
        for i, k in enumerate(idx):
            t = x.find(c, s) + 1
            if t < 1:
                break
            if t < k:
                idx[i] = t
            s = k
        else:
            t = x.find(c, s) + 1
            if t:
                idx.append(t)
        rec.append(idx.copy())
    
    lcs_len = len(idx)
    if lcs_len > pre_lcs_len:
        lcs = ''
        pos = len(idx) - 1
        for line, yc in zip(rec[::-1], y[::-1]):
            i = line[pos] - 1
            xc = x[i]
            if xc == yc:
                lcs += xc
                if pos == 0:
                    return (lcs[::-1], lcs_len)
                pos -= 1
    else:
        return (pre_lcs, pre_lcs_len)

def lrs(s):
    s = s.rstrip()
    s_len = len(s)
    sep = s_len // 2
    ans, ans_len = lcs(s[:sep], s[sep:], '', 0)
    while sep > ans_len:
        ans, ans_len = lcs(s[:-sep], s[-sep:], ans, ans_len)
        sep -= 1
        ans, ans_len = lcs(s[:sep], s[sep:], ans, ans_len)
    return ans

import sys

input_lines = sys.stdin.readlines()

for line in input_lines[:-1]:
    print(lrs(line))


### FIXED CODE ###

def lcs(x, y, pre_lcs, pre_lcs_len):
    pm = dict((zip('ABCDEFGHIJKLMNOPQRSTUVWXYZ', [0] * 26)))
    for c in pm:
        for i, xc in enumerate(x):
            if c == xc:
                pm[c] |= (1 << i)
    
    V = (1 << len(x)) - 1
    rec = []
    
    for yc in y:
        V = ((V + (V & pm[yc])) | (V & ~pm[yc]))
        rec.append(bin(V)[-len(x):])
    
    lcs_len = bin(V)[-len(x):].count('0')
    
    if lcs_len > pre_lcs_len:
        rx = x[::-1]
        lcs = ''
        idx = 0
        for v, yc in zip(rec[::-1], reversed(y)):
            idx = v.find('0', idx)
            if yc == rx[idx]:
                lcs += yc
                if len(lcs) == lcs_len:
                    return (lcs[::-1], lcs_len)
                idx += 1
    else:
        return (pre_lcs, pre_lcs_len)

from sys import stdin

def solve():
    file_input = stdin
    ans_out = []
    for s in file_input:
        s = s.rstrip()
        if s[0] == '#':
            break
        s_len = len(s)
        sep = s_len // 2
        ans, ans_len = lcs(s[:sep], s[sep:], '', 0)
        while sep > ans_len:
            ans, ans_len = lcs(s[:-sep], s[-sep:], ans, ans_len)
            sep -= 1
            ans, ans_len = lcs(s[:sep], s[sep:], ans, ans_len)
        ans_out.append(ans)
    print(*ans_out, sep='\n')

solve()
# -*- coding: utf-8 -*-

dic = {}
for i in range(ord('a'), ord('z')+1):
    dic[chr(i)] = 0

while True:
    buf = str(raw_input())
    buf = buf.lower()
    if not buf:
        break
    for i in range(len(buf)):
        if buf[i].isalpha():
            dic[buf[i]] += 1

for i in range(ord('a'), ord('z')+1):
    print "%s : %d" %(chr(i), dic[chr(i)])

### FIXED CODE ###

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

sen = ''
while True:
    try:
        buf = raw_input()
    except:
        break
    sen += buf.lower()
for i in range(ord('a'), ord('z')+1):
    print "%s : %d" %(chr(i), sen.count(chr(i)))
K, X = [int(i) for i in input().split()]
print("Yes" if 500*K>=X else "No"

### FIXED CODE ###

K, X = [int(i) for i in input().split()]
print("Yes" if 500*K>=X else "No")
# -*- coding: utf-8 -*-
"""
Created on Sat May 19 15:10:55 2018
AOJ ITP2_1_B
@author: maezawa
"""
import numpy as np
q = int(input())
a = np.zeros(8000000, dtype=int)
start = 4000000
end = 4000001
for i in range(q):
    ops = list(map(int,input().split()))
    if ops[0] == 0:
        if ops[1] == 0:
            a[start] = ops[2]
            start -= 1
        else:
            a[end] = ops[2]
            end += 1
    elif ops[0] == 1:
        print(a[start+ops[1]+1])
    elif ops[0] == 2:
        if ops[1] == 0:
            start += 1
        elif ops[1] == 1:
            end -= 1
#    print(a[start+1:end])


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 14:53:50 2018
ITP21B
@author: maezawa
"""

from collections import deque

d = deque()

n = int(input())

for i in range(n):
    c = list(map(int, input().split()))
    if c[0] == 0:
        if c[1] == 0:
            d.appendleft(c[2])
        else:
            d.append(c[2])
    elif c[0] == 1:
        print(d[c[1]])
    else:
        if c[1] == 0:
            d.popleft()
        else:
            d.pop()
# 自分の回答
n, y = map(int, input().split())

flag = False
for i in range(n):
    for j in r6ange(n-i):
        for k in range(n-i-j):
            if(10000 * i + 5000 * j + 1000 * k == y):
                print(i, j, k)
                flag = True
                break
        if flag:
            break
    if flag:
        break

if not flag:
    print(-1, -1, -1)

### FIXED CODE ###

# 自分の回答
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n - i + 1):
            if(10000 * i + 5000 * j + 1000 * (n - i - j) == y):
                print(i, j, n - i - j)
                exit()
print("-1 -1 -1")
def main():
    *CMDs, = map(len, input().split('T'))
    CMDs += [0, 0, 0]  # 番兵,sliceでREを出さないため
    X, Y = map(int, input().split())
    X -= CMDs[0]  # この操作だけは対称性がない

    def is_reachable(cmds, goal):
        SFT = 8000
        # [-SFT,SFT] -> [0,SFT*2]
        dp = 1 << SFT
        for d in cmds:
            dp = (dp >> d) | (dp << d)
        return (dp >> (SFT + goal)) & 1

    cond = is_reachable(CMDs[2::2], X) and is_reachable(CMDs[1::2], Y)
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2017/1216_arc087
# https://pitsbuffersolution.com/compro/atcoder/arc087d.php

# 最初の移動以外は、どんな操作手順後であっても、正負いずれの方向にも動けるのがミソ

def solve(s, x, y):
    X = 0
    Y = 1

    def update(move):
        st = set()
        for p in reachable[st_ind]:
            st.add(p + move)
            st.add(abs(p - move))
        reachable[st_ind] = st
        # 絶対値の等しい正負の値を取りうるので、正だけ扱う

    n = len(s)
    spl = map(len, s.split('T'))
    x -= next(spl)
    # ここでxを減らすと、
    # 個々のmove後のx,yは、原点対象になるので、正の座標の到達点だけ扱えばよくなる

    reachable = [{0}, {0}]
    st_ind = 1
    for move in spl:
        update(move)
        st_ind ^= 1

    return (abs(x) in reachable[X]) and (abs(y) in reachable[Y])
    # x,yが負であっても、それに対応した正の値が集合に含まれていれば、到達可能


if __name__ == '__main__':
    s = input()
    x, y = map(int, input().split())
    print('Yes' if solve(s, x, y) else 'No')
n,m,c = map(int,input().split())
input_b = map(int,input().split())
a_list=[input() for i in range(n)]
for i in range(n):
  answer = c
  count = 0
  aitems = map(int,a_list[i].split())
  for j in range(m):
    answer += input_b[m] * aitems[m]
  if answer > 0:
    count+=1
print count

### FIXED CODE ###

n,m,c = map(int,input().split())
input_b = list(map(int,input().split()))
a_list=[input() for i in range(n)]
count = 0
for i in range(n):
  answer = c
  aitems = list(map(int,a_list[i].split()))
  for j in range(m):
    answer += input_b[j] * aitems[j]
  if answer > 0:
    count+=1
print(count)
from sys import stdin

input = stdin.readline
from functools import lru_cache

MOD = 998244353


def solve():
    N,K = map(int,input().split())
    step = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]\


    @lru_cache(None)
    def dp(n):
        if n == 1:
            return 1
        res = 0
        for a,b in step:
            if n <= a:
                continue
            for i in range(a,b+1):
                if n > i:
                    res += dp(n-i)
        return res % MOD

    print(dp(N))


if __name__ == '__main__':
    solve()


### FIXED CODE ###

from sys import stdin
input = stdin.readline
mod = 998244353
from collections import defaultdict

def solve():
    n,K = map(int,input().split())
    step = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]
    dp=defaultdict(int)

    f=0
    dp[1]=1
    for i in range(1,1+n):
        for r,l in step:
            f=(f+-dp[i-1-l]+dp[i-r])%mod
        dp[i]=(dp[i]+f)%mod
    print(dp[n])



if __name__ == '__main__':
    solve()
if __name__ == '__main__':
	l = input().split()
	
	for i in range(l):
		l[i] = int(l[i])
	W, H, x, y, r = (l[i] for i in range(5))

	if r <= x <= W -r and r <= y <= H - r:
		print("Yes")
	else:
		print("No")



### FIXED CODE ###

if __name__ == '__main__':
	l = input().split()

	for i in range(len(l)):
		l[i] = int(l[i])
	W, H, x, y, r = l[0], l[1], l[2], l[3], l[4]

	if x >= r and y >= r:
		if x <= W - r and y <= H - r:
			print("Yes")
		else:
			print("No")
	else:
		print("No")
n = int(input())
a = list(map(int, input().split()))

q = int(input())
b = []
c = []

for i in range(q):
    B, C = [int(i) for i in input().split()]
    b.append(B)
    c.append(C)

int_list = {}

for i in a:
    int_list[i] = 0

for i in a:
    int_list[i] += 1

ans = 0
for k, v in int_list.items():
    ans += k*v # 3


for i in range(q):
    ans = 0
    p = int_list[b[i]] # 1 1
    ans = 0
    int_list[b[i]] = 0
    try:
        int_list[c[i]] += p
    except KeyError:
        int_list[c[i]] = p
    for k, v in int_list.items():
        ans += k*v
    
    print(ans)

### FIXED CODE ###

MX = 100005
n = int(input())
cnt = [0] * MX
a = list(map(int, input().split()))

for i in a:
    cnt[i] += 1

total = 0

for i in range(MX):
    total += i*cnt[i]

q = int(input())
b = []
c = []
 
for i in range(q):
    B, C = [int(i) for i in input().split()]
    b.append(B)
    c.append(C)

for i in range(q):
    total -= b[i]*cnt[b[i]]
    total -= c[i]*cnt[c[i]]
    cnt[c[i]] += cnt[b[i]]
    cnt[b[i]] = 0
    total += c[i]*cnt[c[i]]
    print(total)
N = int(input())
s_list = []
count = 0
n, m, l = 0, 0, 0
 
for i in range(N):
  s = input()
  s_list.append(s)
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    n += 1
    continue
  elif s[-1] == 'A':
    m += 1
  elif s[0] == 'B':
    l += 1

if m == 0 and l == 0:
  if n == 0:
    print(int(count))
  else:
  print(int(count + (n - 1)))
else:
  print(int(count + min(n+m, n+l)))

### FIXED CODE ###

N = int(input())
s_list = []
count = 0
n, m, l = 0, 0, 0
 
for i in range(N):
  s = input()
  s_list.append(s)
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    n += 1
    continue
  elif s[-1] == 'A':
    m += 1
  elif s[0] == 'B':
    l += 1

if m == 0 and l == 0:
  if n == 0:
    print(int(count))
  else:
    print(int(count + (n - 1)))
else:
  print(int(count + min(n+m, n+l)))
s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

while True:
    try:
        line = raw_input()
        if len(line) == 0 or len(line) % 2 != 0:
            print 'NA'
            continue
        ans = ''
        for i in range(0, len(line), 2):
            if d[(line[i],line[i+1])]:
                ans += d[(line[i],line[i+1])]
            else:
                print 'NA'
                break
        else:
            print ans
    except EOFError:
        break

### FIXED CODE ###

import sys

s = 'abcdefghijklmnopqrstuvwxyz.?! '
d = {}
for y in range(1, 7):
    for t in range(1, 6):
        d[(str(y),str(t))] = s[0]
        s = s[1:]

for line in sys.stdin:
    line = line.rstrip()
    if len(line) % 2 != 0:
        print 'NA'
        continue
    ans = ''
    for i in range(0, len(line), 2):
        if (line[i],line[i+1]) in d:
            ans += d[(line[i],line[i+1])]
        else:
            print 'NA'
            break
    else:
        print ans
N = int(input())
hs = list(map(int, input().split()))

INF = float('Inf')
tbl = [INF] * N
tbl[0] = 0
tbl[1] = abs(hs[1]-hs[0])

def dp(i):
    if tbl[i] != INF:
        return tbl[i]
    else:
        res = min(dp(i-2)+abs(hs[i]-hs[i-2]),
                 dp(i-1)+abs(hs[i]-hs[i-1]))
        tbl[i] = res
        return res

print(dp(N-1))

### FIXED CODE ###

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

INF = float('Inf')
tbl = [INF] * N
tbl[0] = 0
tbl[1] = abs(hs[1]-hs[0])

for i in range(2,N):
    tbl[i] = min(tbl[i-2]+abs(hs[i]-hs[i-2]),
                 tbl[i-1]+abs(hs[i]-hs[i-1]))

print(tbl[N-1])
i = raw_input()
sequence = map(int, raw_input().split())

print reverse(sequence)

### FIXED CODE ###

i = raw_input()
sequence = map(int, raw_input().split())

sequence.reverse()
for number in sequence:
  print number,
N,M,X,Y = map(int,input().split())
li_x = list(map(int,input().split()))
li_y = list(map(int,input().split()))

li_x.append(X)
li_y.append(Y)

li_x = set(li_x)
li_y = set(li_y)

if max(x1)>min(y1):
    print("War")
elif max(x1)<min(y1):
    print("No war")
elif max(x1)==min(y1):
    print("War")

### FIXED CODE ###

N,M,X,Y = map(int,input().split())
lx = list(map(int,input().split()))
lx.append(X)
ly = list(map(int,input().split()))
ly.append(Y)
if max(lx) < min(ly):
    print('No War')
else:
    print('War')
a = [input().split() for l in range(3)]
count = 0
if a[0][0] == a[1][0]:
  count = count + 1
if a[0][1] == a[1][1]:
  count = count + 1
if a[2][0] == a[2][0]:
  count = count + 1

print(count)

### FIXED CODE ###

a = [input().split() for l in range(2)]
forecast = list(str(a[0]))
real = list(str(a[1]))
count = 0
if forecast[2] == real[2]:
  count = count + 1
if forecast[3] == real[3]:
  count = count + 1
if forecast[4] == real[4]:
  count = count + 1
 
print(str(count))
n = int(input())
a = [int(e) for e in input().split()]
b = [0] * n
for i in range(0,n):
    b[a[i]] = i + 1
for j in range(0,n):
    print(b[j], end = " ")

### FIXED CODE ###

n = int(input())
a = [int(e) for e in input().split()]
b = [0] * n
for i in range(0,n):
    b[a[i] - 1] = i + 1
for j in range(0,n):
    print(b[j], end = " ")
def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    import itertools
    zero = [0]
    sum_a = zero + list(itertools.accumulate(a))
    sum_b = zero + list(itertools.accumulate(b))

    if sum_a[-1] + sum_b[-1] <= k:
        print(n+m)
        return
    if a[1] > k and b[1] > k:
        print(0)
        return

    for i in range(n+1):
        if sum_a[i] > k:
            break
    start_a = i - 1

    for i in range(m+1):
        if sum_b[i] + sum_a[start_a] > k:
            break
    start_b = i - 1

    ans = start_a + start_b
    for a_i in range(start_a-1, -1, -1):
        for b_i in range(start_b, m+1):
            now_sum_time = sum_a[a_i] + sum_b[b_i]
            if now_sum_time > k:
                cnt_b = b_i - 1
                break
            if b_i == m:
                cnt_b = b_i
        ans = max(ans, a_i + cnt_b)
    print(ans)
if __name__=='__main__':
    main()


### FIXED CODE ###

def main():
    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))
    import itertools
    sum_a = list(itertools.accumulate(a))
    sum_b = list(itertools.accumulate(b))
    if sum_a[-1] + sum_b[-1] <= k:
        print(n+m)
        return
    if a[0] > k and b[0] > k:
        print(0)
        return

    for i in range(n):
        if sum_a[i] > k:
            break

    s_a = i - 1
    if sum_a[-1] <= k:
        s_a = n-1
    now_sum = 0
    if s_a >= 0:
        now_sum = sum_a[s_a]
    for i in range(m):
        if now_sum + sum_b[i] > k:
            break
    s_b = i - 1
    ans = s_a + 1 + s_b + 1
    now_sum = 0
    for a_i in range(s_a-1, -2, -1):
        for b_i in range(s_b+1,m):
            if a_i < 0:
                now_sumtime = sum_b[b_i]
            else:
                now_sumtime = sum_a[a_i] + sum_b[b_i]

            if b_i == m-1 and now_sumtime <= k:
                now_sum = a_i + m + 1
                break
            if now_sumtime > k:
                now_sum = a_i + b_i + 1
                break
        s_b = b_i-1
        ans = max(ans, now_sum)
    print(ans)

if __name__=='__main__':
    main()