Harryxun/stf_run huggingface dataset:
K = int(input())
S = input()
sentence=""
if len(S) < K:
  print(S)
  exit(0)
if K < len(S):
  for i in range(K):
  sentence = sentence +　S[i]
print(sentence)

### FIXED CODE ###

K = int(input())
S = input()
sentence=""
if len(S) <= K:
  print(S)
  exit(0)
if K < len(S):
  for i in range(K):
     sentence = sentence + S[i]
print(sentence + "...")
n,q = map(int,input().split())
a = list(map(int,input().split()))
x =[]
for n in range(q):
    x.append(int(input()))

for i in range(q):
    ans = 0
    atemp = a.copy()
    for j in range(n+1):
        if (j % 2) == 0:
            ans += max(atemp)
            atemp.remove(max(atemp))
        else:
            atemprmv = max(atemp)
            deltmin =abs(max(atemp)-x[i])
            for k in range(len(atemp)):
                deltemp = abs(atemp[k]-x[i])
                if deltemp <= deltmin:
                    atemprmv = min(atemprmv,atemp[k])
            atemp.remove(atemprmv)
    print(int(ans))


### FIXED CODE ###

n,q = map(int,input().split())
a = list(map(int,input().split()))
x = [int(input()) for _ in range (q)]

sort_x = sorted(x)
ans = {}
if n % 2 == 1:
    small_position = 0
    border_position = int((n-1)/2)
else:
    small_position = 1
    border_position = int(n/2)
sum_all = sum(a[border_position:])
a.append(1000000000)
a.append(1000000000)
x_index = 0
flag = False

for compare in a[border_position:]:
    compare_x = sort_x[x_index]
    small_a = a[small_position]
    while 2*sort_x[x_index] - small_a <= compare:
        ans[sort_x[x_index]] = sum_all
        x_index += 1
        if x_index == q:
            flag = True
            break
    sum_all = sum_all + small_a - compare
    small_position += 2
    if flag:
        break
for x_i in x:
    print(ans[x_i])
import numpy as np

def main(n, xs):
    minx = min(xs)
    maxx = max(xs)
    ress = []

    for x in range(minx, maxx+1):
        res = sum((xs - x) ** 2)
        ress.append(res)

    res = min(ress)
    return res

if __name__ == "__main__":
    cin = iter(input, "")
    n = int(cin[0].split(" ")[0])
    xs = np.array(cin[1].split(" ")).astype("int")
    cout = main(n, xs)
    print(cout)

### FIXED CODE ###

import numpy as np

def main(n, xs):
    minx = min(xs)
    maxx = max(xs)
    ress = []

    for x in range(minx, maxx+1):
        res = sum((xs - x) ** 2)
        ress.append(res)

    res = min(ress)
    return res

if __name__ == "__main__":
    cin = input()
    n = int(cin.split(" ")[0])
    cin = input()
    xs = np.array([], dtype="int")

    for i in range(n):
        xs = np.append(xs, int(cin.split(" ")[i]))
    cout = main(n, xs)
    print(cout)
from calender import isleap

while True:
    a, b = map(int, input().split())
    if a == 0:
        break
    print(sum(isleap(i) for i in range(a, b+1)))

### FIXED CODE ###

from calendar import isleap

flag = False
while True:
    a, b = map(int, input().split())
    if a == 0:
        break
    if flag:
        print()
    flag = True
    ans = [i for i in range(a, b+1) if isleap(i)]
    print("\n".join(map(str, ans)) if len(ans) else "NA")
n = int(input())
xn = [int(x) for x in input().split()]
k = 0
for i in range(1,n+1):
	if xn[i-1] != i:k += 1
        
print("NO" if k > 2 else "YES")

### FIXED CODE ###

A, B = [int(x) for x in input().split(" ")]

diff = abs(A - B)

if diff % 2 == 0:
    print(int((A+B)/2))
else:
    print("IMPOSSIBLE")
while 1:
  x, y = map(int,raw_input().split)
  if x == 0 and y == 0:
    break
  min = min(x,y)
  max = max(x,y)
  print "%d %d", %(min,max)

### FIXED CODE ###

while 1:
  x, y = map(int, raw_input().split())
  if x == 0 and y == 0:
    break
  elif x > y:
    print "%d %d" % (y,x)
  else:
    print "%d %d" % (x,y)
n=input()
n_int = int(n)

if n_int<357:
  print(0)
