Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

N, M = Is()
H = LI()
AB = [[0]*N for _ in range(N)]
for i in range(M):
    a, b = Is()
    a -= 1
    b -= 1
    AB[a][b] = 1
    AB[b][a] = 1

# print(AB)
ans = 0
notgood = [False]*N

for i in range(N):
    if notgood[i]:
        continue
    for j in range(N):
        if AB[i][j] != 0:
            if H[i] > H[j]:
                notgood[j] = True
            elif H[i] < H[j]:
                notgood[i] = True
                break
            else:
                notgood[i] = True
                notgood[j] = True
                break
    else:
        ans += 1

print(ans)

### FIXED CODE ###

def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]


N, M = Is()
H = LI()
AB = [set() for _ in range(N)]
for i in range(M):
    a, b = Is()
    a -= 1
    b -= 1
    AB[a].add(b)
    AB[b].add(a)

ans = 0
notgood = [False]*N

# print(AB)

for i in range(N):
    # print("{} start".format(i))
    # print(AB[i])
    if notgood[i]:
        continue
    if len(AB[i]) == 0:
        ans += 1
        continue
    for x in AB[i]:
        # print(H[x], H[i])
        if H[x] > H[i]:
            notgood[i] = True
            break
        elif H[x] == H[i]:
            notgood[x] = True
            notgood[i] = True
            break
        else:
            notgood[x] = True
    else:
        ans += 1
        # print("{} is GOOD!!!".format(i))

print(ans)
### BUGGY CODE ###

from fractions import gcd
k = int(input())
summation = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ab = gcd(a,b)
            abc = gcd(ab,c)
            summation += abc
print(summation)

### FIXED CODE ###

from math import gcd
k = int(input())
total = 0
ab_gcd = []
for a in range(1,k+1):
    for b in range(1,k+1):
        ab_gcd.append(gcd(a,b))
for ab in ab_gcd:
    for c in range(1,k+1):
        abc = gcd(ab,c)
        total += abc
print(total)
### BUGGY CODE ###

N = int(input())
As = list(map(int, input().strip().split()))

for i in range(1, N+1):
    num_sub = As.count(i)
    print(num_sub)

### FIXED CODE ###

# coding: utf-8
# Your code here!

N = int(input())
As = list(map(int, input().split()))
ans = [0 for _ in range(N)]
 
for a in As:
    ans[a-1] += 1

print(*ans, sep="\n")
### BUGGY CODE ###

import copy

def main():
    n = int(input())
    num_list = [int(input()) for _ in range(n)]
    
    for i in range(n):
        tmp = copy.deepcopy(num_list)
        tmp.pop(i)
        print(max(tmp))
        
if __name__ == '__main__':
    main()

### FIXED CODE ###

import copy

def main():
    n = int(input())
    num_list = [int(input()) for _ in range(n)]

    tmp = copy.deepcopy(num_list)
    tmp.sort()

    max_first = max(num_list)
    max_second = tmp[n-2]
    
    for num in num_list:
        if num == max_first:
            print(max_second)
            continue
        print(max_first)
        
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    a,b,k=map(int,input().split())
    l=[i for i in range(a,b+1)]

    ans=[]
    if k>b-a+1:
        ans.extend([_ for _ in range(a,b+1)])
        for i in sorted(ans):
            print(i)
    else:

        ans.extend([i for i in range(a,a+k)])
        ans.extend([i for i in range(b,b-1-(k-1),-1)])

        for i in sorted(set(ans)):
            print(i)


resolve()



### FIXED CODE ###

# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

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

    ans=[]
    if k>=b-a+1:
        for i in range(a,b+1):
            print(i)
    else:
        for i in range(a,a+k):
            ans.append(i)
        for j in range(b-k+1,b+1):
            if j not in ans:
                ans.append(j)


        for i in ans:
            print(i)


resolve()
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc168_d():
    N, _ = map(int, readline().split())
    adj_mtx = [[False] * (N+1) for _ in range(N+1)]  # 0行0列は使わない
    for ln in readlines():
        a, b = map(int, ln.split())
        adj_mtx[a][b] = adj_mtx[b][a] = True

    labels = [-1] * (N+1)  # -1は未訪問
    labels[0] = labels[1] = 0  # index=0はずっと未訪問だけど0にしておく

    from collections import deque
    que = deque([1])

    while que:
        k = que.popleft()
        for x in range(N+1):
            if not adj_mtx[k][x]: continue  # つながっていない
            if labels[x] != -1: continue  # 訪問済み
            labels[x] = k  # 行先表示が確定
            que.append(x)  # キューに追加

    if -1 in labels:
        print('No')
        return
    else:
        print('Yes')
        print(*labels[2:], sep='\n')

