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

import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'101': ' ', '000000': "'", '000011': ',', '10010001': '-',
        '010001': '.', '000001': '?', '100101': 'A', '10011010': 'B',
        '0101': 'C', '0001': 'D', '110': 'E', '01001': 'F', '10011011': 'G',
        '010000': 'H', '0111': 'I', '10011000': 'J', '0110': 'K', '00100': 'L',
        '10011001': 'M', '10011110': 'N', '00101': 'O', '111': 'P', '10011111': 'Q',
        '1000': 'R', '00110': 'S', '00111': 'T', '10011100': 'U', '10011101': 'V',
        '000010': 'W', '10010010': 'X', '10010011': 'Y', '10010000': 'Z'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans = ""
    a, i = 0, 3
    while a+i != len(d):
        i = 3
        while True:
            if code.get(d[a:a+i], None) is not None:
                ans += code[d[a:a+i]]
                a += i
                break
            i += 1
    print(ans)

### FIXED CODE ###

import string
s = {i : "{:05b}".format(c) for i, c in zip(string.ascii_uppercase+" .,-'?", range(32))}
code = {'101': ' ', '000000': "'", '000011': ',', '10010001': '-',
        '010001': '.', '000001': '?', '100101': 'A', '10011010': 'B',
        '0101': 'C', '0001': 'D', '110': 'E', '01001': 'F', '10011011': 'G',
        '010000': 'H', '0111': 'I', '10011000': 'J', '0110': 'K', '00100': 'L',
        '10011001': 'M', '10011110': 'N', '00101': 'O', '111': 'P', '10011111': 'Q',
        '1000': 'R', '00110': 'S', '00111': 'T', '10011100': 'U', '10011101': 'V',
        '000010': 'W', '10010010': 'X', '10010011': 'Y', '10010000': 'Z'}

while True:
    try:
        data = input()
    except:
        break
    d = ''.join(s[c] for c in data)
    ans=tmp=""
    for c in d:
        tmp += c
        if tmp in code:
            ans += code[tmp]
            tmp = ""
    print(ans)
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]      

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]      
      
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
      
n,m = map(int,input().split())
P = list(map(int,input().split()))

uf = UnionFind(n)

for i in range(m):
  a,b = map(int,input().split())
  uf.union(a-1,b-1)
values = uf.all_group_members().values()

ans = 0
for vs in values:
  s = set(P[v]-1 for v in vs)
  ans += len(s & (set(vs)))

print(ans)  

### FIXED CODE ###

## TLE
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def same(self, x, y):
        return self.find(x) == self.find(y)
      
n,m = map(int,input().split())
P = list(map(int,input().split()))

uf = UnionFind(n)

for i in range(m):
  a,b = map(int,input().split())
  uf.union(a-1,b-1)

ans = 0  
for i in range(n):
  if uf.same(P[i]-1,i):
    ans += 1

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    while a%b != 0:
        a, b = b, a%b
    return b

def gcd_m(*args):
    a, b = args[0], args[1]
    for i in range(2, len(args)):
        a, b = gcd(a, b), args[i]

    return gcd(a, b)

K = int(input())
sum_gcd = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            sum_gcd += gcd_m(a, b, c)
print(sum_gcd)


### FIXED CODE ###

from math import gcd

log = {}
K = int(input())
sum_gcd = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            sum_gcd += gcd(gcd(a, b), c)
print(sum_gcd)
### BUGGY CODE ###

H, W, M = map(int, input().split())
# タプルは更新と削除は不可だからそれらの操作をしない時はリストよりタプルを使うべし
hw = []
sum_h = [0] * W
sum_w = [0] * H
for _ in range(M):
    h, w = map(int, input().split())
    hw.append((h, w))
    h -= 1
    w -= 1
    sum_h[w] += 1
    sum_w[h] += 1


max_h = max(sum_h)
max_w = max(sum_w)

new_H = [h for h in range(H) if sum_w[h] == max_w]
new_W = [w for w in range(W) if sum_h[w] == max_h]

