Harryxun/stf_run huggingface dataset:
k = input()
a,b = map(int,input().split())
for i in range(a,b,1):
    if i%k == 0:
        han = True
if han == True:
    print("OK")
else:
    print("No")

### FIXED CODE ###

k = int(input())
a,b = map(int,input().split())
han = False
for i in range(a,b+1):
    if i%k == 0:
        han = True
if han == True:
    print("OK")
else:
    print("NG")
print(2 3)

### FIXED CODE ###

s = input()
t = s[1:]+" "
r = s[2:]+"  "
for n,(i,j,k) in enumerate(zip(s,t,r)):
    if i == j :
        print(n+1,n+2)
        exit()
    elif i == k:
        print(n+1,n+3)
        exit()
print(-1,-1)
n, p = map(int,input().split())
D = input()
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * 10**i) % p
        ten = ten * 10 % p
        count[mod] += 1
        out += (c * (c - 1)) // 2
print(out)

### FIXED CODE ###

n, p = map(int,input().split())
D = input()
out = 0


if 10 % p == 0:
    for i in range(n):
        if int(D[i]) % p == 0:
            out += i + 1
else:
    mod = 0
    count = [0] * p
    ten = 1
    count[mod] += 1
    for i in range(n):
        mod = (mod + int(D[n-i-1]) * ten) % p
        ten = ten * 10 % p
        count[mod] += 1
    for c in count:
        out += (c * (c - 1)) // 2
print(out)
def equal(n, available):
  return n in available 

def less(n, available):
  return n < sorted(available)[0]

def greater(n, available):
  return n > sorted(available, reverse=True)[0]
  

#less(n, available) == True であること
def upper_next(n, available):  
  for v in sorted(available):
    if n < v:
      return v
  return 1/0

  
n_str, _ = [v for v in input().split()]
n_s = [0]
n_s.extend([int(n_str[i:i+1]) for i in range(len(n_str))])

d_s = [int(v) for v in input().split()]

available = set(list(range(10))) - set(d_s)

#print("n", n_s, "d", d_s, "u", available)

min_available = sorted(available)[0]
max_available = sorted(available, reverse=True)[0]

ans = [0]
ans.extend([min_available] * (len(n_s) - 1))

eq = True
for i in range(1, len(n_s)):
  if eq:
    if equal(n_s[i], available):
      ans[i] = n_s[i]
      continue
    else:
      eq = False
      if less(n_s[i], available):
        ans[i] = upper_next(n_s[i], available)
        #残りは最小値詰め
        break
      else:
        for j in range(i - 1, -1, -1):
          if ans[j] == max_available:
            ans[j] = min_available
          else:
            ans[j] = upper_next(ans[j], available)
            break
        break

begin = 0
if ans[0] == 0:
  begin = 1
ans_val = "".join(map(lambda x:str(x), ans[begin:]))

print(ans_val)

### FIXED CODE ###

s = sorted([int(v) for v in input().split()])
if s == [5, 5, 7]:
  ans = "YES"
else: 
  ans = "NO"
print(ans)
A, B = map(int, input().split())
count = 1
for i in range(100000):
    count = count + A - i
    if count > B
        print(i)
        exit()

### FIXED CODE ###

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

if B == 1:
    print(0)
    exit()
    
for i in range(1, 400):
    count = count + A - 1
    if count >= B:
        print(i)
        exit()
num = map(int,input().split())
for i in num:
  if num[i] == 7:
    break
    print("Yes")
else:
  print("No")

### FIXED CODE ###

nums = [int(i) for i in list(input())]
for i in nums:
  if  i == 7:
    print("Yes")
    break
else:
  print("No")
import math
N = int(input())
A = list(map(int, input().split()))

