Harryxun/stf_run huggingface dataset:
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()

num = [0,2,5,5,4,5,6,3,7,6]

A_num = [(num[a], -a) for a in A]
A_num.sort()

min_A = -A_num[0][1]
min_num = A_num[0][0]
keta_max = N//min_num

def solve(d, amari):
    if amari < 0:
        return None
    elif amari == 0:
        if d == 0:
            return ""
        else:
            return None
    if amari < d*min_num:
        return None
    elif amari == d*min_num:
        return str(min_A) * d
    for a in A:
        temp = solve(d-1, amari-num[a])
        if temp != None:
            return str(a) + temp
    return None
    

for keta in range(keta_max, 0, -1):
    ans = solve(keta, N)
    if ans:
        break
print(ans)

### FIXED CODE ###

import sys

N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]
A.sort()
A.reverse()

num = [0,2,5,5,4,5,6,3,7,6]

A_num = [(num[a], -a) for a in A]
A_num.sort()

min_A = -A_num[0][1]
min_num = A_num[0][0]
keta_max = N//min_num

DP = [-1] * (N+1)
DP[0] = 0

for i in range(N+1):
    for j in range(M):
        n = num[A[j]]
        if i - n >= 0 and DP[i-n] != -1:
            DP[i] = max(DP[i], DP[i-n] * 10 + A[j])

print(DP[N])
import sys
import math
import heapq
import numpy
import bisect

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,M=LI()
As=LI()
As.sort()
len_As = len(As)
Acum=numpy.cumsum(As)
# print(As)
# print(Acum)

ok = 0
ng = 2*max(As)

pat = 0
sm = 0
while ng - ok > 1:
    mid_sum = (ok + ng)//2
    pat = 0
    sm = 0
    for A in As:
        A2 = mid_sum - A
        # print(A2)
        lft = bisect.bisect_left(As, A2)
        pat += len_As - lft
        sm += Acum[len_As-1] - (lft and Acum[lft-1]) + (len_As - lft)*A
    # print(pat, M, ok, ng)

    if pat < M: ng = mid_sum
    else: ok = mid_sum

pat = 0
sm = 0
for A in As:
    A2 = ok - A
    # print(A2)
    lft = bisect.bisect_left(As, A2)
    pat += len_As - lft
    sm += Acum[len_As-1] - (lft and Acum[lft-1]) + (len_As - lft)*A

# print("lo:{} hi:{} pat:{} sum:{}".format(ok, ng, pat, sm))

print(sm - (pat-M)*ok)


### FIXED CODE ###

import sys
import math
import heapq
import bisect

sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N,M=LI()
As=LI()
As.sort()
len_As = len(As)
Acum=[As[0]]
for i in range(1, len_As):
    Acum.append(Acum[i-1]+As[i])
# print(As)
# print(Acum)

ok = 0
ng = 2*max(As)+1

pat = 0
sm = 0
while ng - ok > 1:
    mid_sum = (ok + ng)//2
    pat = 0
    sm = 0
    for A in As:
        A2 = mid_sum - A
        # print(A2)
        lft = bisect.bisect_left(As, A2)
        pat += len_As - lft
        sm += Acum[len_As-1] - (lft and Acum[lft-1]) + (len_As - lft)*A
    # print(pat, M, ok, ng)

    if pat < M: ng = mid_sum
    else: ok = mid_sum

pat = 0
sm = 0
for A in As:
    A2 = ok - A
    # print(A2)
    lft = bisect.bisect_left(As, A2)
    pat += len_As - lft
    sm += Acum[len_As-1] - (lft and Acum[lft-1]) + (len_As - lft)*A

# print("lo:{} hi:{} pat:{} sum:{}".format(ok, ng, pat, sm))

print(sm - (pat-M)*ok)
n,m=map(int, input().split())
l=list(map(int, input().split()))
ans=0
l.sort()
for i in range(k):
    ans=ans+l[k]
print(ans)

### FIXED CODE ###

