peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
n = int(input())
s = input() #sys.stdin.readlineは最後が改行

r=[]
g=[]
b=[]

for i in range(n):
    if s[i] == 'R': r.append(i)
    elif s[i] == 'G': g.append(i)
    else: b.append(i)

ans=0
for i in r:
    for j in g:
        for k in b:
            i_, j_, k_ = sorted([i,j,k])
            if j_-i_ != k_-j_ :
                ans+=1
                print(i_,j_,k_)

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

if a <= b <= a + w or b <= a + w <= b + w:
    print(0)
elif a + w < b:
    print(b - a - w)
elif b+w < a:
    print(a - b - w)
# Judge status: Wrong Answer
import sys

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
A.sort()
C = []

for _ in range(M):
    if len(C) >= N:
        break
    b, c = map(int, input().split())
    for _ in range(b):
        C.append(c)

C.sort(reverse=True)

res = 0
lenC = len(C)
for i in range(N):
    if i < lenC and A[i] < C[i]:
        res += C[i]
    else:
        res += A[i]
print(res)
# Judge status: Accepted
from collections import Counter as C

_ = input()
a = C([int(x) for x in input().split()])

b = []
for k, v in a.items():
    for _ in range(v // 2):
        b.append(k)
else:
    if 2 <= len(b):
        b.sort()
        print(b[-1] * b[-2])
    else:
        print(0)
# Judge status: Wrong Answer
s = list(input())
y = list()

for i in range(1, len(s)):
	y = s[:len(s)-i]
	if i % 2 == 0:
		h = int(len(s[:len(s)-i]) / 2 )
		if y[:h] == y[h:]:
			print(len(y))
# Judge status: Accepted
def main():
    cards = [input() for _ in range(3)]
    next_turn = {"a": 0, "b": 1, "c": 2}
    answer = {}
    for person, index in next_turn.items():
        answer[index] = person.upper()
    now_turn = 0
    while True:
        if cards[now_turn] == "":
            print(answer[now_turn])
            break
        else:
            next = cards[now_turn][0]
            cards[now_turn] = cards[now_turn][1:]
            now_turn = next_turn[next]


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


# For taking integer inputs.
def inp():
    return(int(input()))


n = inp()
res = round(n/1.08)
if math.floor(res*1.08) >= n:
    print(res)
else:
    print(":(")
# Judge status: Accepted
s = list(input())
a_ind = []
z_ind = []
for i, v in enumerate(s):
    if v == "A":
        a_ind.append(i)

    if v == "Z":
        z_ind.append(i)

print((max(z_ind) - min(a_ind)) + 1 )
# Judge status: Wrong Answer
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]
h.sort()
l = []
for i in range(1, n):
    l.append(h[i]-h[i-1])
print(l[k-1])
# Judge status: Wrong Answer
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N, K = map(int, input().split())
D = input().split()

for n in range(N, 10000):
    s = str(n)
    ok = True
    for c in s:
        if c in D:
            ok = False
    if ok:
        print(n)
        break
# Judge status: Accepted
# author:  Taichicchi
# created: 28.09.2020 23:24:54

import sys

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

if (n == 1) & (m == 1):
    print(1)
elif n == 1:
    print(m - 2)
elif m == 1:
    print(n - 2)
else:
    print((n - 2) * (m - 2))
# Judge status: Accepted
import sys

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

A, B, C, K = lr()
if K%2 == 0:
    answer = A - B
else:
    answer = B - A

if answer > 10 ** 18:
    answer = 'Unfair'

print(answer)
# Judge status: Accepted
A, B = list(map(int, input().split()))
print(max(A+A-1,B+B-1,A+B))
# Judge status: Wrong Answer
def change(A,B,C):
    move=True
    a=A
    b=B
    c=C
    A=b+c
    B=a+c
    C=a+b
    if B-A==a-b:
        move=False
    return A,B,C,move
A,B,C,K=map(int,input().split())
ans=A-B
for i in range(K):
    A,B,C,move=change(A,B,C)
    ans=A-B
    if abs(ans)>1000000000000000000:
        print("Unfair")
        break
    elif not(move):
        print(ans)
        break
else:
    print(ans)
