Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
ans=0

group = [0]*n
group_num = 1

for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    a1 = group[a]  
    b1 = group[b]
    if a1 == 0 and b1 == 0:
        group[a] = group_num
        group[b] = group_num
        group_num += 1
    elif a1 != 0:
        group[b] = a1
    else:
        group[a] = b1

group.sort()
group_num1 = 1
cnt = 1

if m != 0:
    for i in range(group.index(1)+1,n):
        if group[i] == group[i-1]:
            cnt += 1
        else:
            ans = max(ans,cnt)
            cnt = 1
    ans = max(ans,cnt)
    print(ans)
else:
    print(1)

### FIXED CODE ###

from collections import deque
n,m=map(int,input().split())
ans=0


group = [set() for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    group[a].add(b)
    group[b].add(a)


kisyutu = set()
deque = deque()

for i in range(n):
    if i not in kisyutu:
        kisyutu.add(i)
        friend_set=group[i]

        deque.extend(group[i])

        while deque:
            a1 = deque.pop()
            if a1 not in kisyutu:
                kisyutu.add(a1)
                friend_set.add(a1)
                deque.extend(group[a1])
        ans = max(ans, len(friend_set)+1)

if m!=0:
    print(ans)
else:
    print(1)
d = input().split()
a = input().split()
p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),
(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]
t, f = d.index(a[0]), d.index(a[1])
r = p[t][f]
l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]
print("Yes") if a == l else print("No")


### FIXED CODE ###

d = input().split()
a = input().split()
p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),
(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]
ts = [i for i, x in enumerate(d) if x == a[0]]
fs = [i for i, x in enumerate(d) if x == a[1]]
b = 0
for t in ts:
  for f in fs:
    if t == f: continue
    r = p[t][f]
    if r == -1: continue
    l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]
    if a == l: b += 1; break
print("Yes") if b > 0 else print("No")
n, m = map(int, input().split())
result = [0 for _ in range(m)]
for i in range(m):
    a, b = map(int, input().split())
    result[a-1] += 1
    result[b-1] += 1

for j in result:
    print(j)



### FIXED CODE ###

