peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, M = map(int, input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort()
onedan = 0
for ab in AB:
    buy = min(ab[1], M)
    onedan += buy * ab[0]
    M -= buy
print(onedan)
# Judge status: Wrong Answer
S = input()
if S[2]==S[3] and S[4]==S[5]:
    print('True')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

prev = A[0]
isUp = True
isDown = True

ans = 0
for a in A[1:]:
  if prev == a:
    pass
  elif prev < a:
    isDown = False
    if not isUp:
      isUp = True
      ans += 1
  elif a < prev:
    isUp = False
    if not isDown:
      isDown = True
      ans += 1
      
  prev = a
  
print(ans+1)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

a = list( map(int, input().split()))
b=[]
ans = 0

for i in reversed(range(n)):
    if a[i] > 1:
        print(-1)
        exit()
    cnt = n // (i+1)
    tmp = 0
    for j in range(2,cnt):

        tmp += a[(i+1) * j]
    tmp2 = (tmp%2+a[i])%2
    ans += tmp2
    if tmp2 == 1:
        b.append(i+1)

print(ans)
print(*b, sep=' ')
# Judge status: Wrong Answer
import string

s = input()

lall = [chr(i) for i in range(97, 97+26)]
#print(lall)

for x in lall:
    if x not in s:
        print(x)
        break
print("None")
# Judge status: Accepted
a,b,c=map(int,input().split())
d=[a,b,c]
if d.count(5)==2 and d.count(7)==1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

M = max(a)

a = sorted(a)
a = [a[i] for i in range(n-1)]

b = 0
for i in range(n-1):
    if abs(a[i]-M/2) <= abs(b-M/2):
        b = a[i]

print('{} {}'.format(M,b))
# Judge status: Wrong Answer
N = int(input())
s = sorted([input() for i in range(N)])
M = int(input())
t = sorted([input() for i in range(M)])
a = 0
for i in range(N):
    for j in range(M):
        if a < s.count(s[i])-t.count(j):
            a = s.count(s[i])-t.count(j)
print(a)
# Judge status: Wrong Answer
#52 1日かかった
N = int(input())
b = list(map(int,input().split()))
a = [0 for i in range(N)]

for i in range(N-2):
    a[i] = min(b[i],b[i+1])

a[-1] = b[-1]
            
        
    

print(sum(a))
# Judge status: Accepted
N = int(input())
c = 0
ans = 1
for i in range(1, N + 1):
    n = i
    for t in range(N + 1):
        if n % 2 != 0:
            if c < t:
                c = t
                ans = i
            break
        n //= 2
print(ans)
# Judge status: Accepted
import sys
N = int(input())
W = [input() for _ in range(N)]
if len(set(W)) == len(W):
  for i in range(1, len(W)):
    if W[i-1][-1] != W[i][0]:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
print('Yes')
# Judge status: Wrong Answer
a,b=map(int, input().split())
ab=int(str(a)+str(b))
if ab^0.5.is_integer():
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import itertools
import numpy as np
n, m, x = map(int, input().split())
temp = [list(map(int, input().split())) for _ in range(n)]
ans = []
for li in itertools.product([0,1], repeat=n):
    cnt = 0
    check = np.zeros(m, np.int)
    for i in range(n):
        if li[i] == 1:
            check += np.array(temp[i][1:])
            cnt += temp[i][0]
    if min(check) >= x:
        ans.append(cnt)
print(min(ans) if len(ans) !=0 else -1)
# Judge status: Accepted
from sys import stdin
input = stdin.readline

a=input()
print(a[:3])
# Judge status: Accepted
n,k=map(int,input().split())
x=list(map(int,input().split()))
l=[]
for i in range(n-k+1):
  l.append(x[i+k-1]-x[i]+min(abs(x[i+k-1]),abs(x[i])))
print(min(l))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n):
    ans += (n-1) // i
print(ans)
# Judge status: Accepted
S = list(map(str, input()))
T = list(map(str, input()))

def judge(S, T):
	for _ in range(len(S)):
		S.insert(0, S.pop(-1))
		if S == T:
			return "Yes"
	return "No"
	
print(judge(S, T))
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())
c = [0]*(n-1)
s = [0]*(n-1)
f = [0]*(n-1)

for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

