peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
X,K,D = map(int,input().split())
X=abs(X)
q=X//D
mod=X%D

if q <= K:
    if (K-q)%2==0:
        ans=mod
    else:
        ans=D-mod
else:
    ans=X-K*D
print(ans)
# Judge status: Accepted
N, A, B = list(map(int, input().split()))

cnt = A * (N//(A+B))
x =  N % (A+B)
if x > A:
    cnt += A
else:
    cnt += x
    
print(cnt)
# Judge status: Accepted
N,K = map(int,input().split())
H = list(map(int,input().split()))
R = sorted(H)
m = N - K 

a = R[0 : m]
point = sum(a) 
if K >= N :
    point = 0
print(point)
# Judge status: Accepted
x,y=list(map(int, input().split()))

a={1,3,5,7,8,10,12}
b={4,6,9,11}

if x in a and y in a or x in b and y in b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a = list(map(int,input().split()))

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

print(len(set(prime_factorize(a[0])) & set(prime_factorize(a[1])))+1)
# Judge status: Accepted
[n,m] = [int(i) for i in input().split()]
if n == 1:
    print(m)
else:
    ans = -1
    #a1は高々この値
    a1_max = m // n
    for i in range(a1_max,0,-1):
        if (m - i) % i == 0 and (m - i)//i >= (n-1):
            ans = max(ans,i)
    print(ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a > b:
    print(c - (a - b))
else:
    print(c)
# Judge status: Accepted
s = list(input())
K = int(input())

for i in range(len(s)):
    if s[i] == "a":
        continue
    d = ord("z")-ord(s[i]) + 1
    if d <= K:
        s[i] = "a"
        K -= d

x = (ord(s[-1])-ord("a")+K)%26
s[-1] = chr(ord("a")+x)
print("".join(s))
# Judge status: Accepted
N = int(input())
def cnt_div(n):
    cnt = 0
    for i in range(1,n+1):
        if i*i>n:break
        if n%i==0:
            cnt+=1
            if n//i!=i:
                cnt+=1
    return cnt
cnt = 0
for i in range(1,N+1):
    if i%2==1 and cnt_div(i)==8:
        cnt+=1
print(cnt)
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
K=int(input())
flag = 0
for k in range(K):
    if B*(k+1)*2>A:
        Bnew=B*(k+1)*2
        newK = K - k - 1
        for newk in range(newK):
            if C * (newk + 1) * 2 > Bnew:
                print('Yes')
                flag=1
                break
        break

if flag == 0:
    print('No')
# Judge status: Accepted
from bisect import bisect_left

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        idx = bisect_left(L, a + b)
        ans += idx - 1 - j
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
# input = sys.stdin.r/eadline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

def main():
    N = INT()
    A = LI()
    A.sort()
    answer = 0
    for i in range(N):
        answer += A[N+2*i]
    print(answer)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from collections import deque

S = input()
Q = int(input())

cur = 1
d = deque([S])

for _ in range(Q):
    xs = input().split()

    if len(xs) == 1:
        cur = 2 if cur == 1 else 1
    else:
        _, f, c = xs
        if f == cur == 1 or f == cur == 2:
            d.append(c)
        else:
            d.appendleft(c)

if cur == 1:
    ans = "".join(d)
else:
    d.reverse()
    ans = "".join(d)

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
x = list(map(int , input().split()))

#from bisect import bisect_left

#p0 = bisect_left(x, 0)
#x[p0] == 0
ans = 10 ** 10
for i in range(n-k+1):
    ans = min(ans, abs(x[i]) + abs(x[i+k-1] - x[i]))
    ans = min(ans, abs(x[i+k-1]) + abs(x[i+k-1] - x[i]))
    #print(i, i+k-1, ans)
print(ans)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
cnt1,cnt2,cnt4=0,0,0
for i in A:
  if i%2!=0:
    cnt1+=1
  elif i%2==0 and i%4!=0:
    cnt2+=1
  else:
    cnt4+=1
if cnt2==0:
  if cnt4>=cnt1+1:
    print('Yes')
    exit()    
else:
  if cnt4>=cnt1:
    print('Yes')
    exit() 
print('No')
# Judge status: Wrong Answer
S = input()

answer = S[0:2] + "8" + S[4:9]

print(answer)
# Judge status: Wrong Answer
alphabet = 'abcdefghijklmnopqrstuvwxyz'
s = input()
K = int(input())
ans = ''
for i in range(len(s) - 1):
    s_i = alphabet.index(s[i])
    if s_i == 0:
        continue
    elif 26 - s_i < K:
        K -= 26 - s_i
        s_i = 0
    ans += alphabet[s_i]
s_i = (alphabet.index(s[-1]) + K) % 26
ans += alphabet[s_i]
print(ans)
# Judge status: Accepted
n, c, k = map(int, input().split())
t = sorted(int(input()) for _ in range(n))
cnt = 0
bus_people = 0
bus_time = 0
for i in range(n):
    if bus_people >= c or t[i] > bus_time:
        bus_people = 1
        bus_time = t[i] + k
        cnt += 1
    else:
        bus_people += 1
print(cnt)
# Judge status: Accepted
from functools import lru_cache
MOD = 10**9+7
x,y = map(int, input().split())
summ = x+y

@lru_cache(maxsize=None)
def inv(n):
    return pow(n,-1,MOD)

if summ%3 == 0 and summ//3 <= x and summ//3 <= y:
    mn = min(x,y)
    n = mn - summ//3
    a = summ//3
    b = 1
    ans = 1
    for i in range(n):
        ans *= a
        ans *= inv(b)
        ans %= MOD
        a -= 1
        b += 1
    print(ans)
else:
    print(0)
# Judge status: Accepted
a = int(input())
b = int(input())
c = 6 - a - b

print(c)
# Judge status: Wrong Answer
n, m = map(int, input().split())


if n > m // 4:
    print(n + (m - 2 * n) // 4)
else:
    print(m // 4 + min(n, m % 4 // 2))
# Judge status: Accepted
# 各日について満足度の一番高いコンテストを選択する貪欲
def main():
    import sys
    import numpy as np
    D=int(sys.stdin.readline())
    S=np.zeros((D,26))
    C=np.array(map(int,sys.stdin.readline().split()))
    for i in range(D):
        S[i]=list(map(int,sys.stdin.readline().split()))
    
    for i in range(D):
        print(np.argmax(S[i])+1)

main()
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    ans=0
    cnt=0
    for i in reversed(range(N)):
        p,mod=divmod(A[i]+cnt,B[i])
        if mod==0:
            continue
        else:
            cnt+=B[i]-mod
    print(cnt)







resolve()
# Judge status: Accepted
ans=1
n=int(input())
for i in range(1,n+1):
    ans*=i
    ans=ans%(10**9+7)
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

s = input()
ans = 753
for i in range(len(s) - 3):
    num = int(s[i:i+3])
    ans = min(ans, abs(num - 753))
print(ans)
# Judge status: Accepted
import fractions

A,B,C,D = map(int,input().split())
l = C*D // fractions.gcd(C,D)
x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l
y = B - B//C - B//D + B//l
print(y-x)
# Judge status: Accepted
l,r=map(int,input().split())
for i in range(l,r+1):
  if i%2019==0:
    print(0)
    break
else:
  mini=2018
  for i in range(l,r):
    for j in range(i+1,r+1):
      if (i*j)%2019<=mini:
        mini=(i*j)%2019
  print(mini)
# Judge status: Accepted
n, m = map(int, input().split())
root = [[False]*n for _ in range(2)]

for i in range(m):
    a, b = map(int, input().split())
    if a==1:
        root[0][b-1] = True
    if b==n:
        root[1][a-1] = True
for j in range(n):
    if root[0][j]:
        if root[1][j]:
            print('POSSIBLE')
            exit(0)
print('IMPOSSIBLE')
# Judge status: Accepted
weather={"Sunny":"Cloudy","Cloudy":"Rainy","Rainy":"Sunny"}
print(weather[input()])
# Judge status: Wrong Answer
N = int(input())
risuto = []
while N != 0:
    if N%26 == 0:
        risuto = [26] + risuto
    else:
        risuto = [N%26] + risuto
    if N % 26 == 0 and N // 26 == 1:
        break
    N //= 26
ans = ""
print(risuto)
for i in risuto:
    ans += "abcdefghijklmnopqrstuvwxyz"[i-1]
print(ans)
# Judge status: Accepted
import math
x, y = map(int,input().split())

l = 0
while x <= y:
    l += 1
    x = 2*x

print(l)

# なぜWA?
# print(int(math.log2(int(y/x)) + 1))
# Judge status: Wrong Answer
def main():
    n = int(input())
    s = list(input().split())

    ans = 0
    now = 0
    for i, i_d in enumerate(s):
        if i_d == 'I':
            now += 1
            ans = max(ans, now)
        else:
            now -= 1

    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Accepted
n,k = map(int,input().split())
h = list(map(int,input().split()))

dp = [0,abs(h[1]-h[0])]
for i in range(2,n):
    u = []
    for j in range(1,min(i,k)+1):
        u.append(dp[i-j]+abs(h[i]-h[i-j]))
    dp.append(min(u))

print(dp[n-1])
# Judge status: Accepted
n=int(input())
s=input()
w_right=s.count(".")
b_left=0
ans=w_right
for i in range(n):
  if s[i]=="#":
    b_left+=1
  else:
    w_right-=1
  ans=min(ans,w_right+b_left)
print(ans)
# Judge status: Accepted
n=int(input())
a,b=2,1
for i in range(n-1):
  a,b=b,(a+b)
print(b)
# Judge status: Accepted
N = input()
n = 0
for i in range(1,len(N)):
	if(N[i] == "9"):
		n+=1
if(n==len(N)-1):
	print(int(N[0]) + (len(N)-1)*9)
else:
	print(int(N[0]) - 1 + (len(N)-1)*9)
# Judge status: Wrong Answer
s = list(input())
t = list(input())

s.sort()
t.sort()
flag = True

for i in range(len(s)):
    s.insert(0,s.pop(-1))
    if "".join(s) == "".join(t):
        print("Yes")
        flag = False
        break



if flag:
    print("No")
# Judge status: Accepted
def main():
  n, y = map(int, input().split())
  for i in range(n + 1):
    for j in range(n + 1 - i):
      z = n - i - j
      if i * 10000 + j * 5000 + z * 1000 == y:
        print(i, j, z)
        exit()
  print('-1 -1 -1')
  
if __name__ == '__main__':
  main()
# Judge status: Accepted
N, M, K = map(int, input().split())

for n in range(N + 1):
    for m in range(M + 1):
        if K == (N - n) * m + (M - m) * n:
            print('Yes')
            exit()

print('No')
# Judge status: Accepted
ss = input()
zero = 0
one = 0
for s in ss:
    if s == "0":
        zero += 1
    elif s == "1":
        one += 1
print(2 * min(zero, one))
# Judge status: Accepted
from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))
# Judge status: Wrong Answer
n = int(input())
x = n % 1000
if x == 0:
    print(x)
print(1000 - x)
# Judge status: Accepted
N,K = map(int, input().split())
A = [*map(lambda x:int(x)-1, input().split())]
index = [-1]*N
path = []
pre = 0
while index[pre] < 0:
    index[pre] = len(path)
    path += [pre]
    pre = A[pre]
one = index[pre]
loops = len(path) - one

k = max(0, K-one) % loops + min(K, one)
pre = 0
for _ in range(k): pre = A[pre]
print(pre + 1)

# if K <= one: print(path[K])
# else: print(path[(K-one) % loops + one]+1)
# Judge status: Accepted
i=int(input())
if(0<i and i<10):
    cnt1=i
    print(cnt1)
if(10<=i and i<100):
    print(9)
if(100<=i and i<1000):
    cnt2=i-99+9
    print(cnt2)
if(1000<=i and i<10000):
    print(909)
if(10000<=i and i<100000):
    cnt3=i-9999+999-99+9
    print(cnt3)
if(i==100000):
    print(90909)
# Judge status: Accepted
n,b = map(int,input().split())
if n >= 13:
  print(b)
elif n <= 5:
  print(0)
else:
  print(b//2)
# Judge status: Accepted
from operator import itemgetter
N=int(input())
tasks=[list(map(int,input().split())) for _ in range(N)]
tasks.sort(key=itemgetter(1))
t=0
for w,l in tasks:
    if t+w>l:
        print('No')
        exit()
    t+=w
print('Yes')
# Judge status: Accepted
a=int(input())
print("Christmas"+" Eve"*(25-a))
# Judge status: Accepted
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b = map(int, input().split())
    r = 0
    for i1 in range(a, b + 1):
        c1 = i1 // 10000 == i1 % 10
        c2 = ((i1 // 1000) % 10) == ((i1//10)%10)
        r += c1 and c2
    print(r)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
A,B=map(int,input().split())
sampleA=A*100/8
sampleB=B*10
sampleA=int(sampleA)
sampleB=int(sampleB)
ans=[]
for i in range(max(sampleA,sampleB),max(sampleA,sampleB)+10):
    if int(i*8/100)==A and int(i*0.1)==B:
        ans.append(i)
        break
    else:
        ans.append(-1)
print(min(ans))
# Judge status: Accepted
import sys
import heapq
N,M=map(int,input().split())
alist=list(map(int,input().split()))

cblist=[]
for i in range(M):
  B,C=map(int,input().split())
  cblist.append((C,B))
cblist.sort(reverse=True)

hq=[]
for a in alist:
  heapq.heappush(hq,a)
  
for C,B in cblist:
  for i in range(B):
    if C<=hq[0]:
      print(sum(hq))
      sys.exit(0)
    else:
      heapq.heapreplace(hq,C)
else:
  print(sum(hq))
# Judge status: Accepted
s = int(input())
a, b = s // 100, s % 100
x = "YY" if a == 0 or a > 12 else "MM"
y = "YY" if b == 0 or b > 12 else "MM"
if x != y:
    print(x + y)
else:
    print("NA" if x == "YY" else "AMBIGUOUS")
# Judge status: Accepted
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))

if n >= m:
  print(0)
  quit()
  
x.sort()
y = [x[i]-x[i-1] for i in range(1, m)]
y.sort(reverse = True)
ans = sum(y)

for i in range(n-1):
  ans -= y[i]
  
print(ans)
# Judge status: Wrong Answer
import sys

s = str(input())
ans = ""

for i in range(0,len(s)):
  if s[i] == "A":
    for j in range(i,len(s)):
      if s[j] != "Z":
        ans = ans +s[j]
      else:
        ans = ans + "Z"
        print (len(ans))
        sys.exit()
# Judge status: Wrong Answer
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
ans=0

for x in range(1,n+1):
  a1sum=sum(a1[0:x+1])
  a2sum=sum(a2[x:n+1])
  ans=max(ans,a1sum+a2sum)
  
print(ans)
# Judge status: Accepted
import sys
N=int(input())
l=[int(x) for x in input().split()]
l1=[sys.maxsize]*(N)
l1[0]=0
for i in range(N):
    for j in range(i+1,i+3):
        if j<N:
            l1[j]=min(l1[j],l1[i]+abs(l[j]-l[i]))
print(l1[N-1])
# Judge status: Accepted
x=int(input())
ans=(x//11)*2
if x%11==0:
  print(ans)
elif x%11<=6:
  print(ans+1)
else:
  print(ans+2)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import *

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

if A<=C<=B:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

l = [20, 11, 9, 24]
total = 0
for i in l:
  total ^= i
ans=[]
for i in l:
  ans.append(total^i)
print(*ans)
# Judge status: Wrong Answer
s,w = map(int, input().split())

if w >= s is True:
	print("unsafe")
else:
	print("safe")
# Judge status: Wrong Answer
k = int(input())
q = [1,2,3,4,5,6,7,8,9]

for i in range(k):
	x = q.pop(0)
	if x%10 != 0:
		q.append(10*x + (x%10) -1)
	q.append(10*x + (x%10))
	if x%9 != 0:
		q.append(10*x + (x%10) +1)
		
print(x)
# Judge status: Accepted
D,N=map(int, input().split())
m=0
for i in range(1, 10**10):
    c=0
    n=i
    while i%100==0:
        i//=100
        c+=1
    if c==D:
        m+=1
        if m==N:
            print(n)
            exit()
# Judge status: Accepted
a, b, c = map(int, input().split())
if a + b + c >= 22:
  print('bust')
else:
  print('win')
# Judge status: Accepted
from collections import Counter
X = open(0).readlines()
n = int(X[0])
*A, = map(int, X[1].split())
counter = Counter(A)
q = int(X[2])
s = sum(A)
for x in X[3:]:
    b, c = map(int, x.split())
    if b in counter:
        t = counter.pop(b)
        s += c*t - b*t
        counter[c] = counter.get(c, 0) + t
    print(s)
# Judge status: Accepted
def main():
    n = list(input())
    ans = max(int(n[0])-1 + 9*(len(n)-1), int(n[0]), sum(map(int, n)))
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import math

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())


minmove = min([a, b, c, d, e])

ans = math.ceil(n/minmove) + 4

print(ans)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
ll=[]
for i in range(n):
    ll.append([l[i],i+1])
    
ll=sorted(ll)
ans=[]
for j in range(n):
    ans.append(ll[j][1])

print(*ans)
# Judge status: Accepted
from itertools import accumulate

N = int(input())
lst = list(map(int, input().split()))

cumsum = list(accumulate(lst))

mi = 2 * 10 ** 9
su = cumsum[-1]
for i in range(len(cumsum)-1):
  mi = min(mi, abs(cumsum[i] - (su-cumsum[i])))
print(mi)
# Judge status: Accepted
s,t = input().split()
print(t+s)
# Judge status: Accepted
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)
# Judge status: Accepted
import fractions
a,b,c,d=map(int,input().split())
nc=b//c-(a+c-1)//c+1
nd=b//d-(a+d-1)//d+1
cd=c*d//fractions.gcd(c,d)
ncd=b//cd-(a+cd-1)//cd+1
print(b-a+1-(nc+nd-ncd))

# math.ceil(a/b)->(a+b-1)//b
# Judge status: Accepted
s = input()
t = input()
 
ans = 10000
for i in range(len(s) - len(t) + 1):
  tmp = 0
  for j in range(len(t)):
    if s[i + j] != t[j]:
      tmp+=1
  ans = min(ans, tmp)
print(ans)
# Judge status: Accepted
n = int(input())
a = int(input())

if n % 500 <= a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import sys
n = int(input())
pos = [list(map(int,input().split())) for p in range(n)]
for i in range(len(pos)):
  if i == 0:
    if pos[i][1]+pos[i][2] != pos[i][0]:
      print("No")
      sys.exit()
  else:
    diff = pos[i][0]-pos[i-1][0]
    num = abs(pos[i][1]-pos[i-1][1]) + abs(pos[i][2]-pos[i-1][2])
    if num <= diff and diff * (diff%2) == num%2:
      pass
    else:
      print("No")
      sys.exit()      
print("Yes")
# Judge status: Accepted
import numpy as np

D=int(input())
*c,=map(int,input().split())
c=np.array(c,dtype=int)
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

s=np.array(s,dtype=int).reshape((D,26))
dt=[]
cnt=np.array([0]*26)

for d in range(D):
    y=np.argmax(c*(d-cnt))
    cnt[y]=d+1
    dt.append(y+1)

for i in dt:
    print(i)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b,c=0,0
for i in a:
    if i%4==0:
        b+=1
    elif i%2==0:
        c+=1
if b+c/2.01>=(len(a)-1)/2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a=input().split(" ")
x1=""
x2=""

for j in range(int(a[0])):
    x1=x1+a[0]

for y in range(int(a[1])):
    x2=x2+a[1]

z1=int(x1)
z2=int(x2)

if x1>x2:
	print(x1)
elif x1<x2:
	print(x2)
else:
	print(x1)
# Judge status: Accepted
from itertools import combinations

N, M, X = map(int, input().split())
books = []
for _ in range(N):
	C, *l = map(int, input().split())
	books.append((C, l))

best = None
for bs in range(1, 2 ** N):
	lev = [0] * M
	pri = 0
	for j in range(N):
		if bs & (1 << j) == 0: continue
		pri += books[j][0]
		for k, v in enumerate(books[j][1]):
			lev[k] += v
	if all(v >= X for v in lev):
		if best is None or pri < best:
			best = pri
print(-1 if best is None else best)
# Judge status: Wrong Answer
x, a, b=map(int, input().split())
if a<=b:
  print('delicious')
else:
  if b-a<x+1:
    print('safe')
  else:
    print('dangerous')
# Judge status: Accepted
import math

x = int(input())
print(360 // math.gcd(360, x))
# Judge status: Accepted
n=int(input())
s=input()
cnt=0
ri=len(s)-1
for li,ss in enumerate(s):
  if ss=="W":
    while ri>li and s[ri]=="W":
      ri-=1
    if ri<=li:
      break
    ri-=1
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
import math

n, m = map(int, input().split())
if n==m:
    print((math.factorial(n)*math.factorial(m)*2)%1000000007)
elif abs(n)-abs(m)==1:
    print((math.factorial(n)*math.factorial(m))%1000000007)
else:
    print(0)
# Judge status: Accepted
n=int(input())

n%=10

if n==3:
 print('bon')
elif n==0 or n==1 or n==6 or n==8:
 print('pon')
else:
 print('hon')
# Judge status: Wrong Answer
N= int(input())
As = list(map(int,input().split()))
As= [a for a in As if As.count(a)==1]
As.sort()
import sys
if len(As)==0:
    print(0)
    sys.exit()
count=1
for i in range(1,len(As),-1):
    flg=True
    for j in range(i):
        if As[i]%As[j]==0:
            flg=False
            break
        if As[j]>As[i]**0.5:
            break
    if flg:
        count +=1
print(count)
# Judge status: Wrong Answer
from itertools import combinations_with_replacement

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

query = tuple(tuple(map(int, input().split())) for _ in range(Q))

ans = 0
for comb in combinations_with_replacement(range(1, 11), N):
    score = 0
    for a, b, c, d in query:
        if comb[b-1] - comb[a-1] == c:
            score += d
    ans = max(ans, score)
print(ans)
# Judge status: Wrong Answer
a,b = map(int,input().split())
A = (a+b)/2
print(A if (A*10)%2 == 0 else int(A+0.5))
# Judge status: Wrong Answer
n = int(input())
z = list(map(int, input().split()))
print('APPROVED' if (a & 1 or i % 3 == 0 or i % 5 == 0 for i in z) else 'DENIED')
# Judge status: Accepted
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()
T = [I() for _ in range(N)]

from fractions import gcd

ans = T[0]
for i in range(N-1):
    ans = (ans*T[i+1])//gcd(ans,T[i+1])

print(ans)
# Judge status: Accepted
x, a, b = map(int, input().split())
print('B' if abs(b-x) < abs(a-x) else 'A')
# Judge status: Accepted

    
S = input()
    
s = sorted(S)
if (s[0] == s[1] and s[2] == s[3]) and (s[1] != s[2]):
    print("Yes")
    
else:
    print("No")
# Judge status: Wrong Answer
n,l = map(int,input().split())
s = []
for i in range(n):
    s.append(input())
print(sorted(s))
# Judge status: Accepted
#B
import math
n, d = map(int, input().split())
x = []
for i in range(n):
    x.append(list(map(int, input().split())))
ans=0
for i in range(n):
    for j in range(i + 1, n):
        dif = 0
        for k in range(d):
            dif += abs(x[i][k] - x[j][k])** 2
        if math.sqrt(dif) % 1 == 0:
            ans += 1
print(ans)
# Judge status: Wrong Answer
a, b, m = map(int,raw_input().split())
dr = map(int,raw_input().split())
wa = map(int,raw_input().split())
xyc = [map(int,raw_input().split()) for i in range(m)]
low = 200001

for i in range(m):
    f = xyc[i][0] - 1
    d = xyc[i][1] - 1
    if low >= dr[f]+wa[d]-xyc[i][2]:
        law = dr[f]+wa[d]-xyc[i][2]

dr.sort()
wa.sort()

if law >= (dr + wa):
    print (dr + wa)
else:
    print law
# Judge status: Accepted
s=input()
if s[0]==s[1] and s[1] == s[2]:
	print('No')
else:
	print('Yes')
# Judge status: Accepted
n=int(input())

def func(start,goal,t):
    distance=abs(start[0]-goal[0])+abs(start[1]-goal[1])
    if distance<=t and (t-distance)%2==0:
        return True
    return False
now=0
can=1
start=[0,0]
for i in range(n):
    t,x,y=[int(i) for i in input().split()]
    goal=[x,y]
    if not func(start,goal,t-now):
        can=0
        break
    else:
        start=goal
        now=t

if can==1:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys
a1=sys.stdin.readline()
a2=list(a1)
b=[ord(x) for x in a2]
b.sort()
if len(a2)==4 and (b[0]>=65 and b[0]<=90) and (b[1]>=65 and b[1]<=90) and (b[2]>=65 and b[2]<=90) and (b[3]>=65 and b[3]<=90):
    if b[0]==b[1] and b[2]==b[3] and b[0]!=b[3] and b[1]!=b[2]:
        print("Yes")
    else:
        print("No")
else:
    print("Error")
# Judge status: Wrong Answer
#ABC122C 累積和
from itertools import accumulate
A = []
N, Q = map(int, input().split())
B = [0]*N
S = list(input())
ans = []
for i in range(1, N):
    if S[i-1]=='A' and S[i]=='C':
        B[i] = 1
A = list(accumulate(B))
print(A)
for j in range(Q):
    l, r = map(int, input().split())
    ans.append(A[r-1]-A[l-1])
print('\n'.join(map(str, ans)))
# Judge status: Accepted
k = int(input())
ans = 0
mod = 7
flag = 0
for i in range(10 ** 6 + 1):
    ans += 1
    if mod % k == 0:
        flag = 1
        break
    else:
        mod = (mod % k) * 10 + 7

if flag == 1:
    print(ans)
else:
    print(-1)
# Judge status: Accepted
import fractions
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))