peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N = int(input())
S = []
for _ in range(N):
    D = list(map(int, input().split()))
    S.append(D)

dp = [[0 for _ in range(3)] for _ in range(N+1)]

for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if j != k:
                happy =  dp[i-1][k] + S[i-1][j]
                if dp[i][j] < happy:
                    dp[i][j] = happy

print(int(max(dp[N])))
# Judge status: Wrong Answer
n=int(input())
l=[list(map(int,input().split())) for _ in range (n)]

a=0

for i in range (n):
  for j in range (n):
    a+=((l[i][0]-l[j][0])**2+(l[i][1]-l[j][1])**2)**(1/2)
    
print (a*2/n)
# Judge status: Wrong Answer
X = int(input())
if  40 >= X >= -40:
    print('yes')
else:
    print('no')
# Judge status: Accepted
D = int(input())
ans = ['Christmas'] + ['Eve'] * (25 - D)
print(' '.join(ans))
# Judge status: Accepted
A,B,C,X,Y = map(int,input().split())

cost = A*X + B*Y
a = X
b = Y
c  = 0
N = max(X,Y)

for i in range(N):
  c += 2
  if a > 0:
    a -= 1
  if b > 0:
    b -= 1
  cost = min(cost,A*a + B*b + c*C)
print(cost)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
C = {0:0,2:0,4:0}
for i in range(N):
    a = A[i]
    if a%2==1:
        C[0] += 1
    elif a%4==0:
        C[4] += 1
C[2] = N-C[0]-C[4]
if C[4]==C[0]-1:
    if C[2]<=C[4]-1:
        print("Yes")
    else:
        print("No")
elif C[4]>=C[0]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
ansl = []
while n != 0:
	if n % 2 == 1:
		ansl.append("1")
		n -= 1
	else:
		ansl.append("0")
	n //= -2
print("".join(ansl)[::-1])
# Judge status: Accepted
n=input();s=input();
x=0
max_num=0
for i in s:
  if i=='I':
    x+=1
  else:
    x-=1
  max_num=max(max_num,x)
