peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import Counter

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

ans = sum(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    ans += (c - b) * ac[b]
    ac[c] += ac[b]
    ac[b] = 0
    print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
G=[]
for _ in range(m):
  p,y=map(int,input().split())
  G.append([p,y,_])
  
G.sort(key=lambda x:x[0])
G.sort(key=lambda x:x[1])
p=G[0][0]
cnt=0
A=[None]*m
for i in range(m):
  if p<G[i][0]:
    p+=1
    cnt=1
  else:
    cnt+=1
  P=str(p).zfill(6)
  Y=str(cnt).zfill(6)
  A[G[i][2]]=P+Y

for a in A:
  print(a)
# Judge status: Accepted
#!/usr/bin/env python3

s = int(input())



if s <= 2:
    print(0)
else:
    a = [0] * (s + 1)
    a[0] = 1
    for i in range(3, s + 1):
        a[i] = int((a[i - 1] + a[i - 3]) % (1e9 + 7))

    print(a[s])
# Judge status: Accepted
import itertools
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
cands = itertools.permutations(range(1,N+1))
cands = [list(e) for e in cands]
print(abs(cands.index(P) - cands.index(Q)))
# Judge status: Accepted

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

from heapq import heappush, heappop

queue = []
for a in A:
  heappush(queue, -a)

for i in range(M):
  x = -heappop(queue)
  heappush(queue, -(x // 2))

print(-sum(queue))
# Judge status: Wrong Answer
print('YNeos'[sorted(input())!='abc'::2])
# Judge status: Wrong Answer
k=int(input())

que=list(range(1,9+1))

while True:
 k-=len(que)
 for q in que[:]:
    que.remove(q)
    lq=int(str(q)[-1])
    for r in (lq-1,lq,lq+1):
        if 0<=r<=9:
            que.append(int(str(q)+str(r)))
 # print(que)
 
 if len(que)>=k:
    break
 
que.sort()
print(que[k-1])
# Judge status: Wrong Answer
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

w = l()

cnt = 0
w.sort()
for i in range(len(w) - 1):
	print(cnt)
	if w[i] == w[i+1]:
		cnt += 1
		if  i == len(w) - 2:
			print("No")
			exit()
	elif w[i] != w[i+1]:
		if cnt%2 == 0:
			print("No")
			exit()
		cnt = 0
	
print("Yes")
# Judge status: Accepted
n = int(input())

aList = []
bList = []
for i in range(n):
    a, b = map(int, input().split())
    aList.append(a)
    bList.append(b)

aList.sort()
bList.sort()


if not n % 2 == 0:
    half = (n+1) // 2 - 1
    print(bList[half] - aList[half] + 1)
else:
    half = (n) // 2 - 1
    print(bList[half] + bList[half+1] - (aList[half] + aList[half+1]) + 1)
# Judge status: Wrong Answer
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
flag=0
n=int(input())
for i in range(n):
  a=int(input())
  if a in l1 or a in l2 or a in l3:
    flag=1 
if(flag==1):
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

if b > 0 and d > 0:
    print(max(b*d, a*c))
elif b > 0 and d < 0:
    print(a*d)
elif b < 0 and d > 0:
    print(b*c)
elif b <= 0 and d <= 0:
    print(a*c)
# Judge status: Wrong Answer
As = list(map(int, input().split()))

print("bust" if sum(As) >22 else "win")
# Judge status: Accepted
N,K=map(int, input().split())
R,S,P=map(int, input().split())
T=list(input())
D={"r":P, "s":R, "p":S}
result=["none"]*N
ans=0
for i in range(N):
    if i<K:
        ans+=D[T[i]]
        result[i]=T[i]
    else:
        if T[i]!=result[i-K]:
            ans+=D[T[i]]
            result[i]=T[i]
print(ans)
# Judge status: Wrong Answer
N = int(input())
l = list(input())
 
rev = 0
 
# for i in range(1, len(l)-1):
#   if l[i-1] == 'W' and l[i] == 'R':
#    l.insert(0, l.pop(i))
 
rl = l.count('R')
wl = l.count('W')
 
print(rl if rl < wl else wl)
# Judge status: Wrong Answer
import math
K = int(input())

ans = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += math.gcd( math.gcd(i,j) , k )

print(ans)
# Judge status: Accepted
import sys
n,m = map(int,input().split())
a = []
for i in range(n):
    a.append(input())
b = []
for i in range(m):
    b.append(input())

for i in range(n-m+1):
    for j in range(n-m+1):
        find = True
        for k in range(m):
            if not a[i+k][j:j+m] == b[k]:
                find = False
                break
        if find:
            print("Yes");sys.exit()
print("No")
# Judge status: Accepted
N, K = map(int, input().split())

A_list = [[0, j] for j in range(N)]
B_list = [0] * N

for i in range(N):
    A_list[i][0], B_list[i] = map(int, input().split())

A_list.sort()
sort_key = [j[1] for j in A_list]
B_list_sort = [B_list[j] for j in sort_key]

for i in range(10 ** 5):
    K -= B_list_sort[i]
    if K <= 0:
        print(A_list[i][0])
        break
# Judge status: Wrong Answer
n = int(input())

ans = []
def dfs(A):
    if len(A) == n:
        ans.append(''.join(A))
        return
    for i in range(len(A)+1):
        v = chr(i+ord('a'))
        A.append(v)
        dfs(A)
        A.pop()

dfs([])
ans.sort()
for i in range(len(ans)):
    print(ans[i])
# Judge status: Accepted
from collections import Counter
import copy
from itertools import combinations


def A(x):
  return 'Yes' if x >= 30 else 'No'


def B(N, D, X, Y):
  ans = 0
  for i in range(N):
    Di = X[i]**2 + Y[i]**2
    if Di <= D**2:
      ans += 1
  return ans


def main():
  N, D = map(int, input().split())
  X = []
  Y = []
  for i in range(N):
    Xi, Yi = map(int, input().split())
    X.append(Xi)
    Y.append(Yi)
  print(B(N, D, X, Y))


if __name__ == '__main__':
  main()
# Judge status: Wrong Answer
#145 b
n=int(input())
s=input()
ans="No"
if n%2==1:
    print(ans)
else:
    x=int(n/2)
    if s[0:x]==s[x:]:
        ans="Yes"
print(ans)
# Judge status: Accepted
s = input()
d = {'SUN':0,'MON':1,'TUE':2,'WED':3,'THU':4,'FRI':5,'SAT':6}
print(7-d[s])
# Judge status: Accepted
n = int(input())
r_set = set()
for i in range(n):
	a = int(input())
	if a in r_set:
		r_set.remove(a)
	else:
		r_set.add(a)
print(len(r_set))
# Judge status: Wrong Answer
s = list(input().split())
t = list(input().split())
del t[-1]

if s == t:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
memo = {}
ans = []

for i in range(n):
  	a = input()
  	if a in memo:
  	    memo[a] += 1
  	    if a in ans:
  	        pass
  	    else:
  	        ans.append(a)
  	else:
  	    memo[a] = 1

max_n = 0
saigo = "a"

for i in range(len(ans)):
    if memo[ans[i]] > max_n:
        max_n = memo[ans[i]]
        saigo = ans[i]
    elif memo[ans[i]] == max_n:
        saigo += " " + ans[i]


for i in saigo.split():
    print(i)
# Judge status: Accepted
N,K = map(int,input().split())
H = sorted([int(input()) for n in range(N)])
A = []

for n in range(N-K+1):
  A+=[H[n+K-1]-H[n]]

print(min(A))
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int, input().split())))

