peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import itertools

l = list()
for a in range(0, 5):
    l.append(int(input()))

k = int(input())

com = list(itertools.combinations(l, 2))

for a in range(0, len(com)):
    com[a] = list(com[a])
    com[a] = abs(com[a][0] - com[a][1])

ans = 'Yay!'

for a in com:
    if a > k:
        ans = ':('
        break

print(ans)
# Judge status: Accepted
S={"hi"*i for i in range(1,6)}
if input() in S:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from fractions import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
lcm = 1

def f(n):
  res = 0
  while n%2 == 0:
    res += 1
    n //= 2
  return res

t = f(A[0])
for a in A:
  if t != f(a):
    print(0)
    exit()
  a //= 2
  lcm *= a // gcd(lcm, a)

print(M//lcm - M//(lcm*2))
# Judge status: Wrong Answer
n,m = map(int, input().split())
a = list(map(int, input().split()))
sub = [0]
a.sort()
for i in range (m):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.insert(1,x//2)
    else:
        x =sub.pop()
        sub.insert(1,x//2)
print(sum(a)+sum(sub))
# Judge status: Accepted
X, Y = map(int, input().split())

ans = 0
while X <= Y:
  ans += 1
  X *= 2
print(ans)
# Judge status: Accepted
f=lambda:map(int,input().split())
n,d=f()
c=0
for _ in range(n):
  x,y=f()
  if x**2+y**2<=d**2: c+=1
print(c)
# Judge status: Accepted
W,H,N=map(int,input().split())
x=[0]*N
y=[0]*N
a=[0]*N
minX=0
maxX=W
minY=0
maxY=H
for i in range(N):
  x[i],y[i],a[i]=map(int,input().split())
  if a[i]==1:
    minX=max(minX,x[i])
  if a[i]==2:
    maxX=min(maxX,x[i]) 
  if a[i]==3:
    minY=max(minY,y[i])
  if a[i]==4:
    maxY=min(maxY,y[i]) 

ans=(maxX-minX)*(maxY-minY)
if maxX<minX or maxY<minY:
  ans=0
print(ans)
# Judge status: Accepted
N,D = map(int, input().split())
d = D * D
ret = 0
for i in range(N):
  x,y = map(int, input().split())
  if x * x + y * y <= d:
    ret += 1
print(ret)
# Judge status: Accepted
S = input()

if S[len(S)-1] == "s":
    S = S + "es"
else:
    S = S + "s"
print(S)
# Judge status: Wrong Answer
def resolve():
	n, k = map(int, input().split())
	ans = 0
	for i in range(n):
		a, b = map(int, input().split())
		ans += b
		if ans >= k:
			print(a)
			break
resolve()
# Judge status: Accepted
#!/usr/bin/env python3

TestCaseNum, ACNum = map(lambda x: int(x), input().split())
if TestCaseNum==ACNum:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from fractions import gcd 
a,b = map(int, input().split())
print((a*b)//gcd(a,b))
# Judge status: Wrong Answer
import math
import bisect
n,k = map(int,input().split())
li = list(map(int,input().split()))
index = bisect.bisect_left(li, 1)
lef = index
right = n - index - 1
if min(lef,right) >= k -1:
    print(math.ceil((n-1)/(k-1)))
else:
    tmp = max(lef,right) - min(lef,right) - 1
    print(math.ceil((tmp)/(k-1))+1)
# Judge status: Wrong Answer
import copy
n = int(input())
b = list(map(int,input().split()))
a = copy.copy(b)
a.append(b[-1])
for i in range(n-1):
    if b[i]<max(a[i],a[i+1]):
        a[i+1]=a[i]
print(sum(a))
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
if a <= x <= a + b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N = input()
if N[0] == "9" or N[1] == "9":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
from collections import Counter
input = raw_input
n = int(input())
As = map(int, input().split(" "))

counter = Counter(As)
cur_sum = sum(As)

q = int(input())
for i in range(q):
    b, c = map(int, input().split(" "))
    try:
        num1 = counter[b]
    except:
        num1 = 0
    try:
        counter[c] += num1
    except:
        counter[c] = num1

    diff = (c - b) * num1
    cur_sum += diff
    print(cur_sum)
# Judge status: Accepted
N, K = map(int,input().split())
ans = 0 if N % K == 0 else 1
print(ans)
# Judge status: Wrong Answer
s = input()

print(s.find("7"))
if(s.find("7")== -1):
    print("NO")
else:
    print("YES")
# Judge status: Accepted
import math

n = int(input())
end = math.ceil((-1 + (1 + 8 * n)**(0.5)) / 2)

ans = [j for j in range(1, end+1)]

sum_to_end = ( end ** 2 + end ) // 2

if sum_to_end != n:
    ans.remove(sum_to_end - n)

print('\n'.join(map(str, ans)))
# Judge status: Accepted
s=str(input())
if s=="RRR":
  print(3)
elif s=="RRS" or s=="SRR":
  print(2)
elif s=="SSS":
  print(0)
else:
  print(1)
# Judge status: Accepted
a,b = map(int,input().split())
if a*b<=0:
    print("Zero")
elif b<0 and(b-a)%2==0:
    print("Negative")
else:
    print("Positive")
# Judge status: Accepted
n = int(input())

a = [int(input())-1 for _ in range(n)]

flag = False
index = 0
count = 0

for i in range(n):
  index = a[index]
  count += 1
  if index == 1 :
    flag = True
    break

if flag:
  print(count)
else:
  print(-1)
# Judge status: Accepted
K,A,B=list(map(int,input().split()))
hand=0
if B-A<=2:
    print(K+1)
    exit()
K=K-A+1
if K%2==1:
    hand=1+int((K-1)/2)*(B-A)
else:
    hand=int(K/2)*(B-A)
print(hand+A)
# Judge status: Accepted
S=input()
T=input()


if len(S)+1==len(T):
    for i in range(len(S)): #回数の時は絶対range()
        if S[i]==T[i]:
            a='ok'
            continue
        else:
            a='no'
            break
else:
    print('no')

if a=='ok':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import numpy as np
N, M = map(int, input().split())
AA = np.array(list(map(int, input().split())))


S = sum(AA >= (sum(AA)/(4*M)))
if S >= M:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
S = list(input())
if len(S) != 3:
    sys.exit


if S.count('a') == 1 and S.count('b') == 1 and S.count('c') == 1:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
a, b = map(int, input().split())

ab = None
for i in range(1, 4):
    if b == b%(10**i):
        ab = a*(10**i) + b
        break

print(ab)

for i in range(1, 1000):
    if i**2 == ab:
        print('Yes')
        exit()

print('No')
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
funcionarios = list(map(int,input().split()))
for x in Counter(funcionarios).values():
    print(x)
    N -= 1
a = N
while a != 0:
    print(0)
    a -= 1
# Judge status: Accepted
#!/usr/bin/env python3
n, m = map(int, input().split())
(*a, ) = map(int, input().split())
a.sort()
q = [[*map(int, input().split())] for _ in range(m)]
q.sort(key=lambda x: -x[1])
idx = 0
for b, c in q:
    for _ in range(b):
        if idx >= n or a[idx] >= c:
            print(sum(a))
            exit()
        a[idx] = c
        idx += 1
print(sum(a))
# Judge status: Wrong Answer
from collections import deque
n = int(input())
l = map(int, input().split())
d = deque()
for i in l:
    if i % 2 == 1:
        d.appendleft(i)
    else:
        d.append(i)
if n % 2 == 0:
    d.reverse()
print(' '.join(map(str, d)))
# Judge status: Accepted
n,k=map(int,input().split())
if k==1:
  print(0)
else:
  a=n%k
  b=abs(a-k)
  print(min(a,b))
# Judge status: Accepted
n,m = map(int,input().split())
v = [0] * m
for i in range(n):
    a = list(map(int,input().split()))
    for j in range(1,a[0]+1):
        v[a[j]-1] += 1
ans = 0
for i in range(m):
    if v[i] == n: ans += 1
print(ans)
# Judge status: Accepted
N = map(int, input())
An = list(map(int, input().split()))
mnum = 10 ** 9 + 7
CumSum = An[0]
answer = 0
for i in range(1, len(An)):
    answer = (answer + CumSum * An[i]) 
    CumSum = (CumSum + An[i])
print(answer%mnum)
# Judge status: Accepted
n=int(input())
print(((n+1)//2)/n)
# Judge status: Wrong Answer


import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[-int(i) for i in a]

heapq.heapify(b)

for i in range(m):
    x=heapq.heappop(b)//2
    heapq.heappush(b,-x)

print(-sum(b))
# Judge status: Wrong Answer
#D
N,K=map(int,input().split())
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans=0
for i in range(K,N+1):
    ans+=combinations_count(N+1, i)
    
print(ans)
# Judge status: Accepted
S=list(input())
a=S.index('A')
z=[i for i, x in enumerate(S) if x == 'Z']
print(z[-1]-a+1)
# Judge status: Accepted
n,k,*a=map(int,open(0).read().split())
print(min(r-l+min(abs(r),abs(l))for l,r in zip(a,a[k-1:])))
# Judge status: Accepted
s = int(input())

def f(n):
  if n%2:
    return n*3+1
  else:
    return n//2

i = 1
hist = {s:i}
while 1:
  s = f(s)
  i+=1
  if s in hist:
    print(i)
    break
  else:
    hist[s]= i
# Judge status: Wrong Answer
from collections import defaultdict
strN=input()
lenN=len(strN)
N=int(strN)

if N<=9:print(N)
else:
  count = defaultdict(int)
  for i in range(10,N+1):
    a,b=int(str(i)[0]),int(str(i)[1])
    if b==0:continue
    count[(a,b)] += 1

  ans=0
  for i in range(1,10):
    count[(i,i)] += 1
  count = dict(count)
  for key in count.keys():
    if key[0]<key[1] and count.get((key[1],key[0])):
      ans += count[key] * count[(key[1],key[0])] * 2
    if key[0]==key[1]:
      ans += count[key]**2
  print(ans)
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline


def main():
    N = int(input())

    if N <= 6:
        print(1)
        return
    elif N <= 11:
        print(2)
        return
    else:
        x, y = divmod(N, 11)
        ans = x * 2
        if y <= 6:
            print(ans + 1)
            return
        elif y <= 11:
            print(ans + 2)
            return


if __name__ == '__main__':
    main()
# Judge status: Accepted
x = int(input())

if x>=30:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def solve():
    h, a = map(int, input().split())
    print(-(-h//a))

if __name__ == '__main__':
    solve()
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
cnt = 0
m = n + 1
for i in range(n):
    if m > p[i]:
        cnt += 1
        m = p[i]
print(cnt)
# Judge status: Accepted
def main():
    N, A, B  = map(int, input().split())
    sum_v = 0
    for i in range(1, N+1):
        v = sum([int(s) for s in str(i)])
        if v >= A and v <= B:
            sum_v += i
    print(sum_v)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
K = int(input())

mod_ini = 7%K
mod = 0
cnt = 0

while True:
    if K%2 != 0:
        print(-1)
        break
    
    cnt += 1
    mod = (mod*10 + 7)%K
    #print(mod)
    
    if mod == 0:
        print(cnt)
        break
    elif mod == mod_ini and cnt != 1:
        print(-1)
        break
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))
a,b,c=0,0,0
ans='No'
for i in x:
  if i%4==0:
    a+=1
  elif i%2==0:
    b+=1
  else:
    c+=1
if n%2==1:
  if c-a==1:
    if b==0:
      ans='Yes'
  elif a>=c:
    ans='Yes'
else:
  if a>=c:
    ans='Yes'
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())

if a%2==1 or b%2==1 or c%2==1:
    print("0")
    exit()

for i in range(1,1000000):
    a2=(b//2)+(c//2)
    b2=(a//2)+(c//2)
    c2=(a//2)+(b//2)
    
    a,b,c=a2,b2,c2
    
    if a%2==1 or b%2==1 or c%2==1:
        print(i)
        exit()

print("-1")
# Judge status: Accepted
k,a,b=map(int,input().split())
c=k-a+1
print(max(k+1,a+(c//2)*(b-a)+c%2))
# Judge status: Wrong Answer
A,B=map(int,input().split())
if abs(A+B)%2==0:
    print(abs(A+B)/2)
else:
    print("IMPOSSIBLE")
# Judge status: Wrong Answer
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab,key=lambda x:x[0])
ans = 0
for i in ab:
  m -= i[1]
  ans += i[0]*i[1]
  if m <= 0:
    print(ans + m*i[0])
    break
  elif i == ab[-1]:
    print(ans)
    break
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N, M = map(int, input().split())
    if N == 1 and M == 1:
        print(1)
    elif (N == 1 and M >= 2):
        print(M - 2)
    elif (N >= 2 and M == 1):
        print(N - 2)
    else:
        print((N - 2) * (M - 2))


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

cur = abs(x)  # 座標を正にしてしまいます
rem = k  # 残りの移動回数です

cnt = min(cur // d, k)  # 0に向かって移動する回数です
cur -= d * cnt
rem -= cnt

# 0 % 2 = 0なので、残り回数の場合分けをする必要はないのですが、一応
if rem > 0:
    if rem % 2 == 1:
        cur = cur - d

ans = abs(cur)
print(ans)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n, x = map(int, input().split())
    l = tuple(map(int, input().split()))

    d = 0
    for i in range(1, n+1):
        d += l[i-1]
        if d >= x:
            print(i)
            quit()
    else:
        print(n)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
a, b = input().split()
c = int(a+b)

if math.sqrt(c) == int(math.sqrt(c)):
    print('Yes')

else:
    print('No')
# Judge status: Accepted
S = input()
k=0
t=len(S)
while k<len(S):
    if(S[-(k+5):t-k] == 'dream' or S[-(k+5):t-k] == 'erase')and k+5<len(S)+1:
        k+=5
        continue
    elif(S[-(k+6):t-k] == 'eraser')and k+6<len(S)+1:
        k+=6
        continue
    elif(S[-(k+7):t-k] == 'dreamer')and k+7<len(S)+1:
        k+=7
        continue
    else:
        print('NO')
        break
else:
    print('YES')
# Judge status: Accepted
from collections import *
n,m=map(int,input().split())
l=list(map(int,input().split()))
k=len(set(l))
if(k<=m):
    print(0)
else:
    d=defaultdict(int)
    for i in l:
        d[i]+=1
    f=list(d.values())
    f.sort()
    g=k-m
    c=0
    for i in range(g):
        c+=f[i]
    print(c)
# Judge status: Accepted
N,M=[int(i) for i in input().split()]
PY=[[] for _ in range(N)]
py=[]

for i in range(M):
    p,y=[int(i) for i in input().split()]
    PY[p-1].append((y,i))

ans=[None]*M
for j,py in enumerate(PY): #jが県番号
    py.sort()
    for k,(y,i) in enumerate(py):
        ans[i]=str(j+1).zfill(6) + str(k+1).zfill(6)

print(*ans,sep="\n")
# Judge status: Accepted
x,y,z = map(int,input().split())
print((x-z)//(y+z))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans=0
ans2=0
for i in a:
  if i % 2 == 0:
    ans +=1
    if i % 3 == 0 or i % 5 == 0:
      ans2 +=1
if ans == ans2:
  print('APPROVED')
else:
  print('DENIED')
# Judge status: Accepted
N,Q = map(int, input().split())
S = input()

a = [0]*N

for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        a[i] = 1

s = [0]*(N+1)
for i in range(N):
    s[i+1] = s[i] + a[i]

for i in range(Q):
    l,r = map(int, input().split())
    ans = s[r-1]-s[l-1]
    print(ans)
# Judge status: Accepted
A,B,C,K=map(int,input().split())

if K<A:
    ans=K
elif A<=K and K<=A+B:
    ans=A
else:
    ans=2*A+B-K

print(ans)
# Judge status: Accepted
S = input()
A = False
B = False

for s in S:
  if s == "A":
    A = True
  else:
    B = True

if A == True and B == True:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from operator import itemgetter
N = int(input())
inf = {}
for i in range(1,N+1):
  s,p = input().split()
  pint = int(p)
  inf[(s,pint)] = i
a = sorted(inf.keys(), key=itemgetter(1), reverse=True)
dic2 = sorted(a, key=itemgetter(0))
for i in range(N):
  print(inf[dic2[i]])
# Judge status: Accepted
# B
a, b, c, k = map(int, input().split())

if a >= k:
    print(k)
elif a+b >= k:
    print(a)
else:
    print(a - (k-a-b))
# Judge status: Accepted
def gcd(x, y):
    while y > 0:
        tmp = x % y
        x = y
        y = tmp
    return x

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    else:
        return x // gcd(x, y) * y

def main():
    mod = int(1e9 + 7)
    n = int(input())
    a = list(map(int, input().split()))
    l = 1
    for i in range(n):
        l = lcm(l, a[i])

    ans = 0

    print(int(sum(l // i for i in a) % mod))

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
T, A = map(int, input().split())
X = list(map(int, input().split()))

s = 10000

for i in range(N):
  x = T - X[i] * 0.006
  if abs(A - x) < s:
    ans = i
    s = abs(A - x)
print(ans+1)
# Judge status: Wrong Answer
alpha = input()

if alpha < 'A':
    print('a')
else:
    print('A')
# Judge status: Accepted
from statistics import median 
n=int(input())
a=list(map(int,input().split()))

b=[x-i-1 for i,x in enumerate(a)]
"""
b=[]
for///:
    y.append///
"""
m=int(median(b))
print(sum(abs(y-m) for y in b))
# Judge status: Accepted
#!/usr/bin/env python3
import sys


def solve(N: int):
    res = (1 + N) * (N / 2)
    print(int(res))


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n,k=map(int,input().split())
count=0
for i in range(n+2):
    if i<k:
        continue
    elif i>=k:
        mini=i*(i-1)//2
        a=n*(n+1)//2
        b=(n-i)*(n-i+1)//2
        maxi=a-b
        total=maxi-mini+1
        count+=total
print(count)
# Judge status: Accepted
N = int(input())
A = int(input())

print("Yes" if (N % 500 <= A) else "No")
# Judge status: Accepted
n = list(map(int, input().split())) 

for i in range(5):
  if n[i] == 0:
    print(i+1)
# Judge status: Accepted
X = int(input())

while True:
  flag = 0
  for i in range(2,X//2):
    if X % i == 0:
      flag = 1
      break
  if flag == 0:
    print(X)
    exit()
  X = X + 1
# Judge status: Accepted
a, b, c, d = [int(s) for s in input().split(" ")]
ans1 = a * c
ans2 = b * d
ans3 = a * d
ans4 = b * c
print("%d" % max([ans1, ans2, ans3, ans4]))
# Judge status: Accepted
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for k, v in c.items():
    if k < v:
        ans += v - k
    elif k > v:
        ans += v
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))
print(max(-1,n-sum(a)))
# Judge status: Accepted
from math import gcd
n = int(input())
l = list(map(int,input().split()))
mi = 1
gcd_l = [l[0]]
gcd_r = [l[-1]]
for i in range(1,n):
  gcd_l.append(gcd(l[i],gcd_l[-1]))
for i in range(n-2,-1,-1):
  gcd_r.append(gcd(l[i],gcd_r[-1]))
  
for i in range(0,n-2):
  t = gcd(gcd_l[i], gcd_r[n-3-i])
 # print(t)
  mi = max(mi,t)
#print(gcd_l)
#print(gcd_r)
mi = max(mi,gcd_r[-2])
mi = max(mi,gcd_l[-2])
print(mi)
# Judge status: Accepted
n = int(input())
d = {}
c = 0
for i in range(n):
    s = input()
    s = tuple(sorted(s)) #文字列をsort
    if s in d:
        c = c + d[s]
        d[s] = d[s] + 1
    else:
        d[s] = 1
print(c)
# Judge status: Accepted
l, r = map(int, input().split())
ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)
# Judge status: Wrong Answer
A, B, K = [int(i) for i in input().split()]
result_list = []

def divisor_list(n):
    i = 1
    array = []
    while i * i <= n:
        if n % i == 0:
            array.append(i)
            array.append(n//i)
        i += 1
    array = list(set(array))
    return array

for i in divisor_list(A):
    for j in divisor_list(B):
        if i == j:
            result_list.append(i)

print(result_list[-K])
# Judge status: Wrong Answer
N = int(input())

s = (1+N)*N // 2
s1 = 0
s2 = 0
s3 = 0
if N >= 3:
    s1 = ((3 + (N//3)*3) * (N//3)) // 2
if N >= 5:
    s2 = ((5 + (N//5)*5) * (N//5)) // 2
if N >= 15:
    s3 = ((15 + (N//15)*15) * (N//15)) // 2
print(s + s3 - s1 - s2)
# Judge status: Accepted
from decimal import Decimal
N = list(map(str,input().split()))
A = Decimal(N[0])
B = Decimal(N[1])

print(int(A * B))
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
mod = 10**9 + 7


def nCr(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


ans = pow(2, n, mod)-1-nCr(n, a, mod)-nCr(n, b, mod)
if ans < 0:
    print(ans + mod)
else:
    print(ans)
# Judge status: Wrong Answer
X = int(input())
benjin = 100
t = 0
while benjin <= X:
    benjin = int(benjin * 1.01)
    t = t + 1
print(t)
# Judge status: Wrong Answer
inital_string = input()
num_of_q = int(input())
flag = True

for i in range(num_of_q):
  q = input()
  if q[0] == '1':
    flag = not flag
  else:
    if q[2] == "1":
      if flag:
        inital_string = inital_string + q[4]
      else:
      	inital_string = q[4] + inital_string
    else:
      if flag:
        inital_string = q[4] + inital_string
      else:
      	inital_string = inital_string + q[4]
if flag:
  inital_string = inital_string[::-1]
print(inital_string)
# Judge status: Accepted
n = int(input())
if n % 2 == 1:
  print(0)
else:
  a = 0
  m = n // 2
  while True:
    m = m // 5
    a += m
    if m == 0:
      break
  print(a)
# Judge status: Accepted
# E - Payment

N = input().strip()

s = 0
carry = 0
five = False
for c in reversed(N):
    x = int(c) + carry
    if x == 5 and not five:
        s += x
        carry = 0
        five = True
    elif x >= 5:
        if five:
            x += 1
        s += 10 - x
        carry = 1
        five = False
    else:
        s += x
        carry = 0
        five = False
s += carry

print(s)
# Judge status: Wrong Answer
n = int(input())
s = [int(input()) for i in range(n)]

dp = [[0] * 2]*(n+1)

for i,_s in enumerate(s):
  if i % 10==0:
    dp[i+1][1] = dp[i][1]
  else:
    if (dp[i][0] + _s) % 10 ==0:
      dp[i+1][1] = dp[i][0] + _s
    else:
      dp[i+1][0] = dp[i][1] + _s
print(dp[n][0])
# Judge status: Accepted
abcd = list(input())

for bit in range(1 << 3):
    answer = 0
    op = ["-", "-", "-"]
    for i in range(3):
        if (bit >> i) & 1:
            op[i] = "+"
    if eval(abcd[0] + op[0] + abcd[1] + op[1] + abcd[2] + op[2] + abcd[3]) == 7:
        answer = abcd[0] + op[0] + abcd[1] + op[1] + abcd[2] + op[2] + abcd[3] + "=7"
        break
print(answer)
# Judge status: Accepted
s = int(input())
if s % 2 == 1:
  Odd = (s+1)/2
  Even = Odd -1
else:
  Odd = s/2
  Even = Odd
res= int(Odd) * int(Even)
print(res)
# Judge status: Accepted
n, m = map(int, input().split())
if n*2 >= m:
    result = m//2
else:
    result = (m - n*2)//4 + n
print(result)
# Judge status: Accepted
h,a = map(int,input().split())
ans = 0
for _ in range(h):
  h -= a
  ans += 1
  if h <= 0:
    break
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split()) 
import math
x = math.floor(M/N)
y = int(math.sqrt(M))
if y < x:
  x = y
for i in range(-x,0):
  if M%(-i)==0:
    print(-i)
    break
# Judge status: Accepted
num_list = [int(x) for x in input().split()]
k = int(input())
print(sum(num_list) + max(num_list) * (2 ** k - 1))
# Judge status: Accepted
import sys

def compute_gcd(x, y):
   while(y):
       x, y = y, x % y
   return x
 
def compute_lcm(x, y):
   lcm = (x*y)//compute_gcd(x,y)
   return lcm

def lcm(a):
	x = a[0]
	for i in range(1, len(a)):
		x = compute_lcm(x, a[i])
	return x

n = int(input())

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

MOD = 10 ** 9 + 7

ans = lcm(a)
cur = 0

for i in a:
	cur += ans // i

print(cur % MOD)
# Judge status: Accepted
N,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b)
print(ans%MOD)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort()
M = A[-1]
b = [True] * (M + 1)

count = 0
for i, a in enumerate(A):
  if not b[a]:
    continue
  for j in range(a, M+1, a):
    b[j] = False
  if i < N-1 and A[i+1] == a:
    continue
  count += 1

print(count)
# Judge status: Accepted
import sys

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


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    for mask in range(60):
        cnt1 = sum([1 if a & (1 << mask) else 0 for a in A])
        cnt0 = n - cnt1
        res += (pow(2, mask, mod) * cnt1 * cnt0) % mod
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()