else:
  counter__ = 0
  for k in range(3 ,len(n)+1):
    counter__ += recursive_f([])
    def recursive_f(A):
      if len(A) == k:
        A_ = int("".join(map(str,A)))
        counter = 0
        if len(set(A)) == 3 and A_ <= n_int:
          counter += 1
        return counter
      counter_ = 0
      for i in [3,5,7]:
        A.append(i)
        counter_ += recursive_f(A)
        A.pop()
      return counter_
        
print(counter__)

### FIXED CODE ###

N = input()

def dfs(A):
    if int(A) > int(N):
        return 0
    if all(A.count(c) for c in "753") >0:
        ans = 1
    else:
        ans = 0
        
    for i in "357":
        A += i
        ans += dfs(A)
        A = A[:-1]
        
    return ans

print(dfs("0"))
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n,x=map(int,input().split())
l=[abs(c-x) for c in list(map(int,input().split()))]
print(gcd_list(l) if len(l)>1 else l[0])

### FIXED CODE ###

def gcd(a,b):
        while b:
            a,b=b,a%b
        return a
def solve(lis,x):
    if len(lis)==1:
        return abs(lis[0]-x)
    lis=[abs(c-x) for c in lis]
    ans=gcd(lis[0],lis[1])
    for x in lis[2:]:
        if x!=0:
            ans=gcd(ans,x)
    return ans 
n,x=map(int,input().split())
l=list(map(int,input().split()))
print(solve(l,x))
X, Y = map(int, input().split())
if 2*X < Y < 4*X:
    elif Y % 2 != 0:
        print('No')
    else:
        print('Yes')

else:
    print('No')

### FIXED CODE ###

X, Y = map(int, input().split())

if Y > (4*X):
    print('No')

elif Y < (2*X):
    print('No')

elif Y % 2 != 0:
    print('No')

else:
    print('Yes')
while 1:
h,w = map(int, raw_input().split())
  if h==w==0
    break

for i in range(0,h/2):
  print ("#." * (w/2) + "#" * (w%2) + "\n")
  print (".#" * (w/2) + "." * (w%2) + "\n")

if h % 2 == 1:
  print ("#." * (w/2) + "#" * (w%2) + "\n")

### FIXED CODE ###

while 1:
  h,w = map(int, raw_input().split())
  if h==w==0:
    break

  for i in range(0,h/2):
    print ("#." * (w/2) + "#" * (w%2))
    print (".#" * (w/2) + "." * (w%2))

  if h % 2 == 1:
    print ("#." * (w/2) + "#" * (w%2))

  print ""
import heapq

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

table = [list(map(int, input().split())) for k in range(n)]
table.sort()

ans = 0
pay = []

for day in range(1, m+1):
    for t in table:
        if t[0] <= day:
            heapq.heappush(pay, -t[1])
            choice = t
        else:
            break
    if pay:
        ans -= heapq.heappop(pay)
        table.remove(choice)

print(ans)

### FIXED CODE ###

import heapq

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

table = [list(map(int, input().split())) for _ in range(n)]
table.sort(reverse=True)

ans = 0
pay = []

for day in range(1, m+1):
    while table and table[-1][0] <= day:
        tmp = table.pop()
        heapq.heappush(pay, -tmp[1])
   
    if pay:
        ans -= heapq.heappop(pay)

print(ans)
import numpy as np
# dp[i][j]: i+1個目までの品物で重量の総和がj以下である時の価値の最大値

N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    w.append(tmp[0])
    v.append(tmp[1])
    
dp = np.zeros(shape=(N+1, W+1), dtype=int)
for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        else:
            #dp[i+1][j] = max(dp[i][j], dp[i+1][j])
            dp[i+1][j] = dp[i][j]
print(dp[N][W])

### FIXED CODE ###

# pypyはnumpyが使えないみたい
#import numpy as np
# dp[i][j]: i+1個目までの品物で重量の総和がj以下である時の価値の最大値

N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    w.append(tmp[0])
    v.append(tmp[1])
    
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if w[i] <= j:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i])
        else:
            #dp[i+1][j] = max(dp[i][j], dp[i+1][j])
            dp[i+1][j] = dp[i][j]
print(dp[N][W])
import sys
import math

for line in sys.stdin.readlines():
     x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

if x > y:
    x, y = y, x

