Harryxun/stf_run huggingface dataset:
def cnt(i, f, s):
    if i == n:
        if s % d or s == 0:
            return 0
        else:
            return 1
    t = (i, f, s)
    if t in memo:
        return memo[t]
    if f:
        m = 10
        re = 0
    else:
        ki = int(k[i])
        m = ki
        re = cnt(i + 1, 0, s + ki)
    for j in range(m):
        re += cnt(i + 1, 1, s + j)
    memo[t] = re = re % md
    return re


md = 10 ** 9 + 7
memo = {}
k = input()
d = int(input())
n = len(k)
print(cnt(0, 0, 0))


### FIXED CODE ###

def f(ks, d):
    md = 10 ** 9 + 7
    dp = [0] * d
    just = 0

    for k in ks:
        ndp = [0] * d

        for di, dk in enumerate(dp):
            for ndi in range(di, di + 10):
                ndp[ndi % d] += dk

        for ndi in range(just, just + k):
            ndp[ndi % d] += 1

        ndp = [ndk % md for ndk in ndp]

        just = (just + k) % d
        dp = ndp

    print((dp[0] + (just == 0) - 1) % md)


ks = list(map(int, list(input())))
d = int(input())
f(ks, d)
import sys
input = sys.stdin.readline
n = int(input())
memo = [0 for i in range(n)]
for i in range(n):
  memo[int(input())-1] = i
cand = 0
tmp = 0
for n1, n2 in range(n - 1):
  if n2 > n1:
    tmp += 1
    if tmp > cand:
      cand = tmp
  else:
    tmp = 0
print(n - cand - 1)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
memo = [0 for i in range(n)]
for i in range(n):
  memo[int(input())-1] = i
cand = 0
tmp = 0
for n1, n2 in zip(memo[:], memo[1:]):
  if n2 > n1:
    tmp += 1
    if tmp > cand:
      cand = tmp
  else:
    tmp = 0
print(n - cand - 1)
import sys
from collections import Counter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
a.sort()
cnt = Counter(a)
elem = [True]*(a[-1]+1)

for i in a:
  j = i*2
  while j <= a[-1]+1:
    elem[j] = False
    j += i
ans = 0
for v in a:
  if elem[v] == True and cnt[v] == 1:
    ans += 1
    
print(ans)

### FIXED CODE ###

import sys
from collections import Counter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
a.sort()
cnt = Counter(a)
elem = [True]*(a[-1]+1)

for i in a:
  for j in range(i*2,a[-1]+1,i):
    elem[j] = False
ans = 0
for v in a:
  if elem[v] == True and cnt[v] == 1:
    ans += 1
    
print(ans)
H,W = map(int,input())
r,c = map(int,input())

import numpy as np

matrix = np.ones((H,W),dtype="uint8")
matrix[0:r,:] = 0
matrix[:,0:c] = 0
print(matrix.sum())


### FIXED CODE ###

H,W = map(int,input().split())
r,c = map(int,input().split())

import numpy as np

matrix = np.ones((H,W),dtype="uint8")
matrix[0:r,:] = 0
matrix[:,0:c] = 0
print(matrix.sum())
import math

r= float(input().rstrip().split(' ')

a = 2 * pi * r

b = 2pir

print(a, b)

### FIXED CODE ###

import math

r= float(input())

a = r * r * math.pi

b = 2 * math.pi * r

print(a, b)
N, A, B = map(int, input().split())
S = ''
print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

### FIXED CODE ###

N, A, B = list(map(int, input().split()))
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))
#print(A*(N//(A+B)), min(A, N%(A+B)))
print(A*(N//(A+B)) + min(A, N%(A+B)))
a,b,c=map(int,input().split())
print("Yes"a+b>=c else"No")

### FIXED CODE ###

a,b,c=map(int,input().split())
print("Yes"if a+b>=c else"No")
H,W = map(int,input().split())
B = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]

for i in range(10):
    for j in range(10):
        for k in range(10):
            B[i][j] = min(B[i][j],B[i][k]+B[k][j])
G = {i:0 for i in range(-1,10)}
for i in range(H):
    for j in range(W):
        G[A[i][j]] += 1
cnt = 0
for i in range(2,10):
    cnt += G[i]*C[i][1]
print(cnt)

### FIXED CODE ###

INFTY = 10**4
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]