abc168_d()

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def abc168_d():
    N, _ = map(int, readline().split())
    adj = [[] for _ in range(N+1)]
    for ln in readlines():
        a, b = map(int, ln.split())
        adj[a].append(b)
        adj[b].append(a)

    label = [-1] * (N+1)
    label[0] = label[1] = 0

    from collections import deque
    que = deque([1])

    while que:
        k = que.popleft()
        for x in adj[k]:
            if label[x] != -1: continue  # 訪問済み
            label[x] = k  # 行先表示が確定
            que.append(x)  # キューに追加

    if -1 in label:
        print('No')
        return
    else:
        print('Yes')
        print(*label[2:], sep='\n')

abc168_d()
### BUGGY CODE ###

N=int(input())
xy=[map(int,input().split()) for i in range(N)]
x,y=[list(j) for j in zip(*xy)]

s=0
while s<3:
  for k in range(N):
      if x[k]==y[k]:
         s=s+1
      else:
         s=0
 
if s>=3:
  print('Yes')
else:
  print('No')
  

### FIXED CODE ###

N=int(input())
xy=[map(int,input().split()) for i in range(N)]
x,y=[list(j) for j in zip(*xy)]

s=0
flag=False
for k in range(N):
      if x[k]==y[k]:
         s=s+1
         if s==3:
          flag=True
          break
      else:
         s=0
 
if flag==True:
  print('Yes')
else:
  print('No')
### BUGGY CODE ###

(_,K),*T=[map(int,t.split())for t in open(0)]
A,B=map(sorted,T)
d=[2**40,0]
exec("i=sum(d)//2;d[sum(max(0,a-i//b)for a,b in zip(A,B[::-1]))>K]=i;"*41)
print(d[0])

### FIXED CODE ###

import math
N, K = map(int, input().split())
As = sorted(list(map(int, input().split())))
Bs = sorted(list(map(int, input().split())))[::-1]
Cs = [a*b for a, b in zip(As, Bs)]
BCs = list(zip(Bs, Cs))

def func(target):
    r = 0
    for b, c in BCs:
        r += math.ceil(max(0, c - target) / b)
    return r <= K

if __name__ == '__main__':
    min_i, max_i, index = 0, max(Cs)+1, 1
    while True:
        if func(index):
            index, max_i = (index-1 + min_i)//2, index-1
        else:
            index, min_i = (index+1 + max_i)//2, index+1
        if min_i > max_i:
            print(min_i)
            break
### BUGGY CODE ###

N=int(input())
st=input().split()
a=[0 for i in range(N)]
M=set([])
for i in range(N):
    a[i]=int(st[i])
    M.add(a[i])
Numlist=list(M)
b=[0 for i in range(len(M))]
def search(num):
    for k in range(len(M)):
        if Numlist[k]==num:
            return k
    return -1
for i in range(N):
    b[search(a[i])]+=1
count=0
for i in range(len(M)):
    if Numlist[i]<=b[i]:
        count+=b[i]-Numlist[i]
    else:
        count+=b[i]
print(count)

### FIXED CODE ###

N=int(input())
a=[0 for i in range(N)]
st=input().split()
for i in range(N):
    a[i]=int(st[i])
aa=sorted(a)
count=0
nowp=aa[0]
aa.append(10**9+1)
nowcount=1
for i in range(1,N+1):
    if aa[i-1]==aa[i]:
        nowcount+=1
    else:
        nowp=aa[i]
        if nowcount<aa[i-1]:
            count+=nowcount
        else:
            count+=nowcount-aa[i-1]
        nowcount=1
print(count)
### BUGGY CODE ###

#141
N, K, Q = map(int, input().split())

A = []
for i in range(Q):
    A += [int(input())]

cnt = 0
for j in range(N):
    for k in range(Q):
        if A[k] == j+1:
            cnt += 1
    print('No' if (Q - cnt) >= K else 'Yes')
    cnt = 0

### FIXED CODE ###

#141
N, K, Q = map(int, input().split())

cnt = 0
P = [K - Q] * N
for i in range(Q):
    idx = int(input()) - 1    
    P[idx] += 1

