peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import deque
S=input()
Q=int(input())
query=[list(map(str,input().split())) for _ in range(Q)]

ans=deque(S)
reverse=False
for i,q in enumerate(query):
  if len(q)==1:
    reverse=not reverse
  else:
    _,f,c=q
    if (f=='2') ^ reverse:
      ans.append(c)
    else:
      ans.appendleft(c)
if reverse:
  print(*reversed(ans),sep='')
else:
  print(*ans,sep='')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
o = 0
t = 0
f = 0
for i in range(n):
    if a[i]%4 == 0:
        f += 1
    elif a[i]%2 == 0:
        t += 1
    else:
        o += 1
if t == 0:
    if f+1 >= o:
        print("Yes")
    else:
        print("No")
else:
    if f >= o:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
for i in range(n):
    if b[i] < a[i]:
        c += b[i]
    else:
        d = min(a[i+1],b[i]-a[i])
        a[i+1] -= d
        c += a[i] + d
print(c)
# Judge status: Accepted
import sys

input = sys.stdin.readline

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

a_list = list(map(int, input().split()))

count = 0
if a_list[0] > x:
    count += a_list[0] - x
    a_list[0] -= a_list[0] - x
for i in range(len(a_list)):
    if i+1 == len(a_list):
        break
    if a_list[i] + a_list[i+1] > x:
        count += a_list[i] + a_list[i+1] - x
        a_list[i+1] -= a_list[i] + a_list[i+1] - x
        

print(count)
# Judge status: Wrong Answer
a, b = map(int, input().split())
zero = (a == 0 | b == 0) | (a < 0 and 0 < b) | (b < 0 and 0 < a)
negative_a = (a < 0 and 0 < b) and (a + b) % 2 == 0
negative_b = (a < 0 | b < 0)
if zero:
    print("Zero")
elif negative_a | negative_b:
    print("Negative")
else:
    print("Positive")
# Judge status: Accepted
import math
fp = 10
ans = 0
for i in range(5):
    a = int(input())
    ans+= math.ceil(a/10)*10
    if a%10!=0:
        fp =  min(fp, a%10)
print(ans+fp -10 if fp!=10 else ans )
# Judge status: Accepted
n = int(input())
s = input()
sn = len(set(s))
r = 0
for i in range(n+1):
    t = len(set(s[:i])) + len(set(s[i:])) - sn
    r = r if r>t else t
print(r)
# Judge status: Accepted
N,K,S=map(int,input().split())
A=[]


for i in range(K):
  print(S,end=" ")
  
for j in range(N-K):
  if S!=10**9:
    print(10**9,end=" ")
  else:
    print(1,end=" ")
# Judge status: Accepted
N = int(input())
act = []
for _ in range(N):
    act.append(tuple(map(int, input().split())))

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

for i in range(3):
    dp[0][i] = act[0][i]

for i in range(1, N):
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1) % 3], dp[i-1][(j+2) % 3]) + act[i][j]


print(max(dp[N-1]))
# Judge status: Accepted
s,t=map(str,input().split())
a,b=map(int,input().split())
u=input()

if u==s:
  a-=1
elif u==t:
  b-=1
print("{0} {1}".format(a,b))
# Judge status: Accepted
k = int(input())
s = list(str(input()))
if len(s) <= k:
    print(''.join(s))
else:
    ln = s[:k]
    ln.append('.')
    ln.append('.')
    ln.append('.')
    print(''.join(ln))
# Judge status: Accepted
n=int(input())
s=input()
now=0
rec=0
for i in s:
    now+=(-1)**(i==")")
    rec=min(now,rec)
f,t="",""
if rec<0:
    f="("*-rec
    now-=rec
if now>0:
    t=")"*now
print(f+s+t)
# Judge status: Wrong Answer
H, N = map(int,input().split())
data = []

for i in range(N):
    data.append([0, 0])
    a, b = map(int,input().split())
    data[i][0] = a
    data[i][1] = b
