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

N = int(input())

point = []
dist = []
maxDist = 0

for _ in range(N) :
    x, y = map(int, input().split())
    d = abs(x) + abs(y)
    maxDist = max(maxDist, d)
    point.append((x, y, d))
    dist.append(d)

mask = maxDist % 2

for d in dist :
    if d % 2 != mask :  # 実現不可能
        print('-1')
        break
else :  # 実現可能
    print(maxDist) # 腕の数
    tmp = (5 * 10**4)
    out = [1] * tmp
    for _ in range(maxDist // tmp) :
        print(*out)
    out = [1] * (maxDist % tmp)
    print(*out)

    for x, y, d in point :
        if x < 0 :
            for _ in range(-x) :
                print('L', end='')
        elif x > 0 :
            for _ in range(x) :
                print('R', end='')

        if y < 0 :
            for _ in range(-y) :
                print('D', end='')
        elif y > 0 :
            for _ in range(y) :
                print('U', end='')

        R = (maxDist - d) // 2
        if R > 0 :
            for _ in range(R) :
                print('LR', end='')

        print('')


### FIXED CODE ###

N=int(input())

point = []
parity = {}
for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    parity[(x + y) % 2] = 1

if len(set(parity)) == 2 :
    print('-1')
else :
    m = 38
    parity = 1 if (1 in parity) else 0
    print(m + 1 - parity)
    if parity == 1 :  # 距離が奇数
        print(*[1 << i for i in range(m)])
    else :
        print(1, *[1 << i for i in range(m)])

    def arm(x, y, m) :
        if abs(x) >= abs(y) :
            if x >= 0 :
                return ('R', x - (1<<m), y)
            else :
                return ('L', x + (1<<m), y)
        else :
            if y >= 0 :
                return ('U', x, y - (1<<m))
            else :
                return ('D', x, y + (1<<m))

    for x, y in point :
        ans = []
        for i in range(m-1, -1, -1) :
            mode, x, y = arm(x, y, i)
            ans.append(mode)
        if parity == 0 :  # 偶数の場合一つ足す
            if x == 1 :
                ans.append('R')
            elif x == -1 :
                ans.append('L')
            elif y == 1 :
                ans.append('U')
            elif y == -1 :
                ans.append('D')
        print(''.join(ans[::-1]))
### BUGGY CODE ###

A, B, N = map(int, input().split())
Ymax=0

if N<B:
  L = N
else:
  L = B

for i in range(L):
  x = i+1
  Y = int(float(A*x)//float(B)) - A*(x//B)
  if Y>Ymax:
    Ymax = Y
print(Ymax)

### FIXED CODE ###

A, B, N = map(int, input().split())
Ymax=0
if A*N < B:
  print(0)
elif N<B:
  Ymax = A*N // B
  print(Ymax)
else:
  x = B-1
  Ymax = A*x//B - A*(x//B)
  print(Ymax)
### BUGGY CODE ###

def index(l, x, default=None):
    if x in l:
        return l.index(x)
    else:
        return default


def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    b = []

    ans = -1
    tmp_index = 0
    for i in range(N):
        if index(a[tmp_index:], i + 1) is None:
            break
        else:
            tmp_index = index(a[tmp_index:], i + 1)
            b.append(i + 1)

    if len(b) == 0:
        print(ans)
        return None
    for i, e in enumerate(b):
        if e != i + 1:
            break
    else:
        ans = N - len(b)

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    counter = 0
    for a in A:
        if a == counter + 1:
            counter += 1
    if counter == 0:
        ans = -1
    else:
        ans = N - counter
    print(ans)


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

# Time Complexity: O(n^2)
# TLE
n, N = int(raw_input()), []
for i in xrange(n):
    N.append(int(raw_input()))

def LIS(lis, A, flag):
    '''
    '''
    if flag == 1 and len(A) != 0:
        lis.append(A[0])

    if len(A) == 0:
        if len(lis) == 0: return 0
        return len(lis)
    elif len(lis) > 1:
        if lis[-2] >= lis[-1]:
            return 0

    return max(LIS(lis[:], A[1:], 1), LIS(lis[:], A[1:], 0))

print max(LIS([], N[:], 1), LIS([], N[:], 0))

### FIXED CODE ###

import bisect

def _input(n):
    return [int(raw_input()) for i in xrange(n)]

# Wrapper for built-in function
def lower_bound(arr, target):
    return bisect.bisect_right(arr, target)


def LIS(arr, n):
    L = [0] * n

    L[0] = arr[0]
    length = 1

    for i in xrange(1, n):
        if L[length - 1] < arr[i]:
            L[length] = arr[i]#L.append(A[i])
            length += 1
        else:
            if L[lower_bound(L[:length], arr[i])-1 if lower_bound(L[:length], arr[i])-1 > 0 else 0] \
                    != arr[i]: # Fix common item - Dont insert common item and zero Problem
                L[lower_bound(L[:length], arr[i])] = arr[i]
    return length, L

#=========================================================
def main():

    n = int(raw_input())
    arr = _input(n)
    print LIS(arr, n)[0]#, LIS(arr, n)[1]#, arr

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

[N,L] = [int(x) for x in input().split()]
A = {}
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count > N + L : break

for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N):
    ans *= A[i]

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
 
ans = 1
flag = 1
if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10 ** 18:
            flag = 0
            break

if flag == 0:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

s = input()

ans = 0

for i in range(len(s)):
    for j in range(i+1,len(s)):
        if int((s[i:j+1])) % 2019 == 0:
            ans +=1
print(ans)

### FIXED CODE ###

s = input()

arr = []
amari = [0 for i in range(2019)]
amari[0] +=1
ans = 0
cnt = 0
keta = 1
for i in range(len(s)):
    cnt = (cnt + int(s[-(i+1)]) * keta) % 2019
    arr.append(cnt)
    keta =keta * 10 % 2019

for i in range(len(arr)):
    amari[arr[i]] +=1    
    
for i in amari:
    ans = ans + i * (i-1) // 2
print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
P = list(map(int, input().split()))

e = []
for p in P:
    e.append(sum(range(p + 1)) / p)

ans = 0
for i in range(n - k + 1):
    a = 0
    for j in range(i, i + k):
        a += e[j]
    ans = max(ans, a)
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
P = list(map(int, input().split()))

m = prev = sum(P[:k])
s = 0
for i in range(1, n - k + 1):
    tmp = prev - P[i - 1]+ P[i + k - 1]
    prev = tmp
    if tmp > m:
        s = i
    m = max(tmp, m)

ans = 0
d = dict()
for i in range(s, s + k):
    p = P[i]
    if p not in d.keys():
        tmp = sum(range(p + 1)) / p
        ans += tmp
        d[p] = tmp
    else:
        ans += d[p]
print(ans)
### BUGGY CODE ###

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

cum =[0 for _ in range(n)]
cum[0] = a[0] % m
for i in range(1, n):
    cum[i] = cum[i-1] + a[i] % m
    cum[i] %= m

ans = 0
cnt = [0 for _ in range(m)]

for i in cum:
    ans += cnt[i]
    cnt[i] += 1
ans += cnt[0]
print(ans)


### FIXED CODE ###

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

cum =[0 for _ in range(n)]
cum[0] = a[0] % m
for i in range(1, n):
    cum[i] = cum[i-1] + a[i] % m
    cum[i] %= m

from collections import Counter
c = Counter(cum)

ans = sum((v*(v-1)//2) for v in c.values())
if 0 in c:
    ans += c[0]
print(ans)
### BUGGY CODE ###

import re
N = int(input())
al = "abcdefghijklmnopqrftuvwxyz"
S = []
for n in range(N):
    S2 = []
    s = input()
    for a in al:
        S2.append(s.count(a))
    S.append(S2)

# print (S)
cnt = 0
for n in range(N):
    for n2 in range(n + 1, N):
        if (S[n] == S[n2]): cnt += 1

print (cnt)


### FIXED CODE ###

N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]

# print(S)

D = {}
for s in S:
    if not(s in D.keys()):
        D[s] = 1
    else:
        # print(s)
        D[s] += 1


cnt = 0
for c in D.values():
    if c != 1:
        cnt += (c * (c - 1)) // 2

print (cnt)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
a=1
for i in range(N):
    a=a*A[i]
if a>(10**18):
    print('-1')
else:
    print(a)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
a=1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a*=A[i]
        if a>1000000000000000000:
          print(-1)
          break
    else:
        print(int(a))
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
lr=[list(map(int,input().split())) for _ in range(Q)]

for i in range(Q):
  s=S[lr[i][0]-1 : lr[i][1]]
  print(s.count('AC'))

### FIXED CODE ###

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

t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i:i+2] == 'AC' else 0)
for i in range(Q):
  l,r=map(int,input().split())
  print(t[r-1]-t[l-1])