n, m = map(int, input().split())
result = [0 for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    result[a-1] += 1
    result[b-1] += 1

for j in result:
    print(j)
from math import gcd 
n=int(input())
mod = 10**9+7
count = {}

for _ in range(n):
    a,b = map(int,input().split())
    if a==0 and b==0:
        continue
    if a*b != 0:
        g=gcd(a,b)*b//abs(b)
    elif a != 0:
        g=a
    else:
        g=b
        
    x=a//g,b//g
    count[x]=count.get(x,0)+1
        
mem=set()
ans=1
for (x,y),z in count.items():
    if (-1*x//abs(x)*y,abs(x)) in mem:
        continue
    mem.add((x,y))
    ans*=pow(2,z)+pow(2,count.get((-1*x//abs(x)*y,abs(x)),0)-1
    ans%=mod

print((ans-1)%mod)

### FIXED CODE ###

from math import gcd 
n=int(input())
mod = 10**9+7
count = {}

num=0
for _ in range(n):
    a,b = map(int,input().split())
    if a==0 and b==0:
        num+=1
        continue
    if a*b != 0:
        g=gcd(a,b)*(b//abs(b))
    elif a != 0:
        g=a
    else:
        g=b
        
    l=a//g,b//g
    count[l]=count.get(l,0)+1
        
mem=set()
ans=1
for (x,y),z in count.items():
    if x*y==0:
        k=(y,x)
    else:
        k=(-1*x//abs(x)*y,abs(x))
    if k in mem:
        continue
    mem.add((x,y))
    ans*=(pow(2,z)+pow(2,count.get(k,0))-1)
    ans%=mod

print((ans+num-1)%mod)
n,m=map(int,input().split())
l=list(map(int,input().split()))
b=True
while b:
  b1=False
  l1=list(str(n))
  for i in l1:
    if i in l:
      b1=True
  if b1=False:
    b=True
    print(n)
    break
  else:
    n+=1

### FIXED CODE ###

n,m=map(int,input().split())
l=list(map(int,input().split()))
b=True
while b:
  b1=False
  l1=list(str(n))
  for i in l1:
    if int(i) in l:
      b1=True
  if b1==False:
    b=False
    print(n)
    break
  else:
    n+=1
n = int(input())
s = input()
k = int(input())
for i in range(len(s))
	if s[i] != s[k-1]
  		s[i] = "*"
print(s)


### FIXED CODE ###

input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")
n,k = map(int,input().split())
a = list(map(int,input().split()))
#"tel"は既に訪れている町
tel = set()
route = []
#"town"は今いる町
town = 1
route.append(town)
tel.add(town)
time_loop = 0
for i in range(k):
    town = a[town-1]
    if town in tel:
        time_loop += 1
        break
    tel.add(town)
    route.append(town)
    #テレポートした回数をカウント
    time_loop += 1

#"start"は"route"内のループの起点のとなる町のインデックス番号
start = route.index(town)
k = (k - start) % (time_loop - start)
print(route[k+start])




### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
#"tel"は既に訪れている町
tel = set()
route = []
#"town"は今いる町
town = 1
route.append(town)
tel.add(town)
time_loop = 0
for i in range(k):
    town = a[town-1]
    if town in tel:
        time_loop += 1
        break
    tel.add(town)
    route.append(town)
    #テレポートした回数をカウント
    time_loop += 1

#"start"は"route"内のループの起点のとなる町のインデックス番号
start = route.index(town)
if time_loop != start:
    k = (k - start) % (time_loop - start)
    print(route[k+start])
else:
    print(town)
[N, D] = input().split()
s = 0
D = int(D)
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D**2:
        s +=1
print(s)        

### FIXED CODE ###

[N, D] = input().split()
s = 0
N = int(N)
D = int(D)
D = D**2
for i in range(N):
    [X, Y] = input().split()
    X = int(X)
    Y = int(Y)
    Z = X**2 + Y**2
    if Z <= D:
        s += 1
print(s)
N, M = map(int, input().split())
A = [int(input()) for i in range(M)]

from functools import lru_cache
@lru_cache(maxsize=None)
def fibo(n):
    if n in A:
        return 0
    elif n == 0 or n == 1:
        return 1
    return fibo(n-1) + fibo(n-2)

print(fibo(N) % 1000000007)

### FIXED CODE ###

N, M = map(int, input().split())
A = set([int(input()) for i in range(M)])
t = 10**9+7
import sys
sys.setrecursionlimit(500000)
from functools import lru_cache
@lru_cache(maxsize=None)
def fibo(n):
    if n in A:
        return 0
    elif n == 0 or n == 1:
        return 1
    return (fibo(n-2) + fibo(n-1)) % t
print(fibo(N) % t)
#coding utf=8
a,b = map(int,input().split())
if a > b:
print(“a > b”)
elif a < b:
print(“a < b”)
else:
print(“a == b”)


### FIXED CODE ###

a,b = map(int, input().split())
if a > b:
 print("a > b")
elif a < b:
 print("a < b")
else:
 print("a == b")
S = input()
L = len(S)
N = 0

for i in range(L - 3):
    for j in range(4,L - i+1):
        P = int(S[i:i + j])
        if P % 3 == 0:
            if P % 2019 == 0: N += 1

print(N)

### FIXED CODE ###

list = list(map(int, input().split()))
S = list[0]
W = list[1]
if W >= S: print("unsafe")
else: print("safe")
a = int(input())
b = int(input())
print(2*c-a)

### FIXED CODE ###

a = int(input())
b = int(input())
print(2*b-a)
N,M=map(int, input().split())
A=[list(map(int, input().split()))  for _ in range(M)]
A = sorted(A, reverse=False, key=lambda x: x[0])

ans=[[] for i in range(N)]
if A[0][0]==1 and A[0][1]==0:
    print(-1)
    exit(0)

elif A[0][0]==1:
    ans[0]=A[0][1]
elif A[0][0]!=1:
    ans[0]=1
pt=1
for i in range(1,M):
    while pt+1<A[i][0]:
        ans[pt]=0
        pt+=1
    if A[i-1][0]==A[i][0] and A[i-1][1]!=A[i][1]:
        print(-1)
        exit(0)
    else: ans[pt]=A[i][1]
        
print(''.join(map(str,ans)))    

### FIXED CODE ###

N,M=map(int, input().split())
A=[list(map(int, input().split()))  for _ in range(M)]
A = sorted(A, reverse=False, key=lambda x: x[0])

if M==0:
    if N==3:
        print(100)
        exit(0)
    elif N==2:
        print(10)
        exit(0)        
    elif N==1:
        print(0)
        exit(0)

if N!=1 and A[0][0]==1 and A[0][1]==0:
    print(-1)
    exit(0)
i=1
j=len(A)
while i<j:
    if A[i][0]==A[i-1][0] and A[i][1]==A[i-1][1]:
        A.pop(i)
        j-=1
        continue
    elif A[i][0]==A[i-1][0] and A[i][1]!=A[i-1][1]:
        print(-1)
        exit(0)
    i+=1
ans=[None]*N

for i,j in A:
    ans[i-1]=j

for i in range(len(ans)):
    if ans[i]==None:
        if i==0:
            ans[i]=1
        else:
            ans[i]=0

print(''.join(map(str,ans)))
a = int(input())
b = int(input())

if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

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

if a <= 8 and b <= 8:
    print('Yay!')
else:
    print(':(')
import sys


def input():
    return sys.stdin.readline().strip()


def dfs(v):
    if dp[v] >= 0:
        return dp[v]
    res = 0
    for nv in g[v]:
        res = max(res, dfs(nv) + 1)
    dp[v] = res
    return res


n, m = map(int, input().split())
g = {i: set() for i in range(1, n + 1)}
for _ in range(m):
    x, y = map(int, input().split())
    g[x].add(y)

dp = [-1] * (n + 1)
for v in g:
    dp[v] = max(dp[v], dfs(v))
    print(v, dp)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)


def input():
    return sys.stdin.readline().strip()


def dfs(v):
    if dp[v] >= 0:
        return dp[v]
    res = 0
    for nv in g[v]:
        res = max(res, dfs(nv) + 1)
    dp[v] = res
    return res


n, m = map(int, input().split())
g = {i: set() for i in range(1, n + 1)}
for _ in range(m):
    x, y = map(int, input().split())
    g[x].add(y)

dp = [-1] * (n + 1)
for v in g:
    dp[v] = max(dp[v], dfs(v))
print(max(dp))
while True:
    m,n=map(int,raw_input().split())
    if m==n==0:
        break
    L=[]
    s=range(1,m+1)
    for i in range(1,n+1):
        if i%15==0:
            L.append("FizzBuzz")
        elif i%5==0:
            L.append("Buzz")
        elif i%3==0:
            L.append("Fizz")
        else:
            L.append(str(i))

    j=0
    for chars in L:
        t=raw_input()
        if t<>chars:
            del s[j%m]
        j+=1
    print " ".join([str(i) for i in s])

### FIXED CODE ###

def Judge(i):
    if i%15==0: return "FizzBuzz"
    if i%5==0:  return "Buzz"
    if i%3==0:  return "Fizz"
    return str(i)

while True:
    m,n=map(int,raw_input().split())
    if m==n==0:break
    L=range(1,m+1)
    j=0
    for i in range(1,n+1):
        c=raw_input()
	if len(L)>1:
            if Judge(i)!=c:
                del L[j]
                j%=len(L)
            else:
                j=(j+1)%len(L)
    print " ".join(map(str,L))
import numpy as np
X=int(input())
flag=1
for c in range(np.power(10,9)):
    c+=1
    x=X
    if x%c==0:
        x=x//c
        for a in range(np.power(10,3)):
            if (np.power(a,4) + np.power(a,3)*(a-c) + np.power(a,2)*np.power(a-c,2) + a*np.power(a-c,3) + np.power(a-c,4))==x:
                print(a,a-c)
                flag=0
                break
    if flag==0:
        break

### FIXED CODE ###

N, M = list(map(int, input().split()))
record = [1 for i in range(N)]
H = list(map(int, input().split()))
grid = []
for i in range(M):
    array = list(map(int, input().split()))
    grid.append(array)

for i in range(M):
    if H[grid[i][0]-1] > H[grid[i][1]-1]:
        record[grid[i][1]-1] = 0
    elif H[grid[i][0]-1] < H[grid[i][1]-1]:
        record[grid[i][0]-1] = 0
    elif H[grid[i][0]-1] == H[grid[i][1]-1]:
        record[grid[i][0]-1] = 0
        record[grid[i][1]-1] = 0

flag = 0
for i in range(N):
    if record[i] == 1:
        flag += 1
print(flag)
import sys
input = sys.stdin.readline

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

for cnt in range(m):
    a[0] = a[0] // 2
    if a[0] < a[1]:
         a.sort(reverse = True)

print(sum(a))

### FIXED CODE ###

import sys
import heapq
input = sys.stdin.readline
 
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] *= -1
heapq.heapify(a)
 
for cnt in range(m):
    temp = heapq.heappop(a)*(-1)
    if temp == 0:
        break
    heapq.heappush(a, (temp//2)*(-1))
    
print(sum(a)*(-1))
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
a = [int(input()) for _ in range(n)]

s = deque([a[0]])

from bisect import bisect_right

for i in a[1:]:
    if i <= s[0]:
        s.appendleft(i)
    else:
        s[bisect_left(s, i) - 1] = i

# print(s)
print(len(s))


### FIXED CODE ###

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

n = int(input())
a = [int(input()) for _ in range(n)]

s = deque([a[0]])

from bisect import bisect_left

for i in a[1:]:
    if i <= s[0]:
        s.appendleft(i)
    else:
        s[bisect_left(s, i) - 1] = i

# print(s)
print(len(s))
n,k=map(int,input().split())
a=0
while k<=n+1:
    b=1
    s=1
    for t in range(k):
        b*=(t+1)
        s*=(n+1-t)
    a+=s/b
    k+=1
print(a)

### FIXED CODE ###

n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))
one = len([i for i in s if i == '1'])
zero = len(s)- one

print(2*min(one,zero))

### FIXED CODE ###

s  = input()

one = len([i for i in s if i == '1'])
zero = len(s)- one

print(2*min(one,zero))
import sys, math
from collections import deque

readline = sys.stdin.readline

S = int(readline())

M = 10 ** 9
rS = math.ceil(math.sqrt(S))

while True:
    rem = rS ** 2 - S


    if rem <= M:
        b = rem
        break
    else:
        b = 0
        a = rem // M + 1
        c = math.floor(rem ** 0.5)
        while a < c and a < M:
            if rem % a == 0:
                b = a
                break
            a += 1
        if b != 0:
            break
    
    if rS >= M:
        rS = M - 1000
    else:
        rS += 1
print('0 0 {} {} {} {}'.format(rS, b, rem // b, rS))

### FIXED CODE ###

import sys, math
from collections import deque

readline = sys.stdin.readline

S = int(readline())

M = 10 ** 9
rS = math.ceil(math.sqrt(S))

while True:
    rem = rS ** 2 - S

    if rem == 0:
        print('0 0 {} {} {} {}'.format(rS, 0, 0, rS))
        exit(0)

    if rem <= M:
        b = rem
        break
    else:
        b = 0
        a = rem // M + 1
        c = math.floor(rem ** 0.5)
        while a < c and a < M:
            if rem % a == 0:
                b = a
                break
            a += 1
        if b != 0:
            break
    
    if rS >= M:
        rS = M - 1000
    else:
        rS += 1


print('0 0 {} {} {} {}'.format(rS, b, rem // b, rS))
import math

L, R = list(map(int, input().split()))
data = [x for x in range(L, R+1)]

mod_min = math.inf
for x in data:
    for y in data:
        if x == y:
            continue
            
        mod = (x * y) % 2019
        mod_min = mod if mod_min > mod else mod_min

print(mod_min)

### FIXED CODE ###

l, r = list(map(int,input().split()))

if r - l >= 2019:
  print(0)
  
else:
  ll = l % 2019
  rr = r % 2019
  if rr < ll:
    print(0)
    
  else:
    keep = 2020
    for i in range(ll, rr+1):
      for j in range(i+1, rr+1):
        keep = min((i*j)%2019, keep)
    print(keep)
a=int(input())
b=int(input())
if a*b%2==1:
  print('Odd')
elif a*b%2==0:
  print('Even')

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")
n = int(input())

if n<1200:
  print("ABC")
  
elif 1200=<n<2800:
  print("ARC")
  
else:
  print("AGC")

### FIXED CODE ###

n = int(input())

if n<1200:
  print("ABC")
  
elif 1200<=n<2800:
  print("ARC")
  
else:
  print("AGC")
from itertools import combinations
l,r = map(int,input().split())

m = 2019
for i, j in combinations(range(l, r+1),2):
      tmp = i*j % 2019
      if m > tmp:
            m = tmp
print(m)

### FIXED CODE ###

from itertools import combinations

l,r = map(int,input().split())

if r - l >= 2019:
    print(0)
else:
    m = 2019
    for i, j in combinations(range(l, r+1),2):
        tmp = i*j % 2019
        if m > tmp:
            m = tmp
    print(m)
s = input()
x1 = y1 = x2 = y3 = 0
y2 = 1
print(str(x1) + ' ' +str(y1) + ' ' +str(x2) + ' ' +str(y2) + ' ' + s + ' ' + str(y3))

### FIXED CODE ###

from math import ceil


S = int(raw_input())

x2 = y3 = int(ceil(S ** 0.5))

y2 = x2 * y3 - S 
x3 = 1

print 0, 0, x2, y2, x3, y3
lst = [int(i) for i in input().split()]
for i in range(lst):
  if lst[i] == 0:
    ans = i+1
print(ans)

### FIXED CODE ###

lst = [int(i) for i in input().split()]
for i in range(len(lst)):
    if lst[i] == 0:
        ans = i+1
print(ans)
max = 0
i = 0
j = 0
k = 0

n_max = int(raw_input())
price = [0]*n_max
    
for i in range(n_max)
    for j in range(k, n_max)
        if max <= price[j] - price[i]:
            max = price[j] - price[i]
print max

### FIXED CODE ###

import sys

n = int(raw_input())

min_R = int(raw_input())
nums = map(int, sys.stdin.readlines())

ans = -10**9

for num in nums:
    if num - min_R > ans:
        ans = num - min_R
    if num < min_R:
        min_R = num
        
print ans
n = int(input())
list = []
for i in range(n):
    a = bay(input())
    if a in list:
        list.remove(a)
    else:
        list.append(a)
print(len(list))

### FIXED CODE ###

num = int(input())
if num % 10 == 9 or num // 10 == 9:
    print("Yes")
else:
    print("No")
S=input().split()
total=0

for i in range(ren(S))
    if  i%0:
        if  S[i]=='R'or'U'or'D':
            pass
        else:
            total+=1
    elif  i%1:
        if  S[i]=='L'or'U'or'D':
            pass
        else:
            total+=1

if  total==0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

S=input()
total=0

for i in range(len(S)):
    if  (i%2)==0:
        if  (S[i]=='R')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1
    else:
        if  (S[i]=='L')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1

if  total==0:
    print('Yes')
else:
    print('No')
s = input()
t = []
for i in range(len(s)):
  if s[i] == '1':
    t.append('9')
  elif:
    t.append('1')
print(''.join(t))

### FIXED CODE ###

s = input()
t = []
for i in range(len(s)):
  if s[i] == '1':
    t.append('9')
  else:
    t.append('1')
print(''.join(t))
from sys import exit

def reads():
  return [int(x) for x in input().split()]

(N, A) = reads()
x = reads()

assert(N <= 16)

count = 0

for b in range(1, 1<<N):
  bits = [bool(b&(1 << i)) for i in range(N)]
  if sum(x[i] for i in range(N) if bits[i]) == A * sum(bits):
    count += 1
    # print(bits)

print(count)


### FIXED CODE ###

from sys import exit

def reads():
  return [int(x) for x in input().split()]

(N, A) = reads()
x = reads()

d = dict()

d[0] = 1

for i in range(N):
  for (s, N) in list(d.items()):
    k = s + x[i] - A
    d[k] = d.get(k, 0) + N

print(d[0]-1)
if S<= W:
  print("unsafe")
 else:
  print("safe)
        

### FIXED CODE ###

s, w = map(int, input().split()) 
if w>=s:
	print("unsafe") 
else:
	print("safe")
n = int(input())
print(!n)

### FIXED CODE ###

n = int(input())
print(1^n)
import bisect

def lis(lst):
    lis_lst = [lst[0]]
    for i in lst:
        if i > lis_lst[-1]:
            lis_lst.append(i)
        else:
            lis_lst[bisect.bisect_left(lis_lst, i)] = i
    return len(lis_lst)

n = int(input())

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

uv = {}
for _ in range(n-1):
    u, v = map(int, input().split())
    uv[v] = u
    
for i in range(1, n + 1):
    lst = []    
    while i != 1:
        lst.append(a[i - 1])
        i = uv[i]
    lst.append(a[0])
    lst.reverse()
    print(lis(lst))

### FIXED CODE ###

import itertools

n, m, q = map(int, input().split())
lst = []
for _ in range(q):
    item = list(map(int, input().split()))
    lst.append(item)

max_num = 0
for num_lst in itertools.combinations_with_replacement(range(1, m + 1), n):
    count = 0
    for a, b, c, d in lst:
        if num_lst[b - 1] - num_lst[a - 1] == c:
            count += d
    max_num = max(max_num, count)
print(max_num)
s = list(input())
acgt = ['A','C','G','T']
tmp = ''
ans = []
for i in range(len(s)):
    if s[i] in acgt:
        tmp+=s[i]
    else:
        ans.append(tmp)
        tmp = ''
if max(ans)==0:
    print(0)
else:
    print(len(max(ans)))


### FIXED CODE ###

s = input()
acgt = ['A','C','G','T']
cnt = 0
ans = 0
for i in range(len(s)):
    if s[i] in acgt:
        cnt+=1
    else:
        ans = max(ans,cnt)
        cnt = 0
ans = max(ans,cnt)
print(ans)
from collections import deque

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = deque(a)
b = deque(b)
t = 0
ans = 0
while True:
    if len(a) == 0 and len(b) == 0:
        break
    elif len(a) == 0:
        if t+b[0] > k:
            break
        ans += 1
        t += b.popleft()
    elif len(b) == 0:
        if t+a[0] > k:
            break
        ans += 1
        t += a.popleft()
    else:
        if a[0] < b[0]:
            if t+a[0] > k:
                break
            ans += 1
            t += a.popleft()
        elif a[0] > b[0]:
            if t+b[0] > k:
                break
            ans += 1
            t += b.popleft()
        else:
            if len(a) == 1:
                if t+b[0] > k:
                    break
                ans += 1
                t += b.popleft()
            elif len(a) == 1:
                if t+a[0] > k:
                    break
                ans += 1
                t += a.popleft()
            else:
                if a[1] < b[1]:
                    if t+a[0] > k:
                        break
                    ans += 1
                    t += a.popleft()
                else:
                    if t+b[0] > k:
                        break
                    ans += 1
                    t += b.popleft()
print(ans)

### FIXED CODE ###

from collections import deque

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = deque(a)
b = deque(b)
t = 0
book = deque()
while len(b):
    if b[0]+t <= k:
        t += b[0]
        book.append(b.popleft())
    else:
        break
nn = len(book)
# 逆じゅん
new_book = deque()
for i in range(nn):
    new_book.append(book.pop())
book = new_book
# aも詰め込めるだけ
while len(a):
    if a[0]+t <= k:
        t += a[0]
        book.append(a.popleft())
    else:
        break
ans = len(book)
for i in range(nn):
    t -= book.popleft()
    while len(a) and t+a[0]<=k:
        ta = a.popleft()
        t += ta
        book.append(ta)
    ans = max(ans, len(book))

print(ans)
str_atog = "ABCDEFG"
str_hton = "hijklmn"
 
# lower(), upper()????????????????????????
print "??§??????(???) %s ????°???????(???) %s ?????????" % (str_atog, str_atog.lower())
print "?°???????(???) %s ?????§??????(???) %s ?????????" % (str_hton, str_hton.upper())
print
 
arr  = ['And', 'Begin', 'Code', 'Double']
arr2 = ['end', 'flag', 'gem', 'halt']
# for?????§?°???????[??§??????](???)???????´???¨????????????????????????
n_arr = []
for str in arr:
    n_arr.append(str.lower())
print n_arr
 
n_arr2 = []
for str in arr2:
    n_arr2.append(str.upper())
print n_arr2, 'n'
 
# ????????????????????????????????§?????§?°???????[??§??????](???)???????´???¨????????????????????????
print [str.lower() for str in arr]
print [str.upper() for str in arr2]

### FIXED CODE ###

s = input()
print(s.swapcase())
N,A,B = map(int,input()split())
print(min(A*N,B))

### FIXED CODE ###

N,A,B = map(int,input().split())
print(min(A*N,B))
x = int(input())
a = int(input())
b = int(input())

print(x-a-(b*(x-a)//b)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())
 
print((x-a)%b)
a=1
n=input()

s=input()
for i in range(len(s)):
  if i%2==1:
    continue
  a*=int(s[i])
if a>10**18:
  print(-1)
else:
  print(a)

### FIXED CODE ###

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

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)
a=input()
b=input()
if a==b:
  print("No")
else:
  a.sort()
  b.sort()[::-1]
  list_ = [a,b]
  list_.sort()
  if list_[0]==a:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a=list(input())
b=list(input())
if a==b:
  print("No")
else:
  a.sort()
  a="".join(a)
  b.sort()
  b=b[::-1]
  b="".join(b)
  list_ = [a,b]
  list_.sort()
  if list_[0]==a:
    print("Yes")
  else:
    print("No")