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

N, Ma, Mb = map(int, input().split())

G = []
for i in range(N):
 a, b, c = map(int, input().split())
 G.append( (a,b,c) )

M = 401
INF = 1000000000
dp = [INF] * (M * M)
dp[0] = 0
for a, b, c in G:
  i = M - a - 1
  while i >= 0:
    j = M - b - 1
    while j >= 0:
      dp[(i+a)*M+(j+b)] = min(dp[(i+a)*M+(j+b)], dp[i*M+j] + c)
      j -= 1
    i -= 1

ans = INF
x = 1
while Ma * x < M and Mb * x < M:
  ans = min(ans, dp[Ma * x * M + Mb * x])
  x += 1
if ans >= INF:
  ans = -1
print(ans)


### FIXED CODE ###

N, Ma, Mb = map(int, input().split())

G = []
for i in range(N):
 a, b, c = map(int, input().split())
 G.append( (a,b,c) )

M = 1 + min(sum([ a for a, b, c in G ]),
            sum([ b for a, b, c in G ]) )
INF = 1000000000
dp = [INF] * (M * M)
dp[0] = 0
for a, b, c in G:
  i = M - a - 1
  while i >= 0:
    j = M - b - 1
    while j >= 0:
      dp[(i+a)*M+(j+b)] = min(dp[(i+a)*M+(j+b)], dp[i*M+j] + c)
      j -= 1
    i -= 1

ans = INF
x = 1
while Ma * x < M and Mb * x < M:
  ans = min(ans, dp[Ma * x * M + Mb * x])
  x += 1
if ans >= INF:
  ans = -1
print(ans)
### BUGGY CODE ###

from collections import Counter
class UF():
  def __init__(self, N):
    self.parents = [-1] * (N+1)

  def union(self, f, t):
    p1 = self.find(f)
    p2 = self.find(t)
    if p1 == p2:
      return

    if self.parents[p1] > self.parents[p2]:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

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

  def members(self, n):
    root = self.find(n)
    if root == -1:
      return []
    return [ i for i, p in enumerate(self.parents) if self.find(i) == root]

N,K,L = map(int, input().split())
uf_road = UF(N)
uf_railway = UF(N)

for _ in range(K):
  f,t = map(int, input().split())
  uf_road.union(f,t)

for _ in range(L):
  f,t = map(int, input().split())
  uf_railway.union(f,t)

res = []
for i in range(1, N+1):
  road_members = uf_road.members(i)
  railway_members = uf_railway.members(i)
  c = 0
  for road_member in road_members:
    if road_member in railway_members:
      c += 1
  res.append(c)

print(" ".join([str(i) for i in res]))

### FIXED CODE ###

from collections import defaultdict, Counter
class UF():
  def __init__(self, N):
    self.parents = [-1] * (N+1)

  def union(self, f, t):
    p1 = self.find(f)
    p2 = self.find(t)
    if p1 == p2:
      return

    if self.parents[p1] > self.parents[p2]:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

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

  # def members(self, n):
  #   root = self.find(n)
  #   if root == -1:
  #     return []
  #   import pdb; pdb.set_trace()
  #   return [ i for i, p in enumerate(self.parents) if self.find(i) == root]

N,K,L = map(int, input().split())
uf_road = UF(N)
uf_railway = UF(N)

for _ in range(K):
  f,t = map(int, input().split())
  uf_road.union(f,t)

for _ in range(L):
  f,t = map(int, input().split())
  uf_railway.union(f,t)

l = []
for i in range(1, N+1):
  l.append((uf_road.find(i), uf_railway.find(i)))

c = Counter(l)
for i in range(N):
  print(c[l[i]], end=" ")
### BUGGY CODE ###

# たぶん最小の値は最小公倍数になりそう

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


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


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


l = lcm(n, m)
arr = [0 for _ in range(l)]