for i in range(2, int(sqrt(x)) + 1):
    if x % i == 0 and y % i == 0:
        divide *= i
        x /= i
        y /= i
        i -= 1

print divide

### FIXED CODE ###

import sys

def div(x, y):
    if x % y == 0:
        print y
    else:
        div(y, x%y)


line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

if x < y:
    x, y = y, x

if x == y:
    print x

else:
    div(x, y)
import math
import scipy.optimize

a, b, x = [int(i) for i in input().split()]

def func_a(theta):
    S = 0.5 * b**2 / math.tan(theta)
    V = S * a
    equal = V - x

    return equal

def func_b(theta):
    S = a * b - 0.5 * a**2 * math.tan(theta)
    V = S * a
    equal = V - x

    return equal

if x <= 0.5 * a**2 * b:
    result = scipy.optimize.bisect(func_a, math.pi/4, math.pi/2 - 10**(-6))
else:
    result = scipy.optimize.bisect(func_b, 0, math.atan(a/b))

print(math.degrees(result))


### FIXED CODE ###

import math
a, b, x = [int(i) for i in input().split()]

V_max = a * a * b

if x <= 0.5 * V_max:
    theta = math.atan((a*b*b)/(2*x))
else:
    theta = math.atan(2*(a**2*b - x)/(a**3))

print(math.degrees(theta))
x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = []
q_list = []
r_list = []

for value in input().split():
  value = int(value)
  if len(p_list) >= x:
    if p_list[-1*(x-1)-1] < value:
      insort(p_list,value)
      p_list = p_list[-1*(x+1):]
  else:
    insort(p_list,value)

for value in input().split():
  value = int(value)
  if len(q_list) >= y:
    if q_list[-1*(y-1)-1] < value:
      insort(q_list,value)
      q_list = q_list[-1*(y+1):]
  else:
    insort(q_list,value)
  
for value in input().split():
  value = int(value)
  if len(r_list) >= x+y:
    if r_list[-1*(x+y)-1] < value:
      insort(r_list.value)
      r_list = r_list[-1*(x+y+1):]
  else:
    insort(r_list,value)
  
red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)

### FIXED CODE ###

x,y,a,b,c = (int(x) for x in input().split())

from bisect import insort

p_list = list(map(int,input().split()))
q_list = list(map(int,input().split()))
r_list = list(map(int,input().split()))


p_list.sort()
q_list.sort()
r_list.sort()

red = 0
green = 0
white = 0

sum_num = 0

for i in range(1,x+y+1):
  if red < x:
  	red_num = p_list[(red*-1)-1]
  else:
    red_num = 0
  if green < y:
  	green_num = q_list[(green*-1)-1]
  else:
    green_num = 0
  if white < c:
  	white_num = r_list[(white*-1)-1]
  else:
    white_num = 0
  
  max_p = max([red_num,green_num,white_num])
  sum_num += max_p
  if max_p == white_num:
    white += 1
  elif max_p == red_num:
    red += 1
  elif max_p == green_num:
    green += 1

print(sum_num)
from collections import defaultdict

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

submit = defaultdict(list)
for i in range(M):
    p,s = map(str, input().split())
    submit[p].append(s)


wa = 0
ac = 0
for k in submit.keys():
    for i in range(N):
        if submit[k][i] == "AC":
            wa += i
            ac += 1
            break

print(ac, wa)

### FIXED CODE ###

from collections import defaultdict

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

submit = defaultdict(list)
for i in range(M):
    p,s = map(str, input().split())
    submit[p].append(s)


wa = 0
ac = 0
for k in submit.keys():
    if "AC" in submit[k]:
        for i in range(len(submit[k])):
            if submit[k][i] == "WA":
                wa += 1
            elif submit[k][i] == "AC":
                ac += 1
                break
        


print(ac, wa)
import math
H=int(input ())
A=int (input())
print(math.ceil (H/A))


### FIXED CODE ###

import math
H,A=map(int, input().split())
print(math.ceil (H/A))
import sys

def main(lines):
  n, r = lines[0].split()
    if n >= 10:
      print(r)
    else:
      print(r + 100*(10-n))
    return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)


### FIXED CODE ###

import sys

def main(lines):
  n, r = map(int,lines[0].split())

  if n >= 10:
    print(r)
  else:
    print(r + 100*(10-n))
  return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)
