Harryxun/stf_run huggingface dataset:
x,y,z,q = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)



if  x*y*z <100000
    la = []
    for i in range(x):
        for k in range(y):
            for m in range(z):
                la.append(a[i]+b[k]+c[m])
    la = sorted(la)

    for p in range(q):
        print(la[-p-1])

else:
    la  = []
    for i in range(x):
        for k in range(3000//i, y):
            for m in range(3000//(i*k), z):
                la.append(a[i]+b[k]+c[m])
    la = sorted(la)
    for i in range(q):
        print(la[-i-1])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a = sorted(a)
b = sorted(b)
c = sorted(c)

la = []

for i in range(x):
    s = x-i
    for n in range(max(y-5-3000//s,0),y):
        u = y-n
        for m in range(max(z-5-3000//(s*u),0),z):
            #print(s,u,m)
            la.append(a[i]+b[n]+c[m])

la = sorted(la)

for i in range(k):
    print(la[-i-1])
import sys
N = int(input())
N2 = list(map(int,str(N)))
if not (1000 <= N <= 9999):
    sys.exit()

if N2[0] == N2[1] == N2[2] or N2[1] == N2[2] == N[3]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import sys
N = int(input())
N2 = list(map(int,str(N)))
if not (1000 <= N <= 9999):
    sys.exit()

if N2[0] == N2[1] == N2[2] or N2[1] == N2[2] == N2[3]:
    print("Yes")
else:
    print("No")
from heapq import heappush, heappop
import sys

N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit(1)

h = []
for i in p:
    heappush(h, i)

while(len(h) != K):
    k = heappop(h) + heappop(h)
    heappush(h, k)

print(min(h))


### FIXED CODE ###

import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
    S = str(input())[0]
    if S in d:
        d[S] += 1
    else:
        d[S] = 1
p = list(d.values())
if len(p) < K:
    print(0)
    sys.exit()
c = 0
while(len(p) >= K):
    c += 1
    sq = sorted(p, reverse=True)
    for i in range(K):
        sq[i] = sq[i] - 1
    p = [i for i in sq if i != 0]
print(c)
s = list(input())
if s[2] == s[3] & s[4] == s[5]:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

s = list(input())
if (s[2] == s[3]) & (s[4] == s[5]):
  print('Yes')
else:
  print('No')
N,M = map(int,input().split())
S=[]
C=[]
for i in range(M):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)

ans = 0
C_check = []
S_check = []
for i in range(M):
    j = (N-S[i])
    if S[i] in S_check:
        index = S_check.index(S[i])
        if C[i]!=C[index]:
            ans = '-1'
            break
        continue
    if S[i] < N:
        if S[i]==1 and C[i]==0:
            ans = '-1'
            break

    ans += 10**j*C[i]
    S_check.append(S[i])

if not 1 in S_check:
    ans += 10**(N-1)





print(ans)


### FIXED CODE ###

N,M = map(int,input().split())
S=[]
C=[]
for i in range(M):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)
not_ans=0
ans = 0
C_check = []
S_check = []
for i in range(M):
    j = (N-S[i])
    if S[i] in S_check:
        index = S_check.index(S[i])
        if C[i]!=C[index]:
            not_ans = '-1'
            break
        continue
    if S[i] < N:
        if S[i]==1 and C[i]==0:
            not_ans = '-1'
            break
    if N < S[i]:
        not_ans = '-1'

    ans += 10**j*C[i]
    S_check.append(S[i])

if not 1 in S_check:
    ans += 10**(N-1)

if N==1 and M==0:
    ans = 0




if not_ans=='-1':
    print(not_ans)
else:
    print(ans)
N, Y = map(int, input().split())  
 
def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            # z = n - x - y
            tmp = total - 10000 * x - 5000 * y
            if z == tmp / 1000:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'
 
 
print(judge(N, Y))

### FIXED CODE ###

N, Y = map(int, input().split())
# N = 9
# Y = 45000


def judge(n, target):
    for x in range(n+1):
        for y in range(n+1-x):
            z = n - x - y
            total = 10000 * x + 5000 * y + 1000 * z
            if total == target:
                return '{} {} {}'.format(x, y, z)
    return '-1 -1 -1'


print(judge(N, Y))
def main():
    A, B, X = list(map(int, input().split()))
    if A >= X or B >= X:
        N = 0
    else:
        for d in range(len(str(X)), 0, -1):
            if d * B < X:
                break
        if d > 0:
            N = 0
            d = min(X // A, pow(10, d))
            for N in range(d, 0, -1):
                if afford(A, B, N, X):
                    break
            else:
                N = 0
        else:
            N = 0
    print(N if N < 1e9 else int(1e9))


def afford(a, b, n, x):
    c = a * n
    if c >= x:
        return False
    y = c + b * len(str(n))
    return y <= x


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    dow = ['SAT', 'FRI', 'THU', 'WED', 'TUE', 'MON', 'SUN']
    s = input()
    i = dow.index(s) + 1
    print(i)


if __name__ == "__main__":
    main()
n,k  = map(int,input().split())
a = list(map(int,input().split()))
a.insert(0,0)

town =1
visited = [0] * (n+1)

for i in range(1,k+1):
    town = a[town]
    if visited[town] !=0:
        rest =(k - visited[town]) % (i -visited[town])
        goal =visited.index(visited[town]+rest)
        break
    visited[town] = i 
    

print(goal)

### FIXED CODE ###

import sys
import numpy as np
from collections import defaultdict



#input = sys.stdin.readline

def main():
    N, K = map(int,input().split())
    A = list(map(int,input().split()))
    A = [0] +A  #transporter
    visited = [0] * (N+1)
    town = 1
    cycle = 0
    for i in range(1,K+1):
        town = A[town]
        if visited[town] ==0:
            visited[town] = i
        else:
            cycle = i - visited[town]
            place = (K - visited[town]) % cycle + visited[town]
            for j in range(N+1):
                if visited[j] == place:
                    print(j)
                    exit()
    print(town)




if __name__ == "__main__":
    main()
x = int(input())
a = []

for i in range(100):
    num = i ** 5
    a.append(num)

for i in range(100):
    for j in range(i, 100):
        if a[i] - a[j] == x:
            ans = str(i) + ' ' + str(j)
        elif a[i] + a[j] == x:
            ans = str(i) + ' -' + str(j)
        elif a[j] - a[i] == x:
            ans = '-' + str(i) + ' -' + str(j)

print(ans)
            


### FIXED CODE ###

x = int(input())
a = []

for i in range(500):
    num = i ** 5
    a.append(num)

for i in range(500):
    for j in range(i, 500):
        if a[i] - a[j] == x:
            ans = str(i) + ' ' + str(j)
            break
        elif a[i] + a[j] == x:
            ans = str(i) + ' -' + str(j)
            break
        elif a[j] - a[i] == x:
            ans = '-' + str(i) + ' -' + str(j)
            break

print(ans)
import sys

s = input()

if s[0] != "A":
    print("WA")
    sys.exit(0)

if s[1] < "a" or s[1] > "z":
    print("WA")
    sys.exit(1)


sub = s[2:-1]
has = False
for c in sub:
    if not has and c == "C":
        has = True

    elif "a" <= c <= "z":
        continue

    else:
        has = False
        break

if not has:
    print("wA")
    sys.exit(0)

if "a" <= s[len(s) - 1] <= "z":
    print("AC")
else:
    print("WA")


### FIXED CODE ###

import sys

s = input()

if s[0] != "A":
    print("WA")
    sys.exit(0)

if s[1] < "a" or s[1] > "z":
    print("WA")
    sys.exit(0)


sub = s[2:-1]
has = False
for c in sub:
    if not has and c == "C":
        has = True

    elif "a" <= c <= "z":
        continue

    else:
        has = False
        break

if not has:
    print("WA")
    sys.exit(0)

if "a" <= s[-1] <= "z":
    print("AC")
else:
    print("WA")
import itertools as it

n,m=map(int,input().split())
ans=[]
for i in range(n):
    a,b=map(int,input().split())
    ans.append([a,b])
    ans.append([b,a])
  
a=0
for e in it.permutations(range(n)):
    #print(e)
    count=1
    if e[0]!=0:
        break
    
    for i in range(len(e)-1):
        if [e[i]+1,e[i+1]+1] in ans:
            count*=1
        else:
            count*=0
            break
            
    a+=count
    
print(a)

### FIXED CODE ###

import itertools as it
import sys

N, M = map(int, input().split())
if N==0 or M==0:
    print(0)
    sys.exit()
a=[]

for i in range(M):
    x,y=map(int,input().split())
    a.append([x,y])
    a.append([y,x])

ans=0
for e in it.permutations(range(N)):
    if e[0]!=0:
        break
        
    count=1
    for j in range(N-1):
        if [e[j]+1,e[j+1]+1] in a:
            count*=1
        else:
            count*=0
            break
            
    ans+=count

print(ans)
import time
import math
def sieve(n):
    prime = []
    limit = math.sqrt(n)
    data = [i for i in range(2, n+1)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())
prime = sieve(n)
ans = 1
for sosu in prime:
    cnt = 0
    for i in range(2, n+1):
        num = i
        while num % sosu == 0:
            num //= sosu 
            cnt += 1
    ans *= (cnt + 1)
print(ans % (10**9 + 7))


### FIXED CODE ###

import time
import math
def sieve(n):
    prime = []
    limit = math.sqrt(n)
    data = [i for i in range(2, n+1)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())
if n == 1:
    print(1)
    exit()
prime = sieve(n)
ans = 1
for sosu in prime:
    cnt = 0
    for i in range(2, n+1):
        num = i
        while num % sosu == 0:
            num //= sosu 
            cnt += 1
    ans *= (cnt + 1)
print(ans % (10**9 + 7))
# input
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for i in range(N - M + 1):
    for j in range(N - M + 1):
        for k in range(M):
            for l in range(M):
                if B[k][l] == A[i + k][j + l]:
                    ans += 1
                else:
                    break
            if ans == M * 2:
                print("Yes")
                exit()
            else:
                ans = 0
                break

print('No')

### FIXED CODE ###

import numpy as np

# input
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

A_arr = np.array(A)
B_arr = np.array(B)

for i in range(N - M + 1):
    for j in range(N - M + 1):
        if np.array_equal(A_arr[i:i + M, j:j + M], B_arr):
            print('Yes')
            exit()

print('No')
S = list(map(int,input().split()))
len(S)=p
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(t/2)

### FIXED CODE ###

S = input()
p=len(S)
t=0
for n in range(p):
  if S[n]!=S[p-n-1]:
    t+=1
print(int(t/2))
x = int(input())

rs = [i ** 5 for i in range(300)]

for r in rs:
    if (x - r) in rs:
        print(rs.index(r), - rs.index(x - r))
    elif (x + r) in rs:
        print(rs.index(r), rs.index(x - r))
    else:
        continue
    break


### FIXED CODE ###

x = int(input())

rs = [i ** 5 for i in range(300)]

for r in rs:
    if r <= x:
        if x - r in rs:
            print(rs.index(r), - rs.index(x - r))
            break
    if r > x:
        if r - x in rs:
            print(rs.index(r), rs.index(r - x))
            break
str_n = input()
str_an = input()

n = int(str_n)
an = [int(ai) for ai in str_an.split()]

ans = 1
for ai in an:
  ans *= ai

if ans > 1e8:
  ans = -1
  
print(ans)


### FIXED CODE ###

def main():
  l = input().split()
  A, B = int(l[0]), float(l[1])
  B100 = int(B*1000)
  ans = int((A*B100)/1000)
  print(ans)
  return

main()
import itertools
s = input()
t = input()

A = itertools.combinations(list(range(len(t)+1)),2)
for i in A:
    part = t[i[0]:i[1]]
    if part in s:
        ans = len(part)
        
print(len(t) - ans)


### FIXED CODE ###

s= input()
t = input()

count = len(t)

for i in range(len(s) - len(t) + 1):
    str_ = s[i:i + len(t)]
    temp = 0
    for i in range(len(str_)):
        #print(str_[i])
        if str_[i] != t[i]:
            temp += 1
    count = min(count, temp)    
        
print(count)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = raw_input()

var = var*var*var
print var

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = int(raw_input())
sum = var*var*var

print sum
def swap(a,b):
    temp=a
    a=b
    b=temp


lis=[]
for i in range(3):
    a=int(input())
    lis.append(a)
for j in lis:
    print(j,end=" ")
    
swap(a[1],a[2])
swap(a[1],a[3])
for j in lis:
    print(j)



### FIXED CODE ###

a,b,c=map(int,input().split())
print(c,a,b)
n = int(input())
h = list(map(int, input().split()))

#aとbで小さい方を返す
def chmin(a,b):
    if a > b:
        return b
    else:
        return a

f_inf = float('inf')

dp = [f_inf] * (10**5+10)

dp[0] = 0

def rec(i):
    if dp[i] < f_inf:
        return dp[i]

    if i == 0:
        return 0

    res = f_inf
    res = chmin(res, rec(i-1) + abs(h[i] - h[i-1]))
    if i > 1:
        res = chmin(res, rec(i-2) + abs(h[i] - h[i-2]))

    dp[i] = res
    return res

ans = res(n-1)
print(ans)

### FIXED CODE ###

import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = np.zeros(n, dtype=int)
h = np.array(h)

for i in range(1,n):
    start = max(0, i-k)
    dp[i] = min(dp[start: i] + np.abs(h[i] - h[start: i]))

print(dp[n-1])
N=int(input())

def make_divisors(n):
    divisors=[]
    for i range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)

### FIXED CODE ###

N=int(input())

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    
    divisors.sort()
    return divisors

ans=0
divisors=make_divisors(N)

for d in divisors:
    m=(d-1)
    if m and (N//m==N%m):
        ans+=m

print(ans)
N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  ans = input()
  
  if ans = "AC":
    AC += 1
    
  elif ans = "WA":
    WA += 1
    
  elif ans = "TLE":
    TLE += 1
    
  elif ans = "RE":
    RE += 1
    
print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)

### FIXED CODE ###

N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
  ans = input()
  
  if ans == "AC":
    AC += 1
    
  elif ans == "WA":
    WA += 1
    
  elif ans == "TLE":
    TLE += 1
    
  elif ans == "RE":
    RE += 1
    
print("AC x", AC)
print("WA x", WA)
print("TLE x", TLE)
print("RE x", RE)
import math
def fib(q):
    result = int(1 / math.sqrt(5) * (((1+math.sqrt(5))/2)**(q) - ((1-math.sqrt(5))/2)**(q)))
    return result
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]-1))
out%=c
print(out)

### FIXED CODE ###

import math
def fib(q):
   fibonacci = [0,1]
   for i in range(2,q):
       fibonacci.append(fibonacci[i-2]+fibonacci[i-1])
   return fibonacci[q-1]
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]))
out%=c
print(out)
import sys