for j in range(N):
    if P[j] > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter
from bisect import bisect,insort

def solve(n, ppp):
    q = sorted(enumerate(ppp),key=itemgetter(1),reverse=True)
    le = [-1,-1,q[0][0],n,n]
    ans = 0
    for i, p in q[1:]:
        l_i = bisect(le,i)
        LL = le[l_i-2]
        LR = le[l_i-1]
        RL = le[l_i]
        RR = le[l_i+1]
        ans += p*((LR-LL)*(RL-i)+(RR-RL)*(i-LR))
        insort(le,i)
    return ans


n = int(readline())
ppp = list(map(int,readline().split()))
print(solve(n, ppp))

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from operator import itemgetter

n = int(readline())
ppp = list(map(int,readline().split()))

def BIT_add(i,x):
    while i <= n:
        tree[i] += x
        i += i&(-i)

def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s

def BIT_search(x):
    # 二分探索。和がx以上となる最小のインデックス(>= 1)を返す
      i = 0
      s = 0
      step = 1<<(n.bit_length()-1)
      while step:
          if i+step <= n and s + tree[i+step] < x:
              i += step
              s += tree[i]
          step >>= 1
      return i+1

q = sorted(enumerate(ppp,1),key=itemgetter(1),reverse=True)
tree = [0]*(n+1)

ans = 0
for i, p in q:
    L = BIT_sum(i) # 左にある既に書き込んだ数の個数
    BIT_add(i,1)
    R = n-p-L # 右にある既に書き込んだ数の個数
    LL = BIT_search(L-1) if L >= 2 else 0
    LR = BIT_search(L) if L >= 1 else 0
    RL = BIT_search(L+2) if R >= 1 else n+1
    RR = BIT_search(L+3) if R >= 2 else n+1
    ans += p*((LR-LL)*(RL-i)+(RR-RL)*(i-LR))
print(ans)
### BUGGY CODE ###

import collections
N, Q = [int(_) for _ in input().split()]
STX = [[int(_) for _ in input().split()] for _ in range(N)]
D = [int(input()) for _ in range(Q)]
Add = collections.defaultdict(set)
Elim = collections.defaultdict(set)
Times = set()
for stx in STX:
    s, t, x = stx
    Add[s - x].add(x)
    Elim[t - x].add(x)
    Times.add(s - x)
    Times.add(t - x)
Times = sorted(Times | set(D))
Block = set()
for time in Times:
    for x in Elim[time]:
        Block.remove(x)
    for x in Add[time]:
        Block.add(x)
    if time in D:
        if len(Block):
            print(min(Block))
        else:
            print(-1)


### FIXED CODE ###

import sys
input = sys.stdin.readline
N, Q = [int(_) for _ in input().split()]
STX = [[int(_) for _ in input().split()] for _ in range(N)]
D = [int(input()) for _ in range(Q)]
events = []
for stx in STX:
    s, t, x = stx
    events += [[s - x, 1, x], [t - x, 0, x]]
for i in range(Q):
    events += [[D[i], 2, i]]
events.sort()
block = set()
ans = [-1] * Q
m = float('inf')
for e in events:
    if e[1] == 0:
        block.remove(e[2])
        if m == e[2]:
            if block:
                m = min(block)
            else:
                m = float('inf')
    elif e[1] == 1:
        block.add(e[2])
        m = min(m, e[2])
    else:
        if block:
            if m == float('inf'):
                ans[e[2]] = -1
            else:
                ans[e[2]] = m
print(*ans, sep='\n')
### BUGGY CODE ###

import collections as col

n = int(input())

a = list(map(int, input().split()))
cnt = 0
b = 0
c = [0]
for i in range(n):
    b += a[i]
    c.append(b)
    
d = col.Counter(c)
i=0
ncm=0
lend = len(d)

while i<lend:
    m = d.most_common()[i][1]
    if m > 1:
        ncm += m*(m-1)//2
        i += 1
    else:
        break

print(ncm)

### FIXED CODE ###


n = int(input())

a = list(map(int, input().split()))
cnt = 0
b = 0
c = [0]
for i in range(n):
    b += a[i]
    c.append(b)

c.sort()
i=0
ncm=0
m = 1
while True:
    i += 1
    if i == n+1:
        ncm += m*(m-1)//2
        break        
    if c[i] == c[i-1]:
        m += 1
        continue
    else:
        ncm += m*(m-1)//2
        m = 1