B=sorted(set(A))
sa = []
gokei = 0
for i in range(len(B)):
    x = A.count(B[i])
    if x == 1:
        continue
    elif x ==2:
        gokei += 1
        sa.append(1)
    else:
        z = math.factorial(x)//(math.factorial(x-2)*math.factorial(2))
        gokei += z
        sa.append(z-z*(x-2)//x)

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    if ans[z] == 0:
        e = gokei - sa[B.index(z)]
        ans.append(e)
        print(e)
    else:
        print(ans[z])

### FIXED CODE ###

import collections

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

gokei = 0
counter = collections.Counter(A)
for i in counter.values():
    gokei += i * (i - 1) // 2

ans = [0]*(N+1)
for i in range(N):
    z = A[i]
    d = counter[z]
    if ans[z] == 0:
        e = gokei - (d * (d - 1) // 2 - (d-1) * (d - 2) // 2)
        ans.append(e)
        print(e)
    else:
        print(ans[z])
import sys

s=input()
k=int(input())


s=list(s)

c=0
for i in range(k):
        if s[i]=='1':
                c+=1
if c==k:
        print('1')
        sys.exit()
                

for i in range(len(s)):
        if s[i]!='1':
                print(s[i])
                sys.exit()

### FIXED CODE ###

import sys

s=input()
k=int(input())


s=list(s)

c=0
for i in range(len(s)):
        if s[i]=='1':
                c+=1
if c==len(s):
        print('1')
        sys.exit()

d=0
if len(s)>=k:
        for i in range(k):
                if s[i]=='1':
                        d+=1
if d==k:
        print('1')
        sys.exit()

for i in range(len(s)):
        if s[i]!='1':
                print(s[i])
                sys.exit()
num_list = [0] * (N)
a_b_list = []

for _ in range(N-1):
    a_b_list.append(list(map(int, input().split())))

for _ in range(Q):
    p, x = map(int, input().split())
    num_list[p-1] += x

for a_b in a_b_list:
    num_list[a_b[1]-1] += num_list[a_b[0]-1]

print(*num_list)

### FIXED CODE ###

# dfs(深さ優先探索)

N, Q = map(int, input().split(' '))

num_list = [0] * (N+1)

tree_list = [[] for _ in range(N+1)]

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

for _ in range(Q):
    p, x = map(int, input().split())
    num_list[p] += x

q = [1]
checked = [0] * (N+1)

while q:
    v=q.pop()
    checked[v] = 1
    for u in tree_list[v]:
        if checked[u] == 1:
            continue
        num_list[u] += num_list[v]
        q.append(u)

print(*num_list[1:])
n=int(input())
d=[int(input()) for i in range(n)]

sum=0
for i in range(n):
    for l in range(1<=n):
        sum+=d[i]*d[l]
print(sum)


    

### FIXED CODE ###

n=int(input())
d=list(map(int,input().split()))
 
sum=0
for i in range(n-1):
    for l in range(i+1,n):
        sum+=d[i]*d[l]
print(sum)
a,b=input().split()
Lis=["1","2","3"]
for i in range(3):
  if a!=Lis[i] and b!=Lis[i]:
    print(Lis[i])

### FIXED CODE ###

a=input()
b=input()
Lis=["1","2","3"]
for i in range(3):
  if a!=Lis[i] and b!=Lis[i]:
    print(Lis[i])
def Fib(n):    
    if n == 2 or n == 3:
        return 1
    else:
        return Fib(n - 1) + Fib(n - 2)
    
N, M = map(int, input().split())
S = [-1]
for i in range(M):
    S.append(int(input()))
S.append(N + 1)
S = [S[i + 1] - S[i] for i in range(M + 1)]
if any([x == 1 for x in S]):
    print(0)
    exit()
num = 1
for x in S:
    num *= Fib(x)
    num = num % 1000000007
print(num)

### FIXED CODE ###

def fib(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]
    
N, M = map(int, input().split())
if N == 1:
    print(1)
    quit()
S = [-1]
for i in range(M):
    S.append(int(input()))
S.append(N + 1)
S = [S[i + 1] - S[i] for i in range(M + 1)]
if any([x == 1 for x in S]):
    print(0)
    exit()
num = 1
for x in S:
    num *=  fib(x - 1)
    num = num % 1000000007
print(num)
import sys


def main():
    lines = sys.stdin.readlines().split(' ')
    one_try = int(lines[0])
    money = int(lines[1])
    count = int(lines[2])
    n = 0
    while(True):
        if money >= one_try:
            money = money - one_try
            n = n + 1
        else:
            break
        if n == count:
            break
    print(n)


if __name__ == '__main__':
    main()
    

### FIXED CODE ###

import sys


def main():
    lines = sys.stdin.readlines()[0].split(' ')
    one_try = int(lines[0])
    money = int(lines[1])
    count = int(lines[2])
    n = 0
    while(True):
        if money >= one_try:
            money = money - one_try
            n = n + 1
        else:
            break
        if n == count:
            break
    print(n)


if __name__ == '__main__':
    main()
from sys import stdin
import copy

n = int(input())
S = [stdin.readline()[:-1] for i in [0]*(n-1)]
S.append(stdin.readline())
s = []
for i in S:
    s.append("".join(sorted(i)))
s.sort()
arr = []
temp = 1
for i in range(n-1):
    if temp>1 and s[i]!=s[i+1]:
        arr.append(temp)
        temp = 1
    if s[i]==s[i+1]:
        temp += 1
if temp>1:
    arr.append(temp)
arr.sort()
factorial = [1]
for i in range(arr[-1]+1):
    factorial.append(factorial[i]*(i+1))
comb = [0,0]
for i in range(2,arr[-1]+1):
    comb.append(factorial[i]/(2*factorial[i-2]))
ans = 0
for i in arr:
    ans += comb[i]
print(int(ans))

### FIXED CODE ###

from sys import stdin
import copy

n = int(input())
S = [stdin.readline()[:-1] for i in [0]*(n)]
#S.append(stdin.readline())
s = []
for i in S:
    s.append("".join(sorted(i)))
s.sort()
arr = []
temp = 1
for i in range(n-1):
    if temp>1 and s[i]!=s[i+1]:
        arr.append(temp)
        temp = 1
    if s[i]==s[i+1]:
        temp += 1
if temp>1:
    arr.append(temp)

ans = 0
for i in arr:
    ans += i*(i-1)//2
print(ans)
a,b=map(int,input().split());s=input();print("YNeos"[len(s)<11*s[a]=="-"::2])

### FIXED CODE ###

a,b=map(int,input().split())
s=input()
if s.count("-")<2 and s[a]=="-":
  print("Yes")
else:
  print("No")
x = int(input())
if x>=30:
  print("Yes")
else:
  praint("No")

### FIXED CODE ###

x = int(input())
if x>=30:
  print("Yes")
else:
  print("No")
nums = [input() for i in range(2)]
A,B,C = map(int,nums)
x = int(input())
  
count = 0
for i in range(A):
  if i*500 == x:
    count += 1
    break
  else:
    x -= i*500
    for j in range(B):
  		if j*100 == x:
    	  count += 1    		
  		  break
        else:
          x -= j*100
          for k in range(C):
            if k*50 == x:
    		  count += 1
      		  break
print(count)
  			
    
    
     


### FIXED CODE ###

nums = [input() for i in range(3)]
A,B,C = map(int,nums)
x = int(input())
count = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i+100*j+50*k == x:
        count +=1
print(count)
import math

    a, b, h, m = map(int, input().split())
    h = h * 30 + m/2
    m = m * 6
    degree = abs(h - m)
    if degree > 180:
        degree = 360 - degree
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(degree))))

