Harryxun/stf_run huggingface dataset:
N = int(input())
W = list(map(int,input().split()))
R = [W[0]]
for i in range(1,N):
    R.append(R[i-1] + W[i])
s = sum(W)

ans = 1000

for i in range(N):
    ans = min(ans,abs(R[i]-(s-R[i])))
print(ans)
"""

"""
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]

G_jouge = []
G_sayu = []
for h in range(H):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for w in range(W):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[h][W-1-w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_sayu.append([G_hidari[W-1-i]+G_migi[i] for i in range(W)])
for w in range(W):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for h in range(H):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[H-1-h][w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_jouge.append([G_hidari[H-1-i]+G_migi[i] for i in range(H)])

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,G_sayu[h][w]+G_jouge[w][h])
print(ans+1)

### FIXED CODE ###

H,W = map(int,input().split())
S = [list(input()) for i in range(H)]

G_jouge = []
G_sayu = []
for h in range(H):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for w in range(W):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[h][W-1-w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_sayu.append([G_hidari[W-1-i]+G_migi[i] for i in range(W)])
for w in range(W):
    G_migi = []
    G_hidari = []
    r = 0
    l = 0
    for h in range(H):
        if S[h][w] == '.':
            G_migi.append(r)
            r += 1
        else:
            r = 0
            G_migi.append(r)
        if S[H-1-h][w] == '.':
            G_hidari.append(l)
            l += 1
        else:
            l = 0
            G_hidari.append(l)
    G_jouge.append([G_hidari[H-1-i]+G_migi[i] for i in range(H)])

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,G_sayu[h][w]+G_jouge[w][h])
print(ans+1)
x = int(input())
 print(x ** 3)

### FIXED CODE ###

x = int(input())
print(x ** 3)
from collections import defaultdict
s = input().split()
n = int(s[0]) 
m = int(s[1])
graph = defaultdict(list)
for i in range(m):
    s = input().split(" ")
    graph[int(s[0])].append(int(s[1]))
    graph[int(s[1])].append(int(s[0]))
visited = [False] * (n+1)

def dfs(root):
    visited[root] = True
    for child in graph[root]:
        if not visited[child]:
            dfs(child)

ans  = 0
prev = 0
for i in range(1, n+1):
    if not visited[i]:
        dfs(i)
        temp = 0
        for k in visited:
            if k:
                temp+=1
        ans  = max(ans, temp-prev)
        prev = temp

print(ans)



### FIXED CODE ###

from collections import defaultdict
s = input().split()
n = int(s[0]) 
m = int(s[1])
graph = defaultdict(set)
for i in range(m):
    s = input().split(" ")
    graph[int(s[0])].add(int(s[1]))
    graph[int(s[1])].add(int(s[0]))

visited = [False] * (n+1)

def bfs (node):
    queue = [node]  
    ans = 0
    visited[node] = True
    while queue:
        root = queue.pop()
        ans +=1
        
        for child in graph[root]:
            if not visited[child]:
                queue.append(child)
                visited[child]  =True
    return ans

ans  = 0
for i in range(1, n+1):
    if not visited[i]:
        ans = max(ans, bfs(i))
print( ans)
m, d = map(int, raw_input().split())
if m in (1,3,5,7,8,10,12) and d == 31:
  print(1)
elif m in (4,6,9,11) and d == 30:
  print(1)
elif m == 2 and d == 28:
  print(1)
else:
  print(0)


### FIXED CODE ###

m, d = map(int, raw_input().split())
raw_input()
if m in (1,3,5,7,8,10,12) and d == 31:
  print(1)
elif m in (4,6,9,11) and d == 30:
  print(1)
elif m == 2 and d == 28:
  print(1)
else:
  print(0)
n,m=(int(i) for i in input().split(' '))
i=m//i
while True:
  if m%i==0 and m//i>=n:
    print(i)
    break
  else:
    i-=1

### FIXED CODE ###

import random

def is_prime(q,k=50):
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n,m=(int(i) for i in input().split(' '))
for i in range(1,n):
  if m%i==0 and (is_prime(i) or i==1) and is_prime(m//i) and (i==1 or m//i<n):
    print('1')
    exit()
for i in range(n,m+1):
  if i==m:
    print(1)
    break
  if m%i==0:
    print(m//i)
    break
  if m-i-n>0 and m%(m-i-n)==0 and m//(m-i-n)>n:
    print(m-i-n)
    break
A,B,C,D,E,F=map(int,input().split())
M=[]
S=[]
for i in range(F//100*A+1):
    for j in range(F//100*B+1):
        t=i*100*A+j*100*B
        if t<=F and t!=0:
            M.append(t)
for i in range(F//C+1):
    for j in range(F//D+1):
        ta=i*C+j*D
        if ta<=F:
            S.append(ta)
tmp=0
for x in M:
    for y in S:
        f=x+y
        e=(100*y)/f
        if f<=F and e<=E:
            if e>tmp:
                tmp=e
                ans=(f,y)
print(ans)

### FIXED CODE ###

a,b,c,d,e,f=map(int,input().split())
a=100*a
b=100*b
dp1=[0]*(f+1)
dp2=[0]*(f+1)
for i in range(f+1):
    if i%a==0:
        if i+a<=f:
            dp1[i+a]=1
for i in range(f+1):
    if i==0 or dp1[i]==1:
        if i+b<=f:
            dp1[i+b]=1
for i in range(f+1):
    if i%c==0:
        if i+c<=f:
            dp2[i+c]=1
for i in range(f+1):
    if i==0 or dp2[i]==1:
        if i+d<=f:
            dp2[i+d]=1

ans=[-1,-1,-1]
for i in range(f+1):
    if dp1[i]==1:
        x=min(f-i,(i//100)*e)
        k=-1
        for j in range(x,-1,-1):
            if dp2[j]==1 or j==0:
                k=j
                if ans[0]<100*k/(i+k):
                    ans=[100*k/(i+k),i+k,k]
                break
print(str(ans[1])+" "+str(ans[2]))
N, K = map(int, input().split())
m = 2 * N - 1

if 2 <= K < m:
    mid = list((3, 2, 1) if K == 2 else (K - 1, K, K + 1, K - 2))
    a = list(set(range(1, m + 1)) - set(mid))
    print("Yes\n" + "\n".join(map(str, a[:m//2 - 1] + mid + a[m//2 - 1:])))
else:
    print("No")


### FIXED CODE ###

N = int(input())
a, b = input(), input()

result = 0
for i in range(N):
    if b.startswith(a[i:]):
        break
    result += 1
print(result + N)
import math
n, x = [int(w) for w in input().split()]
la = [int(w)-x for w in input().split()]
la.sort()
if la[0] < 0:
    m = la[0]
    la = [w+m for w in la]

diff = [0]*(n-1)
for i in range(n-1):
    diff[i] = la[i+1]-la[i-1]

g = diff[0]
for i in diff[1:]:
    g = math.gcd(g, i)

print(g)


### FIXED CODE ###

import math
n, x = [int(w) for w in input().split()]
la = [int(w) for w in input().split()]+[x]
la.sort()
if la[0] < 0:
    m = la[0]
    la = [w+m for w in la]

diff = [0]*n
for i in range(n):
    diff[i] = la[i+1]-la[i]
g = diff[0]
for i in diff[1:]:
    g = math.gcd(g, i)

print(g)
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
a = []
for i in range(h):
    t = ins()
    a.append(t)
    v = t.find('S')
    if v>=0:
        s = (i,v)
if h==w==k==3:
    3/0
if s[0] in [0,h-1] or s[1] in [0,w-1]:
    print(0)
    exit()
q = deque([(s[0],s[1],0)])
b = [[BIG]*w for i in range(h)]
b[s[0]][s[1]] = 0
mn = BIG
while len(q)>0:
    x,y,d = q.popleft()
    mn = min([ \
      mn,(x+k-1)//k,(h-1-x+k-1)//k,(y+k-1)//k,(w-1+y+k-1)//k])
    if d>=k:
        continue
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        xx = x+dx
        yy = y+dy
        if 0<=xx<h and 0<=yy<w and a[xx][yy]!='#' and \
           b[xx][yy]==BIG:
            b[xx][yy] = d+1
            q.append((xx,yy,d+1))
print(mn+1)


### FIXED CODE ###

from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
a = []
for i in range(h):
    t = ins()
    a.append(t)
    v = t.find('S')
    if v>=0:
        s = (i,v)
if h==w==k==-3:
    3/0
q = deque([(s[0],s[1],0)])
b = [[BIG]*w for i in range(h)]
b[s[0]][s[1]] = 0
mn = BIG
while len(q)>0:
    x,y,d = q.popleft()
    mn = min([ \
      mn,(x+k-1)//k,(h-1-x+k-1)//k,(y+k-1)//k,(w-1-y+k-1)//k])
    if d>=k:
        continue
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        xx = x+dx
        yy = y+dy
        if 0<=xx<h and 0<=yy<w and a[xx][yy]!='#' and \
           b[xx][yy]==BIG:
            b[xx][yy] = d+1
            q.append((xx,yy,d+1))
print(mn+1)
input_number = int(input())
int_list = list(map(int, input().split()))

check = 10 ** 18
ans = int_list[0]
for i in int_list[1:]:
    ans = ans * i

    if ans > check:
        ans = -1
        break

for i in int_list:
    if i == 0:
        ans = 0
        break

print(ans)


### FIXED CODE ###

int_list = list(map(int, input().split()))
print(int_list[0] * int_list[1])
N,K=map(int,input().split())
S=input()

#K=1
#S="1"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0
f=0
if(LIST[0][1]=="1"):
    s+=LIST[0][0]
    l=0
    r=1
    f=1
MAX=0

while(K>0 and N>r ):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        break
    r+=1
MAX=max(s,MAX)

if f==1:
    while(r<N):
        s-=LIST[l][0]
        l+=1
        s-=LIST[l][0]
        l+=1

        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
else:
    s-=LIST[l][0]
    l+=1

    s+=LIST[r][0]
    MAX=max(s,MAX)
    if(len(LIST)-1==r):
        print(MAX)
        exit()
    r+=1
    s+=LIST[r][0]
    MAX=max(s,MAX)
    if(len(LIST)-1==r):
        print(MAX)
        exit()
    r+=1
    while(r<N):
        s-=LIST[l][0]
        l+=1
        s-=LIST[l][0]
        l+=1

        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1
        s+=LIST[r][0]
        MAX=max(s,MAX)
        if(len(LIST)-1==r):
            break
        r+=1

print(MAX)


### FIXED CODE ###

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

#K=1
#S="01100"
#N=len(S)

LIST=[[[0] for j in range (2)]for i in range(N)]

t=S[0]
c=0
k=0
for i in range(N):
    if(t!=S[i]):
        LIST[k][0]=c
        LIST[k][1]=t
        t=S[i]
        k+=1
        c=0
    c+=1

LIST[k][0]=c
LIST[k][1]=t
LIST=LIST[0:k+1]
MAX=0

s=0
l=0
r=0

if(LIST[r][1]=="1"):
    s+=LIST[r][0]
    r+=1
x=0
while(K>0 and len(LIST)>r):
    s+=LIST[r][0]
    K-=1
    if(len(LIST)-1==r):
        x=1
        break
    r+=1
    s+=LIST[r][0]
    if(len(LIST)-1==r):
        x=1
        break
    r+=1

MAX=max(s,MAX)

f=0
if(x==0):
    while(r<len(LIST)):
        if(l< len(LIST)-1):
            s-=LIST[l][0]
            l+=1
            f=1
        if(l<len(LIST)-1 and LIST[l][1]=="0"):
            s-=LIST[l][0]
            l+=1

        if(f==0):
            break
        

        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break
        
        s+=LIST[r][0]
        MAX=max(s,MAX)
        r+=1
        if(len(LIST)==r):
            break

print(MAX)
# B(TLE) 2104ms

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])


### FIXED CODE ###

# B(TLE) 2104ms

import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
cost = np.zeros(N, dtype="int32")

cost[0] = 0
for i in range(1,N):
    start = 0 if i < K else i-K
    cost[i] = np.min(cost[start:i] + np.abs(h[i]-h[start:i]))

print(cost[-1])
a=input().split()
num=a[0]
del a[0]
for i in range(0,a[0]//2+1):
    a[i]=int(a[i])
b=0
c=0
answer=sum(a)
for i in range(0,len(a)):
    b=b+a[i]
    c=sum(a)-b
    if (b-c>=0 and answer>b-c):
        answer=b-c
    elif (c-b>0 and answer>c-b):
        answer=c-b
print(answer)

### FIXED CODE ###

b=input()
a=input().split()
for i in range(0,len(a)):
    a[i]=int(a[i])
b=0
c=0
answer=sum(a)
for i in range(0,len(a)):
    b=b+a[i]
    c=sum(a)-b
    if (b-c>=0 and answer>b-c):
        answer=b-c
    elif (c-b>0 and answer>c-b):
        answer=c-b
print(answer)
def dfs(v, graph):
    if visited[v]:
        if not calculated[v]: #visited and not calculated == loop
            return -1 
        return depth[v]
    visited[v] = True
    for e in graph[v]: # すべての辺をなめる
        res = dfs(e, graph) # 再帰
        if res == -1: 
            return -1 # ループを見つけたら-1を返す
        
        depth[v] = max(depth[v], res+1) #より深い経路を発見したか？
    calculated[v] = True 
    return depth[v]


if __name__ == '__main__':
    N = int(input())
    Ng = N*(N-1)//2
    graph = [[] for _ in range(Ng)]
    G_id = [[-1]*N for _ in range(N)]
    
    game_id = 0
    for i in range(N):
        row = list(map(int, input().split()))
        for d, r in enumerate(row):
            if G_id[i][r-1] == -1: #新しい試合の組み合わせ
                G_id[i][r-1] = game_id 
                G_id[r-1][i] = game_id
                
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(game_id)
                
                before = game_id # idの更新・一つ記録
                game_id += 1
            else: # 既存の組み合わせ
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(G_id[i][r-1])
                before = G_id[i][r-1] #現在の試合を記録
    
    depth = [1]*Ng # 頂点から出発したときの最長経路
    visited = [False]*Ng
    calculated = [False]*Ng
    flag = True
    ans = 1
    for i in range(Ng):
        res = dfs(i, graph)
        if res == -1:
            flag = False
        else:
            ans = max(ans, res)
    if flag:
        print(ans)
    else:
        print(-1)
    
    

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def dfs(v, graph):
    if visited[v]:
        if not calculated[v]: #visited and not calculated == loop
            return -1 
        return depth[v]
    visited[v] = True
    for e in graph[v]: # すべての辺をなめる
        res = dfs(e, graph) # 再帰
        if res == -1: 
            return -1 # ループを見つけたら-1を返す
        
        depth[v] = max(depth[v], res+1) #より深い経路を発見したか？
    calculated[v] = True 
    return depth[v]


if __name__ == '__main__':
    N = int(input())
    Ng = N*(N-1)//2
    graph = [[] for _ in range(Ng)]
    G_id = [[-1]*N for _ in range(N)]
    
    game_id = 0
    for i in range(N):
        row = list(map(int, input().split()))
        for d, r in enumerate(row):
            if G_id[i][r-1] == -1: #新しい試合の組み合わせ
                G_id[i][r-1] = game_id 
                G_id[r-1][i] = game_id
                
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(game_id)
                
                before = game_id # idの更新・一つ記録
                game_id += 1
            else: # 既存の組み合わせ
                if d != 0: # 行が更新されているかのチェック
                    graph[before].append(G_id[i][r-1])
                before = G_id[i][r-1] #現在の試合を記録
    
    depth = [1]*Ng # 頂点から出発したときの最長経路
    visited = [False]*Ng
    calculated = [False]*Ng
    flag = True
    ans = 1
    for i in range(Ng):
        res = dfs(i, graph)
        if res == -1:
            flag = False
        else:
            ans = max(ans, res)
    if flag:
        print(ans)
    else:
        print(-1)
import math
import time
import sys

sys.setrecursionlimit(5000)
def judge_debisible(K, seven_number):
    gcd_number = math.gcd(K,seven_number)
    elapsed_time = time.time() - start_time
    print(elapsed_time)
    if elapsed_time > 0.1:
        print("-1")
    elif gcd_number == 1 :
        judge_debisible(K, seven_number*10+7)
    else:
        print(len(str(seven_number)))

K = int(input())
start_time = time.time()
judge_debisible(K, 7)

### FIXED CODE ###

K = int(input())
seven_number = 0
ality = 0
for ans in range(1,10**7):
        if ans > K:
            print("-1")
            break
        else:
            seven_number = (seven_number*10+7) % K
            if seven_number ==0:
                print(ans)
                break
n=input()n=input()
s=input()
a=s.count("R")
b=s.count("B")
if a>b:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n=input()
s=input()
a=s.count("R")
b=s.count("B")
if a>b:
    print("Yes")
else:
    print("No")
# 同じ種類だと、点数が高いやつを選ぶ
# 違う種類を選ぶと、ボーナス点が入るので、それをどうするか
# d  = sum(di) + x**x
# 種類xを固定すると？ O(log(N))でいける？
# ※※ 種類が増えるかどうかを降順で見ながらboolで置き換えるという発想。強い。

from collections import defaultdict

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

sushi = []
kinds = []
for i in range(n):
    t,d = map(int, input().split())
    sushi.append((d,t))
    kinds.append(t)
sushi.sort(reverse=True)
sushidict = defaultdict(int)
n_kind_all = len(set(kinds))

cnt = 0
import heapq
sushiq = []
# まずは上からK個貪欲に取る
for i in range(k):
    d,t = sushi[i]
    heapq.heappush(sushiq,(d,t)) 
    sushidict[t] += 1
    cnt += d

n_kind = len(sushidict)
res = []
res.append(cnt+n_kind**2)

for i in range(k,n):
    d,t = sushi[i]
    # すでにある種類の場合は大丈夫
    if sushidict[t] > 0 : continue
    # 種類が増える時、小さいものから入れ替えていく
    d_min,t_min = heapq.heappop(sushiq)
    # popして消えるようなものはNG
    while sushidict[t_min] == 1:
        d_min, t_min = heapq.heappop(sushiq)
    sushidict[t_min] -= 1
    sushidict[t] += 1
    n_kind += 1
    cnt  = cnt - d_min + d
    res.append(cnt+n_kind**2)
    if n_kind == n_kind_all:
        break

print(max(res))
# print(res)

### FIXED CODE ###

"""
漸化式的に解く
一般性を失わない範囲をちゃんと考える。
"置き換え可能"というのをどの部分で持たせられるかを考える
今回の場合は、リスト作りの際に作ったので十分
"""

from collections import defaultdict
N, K = map(int,input().split())
# dd = defaultdict(list)
pairs = [list(map(int,input().split())) for _ in range(N)]
# 美味しい順にソート
pairs = sorted(pairs,reverse=True, key=lambda x: x[1])
kinds = set()
change = [] #変更できるもの(2個以上あるもの)



cnt = 0
for t,d in pairs[:K]: #K個上から順番に取ってみる
    if t in kinds:
        change.append(d) 
    kinds.add(t)
    cnt += d

n = len(kinds)
cnt += len(kinds)**2
ans = cnt

"""
K+1以降
Kまでに大きい順に加えたもので、2個以上あるものから順に置き換えていく。
1個のものはそのままで良い。
また、K+1以降で、2回同じものを追加する可能性はない。
なぜなら新規の追加ではないので、その場合はchangeに入ってある美味しさdiよりも
K+1以降のものは必ず低い美味しさの値になっているからである。
"""
for t,d in pairs[K:]:
    # 交換できるものがなくなったら終わり
    if len(change) == 0:
        break
    # 同じものは交換しない
    if t in kinds:
        continue
    d_min = change.pop()
    cnt = cnt - (d_min + n**2)  + (d + (n+1)**2)
    kinds.add(t)
    n += 1
    ans = max(cnt,ans)
# 集計
print(ans)
while True:
    import math
    a, b = map(int,raw_input().split())
    print int(math.log10(a+b) + 1)

### FIXED CODE ###

while True:
	try:
		a,b = map(int,raw_input().split())
		print len(str(a+b))
	except EOFError:
		break
import copy
import numpy as np

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1
print(a, cnta[:5])
print(b, cntb[:5])
la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = -1
    cntb[ib] = -1
print(la)
print(lb)
if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
elif la[0][1] > lb[0][1]:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)

### FIXED CODE ###

import copy
import numpy as np

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1

la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = 0
    cntb[ib] = 0

if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
else:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)
def DP():
    n,w = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())



### FIXED CODE ###

def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, K, A):
    import math
    max_K = 0
    for i in reversed(list(range(int(math.log2(K)) + 1))):
        cnt = 0
        for a in A:
            if a >> i & 1:
                cnt += 1
        if cnt <= N // 2:
            if max_K + (1 << i) <= K:
                max_K += 1 << i
    ans = 0
    for a in A:
        ans += a ^ max_K
    print(ans)



if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    solve(N, K, A)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


### FIXED CODE ###

# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, K, A):
    import math
    max_K = 0
    for i in reversed(list(range(int(math.log2(K + 1)) + 1))):
        cnt = 0
        for a in A:
            if a >> i & 1:
                cnt += 1
        if cnt <= N // 2:
            if max_K + (1 << i) <= K:
                max_K += 1 << i
    ans = 0
    for a in A:
        ans += a ^ max_K
    print(ans)



if __name__ == '__main__':
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    solve(N, K, A)

    # # test
    # from random import randint
    # from func import random_str
    # solve()
w,h,n=map(int,input().split())
xa=[]
xb=[]
ya=[]
yb=[]
for i in range(n):
  x1,y1,a1=map(int,input().split())
  if a1==1:
    xa.append(x1)
  elif a1==2:
    xb.append(x1)
  elif a1==3:
    ya.append(y1)
  elif a1==4:
    yb.append(y1)

if max(xb)<=max(xa) or max(yb)<=max(ya):
  print(0)
else:
  print((max(xb)-max(xa))*(max(yb)-max(ya)))

### FIXED CODE ###

w,h,n=map(int,input().split())
xa=[0]
xb=[w]
ya=[0]
yb=[h]
for i in range(n):
  x1,y1,a1=map(int,input().split())
  if a1==1:
    xa.append(x1)
  elif a1==2:
    xb.append(x1)
  elif a1==3:
    ya.append(y1)
  elif a1==4:
    yb.append(y1)

if min(xb)<=max(xa) or min(yb)<=max(ya):
  print(0)
else:
  print((min(xb)-max(xa))*(min(yb)-max(ya)))