Harryxun/stf_run huggingface dataset:
import math
ans=0
c=0
N = int(input())
A = [int(i) for i in input().split()] 
L=[1]*N
R=[1]*N
L[0]=1
L[1]=A[0]
R[N-1]=1
R[N-2]=A[N-1]
for i in range(2,N):
    L[i]=math.gcd(L[i-1],A[i-1])
    R[N-i-1]=math.gcd(R[N-i],A[N-i])
print(L,R)
for i in range(N):
    if i==0 or i==N-1:
        c=max(L[i],R[i])
        if c>=ans:
            ans=c
    else:
        c=math.gcd(L[i],R[i])
        if c>=ans:
            ans=c
print(ans)

### FIXED CODE ###

from fractions import gcd
n = int(input())
a = list(map(int,input().split()))
left,right = [a[0]]+[0]*(n-1),[0]*(n-1)+[a[n-1]]
arr = [0]*n
for i in range(0,n-1):
  left[i+1] = gcd(left[i],a[i+1])
  right[n-2-i] = gcd(right[n-1-i],a[n-2-i])
arr[0] = right[1]
arr[n-1] = left[n-2]
for i in range(1,n-1):
  arr[i] = gcd(left[i-1],right[i+1])
print(max(arr))
a,b,c,k=map(int,input().split())

if k>=a+b+c:
  print(a-c):
elif a+b<=k<=a+b+c:
  print(a-(k-(a+b)))
elif a<=k<=a+b:
  print(a)
elif 0<=k<=a:
  print(k)

### FIXED CODE ###

a,b,c,k=map(int,input().split())

if k>=a+b+c:
  print(a-c)
elif a+b<=k<=a+b+c:
  print(a-(k-(a+b)))
elif a<=k<=a+b:
  print(a)
elif 0<=k<=a:
  print(k)
