peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from math import gcd
ans = 0
k = int(input())
for i in range(1, k+1):
  for j in range(1, k+1):
    GCD = gcd(i, j)
    for l in range(1, k+1):
      ans += gcd(GCD, l)
print(ans)
# Judge status: Wrong Answer
n,*a=map(int,open(0).read().split())
s=1
if 0 in a:
    print(0)
    exit()
for i in a:
    s*=i
    if  s > 10**18:
        print(-1)
        exit()
print(s)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
mod = 10**9 + 7
a = min(a, n-a)
b = min(b, n-b)
com = [1] * (max(a, b) + 1)
for i in range(1,len(com)):
    com[i] = (com[i-1] * pow(i, mod-2, mod) * (n-i+1)) % mod
print(pow(2, n, mod) - 1 - com[a] - com[b])
# Judge status: Accepted
import math
x=int(input())
t=100
count=0
while t<x:
    t+=math.floor(t*0.01)
    count+=1
print(count)
# Judge status: Accepted
S = input()
Q = int(input())

prefix = ''
suffix = ''
mode = 0
for _ in range(Q) :
  Query = list(input().split())
  if Query[0] == '1' :
    mode ^= 1
  else :
    _, F, C = Query
    F = int(F) - 1
    
    if mode != F :
      suffix += C
    else :
      prefix += C
      

if mode == 0 :
  print(prefix[::-1] + S + suffix)
else :
  print(suffix[::-1] + S[::-1] + prefix)
# Judge status: Accepted
import math
N=int(input())

if N<10 or N%2==1:
  print(0)
else:
  N//=10
  answer=0
  while(N>0):
    answer+=math.floor(N)
    N//=5

  print(answer)
# Judge status: Accepted
X = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0]
def solve(N):
    N = [int(c) for c in N][::-1]
    p = 0
    b = 0
    for i in range(len(N)):
        c = N[i] + b
        p += X[c]
        if c == 5:
            b = 0 if i == len(N)-1 or N[i+1] < 5 else 1
        else:
            b = c > 5
    return p + b

print(solve(input()))
# Judge status: Accepted
n = int(input())
s = [int(input()) for i in range(n)]
s.sort()
score = sum(s)
score2 = score
c=0
for i in range(n):
    if score2%10 == 0:
        score2 = score - s[i]
        c+=1
    else:
        break
if c==n:
    score2=0
print(score2)
# Judge status: Wrong Answer
li = []
s = input()
li2 = []
for i in range(4):
  li.append(int(s[i]))
n1 = 4
def func(n, t):
  if n == 1:
    if t == li[0]:
      return True
    else:
      return False
  if func(n-1, t+li[n-1]):
    li2.append('-')
    return True
  elif func(n-1, t-li[n-1]):
    li2.append('+')
    return True
  else:
    return False
if func(n1, 7):
  print("{0}{4}{1}{5}{2}{6}{3}=7".format(li[0], li[1], li[2], li[3], li2[0], li2[1], li2[2]))
  print(li2)
# Judge status: Wrong Answer
K = int(input())
a = int(K / 2)
if K % 2 == 0:
  print(a ** a)
else:
  print(a * (a + 1))
# Judge status: Accepted
n, m = list(map(int, input().split()))