### FIXED CODE ###

from math import *
a, b, h, m = map(int, input().split())
h = 30 * h + m / 2
m *= 6
d = (a * sin(radians(h))) - (b * sin(radians(m)))
e = (a * cos(radians(h))) - (b * cos(radians(m)))
print((d * d + e * e)**0.5)
n = int(input())
li =list(input().split())
for i in range(n-1):
  if li[i] == li[i+1]:
    li.remove(li[i])
print(len(li))


### FIXED CODE ###

n = int(input())
li =list(input())
a=0
for i in range(n-1):
  if li[i] == li[i+1]:
    a += 1
print(n-a)
S=input()
N=len(S)
mod=10**9+7

import sys
sys.setrecursionlimit(200000)

from functools import lru_cache

@lru_cache(maxsize=None)
def dp(cur,i):
	if cur==N:
		if i==3:
			return 1
		else:
			return 0
	else:
		if S[cur]=='ABCD'[i]:
			return (dp(cur+1,i+1)+dp(cur+1,i))%mod
		elif S[cur]=='?' and i!=3:
			return (dp(cur+1,i+1)+3*dp(cur+1,i))%mod
		elif S[cur]=='?':
			return 3*dp(cur+1,i)%mod
		else:
			return dp(cur+1,i)%mod

print(dp(0,0)%mod)

### FIXED CODE ###

