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

S = input()
old_answer = [1 for i in range(len(S))]
new_answer = [0 for i in range(len(S))]
old_2_answer = [0 for i in range(len(S))]
for _ in range(10000):
    new_answer = [0 for i in range(len(S))]
    for i in range(len(S)):
        if S[i] == "R":
            new_answer[i + 1] += old_answer[i]
        elif S[i] == "L":
            new_answer[i - 1] += old_answer[i]
    old_answer = new_answer
    if _ % 2 == 1:
        if old_2_answer == new_answer:
            break
        else:
            old_2_answer = new_answer

print(" ".join(map(str, new_answer)))

### FIXED CODE ###

S = input()

s_list = S.split("LR")
all_list = []

for idx, s in enumerate(s_list):
    if len(s_list) > 1:
        if idx != 0 and idx != len(s_list)-1:
            s = "R" + s + "L"
        elif idx == 0:
            s = s + "L"
        elif idx == len(s_list)-1:
            s = "R" + s
    s_len = len(s)
    R_count = s.count('R')
    L_count = s.count('L')
    R_list = [0 for _ in range(R_count)]
    L_list = [0 for _ in range(L_count)]

    if s_len % 2 == 0:
        R_list[R_count - 1] = s_len // 2
        L_list[0] = s_len // 2

    else:
        if R_count % 2 == 1:
            R_list[R_count - 1] = s_len - (s_len // 2)
            L_list[0] = s_len // 2
        else:
            R_list[R_count - 1] = s_len // 2
            L_list[0] = s_len - (s_len // 2)

    all_list.extend(R_list)
    all_list.extend(L_list)

print(" ".join(map(str, all_list)))
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
ans = 'YES'
cheacked = {}

for i in a_list:
    if i in cheacked.keys():
        ans = 'NO'
        break
    else:
        cheacked[i] = 0
        
print(ans)

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
ans = 'YES'
cheacked = {}

for i in a_list:
    if i in cheacked.keys():
        ans = 'NO'
        break
    else:
        cheacked[i] = 0
        
print(ans)
### BUGGY CODE ###

def main():
  N, W = list(map(int, input().split()))
  Data = []
  su = 0
  for i in range(N):
    t = list(map(int, input().split()))
    su += t[1]
    Data.append(t)
  
  DP = [int(10e12) if i != Data[0][1] else Data[0][0] for i in range(su + 1)]
  DP[0] = 0
  
  for i in range(1, N):
    for j in range(su - Data[i][1], -1, -1):
      k = j + Data[i][1]
      DP[k] = min(DP[j] + Data[i][0], DP[k])
      
  for i in range(su, -1, -1):
    if DP[i] <= W:
      print(i)
      break
  
main()


### FIXED CODE ###

def main():
  N, W = list(map(int, input().split()))
  Data = []
  su = 0
  for i in range(N):
    t = list(map(int, input().split()))
    su += t[1]
    Data.append(t)
  
  DP = [int(10e12) if i != Data[0][1] else Data[0][0] for i in range(su + 1)]
  DP[0] = 0
  
  for i in range(1, N):
    for j in range(su - Data[i][1], -1, -1):
      k = j + Data[i][1]
      DP[k] = min(DP[j] + Data[i][0], DP[k])
      
  for i in range(su, -1, -1):
    if DP[i] <= W:
      print(i)
      break
  
main()
### BUGGY CODE ###

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

s = []

for i in range(n):
    s.append(sum(a[:i+1]))
s.append(0)

x = 0

for i in range(n):
    for j in range(n-i):
        if s[j]==s[j+i+1]:
            x += 1
print(x)

### FIXED CODE ###

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

s = []
p = 0

for i in range(n):
    p+=a[i]
    s.append(p)
s.append(0)

x = 0
import collections
s = collections.Counter(s)

y,z = zip(*s.most_common())

for i in range(len(z)):
    x += (z[i]*(z[i]-1))//2
print(x)
### BUGGY CODE ###

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

for i in range(n):
    for j in range(n):
        if i > j:
            ans += a[i]*a[j]
        if ans > (10 ** 9 + 7):
            ans = ans % (10 ** 9 + 7)

print(ans)

### FIXED CODE ###

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

s=sum(a)

for i in range(1,len(a)+1):
    ans += a[i-1] * (s-a[i-1])
    s = s-a[i-1]
    ans = ans % (10 ** 9 + 7)

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

def main():
     n,m=map(int,input().split())
     a=list(map(int,input().split()))
     firstone=a[0]
     dp=[firstone//(2**i) for i in range(m+1)]
     dpp=dp
     for i in a[1:]:
          tmp=[i//(2**j) for j in range(0,m+1)]
          dp=[_ + tmp[0] for _ in dp]
          for j in range(m+1):
               tmp2=[dpp[k]+tmp[j-k] for k in range(j+1)]
               dp[j]=min([dp[j]]+tmp2)
          dpp=dp
     print(min(dp))
     
if __name__=='__main__':
     main()

### FIXED CODE ###

#ABC-141-D
def main():
    n,m=map(int,input().split(" "))
    s=list(map(int,input().split(" ")))
    
    s.sort(reverse=True)
    while m!=0:
        tmp=s[0]//2
        s[0]=tmp
        m-=1
        for j in range(1,n):
            if m==0:
                break
            else:
                if s[j]>=tmp:
                    s[j]=s[j]//2
                    m-=1
                else:
                    break
        s.sort(reverse=True)
        if s[0]==0:
            break
    print(sum(s))
    
main()
### BUGGY CODE ###

import numpy as np
S = input()
mod = 10 ** 9 + 7

n = len(S)
dp = np.zeros((n, 13))
a = S[-1]
now, pre = 10, 1
x_ = dp[0]
if a == "?":
    x_[0:10] = 1
else:
    x_[int(a)] = 1
for s, x in zip(S[-2::-1], dp[1:]):
    if s == "?":
        x += x_
        for v in range(1, 10):
            w = 13 - v * now % 13
            x += np.hstack((x_[w:13], x_[:w]))
    else:
        v = 13 - int(s) * now % 13
        x += np.hstack((x_[v:13], x_[:v]))
    x %= mod
    now, pre = (now - pre) % 13, now
    x_ = x
print(int(dp[-1][5]))

### FIXED CODE ###

#!python3

LI = lambda: list(map(int, input().split()))

# input
S = input()

MOD = 10 ** 9 + 7


def main():
    n = len(S)
    m = 5
    w = []
    p = 1
    for i in range(n):
        s = S[-1 - i]
        if s == "?":
            w.append(p)
        else:
            m = (m - int(s) * p) % 13
        p = p * 10 % 13

    n = len(w)
    l1 = [0] * 13
    l1[0] = 1
    for i in range(1, n + 1):
        l2 = [0] * 13
        for j in range(10):
            x = w[i - 1] * j % 13
            for k in range(13):
                t = (x + k) % 13
                l2[t] += l1[k]
        l1 = [y % MOD for y in l2]
    
    ans = l1[m]
    print(ans)


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

import numpy as np
n = int(input())
A = np.array([int(input()) for i in range(n)])
for i in range(n):
  m = A.max()
  if A[i] == m:
    print(np.delete(A, i).max())
  else:
    print(m)

### FIXED CODE ###

import numpy as np
n = int(input())
A = np.array([int(input()) for i in range(n)])
idxs = np.argsort(A)
m1 = A[idxs[-1]]
m2 = A[idxs[-2]]
for i in range(n):
  if i != idxs[-1]:
    print(m1)
  else:
    print(m2)
### BUGGY CODE ###

class Combination:
    '''mod上の
    計算量：階乗・逆元テーブルの作成O(N)
    nCkを求めるO(1)'''
 
    def __init__(self, n, mod):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % mod)
        self.inv_fact = [pow(self.fact[i], mod - 2, mod) for i in range(n + 1)]
        self.mod = mod
 
    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]
 
    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]
 
    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[r]) % self.mod
 
    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.mod

    def combination_large(self, k, r):
        """kCrを求める O(r) kが大きいが、r <= nを満たしているときに使用"""
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.mod
        return (res * self.inv_fact[r]) % self.mod