def count(split_haichi):
    black_count = sum([x == '#' for x in split_haichi])
    white_count = len(split_haichi) - black_count
    return min(black_count, white_count)


a = []
for l in sys.stdin:
    a.append(l)

num = int(a[0])
haichi = a[1]
count_list = []

black_all_count = sum([x == '#' for x in haichi])
white_all_count = num - black_all_count
for i in range(num-1):
    if haichi[i] == '#':
        split_haichi_1 = haichi[:i+1]
        split_haichi_2 = haichi[i+1:]

        black_count_1 = sum([x == '#' for x in split_haichi_1])
        white_count_1 = len(split_haichi_1) - black_count_1

        black_count_2 = black_all_count - black_count_1
        white_count_2 = white_all_count - white_count_1

        count_list.append(min(black_count_1, white_count_1) + min(black_count_2, white_count_2))

print(min(count_list))


### FIXED CODE ###

import sys
a = []
for l in sys.stdin:
    a.append(l)

zahyou = [int(x) for x in a[0].split()]
a, b, c = zahyou
if max(zahyou) == c or min(zahyou) == c:
    print("No")
else:
    print("Yes")
a,b = map(int, input().split())

ans = a * b
for i in range(a)
if ans % i**2:
	ans = ans // i
print(ans)

### FIXED CODE ###

