Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# D-Grid and Integers

from collections import defaultdict

def ReadInput():
	return [int(i) for i in input().split(" ")]

(R, C) = ReadInput()
N = int(input())
VectorSet = set() 
Grid = defaultdict(list)
for i in range(N):
	(r, c, a) = ReadInput()
	Grid[("R", r)].append((("C", c), a))
	Grid[("C", c)].append((("R", r), a))
	VectorSet.add(('R', r))
	VectorSet.add(('C', c))

def iteration(vector):
	VectorSet.discard(vector)
	for (v, a) in Grid[vector]:
		temp = a - VectorCover[vector]
		if (v in VectorCover):
			if(temp is not VectorCover[v]):
				print("No")
				exit()
		else:
			VectorCover[v] = temp
			iteration(v) 

while(len(VectorSet) is not 0):
	vector = VectorSet.pop()
	VectorCover = defaultdict(int)
	VectorCover[vector] = 0
	iteration(vector)
	minR = min(a for (p, a) in VectorCover.items() if (p[0] is "R"))
	minC = min(a for (p, a) in VectorCover.items() if (p[0] is "C"))
	if (minR + minC < 0):
		print("No")
		exit()
		
print("Yes")


### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

def ReadInput():
	return [int(i) for i in input().split(" ")]

(R, C) = ReadInput()
N = int(input())
VectorSet = set() 
Grid = defaultdict(list)
for i in range(N):
	(r, c, a) = ReadInput()
	Grid[("R", r)].append((("C", c), a))
	Grid[("C", c)].append((("R", r), a))
	VectorSet.add(("R", r))
	VectorSet.add(("C", c))

def iteration(vector):
	VectorSet.discard(vector)
	for (v, a) in Grid[vector]:
		temp = a - VectorCover[vector]
		if (v in VectorCover):
			if(temp != VectorCover[v]):
				print("No")
				exit()
		else:
			VectorCover[v] = temp
			iteration(v) 

while(len(VectorSet) != 0):
	vector = VectorSet.pop()
	VectorCover = dict() 
	VectorCover[vector] = 0
	iteration(vector)
	minR = min(a for (p, a) in VectorCover.items() if (p[0] == "R"))
	minC = min(a for (p, a) in VectorCover.items() if (p[0] == "C"))
	if (minR + minC < 0):
		print("No")
		exit()

print("Yes")
S, T = input().split()
a, b = int(input.split())
U = input()
if list(S) == list(U):
  print(a-1)
else:
  print(b-1)

### FIXED CODE ###

S, T = input().split(" ")
A, B = [int(i) for i in input().split(" ")]
U = input()
 
if S==U :
  print("{} {}".format(A-1,B))
else:
  print("{} {}".format(A,B-1))
n, k = map(int, input().split())
s = input()
#s.append('e')
prev = 'e'
flag = 0

count = 0
        
for i in range(n):
    #print(flag)
    if i == n - 1:
        if flag == 1:
            count += 1
    if s[i] == 'L':
        if prev == 'R':
            if k == 0:
                ;
            elif flag == 0:
                flag = 1
            else:
                count += 2
                k -= 1
                flag = 0
        elif prev == 'L':
            count += 1
    else:
        if prev == 'L':
            if k == 0:
                ;
            elif flag == 0:
                flag = 1
            else:
                count += 2
                k -= 1
                flag = 0
        elif prev == 'R':
            count += 1
    prev = s[i]
    
print(count)

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
prev = 'e'
flag = 0

count = 0
        
for i in range(n):
    if s[i] == 'L':
        if prev == 'R':
            if k == 0:
                pass
            elif flag == 0:
                flag = 1
            else:
                count += 2
                k -= 1
                flag = 0
        elif prev == 'L':
            count += 1
    else:
        if prev == 'L':
            if k == 0:
                pass
            elif flag == 0:
                flag = 1
            else:
                count += 2
                k -= 1
                flag = 0
        elif prev == 'R':
            count += 1
    if i == n - 1:
        if flag == 1:
            count += 1
    prev = s[i]
    