### BUGGY CODE ###

# E - Sum of gcd of Tuples (Hard)
# https://atcoder.jp/contests/abc162/tasks/abc162_e

MOD = 10 ** 9 + 7

n, k = map(int, input().split())
dic = {}

ans = 0
for i in range(k, 0, -1):
  num = (k // i) ** n
  for key, val in dic.items():
    if key % i == 0:
      num -= val
  dic[i] = num
  ans += num * i
  ans %= MOD

print(ans)



### FIXED CODE ###

# E - Sum of gcd of Tuples (Hard)
# https://atcoder.jp/contests/abc162/tasks/abc162_e

MOD = 10 ** 9 + 7

n, k = map(int, input().split())
dic = [0] * (k + 1)

ans = 0
for i in range(k, 0, -1):
  dic[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):
  for j in range(i * 2, k + 1, i):
    dic[i] -= dic[j]
    dic[i] %= MOD

ans = 0
for i in range(1, k + 1):
  ans += dic[i] * i
  ans %= MOD

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

import sys

import numpy as np

sys.setrecursionlimit(10000)
INF = float('inf')

N, K = map(int, next(sys.stdin).split())

MOD = K * 2
grid = np.zeros((MOD, MOD))


def draw(sx, sy, ex, ey):
    sx %= MOD
    sy %= MOD
    ex = (ex - 1) % MOD + 1
    ey = (ey - 1) % MOD + 1

    if sx < ex and sy < ey:
        grid[sx, sy] += 1
        if ex < MOD:
            grid[ex, sy] -= 1
        if ey < MOD:
            grid[sx, ey] -= 1
        if ex < MOD and ey < MOD:
            grid[ex, ey] += 1

    elif ex <= sx:
        if ey <= sy:
            draw(0, 0, ex, ey)
            draw(0, sy, ex, MOD)
            draw(sx, 0, MOD, ey)
            draw(sx, sy, MOD, MOD)
        else:
            draw(0, sy, ex, ey)
            draw(sx, sy, MOD, ey)
    else:
        draw(sx, 0, ex, ey)
        draw(sx, sy, ex, MOD)


for _ in range(N):
    x, y, c = next(sys.stdin).split()
    x = int(x)
    y = int(y)
    if c == 'W':
        x += K

    # 黒マスをどこに置けばこの条件を満たすか
    # 累積和とったときに条件を満たす範囲だけ +1 されるように調整
    draw(x, y, x + K, y + K)
    draw(x + K, y + K, x + K * 2, y + K * 2)
print(int(grid.cumsum(axis=0).cumsum(axis=1).max()))


### FIXED CODE ###

import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, K = map(int, next(sys.stdin).split())

MOD = K * 2
grid = [[0 for _ in range(MOD)] for _ in range(MOD)]


def draw(sx, sy, ex, ey):
    sx %= MOD
    sy %= MOD
    ex = (ex - 1) % MOD + 1
    ey = (ey - 1) % MOD + 1

    if sx < ex and sy < ey:
        grid[sx][sy] += 1
        if ex < MOD:
            grid[ex][sy] -= 1
        if ey < MOD:
            grid[sx][ey] -= 1
        if ex < MOD and ey < MOD:
            grid[ex][ey] += 1

    elif ex <= sx:
        if ey <= sy:
            draw(0, 0, ex, ey)
            draw(0, sy, ex, MOD)
            draw(sx, 0, MOD, ey)
            draw(sx, sy, MOD, MOD)
        else:
            draw(0, sy, ex, ey)
            draw(sx, sy, MOD, ey)
    else:
        draw(sx, 0, ex, ey)
        draw(sx, sy, ex, MOD)


for _ in range(N):
    x, y, c = next(sys.stdin).split()
    x = int(x)
    y = int(y)
    if c == 'W':
        x += K

    # 黒マスをどこに置けばこの条件を満たすか
    # 累積和とったときに条件を満たす範囲だけ +1 されるように調整
    draw(x, y, x + K, y + K)
    draw(x + K, y + K, x + K * 2, y + K * 2)

for i in range(MOD - 1):
    for j in range(MOD):
        grid[i + 1][j] += grid[i][j]
for i in range(MOD - 1):
    for j in range(MOD):
        grid[j][i + 1] += grid[j][i]
ans = 0
for i in range(MOD):
    ans = max(ans, *grid[i])
print(ans)
### BUGGY CODE ###

# 初期入力
N = int(input())
AB = [list(map(int, input().split())) for i in range(N-1)]

#　頂点をキー、つながり先をVALUEの辞書
tunagari ={}
for ab in AB:
    tunagari.setdefault(ab[0], []).append(ab[1])
    tunagari.setdefault(ab[1], []).append(ab[0])

# 　最小の色数（根の辺の数）
color_count = [len(i) for i in tunagari.values() ]
color_max =max(color_count)     
print(color_max) #答え

#
color_set =set("")
#頂点とつながり先をキー、色をValueの辞書
color_ten_ten = {}
from collections import defaultdict
col_sumi= {i:set() for i in tunagari.keys()} # 使った色を覚えておく辞書

for k,v in tunagari.items():
    color_set =set([i for i in range(1,color_max+1) ])
    for ii in v:
        if k<ii:
            if col_sumi[k] & color_set:
                color_set = color_set - col_sumi[k] # 今の頂点に対して覚えていた色を消す
            if col_sumi[ii] & color_set:    
                color_set =color_set - col_sumi[ii] # 先の頂点に対して覚えていた色を消す
        
            xx = color_set.pop() # ポップだから速度のため末尾から消す  
            color_ten_ten.setdefault((k,ii) ,xx)  
            col_sumi[k].add(xx) # 元の頂点に対して使った色を覚えておく
            col_sumi[ii].add(xx) # 後の頂点に対して使った色を覚えておく

#AB＝color_ten_tenのキーが同じなら、値の色をprint
for i in AB:
    ab = tuple(i)
    if ab in color_ten_ten.keys() :
        print(color_ten_ten[ab])

### FIXED CODE ###

"""
参考    yy4さん 2019-11-24 21:24:43
516 ms          PyPy3 (2.4.0)
"""
#def solve():
from collections import deque
import sys

input = sys.stdin.readline

n = int(input())

g = tuple(set() for _ in range(n))
for idx in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add((b, idx))
    g[b].add((a, idx))

q = deque()
q.append((0, -1, -1))

e = [-1] * n  # e[-1]は使わない
used = [False] * n
used[0] = True
while q:
    v, v_idx, prev_color = q.popleft()
    curr = 1 if prev_color != 1 else 2
    for u, u_idx in g[v]:
        if used[u]:
            continue
        used[u] = True
        e[u_idx] = curr
        q.append((u, u_idx, curr))
        curr += 1
        if curr == prev_color:
            curr += 1

ret = e[:-1]
#return len(set(ret)), ret

    
#l, ret = solve()
l=len(set(ret))
print(l)
print(*ret, sep='\n')
### BUGGY CODE ###

n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

start = 0

from collections import deque
que = deque([start])
done = {start}
depth = [1e9]  * n
depth[start] = 0
parents = [-1] * n
while True:
    if len(que) == 0:
        break
    now = que.popleft()
    dep = depth[now]
    for node in edge[now]:
        if node not in done:
            if dep < depth[node]:
                depth[node] = dep + 1
                parents[node] = now
                que.append(node)
    done.add(now)
#     print(now)
if max(depth) == 1e9:
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)