max_num = max_h + max_w - 1
for i in new_H:
    for j in new_W:
        if (i + 1, j + 1) not in hw:
            print(max_h + max_w)
            exit()
        else:
            continue
        break

print(max_num)


### FIXED CODE ###

H, W, M = map(int, input().split())
hw = set()
sum_h = [0] * W
sum_w = [0] * H
for _ in range(M):
    h, w = map(int, input().split())
    hw.add((h, w))
    h -= 1
    w -= 1
    sum_h[w] += 1
    sum_w[h] += 1


max_h = max(sum_h)
max_w = max(sum_w)

new_H = [h for h in range(H) if sum_w[h] == max_w]
new_W = [w for w in range(W) if sum_h[w] == max_h]

max_num = max_h + max_w - 1
for i in new_H:
    for j in new_W:
        if (i + 1, j + 1) not in hw:
            print(max_h + max_w)
            exit()
        else:
            continue
        break

print(max_num)
### BUGGY CODE ###

N,M=map(int,input().split())
x=set([int(x) for x in range(1,N+1)])
for i in range(M):
    L,R=map(int,input().split())
    y=set(range(L,R+1))
    x=x & y
print(len(x))

### FIXED CODE ###

N,M=map(int,input().split())
l=[]
r=[]
for i in range(M):
    L,R=map(int,input().split())
    l.append(L)
    r.append(R)
a=max(l)
b=min(r)
x=list(range(a,b+1))
print(len(x))
### BUGGY CODE ###

n=int(input())
tmp=list(map(int,input().split()))
tmp.append(10**9+7)
ans=0
while len(tmp)>1:
    A=tmp.copy()
    
    A.sort(reverse=True)
    MAX=max(A)
    tmp=[]
    a=A.pop()
    
    if A[-1]!=a:
        ans+=1
    for m in A:
        if m%a==0:
            continue
        else:
            tmp.append(m)
print(ans)
        

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)
### BUGGY CODE ###

a,b,k = map(int,input().split(" "))
r = list(map(int,input().split(" ")))
l = list(map(int,input().split(" ")))
ar = [0]
br = [0]
for i in range(a):
    ar.append(ar[-1] + r[i])
for i in range(b):
    br.append(br[-1] + l[i])
ans = 0
for i in range(len(ar)):
    if ar[i] > k:
        break
    for j in range(len(br)):
        if ar[i] + br[j] <= k:
            t = i + j
        else:
            break
        ans = max(ans,t)
print(ans)

### FIXED CODE ###

a,b,k = map(int,input().split(" "))
r = list(map(int,input().split(" ")))
l = list(map(int,input().split(" ")))
ar = [0]
br = [0]
for i in range(a):
    ar.append(ar[-1] + r[i])
for i in range(b):
    br.append(br[-1] + l[i])
ans = 0
j = b
for i in range(len(ar)):
    if ar[i] > k:
        break
    while True:
        if ar[i] + br[j] <= k:
            t = i + j
            break
        j -= 1
    ans = max(ans,t)
print(ans)
### BUGGY CODE ###

[k,s]=[int(i) for i in input().split()]
a=[]
for i in range(k+1):
    x=i
    for j in range(s-x+1):
        y=s-x-j
        z=s-x-y
        if x<=k and y<=k and z<=k:
            a.append([x,y,z])
#print(a)
print(len(a))

### FIXED CODE ###

[k,s] = [int(i) for i in input().split()]
count = 0
for x in range(k+1):
  for y in range(min(s-x+1,k+1)):
      if s - x - y <= k:
          count += 1
print(count)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
B=[list(map(int,input().split())) for i in range(Q)]
from bisect import bisect_left,bisect_right
# def 二分探索(リスト, 要素)
def index(lst, e):
    # Step 1. bisect_left して
    i = bisect_left(lst, e)
    
    # Step 2. 変な値を ValueError で弾いて
    if i == len(lst):
        return -1
    if lst[i] != e:
        return -1
    # Step 3. 値を返す。
    return i