S=input()
lens=len(S)
mod=10**9+7
cnt=[0,0,0,1]
for s in S:
    if s=="A":
        cnt[0]=(cnt[0]+cnt[3])%mod
    elif s=="B":
        cnt[1]=(cnt[0]+cnt[1])%mod
    elif s=="C":
        cnt[2]=(cnt[1]+cnt[2])%mod
    else:
        cnt[2]=(cnt[1]+3*cnt[2])%mod
        cnt[1]=(cnt[0]+3*cnt[1])%mod
        cnt[0]=(3*cnt[0]+cnt[3])%mod
        cnt[3]=cnt[3]*3%mod
print(cnt[2]%mod)
import re
print(max(map(len, re.findall("A.*Z",input())))

### FIXED CODE ###

import re

r = re.compile(r"A.*Z")
print(max(map(len, r.findall(input()))))
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  if a[i][1]=='BTC':
    ans+=380000*a[i][0]
  else:
    ans+=a[i][0]
print(ans)

### FIXED CODE ###

n=int(input())
a=[]
for i in range(n):
  x,v=input().split()
  a.append([x,v])
ans=0
for i in range(n):
  if a[i][1]=='BTC':
    ans+=380000*float(a[i][0])
  else:
    ans+=int(a[i][0])
print(ans)
S = intinput()
n = len(S)
ans = 0
for i in range(2**(n-1)):
    s = S[0]
    for j in range(n-1):
        if (i >> j) & 1:
            s += '+'
        s += S[j+1]
    ans += eval(s)
print(ans)


### FIXED CODE ###

S = input()
n = len(S)
ans = 0
for i in range(2**(n-1)):
    s = S[0]
    for j in range(n-1):
        if (i >> j) & 1:
            s += '+'
        s += S[j+1]
    ans += eval(s)
print(ans)
N,A,B=list(map(lambda i:int(i),input().split()))

answer =0

if A==0:
    answer = 0
if b==0:
    answer = N
else:
    tail=0
    if N%(A+B) > B:
        tail = B
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)


### FIXED CODE ###

N,A,B=list(map(lambda i:int(i),input().split()))

answer =0

if A==0:
    answer = 0
elif B==0:
    answer = N
else:
    tail=0
    if N%(A+B) > A:
        tail = A
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)
import numpy as np
def getLine():
    return list(map(int, input().split()))
n,m = getLine()
s = np.full(m,-1)
c = np.full(m,10)
r = np.full(n,-1)
for i in range(m):
    a,b = getLine()
    if a in s:
        c[np.where(a == s)] = min(c[np.where(a == s)], b)
    else:
        s[i] = a
        c[i] = b
for a,b in zip(s,c):
    r[a-1] = b
if r[0] < 0 or (n > 1 and r[0] == 0):
    print(-1)
else:
    r[np.where(r == -1)] = 0
    r[np.where(r == 10)] = 0
    r = r.astype(str)
    print(''.join(r))

### FIXED CODE ###

import numpy as np
def getLine():
    return list(map(int, input().split()))
n,m = getLine()
r = np.full(n,-1,dtype=int)
for i in range(m):
    a,b = getLine()
    
    if r[a - 1] == -1:
        r[a - 1] = b
    elif r[a - 1] != b:
        print(-1)
        break
else:
    if n > 1 and r[0] == 0:
        print(-1)
    else:
        if r[0] == 0 and n == 1:
            print('0')
        else:
            if n > 1 and r[0] == -1:
                r[0] = 1
            r[r == -1] = 0
            r = r.astype(str)
            print(''.join(r))
while True:
  a,b=map(int, input().split())
  if a = 0 and b = 0:
    break
  for i in range(a):
    for j in range(b):
      if i>0 and i < a-1 and j>0 and j<b-1 and a>0 and b>0:
        print(".",end="")
      else:
        print('#',end='')
    print('')

### FIXED CODE ###

while True:
  a,b=map(int, input().split())
  if a == 0 and b == 0:
    break
  for i in range(a):
    for j in range(b):
      if i>0 and i < a-1 and j>0 and j<b-1 and a>0 and b>0:
        print(".",end="")
      else:
        print('#',end='')
    print('')
  print('')
N,W=map(int,input().split())
A=[]
for _ in range(N):
    B=list(map(int,input().split()))
    A.append(B)
dp=[]
for _ in range(N):
    dp.append([0]*(W+1))
for j in range(W+1):
    if j>=A[0][0]:
        dp[0][j]=A[0][1]