### FIXED CODE ###

n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

start = 0

from collections import deque
que = deque([start])
done = {start}
depth = [1e9]  * n
depth[start] = 0
parents = [-1] * n
while True:
    if len(que) == 0:
        break
    now = que.popleft()
    dep = depth[now]
    
    for node in edge[now]:
        if node not in done:
#             if dep < depth[node]:
            depth[node] = dep + 1
            parents[node] = now
            que.append(node)
        done.add(node)
#     done.add(now)
#     print(now)
if max(depth) == 1e9:
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)
### BUGGY CODE ###

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

dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1, N+1):
    w, v = map(int, input().split())
    for j in range(0, W+1):
        if j >= w:
            dp[i][j] = max(dp[i][j], dp[i-1][j-w] + v)
        dp[i][j] = max(dp[i][j], dp[i-1][j])

print(dp[N][W])

### FIXED CODE ###

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

dp = [[0 for i in range(W+1)] for j in range(N+1)]
for i in range(1, N+1):
    w, v = map(int, input().split())
    for j in range(0, W+1):
        if j >= w:
            dp[i][j] = max(dp[i][j], dp[i-1][j-w] + v)
        dp[i][j] = max(dp[i][j], dp[i-1][j])

print(dp[N][W])
### BUGGY CODE ###

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