def index2(lst, e):
    # Step 1. bisect_left して
    i = bisect_right(lst, e)
    
    # Step 2. 変な値を ValueError で弾いて
    if i == len(lst)+1:
        return -1
    if lst[i-1] != e:
        return -1
    # Step 3. 値を返す。
    return i
def count_sort(arr):
    max_num = max(arr)
    min_num = min(arr)
    count = [0] * (max_num - min_num + 1)
    for ele in arr:
        count[ele - min_num] += 1

    return [ele for ele, cnt in enumerate(count, start=min_num) for __ in range(cnt)]

A=count_sort(A)

for i in B:
    j=index(A,i[0])
    if not j==-1:
        k=index2(A,i[0])
        for l in range(j,k):
            A[l]=i[1]
    A=count_sort(A)
    print(sum(A))

### FIXED CODE ###

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

dp=[0 for i in range(1,10**6)]
for i in A:
    dp[i]+=1
S=sum(A)
for i in B:
    S+=(i[1]-i[0])*dp[i[0]]
    print(S)
    dp[i[1]]+=dp[i[0]]
    dp[i[0]]=0
### BUGGY CODE ###

import sys
input = sys.stdin.readline
H, W, M = map(int, input().split())#slow,行数H、列数W、爆弾数M
hcnt = [0] * H#何行目に何個あるか
wcnt = [0] * W#何列目に何個あるか
bomb = []
cnt = 0

for i in range(M):
    bh, bw = map(int, input().split())
    hcnt[bh - 1] += 1#行方向
    wcnt[bw - 1] += 1#列方向
    if bomb.count([bh - 1,bw - 1]) == 0:
        bomb.append([bh - 1,bw - 1])
#hcnt [2,1]
#wcnt[1,1,1]
hmax = max(set(hcnt))
wmax = max(set(wcnt))
for i in range(H):
    for j in range(W):
        if hcnt[i] == hmax and wcnt[j] == wmax and bomb.count([i, j]) == 0:
            cnt += 1

if cnt > 0:
    print(hmax + wmax)
else:
    print(hmax + wmax - 1)


### FIXED CODE ###


import sys
from collections import Counter

H, W, M = map(int, sys.stdin.readline().rstrip().split())#行数H、列数W、爆弾数M
hcnt = [0] * H#何行目に何個あるか
wcnt = [0] * W#何列目に何個あるか
bomb = []

for i in range(M):
    bh,bw=map(int,sys.stdin.readline().rstrip().split())
    hcnt[bh - 1] += 1#行方向
    wcnt[bw - 1] += 1#列方向
    bomb.append((bh - 1,bw - 1))
#hcnt [2,1]
#wcnt[1,1,1]
#bomb[[1,1],[0,0],[0,2]]
hmax = max(hcnt)#2
wmax = max(wcnt)#1

crs = 0#hmax and wmax crosspoint
for (i, j) in bomb:
    if hcnt[i] == hmax and wcnt[j] == wmax:
        crs += 1
#all crosspoint has bomb
if crs == Counter(hcnt)[hmax] * Counter(wcnt)[wmax]:
    print(hmax + wmax - 1)
#more than one crosspoint has no bomb
else:
    print(hmax + wmax)
### BUGGY CODE ###

from collections import Counter
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = Counter(a)
s = 0

for i in c.keys():
    n = c[i]
    if n >= 2:
        s += comb(n, 2)

for i in a:
    n = c[i]
    if 1 <= n-1 < 2:
        ans = s - comb(n, 2)
    elif n-1 >= 2:
        ans = s - comb(n, 2) + comb(n-1, 2)
    else:
        ans = s


    print(ans)




### FIXED CODE ###

from collections import Counter

def combination2(n):
    return int(n * (n-1) / 2)

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

c = Counter(a)
s = 0

for i in c.values():
    s += combination2(i)

for i in a:
    n = c[i]
    ans = s - combination2(n) + combination2(n-1)
    print(ans)
### BUGGY CODE ###