a,b = map(int, input().split())
 
com = 1
for i in reversed(range(2,a+1)):
	if a % i ==0 and b % i == 0:
		a = a//i
		b = b//i
		com = com*i
#		print(i)
print(a*b*com)
import heapq
def sol(inp=input):
    n,m=map(int,inp().split())
    G={i+1:set() for i in range(n)}
    for _ in range(m):
        i,j=map(int,inp().split())
        G[i].add((j,1))
    s,t=map(int,inp().split())
    cache_kenken={}
    def kenkenpa(v):
        for v1,l1 in tuple(G[v]):
            if l1==1:
                for v2,l2 in tuple(G[v1]):
                    if l1+l2==3:
                        yield v2
                        continue
                    else:
                        G[v].add((v2,l1+l2))
                        for v3,l3 in G[v2]:
                            G[v1].add((v3,l2+l3))
                            yield v3
                            continue
            if l1==2:
                for v2,l2 in G[v1]:
                    if l1+l2==3:
                        yield v2
                        continue
        
    visited={s}
    revisited=set()
    v_steps=[]
    visited_pa={s}
    que=[]
    heapq.heappush(que,(0,s))
    while len(que)>0:
        step,u=heapq.heappop(que)
        for v in kenkenpa(u):
            if v not in visited:
                visited.add(v)
                v_steps.append((step+1,v))
                heapq.heappush(que,(step+1,v))
            if v==t:
                return step+1
            if v not in visited:
                visited.add(v)
    return -1