ans=1
for i in range(n):
    ans *= a[i]

if ans > (10**18):
    print('-1')
else:
     print(ans)

### FIXED CODE ###

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

ans=1

if 0 in a:
    print(0)
    exit()
else:
    for i in range(n):
        ans *= a[i]
        if ans > (10 ** 18):
            print('-1')
            exit()
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def add_edge(self, a, b, w):
        self.graph[a].append((b, w))


class Dijkstra(object):
    def __init__(self, graph, s):
        self.g = graph.graph
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[s] = 0

        self.Q = []
        heappush(self.Q, (self.dist[s], s))
        while self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, w in self.g[u]:
                alt = dist_u + w
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    heappush(self.Q, (alt, v))

    def s_d(self, goal):
        return self.dist[goal]


xs, ys, xg, yg = list(map(int, input().split()))
xyr = []
xyr.append([xs, ys, 0])
N = int(input())

for i in range(N):
    xyr.append(list(map(int, input().split())))
xyr.append([xg, yg, 0])

g_a = Graph()
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        R = ((xyr[i][0] - xyr[j][0]) * (xyr[i][0] - xyr[j][0]) + (xyr[i][1] - xyr[j][1]) * (xyr[i][1] - xyr[j][1]))
        R = R ** 0.5
        if R > xyr[i][2] + xyr[j][2]:
            r = R - xyr[i][2] - xyr[j][2]
        else:
            r = 0
        g_a.add_edge(i, j, r)
        g_a.add_edge(j, i, r)