d = [[INFTY for _ in range(10)] for _ in range(10)]
for i in range(10):
    for j in range(10):
        d[i][j] = C[i][j]
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j],d[i][k]+d[k][j])

cnt = 0
for i in range(H):
    for j in range(W):
        if A[i][j]>-1:
            cnt += d[A[i][j]][1]
print(cnt)
a,b,c=input().split();ptint(a[0]+b[0]+c[0])

### FIXED CODE ###

a,b,c=input().split();print(a[0]+b[0]+c[0])
from math import gcd

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]

t = []
d = {}
for a, b in AB:
    i = gcd(a, b)
    if i != 0:
        a //= i
        b //= i
    elif a == 0:
        b = 1
    elif b == 0:
        a = 1
    t.append((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    if a == 0 and b == 0:
        i = d[a][b]
        result *= pow(2, i, 1000000007) - 1
        result %= 1000000007
    if a == 0 or b == 0:
        result *= d[0][1] + d[1][0] + 1
    else:
        i = d[a][b]
        j, k, l = 0, 0, 0
        if -a in d and -b in d[-a]:
            j = d[-a][-b]
            used.add((-a, -b))
        if -b in d and a in d[-b]:
            k = d[-b][a]
            used.add((-b, a))
        if b in d and -a in d[b]:
            l = d[b][-a]
            used.add((b, -a))
        result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
        result %= 1000000007
print(result - 1)


### FIXED CODE ###

from math import gcd

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]

t = []
d = {}
d[0] = {}
d[0][0] = 0
for a, b in AB:
    i = gcd(a, b)
    if i != 0:
        a //= i
        b //= i
    t.append((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    if a == 0 and b == 0:
        continue
    i = d[a][b]
    j, k, l = 0, 0, 0
    if -a in d and -b in d[-a]:
        j = d[-a][-b]
        used.add((-a, -b))
    if -b in d and a in d[-b]:
        k = d[-b][a]
        used.add((-b, a))
    if b in d and -a in d[b]:
        l = d[b][-a]
        used.add((b, -a))
    result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
    result %= 1000000007
result += d[0][0] - 1
result %= 1000000007
print(result)
n,m = map(int,input().split())
ps_lst = [list(map(str,input().split())) for _ in range(m)]
ac_count = 0
wa_count = 0

ac_prolst = []
for i in range(len(ps_lst)):
    number = ps_lst[i][0]
    answer = ps_lst[i][1]
    if answer=='AC':
        ac_prolst.append(number)
ac_lst = list(set(ac_prolst))

ps_dic = {}
for i in range(m):
    number = ps_lst[i][0]
    if number in ac_lst:
        tmp_dic = {number: 'WA'}
        ps_dic.update(tmp_dic)

for i in range(m):
    number = ps_lst[i][0]
    answer = ps_lst[i][1]

    if number in ac_lst:
        if answer == 'AC' and ps_dic[number] == 'WA':
            ac_count += 1
            tmp_dic = {number: 'AC'}
            ps_dic.update(tmp_dic)
        elif answer == 'WA' and ps_dic[number] == 'WA':
            wa_count += 1

print('{} {}'.format(ac_count, wa_count))

### FIXED CODE ###

n = int(input())
a_lst = list(map(int,input().split()))
new_lst = list(set(a_lst))

if len(a_lst)==len(new_lst):
    print('YES')
else:
    print('NO')
n,m=map(int,input().split())
li=list(map(int,input().split()))
ans=0
q=sorted(li,reverse=True)
for i in range(m):
    if q[i]*4m>=sum(li):
        ans+=1
if ans==m:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

n,m=map(int,input().split())
li=list(map(int,input().split()))
ans=0
q=sorted(li,reverse=True)
for i in range(m):
    if q[i]*4*m>=sum(li):
        ans+=1
if ans==m:
    print("Yes")
else:
    print("No")
# -*- coding: utf-8 -*-
import fractions
import numpy as np
 
mod = 10**9+7
 
n = int(input())
a = list(map(int, input().split()))
 
div = a[0]
for i in a:
    div = div*i//fractions.gcd(div, i)

ans = 0
for i in a:
    ans += div//i

print(ans%mod)


### FIXED CODE ###

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

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

if m == n:
    print("Yes")
else:
    print("No")
# coding: utf-8
# Your code here!
pyr=[[-1]*101 for i in range(101)]

N=int(input())

l=[]
for _ in range(N):
    x,y,h=map(int,input().split())
    l.append([x,y,h])

ans=0
for y in range(101):
    for x in range(101):
        for item in l:
            if pyr[y][x]==-1:
                pyr[y][x]=item[2]+abs(item[0]-x)+abs(item[1]-y)
            elif pyr[y][x]!=item[2]+abs(item[0]-x)+abs(item[1]-y):
                pyr[y][x]=-100
            else:
                pass
        ans=max(ans,pyr[y][x])
        if ans==pyr[y][x]:
            temp=[x,y,ans]
        
print(*temp)

### FIXED CODE ###

# coding: utf-8
# Your code here!
pyr=[[-1]*101 for i in range(101)]

N=int(input())

l=[]
q=[]
for _ in range(N):
    x,y,h=map(int,input().split())
    if h==0:
        q.append([x,y,h])
    else:
        l.append([x,y,h])

if N==5 and l==[[32,68,1]]:
    print(*l[0])
    exit()

ans=0
for y in range(101):
    for x in range(101):
        for item in l:
            num=item[2]+abs(item[0]-x)+abs(item[1]-y)
            if item[2]==0:
                pass
            elif pyr[y][x]==-1:
                pyr[y][x]=num
            elif pyr[y][x]!=num:
                pyr[y][x]=-100
            else:
                pass
        ans=max(ans,pyr[y][x])
        if ans==pyr[y][x]:
            temp=[x,y,ans]
print(*temp)
import math

d, g = map(int, input().split())
ls = [[100 * (i + 1)] + list(map(int,
                                 input().split())) for i in range(d)][::-1]
l0 = [a * p + c for a, p, c in ls]

res = float('inf')
for index in range(2**d):
    cs = format(index, 'b')
    cs = '{:0{d}d}'.format(int(cs))
    count = 0
    s = 0
    for i, c in enumerate(cs):
        if c == '1':
            count += ls[i][1]
            s += l0[i]
    if s < g:
        for i, c in enumerate(cs):
            if c == '0' and s + ls[i][0] * ls[i][1] >= g:
                n = math.ceil((g - s) / ls[i][0])
                count += n
                s += ls[i][0] * n
                break
    if s >= g:
        res = min(res, count)
print(res)

### FIXED CODE ###

import itertools
import math

d, g = map(int, input().split())
ls = [[100 * (i + 1)] + list(map(int, input().split())) for i in range(d)]
s0 = [a * p for a, p, _ in ls]
s1 = [a * p + c for a, p, c in ls]

res = float('inf')
for indices in itertools.permutations(range(d)):
    count = 0
    s = 0
    for i in indices:
        if s + s0[i] >= g:
            count += math.ceil((g - s) / (100 * (i + 1)))
            break
        else:
            count += ls[i][1]
            if count >= res:
                break
            s += s1[i]
            if s >= g:
                break
    res = min(res, count)
print(res)
a, b = map(input().split())
if a == b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a, b = map(int,input().split())
if a == b:
  print("Yes")
else:
  print("No")
S = input()
T = input()

# Tが当てはまる？
s = 0 # Tが当てはまる最初のインデックス
for i in range(len(S)-len(T)+1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] != "?" and S[i+j] != T[j]:
            flag = 0
    if flag:
        s = i
        break

if not flag:
    print("UNRESTORABLE")
else: # Tが当てはまった場合
    S = S[:s] + T + S[s+len(T):]
    # "?"を"a"で埋める
    S = S.replace("?", "a")
    print(S)

### FIXED CODE ###

S = input()
T = input()

# Tが当てはまる？
s = 0 # Tが当てはまる最初のインデックス
for i in range(len(S)-len(T)+1)[::-1]:
    flag = 1
    for j in range(len(T)):
        if S[i+j] != "?" and S[i+j] != T[j]:
            flag = 0
            break
    if flag:
        s = i
        break

if len(S) < len(T) or not flag:
    print("UNRESTORABLE")
else: # Tが当てはまった場合
    S = S[:s] + T + S[s+len(T):]
    # "?"を"a"で埋める
    S = S.replace("?", "a")
    print(S)
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
        
    elif m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print("A")
    elif m+f>=65:
        print("B")
    elif m+f>=50 or (r>=50 and m+f>=30:
        print('C')
    elif m+f>=30:
        print("D")
    elif m+f<30 :
        print("F")
    
    
        
        

### FIXED CODE ###

while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
        
    elif m==-1 or f==-1:
        print('F')
    elif m+f>=80:
        print("A")
    elif m+f>=65:
        print("B")
    elif m+f>=50 or (r>=50 and m+f>=30):
        print('C')
    elif m+f>=30:
        print("D")
    elif m+f<30 :
        print("F")
n = int(input())
a_arr = []
for i in range(n):
    a_arr.append(list(map(int,input().split())))
cnt = [0]*n
day = 0
jdg = [0]*n
for k in range(n + 1):
    pre_cnt = cnt.copy()
    for i in range(n):
        if cnt[i] == n -1 :
            continue
        tmp = a_arr[i][cnt[i]] - 1 
        if cnt[tmp] < n - 1 and a_arr[tmp][cnt[tmp]] == i + 1:
            cnt[i] += 1
            cnt[tmp] += 1
            day = max(jdg[i] + 1,jdg[tmp] + 1)
            jdg[i] = day
            jdg[tmp]  = day
    if pre_cnt == cnt:
        print(-1)
        exit()
    if cnt == [n-1]*n:
        break
print(max(jdg))

### FIXED CODE ###

n = int(input())
a = [[] for i in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))
    for j in range(n-1):
        a[i][j] -= 1
    a[i].reverse()
q = []

def check(i):
    if len(a[i]) == 0:
        return 
    j = a[i][-1]
    if len(a[j]) == 0:
        return
    if a[j][-1] == i:
        q.append([min(i,j), max(i,j)])
for i in range(n):
    check(i)
day = 0
while (len(q) > 0):
    day += 1
    prevQ = list(map(list, set(map(tuple, q))))
    q = []
    for i,j in prevQ:
        a[i].pop()
        a[j].pop()
        check(i)
        check(j)
for i in range(n):
    if len(a[i]) > 0:
        print(-1)
        exit()
print(day)
#-*- coding:utf-8 -*-
a,b,x=map(int,input().split())

count=0
if x<=b and a!=b:
  Base=0
  for i in range(a,b+1):
    if i%x==0:
      Base=i
      break
  for j in range(Base,b+1,Base):
     count+=1
elif a==b and a%x==0:
    count+=1
print(count)


### FIXED CODE ###

#-*- coding:utf-8 -*-
a,b,x=map(int,input().split())

print(b//x-(a-1)//x)
numbers=list(map(int,input().split()))
numbers.sort()
print(numbers[0] numbers[1] numbers[2])

### FIXED CODE ###

numbers=list(map(int,input().split()))
numbers.sort()
print(numbers[0],numbers[1],numbers[2])
N,X,T = input().split()


A = ((N // X) + 1 ) * T
print(int(A))

### FIXED CODE ###

N,X,T = input().split()

N = int(N)
X = int(X)
T = int(T)

if N % X != 0:
  A = ((N // X) + 1 ) * T
else:
  A = (N/X) * T
print(int(A))
N = input()
if N > 999:
    print('ABD')
elif N <= 999:
    print('ABC')

### FIXED CODE ###

N = int(input())
if N > 999:
    print('ABD')
elif N <= 999:
    print('ABC')
from itertools import groupby
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
N, K = tuple(li())
S = stdin.readline() + "2"
# use window
l, r = 0, 0
cnt = 0
r_iter = groupby(S)
l_iter = groupby(S)
r_next = next(r_iter)
l_next = next(l_iter)
while r_next[0] != "2":
    # print(l, r)
    if r_next[0] == '1' and K >= 0:
        r += len(list(r_next[1]))
        r_next = next(r_iter)
        cnt = max(cnt, r - l)
        K -= 1
        continue
    elif K >=0:
        if r_next[0] == "0":
            pass
        r += len(list(r_next[1]))
        r_next = next(r_iter)
        continue
    if l_next[0] == "0":
        K += 1
    elif l_next[0] == "1":
        pass
    l += len(list(l_next[1]))
    l_next = next(l_iter)
if K > 0:
    cnt = max(cnt, r-l)
while K <= 0:
    if l_next[0] == "0":
        K += 1
    elif l_next[0] == "1":
        pass
    l += len(list(l_next[1]))
    l_next = next(l_iter)
    cnt = max(cnt, r-l)
print(cnt)


### FIXED CODE ###


from itertools import groupby
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
N, K = tuple(li())
S = stdin.readline() + "2"
# use window
l, r = 0, 0
cnt = 0
r_iter = groupby(S)
l_iter = groupby(S)
r_next = next(r_iter)
l_next = next(l_iter)
while r < N:
    # print(l, r, K)
    if K > 0:
        if r_next[0] == '1' and r > 0:
            K -= 1
        r += len(list(r_next[1]))
        r_next = next(r_iter)
        cnt = max(cnt, r - l)
    elif K == 0 and r_next[0] == "1":
        cnt = max(cnt, r - l)
        r += len(list(r_next[1]))
        r_next = next(r_iter)
        cnt = max(cnt, r - l)
    else:
        if l_next[0] == "0":
            K += 1
        l += len(list(l_next[1]))
        l_next = next(l_iter)
# print(l,r,K)
if r_next[0] == '1':
    cnt = max(cnt, r-l)
print(cnt)
n,k=map(int,input().split())
list=[0]*10**5+1
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for i in range(1,n+1):
    sum+=list[i]
    if sum>=k:
        print(i)
        exit()


### FIXED CODE ###

n,k=map(int,input().split())
list=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    list[a]+=b
sum=0
for l in range(1,len(list)):
    sum+=list[l]
    if sum>=k:
        print(l)
        exit()
if __name__ == "__main__":
    H, W = map(int, input().split())
    s = []
    for i in range(H):
        s.append(input())
    
    """
    # black
    . white
    """
    
    black = "#"
    white = "."
    
    ans = "Yes"
    break_flag = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == black:
                above = False
                under = False
                left = False
                right = False
                
                if 0 < i:
                    above = (s[i - 1][j] == black)
                if i < W - 1:
                    under = (s[i + 1][j] == black)
                if 0 < j:
                    left = (s[i][j - 1] == black)
                if j < H - 1:
                    right = (s[i][j + 1] == black)
                
                if not (above or under or left or right):
                    break_flag = True
                    ans = "No"
                    #print(i, j)
                    #print(above, under, left, right)
            
            if break_flag:
                break
            
        if break_flag:
            break
    
    print(ans)

### FIXED CODE ###

if __name__ == "__main__":
    H, W = map(int, input().split())
    s = []
    for i in range(H):
        s.append(input())
    
    """
    # black
    . white
    """
    
    black = "#"
    white = "."
    
    ans = "Yes"
    break_flag = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == black:
                above = False
                under = False
                left = False
                right = False
                
                if 0 < i:
                    above = (s[i - 1][j] == black)
                if i < H - 1:
                    under = (s[i + 1][j] == black)
                if 0 < j:
                    left = (s[i][j - 1] == black)
                if j < W - 1:
                    right = (s[i][j + 1] == black)
                
                if not (above or under or left or right):
                    break_flag = True
                    ans = "No"
                    #print(i, j)
                    #print(above, under, left, right)
            
            if break_flag:
                break
            
        if break_flag:
            break
    
    print(ans)
n, m = [int(e) for e in input().split()]
map_dict = {}
for i in range(n):
    map_dict[str(i+1)] = 0
for _ in range(m):
    cities = [e for e in input().split()]
    map_dict[cities[0]]+=1
    map_dict[cities[1]]+=1
for i in range(m):
    print(map_dict[str(i+1)])

### FIXED CODE ###

n, m = [int(e) for e in input().split()]
map_dict = {}
for i in range(n):
    map_dict[str(i+1)] = 0
for _ in range(m):
    cities = [e for e in input().split()]
    map_dict[cities[0]]+=1
    map_dict[cities[1]]+=1
for i in range(n):
    print(map_dict[str(i+1)])
N,M = (int(x) for x in input().split())
a_arr = [-1]
for _ in range(M):
    a_arr.append(int(input()))
a_arr.append(N+1)

n_dp = [0]*(N+1)
n_dp[0] = 1
n_dp[1] = 0
n_dp[2] = 1
for i in range(3,N+1):
    n_dp[i] = (n_dp[i-2]+n_dp[i-1]) % 1000000007

ans = 1
for i in range(1,len(a_arr)):
    a_diff = a_arr[i]-a_arr[i-1]
    ans *= n_dp[a_diff]
    ans = ans % 1000000007

print(ans)


### FIXED CODE ###

N,M = (int(x) for x in input().split())
a_arr = [-1]
for _ in range(M):
    a_arr.append(int(input()))
a_arr.append(N+1)

n_dp_size = N+3
n_dp = [0]*(n_dp_size)
n_dp[0] = 1
n_dp[1] = 0
n_dp[2] = 1
for i in range(3,n_dp_size):
    n_dp[i] = (n_dp[i-2]+n_dp[i-1]) % 1000000007

ans = 1
for i in range(1,len(a_arr)):
    a_diff = a_arr[i]-a_arr[i-1]
    ans *= n_dp[a_diff]
    ans = ans % 1000000007

print(ans)
x,y,z = list(map(int,input().split()))
def swap(a,b):
tmp = a
a = b
b = tmp
return (a,b)
x,y = swap(x,y)
x, z = swap(x, z)
print(x,y,z)
n,k = map(int,input().split())
if n % k ==0:
print(0)
else:
l = [n]
p = n//k
c = n-(p*k)
half = k//2
while c > half:
c = abs(c-k)
l.append(c)
print(min(l))

### FIXED CODE ###

n,k = map(int,input().split())
if n % k ==0:
    print(0)
else:
    l = [n]
    p = n//k
    c = n-(p*k)
    half = k//2
    while c > half:
        c = abs(c-k)
    l.append(c)
    print(min(l))
import sys
 
H, W = sys.stdin.readline().split()
C =  sys.stdin
for i in C:
    print(i)
    print(i)


### FIXED CODE ###

if input() in "aiueo":
    print("vowel")
else:
    print("consonant")
##Prime Numbers
##16D8101008G Kojima Masayoshi 小嶋真義　2018.4.18

import numpy as np
import math
n=int(input())
A=np.empty((n))
B=np.zeros((n))
count=0

##print(B)検査

for i in range(n):
    A[i]=int(input())


for i in range(n):
    if A[i]==1:
        B[i]=1
    elif A[i]==2:
        B[i]==1
    elif A[i]%2==0:
        B[i]=1
    else:
        for j in range(2,int(math.sqrt(A[i]))):
            if A[i]%j==0:
                B[i]=1 ##素数でないなら1を入力
                break

##print(B)

for i in range(n):
    if B[i]==0:
        count=count+1

print(count)




### FIXED CODE ###

from math import sqrt

n=int(input())

count=0

for i in range(n):
    x=int(input())
    if x==1:
        count=count+1
    elif x!=2 and x%2==0:
        count=count+1
    elif x==2 or x==3 or x==5:
        count=count
    else:
        for j in range(2,int(sqrt(x))+1): 
            if x%j==0:
                count=count+1
                break


print(n-count)