peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n-1,-1,-1):
    ans += min(a[i]+a[i+1],b[i])
    a[i] = max(a[i]-max(b[i]-a[i+1],0),0)
print(ans)
# Judge status: Wrong Answer
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

n = ri()
a = []
for i in range(n):
    x,y = rl()
    a.append((x,y, x+y))
a = sorted(a, key=lambda x: x[2])
print(abs(a[-1][0]- a[0][0]) + abs(a[-1][1]-a[0][1]))
# Judge status: Wrong Answer
a=[int(input()) for i in range(5)]
print(a)
k=int(input())
for i in range(4):
    for j in range(i+1,5):
        print(a[j]-a[i])
        if a[j]-a[i]>k:
            print(":)")
            exit()
print("Yay!")
# Judge status: Accepted
r, g, b = map(str, input().split())
a = int(r + g + b)
if a % 4 == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
n = int(input())
"""求める最大の余りの合計は1〜N-1の合計に等しい"""
result = n*(n-1)//2
print(result)
# Judge status: Accepted
x, y = map(int, input().split())
ans = len(str(bin(y // x))) -2
print(ans)
# Judge status: Accepted
print(1 if int(input())<1 else 0)
# Judge status: Wrong Answer
import math
A, B = list(map(int, input().split()))

amax = math.ceil((A + 1) / 8 * 100) - 1
amin = math.ceil(A / 8 * 100)
bmax = math.ceil((B + 1) * 10) - 1
bmin = math.ceil(B / 10 * 10)

if amin > bmax or bmin > amax:
    print(-1)
else:
    print(int(max(amin, bmin)))
# Judge status: Accepted
def readInt():
    return list(map(int,input().split()))
n = int(input())
l = []
for i in range(1,n):
    ans = 0
    j = i
    k = n-i
    while j>0:
        ans += int(j%10)
        j = int(j/10)
    while k>0:
        ans += int(k%10)
        k = int(k/10)
    l.append(ans)
# print(l)
print(min(l))
# Judge status: Accepted
n = int(input())
a_ = list(map(int,input().split()))

import collections
cnt = list(collections.Counter(a_))

print('YES' if len(cnt) == n else 'NO')
# Judge status: Accepted
s = input()

out_s = []
for i in range(len(s)):
  if s[i] == '0' or s[i] == '1':
    out_s.append(s[i])
  elif s[i] == 'B':
    if len(out_s) != 0:
      del out_s[-1]

tmp = ''
for i in range(len(out_s)):
  tmp += out_s[i]
print(tmp)
# Judge status: Accepted
nancy = int(input())
print("Christmas" + (25-nancy)*" Eve")
# Judge status: Accepted
import math

A, B = map(int, input().split())
cnt = 1 + math.ceil( (B-A) / (A-1) )
print(cnt)
# Judge status: Accepted
import numpy as np
n, c, k = [int(a) for a in input().split()]
t = []
for _ in range(n):
    t.append(int(input()))
t = np.asarray(t)
t = np.sort(t)

ans = 0
count = 0
lim = 0

for i in range(t.shape[0]):
    if count == 0:
        lim = t[i] + k
        count += 1
    elif t[i] <= lim and count < c:
        count += 1
    else:
        lim = t[i] + k
        ans += 1
        count = 1

print(ans+1)
# Judge status: Wrong Answer
from collections import Counter as C
print("Yes" if len(C(input())) <= 2 else "No")
# Judge status: Accepted
# AtCoder
N = int(input())
A = list(map(int, input().split()))

ans = 0
s = 0
m = float('inf')

for i in A:
    i = abs(i)
    s += i
    m = min(m, i)

minus_num = len(list(filter(lambda x: x < 0, A)))

if minus_num % 2 == 0:
    print(s)
else:
    print(s-2*m)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n):
    x = 0
    for j in range(n):
        if i != j:
            if x == 0:
                x = a[j]
            else:
                x ^= a[j]
    
    ans.append(x)
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())

make = False
for i in range(1, B+1):
    rem = (A * i) % B
    if rem == C:
        make = True
        break

if make:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print(c-(a-b))
# Judge status: Wrong Answer
n=int(input())
l=[int(x) for x in input().split()]
cnt=0
x=0
y=0
b=0
for i in range(n):
    if(i+1!=l[i]):
        cnt+=1
        if(cnt==1):
            x=l[i]
        elif(cnt==2):
            y=l[i]
        elif(cnt>0):
            b=1
            break
if(b==1):
    print("NO")
elif(l[x-1]!=y and l[y-1]!=x):
    print("NO")
else:
    print("YES")
# Judge status: Accepted
import collections

N = int(input())
S = input()

m = 0
index = 0
for i in range(N):
    a = set(S[:i])
    b = set(S[i:])
    
    common_char = a & b
    if len(common_char) > m:
        m = len(common_char)
        index = i
print(m)
# Judge status: Accepted
a,b,c = map(int,input().split())

if b-a==c-b:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
A = int(input())
B = int(input())

for i in range(3):
  if (i == A):
    break
  elif(i == B):
    break
  else:
    print(i)
# Judge status: Wrong Answer
import math
n,k=map(int,input().split())
l=set(map(int,input().split()))
s=n
p=set()
for i in range(10):
  if i not in l:
    p.add(i)
if k==1 and 0 in l:
  print(n)
else:
  d=math.floor(math.log(n, 10)+1) 
  for i in p:
    n=n+i*(10**d)
    d=d+1
  print(n)
# Judge status: Accepted
from collections import Counter
import math

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

ctr = Counter(aa)

cmb2 = [0] * 200001
for n in range(2, 200001):
    r = 2
    num = 1
    for i in range(1, r + 1):
        num = num * (n - i + 1) // i
    cmb2[n] = num

x = 0
for k, v in ctr.items():
    x += cmb2[v]

for a in aa:
    k = ctr[a] - 1
    print(x - k)
# Judge status: Accepted
import itertools
N = int(input())
P = list(map(int, input().split())) 
Q = list(map(int, input().split())) 

l = []
for i in range(1, N + 1): 
        l.append(i)

p = list(itertools.permutations(l, N)) 

print(abs((p.index(tuple(P)) + 1) - (p.index(tuple(Q)) + 1 )))
# Judge status: Accepted
S = input()
T = input()
ListS = []
ListT = []
Alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(26):
    ListS.append(S.count(Alphabet[i]))
    ListT.append(T.count(Alphabet[i]))
ListS.sort()
ListT.sort()
print("Yes" if ListS == ListT else "No")
# Judge status: Wrong Answer
N = int(input())

dists = []
while N:
    x, y = map(int, input().split())
    dists.append((x, y, x+y))
    N -= 1

dists.sort(key=lambda x: x[2])
print(abs(dists[0][0] - dists[-1][0]) + abs(dists[0][1] - dists[-1][1]))
# Judge status: Wrong Answer
N = int(input())
S = input()

d = [0] * (N + 1)
for i in range(N):
    d[i + 1] = d[i] + int(S[i] == "(") - int(S[i] == ")")

a = d[-1]
b = min(d)

print("(" * -a + S + ")" * (b - a))
# Judge status: Accepted
l=[int(i) for i in input()]

ans_c=[['+','+','+'],['+','+','-'],['+','-','+'],['-','+','+'],['+','-','-'],['-','+','-'],['-','-','+'],['-','-','-'],]

for i in ans_c:
  num=l[0]
  for j in range(3):
    if i[j]=='+':
      num+=l[j+1]
    else:
      num-=l[j+1]
  if num==7:
    print(str(l[0])+i[0]+str(l[1])+i[1]+str(l[2])+i[2]+str(l[3])+'=7')
    exit()
# Judge status: Wrong Answer
k,a,b=map(int,input().split())
ans=0
k+=1
if a>b+1:
    ans=k
else:
    if a+2>k:
        ans=k
    else:
        ans+=b
        k-=a+2
        ans+=(b-a)*(k//2)
        ans+=k%2
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * n
for i in range(n):
    x = a[i]
    cnt[x-1] = i+1
print(cnt)
# Judge status: Accepted
a,b = map(int,input().split())
if a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
N, x = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
if A[0] > x:
  ans = A[0] - x
  A[0] = x
for i in range(N-1):
    if A[i] + A[i+1] > x:
        ans += A[i]+A[i+1]-x
        A[i+1] = x-A[i]
print(ans)
# Judge status: Wrong Answer
H, A = map(int, input().split())

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


while H > 0:
  for i in sa:
    H = H - i

  if H > 0:
    break

if H <= 0:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
N = int(input())
robo = []
for _ in range(N):
    robo.append(list(map(int, input().split())))
robo.sort()
ans = 0
flg = False
for i in range(N-1):
    if flg:
        flg = False
        continue
    if robo[i][0] + robo[i][1] <= robo[i+1][0] - robo[i+1][1]:
        continue
    else:
        ans += 1
        flg = True
print(N-ans)
# Judge status: Accepted
n=int(input())
lst=[]
for i in range(n):
    w=input()
    if w in lst:
        print("No")
        exit(0)
    elif len(lst)>0:
        if lst[-1][-1]!=w[0]:
            print("No")
            exit(0)
    lst.append(w)
print("Yes")
# Judge status: Wrong Answer
from sys import stdin

def main():
  read = stdin.readline
  N =int(read())
  count = 0
  start = 2
  while(1):
    if N < start:
      break
    for i in range(start,N+1):
      if N%i == 0:
        count += 1
        N = N//i
        start = i+1
        break
  print(count)
        
      

  
  
  
if __name__ == "__main__":
  main()
# Judge status: Accepted


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    '''
    RL...LL 0
    RL...RR 0
    RL...RL 0

    RL...LR +2
    LR...RL +2

    RL      +1

    13 3
    LRRLRLRRLRLLR
    '''
    N, K = read_ints()
    S = input()
    score = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            score += 1
    return min(score+2*K, N-1)


if __name__ == '__main__':
    print(solve())
# Judge status: Accepted
s = input()
if s == 'SUN':
  print(7)
if s == 'MON':
  print(6)
if s == 'TUE':
  print(5)
if s == 'WED':
  print(4)
if s == 'THU':
  print(3)
if s == 'FRI':
  print(2)
if s == 'SAT':
  print(1)
# Judge status: Accepted
x = int(input())

if x == 7 or x ==  5 or x ==  3:
  print("YES")
  
else:
  print("NO")
# Judge status: Accepted
n,m=map(int,input().split())
drink=[list(map(int,input().split())) for i in range(n)]
drink.sort(key=lambda i:i[0])

tot,cnt=0,0
for i in range(n):
  if cnt+drink[i][1]>=m:
    tot+=drink[i][0]*(m-cnt)
    break
  else:
    cnt+=drink[i][1]
    tot+=drink[i][0]*drink[i][1]

print(tot)
# Judge status: Accepted
from collections import Counter

n = int(input())
integer = list(map(int, input().split()))
length = len(integer)
counter = Counter(integer)
keys = counter.keys()
total = 0
for key in keys:
  total += counter[key] * ( counter[key] -1 ) / 2
total = int(total)

for i in integer:
  tmp = total
  tmp -= counter[i] - 1
  print(tmp)
# Judge status: Accepted
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()
ans=0
for i in range(n):
    if m>ab[i][1]:
        ans+=ab[i][0]*ab[i][1]
        m-=ab[i][1]
    else:
        ans+=ab[i][0]*m
        print(ans)
        break
# Judge status: Wrong Answer
import numpy as np
N = int(input())
X = np.array(input().split(), dtype=np.int64)
argsort = X.argsort().argsort()
X_sorted = X[argsort]
m1, m2 = N // 2 - 1, N // 2
for idx in argsort:
    if idx > m1:
        print(X_sorted[m1])
    else:
        print(X_sorted[m2])
# Judge status: Accepted
n = int(input())
alist = list(map(int,input().split()))

s = 0
for i in alist:
    s ^= i

ans = []
for i in alist:
    ans.append(s ^ i)

print(" ".join(str(x) for x in ans))
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[20]:


A = int(input())
B = int(input())
C = int(input())
X = int(input())


# In[22]:


ans = 0
for a in range(min(X//500+1, A+1)):
    for b in range(min((X-500*a)//100+1, B+1)):
        c = (X-500*a-100*b)//50
#         print(a,b,c)
        if c <= C:
            ans += 1
print(ans)


# In[ ]:
# Judge status: Wrong Answer
li = list(input())
sorted(li)
if li[0] == 'a' and li[1] == 'b' and li[2] == 'c':
    print('Yes')
else:
    print('Yes')
# Judge status: Accepted
N = int(input())
A = sorted(a-i-1 for i, a in enumerate(map(int, input().split())))
print(sum(abs(a-A[N//2]) for a in A))
# Judge status: Accepted
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
  n, k = na()

  def Base_10_to_n(X, n):
    if (int(X/n)):
      return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
  
  print(len(Base_10_to_n(n, k)))

if __name__ == '__main__':
  main()
# Judge status: Accepted
#A
a, b, c = map(int, input().split())
d = c - a + b
if d < 0:
    print(0)
else:
    print(d)
# Judge status: Accepted
K = int(input())

e_n = K // 2
o_n = K - e_n

print(e_n * o_n)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

n = int(input())
A = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#a = [int(input()) for _ in range(n)]
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

ID = [i for i in range(1,n+1)]

ans = 0

for i,a in zip(ID, A):
    if i%2 == 1 and a%2 == 1:
        ans += 1
        
print(ans)
# Judge status: Accepted
S = input()
s = sorted(S)

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N=int(input())
P=map(int,input().split())
S=[]
for x,y in zip(P, range(1,N+1)):
    if x==y: S.append(y)

S.append('$')
L=len(S)

lake=[]
lake.append(S[0])
i=1
a=0
while i<L:
    if S[i]=='$':
     a+=1
    elif lake[0]+1!=S[i]:
     a+=1
     lake=[]
     lake.append(S[i])
    else:
     lake.append(S[i])
    i+=1
print(a)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a <= 5:
    print("0")

elif 6 <= a and a <= 12:
    print(b/2)

elif a >= 13:
    print(b)
# Judge status: Wrong Answer
import math

x = int(input())
y = math.floor(x / 2)
if y == 1:
    print(x)
else:
    print(y)
# Judge status: Accepted
n, *p = map(int, open(0).read().split())

ans = 0
for i in range(n-1):
        if p[i]==i+1:
                p[i], p[i+1] = p[i+1], p[i]
                ans += 1
if p[n-1]==n: ans += 1
print(ans)
# Judge status: Accepted
x, n = map(int, input().split())
p = set(map(int, input().split()))
mi = 1000
for i in range(102):
    if i in p:
        continue
    if abs(i-x)<mi:
        mi = abs(i-x)
        ans = i
print(ans)
# Judge status: Accepted
def main():
    S = input()[::-1]
    ans = 0
    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        mods[current % 2019] += 1
        x = x * 10 %2019
    
    for i in mods:
        ans += i*(i-1)//2
    print(ans)
if __name__ == '__main__':
    main()
# Judge status: Accepted
x, n = map(int, input().split())
num_list = list(map(int, input().split()))
dif = 100000
o_list = []

if len(num_list) == 0:
    print(x)
    exit()
#
# for i in range(1, max(num_list)):
#     if i not in num_list:
#         o_list.append(i)

for i in range(-1000, 1000):
    if i not in num_list:
        o_list.append(i)

o_list.sort(reverse=True)

for num in o_list:
    if abs(x - num) <= dif:
        # if x not in num_list:
        dif = abs(x -num)
        ans = num

print(ans)
# Judge status: Accepted
L = int(input())

ans = 0
i = L / 3
ans = i ** 3

print('{:.7f}'.format(ans))
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
B = [i+1 for i in range(n)]
li = []
for i in range(n):
    li.append([A[i],B[i]])
li.sort()
b = []
for i in range(n):
    b.append(li[i][1])
b = map(str,b)
print(' '.join(b))
# Judge status: Wrong Answer
n=int(input())
h=list(map(int,input().split()))
temp=0
if n==1:
  print("Yes")
else:
  for i in range(0,n-1):
    if h[i]-1<temp:
      print("No")
      break
    temp=max(temp,h[i])
  else:
    print("Yes")
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[2]:


S = input()
print(S[:3])


# In[ ]:
# Judge status: Wrong Answer
n = int(input())
a = sorted(list(map(int, input().split())))
ans1 = 0
ans2 = 0
for i in range(n, n*3):
    if i%2 == 0:
        ans1 += a[i]
    if i < n*2:
        ans2 += a[i]
print(max(ans1, ans2))
# Judge status: Accepted
import math

n = int(input())

k = math.ceil(((1 + 8 * n) ** 0.5 - 1) / 2)

tmp = k * (k + 1) / 2 - n
for i in range(1, k + 1):
    if i == tmp:
        continue
    print(i)
# Judge status: Wrong Answer
K = int(input())

answer = [0]

for k in range(K):
  minvalue = min(answer)
  if minvalue == 9:
    for i in range(len(answer)):
      answer[i] = 0
    answer.append(1)
  else:
    target = answer.index(minvalue)
    answer[target] += 1
    if target != 0:
      for i in range(len(answer) - target):
        iindex = target - i - 1
        if 1 <= iindex + 1 <= len(answer) - 1:
          answer[iindex] = max(0, answer[iindex + 1] - 1)

answer.reverse()
print(''.join(map(str, answer)))
# Judge status: Accepted
a, b, c, d = [int(i) for i in input().split()]
nums = [a, b, c, d]

if a < 0 and b < 0 and 0 < c and 0 < d:
  print(b * c)
  exit(0)
if c < 0 and d < 0 and 0 < a and 0 < b:
  print(d * a)
  exit(0)


minus_num = len([i for i in nums if i < 0])
if minus_num == 4:
  print(a * c)
  exit(0)
if minus_num == 1 or minus_num == 0:
  print(b * d)
  exit(0)

if a * c < b * d:
  print(b * d)
else:
  print(a * c)
# Judge status: Wrong Answer
K = int(input())
A, B = map(int, input().split())

flag = False
for i in range(1000):
    if A <= i*K and i*K <= B:
        flag = True

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S=input()
day={"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
print(day[S])
# Judge status: Accepted
N = int(input())
from fractions import gcd

ans = 1
for i in range(N):
  T = int(input())
  g = gcd(ans,T)
  ans *= T//g

print(ans)

#print(*ans, sep='\n')
# Judge status: Accepted
n=int(input())
alis=list(map(int,input().split()))
xlis=dict()
for i in set(alis):
    xlis[i-1]=0
    xlis[i+1]=0
    xlis[i]=0
for i in alis:
    xlis[i-1]+=1
    xlis[i+1]+=1
    xlis[i]+=1
print(max(xlis.values()))
# Judge status: Wrong Answer
a, b, c, d = map(int,input().split())

if (a - c) <= d or (a - b) <= d and (b - c) <= d:
    print('Yes')
else :
    print('No')
# Judge status: Accepted
def solve(x):
    # 方針: ただ 6->5 を繰り返すだけ
    return 2 * (x // 11) + (0 if x % 11 == 0 else 1 if x % 11 <= 6 else 2)

_x = int(input())
print(solve(_x))
# Judge status: Accepted

n = int(input())

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

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

mx = 0
for i in range(n):
	pass
	up = sum(row1[:i+1])
	down = sum(row2[i:])
	mx = max(mx,up+down)

print(mx)
# Judge status: Accepted
import itertools
import math

n = int(input())
l = []
x = []
y = []
for i in range(n):
    l.append(i+1)
    tmp_x, tmp_y = map(int, input().split())
    x.append(tmp_x)
    y.append(tmp_y)

permutation = list(itertools.permutations(l, n))

ans = 0
for per in itertools.permutations(l, n):
    for i in range(0, n-1):
        suffix = per[i]
        ans += math.sqrt((x[per[i]-1] - x[per[i+1]-1])**2 + (y[per[i]-1] - y[per[i+1]-1])**2)

print(ans / len(permutation))
# Judge status: Wrong Answer
s=input()
if (s[::2]=='R' or 'U' or 'D') and (s[1::2]=='L' or 'U' or 'D'):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b = map(int, input().split())
if a > 0 and b > 0:
    print("Positive")
elif a < 0 and b > 0:
    print("Zero")
elif a == 0 or b == 0:
    print("Zero")
else:
    d = abs(a) - abs(b)
    if d % 2 == 1:
        print("Positive")
    else:
        print("Negative")
# Judge status: Accepted
import bisect
n = int(input())
colors = [-1]*(n+1)
for _ in range(n):
    a = int(input())
    idx = bisect.bisect_left(colors, a)-1
    colors[idx] = a
print(colors[::-1].index(-1))
# Judge status: Accepted
s=input()
t=sorted(s)
u=''.join(t)
if u[0]==u[1] and u[1]!=u[2] and u[2]==u[3]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import math
N = int(input())
print(int(N*((N-1)/2)))
# Judge status: Accepted
N = int(input())
temp = []
for i in range(1,N+1):
    if (i%3 ==0)or(i%5==0)or((i%3==0)&(i%5==0)):
        pass
    else:
        temp.append(i)
print(sum(temp))
# Judge status: Wrong Answer
n,a,b = map(int,input().split())

count = 0
for i in range(1,n+1) :
	s = str(i)
	l = len(s)
	x = 0
	for j in range(l):
		x += int(s[j])
	if 	x >= a and x <= b:
		print(i)
		count += i

print(count)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
x = [0]*max(a)
for i in a:
    x[i-1]+=1


for i in range(1,n+1):
    x[a[i-1]-1]-=1
    count = 0
    x_ = [(k*(k-1))/2 for k in x if k>=2]
    count = sum(x_)
    # for j in x:
    #     if j>=2:
    #         count += int((j*(j-1)/2))
    x[a[i-1]-1]+=1
    print(count)
# Judge status: Wrong Answer
def main():
    S = input()

    if S[0] != 'A':
        print('WA')
        exit()
    S = 'a'+S[1:]
    if S.count('C', 2, len(S)-2) != 1:
        print('WA')
        exit()
    tmp = S[2:len(S)-2].find('C') + 2
    S = S[:tmp] + 'c' + S[tmp+1:]
    if S != S.lower():
        print('WA')
        exit()
    print('AC')


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
ans = 0

for x in range(1, n+1):
  k = n//x
  ans += n*(2*x + (n-1)*x)//2
  
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
sequence = list(map(int, input().split()))
a = sum(sequence)
if a > n:
    print(-1)
else:
    print(n - a)
# Judge status: Accepted
n=int(input())
alis=[]
blis=[]
for i in range(n):
  a,b=map(int,input().split())
  alis.append(a)
  blis.append(b)
  
  
alis=sorted(alis)
blis=sorted(blis)
if n%2!=0:
  print(blis[int((n-1)/2)]-alis[int((n-1)/2)]+1)
else:
  bb=(blis[int(n/2)-1]+blis[int(n/2)])
  aa=(alis[int(n/2)-1]+alis[int(n/2)])
  print(bb-aa+1)
# Judge status: Accepted
n = int(input())

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

diff = [0] * n

for i in li:
    diff[i - 1] += 1

for j in diff:
    print(j)
# Judge status: Wrong Answer
# B - Postdocs

T = list(str(input()))
len_T = len(T)

for i in range(1, len_T):
    if T[i-1] == 'P' and T[i] == '?':
        T[i] = 'D'
    elif T[i-1] == '?' and T[i] == '?':
        T[i-1] = 'P'
        T[i] = 'D'
    elif T[i-1] == '?' and T[i] == 'D':
        T[i-1] = 'P'
    elif T[i-1] == '?' and T[i] == 'P':
        T[i-1] = 'D'

print(''.join(map(str, T)))
# Judge status: Wrong Answer
import sys
n = input()
list_a = list(map(int, input().split()))

for a in list_a:
  if a%2 == 0:
      if a%3 == 0:
          if a%5 == 0:
            pass
          else:
            print("DENIED")
            sys.exit()
      else:
        print("DENIED")
        sys.exit()
    
print("APPROVED")
# Judge status: Accepted
H, A = map(int, input().split())

if H % A == 0:
    print(H // A)
else:
    print((H // A) + 1)
# Judge status: Wrong Answer
N = int(input())
print(int(N / 1.08))
# Judge status: Accepted
N = int(input())
List = [int(i) for i in input().split()]


ans = 10**18
def rally(p):
    n = 0
    for a in range(N):
        n += (int(p)-List[a])**2
    return n

for i in range(1,101):
    ans = min(rally(i),ans)

print(ans)
# Judge status: Accepted
#B
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(N):
    if (i+1)%2==1 and A[i]%2==1:
        ans+=1
        
print(ans)
# Judge status: Wrong Answer
s=input().split()[1][0]

print("AtCode"+"Contest")
# Judge status: Wrong Answer
H, W, N = [int(input()) for _ in range(3)]
print(min((N+H-1)//H, (W+W-1)//W))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
sub = 0
for i in range(n):
    sub ^= a[i]

for i in range(n):
    print(sub ^ a[i],end = ' ')
# Judge status: Accepted
import math
a,b = list(map(int,input().split()))
for i in range(1,1001):
  if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
    print(i)
    break
else:
  print(-1)
# Judge status: Accepted
A, B = [int(v) for v in input().split()]
print(A * B)
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0

for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i+100*j+50*k==X:
                count+=1
            else:
                pass

print(count)