d_a = Dijkstra(g_a, 0)
print(d_a.s_d(N + 1))

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def add_edge(self, a, b, w):
        self.graph[a].append((b, w))


class Dijkstra(object):
    def __init__(self, graph, s):
        self.g = graph.graph
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[s] = 0

        self.Q = []
        heappush(self.Q, (self.dist[s], s))
        while self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, w in self.g[u]:
                alt = dist_u + w
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    heappush(self.Q, (alt, v))

    def s_d(self, goal):
        return self.dist[goal]


xs, ys, xg, yg = list(map(int, input().split()))
xyr = []
xyr.append([xs, ys, 0])
N = int(input())

for i in range(N):
    xyr.append(list(map(int, input().split())))
xyr.append([xg, yg, 0])

g_a = Graph()
for i in range(N + 1):
    for j in range(i + 1, N + 2):
        R = ((xyr[i][0] - xyr[j][0]) * (xyr[i][0] - xyr[j][0]) + (xyr[i][1] - xyr[j][1]) * (xyr[i][1] - xyr[j][1]))
        R = R ** 0.5
        if R > xyr[i][2] + xyr[j][2]:
            r = R - xyr[i][2] - xyr[j][2]
        else:
            r = 0
        g_a.add_edge(i, j, r)
        g_a.add_edge(j, i, r)