n,m=map(int, input().split())
l=list(map(int, input().split()))
ans=0
l.sort()
for i in range(m):
    ans=ans+l[i]
print(ans)
s=input()
t=input()
if(s[-1]==t[-1]):
    return "No"
return "Yes"

### FIXED CODE ###

import sys 
s=input()
t=input()
l=list()
for i in "abcdefghijklmnopqrstuvwxyz":
    l.append(s+""+i)
if(t in l):
    print("Yes")
else:
    print("No")
N = input()
print(N * (N + 1) / 2)


### FIXED CODE ###

N = int(input())
print(int(N * (N + 1) / 2))
n = int(input())
# w = list(map(int, input().split()))
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
q = int(input())
#p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
a_count = collections.Counter(a)
a_list = dict(list(a_count.items()))
#print(a_list)
total = sum(a)
for b, c in bc:
    if b in a_list:
        total += (c-b)*a_list[b]
        num = a_list[b]
        a_list[b] = 0
        if c in a_list:
            a_list[c] += num
        else:
            a_list[c] = num
            
    print(total)


### FIXED CODE ###

import collections
n = int(input())
# w = list(map(int, input().split()))
#n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
q = int(input())
#p = list(map(int, input().split()))
#a = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
bc = [list(map(int, input().split())) for i in range(q)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
a_count = collections.Counter(a)
a_list = dict(list(a_count.items()))
#print(a_list)
total = sum(a)
for b, c in bc:
    if b in a_list:
        total += (c-b)*a_list[b]
        num = a_list[b]
        a_list[b] = 0
        if c in a_list:
            a_list[c] += num
        else:
            a_list[c] = num
            
    print(total)
s = input()

d = ['SUN', 'MON', 'TUE', 'WEN', 'THU', 'FRI', 'SAT']

if s == 'SUN':
  print(0)
else:
  print(7- d.index(s))

### FIXED CODE ###

s = input()

d = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

print(7- d.index(s))
N=int(input())
S=input()
abc_list="abcdefghijklmnopqrstuvwxyz"
L=len(abc_list)
ans= " "
for i in S:
  ans += abc_list[(abc_list.index(i)+N) % L]
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
abc_list="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
L=len(abc_list)
ans= " "
for i in S:
  ans += abc_list[(abc_list.index(i)+N) % L]
print(ans)
A,s,C = input.split()
print(A[0]+s[0]+C[0])

### FIXED CODE ###

A,B,C = tuple(input().split())
print("A"+B[0]+"C")
A,B = input().split()

if B[0] == 0:
    BH =      B[2]+B[3]
else:
    BH = B[0]+B[2]+B[3]

ABH = str(int(A)*int(BH))
print(int(ABH[:-2]))

### FIXED CODE ###

A,B  = input().split()

if B[0] == 0:
    BH =      B[2]+B[3]
else:
    BH = B[0]+B[2]+B[3]

ABH = str(int(A)*int(BH))
if len(ABH) <= 2:
    print('0')
else:
    print(ABH[:-2])
N, K = map(int, input().split())
if(N%K==0):
    return 0
else:
    return 1

### FIXED CODE ###

N, K = map(int, input().split())
if(N%K==0):
    print(0)
else:
    print(1)
a,b=int(input())
c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)

### FIXED CODE ###

a=int(input())
b=int(input())

c=a+b
if c==3:
    print(3)
elif c==4:
    print(2)
else:
    print(1)
print(10 ** int(input()) - 2 * 9 ** int(input()) + 8 ** int(input()))

### FIXED CODE ###

N = int(input())

print(((10 ** N - 2 * 9 ** N + 8 ** N) % (10 ** 9 + 7)))
N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

# 最大値
n = numbers.pop()

# nCk を k < n の範囲で事前に計算する
memo = [0] * n

# nC1 = n
memo[1] = n

for i in range(2, n):
  memo[i] = memo[i - 1] * (n - i + 1) // i

max_value = 0
max_at = 0