N=int(input())
A=[int(_) for _ in input().split()]
B=[]
C=[]
for i in range(N):
  for j in range(N):
    if A[i]%A[j]==0:
      B.append(i)
for x in set(B):
  if B.count(x)<2:
    C.append(x)
print(len(C))

### FIXED CODE ###

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



from collections import Counter
def gcd(a, b):
    while b: a, b = b, a % b
    return a
def isPrimeMR(n):
    d = n - 1
    d = d // (d & -d)
    L = [2]
    for a in L:
        t = d
        y = pow(a, t, n)
        if y == 1: continue
        while y != n - 1:
            y = (y * y) % n
            if y == 1 or t == n - 1: return 0
            t <<= 1
    return 1
def findFactorRho(n):
    m = 1 << n.bit_length() // 8
    for c in range(1, 99):
        f = lambda x: (x * x + c) % n
        y, r, q, g = 2, 1, 1, 1
        while g == 1:
            x = y
            for i in range(r):
                y = f(y)
            k = 0
            while k < r and g == 1:
                ys = y
                for i in range(min(m, r - k)):
                    y = f(y)
                    q = q * abs(x - y) % n
                g = gcd(q, n)
                k += m
            r <<= 1
        if g == n:
            g = 1
            while g == 1:
                ys = f(ys)
                g = gcd(abs(x - ys), n)
        if g < n:
            if isPrimeMR(g): return g
            elif isPrimeMR(n // g): return n // g
            return findFactorRho(g)
def primeFactor(n):
    i = 2
    ret = {}
    rhoFlg = 0
    while i * i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += i % 2 + (3 if i % 3 == 1 else 1)
        if i == 101 and n >= 2 ** 20:
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    rhoFlg = 1
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k
 
    if n > 1: ret[n] = 1
    if rhoFlg: ret = {x: ret[x] for x in sorted(ret)}
    return ret

def divisors(N):
    pf = primeFactor(N)
    ret = [1]
    for p in pf:
        ret_prev = ret
        ret = []
        for i in range(pf[p]+1):
            for r in ret_prev:
                ret.append(r * (p ** i))
    return ret
  
n=int(readline())
a=list(map(int,readline().split()))  
A=set(a)
ans=0
c=Counter(a)
for i in a:
  if c[i]>=2:
    continue
  chk=set(divisors(i))
  if chk&A=={i}:
    ans+=1
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
H=list(map(int,input().split()))
#配るDPでやってみる
#dp[i]をi番目の足場まで行くときの最小コストとする。
dp=[float('inf')]*(2*n)
dp[0]=0
dp[1]=0
for i in range(1,n+1):
    for a in range(1,min(k+1,n-i+1)):
            dp[i+a]=min(dp[i+a], dp[i]+abs(H[i+a-1]-H[i-1]))
print(dp[n])


### FIXED CODE ###

n,k=map(int,input().split())
H=list(map(int,input().split()))
#配るDPでやってみる
#dp[i]をi番目の足場まで行くときの最小コストとする。
dp=[float('inf')]*(2*n)
dp[0]=0
dp[1]=0
for i in range(1,n+1):
    for a in range(1,min(k+1,n-i+1)):
            dp[i+a]=min(dp[i+a], dp[i]+abs(H[i+a-1]-H[i-1]))
print(dp[n])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

S = input().rstrip()

counter = 0
for l_index in range(len(S) - 4):
    atama = int(S[l_index:l_index+2])
    if atama % 2 != 0:
        continue
    else:
        r_index = 5
        while True:
            saigo = l_index + r_index
            if saigo > len(S):
                break
            kouho = int(S[l_index:saigo])
            if kouho % 2019 == 0:
                counter += 1
            r_index += 1


print(counter)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1
MOD = 2019

"""
gcd(10, 2019) = 1 互いに素
-> 10のmod2019での逆元(1/10)が存在
"""
S = input().rstrip()
s_list = list(map(int, list(S)))[::-1]

counts = [0] * MOD
counts[0] = 1

num, d = 0, 1

for s_element in s_list:
    num += s_element * d
    num %= MOD
    d *= 10
    d %= MOD
    counts[num] += 1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2

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

#zero_sum slow
import sys

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

res = 0
s = 0
s_list = [[0,0]]
i = 0
while i < N:
    s += A[i]
    inside = True
    j = 0
    while j < len(s_list):
        if s == s_list[j][1]:
            temp = s_list[j][0]
            s_list[j][0] += 1
            res -= temp * (temp + 1) / 2.
            res += (temp + 1) * (temp + 2) / 2.
            inside = False
            j = len(s_list) + 1
        j += 1
    if inside:
        s_list.append([0,s])
    i += 1
    
print(int(res))

### FIXED CODE ###

#zero_sum slow
import sys

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


res = 0
s = 0
s_list = {}
s_list.update({0:0})
i = 0
while i < N:
    s += A[i]
    try:
        s_temp = s_list[s]
        s_list[s] += 1
        res -= s_temp * (s_temp + 1) / 2.
        res += (s_temp + 1) * (s_temp + 2) / 2.
    except:
        s_list.update({s:0})
    i += 1
    
print(int(res))
### BUGGY CODE ###

import bisect
import sys
input = sys.stdin.readline
from collections import deque
def solve():
  
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  a.sort()
  tmp = deque([])
  for i in range(m):
    r,l = (int(i) for i in input().split())
    tmp.append((l,r))
  tmp= deque(sorted(tmp,reverse =True))
  ans = 0
  while tmp:
    c,b = tmp.popleft()
    place = bisect.bisect_left(a,c)-1
    if place == -1:
      break
    else:
        if len(a) == 0:
           break
        a = a[min(1+place,b)::]
        ans += c*(min(1+place,b))
    #print(a)
  if a:
   ans += sum(a)
  print (ans)
solve()

### FIXED CODE ###

import bisect
import sys
input = sys.stdin.readline
from collections import deque
def solve():
  
  n,m = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  a = deque(sorted(a))
  tmp = deque([])
  for i in range(m):
    r,l = (int(i) for i in input().split())
    tmp.append((l,r))
  tmp= deque(sorted(tmp,reverse =True))
  ans = 0
  while tmp:
    c,b = tmp.popleft()
    place = bisect.bisect_left(a,c)-1
    if place == -1:
      break
    else:
        if len(a) == 0:
           break
        for i in range(min(1+place,b)):
           a.popleft()
        ans += c*(min(1+place,b))
    #print(a)
  if a:
   ans += sum(a)
  print (ans)
solve()
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int, readline().split())
xyp = [tuple(map(int, readline().split())) for _ in range(n)]