pieces = min(n, m//2)
if pieces == n:
    pieces += (m-2*n)//4
print(pieces)
# Judge status: Wrong Answer
H, A = map(int,input().split())
print(H//A +1)
# Judge status: Accepted
def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors


n,m=map(int,input().split())
A=make_divisors(m)
ans=0
for i in A:
    if m%i==0 and n<=m//i:
        ans=max(ans,i)
print(ans)
# Judge status: Wrong Answer
a,b,c=map(int, input().split())
k=int(input())
s=max(a,b,c)
for i in range(k-1):
  s*=2
print(a+b+c+s)
# Judge status: Wrong Answer
from fractions import gcd

def lcm(a):
    ans = a[0]
    
    for i in range(1,len(a)):
        ans = (ans//gcd(ans,a[i]))*a[i]
    
    return ans

N = int(input())
A = tuple(map(int,input().split(" ")))
g = lcm(A)
ans = 0
mod = 10**9+7

for i in A:
    ans += (g//i)%(mod)

print(ans)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print(7)
# Judge status: Accepted
N = 1000001
a = [0]* N
input()
for x in input().split():
  a[int(x)] += 1
for i in range(1, N):
  if a[i]:
    for j in range(i + i, N, i):
      a[j] = 0
print(a.count(1))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7
ans = 0

for bit in range(60):
    m = 1 << bit
    # bit桁目のbitが立っている時の数
    c = sum(a&m for a in A) >> bit
    # bit桁目の1の合計
    ans += (c*(N-c))<<bit
    # 繰り上がりのない足し算
    ans %= mod
print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
print(n+(n-1) if n >= m else m+(m-1))
# Judge status: Wrong Answer
def resolve():
    N, K = list(map(int, input().split(" ")))
    A = list(map(int, input().split(" ")))
    i = A.index(1)
    import math
    print(math.ceil(len(A[:i])/(K-1)) + math.ceil(len(A[i+1:])/(K-1)))

if '__main__' == __name__:
    resolve()
# Judge status: Accepted
n,x=map(int,input().split())
z=list(map(int,input().split()))
z.sort()
def gcd(a,b):
    if b==0:
        return a 
    return gcd(b,a%b)
ans=abs(x-z[0])

for i in range(n-1):
    sa=z[i+1]-z[i]
    ans=gcd(sa,ans)
print(ans)
# Judge status: Wrong Answer
s = []
for l in raw_input():
	if s == 'B':
		if s:s.pop()
	else:
		s.append(l)
print ''.join(s)
# Judge status: Accepted
xs = []
for x in range(5):
    xs.append(int(input()))


def lastDigit(x):
    return x % 10


xs.sort(key=lastDigit)
# print(xs)
time = 0
first = True
for x in xs:
    if x % 10 == 0:
        time += x
    else:
        if first:
            time += x
            first = False
        else:
            time += x + 10 - x % 10
print(time)
# Judge status: Wrong Answer
import sys
input=sys.stdin.readline
N = int(input())
ans = 0
for i in range(1,N+1):
    if i%3!=0 or i%5!=0:
        print(i)
print(ans)
# Judge status: Wrong Answer
W, H, x, y = map(int, input().split())
S = W*H/2
can = 1 if x == W//2 and y == H//2 else 0

print(S, can)
# Judge status: Wrong Answer
A,B = map(int,input().split())
for i in range(101):
  if i*0.08//1 == A and i*0.1//1 == B:
    print(i)
    exit()
print(-1)
# Judge status: Wrong Answer
n = int(input())
s = input()
t = input()
t_ = t[::-1]
if s==t:
    print(n)
else:
    c,d = 0,0
    for i in range(n):
        if s[i]==t[i]:
            c += 1
        if s[i]==t_[i]:
            d += 1
    print(2*n - max(c, d))
# Judge status: Wrong Answer
S=input()
T=input()
num=0
for i in range(len(S)):
    if S[i]==T[i]:
        num+=1
    else:
        print("No")
if num==len(S):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import itertools
n=int(input())
a=[int(i) for i in input().split()]

suma=set()
for i in  itertools.combinations(a,2):
    s=sum(i)
    suma.add(s/2)

print(max(suma))
# Judge status: Accepted
A = []
for a in range(5):
  A.append(int(input()))

k = int(input())


if max(A)-min(A) > k:
  print(':(')
else:
  print('Yay!')
# Judge status: Accepted
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M = lr()
ball = [1] * (N+1) # 1-indexed
red = [True if x == 1 else False for x in range(N+1)] # 1-indexed
for _ in range(M):
    x, y = lr()
    if red[x]: red[y] = True
    ball[x] -= 1
    ball[y] += 1
    if ball[x] == 0:
        red[x] = False

answer = sum(red)
print(answer)
# 37
# Judge status: Accepted
#abc058 b
o=input()
e=input()
ans=""
for i in range(len(e)):
        ans+=o[i]
        ans+=e[i]
if len(o)-len(e)==1:
    ans+=o[-1]
print(ans)
# Judge status: Wrong Answer
N=input()

flg=0
for i in range(len(N)):
    if N[i]=='7':
        flg=1
        exit(0)
if flg!=0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
for i in range(1000000):
  if (i*(i+1))//2>=N:
    a=i
    break
pointer=a
while N>0:
  if N>=pointer:
    print(pointer)
    N-=pointer
    pointer-=1
  else:
    print(N)
    N=0
# Judge status: Accepted
A,B,H,M=map(int,input().split())

h=(H*60+M)/2
m=6*M
import math

pi=math.pi
theta=abs(h-m)*2*pi/360


ans=A**2+B**2-2*A*B*math.cos(theta)

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

#n=2
#m=5
#x=[10 ,12,1,2,14]

#n=3
#m=7
#x=[-10,-3,0,9,-100,2,17]

x.sort()
dx=[]
if n>=m:
    print(0)
else:
#    print(x)
    for i in range(len(x)-1):
        dx.append(x[i+1]-x[i])
    dx.sort()
    dxsum=sum(dx[0:m-n])
    print(dxsum)
# Judge status: Accepted
L=0
N=int(input())
for i in range(N):
  a,b=map(int,input().split())
  if a==b:
    L+=1
    if L==3:
      print("Yes")
      exit()
  else:
    L=0
print("No")
# Judge status: Wrong Answer
H,N=map(int,input().split())

A=[]
B=[]

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

DP=[1000000000]*(H+max(A)+1)


for i in range(N):
    DP[A[i]]=B[i]

for i in range(N):
    for h in range(A[i],H+max(A)+1):
        DP[h]=min(DP[h-A[i]]+B[i],DP[h])

print(min(DP[H:]))
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
aa = [(num,i) for i,num in enumerate(a)]
aa.sort()
write(" ".join(map(str, [item[1]+1 for item in aa])))
# Judge status: Wrong Answer
n = int(input())
s = input()

ANS = []
for i in range(n):
  p = 0
  A = set(s[0:i])
  B = set(s[i-1:n+1])
  for j in A:
    if j in B:
      p += 1
  ANS.append(p)
  
  
print(max(ANS))
# Judge status: Wrong Answer
N = int(input())

S = []
for i in range(N):
  S.append([input()][0])
  
S.sort()
S_set = list(set(S))
ans = [["" for i in range(2)] for i in range(len(S_set))]
n = 0
for i in range(len(S_set)):
  count = S.count(S_set[i])
  ans[i][0] = S_set[i]
  ans[i][1] = count
  if n < count:
    n = count
    
for i in range(len(S_set)):
  if ans[i][1] == n:
    print(ans[i][0])
# Judge status: Accepted
A, B, C = map(int, input().split())
if A + B + C <= 21:
  print("win")
else:
  print("bust")
# Judge status: Accepted
S=input()
s=list(S)
T=input()
t=list(T)
for i in range(len(s)):
  s.insert(0,s[-1])
  s.pop(-1)
  if s==t:
    print('Yes')
    exit()
  
print('No')
# Judge status: Wrong Answer
import itertools
import math
s =int(input())
a = s
count = 0
while a >=4:
    if a % 2 == 0:
        a /= 2
    else:
        a = 3 * a + 1
    count += 1

print(count+3)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
S = ((a+b)*c)/2
print(S)
# Judge status: Accepted
from bisect import bisect_left
n, q = map(int, input().split())
s = list(input())
L = []
for i in range(n - 1):
    if s[i] == "A" and s[i + 1] == "C":
        L.append(i)
ans = []
for i in range(q):
    l, r = map(int, input().split())
    l, r = l - 1, r - 1
    st = bisect_left(L, l)
    fi = bisect_left(L, r)
    ans.append(fi - st)

for i in ans:
    print(i)
# Judge status: Wrong Answer
import sys
import networkx as nx
n,m=map(int,input().split())
g = nx.Graph()
l = sys.stdin.readlines()
for x in l:
    g.add_edge(int(x.split(' ')[0]), int(x.split(' ')[1].strip()))
# Judge status: Wrong Answer
a = list(map(int,input().split()))

for i in range(10**4):
  if a[1]*i > a[0]:
    break
    
print(i)
# Judge status: Wrong Answer
w, h, n = [int(i) for i in input().split()]
x_list = []
y_list = []
a_list = []
left = 0
right = w
upper = h
lower = 0

for i in range(n):
	x, y, a = [int(k) for k in input().split()]
	if a == 1:
		left = x
	elif a == 2:
		right = x
	elif a == 3:
		lower = y
	elif a == 4:
		upper = y

S = (right-left)*(upper-lower)
if right-left < 0 or upper-lower < 0:
	print(0)
else:
	print(S)
# Judge status: Accepted
S = input()
a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)
        

for i in range(1, len(S)+1):
    if S[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
        
print(sum(a))
# Judge status: Accepted
# B - Golden Coins

# X
X = int(input())

kiri_happy = X // 500
inaho_happy = (X - (500 * kiri_happy)) // 5

answer = (kiri_happy * 1000) + (inaho_happy * 5)

print(answer)
# Judge status: Accepted
# 入力
a, b, c = map(int, input().split())

# 処理
if a + b == c or b + c == a or c + a == b:
    print('Yes')

else:
    print('No')


# 出力
# Judge status: Accepted
N, K = map(int, input().split())
X = list(map(int, input().split()))

a = 10**10
for left,x in enumerate(X):
  right = left + K - 1
  if right == N:
    break
  left_to_right = abs(X[left])+abs(X[right]-X[left])
  right_to_left = abs(X[right])+abs(X[right]-X[left])
  m = min(left_to_right, right_to_left)
  if a > m:
    a = m
    
print(a)
# Judge status: Accepted
N = int(input())
A = int(input())

remain = N % 500

if remain <= A:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
x = int(input())

ans = (x // 11) * 2
b = x % 11
if b > 0:
    ans += 1
    if b > 6:
        ans += 1

print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

def cal(c):
    d = [1]
    for i in range(2, c):
        if c%i == 0:
            d.append(i)
            c //= i
    return d
    
c = gcd(a, b)
d = cal(c)
print(len(d))
# Judge status: Accepted
k = int(input())

e = k // 2
o = k - e
ans = e * o
print(ans)
# Judge status: Accepted
ans = 0
tmp = 0
for s in input():
    if s == 'R':
        tmp += 1
    else:
        ans = max(ans,tmp)
        tmp = 0
print(max(ans,tmp))
# Judge status: Accepted
import sys

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

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

lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm//i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

if abs(c-a) > d:
    print('Yes')
elif abs(b-a) > d and abs(c-b) > d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = 0
for a, b in zip(A, B):
    if a > b:
        cnt -= a - b
    if a < b:
        cnt += (b - a) // 2

if cnt < 0:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
N = int(input())
A = 0
Xmin = Ymin = 1e9 + 5
Xmax = Ymax = 0
for _ in range(N):
    x, y = map(int, input().split())
    X = x + y
    Y = abs(x - y)
    Xmin = min(Xmin, X)
    Xmax = max(Xmax, X)
    Ymin = min(Ymin, Y)
    Ymax = max(Ymax, Y)
if Xmin == 1e9 + 5:
    Xmin = Xmax
if Ymin == 1e9 + 5:
    Ymin = Ymax
Z = max(Xmax - Xmin, Ymax - Ymin)
print(Z)
# Judge status: Accepted
A, B = map(int, input().split())

ans = max(A + max(A-1, B), B + max(A, B-1))

print(ans)
# Judge status: Accepted
import queue
k = int(input())
q = queue.Queue()
cnt = 0
for i in range(1,10):
    q.put(i)
while True:
    a = q.get()
    cnt += 1
    if cnt == k:
        print(a)
        break
    else:
        s = a%10
        if s != 0:
            q.put(10*a + s-1)
        q.put(10*a + s)
        if s != 9:
            q.put(10*a + s+1)
# Judge status: Wrong Answer
N=int(input())
if N % 2 == 0:
  print((N/2)/N)
else:
  print((N+1/2)/N)
# Judge status: Accepted
a, b, c = map(int, input().split())
 
if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
    print(0)
elif a == b == c:
    print(-1)
else:
    num = 0
    while (a % 2 == 0 and b % 2 == 0 and c % 2 == 0):
        a, b, c = (b+c)/2, (a+c)/2, (a+b)/2
        num += 1
    print(num)
# Judge status: Accepted
import itertools
import math
import fractions
import functools
n, t = map(int, input().split())
pair = []
for i in range(n):
    ci, ti = map(int, input().split())
    pair.append([ci, ti])

c = 1001
for i in range(n):
    if pair[i][1] <= t:
        c = min(c,pair[i][0])

if c == 1001:
    print("TLE")
else: print(c)
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
s,temp = [],0
for i in range(n):
    temp += a[i]
    s.append(temp)
sn,mi = s[n-1],2000000001
for i in range(n-1):
    snuke = s[i]
    arai = sn-s[i]
    if abs(snuke-arai)<mi:
        mi = abs(snuke-arai)
print(mi)
# Judge status: Accepted
n,x = map(int,input().split())
X = list(map(int,input().split()))

X.append(x)
X = sorted(X)

import fractions
ans = X[1] - X[0]

for i in range(n-1):
    ans = fractions.gcd(ans,X[i+2]-X[i+1])
    
print(ans)
# Judge status: Accepted
n, m = list(map(int, input().split()))

print(sum(range(n)) + sum(range(m)))
# Judge status: Wrong Answer
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

import bisect
from collections import deque
q = deque()

q.append(a[0])

for num in a[1:]:
    if num <= q[0]:
        q.appendleft(num)
    else:
        ind = bisect.bisect_left(q,num)
        if ind==len(q):
            ind-=1
        q[ind]=num

print(len(q))
# Judge status: Wrong Answer
A,B,C = (int(x) for x in input().split())

ans = B+C-A
print(ans)
# Judge status: Wrong Answer
n = int(input())

L = []
for _ in range(n):
    tmp = list(input())
    L.append(tmp)
    #L.extend(tmp)

#w = list("".join(L))
#w = list(sorted(w))

#print(L)
st = L[0]

for i in range(1,n):
    tmp = L[i]
    ans = []
    for moji in st:
        if moji in tmp:
            ans.append(moji)
            tmp.remove(moji)
    tmp = ans

tmp = list(sorted(tmp))
print("".join(tmp))
# Judge status: Accepted
S = input()

memo = []
memo.append(S[0])
p = 1

while p<len(S):
    if len(memo[-1])==2:
        memo.append(S[p])
        p += 1
    elif memo[-1]!=S[p]:
        memo.append(S[p])
        p += 1
    elif p+1==len(S):
        break
    else:
        memo.append(S[p:p+2])
        p += 2
print(len(memo))
# Judge status: Accepted
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()

for i, v in enumerate(a):
    if i % 2 == 0:
        b.append(v)
    else:
        b.appendleft(v)

if n % 2 == 1:
    b.reverse()

for num in b:
    print(num, end=' ')
print()
# Judge status: Accepted
s,t = input().split()
a,b = map(int,input().split())
u = input()

if s == u:
    print(a-1,b)
else:
    print(a,b-1)
# Judge status: Accepted
n = int(input())
abc = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
dp[0] = abc[0]
for i in range(n - 1):
    dp[i + 1][0] = max(dp[i][1], dp[i][2]) + abc[i + 1][0]
    dp[i + 1][1] = max(dp[i][0], dp[i][2]) + abc[i + 1][1]
    dp[i + 1][2] = max(dp[i][0], dp[i][1]) + abc[i + 1][2]
print(max(dp[-1]))
# Judge status: Accepted
N = int(input())
S = []
for i in range(N):
    S.append(input())



www = "YYY"
for i in range(N-1):
    if S[i][-1] != S[i+1][0]:
        www = "fuck"

qqq = "ZZZ"
S.sort()
for i in range(N-1):
    if S[i] == S[i+1]:
        qqq = "bich"

if www == "YYY" and qqq == "ZZZ":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()

if s.isupper():
    print("A")
else:
    print("b")
# Judge status: Accepted
T = input()
L = [chr(l) for l in range(ord("a"), ord("z")+1)]
L = [l for l in L if l not in T]
print(min(L) if len(L)>0 else "None")
# Judge status: Accepted
def main():
    abcd = list(map(int, input().split()))
    aok = (abcd[2]-1) // abcd[1]
    tac = (abcd[0]-1) // abcd[3]
    print('Yes' if tac >= aok else 'No')

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

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

temp = list(combinations([i for i in range(1,m+1)],n))


ans = 0

for a_temp in temp:
    ans_temp = 0
    for i in range(q):
        if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]:
            ans_temp += a[i][3]
    if ans < ans_temp:
        ans = ans_temp
print(ans)
# Judge status: Wrong Answer
n,m = map(int, input().split())
from_start = []
to_end = []

for _ in range(m):
  temp = []
  temp = list(map(int, input().split()))
  if temp[0]==1:
    from_start.append(temp[1])
  elif temp[1]==n:
    to_end.append(temp[0])
else:
  print(from_start)
  print(to_end)
  for i in from_start:
    if i in to_end:
      print('POSSIBLE')
      break
  else:
    print('IMPOSSIBLE')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

num = 0
a.sort(reverse=True)
i = 1
j = 0
while j < n:
    num += a[i]
    i += 2
    j += 1
print(num)
# Judge status: Accepted
a = [int(input()) for _ in range(5)]

maxv = 0
b = 4
for i in range(5):
    if maxv < 10 - (a[i]%10) and a[i] % 10 != 0:
        maxv, b = 10 - (a[i]%10), i

ans = 0

for i in range(5):
    if i != b:
        ans += a[i]

    if ans % 10 != 0:
        for j in range(10):
            ans += 1
            if ans % 10 == 0:
                break

ans += a[b]
print(ans)
# Judge status: Accepted
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
xyc = [list(map(int,input().split())) for i in range(m)]

a_m = min(a)
b_m = min(b)
ans = a_m + b_m

for i in range(m):
    a_i = xyc[i][0] - 1
    b_i = xyc[i][1] - 1
    c_i = xyc[i][2]
    pri = a[a_i] + b[b_i] - c_i
    ans = min(ans,pri)

print(ans)
# Judge status: Accepted
n=int(input())
l=sorted(map(int,input().split()))[::-1]

if l[0]<sum(l[1:]):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
# -*- coding: utf-8 -*-

X,Y,Z = list(map(int, input().rstrip().split()))

print( (X-Z) // (Z+Y) )
# Judge status: Accepted
N =input()
print("Yes" if "9" in N else "No")
# Judge status: Wrong Answer
X = str(input())
ans = []
for x in X:
    if x == 'S':
        ans.append(x)
    else:
        if len(ans) != 0:
            if ans[-1] == 'T':
                ans.pop()
            else:
                ans.append(x)
        else:
            ans.append(x)
print(len(ans))
# Judge status: Wrong Answer
import sys

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

a, b, c, d = inintm()

print(b-a+1 - (-(-(b-a)//c) + -(-(b-a)//d)) + 1)
# Judge status: Accepted
a,b=map(int,input().split())
if max(a,b)>=10:
  print(-1)
else:
  print(a*b)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

def count_all(text, part):
    return sum(text.startswith(part, i) for i in range(len(text)))

S = input()
I = 2019
l = []
count = 0

while I < 200000:
    count += count_all(S,str(I))
    I += 2019

print(count)
# Judge status: Accepted
import statistics
N = int(input())
AB = [map(int, input().split()) for _ in range(N)]
A,B = [list(i) for i in zip(*AB)]
if N%2 == 1:
    low_med = statistics.median(A)
    high_med = statistics.median(B)
    print(high_med - low_med +1)
else:
    low_med = statistics.median(A)
    high_med = statistics.median(B)
    print(int(2 * (high_med - low_med) +1))
# Judge status: Wrong Answer
a, b = map(int, input().split())
s = input()
if len(s) >= 0 and len(s) <= 9:
    if s[a] =="-" and s.count("-") ==1:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Wrong Answer
s, w = map(int, input().split())

if s > s:
    print('safe')
if s < w:
    print('unsafe')
# Judge status: Wrong Answer
n=int(input())
x=""
while n!=0:
    x= x+str(n%2)
    n=-(n//2)

if x=="":
    print(0)
else:
    print(x)
# Judge status: Wrong Answer
from itertools import permutations

N = int(input())

p = ''.join(input().split())
q = ''.join(input().split())

l = list(range(1, N+1))
l = sorted(permutations(l))

p_idx = 0
q_idx = 0
for n, i in enumerate(l):
    if ''.join(map(str, i)) == p:
        p_idx = n
    elif ''.join(map(str, i)) == q:
        q_idx = n
print(abs(p_idx-q_idx))
# Judge status: Accepted
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
  if '##' in s[a-1:d]:
    print('No')
  else:
    print('Yes')
else:
  if '##' in s[a-1:c] or '...' not in s[b-2:d+1]:
    print('No')
  else:
    print('Yes')
# Judge status: Accepted
N, K = map(int, input().split())

ans = 0

ans_1 = N//K
ans_2 = ans_1 + 1

ans = min(abs(N-ans_1*K), abs(N-ans_2*K))
print(ans)
# Judge status: Accepted
S=input()
T=input()
S=sorted(S)
T=sorted(T,reverse=True)
print('Yes' if S<T else 'No')
# Judge status: Accepted
w = str(input())
dic = {}
for s in w:
    dic.setdefault(s,0)
    dic[s] += 1
#print(dic)
isOK = True
for i in dic.values():
    if i % 2 != 0:
        isOK = False
        break
if isOK:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
s = input()
key = "keyence"
ptr = 0
cnt = 0
m = -1
f = True
if s == key:
    print("YES")
    exit()

for i in range(len(s)):
    if ptr != 7 and s[i] == key[ptr]:
        ptr += 1
    else:
        if m == -1 or m + 1 == i:
            m = i
        else:
            f = False

if f:
    f = (ptr == 7)

print("YES" if f else "NO")