print(sol())

### FIXED CODE ###

import heapq
def sol(inp=input):
    s=3
    n,m=map(int,inp().split())
    G={(i+1,j):set() for i in range(n) for j in range(s)}
    for _ in range(m):
        u,v=map(int,inp().split())
        for i in range(s):
            G[(u,i)].add((v,(i+1)%s))
    s,t=map(int,inp().split())
    visited={(s,0)}
    que=[]
    heapq.heappush(que,(0,(s,0)))
    while len(que)>0:
        step,u=heapq.heappop(que)
        for v in G[u]:
            if v not in visited:
                visited.add(v)
                heapq.heappush(que,(step+1,v))
            if v==(t,0):
                return (step+1)//3
    return -1
print(sol())
# -*- coding: utf-8 -*-
N = int(input())
C = [[] for _ in range(N)]

for i in range(1, N):
    C[int(input())-1].append(i)

def cal(x):
    if len(C[x]) == 0:
        return 0
    else:
        D = sorted([cal(a) for a in C[x]], reverse=True)
        res = 0
        for i, d in enumerate(D, start=1):
            res = max(res, i+d)
        return res

print(cal(0))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import setrecursionlimit
setrecursionlimit(10000000)

N = int(input())
C = [[] for _ in range(N+1)]

for i in range(1, N):
    C[int(input())-1].append(i)