for i in numbers:
  if max_value < memo[i]:
    max_value = memo[i]
    max_at = i
          
print(n, max_at)        

### FIXED CODE ###

N = int(input())
numbers = [int(x) for x in input().split()]

numbers.sort()

n = numbers.pop()
r = min(numbers, key=lambda x: abs(x - n / 2))  # N

print(n, r)
input()
A = list(map(int,input().split()))
ans = 0

while all(a% == 0 for a in A):
  A = [a/2 for a in A]
  ans += 1
print(ans)

### FIXED CODE ###

input()
A = list(map(int,input().split()))
ans = 0
 
while all(a%2 == 0 for a in A):
  A = [a/2 for a in A]
  ans += 1

print(ans)
h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
def taka(k,pos):
    if k=='U' and pos[0]-1<=h-pos[0]+1:
        pos[0] -= 1
    if k=='D' and h-pos[0]<=pos[0]:
        pos[0] += 1
    if k=='R' and w-pos[1]<=pos[1]:
        pos[1] += 1
    if k=='L' and pos[1]-1<=w-pos[1]+1:
        pos[1] -= 1
    return pos
def ao(k,pos):
    if k=='U' and pos[0]-1>=h-pos[0]+1:
        pos[0] -= 1
    if k=='D' and h-pos[0]>=pos[0]:
        pos[0] += 1
    if k=='R' and w-pos[1]>=pos[1]:
        pos[1] += 1
    if k=='L' and pos[1]-1>=w-pos[1]+1:
        pos[1] -= 1
    return pos
pos = [sr,sc]
for i in range(n):
    pos = taka(s[i],pos)
    if pos[0]<=0 or pos[1]=0 or pos[0]>h or pos[1]>w:
        print('NO')
        exit()
    pos = ao(t[i],pos)
print('YES')

### FIXED CODE ###

h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
wr = sc
wl = sc
hu = sr
hd = sr
def taka(k,wr,wl,hu,hd):
    if k=='U':
        hu -= 1
    if k=='D':
        hd += 1
    if k=='R':
        wr += 1
    if k=='L':
        wl -= 1
    return wr,wl,hu,hd
def ao(k,wr,wl,hu,hd):
    if k=='U':
        hd = max(1,hd-1)
    if k=='D':
        hu = min(h,hu+1)
    if k=='R':
        wl = min(w,wl+1)
    if k=='L':
        wr = max(1,wr-1)
    return wr,wl,hu,hd
for i in range(n):
    wr,wl,hu,hd = taka(s[i],wr,wl,hu,hd)
    if wl==0 or hu==0 or hd==h+1 or wr==w+1:
        print('NO')
        exit()
    wr,wl,hu,hd = ao(t[i],wr,wl,hu,hd)
print('YES')
from collections import deque

INF = 10 ** 20

V, E = map(int, input().split())
net = [[0] * V for _ in range(V)]
for _ in range(E):
  u, v, c = map(int, input().split())
  net[u][v] = c

start = 0
goal  = V - 1
def check_net(node, path, capacity):
  for i in range(V):
    cap = net[node][i]
    if cap != 0:
      if i == goal:
        return (path + [i], min(cap, capacity))
      else:
        return check_net(i, path + [i], min(cap, capacity))

  else:
    return ([], 0)

def update_net(path, capacity):
  for fromi, toi in zip(range(len(path) - 1), range(1, len(path))):
    fr, to = path[fromi], path[toi]
    net[fr][to] -= capacity
    net[to][fr] += capacity

i = 0
while True:
  path, cap = check_net(start, [], INF)
  if path == []:
    break
  update_net(path, cap)

print(sum(net[start]))


### FIXED CODE ###

from collections import deque

class Edge:
    def __init__(self, fromNode, toNode, cap, rev=None):
        self.fromNode = fromNode
        self.toNode = toNode
        self.cap = cap
        self.rev = rev