N = 1<<n
INF = 1<<60
resx = []
resy = []
for i in range(n):
    x,y,p = xyp[i]
    rx = [min(abs(x),abs(y))]*N
    ry = [min(abs(x),abs(y))]*N
    for j in range(n):
        for k in range(1<<j):
            rx[k+(1<<j)] = min(rx[k],abs(x-xyp[j][0]))
            ry[k+(1<<j)] = min(ry[k],abs(y-xyp[j][1]))
    
    for j in range(N):
        rx[j] *= p
        ry[j] *= p
    resx.append(rx)
    resy.append(ry)

from itertools import product
ans = [INF]*(n+1)
for lst in product(range(3),repeat=n):
    """
    0: なし、1: 縦、2: 横
    """
    v = lst.count(0)
    x = y = 0
    for i in range(n):
        if lst[i]==1: x |= 1<<i
        if lst[i]==2: y |= 1<<i
    
    r = 0    
    for i in range(n):
        r += min(resx[i][x],resy[i][y])
    if r < ans[v]:
        ans[v] = r

for i in ans[::-1]:
    print(i)


### FIXED CODE ###

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, = map(int, readline().split())
xyp = tuple(tuple(map(int, readline().split())) for _ in range(n))

N = 1<<n
INF = 1<<60
resx = []
resy = []
for i in range(n):
    x,y,p = xyp[i]
    rx = [min(abs(x),abs(y))]*N
    ry = [min(abs(x),abs(y))]*N
    for j in range(n):
        for k in range(1<<j):
            rx[k+(1<<j)] = min(rx[k],abs(x-xyp[j][0]))
            ry[k+(1<<j)] = min(ry[k],abs(y-xyp[j][1]))
    
    for j in range(N):
        rx[j] *= p
        ry[j] *= p
    resx.append(rx)
    resy.append(ry)