print(max_num)
# Judge status: Accepted
n=int(input())
x=800*n
y=200*(n//15)
print(x-y)
# Judge status: Accepted
N=int(input())
A=[int(input()) for _ in range(N)]
cnt=0
buf=0
#print(A)
if N==1:
    print(A[0]//2)
else:
    for i in range(N-1):
        su=A[i]+A[i+1]
        cnt=cnt+su//2
        buf=(su//2)*2
        if buf>A[i]:
            A[i+1]=A[i+1]-(buf-A[i])
            A[i]=0
        else:
            A[i]=A[i]-buf
    #print(A,cnt)
    print(cnt)
# Judge status: Accepted
d=int(input())
c="Christmas"
e="Eve"
if d==25:
  print(c)
elif d==24:
  print(c,e)
elif d==23:
  print(c,e,e)
elif d==22:
  print(c,e,e,e)
# Judge status: Wrong Answer
import itertools
x = int(input())
if x>=2000:
  print(1)
  exit()
else:
  l = list()
  for nums in itertools.product(l,repeat=6):
    if (nums[0]*100+nums[1]*101+nums[2]*102+nums[3]*103+nums[4]*104+nums[5]*105)==x:
      print(1)
      exit()
print(0)
# Judge status: Wrong Answer
n,m = map(int,input().split())
mx = max(n,m)
mn = min(n,m)

if mn == 1:
    if mx == 1:
        print(1)
    else:
        print(m - 2)
elif mn >= 2:
    print((mx - 2) * (mn - 2))
# Judge status: Accepted
n = int(input())
ans = 'No'
for i in range(1,10):
    for j in range(i,10):
        if i*j == n:
            ans = 'Yes'
print(ans)
# Judge status: Wrong Answer
k = input()
flag = True
for i in k:
	if i != '7':
		flag = False
		break
if flag: print(len(k))
else:
	k = int(k)
	for i in range(1,k+1):
		a = pow(10,i,k) - 1
		if a%9 == 0:
			print(i)
			flag = True
			break
	if not flag: print("-1")
# Judge status: Accepted
if __name__ == '__main__':
	K, S = map(int, input().split())

	ans = 0
	for x in range(K+1):
		for y in range(K+1):
			z = S - x - y
			if 0 <= z and z <= K:
				ans += 1

	print(ans)
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
c = 0
d = 0
for i in range(n):
    for j in range(c, n):
        if i + 1 == a[j]:
            c = j
            d += 1
            break
    if c == n - 1:
        break
if 1 not in a:
    print(-1)
else:
    print(n - d)
# Judge status: Accepted
import fractions
from functools import reduce

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

#累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)
# Judge status: Accepted
from collections import Counter
N,K = map(int, input().split())
A = Counter(input().split())
B = A.values()
k = len(B) - K
if k <= 0:
    print(0)
else:
    print(sum(sorted(B)[0:k]))
# Judge status: Accepted
n,tt=map(int,input().split())
ans=1001
for i in range(n):
    c,t=map(int,input().split())
    if t<=tt and c<ans:
        ans=c
if ans == 1001:
    print("TLE")
else:
    print(ans)
# Judge status: Accepted
N = int(input())
prices = list(map(int, input().split()))

cash = 1000

low_p = prices[0]
share = cash // low_p

for price in prices:
    if low_p > price:
        low_p = price
        share = cash // price

    if low_p < price:
        cash += (price - low_p) * share
        low_p = price

print(cash)
# Judge status: Accepted
def main():
    N = int(input())

    ans = N - 1

    d = 1
    while d * d <= N:
        if N % d == 0:
            ans = min(ans, d + N // d - 2)
        d += 1

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
L, R, d = map(int, input().split())

x = L
ans = 0

while x<=R:
  if x % d == 0:
    ans += 1
  x += 1

print(ans)
# Judge status: Accepted
N = int(input())
p = list(map(int,input().split()))
cnt = 0
flag = True
for i in range(N):
    if p[i] == i+1:
        if flag:
            cnt += 1
            flag = False
        else:
            flag = True
    else:
        flag = True
print(cnt)
# Judge status: Accepted
n = float(input())

print(float((n//2+(n-n//2*2))/(n//2*2+(n-n//2*2))))
# Judge status: Wrong Answer
def resolve():

    N,Y=map(int,input().split())
    for i in range(N+1):
        for j in range(N+1-i):
            if 10000*i+5000*j+1000*(N-i-j)==Y:
                print(i,end=' ')
                print(j,end=' ')
                print(N-i-j)

resolve()
# Judge status: Accepted
def main():
    N, T = map(int, input().split())
    path = [[int(a) for a in input().split()] for i in range(N) ]
    minc = 10000
    for [c, t] in path:
        if t <= T :
            if minc > c:
                minc = c
    if minc == 10000:
        print("TLE")
    else:
        print(minc)
main()
# Judge status: Wrong Answer
a, b = map(int, input().split())
print('Possible' if (a // 3) == 0 or (b // 3) == 0 or ((a + b) // 3) == 0 else 'Impossible')
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())

# 2次関数の最大値を求める感じの場合分け
if a >= d or b <= c:
    print(0)
    exit()

if d >= a and c <= a:
    print(d-a)
    exit()

if c >= a and b >= d:
    print(d-c)
    exit()

if d >= b and c <= b:
    print(b-c)
    exit()

if a >= c and d >= b:
    print(b-a)
    exit()
# Judge status: Accepted
n,m,x=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(n)]
import itertools
sum_min=10**7
for i in itertools.product([0,1],repeat=n):
    level=[0]*m
    for j in range(m):
        level[j]=sum(i[k]*c[k][j+1] for k in range(n))
    for l in range(m):
        if level[l]<x:
            break
    else:
        sum_min=min(sum_min,sum(i[k]*c[k][0] for k in range(n)))
print(sum_min if sum_min!=10**7 else -1)
# Judge status: Accepted
N,M =map(int,input().rstrip().split(" "))
ans = [0 for _ in range(N + 3)]
ans[0] = 1
m = []
mc = 0
for _ in range(M):
  m.append(int(input()))
m.append(0)
for i in range(1,N + 1):
  if m[mc] != i:
    ans[i] += ans[i - 1]
    ans[i] += ans[i - 2]
    ans[i] %= 1000000007
  else:
    mc += 1
print(ans[N])
# Judge status: Wrong Answer
f = lambda : map(int,input().split())
n, q = f()
s = input()

cnt = 0
ln = [0]*n
for i in range(1,n):
  if s[i-1:i+1] == 'AC':
    cnt += 1
  ln[i] = cnt
print(ln)
for _ in range(q):
  l, r = f()
  print(ln[r-1]-ln[l-1])
# Judge status: Accepted
c = [int(i) for i in input().split()]
a = c[0]
b = c[1]

r = int((a*b)/2)
if a == 1 or b == 1:
    print(1)
elif a%2 == 0 or b%2 == 0:
    print(r)
else:
    print(r+1)
# Judge status: Wrong Answer
A, B, C, X = [int(input()) for i in range(4)]

res = 0
for a in range(A):
	for b in range(B):
		for c in range(C):
			total = 500 * a + 100 * b + 50 * c
			if total == X:
				res += 1
print(res)
# Judge status: Wrong Answer
# input
S = input()
best = 753

# check
make_min_num = min(
    [
        abs(int("".join(S[i:i + 3])) - best)
        for i in range(0, len(S) - 3)
    ]
)

print(make_min_num)
# Judge status: Accepted
S = input()
minn = 10**10
for i in range(len(S)-2):
    minn = min(minn, abs(int(S[i:i+3])-753))
print(minn)
# Judge status: Accepted
from collections import Counter

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

c = Counter(a).most_common()
edge = sorted([key, val] for key, val in c if val >= 2)

if len(edge) < 2:
    ans = 0
elif edge[-1][1] >= 4:
    ans = edge[-1][0] ** 2
else:
    ans = edge[-1][0] * edge[-2][0]

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

if max(l) < sum(l)-max(l):
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
import collections
n = int(input())
a = list(map(int,input().split()))
p = [0 for i in range(max(a)+2)]

for i in range(n):
    p[a[i]] += 1
    p[a[i] + 1] += 1
    p[a[i] - 1] += 1

print(max(p))
# Judge status: Accepted
N = int(input())
lst = list(map(int, input().split()))
avg = round(sum(lst) / N)

result = 0
for i in lst:
    result += (i - avg)**2

print(result)
# Judge status: Wrong Answer
n=int(input())
total=0
for i in range(0,n+1):
    if (i%3==0 and i%5==0) or i%3==0 or i%5==0:
        total+=0
    else:
        print(i)
        total+=i
print(total)
# Judge status: Accepted
S = list(input())
T = list(input())
ans = 0

for i in range(len(S)):
    if S[i] == T[i]:
        pass
    else:
        ans += 1
print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
a = map(int, input().split())
counter = Counter(a)
ans = 0
for i, j in counter.items():
    ans += min(abs(j - i), j)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
ans = 0
mod = 10**9+7
for i in range(k, n+2):
    ans += i*(2*n-i+1)//2 - i*(i-1)//2 + 1
    ans %= mod
print(ans)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

if A - K >= 0:
  A = A - K
  print(A, B)
else:
  B = B - (K - A)
  A = 0
  print(A, B)
# Judge status: Wrong Answer
a, b = [int(i) for i in input().split()]
tmp = a + b
if tmp >= 24:
  print(tmp // 24)
else:
  print(tmp)
# Judge status: Accepted
sx,sy,tx,ty = map(int, input().split())
ans = []
for _ in range(ty-sy):
  ans.append("U")
for i in range(tx-sx):
    ans.append("R")
for i in range(abs(sy-ty)):
    ans.append("D")
for i in range(abs(sx-tx)):
    ans.append("L")

ans.append("L")
for i in range(ty-sy+1):
    ans.append("U")
for i in range(tx-sx+1):
    ans.append("R")
ans.append("D")
ans.append("R")
for i in range(abs(sy-ty)+1):
    ans.append("D")
for i in range(abs(sx-tx)+1):
    ans.append("L")
ans.append("U")

print("".join(ans))
# Judge status: Wrong Answer
t_list = [i % 26 for i in range(365)]
for i in range(365):
    print(t_list[i])
# Judge status: Wrong Answer
N, K = map(int, input().split())
l = list(map(int, input().split()))
index = l.index(1)

ans = 0
if index != 0:
    p = (index + 1) - K
    ans += 1
    if p < 0:
        index = K - 1

    while p > 0:
        p = p - K
        ans += 1

while index < (N - 1):
    index = index + K - 1
    ans += 1

print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)

e = []
for k, v in c.items():
    if v > 3:
        e.append(k)
        e.append(k)
    elif v > 1:
        e.append(k)
e.sort(reverse=True)

if len(e)<2:
    print(0)
else:
    print(e[0]*e[1])
# Judge status: Accepted
from fractions import gcd
n = int(input())
a = [int(i) for i in input().split()]
gcd_ = [0] * n
L, R = [0] * (n + 1), [0] * (n + 1)
for i in range(n):
    L[i + 1] = gcd(L[i], a[i])
    R[n - (i + 1)] = gcd(R[n - i], a[(n - 1) - i])
for i in range(n):
    gcd_[i] = gcd(L[i], R[i + 1])
print(max(gcd_))
# Judge status: Accepted
n = int(input())

c = n % 1000

if c == 0:
  print(0)
else:
  print(1000 - c)
# Judge status: Wrong Answer
n = int(input())

tp = 0
xp = 0
yp = 0
flag = 0
for i in range(n):
  t, x, y = map(int,input().split())
  dt = t-tp
  dx = abs(xp-x)
  dy = abs(yp-y)
  if dx+dy==dt:
    flag=1
  elif dt%2==0 and dx%2==0 and dy%2==0:
    flag=1
  elif dt%2==0 and dx%2==1 and dy%2==1:
    flag=1
  elif dt%2==1 and dx%2==0 and dy%2==1:
    flag=1
  elif dt%2==1 and dx%2==1 and dy%2==0:
    flag=1
  tp=t
  xp=x
  yp=y

if flag==1:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
menu=[]
total=10
c=0
for i in range(5):
    a=int(input())
    b=a%10
    if 0<b<=9:
        if total>b:
            total=b
            menu.append(a)
        else:
            menu.append(a+10-b)
    else:
        menu.append(a)
print(sum(menu))
# Judge status: Accepted
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
ans=[0]*(n-k+1)
for i in range(n-k+1):
    ans[i]=h[k+i-1]-h[i]
print(min(ans))
# Judge status: Accepted
S = input()
n = len(S)

answer = 0
for i in range(n - 1):
    if S[i] == S[i + 1] :
        answer = 1
        
if answer == 1:
	print("Bad")
else:
	print("Good")
# Judge status: Wrong Answer
s = input()
n = len(s)
pr =s[0]
ls = ["h","i"]
cnt = 0
for i in range(n):
    pr = s[i]
    if pr == ls[cnt]:
        pass
        cnt = (cnt+1)%2
    else:
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
n = int(input())
d = {}
for ai in input().split():
  ai = int(ai)
  if ai not in d:
    d[ai] = 0
  d[ai] += 1

n2 = [k for k in d if d[k] > 1]
n4 = [k for k in d if d[k] > 3]

n2.sort(reverse = True)
n4.sort(reverse = True)

ans = 0

if n4:
  ans = n4[0] ** 2

if len(n2) > 1:
  max(ans, n2[0] * n2[1])

print(ans)
# Judge status: Accepted
L = int(input())
l = L/3
print(l**3)
# Judge status: Accepted
n, a, b = map(int, input().split())
S =input()

x = 1
y = 1
for i in range(len(S)):
    if S[i] == "a":
        if x <= a + b:
            print("Yes")
            x += 1
        else:
            print("No")
    elif S[i] == "b":
        if (x <= a + b) and (y <= b):
            print("Yes")
            x += 1
            y += 1
        else:
            print("No")
    else:
        print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

B = []
for i in A:
    cnt = 0
    while i%2 == 0:
        if i%2 == 0:
            cnt += 1
            i = i/2
    B.append(cnt)
print(min(B))
# Judge status: Wrong Answer
import collections
s = list(input())

c = collections.Counter(s).most_common()
if c[0][1] >= c[-1][1] + 2:
    print('NO')
else:
    print('YES')
# Judge status: Wrong Answer
N=int(input())
print(N*800 - N%15*200)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
a.sort()

ans = 0
for i in range(N):
    ans += a[len(a)-2-i]
print(ans)
# Judge status: Wrong Answer
#C-Poll
import collections
n=int(input())
words = [input() for _ in range(n)]
count = collections.Counter(words)
leng = len(count)
ansallay = []
#抽出用に何回出てればansに出すかを変数に突っ込む
record = count.most_common()[0][1]
for num in range(leng-1):
    if(count.most_common()[num][1] == record):
        ansallay.append(count.most_common()[num][0])
    else:
        break
ansallay.sort()
for word in ansallay:
    print(word)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
mod = 998244353
if d[0] != 0:
    print(0)
else:
    a = Counter(d)
    ans = 1
    for i in range(1, max(d)+1):
        ans *= a[i-1]**a[i]
        ans %= mod
    print(ans)
# Judge status: Accepted
n, a, b = map(int, input().split())
mod = 10**9+7

ans = pow(2, n, mod)-1

def choose(n, r):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= mod
        fac *= i+1
        fac %= mod
    return res*pow(fac, mod-2, mod)%mod

ans -= choose(n, a)
ans -= choose(n, b)

print(ans%mod)
# Judge status: Accepted
A, B, M = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
mi = min(a) + min(b)

for i in range(M):
  c1, c2, c3 = [int(j) for j in input().split()]
  m =  a[c1-1] + b[c2-1] - c3
  if mi > m:
    mi = m

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

p = sorted(list(map(int, input().split())))
print(sum(p[:k]))
# Judge status: Accepted
#!/usr/bin/env python3
# %%
stdin = open(0)

# %%
N,R = map(int, stdin.read().split())
if N >= 10:
    answer = R
else:
    answer = R + 100 * (10-N)

# %%
print(answer)

# %%
# Judge status: Wrong Answer
n, p = map(int, input().split())
a = list(map(int, input().split()))

if n == 1 and a[0] % 2 == 0:
    if p == 0:
        print(2)
    else:
        print(0)
elif n == 1 and a[0] % 2 == 1:
    print(1)
else:
    print(2 ** n // 2)
# Judge status: Wrong Answer
from math import*
from bisect import*
import copy

n=int(input())
arr=list(map(int,input().split()))
arr.sort()
brr=copy.deepcopy(arr)
brr=list(set(brr))
#print(arr)
ans=0
#print(bisect_right(arr,6))
for i in range(len(brr)):
	d=bisect_left(arr,brr[i])
	c=bisect_right(arr,brr[i]+2)
	if ans<c-d:
		ans=c
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
C = 10 ** 9
for i in range(-100, 101):
    c = 0
    for a in A:
        c += (i - a) ** 2
    C = min(C, c)
print(C)
# Judge status: Accepted
k=int(input())
a,b=map(int,input().split())
ans=""
if a%k==0:
    ans="OK"
elif b-a>=k-a%k:
    ans="OK"
else:
    ans="NG"
print(ans)
# Judge status: Accepted
L=int(input())
print((L**3)/27)
# Judge status: Accepted
sx,sy,tx,ty = map(int,input().split())
x_move = tx - sx
y_move = ty - sy
ans = ""
for i in range(x_move):
  ans += "R"
for j in range(y_move):
  ans += "U"
for a in range(x_move):
  ans += "L"
for b in range(y_move):
  ans += "D"
ans += "L"
for i in range(y_move + 1):
  ans += "U"
for i in range(x_move + 1):
  ans += "R"
ans += "D"
ans += "R"
for i in range(y_move + 1):
  ans += "D"
for i in range(x_move + 1):
  ans += "L"
ans += "U"
print(ans)
# Judge status: Wrong Answer
def main():
  n, m = map(int, input().split())
  if n == 1 and m == 1:
    print(1)
  if n == 1 or m == 1:
    print(max(n-2, m-2))
  else:
    print(n*m-2*(n+m)+4)
if __name__ == "__main__":
  main()
# Judge status: Accepted
k, x = map(int, input().split())
for i in range(x-(k-1), x+(k-1)+1):
    print(i, end=' ')
print()
# Judge status: Accepted
N = int(input())
N = str(N)
if "7" in N:
    print("Yes")
else:
    print("No")
# Judge status: Accepted

def f(t, _ans, length):
    for _ in range(length):
        t += length
        _ans += 1

        if t >= n:
            print(_ans)
            exit()

    return _ans

h = int(input())
w = int(input())
n = int(input())
t = 0
ans = 0

if h > w:
    f1, f2 = h, w
else:
    f1, f2 = w, h

ans = f(t, ans, f1)
f(t, ans, f2)
# Judge status: Wrong Answer
from math import *
n,k=map(int,input().split())
print(ceil(n/k))
# Judge status: Accepted
N,A,B = map(int,input().split())
cnt = 0
sum = 0
i = 0
for i in range(N+1):
    j = 0
    tmpsum = 0
    l = list(str(i))
    for j in l:
        tmpsum += int(j)
    if tmpsum>=A and tmpsum <=B:
        sum += i
print(sum)
# Judge status: Wrong Answer
n,k=map(int,input().split())
p=list(map(int,input().split()))
pnew=sorted(p)
sums=0
for i in range(k):
    sums=sums+pnew[i]
    
print(pnew)
print(sums)
# Judge status: Accepted
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
n, d = [int(x) for x in input().split()]
l = 2 * d + 1
print((n + l - 1) // l)
# Judge status: Accepted
n = int(input())
w_list = [input() for _ in range(n)]

flag = True

for i in range(1, n):
    if w_list[i-1][-1] != w_list[i][0]:
        flag = False
    elif w_list[i] in w_list[:i-1]:
        flag = False
if flag == True:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,k = map(int,input().split())
coin = [0]*n
while k > 1:
    for i in range(min(int(k-1/1e10),n)):
        coin[i] += 1
    k /= 2
ans = 0
print(coin)
for i in range(n):
    ans += 1 / (2**coin[i] * n)
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())

def fact(n):
    k = 2
    l = [] 
    temp=n
    while pow(k, 2)<=n:
        if temp%k==0:
            l.append(k)
            while temp%k==0:
                temp//=k
        k+=1
    if temp!=1:
        l.append(temp)
    return l

if A==1 and B==1:
    print(1)
elif A==B:
    print(len(set(fact(A)))+1)
else:
    print(len(set(fact(A))&set(fact(B)))+1)
# Judge status: Accepted
N = int(input())
S = input().strip()
while True:
    lv = 0
    lmin = len(S)
    for i in range(len(S)):
        if S[i]=="(":
            lv += 1
        else:
            lv -= 1
        lmin = min(lmin,lv)
    if lmin<0:
        S = "("*(-lmin)+S
    else:break
lv = 0
for i in range(len(S)):
    if S[i]=="(":
        lv += 1
    else:
        lv -= 1

if lv>0:
    S = S+")"*lv
print(S)
# Judge status: Accepted
s = input()[::-1]
size = len(s)
s += "4"

a, b = 0, 0

for i in range(size):
    v1, v2 = int(s[i]), int(s[i+1])
    if v1+b>=6 or (v1+b>=5 and v2>=5):
        a += 10-v1-b
        b = 1
    else:
        a += v1+b
        b = 0

print(a+b)
# Judge status: Accepted
n=int(input())
k=len(str(n))
if k==1:
  print(n)
else:
  a=str(n)
  array=list(map(int,list(a)))
  print(max(int(a[0])-1+9*(k-1),sum(array)))
# Judge status: Wrong Answer
a, b = map(int, input().split())

a_min = -(-a*100//8)
a_max = int((a+1)*100/8)
b_min = -(-b*100//10)
b_max = int((b+1)*100/10)

if a_max >= b_min and b_max >= a_min:
    print(max([a_min, b_min]))
else:
    print(-1)
# Judge status: Wrong Answer
h, n = map(int, input().split())
a = list(map(int, input().split()))
hp = 0

for i in range(n):
    h -= a[i]
    
if h < 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#AGC002-A
a,b = map(int,input().split())
if a > 0:
    print('Positive')
elif a <= 0 and b >= 0:
    print('Zero')
else:
    if (b - a + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')
# Judge status: Wrong Answer
N,*A=map(int, open(0).read().split())
acc=A[0]
ans=0
for a in A[1:]:
    b=min(acc,a)
    acc-=b
    ans+=b+acc//2
    acc=a-b
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())

i = 1
j = N
if N % 2 == 1:
  for k in range(M):
      print(i, j)
      i += 1
      j -= 1
    
else:
  for k in range(M//2+1):
      print(i, j)
      i += 1
      j -= 1
  j -= 1
  for k in range(M//2):
      print(i, j)
      i += 1
      j -= 1
# Judge status: Accepted
from collections import Counter
# from scipy.special import comb
from scipy.misc import comb
n = int(input())
a = [int(x) for x in input().split()]
aa = Counter(a)
cnt = []
for i in range(1, n + 1):
    cnt.append(comb(aa[i], 2, exact=True))
s = sum(cnt)
for i in range(n):
    print(s - comb(aa[a[i]], 2, exact=True) + comb(aa[a[i]] - 1, 2, exact=True))
# Judge status: Accepted
S = input()

flag = 1
c_count = 0
if S[0] == 'A':
  for i in range(1,len(S)):
    if 2 <= i <= len(S)-2:
      if S[i] == 'C':
        c_count += 1
    else:
      if S[i].islower() == False:
        flag = 0
else:
  flag = 0
if c_count == 1 and flag == 1:
  print('AC')
else:
  print('WA')
# Judge status: Wrong Answer
a,b=map(float,input().split())
ans=a*100+b*100
print(int(ans//100))
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())
print(int(1/2*(a+b)*h))
# Judge status: Accepted
A, B, C, D = map(int,input().split())
print("Yes" if (A-1) // D >= (C-1) // B else "No")
# Judge status: Accepted
def main():
    a,b,k = map(int, input().split())

    array = range(a,b+1)
    ans = list(set(array[:k]) | set(array[-k:]))
    ans.sort()
    for val in ans:
        print(val)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n,y=map(int,input().split())

res=(-1,-1,-1)

for i in range(n+1):
    for j in range(n-i+1):
        k = 10000*i + 5000*j + 1000*(n-i-j)
        if k==y:
            res=(i,j,n-i-j)
            break
print(*res)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

if (a == b and a == c) or (a != b and a != c):
    print("No")
else:
    print("Yes")