a,b,c,d = map(int, input().split())
print(max([a*c, a*d, b*c, b*d])

### FIXED CODE ###

a,b,c,d = map(int, input().split())
print(max([a*c, a*d, b*c, b*d]))
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
print(alphabet[(alphabet.index(input())+n)%26])

### FIXED CODE ###

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
n = int(input())
s = input()
for x in s:
  print(alphabet[(alphabet.index(x)+n)%26], end="")
print()
a, b, c, d = map(int, input().split())
if abs(a-c) <= d or (abs(a-b) <= d && abs(b-c) <= d):
	print('Yes')
else:
	print('No')

### FIXED CODE ###

a, b, c, d = map(int, input().split())
if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
    print('Yes')
else:
    print('No')
import sys
N = int(input())
s = []
for l in sys.stdin:
    s.append(int(l))
    
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
 
print("AC"+"x"+str(a))
print("WA"+"x"+str(b))
print("TLE"+"x"+str(c))
print("RE"+"x"+str(d))

### FIXED CODE ###

import sys
N = int(input())
s = [input() for i in range(N)]
    
a = s.count("AC")
b = s.count("WA")
c = s.count("TLE")
d = s.count("RE")
 
print("AC"+" x "+str(a))
print("WA"+" x "+str(b))
print("TLE"+" x "+str(c))
print("RE"+" x "+str(d))
def binary_search(x, li, value):
  l = []
  left = x+1
  y = x
  right = len(li) - 1
  while left <= right:
    mid = (left + right) // 2
    if li[mid] > value - 1:
      right = mid - 1
    elif li[mid] < value - 1:
      y = mid
      left = mid + 1
    else:
      for i in range(1, 1000):
        if li[mid] == li[mid + i]:
          y = mid + i
        else:
          y = mid
          break
  return y
  
N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    cnt += binary_search(j, L, L[i]+L[j]) - j
print(cnt)

### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
cnt = 0
for i in range(N-2):
  for j in range(i+1, N-1):
    cnt += bisect_left(L, L[i] + L[j]) - j - 1
print(cnt)
A, B, K = map(int, input().split())
 
for i in range(K):
	if i % 2 == 0:
		B = B + A/2
		A = A/2
	else:
		A = A + B/2
        B = B/2 
print ('{} {}'.format(A,B))

### FIXED CODE ###

A, B, K = map(int, input().split())
for i in range(0, K):
    if(i & 1):
        if(B & 1):
            B -= 1
        A += B//2
        B //= 2
    else:
        if(A & 1):
            A -= 1
        B += A//2
        A //= 2
print("{0} {1}".format(A, B))
people_num, first_point, correct = map(int,input().split())
people = [input() for i in range(people_num)]
points = [correct for i in range(people_num)]
 
for i in range(correct):
  for j in range(people_num):
    if j != i:
      points[j] -= 1
      if points[j] == 0:
        prints[j] = - 100000000
        
for i in range(people_num):
  if points[i] < 0:
    print("No")
  else:
    print("Yes")

### FIXED CODE ###

people_num, first_point, correct = map(int,input().split())
who_correct = [input() for i in range(correct)]
points = [first_point-correct for i in range(people_num)]

 
for i in range(correct):
    points[int(who_correct[i])-1] += 1
    
for i in range(people_num):
  if points[i] <= 0:
  	print("No")
  else:
    print("Yes")
N = input()
if N in A and N in B:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = input()
if 'A' in N  and 'B' in N:
  print('Yes')
else:
  print('No')
import sys
input = sys.stdin.readline
from itertools import permutations

def main():
    N = int(input())
    xy = [tuple(map(int,input().split())) for _ in range(N)]
    answer = 0
    for perm in permutations(list(range(N))):
        all_distance = 0

        for i in range(N-1):
            all_distance += ((perm[i+1][1]-perm[i][1])**2 + (perm[i+1][0]-perm[i][0])**2)**(1/2)

        answer = min(answer,all_distance)
    print(answer)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import itertools

def solve(N: int, x: "List[int]", y: "List[int]"):
    pattern = list(itertools.permutations(range(N)))
    sum_dist = 0
    for p in pattern:
        for i in range(1,N):
            sum_dist+=((x[p[i]]-x[p[i-1]])**2+(y[p[i]]-y[p[i-1]])**2)**(1/2)

    print(sum_dist/len(pattern))

    return


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
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()
A,B,C,D,E,F=map(int, raw_input().split())
noudo=int(float(E)/(100+E)*100)

a=[]
for i in range(noudo):
	for j in range(noudo):
		#print i,j
		if i*C+D*j<=noudo:
			a.append(i*C+D*j)

b=[]
cnt=F/100
for i in range(cnt):
	for j in range(cnt):
		if i*100+j*100<=F and i*100+j*100!=0:
			b.append(i*100+j*100)


noudo=float(E)/(100+E)*100
max_noudo=0
for i in a:
	for j in b:
		t_noudo=float(i)/(i+j)*100
		if t_noudo>max_noudo:
			max_noudo=t_noudo
			ans=i,j

print ans[0]+ans[1],ans[0]




### FIXED CODE ###

# -*- coding: utf-8 -*-
A,B,C,D,E,F=map(int, raw_input().split())
#print A,B,C,D,E,F

sugar_list=[0]*(F+1)
i=0
while i <= F :
	for j in range(F):
		val=C*i+D*j
		if val > F:
			break
		elif val <= F:
			sugar_list[val]=1
	i+=1

#print "# Sugar"
#print sugar_list

#Water
water_list=[0]*(F/100+1)
#print water_list
loop_cnt=F/100+1

i=0
while i <= loop_cnt:
	for j in range(loop_cnt):
		val=A*i+B*j
		if val > F/100:
			break
		else:
			#print i,j,val
			water_list[val]=1
	i+=1

#print "# Water"
#print water_list

max_noudo=float(E)/(100+E)
#print max_noudo


hwm=0
water_ans=A*100
sugar_ans=0
for i in range(1,len(water_list)):
	for j in range(len(sugar_list)):
		if water_list[i]*sugar_list[j]==1 and i*100+j<=F and j<=i*E:
			if float(j)/(i*100+j)>hwm:
				hwm=float(j)/(i*100+j)
				water_ans=i*100
				sugar_ans=j
				

print water_ans+ sugar_ans, sugar_ans
from collections import defaultdict
g = defaultdict(list)

n, m = map(int, input().split())
if m==0:
    print('Yes')
    exit()
for i in range(m):
    l, r, d = map(int, input().split())
    g[l].append((r, d))
    g[r].append((l, -1*d))
    
visited = {}
vv = {k:None for k in g.keys()}
def dfs(v):
    stack = []
    visited[v] = True
    stack.append((v,0))
    while not stack:
        v,w = stack.pop()
        vv[v] = w
        for c,d in g[v]:
            if not visited.get(c, False):
                visited[c] = True
                stack.append((c,w+d))

for f in g.keys():
    if not visited.get(f):
        dfs(f)
        
for k in g.keys():
    v = vv[k]
    for c,w in g[k]:
        if not v + w == vv[c]:
            print('No')
            exit()

print('Yes')

### FIXED CODE ###

from collections import defaultdict
g = defaultdict(list)

n, m = map(int, input().split())
if m==0:
    print('Yes')
    exit()
for i in range(m):
    l, r, d = map(int, input().split())
    g[l].append((r, d))
    g[r].append((l, -1*d))
    
visited = {}
vv = {k:None for k in g.keys()}
def dfs(v):
    stack = []
    visited[v] = True
    stack.append((v,0))
    while len(stack)!=0:
        v,w = stack.pop()
        vv[v] = w
        for c,d in g[v]:
            if not visited.get(c, False):
                visited[c] = True
                stack.append((c,w+d))

for f in g.keys():
    if not visited.get(f):
        dfs(f)

for k in g.keys():
    v = vv[k]
    for c,w in g[k]:
        if not v + w == vv[c]:
            print('No')
            exit()

print('Yes')
d, n = map(int, input().split())
a = []
for i in range(100 ** d, 100 ** (d + 1)):
  if i % (100 ** d) == 0:
    a.append(i)
print(a[n-1])

### FIXED CODE ###

d, n = map(int, input().split())
print(n * (100 ** d) if n < 100 else (n + 1) * (100 ** d) )
N,M = map(int,input().split())

A = [input() for i in range(N)]
B = [input() for i in range(M)]


for i in range(N-M):
    for j in range(N-M):
        flg = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] == B[k][l]:
                    pass
                else:
                    flg=False
                    break
            if flg==False:
                break

        if flg:
            break
    if flg:
        break
