peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
a,b=map(int,input().split())
x=(a+b)/2
if x.is_integer()==1:print(x)
else:print("IMPOSSIBLE")
# Judge status: Wrong Answer
N=int(input())
A=[0]*N
for i in range(N):
    A[i]=int(input())
B   = [0]*N
B[0]= A[0] %2
ans= A[0]//2

for i in range(1,N):
    #print(i,A[i],B[i-1], (B[i-1]+A[i])//2 )
    pair= (B[i-1]+A[i])//2
    ans += pair
    if (A[i]+B[i-1]) %2==1 and A[i]%2==1:
        B[i] = 1
    else:
        B[i] = 0

#print(ans,B)
print(ans)
# Judge status: Wrong Answer
n = int(input())
s = input()

flg = False
count = 0
for l in s:
    if l=="#":
        flg = True
    else:
        if flg:
            count+=1

print(count)
# Judge status: Wrong Answer
a=int(input())

b=a//2+1

print(b/a)
# Judge status: Accepted
s = int(input())

x2 = 10**9
y2 = 1
x3 = s % (10**9) 
y3 = s // (10**9) 
if x3 > 0:
  x3 = 10**9 - s % (10**9) 
  y3 = s // (10**9) + 1
print("0 0 " + str(10**9) + " 1 " + str(x3) + " " + str(y3))
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = int(readline())
    s = set()

    for i in range(1, 1001):
        for j in range(2, 16):
            if i ** j <= x:
                s.add(i ** j)
            else:
                break

    l = list(s)
    l.sort(reverse=True)

    print(l[0])


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
x = int(input())
gohyoku = math.floor(x/500)
goen = math.floor((x-500*gohyoku)/5)
print(gohyoku*1000+goen*5)
# Judge status: Wrong Answer
MOD = 10**9 + 7

def fac(n):
    ans = 1
    for i in range(1, n + 1):
        ans = ans * i % MOD
    return ans

X, Y = map(int, input().split())

if (2 * X - Y) % 3 != 0:
    print(0)
else:
    a, b = (2 * Y - X) // 3, (2 * X - Y) // 3
    print((fac(a + b) * pow(fac(a), MOD-2, MOD) * pow(fac(b), MOD-2, MOD)) % (10**9 + 7))
# Judge status: Accepted
a,b,x = map(int,input().split())
ans = b//x -(a-1)//x
print(ans)
# Judge status: Wrong Answer

N = int(input())
x, y, z = 0, 0, 0
dp = [[0, 0, 0] for _ in range(N)]
for i in range(1, N):
    a, b, c = map(int, input().split())
    dp[i][0] = max(dp[i-1][0]+b, dp[i-1][0]+c)
    dp[i][1] = max(dp[i-1][1]+a, dp[i-1][1]+c)
    dp[i][2] = max(dp[i-1][2]+a, dp[i-1][2]+b)

print(max(dp[-1]))
# Judge status: Accepted
from math import ceil, floor
n,k = map(int,input().split())
a = list(map(int,input().split()))
l = 0
r = 10**9
m = (l+r)//2+1
for i in range(100):
    # print(l,m,r)
    cnt = 0
    for j in a:
        cnt += (ceil(j/m)-1)
    # print(cnt)
    # print(l,m,r,cnt)
    if cnt <= k:
        r = m
        m = ceil((l+r)/2)
    else:
        l = m
        m = ceil((l+r)/2)
print(m)
# Judge status: Wrong Answer
n = int(input())
for i in range(1,n):
  if(int(i*1.08) == n):
    print(i)
    exit()
print(":(")
# Judge status: Wrong Answer
A = [int(input()) for i in range(5)]
d = 9
ans = 0
for a in A:
    ans += 0--a//10*10
    if a%10:
        d = min(d,a%10)
print(ans - 10 + d)
# Judge status: Wrong Answer
a,b,c=[int(i) for i in input().split()]
print((a*b)/2)
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    d = []
    e = []
    for k in range(N):
        x, y = map(int,input().split())
        d.append(x+y)
        e.append(x-y)
    d.sort()
    e.sort()
    print(max(e[-1]-e[0],d[-1]-d[0]))

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])

tmp, cnt, ans = 0, 0, 0
for t in T:
  if not tmp:
    tmp = t + K
    cnt += 1
    ans += 1
  elif tmp < t or cnt == C:
    tmp = t + K
    cnt = 1
    ans += 1
  else:
    cnt += 1
    