data.sort(key=lambda x: x[0])
cost = [float("inf")] * (H + data[-1][0])
cost[0] = 0
for i in range(1, H + data[-1][0]):
    for magic in data:
        if i < magic[0]:
            break
        if cost[i] > cost[i - magic[0]] + magic[1]:
            cost[i] = cost[i - magic[0]] + magic[1]
print(min(cost[H:]), cost, data)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = []
C = 0
for i in range(N):
  if A[i]//400 < 8:
    B.append(A[i]//400)
  else:
    C += 1
b = set(B)
if len(b) == 0:
  print(1, C)
else:
  print(len(b), len(b)+C)
# Judge status: Accepted
import math
N, D = map(int,input().split())
print(math.ceil(N/(2*D+1)))
# Judge status: Wrong Answer
from collections import deque
S = deque(input())
Q = int(input())
sousa = []
for i in range(Q):
  sousa.append(input().split())

for j in range(Q):
  rev = 0
  if sousa[j][0] == '1':
    rev += 1
  else:
    if rev%2 == 1:
      S.reverse()
    if sousa[j][1] == '1':
      S.appendleft(sousa[j][2])
    else:
      S.append(sousa[j][2])
Ans = ''.join(list(S))
print(Ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = sorted(set(a), reverse=True)
c = []
for i in b:
    if a.count(i) >= 4:
        print(i*i)
        exit(0)
    elif a.count(i) >= 2:
        c.append(i)
        if len(c)==2:
            print(c[0]*c[1])
            exit(0)
print(0)
# Judge status: Accepted
import itertools
x = int(input())
itr = list(itertools.accumulate([i for i in range(100000)]))
for i in range(100000):
  if itr[i] < x <= itr[i + 1]:
    print(i + 1)
    exit()
# Judge status: Accepted
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from math import ceil
#import numpy as np
def main():
    n = int(input())
    r = ceil(n / 1000) * 1000 - n
    print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
s = list(int(input()) for _ in range(n))
ans = sum(s)
flag = float('inf')
for i in range(n):
    if s[i] % 10 != 0:
        flag = min(flag,s[i])
if ans % 10 == 0:
    if flag != float('inf'):
        print(ans - flag)
    else:
        print(0)
else:
    print(ans)
# Judge status: Wrong Answer
import math
n = int(input())
n_list = []
for i in range(1, int(math.sqrt(n))):
    if n % i == 0:
        n_list.append((i, n//i))
sa = n-1
for x, y in n_list:
    if sa >= abs(x-1)+abs(y-1):
        sa = abs(x-1) + abs(y-1)
print(sa)
# Judge status: Accepted
N = str(input())
if  N[len(N)-1] == "3" :
  print("bon")
if N[len(N)-1] == "0" or N[len(N)-1] =="1" or N[len(N)-1] =="6" or N[len(N)-1] == "8": 
  print("pon")
elif N[len(N)-1]== "2" or N[len(N)-1] == "4" or N[len(N)-1] =="5" or N[len(N)-1] =="7" or N[len(N)-1] =="9":
  print("hon")
# Judge status: Accepted
a,b = map(int,input().split())

consent = 1
ans = 0

while consent < b:
  consent += (a - 1)
  ans += 1
  
print(ans)
# Judge status: Accepted
o = input()
e = input()
ans = ''
for i in range(len(e)):
    ans += o[i]
    ans += e[i]
if len(o) == len(e):
    pass
else:
    ans += o[len(o)-1]
print(ans)
# Judge status: Accepted
sa = list(str(input()))
sb = list(str(input()))
sc = list(str(input()))
 
tmp = 'a'
while True:
    if tmp == 'a':
        tmp = sa.pop(0)
    elif tmp == 'b':
        tmp = sb.pop(0)
    elif tmp == 'c':
        tmp = sc.pop(0)
    if len(sa) == 0 and tmp == 'a':
        print('A')
        exit()
    elif len(sb) == 0 and tmp == 'b':
        print('B')
        exit()
    elif len(sc) == 0 and tmp == 'c':
        print('C')
        exit()
# Judge status: Wrong Answer
N,M=(int(x) for x in input().split())

A = list(map(int, input().split()))

list.sort(A,reverse = True)

s=float(sum(A)/(4*M))
check=0
for i in range(0, M):
    if A[i]<=s:
        check=1

if check ==1:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
# B
n = int(input())
w = list(map(int, input().split()))

l = []
for i in range(n):
    ans = abs(sum(w[:i]) - sum(w[i:]))
    l.append(ans)
    
print(min(l))
# 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())
xy = [tuple(map(int, input().split())) for _ in range(n)]
l = [(item[0]+item[1], item[0]-item[1]) for item in xy]
l.sort()
v0 = l[-1][0]-l[0][0]
l.sort(key=lambda x: x[1])
v1 = l[-1][1]-l[0][1]
ans = max(v0,v1)
print(ans)
# Judge status: Accepted
N = int(input())
S = [0 if s == "#" else 1 for s in list(input())]
ruisekiwa = [0]*(N+2)
i = 1
r = 0
while i <= N:
  r = r+S[i-1]
  ruisekiwa[i] = r
  i += 1
ruisekiwa[N+1] = ruisekiwa[N]
ans = 10**10
i = 1
while i <= N+1:
  towhite = (i-1)-(ruisekiwa[i-1]-ruisekiwa[0])
  toblack = ruisekiwa[N+1]-ruisekiwa[i-1]
  ans = min(ans, towhite+toblack)
  i += 1
print(ans)
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=int(b)
c=1
d=0
if a>b:
  for i in range(1,a):
    if a%i==0 and b%i==0:
      a=a/i
      b=b/i
      c=c*i
  print(int(a*b*c))
if a<b:
  for i in range(1,b):
    if a%i==0 and b%i==0:
      a=a/i
      b=b/i
      c=c*i
  print(int(a*b*c))
# Judge status: Accepted
S = input()
K = int(input())

if all(s == "1" for s in S[:K]):
    print(1)
else:
    for i in range(len(S)):
        if S[i] != "1":
            print(S[i])
            break
# Judge status: Accepted
n = int(input())
v = list(map(int, input().split()))

v.sort()
tmp = (v[0] + v[1])/2
for i in range(2, n):
    tmp = (tmp + v[i])/2

print(tmp)
# Judge status: Wrong Answer
N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]


MPs = {}
for a, b in sorted(ABs, key=lambda i: i[1]):
    if a not in MPs:
        MPs[a] = 1
    else:
        MPs[a] += 1
    if b not in MPs:
        MPs[b] = 1
    else:
        MPs[b] += 1

for mp in range(N):
    if mp in MPs:
        MPs[mp] = 0

for x, y in sorted(MPs.items(), key=lambda j: j[0]):
    print(y)
# Judge status: Accepted
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
a.sort()
for i in range(n):
    ai = a[i]
    if i==n-1:
        if ai==x:
            ans+=1
        else:
            pass
        break
    if ai<=x:
        ans+=1
        x-=ai
print(ans)
# Judge status: Accepted
K=int(input())
S=list(input())
if len(S)<=K:
    print("".join(S))
else:
    ans="".join(S[0:K])
    ans+="..."
    print(ans)
# Judge status: Accepted
s={int(input())}
def f(k,m):
  p=1;
  while p*m<=k: p*=m
  return p
a=0
while all(s):
  s={i-f(i,6) for i in s}|{i-f(i,9) for i in s}
  a+=1
print(a)
# Judge status: Wrong Answer
l= ["SUN","MON","TUE","WED","THU","FRI","SAT"]
s=input()
ans=0
for i in range(7):
  if s==l[i]:
    ans =(7-i)%7
print(ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
chizu = [[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    chizu[a-1].append(b-1)
    chizu[b-1].append(a-1)
inf = 10**10
dep = [inf]*n
dep[0] = 0
prev = [-1]*n
former = []

for i in range(n):
    for j in chizu[i]:
        if dep[i]+1 < dep[j]:
            prev[j] = i+1
            dep[j] = dep[i]+1
        
    
print('Yes')
for i in range(1,n):
    print(prev[i])
# Judge status: Accepted
A, B, C, K = map(int, input().split())
threshold = 10 ** 18
res = (-1) ** K * (A - B)
if abs(res) > threshold:
    print('Unfair')
else:
    print(res)
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())
ans = 0
plus = max(H,W)
cnt = 0
while ans < N:
	ans+=plus
	cnt+=1
print(cnt)
# Judge status: Accepted
import sys
import numpy as np
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    A,B=[0]*N,[0]*N
    for i in range(N):
        A[i],B[i]=map(int,input().split())
    Bargsort=np.argsort(B)
    t=0
    for i in Bargsort:
        t+=A[i]
        if t>B[i]:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()
# Judge status: Accepted
n, k = map(int, input().split())
r, s, p = map(int, input().split())
T = list(input())
P = {'s':r, 'p':s, 'r':p}
 
mx = r*T.count('s')+s*T.count('p')+p*T.count('r')
if len(T)<k:
    print(mx)
else:
    for i in range(n-k):
        if T[i]==T[i+k]:
            mx -= P[T[i]]
            T[i+k] = '_'
print(mx)
# Judge status: Accepted
n = int(input())
p = [int(i) for i in input().split()]
count = 0
min_value = p[0]
for i in p:
    if i <= min_value:
        count += 1
        min_value = i
print(count)
# Judge status: Wrong Answer
n,t = map(int,input().split())
ans = 0
for i in range(n):
  a,b = map(int,input().split())
  if t > b:
    ans = b
print(ans if ans > 0 else "TLE")
# Judge status: Accepted
from itertools import accumulate

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

a = [0] + list(accumulate(a))
b = [0] + list(accumulate(b))

ans = 0
j = 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
n = int(input())
print("ABC" if n <1000 else "ABD")
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

def main():
    N, x = map(int, input().split())
    a_list = list(map(int, input().split()))
    ans = 0
    for a in sorted(a_list):
        if a <= x:
            ans += 1
            x -= a
        else:
            break
    if ans == N:
        print(ans - 1)
    else:
        print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
# import sys;input = lambda : sys.stdin.readline()
import collections
d=collections.defaultdict(lambda:0)
for _ in range(int(input())):
    s=input()
    d[s]+=1
print("AC X",d['AC'])
print("WA X",d['WA'])
print("TLE X",d["TLE"])
print("RE X",d['RE'])
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if p[i]-1 == i:
        p[i], p[i+1] = p[i+1], p[i]
        ans += 1

print(ans)
# Judge status: Accepted
s = input()
t = ''
a = ['-1']

for i in s:
    t += i
    if t != a[-1]:
        a += [t]
        t = ''
print(len(a)-1)
# Judge status: Accepted
n, k = map(int, input().split())

if k > n:
    tmp = n
else:
    tmp = n % k

if tmp > k / 2:
    tmp = k - tmp

print(tmp)
# Judge status: Accepted
# input
N, M = map(int, input().split())

c = []

c_append = c.append

for i in range(M):
    sm, cm = map(int, input().split())
    c_append((sm, cm))

ans = -1

# check
for i in range(1000):
    str_i = str(i)

    if N < len(str_i):
        break

    if N == len(str_i) and False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:
        ans = i
        break

print(ans)
# Judge status: Accepted
S = input()
N = len(S) + 1
A = [0]*N
for i in range(N-1):
    if S[i] == "<":
        A[i+1] = max(A[i]+1, A[i+1])
for i in range(N-2, -1, -1):
    if S[i] == ">":
        A[i] = max(A[i], A[i+1]+1)
print(sum(A))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=0
check=[0]*8
while i<n and a[i]<3200:
    a_i=a[i]
    for j in range(8):
        if check[j]==0 and a_i>=400*j and a_i<400*(j+1):
            check[j]=1
            break
    i+=1
if sum(check)==0:
    ans_min=1
    ans_max=n
else:
    ans_min=sum(check)
    ans_max=ans_min+n-i
print(ans_min,ans_max)
# Judge status: Accepted
n= int(input())
a= [int(input()) for i in range(n)]
c,s = 1,a[0]
while s!=2 and c<n:
    c,s=c+1,a[s-1]
print(c if c<n else -1)
# Judge status: Wrong Answer
import copy
a = list(map(int,input().split()))
nokori  = copy.copy(a)
count = max(a)
nokori.remove(count)
if a[0] == a[1] == a[2]:
    print("NO")
if int(nokori[0] + nokori[1]) == count:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
a, b = input().split()
if (int(b) <= int(a)): print(b * int(a)); exit(0)
else: print(a * int(a)); exit(0)
# Judge status: Accepted
N = input()

if N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = int(input())
a = [s]
i = 0
while True:
    if a[i]%2==0:
        f = a[i]//2
    else:
        f = 3*a[i]+1
    if f not in a:
        a.append(f)
        i+=1
    else:
        print(i+2)
        break
# Judge status: Accepted
n=int(input())
plus=[]
minus=[]
for i in range(n):
    x,y=map(int,input().split())
    plus.append(x+y)
    minus.append(x-y)
print(max(max(plus)-min(plus),max(minus)-min(minus)))
# Judge status: Wrong Answer
import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
ans = math.ceil(n/(k-1))
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
if(N==M):print('Yes')
else:print('No')
# Judge status: Accepted
import bisect
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

count=0
for i in B :
    a=bisect.bisect_left(A,i)
    c=bisect.bisect_right(C,i)
    p=a*(N-c)
    count+=p

print(count)
# Judge status: Accepted
a, b, x = map(int, input().split())
ans = b//x - (a-1)//x
print(ans)
# Judge status: Accepted
import math
a, b, n = list(map(int, input().split()))

x = min(b-1, n)
print(math.floor(a * x / b) - a * math.floor(x / b))
# Judge status: Wrong Answer
N, X, T = map(int, input().split())

time = int(N / X) * T
if N%T==0:
  print(time)
else:
  print(time+T)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 28 01:14:47 2020

@author: liang
"""

N, K = map(int,input().split())
A = list()
for i in range(N):
    a, b = map(int,input().split())
    A.append((a,b))
A.sort(key= lambda x:x[0])

tmp = 0
for i in range(N):
    a, b = A[i]
    tmp += b
    if tmp >= K:
        print(a)
        break
# Judge status: Accepted
s = input()
print("A"+s[8]+"C")
# Judge status: Accepted
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
    A[i],B[i]=map(int,input().split())

A.sort()
B.sort()

if N%2==1:
    print(abs(A[N//2]-B[N//2])+1)
else:
    print(abs(A[N//2]+A[N//2-1]-B[N//2]-B[N//2-1])+1)
# Judge status: Accepted
N = int(input())

for i in range(111, 1000, 111):
  if i >= N:
    print(i)
    break
# Judge status: Wrong Answer
A,B,C,D = map(int,input().split())
#print(A,B,C,D)
def judge(A,B,C,D):
    for i in range(99):
        C = C-B
        A = A - D
        if C==0:
            return 1
        elif A == 0:
            return 0
if judge(A,B,C,D)==1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys

lis = list()

for line in sys.stdin : 
  lis.append(int(line))
  

if (lis[0] - lis[1]) < 0 : 
  print(lis[0] * lis[2])
  
else : 
  sum = lis[1] * lis[2] + (lis[0] - lis[1]) * lis[3]
  print(sum)
# Judge status: Accepted
import numpy as np

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

ai = a.max()

v, aj = 0, 0
for i in a[:-1]:
    tmp = i * (ai - i)
    if v < tmp:
        v = tmp
        aj = i
# print(v, aj)
print(ai)
print(aj)
# Judge status: Accepted
N = int(input())
S = input()
char = set(list(S))
mod = 10**9+7
ans = 1
for c in char:
    ans *= S.count(c) + 1
    ans %= mod
ans -=1
print(ans)
# Judge status: Accepted
N = int(input())
F = [tuple(map(int, input().split())) for _ in range(N)]

DP = [0] * 3

for f in F:
    D = [0] * 3
    S = {0, 1, 2}
    for i in range(3):
        S.remove(i)
        for s in S:
            D[i] = max(D[i], f[i] + DP[s])
        S.add(i)
    DP = D

print(max(DP))
# Judge status: Accepted
N, K = map(int, input().split())
*A, = map(int, input().split())


def isOk(m):
    k = 0
    for a in A:
        if a > m:
            k += a//m
            if a % m == 0:
                k -= 1
    if k <= K:
        return True
    else:
        return False


l, r = 10**19, 1
while abs(r-l) > 1:
    m = (l+r)//2
    if isOk(m):
        l = m
    else:
        r = m

if isOk(r):
    print(r)
else:
    print(l)
# Judge status: Accepted
n = int(input())
if n % 2 == 1:
    print('0')
    exit()

ans = 0
mul5 = 10
while mul5 <= n:
    ans += n // mul5
    mul5 *= 5
print(ans)
# Judge status: Accepted
def main():
    X=int(input())
    for A in range(-1000,1000):
        for B in range(-1000,1000):
            if A**5-B**5==X:
                print(A,B)
                exit()

main()
# Judge status: Accepted
N, M = map(int, input().split())
A = [None]*M

is_broken = [False] * (N+1)

for i in range(M):
    A[i] = int(input())
    is_broken[A[i]] = True

dp = [0] * (N+1)
dp[0] = 1

for i in range(1, N+1):
    if is_broken[i]:
        continue
    dp[i]  = (dp[i-1] + dp[i-2]) % (10**9 + 7)

print(dp[-1])
# Judge status: Accepted
n = list(input())
if '7' in n:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
x,y = map(int,input().split())
if x%y == 0:
  print(-1)
else:
  print(x)
# Judge status: Wrong Answer
a,b,N=map(int,input().split())
d=[]
for i in range(1,N+1):
    d.append(((a*i)//b)-(a*(i//b)))
print(d[-1])
# Judge status: Accepted
from collections import Counter
N = int(input())
C = Counter(map(int, input().split()))
ans = 0
for i in C:
    if C[i]>i:
        ans += C[i]-i
    elif C[i]<i:
        ans += C[i]
print(ans)
# Judge status: Accepted
c = [list(map(int, input().split())) for _ in range(3)]
a = [0, 0, 0]
b = [0, 0, 0]
b[0] = c[0][0] - a[0]
b[1] = c[0][1] - a[0]
b[2] = c[0][2] - a[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]

cnt = 0
for i in range(3):
    for j in range(3):
        if c[i][j] == a[i]+b[j]:
            cnt += 1

print('Yes' if cnt == 9 else 'No')
# Judge status: Accepted
x, k, d = map(int, input().split())
p = (x + d * k) // (2 * d)

def f(a):
  return abs(x + d * (k - 2 * a))

if p > k or p < 0:
  print(min(f(0), f(k)))
else:
  print(min(f(p), f(p + 1)))
# Judge status: Accepted
import sys
input = lambda:sys.stdin.readline().strip()
n = int(input())
a = [0]
b = [0]
for i in range(n):
    ai,bi = map(int,input().split())
    a.append(ai)
    b.append(bi)
a.sort()
b.sort()
if n&1:
    print(b[(n+1)//2]-a[(n+1)//2]+1)
else:
    print((b[n//2]+b[(n//2)+1])-(a[n//2]+a[(n//2)+1])+1)
# Judge status: Accepted
def main():
    a,b=map(int,input().split())
    p=b-a
    if b==1:print(0)
    elif p<=0:print(1)
    else:
        if p%(a-1)==0:print((p//(a-1))+1)
        else:print((p//(a-1))+2)
main()
# Judge status: Accepted
import sys
N=int(input())
A=list(map(int,input().split()))
if A[0]>=2:
  print(-1)
  sys.exit()
if A[0]==1:
  left=0
else:
  left=1
ans=A[N]
P=[1 for i in range(N+1)]
for i in range(1,N+1):
  point=left*2
  P[i]=point
  if point-A[i]<0:
    print(-1)
    sys.exit()
  left=point-A[i]
root=A[N]
for i in range(N,0,-1):
  root=min(P[i-1],root+A[i-1])
  ans+=root
print(ans)
# Judge status: Wrong Answer
# coding: utf-8
N=int(input())
A=[]
for i in range(N):
    A.append(int(input()))
cnt=0
flg=False
light=0

for i in range(N):
    light=A[light]-1
    cnt+=1
    if light==1:
        flg=True
        print(cnt)

if not(flg):
    print(-1)
# Judge status: Accepted
def solve():
	n = int(input())
	tasks = []
	for i in range(n):
		a, b = map(int,input().split())
		tasks.append((b,a))

	tasks.sort()

	t = 0
	for task in tasks:
		t += task[1]
		if t > task[0]:
			return False
	return True

print("Yes" if solve() else "No")
# Judge status: Wrong Answer

N, X, Y = input().split()
N = int(N)
X = int(X)
x = X - 1
Y = int(Y)
y = Y -1
ans = [0] * (N-1)
A = [[] * N for _ in range(N)]
for i in range(N):
    for j in range(N-i):
        path = min(abs(x- i) +1 +abs(y-i-j),j)
        ans[path] += 1
for _ in range(len(ans)):
    if _ == 0:
        continue
    print(ans[_])
# Judge status: Accepted
dp = [True] #i円の買い物ができるか
x = int(input())
for i in range(99):
  dp.append(False)
for i in range(100, x+1):
  if(i < 106):
    dp.append(True)
  else:
    if(dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]):
      dp.append(True)
    else:
      dp.append(False)
if(dp[x]):
  print(1)
else:
  print(0)
# Judge status: Wrong Answer
n,d = map(int ,input().split())
a = 2*d+1

for i in range(n):
    if a*i > n:
        print(i)

        break
# Judge status: Accepted
a = int(input())
s = str(input())
if(a >= 3200):
    print(s)
else:
    print("red")
# Judge status: Accepted
import itertools
N = int(input())
L = list(map(int,input().split()))
l_list = list(itertools.combinations(L, 3))
counter = 0
for n in l_list:
    i = n[0]
    j = n[1]
    k = n[2]
    if i != j and j != k and k != i:
        if (i < j + k) and (j < i + k) and (k < i + j):
            counter += 1
print(counter)
# Judge status: Accepted
import sys
import math
n, m = map(int, input().split())
mod = 10 ** 9 + 7
if n == m:
    ans = math.factorial(n) % mod
    ans = (ans * math.factorial(m)) % mod
    ans = (ans * 2) % mod
elif abs(n - m) >= 2:
    ans = 0
else:
    ans = math.factorial(n) % mod
    ans = (ans * math.factorial(m)) % mod
print(ans)
# Judge status: Wrong Answer
import math
N=int(input())
x,y=[0]*N,[0]*N
ans=0
for i in range(N):
    x[i],y[i]=map(int,input().split())
    if i==0:
        pass
    else:
        ans+=math.sqrt(pow(x[i-1]-x[i],2)+pow(y[i-1]-y[i],2))
print(ans)