d_a = Dijkstra(g_a, 0)
print(d_a.s_d(N + 1))
### BUGGY CODE ###

R,G,B,N=list(map(int,input().split()))
ans=0
for r in range(0,N//R+1):
    for g in range(0,N//G+1):
        if 0<= (N-(R*r+G*g))//B<=N/B and (N-(R*r+G*g))%B==0 :
            ans+=1
print(ans)

### FIXED CODE ###

R,G,B,N=list(map(int,input().split()))
ans=0
for r in range(0,N//R+1):
    for g in range(0,N//G+1):
        if 0<= (N-(R*r+G*g))//B<=N/B and (N-(R*r+G*g))%B==0 :
            ans+=1
print(ans)
### BUGGY CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
exp=[a/2+0.5 for a in p]
A=[]
for i in range(N-K+1):
  A.append(sum(exp[i:i+K]))
print(max(A))

### FIXED CODE ###

N,K=map(int,input().split())
p=list(map(int,input().split()))
S=sum(p[:K])
T=S
for i in range(N-K):
  S=S-p[i]+p[i+K]
  T=max(T,S)
print((T+K)/2)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    keta = [0 for i in range(61)]
    ans = 0
    for i in range(61):
        kaizyo.append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for i, v in enumerate(bin(i)[:1:-1]):
            keta[i] += int(v)
    # print(kaizyo)
    # print(keta)
    for i, v in enumerate(keta):
        c = v * (n-v)
        ans += c * kaizyo[i]
        ans = ans % MOD
        # print(ans, c, kaizyo[i])

    print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(60)]
    ans = 0
    for i in range(60):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for j in range(60):
            v, i = i % 2, i // 2
            keta[j] += v
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i] % MOD
        ans = ans % MOD

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

def calculate(n, m, id_list):
  result = 0
  for i in range(1, n+1):
    is_passed = True
    for gate in id_list:
      if not((i >= gate[0]) and (i <= gate[1])) :
        is_passed = False
        break
        
    if is_passed:
      result = result + 1
    
  return result
  
  
import sys
 
n=0
m=0
id_list=[]
is_arg_ok = False
try:
  n, m  = map(int, input().split())
  for i in range(0, m):
    gate_min, gate_max = map(int, input().split())
    id_list.append([gate_min, gate_max])
  is_arg_ok = True
  
except:
  print('arg error')
  sys.exit(1)
 
calculated_num = calculate(n, m, id_list)
print(calculated_num)
sys.exit(0)

### FIXED CODE ###

import sys
n=0
m=0

n, m  = map(int, input().split())
_min, _max  = map(int, input().split())
for i in range(1, m):
  gate_min, gate_max = map(int, input().split())
  if (_max > gate_max):
    _max = gate_max
   
  if _min < gate_min:
    _min = gate_min
 
result_list = list(filter(lambda x : (_min <= x) and (x <= _max), range(1, n+1)))
result = len(result_list)

print(result)
sys.exit(0)