peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
X, Y, A, B, C = map(int,input().split())
P = sorted(list(map(int,input().split())), reverse=True)
Q = sorted(list(map(int,input().split())), reverse=True)
R = sorted(list(map(int,input().split())), reverse=True)
P = P[:X]
Q = Q[:Y]
A = P + Q + R
A.sort(reverse=True)
ans = sum(A[:X+Y])
print(ans)
# Judge status: Accepted
def gcd(x, y):
    if x == 0:
        return y
    else:
        return gcd(y % x, x)


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


n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = lcm(ans, t)
print(ans)
# Judge status: Accepted
w, h, n = map(int, input().split())
x = []
y = []
a = []
for i in range(n):
  xi, yi, ai = map(int, input().split())
  x.append(xi)
  y.append(yi)
  a.append(ai)
xmin = 0
xmax = w
ymin = 0
ymax = h
for i in range(n):
  if a[i] == 1:
    xmin = max(xmin, x[i])
  elif a[i] == 2:
    xmax = min(xmax, x[i])
  elif a[i] == 3:
    ymin = max(ymin, y[i])
  else:
    ymax = min(ymax, y[i])
print(max(0, xmax - xmin) * max(0, ymax - ymin))
# Judge status: Wrong Answer
N = int(input())
A = []
for i in range(1,46):
  for j in range(1,46):
    for k in range(1,46):
      A.append(i**2+j**2+k**2+i*j+i*k+j*k)
A = sorted(A)
B = [0]*100000
for i in range(10000):
  if A[i] < 10000:
    B[A[i]] += 1