# Judge status: Wrong Answer
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    M = 1000
    S = 0
    A.append(0)

    for i in range(N):
        if A[i] < A[i+1]:
            S = M // A[i]
            M -= S * A[i]
        elif A[i] > A[i+1]:
            M += S * A[i]
            S = 0
    print(M)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,M=map(int,input().split())

graph=[set() for _ in range(N+1)]
for i in range(M):
  a,b=map(int,input().split())
  graph[a].add(b)
  graph[b].add(a)
#print(graph)  

for i in range(1,N+1):
  print(len(graph[i]))
# Judge status: Accepted
k,x=map(int,input().split())
for i in range(x-k+1,x+k):
    print(i,end=' ')
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
mini = 0
m = a % c
if m == 0:
  mini = a/c
else:
  mini = (c-m + a)/c
maxi = 0
M = b % c
if M == 0:
  maxi = b/c
else:
  maxi = (b-m)/c
res = int(maxi) - int(mini) + 1
print(res)
# Judge status: Accepted
from fractions import gcd


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] = (gcd(left[i], a[i]))
    right[n - i - 1] = (gcd(right[n - i], a[n - 1 - i]))

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i + 1]))
print(ans)
# Judge status: Accepted
n=int(input())
sum=0
for i in range(1,n+1):
  if i%3!=0 and i%5 !=0:
    sum+=i
print(sum)
# Judge status: Accepted
K, A, B = map(int, input().split())

if A + 2 >= B:
    print(1 + K)
    exit()

# ループに入るまでの操作
count = A
K -= (A - 1)
# これ以降はAを交換してBを繰り返す。２回ごとにBーA増えていく

