peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import bisect
N,M = map(int,input().split())
A = [[] for _ in range(N)] #重複がある場合にはsetにする？
original = []
for i in range(M):
  a,b = map(int,input().split())
  a-=1 #県を0indexに直す
  A[a].append(b)
  original.append((a,b))
for X in A:
  X.sort()

for i in range(M):
  ken,now = original[i]
  ID = bisect.bisect_left(A[ken],now)
  ken += 1; ID+=1
  ans = "0"*(6-len(str(ken)))+str(ken)+"0"*(6-len(str(ID+1)))+str(ID)
  print(ans)
# Judge status: Wrong Answer
a,b,c = sorted(map(int,input().split()))
print(a*10+b+c)
# Judge status: Accepted
A, B, C, D = map(int, input().split())
while True:
    C -= B
    if C <= 0:
        print("Yes")
        break
    A -= D
    if A <= 0:
        print("No")
        break
# Judge status: Accepted
from bisect import bisect_right, bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i, a in enumerate(L):
    for j, b in enumerate(L[i + 1:], start=i + 1):
        left = bisect_right(L, abs(a - b))
        right = bisect_left(L, a + b)
        ans += right - left

        if left <= i < right:
            ans -= 1
        if left <= j < right:
            ans -= 1

print(ans // 3)
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

l = [a % 10, b % 10, c % 10, d % 10, e % 10]
print((a // 10) * 10 + (b // 10) * 10 + (c // 10) * 10 + (d // 10) * 10 + (d // 10) * 10 + max(l) - 10)
# Judge status: Accepted
N = int(input())
D = [[0 for j in range(2)] for i in range(N)]
c, t = 0, 0

for i in range(N):
    D[i][0], D[i][1] = map(int, input().split())
    if D[i][0] == D[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        t = 1
if t == 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import heapq
N, M = map(int, input().split())
works = sorted([list(map(int, input().split())) for i in range(N)])

ans = 0
hq = []
i = 0
for limit in range(1, M + 1):
    while (i < N) and (works[i][0] <= limit):
        cost, value = works[i]
        heapq.heappush(hq, -value)
        i += 1

    if hq:
        ans += -heapq.heappop(hq)

print(ans)
# Judge status: Accepted
INP=list(map(int, input().split()))
N,L=INP[0],INP[1]
Slist=[]
for i in range(N):
  Slist.append(str(input()))
print("".join(sorted(Slist)))
# Judge status: Wrong Answer
import math
N,H=map(int,input().split())
a=[0]*N
b=[0]*N
c=[]
for i in range(N):
  a[i],b[i] = map(int,input().split())
  c.append([a[i],b[i]])
  
p=0
cnt=0
b.sort(reverse=True)
maxi=max(a)
for th in b:
  if p>=H:
    break
  else:
    if th>=maxi:
      p += th
      cnt+=1
nokori= math.ceil((H-p)/maxi)
print(cnt+nokori)
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
x=0
k=sum(a)
m = 3*10**6
"""
if sum(a)==0 and n>2:
  print(0)
  exit()
  """
for i in range(n-1):
  x+=a[i]
  if m>abs(2*x-k):
    m=abs(2*x-k)
print(m)
# Judge status: Accepted
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

print(I()**2)
# Judge status: Accepted
s = list(input())
k = int(input())
num_list = [int(i) for i in s]
ans = 1
for i in range(k):
    if num_list[i] != 1:
        ans = num_list[i]
        break
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

h,w = input_multiple_number()


print((h*w+1)//2)
# Judge status: Accepted
A, B, C = map(int, input().split())
D = max(A, B, C)
S = sum([A, B, C])
print((D * 3 - S) // 2 if D % 2 == S % 2 else ((D + 1) * 3 - S) // 2)
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = list(map(int, input().split()))

if k >= n:
    for i in range(n-1):
        print(n, end=" ")
    print(n)
    exit()

for _ in range(k):
    list = [1]*n
    for i, d in enumerate(a):
        tmp = [0]*(i-d) + [1]*(2*d+1) + [0]*(n-i-d-1)
        list += tmp
    a = list.copy()
    if _ > 3000:
        break
for i in range(n-1):
    print(a[i], end=" ")
print(a[-1])
# Judge status: Accepted
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
    print(a*b)
else:
    print("-1")
# Judge status: Accepted
h,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
dp=[float('inf')]*(h+10**4+1)
dp[0]=0
for i in range(h+10**4+1):
  for j in range(n):
    if i-ab[j][0]>=0:
      dp[i]=min(dp[i-ab[j][0]]+ab[j][1],dp[i])
print(min(dp[h:]))
# Judge status: Accepted
A,B,K = map(int,input().split())
if A<=K:
  K-=A
  A=0
  if B<=K:
    B=0
  else:
    B-=K
else:
  A-=K

print(A,B)
# Judge status: Wrong Answer
L,R,d = map(int,input().split())
L1 = L//d
R1 = R//d
print(R1-L1)
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
count=0
maxcount=0

for i in range(n-1):
  if h[i]>=h[i+1]:
    count+=1
  elif h[i]<h[i+1]:
    if count>=maxcount:
      maxcount=count
    count=0
  if i==n-2:
    if count>=maxcount:
      maxcount=count
      
print(maxcount)
# Judge status: Accepted
import math

a,b,x=map(int,input().split())
h=x/(a**2)
if 2*h>=b:
    print(math.degrees(math.atan((2*(b-h))/a)))
else:
    
    print(math.degrees(math.atan(b**2/(2*a*h))))
# Judge status: Wrong Answer
from fractions import gcd
import sys
input = sys.stdin.readline

n = int(input())
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans*n//gcd(ans, n)
print(ans)
# Judge status: Accepted
import io

nim,mike = map(int,input().split())
kite = list(map(int,input().split()))
counter1 = 0
result = 0
for i in kite:
  highest = max(0,counter1+i-mike)
  counter1 = i - highest
  result+= highest
print(result)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
print("APPROVED" if all(a&1 or (a%3==0 or a%5==0) for a in A) else "DENIED")
# Judge status: Accepted
n,m=map(int,input().split())
if n==m:
  print('Yes')
else:print('No')
# Judge status: Wrong Answer
N = int(input())
if N <= 999:
    print('ABC' + str(N).zfill(3))
else:
    print('ABD' + str(N-999).zfill(3))
# Judge status: Accepted
N = int(input())
s = input()
t = input()
for i in range(N):
  if s[i:] == t[:N-i]:
    print(N + i)
    break
else:
  print(N * 2)
# Judge status: Accepted
s = input()
n = len(s)
count1 = 0
count2 = 0
for i in range(n):
    if i%2 == 0:
        if s[i] == "1":
            count2 += 1
        elif s[i] == "0":
            count1 += 1
    if i%2 != 0:
        if s[i] == "0":
            count2 += 1
        elif s[i] == "1":
            count1 += 1
print(min(count1, count2))
# Judge status: Accepted
from collections import deque

S = input()
Q = int(input())

queue = deque(list(S))

r = False
for _ in range(Q):
    query = input()
    if query == '1':
        r ^= True
    else:
        _, f, c = query.split()
        front = f == '1'

        if r ^ front:
            queue.appendleft(c)
        else:
            queue.append(c)

if r:
    ans = ''.join(list(queue)[::-1])
else:
    ans = ''.join(queue)

print(ans)
# Judge status: Accepted
import numpy as np
N = input()
Si = [input() for _ in range(int(N))]

uni = np.unique(Si)

print(len(uni))
# Judge status: Wrong Answer
S = input()
minimum=642
for i in range(len(S)-2):
    number=abs(int(S[i:i+3])-753)
    print(S[i:i+3])
    minimum = min(minimum, number)
print(minimum)
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
num = 1
cnt = 0

for i in range(N):
  if a[i] == num:
    num += 1
  else:
    cnt += 1
    
if cnt == N:
  print(-1)
else:
  print(cnt)
# Judge status: Accepted
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
a = Y[n//2-1]
b = Y[n//2]
for  xi in X:
  if xi <= a:print(b)
  else:
    print(a)
# Judge status: Accepted
n = int(input())
v = sorted(list(map(int, input().split())))

ans = v[0]
for i in range(1,n):
  ans = (ans + v[i])/2
print(ans)
# Judge status: Accepted
n = int(input())
t = [[0]*9 for i in range(9)]
for j in range(1, n+1):
    if int(str(j)[-1])==0:
        continue
    t[int(str(j)[0])-1][int(str(j)[-1])-1]+=1
ans = 0
for i in range(9):
    for j in range(9):
        ans += t[i][j]*t[j][i]
print(ans)
# Judge status: Accepted
N = int(input())
S = list(input())
x = 0
max_x = 0
for i in range(N):
    if S[i] == "I":
        x+= 1
    else:
        x -= 1
    max_x = max(x, max_x)
print(max_x)
# Judge status: Accepted
n = int(input())
s = [input() for i in range(n)]
ans = ['AC', 'WA', 'TLE', 'RE']
for i in ans:
    print(i, 'x', s.count(i))
# Judge status: Wrong Answer
N = int(input())
if N == 1:
  print(1)
elif N%2 != 0:
  print((N-2)/N)
else:
  print(N/2)
# Judge status: Wrong Answer
n = int(input())
if n <= 999:
  answer = "ABC"+str(n).zfill(3)
else:
  answer = "ABD"+str(n-999).zfill(3)
print(answer)
# Judge status: Accepted
n = int(input())

A = [0]*(n+1)

ans = 0
for i in range(n):
    A[i] = int(input())
    
    
for i in range(n):
    ans += A[i]//2
    A[i] = A[i]%2
    
    if A[i] and A[i+1]:
        ans += 1
        A[i+1] -= 1
        
print(ans)
# Judge status: Wrong Answer
n,r=map(int,input().split())
print(r-100*max(0,10-n))
# Judge status: Wrong Answer

S=input()
num = len(S) - 1

for i in range(2**num):
    l = ['-']*num
    for j in range(num):
        if(i>>j)&1:
            l[num-j-1] = "+"

    formula=""
    for l_num,l_m in zip(S,l+[""]):
        formula = l_num+l_m

    if eval(formula)==7:
        print(formula+'=7')
        break
# Judge status: Accepted
import itertools
n,m,q=map(int,input().split())
a=[list(map(int,input().split())) for i in range(q)]
l=range(1,m+1)
h_list = list(itertools.combinations_with_replacement(l, n))
ans=0
for i in h_list:
    b=0
    for j in a:
        if i[j[1]-1]-i[j[0]-1]==j[2]:
            b+=j[3]
    ans=max(ans,b)
print(ans)
# Judge status: Accepted
import statistics
import math

n = int(input())
aa,bb = [],[]

for i in range(n):
    a,b = map(int,input().split())
    
    aa.append(a)
    bb.append(b)
    
aa.sort()
bb.sort()
    
if n % 2 == 1:
    am = aa[n//2]
    bm = bb[n//2]
    
    ans = bm - am + 1
    
else:
    am = (aa[n//2] + aa[n//2-1]) / 2
    bm = (bb[n//2] + bb[n//2-1]) / 2
    
    ans = (bm - am)*2 + 1
    
print(int(ans))
# Judge status: Accepted
n=int(input())
a=sorted(set([int(x) for x in input().split()]))

while len(a)!=1:
    if a[0]==0:
        a=a[1:]
    for i in range(1,len(a)):
        a[i]%=a[0]
    a=sorted(set(a))

print(a[0])
# Judge status: Wrong Answer
s=input()
ryoko={'S':0,'N':0,'W':0,'E':0}
for c in s:
    ryoko[c]+=1
if (ryoko['S']>0 and ryoko['N']>0) or (ryoko['W']>0 and ryoko['E']>0):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
def solve():
    n,x = map(int,input().split())
    l = list(map(int,input().split()))
    d = abs(x-l[0])
    for i in range(1,n):
        d = gcd(d,abs(x-l[i]))
    print(d)
if __name__=='__main__':
    solve()
# Judge status: Accepted
N,M = map(int,input().split())
if N>M:N,M = M,N
ans = 0
if N==1:
    if M==1:
        ans = 1
    else:
        ans = M-2
else:
    ans = N*M - 2*(N+M-2)
print(ans)
# Judge status: Accepted
x = int(input())
deposit = 100
count = 0

while deposit < x:
    deposit += int(deposit*0.01)
    count += 1

print(count)
# Judge status: Wrong Answer
n,x = map(int,input().split())
a = [int(x.strip()) for x in input().split()]
a_sorted = sorted(a)
ch,ans = 0,0
for i in range(n):
  ch = sum(a_sorted[:i+1])
  if ch < x:
    ans += 1
  elif ch == x:
    ans += 1
    break
  else:
    break
if ans != 0 and ch != x:
  ans = ans-1
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

prev = a[0]
mon = 1000
stc = 0

for i in range(1, n):
    print(prev)
    if prev < a[i]:
        stc = mon // prev
        mon = mon - stc * prev
        print("stc = {} mon = {}" .format(stc, mon))
    elif prev > a [i]:
        mon = mon + stc * prev
        stc = 0
        print("stc = {} mon = {}" .format(stc, mon))
    prev = a[i]

if stc != 0:
    mon = mon + stc * a[n - 1]

print(mon)
# Judge status: Accepted
import numpy as np


def main():
    n = int(input())
    As = list(map(int, input().split()))
    cumsum = np.cumsum(As)
    ans = float("inf")
    for i in range(n-1):
        ans = min(ans, abs(cumsum[n-1]-2*cumsum[i]))
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
h1,m1,h2,m2,k=map(int,input().split())
t1=h1*60+m1
t2=h2*60+m2
print(max(t2-t1-k,0))
# Judge status: Accepted
N = int(input())
print(N ** 2)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    A = [readline().rstrip() for _ in range(N)]
    B = [readline().rstrip() for _ in range(M)]
    if A == B:
        print('Yes')
        return
    for h in range(N-M):
        for w in range(N-M):
            a = [l[w:w+M] for l in A[h:h+M]]
            if a == B:
                print('Yes')
                return

    print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
t = input()

if s == t[:-1] and len(s) == len(t)-1:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N=input()

if(int(N[-1]) in [2,4,5,7,9]):
    print("hon")
elif(int(N[-1]) in [0,1,6,8]):
    print("pon")
else:
    print("bon")
# Judge status: Accepted
# 初期入力
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
K =[0]*N
A=[]
for i in range(N):
    a,*b = list(map(int, input().split()))
    K[i] =a
    A.append(set(b))
ans =set(list(A[0]))
for i in A:
    ans &=i
print(len(ans))
# Judge status: Wrong Answer
n = int(input())
odd = (n+1)/2
print(odd/n)
# Judge status: Wrong Answer
N, K = map(int, input().split())

if N % K == 0:
  print(0)
elif N % 2 != 0 or K % 2 != 0:
  print(1)
else:
  print(2)
# Judge status: Accepted
import heapq
N, M = map(int, input().split())
jobs = {m:[] for m in range(1,M+1) }

for i in range(N):
  hi,yen = map(int, input().split())
  if hi <= M:
    jobs[hi].append(yen)
  
q = []
ans = 0
for i in range(1,M+1):
  for j in jobs[i]:
    heapq.heappush(q, -j)
  if len(q) > 0:
    a = heapq.heappop(q)
    ans += -a  
print(ans)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))

min = p[0]
cnt = 1

for i in range(1,n):
    if min > p[i]:
        min = p[i]
        cnt += 1
            
print(cnt)
# Judge status: Wrong Answer
N, K = map(int, input().split())
q = N/K
num = 0
while q >0:
  q = q / (K**num)
  num = num + 1
print(num)
# Judge status: Accepted
n = int(input())
a = n//11
b = n%11
if b == 0:
  print(2*a)
elif b < 7:
  print(2*a+1)
else:
  print(2*(a+1))
# Judge status: Wrong Answer
a, b, c, d, e, k = int(input()), int(input()), int(input()), int(input()), int(input()), int(input())
distancies = {
    "a_b": b - a,
    "a_c": c - a,
    "a_d": d - a,
    "a_e": e - a,
    "b_c": c - b,
    "b_d": d - b,
    "b_e": e - b,
    "c_d": d - c,
    "c_e": e - c,
    "d_e": e - d
}
print("Yay!") if all(v < k for v in distancies.values()) else print(":(")
# Judge status: Accepted
import sys
rl = sys.stdin.readline


def solve():
    N, M = map(int, rl().split())
    graph = [set() for _ in range(N)]
    for _ in range(M):
        a, b = map(lambda x: int(x) - 1, rl().split())
        graph[a].add(b)
        graph[b].add(a)
    
    for child in graph[0]:
        if N - 1 in graph[child]:
            print('POSSIBLE')
            exit()
    print('IMPOSSIBLE')


if __name__ == '__main__':
    solve()
# Judge status: Accepted
N = int(input())

th = N // 15

result = N * 800 - th * 200

print(result)
# Judge status: Accepted
s=input()
st=200000
for i in range(len(s)):
  if s[i]=="A" and st>i:
    st=i
  elif s[i]=="Z":
    en=i
print(en-st+1)
# Judge status: Wrong Answer
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

x,y = iim()
xabs = abs(x)
yabs = abs(y)

if y>=x:
    if x*y>0:
        ans = y-x
    else:
        ans = y-abs(x)+1
else:
    if x*y>0:
        ans = x-y+2
    else:
        ans = abs(y)-x+1
print(ans)
# Judge status: Accepted
a,b,c=map(int, input().split())
if c-(a-b)>0:
	print(c-(a-b))
else:
	print(0)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))
total = 1
for i in range(K):
    total += A[i]
before = total
for i in range(K, N):
    total -= A[i-K]
    total += A[i]
    if total > before:
        print('Yes')
    else:
        print('No')
    before = total
# Judge status: Accepted
N = int(input())
if N < 1000:
  print("ABC")
else:
  print("ABD")
# Judge status: Accepted
s = input()
k = int(input())

len_s = len(s)
moji = [0]*(len_s)

for i in range(len_s):
    num = 26-(ord(s[i])-ord('a'))
    if num <= k and num != 26:
        moji[i] = 'a'
        k -= num
    else:
        moji[i] = s[i]

     
if k != 0:
    #print(k)
    moji[len_s-1] = chr(ord(moji[len_s-1])+k%26)
        
print(*moji,sep='')
# Judge status: Accepted
N = int(input())
A = [0] * N
B = [0] * N

for i in range(N):
    A[i], B[i] = map(int, input().split())

A.sort()
B.sort()

if N % 2 == 1:
    mid_a = A[(N + 1) // 2 - 1]
    mid_b = B[(N + 1) // 2 - 1]
    print(mid_b - mid_a + 1)
else:
    mid_a = (A[N // 2 - 1] + A[N // 2]) / 2
    mid_b = (B[N // 2 - 1] + B[N // 2]) / 2
    print(int((mid_b - mid_a) * 2) + 1)
# Judge status: Wrong Answer
n = int(input())
a = [int(i) for i in input().split()]
sumA = 0
sumB = 0
ans = 1000000000
for i in range(1,n):
    sumA = sum(a[:i])
    sumB = sum(a[i:])
    ans = min(ans,abs(sumA-sumB))
print(ans)
# Judge status: Accepted
n = int(input())
ans = 0

for i in range(1,n+1):
  if i%3 == 0:
    continue
  
  if i%5 == 0:
    continue
    
  ans = ans + i
  
print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1
MOD = 1000000007

dp=[0]*(N+1)
dp[0]=1
if a[1]==1:
    dp[1]=0
else:dp[1]=1

for i in range(2,N+1):
    #n-1段目が安全なら
    if a[i-1]==0:
        dp[i]+=dp[i-1]
    #n-2段目が安全なら
    if a[i-2]==0:
        dp[i]+=dp[i-2]
    dp[i] = dp[i]%MOD
print(dp[N])
# Judge status: Accepted
s = input()
t = input()
d = {}
for si, ti in zip(s, t):
    if si in d:
        if d[si] != ti:
            print('No')
            exit()
    else:
        d[si] = ti
l = len(set(d.values()))
print('Yes' if len(d) == l else 'No')
# Judge status: Wrong Answer
h = int(input())
w = int(input())
n = int(input())

if h>w:
	nBig = h
else:
    nBig = w
    
ans = int(n/nBig)

print(ans)
# Judge status: Accepted
N,C,K = map(int,input().split())

cnt = 0
ans = 0
lst = [int(input()) for _ in range(N)]
lst = sorted(lst)
next_t = 10**10
for t in lst:
  next_t = min(t+K,next_t)
  if (t > next_t):
    ans += 1
    cnt = 0
    next_t = t+K
    
  cnt += 1
  if (cnt == C):
    ans += 1
    cnt = 0
    next_t = 10**10
    
if (cnt > 0):
  ans += 1
print(ans)
# Judge status: Wrong Answer

N=int(input())
l = input()
mi = 300000

print(l)

for i in range(N):
    count=0
    for j in range(N):
        if i>j:
            if l[j]=="W":
                count+=1
        elif i<j:
            if l[j]=="E":
                count+=1
        else:
            continue
    mi=min(mi,count)

print(mi)
# Judge status: Accepted
s = input()
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
	print("Bad")
else:
	print("Good")
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = [i for i in range(1, m+1)]
b = [i for i in reversed(range(m+1, 2*m+1))]
for x, y in zip(a, b):
    print(x, y)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
if n==0:
  if a[0]==1:
    print(1)
    exit()
  else:
    print(-1)
    exit()
if a[0]>0:
  print(-1)
  exit()

ans=1
pre_no_ha=1
all_ha=sum(a)

for ai in a[1:]:
  if pre_no_ha<=0:
    print(-1)
    exit()
  if ai>pre_no_ha*2:
    print(-1)
    exit()
  
  pre_no_ha*=2
  pre_no_ha-=ai
  all_ha-=ai
  pre_no_ha=min(pre_no_ha,all_ha)
  ans+=pre_no_ha+ai

print(ans)
# Judge status: Accepted
import numpy as np

def main():
    n = int(input())
    a = np.array([int(i) for i in input().split()])
    mod = 10**9 + 7
    c = 0
    for k in range(60):
        kc = len(a[a & 1 == 1])
        c = (c + kc * (n - kc) * pow(2, k, mod)) % mod
        a //= 2
    print(c)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
res = False

for i in range(N):
  if A[i]%2 == 0:
    if A[i]%3 == 0 or A[i]%5 == 0:
      res = True
    else:
      res = False
if res:
  print("APPROVED")
else:
  print("DENIED")
# Judge status: Accepted
import numpy as np
A, B, H, M = list(map(int, input().split()))
print(np.sqrt(A**2+B**2-2*A*B*np.cos(np.deg2rad(abs(360*((H+M/60)/12-M/60))))))
# Judge status: Accepted
a=[list(map(int,input().split())) for _ in range(3)]
for i in range(int(input())):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:a[j][k]=0
ans="No"

for i in range(3):
    if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
    if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
    if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
    if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)
# Judge status: Wrong Answer
ans = int(input())
if 400 <= ans < 599:
  ans = 8
elif 600 <= ans <= 799:
  ans = 7
elif 800 <= ans <= 999:
  ans = 6
elif 1000 <= ans <= 1199:
  ans = 5
elif 1200 <= ans <= 1399:
  ans = 4
elif 1400 <= ans <= 1599:
  ans = 3
elif 1600 <= ans <= 1799:
  ans = 2
elif 1800 <= ans <= 1999:
  ans = 1
print(ans)
# Judge status: Accepted
from typing import NoReturn


def main() -> NoReturn:
    a, b, c, k = map(int, input().split())  # type: int, int, int, int
    if a >= k:
        print(k)
    elif a + b >= k:
        print(a)
    else:
        print(2 * a + b - k)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import collections

n,m = map(int,raw_input().split(' '))
operations = [map(int, raw_input().split(' ')) for _ in range(m)]
def f(operations, n):

	res = [-1] * n

	for s,c in operations:
		s -=1
		if res[s] == -1:
			res[s] = c
		elif res[s] != c:
			return (False, res)
	
	for i in range(len(res)):
		if res[i] == -1: 
			res[i] = 0 if (i or n == 1) else 1
	
	if res[0] == 0 and n > 1:
		return (False, res)
	return (True, res)
f,r = f(operations, n)
print ''.join(map(str,r)) if f else -1
# Judge status: Wrong Answer
import sys

N = int(input())

dp = [[0]*3  for i in range(N)]

dp[0][0], dp[0][1], dp[0][2] = map(int, sys.stdin.readline().split())

tmp = [0, 0, 0]

for i in range(1, N):
    tmp[0], tmp[1], tmp[2] = map(int, sys.stdin.readline().split())
    for j in range(3):
        dp[i][j] = max(dp[i-1][(j+1)%3]+tmp[(j+2)%3], dp[i-1][(j+2)%3]+tmp[(j+2)%3])

print(max(dp[N-1]))
# Judge status: Wrong Answer
a,b=map(int,input().split())
if (a%3==0 or b%b==0 or (a+b)%3==0) and a+b>2:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))
if k >= n:
    print(0)
else:
    h.sort()
    count = 0
    for i in range(n - k):
        count += h[i]
    print(count)
# 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
n,k=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
print(sum(p[:3]))
# Judge status: Accepted
from operator import itemgetter
n = int(input())
SP = []
for i in range(1, n+1):
    s, p = input().split()
    p = int(p)
    SP.append([i, s, -p])
SP.sort(key=itemgetter(1, 2))
print(*map(itemgetter(0), SP), sep='\n')
# Judge status: Accepted
a, b, c, k = map(int, input().split())

if k % 2 == 0:
    print(a-b)
else:
    print(b-a)
# Judge status: Accepted
n, k = [int(i) for i in input().split()]
xx = [int(i) for i in input().split()]

cost = float("inf")
for i in range(n-k+1):
  j = i + k - 1
  cost = min(
    cost,
    abs(xx[i] - 0) + abs(xx[j] - xx[i]),
    abs(xx[j] - 0) + abs(xx[i] - xx[j])
  )
print(cost)