Harryxun/stf_run huggingface dataset:
n = int(input())
     
    f = [int(input().replace(" ", ""), 2) for _ in range(n)]
    p = [list(map(int, input().split())) for _ in range(n)]
     
    ans = float('-inf')
     
    for i in range(1, 1024):
        price = 0
        for j in range(n):
            price += p[j][bin(i & f[j]).count('1')]
        ans = max(ans, price)
     
    print(ans)

### FIXED CODE ###

n = int(input())

f = [int(input().replace(" ", ""), 2) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = float('-inf')

for i in range(1, 1024):
    price = 0
    for j in range(n):
        price += p[j][bin(i & f[j]).count('1')]
    ans = max(ans, price)

print(ans)
import collections
n = int(input())
v = input().split()
v_int = [int(i) for i in v]
v_odd = []
v_even = []
for i in range(int(n/2)):
  v_even.append(v_int[i*2])
  v_odd.append(v_int[i*2+1])
c_odd = collections.Counter(v_odd)
c_even = collections.Counter(v_even)
max_odd = 0
second_odd = 0
max_key_odd = 0
for key in c_odd:
  if max_odd < c_odd[key]:
    second_odd = max_odd
    max_odd = c_odd[key]
    max_key_odd = key
  elif second_odd < c_odd[key]:
    second_odd = c_odd[key]
    
max_even = 0
second_even = 0
max_key_even = 0
for key in c_even:
  if max_even < c_even[key]:
    second_even = max_even
    max_even = c_even[key]
    max_key_even = key
  elif second_even < c_even[key]:
    second_even = c_even[key]
    
if max_key_even != max_key_odd:
  print(int(n)- max_even - max_odd)
else:
  if max_even > max_odd:
    if max_even == second_even:
      print(int(n) - max_even - max_odd)
    else:
      print(int(n) - max_even - second_odd)
  elif max_even < max_odd:
    if max_odd == second_odd:
      print(int(n) - max_odd - max_even)
    else:
      print(int(n) - max_odd - second_even)
  else : 
    if second_odd > second_even:
      print(int(n) - max_even - second_odd)
    else :
      print(int(n) - max_odd - second_even)

### FIXED CODE ###

a = input()
l = [int(x) for x in list(str(a))]
s = ""
for i in l:
  if i == 1:
    s += "9"
  elif i == 9:
    s += "1"
print(int(s))
from sys import stdin
from itertools import accumulate

stdin = open('sample.txt')


def main():
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    A1 = [A[0]]
    for i in range(1, N):
        A1.append(A1[-1] ^ A[i])
    A2 = list(accumulate(A))
    l = 0
    r = 1
    tmp1 = A1[0]
    tmp2 = A2[0]
    count = 0
    while True:
        if (l == N - 1) and (r == N):
            count += 1
            break

        if (r != N) and (tmp1 ^ A[r + 1 - 1] == tmp2 + A[r + 1 - 1]):
            if tmp1 == tmp2:
                count += 1
            r += 1
            tmp1 = tmp1 ^ A[r - 1]
            tmp2 = tmp2 + A[r - 1]
            continue
        else:
            if tmp1 == tmp2:
                count += (r - l - 1)
            tmp1 = tmp1 ^ A[l]
            tmp2 = tmp2 - A[l]
            l += 1

    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from sys import stdin
from itertools import accumulate


def main():
    N = int(stdin.readline().rstrip())
    A = [int(x) for x in stdin.readline().rstrip().split()]
    A1 = [A[0]]
    for i in range(1, N):
        A1.append(A1[-1] ^ A[i])
    A2 = list(accumulate(A))
    l = 0
    r = 1
    tmp1 = A1[0]
    tmp2 = A2[0]
    count = 0
    while True:
        if (l == N - 1) and (r == N):
            count += 1
            break

        if (r != N) and (tmp1 ^ A[r + 1 - 1] == tmp2 + A[r + 1 - 1]):
            if tmp1 == tmp2:
                count += 1
            r += 1
            tmp1 = tmp1 ^ A[r - 1]
            tmp2 = tmp2 + A[r - 1]
            continue
        else:
            if tmp1 == tmp2:
                count += (r - l - 1)
            tmp1 = tmp1 ^ A[l]
            tmp2 = tmp2 - A[l]
            l += 1

    print(count)


if __name__ == '__main__':
    main()
n, k = map(int, input().split())
dis = [_ for _ in input().split()]
for yen in range(1, 100000):
    if yen < n:
        pass
    else:
        if len(set(list(str(yen))) & set(dis)) == 0:
            print(yen)
            exit()


### FIXED CODE ###

a, b, c = map(int, input().split())
abc = sorted([a, b, c])
if abc[0] == 5 and abc[1] == 5 and abc[2] == 7:
    print('YES')
else:
    print('NO')
import bisect
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
idx = bisect.bisect_left(A,0)
if idx%2 == 0:
  ans = abs(sum(A[0:idx])) + sum(A[idx:])
else:
  ans = abs(sum(A[0:idx-1])) + abs(A[idx-1]+A[idx]) + sum(A[idx+1:])
print(ans)

### FIXED CODE ###

import bisect
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
idx = bisect.bisect_left(A,0)
ans = 0
if idx%2 == 0:
  ans += abs(sum(A[0:idx]))
  if N > idx:
    ans += sum(A[idx:])
else:
  ans += abs(sum(A[0:idx-1]))
  if idx < N:
    ans += abs(A[idx-1]+A[idx])
  elif idx == N:
    ans += A[idx-1]
  if idx + 1 < N:
    ans += sum(A[idx+1:])
print(ans)
import sys
 
N, A, B = map(int,input().split())
 
ans = 0
 
if N < A:
  print(N)
  sys.exit()
 
if N < A+B:
  print(A)
  sys.exit()

if N%(A+B) <A:
  print((A*(N//(A+B))) + (N%(A+B)))
else:
  print((A*(N//(A+B))) + A)


### FIXED CODE ###

s = input()
if s=="AAA" or s=="BBB":
  print("No")
else:
  print("Yes")
# -*- coding: utf-8

a = []

while True:
   n = input():
   if n == 0:
      break
   a.append(n)

for i in range(len(a)):
   print('Case %i: %i' % (i+1,a[i]))





### FIXED CODE ###

# -*- coding: utf-8

a = []

while True:
   n = input()
   if n == 0:
      break
   a.append(n)

for i in range(len(a)):
   print('Case %i: %i' % (i+1,a[i]))
print(int(input()-1)//2)


### FIXED CODE ###

print((int(input())-1)//2)
import numpy as np
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
h,w = map(int,input().split())
l=['#'*(w+2)]+['#'+input().strip()+'#' for i in range(h)]+['#'*(w+2)]
dp = np.zeros((h+2,w+2,2),dtype=int)
cnt = 0
ans = 0

def dfsw(x,y,cnt):
  if l[x][y+1] == '.':
    cnt += 1
    dp[x,y,0] = dfsw(x,y+1,cnt)
    return dp[x,y,0]
  else:
    dp[x,y,0] = cnt
    return dp[x,y,0]

def dfsh(x,y,cnt):
  if l[x+1][y] == '.':
    cnt += 1
    dp[x,y,1] = dfsh(x+1,y,cnt)
    return dp[x,y,1]
  else:
    dp[x,y,1] = cnt
    return dp[x,y,1]

for i in range(h+2):
  for j in range(w+2):
    if l[i][j] == '.':
      if dp[i,j,0] == 0:
        dfsw(i,j,1)
      if dp[i,j,1] == 0:
        dfsh(i,j,1)
      ans = max(ans, sum(dp[i,j]) - 1)
print(ans)

### FIXED CODE ###

import numpy as np
h,w = map(int,input().split())
ar = np.array([list(input()) for _ in range(h)]) == '.'
#print(ar)
l = np.zeros((h,w),dtype=int)
r = np.zeros((h,w),dtype=int)
u = np.zeros((h,w),dtype=int)
d = np.zeros((h,w),dtype=int)

for i in range(h):
  u[i] = (u[i-1]+1)*ar[i]
  #print(u)
  d[-i-1] = (d[-i]+1)*ar[-i-1]
  #print(d)
  
for j in range(w):
  l[:,j] = (l[:,j-1]+1)*ar[:,j]
  #print(l)
  r[:,-j-1] = (r[:,-j]+1)*ar[:,-j-1]
  #print(r)
print(np.max(u+d+l+r)-3)
i= readInt()
print i*i*i

### FIXED CODE ###

i = input()
print i*i*i
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])s
s = input()
n = len(s)

print(dfs(0, s[0]))


### FIXED CODE ###

def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + \
           dfs(i + 1, f + "+" + s[i + 1])


s = input()
n = len(s)

print(dfs(0, s[0]))
n = input()
l = []
for i in range(len(n)-2):
    num = f'{n[i]}{n[i+1]}{n[i+2]}'
    l.append(int(num))
    
print(min([abs(i - 753) for i in l]))


### FIXED CODE ###

n = input()
l = []
for i in range(len(n)-2):
    num = '{}{}{}'.format(n[i],n[i+1],n[i+2])
    l.append(int(num))  
print(min([abs(i - 753) for i in l]))
N, M, X, Y =list(map(int,input().split()))
a =max( [i for i in map(int, input().split())])                
b =min([i for i in map(int, input().split())])

for z in range(-101,101):
    if (x <= z <= y) and (a < z) and (b >= z):
        cnt +=1
        break

if cnt > 1:
    print('No War')
else:
    print('War')

### FIXED CODE ###

N, M, X, Y =list(map(int,input().split()))
x = [i for i in map(int, input().split())]        
y =[i for i in map(int, input().split())]
x_max =max(x)
y_min =min(y)

# X<Z<=Y を満たす数を列挙
for Z in range(X+1,Y+1):

  # x1, x2, ... , xn < Z <= y1, y2, ... , yn の判定
  if x_max<Z and Z<=y_min:
    print('No War')
    exit()

# 条件を満たすZが存在しない場合
print('War')
import numpy as np

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

dp = np.zeros(n)
dp[0] = 0
dp[1] = abs(h[1]-h[0])

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

print(int(dp[n-1]))


### FIXED CODE ###

import numpy as np

n, k = map(int, input().split())
h = np.array([int(i) for i in input().split()])

dp = np.zeros(n)
dp[0] = 0
dp[1] = abs(h[1]-h[0])

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

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

if(S == "ABC"):
	print("ARC")
elif(S == "ARC"):
	print("ABC")



### FIXED CODE ###

S = input()

if(S == "ABC"):
	print("ARC")
elif(S == "ARC"):
	print("ABC")
n,m=list(map(int,input().split()))
p=list(map(int,input().split()))
from collections import defaultdict
c=0
for i in range(n):
    if p[i]==i+1:
        c+=1
vis=[0]*n
def dfs(x):
    vis[x]=1
    a.add(x+1)
    for u in d[x]:
        if vis[u]==0:
            dfs(u)
d=defaultdict(list)
for i in range(m):
    a,b=list(map(int,input().split()))
    d[a-1].append(b-1)
    d[b-1].append(a-1)
ans=0
for i in range(n):
    if vis[i]==0:
        a=set()
        dfs(i)
        l=0
        z=0
        for j in a:
            if p[j-1] in a:
                z+=1
            if p[j-1]==j:
                l+=1
        ans=max(ans,c+z-l)
print(ans)
        
                
                
    
    
    
    

### FIXED CODE ###

n,m=list(map(int,input().split()))
p=list(map(int,input().split()))
from collections import defaultdict
from collections import deque
c=0
for i in range(n):
    if p[i]==i+1:
        c+=1
vis=[0]*n
def dfs(x):
    vis[x]=1
    a.add(x+1)
    
    di = deque()
    di.append(x)
    while di:
        now = di.popleft()
        for j in d[now]:
            if not vis[j]:
                vis[j] = 1
                a.add(j+1)
                di.append(j)
    
    
    for u in d[x]:
        if vis[u]==0:
            dfs(u)
d=defaultdict(list)
for i in range(m):
    a,b=list(map(int,input().split()))
    d[a-1].append(b-1)
    d[b-1].append(a-1)
ans=0
for i in range(n):
    if vis[i]==0:
        a=set()
        dfs(i)
        l=0
        z=0
        for j in a:
            if p[j-1] in a:
                z+=1
            if p[j-1]==j:
                l+=1
        ans=max(ans,c+z-l)
print(ans)
import math
 
def round(R):
  return 2*R*pi

R = int(input())
round(R)

### FIXED CODE ###

import math
 
def round(R):
  return 2*R*math.pi
 
R = int(input())
print(round(R))
a,b,c=mpp(int,input().split())
l=[a,b,c]
sorted(l)
if len(l)==2:
  print('Yes')
elif:
  print('No')
  

### FIXED CODE ###

a,b,c=map(int,input().split())
l=[a,b,c]
l.sort()
if l[0]==l[1] and l[1]!=l[2]:
  print('Yes')
elif l[0]!=l[1] and l[1]==l[2]:
  print('Yes')
else:
  print('No')
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]
C=[[0]*l for i in range(n)]

for x in range(n):
    for y in range(m):
        for z in range(l):
            C[x][y] += A[x][z]*B[z][y]

for row in range(n):
    print("%d"%(C[row][0]).end="")
    for col in range(1,l):
        print(" %d"%(C[row][col]),end="")
    print()



### FIXED CODE ###

n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]
C=[[0]*l for i in range(n)]

for x in range(n):
    for y in range(l):
        for z in range(m):
            C[x][y] += A[x][z]*B[z][y]

for row in range(n):
    print("%d"%(C[row][0]),end="")
    for col in range(1,l):
        print(" %d"%(C[row][col]),end="")
    print()
n = int(input())
table = list(map(int,input().split()))
table.sort()
count = 0
for i in range(1,n+1):
    if i%2 = 1:
        count += table[i]
    else:
        pass
print(count)

### FIXED CODE ###

n = int(input())
table = list(map(int,input().split()))
table.sort()
count = 0
for i in range(2*n):
    if i%2 == 0:
        count += table[i]
    else:
        pass
print(count)
a,b = map(int,input().split())
import math
c = math.gcd(a,b)
answer = a*b/c
print(int(answer))

### FIXED CODE ###

a,b = map(int,input().split())
from fractions import gcd
c = gcd(a,b)
answer = a*b/c
print(int(answer))
import sys
sys.setrecursionlimit(4000000000000)
def knap(n,w,weight,value,dp):
  #  print(n,":",w,":",len(dp),":",len(dp[n]))
    if dp[n][w]!=-1:
        return dp[n][w]
    if n==0:
        dp[n][w]=0
        return 0
    if w==0:
        dp[n][w]=0
        return 0
    if w-weight[n]<0:
        tmp2=knap(n-1,w,weight,value,dp)
        dp[n][w]=tmp2
        return tmp2
    tmp1=knap(n-1,w-weight[n],weight,value,dp)+value[n]
    tmp2=knap(n-1,w,weight,value,dp)
    if tmp1>tmp2:
        dp[n][w]=tmp1
        return tmp1
    else:
        dp[n][w]=tmp2
        return tmp2
        

n,W=map(int,input().split())
weight=[0]
value=[0]
for i in range(n):
    a,b=map(int,input().split())
    weight.append(a)
    value.append(b)
dp=[[-1]*(W+1)]*(n+1)
print(knap(n,W,weight,value,dp))



### FIXED CODE ###

def knap(N,W,weight,value):
    inf=float("inf")
    dp=[[-inf for i in range(W+1)] for j in range(N+1)]
    #各nについて初期化　以下で各ｗについて0この時０とする
    for i in range(W+1):#w+1とは0~w
        dp[0][i]=0
    for i in range(N):#each n 0~N-1
        for w in range(W+1):#w 0~w
            if weight[i]<=w:#=を入れないとぎりぎりの時が困る
                dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w])
            else:
                dp[i+1][w]=dp[i][w]
   # print(dp)
    return dp[N][W]


n,W=map(int,input().split())
w=[]
v=[]
for i in range(n):
    a,b=map(int,input().split())
    w.append(a)
    v.append(b)
print(knap(n,W,w,v))
import functools, fraction

N,M = map(int,input().split())
S = input()
T = input()

def lcm(a, b):
	return a * b // fraction.gcd(a, b)

def check(L, NM):
    res = []
    for i in range(NM):
        res.append(int(i*(L/NM)+1))
    return res

def check2(x, L, NM):
    return int((x-1)*NM/L)

L = lcm(N,M)
ans = L


a = list(set(check(L, N)) & set(check(L, M)))
for i in a:
    if S[check2(i, L, N)] != T[check2(i, L, M)]:
        ans = -1
        break
print(ans)

### FIXED CODE ###

import functools, fractions

N,M = map(int,input().split())
S = input()
T = input()

def lcm(a, b):
	return a * b // fractions.gcd(a, b)

def check(L, NM):
    res = []
    for i in range(NM):
        res.append(int(i*(L/NM)+1))
    return res

def check2(x, L, NM):
    return int((x-1)*NM/L)

L = lcm(N,M)
ans = L


a = list(set(check(L, N)) & set(check(L, M)))
for i in a:
    if S[check2(i, L, N)] != T[check2(i, L, M)]:
        ans = -1
        break
print(ans)
from itertools import chain, permutations, dropwhile
from heapq import merge
from functools import wraps

def listify(fn):
  @wraps(fn)
  def wraper(*args, **kwargs):
    return list(fn(*args, **kwargs))
  return wraper

def comp_wild(a,b):
  return all(x==y or "?" in (x,y) for x,y in zip(a, b))

@listify
def includers(a,b):
  for i in range(len(a)-len(b)+1):
    if comp_wild(a[i:], b):
      yield i

@listify
def connectors(a,b):
  la = len(a)
  for i in range(max(la-len(b)+1, 1), la):
    if comp_wild(a[i-la:], b):
      yield i
  yield la

class c_int(int):
  def __new__(cls, *args, **kwargs):
    cond = kwargs.pop("cond", lambda:True)
    i = int.__new__(cls, *args, **kwargs)
    i.cond = cond
    return i

def iter_from(it, fm):
  return dropwhile(fm.__gt__, it)

def solve(a, b, c):
  keys = sorted((a,b,c), key=len, reverse=True)
  len_keys = list(map(len, keys))
  inc = { (i,j):includers(keys[i],keys[j]) for i,j in permutations(range(3), 2) }
  con = { (i,j):connectors(keys[i],keys[j]) for i,j in permutations(range(3), 2) }
  
  for i in inc[0,1]:
    for j in inc[0,2]:
      if (
        j+len_keys[2] <= i or i+len_keys[2] <= j or
        j-i in inc[1,2] or j-i in con[1,2] or i-j in con[2,1]
      ):
        return len_keys[0]
  
  def candicates(x,y,z):
    return chain(
      ( c_int(
          i+len_keys[z], 
          cond=lambda:(
            (inc[x,y] and inc[x,y][0]+len_keys[y] <= i) or 
            (inc[z,y] and len_keys[x] <= i+inc[z,y][-1]) or 
            any(
              (i-j in con[y,z] if i>j else j-i in inc[z,y])
               for j in iter_from(inc[x,y]+con[x,y], i-len_keys[y])
            )
          )
        ) for i in iter_from(con[x,z], len_keys[y]-len_keys[z]+1)
      ),
      ( c_int(
          min( i+next(iter_from(q, len_keys[x]-i+1))+len_keys[z] for i in p )
        ) for (p, q) in [sorted((con[x,y], con[y,z]), key=len)]
      ),
    )
  
  for c in merge(*( candicates(*xyz) for xyz in permutations(range(3), 3) )):
    if c.cond():
      return c
  
  return sum(len_keys)

print(solve(*(input() for _ in range(3))))


### FIXED CODE ###

import math
a,b = list(map(int, input().split()))
if(a== 1 or b==1):
    print(1)
else:
    print(math.ceil((a*b)/2))
r,c=map(int,raw_input().split())
l=[]
for i in range(r):l.append(map(int,raw_input().split()))
l.append([0]*c)
for i in range(c):
    for j in range(r):l[c-1][i]+=l[j][i]
    l[i].append(sum(l[i]))
for i in range(r+1):print' '.join(map(str,l[i]))

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import time
import sys
import io
import re
import math
#start = time.time()
start = time.clock()
l=[]
m=[]
s=[]
(r,c)=map(int, raw_input().split())
for i in range(r):
    l.append(map(int, raw_input().split()))
### ???????????則??\?????????
for cc in range(c):
    a=0
    for rr in range(r):
        a+=int(l[rr][cc])
#        print int(l[rr][cc])
    s.append(a)
for j in range(r):
    print ' '.join(map(str,l[j])),str(sum(l[j]))
print ' '.join(map(str,s)),str(sum(s))
A, B = map(int, input())

if A + B >= 10:
    print("error")
else:
    print(A+B)

### FIXED CODE ###

A, B = map(int, input().split())
 
if A + B >= 10:
    print("error")
else:
    print(A+B)
n,m=map(int,input().split())
S,C=[], []
for i in range(m):
  a,b=map(int,input().split())
  S.append(a)
  C.append(b)
for j in range(10**n):
  if len(j)==n and all(str(j)[x-1]==str(y) for x,y in zip(S,C)):
    print(j)
    break;
else:
  print(-1)

### FIXED CODE ###

n,m=map(int,input().split())
S,C=[], []
for i in range(m):
  a,b=map(int,input().split())
  S.append(a)
  C.append(b)
for j in range(10**n):
  if len(str(j))==n and all(str(j)[x-1]==str(y) for x,y in zip(S,C)):
    print(j)
    break;
else:
  print(-1)
N = int(input())
S = list(map(int,input().split()))
print("Four" if "Y" in S else "Three")

### FIXED CODE ###

N = int(input())
S = list(input().split())
print("Four" if "Y" in S else "Three")
a = int(input()
if a = 1:
    print(0)
else:
    print(1)

### FIXED CODE ###

a = int(input())
if a == 1:
    print(0)
else:
    print(1)
N,R = map(int, input().split())

if N >= 10:
    print(R)
else:
    print(R + (100*(10-K)))
    

### FIXED CODE ###

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

if N >= 10:
    print(R)
else:
    print(R + (100*(10-N)))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

var = int(raw_input())

h = var / 3600
ms = var % 3600
m = ms / 60
s = ms % 60

print ":".join([h, m, s])

### FIXED CODE ###

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

var = int(raw_input())

h = str(var / 3600)
ms = var % 3600
m = str(ms / 60)
s = str(ms % 60)

print ":".join([h, m, s])
A=int(input("Enter A:"))
B=int(input("Enter B:"))
C=int(input("Enter C:"))
if((A==5 and B==5 and C==7) or (A==5 and C==5 and B==7) or (B==5 and C ==5 and  A==7)):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

same = tuple(sorted(map(int, input().split()))) == (5, 5, 7)
print("YES" if same else "NO")
#include <iostream>

using namespace std;

bool is_prime(long long x) {
  for (long long i = 2; i*i <= x; i++) {
    if (x % i == 0) { return false; }
  }
  return x != 1;
}

int main() {
  int x; cin >> x;

  for (int i = x; ; i++) {
    if (is_prime(i)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

### FIXED CODE ###

#!/usr/bin/env python3

def is_prime(x):
    i = 2
    while i*i <= x:
        if x%i == 0: return False
        i += 1
    return x != 1

x = int(input())

while True:
    if is_prime(x):
        print(x)
        break
    x += 1
import math

def lcm(a, b):
    return a * b // math.gcd(a, b)

n, m = map(int, input().split())
s = list(input())
t = list(input())

s1 = ['*'] * lcm(n, m)
l = len(s1)

for i in range(n):
    s1[(l//n) * i] = s[i]

for j in range(m):
    if s1[(l//m) * j] != '*' and s1[(l//m) * j] != t[j]:
        print(-1)
        break
    if j == m - 1:
        print(l)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

n, m = map(int, input().split())
s = list(input())
t = list(input())

for i in range(gcd(n, m)):
    if s[i * (n // gcd(n, m))] != t[i * (m // gcd(n, m))]:
        print(-1)
        break
    if i == gcd(n, m) - 1:
        print(lcm(n, m))
from collections import deque

H, W = map(int, input().split())
grid = [list(input()) for i in range(H)]

# 初期が黒('#')の位置からの距離
dist = [[-1]*H for _ in range(W)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append([h, w])
            dist[h][w] = 0

del grid

def bfs(black_cells, dist):
    ans = 0
    while len(black_cells) > 0:
        # キューとして使うのでpop()ではなくpopleft()
        h, w = black_cells.popleft()  # 黒いセルの座標
        d = dist[h][w]
        ans = max(ans, d)
        for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d+1
                black_cells.append([new_h, new_w])
    return ans

ans = bfs(black_cells, dist)
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
grid = [list(input()) for i in range(H)]

# '#'の位置をキューに追加（＝今回はこれが複数あるので、複数スタートとなる）
black_cells = deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == '#':
            black_cells.append([h, w, 0])

ans = 0
while len(black_cells) > 0:
    one_black_cell = black_cells.popleft()  # キューとして使うのでpop()ではなくpopleft()
    for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
        nh = one_black_cell[0] + dy
        nw = one_black_cell[1] + dx
        d = one_black_cell[2]
        if nh < 0 or H <= nh or nw < 0 or W <= nw:
            continue
        if grid[nh][nw] == '.':
            grid[nh][nw] = '#'
            black_cells.append([nh, nw, d + 1])
        ans = d

print(ans)
N,P=map(int,input().split())
S=input()

amari=[0]*P
amari[0]=1

if P==2:
  ans=0
  for i in range(1,N+1):
    if S[-i]%2==0:
      ans+=N-i
  print(ans)
  exit()

if P==5:
  ans=0
  for i in range(1,N+1):
    if S[-i]%5==0:
      ans+=N-i
  print(ans)
  exit()

for i in range(1,N+1):
  amari[int(S[-i:])%P]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)

### FIXED CODE ###

N,P=map(int,input().split())
S=input()
sn=int(S)

if P==2:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%2==0:
      ans+=N-i+1
  print(ans)
  exit()

if P==5:
  ans=0
  for i in range(1,N+1):
    if int(S[-i])%5==0:
      ans+=N-i+1
  print(ans)
  exit()

amari=[0]*P
amari[0]=1

mod=0
for i in range(1,N+1):
  mod=(mod+int(S[-i])*pow(10,i-1,P))%P
  amari[mod]+=1
ans=0
for tmp in amari:
  ans+=tmp*(tmp-1)//2
  
print(ans)