count += (K // 2) * (B - A)
# B変換できない分のあまりは叩いて増やしておく
count += K % 2
print(count)
# Judge status: Accepted
x = int(input())
print(x//11*2 + (0 if x%11 == 0 else (1 if x%11 <= 6 else 2)))
# Judge status: Accepted
import sys
input = sys.stdin.readline
N,H=map(int,input().split())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)


amax=max(A)
#print(amax)
b=[]
for i in range(N):
    if B[i]>=amax:
        b.append(B[i])
b.sort()
#print(b)
cnt=0
while b:
    if H>0:
        H-=b.pop()
        cnt+=1
    if H<=0:
        print(cnt)
        exit()

cnt+=-(-H//amax)
print(cnt)
# Judge status: Accepted
import heapq
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
if k == 0:
    print(a[0])
    exit(0)
mean_a = sum(a) / k
q = []
for aa in a:
    d = max(math.floor(aa / mean_a), 1)
    q.append((-aa/d, d))
    k -= (d-1)
heapq.heapify(q)

for _ in range(k):
    aa, n = heapq.heappop(q)
    heapq.heappush(q, (aa*n/(n+1), n+1))

ans, _ = heapq.heappop(q)
print(math.ceil(-ans))
# Judge status: Wrong Answer
S = input()
mi = 9999999
for i in range(len(S) - 2):
  mi = min(mi, int(S[i]+S[i+1]+S[i+2]))
print(mi)
# Judge status: Accepted
inp = input()
print('Yes' if inp[2] == inp[3] and inp[4] == inp[5] else 'No')
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    a = [int(i) for i in readline().split()]
    s = 0
    P = int(1e9)+7
    for k in range(60):
        cnt = 0    
        for e in a:
            if (e>>k) & 1:
                cnt += 1
        s += cnt*(n-cnt)*pow(2, k, P)
        s %= P
    print(s)
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from collections import deque

h, k, *a = map(int, open(0).read().split())
if h <= k:
    print(k)
    exit()

a.sort()
q = deque(a)

[q.pop() for _ in range(k)]
print(q)
print(sum(q))
# Judge status: Wrong Answer
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(n):
  if p[i]==i+1:
    ans=ans+1
    if i!=n-1:
      if p[i+1]==i+2:
        ans=ans-1
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(n):
    if a[i]%2==0:
        b.append(a[i]/2)
fl=0
for i in range(len(b)):
    if b[i]%3==0 or b[i]%5==0:
        fl+=0
    else:
        fl+=1
if fl==0:
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Accepted
def lcm(data):
    from fractions import gcd
    x = data[0]
    for i in range(1, len(data)):
        x = (x * data[i]) // gcd(x, data[i])
    return x


k = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
z = lcm(a)
answer = 0
for j in range(n):
    answer += z // a[j]
print(answer % k)
# Judge status: Wrong Answer
#!/usr/bin/env python3
n, x, *l = map(int, open(0).read().split())
a = 0
while n > a and x >= 0:
    x -= l[a]
    a += 1
print(a)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
a = [readline().rstrip().decode() for _ in range(n)]
b = [readline().rstrip().decode() for _ in range(m)]
for y in range(n - m + 1):
    for x in range(n - m + 1):
        if [aa[x:x + m] for aa in a[y:y + m]] == b:
            print('Yes')
            exit()
print('No')
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k < n:
    c = 1
    n -= k
    while n > 0:
        n -= k-1
        c += 1
    print(c)
else:
    print(1)
# Judge status: Wrong Answer
x,k,d = map(int,input().split())
jud = x//d
if(k<=jud):
  print(abs(abs(x)-d*k))
else:
  if((k-jud%2) == 1):
    print(abs(abs(x)-(jud+1*d)))
  else:
    print(abs(abs(x)-jud*d))
# Judge status: Accepted
a,b,c=map(int,input().split())
if a+b+c<=21:
  print("win")
else:
  print("bust")
# Judge status: Accepted
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)  # aを優先度付きキューに

for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a, (-1)*(-tmp_min//2))  # 計算誤差の関係で-1を2回かけてます
print(-sum(a))
# Judge status: Accepted
A, B = map(int, input().split())
print('Possible' if (A*B%3==0) or ((A+B)%3==0) else 'Impossible')
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
count=0
#print(p)
p_sorted = sorted(p)
#print(p_sorted)

for i in range(n):
    #print(i)
    if p[i]!=p_sorted[i]:
        count+=1
        #print(count)

if count==0 or count==2:
    print("YES")
else :
    print("NO")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
sumA = sum(A)
numlist = [0]*(10**5 + 1)
for Aele in A:
    numlist[Aele] += 1
for i in range(Q):
    (B,C) = map(int,input().split())
    Bs = numlist[B]
    sumA = sumA + C*Bs - B*Bs
    numlist[B] = 0
    numlist[C] += Bs
    print(sumA)
# Judge status: Wrong Answer
from collections import Counter
n,k = map(int,input().split())
c = 0
list_A = Counter(list(map(int,input().split())))
t = len(list_A.keys())-k
if t<=0:
  print(0)
else:
  B =sorted(list_A.items(),key=lambda x:x[1])
  for j in range(t):
    c += B[j][1]
print(c)
# Judge status: Wrong Answer
s = [list(input()) for i in range(3)]
turn = s[0]
for i in range(300):
    if "a" == turn[0]:
        s[0] = turn = s[0][1:]
    elif "b" == turn[0]:
        s[1] = turn = s[1][1:]
    else:
        s[2] = turn = s[2][1:]
    if not s[0]:
        print("A")
        exit()
    if not s[1]:
        print("B")
        exit()
    if not s[2]:
        print("C")
        exit()
# Judge status: Accepted
S = list(map(int, input().split()))
S = sorted(S)
print("Yes" if S[0]+S[1] == S[2] else "No")
# Judge status: Accepted
h,w = map(int,input().split())

if h == 1 or w == 1:
    ans = 1
else:
    if (h*w) % 2 == 0:
        ans = int(h*w/2)
    else:
        ans = int(h*w//2 +1)
        
print(ans)
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    N = int(input())

    num_lists = [[int(item) for item in input().split()] for _ in range(N)]

    res = 0

    for a, b in num_lists[::-1]:
        temp_mod = (a + res ) % b
        if temp_mod > 0:
            res += b - temp_mod

    print(res)

if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
import itertools
import math

N = int(input())
xy  = [[int(i) for i in input().split()] for j in range(N)]
distance = [[0 for j in range(N)] for i in range(N)]
for i in range(N):
    for j in range(N):
        xi = xy[i][0]
        yi = xy[i][1]
        xj = xy[j][0]
        yj = xy[j][1]
        d = math.sqrt((xi-xj)**2+(yi-yj)**2)
        distance[i][j] = d
        distance[j][i] = d

print(sum([sum(i) for i in distance])*2/N)
# Judge status: Accepted
import math
import numpy as np

N, D = map(int, input().split())
ctr = 0

X = [list(map(int, input().split())) for i in range(N)]
X = np.array(X)

def cal_distance(a, b):
    distance = np.sqrt(np.sum((a - b) ** 2))
    return (distance)

for i in range(N):
    
    for j in range(i + 1, N):
        
        dis = cal_distance(X[i], X[j])
        if (math.floor(dis) == dis):
            ctr += 1

print(ctr)
# Judge status: Wrong Answer
a,b,c=input()
if a==b and b==c:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
n,x,t = map(int,input().split())

if n%x == 0:
  print(t*n//x)
else:
  print(t*n//x + t)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()
s="YES"
for i in range(n-1):
    if a[i]==a[i+1]:
        s="NO"
        break
print(s)
# Judge status: Wrong Answer
s=input()
t=input()
res=float("INF")
for i in range(len(s)):
    for j in range(len(t)):
        if s[i]==t[j] and i>=j and len(s)-i>=len(t)-j :
            tmp=j
            for k in range(j,len(t)):
                if i-j+k<(len(s)) and s[i-j+k] != t[k]:
                    tmp+=1
            res=min(res,tmp)
print(res)
# Judge status: Accepted
#C - Unification
import collections
S = input()
S1 = [int(x) for x in list(str(S))]

c = collections.Counter(S1)
#print(c)
ans = 2*min(c[0],c[1])
print(ans)
# Judge status: Accepted
a,b,k = map(int,input().split())

if b-a < 2*k:
  for i in range(a, b+1):
    print(i)
else:
  for i in range(k):
    print(a+i)
  for i in range(k):
    print(b-k+1+i)
# Judge status: Accepted
N,M=map(int,input().split())
seiseki=[[0]*N for _ in range(2)]
for i in range(M):
  p,S=input().split()
  p=int(p)
  if seiseki[1][p-1]==0:
    if S=='WA':
      seiseki[0][p-1]+=1
    else:
      seiseki[1][p-1]=1
AC=sum(seiseki[1])
WA=0
for i in range(N):
  if seiseki[1][i]==1:
    WA+=seiseki[0][i]
print(AC,WA)
# Judge status: Accepted
n = int(input())

_sum = 0
_tmp = 0
while _sum <= n:
    _tmp += 1
    _sum += _tmp
    if _sum >= n:
        break

ans = []
while n:
    if n - _tmp < 0:
        _tmp -= 1
    else:
        ans.append(_tmp)
        n -= _tmp
        _tmp -= 1

for i in ans:
    print(i)
# Judge status: Accepted
n,m = map(int,input().split())
print(abs(n-2)*abs(m-2))
# Judge status: Wrong Answer
N, K = map(int, input().split())
count = 1
while True:
    N = N // K
    count += 1
    if N <= K:
        break
print(count)
# Judge status: Accepted
x,y=map(int,input().split())
ans=1
while True:
  x*=2
  if x>y:
    break
  else:
    ans+=1

print(ans)
# Judge status: Accepted
K = int(input())
A,B = map(int, input().split())
for i in range(A,B+1):
  if i % K == 0:
    print('OK')
    exit(0)
print('NG')
# Judge status: Accepted
import math

X = int(input())
yokin = 100
ans = 0
while yokin < X:
    yokin = int(yokin*1.01)
    
    ans += 1

print(ans)
# Judge status: Accepted
a,b,k = map(int,input().split())
x = []
for i in range(1,a+1):
    if a%i == 0 and b%i == 0:
        x.append(i)
print(x[-k])
# Judge status: Accepted
n=int(input())
dp=[0]*(n+1)
for i in range(n+1):
  t=i
  count=0
  while t>0:
    count+=t%6
    t//=6
  t=n-i
  while t>0:
    count+=t%9
    t//=9
  dp[i]=count
print(min(dp))
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

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

for i in range(K):
    a = A
    b = B
    c = C

    A = b + c
    B = a + c
    C = a + b

ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans <= -1*10**8:
    ans = 'Unfair'

print(ans)
'''



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

if K%2==1: 
    ans = B - A
else:
    ans = A - B

if ans >= 10**8:
    ans = 'Unfair'
elif ans <= -1*10**8:
    ans = 'Unfair'

print(ans)
# Judge status: Wrong Answer
x,y,z = map(int,input().split())
s = 0
count = 0

for i in range(10**99):
  s += y+z
  count += 1
  if s > x:
    break
  
if s - z <= x:
  print(count)
elif s-z > x:
  print(count-1)
# Judge status: Wrong Answer
n=int(input())
b=list(map(int,input().split()))
k=[]
if n>2:
    for i in range(n-2):
        if i==0:k.append(b[i])
        k.append(min(b[i],b[i+1]))
    k.append(b[-1])
else:k.append(b[-1])
print(sum(k))
# Judge status: Wrong Answer
import math

def main():
    a, b, x = map(int, input().split())
    if(x <= (a * b * b) / 2): 
        tan_th = (a * b * b) / (2 * x)
    else:
        tan_th = (2 * a * a * b - 2 * x) / (a * a * a)
    ans = math.degrees(math.atan(tan_th))
    print(ans)
    return 0
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
blue = [input() for _ in range(n)]

m = int(input())
red = [input() for _ in range(m)]

price_max = 0
for a in blue:
    if (blue.count(a) - red.count(a)) > price_max:
        price_max = blue.count(a) - red.count(a)
print(price_max)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
money=1000
stock=0
for i in range(n-1):
  if a[i]>a[i+1]:
    money+=stock*a[i]
    stock=0
  else:
    stock+=money//a[i]
    money=money%a[i]
print(money+stock*a[n-1])
# Judge status: Accepted
N, K, S = map(int, input().split())
A = []
for i in range(K):
    A.append(S)

if S != 10 ** 9:
    res = S + 1
else:
    res = 1

for j in range(N - K):
    A.append(res)
print(*A)
# Judge status: Accepted
a,b = input().split()
times = int(a)*int(b)

if times%2 == 0:
  print("Even")
else:
  print("Odd")
# Judge status: Accepted
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
a=[]
for i in range(1,m):
    a.append(x[i]-x[i-1])

a.sort()
a.reverse()

ans=sum(a)-sum(a[0:n-1])
print(ans)
# Judge status: Accepted
N = int(input())
S = list(map(int,input().split()))

ans = 0
if N < 3:
    ans = 0
else:
    for i in range(N):
        for j in range(i,N):
            for k in range(j,N):
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    if S[i] + S[j] > S[k] and S[j] + S[k] > S[i] and S[k] + S[i] > S[j]:
                        ans += 1
print(ans)
# Judge status: Accepted
S=input()
T=len(S)
a=0
d=1
mod=[0]*2019
mod[0]+=1
for i in range(T):
 a+=(int(S[T-i-1])*(d))%2019
 b=a%2019
 mod[b]+=1
 d*=10
 d%=2019
c=0
for i in range(2019):
 if mod[i]>=2:
  c+= mod[i]*(mod[i]-1)/2
print(int(c))
# Judge status: Accepted
X, Y, Z = map(int, input().split())
print(str(Z) + ' ' + str(X) + ' ' + str(Y))
# Judge status: Accepted
import heapq
from collections import deque

N, M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])
d=deque(AB)
h=[]
ans=0
for i in range(M+1):
    while d and d[0][0]<=i:
        heapq.heappush(h, -d.popleft()[1])
    if h:
        ans-=heapq.heappop(h)
print(ans)
# Judge status: Wrong Answer
N = int(input())

flag = 0

for i in range(N):
    a,b = map(int,input().split())
    if a == b:
        flag += 1
    else:
        flag = 0

if flag >= 3:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import numpy as np

X, N = map(int, input().split())
P = set(map(int, input().split()))
Q = set(range(101))
P = np.array(list(Q - P))
Q = np.abs(P - X)
Q = np.where(Q == Q.min())

print(P[Q].min())
# Judge status: Accepted
a,b = input().split()
print('Yes' if a!=0 and a==b else 'No')
# Judge status: Accepted
D, N = map(int, input().split())

D = 100 ** D
if N<= 99:
    print(D*N)
else:
    print(D*101)
# Judge status: Accepted
n = int(input())
candy = 0
for i in range(n):
    i += 1
    candy += i
print(candy)
# Judge status: Accepted
n = int(input())
s = str(input())
a = 0
c = len(s)//2
if n % 2 == 0:
  for i in range(c):
    if s[i] == s[c+i]:
      a += 1
  if a == n/2 :
    print("Yes")
  else :
    print("No")
else :
  print("No")
# Judge status: Wrong Answer
n=int(input())
a=[2,1]
for i in range(n-2):
  a+=[sum(a[-2:])]
print(a[n-1])
# Judge status: Wrong Answer
n,k=map(int,input().split())
p=list(map(int,input().split()))
for i in range(n):
    p[i]=(p[i]+1)/2
print(p)
q=[]
for i in range(n-k+1):
    q.append(p[i:k+i])
q.sort()
print(sum(q[n-k]))
# Judge status: Wrong Answer
n = float(input())
cnt = 0
while True:
    r = float(n % 10)
    n = float((n-r) / 10)
    cnt += r
    if n == 0:
        break
res = cnt % 9
if res == 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

lcm_ = lcm_ % mod
ans = 0
for i in range(N):
    ans += (lcm_ // A[i]) % mod

print(ans % mod)
# Judge status: Accepted
#create date: 2020-04-26 08:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = na()
    ans = 0
    for i in range(n):
        res = min(b[i], a[i])
        b[i] -= res
        ans += res
        res = min(a[i+1], b[i])
        a[i+1] -= res
        ans += res
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
from functools import reduce

def my_gcd(*N):
    return reduce(math.gcd, N)

N, X = map(int,input().split())
C = list(map(int,input().split()))

if X not in C:
	C.append(X)
C.sort()

D = []
for i in range(len(C)-1):
	D.append(C[i+1] - C[i])

print(my_gcd(*D))
# Judge status: Accepted
MM = input().split()
M1 = ''.join(MM)
M = int(M1)
import math
L =math.sqrt(M)
N = int(L)*int(L)
if N ==M:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys

S = input()

if S[0] == 'A' and S[2:-1].count('C') == 1:
    s = S.replace('A', 'a', 1).replace('C', 'c', 1)
    if s == S.lower():
        print('AC')
        sys.exit()

print('WA')
# Judge status: Accepted
def main():
  num = [int(input()) for i in range(2)]
  print(6-num[0]-num[1])

main()
# Judge status: Accepted
# 二分探索
import bisect

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

#リストをソート
a=sorted(a)
b=sorted(b)
c=sorted(c)

count=0
#a[i]の個数
for i in range(n):
    a_count = bisect.bisect_left(a, b[i])
    c_count = bisect.bisect_right(c, b[i])
    count+=a_count*(len(c)-c_count)

print(count)
# Judge status: Wrong Answer
N = int(input())
V = list(map(int, input().split()))
V.sort()
x = V[0]
for i in range(N-1):
    x += V[1]
    x /= 2
print(x)
# Judge status: Wrong Answer
m = input()
c = m[-1]
if c == 's':
  print(m+'es')
else:
  print(c+'s')
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = str(input())

# ##となっていたら無理
# C < D のとき、それぞれが移動可能かでわかる
# C > D のときは? 追い越しは...となる箇所があればいける

if '##' in S[min(A, B)-1:max(D, C)]:
    print('No')
    quit()

if C < D:
    print('Yes')
else:
    if '...' in S[B-2:D+1]:
        print('Yes')
        quit()
    print('No')
# Judge status: Accepted
d, t, s = map(int, input().split())
if t*s >= d:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x, a, b = map(int, input().split())

x_a = abs(x-a)
x_b = abs(x-b)

if (x_a > x_b):
    print("B")

else:
    print("A")
# Judge status: Accepted
[N,K] = list(map(int,input().split()))
A = list(map(int,input().split()))

for j in range(min(K,50)):
    NextA = [0]*N
    for i in range(N):
        l = max(0, i-A[i])
        r = min(N-1, i+A[i])

        NextA[l]+=1
        if r+1<=N-1:
            NextA[r+1]-=1

    for i in range(1,N):
        NextA[i] += NextA[i-1]
    A = NextA[:]

print(*NextA)