print(count)
k = int(input())
print((k//2)*((k+1)//2)


### FIXED CODE ###

k = int(input())
n = k//2
print(n*(n+1) if k % 2 == 1 else n**2)
K,X = map(int,input().split())
a = 500 * K
if (a => X):
    print ('Yes')
else:
    print ('No')


### FIXED CODE ###

a = input().split()
K = int(a[0])
X = int(a[1])
if 500 * K >= X:
    print('Yes')
else:
    print('No')
N,R = map(int, input.split())

if (N < 10):
    print(R + ((10 - N) * 100))
else:
    print(R)

### FIXED CODE ###

N,R = map(int, input().split())
 
if (N < 10):
    print(R + ((10 - N) * 100))
else:
    print(R)
n=int(input())
a=list(map(int,input().split()))

b=[i for i in a if i%2==0]

for j in b:
    if j%3==0 or j%5==0:
        ans=True
    else:
        print('DENIED')
        exit()
if ans:
    print('APPROVED')

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=[]
for i in a:
   if i%2==0:
       b.append(i)

ans=True       
for i in b:
    if i%3==0 or i%5==0:
        ans=True
    else:
        ans=False
        break
        
if ans:
    print('APPROVED')
else:
    print('DENIED')
a,b=map(int,raw_input().split())
print(a*b,(a+b)*2)

### FIXED CODE ###

[a,b]=map(int,input().split())
print(a*b,(a+b)*2)
N, M = map(int, input().split())
pS = [list(input().split()) for i in range(M)]

for x in range(M):
    pS[x][0] = int(pS[x][0])
    
Ans, Pen = 0, 0
for x in range(M):
    if (pS[x][0] != pS[x-1][0]):
        pS_temp = 0
        Ans_temp = 0
    if (pS[x][1] == 'AC') and (pS_temp == 0):
        Ans += 1
        Ans_temp += 1
        pS_temp += 1
    elif (pS[y][1] == 'WA') and (pS_temp == 0) and (Ans_temp == 0):
        Pen += 1
print(Ans, Pen)

### FIXED CODE ###

N, M = map(int, input().split())
Q_n = [0] * N
C = [0] * N

Ans = 0
Pen = 0
for i in range(M):
    p, S = input().split()
    p = int(p)-1
    if (S == 'AC') and (Q_n[p] == 0):
        Q_n[p] = 1
        Ans += 1
        Pen += C[p]
    elif (S == 'WA'):
        C[p] += 1
        
print(Ans, Pen)
a = input()
if a = a.upper():
  print('A')
else:
  print('a')

### FIXED CODE ###

a = input()
if a == a.upper():
  print('A')
else:
  print('a')
def main():
    N, M = map(int, input().split())
    P = {tuple(map(int, input().split())) for _ in range(M)}
    P = sorted(P)
    ans = [0 for _ in range(N)]

    if N > 1 and (1, 0) in P:
        print(-1)
        return

    if N > 1 and P[0][0] != 1:
        print(-1)
        return

    for i in range(len(P) - 1):
        if P[i][0] == P[i + 1][0]:
            print(-1)
            return

    for p in P:
        ans[p[0] - 1] = p[1]

    ans = map(str, ans)
    print("".join(ans))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, M = map(int, input().split())
    P = {tuple(map(int, input().split())) for _ in range(M)}
    P = sorted(P)
    ans = [0 for _ in range(N)]

    if N == 1 and M == 0:
        print(0)
        return

    if N == 2 and M == 0:
        print(10)
        return

    if N == 3 and M == 0:
        print(100)
        return

    if N > 1 and (1, 0) in P:
        print(-1)
        return

    if N > 1 and P[0][0] != 1:
        ans[0] = 1

    for i in range(len(P) - 1):
        if P[i][0] == P[i + 1][0]:
            print(-1)
            return

    for p in P:
        ans[p[0] - 1] = p[1]

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


if __name__ == "__main__":
    main()
x,y = map(int, input().split())
if a*b %2 = 0: print("Even")
if a*b %2 = 1: print("Odd")

### FIXED CODE ###

a,b = map(int, input().split())
if a*b %2 == 0: print("Even")
if a*b %2 == 1: print("Odd")
n=int(input())
a=list(map(int,input().split()))[::-1]


i=0
result=0

while i<n-1:
  maxV=max(a[i],a[i+1])
  temp=min(a[i],a[i+1])
  result+=temp
  j=i+2
  while j<n:
    if temp>a[j]:
      result+=temp
      #print(i,j)
    else:
      if a[j]>maxV:
        temp=maxV
        result+=temp
        maxV=a[j]
      else:
        temp=a[j]
        result+=temp
    #print(i,j,temp)
        
    j+=1
  
  i+=1
  
print(result)
  


### FIXED CODE ###

n=int(input())
print(n**3)
N,K=map(int,input().split())
if N==0:print(0)
elif N<K:print(min(N,K-N))
elif N>=K*2:print(N%K)
else:print(N%(N-K))  

### FIXED CODE ###

N,K=map(int,input().split())
print(min(N%K,K-(N%K)))
import math 

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
if b*a*a >= x:
    ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
else:
    ans1 =0
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if ans1 <= 45.0:
    print (ans1)
else:
    print (ans2)

### FIXED CODE ###

import math 

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
if b*a*a > x:
    ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
else:
    ans1 = 0.0
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if a*a*b/2 <= x:
    print (ans1)
else:
    print (ans2)
N = int(input())
dsum = 0
tmp = N
while tmp > 0:
  dsum += tmp % 10
  tmp /=  10
  tmp  = int(tmp)
if N % dsum != 0:
  print ("No")
else:
  print ("Yes")

### FIXED CODE ###

import math
def main():
    line_input = input().split()
    n = int(line_input[0])
    k = int(line_input[1])
    nums = input().split()
    print(math.ceil((n - 1) / (k - 1)))

main()
13 1 4 3000

### FIXED CODE ###

R,G,B,N=map(int,input().split())

ans=[]

count=0
for r in range(int(N/R)+1):
    for g in range(int((N-r*R)/G)+1):
        
        if (N-r*R-g*G)%B==0:
            count+=1
            #ans.append([r,g,(N-r*R-g*G)/B])

#print(ans)
print(count)
#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[float("inf") for i in range(5)] for j in range(L+1)]
for i in range(L+1):
    DP[0][i] = 0

def cost(s, i, A):
    if s == 0 or s == 4:
        return A[i]
    elif s == 1 or s == 3:
        if A[i] > 0:
            if A[i]%2 == 0:
                return 0
            else:
                return 1
        else:
            return 2
    else:
        if A[i]%2 == 1:
            return 0
        else:
            return 1

for i in range(L):
    for j in range(5):
        for k in range(j,5):
            DP[i+1][k] = min(DP[i+1][k], DP[i][j]+ cost(k, i, A))



print(min(DP[L]))

### FIXED CODE ###

#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[float("inf") for i in range(5)] for j in range(L+1)]
for i in range(5):
    DP[0][i] = 0

def cost(s, i, A):
    if s == 0 or s == 4:
        return A[i]
    elif s == 1 or s == 3:
        if A[i] > 0:
            if A[i]%2 == 0:
                return 0
            else:
                return 1
        else:
            return 2
    else:
        if A[i]%2 == 1:
            return 0
        else:
            return 1

for i in range(L):
    for j in range(5):
        for k in range(j,5):
            DP[i+1][k] = min(DP[i+1][k], DP[i][j]+ cost(k, i, A))



print(min(DP[L]))
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
  g = gcd(g, e)
if k <= max(arr) and k//g*g == k:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
A, B = map(int, input().split())

import math
# import time

G = math.gcd(A, B)
ans = 1
# print("G:", G)



for i in range(G-1):
    if (G < i):
        break
    # print("G % (i+1) == 0:", G % (i+1) == 0)
    if(G % (i+2) == 0):
        ans += 1
        j = 1
        while(G % ((i+2)**j) == 0):
            G /= i+2
            j += 1
            # print("i:", i + 2, "j:", j)
            # time.sleep(1)

print(ans)



### FIXED CODE ###

import fractions
from math import sqrt

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

G = fractions.gcd(A, B)
N = int(sqrt(max(A,B)))+1
g = G
ans = 1

for i in range(2, N+3):
    if(g % i == 0):
        ans += 1
        while(g % i == 0):
            g = g/i
            
if g != 1:
    ans += 1

print(ans)
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A, reverse = True)
for i in range(N-1):
  print(A[i])
  ans += A[i]
print(ans)

### FIXED CODE ###

import math
X = int(input())
print(str(10-math.floor(X/200)))
n, a, b = map(int, input().split())
ans = 0
if abs(a-b)%2:
    if max(a, b)-1 >  n-min(a, b):
        if a > b:
            pirnt(n-a+abs(n-(b+n-a)))
        else:
            pirnt(n-b+abs(n-(a+n-b)))
    else:
        if a > b:
            print(b-1+abs(1-(a-b+1)))
        else:
            print(a-1+abs(1-(b-a+1)))
else:
    print(abs(a-b)//2)

### FIXED CODE ###

n, a, b = map(int, input().split())
if abs(a-b)%2:
    if b>a: a, b = b, a
    print(min(a-1, n-b)+1+(b-a-1)//2)
else:
    print(abs(a-b)//2)
# coding:utf-8
# Doubly Linked List

class DLL:

    def __init__(self):
        self.array = []

    def insert(self, x):
        self.array = [x] + self.array
    
    def delete(self, x):
        del self.array[self.array.index(x)]

    def deleteFirst(self):
        del self.array[0]

    def deleteLast(self):
        del self.array[len(self.array)-1]


def main():

    dll = DLL()
    n = int(input())

    for _ in range(n):
        operation = input().split()
        command = operation[0]
        if command in ["insert", "delete"]:
            key = operation[1]
            eval("dll." + command + '(' + key + ')')

        else:
            eval("dll." + command + "()")

    print(str(dll.array)[1:len(str(a))-1])

if __name__ == "__main__":
    main()

### FIXED CODE ###

# coding:utf-8
# Doubly Linked List

from collections import deque

def main():

    n = int(input())
    dll = deque()

    for _ in range(n):
        operation = input().split(' ')
        if operation[0] in ["insert", "delete"]:
            key = operation[1]
            if operation[0] == "insert":
                dll.appendleft(key)
            else:
                try:
                    dll.remove(key)
                except:
                    pass

        else:
            if operation[0][6] == 'F':
                dll.popleft()

            else:
                dll.pop()

    print(' '.join(dll))

if __name__ == "__main__":
    main()
#!/usr/bin/env python3

def main():
    n = int(input())
    s = input()
    for d0 in ["S", "W"]:
        for d1 in ["S", "W"]:
            pat = wrap(n, s, d0, d1)
            if pat[0] == pat[n] and pat[1] == pat[n + 1]:
                res = "".join(pat[:n])
                print(res)
                return
    print("-1")

def wrap(n, s, d0, d1):
    ds = [d0, d1]
    for i in range(2, n + 2):
        d = get_dnext(ds[i - 2], ds[i - 1], s[i - 1])
        ds.append(d)
    assert len(ds) == n + 2
    return ds

def get_dnext(dpre, di, si):
    if di == "S" and si == "o":
        dnext = dpre
    elif di == "S" and si == "x":
        dnext = inv(dpre)
    elif di == "W" and si == "o":
        dnext = inv(dpre)
    elif di == "W" and si == "x":
        dnext = dpre
    else:
        raise Exception
    return dnext

def inv(d):
    return "W" if d == "S" else "S"

main()


### FIXED CODE ###

#!/usr/bin/env python3

def main():
    n = int(input())
    s = input()
    s = list(s)
    s.append(s[0])
    for d0 in ["S", "W"]:
        for d1 in ["S", "W"]:
            pat = wrap(n, s, d0, d1)
            if pat[0] == pat[n] and pat[1] == pat[n + 1]:
                res = "".join(pat[:n])
                print(res)
                return
    print("-1")

def wrap(n, s, d0, d1):
    ds = [d0, d1]
    for i in range(2, n + 2):
        d = get_dnext(ds[i - 2], ds[i - 1], s[i - 1])
        ds.append(d)
    assert len(ds) == n + 2
    return ds

def get_dnext(dpre, di, si):
    if di == "S" and si == "o":
        dnext = dpre
    elif di == "S" and si == "x":
        dnext = inv(dpre)
    elif di == "W" and si == "o":
        dnext = inv(dpre)
    elif di == "W" and si == "x":
        dnext = dpre
    else:
        raise Exception
    return dnext

def inv(d):
    return "W" if d == "S" else "S"

main()
n = input()
a = input()

if n%500 > a:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

n = int(input())
a = int(input())

if n%500 > a:
  print("No")
else:
  print("Yes")
A, B = list(map(int, input().split()))

def calc_num(N):
  if N % 4 == 1 or N % 4 == 3:
    return (1, 0)
  if N % 4 == 2:
    return (N, 1)
  return (N, 0)

A, subA = calc_num(A-1)
B, subB = calc_num(B)

numbers = [2**i for i in range(40)]

A = [int(i) for i in str(bin(A)).split("b")[1]]
B = [int(i) for i in str(bin(B)).split("b")[1]]
A[-1] += subA
B[-1] += subB

if len(B) > len(A):
  temp = [0] * (len(B)-len(A))
  temp.extend(A)
  A = temp
#print(A)
#print(B)

res = [str((A[i]+B[i])%2) for i in range(len(A))]
#print(res)
print(int("".join(res), 2))


### FIXED CODE ###

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

def calc_num(N):
  if N==0:
    return 0
  if N % 4 == 1:
    return 1
  if N % 4 == 2:
    return N ^ 1
  if N % 4 == 3:
    return 0
  return N ^ 0

A = calc_num(A-1)
B = calc_num(B)

print(A^B)
n, a, b = map(int, open(0))
if n == 1:
    print("Hello World")
else:
    print(a+b)


### FIXED CODE ###

n, *t = map(int, open(0))
if n == 1:
    print("Hello World")
else:
    print(sum(t))
A, B, C, D = map(int, input().split())

for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()

  A -= D
  if A <= 0:
    print("No")
    exit()


### FIXED CODE ###

A, B, C, D = map(int, input().split())
for _ in range(10000):
  C -= B
  if C <= 0:
    print("Yes")
    exit()
  A -= D
  if A <= 0:
    print("No")
    exit()
index = {}
while True:
    try:
        w, p = map(str, raw_input().split())
        index.setdefault(w,[]).append(int(p))
index.sort()
for i in index:
    index[i].sort()
    print i
    print " ".join(map(int, index[i]))

### FIXED CODE ###

index = {}
while True:
    try:
        w, p = map(str, raw_input().split())
        index.setdefault(w,[]).append(int(p))
    except:
        break

for k,v in sorted(index.items()):
   print k
   print " ".join(map(str, sorted(v)))
import sys
import numpy as np
import math

input = sys.stdin.readline


def solve():
    n, m, le = map(int, input().split())
    paths = np.zeros((n, n))
    for i in range(n):
        for j in range(n):
            if i != j:
                paths[i, j] = math.inf

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

    for i in range(n):
        for j in range(n):
            for k in range(n):
                paths[i, j] = min(paths[i, j], paths[i, k] + paths[k, j])

    refuels = np.array(paths, copy=True)
    for i in range(n):
        for j in range(n):
            refuels[i, j] = 1 if paths[i, j] < le else math.inf
            if i == j:
                refuels[i, j] = 0

    for i in range(n):
        for j in range(n):
            for k in range(n):
                refuels[i, j] = min(refuels[i, j], refuels[i, k] + refuels[k, j])

    q = int(input())
    for _ in range(q):
        s, t = map(int, input().split())
        print(int(refuels[s-1, t-1] - 1 if refuels[s-1, t-1] < math.inf else -1))


if __name__ == "__main__":
    solve()


### FIXED CODE ###


from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
graph = np.full((N, N), 10 ** 10)
for _ in range(M):
    s, t, w = map(int, input().split())
    if w <= L:
        graph[s - 1][t - 1] = graph[t - 1][s - 1] = w
graph = floyd_warshall(graph, directed=False)
graph = floyd_warshall(graph <= L, directed=False)
graph[np.isinf(graph)] = 0

Q = int(input())
ans = []
for _ in range(Q):
    s, t = map(int, input().split())
    ans.append(int(graph[s - 1][t - 1]) - 1)
print(*ans, sep='\n')
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [x - 1 for x in A]

id = [-1] * N
x = A[0]
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

c = l - id[x]
if K <= l:
    print(a[K] + 1)
else:
    print(a[id[x] + K % c - 1] + 1)


### FIXED CODE ###

N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

id = [-1] * (N + 1)
x = 1
l = 0
a = []
while id[x] == -1:
    a.append(x)
    id[x] = l
    l += 1
    x = A[x]

c = l - id[x]
if K < l:
    print(a[K])
else:
    K -= l
    print(a[id[x] + K % c])
n,m=map(int,input().split())
a=n%(m//2)
print(a+(m-2*a)//4)

### FIXED CODE ###

n,m=map(int,input().split())
print(min((m+2*n)//4,m//2))
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

max_num = 0


def dfs(curr_a, curr_b, choice, time_required, count):
    global max_num
    if choice == 0:
        if curr_a >= N - 1:
            if max_num < count:
                max_num = count
            return
        else:
            curr_a += 1
            time_required += a[curr_a]
    else:
        if curr_b >= M - 1:
            if max_num < count:
                max_num = count
            return
        else:
            curr_b += 1
            time_required += b[curr_b]
    if time_required > K:
        if max_num < count:
            max_num = count
        return
    count += 1
    dfs(curr_a, curr_b, 0, time_required, count)
    dfs(curr_a, curr_b, 1, time_required, count)

curr_a = -1
curr_b = -1
time_required = 0
count = 0
dfs(curr_a, curr_b, 0, time_required, count)
curr_a = -1
curr_b = -1
time_required = 0
count = 0
dfs(curr_a, curr_b, 1, time_required, count)

print(max_num)

### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)
#B
H,W = map(int, input().split())
s=H*W
if ((H==1) or (W==1)):
    ans = 1
elif (s%2) ==0:
    ans = (s//2)
else:
    ans = ((s+1)//2)
print(ans)

### FIXED CODE ###

arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(arr[K-1])
N, M = map(int, input().split())
votes = list(map(int, input().split()))
min_votes: float = sum(votes) * 1.0 / (4*M)
votes_greater_than_min = list(filter(lambda x: x >= min_votes, votes))
if len(votes_greater_than_min) >= M:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N, M = map(int, input().split())
votes = list(map(int, input().split()))
min_votes = sum(votes) * 1.0 / (4*M)
votes_greater_than_min = list(filter(lambda x: x >= min_votes, votes))
if len(votes_greater_than_min) >= M:
    print('Yes')
else:
    print('No')
N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]

ans=input()
print(s.count(ans)-t.count(ans))

### FIXED CODE ###

N=int(input())
s=[input() for _ in range(N)]
M=int(input())
t=[input() for _ in range(M)]
def ans1(x):
    return s.count(x)-t.count(x)
ans2=0
ans_1=0
for S in s:
    if ans1(S)>0 and ans1(S)>ans2:
            ans2=ans1(S)
if ans2>=0:
    print(ans2)
else:
    print("0")
N = int(input())
A = list(map(int, input().split()))
ans = [0] * 9

for i in range(N):
  aa = int(A[i] / 400)
  ans[aa] += 1
  
min_a = 0
max_a = 0
for i in range(9):
  if i != 8:
    if ans[i] != 0:
      min_a += 1
      max_a += 1
  else:
    max_a += ans[i]
    
print(min_a, max_a)





### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = [0] * 9

for i in range(N):
  aa = int(A[i] / 400)
  if aa > 8:
    aa = 8
  ans[aa] += 1
  
min_a = 0
max_a = 0
for i in range(9):
  if i != 8:
    if ans[i] != 0:
      min_a += 1
      max_a += 1
  else:
    max_a += ans[i]
    
min_a = max(min_a, 1)    
print(min_a, max_a)