ans = [INF]*(n+1)
N = 3**n

p = tuple(3**i for i in range(n+1))
rv = [0]*N
rx = [0]*N
ry = [0]*N
for j in range(n):
    for k in range(p[j]):
        rv[k+  p[j]] = rv[k+2*p[j]] = rv[k]
        rv[k] += 1

        rx[k+  p[j]] = rx[k]|(1<<j)
        ry[k+  p[j]] = ry[k]

        rx[k+2*p[j]] = rx[k]
        ry[k+2*p[j]] = ry[k]|(1<<j)

for mask in range(N):
    v = rv[mask]
    x = rx[mask]
    y = ry[mask]
    
    r = 0    
    for i in range(n):
        r += min(resx[i][x],resy[i][y])
    if r < ans[v]:
        ans[v] = r

for i in ans[::-1]:
    print(i)
### BUGGY CODE ###

N,M = map(int,input().split())
a = [int(input()) for i in range(M)]

dp = [0]*(N+1)
dp[0] = 1

if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1

for i in range(2,N+1):
    if i in a:
        continue
    dp[i] = dp[i-2] + dp[i-1]

print(dp[N] % (10**9+7))


### FIXED CODE ###

N,M = map(int,input().split())
a = [int(input()) for i in range(M)]

dp = [-float("inf")]*(N+1)
dp[0] = 1
dp[1] = 1

for i in a:
    dp[i] = 0

for i in range(2,N+1):
    if dp[i] == 0:
        continue
    dp[i] = dp[i-2] + dp[i-1]
    dp[i] = dp[i] % (10**9+7)

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

N, M = map(int,input().split())
list_append = list(range(1,N+1,1))
for i in range(M):
    L, R = list(map(int, input().split()))
    list_append += list(range(L,R+1,1))
    list_append = [x for x in set(list_append) if list_append.count(x) > 1]
print(len(list_append))

### FIXED CODE ###

n, m = map(int, input().split())
l = 0
r = n
for _ in range(m):
    nl, nr = map(int, input().split())
    l = max(nl, l)
    r = min(nr, r)
 
print(max(r - l + 1, 0))
### BUGGY CODE ###

N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors
ans = make_divisors(N-1)
del ans[0]
cand = make_divisors(N)
del cand[0]
for one in cand:
    n = N
    while True:
        if n%one==0:
            n = N//one
        else:
            if n%one==1:
                ans.append(one)
            break
print(len(ans))

### FIXED CODE ###

N = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors
ans = make_divisors(N-1)
del ans[0]
cand = make_divisors(N)
del cand[0]
for one in cand:
    n = N
    while True:
        if n%one==0:
            n = n//one
        else:
            if n%one==1:
                ans.append(one)
            break

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

N=int(input())
A=list(map(int,input().split()))
A.sort()
l=len(format(A[-1],'b'))
Z=[0]*l
for a in A:
  a=format(a,'b').zfill(l)
  for i,ai in enumerate(a):
    if ai=='0':
      Z[i]+=1
x=1
ans=0
for z in Z[::-1]:
  ans+=x*(z*(N-z))
  x*=2
print(ans%(10**9+7))

### FIXED CODE ###

import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
l=len(format(A.max(),'b'))
MOD=10**9+7

tei=1
ans=0
for i in range(l):
  B=(A >> i) & 1
  one=np.count_nonzero(B)
  zero=N-one
  ans+=tei*one*zero
  tei*=2
print(ans%MOD)