def cal(x):
    if len(C[x]) == 0:
        return 0
    else:
        D = sorted([cal(a) for a in C[x]], reverse=True)
        res = 0
        for i, d in enumerate(D, start=1):
            res = max(res, i+d)
        return res

print(cal(0))
n, m = map(int,input().split())
l = list(map(int,input().split()))
 
import math
 
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)
def lcm(x, y):
    return x * y / gcd(x, y)
 
ans = 1
tf = True
 
for i in l:
    i /= 2
    ans = lcm(ans, i)
    if (ans / i) % 2 == 0 or ans > m:
        print(0)
        tf = False
        break
 
if tf == True:
    print(math.ceil(m / (ans * 2)))

### FIXED CODE ###

k, x = map(int, input().split())
print('Yes' if x <= 500 * k else 'No')
import math

n = int(input())
for i in range(n):
    x = int(input())
    y = int(input())
    result = x + y
    if math.log10(result) + 1 < 81:
        print(result)
    else:
        print("overflow")

### FIXED CODE ###

n = int(input())
for i in range(n):
    x = int(input())
    y = int(input())
    if x + y >= 10 ** 80:
        print("overflow")
    else:
        print(x + y)
import heapq,sys


def main():
    input = sys.stdin.readline
    X, Y, Z, K = map(int, input().split())
    A = sorted([int(i) for i in input().split()], reverse=True)
    B = sorted([int(i) for i in input().split()], reverse=True)
    C = sorted([int(i) for i in input().split()], reverse=True)
    ans = []
    AandB = []
    for i in range(X):
        for j in range(Y):
            heapq.heappush(AandB, A[i] + B[j])
            #要素がK+1個以上なら一々はじく！！！ことでO(logK)
            if len(AandB) > K:
                heapq.heappop(AandB)
    
    heap_queue = []
    for k in range(Z):
        for h in range(len(AandB)):
            heapq.heappush(heap_queue,C[k] + AandB[h])
            if len(heap_queue) > K:
                heapq.heappop(AandB)
    heap_queue.sort(reverse = True)
    for e in heap_queue:
        print(e)
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,bisect
input = sys.stdin.readline