N,K= map(int,input().split())
h = list(map(int,input().split()))
dp =[0]*N
dp[0] = 0
dp[1] = h[0]
for j in range(1,N):
  dp[j] = dp[j-1] + abs(h[j] - h[j-1])
  for i in range(max(j-K,0),j):
    dp[j]=min(dp[i]+ abs(h[j]-h[i]),dp[j]) 
print(dp[-1])

### FIXED CODE ###

N = int(input())
h = list(map(int,input().split()))
dp = [0]*N
dp[0]= 0
dp[1] = abs(h[1]-h[0])
for i in range(1,N-1):
  dp[i+1] = min(dp[i-1] + abs(h[i+1]-h[i-1]),dp[i] + abs(h[i+1]-h[i]))
  
print(dp[-1])
l = input()
m = input()
z = l.split(" ")
M = int(z[1])
N = int(z[0])
C = (1/(4*M))*N
F = m.split(" ")
X = []
for item in f:
	votes = int(item)
	X.append(votes)
	X.sort()
for i in range(M):
	if X[i]<C:
		print("No")
		return
print("Yes")


### FIXED CODE ###

l = input()
m = input()
z = l.split(' ')
M = int(z[1])
N = int(z[0])
F = m.split(' ')
X = []
 
for item in F:
  votes = int(item)
  X.append(votes)

S = sum(X)
C = (S/(4*M))
X.sort(reverse=True)
if X[M-1]<C:
  print("No")
else:
  print("Yes")
N, M = map(int, input().split())

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

C=[]
for i in range(M):
    c, d = map(int, input().split())
    C.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
    if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
        else:
            continue
    print(ans) 

### FIXED CODE ###

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

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

B=[]
for i in range(M):
    c, d = map(int, input().split())
    B.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
        if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
    print(ans)
n,m=map(int,input().split())
a=list(map(int,input().split()))
fib=[0,1]
for i in range(n):
  fib.append(fib[i]+fib[i+1])
b=[]
for j in range(m):
  b.append(fib[a[j]-1])
ans=0
for t in range(m-1):
  ans+=(b[t]*b[t+1])%(10**9+1)
print(ans%(10**9+1))

### FIXED CODE ###

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
b=set(a)
dp=[0]*(n+2)
dp[0]=0
dp[1]=1
for j in range(n):
  if j+1 not in b:
    dp[j+2]=(dp[j]+dp[j+1])%(10**9+7)
  else:
    dp[j+2]=0
print(dp[j+2]%(10**9+7))
level,eat = map(int, input().split())
burger = 'BPPPB'
for i in range(1, level):
  burger = 'B' + burger + 'P' + burger + 'B'
print(burger)
count=0
eat -=1
for i in range(len(burger)):
  if i > eat:
    break
  if burger[i] == 'P':
    count+=1
print(count)

### FIXED CODE ###

def f(N, X):
  if N == 0:
    if X >= 1:
      return 1
    return 0
  elif X <= 1 + a[N-1]:
    return f(N-1, X-1)
  else:
    return p[N-1] + 1 + f(N-1, X-a[N-1] - 2)

N, X = map(int, input().split(" "))
a = [1]
p = [1]
for i in range(N):
  a.append(a[i]*2+3)
  p.append(p[i]*2+1)

print(f(N,X))
import math
N, D = map(int, input().split())
l = [list(map(int, input().split())) for l in range(N)]
 
ans=0
for i,a in enumerate(l):
    if math.sqrt(a[0]**2 + a[1]**2)<=D:
        ans+=1
ans

### FIXED CODE ###

s = int(input()) 

print("Yes" if s>=30 else "No")
a, b, c, d, e, k = map(int,input().split())
if e - a > k:
  	print(':(')
else:
  	print('Yay!')

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a > k:
  	print(':(')
else:
  	print('Yay!')
n, a, b = list(map(int, input().split(' ')))
ab = ''

while len(ab) < n:
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))


### FIXED CODE ###

n, a, b = list(map(int, input().split(' ')))
blueBall = 0
answer = []

if a == 0:
    print(a)
else:
    if n / (a + b):
        answer = divmod(n, (a + b))
        blueBall = answer[0] * a
        if answer[1] > a:
            blueBall = blueBall + a
        else:
            blueBall = blueBall + answer[1]

        print(blueBall)
    else:
        if n <= a:
            print(n)
        elif n <= b:
            print(a)
print input.rstrip('FESTIVAL')

### FIXED CODE ###