class MaxFlow:
    def __init__(self, V):
        self.v = V
        self.edges = [[] for _ in range(V)]

    def addEdge(self, fromNode, toNode, cap):
        forEdge = Edge(fromNode, toNode, cap)
        backEdge = Edge(toNode, fromNode, 0)
        forEdge.rev = backEdge
        backEdge.rev = forEdge
        self.edges[fromNode].append(forEdge)
        self.edges[toNode].append(backEdge)
    
    def bfs(self, source, sink):
        self.level = [None] * self.v
        self.level[source] = 0
        que = deque()
        que.append(source)
        while que:
            node = que.popleft()
            newLevel = self.level[node] + 1
            for edge in self.edges[node]:
                if edge.cap and self.level[edge.toNode] is None:
                    self.level[edge.toNode] = newLevel
                    que.append(edge.toNode)

        return self.level[sink] is not None

    def dfs(self, node, sink, f):
        if node == sink: return f

        for edge in self.edges[node]:
            if edge.cap and self.level[edge.fromNode] < self.level[edge.toNode]:
                newFlow = self.dfs(edge.toNode, sink, min(f, edge.cap))
                if newFlow:
                    edge.cap -= newFlow
                    edge.rev.cap += newFlow
                    return newFlow

        return 0
    
    def run(self, source, sink):
        flow = 0
        INF = 10 ** 10
        while self.bfs(source, sink):
            addFlow = INF
            while addFlow:
                addFlow = self.dfs(source, sink, INF)
                flow += addFlow

        return flow

V, E = map(int, input().split())
net = MaxFlow(V)
for _ in range(E):
    u, v, c = map(int, input().split())
    net.addEdge(u, v, c)
print(net.run(0, V - 1))
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split())))

if 0 in A:
    print(0)
    exit(1)

if np.sum(A > 0) % 2 == 1:
    print(np.prod(A))
    exit(1)

mul = A[0]
for i in A[1:]:
    if 1000000000000000000 / i < mul:
        print(-1)
        exit(1)
    mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(1)

print(mul)

### FIXED CODE ###

# -*- coding: utf-8 -*-

import numpy as np

N = int(input())

A = np.array(list(map(int, input().split())))

if 0 in A:
    print(0)
    exit(0)

mul = A[0]

if np.sum(A < 0) % 2 == 1:
    for i in A[1:]:
        mul *= i
else:
    for i in A[1:]:
        if 1000000000000000000 / i < mul:
            print(-1)
            exit(0)
        mul *= i

if mul > 1000000000000000000:
    print(-1)
    exit(0)

print(mul)
n,yen = map(int,input().split())

bol = False
for x in range(n+1):
    for y in range(n+1-x):
        for z in range(n+1-x-y):
            if 10000*x+5000*y+1000*z==yen:
                bol = True
                ans = [x,y,z]
                break
        if bol is True:
            break
    if bol is True:
        break

print(ans[0],ans[1],ans[2])

### FIXED CODE ###

n,yen = map(int,input().split())
ans = [-1,-1,-1]

for x in range(n+1):
    for y in range(n+1-x):
        z= int(yen/1000) - 10*x - 5*y
        if (0<= z) and (z == n-x-y):
            #print(x,y,n-x-y,z)
            bol = True
            ans = [x,y,z]
            break

print(ans[0],ans[1],ans[2])
'''
        if 0<= yen/1000 + 12*x + 5*y <= n+1-x-y:
            print(x,y,z)
            break
'''
n = int(input())
a = list(map(int, input().split()))

ans = [0]*n

for i in range(n):
    ans[a[i]-1] = i + 1
print(" ".join(mao(str, ans)))

### FIXED CODE ###

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

ans = [0]*n

for i in range(n):
    ans[a[i]-1] = i + 1
print(" ".join(map(str, ans)))
# スペース区切りの整数の入力
b, c = map(int, input().split())

if B * C % 2 == 0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

# スペース区切りの整数の入力
b, c = map(int, input().split())
 
if b * c % 2 == 0:
  print("Even")
