Harryxun/stf_run huggingface dataset:
N, Q = map(int, input().split())

edges = [[] for _ in range(N)]

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

counter = [0] * N

def process(root, value):
    counter[root] += value
    for next_root in edges[root]:
        process(next_root, value)

for _ in range(Q):
    p, x = map(int, input().split())
    process(p - 1, x)

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

### FIXED CODE ###

from collections import deque

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

edges = [[] for _ in range(N)]

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

counter = [0] * N
checked = [False] * N

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

queue = deque()
queue.append(0)

while queue:
    root = queue.pop()
    checked[root] = True
    for e in edges[root]:
        if checked[e] == False:
            queue.append(e)
            counter[e] += counter[root]

print(" ".join(map(str, counter)))
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
    
check = [0 for i in range(10**5 + 1)]
for i in a:
    check[i] += 1
count = 0
for i in check:
    if i % 2 != 0:
        count += 1
print(count)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
    
check = {}
for i in set(a):
    check[i] = 0
for i in a:
    check[i] += 1
    
count = 0
for i in check.items():
    if i[1] % 2 != 0:
        count += 1
print(count)
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
d={}
mod=10**9+7
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y

for i in range(n):
    a,b=ab[i]
    x=gcd(a,b)
    a//=x
    b//=x
    if a<0:
        a*=-1
        b*=-1
    if a==0:
        b=1
    if b==0:
        a=1
    y=(a,b)
    if y in d:
        d[y]+=1
    else:
        d[y]=1
z=0
if (0,0) in d:
    z=d[(0,0)]
ans=1
re={}
for t,v in d.items():
    if t in re:
        continue
    a,b=t
    c=0
    if (b,-a) in d:
        c+=d[(b,-a)]
        re[(b,-a)]=1
    if (-b,a) in d:
        c+=d[(-b,a)]
        re[(-b,a)]=1
    ans*=(2**v-1+2**c-1+1)
    ans%=mod
ans-=1
ans+=z
ans%=mod
print(ans)


### FIXED CODE ###

n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
d={}
mod=10**9+7
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y
z=0
for i in range(n):
    a,b=ab[i]
    if a==0 and b==0:
        z+=1
        continue
    if a==0:
        b=1
        y=(a,b)
        if y in d:
            d[y]+=1
        else:
            d[y]=1
        continue
    if b==0:
        a=1
        y=(a,b)
        if y in d:
            d[y]+=1
        else:
            d[y]=1
        continue
    x=gcd(a,b)
    a//=x
    b//=x
    if a<0:
        a*=-1
        b*=-1
    y=(a,b)
    if y in d:
        d[y]+=1
    else:
        d[y]=1
ans=1
re={}
for t,v in d.items():
    if t in re:
        continue
    a,b=t
    c=0
    if (b,-a) in d:
        c+=d[(b,-a)]
        re[(b,-a)]=1
    if (-b,a) in d:
        c+=d[(-b,a)]
        re[(-b,a)]=1
    ans*=(2**v-1+2**c-1+1)
    ans%=mod
ans-=1
ans+=z
ans%=mod
print(ans)
from functools import reduce
from operator import mul
N = int(input())

for i in range(2, N):
  if N % i == 0:
    break