C = B[1:N+1]
[print(i) for i in C]
# Judge status: Accepted
N = int(input())
S = list(map(int, input().split()))
S.sort()
print(S[N//2]-S[N//2-1])
# Judge status: Accepted
N, M = map(int,input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
    p, s = map(str,input().split())
    num = int(p)-1
    if s == 'WA' and ac[num] == 0: 
        wa[num] += 1
    elif s == 'AC' and ac[num] == 0:
        ac[num] += 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print('{} {}'.format(sum(ac), sum(wa)))
# Judge status: Accepted
from decimal import Decimal
W, H, x, y = map(int, input().split())

if W == 2*x and H == 2*y:
    print(Decimal(W*H/2), 1)
else:
    print(Decimal(W*H/2), 0)
# Judge status: Accepted
place = input('')

if place == 'ABC':
    print('ARC')
else:
    print('ABC')
# Judge status: Accepted
a = list(raw_input())
b = []
q = input()
for _ in xrange(q):
    line = raw_input().split()
    if line[0] == "1":
        a, b = b, a
    elif line[1] == "1":
        b.append(line[2])
    else:
        a.append(line[2])
print ''.join(b[::-1] + a)
# Judge status: Accepted
N = int(input())
res = "No"
for c in range(N//4 + 1):
    for d in range(N//7 + 1):
        total = 4*c + 7*d
        if total == N:
            res = "Yes"
print(res)
# Judge status: Accepted
N, T = list(map(int, input().split()))

flag = False
mins = 10000
for i in range(N):
  s, t = list(map(int, input().split()))
  if T >= t:
    mins = s if mins > s else mins
    flag = True
    
print(mins if flag is True else 'TLE')
# Judge status: Accepted
temp = int(input())
if temp >= 30:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
import math
sq=math.sqrt(int("".join(input().split())))
print("YES" if sq.is_integer() else "NO")
# Judge status: Wrong Answer
n=int(input())
for i in range(1,n):
    if int(i*1.08) == n:
        print(i)
        break
else:
    print(':(')
# Judge status: Accepted
#!/usr/bin/env python3

def main():
    A, B = map(int, open(0).read().split())
    if (A < 10 and B < 10):
        print(A * B)
    else:
        print('-1')


main()
# Judge status: Accepted
A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:
    print('Possible')
else:
    print('Impossible')
# Judge status: Accepted
N,M = map(int, input().split())

M1 = M//2
M2 = M-M1

for i in range(M1):
    a=i+1
    b=2*M1+1-i
    print(a,b)
for i in range(M2):
    a=i+1
    b=2*M2-i
    print(2*M1+1 + a,2*M1+1 + b)
# Judge status: Wrong Answer
n,m = map(int, input().split())

if n > n:
    n,m = m,n

if n==1 and m==1:
    print(1) 
elif n==1:
    print(m-2)
elif n==2 or m==2:
    print(0)
else:
    print((m-2)*(n-2))
# Judge status: Accepted
import sys

S = input()

a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] == '<':
        a[i+1] = max(a[i+1], a[i]+1)

for i in range(len(S)):
    if S[-i-1] == '>':
        a[-i-2] = max(a[-i-1]+1, a[-i-2])

count = 0
for i in a:
    count += i
print(count)
# Judge status: Accepted
x, y = map(int, input().split())
cnt=0
while y >= x:
  x = x*2
  cnt +=1
print(cnt)
# Judge status: Accepted
def count(s):
    if s == 'SUN': return 7
    if s == 'MON': return 6
    if s == 'TUE': return 5
    if s == 'WED': return 4
    if s == 'THU': return 3
    if s == 'FRI': return 2
    if s == 'SAT': return 1

s = input()
print(count(s))
# Judge status: Wrong Answer
def resolve():
    S=int(input())
    i,mod=divmod(S,10**9)
    print(0,0,10**9,i,1,mod)

resolve()
# Judge status: Accepted
L = list(map(int,input().split()))
print(L.index(0)+1)
# Judge status: Wrong Answer
n = int(input())
nums = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

def gcd(x, y): #GCD
    # greatest_common_divisor
    if x < y:
        x, y = y, x
    if y == 0:
        return 0
    if x % y == 0:
        return y
    return gcd(y, x % y)

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

LCM = 1
for num in nums:
    LCM = lcm(num, LCM)
LCM %= mod
ans = 0
for num in nums:
    ans += (LCM // num) % mod
print(ans % mod)
# Judge status: Accepted
import fractions
N, X = map(int, input().split())
x  = list(map(int, input().split()))

ans = abs(X - x[0])
for i in range(N):

    ans = fractions.gcd(ans, abs(x[i]-x[i-1]))

print(ans)
# Judge status: Accepted
import sys

n=int(input())
c=input()
black=c.count("#")
white=c.count(".")

if black==n:
  print(0)
  sys.exit()

b=0
w=0
now=0
ans=float('inf')

for i in range(n):
  if c[i]=="#":
    b+=1
  w=(i+1)-b

  now=b+(white-w)
  ans=min(ans,now)
  
print(min(ans,white))
# Judge status: Accepted
n,a,b=map(int,input().split())
total=0
i=1
while i in range(1,n+1):
   l=list(str(i))
   ll=[int(s) for s in l]
   if a<=sum(ll)<=b:
        total+=i
        i+=1
   else:
           i=i+1
else:
    print(total)
# Judge status: Accepted
import math

import numpy as np

a, b = [int(v) for v in input().split()]


try:
    print(min(np.intersect1d(np.arange(math.ceil(a/0.08), (a+1) //0.08+ 1).astype(int), np.arange(math.ceil(b/0.1), (b+1)//0.1 + 1).astype(int))))

except:
    print(-1)
# Judge status: Wrong Answer
import sys
from collections import defaultdict

sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,k = map(int, input().split())
h = []
d = defaultdict(int)
cnt = []
for i in range(n):
    x = int(input())
    h.append(x)
    d[x] += 1

sh = sorted(h)
if d[sh[0]] == k or d[sh[k - 1]] == k:
    print(0)
else:
    print(sh[k - 1] - sh[0])
# Judge status: Accepted
A, B, C = map(int,input().split())
if A + B >= C:
  r = 'Yes'
else:
  r = 'No'
print(r)
# Judge status: Accepted
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

L,R,d = LI()
ans = 0
for i in range(L,R+1):
    if i % d == 0:
        ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
A_list = list(map(int, input().split()))

if len(A_list) == len(set(A_list)):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
n = int(input())

if n %2 :
    print(n//2+1)
else:
    print(n//2)
# Judge status: Accepted
import sys
input = sys.stdin.readline


def log(*args):
    print(*args, file=sys.stderr)


def main():
    N, A, B, C, D = map(int, input().split())
    log(N, A, B, C, D)
    S = input()
    if "##" in S[A-1:max(D, C)]:
        print("No")
        return
    if C < D:
        print("Yes")
        return
    log(S[B-2:D+1])
    if "..." in S[B-2:D+1]:
        print("Yes")
        return
    print("No")


if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c=map(int,input().split())
if(a==5):
    if(b==7 and c==5):
        print("YES")
    elif(b==5 and c==7):
        print("YES")
    else:
        print("NO")
elif(a==7):
    if(b==5 and c==5):
        print("YES")
    else:
        print("NO")
else:
    print("NO")
# Judge status: Wrong Answer
N = int(input())
T = []
for i in range(4):
    T.append(int(input()))
k = 0
for i in range(4):
    if N % T[i] == 0:
        k = max(k, N//T[i])
    else:
        k = max(k, N//T[i] + 1)
print(4 + k)
# Judge status: Accepted
k = [int(i) for i in input().split()]
ans='No'
if k[0] == k[1]: ans='Yes'
print(ans)
# Judge status: Wrong Answer
s = input()
t = input()
mins = 1000
maxt = 0
for i in range(len(s)):
    mins = min(mins,ord(s[i]))
for i in range(len(t)):
    maxt = max(maxt,ord(t[i]))
if mins < maxt: print('Yes')
elif mins == maxt:
    if len(s) >= len(t): print('No')
    else: print('Yes')
else: print('No')
# Judge status: Wrong Answer
def solve(N, W, weight_values):
  dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]
  dp[0][0] = 1

  for i in range(N + 1):
    i_weight, i_value = weight_values[i - 1]
    for w in range(i_weight, W + 1):
      dp[i][w] = max(dp[i - 1][w - i_weight] + i_value, dp[i - 1][w])

  print(dp[N][W])

  
def iln(): return list(map(int, input().split()))


N, W = iln()
w_v = []
for i in range(N):
  w_v.append(iln())
  
solve(N, W, w_v)
# Judge status: Accepted
import sys
from bisect import bisect_left

input = sys.stdin.readline


def solve(N, L):
    L.sort()
    ans = 0
    for a in range(N - 2):
        for b in range(a + 1, N - 1):
            c = bisect_left(L, L[a] + L[b]) - 1
            ans += c - b
    return ans


def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = solve(N, L)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,c = map(int,input().split())
r = int(input())

for i in range(r):
    if a >= b:
        b = b*2
    elif b >= c:
        c = c*2
    if a < b and b < c:
        print('Yes')
        break
else:
    print('No')
# Judge status: Wrong Answer
import collections

def main():
    n =int( input())

    cnt=dict()
    for _ in range(n):
        s=input()
        if s in cnt:
            cnt[s]+=1
        else :
            cnt[s]=1
    #print(cnt)
    
    a = [k for k, v in cnt.items() if v == max(cnt.values())]
    print("aa")
    a.sort()
    for elm in a:
        print(elm)

main()
# Judge status: Accepted
s=input()
a="abcdefghijklmnopqrstuvwxyz"
for i in range(26):
  if a[i] in s:
    continue
  else:
    print(a[i])
    exit()
print("None")
# Judge status: Accepted
x = int(input())
ans = 0
money = 100
while True:
    money = int(money * 1.01)
    ans += 1
    if money >= x:
        print(ans)
        exit()
# Judge status: Accepted
def main():
    N = list(str(input()))
    n = int("".join(N))
    sum_N = sum(list(map(int,N)))
    if n%10 == 0 and sum_N == 1:
        print(10)
    else:
        print(sum_N)


if __name__ == '__main__':
    main()
# Judge status: Accepted
# ABC 071: A – Meal Delivery
x, a, b = [int(s) for s in input().split()]
print('A' if abs(x - a) < abs(x - b) else 'B')
# Judge status: Accepted
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = float("inf")
for i in range(N - K + 1):
    left, right = X[i], X[i + K - 1]
    if left * right <= 0:
        ans = min(ans, abs(left) + right + min(abs(left), right))
    elif left > 0:
        ans = min(ans, right)
    else:
        ans = min(ans, abs(left))
print(ans)
# Judge status: Accepted
n, k, *d = map(int, open(0).read().split())
d = set(d)

while 1:
    for i in str(n):
        if int(i) in d: break
    else:
        print(n)
        break
    n += 1
# Judge status: Accepted
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [0]*(N+1)

    for i in range(1,N+1):
        X[i] += A[i-1] + X[i-1]
    ans  = float('INF') 
    for i in range(1,N):
        ans = min(ans,abs(X[N] - 2*X[i]))
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# input
N = int(input())
pat = set(
    [
        fn
        for fn in range(4, 100, 4) 
    ] + [
        sn
        for sn in range(7, 100, 7)
    ]
)

if N in pat:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A,B=input().split()
A=int(A)
B=list(B)
N=B[0]+B[2]+B[3]
N=int(N)
C=int(A*N//100)
print(C)
# Judge status: Accepted
a=int(input())
if(400<=a<=599):
    b=8
if(600<=a<=799):
    b=7
if(800<=a<=999):
    b=6
if(1000<=a<=1199):
    b=5
if(1200<=a<=1399):
    b=4
if(1400<=a<=1599):
    b=3
if(1600<=a<=1799):
    b=2
if(1800<=a<=1999):
    b=1
print(b)
# Judge status: Wrong Answer
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]
A.sort(key=lambda x:x[0])
X = []
L = []
for l in A:
    X.append(l[0])
    L.append(l[1])

pl = X[0] + L[0]
k = 0
for i in range(1, N):
    pr = X[i] - L[i]
    if pl > pr:
        k += 1
    else:
        pl = min(pl, X[i] + L[i])


print(N - k)
# Judge status: Accepted
n = int(input())

table = [0] * 10001

for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            k = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x)
            if k < 10001:
                table[k] += 1

for i in range(1, n + 1):
    print(table[i])
# Judge status: Accepted
from collections import deque
N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)

que = deque([0])
guideposts = [-1] * N
guideposts[0] = None

while que:
    n = que.pop()
    for to in G[n]:
        if guideposts[to] != -1:
            continue
        guideposts[to] = n
        que.appendleft(to)

print('Yes')
print(*[guisepost + 1 for guisepost in guideposts[1:]], sep="\n")
# Judge status: Wrong Answer
t = list(input())
for i in range(len(t)):
    if t[i] == '?':
        t[i] = 'D'
print(t)
# Judge status: Accepted
x = int(input())
cnt = 1
if x % 11 >= 7:
    cnt += 1
cnt += int(x/11) * 2
if x % 11 == 0:
    print(x//11*2)
else:
    print(cnt)
# Judge status: Accepted
s = input()
a = s.find('A')
z =s.rfind('Z')
print(z-a+1)
# Judge status: Wrong Answer
import sys
import itertools


sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M, Q = map(int, input().split())
ABCD = [list(map(int, input().split())) for _ in range(Q)]


ans = 0
for lst in itertools.combinations_with_replacement(range(1, N + 1), N):
    s = 0
    for a, b, c, d in ABCD:
        if (lst[b - 1] - lst[a - 1]) == c:
            s += d

    ans = max(ans, s)

print(ans)
# Judge status: Accepted
import fractions
 
n = int(input())
a = list(map(int, input().split()))
 
l = 1
for i in range(n):
	l = l // fractions.gcd(l, a[i])*a[i]
 
ans = 0
for i in range(n):
	ans += l//a[i]
print(ans%(10**9+7))
# Judge status: Accepted
import bisect
from collections import deque

N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

buf = deque()
for a in A:
    i = bisect.bisect_right(buf, a-1)-1
    if i < 0:
        buf.appendleft(a)
    else:
        buf[i] = a
print(len(buf))
# Judge status: Accepted
a,b = map(str,input().split())

a_L = []
a_L.append(a*int(b))
a_L.append(b*int(a))
a_L.sort()
print(a_L[0])
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
dls = []
A.sort()
A.reverse()
now = 0
for i in range(N-1):
  if now >= N-1:
    break
  else:
    if A[now] == A[now+1]:
      dls.append(A[now])
      now += 2
    else:
      now += 1
if len(dls) >= 2:
  print(dls[0]*dls[1])
else:
  print(0)
# Judge status: Wrong Answer
H, A = map(int, input().split())
i = 0

while H>=0:
    H = H-A
    i += 1

print(i)
# Judge status: Accepted
s = list(input())

count = 0

for i in range(0, 3):
    if s[i] == '1':
        count += 1

print(count)
# Judge status: Accepted
a_s, b_s = input().split()
a_i = int(a_s)
b_i = int(b_s)

a,b = "",""
for _ in range(a_i):
  b += b_s
for _ in range(b_i):
  a += a_s

ans = []
ans.append(a)
ans.append(b)

ans.sort()

print(ans[0])
# Judge status: Wrong Answer
N = int(input())

if 1998>=N>=999:
     print('ABD')
else:
    print('ABC')
# Judge status: Accepted
str = input()
if str.count('5') == 2 and str.count('7') == 1:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
import numpy as np
input()
x = np.array(input().split(),dtype=np.int32)

ans = 0
while (x%2==0).all():
  x //= 2
  ans += 1
print(ans)
# Judge status: Accepted
def main():
    n = int(input())
    s = list(input())

    x = 0
    ans = 0
    for i in range(n):
        if s[i] == 'I':
            x += 1
        if s[i] == 'D':
            x -= 1
        ans = max(ans, x)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
h1, m1, h2, m2, k = list(map(int, input().split()))

if m2 >= m1:
	time = (h2 - h1) * 60 + abs(m1 - m2) - k
else:
	time = abs(m1 - m2) - k

print(time)
# Judge status: Accepted
A,B,K=map(int,input().split())
lst=[]
a=min(A,B)
for i in range(1,a+1):
    if A%i==0:
        if B%i==0:
            lst.append(i)
lst.reverse()
print(lst[K-1])
# Judge status: Accepted
C1=input()
C2=input()
print('YES' if C1==C2[2]+C2[1]+C2[0] else 'NO')
# Judge status: Accepted
print(["No","Yes"][len(set(list(input())))==2])
# Judge status: Accepted
N = str(input())

if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n, *A = map(int, open(0).read().split())

def f(x):
  y = 0
  q, r = divmod(x, 2)
  while r == 0:
    y += 1
    q, r = divmod(q, 2)
  return y

B = [0] * 3
for a in A:
  b = f(a)
  B[0] += b == 0
  B[1] += b == 1
  B[2] += b >= 2
print('Yes' if B[0] + (B[1]!=0) <= B[2] else 'No')
# Judge status: Accepted
n,m=map(int,input().split())
SC=[list(map(int,input().split())) for _ in range(m)]
ans=-1
if n==1:
    r=range(10)
elif n==2:
    r=range(10,100)
else:
    r=range(100,1000)
for i in r :
    i=str(i)
    for j ,k in SC:
        if i[j-1]!=str(k):
            break
    else:
        print(i)
        exit()
print(-1)
# Judge status: Accepted
N = int(input())
L = [2, 1]
for i in range(2, N+1):
  L.append(L[i-1] + L[i-2])
print(L[N])
# Judge status: Accepted
N, M = map(int, input().split())
answer = 0

if N == 1 and M == 1:
    answer = 1
elif N == 1 or M == 1:
    answer = max(N, M)-2
else:
    answer = (N-2)*(M-2)

print(answer)
# Judge status: Accepted
n,r=map(int,input().split())
if n>=10:
  print(str(r))
else :
  print(r+(100*(10-n)))
# Judge status: Accepted
def resolve():
	a, b = map(int, input().split())
	if a > 8 or b > 8:
		print(':(')
	else:
		print('Yay!')
resolve()
# Judge status: Wrong Answer
s = input()
set_s = list(set(s))
s_n = len(set_s)
if s_n == 1 or s_n == 3:
  print("No") 
elif s_n==2:
  if "N" in set_s and "S" in set_s:
    print("Yes")
  elif "E" in set_s and "W" in set_s:
    print("YES")
  else:
    print("No")
else:
  print("Yes")
# Judge status: Accepted
a, b = map(int, input().split())
if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
# Judge status: Accepted
A,B = map(int,input().split())
tap = 0
plg = 1

for n in range(20):
  if plg>=B:
    print(tap)
    exit()
  else:
    plg+=A-1
    tap+=1
    
print(tap)
# Judge status: Accepted
import math
x = int(input())

year = 0
now = 100
while True:
    now = math.floor(now * 0.01) + now
    year += 1
    if now >= x:
        print(year)
        exit()
# Judge status: Accepted
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = math.ceil((n - k) / (k - 1)) + 1
print(ans)
# Judge status: Accepted
import itertools
import bisect

n,m,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
b=list(map(int,input().split()))
aa=list(itertools.accumulate(a))
bb=list(itertools.accumulate(b))
r=0
for i,ax in enumerate(aa):
    bis=bisect.bisect_right(bb,k-ax)
    if bis==0 and ax>k:continue
    r=max(r,i+bis)
print(r)
# Judge status: Wrong Answer
import math

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

print(int(math.log2(y//x))+1)
# Judge status: Accepted
n, m = map(int, input().split())
a = [list(input()) for i in range(n)]
b = [list(input()) for i in range(m)]
check = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        tmp_check = True
        for k in range(m):
            for l in range(m):
                if not (a[i + k][j + l] == b[k][l]):
                    tmp_check = False
        check = check or tmp_check
print("Yes" if check else "No")
# Judge status: Accepted
n, a = int(input()), int(input())
flg = n % 500 - a > 0

print('No' if flg else 'Yes')
# Judge status: Accepted
n,k=map(int,input().split())
l=list(map(int,input().split()))

s=1
q=[0]*n
q[0]=1
r=[1]
for i in range(k):
  s=l[s-1]
  if q[s-1]==0:
    q[s-1]+=1
    r.append(s)
    if i==k-1:
      print(s)
  else:
    x=r.index(s)
    mod=len(r)-x
    t=(k-x)%mod
    print(r[x+t])
    break
# Judge status: Wrong Answer
in_all = list(map(int, input().split()))

cnt = 0
for n in range(in_all[0]):
    tmp = str(n)
    all = 0
    for t in tmp:
        all += int(t)
    if all>=in_all[1] and all<=in_all[2]:
        cnt += 1

print(cnt)
# Judge status: Accepted
kx = list(map(int, input().split()))
k, x = kx[0], kx[1]
minimum = x - k + 1
maximum = x + k - 1
minimum = max(minimum, -1000000)
maximum = min(maximum, 1000000)
r = [i for i in range(minimum, maximum + 1)]
print(" ".join(list(map(str, r))))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
bai4 = []
bai2 = []
bai_ = []
for ai in a:
    if ai % 4 == 0:
        bai4.append(ai)
    elif ai % 2 == 0:
        bai2.append(ai)
    else:
        bai_.append(ai)

len_bai_ = len(bai_)
len_bai2 = len(bai2)
len_bai4 = len(bai4)


if len_bai_ > len_bai4:
    if len_bai_ == len_bai4 + 1 and n == len_bai_ + len_bai4:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
  if cnt<sum(p)/2:
    cnt+=p[i]
print(abs(sum(p)-cnt*2))
# Judge status: Accepted
import math

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

s=abs(h*30+m*0.5-m*6)

d=min(s,360-s)

c=a*a+b*b-2*a*b*math.cos(math.radians(d))

print(math.sqrt(c))
# Judge status: Wrong Answer
n = int(input())
AB = [tuple(map(int, input().split())) for i in range(n)]
A = [AB[i][0] for i in range(n)]
B = [AB[i][1] for i in range(n)]
# A = [(AB[i][0], i) for i in range(n)]
# B = [(AB[i][1], i) for i in range(n)]

A.sort()
B.sort()

if n % 2 == 1:
    print(B[n % 2] - A[n % 2] + 1)

if n % 2 == 0:
    print(B[n % 2 + 1] - A[n % 2] + 1)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
	if a[i] % 2 == 1: continue
	if a[i] % 3 != 0 and a[i] % 5 != 0:
		print("DENIED")
		break
else:
	print("APPROVED")
# Judge status: Wrong Answer
input_text = input()

count = len(set(input_text.split(" ")))
if count == 1:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
n,x=list(map(int,input().split()))
l=list(map(int,input().split()))
d=[0]*n
d.append(0)
for i in range(1,len(l)+1):
    d[i]=d[i-1]+l[i-1]
if d[1]>x:
    print(0)
    exit()
for i in range(len(d)):
    if d[i]>x:
        print(i)
        exit()
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
if (b-a)%2==0:
    ans=(b-a)//2
else:
    ans=(b-a)//2+1
print(ans)
# Judge status: Accepted
from collections import Counter

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

cnt = s[0]
for scnt in s:
    for str in (scnt | cnt):
        cnt[str] = min(cnt[str], scnt[str])

a = ord('a')
ans = [chr(a + i) * cnt[chr(a + i)] for i in range(26)]
print(*ans, sep='')
# Judge status: Wrong Answer
x=int(input())
ans = x//11
ans *=2
ans+=1
if x%11==0:
  ans -=1
if x%11>5:
  ans +=1
print(ans)
# Judge status: Accepted
n,m,x = map(int,input().split())
books = [list(map(int, input().split())) for _ in range(n)]

ans = []

for i in range( 1 << n):
    total = [0] * (m + 1)
    for j in range(n):
        if (i >> j) & 1:
            total = [total[k] + books[j][k] for k in range(m+1)]

    over = True
    for j in range(1, m+1):
        if total[j] < x:
            over = False
    if over:
        ans.append(total[0])

if len(ans) > 0:
    print(min(ans))
else:
    print('-1')