else:
  print("Odd")
import math

N = int(input())

rtn = int(math.sqrt(N)) + 1 

used = []

count = [0] * N


if N <= 5:
    for x in range(N):
        print(count(x))
else:
    for n in range(6,N):
        print(n)
        for x in range(1,rtn):
            #print(x)
            xx = x**2
            if xx <= n - 5:
                #print("xpath")
                for y in range(1,rtn):
                    #print(x,y)
                    xy = x*y
                    yy = y**2
                    ysum = xx+yy+xy
                    if ysum <= n-3:
                        #print("ypath")
                        for z in range(1,rtn):
                            #print(x,y,z)
                            zz = z**2
                            xz = x*z
                            yz = y*z
                            result = ysum+zz+xz+yz
                            if result > n:
                                break
                            if result == n:
                                count[n-1] += 1
                                #print("zpath")
    for x in range(N):
        print(count[x])

### FIXED CODE ###

L, R, d = [int(x) for x in input().split()]

count = 0

for x in range(L,R+1):
    if x % d == 0:
        count += 1

print(count)
N,Y= [int(i) for i in input().split()]

if N < X:
	print(0)
else:
	print(10)


### FIXED CODE ###

N,Y= [int(i) for i in input().split()]

if N < Y:
	print(0)
else:
	print(10)
import math
def is_ok(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += math.ceil(A[i] / length)-1
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K == 0:
    print(max(A))
    exit()
ok = max(A)
ng = -1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))

### FIXED CODE ###

import math
def is_ok(K, N, A, length):
    s = 0
    for i in range(N):
        if A[i] > length:
            s += math.ceil(A[i] / length)-1
    return K >= s


N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if K == 0:
    print(max(A))
    exit()
ok = max(A)
ng = 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if is_ok(K, N, A, mid):
        ok = mid
    else:
        ng = mid

print(math.ceil(ok))
N = int(input())

sosuu = 1
for i in range(1,int(math.sqrt(N+1))):
    if N % i == 0:
        sosuu = i
        B = N // i

print(len(str(max(sosuu, B))))


### FIXED CODE ###

import math

N = int(input())

sosuu = 1
B = 1
for i in range(1,int(math.sqrt(N)+1)):
    if N % i == 0:
        sosuu = i
        B = N // i

print(len(str(max(sosuu, B))))
import sys

if __name__ == '__main__':
    a = input()
    a = a.split('/')
    year = int(a[0])
    month = int(a[1])
    date = int(a[2])
    if year > 2019:
        print('TBD')
    elif year < 2019:
        print('Heisei')
    elif month < 4:
        print('Heisei')
    elif month > 4:
        print('TBD')
    elif data < 30:
        print('Heisei')
    else:
        print('TBD')

### FIXED CODE ###

import sys

if __name__ == '__main__':
    a = input()
    a = a.split('/')
    year = int(a[0])
    month = int(a[1])
    date = int(a[2])
    if year > 2019:
        print('TBD')
    elif year < 2019:
        print('Heisei')
    elif month < 4:
        print('Heisei')
    elif month > 4:
        print('TBD')
    elif date <= 30:
        print('Heisei')
    else:
        print('TBD')
x, y, z = map(int, input().split())

print (x-z)%(x+y)


### FIXED CODE ###

from sys import stdin
import math
 
x, y, z = stdin.readline().split()
 
print (math.floor(( ( int(x)-int(z) ) / ( int(y) + int(z) ) )))
x

### FIXED CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

S = list(input().rstrip())
T = list(input().rstrip())

count = 0
for i in range(3):
    if S[i] == T[i]:
        count += 1

print(count)
S = list(input().split())
if S[2] == S[3] or S[4] == S[5]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = input()
 
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
n,k = map(int,input().split())
a = list(map(int,input().split()))

awk = 0
aix = k
for i in range(k):
  awk += a[i]
  #print(a[i])
#print('--')
a_max = awk