print(ans)
# Judge status: Accepted
from collections import defaultdict
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = list(map(int, input().split()))
    color = defaultdict(int)
    g = 0
    for a in A:
        if a >= 3200:
            g += 1
            continue
        for j in range(8):
            if 400 * j <= a < 400 * (j + 1):
                color[j] = 1
    print(max(1, len(color)), len(color) + g)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
import sys
input = sys.stdin.readline
N=int(input())
d={}
for i in [0]*N:
 s = ''.join(sorted(input().strip()))
 if s in d:
  d[s]+=1
 else:
  d[s]=1
e=0
for v in d.values():
 if v>=2:
  e+=int(v*(v-1)/2)
print(e)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
for i in a:
    if i<=b[(n//2)-1]:
        print(b[n//2])
    else:
        print(b[(n//2)-1])
# Judge status: Wrong Answer
s=int(input())
t=str(input())
t=list(t)
ans=0
temp=-999
for i in range(0,s):
  if t[i]=="I":
    ans=ans+1
  else:
    ans=ans-1
  temp=max(ans,temp)
print(temp)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
count = 0
p_new = sorted(p)
for i in range(n):
    if p_new[i] != p[i]:
        count += 1

if count==2 or count==0:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
W, H, x, y = map(int,input().split())

if x == W//2 and y == H//2:
  ans = 1
else:
  ans = 0
print(W*H/2, ans)
# Judge status: Wrong Answer
n=int(input())
if n%2 ==0:
    num=10
    c=0;
    while num <= n:
        c += int(n/num)
        num *= 5
    print(int(c))
else:
    print(0)
# Judge status: Accepted
import sys

input = sys.stdin.readline
D,T,S = map(int,input().split())

if(D/S <= T):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = str(input())
disp = ""

for i in range(0, len(s)):
  if s[i] == "1":
    disp = disp + "1"
  if s[i] == "0":
    disp = disp + "0"
  if s[i] == "B":
    if len(disp) != 0:
      disp = disp[:-1]
    else:
      disp == ""
print(disp)
# Judge status: Accepted
from collections import defaultdict
n,m=map(int,input().split())
ab=defaultdict(lambda: [])
for i in range(m):
  a,b=map(int,input().split())
  ab[a].append(b)
for aa in ab[1]:
  for bb in ab[aa]:
    if bb == n:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")
# Judge status: Accepted
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]

def mid(AB, idx):
    if N % 2 == 0:
        return (AB[N//2-1][idx] + AB[N//2][idx]) / 2
    else:
        return AB[(N+1)//2-1][idx]

AB.sort()
amid = mid(AB, 0)
AB.sort(key=lambda x: x[1])
bmid = mid(AB, 1)
tmp = 1 if N % 2 == 1 else 2
print(int(tmp * (bmid - amid) + 1))
# Judge status: Accepted
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
S,W = map(int,input().split())
print('safe' if S > W else 'unsafe')
# Judge status: Accepted
a1,a2,a3 = map(int,input().split())
if a1 + a2 + a3 >= 22:
    print("bust")
else:
    print("win")
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))

money = 1000


for i in range(1, n):
  p_now = arr[i]
  p_before = arr[i-1]
  if p_before < p_now:
    stock = money // p_before
    money += stock*(p_now - p_before)

print(money)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print('YES' if b-c == c-b else 'NO')
# Judge status: Accepted
s = int(input())

if s == 1 or s == 2:
    print(4)
    exit()

ans = 1
while s != 4:
    ans += 1
    if s % 2 == 0:
        s //= 2
    else:
        s *= 3
        s += 1

print(ans + 3)
# Judge status: Wrong Answer
from itertools import combinations_with_replacement
N, M, Q = [int(x) for x in input().split()]
lst = [list(map(int, input().split())) for _ in range(Q)]
ans = 0
for seq in combinations_with_replacement(range(1, M+1), N):
    print(seq)
    tmp = 0
    for a, b, c, d in lst:
        if (seq[b-1] - seq[a-1] == c):
            tmp += d
    ans = max(ans, tmp)
print(ans)
# Judge status: Accepted
l=[2,1]
n=int(input())

for i in range(2,n+1):
    l.append(l[i-1]+l[i-2])
print(l[n])
# Judge status: Accepted
N = int(input())
s = [list(input()) for i in range(N)]
for i in range(N):
    s[i].sort()
s = [''.join(s[i]) for i in range(N)]

import collections
cnt = collections.Counter(s)

ans = 0
for n in cnt.values():
    if n != 1:
        k = n * (n-1) // 2
        ans += k 

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

for num in a:
    if num % 2 == 0:
        if num%3==0 or num%5==0:
            pass
        else:
            print('DENIED')

print('APPROVED')
# Judge status: Accepted
N=int(input())
num_list=[]
while True:
    try:
        num_list.append(list(map(int,input().split())))
    except:
        break;

sum_list=[]
for k in range(N):
  sum_list.append(sum(num_list[0][0:k+1])+sum(num_list[1][k:N+1]))
          
print(max(sum_list))
# Judge status: Wrong Answer
X, A, B = [ int(v) for v in input().split(" ") ]

# A: 3 B: 4 X: 3

result = A - B

if result >= 0:
  print("delicious")
elif abs(result) >= X:
  print("dangerous")
else:
  print("safe")
# Judge status: Wrong Answer
k, s = map(int, input().split())
i = 0
x = 0
for x in range(0,k+1):
    for y in range(0,k+1-x):
        for z in range(0,k+1-x-y):
            p = x+y+z
            if x+y+z == s: i += 1

print(i)
# Judge status: Wrong Answer
from math import gcd

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

m = gcd(A, B)
#print(m)

num = int(m**0.5) + 1 #mに対する素因数分解は、int(√m)+1の場合を調べればよい
ans = 1

for i in range(2,num+1):
    if m%i:
        continue
    ans += 1
    while not m%i:
        m = m/i

print(ans)
# Judge status: Accepted
n = int(input()) 
a = list(map(int, input().split(' ')))

sa = sorted(a,reverse=True)[0:2 * n]

cs = sa[1::2]

print(sum(cs))
# Judge status: Accepted
x=int(input())
print(x//500*1000+(x%500)//5*5)
# Judge status: Wrong Answer
k, n = [int(elem) for elem in input().split()]
a_lst = [int(elem) for elem in input().split()]

res = 0
if (a_lst[-1] - a_lst[-2]) <= (k - a_lst[-1]):
    for i, a in enumerate(a_lst[:-1]):
        res += a_lst[i+1] - a
else:
    for i, a in enumerate(a_lst[1:]):
        res += a - a_lst[i-1]
    res += (a_lst[0] + k) - a_lst[-1] 
print(res)
# Judge status: Accepted
n = int(input())
sticks = [int(x) for x in input().split()]

count = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        for k in range(j + 1, n):
            a, b, c = sticks[i], sticks[j], sticks[k]
            if a != b and a != c and b != c:
                if a + b > c and b + c > a and c + a > b:
                    count += 1

print(count)
# Judge status: Wrong Answer
n = int(input())

if n == 1:
    print(0)
    exit()
elif n == 2:
    print(1)
    exit()

# ans = 0
# for i in range(1, n):
#     ans += i

# print(ans)

ans = int(n / (n-1) * (n-1) ** 2 / 2)
print(ans)
# Judge status: Wrong Answer
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "WA":
        wa += 1
    elif s == "TLE":
        tle += 1
    else:
        re += 1
print(f"AC × {ac}\nWA × {wa}\nTLE × {tle}\nRE × {re}")
# Judge status: Wrong Answer
n, k = map(int, input().split())
if n >= k:
    print(n%k)
else:
    print(k%n)
# Judge status: Accepted
n = int(input())
ai = [int(e) for e in input().split()]
bi = []
for i in range(len(ai)):
    bi.append(ai[i]-i-1)
bi = sorted(bi)
b = bi[int(len(bi)/2)]
su = 0
for i in range(len(ai)):
    su += abs(ai[i] - (b+i+1))
print(su)
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int, input().split())))
   
ans = a[-2*n :: 2]
print(sum(ans))
# Judge status: Wrong Answer
A, Y = map(int, input().split())
ans = 0
while A<=Y:
  ans+=1
  A*=2
print(A)
# Judge status: Wrong Answer
n = int(input())

if n % 2 == 0:
    print(int((n+1)*(n/2)-n))
else:
    print(int(n*(n//2)))
# Judge status: Accepted
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

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

if int(m/2) - n > 0:
    print(n + int((m - 2*n)/4))
else:
    print(int(m/2))
# Judge status: Accepted
n,m=map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
now=0
ans=0
for i in range(n):
  if now+ab[i][1]<=m:
    now += ab[i][1]
    ans += ab[i][0]*ab[i][1]
  else:
    ans += ab[i][0]*(m-now)
    break
print(ans)
# Judge status: Accepted
a, b = list(map(int, input().split()))

if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c=map(int, input().split())
    if a+b>=c:
        print('Yes')
    else:
        print('No')
resolve()
# Judge status: Accepted
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
f = [0] * N
for x in range(1,100+1):
    for y in range(1, 100+1):
        for z in range(1, 100+1):
            h = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if h > N:
                continue
            f[h - 1] += 1
for i in range(N):
    print(f[i])
# Judge status: Wrong Answer
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b,c,k = map(int,input().split())

    if a == b == c:
        print(0)
    elif (b+c)*k>10**18 or (a+c)*k > 10**18:
        print("Unfair")
    elif k % 2==0:
        print(-1*((b+c)-(a+c)))
    else:
        print((b+c)-(a+c))
    

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

n -= 2
m -= 2

ans = 0

if n == 0 or m == 0:
    ans = 0

elif n == -1 and m == -1:
    ans = 1

elif n == -1 or m == -1:
    ans = max(n, m)

else:
    ans = n * m

print(ans)
# Judge status: Wrong Answer
from collections import defaultdict

n = int(input())

d = defaultdict(int)

for i in range(1, 120):
    for j in range(1, 120):
        for k in range(1, 120):
            num = i**2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            d[num] += 1

for i in range(n+1):
    print(d[i])
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

# A - Dividing a String
def count_substrings(first_substring):

	arr = [first_substring]
	i = len(first_substring)

	while i < len(S):
		s = S[i]
	
		if s == arr[-1]:
			if i + 1 < len(S):
				i += 1
				s += S[i]
			else:
				arr[-1] += s
				break
	
		arr.append(s)
		i += 1

	ans = len(arr)

	if arr[-1] == arr[-2]:
		ans -= 1	

	return ans


S = input()

ans1 = count_substrings(S[:1])
ans2 = count_substrings(S[:2])

print(max(ans1, ans2))
# Judge status: Wrong Answer
n,m=map(int,input().split())
t=1
for i in range(1,m+1):
    print(i,n-i+1)
# Judge status: Accepted
x1, y1, x2, y2 = map(int, input().split())

ans = ''

dx = x2 - x1
dy = y2 - y1

ans += 'R'*dx + 'U'*dy + 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'*(dy+1) + 'R'*dx + 'U' + 'L'*(dx+1) + 'D'*(dy+1) + 'R'

print(ans)
# Judge status: Accepted
n,x,t=map(int,input().split())
if n%x==0:
	print((n//x)*t)
else:
	print((1+n//x)*t)
# Judge status: Wrong Answer
a,b = map(int, input().split())
s=[]
for _ in range(b-1):
 try:
   p=input().split()
 except:
  p=""
 try:
  r=input().split()
  for b in r:
   for bb in b:
    s.append(int(bb))
 except:
  r=""
result = list(filter(lambda x: x not in list(set(s)), list(range(1,a+1))))
print(len(result))
# Judge status: Accepted
S=input();print(['no','yes'][len(set(S))==len(S)])
# Judge status: Wrong Answer
import math , sys

def fac(x,T):
    m = int(math.sqrt(x))+1
    i=2
    while x>1 and i <=m+1:
        ind=0
        while x%i == 0:
            ind+=1
            x=int(x/i)
        if ind>0:
            T.append( ind )
        i+=1
    return T

def sta ( x ):
    return int( 0.5* (-1 + math.sqrt(1+8*x)))
N = int( input() )

Is = fac( N , [] )
ans = sum( [ sta(j) for j in Is])
print(ans)
# Judge status: Accepted
def q3():
    W, H, x, y = (int(i) for i in input().split())

    # 最大になるのは面積のちょうど半分
    ans1 = W * H / 2

    # (x,y)が長方形の中心の場合1
    ans2 = 0
    if x*2 == W and y*2 == H:
        ans2 = 1

    print('{0:.6f} {1}'.format(ans1, ans2))


if __name__ == '__main__':
    q3()
# Judge status: Accepted
a, b, c = map(int, input().split())
abc = sorted([a, b, c])
if abc[0] == 5 and abc[1] == 5 and abc[2] == 7:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
n,a,b = map(int,input().split())
k = b-a
if k<0:
  print(0)
elif k==0:
  print(1)
else:
  print(b*k - a*k+1)
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
count = 0
for i in range(n):
    for ii in range(n):
        for iii in range(n):
            if l[i] + l[ii] > l[iii] and l[ii] + l[iii] > l[i] and l[iii] + l[i] > l[ii] and i<ii and ii < iii and l[i] != l[ii] and l[i] != l[iii] and l[ii] != l[iii]:
                count += 1
print(count)
# Judge status: Wrong Answer
W,H,N=map(int,input().split())
rec=[[0,0],[W,H]]

for i in range(N):
    x,y,a=map(int,input().split())
    if a==1:
        rec[0][0]=max(rec[0][0],x)
    elif a==2:
        rec[1][0]=min(rec[1][0],x)
    elif a==3:
        rec[0][1]=max(rec[0][1],y)
    elif a==4:
        rec[1][1]=min(rec[1][1],y)
        
ans=(rec[1][0]-rec[0][0])*(rec[1][1]-rec[0][1])
print(ans if ans>=0 else 0)
# Judge status: Accepted
H, W = map(int, input().split())
if H == 1 or W == 1:
    print(1)
    exit()

if H*W % 2 != 0:
    print(H*W//2+1)
else:
    print(H*W//2)
# Judge status: Accepted
from sys import exit
n, m = map(int, input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]
for x, a in enumerate(A):
    if x > n - m + 1:
        break
    for i in range(n - m + 1):
        if a[i: i + m] == B[0]:
            for j in range(m):
                if A[x + j][i: i + m] != B[j]:
                    break
            else:
                print("Yes")
                exit()
print("No")
# Judge status: Accepted
import sys

n = int(sys.stdin.readline().rstrip())

def base_convert(n, b):
    res = ''
    while n:
        r = abs(n % b)
        res = str(r) + res
        n = (n - r) // b

    return int(res) if res else 0

def main():
    return base_convert(n, -2)

if __name__ == '__main__':
    ans = main()
    print(ans)
# Judge status: Wrong Answer
a = int(input().replace(' ', ''))
b = 12345
c = b-a
while c > 10:
  c = c//10
  
print(c)
# Judge status: Accepted
s = input()
print('Yes' if ('a' in s) and ('b' in s) and ('c' in s) else 'No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

for x in a:
    if x%2 == 0:
        if x%3 == 0 or x%5 == 0:
            pass
        else:
            print("DENIED")
            exit()
            

print("APPROVED")
# Judge status: Accepted
S = input()
ans = '2018/01/' + S[8:]
print(ans)
# Judge status: Accepted
a_poll, b_poll, c_poll = map(int, input().split())

if b_poll - a_poll == c_poll - b_poll:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import queue

k = int(input())

q = queue.Queue()

for i in range(1, 10):
    q.put(i)

for i in range(k):
    x = q.get()
    if x % 10 > 0:
        q.put(x*10 + x % 10 - 1)
    q.put(x*10 + x % 10)
    if x % 10 < 9:
        q.put(x*10 + x % 10 + 1)

print(x)
# Judge status: Wrong Answer
n, m = map(int, input().split())
drinks = {}
for i in range(n):
    a, b = map(int, input().split())
    drinks[a] = b
sorted_drinks = sorted(drinks.items())

amount = 0
for d in sorted_drinks:
    if m < d[1]:
        amount += d[0]*m
        break

    m -= d[1]
    amount += d[0]*d[1]
print(amount)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
c4 = 0
c2 = 0
for i in a:
    if i%4 == 0:
        c4 += 1
    elif i%2 == 0:
        c2 += 1
c0 = n - c4 - c2

ans = False
if c2 < 2:
    if c0 + c2 <= c4 + 1:
        ans = True
else:
    if c0 <= c4:
        ans = True
if ans:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S=str(input())
if int(S[5:7])<=4:
  print('Heisei')
else:
  print('TBD')
# Judge status: Wrong Answer
from itertools import groupby as gb
n,s=open(0)
n=int(n)
s=sorted(s)
ans=1
mod=10**9+7
for i,x in gb(s):
  ans=ans*(len(list(x))+1)%mod
print(ans-1)
# Judge status: Accepted
n=int(input())

ans=0
for i in range(1,n):
    ans+=(n-1)//i
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
ans = 0
for i in range(K, N+2):
    ans += i * (N+1-i) + 1
print(ans % (10**9+7))
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
mod = 10**9+7
for i in range(60):
    x = 0
    for j in range(n):
        if a[j] >> i & 1: x += 1 # i桁目が1である数の個数
    now = x*(n-x)%mod # 0と1の組み合わせの数(0 xor 1 = 1)
    for _ in range(i): now = now*2%mod # i桁目が1なら*2^i
    ans += now
    ans %= mod
print(ans)
# Judge status: Accepted
n = int(input())
count = 0
for i in range(1,n):
  count += (n-1)//i
print(count)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
w,a,b = (int(T) for T in input().split())
if a+w<b:
    print(b-(a+w))
elif a<=b<=a+w:
    print(0)
else:
    print(a-(b+w))
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
B = [0]*3
for i in A:
    if i%4==0: B[0]+=1
    elif i%2==0: B[1]+=1
    else: B[2]+=1
print('Yes' if B[0]==0 and B[2]==0 or B[0]>=B[2] or B[1]==0 and B[2]-B[0]==1 else 'No')
# Judge status: Accepted
n,a,b=map(int,input().split())
c=a+b
s=input()
count1=0
count2=0
for i in s:
    if count1>=c:
        print("No")
        continue
    else:
        if i=="a":
            print("Yes")
            count1+=1
            continue
        if i=="b" and count2<b:
            print("Yes")
            count1+=1;count2+=1
            continue
        print("No")
# Judge status: Accepted
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]-(i+1)
ac=Counter(a)
if len(a)%2==0:
    dist=len(a)//2
else:
    dist=len(a)//2+1
temp=0
for i,j in sorted(ac.items()):
    temp+=j
    if temp>=dist:
        ans=0
        for k in range(n):
            ans+=abs(a[k]-i)
        print(ans)
        
        exit()
# Judge status: Accepted
K, N = map(int, input().split())
A = list(map(int, input().split()))

A.append(K + A[0])

distance = 0
for x in range(len(A) - 1):
    distance = max(distance, A[x + 1] - A[x])

print(K - distance)
# Judge status: Accepted
N=int(input())
import math
print((int(math.sqrt(N)))**2)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
lim = 10**18

if 0 in A:
  print(0)
  exit()

  
ans = 1
A.sort(reverse = True)
for i in range(len(A)):
  ans = ans * A[i] 
  if ans > lim:
    print(-1)
    exit()

if ans > lim:
  print(-1)
else:
  print(ans)
# Judge status: Accepted
k, x = map(int, input().split())
if x <= k * 500:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
#lis = list(map(int,input().split()))
if (a%(b+c)) == 0:
    print((a//(b+c))-1)
else:
     print((a//(b+c)))
# Judge status: Wrong Answer
import heapq
N=int(input())
A=list(map(int,input().split()))
heapq.heapify(A)
t1=heapq.heappop(A)
t2=heapq.heappop(A)
if t2%t1==0:
  print(t1)
else:
  a=t2
  b=t1
  while True:
    a-=b
    if a<1:
      print(b)
      break
    elif a>=b:
      pass
    else:
      t=a
      a=b
      b=t
# Judge status: Wrong Answer
s=input()
n=len(s)
ans=0
for i in range(n-1):
    if s[i]=="0" and i%2==0:
        ans+=1
    elif s[i]=="1" and i%2==1:
        ans+=1
ans1=0
for i in range(n-1):
    if s[i]=="1" and i%2==0:
        ans1+=1
    elif s[i]=="0" and i%2==1:
        ans1+=1

print(min(ans,ans1))
# Judge status: Wrong Answer
import string
abc = string.ascii_lowercase
s = list(input())
K = int(input())
index = 0
while K > 0:
    if index == len(s) - 1:
        s[index] = abc[(abc.index(s[index]) + K) % 26]
        break
    tmp = 26 - abc.index(s[index])
    if tmp == 0: continue
    if K >= tmp:
        s[index] = 'a'
        index += 1
        K -= tmp
    else:
        index += 1

for i in s:
    print(i, end='')
# Judge status: Wrong Answer
k = int(input())
cs = input()
print(cs[:len(cs)//2].count("W"))
# Judge status: Accepted
n = int(input())
print(n // 500 * 1000 + n % 500 // 5 * 5)