x, y = map(int, input().split())
mod = 10**9 + 7
comb = Combination(10**6,mod)

if (x+y)%3 != 0:
    print(0)
    exit(0)
i = (2*x-y)//3
j = (2*y-x)//3
print(comb.combination(i+j, i))


### FIXED CODE ###

# ABC145 D Knight
def factorial_mod(n, mod):
    a = 1
    for i in range(1, n + 1):
        a *= i
        a %= mod
    return a

def comb_mod(n, k, mod):
    if k > n or k < 0:
        return 0
    fact_n = factorial_mod(n, mod)
    fact_k = factorial_mod(k, mod)
    fact_n_k = factorial_mod(n - k, mod)
    return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod

x, y = map(int, input().split())
MOD = 10**9 + 7
if (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
    print(0)
    exit()
i = (2 * x - y) // 3
j = (2 * y - x) // 3
print(comb_mod(i + j, i, MOD))
### BUGGY CODE ###

import itertools

x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list(int(i) for i in input().split())
#a.sort(reverse=True)
b=list(int(i) for i in input().split())
#b.sort(reverse=True)
c=list(int(i) for i in input().split())
#c.sort(reverse=True)
#print(a,b,c)

#a=[int(i) for i in range(1000,-1,-1)]
#b=[int(i) for i in range(1000,-1,-1)]
#c=[int(i) for i in range(1000,-1,-1)]
x=list(itertools.product(a,b))
for i in range(len(x)):
  x[i]=x[i][0]+x[i][1]
x.sort(reverse=True)
y=[]
length=min(len(x),1600)
for i in range(length):
  y+=[x[i]]
#print(len(y))
y=list(itertools.product(y,c))
#print(y)
for i in range(len(y)):
  y[i]=y[i][0]+y[i][1]
y.sort(reverse=True)

for i in range(k):
  print(y[i])


### FIXED CODE ###

#import itertools

x,y,z,k=(int(i) for i in input().split())
#print(x,y,z,k)
a=list(int(i) for i in input().split())
a.sort(reverse=True)
b=list(int(i) for i in input().split())
b.sort(reverse=True)
c=list(int(i) for i in input().split())
c.sort(reverse=True)
#print(a,b,c)

#k=3000
#a=[int(i) for i in range(1000)]
#b=[int(i) for i in range(1000)]
#c=[int(i) for i in range(1000)]
x=[]
for h in range(len(a)):
    for i in range(len(b)):
        if (h+1)*(i+1) <=k:
            for j in range(len(c)):
                if (h+1)*(i+1)*(j+1) <=k:
                    x.append(a[h]+b[i]+c[j])

x.sort(reverse=True)
for i in range(k):
  print(x[i])
### BUGGY CODE ###

N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

def calc(A, B, N):
    M = N
    if len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 1:
        i = [i for i, (a, b) in enumerate(zip(A, B)) if a < b][0]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            if D < 0:
                continue

            D += k * B[i]
            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 2:
        i, j = [i for i, (a, b) in enumerate(zip(A, B)) if a < b]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            l, D = divmod(D, A[j])

            D += k * B[i]
            D += l * B[j]

            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 3:
        for g in range(N // A[0] + 1):
            for s in range(N // A[1] + 1):
                D = N - g * A[0] - s * A[1]

                if D < 0:
                    break

                q, r = divmod(D, A[2])

                D += g * B[0]
                D += s * B[1]

                r += g * B[0]
                r += s * B[1]
                r += q * B[2]

                M = max(M, D, r)
    return M

print(calc(B, A, calc(A, B, N)))


### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

def calc(A, B, N):
    M = N
    if len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 1:
        i = [i for i, (a, b) in enumerate(zip(A, B)) if a < b][0]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            if D < 0:
                continue

            D += k * B[i]
            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 2:
        i, j = [i for i, (a, b) in enumerate(zip(A, B)) if a < b]

        for k in range(N // A[i] + 1):
            D = N - k * A[i]
            l, D = divmod(D, A[j])

            D += k * B[i]
            D += l * B[j]

            M = max(M, D)
    elif len([i for i, (a, b) in enumerate(zip(A, B)) if a < b]) == 3:
        for g in range(N // A[0] + 1):
            for s in range(N // A[1] + 1):
                D = N - g * A[0] - s * A[1]

                if D < 0:
                    break

                q, r = divmod(D, A[2])

                D += g * B[0]
                D += s * B[1]

                r += g * B[0]
                r += s * B[1]
                r += q * B[2]

                M = max(M, D, r)
    return M

print(calc(B, A, calc(A, B, N)))
### BUGGY CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
l = []
for i in range(m):
    b, c = map(int, input().split())
    l.extend([c]*b)
l.sort(reverse=True)
ret = 0
for i in range(n):
    if l and l[0] > a[0]:
        ret += l.pop(0)
    else:
        ret += a.pop(0)
print(ret)

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
l = [list(map(int, input().split())) for i in range(m)]
l.sort(key=lambda x: x[1], reverse=True)

res = 0
pos_1 = 0
pos_2 = 0
for _ in range(n):
    if pos_2 == m or a[pos_1] > l[pos_2][1]:
        res += a[pos_1]
        pos_1 += 1
    else:
        res += l[pos_2][1]
        l[pos_2][0] -= 1
        if l[pos_2][0] == 0:
            pos_2 += 1
 
print(res)

# d = []
# while l and len(d) <= n:
#     bc = l.pop(0)
#     d.extend([bc[1]]*bc[0])
# ret = 0
# for i in range(n):
#     if d and d[0] > a[0]:
#         ret += d.pop(0)
#     else:
#         ret += a.pop(0)
# print(ret)
### BUGGY CODE ###

import numpy as np
import math 
N, K=map(int,input().split())
A = np.zeros(N)
A = list(map(int,input().split()))
A = list(map(lambda x: x -1 , A))
current_town = 0

K2 = K % math.factorial(N)

for i in range(K2):
    current_town = A[current_town]

print(current_town+1)


### FIXED CODE ###

import numpy as np
n, k=map(int,input().split())

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

 
s = list()
ord = np.full(n+1, -1)
c=1
l=0

v=1
while ord[v]==-1:
    ord[v]=len(s)
    s.append(v)
    v=a[v-1]
c=len(s)-ord[v]
l=ord[v]

if k<l:
    print(s[k])  
else:
    k-=l
    k%=c
    print(s[l+k])
### BUGGY CODE ###

S = input()
T = input()

count = len(T)

for i in range(len(T)):
    for j in range(len(S)):
        if T[i] == S[j]:
            start = j - i
            end = j + (len(T) - i)
            if start < 0 or end > len(S):
                continue
            else:
                s = S[start:end]
                c = 0
                for k in range(len(T)):
                    if T[k] != s[k]:
                        c += 1
                count = min(count, c)
print(count)


### FIXED CODE ###

n_gram = lambda t, n: [t[i:i+n] for i in range(len(t) - n + 1)]

S = input()
T = input()

t_len = len(T)
count = t_len

s_list = n_gram(S, t_len)

for s in s_list:
    c = 0
    for i in range(len(s)):
        if s[i] != T[i]:
            c += 1
    count = min(count, c)

print(count)
### BUGGY CODE ###

import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(map(int, input().split()))
mod=1000000007

#+++++

def main():
	n = int(input())
	nn = [[min(i+1,j+1,n-i,n-j) for j in range(n)] for i in range(n)]
	is_sit = [[True] * n for _ in range(n)]
	cc = [[0]*n for _ in range(n)]
	
	#b , c = tin()
	pl = lin()
	ans = 0
	for i, p in enumerate(pl):
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]-1
		is_sit[x][y] = False
		nn[x][y]-=1
		q = [(x, y, nn[x][y])]
		while q:
			(x, y, v) = q.pop()
			for dx,dy in ([-1,0], [0,-1], [1,0], [0,1]):
				if x+dx < 0 or x +dx >= n or y + dy < 0 or y + dy >= n:
					continue
				iss = 1 if is_sit[x+dx][y+dy] else 0
				if nn[x+dx][y + dy] <= v + iss:
					continue
				nn[x+dx][y+dy] = v + iss
				q.append((x+dx, y+dy, v+is_sit[x+dx][y+dy]))
		
	print(ans)
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)


### FIXED CODE ###

import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

#+++++

def main():
	n = int(input())
	nn = [[min(i,j,n-i-1,n-j-1) for j in range(n)] for i in range(n)]
	is_sit = [[True] * n for _ in range(n)]
	cc = [[0]*n for _ in range(n)]
	
	#b , c = tin()
	pl = list(map(int, input().split()))
	ans = 0
	for p in pl:
		x, y = (p-1) // n, (p-1) % n
		ans += nn[x][y]
		is_sit[x][y] = False
		q = [(x, y, nn[x][y])]
		while q:
			(x, y, v) = q.pop()
			if x >= 0 and nn[x-1][y]>v:
				nn[x-1][y] = v
				q.append((x-1, y, v+is_sit[x-1][y]))
			if x < n-1 and nn[x+1][y]>v:
				nn[x+1][y] = v
				q.append((x+1, y, v+is_sit[x+1][y]))		
			if y >= 0 and nn[x][y-1]>v:
				nn[x][y-1] = v
				q.append((x, y-1, v+is_sit[x][y-1]))
			if y < n-1 and nn[x][y+1]>v:
				nn[x][y+1] = v
				q.append((x, y+1, v+is_sit[x][y+1]))	
		
	print(ans)
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

n,m=map(int, input().split())
a=[int(input())  for i in  range(m)]
x=(10**9)+7

dp=[0]*(n+1)
dp[0]=1
if 1 not in a:
  dp[1]=1

for i in range(2,n+1):
  if i in a:
    if i+1 in a:
      print(0)
      exit()
    dp[i]=0
    continue
    
  if i-1 not in a:
    dp[i]+=dp[i-1]
  if i-2 not in a:
    dp[i]+=dp[i-2]
  
print(dp[-1]%x)

### FIXED CODE ###

n,m=map(int, input().split())
a=set(int(input())  for i in  range(m))
x=(10**9)+7

dp=[0]*(n+1)
dp[0]=1
if 1 not in a:
  dp[1]=1

for i in range(2,n+1):
  if i in a:
    continue
  dp[i]+=dp[i-1]+dp[i-2]
  #print(dp)
  
print(dp[-1]%x)
### BUGGY CODE ###

def main():
    N, Q = map(int, input().split())

    graph = dict()
    for i in range(N-1):
        a, b = map(int, input().split())
        if a not in graph: graph[a] = [b]
        else: graph[a].append(b)
        # if b not in graph: graph[b] = [a]
        # else: graph[b].append(a)

    ops = dict()
    for i in range(Q):
        p, x = map(int, input().split())
        if p not in ops: ops[p] = x
        else: ops[p] += x

    # print(graph)
    # print(ops)
    vals = [0 for _ in range(N)]
    v = 0
    if 1 in ops: v = ops[1]
    cur = [[1, v]]

    visited = set([1])
    while cur:
        temp = []
        for a, v in cur:
            vals[a-1] += v
            if a in graph:
                for b in graph[a]:
                    if b not in visited:
                        if b in ops:
                            temp.append([b, v+ops[b]])
                        else:
                            temp.append([b, v])
                        visited.add(b)
        cur = temp

    print(' '.join(map(str, vals)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections

def main():
    N, Q = map(int, input().split())

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

    ops = collections.defaultdict(int)
    for i in range(Q):
        p, x = map(int, input().split())
        ops[p] += x

    vals = [0 for _ in range(N)]
    v = 0
    if 1 in ops: v = ops[1]
    cur = [[1, v]]

    while cur:
        temp = []
        for a, v in cur:
            vals[a-1] += v
            for b in graph[a]:
                temp.append([b, v+ops[b]])
        cur = temp

    print(' '.join(map(str, vals)))

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

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


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


candidate = {}
for i in range(N):
    if i == 0:
        candidate1 = make_divisors(A[i])
        for c in candidate1:
            candidate[c] = {
                'atari': 1,
                'hazure': 0,
            }
    elif i == 1:
        candidate2 = make_divisors(A[i])
        for c in candidate:
            if c not in candidate2:
                candidate[c]['hazure'] += 1
        for c in candidate2:
            if c not in candidate:
                candidate[c] = {
                    'atari': 1,
                    'hazure': 1
                }
            else:
                candidate[c]['atari'] += 1
    else:
        delete_key = []
        for c in candidate.keys():
            if A[i] % c == 0:
                candidate[c]['atari'] += 1
            else:
                if candidate[c]['hazure'] > 0:
                    delete_key.append(c)
                else:
                    candidate[c]['hazure'] += 1
        for d in delete_key:
            del candidate[d]
print(max(candidate.keys()))

### FIXED CODE ###

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

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

candidate1 = []
candidate = {}
for i in range(N):
    if i > 1:
        delete_key = []
        for c in candidate.keys():
            if A[i] % c == 0:
                candidate[c]['atari'] += 1
            else:
                candidate[c]['hazure'] += 1        
    elif i == 0:
        candidate1 = make_divisors(A[i])
    elif i == 1:
        candidate2 = make_divisors(A[i])
        prev = -1
        for c in sorted(candidate1 + candidate2):
            if c != prev and prev != -1 and candidate[prev]['atari'] < 2:
                candidate[prev]['hazure'] += 1
            if c not in candidate:
                candidate[c] = {
                    'atari': 1,
                    'hazure': 0
                }
            else:
                candidate[c]['atari'] += 1
            prev = c
        if candidate[prev]['atari'] < 2:
            candidate[prev]['hazure'] += 1            
max = 0
for c in candidate:
    if candidate[c]['hazure'] < 2 and max < c:
        max = c
print(max)
### BUGGY CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))

def expect_val(x):
    return (1 / x) * ((x * (x + 1)) / 2)


ans = []
curr_max = 0
for i in range(N - 1, K - 2, -1):
    curr_vals = p[i - K + 1:i + 1]
    if sum(curr_vals) >= curr_max:
        curr_max = sum(curr_vals)
        ans = curr_vals

print("{}".format(sum(list(map((lambda x: expect_val(x)), ans)))))

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))

E = [(1 + p) / 2 for p in p]
curr_sum = sum(E[:K])
curr_max = curr_sum

for i in range(N - K):
    curr_sum += (E[i + K] - E[i])
    curr_max = max(curr_max, curr_sum)

print(curr_max)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
c = 0
for i in a:
    c ^= i

c = format(c,'b').zfill(30)[::-1]

buf = []
for i in a:
    s = format(i,'b')[::-1]
    ans = list(c)
    for j in range(len(s)):
        x = (int(ans[j])+int(s[j]))%2
        ans[j] = str(x)
    x = ''.join(ans)
    buf.append(int(x[::-1],2))
print(*buf)



### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
c = 0
for i in a:
    c ^= i

buf = []
for i in a:
    buf.append(c^i)
    
print(*buf)