print(0, 0, 0, N//i, 0, i)



### FIXED CODE ###

import math
S = int(input())
 
x1 = math.ceil(math.sqrt(S))
y1 = 1
x2 = x1 ** 2 - S
y2 = x1
x3 = 0
y3 = 0
 
print(x1, y1, x2, y2, x3, y3)
s = input()
if s[1] == s[2] == s[3]:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

s = input()
if s[0] == s[1] == s[2]:
    print("No")
else:
    print("Yes")
n, k = map(int, input().split())
s = input()
pre = 0
sepS = []
happyCount = 0
RLcount = 0
for i in range(1, n):
    if s[i] == s[i - 1]:
        happyCount += 1
    if s[i] == 'L' and s[i - 1] == 'R':
        RLcount += 1
#print("now HP =>{}".format(happyCount))
happyCount += min(k, RLcount) * 2
if k > RLcount:
    happyCount += 1
print(min(n - 1, happyCount)


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
pre = 0
sepS = []
happyCount = 0
RLcount = 0
for i in range(1, n):
    if s[i] == s[i - 1]:
        happyCount += 1
    if s[i] == 'L' and s[i - 1] == 'R':
        RLcount += 1
#print("now HP =>{}".format(happyCount))
happyCount += min(k, RLcount) * 2
if k > RLcount:
    happyCount += 1
print(min(n - 1, happyCount))
if int(input())>29:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

if int(input())>29:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
from bisect import bisect
N = int(input())
A = [int(input()) for _ in range(N)]
L = [A[0]]

for i in range(1, N):
    if L[-1] < A[i]:
        L.append(A[i])
    else:
        L[bisect(L, A[i])]  = A[i]
print(len(L))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from bisect import bisect_left
def inpl(): return list(map(int, input().split()))
N = int(input())
A = [int(input()) for _ in range(N)]

LIS = [A[0]]

for a in A[1:]:
    if a > LIS[-1]:
        LIS.append(a)
    else:
        LIS[bisect_left(LIS, a)] = a

print(len(LIS))
N = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(len(a)) :
	if a[i] == 0:
		print(0)
		exit(1)
for i in range(len(a)) :
	ans *= a[i]
	if ans > 1e18 :
		print(-1)
		exit(1)
print(ans)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
ans = 1
zero = 0
over = 0
for i in range(len(a)) :
	if a[i] == 0 :
		zero = 1
for i in range(len(a)) :
	if over : break
	ans *= a[i]
	if ans > 1e18 :
		over = 1
if zero : print(0)
elif over : print(-1)
else : print(ans)
n = int(input())
a = []
for i in range(n):
    ai = int(input())
    a.append(ai)

cnt = 0
i = 0
while True:
    if a[i] >= 2:
        pairs = a[i] // 2
        cnt += pairs
        a[i] -= (pairs * 2)

    elif a[i] == 1:
        if i + 1 >= n:
            break

        if a[i + 1] > 0:
            cnt += 1
            a[i] -= 1
            a[i + 1] -= 1

        else:
            i += 1

    else:
        i += 1

print(cnt)

### FIXED CODE ###

#B
n = int(input())
a = []
for i in range(n):
    ai = int(input())
    a.append(ai)

cnt = 0
i = 0
while i < n:
    if a[i] >= 2:
        pairs = a[i] // 2
        cnt += pairs
        a[i] -= (pairs * 2)

    elif a[i] == 1:
        if i + 1 >= n:
            break

        if a[i + 1] > 0:
            cnt += 1
            a[i] -= 1
            a[i + 1] -= 1

        else:
            i += 1

    else:
        i += 1

print(cnt)
ABC = input("The element of S: ")
ARC = input("The element of S: ")
if ABC == "S":
    print("ABC")
if ARC == "S":
    print("ARC")


### FIXED CODE ###

s = input()
if s == "ABC":
    print("ARC")
if s == "ARC":
    print("ABC")
A1,A2,A3 = map(int,input().split())

x = abs(A1 - A2)
y = abs(A2 - A3)
z = abs(A3 - A1)

if x + y <= y + z and x <= z + x:
	print(x + y )
elif y + z <= x + y and  y + Z <= z + x:
	print(y + z )
else:
	print(z + x)

### FIXED CODE ###

A1,A2,A3 = map(int,input().split())
 
x = abs(A1 - A2)
y = abs(A2 - A3)
z = abs(A3 - A1)
 
if x + y <= y + z and x + y <= z + x:
	print(x + y )
elif y + z <= x + y and  y + z <= z + x:
	print(y + z )
else:
	print(z + x)
A, B = map(int, input().split())

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

print(lcm(A, B))

### FIXED CODE ###

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

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

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

print(lcm(A, B))
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
memo = [[-1]*(M+1) for _ in range(N)]
List = [[]for _ in range(N)]

for i in range(N):
    for j in range(M):
        if S[i]==T[j]:
            List[i].append(j)
def dp(i, j):
    if i==N-1:
        cnt = 0
        for k in List[i]:
            if j<k:
                cnt+=1
        return (cnt+1)%mod
    res = 0
    for k in List[i]:
        if j<k:
            if memo[i+1][k]<0:
                memo[i+1][k]=dp(i+1, k)
            res+=memo[i+1][k]
    if memo[i+1][j]<0:
        memo[i+1][j]=dp(i+1, j)
    res+=memo[i+1][j]
    return res%mod
print(dp(0, -1)%mod)


### FIXED CODE ###

mod = 10**9+7
N, M = map(int, input().split())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
dp = [[0]*(M+1) for _ in range(N+1)]
dp[0][0] = 1
Sum = [[1]*(M+1) for _ in range(N+1)]
for i in range(1, N+1):
    for j in range(1, M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = Sum[i-1][j-1]%mod
        else:
            dp[i][j] = 0
        Sum[i][j] = (Sum[i-1][j]+Sum[i][j-1]-Sum[i-1][j-1]+dp[i][j])%mod
print(Sum[N][M]%mod)
import sys
from itertools import permutations

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    assert N <= 8

    X = [int(i) for i in input().split()]

    cnt = 0
    MOD = 10**9 + 7

    for pm in permutations(range(N)):
        goal = [False] * N
        flag = True

        for p in pm:
            for i in range(p-1, -1, -1):
                if goal[i]:
                    continue
                if X[i] < 2*i + 1:
                    flag = False
                    break
            if flag:
                break
            goal[p] = True

        cnt += flag

    print(cnt % MOD)


if __name__ == '__main__':
    solve()

### FIXED CODE ###

import sys
from math import factorial

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N = int(input())
    X = [int(i) for i in input().split()]
    MOD = 10**9 + 7
    ans = 1
    stack = 0

    for x in X:
        stack += 1
        if x < 2*(stack - 1) + 1:
            ans *= stack
            ans %= MOD
            stack -= 1

    ans *= (factorial(stack) % MOD)
    ans %= MOD

    print(ans)


if __name__ == '__main__':
    solve()
Q = int(input())
Queries = [list(map(int, input().split())) for _ in range(Q)]

import heapq as hp
L = [10**9+1] # 最小ヒープなので負を入れる
R = [10**9+1] # そのまま
hp.heapify(L)
hp.heapify(R)
odd = False
sum_b = 0
sum_l = 0
sum_r = 0

flag = 1

for q in Queries:
  if len(q)==1 and q[0]==2:
    if flag ==0:
      print(*(-L[0], sum_b + abs(sum_l-sum_r)))
    else:
      print(*(-L[0], sum_b)
      flag = 1

  else:
    _, a, b = q
    sum_b += b

    l = -hp.heappop(L)
    r = hp.heappop(R)
    sum_l -= l
    sum_r -= r
    X = sorted([l, r, a])
    if odd==False:
      hp.heappush(L,-X[0])
      hp.heappush(L,-X[1])
      hp.heappush(R,X[2])
      sum_l += X[0]+X[1]
      sum_r += X[2]
      odd=True
    elif odd==True:
      hp.heappush(L,-X[0])
      hp.heappush(R,X[1])
      hp.heappush(R,X[2])
      sum_l += X[0]
      sum_r += X[1] + X[2]
      odd=False



### FIXED CODE ###

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

import heapq as hp
L = [-(-(10**9+1))] # 最小ヒープなので負を入れる
R = [10**9+1] # そのまま
hp.heapify(L)
hp.heapify(R)
odd = False
sum_b = 0
sum_l = 0
sum_r = 0

for q in Queries:
  if len(q)==1 and q[0]==2:
    print(*(-L[0], sum_b + abs(sum_l-sum_r)))
    
  else:
    _, a, b = q
    sum_b += b

    l = -hp.heappop(L)
    r = hp.heappop(R)
    
    X = sorted([l, r, a])
    if odd==False:
      sum_l -= l
      sum_r -= r
      hp.heappush(L,-X[0])
      hp.heappush(L,-X[1])
      hp.heappush(R,X[2])
      sum_l += X[0]
      sum_r += X[2]
      odd=True
    elif odd==True:
      sum_r -= r
      hp.heappush(L,-X[0])
      hp.heappush(R,X[1])
      hp.heappush(R,X[2])
      sum_l += X[0]
      sum_r += X[1] + X[2]
      odd=False
import numpy as np

n, x0 = map(int, input().split())
X = list(map(int, input().split()))

print(np.gcd.reduce([x - x0 for x in X]))


### FIXED CODE ###

from fractions import gcd
from functools import reduce

n, x0 = map(int, input().split())
X = list(map(int, input().split()))

print(reduce(gcd, (abs(x - x0) for x in X)))
if (a * b) % 2 == 1:
  print("Odd")
else:
  print("Even")

### FIXED CODE ###

a, b = map(int, input().split())
if a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
lists = list(input.split())
counter = 0
for i in lists:
  if i == '0':
    break
  counter = counter + 1
print(str(counter))

### FIXED CODE ###

lists = list(input().split())
counter = 1
for i in lists:
  if i == '0':
    break
  counter = counter + 1
print(str(counter))
A, B, K = map(int, input().split())
AB = list(range(A, B+1))


ans = set(AB[:K]+AB[-K:])

for i in sorted(ans):
    print(i)

### FIXED CODE ###

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

if b-a+1 <= 2*k:
    for num in range(a, b+1):
        print(num)
else:
    for num in range(a, a+k):
        print(num)
    for num in range(b-k+1,b+1):
        print(num)
# coding: utf-8
# Your code here!

import numpy as np

def canbe_solved(positions):
    flg = np.dot(positions[0],np.ones(2,int))%2
    for p in positions:
        flg ^= (np.dot(p,np.ones(2,int)) %2 )
        if flg:
            return False
    return True

def solutions(p,vals):
    u = np.dot(p, np.array([1,1]))
    v = np.dot(p, np.array([1,-1]))
    for val in vals:
        if u >=0:
            if v >= 0:
                print('R',end="")
                u -= val
                v -= val
            else:
                print('U',end="")
                u -= val
                v += val
        else:
            if v >= 0:
                print('D',end="")
                u += val
                v -= val
            else:
                print('L',end="")
                u += val
                v += val
    print()
    
    
def main():
    #input
    n = int(input().rstrip())
    positions = [np.asarray(list(map(int,input().rstrip().split()))) for _ in range(n)]
    vals = [1<<i for i in range(30,-1,-1)]
    if np.dot(positions[0], np.ones(2,int)) % 2 == 0:
        vals.append(1)

    if canbe_solved(positions):
        print(len(vals))
        for i,p in enumerate(vals):
            print(p,end="")
            if i == len(vals)-1:
                print('')
        else:
            print(' ', end="")

        for p in positions:
            solutions(p,vals)
    else:
        print('-1')
        
main()

    

### FIXED CODE ###

import collections

arr_length = int(input().rstrip())
arr = list(map(int,input().rstrip().split()))

arr_odd = arr[0::2]
arr_even = arr[1::2]

def count_strange(arr):
    c = collections.Counter(arr)
    keys, vals = zip(*c.most_common())
    return keys, vals

def proc(arr1, arr2):
    keys1, vals1 = count_strange(arr1)
    keys2, vals2 = count_strange(arr2)
    
    if keys1[0] == keys2[0]:
        if len(keys1) == 1 and len(keys2) == 1:
            print(vals1[0])# n = even number
        elif len(keys1) == 1 and len(keys2) > 1:
            print(len(arr2)-vals2[1])
        elif len(keys1) > 1 and len(keys2) == 1:
            print(len(arr1)-vals1[1])
        else: #>1
            print(
                min(
                    len(arr1)-vals1[1] + len(arr2)-vals2[0],
                    len(arr1)-vals1[0] + len(arr2)-vals2[1]
                    )
                    )
    else:
        print(len(arr1)-vals1[0] + len(arr2)-vals2[0])
    
proc(arr_odd, arr_even)
import math
n = int(input())
ans = 0

if n > 2:
  ans += n-1

for i in range(2,math.ceil(n**0.5)+1):

  if n % i == 0:
    j = n // i
    if n % (i-1) == n // (i-1):
      ans += i-1
    if n % (j-1) == n // (j-1) and i != j:
      ans += j-1
  
print(ans)

### FIXED CODE ###

import math
n = int(input())
ans = 0

if n > 2:
  ans += n-1

for i in range(2,math.ceil(n**0.5)+1):
  if n % i == 0:
    j = n // i
    if n % (i-1) == n // (i-1):
      ans += i-1
    if i != j > 1 and n % (j-1) == n // (j-1) :
      ans += j-1
  
print(ans)
print(a = int(input()) a+a**2+a**3)

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)
S = input()
L = len(S)
Truth = 0

for j in range(0, 8):
	if S[0:j] + S[L- 7 +j:] = "keyence":
		Truth = 1

if Truth =1:
	print(YES)
else:
	print(NO)

### FIXED CODE ###

S = input()
L = len(S)
Truth = 0

for j in range(0, 8):
	if S[0:j] + S[L- 7 +j:] == "keyence":
		Truth = 1

if Truth ==1:
	print("YES")
else:
	print("NO")
import sys
 
def main():
  a,b,c = map(lambda x: int(x), input().split())
  k = int(input())
 
  for _ in range(k):
      if b <= a:
          b = 2 * b
          continue
      if c <= b:
          c = 2 * c
          continue
      print('Yes')
      return
 
  if (a < b) & (b < c):
      print('Yes')
      return
  print('No')
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

print(10 - int(input())//200)
n, k, s = map(int, input().split())

#%%
billion = 1000000000

if s == billion:
    front = [s] * k
    back = [1] * (n - k)
else:
    front = [s] * k
    back = [s+1] * (n - k)

print(*front, *back)

### FIXED CODE ###

n, k, s = map(int, input().split())

#%%
billion = 1000000000

if s == billion:
    front = [s] * k
    back = [1] * (n - k)
else:
    front = [s] * k
    back = [s+1] * (n - k)

front.extend(back)
print(*front)
a=int(input())
max=0
min=10000
sum=0
for i in range(0,a):
    b=int(input())
    if(max<=b):
        max=b
    if(min>=b):
        min=b
    sum+=b;
print("{min} {max} {sum}")
    


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
print(min(a),max(a),sum(a))
import collections
import sys

def LI():
	return [ int(s) for s in input().split() ]

N = int(input())
A = LI()

c_counter = collections.Counter(A)
c_dict = dict(c_counter)

total = 0
total_dict = {}

for k,v in c_dict.items():
  if v >= 2:
    comb = v*(v-1)//2
    total_dict[k] = comb
    total += comb

for a in A:
  if total == 0:
    print(0)
  else:
    print(total - total_dict[a] + (c_dict[a]-1)*(c_dict[a]-2)//2) 

### FIXED CODE ###

import collections
 
def LI():
	return [ int(s) for s in input().split() ]
 
N = int(input())
A = LI()
 
c_counter = [0]*(2*(10**5))
 
for a in A:
  c_counter[a]+=1
 
total = 0
total_dict = [0]*(2*(10**5))
 
for a in range(len(c_counter)):
  v = c_counter[a]
  if v >= 2:
    comb = v*(v-1)//2
    total_dict[a] = comb
    total += comb
 
for a in A:
  if total == 0:
    print(0)
  else:
    print(total - total_dict[a] + (c_counter[a]-1)*(c_counter[a]-2)//2)
s = str(raw_input())
s = s.replace('2017', '2018', 1)
print(s)

### FIXED CODE ###

s = str(raw_input())
s = s.replace('2017', '2018', 1)
print(s)
a = int(input())
b = int(input())
x = -(-(a+b)//2)
print(x)

### FIXED CODE ###

a,b=map(int,input().split())
print((a+b+1)//2)
ws = input()

rev = 0
for ch in ws:
    if ch == 'R':
        rev += 1
    else:
        rev = 0

return rev

### FIXED CODE ###

ws = input()

if ws.count('S') == 3:
    print(0)
elif ws.count('S') == 2:
    print(1)
elif ws.count('S') == 1:
    if ws.index('S') == 1:
        print(1)
    else:
        print(2)
else:
    print(3)
n, k = map(int, input().split())

roads = list(map(int, input().split()))

city = 1
route = []
cnt = [0] * n
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k <= len(route):
    print(route[k])

elif length >= 1:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])

### FIXED CODE ###

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

roads = list(map(int, input().split()))

city = 1
route = []
cnt = [0] * n
cnt[0] += 1
route.append(1)


while True:
    city = roads[city-1] 
    cnt[city-1] += 1
    if cnt[city-1] == 2:
        st = route.index(city)
        length = len(route) - st
        break
    route.append(city)


if k < len(route):
    print(route[k])

else:
    amari = (k+1-st) % length
    if amari  == 0:
        print(route[-1])
    else:
        print(route[amari+st-1])
from sys import stdin
n = int(stdin.readline().rstrip())
h = [int(x) for x in stdin.readline().rstrip().split()]
ans = 1
tmp = h[0]
for i in range(n - 1):
    ans += 1 if tmp <= h[i + 1] else 0
    tmp = max(tmp, h[i + 1])
print("{}".format(ans))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin
a, b = [int(x) for x in stdin.readline().rstrip().split()]
res = 0
if a > b:
    res += a
    a -= 1
else:
    res += b
    b -= 1
res += a if a > b else b
print("{}".format(res))
N, K = map(int, input().split())
S = input()
Nums = [0]
now = 1 # 今見ている数
cnt = 0 # nowがいくつ並んでいるか
for i in range(N):
    if s == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        now = 1 - now   # 0と1を切り替えるときの計算 now ^= 1
        cnt = 1
if cnt != 0:
    Nums.append(cnt)
# 1-0-1-0-1-0-1 って感じの配列が欲しい
# 1-0-1-0-1-0 みたいに0で終わっていたら適当に1つ足す
if len(Nums) % 2 == 0:
    Nums.append(0)

Add = 2 * K + 1
ans = 0
# 1-0-1... の1から始めるので、偶数番目だけ見る
for i in range(0, len(Nums), 2):
    tmp = 0
    left = i
    right = min(i + Add, len(Nums))
    for j in range(left, right):
        tmp += Nums[j]
    ans = max(tmp, ans)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

l = [0]
curr = '1'
for c in S:
    if c != curr:
        l.append(1)
        curr = c
    else:
        l[-1] += 1
if curr == '0':
    l.append(0)

n_group = len(l) // 2
sum_ = 0
k = min(K, n_group)
sum_ = sum(l[0:2*k+1])
max_ = sum_
for i in range(k, n_group):
    sum_ -= l[2*i-2*K] + l[2*i+1-2*K]
    sum_ += l[2*i+1] + l[2*i+2]
    max_ = max(max_, sum_)
print(max_)
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort()


C = [1]
r = 1
l = K
for i in range(1,N-K+1):
    C.append(int(C[i-1]*l/r))
    l+=1
    r+=1

C = C[::-1]

X = A[:(N-K+1)]
Y = A[(K-1):]
Y.sort(reverse=True)
output = 0
Z = len(X)
for i in range(Z):
    output += (Y[i]-X[i])*C[i]
    if output >= 10**9+7:
        output = output % (10**9+7)

print(output)

### FIXED CODE ###

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

A.sort()

MAXN = 10**5+10
p = 10**9+7
MOD = p
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % MOD)
def nCr(n, r, mod=MOD):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

MA = 0
for i in range(N-K+1):
    MA = (MA + A[N-1-i]*nCr(N-1-i,K-1))%p

MI = 0
for i in range(N-K+1):
    MI = (MI + A[i]*nCr(N-1-i,K-1))%p

out = MA-MI
if out<0:
    out += p
print(out)
from bisect import bisect_right

def eratosthenes(n):
    A = [i for i in range(2, n+1)]
    P = []
    i = 2
    while i**2 <= n:
        prime = min(A)
        P.append(prime)
        j = 0
        while j < len(A):
            if A[j] % prime == 0:
                A.pop(j)
                continue
            j += 1
        i += 1    
    for a in A:
        P.append(a)
    return P
    
x = int(input())
prime_table = eratosthenes(100003)
prime_set = set(prime_table)
if x in prime_set:
    print(x)
else:
    idx = bisect_left(prime_table, x)
    ans = prime_table[idx]
    print(ans)

### FIXED CODE ###

from bisect import bisect_left

def main():
    def eratosthenes(n):
        A = [i for i in range(2, n+1)]
        P = []
        i = 2
        while i**2 <= n:
            prime = min(A)
            P.append(prime)
            j = 0
            while j < len(A):
                if A[j] % prime == 0:
                    A.pop(j)
                    continue
                j += 1
            i += 1    
        for a in A:
            P.append(a)
        return P

    x = int(input())
    prime_table = eratosthenes(100003)
    idx = bisect_left(prime_table, x)
    ans = prime_table[idx]
    print(ans)

if __name__ == '__main__':
    main()