for i in range(n):
    x = i * (l // n)
    arr[x] = s[i]

for i in range(m):
    x = i * (l // m)
    if arr[x] != 0 and arr[x] != t[i]:
        print(-1)
        exit()
print(l)

### FIXED CODE ###

# たぶん最小の値は最小公倍数になりそう
# 内包表記 -> TLE
# [0]*l -> RE

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


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


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


l = lcm(n, m)
arr = {}

for i in range(n):
    x = i * (l // n)
    arr[x] = s[i]

for i in range(m):
    x = i * (l // m)
    if x in arr and arr[x] != t[i]:
        print(-1)
        exit()
print(l)
### BUGGY CODE ###

n, k = map(int, raw_input().split(" "))

d = {}
for i in range(n):
    a1, b1 = map(int, raw_input().split(" "))
    if a1 in d.keys():
        d[a1] += b1
    else:
        d[a1] = b1


count = 0
for item in sorted(d.items(), key=lambda x: x[0]) :
    if k <= count + item[1]:
        print item[0]
        break
    count += item[1]


### FIXED CODE ###

line_one = raw_input().split()
n = int(line_one[0])
k = int(line_one[1])

l = []
#d = {}
for i in range(n):
    line_one2 = raw_input().split()
    a1 = int(line_one2[0])
    b1 = int(line_one2[1])
    l.append( ( a1, b1 ))
    #if a1 in l:
    #    #d[a1] += b1
    #    l[a1][1] += b1
    #else:
    #    l.append( ( a1, b1 ))
    #    #//d[a1] = b1

#l.sort()
l = sorted(l, key=lambda x: x[0])
count = 0
for item in l:
    count += item[1]
    if k <= count:
        print item[0]
        break
### BUGGY CODE ###

N = input()
N = int(N)

a = []
for i in range(N):
	s_input = input()
	s_input = int(s_input)
	if s_input in a:
		a.remove(s_input)
	else:
		a.append(s_input)

print(len(a))

### FIXED CODE ###

n=int(raw_input())
li={}
while n !=0:
    a = raw_input()
    if a in li:
        del li[a]
    else:
        li[a]=a
    n-=1
print(len(li))
### BUGGY CODE ###

import sys

def q(d, c):
    if c == 1: return str(d), 0
    if d >= 10: 
        lem, count = q(d // 10 + d % 10, c)
        return lem, count + c
    elif c % 2 == 0:
        lem, count = q(d * 2, c // 2)
        return lem, count + c // 2
    elif c % 2 == 1:
        lem, count = q(d * 2, c //2)
        return lem + str(d), count + c // 2

def solve():
    input = sys.stdin.readline
    M = int(input())
    N = ""
    count = 0
    for _ in range(M):
        d, c = map(int, input().split())
        lem, add = q(d, c)
        N += lem
        count += add

    while len(N) > 1:
        N = str(int(N[0]) + int(N[1])) + N[2:]
        count += 1

    print(count)
    
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys
from collections import deque

def q(d, c): #dは9以下、cは桁数
    digsum = d * c
    add = c - 1 + (digsum - 1) // 9
    rem = digsum - 9 * ((digsum - 1) // 9)
    return add, rem

def solve():
    input = sys.stdin.readline
    M = int(input())
    count = -1
    ans = 0
    for _ in range(M):
        d, c = map(int, input().split())
        add, rem = q(d, c)
        count += add
        ans += rem
        count += 1
        if ans > 9:
            ans -= 9
            count += 1

    print(count)
    
    return 0

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

N = int(input())
S = []
ans = N
#for i in range(N):
#    S.append(input())
S = [input() for i in range(N)]
for i in range(N):
    flg = 0
    j  = 0
    while(flg == 0 and j < i):
        if i != j:
#            if len(S[j]) == len(S[i]):
#                if S[j][0] == S[i][0]:
            if S[j] == S[i]:
                S[j] = ''
                ans = ans - 1
                flg = 1
        j = j+1
print(ans)

### FIXED CODE ###

N = int(input())
S = []
ans = N
S = [input() for i in range(N)]
#for i in range(N):
#    S.append(input())
S.sort()
for i in range(N-1):
    if S[i] == S[i+1]:
        ans = ans - 1
print(ans)
### BUGGY CODE ###

from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, K  = [int(x) for x in stdin.readline().rstrip().split()]
A = [0] + [int(x) for x in stdin.readline().rstrip().split()]

stack = deque([1])
nextt = A[1]

while True:
    if not nextt in stack:
        stack.append(nextt)
    else:
        stack.append(nextt)
        break
    nextt = A[nextt]

if len(stack) > K:
    print(stack[K])
    exit()
else:
    num1 = stack.pop()
    length = len(stack)
    tmp = deque([])
    while True:
        num2 = stack.pop()
        if num1 != num2:
            tmp.appendleft(num2)
        else:
            tmp.appendleft(num2)
            break

index = (K - length) % len(tmp)

print(tmp[index])
    


### FIXED CODE ###

from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

N, K  = [int(x) for x in stdin.readline().rstrip().split()]
A = [0] + [int(x) for x in stdin.readline().rstrip().split()]

stack = [1]
nextt = A[1]
visited_dict = {1: True}

while True:
    if not visited_dict.get(nextt, False):
        stack.append(nextt)
        visited_dict[nextt] = True
    else:
        stack.append(nextt)
        break
    nextt = A[nextt]

    if len(stack) > K:
        print(stack[K])
        exit()

num1 = stack.pop()
length = len(stack)
tmp = []
while True:
    num2 = stack.pop()
    if num1 != num2:
        tmp.append(num2)
    else:
        tmp.append(num2)
        break

tmp = tmp[::-1]

index = (K - length) % len(tmp)

print(tmp[index])
### BUGGY CODE ###

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

a = {i for i in range(1, N+1)}
for i in range(M):
    L, R = map(int, input().split())
    # print(a, set([i for i in range(L, R+1)]))
    a = a & {i for i in range(L, R+1)}
    # print(a, set([i for i in range(L, R+1)]))

print(len(a))

### FIXED CODE ###

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

a = {i for i in range(1, N+1)}
L_list = []
R_list = []
for i in range(M):
    L, R = map(int, input().split())
    L_list.append(L)
    R_list.append(R)
    # print(a, set([i for i in range(L, R+1)]))
    # a = a & {i for i in range(L, R+1)}
    # print(a, set([i for i in range(L, R+1)]))

print(max(min(R_list) - max(L_list) + 1, 0))
### BUGGY CODE ###

from itertools import combinations
a = int(input())
b = list(map(int, input().split()))
r = 0
for i, j, k in combinations(b,3):
    if i < j + k and j < i + k and k < i + j:
        r += 1
print(r)


### FIXED CODE ###

def binsearch(l, r, fn, i, j):
    while r - l > 1:
        m = (l + r) // 2
        if fn(m, i, j):
            l = m
        else:
            r = m
    return l

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    def fn(m, i, j):
        a = L[m]
        b = L[i]
        c = L[j]
        if a < b + c and b < c + a and c < a + b:
            return True
        return False
    r = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            if fn(j+1, i, j):
                r += binsearch(j+1, N, fn, i, j) - j
    return r
print(main())
### BUGGY CODE ###

N,Q = map(int, input().split())
import copy
es = {}
for i in range(N-1):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    if a in es:
        es[a].append(b)
    else:
        es[a] = [b]


point_root = [0] * N
query = [None]
for i in range(Q):
    p,x = map(int, input().split())
    point_root[p-1] += x 

ans = [0] * N
for i in range(N):
    ans[i] += point_root[i]
    if es.get(i, None) != None:
        next_nodes = copy.deepcopy(es[i]) # これからポイントを足し行くやつら
    else:
        continue
    
    visited = [False] * N
    visited[i] = True
    idx_n = 0
    while idx_n <= len(next_nodes)-1:
        #idx_n = 0
        if idx_n <= len(next_nodes)-1:
            if visited[next_nodes[idx_n]] == False:
                ans[next_nodes[idx_n]] += point_root[i]
                visited[next_nodes[idx_n]] = True
            #print("--",es,next_nodes)
                #print(es[next_nodes[0]])
                #print("ne",next_nodes)
                idx = next_nodes[idx_n]
                #print("aaa",idx, es)
                tmp = es.get(idx, None)
                if tmp != None:
                    next_nodes.extend(tmp)
                    idx_n += 1
                #next_nodes = next_nodes[1:]
            else:
                idx_n += 1
        else:
            break

print(*ans)



### FIXED CODE ###

N,Q = map(int, input().split())
import copy
import sys

sys.setrecursionlimit(10**6)
es = [[] for i in range(N)]

for i in range(N-1):
    a,b = map(int, input().split())
    a,b = a-1, b-1
    es[a].append(b)
    es[b].append(a)


point = [0] * N

for i in range(Q):
    p,x = map(int, input().split())
    point[p-1] += x 

ans = [0] * N
ans[0] = point[0] # 一番上の根なのでこれだけ
visited = [False] * N
visit_cnt = 1
from collections import deque
nexts = deque([0])
while len(nexts) >= 1:
    now = nexts.popleft()
    visited[now] = True

    for next in es[now]:
        if visited[next] == True:
            continue
        nexts.append(next)
        ans[next] = ans[now] + point[next]


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

from math import factorial

n = int(input())
A = sorted(set(map(int, input().split())))


def comb(m, n):
    ans = factorial(m) / factorial(n) / factorial(m-n)
    return ans


max_num = A[-1]
answer = 0
for i in range(n):
    comb_num = comb(max_num, A[i])
    if answer >= comb_num:
        break
    answer = comb_num

print(max_num, A[i-1])


### FIXED CODE ###

from math import factorial

n = int(input())
A = sorted(list(map(int, input().split())))


max_num = A[-1]
medium = max_num / 2

diff = []
for a in A:
    diff.append(abs(medium-a))

min_index = diff.index(min(diff))
print(max_num, A[min_index])
### BUGGY CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 998244353

def main():
    n,m,k = getList()
    dp = [m]
    # dp[0] = m
    for i in range(n-1):
        tmp = [0 for _ in range(min(i+2, k+1))]
        for j, d in enumerate(dp):
            # print(tmp, j)
            # print(dp)
            tmp[j] += d * (m-1)
            if j < k:
                tmp[j+1] += d
                tmp[j+1] = tmp[j+1] % MOD
            # print("   ", tmp)
        dp = tmp
        # print(dp)

    ans = 0
    for d in dp:
        ans += d
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()



### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left

import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 998244353

def main():
    n,m,kk = getList()

    k = m - 1
    ans = 0
    nck = 1
    rui = m
    for itr in range(1, n+1):
        if n - itr <= kk:
            # print(nck, rui)
            ans += (rui*nck) % MOD
            ans %= MOD
            # print(nck, n, itr)
        nck *= (n - itr)
        nck *= pow(itr, MOD-2, MOD)
        nck %= MOD
        rui *= k
        rui %= MOD
        # print(nck, rui)
    print(ans)


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

n = int(input())
a = list(map(str,input().split()))
for i in range(1,n+1):
    print(a.count(str(i)))

### FIXED CODE ###

n = int(input())
a = list(map(str,input().split()))
from collections import Counter
x = Counter(a)
for i in range(1,n+1):
    print(x[str(i)])
### BUGGY CODE ###

N=int(input())
A=list(map(int, input().split()))
Q=int(input())
B,C=map(int, input().split())
rep=[i for i, x in enumerate(A) if x == B]
for i in range(len(rep)):
    A[rep[i]]=C
ans=0
for i in range(N):
    ans+=A[i]
print(ans)

for _ in range(Q-1):
    B,C=map(int, input().split())
    rep=[i for i, x in enumerate(A) if x == B]
    for i in range(len(rep)):
        A[rep[i]]=C
    ans+=(C-B)*len(rep)
    print(ans)

### FIXED CODE ###

mod=pow(10,5)+2
N=int(input())
num=[0]*mod
ans=0
A=list(map(int, input().split()))
for i in range(N):
    num[A[i]]+=1
    ans+=A[i]
Q=int(input())
for i in range(Q):
    B,C=map(int, input().split())
    cnt=num[B]
    num[C]+=num[B]
    num[B]=0
    ans+=(C-B)*cnt
    print(ans)
### BUGGY CODE ###

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    gates=[]
    n,m = map(int,input().split())
    gates=[list(map(int,input().split())) for _ in range(m)]
    gate_dict={}

    for gate in gates:
        for i in range(min(gate),max(gate)+1):
            if i not in gate_dict:
                gate_dict[i]=1
            else:
                tmp=gate_dict[i]
                tmp+=1
                gate_dict[i]=tmp
    answers=[k for k, v in gate_dict.items() if v == m]
    print(len(answers))

if __name__=="__main__":
    main()

### FIXED CODE ###

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    gates=[]
    n,m = map(int,input().split())
    gates=[list(map(int,input().split())) for _ in range(m)]
    min_data=0
    max_data=10**5+1

    for gate in gates:
        if min_data < gate[0]:
            min_data=min(gate)
        if max_data > gate[1]:
            max_data=max(gate)
    print(len(list(range(min_data,max_data+1))))

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

import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))

mod = 10**9+7
suma = 0
for i in range(n-1):
    tmp=np.sum(a[(i+1):])%mod
    suma+= ((a[i]*tmp))%mod
print(suma%mod)

### FIXED CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
suma = 0
mod = 10**9+7
sumall = sum(a)%mod
for i in range(n-1):
    sumall -= a[i]
    suma+= (a[i]*sumall)%mod
print(suma%mod)
### BUGGY CODE ###

#coding: utf-8

import sys

X = int(input())

powers = {}
def powered(i):
    if i in powers:
        return powers[i]
    powered = pow(i, 5)
    powers[i] = powered
    return powered

for a in range(100000, 0, -1):
    for b in range(0, 100000):
        poweredA = powered(a)
        poweredB = powered(b)
        if poweredA - poweredB == X:
            print(a, b)
            sys.exit()
        elif poweredA + poweredB == X:
            print(a, -b)
            sys.exit()


### FIXED CODE ###

#coding: utf-8

import sys

X = int(input())

powers = {}
def powered(i):
    if i in powers:
        return powers[i]
    powered = pow(i, 5)
    powers[i] = powered
    return powered

for a in range(1000, 0, -1):
    for b in range(0, 1000):
        poweredA = powered(a)
        poweredB = powered(b)
        if poweredA - poweredB == X:
            print(a, b)
            sys.exit()
        elif poweredA + poweredB == X:
            print(a, -b)
            sys.exit()
### BUGGY CODE ###

import sys


def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = [0] * nsq
    is_seated = [0] * nsq
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = [-n2, -1, 1, n2]

    ans = 0

    for p in ppp:
        i, j = divmod(p - 1, n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for di in MOVES:
            ni = i + di
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            val = seats[j]

            if is_seated[j]:
                val += 1
            for dj in MOVES:
                nj = j + dj
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

    return ans


n, *ppp = map(int, sys.stdin.buffer.read().split())

print(solve(n, ppp))


### FIXED CODE ###

import sys
import numpy as np

from numba import njit


@njit('i4(i4,i4[:])', cache=True)
def solve(n, ppp):
    n2 = n + 2
    nsq = n2 * n2
    seats = np.zeros(nsq, dtype=np.int16)
    is_seated = np.zeros(nsq, dtype=np.int8)
    for i in range(n):
        ud = min(i, n - 1 - i)
        ri = (i + 1) * n2
        for j in range(n):
            ij = ri + j + 1
            seats[ij] = min(ud, j, n - 1 - j)
            is_seated[ij] = 1

    MOVES = np.array([-n2, -1, 1, n2], dtype=np.int32)

    ans = 0

    for pi in range(n * n):
        i, j = divmod(ppp[pi], n)
        i = (i + 1) * n2 + j + 1
        res = seats[i]
        ans += res
        is_seated[i] = 0

        q = []
        for mi in range(4):
            ni = i + MOVES[mi]
            if seats[ni] > res:
                seats[ni] = res
                q.append(ni)

        while q:
            j = q.pop()
            # print(val, j, seats[j], l, r)
            val = seats[j]

            if is_seated[j]:
                val += 1
            for mi in range(4):
                nj = j + MOVES[mi]
                if seats[nj] > val:
                    seats[nj] = val
                    q.append(nj)

        # print(ppp[pi] + 1, i, ans)
        # print(seats.reshape((n2, n2)))
        # print(is_seated.reshape((n2, n2)))

    return ans


n = int(sys.stdin.buffer.readline())
ppp = np.array(list(map(int, sys.stdin.buffer.read().split())), dtype=np.int32) - 1

# n = 20
# np.random.seed(seed=32)
# ppp = np.random.permutation(n * n).astype(np.int32)
# print(ppp)

print(solve(n, ppp))
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    XY = [tuple(map(int, input().split())) for _ in range(N)]
    # XY = [list(map(int, input().split())) for _ in range(N)]
    XY.sort()
    XY = tuple(XY)

    def count(x_min, x_max, y_min, y_max, i, j):
        OK = 0
        NG = 0
        a = j - i + 1 - K
        for m in range(i, j + 1):
            if y_min <= XY[m][1] <= y_max:
                OK += 1
            else:
                NG += 1
            if OK >= K:
                return True
            if NG > a:
                return False

    ans = 10 ** 20
    for i in range(N - 1):
        a = XY[i][0]
        for j in range(i + K - 1, N):
            b = XY[j][0]
            for k in range(N):
                c = XY[k][1]
                for l in range(N):
                    d = XY[l][1]
                    if c < d:
                        if count(a, b, c, d, i, j):
                            # print ('A')
                            ans = min(ans, (a - b) * (c - d))
    print (ans)
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#PythonだとTLEする
N, K = map(int, input().split())
X = [0] * N
Y = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    X[i] = x
    Y[i] = y

def count(x_min, x_max, y_min, y_max):
    cnt = 0
    for i in range(N):
        if x_min <= X[i] <= x_max and y_min <= Y[i] <= y_max:
            cnt += 1
    return cnt

ans = 10 ** 20
for i in range(N):
    for j in range(N):
        for k in range(N):
            for l in range(N):
                # print ('i, j , k, l = ', i, j, k, l)
                if X[i] < X[j] and Y[k] < Y[l]:
                    if count(X[i], X[j], Y[k], Y[l]) >= K:
                        # print ('A')
                        ans = min(ans, (X[j] - X[i]) * (Y[l] - Y[k]))
print (ans)
### BUGGY CODE ###

def main():
    M = 1000000007
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    bit_size = len(bin(a[-1])[2:])
    for i in range(n):
        a[i] = bin(a[i])[2:].zfill(bit_size)

    sum = 0
    for i in range(bit_size):
        one = 0
        zero = 0
        for j in range(n):
            if a[j][i] == '1':
                one += 1
            else: 
                zero += 1
        sum += 2**(bit_size - i - 1) * one * zero
        sum %= M
    print(sum)

if __name__ == '__main__':
    main()



### FIXED CODE ###

M = 1000000007
def pow(k):
    ans = 1
    for _ in range(k):
        ans *= 2
        ans %= M
    return ans

def main():
    n = int(input())
    a = list(map(int, input().split()))
    bit_size = len(bin(max(a))[2:])
    for i in range(n):
        a[i] = bin(a[i])[2:].zfill(bit_size)

    sum = 0
    for i in range(bit_size):
        one = 0
        zero = 0
        for j in range(n):
            if a[j][i] == '1':
                one += 1
            else: 
                zero += 1
        sum += pow(bit_size - i - 1) * (one % M) * (zero % M)
        sum %= M
    print(sum)

if __name__ == '__main__':
    main()