peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
x=int(input())
if x>=2000:
    print(1)
else:
    if (x%100)**100<=x<=(x%100)**105:
        print(1)
    else:
        print(0)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**8)
alpha = "abcdefghij"
ans = []
N = int(input())

def dfs(S, num):
    if len(S) == N:
        ans.append(S)
    else:
        right = num + 2
        seq = alpha[:right]
        for i, c in enumerate(seq):
            dfs(S+c, max(i, num))

dfs("a", 0)
ans = sorted(ans)
for a in ans:
    print(a)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = a[0]
for i in range(n-2):
    ans += a[1+(i//2)]

print(ans)
# Judge status: Accepted
N=int(input())
binary=[int(s) for s in input().split()]

boxes=[0 for _ in range(N)]
ans=set()

for i in range(N-1,-1,-1):
  if sum(boxes[i::i+1])%2!=binary[i]:
    boxes[i]=1
    ans.add(i+1)
print(len(ans))
print(*ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
print(1 if N % K == 0 else 1)
# Judge status: Accepted
a,b,c=map(int,input().split())
if c-(a-b)>0:
    print(c-(a-b))
else:
    print(0)
# Judge status: Accepted
import bisect
n,m = map(int,input().split())
x = [list() for i in range(n)]
p = []
y = []
for i in range(m):
  s,t = map(int,input().split())
  p.append(s)
  y.append(t)
  x[s-1].append(t)
for i in range(n):
  x[i].sort()
  
for i in range(m):
  index = bisect.bisect_left(x[p[i]-1],y[i])
  print("{:06}{:06}".format(p[i],index+1))
# Judge status: Wrong Answer
l = int(input())

ans = -1.0
for i in range(1, l+1):
    for j in range(1, l+1):
        k = l - i - j
        if i + j + k == l and k > 0:
            ans = max(ans, float(i * j * k))

print(ans)
# Judge status: Wrong Answer
a, b, m = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
M = []
lp = 0
id = 0
for i in range(m):
    l = list(map(int, input().split(' ')))
    M.append(l)
    if lp < l[2]:
        lp = l[2]
        id = i
m1 = min(A) + min(B)
m2 = A[M[id][0] - 1] + B[M[id][1] - 1] - M[id][2]
print(m1 if m1 < m2 else m2)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
res = 10**9
left = A[0]
right = sum(A) - left
for i in range(1,N):
    left += A[i] 
    right -= A[i]
    if abs(right-left) < res:
        res = abs(right-left)
print(res)
# Judge status: Wrong Answer
n,m=map(int,input().split())

p=1
q=1
for i in range(1,n+1):
    p*=(i%(10**9+7))
for i in range(1,m+1):
    q*=(i%(10**9+7))


if abs(n-m)>=2:
    print(0)
if abs(n-m)==1:
    print((p*q)%(10**9+7))
else:
    print(2*(p*q)%(10**9+7))
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a - 1 for a in A]
L = [None]*(N+1)
s = 0
L[0] = s
index = -1
for i in range(min(N,K)):
  e = i+1
  s = A[s]
  if s not in L:
    L[i+1] = s
  else:
    index = L.index(s)
    break
if index == -1:
  g = K%e
  print(L[g]+1)
else:
  g = index + (K-index)%(e-index)
  print(L[g]+1)
# Judge status: Accepted
from itertools import combinations_with_replacement
from math import factorial
n,m,q=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(q)]
total=[]
for a in combinations_with_replacement(range(1,m+1),n):
  ans=0
  for j in range(q):
    if int(a[lst[j][1]-1])-int(a[lst[j][0]-1])==lst[j][2]:
      ans+=lst[j][3]
  total.append(ans)

print(max(total))
# Judge status: Accepted
a = [int(input()) for _ in range(5)]
k = int(input())

print( ":(" if (max(a)-min(a))>k else "Yay!" )
# Judge status: Accepted
print("YES"if input()in"357"else"NO")
# Judge status: Wrong Answer
a,b,x = map(int,input().split())

if a > x or b < x:
    print("0")
elif a%x == 0:
    print(b//x-a//x+1)
else:
    print(b//x-a//x)
# Judge status: Accepted
n = int(input())
count = 0

while n > count:
  count = count + 111
print(count)
# Judge status: Accepted
n = int(input())
if n%2 == 0:
    print((1+n)*(n//2))
else:
    print((1+n)*(n//2)+(1+n)//2)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

find_num=1
break_num=0
flag = False
for i in range(n):
    if a[i] == find_num:
        find_num+=1
        flag = True
    else:
        break_num+=1

if flag:
    print(break_num)
else:
    print(-1)
# Judge status: Accepted
input();l=[int(i)%4 for i in input().split()];f=l.count;print('YNeos'[f(0)+f(2)//2<len(l)//2::2])
# Judge status: Wrong Answer
k, a, b = map(int, input().split())

if k > a+1 and a+2 <= b:
    print(max((k-a-1) // 2 * (b-a) + b + (k-a-1) % 2, k+1))
else:
    print(k+1)
# Judge status: Accepted
A,B,N=map(int,input().split())
def floor(x):
    return int(A*x/B)-A*int(x/B)
print(floor(min(B-1,N)))
# Judge status: Accepted
def main():
    k = int(input())
    s = str(input())
    if len(s) <= k:
        print(s)
    else:
        print(s[:k] + '...')


def input_list():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
a = input().split()
a_i = [int(s) for s in a]
a_i.sort()
print(a_i)
result = 0
for i in range(N,N + N):
    result += int(a[i])
print(result)
# Judge status: Accepted
n= int(input())
if n%2==0:
    print(0.5)
else:
    print(((n//2)+1)/n)
# Judge status: Accepted
import math

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

def get_distance(x1, y1, x2, y2):
    dist = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return dist

dist_sum = 0

for i in range(n):
  for j in range(i+1,n):
    dist_sum += get_distance(d[i][0],d[i][1],d[j][0],d[j][1])

print(dist_sum * 2 / n)
# Judge status: Accepted
n = int(input())
A = []
B = []
ans = 0
import math

for _ in range(n):
  a,b = map(int,input().split())
  A.append(a)
  B.append(b)
  
for _ in range(n):
  a = A.pop(-1)
  b = B.pop(-1)
  a += ans
  ans += math.ceil(a/b)*b - a

print(ans)
# Judge status: Accepted
s = input()
e = ""
for i in range(len(s)):
    if s[i] == "0" or s[i] == "1":
        e += s[i]
    else:
        if len(e) != 0:
            e = e[0:len(e)-1]
print (e)
# Judge status: Accepted
n = int(input())
n = n % 1000
if 1000 - n == 1000:
    print(0)
else:
    print(1000 - n)
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())
print(a - b if k % 2 == 0 else b - 1)
# Judge status: Accepted
N = int(input())
out=0
k=0
for i in range(1,N+1):
    k=0
    if i % 2==1:
        for j in range(1,i+1):
            if i % j==0:
                k = k+1
        if k==8:
            out = out+1
    
print(out)
# Judge status: Accepted
import math
a, b = map(int, input().split())


def factorization(n):
    arr = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt
    if temp!=1:
        arr[temp] = 1
    if arr==[]:
        arr[n] = 1
    return arr


g = math.gcd(a, b)
print(len(factorization(g))+1)
# Judge status: Accepted
def fanc():
  a,b,n=map(int,input().split())
  x=min(b-1,n)
  max_res=int(a*x/b)-a*int(x/b)
  print(max_res)
  
if __name__=="__main__":
  fanc()
# Judge status: Accepted
n, k = map(int, input().split())

A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

C = zip(A, B)
C = sorted(C)
A, B = zip(*C)
for i in range(n):
    a = A[i]
    b = B[i]
    k -= b
    if k <= 0:
        print(a)
        break
# Judge status: Accepted
n = int(input())

buttons = []

for i in range(n):
    buttons.append(int(input()))

next = 1
i = 0
while i <= 10**5:
    i += 1
    next = buttons[next-1]
    if next == 2:
        print(i)
        exit()

print(-1)
# Judge status: Accepted
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
count = 0
for i in range(n-1):
  if a[i] <= x:
    x = x - a[i]
    count += 1
if a[n-1] == x:
  count += 1
    
print(count)
# Judge status: Accepted
a = int(input())
if a % 9 == 0:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
def fizzbuzz(n):
    ans = 0
    for i in range(n):
        if (i+1)%3 != 0 and (i+1)%5 != 0:
            ans += i+1
            # print(i+1, ans)
    print(ans)

n = int(input())
fizzbuzz(n)
# Judge status: Accepted
x,a,b=map(int, input().split())
date=b-a
if date<=0:
  print("delicious")
elif date<=x:
  print("safe")
else:
  print("dangerous")
# Judge status: Accepted
N = int(input())
C = list(input())
C_ = sorted(C)

wr = rw = 0
for i in range(len(C_)):
    if C[i] != C_[i]:
        if C[i] == 'R' and C_[i] == 'W':
            rw += 1
        else:
            wr += 1

print(max(wr, rw))
# Judge status: Accepted
x = list(map(int, input().split()))

if x[1]%2 == 1:
    print('No')
elif x[0]*2 <= x[1] <= x[0]*4:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
S = input()
T = input()

width = len(T)
predict_word = []
for s_index in range(len(S)):
    if(len(S) < s_index + width):
        break
    predict_word.append(S[s_index:s_index+width])


count_list, ans = [], []
for p_word in predict_word:
    tmp = []
    for count, word in enumerate(p_word):
        if(T[count] == word):
            tmp.append(word)
    count_list.append(tmp)

for count in count_list:
    ans.append(len(count))

print(len(T)-max(ans))
# Judge status: Accepted
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort(key=lambda x: x[1])
timer = 0

for i in range(N):
  timer += AB[i][0]
  if timer > AB[i][1]:
    print("No")
    exit()
    
print("Yes")
# Judge status: Accepted
s = input()
a_cnt = s.count("a")
b_cnt = s.count("b")
c_cnt = s.count("c")
cnt = len(s)
if max(a_cnt, b_cnt, c_cnt) - min(a_cnt, b_cnt, c_cnt) <= 1:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
def no_2(N,S,start,stop):
  for i in range(start,stop):
    if i < N - 2 and S[i] == "#" and S[i+1] == "#":
      return False
  return True


N,A,B,C,D = map(int,input().split())
S = input()

f = no_2(N,S,B-1,D)
s = no_2(N,S,A-1,C)
if not (f and s):
  print("No")
elif C < D:
  print("Yes")
else:
  for i in range(B-1,D+1):
    if i < N - 3 and S[i:i+3] == "...":
      print("Yes")
      break
  else:
    print("No")
# Judge status: Accepted
n = int(input())
s = input()
ans = s
while s.count("()")>0:
    s = s.replace("()", "")
cnt_l = s.count(")")
cnt_r = s.count("(")
ans = cnt_l * "(" + ans
ans += cnt_r * ")"
print(ans)
# Judge status: Wrong Answer
a,b,c=map(float,input().split())

if pow(a,0.5)+pow(b,0.5)<pow(c,0.5):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

B = [A[0]]

for i in range(N-1):
    B.append(A[i+1])
    B.append(A[i+1])

B.sort(reverse=True)

print(sum(B[:N-1]))
# Judge status: Accepted
N,M=list(map(int, input().split()))
P=[0]*M
S=[0]*M
for i in range(M):
    P[i],S[i]=list(input().split())
    P[i]=int(P[i])

flagac=[False]*N
pnlt=[0]*N
for i in range(M):
    p=P[i]-1
    s=S[i]
    if s=='AC':
        flagac[p]=True
    else:
        pnlt[p]+=(flagac[p]+1)%2
# print(flagac)
# print(pnlt)

ctac=0
ctwa=0
for i in range(N):
    if flagac[i]:
        ctac+=1
        ctwa+=pnlt[i]
print(ctac, ctwa)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
x = 0
z = 0
MOD = 10**9 + 7
for i in A:
  x = (x + i)%MOD
  z = (z + i*i)%MOD
y = x*x%MOD
w = (y-z)//2%MOD
print(w)
# Judge status: Wrong Answer
S = input()

if (int(S[:2]) <= 0 or int(S[2:]) <= 0) or (int(S[:2]) > 12 and int(S[2:]) > 12):
  print("NA")
elif int(S[:2]) > 12 and int(S[2:]) <= 12:
  print("YYMM")
elif int(S[:2]) <= 12 and int(S[2:]) > 12:
  print("MMYY")
else:
  print("AMBIGUOUS")
# Judge status: Wrong Answer
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

oni = a + (v * t)
ko = b + (w * t)

if oni <= ko:
    print("NO")
    exit()

for i in range(1, t):
    a = a + v
    b = b + w
    if a >= b:
        print("YES")
        exit()

print("NO")
# Judge status: Wrong Answer
p=0
N,K=map(int,input().split())
for i in range(1,N+1):
  n=0
  while  i<=K:
    i*=2
    n+=1
  p+=(1/N)*(0.5)**n
print(p)
# Judge status: Wrong Answer
N = int(input())
p = [int(s) for s in input().split()]
sum([ sorted([p1,p2,p3])[1] == p2 for p1,p2,p3 in zip(p[2:],p[1:(N-1)],p[:(N-2)])])
# Judge status: Wrong Answer
print('A' + input()[0] + 'C')
# Judge status: Accepted
def main():
	n = int(input())
	cnt = 0
	arr = list(map(int,input().split()))
	for i in range(len(arr)):
		if arr[i]!=i+1:
			cnt+=1
	if cnt>=3:
		print("NO")
	else:
		print("YES")


main()
# Judge status: Accepted
a = list(map(int, input().split()))
M = max(a)
a.remove(M)
ans = 1 / 2
for aa in a:
    ans *= aa
print(int(ans))
# Judge status: Accepted
import heapq

n, m = map(int, input().split())
A = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(A)
for _ in range(m):
    tmp = heapq.heappop(A)
    tmp = int((-tmp / 2) // 1)
    heapq.heappush(A, -tmp)
print(-sum(A))
# Judge status: Wrong Answer
n = int(input())

lis = []

for i in range(n):
  lis.append(list(map(int,input().split())))

lis.append([0,0,0])

first = 0

for val in range(len(lis)-1):

  a = lis[val].index(max(lis[val]))

  lis[val+1][a]=0

  first += max(lis[val])

  
print(first)
# Judge status: Wrong Answer
import itertools
N = int(input())
motoS = input()
S = list(motoS)
gr = itertools.groupby(S)
ls = []
for key,group in gr:
    ls.append(len(list(group)))
if S[0] == ')':
    ls.insert(0,0)
if S[-1] == '(':
    ls.append(0)
start = 0
end = 0
for i in range(len(ls)//2):
    if ls[2*i+1] - ls[2*i] >= 0:
        start += ls[2*i+1] - ls[2*i]
    if ls[2*i+1] - ls[2*i] <= 0:
        end += ls[2*i] - ls[2*i+1]
print('('*start+motoS+')'*end)
# Judge status: Accepted
n=int(input())
P=list(map(int,input().split()))
M = P[0]
ans = 1
for p in P[1:]:
  if p <= M:
    ans+=1
    M=p
print(ans)
# Judge status: Wrong Answer
r,g,b = map(int,input().split())
if (100*r+10*g+b) % 4 ==0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
o = input()
e = input()
n = len(o)
m = len(e)
st = [0]*(n+m)
for i in range(0,n):
  try:
    st[i*2]=o[i]
  except:
    pass
  try:
    st[i*2+1]=e[i]
  except:
    pass
string = "".join(map(str,st)) 
print(string)
# Judge status: Accepted
A,B,C,K = map(int, input().split())

ans = B-A
if abs(ans) > 10**18:
    ans = "Unfair"
elif K%2 == 0:
    ans *= -1
print(ans)
# Judge status: Wrong Answer
import bisect
N, M = map(int,input().split())
al = list(map(int,input().split()))
al.sort()
print(al)

for _ in range(M):
    x = al.pop()
    bisect.insort(al, x//2)

print(sum(al))
# Judge status: Accepted

def main():
    D, T, S = list(map(int, input().split()))
    if S * T >= D:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
# Judge status: Accepted
h=int(input())
w=int(input())
n=int(input())
import math
print(math.ceil(n/max(h,w)))
# Judge status: Accepted
n,k=[int(_) for _ in input().split()]
p=[int(_) for _ in input().split()]

p.sort()

print(sum(p[:k]))
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
X=[]
count = 0
for i in range(N):
  if A[i]%2==0:
    if A[i]%3==0 or A[i]%5==0:
      count+=1
if count > 0:
  print("DENIED")
else:
  print("APPROVED")
# Judge status: Wrong Answer
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
ans = 100000
count = 0
for i in range(n):
    ch = abs(a - (t - h[i]*6/1000))
    if abs(ans-a) > ch:
        ans = ch
        count = i+1
print(count)
# Judge status: Accepted
import sys
# input = sys.stdin.buffer.readline
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

S = input()
n = len(S)

def kaibun(s):
    n = len(s)
    for i in range(n//2):
        if s[i] != s[-1-i]:
            return False
    return True

if kaibun(S) and kaibun(S[:n//2]) and kaibun(S[n//2+1:]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=int(input())
S=list()
for i in range(N):
  S.append(input())
M=int(input())
T=list()
for i in range(M):
  T.append(input())
ans=0
for i in S:
  v=S.count(i)-T.count(i)
  if v>ans:
    ans=v
print(ans)
# Judge status: Accepted
c = input()
if  c in 'aeiou':
  print('vowel')
else:
  print('consonant')
# Judge status: Wrong Answer
N,M=list(map(int, input().split()))
A=list(map(int, input().split()))
ans=sum(A)
if N<ans:
    print('-1')
else:
    print(M-ans)
# Judge status: Accepted
N,M = map(int,input().split())
ls = []
for i in range(M):
    P,Y = map(int,input().split())
    ls.append([P,Y,i])
ls.sort()
num = 1
city = ls[0][0]
for i in range(M):
    if ls[i][0] == city:
        ls[i][1] = num
        num += 1
    else:
        num = 1
        ls[i][1] = num
        city = ls[i][0]
        num += 1
ls.sort(key=lambda x:x[2])
for i in range(M):
    print('{0:06d}'.format(ls[i][0])+'{0:06d}'.format(ls[i][1]))
# Judge status: Accepted
s=input()
if int(s[6])<5 and int(s[5])==0:
    print("Heisei")
else:
    print("TBD")
# Judge status: Accepted
s = input()
head = int(s[:2])
tail = int(s[2:])

is_mmyy = False
is_yymm = False

if 1 <= head <= 12:
    is_mmyy = True

if 1 <= tail <= 12:
    is_yymm = True

if is_yymm and is_mmyy:
    print('AMBIGUOUS')
elif is_yymm:
    print('YYMM')
elif is_mmyy:
    print('MMYY')
else:
    print('NA')
# Judge status: Wrong Answer
n = int(input())
print(n*800-n%15*200)
# Judge status: Accepted
from heapq import heappush, heappop
N, M = map(int, input().split())
D = {i+1: [] for i in range(M)}
for _ in range(N):
  A, B = map(int, input().split())
  if A <= M:
    D[A].append(B)
rew = 0
pq = []
for i in range(M):
  for j in D[i+1]:
    heappush(pq, -j)
  if pq != []:
    rew += -heappop(pq)
print(rew)
# Judge status: Wrong Answer
a, b = map(int, input().split())

n = abs(a-b)
print("IMPOSSIBLE" if n&1 else n)
# Judge status: Accepted
n, m = list(map(int, input().split()))

redball = [0]*n
redball[0] = 1
ball_cnt = [1]*n

for _ in range(m):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1

    if ball_cnt[x] == 1 and redball[x] == 1:
        redball[x] = 0
        redball[y] = 1

    if ball_cnt[x] > 1 and redball[x] == 1:
        redball[y] = 1

    ball_cnt[x] -= 1
    ball_cnt[y] += 1

print(redball.count(1))
# Judge status: Accepted
s = input()
length = len(s)
count = 0
count_large = 0
sep = s[2:length-1]


if s[0] == 'A':
    count += 1

if sep.count('C') == 1:
    count += 1

for i in range(length):
    if s[i].isupper():
        count_large += 1
        
if count_large == 2:
    count += 1

if count == 3:
    print('AC')
else:
    print('WA')
# Judge status: Accepted
n=int(input())
w=[int(x) for x in input().split()]


m = 5000
l=[]
r=[]

for i in range(n-1):
    t = i+1
    l=w[0:t]
    r=w[t:n]  
    if abs(sum(l)-sum(r)) < m:
        m=abs(sum(l)-sum(r))
print(m)
# Judge status: Accepted

def main():
    x, y = map(int, input().split())
    print(x + int(y * 0.5))


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
def fl(x):
    digits = 8
    form = '%.'+str(digits-1)+'e'
    return float((form % x))
a,b,x=map(int,input().split())
import math
if x==b*a**2:
    print(0)
else:
    if x >= a * b / 2:
        print(90 - math.degrees(math.atan(fl(a / 2 / (b - fl(x / a ** 2))))))
    else:
        tate = fl(2 * x / a / b)
        print(90 - math.degrees(math.atan(fl(tate / b))))
# Judge status: Accepted
N = int(input())
S = input()

cr = 0
cl = 0

for i in range(N):
    if S[i] == '(':
        cr += 1
    else:
        if cr > 0:
            cr -= 1
        else:
            cl += 1
print('('*cl+S+')'*cr)
# Judge status: Wrong Answer
import math
n=int(input())
a=list(map(int,input().split()))

g=a[0]
t=1
ch=0
for x in range(1,n):
  y=math.gcd(g,a[x])
  g=y
  s=g//y
  
  if t<s:
    t=s
    ch=x
G=a[0]    
for z in range(1,n):
  if z!=ch:
    G=math.gcd(G,a[z])
    
W=a[1]
if n>2:
  for t in range(2,n):
    W=math.gcd(W,a[t])
    
print(max(W,G))
# Judge status: Wrong Answer
n = int(input())
a = n//11
b = n%11
if b == 0:
    print(2*a)
elif b <= 5:
    print(2*a+1)
elif b <= 10:
    print(2*a+2)
# Judge status: Accepted
n, m = map(int, input().split())
l = []
ans = 1
if(n%m == 0):
  ans=0
else:
  for x in (0,1000000000000000000):
    n = abs(n%m)
    l.append(n)
  l.sort()
  ans = min(m-n,l[0])
print(ans)
# Judge status: Wrong Answer
h, a = map(int, input().split())
print((h + a - 1) / a)
# Judge status: Accepted
n = int(input())
x = list(range(n))
for i in range(n):
  x[i] = input()
c_0 = x.count("AC")
c_1 = x.count("WA")
c_2 = x.count("TLE")
c_3 = x.count("RE")
print("AC x {}".format(c_0))
print("WA x {}".format(c_1))
print("TLE x {}".format(c_2))
print("RE x {}".format(c_3))
# Judge status: Accepted
#!/usr/bin/env python3

#!/usr/bin/env python3

N, D = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
cnt = 0

def dist(X,i,j):
    dist = 0
    for k in range(D):
        dist += (X[i][k] - X[j][k]) **2
    dist = dist ** 0.5
    return dist.is_integer()

for i in range(N):
    for j in range(N):
        if i >= j :
            continue
        else:
            if dist(X,i,j):
                cnt += 1

print(cnt)
# Judge status: Accepted
n,k = map(int, input().split())
if n%k == 0:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
l=[int(i) for i in range(a,b+1)]
l1=sorted(l,reverse=True)
ans=[]
if k>len(l):
    for a in l:
        print(a)
else:
    for i in range(0,k):
        ans.append(l[i])
    for j in range(0,k):
        ans.append(l1[j])
    ans=set(sorted(ans))
    for g in ans:
        print(g)
# Judge status: Accepted
s = input()
i = 0
c = 0
while i < (len(s) - 1) * 0.5:
    if s[i] != s[len(s) - 1 - i]:
        c += 1
    i += 1
print(c)
# Judge status: Accepted
X = int(input())
if 360 % X == 0:
  ans = int(360 / X)
else:
  import math
  kaku = (360 * X) / math.gcd(360, X)
  ans = int(kaku / X)
print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
from fractions import gcd
from functools import reduce

n,m,*alst = list(map(int,read().split()))
mm=2*m
def lcm(x,y):
  g=gcd(x,y)
  if x//g %2==0 or y//g%2==0:
    return 0
  g=x*y//g
  if g>mm:
    return 0
  return g
f=lambda x,y:0 if x==0 else lcm(x,y)
g=reduce(f,alst)
if g==0:
  print(0)
  quit()
else:
  res=(mm//g)
  print(res//2+res%2)
# Judge status: Accepted
import math

R = int(input())

print(2 * math.pi * R)
# Judge status: Accepted
N,H = map(int,input().split())
ls = []
for i in range(N):
    a,b = map(int,input().split())
    ls.append([a,b])
ls.sort()
ls.sort(key=lambda x:-x[0])
mainkatana = ls.pop(0)
ls.sort(key=lambda x:-x[1])
ls.append([0,0])
ii = 0
while ls[0][1] >= mainkatana[0] and H > mainkatana[1]:
    ii += 1
    nage = ls.pop(0)
    H -= nage[1]
cut = max(0,-(-(H-mainkatana[1])//mainkatana[0]))
ii += cut
if H > 0:
    ii += 1
print(ii)
# Judge status: Accepted
n = int(input())
s = input()
ss = list(s)[::-1]

white = 0
black = 0
w = [0] * n
b = [0] * n

for i in range(n):
    if s[i] == '#':
        black += 1
    if ss[i] == '.':
        white += 1
    b[i] = black
    w[-i-1] = white

ans = 10**9

for i in range(n):
    if b[i] + w[i] < ans:
        ans = b[i] + w[i]

print(ans-1)
# Judge status: Accepted
n=int(input())
a=[int(input()) for _ in range(n)]
ans=0
for i in range(n):
    ans+=a[i]//2
    a[i]=a[i]%2
    if i<n-1 and a[i]>0 and a[i+1]>0:
        a[i]=0
        a[i+1]-=1
        ans+=1
print(ans)
# Judge status: Accepted
N = int(raw_input())
A = map(int, raw_input().split())

ans = "APPROVED"
for i in range(N):
    if A[i]%2 == 0:
        if A[i]%3 != 0 and A[i]%5 != 0:
            ans = "DENIED"

print ans
# Judge status: Accepted
s = list(input())
t = list(input())
t.pop(-1)
if s==t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, m = [int(_) for _ in input().split()]
student = [[int(x) for x in input().split()] for i in range(n)]
check = [[int(x) for x in input().split()] for i in range(m)]
for s in student:
  d = 10**12
  i = -1
  for ii, c in enumerate(check, 1):
    dd = abs(s[0] - c[0]) + abs(s[1] - c[1])
    if dd < d:
      d = dd
      i = ii
  print(i)
# Judge status: Accepted
a,b,c = map(int,input().split())
print(max(0,c-a+b))
# Judge status: Accepted
N=int(input())
for i in range(N):
    if N<=2:
        print(1)
        break
    if i*i>N:
        print((i-1)*(i-1))
        break