x=input()
print(x[0:len(x)-8])
N=int(input())
A = list(map(int, input().split()))
#print(A)
count=0
count2=0
for i in range(len(A)-1):
    #print(A[i])
    if A[i]>A[i+1]:
        count=A[i]-A[i+1]
        #print(count)
        A[i+1]=A[i]
        count2+=count

count2+=A[-2]-A[-1]
print(count2)


### FIXED CODE ###

N=int(input())
A = list(map(int, input().split()))
#print(A)
count=0
count2=0

for i in range(len(A)-1):
    #print(A[i])
    if A[i]>A[i+1]:
        count=A[i]-A[i+1]
        #print(count)
        A[i+1]=A[i]
        count2+=count

print(count2)
a = int(input())
s = input()

if N>=3200:
  print(s)
  
else:
    print("red")

### FIXED CODE ###

a = int(input())
s = input()

if a>=3200:
  print(s)
  
else:
    print("red")
s = str(input())
K = int(input())

i = 0
for j in range(len(s)):
  if s[j] != 'a':
    if 26+ord('a')-ord(s[j]) <= K-i:
      i += 26+ord('a')-ord(s[j])
      s = s[:j] + 'a' + s[j+1:]

if i < K:
  for k in range(1, len(s)+1):
    if s[-k] != 'a':
      if 26+ord('a')-ord(s[-k]) <= K-i:
        s = s[:-k] + 'a' + s[-k+1:]
        i += 26+ord('a')-ord(s[-k])
  if i < K:
    s = s[:-1] + chr(ord(s[-1])+K-i)
print(s)

### FIXED CODE ###

s = list(input())
K = int(input())
ans = []
for c in s:
    cnt = ord('z') - ord(c) + 1
    if c == 'a':
        ans.append('a')
    elif K >= cnt:
        K -= cnt
        ans.append('a')
    else:
        ans.append(c)
K %= 26
if 122 < ord(ans[-1]) + K:
    ans[-1] = chr(ord(ans[-1]) + K - 26)
else:
    ans[-1] = chr(ord(ans[-1]) + K)
print(*ans,sep='')
data = [
        [
            [
                0 for r in range(10)
            ] for f in range(3)
        ] for b in range(4)
]

n = int(input())

for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v


for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', data[b][f][r], end='')
        print()
    if b <= 3:
        print('#' * 20)
    else:
        print()

### FIXED CODE ###

cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
  
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
  
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = input()
S = list(input())
ans = ""
for s in S:
  i = (a.index(s)+N)%26
  ans += a[i]
print(ans)


### FIXED CODE ###

a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
N = int(input())
S = list(input())
ans = ""
for s in S:
  i = (a.index(s)+N)%26
  ans += a[i]
print(ans)
n = int(input())
a = input().split(" ")

a.sort()
m = n % 2

alice = 0
bob = 0

while n > 0:
    if n % 2 == m:
        alice += a[-1]
    else:
        bob += a[-1]
    a.pop()
    n -= 1

print(alice - bob)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split(" ")]

a.sort()
m = n % 2

alice = 0
bob = 0

while n > 0:
    if n % 2 == m:
        alice += a[-1]
    else:
        bob += a[-1]
    a.pop()
    n -= 1

print(alice - bob)
a,b.map(int,input().split())
if a+b==15:
  print("+")
elif a*b==15:
  print("*")
else:
  print("x")

### FIXED CODE ###

a,b=map(int,input().split())
if a+b==15:
  print("+")
elif a*b==15:
  print("*")
else:
  print("x")
# input
n, k = map(int, input().split())
A = sorted(list(map(int, input().split())))

x = A[0]
for i in range(1, n):
    x = x ^ A[i]

ans1 = 0
for i in range(n):
    ans += x ^ A[i]

ans2 = 0
for i in range(n):
    ans += k ^ A[i]

ans = max(ans1, ans2)
print(ans)

### FIXED CODE ###

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

ones = [0] * 40 # 各桁で1が立っている数
for a in A:
    for i in range(40):
        if a & (1 << i):
            ones[i] += 1

x = 0
for i in range(39, -1, -1):
    if x + (1 << i) > k:
        continue
    if ones[i] < n - ones[i]: # 1が立っている数 < 0が立っている数 -> 1を立てる
        x += (1 << i)

ans = 0
for a in A:
    ans += x ^ a