if flg:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

A = [input() for i in range(N)]
B = [input() for i in range(M)]


for i in range(N-M+1):
    for j in range(N-M+1):
        flg = True
        for k in range(M):
            for l in range(M):
                if A[i+k][j+l] == B[k][l]:
                    pass
                else:
                    flg=False
                    break
            if flg==False:
                break

        if flg:
            break
    if flg:
        break
if flg:
    print('Yes')
else:
    print('No')
n = int(input())
a = list(map(int, input().split()))
if n == 0 and a[0] == 0:
    print(-1)
    exit()
if n != 0 and a[0] >= 1:
    print(-1)
    exit()
val = 1
ans = 1
vlis = []
for i in range(n):
    ans += val * 2
    val *= 2
    val -= a[i+1]
    if val < 0:
        print(-1)
        exit()
    if val == 0 and i != (n-1):
        print(-1)
        exit()
    vlis.append(val-a[i+1])
val3 = (vlis[-2] - a[-2])
val -= val3
if val//2 > vlis[-2]:
    print(-1)
    exit()
ans -= val//2
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
if n == 0 and a[0] == 0:
    print(-1)
    exit()
if n != 0 and a[0] >= 1:
    print(-1)
    exit()
if n == 0 and a[0] >= 2:
    print(-1)
    exit()