for i in range(0,N-1):
    for w in range(W+1):
        if w>=A[i+1][0]:
            dp[i+1][w]=max(dp[i][w-A[i+1][0]]+A[i+1][1],dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[N-1][W])


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, W = [int(x) for x in input().split()]
wv = []
for _ in range(N):
    wv.append([int(x) for x in input().split()])
V = 10 ** 5
inf = float("inf")

dp = [[inf] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
ans = -1

for i in range(N):
    for j in range(V + 1):
        w, v = wv[i]
        if j >= v:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w)
        else:
            dp[i + 1][j] = dp[i][j]
        if dp[i + 1][j] <= W:
            ans = max(ans, j)
print(ans)
N = int(input())
my_list =list(range(1,N ))

print(sum(my_list))

### FIXED CODE ###

N = int(input())

if (N -1) % 2 == 0:
  ans = N*(N-1)//2
else:
  ans = N*(N-2)//2 + N//2
  
print(ans)
b = "ACACTACG"
n, q = map(int, input().split())
b = input()
a = [[int(x) for x in input().split()] for _ in range(q)]
for j in range(len(b)-1):
        if b[j] == "A" and b[j+1] == "C":
            ans.append(1)
        else:
            ans.append(0)
for i in a:
    print(sum(ans[i[0]:i[1]]))


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
t = [[int(x) for x in input().split()] for _ in range(q)]
add_list = [0]
for i in range(len(s)-1):
    if s[i:i+2] == "AC":
        add_list.append(add_list[i]+1)
    else:
        add_list.append(add_list[i])
for i in t:
    ans = add_list[i[1]-1] - add_list[i[0]-1]
    print(ans)
import math
a,b = map(int, input().split())
print(int(math.floor(a*b)))

### FIXED CODE ###

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