print(ncm)
### BUGGY CODE ###

class T():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)
inf = float('inf')

# input
N, K = map(int, input().split())
h = list(map(int, input().split()))

# dp table
dp = [inf]*N
dp[0] = 0

for i in range(N):
    for j in range(1,K+1):
        if i-j>=0:
            dp[i] = T(dp[i]) + T(dp[i-j] + abs(h[i]-h[i-j]))
print(dp[N-1])

### FIXED CODE ###

def chmin(a,b):
    if a > b:
        return b
    else:
        return a


N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = float('inf')
dp = [INF] * N
dp[0] = 0


for i in range(N):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j] = chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]))

print(dp[N-1])
### BUGGY CODE ###

i=int(input())
nest=1
a=0
p=i
while True:
  nest+=1
  p=p//2
  if p==1:
    break
for k in range(nest):
  a+=2**k
print(a)


### FIXED CODE ###

i=int(input())
nest=1
a=0
p=i
if p==1:
  print(1)
else:
  for k in range(50):
    nest+=1
    p=p//2
    if p==1:
      break
  a=(2**nest)-1
  print(a)
### BUGGY CODE ###

n = int(input())
c = input().split()

for i in range(1, n+1):
    print(c.count(str(i)))


### FIXED CODE ###

n = int(input())
c = input().split()
c = [int(n) for n in c]

s = dict.fromkeys([int(n) for n in range(1,n+1)], 0)

for i in c:
    s[i] = s[i] + 1

for i in range(1, n+1):
    print(s[i])
### BUGGY CODE ###

from copy import deepcopy
import queue

def shortestpath(start, goal, maze, h, w):
    y1, x1 = start
    y2, x2 = goal
    if maze[y1][x1] == '#' or maze[y2][x2] == '#':
        return -1
    if start == goal:
        return -1
    
    step_cnt = [[-1] * w for _ in range(h)]
    q = queue.Queue()
    step_cnt[y1][x1] = 0
    q.put((y1, x1))
    dy = [-1, 0, 1, 0]
    dx = [0, -1, 0, 1]
    while not q.empty():
        y, x = q.get()
        maze[y][x] = '#'
        for i in range(4):
            y_next = y + dy[i]
            x_next = x + dx[i]
            if 0 <= y_next < h and 0 <= x_next < w and maze[y_next][x_next] == '.':
                q.put((y_next, x_next))
                step_cnt[y_next][x_next] = step_cnt[y][x] + 1
                if y_next == y2 and x_next == x2:
                    return step_cnt[y2][x2]
                    
    return -1

h, w = map(int, input().split())      
maze = [[x for x in input()] for _ in range(h)]
max_steps = -1

for y1 in range(h):
    for x1 in range(w):
        for y2 in range(y1, h):
            for x2 in range(w):
                copymaze = deepcopy(maze)
                max_steps = max(max_steps, shortestpath((y1,x1), (y2,x2), copymaze, h, w))

print(max_steps)

### FIXED CODE ###

import queue

def shortestpath(y0, x0):
    step_cnt = [[-1] * w for _ in range(h)]
    step_cnt[y0][x0] = 0
    q.put((y0, x0))
    while not q.empty():
        y, x = q.get()
        for i in range(4):
            y_next = y + dy[i]
            x_next = x + dx[i]
            if 0 <= y_next < h and 0 <= x_next < w\
            and maze[y_next][x_next] == '.'\
            and step_cnt[y_next][x_next] == -1:
                q.put((y_next, x_next))
                step_cnt[y_next][x_next] = step_cnt[y][x] + 1
                    
    return step_cnt[y][x]

h, w = map(int, input().split())      
maze = [[x for x in input()] for _ in range(h)]
dy = [-1, 0, 1, 0]
dx = [0, -1, 0, 1]
q = queue.Queue()

max_steps = -1
for y0 in range(h):
    for x0 in range(w):
        if maze[y0][x0] != '#':
            max_steps = max(max_steps, shortestpath(y0, x0))

print(max_steps)
### BUGGY CODE ###

n, b, r = map(int, input().split())
count = 0
i = 0
while (n>i):
    for bi in range(b):
        count += 1
        i += 1
        if n <= i:
            break
    for ri in range(r):
        i += 1
        if n<=i:
            break
print(count)

### FIXED CODE ###