x,y,z,k = map(int,input().split())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))
c = list(map(int,input().split()))

ab = []
for e in a:
    for w in b:
        ab.append(e+w)
ab.sort()

ok = -1
ng = 10**12
while abs(ok-ng)>1:
    mid = (ok+ng)//2
    cnt = 0
    for e in c:
        cnt += len(ab)-bisect.bisect_left(ab,mid-e)
    if cnt >= k:
        ok = mid
    else:
        ng = mid

res = []
for e in c:
    ind = bisect.bisect_left(ab,ok-e)
    for i in range(ind,len(ab)):
        res.append(e+ab[i])
res.sort()
for i in range(1,k+1):
    print(res[-i])
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ans = 9999999999
lists = []
for i in range(1, 101):
    if i not in p:
        lists.append(i)
for i in lists:
    if ans > abs(x - i):
        ans = abs(x-i)
        m = i

print(m)


### FIXED CODE ###

x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
li = []
ans = []
Min_sa = 9999999999
for i in range(-200,201):
    if i not in p:
        li.append(i)
for i in li:
     Min_sa = min(Min_sa,abs(x-i))
for i in li:
    if abs(x-i) == Min_sa:
        ans.append(i)
print(min(ans))
n=int(input())
dp=[[a,b,c] for i in range(n)]
for i in range(n):
    a,b,c=map(int,input().split())
    dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a
    dp[i][1]=max(dp[i-1][2],dp[i-1][0])+b
    dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c
print(max(dp[n-1]))

### FIXED CODE ###

n=int(input())
dp=[0,0,0]
for i in range(n):
    a,b,c=map(int,input().split())
    dp=[max(dp[1],dp[2])+a,max(dp[0],dp[2])+b,max(dp[0],dp[1])+c]
print(max(dp))
import fraction
# import math
n,m=map(int,input().split())
# 1*mのうちnコを予め除いた残りで組み合わせの数を求められる
# (m-n+n-1)!/((m-n)!(n-1)!)
if m%n==0:
    print(m//n)
else:
    print(fraction.gcd(m//n,m%n))
    # print(math.gcd(m//n,m%n))


### FIXED CODE ###

# できなかった
# a1,...,anがdivisorで割り切れる、すなわちdivisorはMの約数である
n,m=map(int,input().split())

divisors=[]
for i in range(1,int(m**0.5)+1):
    if m%i==0:
        divisors.append(i)
        if i!=m//i:
            divisors.append(m//i)

divisors.sort(key=lambda x:-x)
# print(divisors)
for d in divisors:
    if d<=m//n:
        print(d)
        break