ar = list(reversed(a))
#print(ar)
com = [ar[0]]
for i in range(n):
    com.append(com[i] + ar[i+1])
#print(com)
com.reverse()
ans = 1
val = 1
for i in range(1,n+1):
    val *= 2
    ans += min(val,com[i])
    val -= a[i]
    if (i < n and val <= 0) or (i == n and val < 0):
        print(-1)
        exit()
print(ans)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

S = input().rstrip()
l = list(S)
N = len(l)

def getbit(i, length):
    return format(i, '0' + str(length) + 'b')

bits = []
for i in range(2**(N-1)):
    bits.append(getbit(i, N-1))


ans = 0

for i in range(len(bits)):
    s = str(l[0])

    bitlist = list(bits[i])
    for j in range(len(bitlist)):
        if bitlist[j] == '0':
            pass
        else:
            s += '+'

        s += str(l[j+1])
    ans += eval(s)

print(ans)

### FIXED CODE ###


import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

S = input().rstrip()
l = list(S)
N = len(l)

if S == '1':
    print(1)
    exit()

def getbit(i, length):
    return format(i, '0' + str(length) + 'b')

bits = []
for i in range(2**(N-1)):
    bits.append(getbit(i, N-1))


ans = 0

for i in range(len(bits)):
    s = str(l[0])

    bitlist = list(bits[i])
    for j in range(len(bitlist)):
        if bitlist[j] == '0':
            pass
        else:
            s += '+'

        s += str(l[j+1])

    ans += eval(s)

print(ans)
import sys,collections as cl,bisect as bs,copy
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return k
    else:
        return False

n = onem()

on = []
wh = [[-1 for j in range(n)] for i in range(n)]
de = cl.deque()
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    de.append([k[-1],i])
    on.append(cl.deque(k))


co = 0
ddd = []
while True:
    ddd = []
    co += 1
    cl = [1 for i in range(n)]
    
    while de:
        kkk = de.popleft()
        if on[kkk[0]][-1] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
            cl[kkk[0]] = 0
            cl[kkk[1]] = 0
            on[kkk[0]].pop()
            on[kkk[1]].pop()
            if len(on[kkk[1]]) != 0:
                ddd.append([on[kkk[1]][-1],kkk[1]])
            if len(on[kkk[0]]) != 0:
                ddd.append([on[kkk[0]][-1],kkk[0]])
    de = ddd[:]
    
    if sum(cl) == n:
        co = -1
        break
    elif len(de) == 0:
        break

print(co)





















### FIXED CODE ###

import collections as cl
def l(): #intのlist
    return list(map(int,input().split()))
def onem(): #Nとかの取得
    return int(input())
n = onem()

on = []
de = cl.deque()
ppp = [n-1 for i in range(n)]
for i in range(n):
    k = l()
    for j in range(n-1):
        k[j] -= 1
    k.reverse()
    de.append([k[0],i])
    on.append(cl.deque(k))


co = 1
ddd = cl.deque()
de.append([-1,-1])
ppppp = [1 for i in range(n)]
cl = ppppp[:]
while de:
    kkk = de.popleft()
    if kkk[0] == -1 and kkk[1] == -1:
        if sum(cl) == n:
            co = -1
            break
        if len(de) == 0:
            break
        de.append([-1,-1])
        co += 1
        cl = ppppp[:]

    elif ppp[kkk[0]] != 0 and on[kkk[0]][0] == kkk[1] and cl[kkk[0]] and cl[kkk[1]]:
        cl[kkk[0]] = 0
        cl[kkk[1]] = 0
        on[kkk[0]].popleft()
        on[kkk[1]].popleft()
        ppp[kkk[0]] -= 1
        ppp[kkk[1]] -= 1
        if ppp[kkk[1]] != 0 != 0 and ppp[kkk[0]] != 0 and on[kkk[1]][0] == kkk[0] and on[kkk[0]][0] == kkk[1]:
            de.append([on[kkk[1]][0],kkk[1]])
        else:
            if len(on[kkk[1]]) != 0:
                de.append([on[kkk[1]][0],kkk[1]])
            if len(on[kkk[0]]) != 0:
                de.append([on[kkk[0]][0],kkk[0]])