A = int(A)
B = int(''.join(B.split('.')))
print(A*B//100)
n = int( input())
a = list ( map( int, input().split()))

def swap(a,i,j):
  c = a[i]
  d = a[j]
  if a[i]>a[j]:
    a[j] = c
    a[i] = d
  return a

for i in range (n/2+1):
  for j in range (i+1,n):
    swap(a,i,j)
    
print(a[n/2+1]-a[n/2])
  

### FIXED CODE ###

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

a.sort()
k = int(n/2)    
print(a[k]-a[k-1])
from operator import itemgetter

n = int(input())
r = []
b = []
c = 0
for i in range(n):
  r.append(list(map(int,input().split())))
for i in range(n):
  b.append(list(map(int,input().split())))
r.sort(key = itemgetter(1),reverse = True)
b.sort(key = itemgetter(0))
for i in range(n):
  for j in range(n):
    if b[i][0] > r[j][0] and b[i][1] > r[j][1]:
      r[j] = [10**6,10**6]
      c += 1
      break
print(c)
    


### FIXED CODE ###

a,b,c = map(int,input().split())
if a + b >= c:
  print("Yes")
else:
  print("No")
import sys
from math import sqrt
from collections import Counter, defaultdict

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    k = I()

    c = 0
    for i in range():
        string = str(i)
        s0 = int(string[0])
        flag = True
        for s in string:
            ints = int(s)
            if abs(ints - s0) > 1:
                flag = False
                break
            s0 = ints
        if flag:
            c += 1
        if c == k:
            print(i)

    pass


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from math import sqrt
from collections import Counter, defaultdict, deque

input = sys.stdin.readline


def I():
    return int(input())


def MI():
    return map(int, input().split())


def LI():
    return list(MI())


def LIN(n: int):
    return [I() for _ in range(n)]


inf = float("inf")
mod = 10 ** 9 + 7


def main():
    k = I()

    q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
    for i in range(1, 10 ** 5 + 1):
        ln = q.popleft()

        if i == k:
            print(ln)
            break

        r = ln % 10
        new_ln = ln * 10 + r
        if r != 0:
            q.append(new_ln - 1)
        q.append(new_ln)
        if r != 9:
            q.append(new_ln + 1)


if __name__ == "__main__":
    main()
import sys
sys.setrecursionlimit(10000)

def check(x, y, flag):
	farm[x][y] = "$"
	if farm[x + 1][y] == flag : check(x + 1, y, flag)
	if farm[x - 1][y] == flag : check(x - 1, y, flag)
	if farm[x][y + 1] == flag : check(x, y + 1, flag)
	if farm[x][y - 1] == flag : check(x, y - 1, flag)
	return 1

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	farm = []
	farm.append(list("$" * (w + 2)))
	for i in range(0, h):
		farm.append(list("$" + raw_input() + "$"))
	farm.append(list("$" * (w + 2)))
	
	count = 0
	for i in range(0, h):
		for j in range(0, w):
			if farm[i + 1][j + 1] != "$":
				count += check(i + 1, j + 1, farm[i + 1][j + 1])
				
	print count

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def check(x, y, flag):
	farm[x][y] = "$"
	if farm[x + 1][y] == flag : check(x + 1, y, flag)
	if farm[x - 1][y] == flag : check(x - 1, y, flag)
	if farm[x][y + 1] == flag : check(x, y + 1, flag)
	if farm[x][y - 1] == flag : check(x, y - 1, flag)
	return 1

while True:
	h,w = map(int, raw_input().split())
	if h == 0 and w == 0 : break

	farm = []
	farm.append(list("$" * (w + 2)))
	for i in range(0, h):
		farm.append(list("$" + raw_input() + "$"))
	farm.append(list("$" * (w + 2)))
	
	count = 0
	for i in range(0, h):
		for j in range(0, w):
			if farm[i + 1][j + 1] != "$":
				count += check(i + 1, j + 1, farm[i + 1][j + 1])
				
	print count
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
i = 0
j = 0
for _ in range(n+m):
    # print(i,j,k)
    if n <= i:#
        k -= b[j]
        j += 1
        if k < 0:
            break
        ans += 1
        if k == 0:
            break
        continue
    elif n <= j:
        k -= a[i]
        i += 1
        if k < 0:
            break
        ans += 1
        if k == 0:
            break
        continue
    if a[i] < b[j]:
        k -= a[i]
        i += 1
    else:
        k -= b[j]
        j += 1
    if k < 0:
        break
    ans += 1
    if k == 0:
        break
print(ans)

### FIXED CODE ###

#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    if A[i] > k:
        break
    #K<=A[i]+B[j]となるまでjを引く>>k-A<=B
    while A[i] + B[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)
x = int(input())
print('{}'.format(str(int(x/500)*1000 + x%500))

### FIXED CODE ###

N=int(input())
print('{}'.format(str(int(N/500)*1000+int(N%500/5)*5)))
def gcd(x,y):
  return x if y=0 else gcd(y,x%y)

def lcm(x,y):
  return (x*y)/gcd(x,y)

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

print(lcm(a,b))

### FIXED CODE ###

def gcd(x,y):
  return x if y==0 else gcd(y,x%y)

def lcm(x,y):
  return (x*y)//gcd(x,y)

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

print(lcm(a,b))
import math
S=input()
S_list=[*S]
sumup=0
print(len(S_list))
if len(S_list)%2==0:
  for i in range(math.floor(len(S_list)/2)):
    if S_list[i]!=S_list[len(S_list)-i-1]:
      sumup+=1
  print(sumup)
else:
  for i in range(math.floor((len(S_list)-1)/2)):
    if S_list[i]!=S_list[len(S_list)-i-1]:
      sumup+=1
  print(sumup)

### FIXED CODE ###

import math
s=input()
S_list = [s[i: i+1] for i in range(0, len(s))]
sumup=0
if len(S_list)%2==0:
  for i in range(math.floor(len(S_list)/2)):
    if S_list[i]!=S_list[len(S_list)-i-1]:
      sumup+=1
  print(sumup)
else:
  for i in range(math.floor((len(S_list)-1)/2)):
    if S_list[i]!=S_list[len(S_list)-i-1]:
      sumup+=1
  print(sumup)
import math
a,b,c,d=map(int,input().split())
ans=b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
e=math.gcd(a,b)
ans+=b//e-(a-1)//e
print(ans)

### FIXED CODE ###

def gcd(n,m):
    if n<m:
        return gcd(m,n)
    if n%m==0:
        return m
    else:
        return gcd(m,n%m)

a,b,c,d=map(int,input().split())
ans=b-a+1
ans-=b//c-(a-1)//c
ans-=b//d-(a-1)//d
e=c*d//(gcd(c,d))
ans+=b//e-(a-1)//e
print(ans)