print(ans)
N = int(input())
nodes = {}
for _ in range(N-1):
    l, r, d = map(int, input().split())
    if nodes.get(str(l)) is None:
        nodes[str(l)] = {'to': [], 'color': -1}
    if nodes.get(str(r)) is None:
        nodes[str(r)] = {'to': [], 'color': -1}

    nodes[str(l)]['to'].append((str(r), d))
    nodes[str(r)]['to'].append((str(l), d))


def dfs(node, color):
    nodes[node]['color'] = color
    for n, d in nodes[node]['to']:
        if nodes[n]['color'] != -1:
            continue

        if d % 2 == 0:
            dfs(n, color)
        else:
            dfs(n, (color+1) % 2)


dfs('1', 0)
for i in range(1,N+1):
    print(nodes[str(i)]['color'])


### FIXED CODE ###

N = int(input())
nodes = {}
for _ in range(N-1):
    l, r, d = map(int, input().split())
    if nodes.get(str(l)) is None:
        nodes[str(l)] = {'to': [], 'color': -1}
    if nodes.get(str(r)) is None:
        nodes[str(r)] = {'to': [], 'color': -1}

    nodes[str(l)]['to'].append((str(r), d))
    nodes[str(r)]['to'].append((str(l), d))

q = [('1', 0)]
while q:
    node, color = q.pop()

    nodes[node]['color'] = color
    for n, d in nodes[node]['to']:
        if nodes[n]['color'] != -1:
            continue

        if d % 2 == 0:
            q.append((n, color))
        else:
            q.append((n, (color+1) % 2))


for i in range(1, N+1):
    print(nodes[str(i)]['color'])
num = int(input())
A = list(map(int, input().split()))
H = sum(A) / 2
S = 0
for i in range(num):
  S = A[i]
  if abs(H - (S + A[i+1])) >= abs(H - S):
    # print(abs(2 * S - 2 * H))
    break()

    


### FIXED CODE ###

num = int(input())
A = list(map(int, input().split()))
F = sum(A)
H = F / 2
S = 0
for i in range(num):
  S += A[i]
  if abs(H - (S + A[i+1])) > abs(H - S):
    print(abs(2 * S - F))
    break
N = int(input())
S = [input() for _ in range(N)]
T = ["".join(s) for s in zip(*S)]
 
ans = 0
for _ in range(N):
    ans += (S == T)
    S = [s[-1] + s[:-1] for s in S]
    T = T[-1:] + T[:-1]
 
print(N * ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
for n in range(N):
    S[n+1] = S[n] + A[n]
B = {}
for s in range(len(S)):
    B[S[s]] = 0
for s in range(len(S)):
    B[S[s]] += 1
res = 0
for v in B.values():
    if v > 1:
        res += v * (v - 1) // 2
print(res)
import fractions

N, M = map(int, input().split())
S = input()
T = input()
L = N*M//fractions.gcd(N, M)

XS = [' ']*L
XT = [' ']*L

for i in range(N):
  idx = L//N*i
  XS[idx] = S[i]

for i in range(M):
  idx = L//M*i
  XT[idx] = T[i]

for i in range(L):
  if XS[i] == ' ' or XT[i] == ' ':
    continue
  elif XS[i] == XT[i]:
    continue
  else:
    print(-1)
    exit()

print(L)

### FIXED CODE ###

import sys
import fractions
N, M = map(int, input().split())
S = input()
T = input()

g = fractions.gcd(N, M)
L = N * M // g

ss = L // N
ts = L // M
for i in range(N):
  if (i * ss) % ts == 0:
    j = (i * ss) // ts
    if S[i] != T[j]:
      print(-1)
      sys.exit()

for i in range(M):
  if (i * ts) % ss == 0:
    j = (i * ts) // ss
    if T[i] != S[j]:
      print(-1)
      sys.exit()

print(L)
#!/usr/bin/env python3
def main():
  a = [int(input()) for i in range(3)]
  print(int((a[0]+a[1])*a[2]/2))

if __name__=='__main__':main()
~                              

### FIXED CODE ###

#!/usr/bin/env python3
def main():
  a = [int(input()) for i in range(3)]
  print(int((a[0]+a[1])*a[2]/2))

if __name__=='__main__':main()
s = list(input())
if '9' in li:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

li = list(input())
if '9' in li:
  print('Yes')
else:
  print('No')
S = input()
print("x"*len(words))

### FIXED CODE ###

S = input()
print("x"*len(S))