print(co)
x = input()

print(x ** 3)

### FIXED CODE ###

x = int(input())
print(x ** 3)
def get():
    return list(map(int, input().split()))


a = get()
b = a[0]
c = a[1]
if b < c:
    if abs(b - c) < b:
        print(abs(b - a))
    else:
        print(b)
else:
    if a[0] % a[1] == a[1] or a[0] % a[1] == 0:
        print(0)
    else:
        if abs(a[0] % a[1] - a[1]) < abs((a[0] % a[1] - a[1]) % a[1]):
            if abs(a[0] % a[1]) < abs(a[0] % a[1] - a[1]):
                print(abs(a[0] % a[1]))
            else:
                print(abs(a[0] % a[1] - a[1]))
        else:
            if abs(a[0] % a[1]) < abs((a[0] % a[1] - a[1]) % a[1]):
                print(abs(a[0] % a[1]))
            else:
                print(abs((a[0] % a[1] - a[1]) % a[1]))


### FIXED CODE ###

import sys
# 未解決(最後だけREになる)


def get():
    return list(map(int, input().split()))


a = get()
b = a[0]
c = a[1]
if b < c:
    if abs(b - c) < b:
        print(abs(b - c))
        sys.exit(0)
    else:
        print(b)
        sys.exit(0)
else:
    if a[0] % a[1] == a[1] or a[0] % a[1] == 0:
        print(0)
        sys.exit(0)
    else:
        if abs((a[0] % a[1]) - a[1]) < abs(((a[0] % a[1]) - a[1]) % a[1]):
            if abs(a[0] % a[1]) < abs((a[0] % a[1]) - a[1]):
                print(abs(a[0] % a[1]))
                sys.exit(0)
            else:
                print(abs((a[0] % a[1]) - a[1]))
                sys.exit(0)
        else:
            if abs(a[0] % a[1]) < abs(((a[0] % a[1]) - a[1]) % a[1]):
                print(abs(a[0] % a[1]))
                sys.exit(0)
            else:
                print(abs(((a[0] % a[1]) - a[1]) % a[1]))
                sys.exit(0)
a=int(input()), b=int(input())

c=a*b

c=int(c)

if c%2==0:
    print("Even")

if else:
    print("Odd")

### FIXED CODE ###

a,b=map(int, input().split())

if (a*b)%2==0:
    print("Even")

else:
    print("Odd")
import math
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

N = I()
L = LI()
count =0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      flag = 0
      l1 = [L[i],L[j],L[k]]
      l = sorted(l1)
      for n in range(3):
        if(l.count(l[i])>1):
          flag = 1
      if(flag == 0):
        if(l[1]-l[0] < l[2] and l[1]+l[0] > l[2]):
          count += 1
print(count)

### FIXED CODE ###

import math
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

N = I()
L = LI()
count =0
for i in range(N-2):
  for j in range(i+1,N-1):
    for k in range(j+1,N):
      flag = 0
      l1 = [L[i],L[j],L[k]]
      l = sorted(l1)
      for n in range(3):
        if(l.count(l[n])>1):
          flag = 1
      if(flag == 0):
        if(l[1]-l[0] < l[2] and l[1]+l[0] > l[2]):
          count += 1
print(count)
import math