for i in range(k,n):
  #print(a[i],i-k)
  awk = awk + a[i] - a[i-k]
  if a_max < awk:
    a_max =  awk
    aix   = i

#print('===')
ans = 0.0
for i in range(aix-k+1,aix+1 ):
  #print(a[i],( 1 + a[i] )  / 2.0)
  ans += ( 1 + a[i] )  / 2.0

print(ans)  

### FIXED CODE ###

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

awk = 0
aix = k - 1
for i in range(k):
  awk += a[i]
a_max = awk

for i in range(k,n):
  awk = awk + a[i] - a[i-k]
  if a_max < awk:
    a_max =  awk
    aix   = i

ans = 0.0
#print('aix={}'.format(aix))
for i in range(aix-k+1,aix+1 ):
  #print(a[i])
  ans += ( 1 + a[i] )  / 2.0

print(ans)
N,M = map(int,input().split())
flag = [False]*(10**6)
plu_flag = [False]*(10**6)
plu = 1
for i in range(1,N+1):
  if M==0:
    break
  if (flag[i])or(flag[i+plu]):
    continue
  if (plu_flag[plu])or(plu_flag[N-plu]):
    plu+=1
    continue
    
  if plu>N//2:
    print(d)
  if i+plu>N:
    print(d)
  plu_flag[plu]=True
  plu_flag[N-plu]=True
  flag[i]=True
  flag[i+plu]=True
  print(i,i+plu)
  plu+=1
  M-=1

### FIXED CODE ###

N,M = map(int,input().split())
start = 1
end = M
while True:
  if start>=end:
    break
  print(start,end)
  start+=1
  end-=1
  
start = M+1
end = 2*M+1
while True:
  if start>=end:
    break
  print(start,end)
  start = start+1
  end = end-1
import math
from bisect import bisect_left
from random import random


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


def is_prime(q, k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False

    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


def solve():
    X = int(input())
    if is_prime(X):
        print(X)
    else:
        primes = eratosthenes(100010)
        index = bisect_left(primes, X)
        print(primes[index])


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import math
from bisect import bisect_left


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


def solve():
    X = int(input())
    primes = eratosthenes(100010)
    index = bisect_left(primes, X)
    print(primes[index])


if __name__ == '__main__':
    solve()
#problem-c
n = int(input())
p = list(map(int, input().split()))
cnt = 0
min_p = p[0]
for i in range(n):
    if p[i]=<min_p:
        cnt += 1
        min_p = p[i]
    else:
print(cnt)


### FIXED CODE ###

#problem-c
n = int(input())
p = list(map(int, input().split()))
cnt = 0
min_p = p[0]
for i in range(n):
    if p[i]<=min_p:
        cnt += 1
        min_p = p[i]
print(cnt)
n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
r = (10**9)+7
if n % 2 == 0:
    for i in range(0,n,2):
        if a[i] != a[i+1]:
            print(0)
            break
    else:
        r = (2 ** (n/2))%((10**9)+7)
        print(int(r))
else:
    for i in range(1,n,2):
        if a[i] != a[i+1]:
            print(0)
            break
    else:
        r = (2**((n-1)/2))%((10**9)+7)
        print(int(r))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(' ')))
a.sort()
if n % 2 == 0:
    a_ = [[a[i],a[i+1]] for i in range(0,n,2)]
    for i,j in enumerate(a_):
        j_ = j[0]
        k_ = j[1]
        if  (i*2+1) != j_ or (i*2+1) != k_:
            print(0)
            break
    else:
        r = (2 ** (n//2))%((10**9)+7)
        print(int(r))
else:
    if a[0] == 0:
        a_ = [[a[i],a[i+1]] for i in range(1,n,2)]
        for i,j in enumerate(a_,start=1):
            j_ = j[0]
            k_ = j[1]
            if i*2 != j_ or i*2 != k_:
                print(0)
                break
        else:
            r = (2**((n-1)//2))%((10**9)+7)
            print(int(r))
    else:
        print(0)