n, b, r = map(int, input().split())
i = 0
hoge = n // (b+r)
count = hoge*b
n = n - hoge*(b+r)
if n == 0:
    print(count)
while (n>i):
    count += b
    i += b
    if n<=i:
        print(count - (i-n))
        break
    i += r
    if n<=i:
        print(count)
### BUGGY CODE ###

N,K,Q=map(int,input().split())
A=[int(input()) for _ in range(Q)]
if K>Q:
    for n in range(N):
        print("Yes")
else:
    N_dic={n+1:K for n in range(N)}
    for a in A:
        for k,v in N_dic.items():
            if a!=k:
                N_dic[k]=v-1
    for v in N_dic.values():
        if v>0:
            print("Yes")
        else:
            print("No")

### FIXED CODE ###

N,K,Q=map(int,input().split())
# A=[int(input()) for _ in range(Q)]
point=[0]*N
for i in range(Q):
    point[int(input())-1]+=1
for i in range(N):
    ans=K-(Q-point[i])
    if ans>0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

from math import ceil

N, P = map(int, input().split())

d = 1
for i in range(1, ceil(pow(P, 1/N))+1):
  if P % i**N == 0:
    d = i
print(d)

### FIXED CODE ###

N, P = map(int, input().split())

if N == 1:
  d = P
else:
  d = 1
  i = 2
  while i <= round(pow(P, 1/N)):
    if P % i**N == 0:
      P //= i**N
      d *= i
    else:
      i += 1
print(d)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def solve(N: int, M: int, a: "List[int]"):
    koubaisu = 1
    for i in a:

        koubaisu = lcm(koubaisu, i//2)

    for i in a:
        if koubaisu // (i//2) % 2 == 0:
            print(0)
            exit()

    print(M // koubaisu - M // (2*koubaisu))


    return


# Generated by 1.1.6 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
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from fractions import gcd

def solve(N: int, M: int, a: "List[int]"):
    koubaisu = a[0]
    for i in range(1, N):

        koubaisu = koubaisu * a[i] // gcd(koubaisu, a[i])

    for i in a:
        if koubaisu // i % 2 == 0:
            print(0)
            exit()

    print(M // koubaisu - M // (2*koubaisu))


    return


# Generated by 1.1.6 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
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) // 2 for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
N,Q = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
PX = [tuple(map(int,input().split())) for i in range(Q)]
es = [[] for _ in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)
ex = [0] * N
for p,x in PX:
    ex[p-1] += x

ans = [None] * N
def dfs(v=0,c=0,p=-1):
    c += ex[v]
    ans[v] = c
    for to in es[v]:
        if to==p: continue
        dfs(to,c,v)

dfs()
print(*ans)

### FIXED CODE ###

N,Q = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
PX = [tuple(map(int,input().split())) for i in range(Q)]

es = [[] for i in range(N)]
for a,b in AB:
    a,b = a-1,b-1
    es[a].append(b)
    es[b].append(a)

xs = [0] * N
for p,x in PX:
    xs[p-1] += x

ans = [0] * N
ans[0] = xs[0]
visited = [0] * N
stack = [0]
while stack:
    v = stack.pop()
    visited[v] = 1
    for to in es[v]:
        if visited[to]: continue
        stack.append(to)
        ans[to] = ans[v] + xs[to]

print(*ans)
### BUGGY CODE ###

def main():
    MOD = 10**9+7
    n = int(input())
    al = list(map(int, input().split()))

    base_2_cnt = [0]*60 
    for a in al:
        for i in range(60):
            if ((a >> i) & 1): base_2_cnt[i] += 1

    ans = 0
    curr_2 = 1
    for i in range(60):
        base_01_comb = base_2_cnt[i] * (n-base_2_cnt[i])
        ans += base_01_comb * curr_2
        ans %= MOD
        curr_2*=2
        curr_2%=MOD

    print(ans%MOD)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    MOD = 10**9+7
    n = int(input())
    al = list(map(int, input().split()))

    base_2_cnt = [0]*60 
    for a in al:
        for i in range(60):
            if ((a >> i) & 1): base_2_cnt[i] += 1

    ans = 0
    curr_2 = 1
    for i in range(60):
        base_01_comb = base_2_cnt[i] * (n-base_2_cnt[i])
        ans += base_01_comb * curr_2
        ans %= MOD
        curr_2*=2
        curr_2%=MOD

    print(ans%MOD)

if __name__ == "__main__":
    main()