def solve():
    X,Y=[int(x) for x in input().split()]
    if (2*Y-X)%3 or (2*X-Y)%3:
        return 0
    
    a=(2*X-Y)//3
    b=(2*Y-X)//3

    n=a+b
    r=a
    return (math.factorial(n) // (math.factorial(n - r) * math.factorial(r)))%(10**9+7)

    
print(solve())


### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n, r, mod,g1,g2):

    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


def solve():
    X,Y=[int(x) for x in input().split()]
    if (2*Y-X)%3 or (2*X-Y)%3:
        return 0
    
    a=(2*X-Y)//3
    b=(2*Y-X)//3
    

    n=a+b
    r=a

    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    mod = 10**9+7
    N = 10**6
    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
        
    return cmb(n,r,mod,g1,g2)

    
print(solve())
def a_airport_bus(N, C, K, T):
    import bisect
    t = sorted(T)
    index = 0  # t[index]はまだバスに乗っていない人の内最も早い空港到着時刻
    ans = 0
    while index <= N - 1:
        # 時刻 t[index] にバスを出した場合乗り込める人数の候補
        num_take_bus = bisect.bisect_right(t, t[index] + K) - index
        if num_take_bus > C:
            index += C  # 定員分だけ乗せる
        else:
            index += tmp  # 乗れるだけ乗せる
        ans += 1  # バスを1台出した
    return ans

N, C, K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]
print(a_airport_bus(N, C, K, T))

### FIXED CODE ###

def a_airport_bus(N, C, K, T):
    import bisect
    t = sorted(T)
    index = 0  # t[index]はまだバスに乗っていない人の内最も早い空港到着時刻
    ans = 0
    while index <= N - 1:
        # 時刻 t[index] にバスを出した場合乗り込める人数の候補
        num_take_bus = bisect.bisect_right(t, t[index] + K) - index
        if num_take_bus > C:
            index += C  # 定員分だけ乗せる
        else:
            index += num_take_bus  # 乗れるだけ乗せる
        ans += 1  # バスを1台出した
    return ans

N, C, K = [int(i) for i in input().split()]
T = [int(input()) for _ in range(N)]
print(a_airport_bus(N, C, K, T))
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left
import numpy as np

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()
tmp = []
for i in A:
	if tmp == []:
		tmp = np.array([int(x) for x in list("{:b}".format(i).zfill(39))])
	else:
		tmp += np.array([int(x) for x in list("{:b}".format(i).zfill(39))])
tmp = list(tmp)
a = 0  #  K をこえないように管理する
tmp2 = [0]*39
for i in range(39,-1,-1):
	if a + (1<<(i)) <= K and tmp[38-i] < (N+1)//2:
		a += (1<<i)

# print(tmp2)

ans = 0
for i in A:
	ans += i^a
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()
tmp = [0]*40
for a in A:  # tmpに各ビット毎の1の出現回数を保存
    for i in range(40):
        if a&(1<<i):
            tmp[i]+=1
# print(tmp)
a = 0  # K をこえないように管理する
for i in range(39,-1,-1):
	if a + (1<<i) <= K and tmp[i] < (N+1)//2:
		a += (1<<i)

# print(tmp2)

ans = 0
for i in A:
	ans += i^a
print(ans)
a, b = (int(x) for x in input().split())
if a*b%2 == 0:
    print('Even')
else:
    print('Odd')

### FIXED CODE ###

N = int(input())

x = N // 3

print(x)
N,M=map(int,input().split())
A = [int(x) for x in input().split()]
length = A
for i in range(N):
  b,c = map(int,input().split())
  A.extend(b*[c])
print(sum(A[:length]))

### FIXED CODE ###

read = input 
rn = lambda :map(int, read().split())
n,m = rn()
A = list(rn())
l = len(A)
d = {}
for x in A:
    if x not in d:
        d[x]=0
    d[x] += 1
for i in range(m):
    b, c = rn()
    if c not in d:
        d[c]=0
    d[c] += b
A = list(d.items())
A.sort(reverse=True)
ans = 0
cnt = l
# print(A)
for v, c in A:
    tmp = min(cnt, c)
    ans += tmp * v
    cnt -= tmp
print(ans)