ans = 10 ** 10
for i in range(min(a), max(a) + 1):
    val = sum([(x - i) ** 2 for x in a])
    ans = min(ans, val)

print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 17:58:03 2020

@author: shinba
"""


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

if a+b >= c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    BC = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])
    C = []
    for b, c in BC:
        if len(C) >= n:
            break
        C += [c] * b
    A += C
    A.sort(reverse=True)
    res = sum(A[:n])
    print(res)


if __name__ == '__main__':
    resolve()
# Judge status: Wrong Answer
x,y,a,b,c=map(int,input().split())
P=sorted(list(map(int,input().split())))[::-1]
Q=sorted(list(map(int,input().split())))[::-1]
R=sorted(list(map(int,input().split())))[::-1]+[0]*(x+y)
L=sorted(P[:x]+Q[:y])[::-1]
l=r=0
for i in range(x+y):    
    if r+R[i]<l+L[-i-1]:
        print(sum(L[:x+y-i])+r)
        exit()
    r+=R[i]
    l+=L[-i-1]
print(r)
# Judge status: Wrong Answer
def gcd(a,b,c):
  x=0
  for i in range(min([a,b,c])):
    if a%(i+1)==0 and b%(i+1)==0 and c%(i+1)==0:
      x=i
  return x

def sum(k):
  s=0
  for x in range(k+1):
    for y in range(k+1):
      for z in range(k+1):
        s+=gcd(x+1,y+1,z+1)
  return s
i=int(input())
o=sum(i)
print(o)
# Judge status: Accepted
a= sum(map(int,input().split()))
if a > 21:
    print('bust')
else:
    print('win')
# Judge status: Wrong Answer
n = int(input())
ls = [list(map(str,input().split())) for _ in range(n)]
nums = [e for e in range(1,n+1)]
for i in range(n):
    ls[i][0] = ls[i][0] + str(100-int(ls[i][1]))
    ls[i] = ls[i] + [nums[i]] 
ls = sorted(ls)
for i in range(n):
    print(ls[i][2])
# Judge status: Accepted
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

dp = [0] * n
for i in range (n):
     dp[i] = sum(a1[0:i+1]) + sum(a2[i:n])

print(max(dp))
# Judge status: Wrong Answer
N,M=map(int,input().split())
l=[list(map(int,input().split()))for i in range(M)]
min=0
max=1000000
for i in l:
    if i[0]>=min:
        min=i[0]
    if i[1]<=max:
        max=i[1]
print(max-min+1)
# Judge status: Accepted
X,Y = map(int,input().split())
mod = 10**9+7



def p(m,n):
  a = 1
  for i in range(n):
    a = (a*(m-i)) % mod
  return a

def c(m,n):
  return p(m,n)*pow(p(n,n),mod-2,mod) % mod

if (X+Y) % 3 == 0 and Y//2 <= X <= Y*2:
  print(c((X+Y)//3,(2*X-Y)//3))
else:
  print(0)
# Judge status: Accepted
n=int(input())
D = [list(map(int,input().split())) for i in range(n)]
for i in range(n-2):
  if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
    print("Yes")
    break
else:
  print("No")
# Judge status: Accepted
n=int(input())
c=[];s=[];f=[]
for i in range(n-1):
    ci,si,fi=map(int,input().split())
    c.append(ci);s.append(si);f.append(fi)
for i in range(n-1):
    ans=s[i]+c[i]
    for j in range(i+1,n-1):
        tmp=ans
        if s[j]>=tmp:
            ans+=s[j]-tmp+c[j]
        else:
            ans+=f[j]-((tmp-s[j])%f[j] if (tmp-s[j])%f[j]!=0 else f[j])+c[j]
    print(ans)
print(0)
# Judge status: Wrong Answer
X=int(input('X='))
if 400<=X<=599:
    print(8)
elif 600<=X<=799:
    print(7)
elif 800<=X<=999:
    print(6)
elif 1000<=X<=1199:
    print(5)
elif 1200<=X<=1399:
    print(4)
elif 1400<=X<=1599:
    print(3)
elif 1600<=X<=1799:
    print(2)
elif 1800<=X<=1999:
    print(1)
# Judge status: Accepted
s=input()

if s.count("N")>0 and s.count("S")==0:
    print("No")
    exit()
if s.count("S")>0 and s.count("N")==0:
    print("No")
    exit()
if s.count("W")>0 and s.count("E")==0:
    print("No")
    exit()
if s.count("E")>0 and s.count("W")==0:
    print("No")
    exit()
else:
    print("Yes")
# Judge status: Accepted
N = int(input())

x, y = map(int, input().split())
mz = Mz = x + y
mw = Mw = x - y

for i in range(N-1):
    x, y = map(int, input().split())
    z = x + y
    w = x - y
    mz = min(mz, z)
    Mz = max(Mz, z)
    mw = min(mw, w)
    Mw = max(Mw, w)

print(max(Mz-mz, Mw - mw))
# Judge status: Accepted
H1,M1,H2,M2,K = map(int,input().split())

H1,H2 = 60*H1,60*H2

AM = H1+M1
PM = H2+M2
ans = PM-AM-K
print(ans)
# Judge status: Wrong Answer
import math
X = int(input())
N = int(X**(1/5))
for a in range(N+10):
    M = X-(a**5)
    if M < 0:
        continue
    M **= 1/5
    M = int(M)+10
    for b in reversed(range(M)):
        if a**5 + b**5 == X:
            print(a,-b)
            exit()
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

sum=0
num=[0]*(10**5+1)
for i in range(n):
    sum+=a[i]
    num[a[i]]+=1

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    sum+=(c-b)*num[b]
    print(sum)
    num[c]+=num[b]
    num[b]=0
# Judge status: Accepted
import math

a, b, n = map(int, input().split())
m = min(b - 1, n)
ans = math.floor((a * m) / b) - a * math.floor(m / b)
print(ans)
# Judge status: Wrong Answer
x,n=[int(i) for i in input().split()]
p=[int(i) for i in input().split()]
np=[i for i in range(0,101) if not i in p]
r=0
for i in np:
    if abs(x-i)<abs(x-r):
        r=i
print(r)
# Judge status: Accepted
S = [s for s in input()]
h = 'hi'
if len(S)%2 != 0:
    print('No')
    exit()
flag = 1
while S:
    if len(S) >= 2:
        s1 = S.pop(0)
        s2 = S.pop(0)
        tmp = s1+s2
        if tmp == h:
            continue
        else:
            flag = 0
if flag:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from collections import deque
k = int(input())

q = deque([i for i in range(1,10)])
for i in range(k):
  a = q.popleft()
  
  if a%10 != 0:
    q.append(a*10 + a%10 - 1)
    
  q.append(a*10 + a%10)
  
  if a%10 != 9:
    q.append(a*10 + a%10 + 1)
print(a)
# Judge status: Accepted
x, y = map(int, input().split())
diff = abs(x - y)
ref = (min(x, y) - diff)//3
total = ref*2 + diff
mod = 10**9 + 7
ans = 1
ie = 1

if (x + y)%3 != 0 or ref < 0:
    print(0)
    exit()


for i in range(min(ref, total - ref)):
    ans = ans*(total - i)%mod
    ie = ie*(i + 1)%mod

ie = pow(ie, mod - 2, mod)
ans = ans*ie%mod
print(ans)
# Judge status: Accepted
money = 100
ans = 0
X = int(input())
while money < X:
    money = int(money * 1.01)
    ans += 1
print(ans)
# Judge status: Accepted
import sys
c = [list(map(int, input().split())) for _ in range(3)]

x = []
for i in range(3):
    x.append([c[i][1]-c[i][0], c[i][2]-c[i][0], c[i][2]-c[i][1]])
if x[0] != x[1] or x[1] != x[2]:
    print("No")
    sys.exit()

y = []
for j in range(3):
    y.append([c[1][i]-c[0][i], c[2][i]-c[0][i], c[2][i]-c[1][i]])
if y[0] != y[1] or y[1] != y[2]:
    print("No")
    sys.exit()
print("Yes")
# Judge status: Accepted
A, B = map(int,input().split())
print(A*B)
# Judge status: Wrong Answer
n = input()
digits = list(map(int, list(n)))

s = 0
up = 0
for i, digit in enumerate(digits[::-1], 1):
    if digit + up == 10:
        up = 1
    elif digit + up <= 5:
        s += digit + up
        up = 0
    else:
        s += 10 - digit - up
        up = 1
else:
    s += up
print(s)
# Judge status: Wrong Answer
x=int(input())

a=x%11
b=x//11
print(a,b)
if 0<a<6:
    ans=2*b+1
elif a==0:
    ans=2*b
elif 5<a<11:
    ans=2*(b+1)
print(ans)
# Judge status: Wrong Answer
def main():
    A, B, C = map(int, input().split())
    K = int(input())
    for i in range(K):
        if A > B and A > C:
            A = 2*A
        if B > A and B > C:
            B = 2*B
        if C > A and C > B:
            C = 2*C
    print(sum([A, B, C]))
main()
# Judge status: Wrong Answer
import math


X,Y=map(int, input().split())
if math.isclose(-Y//2+2*X, round(-Y//2+2*X)) and math.isclose(Y//2-X, round(Y//2-X)) and Y//2-X>0 and -Y//2+2*X>0:
    print("Yes")

else:
    print("No")
# Judge status: Accepted
H1,M1,H2,M2,K = map(int, input().split(' '))

#print(H1,M1,H2,M2,K)

# 開始時刻から終了時刻までの長さを分に変換し、勉強時間を減産する

start = (H1 * 60) + M1
end = (H2 * 60) + M2

#print("{0}分から{1}分まで勉強する".format(start, end))

goal = end - start - K

print(goal)
# Judge status: Accepted
X, Y = [int(i) for i in input().split()]

output = 0

while Y >= X:
    X = 2 * X
    output += 1
    
print(output)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
cnt=1
ans=0
for i in range(n):
  if p[i]==i+1:
    cnt+=1
  else:
    ans+=cnt//2
    cnt=1
print(ans+cnt//2)
# Judge status: Wrong Answer
N, M = map(int,input().split())
A = list(map(int,input().split()))
print(A)
for i in range(M):
  max_item = A.index(max(A))
  A[max_item] //= 2
print(sum(A))
# Judge status: Accepted
a, b, c = map(int, input().split())

a1 = (b + c) / 2
b1 = (a + c) / 2
c1 = (a + b) / 2

diffs = [abs(a-a1), abs(b-b1), abs(c-c1)]

ans = []
for tmpdiff in diffs:
  count = 1
  while tmpdiff % 2 == 0:
    tmpdiff = tmpdiff / 2
    count += 1
    if tmpdiff == 0:
      count = -1
      break
      
  ans.append(count)

if not (a%2 ==0 and b%2 ==0 and c%2 ==0):
  print(0)
elif ans == [-1 for _ in range(len(ans))]:
  print(-1)
else:
  print(min([i for i in ans if i >0]))
# Judge status: Accepted
import math
h,w=map(int,input().split())

if h==1 or w==1:
    print(1)
else:
    print(math.ceil(h*w/2))
# Judge status: Accepted
T = int(input())
if T >= 30:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N = int(input())
T = []
XY = []


def f(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)


print('No')
exit()

cx, cy = 0, 0
ct = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    d = f(cx, cy, x, y)
    if d > t - ct:
        print('No')
        exit()
    if (t - ct - d) % 2 != 0:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
n, m = map(int, input().split())
if n != 1 and m != 1:
    ans = (n-2) * (m-2)
elif n == m == 1:
    ans = 1
elif n == 1 and m != 1:
    ans = m-2
else:
    ans = n-2
print(ans)
# Judge status: Wrong Answer
s=list(input())
d=["A","C","G","T"]
ans=0
cnt=0
for c in s:
  if c in d:
    cnt+=1
  else:
    ans=max(cnt,ans)
    cnt=0
print(ans)
# Judge status: Wrong Answer
n=int(input())
s=[]
for i in range(n):
    s.append(input().split()+[str(i+1)])
print(s)
s=sorted(s)
print(s)
for i in range(n):
    print(s[i][-1])
# Judge status: Accepted
c = [list(map(int, input().split())) for _ in range(3)]
if c[1][1] != c[1][0] - c[0][0] + c[0][1]:
    print('No')
elif c[1][2] != c[1][0] - c[0][0] + c[0][2]:
    print('No')
elif c[2][1] != c[2][0] - c[0][0] + c[0][1]:
    print('No')
elif c[2][2] != c[2][0] - c[0][0] + c[0][2]:
    print('No')
else:
    print('Yes')
# Judge status: Accepted
x = int(input())

num = x // 3
rem = x % 3

if rem == 1:
    res = (num+1)*(num**2)

elif rem == 2:
    res = ((num + 1) ** 2) * num

else:
    res = num ** 3

res2 = (x/3)**3
if res > res2:
    print(res)
else:
    print(res2)
# Judge status: Accepted
A = int(input())
B = int(input())

choices = [1, 2, 3]

choices.remove(A)
choices.remove(B)

print(*choices)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort()
l = a[n - 1]
c, d = 0, 0
for i in a:
    if i < l / 2:
        c = i
    else:
        d = i
        break
if (l / 2) - c <= d - (l / 2):
    r = c
else:
    r = d
print(l, r)
# Judge status: Accepted
import collections

n=int(input())

A=[]
for _ in range(n):
    s=sorted(input())
    A.append("".join(s))

B=collections.Counter(A)
C=list(B.values())

cnt=0
for i in C:
    cnt+=(i*(i-1))//2

print(cnt)
# Judge status: Accepted
import collections
S=input()[::-1]
l=len(S)
T,d=0,1
A=[0]*2019
A[0]=1
for i in range(l):
    T+=int(S[i])*d
    d*=10
    T%=2019
    d%=2019
    A[T]+=1
ans=0
for cnt in A:
    ans+=cnt*(cnt-1)//2
print(ans)
# Judge status: Accepted
h, n = map(int, input().split())
a = [int(x) for x in input().split()]
total = 0

for i in a:
    total += i

if h <= total:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A, B, C, D = map(int, input().split())
def gcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a
def lcm(a,b):
    return int(a*b / gcd(a,b))
X = A-B
Y = lcm(C,D)
i = B//C-(A-1)//C
j = B//D-(A-1)//D
k = B//Y-(A-1)//Y
print(int(B-A+1-(i+j-k)))
# Judge status: Wrong Answer
import itertools
n, m, q = list(map(int, input().split()))
queries = [list(map(int, input().split())) for _ in range(q)]

nums = [i for i in range(1, 10)]
ans = 0
for nums in itertools.combinations_with_replacement(nums, r=n):
	tmp = 0
	for query in queries:
		if nums[query[1] - 1] - nums[query[0] - 1] == query[2]:
			tmp += query[3]
	ans = max(ans, tmp)
print(ans)
# Judge status: Accepted
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
num=[0]*(3*n)
num[1]=a[0]
for i in range(1,n):
    num[2*i],num[2*i+1]=a[i],a[i]
ans=0
for i in range(n):
    ans+=num[i]
print(ans)
# Judge status: Accepted
o = b = c = 0;input()
for i, x in enumerate(input().split()):
    x = int(x)
    s = x - b if i else 0
    d = (s>0)-(s<0)
    if abs(d - o) > 1:
        c += 1
        o = 0
    else:
      o = d or o
    b = x
print(c+1)
# Judge status: Wrong Answer
N = int(input())
cards = list(map(int, input().split()))
cards.reverse() 
print(sum(cards[0::2])-sum(cards[1::2]))
# Judge status: Accepted
a,s=open(0)
print(s*(a>'32')or'red')
# Judge status: Accepted
a, b = map(int, input().split())
ans = a + b
if ans >= 24:
    ans = ans - 24
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())

print(abs((N-2)*(M-2)))
# Judge status: Accepted
import math
n = int(input())
temp_p = math.ceil(n / 1.08)
if math.floor(temp_p * 1.08) == n:
    print(temp_p)
else:
    print(":(")
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
m=sum(l)/n
if m-int(m) < 0.5:
  m=int(m)
else:
  m=int(m)+1
print(sum([(k-m)**2 for k in l]))
# Judge status: Wrong Answer
x=int(input())
ans=[]
for i in range(13):
    for j in range(13):
        for k in range(13):
            for l in range(13):
                for m in range(13):
                    for n in range(13):
                        ans.append(100*i+101*j+102*k+103*l+104*m+105*n)
print(1 if x in ans else 0)
# Judge status: Accepted
a=int(input())
b=list(map(int,input().split()))
"""
import statistics
import math
median = statistics.median(b) 中央値出そうとした
print(median)
"""
b.sort()
c=int(a/2)
print(b[c]-b[c-1])
# Judge status: Accepted
W, H, x, y = map(int, input().split())
print(W * H / 2, 1 if x * 2 == W and y * 2 == H else 0)
# Judge status: Accepted
s = input()
t = input()
s = sorted(s)
t = sorted(t,reverse=True)
s = "".join(s)
t = "".join(t)
if s<t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
lst = list(map(int, input().split()))
lst = sorted(lst)
print('Yes' if lst[0] + lst[1] == lst[2] else 'No')
# Judge status: Wrong Answer
x=int(input())
t=0
while x>0:
  if x%7==0:
    t+=1
  x-=4
print(t)
# Judge status: Accepted
a,b,c=(map(int,input().split()))
if a==5:
  if b==5:
    if c==7:
      print("YES")
    else:
      print("NO")
  elif b==7:
    if c==5:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
elif a==7:
  if b==5 and c==5:
    print("YES")
  else:
    print("NO")
else:
  print("NO")
# Judge status: Accepted
import bisect
N = int(input())
A = sorted([int(i) for i in input().split()])
B = [int(i) for i in input().split()]
C = sorted([int(i) for i in input().split()])


ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (N-bisect.bisect_right(C, b))
print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
List = []
for i in range (M):
  List.append(list(map(int, input().split())))
resList = [0]*N
for i in range(M):
  resList[List[i][0]-1] +=1
  if List[i][1]<N:
    resList[List[i][1]] +=-1
for j in range(1,N):
  resList[j] = resList[j] + resList[j-1]
print(resList.count(M))
# Judge status: Accepted
import math
a,b,h,m= map(int, input().split())

hr = 30*h+0.5*m
mr = 6*m
ans = a**2+b**2-2*a*b*math.cos(math.radians(hr-mr))
print(math.sqrt(ans))
# Judge status: Accepted
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(N):
  if i != N -1:
    if a[i] + a[i + 1] > x:
      ans += a[i] + a[i + 1] - x
      a[i + 1] -= min(a[i + 1], a[i] + a[i + 1] - x)
print(ans)
# Judge status: Accepted
import fractions
N,X=map(int,input().split())
x=[int(i) for i in input().split()]
A=[]
for t in x:
    A.append(abs(t-X))
ans=A[0]
for s in A:
    ans=fractions.gcd(ans,s)
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())
a = list(map(int,input().split()))
total = sum(a)
thred = total/(4*m)
if len([i for i in a if i>=thred]) >= m:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
C=input()
R=0
for i in C:
    if i=="R":
        R+=1
D=C[:R]
count=0
for i in D:
    if i=="W":
        count+=1
print(count)
# Judge status: Accepted
x,a,b = map(int, input(). split())
if a>=b:
  print("delicious")
elif b-a <= x:
  print("safe")
else:
  print("dangerous")
# Judge status: Accepted
r, g, b = list(map(int, input().split(' ')))

num = 100 * r + 10 * g + b
if num % 4 == 0:
    print('YES')
else:
    print("NO")