def dfs(eki,t):
    if eki == n-1:
        return t

    cc = c[eki]
    ss = s[eki]
    ff = f[eki]

    if t < ss:
        return dfs(eki+1, ss+cc)
    else:
        return dfs(eki+1, -(-t//ff)*ff+cc)

for i in range(n):
    print(dfs(i,0))
# Judge status: Wrong Answer
n,m = map(int,input().split())

if abs(n-m)>=2:
    print(0)
elif abs(n-m) ==1:
    x =max(n,m)
    for i in range(1,min(n,m)+1):
        x = x*i**2%(10**9+7)
        print(x)
else:
    x =2
    for i in range(1,n+1):
        x = x*i**2%(10**9+7)
        print(x)
# Judge status: Wrong Answer
X,Y = map(int, input().split())
if X%Y==0:
    print(-1)
    exit()
for i in range(2,10**18):
    X=X*i
    if X>10**18:
        print(-1)
        exit()

    if X%Y != 0:
        print(X)
        exit()
    X=X/i
# Judge status: Accepted
X, Y= map(int, input().split())

ans = 'No'
for a in range(X + 1):
    b = X - a
    if 2 * a + 4 * b == Y:
        ans = 'Yes'
print(ans)
# Judge status: Wrong Answer
N=int(input())
l={}

for i in range(N):
  s=input()
  if s in l:
    l[s]+=1
  else:
    l[s]=1
l=sorted(l.items(),key=lambda x: x[1],reverse=True)
ma=max(l)
ans=[]

for i in l:
  if i[1]==ma[1]:
    ans.append(i[0])

ans.sort()
  
for i in ans:
  print(i)
# Judge status: Accepted
def main():
    n = int(input())
    s = input()
    l, r, c = 0, 0, 0
    for a in s:
        if a == '(':
            c += 1
        elif c:
            c -= 1
        else:
            l += 1
    r = c
    print("("*l + s + ")"*r)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N,M= map(int,input().split())

X=list(map(int,input().split()))
X.sort()

L=[0]*(M-1)
for i in range(M-1):
 L[i] = X[i+1]-X[i]


list.sort(L,reverse=True)



print(sum(L[N-1:]))
# Judge status: Wrong Answer
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def lsi():
    x=list(stdin.readline())
    x.pop()
    return x
def si(): return stdin.readline()
############# CODE STARTS HERE #############
n=ii()
a, b, c=mi()
for _ in range(n-1):
    x, y, z=mi()
    a+=max(y, z)
    b+=max(x, z)
    c+=max(y, z)
print(max(a, b, c))
# Judge status: Accepted
n  = int(input())
lst = list(map(int, input().split()))

count4 = 0
count2 = 0

for i in lst:
    if i%4==0:
        count4+=1
    elif i%2==0:
        count2+=1
count1 = n-count4-count2

if count2==0 and count4>=count1-1:
    print("Yes")
elif count2!=0 and count4>=count1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from math import log2
from math import ceil
n,k=map(int,input().split())
p=0


for i in range(1,n+1):
    if i>=k:
        p+=1/n
    else:
        cnt=ceil(log2(k)-log2(i))
        p+=(1/n)*((1/2)**cnt)
    

print(p)
# Judge status: Accepted
A, B, X = map(int, input().split())

P, r = divmod(A, X)
if r:
    P += 1

Q, r = divmod(B, X)

#print(P, Q)
print(max(0, Q-P+1))
# Judge status: Accepted
x=int(input())
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: Wrong Answer
X, Y, Z = map(int, input().split())

result = X // (Y + Z) - 1
while X < result * Y + (result + 1) * Z:
    result += 1
print(result)
# Judge status: Accepted
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
ans = [0] * N
for i in range(N):
  if T[i] == 'r':
    if i > K-1 and T[i-K] == T[i] and ans[i-K]>0:
      pass
    else:
      ans[i] += P
  elif T[i] == 's':
    if i > K-1 and T[i-K] == T[i] and ans[i-K]>0:
      pass
    else:
      ans[i] += R
  else:
    if i > K-1 and T[i-K] == T[i] and ans[i-K]>0:
      pass
    else:
      ans[i] += S
print(sum(ans))
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
kuma = sum(l)-l[0]
snuke = l[0]
gap = abs(snuke-kuma)
for i in range(1,n-1):
    snuke += l[i]
    kuma -= l[i]
    gap = min(gap,abs(snuke-kuma))
print(gap)
# Judge status: Wrong Answer
from copy import deepcopy

N = int(input())
X = list(map(int,input().split()))
Y = deepcopy(X)
Y.sort()
med1 = Y[N//2]
med2 = Y[N//2-1]
print("med1:",med1,"med2",med2)
for i in range(N):
    if i  == N//2 -1 or i == N//2:
        print(med2)
    else:
        print(med1)
# Judge status: Accepted
s=input()
t=s[:4]
u=s[5:7]
v=s[8:]
w=int(t+u+v)

if w<=20190430:
  print('Heisei')
  
else:
  print('TBD')
# Judge status: Accepted
lst = list(map(int, input().split()))
k = int(input())

lst = sorted(lst)
for i in range(k):
  lst[-1] = lst[-1] * 2

print(sum(lst))
# Judge status: Wrong Answer
s = input()

s_cnt, t_cnt = 0, 0
ans = 0
for i in range(len(s)):
    if s[i] == "S":
        s_cnt += 1
    else:
        t_cnt += 1
        if i == len(s) - 1 or s[i + 1] == "S":
            ans += min(t_cnt, s_cnt)
            t_cnt = 0
            c_cnt = 0

print(len(s) - ans * 2)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 1e9
for p in range(-100, 101):
  sub = 0
  for q in a:
    sub += pow(p - q, 2)
  ans = min(ans, sub)

print(ans)
# Judge status: Accepted
from fractions import gcd

N = int(input())
A = list(map(int,input().split()))
'''
res = 0
for i in range(N):
    tmp = A[i+1:] + A[:i]
    ans = tmp[0]
    for i in range(1,N-1):
        ans = gcd(ans,tmp[i])
    res = max(ans,res)
print(res)
'''

L = [0] * (N+1)
R = [0] * (N+1)

for i in range(N):
    L[i+1] = gcd(L[i],A[i])
    R[N-i-1] = gcd(R[N-i],A[N-i-1])
ans = 0
for i in range(N):
    ans = max(ans,gcd(L[i],R[i+1]))

print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
if a <= c <= b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = input()

import re
output ="NO"
s = re.sub('dreameraser', 'A', s)
s = re.sub('dreamerase', 'A', s)
s = re.sub('dreamer', 'A', s)
s = re.sub('eraser', 'A', s)
s = re.sub('erase', 'A', s)
s = re.sub('dream', 'A', s)
if s.isupper() :
    output = "YES"
print(output)
# Judge status: Wrong Answer
N = int(input())

A = [[0]*10 for i in range(10)]

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

ans = 0
for i in range(10):
    for j in range(10):
        ans += A[i][j] * A[j][i] 

print(ans)
# Judge status: Accepted
a,b = map(int, input().split())
if  a * b % 2 == 0:
  print("Even")
else:
  print("Odd")
# Judge status: Accepted
n = int(input())
s = input()
white = s.count(".")
black = s.count("#")

min_num = min(black, white)
black_num = 0
for i, color in enumerate(s, start = 1):
    if color == "#":
        black_num += 1
    min_num = min(min_num, black_num + white - (i - black_num))
    
print(min_num)
# Judge status: Accepted
n, m = map(int, input().split())

if n==m:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
al = list(map(int, input().split()))
al.sort(reverse=True)
a = 0
b = 0
for i in range(n):
    if i%2==0:
        a += al[i]
    else:
        b += al[i]

print(a-b)
# Judge status: Accepted
N,M = map(int,input().split())
a = [0]*N
b = [0]*N
for i in range(N):
    a[i],b[i] = map(int,input().split())
c = [0]*M
d = [0]*M
for i in range(M):
    c[i],d[i] = map(int,input().split())

ans = []
for i in range(N):
    for j in range(M):
        tmp = abs(a[i]-c[j])+abs(b[i]-d[j])
        ans.append(tmp)
    print(ans.index(min(ans))+1)
    ans = []
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[input() for i in range(n)]
    ll=[]
    ans='Yes'
    for j in range(n-1):
        if l[j][-1]==l[j+1][0] and l[j] not in ll:
            ll.append(l[j])
        else:
            ans='No'
            break
    print(ans)
resolve()
# Judge status: Wrong Answer
X , K , D = map(int, input().split())
first_ct = int(X/D)
second_posi = X - D*first_ct
leave_ct = K - first_ct
x = second_posi
for trans in range(leave_ct):
    foward_X = x + D
    back_X = x - D
    if abs(foward_X) > abs(back_X):
        x = back_X
    else:
        x = foward_X
print(abs(x))
# Judge status: Wrong Answer
import sys
from collections import Counter
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    A, B = map(int, readline().split())
    ans = 0
    for i in range(A,B+1):
        s = str(i)
        if s[:2]==s[3:]:
            ans += 1
    print(ans)



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

for i in range(k,n):
    if a_li[i-k] < a_li[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
x,y = map(int,input().split())
ans = abs(abs(x)-abs(y))
print(ans if x * y > 0 else ans + 1)
# Judge status: Accepted
S = input().strip()
if S=="Sunny":
    print("Cloudy")
elif S=="Cloudy":
    print("Rainy")
else:
    print("Sunny")
# Judge status: Wrong Answer
N = input()
l = []
l.append(N[0])
l.append(N[1])
l.append(N[2])
print(max(l)*3)
# Judge status: Wrong Answer
N, M = map(int, input().split())

e = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    e[a-1].append(b-1)
    e[b-1].append(a-1)
visited = [0]*N
visited[0] = 1
que = [0]
while que:
    x = que.pop()
    for i in e[x]:
        if visited[i] == 0:
            visited[i] = x+1
            que.append(i)

print("Yes")


print(*visited[1:], sep="\n")
# Judge status: Accepted
d,t,s=map(int,input().split())
if d-t*s<=0 :
  print('Yes')
else :
  print('No')
# Judge status: Accepted
ans=1
N=int(input())
mod=1000000007
for i in range(1,N+1):
  ans*=i
  ans=ans%mod
print(ans)
# Judge status: Accepted
A,B,C=map(int,input().split())
X=int(input())

while X>0:
  if B<=A:
    B=2*B
  elif C<=B:
    C=2*C
  X-=1

if A<B and B<C:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
#B
T=input()
ans=T.replace("?", "D")
 
print(ans)
# Judge status: Accepted
n=int(input())
s=input()
r,g,b=map(s.count,'RGB')
print(r*g*b-len([1for i in range(n)for j in range(i,n,2)if s[i]!=s[j]!=s[i+j>>1]!=s[i]]))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
monster = 0
hero = 0
for i in range(N):
    allhero = B[i] + hero
    if allhero<=A[i]:
        monster += B[i]
        hero = 0
    else:
        monster += A[i]
        minus = 0
        if hero>A[i]:
            minus = hero-A[i]
        hero = allhero-minus-A[i]
    #print(monster,allhero,hero)

if hero>0:
    monster += min(hero,A[N])
print(monster)
# Judge status: Accepted

S = input()
if S[2]==S[3] and S[4]==S[5]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, Q = map(int, input().split())
S = input()

C = [0 for _ in range(N)]
count = 0
prev = S[0]
for i, s in enumerate(S[1:]):
    now = s
    if prev + now == 'AC':
        count += 1
    C[i+1] = count
    prev = now
C

for j in range(Q):
    l, r = map(int, input().split())
    print(C[r-1] - C[l-1])
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n=int(input())
    ans=''
    
    while n>0:
        n-=1
        a,b=divmod(n,26)
        n//=26
        ans+=chr(ord('a')+b)
    for i in ans[::-1]:
        print(i,end='')
    print()
        

    
resolve()
# Judge status: Wrong Answer

x,y,z = map(int,input().split())
ans = int((x-1)//(y+z))
print(ans)
# Judge status: Wrong Answer
import collections

n = int(input())
a = [int(input()) for i in range(n)]
x = collections.Counter(a)
y = x.most_common()
ans = 0
for i in range(len(y)):
    if y[i][1]%2==1:
        ans+=y[i][1]
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N):
    B[A[i]-1] = i + 1
print(' '.join(map(str, B)))
# Judge status: Wrong Answer
s = input()
  
print(len(s.replace('S', '')))
# Judge status: Accepted
d = int(input())
cs = list(map(int, input().split()))
sm = [list(map(int, input().split())) for _ in range(d)]

import random
for _ in range(d):
    t = random.choice(range(26)) + 1
    print(t)
# Judge status: Accepted
def main():
    W, H, x, y = map(int, input().split())
    pat = 0

    if x == W/2 and y == H/2:
        pat = 1

    print((W*H)/2.0, pat)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
number = int(input())
print(number * (number + 1) / 2)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
syugo = [0]*N
syugo[0] = A[0]
syugo[1] = A[1]
flg = False
ans = A[0]
idx = 1
for i in range(2, N):
    if flg:
        ans += A[idx]
        flg = False
        idx += 1
    else:
        ans += A[idx]
        flg = True

print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    h = [0] * N
    for i in range(N):
        h[i] = int(input())
    h.sort()

    ans = float("inf")
    for i in range(N - (K - 1)):
        diff = h[i + (K - 1)] - h[i]
        if diff < ans:
            ans = diff

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
a,b=map(int,input().split())
gcd=math.gcd(a,b)

def prime_factorization(n):
  i=2
  prime=[]
  while i*i<=n:
    if n%i:
      i+=1
    else:
      n//=i
      prime.append(i)
      while n%i==0:
        n//=i
  if n>1:
    prime.append(n)
  return prime

print(len(prime_factorization(gcd))+1)
#print(prime_factorization(gcd))
# Judge status: Wrong Answer
S = input("Please enter password :")
flag =0
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        flag =1
if flag == 1:
    print("bad")
else:
    print("good")
# Judge status: Wrong Answer
a = int(input())
print(1+ a**2 + a**3)
# Judge status: Wrong Answer
from math import gcd

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

if gcd(gcd(n, m), k) == gcd(n, m):
    print('No')
else:
    ('Yes')
# Judge status: Accepted
N, W = map(int, input().split())
wv_array = [list(map(int, input().split())) for _ in range(N)]

ans_array = [[0] * (W + 1) for _ in range(N + 1)]

for n in range(1, N + 1):
    for w in range(W + 1):
        if wv_array[n - 1][0] > w:
            ans_array[n][w] = ans_array[n - 1][w]
        else:
            ans_array[n][w] = max(
                ans_array[n - 1][w], ans_array[n - 1][w - wv_array[n - 1][0]] + wv_array[n - 1][1])


print(ans_array[N][W])
# Judge status: Accepted
import math

n = int(input())
d = n
m = {}

for i in range(2, int(math.sqrt(n)) + 1):
    m[i] = 0
    while (d % i == 0):
        d //= i
        m[i]+=1
res = 0
for i in m.values():
    res+=int(math.sqrt(i*2+0.25)-0.5)

if d > 1:
    res += 1
print(res)
# Judge status: Wrong Answer
n = int(input())

ans = n//100

if ans< 5:
    print(8)
    exit()
elif ans >= 6 and ans <= 7:
    print(7)
    exit()
elif ans >= 8 and ans <= 9:
    print(6)
    exit()
elif ans >= 10 and ans <= 11:
    print(5)
    exit()
elif ans >= 12 and ans <= 13:
    print(4)
    exit()
elif ans >= 14 and ans <= 15:
    print(3)
    exit()
elif ans >= 16 and ans <= 17:
    print(2)
    exit()
elif ans >= 18 and ans <= 19:
    print(1)
    exit()
# Judge status: Wrong Answer
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))

if n >= m:
    print(0)
    exit()

ans = x[m-1]-x[0]
x = sorted([x[i] - x[i - 1] for i in range(1,m)])

print(ans - sum(x[-n + 1:]))
# Judge status: Accepted
n = int(input())
counter = 0
s = "TEMP"
list = []
temp = ''

while n > 0:
  s = input()
  list.append(s)
  n = n - 1

list.sort()
for item in list:
  if item == temp:
    counter = counter - 1
  counter = counter + 1
  temp = item

print(counter)
# Judge status: Accepted
# ABC 159: B – String Palindrome
S = input()
N = len(S)

conds1 = (N - 1) // 2
conds2 = (N + 3) // 2
S1 = S[:conds1]
S2 = S[conds2 - 1:]

print('Yes' if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1] else 'No')
# Judge status: Wrong Answer
n,m = map(int,input().split())
print(n*(n-1) / 2 + m*(m-1) / 2)

#選んだ 2 つのボールに書かれている数の和が偶数になるのは、 
#2つのボールに書かれた数が共に偶数or共に奇数である場合に限ります。
#そのようなボールの選び方の数を求めればよいです。これは、
# nC2 + mC2通りです。
# Judge status: Wrong Answer
def main():
    N = int(input())
    a = list(map(int, input().split()))
    # 自分以外全体のxorがわかっている状態
    ans = a
    for i in range(10):
        c0,c1 = 0,0
        for j in range(N):
            if (a[j]>>i)&1:
                c1+=1
        if c1%2==0:
            ans[j] += (a[j]>>i)*pow(2,i)
    print(*ans)

main()
# Judge status: Accepted
K, S = map(int, input().split())
result = 0
for i in range(K+1):
  for j in range(K+1):
    if S-i-j<0:
      break
    else:
      if (S-i-j)>K:
        pass
      else:
        result += 1
print(result)
# Judge status: Accepted
n = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(1, n-1):
    tmp_P = P[i-1:i+2]
    a = tmp_P[1]
    tmp_P.sort()
    if a == tmp_P[1]:
        ans += 1

print(ans)
# Judge status: Accepted
N = int(input())
[T, A] = list(map(int, input().split()))
list_H0 = list(map(int, input().split()))
list_H1 = []
for i in list_H0:
  list_H1.append(T - i*0.006)
list_HA = []
for k in list_H1:
  list_HA.append(abs(A - k))
Min = min(list_HA)
print(list_HA.index(Min) + 1)
# Judge status: Accepted
import math
import fractions

A,B,C,D=map(int,input().split())
E=C*D//(fractions.gcd(C,D))
def P(A,B,Q):
	if A%Q==0:
		return B//Q-A//Q+1
	else:
		return B//Q-A//Q
print(B-A+1-(P(A,B,C))-(P(A,B,D))+(P(A,B,E)))
# Judge status: Accepted
n,a,b=map(int,input().split())
if (a-b)%2==0:
    print((b-a)//2)
else:
    print(min(a-1,n-b)+1+(b-a-1)//2)
# Judge status: Accepted


import numpy as np

x,a,b=map(int,input().split())
a=abs(a-x)
b=abs(b-x)

if(a<b):
    print("A")
else:
    print("B")
# Judge status: Accepted
from math import sqrt
from itertools import combinations
N = int(input())
points = tuple(tuple(map(int,input().split())) for _ in range(N))
print(sum(sqrt((x1-x2)**2+(y1-y2)**2) for (x1,y1),(x2,y2) in combinations(points,2))*2/N)
# Judge status: Wrong Answer
s = input()
mul = set(str(2019*i) for i in range(1,100))
ans = 0
for m in mul:
  ans += s.count(m)
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
ab = [[int(i) for i in input().split()] for i in range(M)]
ans = [0] * N

for a, b in ab:
    ans[a-1] += 1
    ans[b-1] += 1
for i in ans:
    print(i)
# Judge status: Accepted
import sys
from collections import defaultdict

(n, m), *q = [[*map(int, i.split())] for i in sys.stdin]
d = defaultdict(list)
for k, v in q:
    d[k].append(v)
c = defaultdict(dict)
for k, v in d.items():
    for i, j in enumerate(sorted(v)):
        c[k][j] = i + 1
for p, y in q:
    print("{:0>6}{:0>6}".format(p, c[p][y]))
# Judge status: Accepted
import itertools

N, Q = map(int, input().split())
S = input()

cnt = [0]*N

for i in range(N):
    if i >= N-1:
        continue
    if S[i] == "A":
        if S[i+1] == "C":
            cnt[i+1] = 1

acum = list(itertools.accumulate(cnt))

for j in range(Q):
    l, r = map(int, input().split())
    print(acum[r-1]-acum[l-1])
# Judge status: Accepted
n = int(input())
c = 0
b = 0
for _ in range(n):
  a = int(input())
  if a == 0:
    b = 0
    continue
  a += b
  c += a // 2
  b = a % 2
print(c)
# Judge status: Accepted
l=[0]+[int(i) for i in input()]
l.reverse()
su=0
for i in range(len(l)):
    if l[i]>5:
        l[i]=10-l[i]
        l[i+1]+=1
    elif l[i]==5 and l[i+1]>4:
        l[i+1]+=1
    su+=l[i]
print(su)
# Judge status: Wrong Answer
n=int(input())
h=list(map(int,input().split()))
c=0
i=0
while i<n-1:
	if i+1==n-1:
		c+=abs(h[i+1]-h[i])
		i+=1
	elif abs(h[i+2]-h[i])<=abs(h[i+2]-h[i+1])-abs(h[i+1]-h[i]):
		c+=abs(h[i+2]-h[i])
		i+=2
	else:
		c+=abs(h[i+1]-h[i])
		i+=1
print(c)
# Judge status: Wrong Answer
# coding: utf-8
N = int(input())
if N == 1:
    print(1)
    exit()
ans = 0
for i in range(1, N+1):
    ans += i
    if ans >= N:
        end = i
        break
res = ans - N
for i in range(1, end):
    if i != res:
        print(i)